akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <map>
#include <sstream>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <iterator>
#include <stack>
#include <list>
#include <ctime>
#include <cstring>
using namespace std;
#define INF 100000000
typedef long long int lli;
typedef pair<int,int> P;


int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool f[8][8][8][8][8][8][8][8];
short cnt[8][8][8][8][8][8][8][8];
int r[2][4]={{0,1,2,3},{4,5,6,7}};
struct puzzle{
	int card[2][4];
	int cnt;
};

int main(){
	puzzle sp;
	for(int i=0; i<2; ++i){
		for(int j=0; j<4; ++j){
			sp.card[i][j]=r[i][j];
		}
	}
	memset(f,false,sizeof(f));
	memset(cnt,0,sizeof(cnt));
	sp.cnt=0;
	queue<puzzle> que;
	que.push(sp);
	while(que.size()){
		puzzle pz=que.front();
		que.pop();
		cnt[pz.card[0][0]][pz.card[0][1]][pz.card[0][2]][pz.card[0][3]][pz.card[1][0]][pz.card[1][1]][pz.card[1][2]][pz.card[1][3]]=pz.cnt;
		f[pz.card[0][0]][pz.card[0][1]][pz.card[0][2]][pz.card[0][3]][pz.card[1][0]][pz.card[1][1]][pz.card[1][2]][pz.card[1][3]]=true;
		for(int i=0; i<2; ++i){
			for(int j=0; j<4; ++j){
				if(pz.card[i][j]==0){
					if(0<=i-1){
						puzzle np=pz;
						np.cnt=pz.cnt+1;
						swap(np.card[i-1][j],np.card[i][j]);
						if(!f[np.card[0][0]][np.card[0][1]][np.card[0][2]][np.card[0][3]][np.card[1][0]][np.card[1][1]][np.card[1][2]][np.card[1][3]])que.push(np);
					}
					if(i+1<2){
						puzzle np=pz;
						np.cnt=pz.cnt+1;
						swap(np.card[i+1][j],np.card[i][j]);
						if(!f[np.card[0][0]][np.card[0][1]][np.card[0][2]][np.card[0][3]][np.card[1][0]][np.card[1][1]][np.card[1][2]][np.card[1][3]])que.push(np);
					}
					if(0<=j-1){
						puzzle np=pz;
						np.cnt=pz.cnt+1;
						swap(np.card[i][j-1],np.card[i][j]);
						if(!f[np.card[0][0]][np.card[0][1]][np.card[0][2]][np.card[0][3]][np.card[1][0]][np.card[1][1]][np.card[1][2]][np.card[1][3]])que.push(np);
					}
					if(j+1<4){
						puzzle np=pz;
						np.cnt=pz.cnt+1;
						swap(np.card[i][j+1],np.card[i][j]);
						if(!f[np.card[0][0]][np.card[0][1]][np.card[0][2]][np.card[0][3]][np.card[1][0]][np.card[1][1]][np.card[1][2]][np.card[1][3]])que.push(np);
					}
				}
			}
		}
	}
	int n[8];
	int ans;
	while(cin>>n[0]>>n[1]>>n[2]>>n[3]>>n[4]>>n[5]>>n[6]>>n[7]){
		ans=cnt[n[0]][n[1]][n[2]][n[3]][n[4]][n[5]][n[6]][n[7]];
		cout << ans << "\n";
	}
	return 0;
}

Measured memory_bytes: 50508
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <stack>
#include <deque>
#include <cmath>
#include <map>
using ll = long long;
using namespace std;

int main() {
  int a, b;
  cin >> a >> b;
  if (a == b) cout << "Draw" << endl;
  else if (a == 1) cout << "Alice" << endl;
  else if (b == 1) cout << "Bob" << endl;
  else if (a > b) cout << "Alice" << endl;
  else cout << "Bob" << endl;
}


Measured memory_bytes: 256
import sys,random
from math import gcd
input=sys.stdin.readline
n=int(input())
*a,=map(int, input().split())
random.shuffle(a)
tmp=a[0]
for i in range(1,n):
    tmp=gcd(tmp,a[i])
if tmp>1:
    print('not coprime')
    exit()

# pairwize coprime なら素因数が2度現れることはない

def f(x):
    res=set()
    for i in range(2,int(x**(1/2))+3):
        if x%i==0:
            while x%i==0:
                x//=i
            res.add(i)
    return res,x
tmp=set()
tmp2=set()
for ai in a:
    for p in tmp:
        if ai%p==0:
            print('setwise coprime')
            exit()
    pp,x=f(ai)
    tmp|=pp 
    if x>1 and x in tmp2:
        print('setwise coprime')
        exit()
    tmp2.add(x)
    
        
print('pairwise coprime')



Measured memory_bytes: 231604
import java.util.*;

public class Main {
	void solve() {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int[] l = new int[n];
		for(int i = 0; i < n; i++) l[i] = scan.nextInt();
		int out = 0;
		for(int i = 0; i < n - 2; i++) {
			for(int j = i; j < n - 1; j++) {
				for(int k = j; k < n; k++) {
				if(i != j && j != k && k != i && l[i] != l[j] && l[j] != l[k] && l[k] != l[i] && l[i] < l[j] + l[k] && l[j] < l[i] + l[k] && l[k] < l[j] + l[i]) {
						out++;
					}
				}
			}
		}
		System.out.println(out);
		scan.close();
	}
	
	public static void main(String[] args) {
		new Main().solve();
	}
}


Measured memory_bytes: 36220
// Created by sz
#include <bits/stdc++.h>
using namespace std;

const int N = 1e5 + 5;
string s;
int x,y;

int main(){
#ifdef LOCAL
    freopen("./input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    cin>>s>>x>>y;
    
    int flag = 1, cnt = 0;
    vector<int> xa, ya;
    s += 'T';
    int first = 1, fircnt = 0;
    for(auto i:s){
        if (i=='T'){
            if(first) {
                fircnt = cnt;
                cnt = 0;
                flag = flag^1;
                first = 0;
                continue;
            }
            if(flag == 1){
                if(cnt&&!first)xa.push_back(cnt);
            }else{
                if (cnt&&!first)ya.push_back(cnt);
            }
            cnt = 0;
            flag = flag^1;
        }else{
            cnt += 1;
        }
    }
    
    
    
    set<int> xvis[2];
    int xflag = 0;
    xvis[0].insert(fircnt);
    for (auto i: xa){
        xvis[xflag^1].clear();
        for (auto j:xvis[xflag]){
            xvis[xflag^1].insert(j + i);
            xvis[xflag^1].insert(j-i);
        }
        xflag = xflag^1;
    }
    
    
    set<int> yvis[2];
    int yflag = 0;
    yvis[0].insert(0);
    for (auto i: ya){
        yvis[yflag^1].clear();
        for (auto j:yvis[yflag]){
            yvis[yflag^1].insert(j + i);
            yvis[yflag^1].insert(j-i);
        }
        yflag = yflag^1;
    }
    
    
    
    
    if(xvis[xflag].count(x)&&yvis[yflag].count(y)){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    
    return 0;
}



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

#define fi  first
#define se  second
#define mp  make_pair
#define pb  push_back

typedef long long ll;
typedef queue <int> qi;
typedef vector <int> vi;
typedef vector <ll> vll;
typedef map <ll, ll> mll;
typedef map <int, int> mii;
typedef pair <int, int> pii;
typedef map <char, int> mci;
typedef map <char, char> mcc;
typedef map <string, int> msi;
typedef pair <string, int> psi;
typedef map <string, string> mss;
typedef unsigned long long ull;

const ll mod = 10e9+7;
const double eps = 1e-11;
const double PI = 2 * acos(0.0);

int main() {
    int n, d, x;
    cin >> n >> d >> x;

    int arr[n];
    for (int i = 0; i < n; i++) cin >> arr[i];

    int sum = x;
    for (int i = 0; i < n; i++) {
        int f = 0, j = 1, m = 0;
        while (j <= d) {
            f++;
            m++;
            j = ((arr[i] * m) + 1);
        }
        //cout << f << endl;
        sum += f;
    }

    cout << sum << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iostream>
#include <vector>

using namespace std;

typedef long long ll;
// typedef pair<ll, ll> P;
typedef pair<double, double> P;
typedef pair<double, P> DP;

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main() {
  int n;
  cin >> n;
  double x[n], y[n];
  REP(i, n) cin >> x[i] >> y[i];
  vector<DP> vec;
  REP(i, n) {
    vec.push_back(make_pair(atan2(y[i], x[i]), make_pair(x[i], y[i])));
  }
  sort(ALL(vec));
  REP(i, n) vec.push_back(vec[i]);
  double ans = 0;
  REP(i, n) for (int j = i; j < n + i; ++j) {
    double nx = 0, ny = 0;
    for (int k = i; k <= j; ++k) {
      nx += vec[k].second.first;
      ny += vec[k].second.second;
    }
    ans = max(ans, nx * nx + ny * ny);
  }
  printf("%.50f\n", sqrt(ans));
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000000000000
#define MOD 1000000007
#define all(v) v.begin(),v.end()
#define pb push_back
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int kaijo[2000010];
struct edge{int to,cost;};
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
void init_fact(){
    kaijo[0]=1;
    for(int i=1;i<=2000000;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=MOD;
    }
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%MOD;
    int memo=modpow(a,b/2);
    return memo*memo%MOD;
}
int comb(int a,int b){
    if(!kaijo[0])init_fact();
    return kaijo[a]*modpow(kaijo[a-b],MOD-2)%MOD*modpow(kaijo[b],MOD-2)%MOD;
}
int inv(int x){
    x=modpow(x,MOD-2);
    return x;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){
    double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
    double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
    double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
    double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
    return tc*td<0&&ta*tb<0;
}
double dist(double ax,double ay,double bx,double by){
    return sqrt((bx-ax)*(bx-ax)+(ay-by)*(ay-by));
}
int n,k,a[21],ans;
bool dp[(1<<20)];
signed main(){
    cin>>n>>k;
    rep(i,n)cin>>a[i];
    for(int i=1;i<(1<<n);i++){
        int sum=0;
        rep(j,n)if((i>>j)&1)sum+=a[j];
        if(sum==k)dp[i]=true;
        rep(j,n){
            if((i>>j)&1){
                if(dp[i-(1<<j)])dp[i]=true;
            }
        }
        if(dp[i]==false){
            int cnt=0;
            rep(j,n){
                if((i>>j)&1)cnt++;
            }
            ans=max(ans,cnt);
        }
    }
    cout<<n-ans<<endl;
    return 0;
}



Measured memory_bytes: 4128
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;

int main() {
  int N;
  cin >> N;
  map<string, int> M;
  rep(i, N) {
    string S;
    cin >> S;
    M[S]++;
  }
  cout << M.size() << endl;
}

Measured memory_bytes: 19204
#include <iostream>

using namespace std;

int main() {
    int A, B, C;
    scanf("%d%d%d", &A, &B, &C);
    if (C > A+B) {
        printf("%d", A+B*2+1);
    } else if (C <= A+B) {
        printf("%d", B+C);
    }
}

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

using namespace std;

int main() {
	int k, t; cin >> k >> t;
	vector<int> a(t);
	for(int &ai:a) cin >> ai;
	sort(a.begin(), a.end());

	if(t == 1) {
		cout << a[t-1]-1 << endl;
	}
	else {
		int s = 0;
		for(int ai:a) s += ai;
		s -= a[t-1];

		if(s >= a[t-1]) {
			cout << 0 << endl;
		}
		else {
			cout << a[t-1] - s - 1 << endl;
		}
	}

	return 0;
}


Measured memory_bytes: 256
W,H,N=map(int,input().split())
XYA=[list(map(int,input().split()))for _ in range(N)]

WX=[0,W]
HY=[0,H]

i=0
while i<N:
    if XYA[i][2]==1:
        WX[0]=max(WX[0],XYA[i][0])
    elif XYA[i][2]==2:
        WX[1]=min(WX[1],XYA[i][0])
    elif XYA[i][2]==3:
        HY[0]=max(HY[0],XYA[i][1])
    elif XYA[i][2]==4:
        HY[1]=min(HY[1],XYA[i][1])
    i+=1

ans=max(0,WX[1]-WX[0])*max(0,HY[1]-HY[0])
print(ans)

Measured memory_bytes: 9256
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int str = scan.nextInt();
        int result = 1;
        for(int i=1;i<=3;i++){
            result = result * str;
        }
        System.out.println(result);
    }
}


Measured memory_bytes: 26200
#include "bits/stdc++.h"
using namespace std;
#define INF 1000000000
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(), (x).end()  //昇順
#define RALL(x) (x).rbegin(), (x).rend() // 降順
#define SZ(x) ((int)(x).size)
const long long mod = 1e9+7;
typedef priority_queue<int> PQ;
typedef vector<long long> Vl;
typedef vector<int> VI;  // VI a(n);
typedef vector<string> VS;  
typedef vector<VS> VSS;  
typedef vector<VI> VVI;   // VVI a(n,vector<int>(m)) n * m 
typedef vector<Vl> VVl;
typedef pair<int, int> PII;
typedef vector<pair<int, int> > PS;
typedef long long ll;  //ll とdoubleは違う
// cout << << endl;
// cin >> ;
template<typename T>   // operator << (cout,a);
ostream& operator << (ostream& os, vector<T>& v) {
    os << "{";
    rep(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); }
    os << "}";
    return os;
}
bool prime(int n);

int main(){
    ll x=1,g=0,n,m,l,ans=1,ptr=0;
    string s,s1,s2;
    cin >> n; 
    VI a(n);
    VI b(n);
    int k=0;
    for(int i=1;i<=n;i++){
        if(prime(i)==true){
            a[k] = i;
            k++;
        }
    }
    for(int i=0;i<n;i++){
        if(a[i]>0){
            for(int j=1;j<=n;j++){
                int o = j;
                while(o%a[i]==0){
                    b[i]++;
                    o /= a[i];
                }
            }

        }
    }
    for(int i=0;i<n;i++){
        if(b[i] > 0){
            ans *= b[i]+1;
            ans %= mod;
        }
    }
    cout << ans <<endl;
    return 0;
}

bool prime(int n){
    if(n < 2) return false;
    else{
        for(int i = 2; i * i <= n; i++){
            if(n % i == 0) return false;
        }
        return true;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

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

    ll n;
    cin >> n;
    ll a, res = 1e10;
    REP(i, n){
        cin >> a;
        ll tmp = 0;
        while(1){
            if(a % 2) break;
            a /= 2;
            tmp++;
        }
        res = min(res, tmp);
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#include <cmath>
#include <queue>
//#include <bits/stdc++.h>
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i,i0,n) for(int (i)=(i0);(i)<(n);(i)++)
#define FORR(i,i0,n) for(int (i)=(n)-1; (i)>=(i0);(i)--)
#define rn return
#define fi first
#define se second
typedef std::pair<int,int> P;
using namespace std;
using ll = long long;


int main(){
    int A,B; cin >> A >> B;
    if (A>=13){
        cout << B;
    }
    else if (A>=6){
        cout << B/2;
    }
    else{
        cout << 0;
    }
    rn 0;
}


Measured memory_bytes: 256
//Andrew Yang
#include <iostream>
#include <stdio.h>
#include <sstream>
#include <fstream>
#include <string>
#include <string.h>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>	
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <climits>
using namespace std;
#define FOR(index, start, end) for(int index = start; index < end; ++index)
#define RFOR(index, start, end) for(int index = start; index > end; --index)
#define FOREACH(itr, b) for(auto itr = b.begin(); itr != b.end(); ++itr)
#define RFOREACH(itr, b) for(auto itr = b.rbegin(); itr != b.rend(); ++itr)
#define INF 1000000000
#define M 1000000007
typedef long long ll;
typedef pair<int, int> pii;
int a[100005];
ll dt[100005];
int dc[100005];
int main(void)
{
	int n, m;
	scanf("%d%d", &n, &m);
	FOR(i, 0, n) {
		scanf("%d", &a[i]);
	}
	int c = 0;
	FOR(i, 0, n - 1) {
		if (a[i] + 1 < a[i + 1]) {
			dc[a[i] + 1]++;
			dc[a[i + 1]]--;
			dt[a[i + 1] + 1] += a[i + 1] - a[i] - 1;
		}
		else if (a[i + 1] < a[i] && (a[i] + 1 % m) != a[i + 1]) {
			dc[(a[i] + 1) % m]++;
			dc[a[i + 1]]--;
			dt[a[i + 1] + 1] += a[i + 1] - a[i] + m - 1;
			if (a[i + 1] > 1) {
				c++;
			}
		}
	}
	int x = 1;
	ll t = 0;
	FOR(i, 0, n - 1) {
		t += min((a[i + 1] - a[i] + m) % m, (a[i + 1] - x + m) % m + 1);
	}
	ll ans = t;
	FOR(i, 2, m + 1) {
		t -= c;
		c += dc[i];
		t += dt[i];
		ans = min(ans, t);
	}
	cout << ans << endl;
}

Measured memory_bytes: 1792
#include "bits/stdc++.h"
using namespace std;
int h,w,n;
string ban[30];
string bancp[30];
void cpstr()
{
	for(int i=0;i<h;i++)
		bancp[i]=ban[i];
	return;
}

void calc_ban()
{
	bool f=true;
	bool kesu[30][30];//そのターンで新しく消すブロック
	while(1)
	{
		//落とす
		while(f)
		{
			f=false;
			for(int i=h-1;i>0;i--)
			{
				for(int j=0;j<w;j++)
				{
					if(bancp[i-1][j]!='.' && bancp[i][j]=='.')
					{
						//cerr<<i<<" "<<j<<" "<<ban[i-1][j]<<endl;
						f=true;
						bancp[i][j]=bancp[i-1][j];
						bancp[i-1][j]='.';
					}
				}
			}
		}
		f=false;
		fill(kesu[0],kesu[30],false);
		//消せるものを探す
		for(int i=0;i<h;i++)
		{
			for(int j=0;j<w;j++)
			{
				if(bancp[i][j]=='.')
					continue;
				//下に探索
				int cnt=0;
				int ind=i;
				while(ind<h && bancp[ind][j]==bancp[i][j])
				{
					ind++;
					cnt++;
				}
				if(cnt>=n)
				{
					f=true;
					for(int k=i;k<ind;k++)
						kesu[k][j]=true;
				}
				//右に探索
				cnt=0;
				ind=j;
				while(ind<w && bancp[i][ind]==bancp[i][j])
				{
					ind++;
					cnt++;
				}
				if(cnt>=n)
				{
					f=true;
					for(int k=j;k<ind;k++)
						kesu[i][k]=true;
				}
			}
		}
		//消すものがなければ終了
		if(!f)
			break;
		//消す
		for(int i=0;i<h;i++)
		{
			for(int j=0;j<w;j++)
			{
				if(kesu[i][j])
					bancp[i][j]='.';
			}
		}
	}
	return;
}

bool check_zenkeshi()
{
	bool ret=true;
	for(int i=0;i<h;i++)
	{
		for(int j=0;j<w;j++)
		{
			if(bancp[i][j]!='.')
				ret=false;
		}
	}
	return ret;
}

int main()
{
	cin>>h>>w>>n;
	for(int i=0;i<h;i++)
		cin>>ban[i];
	for(int i=0;i<h;i++)
	{
		for(int j=0;j<w-1;j++)
		{
			//cerr<<i<<" "<<j<<endl;
			cpstr();
			swap(bancp[i][j],bancp[i][j+1]);
			calc_ban();
			if(check_zenkeshi())
			{
				cout<<"YES"<<endl;
				return 0;
			}
		}
	}
	cout<<"NO"<<endl;
	return 0;
}


Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
int n,m,x,a[105][105],c[105],k[105],sum=1e9,res;
int main()
{
	cin>>n>>m>>x;
	for(int i=0;i<n;i++)
	{
		cin>>c[i];
		for(int j=0;j<m;j++)
			cin>>a[i][j];
	}
	for(int i=0;i<(1<<n);i++)
	{
		res=0;
		for(int j=0;j<m;j++)
			k[j]=0;
		for(int j=0;j<n;j++)
		{
			if((i>>j)&1==1)
			{
				res+=c[j];
				for(int t=0;t<m;t++)
					k[t]+=a[j][t];
			}
		}
		bool ok=true;
		for(int j=0;j<m;j++)
		{
			if(k[j]<x)
			{
				ok=false;
				break;
			}
		}
		if(ok)
			sum=min(sum,res);
	}
	if(sum==1e9)
		cout<<"-1";
	else
		cout<<sum;

	return 0;
}

Measured memory_bytes: 3636
#include <cstdio>

#define HOUR 3600
#define MINUTE 60

int main(void) {
	for(int i = 0; i < 3; i++) {
		int total, a, b, c, d, e, f;
		scanf("%d %d %d %d %d %d", &a, &b, &c, &d, &e, &f);
		total = HOUR * (d - a) + MINUTE * (e - b) + (f - c);
		printf("%d %d %d\n", total / HOUR, (total % HOUR) / MINUTE, total % HOUR % MINUTE);
	}
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int main()  
{   
	string s;
	cin>>s;
	if(s[0]!='A'){
		puts("WA");
		return 0;
	}
	int f=0;
	for(int i=2;i<s.size()-1;i++){
		if(s[i]=='C')
			f++;
	}
	if(f==0){
		puts("WA");
		return 0;
	}
	f=0;
	for(int i=0;i<s.size();i++){
		if(s[i]<='Z'&&s[i]>='A')
			f++;
	}
	if(f!=2){
		puts("WA");
		return 0;
	}
	puts("AC");
	return 0;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		ArrayList<Integer> input = new ArrayList<Integer>();
		ArrayList<Integer> ans = new ArrayList<Integer>();
		int tmp;
		int p = 0;
		int p2 = 0;
		while(scanner.hasNext()){
			tmp = scanner.nextInt();
			if(tmp != 0){
				input.add(p, tmp);
				p++;
			}else{
				ans.add(p2, input.get(p-1));
				p2++;
				p--;
			}
		}
		for(int j=0; j<p2; j++){
			System.out.println(ans.get(j));
		}
	}
}

Measured memory_bytes: 17292
#include <iostream>
using namespace std;
int main()
{
	long long n,k;
	scanf("%lld%lld",&n,&k);
	long long b=1,sum=0;
	while(1)
	{
		if(b*k>n*2)
			break;
		if((b*k)%2==0)
		{
			long long a=b*k/2;
			sum+=((n-a)/k-(-a%k==0?-a/k+1:-a/k)+1)*((n+a)/k-a/k);
		}
		b++;
	}
	printf("%lld\n",sum);
	return 0;
}


Measured memory_bytes: 256
n, x = map(int, input().split())
a = list(map(int, input().split()))
a.append(x)
a = sorted(a)
diff_list = [0] * n
for i in range(1, n + 1):
    diff_list[i - 1] = a[i] - a[i - 1]
g = diff_list[0]
import math
for i in range(1, n):
    g = math.gcd(g, diff_list[i])
print(g)

Measured memory_bytes: 20020
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<int(n);++i)

typedef complex<double> Point;
typedef vector<Point> VP;
#define X real()
#define Y imag()

int main(void){
    int n;
    cin >> n;
    VP ps(n);
    vector<double> dx(n), dy(n);
    rep(i,n) {
        double x,y;
        char ch;
        cin >> x >> y >> ch;
        ps[i] = Point(x,y);
        if (ch == 'R') dx[i] = +1.0;
        if (ch == 'L') dx[i] = -1.0;
        if (ch == 'U') dy[i] = +1.0;
        if (ch == 'D') dy[i] = -1.0;
    }
    double l = 0, r = 1e9;
    auto area = [&](double t) {
        double minX = 1e9, minY = 1e9, maxX = -(1e9), maxY = -(1e9);
        rep(i,n){
            double x = ps[i].X + dx[i]*t;
            double y = ps[i].Y + dy[i]*t;
            minX = min(minX, x);
            minY = min(minY, y);
            maxX = max(maxX, x);
            maxY = max(maxY, y);
        }
        return (maxX - minX) * (maxY - minY);
    };
    rep(loop,500){
        double m1 = (l*2.0 + r)/3.0;
        double m2 = (l + r*2.0)/3.0;
        if (area(m1) <= area(m2)) {
            r = m2;
        } else {
            l = m1;
        }
    }
    printf("%.15f\n", area((l+r)/2.0));
    return 0;
}


Measured memory_bytes: 3456
N,Y = map(int,input().split())
boo = False
yukichi = -1
ichiyo = -1
hideo = -1
for x in range(N+1):
  for y in range(N-x+1):
    if 10000*x+5000*y == Y - 1000*(N-x-y):
      boo = True
      yukichi = x
      ichiyo = y
      hideo = N-x-y
      break
  if boo:
    break
print(yukichi,ichiyo,hideo)

Measured memory_bytes: 3064
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n = int(readline())
s = list(read().rstrip().decode())
ans = 0
for i in range(n):
    ans = max(ans, len(set(s[:i]) & set(s[i:])))
print(ans)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
using namespace std;
typedef long long ll;

int N, M, Q;
vector<int> a, b, c, d;

int score(vector<int> A) {
    int res = 0;
    rep(i, Q) if (A[b[i]] - A[a[i]] == c[i]) res += d[i];
    return res;
}

int main() {
    cin >> N >> M >> Q;
    a.resize(Q); b.resize(Q); c.resize(Q); d.resize(Q);
    rep(i, Q){
        cin >> a[i] >> b[i] >> c[i] >> d[i];
        a[i]--, b[i]--;
    }
    stack<vector<int>> st;
    rep(i, M){
        vector<int> s = {i+1};
        st.push(s);
    }
    int ans = 0;
    while (!st.empty()){
        vector<int> elem = st.top();
        st.pop();
        if (elem.size()==N) ans = max(ans, score(elem));
        else {
            repi(i, elem[elem.size()-1], M+1){
                vector<int> elem_new = elem;
                elem_new.push_back(i);
                st.push(elem_new);
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <set>

#define DEBUG 0
#define lli long long int
#define REP(i,n) for(int i=0;i<n;i++)
#define SIZE 510

using namespace std;


int main(){

	lli n;
	lli *a;
	lli *b;
	lli sumA=0,sumB=0;
	cin>>n;
	a = new lli[n];
	b = new lli[n];

	REP(i,n){
		cin>>a[i];
		sumA+=a[i];
	}
	REP(i,n){
		cin>>b[i];
		sumB+=b[i];
	}
	if(sumA<sumB){
		cout<<-1<<endl;
		return 0;
	}
	vector<lli> c;
	vector<lli> d;
	REP(i,n){
		c.push_back(a[i]-b[i]);
		d.push_back(a[i]-b[i]);
	}

	sort(c.begin(),c.end());
	sort(d.begin(),d.end());

	/*
	REP(i,n){
		cout<<c[i]<<endl;
	}
	*/

	lli cnt=0;
	lli plusN = n-1;

	REP(i,n){
		if(c[i]>=0)break;
		while(c[i]<0){
			if(c[plusN] >= (-1*c[i])){
				c[plusN] += c[i];
				c[i]=0;
			}
			else{
				c[i] += c[plusN];
				c[plusN]=0;
				plusN--;
			}
		}
	}
	REP(i,n){
		if(c[i] != d[i])cnt++;
	}

	cout<<cnt<<endl;

	return 0;
}

Measured memory_bytes: 3572
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <numeric>
using namespace std;
typedef long long ll;

int main(){
    int n,a,b;cin>>n>>a>>b;
    if(n==1)cout<<"Hello World";
    else cout<<a+b;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define print(a,n) rep(i,0,n){ cout<<(i ? " ":"")<<a[i]; }cout<<endl;
const long mod=1e9+7;
int main(){
	string s;cin>>s;
	rep(i,2,s.size()){
		if(s.at(i)==s.at(i-1)||s.at(i)==s.at(i-2)){
			cout<<i-1<<" "<<i+1<<endl;
			return 0;
		}
	}
    if(s.at(0)==s.at(1)) cout<<1<<" "<<2<<endl;
    else cout<<-1<<" "<<-1<<endl;
}

Measured memory_bytes: 512
#include <stdio.h>
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
typedef std::vector<ll> lls;
#define MIN(a, b) ( ((a)<(b)) ? (a) : (b) )


void cinv(lls& llVec, ll n) {
	ll val;
	llVec.reserve((size_t)(n+1));
	llVec.push_back(-99); //dummy
	for (ll i = 1; i <= n; i++) {
		cin >> val;
		llVec.push_back(val);
	}
}

int main()
{
	int ret;
	ll N;
	lls A, B;
	ll count;

	cin >> N;
	cinv(A, N+1);
	cinv(B, N);

	count = 0;
	for (ll i = 1; i <= N; i++) {
		ll minval = MIN(A[i], B[i]);
		A[i] -= minval;
		B[i] -= minval;
		count += minval;

		minval = MIN(A[i + 1], B[i]);
		A[i + 1] -= minval;
		B[i] -= minval;
		count += minval;
	}

	cout << count << '\n';

end:
	return 0;
}



Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;

string s;
int p = 0;

bool is_digit(char c){
	return '0' <= c && c <= '9';
}

int dfs(){
	vector<int> v;
	while( p < s.size() ){
		if( is_digit(s[p]) ){
			int res = 0;
			while( is_digit(s[p]) ){
				res *= 10;
				res += s[p] - '0';
				p++;
			}
			v.push_back((res + 1) / 2);
		}else if( s[p] == '[' ){
			p++;
			v.push_back( dfs() );
		}else if( s[p] == ']' ){
			p++;
			int n = v.size();
			vector<int> a = v;
			sort(a.begin(), a.end());
			int res = 0;
			for(int i = 0; i <= n/2; i++){
				res += a[i];
			}
			return res;
		}
	}
}

int main(){
	int n;
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> s;
		p = 1;
		cout << dfs() << endl;
	}
}

Measured memory_bytes: 1288
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
static class Program{
	const int mod=1000000007;
	static void Main(){
		Sc sc=new Sc();
		string s=sc.S;
		int a=0;
		for(int i = 0;i<s.Length;i++) {if(s[i]=='0'){a++;}}
		Console.WriteLine("{0}",Math.Min(a,s.Length-a)*2);
	}
}
public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()).Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()).Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
}

Measured memory_bytes: 13408
#include<iostream>
using namespace std;
int main(void)
{
	bool cards[4][14];
	int n,rank;
	char suit;
	for(int s=0;s<4;s++)
		for(int r=1;r<=13;r++)
			cards[s][r]=0;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>suit>>rank;
		if(suit=='S') cards[0][rank]=1;
		if(suit=='H') cards[1][rank]=1;
		if(suit=='C') cards[2][rank]=1;
		if(suit=='D') cards[3][rank]=1;
	}
	for(int s=0;s<4;s++){
		for(int r=1;r<=13;r++){
			if(cards[s][r]) continue;
			if(s==0) suit='S';
			if(s==1) suit='H';
			if(s==2) suit='C';
			if(s==3) suit='D';
			cout<<suit<<" "<<r<<endl;
		}
	}
	return 0;
}


Measured memory_bytes: 3104
import sys
input = sys.stdin.readline
from collections import Counter

N = int(input())
A = list(map(int, input().split()))

S = sum(A)
C = Counter(A)
for _ in range(int(input())):
	b, c = map(int, input().split())

	S -= C[b] * b
	S += C[b] * c
	C[c] += C[b]
	C[b] = 0

	print(S)


Measured memory_bytes: 88604
s = [0] * 100100
dp = [0] * 100100
t = [10**i for i in range(10)]
	
while 1:
	a,b,p = map(int,raw_input().split())
	if a == b == p == 0: break
	ans = 0
	for i in range(b - a + 1):
		dp[i] = 1
		m = (a + i) / 10
		while a <= m and m <= b:
			dp[i] += s[m - a]
			dp[i] %= p
			m /= 10
		for j in range(10):
			if a + i == t[j]:
				s[i] = dp[i]
				break
		else:
			dp[i] += s[i - 1] if i > 0 else 0
			dp[i] %= p
			s[i] = s[i - 1] + dp[i] if i > 0 else dp[i]
			s[i] %= p
		ans += dp[i]
		ans %= p
	print ans

Measured memory_bytes: 13744
import sys
N=int(input())
for n in range(1,2*N+1):
  for w in range(1,N+1):
    try:
      h = w*n*N // (4*w*n-(n+w)*N)
    except:
      continue
    if h>0 and h*(4*w*n-(n+w)*N) - w*n*N == 0:
      print(h,n,w)
      sys.exit()

Measured memory_bytes: 66920
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <set>
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)

using namespace std;
typedef long long ll;

int main(void) {
  int a, b;
  cin >> a >> b;
  cout << (b % a == 0 ? a+b : b-a) << endl;
  return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
#include <iostream> 
#include <stdio.h>
#define MAX 20000005
typedef long long ll; 
using namespace std; 
int main () 
{
    int a,b,c,d,e; 
    cin >> a >> b >> c >> d >> e; 
    if (a == 0)
    {
        cout << "1" << endl; 
    }
    if (b == 0) 
    {
        cout << "2" << endl; 
    }
    if(c == 0)
    {
        cout << "3" << endl; 
    }
    if (d == 0) 
    {
        cout << "4" << endl; 
    }
    if (e == 0)
    {
        cout << "5" << endl; 
    }

    return 0; 
}



Measured memory_bytes: 3544
// 3.3 ""
// https://onlinejudge.u-aizu.ac.jp/problems/2298
// 所要時間:
// 着席位置: 左前
// 学んだこと:

#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
using namespace std;
typedef long long ll;

int main(void){
    int n, m;
    cin >> n >> m;
    
    vector<pair<int, int>> make;
    for (int i = 0; i < m; i++) {
        int c, d;
        cin >> c >> d;
        make.emplace_back(c, 1);
        make.emplace_back(d, -1);
    }
    
    sort(make.begin(), make.end());
    
    int ans = n + 1, idx = 0, until;
    for (int i = 0; i < 2*m; i++) {
        if (make[i].second == 1) {
            if (idx == 0) until = make[i].first;
            idx++;
        }
        else idx--;
        
        if (idx == 0) {
            ans += 2 * (make[i].first - until);
        }
    }
    
    cout << ans << endl;
}



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

int main() {
    int a,b; cin>>a>>b;
    int ans = 0;
    for(int i=a;i<=b;++i){
        int tmp=i;
        if((tmp/10000)%10 ==tmp%10 && (tmp/10)%10 ==(tmp/1000)%10)++ans;
    }
    cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> VI;

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()


int main() {
    int n, m;
    cin >> n >> m;
    vector<int> divisors;
    for (int i = 1; i * i <= m; ++i) {
        if (m % i == 0) {
            divisors.push_back(i);
            if (i * i != m) {
                divisors.push_back(m / i);
            }
        }
    }
    int ans = 0;
    for (auto e: divisors) {
        if (1ll * e * n <= 1ll * m) {
            chmax(ans, e);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int dx[] = { -1, 0, 1, 0 }; const int dy[] = { 0, 1, 0, -1 };

struct UnionFind {
	vector<int> v;
	UnionFind(int n) : v(n) { for (int i = 0; i < n; i++) v[i] = i; }
	int  find(int x) { return v[x] == x ? x : v[x] = find(v[x]); }
	void unite(int x, int y) { v[find(x)] = find(y); }
};

int main() {
	int n, m, a, b, c, t;
	while (cin >> n >> m >> a >> b >> c >> t, n) {
		vi num(n);
		vector<vvi> mat(32, vvi(n, vi(n, 0)));
		REP(i, n)
			REP(j, n) {
			if (i == j + 1)
				mat[0][i][j] = a;
			if (i == j)
				mat[0][i][j] = b;
			if (i == j - 1)
				mat[0][i][j] = c;
		}
		FOR(i, 1, 32)
			REP(j, n)
			REP(k, n)
			REP(l, n)
			mat[i][j][k] = (mat[i][j][k]+mat[i-1][l][k]* mat[i - 1][j][l])%m;
		REP(i, n)
			cin >> num[i];
		REP(i, 32) {
			if (t&(1 << i)) {
				vi num2(n, 0);
				REP(j, n) {
					REP(k, n) {
						num2[j] = (num2[j] + mat[i][j][k] * num[k]) % m;
					}
				}
				num = num2;
			}
		}
		REP(i, n) {
			if (i != 0)
				cout << ' ';
			cout << num[i];
		}
		cout << endl;
	}
}

Measured memory_bytes: 3316
#include <cstdio>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
#include <set>
#include <string>
#include <iostream>
#include <cassert>
#include <cmath>
using namespace std;

int main() {
        int a, b;
        scanf("%d%d", &a, &b);
        printf("%d\n", (a % b == 0 ? 0 : 1));
        return 0;
}



Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
using namespace std;
int a[100005];
int main(){
	int n,t;
	cin>>n>>t;
	for(int i=0;i<n;i++) cin>>a[i];
	int maxn=-0x3f3f3f3f,temp=-0x3f3f3f3f;
	for(int i=n-1;i>=0;i--){
		temp=max(temp,a[i]);
		maxn=max(maxn,temp-a[i]);
	}
	temp=-0x3f3f3f3f;
	int cnt=0;
	for(int i=n-1;i>=0;i--){
		temp=max(a[i],temp);
		if(temp-a[i]==maxn){
			cnt++;
		}
	}
	//if(cnt<=t/2) cout<<cnt<<endl;
	//else cout<<t/2<<endl;
	cout<<cnt<<endl; 
} 

Measured memory_bytes: 640
#include<stdio.h>
int main(){
  int n1,n2,amari,x;
  scanf("%d%d",&n1,&n2);
  if(n1<n2){
    x=n1;
    n1=n2;
    n2=x;
  }
  while(1){
    amari=n1%n2;
    if(amari==0)
      break;
    n1=n2;
    n2=amari;
  }
  printf("%d\n",n2);
  return 0;
}



Measured memory_bytes: 2144
/*
    STARK_BOY
*/
#include <bits/stdc++.h>
#include <fstream>
using namespace std;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define repe(i,a,b) for(ll i=a;i<=b;i++)
#define bac(i,a,b) for(ll i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef long long ll;
typedef vector< ll > vi;
typedef vector<pair<ll,ll> > vpii;
typedef pair<ll,ll> pii;
#define all(c) c.begin(),c.end()
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define PI           3.14159265358979323846  /* pi */
mt19937 rng32(chrono::steady_clock::now().time_since_epoch().count());
#define N 1000005
//Variables Start
ll inf=1e18,MOD=1e9+7;
//Variables End


void solve(){
	ll x;cin>>x;
	ll intial = 100ll;
	int ans=0;
	while(intial < x){
		ans++;
		intial = 1.01*intial;
	}
	
	cout<<ans<<endl;
	
}
int main()
{
    ios
    int ti=1;
    //cin>>ti;
    for(int i=1;i<=ti;i++)
    {
		solve();        
    }
    return 0;
        
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
vector<ll> ans;

void f(ll x, int n)
{
	//cout << x << endl;
	if (n == 0) 
	{
		if (x != 0) ans.push_back(x);
		return;
	}
	if (x == 0)

	{
		rep(i,10)
		{
			f(i,n-1);
		}
	}
	else if (x % 10 == 0)
	{
		f(x*10,n-1);
		f(x*10+1,n-1);
	}
	else if (x % 10 == 9)
	{
		f(x*10+8,n-1);
		f(x*10+9,n-1);
	}
	else
	{
		f(x*10+(x%10-1),n-1);
		f(x*10+(x%10),n-1);
		f(x*10+(x%10+1),n-1);
	}
	return;
}

void init()
{
	f(0,9);
	f(1,9);
	f(2,9);
	f(3,9);
}

int main()
{
	init();
	int K;
	cin >> K;
	cout << ans[K-1] << endl;
	return 0;
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
typedef array<int,2> XY;

int main()
{
    int N;
    cin >> N;
    int xi, yi;
    vector<XY> X;
    for(int i=0;i<N;i++){
        cin >> xi >> yi;
        X.push_back(XY{xi, yi});
    }
    if(N==1){
        cout<<"1"<<endl;
        return 0;
    }

    map<XY, int> count;
    for(int i=0;i<N;i++){
        for(int j=i+1;j<N;j++){
            auto p = X[i][0] - X[j][0];
            auto q = X[i][1] - X[j][1];
            if(count.count(XY{p,q})==0) count[XY{p,q}]=0;
            if(count.count(XY{-p,-q})==0) count[XY{-p,-q}]=0;
            count[XY{p,q}]++;
            count[XY{-p,-q}]++;
        }
    }
    auto res = max_element(count.begin(), count.end(),
                            [](pair<XY, int> a, pair<XY, int> b){
                              return a.second < b.second;
                            }
                           )->second;
    cout << (N-res) << endl;

    return 0;
}

Measured memory_bytes: 384
#include <stdio.h>

/** Application main entry point. */
int main (
  int     argc,
  char  * argv[ ]
  )
{
  int i;

  for ( ; ; )
  {
    int res = 0;
    int n;

    scanf ( "%d", &n );
    if ( !( n ) ) break ;

    for ( i = 0; i < n * ( n - 1 ) / 2; ++i )
    {
      int d;

      scanf ( "%d", &d );
      res += d;
    }

    printf ( "%d\n", res / ( n - 1 ) );
  }

  return ( 0 );
}

Measured memory_bytes: 0
#include <stdio.h>
#include <string.h>
  
int main(void){
    char a[10];
    char b[1000];
    int j,count;
    count=0;
    scanf("%s",a);
    for(;;){
        scanf("%s",b);
        if(strcmp(b,"END_OF_TEXT")==0) break;
        for(j=0;j<1000;j++){
            if('A'<=b[j]&&b[j]<='Z') b[j]+=32;
        }
        if(strcmp(a,b)==0) count+=1;
    }
    printf("%d\n",count);
    return 0;
}


Measured memory_bytes: 2064
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;++i)
#include<string>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<int, int>P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//max=({});
//条件式が真ならwhileの中身を回し続ける
//printf("%d\n", ans);

//pairの入力
//vector<pair<ll, ll>>work(n);
//rep(i, n) {
//	ll a, b;
//	cin >> a >> b;
//	work[i] = make_pair(a, b);
//for(auto p:mp)(mapの探索)
//printf("%.10f\n",なんちゃら)

int g[15][15];
const int INF = 1001001001;
const int dx[4] = { -1,0,1,0 };
const int dy[4] = { 0,-1,0,1 };

//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

ll lcm(ll x, ll y) {
	if (x == 0 || y == 0)return 0;
	return (x / gcd(x, y) * y);
}

//素因数分解
vector<pair<ll, int>>factorize(ll n) {
	vector<pair<ll, int>>res;
	for (ll i = 2;i * i <= n;++i) {
		if (n % i)continue;
		res.emplace_back(i, 0);
		while (n % i == 0) {
			n /= i;
			res.back().second++;
		}
	}
	if (n != 1)res.emplace_back(n, 1);
	return res;
}

vector<ll>relation[20], money(20, 1);

int main() {
	int n, k;
	cin >> n >> k;
	vector<ll>a(n);
	rep(i, n) {
		cin >> a[i];
	}
	ll ans = 0;
	if (a[k - 1] > 0 && a[0] < 0) {
		ans += a[k - 1];
		ans += abs(a[0]);
		ans += min(abs(a[0]), abs(a[k - 1]));
	}
	else {
		ans += max(abs(a[0]), abs(a[k - 1]));
	}
	for (int i = 0;i < n - k;++i) {
		ll res = 0;
		if (a[i + 1] < 0 && a[k + i] > 0) {
			res += a[k + i];
			res += abs(a[i + 1]);
			res += min(abs(a[i + 1]), abs(a[k + i]));
		}
		else {
			res += max(abs(a[i + 1]), abs(a[k + i]));
		}
		ans = min(ans, res);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
import sys
from statistics import *
from collections import *
from operator import itemgetter

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()

n, a, b = na()
ct = 0
for i in range(1, n+1):
    num = str(i)
    s = 0
    for j in range(len(num)):
        s += int(num[j])
    if a <= s <= b:
        ct += i
print(ct)

Measured memory_bytes: 5148
from itertools import product
N, A, B, C = map(int, input().split())
l = [int(input()) for i in range(N)]
INF = 10 ** 9
t1 = set([0,1,2,3])
t2= set([1,2,3])
def calc(t):
    t3 = set(t)
    if not (t3 == t1 or t3 == t2): return INF
    a, b, c = 0, 0, 0
    cnt = 0
    for i, v in enumerate(t):
        if v != 0: cnt += 1
        if v == 1: a += l[i]
        elif v == 2: b += l[i]
        elif v == 3: c += l[i]
    return abs(a-A) + abs(b-B) + abs(c-C) + max((cnt-3) * 10, 0)


ans = 10 ** 9
for p in product(range(2), repeat=N*2):
    t = [0] * N
    for i in range(N):
        for j in range(2):
            t[i] += p[i*2+j] * (2 ** j)
    #print(t)
    ans = min(ans, calc(t))

print(ans)



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

#define NIL -1
#define MAX 25

class node{
public:
  int parent;
  int left;
  int right;
  int depth;
  int height;

  node(){
    parent = NIL;
    left = NIL;
    right = NIL;
    depth = NIL;
  }
};

node T[MAX];

void setDepth(int id, int d){
  T[id].depth = d;
  if(T[id].left != NIL) setDepth(T[id].left, d+1);
  if(T[id].right != NIL) setDepth(T[id].right, d+1);
}

int setHeight(int id){
  int h1 = 0;
  int h2 = 0;
  if(T[id].left != NIL) h1 = setHeight(T[id].left)  + 1;
  if(T[id].right!= NIL) h2 = setHeight(T[id].right) + 1;
  T[id].height = max(h1,h2);
  return T[id].height;
}

int getSibling(int id){
  if(T[id].parent == NIL) return NIL;
  if(T[T[id].parent].left != NIL && T[T[id].parent].left != id){
    return T[T[id].parent].left;
  }
  if(T[T[id].parent].right != NIL && T[T[id].parent].right != id){
    return T[T[id].parent].right;
  }
  return NIL;
}

int getDegree(int id){
  int ret = 0;
  if(T[id].left != NIL) ret++;
  if(T[id].right != NIL) ret++;
  return ret;
}

int main(){

  int n;
  scanf("%d", &n);

  for(int i=0; i<n; i++){
    int id, left, right;
    scanf("%d %d %d",&id,&left,&right);
    T[id].left = left != -1 ? left : NIL;
    T[id].right = right != -1 ? right : NIL;
    if(left != -1) T[left].parent = id;
    if(right != -1)T[right].parent = id;
  }

  // Find root id.
  int root;
  for(int i=0; i<n; i++){
    if(T[i].parent == NIL){
      root = i;
      break;
    }
  }

  // Calculate depth recurrently
  setDepth(root, 0);

  // Calculate height recurrently
  setHeight(root);

  //print result
  for(int i=0; i<n; i++){
    printf("node %d: ", i);
    printf("parent = %d, ", T[i].parent);
    printf("sibling = %d, ", getSibling(i));
    printf("degree = %d, ", getDegree(i));
    printf("depth = %d, ", T[i].depth);
    printf("height = %d, ", T[i].height);

    if(T[i].parent == NIL){
      printf("root\n");
    }
    else if(T[i].left != NIL || T[i].right != NIL){
      printf("internal node\n");
    }
    else{
      printf("leaf\n");
    }
  }

  return 0;
}



Measured memory_bytes: 3208
s = input() + 'R'


t = []
b = 0
for i in range(1, len(s)):
    if s[i - 1] + s[i] == 'LR':
        t.append(s[b:i])
        b = i

ans = []


for ss in t:
    nR = ss.find('L')
    nL = len(ss) - nR

    R = nR // 2 + (nR % 2) + nL // 2
    L = nL // 2 + (nL % 2) + nR // 2

    ans += [0 for _ in range(nR - 1)]+[R, L] + [0 for _ in range(nL - 1)]

for i in range(len(ans)):
    if i != 0:
        print(' ', end='')
    print(ans[i],end='')

Measured memory_bytes: 8612
#include<stdio.h>

int main()
{
	int a = 0, b = 0;
	while (a < b || a == b || a > b)
	{
		scanf("%d", &a);
		scanf("%d", &b);
		if (a == 0 && b == 0)
		{
			break;
		}
		if (a < b || a == b)
		{
			printf("%d", a);
			printf(" %d\n", b);
		}
		if (a > b)
		{
			printf("%d", b);
			printf(" %d\n", a);
		}

	}
	return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n;
	vector<int> a;
	while(cin>>n){
		if(n>=512){
			n-=512;
			a.push_back(512);
		}
		if(n>=256){
			n-=256;
			a.push_back(256);
		}
		if(n>=128){
			n-=128;
			a.push_back(128);
		}
		if(n>=64){
			n-=64;
			a.push_back(64);
		}
		if(n>=32){
			n-=32;
			a.push_back(32);
		}
		if(n>=16){
			n-=16;
			a.push_back(16);
		}
		if(n>=8){
			n-=8;
			a.push_back(8);
		}
		if(n>=4){
			n-=4;
			a.push_back(4);
		}
		if(n>=2){
			n-=2;
			a.push_back(2);
		}
		if(n==1){
			a.push_back(1);
		}
		sort(a.begin(),a.end());
		cout<<a[0];
		for(int i=1;i<a.size();i++){
			cout<<" "<<a[i];
		}
		cout<<endl;
		a.clear();
	}
	return 0;
}



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

// syntax sugar: `for (int i = 0; i < N; ++i)`
#define rep(i, N) for (int i = 0; i < (int)(N); ++i)
// syntax sugar: `for (int i = 0; i < N; ++i)`
#define REP(type, name, beginValue, endCondValue) \
  for (type name = beginValue; name < endCondValue; ++name)
// syntax sugar: 多次元vector
#define VECTOR_DIM3(T, name, d1, d2, d3, initValue) \
    std::vector<std::vector<std::vector<T>>> name(d1, std::vector<std::vector<T>>(d2, std::vector<int>(d3, initValue)));
#define VECTOR_DIM2(T, name, d1, d2, initValue) \
    std::vector<std::vector<T>> name(d1, std::vector<T>(d2, initValue));
#define VECTOR_DIM1(T, name, d1, initValue) \
    std::vector<T> name(d1, initValue);
#define ll long long
#define ld long double

int main(){
  int x, n;
  cin >> x >> n;
  vector<int> pi(n, 0);
  unordered_set<int> s;
  rep(i, n) {
    cin >> pi[i];
    s.insert(pi[i]);
  }
  if (n == 0) {
    cout << x << endl;
    return 0;
  }
  int ans = INT_MAX, ab = INT_MAX;
  for(int i = 0; i<= 101; ++i) {
    if (s.find(i) == s.end()) {
      int t = abs(i - x);
      if (t < ab) {
        ans = i;
        ab = t;
      } else if (t == ab) {
        if (ans > i) {
          ans = i;
        }
      }
    }
  }


  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define pb push_back
#define fi first
#define se second
#define pi pair<int, int>
#define rep(i, a, n) for(int i = a; i <= n; i++)
#define REP(i, a, n) for(int i = a; i < n; i++)
#define Y "YES"
#define N "NO"
using namespace std;

int d, s, t;

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	//freopen("in.txt", "r", stdin);
	
	cin >> d >> s >> t;
	if (s * t >= d) cout << "Yes";
	else cout << "No";
}

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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n; string s; cin>>n>>s;
	vector<int>cntr(26,0);
	for(auto&&i:s)++cntr.at(i-'a');
	vector<int>cntl(26,0);
	int ans=0;
	for(int i=0;i<n;++i){
		int c=s.at(i)-'a';
		++cntl.at(c),--cntr.at(c);
		int tans=0;
		for(int j=0;j<26;++j){
			if(cntl.at(j)&&cntr.at(j))++tans;
		}
		ans=max(ans,tans);
	}
	cout<<ans<<"\n"s;
}


Measured memory_bytes: 3656