akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<char,char> pcc;
typedef pair<char,int> pci;
typedef vector<pair<int,int>> vpii;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
#define sci(a) scanf("%d",&a)
#define scii(a,b) scanf("%d %d",&a,&b)
#define sciii(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define sciiii(a,b,c,d) scanf("%d%d%d%d",&a,&b,&c,&d)
#define scl(a) scanf("%lld",&a)
#define scll(a,b) scanf("%lld %lld",&a,&b)
#define sclll(a,b,c) scanf("%lld %lld %lld",&a,&b,&c
#define scllll(a,b,c,d) scanf("%lld %lld %lld %lld",&a,&b,&c,&d)
#define print(a) printf("%d ",a)
#define println(a) printf("%d\n",a)
#define ln printf("\n")
#define pb(a) push_back(a)
#define m_p(a,b) make_pair(a,b)
#define all(a) a.begin(),a.end()
#define rep(i,s,n) for(int i=s;i<=n;i++)
#define rrep(i,e,s) for(int i=e;i>=s;i--)
#define repv(i,m) for(auto i = m.begin();i != m.end();i++)
#define FileIO freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
const long long INF = 4000000000000000000LL;
/************************************* Chocolate *************************************/
const int MAX = 2e4;
class Block{
public:
    int w,s,v;
    Block(int a,int b,int c){
        w = a;
        s = b;
        v = c;
    }
};
bool com(Block a,Block b){
    return a.s + a.w < b.s + b.w;
}
int main(){
    int n;
    sci(n);
    vector<Block> in;
    rep(i,1,n){
        int w,s,v;
        sciii(w,s,v);
        in.pb(Block(w,s,v));
    }
    vll dp(MAX+1,0);
    sort(all(in),com);
    for(Block block:in){
        for(int w = min(block.s+block.w,MAX);w>=block.w;--w){
            dp[w] = max(dp[w],dp[w-block.w] + block.v);
        }
    }
    ll ans = 0;
    for(ll i:dp)
        ans = max(ans,i);
    cout << ans << endl;
}


Measured memory_bytes: 3712
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>

using namespace std;
typedef pair<int, int> P;

int main(int argc, char const* argv[])
{
	int n;
	cin >> n;
	vector<P> vec;
	for(int i = 0; i < n; i++){
			int a, b;
			cin >> a >> b;
			vec.push_back(make_pair(a, b));
	}
	vector<P> b;
	for(int i = 0; i < n; i++){
			int c, d;
			cin >> c >> d;
			b.push_back(make_pair(c, d));
	}
	sort(b.begin(), b.end());
	int res = 0;
	for(int i = 0; i < n; i++){
			int maxy = -1;
			auto thisitr = vec.begin();
			for(auto itr = vec.begin(); itr != vec.end(); ++itr){
					if(b[i].first > (*itr).first && b[i].second > (*itr).second && (*itr).second > maxy){
							maxy = (*itr).second;
							thisitr = itr;
					}
			}
			if(maxy != -1){
					vec.erase(thisitr);
					res++;
			}
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <ctime>
#include <cassert>
#include <unordered_map>
#include <fstream>
#include <random>
#include <cstring>
#include <bitset>
#include <functional>
#include <tuple>
#include <complex>
#include <chrono>
#include <climits>

#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()
#define pb push_back

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef unsigned int uint;
typedef unsigned long long ull;

mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
default_random_engine generator;
// mt19937 rnd(1);

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);      

    int n;
    cin >> n;

    vector<int> a(n), b(n);

    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }

    ll cnt = 0;

    for (int j = 0; j < n; ++j) {
        cin >> b[j];
    }

    set<pii> setik;

    for (int i = 0; i < n; ++i) {
        if (a[i] != b[i]) {
            setik.insert({b[i], i});
        }
        if (a[i] > b[i]) {
            cout << -1 << endl;
            return 0;
        }
    }

    while (!setik.empty()) {
        auto it = --setik.end();
        pii p = *it;
        int i = p.second;

        setik.erase(it);
        int x = (b[(i + 1) % n] + b[(i + n - 1) % n]);
        int k = (b[i] - a[i]) / x;
        if (k == 0) {
            cout << -1 << endl;
            return 0;
        }
        b[i] -= k * x;
        cnt += k;
        if (a[i] != b[i]) {
            setik.insert({b[i], i});
        }
    }

    cout << cnt << endl;


}


Measured memory_bytes: 13312
import sys

# N: コマ数
# M: 地点数

N,M,*X = map(int, open(0).read().split())

# コマ数が地点数以上の場合、各地点にコマを配置できる
# よって 0 回の移動で目的を達成できる
if N >= M:
    print(0)
    sys.exit()

X.sort()
ans = []
for i in range(M-1):
    ans.append(abs(X[i+1] - X[i]))

ans.sort(reverse=True)
print(X[-1] - X[0] - sum(ans[:N-1]))

Measured memory_bytes: 20064
#include<bits/stdc++.h>
using namespace std;

int main(){
  int n;
  cin>>n;
  vector<int>a(n);
  for(int i=0;i<n;i++){
    cin>>a.at(i);
  }
  long int total=0;
  for(int i=0;i<n;i++){
    for(int k=i+1;k<n;k++){
      total+=a.at(i)*a.at(k);
    }
  }
  cout<<total<<endl;
}

    
      
      

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;

#define repr(i,a,b) for (int i=a; i<b; i++)
#define rep(i,n) for (int i=0; i<  n; i++)
 
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
 
const long long INF = 1LL << 60;
#define PI 3.14159265359 
bool dp[100100];
 
int main () {
    int X, Y;
    cin >> X >> Y;

    rep(i,101){
        rep(j,101){
            if(i+j == X && (2*i) + (4*j) == Y){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;

 
}

Measured memory_bytes: 3636
X=int(input())
if 400<=X<=599:
  print(8)
elif 600<=X<=799:
  print(7)
elif 800<=X<=999:
  print(6)
elif 1000<=X<=1199:
  print(5)
elif 1200<=X<=1399:
  print(4)
elif 1400<=X<=1599:
  print(3)
elif 1600<=X<=1799:
  print(2)
else:
  print(1)

Measured memory_bytes: 9184
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
using namespace std;
typedef long long ll;
ll MOD = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)
int main() {
    int n;
    cin >> n;
    vector<ll> a(n+1);
    vector<ll> b(n);
    rep(i, n+1) cin >> a[i];
    rep(i, n) cin >> b[i];
    ll ans = 0;
    rep(i, n) {
        if ( a[i] > b[i] ) {
            ans += b[i];
            a[i] -= b[i];
        }
        else if ( a[i] + a[i+1] > b[i] ) {
            ans += a[i] + ( b[i] - a[i] );
            a[i+1] -= b[i] - a[i];
            a[i] = 0;
        }
        else if ( a[i] + a[i+1] <= b[i] ) {
            ans += a[i] + a[i+1];
            a[i] = 0;
            a[i+1] = 0;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1792
#include <cstdio>
#include <vector>
#include <cstring>
#define pb push_back
#define catans(x) for(int i=1;i<=kn[x];++i)k[++pt]=(i-1)*3+x
using namespace std;vector<int> c[2];int id[200001],ans[200001],k[200001],n,pt,kn[4];
struct edge{int v,next;edge(){}edge(int _v,int _next){v=_v;next=_next;}}e[400001];int head[200001],sz;
void init(){memset(head,-1,sizeof(head));sz=0;}void insert(int u,int v){e[++sz]=edge(v,head[u]);head[u]=sz;}
void dfs(int u,int f,int d){c[d].pb(u);for(int i=head[u];~i;i=e[i].next)if(e[i].v!=f)dfs(e[i].v,u,d^1);}
int main()
{
	scanf("%d",&n);init();for(int i=1;i<n;++i){int u,v;scanf("%d%d",&u,&v);insert(u,v);insert(v,u);}
	dfs(1,0,0);if(c[0].size()>c[1].size())swap(c[0],c[1]);kn[3]=n/3;kn[1]=(n+2)/3;kn[2]=(n+1)/3;
	for(int i=1;i<=c[0].size();++i)id[i]=c[0][i-1];for(int i=1;i<=c[1].size();++i)id[i+c[0].size()]=c[1][i-1];
	if(n/3>=c[0].size()){catans(3);catans(1);catans(2);}else{catans(1);catans(3);catans(2);}
	for(int i=1;i<=n;++i)ans[id[i]]=k[i];for(int i=1;i<=n;++i)printf("%d ",ans[i]);putchar(10);return 0;
}

Measured memory_bytes: 15348
from collections import defaultdict

def main():
    N = int(input())
    A = list(map(int, input().split()))
    d = defaultdict(int)
    for a in A:
        d[a] += 1

    ans = 0
    for i, j in d.items():
        ans += j * (j - 1) // 2

    for a in A:
        tmp = ans - (d[a] * (d[a] - 1) // 2)
        tmp += ((d[a] - 1) * (d[a] - 2) // 2)
        print(tmp)



if __name__ == "__main__":
    main()

Measured memory_bytes: 87884
#include <bits/stdc++.h>
using namespace std ;
typedef long long ll;

int main(){
    int n;cin>>n;
    int a[n+1];
    a[0]=0;
    vector<int> v;
    for(int i=1;i<=n;i++)cin>>a[i];
    int b[n+1];
    for(int i=0;i<=n;i++)b[i]=0;

    for(int i=n;i>=1;i--){
        int mol=n/i;
        int sum=0;
        for(int j=1;j<=mol;j++){
            sum+=b[j*i];
        }
        if(sum%2!=a[i]){b[i]=1;v.push_back(i);}
    }
    cout << v.size() <<endl;
    for(int i=0;i<v.size();i++)cout << v[i]<<endl;


    
}

Measured memory_bytes: 5248
#include <bits/stdc++.h>
#include <algorithm>
#include <math.h>
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
#define INF 999999999
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

using llong = long long;
using namespace std;


int main(){
    double r;
    cin >> r;
    cout << 6.2831853*r << endl;
}


Measured memory_bytes: 3784
#include<cstdio>
#define fo(i, x, y) for(int i = x; i <= y; i ++)
using namespace std;

const int N = 1 << 18;

int n, a[N], a2[20];

int s[N][2], b[N];


int va(int x) {return x == -1 ? -1e9 : a[x];}

void gen(int *x, int y) {
	if(va(y) > va(x[0])) x[1] = x[0], x[0] = y; else
	if(va(y) > va(x[1]) && y != x[0]) x[1] = y;
}

void fen(int *x, int *z) {
	fo(j, 0, 1)	{
		int y = z[j];
		if(va(y)> va(x[0])) x[1] = x[0], x[0] = y; else
		if(va(y) > va(x[1]) && y != x[0]) x[1] = y;
	}
}

int main() {
	a2[0] = 1; fo(i, 1, 18) a2[i] = a2[i - 1] * 2;
	scanf("%d", &n);
	fo(i, 0, a2[n] - 1) scanf("%d", &a[i]);
	fo(i, 0, a2[n] - 1) s[i][0] = s[i][1] = -1;
	fo(i, 0, a2[n] - 1) {
		gen(s[i], i);
		fo(j, 0, n - 1) if(!(i & a2[j])) {	
			fen(s[i | a2[j]], s[i]);
		}
	}
	fo(i, 0, a2[n] - 1) {
		b[i] = va(s[i][0]) + va(s[i][1]);
		if(i > 0) b[i] = b[i - 1] > b[i] ? b[i - 1] : b[i];
	}
	fo(i, 1, a2[n] - 1) printf("%d\n", b[i]);
}

Measured memory_bytes: 7040
#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>
#include <algorithm>
#include <queue>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(x) (x).begin(), (x).end()

int main() {
    long long n,m,t,ans=0,rem,j;
    //int j;
    cin>>n>>m>>t;
    vector<long long>a(n),b(m),ta(n+1),tb(m+1);
    //ta,tb: i冊読むのにかかる時間
    rep(i,n)cin>>a[i];
    rep(i,m)cin>>b[i];
    rep(i,n)ta[i+1]=ta[i]+a[i];
    rep(i,m)tb[i+1]=tb[i]+b[i];
    rep(i,n+1){//aから固定
        rem=t-ta[i];
        if(rem>=0){
            j=(upper_bound(all(tb),rem)-tb.begin())-1;//i+j冊
        
            ans=max(ans,i+j);
        }
    }
    cout<<ans;
	return 0;
}


Measured memory_bytes: 9596
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main()
{
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    int k_need = 0;
    while(a>=b){
        k_need++;
        b*=2;
    }
    while(b>=c){
        k_need++;
        c*=2;
    }
    if(k>=k_need)cout << "Yes";
    else cout << "No";
    return 0;
}


Measured memory_bytes: 3640
//
//  ROIGold.cpp
//  Main calisma
//
//  Created by Rakhman on 05/02/2019.
//  Copyright © 2019 Rakhman. All rights reserved.
//
 
#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cassert>
#include <iterator>
 
#define ios ios_base::sync_with_stdio(0), cout.tie(0), cin.tie(0);
#define S second
#define F first
#define pb push_back
#define nl '\n'
#define NL cout << '\n';
#define EX exit(0)
#define all(s) s.begin(), s.end()
#define no_answer return cout << 0, 0;
#define FOR(i, start, finish, k) for(llong i = start; i <= finish; i += k)
 
const long long MXN = 136 + 200;
const long long MNN = 1e4 + 520;
const long long MOD = 1e9 + 7;
const long long INF = 1e18;
const long long OO = 1e9 + 500;
 
typedef long long llong;
typedef unsigned long long ullong;
 
using namespace std;

string k;
llong d;

int main () {
    ios;
    cin >> k >> d;
    vector<vector<llong> > dp(d, vector<llong> (2, 0));
    dp[0][0] = 1;
    for(int i = 0; i < k.size(); i++){
        vector<vector<llong> > new_dp(d, vector<llong> (2, 0));
        for(int sum = 0; sum < d; sum++){
            for(int lol = 0; lol <= 1; lol++){
                for(int j = 0; j < 10; j++){
                    if(j > k[i] - '0' && lol == 0){
                        break;
                    }
                    new_dp[(sum + j) % d][lol || (j < k[i] - '0')] = (new_dp[(sum + j) % d][lol || (j < k[i] - '0')] + dp[sum][lol]) % MOD;
                }
            }
        }
        dp = new_dp;
    }
    llong ans = dp[0][0] + dp[0][1];
    cout << (ans + MOD - 1) % MOD;
}


Measured memory_bytes: 384
import sys

def main():
    input = sys.stdin.readline
    S = str(input().strip())

    for i, s in enumerate(S, start=1):
        if i%2 == 1:
            if s not in ('R', 'U', 'D'):
                return 'No'
        else:
            if s not in ('L', 'U', 'D'):
                return 'No'

    return 'Yes'


if __name__ == '__main__':
    print(main())


Measured memory_bytes: 2940
#include <iostream>
#include <cmath>
#include <algorithm>

using namespace std;

#define ll long long

int N, L[15];

void solve(){
    int max_l = L[0];

    int sum = 0;
    for(int i = 1; i < N; i++) sum += L[i];

    if(max_l < sum) cout << "Yes" << endl;
    else cout << "No" << endl;
}

int main(){
    cin >> N;
    for(int i = 0; i < N; i++)  cin >> L[i];
    sort(L, L+N);
    reverse(L, L+N);

    solve();
}


Measured memory_bytes: 256
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int sidx = s.length(), gidx = 0;
		for(int i = 0; i < s.length(); i++) { 
			if(s.charAt(i) == 'A') {
				sidx = i;
				break;
			}
		}
		for(int i = s.length() - 1; i >= 0; i--) { 
			if(s.charAt(i) == 'Z') {
				gidx = i;
				break;
			}
		}
		System.out.println(gidx - sidx + 1);
	}
}


Measured memory_bytes: 26544
# -*- coding: utf-8 -*-

int(input())  # Skip
lst = list(map(int, input().split()))

lst_length = len(lst)
idx = max_distance = 0

while True:
    distance = 0
    current_height = lst[idx]
    for i in range(idx + 1, lst_length):
        idx = i
        if current_height >= lst[idx]:
            current_height = lst[idx]
            distance += 1
        else:
            break

        if max_distance < distance:
            max_distance = distance

    if idx == (lst_length - 1):
        if max_distance < distance:
            max_distance = distance
        break

print(max_distance)


Measured memory_bytes: 14224
import java.io.*;
import java.util.*;

public class Main{
    static MyReader in = new MyReader();
    static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args){
        int N = in.i();
        int[] A = in.ii();
        int[] count = new int[N+1];
        HashSet<Integer> idx = new HashSet<>(N);
        for (int i = 0; i < N; i++) {
            count[A[i]]++;
            idx.add(A[i]);
        }
        long sum = 0;
        for (int i : idx) {
            sum += (long)count[i] * (count[i] - 1) / 2;
        }
        for (int i = 0; i < N; i++) {
            out.println(sum - count[A[i]] + 1);
        }
        out.flush();
    }

    static class MyReader extends BufferedReader{
        MyReader(){
            super(new InputStreamReader(System.in));
        }

        String s(){
            try{return readLine();}catch(IOException e){return "";}
        }

        String[] ss(){
            return s().split(" ");
        }

        int i(){
            return Integer.parseInt(s());
        }

        int[] ii(){
            String[] ss = ss();
            int[] ii = new int[ss.length];
            for(int j = 0; j < ss.length; j++) ii[j] = Integer.parseInt(ss[j]);
            return ii;
        }
    }
}


Measured memory_bytes: 55060
#include <iostream>
using namespace std;
int main(void){
    
    while(true){
        int m, f, r;
        cin >> m >> f >> r;
        if(m + f + r == -3) break;
        
        if(m == -1 || f == -1) cout << "F" << endl;
        else if(m + f >= 80) cout << "A" << endl;
        else if(m + f >= 65) cout << "B" << endl;
        else if(m + f >= 50) cout << "C" << endl;
        else if(m + f >= 30){
            if(r >= 50) cout << "C" << endl;
            else cout << "D" << endl;
        }
        else cout << "F" << endl;
    }
    
}



Measured memory_bytes: 3112
#include <iostream>
#include <algorithm>
#include <stack>
#include <cstdio>
#include <deque>

using namespace std;

int main(){
    int n,k;
    scanf("%d",&n);
    int mi = 100000;
    int mx = -1;
    for (int i = 0;i<n;i++){
        cin>>k;
        if (mi>k){
            mi = k;
        }
        if (mx<k){
            mx = k;
        }
    }
    cout<<mx-mi<<endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
    final static long mod = 1000000007;
    //
    public static void main(String[] args){
        Scanner sc= new Scanner(System.in);
    double a = sc.nextDouble();
    double b = sc.nextDouble();
    double c = sc.nextDouble();
    double d = b - c / a / a;
    if(2 * d <= b){
        double ans = Math.atan(2 * d / a) / Math.PI * 180;
        System.out.println(ans);
    }else{
        double ans = 90 - Math.atan((c / (a * a * b / 2) * a) / b) / Math.PI * 180; 
        System.out.println(ans);
    }
    }
    
}



Measured memory_bytes: 23764
#include <bits/stdc++.h>
#define rep(x, y) for(int x = 0; x < (y); x++)
#define REP(x, z, y) for(int x = (z); x < (y); x++)
#define all(x) x.begin(), x.end()
#define len(x) (sizeof(x) / sizeof(x[0]))
#define split_str(str, sp_word) istringstream stream(str); string res; for(int cnt = 0; getline(stream,res,sp_word); cnt++)
#define scanln(x) fgets(x, sizeof x, stdin)
#define down_queue(x) priority_queue<x>
#define up_queue(x) priority_queue<x, vector<x>, greater<x>>
#define i_str(x) atoi(x.c_str())
#define digit(x) ((int)log10((double)(x)) + 1)
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
using namespace std;
const int MOD = 1000000007; 
typedef long long ll;
typedef string str;
  
int main(){
  int N; cin >> N;

  int ans = 0;
  REP(i,1,N + 1)
    ans += i;

  cout << ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;

struct StCoin
{
  StCoin() :
    m_nCoin(0), m_nNum(0)
  { }
  StCoin(int nCoin, int nNum) :
    m_nCoin(nCoin), m_nNum(nNum)
  { }

  int m_nCoin;
  int m_nNum;
};

void fnInput(vector<StCoin>& rvoCoin, int& rnTrgKin)
{
  int nNum500, nNum100, nNum50;
  cin >> nNum500 >> nNum100 >> nNum50;

  int i = 0;
  StCoin oCoin500(500, nNum500);
  rvoCoin[i++] = oCoin500;
  StCoin oCoin100(100, nNum100);
  rvoCoin[i++] = oCoin100;
  StCoin oCoin50(50, nNum50);
  rvoCoin[i] = oCoin50;

  cin >> rnTrgKin;
}

int fnRcsSch(int nPos, int nTrgKin, const vector<StCoin>& cnrvoCoin, int& rnSuccess)
{
  if (!nTrgKin)
  {
    rnSuccess++;
    return 1;
  }
  if (nTrgKin < 0)              return 1;
  if (nPos == cnrvoCoin.size()) return 0;

  for (int i = 0; i <= cnrvoCoin[nPos].m_nNum; i++)
    if (fnRcsSch(nPos + 1, nTrgKin - cnrvoCoin[nPos].m_nCoin * i, cnrvoCoin, rnSuccess))
      break;

  return 0;
}

void fnExhSch(int nTrgKin, const vector<StCoin>& cnrvoCoin)
{
  int nSuccess = 0;
  fnRcsSch(0, nTrgKin, cnrvoCoin, nSuccess);
  cout << nSuccess << endl;
}

int main()
{
  vector<StCoin> voCoin(3);
  int nTrgKin;

  fnInput(voCoin, nTrgKin);
  fnExhSch(nTrgKin, voCoin);

  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
#include<functional>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

int main()
{
	int N,res=0;
	vector<int>FB,LA,FBLA;
	cin>>N;
	for(int i=0;i<N;i++)
	{
		string s;
		cin>>s;
		if(s[0]=='B'&&s[s.length()-1]=='A')FBLA.push_back(i);
		else if(s[0]=='B')FB.push_back(i);
		else if(s[s.length()-1]=='A')LA.push_back(i);
		for(int i=0;i<s.length()-1;i++)
		{
			if(s[i]=='A'&&s[i+1]=='B')res++;
		}
	}
	//BxxxxA
	int fbs=FB.size();
	int las=LA.size();
	if(FBLA.size()>0)
	{
		res+=FBLA.size()-1;
		if(fbs>0)
		{
			res++;
			fbs--;
		}
		if(las>0)
		{
			res++;
			las--;
		}
	}
	res+=min(fbs,las);
	cout<<res<<endl;
}

Measured memory_bytes: 384
n = input()
xs = map(int, raw_input().split())
m = 2000000000
for i in range(n):
    x = xs[i]
    c = 0
    while x % 2 == 0 and c < m:
        x = x / 2
        c += 1
    m = min(c, m)
print m


Measured memory_bytes: 2568
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstdlib>
#include<cstring>
#include<string>
using namespace std;

int main()
{
	string s;
	int k=0;
	cin>>s;
	int l=s.size();
	for(int i=0;i<l;i++)
	{
		if(s[i]=='9')
		{
			k=1;
		} 		
	}
	if(k==1)	cout<<"Yes"<<endl;
	else	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
// #include <priority_queue>
#include <algorithm>
#include <climits>
#include <cmath>

using namespace std;

int n, m;

int ans = 1;

int main() {

	cin >> n >> m;

	for (int i = 1; i*i <= m; ++i)
	{
		if (m % i == 0) {
			int j = m/i;

			if (j >= n)
				ans = max(ans, i);

			if (i >= n)
				ans = max(ans, j);
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
l,r = gets.chomp!.split(" ").map(&:to_i)
 
min = l % (2019 * 2)
max = r % (2019 * 2)

if min >= max
    puts 0
else
    ans = 9999999
    min.upto(max - 1) do |i|
        (i + 1).upto(max) do |j|
            x = (i * j) % 2019
            if x < ans
                ans = x
            end
        end
    end
 
    puts ans
end

Measured memory_bytes: 1788
//Bismillah hirrahmanir Rahim
        #include<bits/stdc++.h>
        #define ll long long
        #define pb push_back
        #define dbug printf("I am here\n");
        #define Fast ios_base::sync_with_stdio(false); cin.tie(0);
        const int m = 10e6;
        using namespace std;

        int main(){
     long long int a,b,tst,k;
     cin>>a;
     b=100;
   int cnt=0;
     while(a>b){
     b+=b/100;
     //cout<<b<<endl;
     cnt++;
     }
     cout<<cnt<<endl;
       return 0;
        }


Measured memory_bytes: 3548
#include <iostream>
#include <vector>

using namespace std;

int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  int ans{};
  for (int i = 0; i < N; i++) {
    cin >> a[i];
    if (a[a[i]-1]-1 == i) ++ans;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <vector>
#include <queue>
using namespace std;

int main(){
    long long N;
    cin >> N;
    long long n_max = (int)ceil(sqrt(N));
    long long x = 1;
    long long y = N;
    long long ans = (N-1);
    for(int i=1; i<=n_max; i++){
        if(N%i == 0){
            long long val = N/i;
            if(ans > (i-1)+(val-1)){
                ans = (i-1)+(val-1);
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3664
#include<iostream>
using namespace std;

int main(){
	int W,H,x,y,r;
	cin>>W>>H>>x>>y>>r;
	
	if(y-r<0||x-r<0){
		cout<<"No"<<endl;
	}else if(W<x+r||H<y+r){
		cout<<"No"<<endl;
	}else{
		cout<<"Yes"<<endl;
	}
	return 0;
}
		
	

Measured memory_bytes: 1156
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <climits>
#include <queue>
#include <string>
#include <cstdlib>

using namespace std;

const int N = 1e5 + 4;
int n, q;
long long Q[N], a[N];

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n >> q;
    if (q == 0) {
        for (int i = 1; i <= n; ++i) cout << 1 << '\n';
        return 0;
    }
    for (int i = 1; i <= q; ++i) cin >> Q[i];

    priority_queue< pair<long long, long long> > pq;
    long long v = Q[q], m = 1;
    for (int i = q-1; i >= 1; --i) {
//		cerr << "i = " << i << endl;
        if (Q[i] >= v) continue;

        pq.push({v % Q[i], m});
//        cerr << v % Q[i] << ' ' << m << endl;
        m *= v / Q[i];
        v = Q[i];

        long long curv = -1, curm = 0;
        while (!pq.empty() && pq.top().first > v) {
            curv = pq.top().first, curm = 0;
            while (!pq.empty() && pq.top().first == curv) {
                curm += pq.top().second;
                pq.pop();
            }
            m += curv / v * curm;
            pq.push({curv % v, curm});
//            cerr << curv % v << ' ' << curm << endl;
        }
//        cerr << "m = " << m << endl;
    }

    a[v%n] += m;
    a[n] += v/n*m;
//    cerr << v << ' ' << m << endl;
    while (!pq.empty()) {
        long long curv = pq.top().first, curm = pq.top().second;
//        cerr << curv << ' ' << curm << endl;
        a[curv%n] += curm;
        a[n] += curv/n*curm;
        pq.pop();
    }

//    for (int i=1;i<=n;++i) cout << a[i] << '\n'; cout << endl;
    for (int i=n-1; i>=1; --i) a[i] += a[i+1];
    for (int i=1;i<=n;++i) cout << a[i] << '\n';
}


Measured memory_bytes: 4976
// ARC093A.cpp
#include <bits/stdc++.h>

using namespace std;

const int MAX_N = 1e5 + 200;

int n, ai[MAX_N];

int main()
{
    scanf("%d", &n), n += 2;
    for (int i = 2; i <= n - 1; i++)
        scanf("%d", &ai[i]);
    int ans = 0;
    for (int i = 2; i <= n; i++)
        ans += abs(ai[i] - ai[i - 1]);
    for (int i = 2; i < n; i++)
    {
        ans -= abs(ai[i - 1] - ai[i]) + abs(ai[i + 1] - ai[i]) - abs(ai[i + 1] - ai[i - 1]);
        printf("%d\n", ans);
        ans += abs(ai[i - 1] - ai[i]) + abs(ai[i + 1] - ai[i]) - abs(ai[i + 1] - ai[i - 1]);
    }
    return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long int64;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long  INFL = 1e18;
const int MOD = 1000000007;
const int MAX = 210000;
const int MAX_NUM = 999999999;
void solve() {
	int H, W; cin >> H >> W;
	string a;
	vector<vector<string>> q(H, vector<string>(W));
	vector<vector<string>> p(H, vector<string>(W));
	vector<vector<string>> ans(H, vector<string>(W));
	int height = 0;
	bool flg = true;
	for (int i = 0; i < H; ++i) {
		cin >> a;
		for (int j = 0; j < a.size(); ++j) {
			q[i][j] = a[j];
		}
		int cnt = 0;
		for (int j = 0; j < a.size(); ++j) {
			if (a[j] == '.') cnt++;	
		}
		if (cnt != W) {
			for (int j = 0; j < a.size(); ++j) {
				p[height][j] = a[j];
			}
			height++;
		}
	}
	int max_height = height;
	int width = 0;
	for (int i = 0; i < W; ++i) {
		int cnt = 0;
		for (int j = 0; j < max_height; ++j) {
			if (p[j][i] == ".") cnt++;
		}
		if (cnt != max_height) {
			for (int j = 0; j < max_height; ++j) {
				ans[j][width] = p[j][i];
			}
			width++;
		}
	}
	int max_width = width;
	if (max_height == 0 && max_width == 0) flg = false;
	if (flg) {
		for (int i = 0; i < max_height; ++i) {
			for (int j = 0; j < max_width; ++j) {
				cout << ans[i][j];
			}
			cout << endl;
		}
	} else {
		for (int i = 0; i < H; ++i) {
			for (int j = 0; j < W; ++j) {
				cout << q[i][j];
			}
			cout << endl;
		}
	}
	return;
}
int main() {
	solve();
	return 0;
}

Measured memory_bytes: 4552
#include <stdio.h>
#include <string.h>
#include <vector>
using namespace std;
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define INF (1<<28)

int dp[2][1000001];

int main() {
    vector<int> a[2];
    for(int i=1;; i++) {
        const int k = i*(i+1)*(i+2)/6;
        if(k>1000000) break;
        if(k%2) a[0].push_back(k);
        else a[1].push_back(k);
    }
    rep(i, 1000001) dp[0][i] = INF;
    dp[0][0] = 0;
    rep(k, a[0].size()) rep(i, 1000001-a[0][k]) {
        dp[0][i+a[0][k]] = min(dp[0][i+a[0][k]], dp[0][i]+1);
    }
    memcpy(dp[1], dp[0], sizeof(dp[0]));
    rep(k, a[1].size()) rep(i, 1000001-a[1][k]) {
        dp[0][i+a[1][k]] = min(dp[0][i+a[1][k]], dp[0][i]+1);
    }
    for(;;) {
        int n;
        scanf("%d", &n);
        if(n==0) return 0;
        printf("%d %d\n", dp[0][n], dp[1][n]);
    }
}

Measured memory_bytes: 0
#! /usr/bin/env python3

import sys
import numpy as np
int1 = lambda x: int(x) - 1
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

c, *N = str(int(readline())+1)
print(int(c) + 9 *len(N)- 1)


Measured memory_bytes: 12504
#include <bits/stdc++.h>
using namespace std;

int main() {
  int A,B;
  string op;
  cin >> A >> op >> B;
  
  if(op == "+") {
    cout << A+B << endl;
  }
  else if(op == "-") {
    cout << A-B << endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N;cin>>N;
    int H[N];int temp=0,count=0;
    for(int i=0;i<N;i++){
        cin>>H[i];
        if(H[i]>=temp){
            count++;
            temp=H[i];
        }
    }cout<<count<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<queue>
#include<cmath>
#include<map>
#include<set>
using namespace std;
const int INF = 1 << 29;
const double EPS = 1e-9;

typedef long long ll;

#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)

int N,K;
int D[11];
int main(int argc, char * argv[])
{
    ios::sync_with_stdio(false);
    cin >> N >> K;
    rep(i,K) cin >> D[i];

    int p = N;
    int ret = -1;
    while (true){
        bool flag = true;
        rep(i,K){
            if (to_string(p).find(to_string(D[i])) != -1) {
                flag = false;
                break;
            }
        }
        if (flag) {
            ret = p;
            break;
        }
        p++;
    }
    cout << p << endl;
        



    return 0;
}



Measured memory_bytes: 256
import random
D = int(input())
c = list(map(int, input().split()))
s = [list(map(int, input().split())) for i in range(D)]
t = [0] * D
for i in range(D):
    r=((i+1)%26)+1
    t[i] = r
 
    
M=22*10*2*100
day=[random.randint(1,365) for i in range(M)]
q=[random.randint(1,26) for i in range(M)]
    
m=[0]*D
 
a=[[0 for i in range(26)] for j in range(D)]
for u in range(D):
    i=t[u]
    for y in range(u,D):
        a[y][i-1]=u+1
    if u==0:
        m[u]=s[u][i-1]
    else:
        m[u]=m[u-1]+s[u][i-1]
mm=[0]*D
for d  in range(D):
    for i in range(26):
        mm[d]+=c[i]*(d+1-a[d][i])
    if not d==0:
        mm[d]+=mm[d-1]
for d in range(D):
    m[d]-=mm[d]
mmm=m[D-1]
 
 
 
for p in range(M):
    new_type=q[p]
    old_type=t[day[p]-1]
    #print(new_type,old_type)
    A=0
    B=0
    C=0
    #C=s[day[p]-1][old_type-1]-s[day[p]-1][new_type-1]
    for d in range(D):
        A+=c[new_type-1]*(d+1-a[d][new_type-1])+c[old_type-1]*(d+1-a[d][old_type-1])
    xday=day[p]
    if xday>1:
        before_new=a[xday-2][new_type-1]
        before_old=a[xday-2][old_type-1]
        now_new=a[day[p]-1][new_type-1]
        now_old=a[day[p]-1][old_type-1]
        for d in range(day[p]-1,D):
            if a[d][new_type-1]==now_new:
                a[d][new_type-1]=xday
            if a[d][old_type-1]==now_old:
                a[d][old_type-1]=before_old
    else:
        for d in range(day[p]-1,D):
            if a[d][old_type-1]==1:
                a[d][old_type-1]=0
            if a[d][new_type-1]==0:
                a[d][new_type-1]=1   
    t[day[p]-1]=new_type
    for d in range(D):
        B+=c[new_type-1]*(d+1-a[d][new_type-1])+c[old_type-1]*(d+1-a[d][old_type-1])
    s=mmm-(B-A+C)
    if s>mmm:
        mmm=s
    #print(mmm)
for i in range(len(t)):
    print(t[i])

Measured memory_bytes: 82480
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <chrono>
#include <random>
#include <tuple>
#include <utility>
#include <fstream>
#include <complex>

const long INF = (1l << 30);
const long LINF = (1l << 60);

long n, a, b;
long ans = 0;
long x[100005];


int main(){
    scanf("%ld%ld%ld", &n, &a, &b);
    for(int i = 0; i < n; i++){
        scanf("%ld", &x[i]);
    }
    for(int i = 0; i < n-1; i++){
        ans += std::min((x[i+1] - x[i]) * a, b);
    }
    printf("%ld\n", ans);
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;

//#define int long long
#define ll long long
#define all(v) (v).begin(), (v).end()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main()
{   
    gearup;
    int k; cin >> k;
    int even = k/2;
    int odd = k - even;
    cout << even*odd << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 200010, M = 1000099;
int a[N];
int t[M];
int main() {
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d", a + i);
		t[a[i]] ++;
	}
	int mmax = *max_element(a, a + n);
	sort(a, a + n);
	int cnt = 0;
	for (int i = 0; i < n; i++) {
		int x = a[i];
		if (t[x] == 0)continue;
		for (int j = 2 * x; j < mmax + 10; j += x) {
			t[j] = 0;
		}
		if (t[x] == 1) cnt++;
	}
	printf("%d\n", cnt);
	return 0;
}

Measured memory_bytes: 8512
import math
import string
import collections
from collections import Counter


def readints():
    return list(map(int, input().split()))


def nCr(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor


# coordinates
dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]
n, t = map(int, input().split())
tt = readints()
cnt = t

for i in range(n-1):
    if tt[i+1]-tt[i] <= t:
        cnt += tt[i+1]-tt[i]
    else:
        cnt += t
print(cnt)


Measured memory_bytes: 87124
#include<bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

ll n, suma;
int main() {
    IOS; cin >> n;
    suma = n*(n+1)/2LL;
    suma -= 3*(n/3)*(n/3+1LL)/2LL;
    suma -= 5*(n/5)*(n/5+1LL)/2LL;
    suma += 15*(n/15)*(n/15+1LL)/2LL;
    cout << suma;
    return 0;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int mod = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};
#define MAX_H 50
#define MAX_W 50

ll h, w;
vector<vector<char>> fieldmap(MAX_H, vector<char>(MAX_W));
bool dfs(int x, int y){
  if(x > h-1 || x < 0 || y < 0 || y > w-1)
    return true;
  else if(fieldmap[x][y] == '.')
    return true;
  else if(fieldmap[x][y] == '-')
    return false;
  else{
    fieldmap[x][y] = '-';
    return dfs(x+dx[0], y+dy[0]) && dfs(x+dx[1], y+dy[1]) \
      && dfs(x+dx[2], y+dy[2]) && dfs(x+dx[3], y+dy[3]);
  }
}

void displaymap(){
  REP(i, w){
    REP(j, h)
      cout << fieldmap[i][j];
    cout << endl;
  }
  
}

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  
  cin >> h >> w;
  REP(i, h){
    REP(j, w)
      cin >> fieldmap[i][j];
  }
  
  REP(i, h){
    REP(j, w){
      if(fieldmap[i][j] == '#' && dfs(i, j)){
        //cout << i << " " << j << endl;
        //displaymap();
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>

using namespace std;
using ll = int64_t;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using mii = map<int, int>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using tpi = tuple<int, int, int>;

using vqi = vector<queue<int>>;
using vpi = vector<pii>;
using bs = bitset<60>;
using vbi = vector<bs>;

ll gcd(ll a, ll b) {
    if (a < b) {
        swap(a, b);
    }

    /* ユークリッドの互除法 */
    ll r = a % b;
    while (r != 0) {
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}

ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

constexpr int64_t __pow_mod(int64_t n, int64_t p, int64_t mod) noexcept {
    if (p == 0) {
        return 1;
    }
    if (p % 2 == 0) {
        int64_t t = __pow_mod(n, p / 2, mod);
        return (t * t) % mod;
    }
    return (n * (__pow_mod(n, p - 1, mod) % mod)) % mod;
}

constexpr int64_t pow_mod(int64_t n, int64_t p, int64_t mod) noexcept {
    int64_t res = __pow_mod(n, p, mod);
    if (res == 0) {
        res = mod;
    }
    return res;
}

constexpr int64_t nCr_mod(int64_t n, int64_t r, int64_t mod) noexcept {
    int64_t count = 1;
    auto a = r;
    for (auto i = n; i > n - r; i--) {
        count *= i;
        if (count % mod != 0) {
            count %= mod;
        }
        int64_t inv = pow_mod(a, mod - 2, mod);
        count *= inv;
        if (count % mod != 0) {
            count %= mod;
        }
        a--;
    }
    return count;
}

void solve(long long N, long long A, long long B) {
    if (A >= N) {
        cout << N << endl;
        return;
    }

    if (A + B >= N) {
        cout << A << endl;
        return;
    } else if (A + B == 0) {
        cout << 0 << endl;
        return;
    } else {
        ll ans = A * (N / (A + B));
        ll m = N % (A + B);
        if (m >= A) {
            ans += A;
        } else {
            ans += m;
        }
        cout << ans << endl;
        return;
    }
}

int main() {
    long long N;
    std::cin >> N;
    long long A;
    std::cin >> A;
    long long B;
    std::cin >> B;
    solve(N, A, B);
    return 0;
}


Measured memory_bytes: 256
from sys import exit
n = input()
arr = []
for i in range(n):
	t = map(int,raw_input().split())
	arr.append(t)
ans = 0
for i in range(n):
	for j in range(n):
		flag = False
		for k in range(n):
			if k == j or k == i:
				continue
			elif arr[i][k]+arr[k][j] < arr[i][j]:
				print "-1"
				exit(0)
			elif arr[i][k]+arr[k][j] == arr[i][j]:
				flag = True
				continue
		if flag == False:
			ans += arr[i][j]
print ans//2


Measured memory_bytes: 33768
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        String S = sc.next();

        String[] strList = S.split("");
        int length = 1;
        for (int i = 0; i < N - 1; i++) {
            if (!strList[i].equals(strList[i + 1])) {
                length++;
            }
        }
        System.out.println(length);
    }
}

Measured memory_bytes: 32176
N = int(input())
d = list(map(int, input().split()))
 
result = 0
# 最後尾はもう全部計算されてるから除外
for i in range(N - 1):
  # i=1個目の時2と3の2パターンをかける
    for j in range(i + 1, N):
        result += d[i] * d[j]
print(result)

# import itertools

# n = input()
# d_list = list(i.combinations(list(map(int,input().split())),2)

# ans = 0

# for i in d_list
   
#    a = i[0] * i[1]
#    ans += a
       
# print(ans)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
const int MAXN=200010;
int n,k,a[MAXN];
double t[MAXN],s[MAXN],ans;
int main () {
	scanf("%d%d",&n,&k);
	for (int i=1;i<=n;i++) {
		scanf("%d",&a[i]);
		t[i]=(double)(a[i]*(a[i]+1))/2.0/(double)a[i];
		s[i]=s[i-1]+t[i];
		if (i>=k) {ans=max(ans,s[i]-s[i-k]);}
	}
	printf("%lf\n",ans);
	return 0;
}

Measured memory_bytes: 4096
n = int(input())
height_list = list(map(int, input().split()))

a = 0
for i in range(n - 1):
    if height_list[i] > height_list[i + 1]:
        a += height_list[i] - height_list[i + 1]
        height_list[i + 1] = height_list[i]
print(a)


Measured memory_bytes: 32184
num = int(input())
i = [input() for _ in range(num)]
 
count_dict = {}
for ele in i:
  if ele not in count_dict:
    count_dict[ele] = 1
  else:
    count_dict[ele] += 1
 
max_count = max(count_dict.values())
max_str = [a for a in count_dict if count_dict[a] == max_count]
for string in sorted(max_str):
  print(string)

Measured memory_bytes: 35220
import sys

readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)
INF = float('inf')

N = int(readline().rstrip())
H = list(map(int, readline().split()))

dp = [INF] * N
dp[0] = 0
for i in range(N):
    if i+1 < N:
        dp[i+1] = min(dp[i+1], dp[i] + abs(H[i] - H[i+1]))
    if i+2 < N:
        dp[i+2] = min(dp[i+2], dp[i] + abs(H[i] - H[i+2]))

ans = dp[-1]
print(ans)

Measured memory_bytes: 12328
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
typedef pair<int, int> P;
const long long inf = 1ll << 61;
const long long mod = 1000000007;

signed main() {
	int n, m; cin >> n >> m;
	string s; cin >> s;
	if (s[0] == 'B') {
		rep(i, m) {
			if (s[i] == 'R')s[i] = 'B'; else s[i] = 'R';
		}
	}
	vector<int>r, b;
	char now = 'R'; int cnt1 = 0;
	s.push_back('A');
	rep(i, m+1) {
		if (now == s[i])cnt1++;
		else {
			if (now == 'R')r.push_back(cnt1);
			else b.push_back(cnt1);
			now = s[i];
			cnt1 = 1;
		}
	}
	s.pop_back();

	if (b.empty()) {//全部一緒
		vector<int>L(200005);
		L[0] = 2; L[1] = 1;
		rep(i, 200002)L[i + 2] = (L[i] + L[i + 1]) % mod;
		cout << L[n] << endl;
		return 0;
	}

	if (n & 1) {
		cout << 0 << endl; return 0;
	}
	else {
		int MR = r[0];
		if (MR & 1)MR += 2;
		else MR += 1;
		rep(i,r.size()-1){
			int e = r[i];
			if (e & 1)MR = min(MR, e);
		}
		if (r.size() == b.size()) {
			int e = r[r.size() - 1];
			if(e&1)MR = min(MR, e);
		}
		MR = (MR + 1) / 2;
		vector<int>dp(200005);
		int s = 1, as = 1;
		dp[1] = 1;
		for (int i = 2; i <= MR; i++) {
			dp[i] = (as + i) % mod;
			as = (as + dp[i]) % mod;
		}
		for (int i = MR + 1; i <= n; i++) {
			dp[i] = as;
			as += dp[i];
			as -= dp[i - MR];
			as = (as + mod) % mod;
		}
		cout << (dp[n/2]*2)%mod << endl;
	}
}

Measured memory_bytes: 2936
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<iomanip>
using namespace std;
int main() {
	long double l;
	cin >> l;
	double a = l / 3;
	double i = (a * a * a);
	cout << fixed << setprecision(7)<< i;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define boost ios_base::sync_with_stdio(false)
#define pb push_back
#define e1 first
#define e2 second
#define x first
#define y second
#define tysiac 1010
#define milion 1000100
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define OUT(x) { cout << x; return 0; }
#define PRINT(x, y) {printf("%d %d\n", x, y); return;} 
#define scanf(...) scanf(__VA_ARGS__)?:0
typedef long long int ll;
typedef unsigned int ui;
typedef unsigned long long ull;
typedef double ld;
typedef pair <int, int> PII;
typedef pair <ll, ll> PLL;
typedef pair <ld, ld> PDD;
typedef pair <PII, PII> PP;
typedef pair <ll, int> PLI;
typedef pair <double, int> PDI;

const int mod = 1e9+7;
const int inf = 1e9+9;
const int MOD = 1e9+696969;
const ll INF = 1e18+3;
int T, n, m, K, a, b, c, k, d, g, Q, DL;

#define maxn 1000100
ll t[maxn];

int main() {
	boost;
	FOR(i, 1, 3) cin >> t[i];
	FOR(i, 1, 3)
	  if (t[i] % 2 == 0) OUT(0);
	sort(t +1, t + 3 + 1);
	cout << t[1] * t[2];
}


Measured memory_bytes: 256
n, k = map(int, input().split())
a = list(map(int, input().split()))
def get_cycle_length():
  pointer1 = 1
  pointer2 = a[1-1]
  while pointer1 != pointer2:
    pointer2 = a[pointer2-1]
    pointer2 = a[pointer2-1]
    pointer1 = a[pointer1-1]
  cycle_length = 1
  pointer2 = a[pointer2-1]
  while pointer1 != pointer2:
    pointer2 = a[pointer2-1]
    cycle_length += 1
  return cycle_length
def get_start_length(cycle_length):
  pointer1 = 1
  pointer2 = 1
  for _ in range(cycle_length):
    pointer2 = a[pointer2-1]
  start_length = 0
  while pointer1 != pointer2:
    start_length += 1
    pointer1 = a[pointer1-1]
    pointer2 = a[pointer2-1]
  return start_length
if k>n:
  cycle_length = get_cycle_length()
  start_length = get_start_length(cycle_length)
  remainder_steps = k - start_length
  modded_remainder = remainder_steps % cycle_length
  k = start_length + modded_remainder
town = 1
for _ in range(k):
  town = a[town-1]
print(town)

Measured memory_bytes: 32384
#include<bits/stdc++.h>
using namespace std;
    int main(){
        int N, K;
            string S;
                cin >> N >> K;
                    cin >> S;
                        if(S.at(K - 1) == 'A'){
                            S.at(K - 1) = 'a';
                        }else if(S.at(K - 1) == 'B'){
                            S.at(K - 1) = 'b';
                        }else if(S.at(K - 1) == 'C'){
                            S.at(K - 1) = 'c';
                        }else{}
                            cout << S << endl;
    return 0;}

Measured memory_bytes: 256