akhauriyash/Code-Regression huggingface dataset:
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
  
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
  
using namespace std;
  
typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;
  
const int INF=1<<29;
const double EPS=1e-9;
  
const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};


int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }

  map<int,int> cnt;
  for (int i = 0; i < N; i++) {
    cnt[A[i]]++;
  }

  ll ans = 0;
  for(auto e: cnt) {
    if (e.first <= e.second) {
      ans += e.second - e.first;
    } else {
      ans += e.second;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 5120
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

class InverseTable:
    __slots__ = ['In', 'fac', 'Ifac']

    def __init__(self, mod, maxnum):
        self.In = [0, 1]; self.fac = [1, 1]; self.Ifac = [1, 1]
        for i in range( 2, maxnum + 1 ):
            self.In.append( ( -self.In[mod % i] * (mod//i) ) % mod )
            self.fac.append( ( self.fac[-1] * i ) % mod )
            self.Ifac.append( (self.Ifac[-1] * self.In[-1]) % mod )
        
    def cmb(self, n, r):
        if ( r<0 or r>n ): return 0
        r = min(r, n-r)
        over = 1
        for i in range(n,n-r,-1):
          over *= i; over %= mod
        
        return over * self.Ifac[r]  % mod
        # return self.fac[n] * self.Ifac[r] * self.Ifac[n-r] % mod
    
    def per(self, n, r):
        if ( r<0 or r>n ): return 0
        return self.fac[n] * self.Ifac[n-r] % mod

invt = InverseTable(mod, 10**6)
# maxnum=10**6だとテーブル生成に200ms程かかるので（Pythonだと1000msほど）
# 最大生成領域は問題ごとに要検討

from operator import mul
from functools import reduce

def cmb(n, r):
    r = min(n-r, r)
    if r == 0:
        return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1, r + 1))
    return over // under

def ncr(n, r):
    r = min(r, n - r)
    if r == 0: return 1;
    if r == 1: return n;
    numerator = [n - r + i + 1 for i in range(r)]
    denominator  = [i + 1 for i in range(r)]
    for p in range(2, r + 1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p - 1, r, p):
                numerator[k - offset] //= pivot
                denominator[k] //= pivot
    result = 1
    for k in range(r):
        if numerator[k] > 1: 
            result *= numerator[k]
            result %= mod
    return result

# N = 10000
# cnt = 0
# for a in xrange(N + 1):
#     cnt += ncr(N, a)

# print cnt == 2 ** N

n,a,b=map(int,input().split())
ans += pow(2,n,mod)-1
ans -= invt.cmb(n,a)
ans -= invt.cmb(n,b)
print(ans%mod)

Measured memory_bytes: 128328
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF (1e9)

int main() {
  map<char, ll> counter;
  ll n, second_condition; cin >> n;
  string s; cin >> s;
  second_condition = 0;
  counter['R'] = counter['G'] = counter['B'] = 0;

  for(int i = 0; i < n; i++) {
    counter[s[i]]++;
  }

  for(int i = 1; i <= (n-1)/2; i++) {
    for(int j = 0; 2*i + 1 + j <= n; j++) {
      if(s[j] != s[j + i] && s[j] != s[j + 2*i] && s[j + i] != s[j + 2*i]) second_condition++; 
    }
  }

  cout << counter['R'] * counter['G'] * counter['B'] - second_condition << endl;

  return 0;
}

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

typedef long long int ll;
#define INF 1999999999
#define MODA 1000000007

int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    s[3] = '8';
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <math.h>
using namespace std;

int main(){
	long double x1,y1,x2,y2;
	cin>>x1>>y1>>x2>>y2;
//	cout<<y1<<endl<<y2<<endl; 
//	cout<<x1<<endl<<x2;
//	cout<<(x2-x1)*(x2-x1)<<endl<<(y2-y1)<<endl;
//	long double f;
	printf("%.8lf", sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1)));
	
	return 0;
}


Measured memory_bytes: 3300
#include <bits/stdc++.h>
#define deb(x)     cerr << (#x) << " : " << (x) << "\n"
#define ll long long int
#define ld long double
#pragma warn +rvl
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
using namespace std;

struct mint {
  ll x;
  mint():x(0){}
  mint(ll x):x((x%MOD+MOD)%MOD){}
  // mint(ll x):x(x){}
  mint& fix() { x = (x%MOD+MOD)%MOD; return *this;}
  mint operator-() const { return mint(0) - *this;}
  mint operator~() const { return mint(1) / *this;}
  mint& operator+=(const mint& a){ if((x+=a.x)>=MOD) x-=MOD; return *this;}
  mint& operator-=(const mint& a){ if((x+=MOD-a.x)>=MOD) x-=MOD; return *this;}
  mint& operator*=(const mint& a){ (x*=a.x)%=MOD; return *this;}
  mint& operator/=(const mint& a){ (x*=a.ex(MOD-2).x)%=MOD; return *this;}
  mint operator+(const mint& a)const{ return mint(*this) += a;}
  mint operator-(const mint& a)const{ return mint(*this) -= a;}
  mint operator*(const mint& a)const{ return mint(*this) *= a;}
  mint operator/(const mint& a)const{ return mint(*this) /= a;}
  mint ex(ll t) const {
    if(!t) return 1;
    mint res = ex(t/2);
    res *= res;
    return (t&1)?res*x:res;
  }
  bool operator<(const mint& a)const{ return x < a.x;}
  bool operator==(const mint& a)const{ return x == a.x;}
};

mint ex(mint x, ll t) { return x.ex(t);}
istream& operator>>(istream&i,mint&a){i>>a.x;return i;}
ostream& operator<<(ostream&o,const mint&a){o<<a.x % MOD;return o;}

ll powmod(ll a, ll b, ll MOD = MOD){
	if(!a and !b)	return 1ll;
	if(!a)	return a;
	ll res = 1ll;
	b %= (MOD - 1ll), a %= MOD;
	while(b){
		if(b%2 == 1)	res = (res * a) % MOD;
		a = (a * a) % MOD;
		b /= 2;
	}
	return res;
}

ld dp[302][302][302];

int main(){	

 
	ios::sync_with_stdio(false);
	cin.tie(NULL);

	int n;
	cin >> n;
	int a = 0, b = 0, c = 0;

	for(int i = 0; i < n; i++){
		int tmp;
		cin >> tmp;
		if(tmp == 1)	a++;
		if(tmp == 2)	b++;
		if(tmp == 3)	c++;
	}

	ld m = n;
	dp[0][0][0] = 0;
	for(int k = 0; k <= n; k++){
		for(int j = 0; j <= n; j++){
			for(int i = 0; i <= n; i++){
				if(!i and !j and !k)	continue;
				if((i + j + k) > n)	continue;
				ld tmp = i + j + k;
				ld &res = dp[i][j][k];
				if(i){
					res += ((ld)i / tmp) * dp[i - 1][j][k];
				}
				if(j)	res += ((ld)j / tmp) * dp[i+1][j-1][k];
				if(k)	res += ((ld)k / tmp) * dp[i][j+1][k-1];
				res += m / tmp;
			}
		}
	}

	cout << setprecision(10) << fixed;
	cout << dp[a][b][c];
}	

Measured memory_bytes: 428288
#include<set>
#include<map>
#include<deque>
#include<queue>
#include<stack>
#include<cmath>
#include<ctime>
#include<bitset>
#include<string>
#include<vector>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<complex>
#include<iostream>
#include<algorithm>
#define ll long long
using namespace std;

const int maxn = 210000;

int n,m;
struct edge{int x,y;edge(){}edge(const int _x,const int _y){x=_x;y=_y;}};
inline bool operator <(const edge x,const edge y){return x.x==y.x?x.y<y.y:x.x<y.x;}

map<int,int>mp[maxn];
multiset<edge>q;
multiset<edge>::iterator it;
multiset<int>S[maxn];
multiset<int>::iterator it2;

int num[maxn];

int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++) num[i]=1;
	for(int i=1;i<=2*(n-1);i++)
	{
		int x,y; scanf("%d%d",&x,&y);
		mp[x][y]++; mp[y][x]++;
		if(mp[x][y]==2) q.insert(x<y?edge(x,y):edge(y,x));
		S[x].insert(y); S[y].insert(x);
	}
	for(int i=1;i<n;i++) 
	{
		it=q.begin(); if(it==q.end()) return puts("NO"),0;
		
		int x=(*it).x,y=(*it).y; q.erase(it);
		if(num[x]<num[y]) swap(x,y);
		num[x]+=num[y];
		
		for(it2=S[y].begin();it2!=S[y].end();it2++)
		{
			int k=(*it2); if(k==x) { S[x].erase(S[x].find(y));continue; }
			
			if(mp[y][k]==2) q.erase(q.find(y<k?edge(y,k):edge(k,y)));
			mp[y][k]--; mp[k][y]--;
			S[k].erase(S[k].find(y));
			
			if(mp[x].count(k)>0&&mp[x][k]==2) return puts("NO"),0;
			mp[x][k]++; mp[k][x]++;
			S[x].insert(k); S[k].insert(x);
			if(mp[x][k]==2) q.insert(x<k?edge(x,k):edge(k,x));
		}
	}
	puts("YES");
	
	return 0;
}


Measured memory_bytes: 72320
#include<bits/stdc++.h>
#define int long long
#define scf(n) scanf("%lld",&n)
#define rep1(n) for(int i=1;i<=n;i++)
#define prf(n) printf("%lld",n)
#define sci(n) scanf("%lld",&n)
#define pri(n) printf("%lld",n)

#define nl printf("\n")
#define spc printf(" ")
#define file freopen("in.txt","rt",stdin)
#define pii pair<int,int>
#define piii pair<pii,int>
#define MOD 10000007
using namespace std;

/*bool sortBySec(const pair<int,int> &a,const pair<int,int> &b)
{
    return (a.second < b.second);
}*/
void faster(void)
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
}
/******************************************/

/***********************************/
int n;
int dp[100009];
int arr[100009];
int DP(int pos)
{
    if(pos>=n)
    {
        return 0;
    }
    if(dp[pos]!=-1)
        return dp[pos];
    int a=9999999999,b=9999999999;
    if(pos+1<=n)
    a = abs(arr[pos]-arr[pos+1]) + DP(pos+1);
    if(pos+2<=n)
    b = abs(arr[pos]-arr[pos+2]) + DP(pos+2);
    dp[pos] = min(a,b);
    return dp[pos];
}
int32_t main()
{
    memset(dp,-1,sizeof dp);
    cin>>n;

    for(int i=1; i<=n; i++)
    {
        cin>>arr[i];
    }
    cout<<DP(1)<<endl;

    return 0;
}


Measured memory_bytes: 4992
#include <iostream>

using namespace std;

int n, m, ans, table[9][9];

int chack(){
	for(int i=0; i<n; i++){
		int tmp=0;
		for(int j=0; j<n; j++) tmp += table[i][j];
		if(tmp)	return 0;
	}
	return 1;
}


void solve(int x, int y){
	if(y < n-1) y++;
	else if(x < n-1){
		y=0;
		x++;
	}else {
		ans += chack();
		return;
	}
	
	if(y==0 && 0<x){
		int tmp =0;
		for(int i=0; i<n; i++) tmp +=table[x-1][i];
		if(tmp) return;
	}	

	if(table[x][y] == 0 && x != y){
		table[x][y] = 1;
		table[y][x] = -1;

		solve(x, y);

		table[x][y] = -1;
		table[y][x] = 1;
		solve(x, y);

		table[x][y] = table[y][x] = 0;
	} else solve(x, y);
}


int main(void) {
	while(1) {
		cin >> n;
		if(!n) break;
		fill(table[0], table[8], 0);
		cin >> m;
		for(int i=0; i<m; i++){
			int x, y; cin >> x >> y;
			x--; y--;
			table[x][y] = 1;
			table[y][x] = -1;
		}

		ans = 0;
		solve(0, 0);
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 3060
r, g, b, n = map(int,input().split())
ans = 0
x = n//min(r,g,b)

for i in range(x+1):
    for j in range(x+1):
        y = r*i + g*j
        if n-y >= 0 and (n-y)%b == 0:
            ans += 1

print(ans)

Measured memory_bytes: 41068
#include<cstdio>
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<algorithm>
#include<vector>
using namespace std;
#define rep2(x,from,to) for(int x=from;x<to;x++)
#define rep(x,to) rep2(x,0,to)
#define N 2000066
int n;
int now;
int nagasa;
int ans;
int doco[200006];
int hai[200006];
int before;
int after;
int main()
{
    cin>>n;
    rep(i,n)
    {
        cin>>hai[i];
        doco[hai[i]]=i;
    }
    rep2(i,1,n+1)
    {
        if(i==1)
        {
            nagasa=1;
            after=doco[i];
        }
        else
        {
            before=after;
            after=doco[i];
            if(before<after)nagasa++;
            else
            {
                ans=max(ans,nagasa);
                nagasa=1;
            }
        }
        if(i==n)ans=max(ans,nagasa);
    }
    cout<<n-ans<<endl;
    return 0;
}

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

class Main {
	static PrintStream out = System.out;
	static Scanner in = new Scanner(System.in);

	public static void main(String[] args) {
		int[] m = new int[6];
		for (int i = 0; i < 6; i++) {
			m[i] = in.nextInt();
		}

		int q = in.nextInt();

		for (int i = 0; i < q; i++) {
			Dice d = new Dice(m);
			int a = in.nextInt();
			int b = in.nextInt();
			int[] n;

			boolean	match = false;
			for (int l = 0; l < 4; l++) {
				d.moveE();
				for (int j = 0; j < 4; j++) {
					d.moveN();
					for (int k = 0; k < 4; k++) {
						d.moveE();
						n = d.getNo();
						if (n[0] == a && n[1] == b) {
							match = true;
							break;
						}
					}
					if (match) break;
				}
				if (match) break;
			}

			n = d.getNo();
			out.println(n[2]);
		}
	}

	private static class Dice {
		private int[] no;
		Dice(int[] no) {
			if (no.length != 6) throw new RuntimeException();
			this.no = Arrays.copyOf(no, no.length);
		}
		private void moveX(boolean rev) {
			int temp = no[0];
			if (rev) {
				no[0] = no[4];
				no[4] = no[5];
				no[5] = no[1];
				no[1] = temp;
			} else {
				no[0] = no[1];
				no[1] = no[5];
				no[5] = no[4];
				no[4] = temp;
			}
		}
		void moveN(){moveX(false);}
		void moveS(){moveX(true);}

		private void moveY(boolean rev) {
			int temp = no[0];
			if (rev) {
				no[0] = no[3];
				no[3] = no[5];
				no[5] = no[2];
				no[2] = temp;
			} else {
				no[0] = no[2];
				no[2] = no[5];
				no[5] = no[3];
				no[3] = temp;
			}
		}
		void moveW(){moveY(false);}
		void moveE(){moveY(true);}

		int[] getNo(){return Arrays.copyOf(no, no.length);};
	}
}

Measured memory_bytes: 17288
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using E = System.Linq.Enumerable;

class Program
{
    static void Main(string[] args)
    {
        //入力を受け取る
        var NK = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
        var N = NK[0];
        var K = NK[1];
      
        var ans = 0L;
      
      　//割る数を固定する
        for(int i = 1;i <= N ;i++){
          //iの倍数ごとのK以上の余りの数
          ans += (N/i)*Math.Max(i-K,0);
          if(N%i != 0){
            if(K==0){
              ans += Math.Max(N%i,0);
            }else{
              ans += Math.Max((N%i)-K+1,0);
            }
          }
          
        }
        Console.WriteLine(ans);
    }
}


Measured memory_bytes: 13396
import java.util.Scanner;

public class Main {
	public static void main (String args[]) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int m = scan.nextInt();
		int p[] = new int[n];
      	int s[] = new int[n];
      	
		int ok = 0;
		int ng = 0;
		
		for(int i = 0; i < m; i++) {
			int pn = scan.nextInt() -1;
			String sn = scan.next();
			if(p[pn] == 1) {
				continue;
			} else {
				if(sn.equals("AC")) {
					p[pn] = 1;
				} else {
					s[pn]++;
				}
			}
		}
		
		for(int i = 0; i < n; i++) {
			if(p[i] == 1) {
				ok++;
				ng = ng + s[i];
			}
		}
		
		System.out.println(ok + " " + ng);
	}
}

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

int main(){
	int a, b, c, d; cin >> a >> b >> c >> d;
	int e, f, g, h; cin >> e >> f >> g >> h;
	ll ans1 = a + b + c + d;
	ll ans2 = e + f + g + h;

	cout << max(ans1, ans2) << endl;
}


Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n,k,cnt=0;
    cin>>n>>k;
    vector<int>h(n);
    for(int i=0;i<n;i++){
        cin>>h[i];
        if(h[i]>=k) cnt++;
    }
    cout<<cnt<<endl;
}

Measured memory_bytes: 3688
#include <algorithm>
#include <iostream>
#include <set>
#include <vector>

using namespace std;

typedef long long ll;

template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

struct obs {
    int s;
    int t;
    int x;
};

vector<struct obs> obss;
vector<int> D;

struct person {
    int id;
    int d;
};

int main(void) {
    int N, Q;
    cin >> N >> Q;

    obss.resize(N);
    for (int i = 0; i < N; i++) {
        cin >> obss[i].s >> obss[i].t >> obss[i].x;
        obss[i].s = obss[i].s - obss[i].x;
        obss[i].t = obss[i].t - obss[i].x;
    }
    sort(obss.begin(), obss.end(), [](const struct obs &a, const struct obs &b) {
            return a.x < b.x;
            });

    D.resize(Q);
    for (int i = 0; i < Q; i++) {
        cin >> D[i];
    }

    auto comp = [](const struct person &a, const struct person &b) { return a.d < b.d; };

    set<struct person, decltype(comp)> people(comp);
    for (int i = 0; i < Q; i++) {
        people.insert({i, D[i]});
    }

    vector<int> ans(Q, -1);
    for (auto &obs : obss) {
        auto it = people.lower_bound({-1, obs.s});
        // printf("[%d, %d): %d\n", obs.s, obs.t, it != people.end() ? it->id : -1);

        set<struct person, decltype(comp)> should_delete(comp);

        while (it != people.end() && it->d < obs.t) {
            ans[it->id] = obs.x;
            should_delete.insert(*it);
            it++;
        }

        for (auto &p : should_delete) {
            people.erase(p);
        }
    }

    for (auto &x : ans) {
        cout << x << endl;
    }

    return 0;
}


Measured memory_bytes: 21248
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstring>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a, b, c;
	cin >> a >> b >> c;
	a -= b + c + c;
	int ans = 1;
	cout << ans + a / (b + c) << endl;
	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;using int32=int_fast32_t;using uint32=uint_fast32_t;using int64=int_fast64_t;using uint64=uint_fast64_t;using pi=pair<int32,int32>;using pll=pair<int64,int64>;using vi=vector<int32>;using vvi=vector<vector<int32>>;using vll=vector<int64>;using ll=int64;using ull=uint64;
#define all(x) x.begin(),x.end()
inline ll read(){ll x=0,f=1;char c=getchar();while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}while(c>='0'&&c<='9')x=x*10+c-'0',c=getchar();return x*f;}
inline string read_s(){string s="";char c=getchar();while(c<'!'||c>'~'){c=getchar();}while(c>='!'&&c<='~'){s+=c;c=getchar();}return s;}
void Main(){
    int a[5];
    a[0]=read();
    for(int i=0;i<4;i++){
        a[i+1] = read();
    }
    int k = read();
    if(k<a[4]-a[0]) printf(":(\n");
    else printf("Yay!\n");
}
int main(){cin.tie(nullptr);ios::sync_with_stdio(false);Main();return 0;}


Measured memory_bytes: 256
a,b,c,d = map(int,input().split())
i = 0
while True:
    if i % 2 == 0:
        c -= b
    else:
        a -= d
    if a <= 0:
        print ('No')
        break
    if c <= 0:
        print ('Yes')
        break
    i += 1


Measured memory_bytes: 9104
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;

public class Main {

	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		ArrayList<Long> height = new ArrayList<Long>();

		for (int i = 0; i < 10; i++) {
			String str = br.readLine();
			height.add(Long.valueOf(str));
		}

		Collections.sort(height, new Comparator<Long>() {

			@Override
			public int compare(Long o1, Long o2) {
				int ret = 0;
				if (o1 > o2) {
					ret = -1;
				} else if (o1 < 02) {
					ret = 1;
				}
				return ret;
			}
		});

		for (int i = 0; i < 3; i++) {
			System.out.println(height.get(i));
		}

	}

}



Measured memory_bytes: 24196
N=int(input())

import numpy as np

a=np.arange(N)
a=np.delete(a,0)

b=N-a

num_arr=[]

for i in range(len(a)):
	factor_a=[int(x) for x in list(str(a[i]))]
	factor_b=[int(x) for x in list(str(b[i]))]
	num_arr.append(sum(factor_a)+sum(factor_b))

print(min(num_arr))


Measured memory_bytes: 14720
#include "bits/stdc++.h"
#define rep(i, N) for(int (i) = 0; (i) < (N); (i)++)
#define debug(var) std::cout << #var << " : " << var << std::endl;
using ll = long long;
using ull = unsigned long long;
using vint = std::vector<int>;
using vvint = std::vector<std::vector<int>>;
using namespace std;
ll mod = 1e9 + 7;


int main() {


	int D, N; cin >> D >> N;
	if (N == 100)N++;
	int div = 1;
	rep(i, D)div *= 100;
	cout << div * N;


	return 0;
}

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

int main() {
  ios::sync_with_stdio(false);

  int N;
  cin >> N;

  long long A = 0, B = 0, ans = LLONG_MAX;

  vector<long long> vec(N);
  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
    A += vec.at(i);
  }

  for (int i = 0; i < N; i++) {
    B += vec.at(i);
    ans = min(ans, abs(B - (A - B)));
  }

  cout << ans << endl;
}

Measured memory_bytes: 1792
n = int(input())
b = input().split()
sum = int(b[0])
for i in range(n-2):
    if(int(b[i]) <= int(b[i+1])):
        sum += int(b[i])
    else:
        sum += int(b[i+1])
sum += int(b[n-2])        
print(sum)

Measured memory_bytes: 3064
import sys
from math import factorial

line = input()
N, M = (int(s) for s in line.split(' '))

total = 0
if N > 1:
  total += factorial(N) / factorial(N - 2) / 2
if M > 1:
  total += factorial(M) / factorial(M - 2) / 2

print(int(total))

Measured memory_bytes: 3064
a,b=map(int,input().split())
x=max(a/0.08,b/0.1)
y=min((a+1)/0.08,(b+1)/0.1)

if x<y:
    if x%1 != 0:
        print(int(x)+1)
    else:
        print(int(x))
else:
    print(-1)

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

int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> v(m, vector<int>(0));
  for(int i=0; i<n; i++) {
    int x;
    cin >> x;
    for(int j=0; j<x; j++) {
      int y;
      cin >> y;
      v[y-1].push_back(334);
    }
  }
  int count = 0;
  for(int i=0; i<m; i++) if(v[i].size() == n) count++;
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
using namespace std;
int a = 0;

string kigou;
int main(){
	cin >> kigou;
  	for(int i = 0; i<4;i++){
    	if(kigou[i]=='+'){
        	a++;
        }else if(kigou[i]=='-'){
        	a--;
        }
    }
  cout << a <<endl;
	
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

typedef long long lint;
typedef unsigned long long ulint;
#define MOD 1000000007

lint root(lint *uni, lint a){
    if(uni[a]<0) return a;
    return uni[a]=root(uni,uni[a]);
}
lint cnt(lint *uni, lint a){
    return -uni[root(uni,a)];
}
lint connect(lint *uni, lint ia, lint ib){
    lint a=root(uni, ia),b=root(uni, ib);
    if(a==b) return -a;
    if(uni[a]<uni[b]){
        uni[a]+=uni[b];
        uni[b]=a;
        return root(uni,a);
    }else{
        uni[b]+=uni[a];
        uni[a]=b;
        return root(uni,b);
    }
}

int main(){
    lint N,M;
    cin >> N >> M;
    lint A[50],B[50];
    for(int i=0;i<M;i++){
        lint a,b;
        cin >> a >> b;
        A[i]=a-1;
        B[i]=b-1;
    }
    lint uni[50];
    int ans=0;
    for(int e=0;e<M;e++){
        for(int i=0;i<N;i++) uni[i]=-1;
        for(int i=0;i<M;i++){
            if(i==e) continue;
            connect(uni,A[i],B[i]);
        }
        if(cnt(uni,0)!=N) ans++;
    }

    cout << ans << endl;

    return 0;
}

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

	public static void main(String[] args) {
		Scanner input=new Scanner(System.in);
	   String s=input.next();
	    long reminder,sum=0;
			
	    for(int i=0;i<s.length();i++)
			{
				int x=s.charAt(i)-'0';
				sum+=x;
		     }
			if(sum%9==0)
				System.out.println("Yes");
			else
				System.out.println("No");
 }

}

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

#define fi first
#define se second
#define mp make_pair
#define pb push_back
const int MOD = 1e9 + 7;
const int INF = 1e9;
const double EPS = 1e-9;
const double PI = acos(-1);
#define nl printf("\n");
#define _FAST ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull; 

int x, a, b, c;

int main() {
  cin>>a>>b>>c>>x;

  int banyakCara = 0;

  for (int i = 0; i <= a; ++i)
  {
  	
  	for (int j = 0; j <= b; ++j)
  	{
  		
  		for (int k = 0; k <= c; ++k)
  		{
  			if ( (500*i + 100*j + 50*k) == x) 
  			{
  				banyakCara++;
  			}
  		}

  	}

  }

  cout<< banyakCara << endl;


  return 0;
}




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

int		main(void)
{
	int n, m, x;

	cin >> n >> m >> x;
	vector<int> line(n + 1);
	vector<int> A(m);
	for (int i = 0; i < m; i++)
		cin >> A[i]; 
	for (int i = 0; i < m; i++)
		line[A[i]] = 1;
	int R = 0, L = 0;;

	for (int i = x; i > 0; i--)
		R += line[i];
	for (int i = x; i < n; i++)
		L += line[i];
	cout << min(R, L) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std ;
#define pb push_back
#define SZ(x) ((int)x.size())
const int N = 2010 ;

int vis[N], ok[N][N], in[N], a[N] ;
vector <int> g[N] ;
int n ;

void dfs(int rt) {
	vis[rt] = 1 ;
	for (int i = 1; i <= n; i++)
	if (!vis[i] && ok[rt][i]) {
		in[i]++ ;
		g[rt].pb(i) ;
		dfs(i) ;
	}
}

void Top() {
	priority_queue <int> q ;
	for (int i = 1;  i <= n; i++) if (!in[i]) q.push(i) ;
	while (!q.empty()) {
		int now = q.top() ;
		q.pop() ;
		cout << a[now] << " " ;
		for (int i = 0; i < SZ(g[now]); i++) q.push(g[now][i]) ;
	}
}

int main(){
	scanf("%d", &n) ;
	for (int i = 1; i <= n; i++) scanf("%d", &a[i]) ;
	sort(a + 1, a + n + 1) ;
	for (int i = 1; i <= n; i++)
	for (int j = i + 1; j <= n; j++)
	if (__gcd(a[i], a[j]) != 1) ok[i][j] = ok[j][i] = 1 ;
	for (int i = 1; i <= n; i++) if (!vis[i]) dfs(i) ;//连通块
	Top() ;//拓扑排序
}

Measured memory_bytes: 16256
# include <iostream>
# include <cstdio>
# include <vector>

using namespace std ;

int n ;
int a[200005] , cnt[1000005] ;
vector < int > divisor ;

int main()
{
	scanf("%d" , &n) ;
	for ( int i = 1 ; i <= n ; i++ )
	{
		scanf("%d" , a + i) , cnt[a[i]] ++ ;
	}
	int ans = 0 ;
	for ( int i = 1 ; i <= n ; i++ )
	{
		// printf("cal:%d\n" , i) ;
		bool flag=  true ;
		divisor.clear() ;
		for ( int j = 1 ; j * j <= a[i] ; j++ )
		{
			if ( a[i] % j == 0 )
			{
				divisor.push_back( j ) ;
				if ( j * j != a[i] ) divisor.push_back( a[i] / j ) ;
			}
		}
		for ( int j = 0 ; j < divisor.size() ; j++ )
		{
			if ( ! cnt[divisor[j]] ) continue ;
			if ( cnt[divisor[j]] == 1 && divisor[j] == a[i] ) continue ;
			flag = false ;
			break ;
		}
		if ( flag ) ans ++ ;
	}
	printf("%d\n" , ans) ;
	return 0 ;
}

Measured memory_bytes: 8368
#include <stdio.h>
int main() {
    int W,H,x,y,r;
    scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);
    if(x - r >= 0 && y - r >= 0 && x + r <= W && y + r <= H) {
        printf("Yes");
    } else {
        printf("No");
    }
    printf("\n");
    return 0;
}

Measured memory_bytes: 1852
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>
#include <iomanip>

using namespace std;

#define FAST       			ios_base :: sync_with_stdio(false); cin.tie(NULL); 
#define endl "\n"

typedef long long int  ll;


int main()
{
	FAST;
	int a,b,c;
	cin >> a >> b >> c;

	bool temp[101] = {false};
	
	int current = 0;
	while(temp[current] == false)
	{
		temp[current] = true;
		current = (current + a) % b;
	}

	if(temp[c])	cout << "YES";
	else		cout << "NO";

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  int alice=0, bob=0;
  for(int i=0; i<N; i++){
    cin >> a.at(i);
  }
  sort(a.begin(), a.end());
  reverse(a.begin(), a.end());
  for(int i=0; i<N; i++){
    if(i%2==0) alice+=a.at(i);
    if(i%2==1) bob+=a.at(i);
  }
  cout << alice-bob << endl;
  
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use std::char::*;
#[allow(unused_imports)]
use std::cmp::*;
use std::io::*;
use std::str::FromStr;
#[allow(unused_imports)]
use std::collections::*;

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

#[derive(PartialEq, PartialOrd)]
pub struct Total<T>(pub T);

impl<T: PartialEq> Eq for Total<T> {}

impl<T: PartialOrd> Ord for Total<T> {
    fn cmp(&self, other: &Total<T>) -> std::cmp::Ordering {
        self.0.partial_cmp(&other.0).unwrap()
    }
}

#[allow(dead_code)]
const MAX:usize = 100006;
#[allow(dead_code)]
const INF_U32:u32 = 1 << 31;
#[allow(dead_code)]
const INF_I32:i32 = 1 << 30;
#[allow(dead_code)]
const INF_U64:u64 = 1 << 63;
#[allow(dead_code)]
const INF_I64:i64 = 1 << 62;


fn main() {
    let a:u32 = read();
    let b:u32 = read();

    println!("{}", if a<9 && b<9 {"Yay!"} else {":("});

}


Measured memory_bytes: 4352
#include <iostream>
using namespace std;
int dp[3400][3400];
char input[3400][3400];
int mod = 1000000007;
int main() 
{
	int H, W;
   	cin >> H >> W;

   	for (int i = 0; i < H; ++i)
   	{
   		for (int j = 0; j < W; ++j)
   		{
   			char a;
   			cin >> a;
   			input[i][j] = a;
   		}
   	}

   	for (int i = H; i >= 0; i--)
   	{
   		for (int j = W; j >=0; j--)
   		{
   			if(i == H-1 && j == W-1)
   				dp[i][j] = 1;
   			else if (i == H || j == W)
   			{
   				dp[i][j] = 0;
   			}
   			else if(input[i][j] == '#')
   				dp[i][j] = 0;
   			else if(input[i][j] == '.')
   				dp[i][j] = (dp[i+1][j] + dp[i][j+1]) % mod;
   		}
   	}

   	int ans = dp[0][0] % mod;
   	cout << ans;

    return 0;
}

Measured memory_bytes: 20736
#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 <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define each(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll inf =1LL << 62;

int dp[1010][1010];
int v[1010];
int w[1010];

int main(void){
	int W,N;
	int num=1;
	while(cin >> W,W){
		clr(dp,-1);
		dp[0][0]=0;
		cin >> N;
		char tmp;
		rep(i,N)
			cin >> v[i+1] >> tmp >> w[i+1];
		for(int i=1;i<=N;i++){
			for(int j=W;j>=0;j--){
				if(j-w[i]>=0)
					dp[i][j]=max(dp[i-1][j],dp[i-1][j-w[i]]+v[i]);
				else
					dp[i][j]=dp[i-1][j];
			}
		}
		int vans=0,wans=0;
		rep(i,W+1){
			if(dp[N][i]>vans){
				vans=dp[N][i];
				wans=i;
			}
		}
		cout << "Case " << num << ":" << endl;
		cout << vans << endl;
		cout << wans << endl;
		num++;
	}
	return 0;
}

Measured memory_bytes: 5160
#include<bits/stdc++.h>
using namespace std;
int main(){
int n;cin>>n;
int a[100];
for(int j=0;j<n;j++) cin>>a[j];
int ans=1e9;
for(int i=-100;i<101;i++){
  int cnt=0;
  for(int j=0;j<n;j++){
    cnt+=(a[j]-i)*(a[j]-i);
  }
  ans=min(ans,cnt);
}
cout<<ans<<endl;
}


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

using namespace std;

int n;
int a[101];
double ans = 0;

int main()
{
    int n;
    scanf("%d",&n);
    for(int i = 1;i <= n;i++)
    {
        scanf("%d",&a[i]);
        ans += 1.0 / a[i];
    }
    ans = 1.0 / ans;
    printf("%.8f",ans);
    return 0;
}


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

using namespace std;

int main() {
    int a ,b ,c;
    cin>>a>>b>>c;
    int freq[20]={};
    freq[a]++;
    freq[b]++;
    freq[c]++;
    if(freq[5]>=2&&freq[7]>=1){
        cout<<"YES";
    }
    else
        cout<<"NO";
    cout<<endl;
    return 0;
}


Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <climits>
#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 <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <cctype>
#include <complex>
#include <regex>

using namespace std;

int main() {

    int N;
    cin >> N;

    vector<int> v(N);
    for (int i = 0; i < N; i++) cin >> v[i];

    map<int, int> even;
    map<int, int> odd;

    for (int i = 0; i < N; i++) {
        if (i % 2 == 0) even[v[i]]++;
        if (i % 2 == 1) odd[v[i]]++;
    }

    vector<pair<int, int>> evenP;
    vector<pair<int, int>> oddP;

    for (auto x: even) evenP.push_back(make_pair(x.second, x.first));
    for (auto x: odd) oddP.push_back(make_pair(x.second, x.first));
    evenP.push_back(make_pair(0, 1000010));
    oddP.push_back(make_pair(0, 1000020));

    sort(evenP.begin(), evenP.end());
    reverse(evenP.begin(), evenP.end());
    sort(oddP.begin(), oddP.end());
    reverse(oddP.begin(), oddP.end());

    if (evenP[0].second != oddP[0].second) {
        int half = N / 2;
        int ans = (half - evenP[0].first) + (half - oddP[0].first);
        cout << ans << endl;
    } else {
        int half = N / 2;
        int ans1 = (half - evenP[0].first) + (half - oddP[1].first);
        int ans2 = (half - evenP[1].first) + (half - oddP[0].first);
        cout << min(ans1, ans2) << endl;
    }

    return 0;
}
































Measured memory_bytes: 6520
#include <unistd.h>
#include <stdlib.h>

char    *create_array(char *s, char *new_arr, char *t, int size)
{
	int i;
	int j;

	i = -1;
	while (s[++i])
		new_arr[i] = s[i];
	free(s);
	j = 0;
	while (j < size)
		new_arr[i++] = t[j++];   
	new_arr[i] = 0;
	return (new_arr);
}

char    *get_data(char *s)
{
	int     size;
	int     sum_size;
	char    t[1000];
	char    *new_arr;

	sum_size = 0;
	while ((size = read(0, t, 1000)))
	{
		if (size == -1)
			return (NULL);
		sum_size += size;
		if (!(new_arr = (char*)malloc(sum_size + 1)))
			return (NULL);
		s = create_array(s, new_arr, t, size);
	}
	return (s);
}

void    write_num(int num)
{
	char c;

	if (num < 10)
	{
		c = num + '0';
		write(1, &c, 1);
	}
	else
	{
		write_num(num / 10);
		write_num(num % 10);
	}
}

int     get_num(char *s, int pass_flag)
{
	int i;
	int num;
	int count;
	
    count = 0;
	i = 0;
	while (count++ < pass_flag)
		while (s[i++] != 10)
			;
	num = 0;
	while ('0' <= s[i] && s[i] <= '9')
		num = num * 10 + s[i++] - '0';
	return (num);
}

char    *get_string(char *tmp, int pass_flag)
{
	int     i;
	int     j;
	int     k;
	int     count;
	char    *new_arr;

    count = 0;
	i = 0;
	while (count++ < pass_flag)
		while (tmp[i++] != 10)
			;
	j = 0;
	while (31 < tmp[i + j] && tmp[i + j] < 127)
		j++;
	if (!(new_arr = (char*)malloc(j + 1)))
	    return (NULL);
	k = -1;
	while (++k < j)
		new_arr[k] = tmp[i + k];
	new_arr[k] = 0;
	return (new_arr);
}

char    **get_strings(char *tmp, int pass_flag, int size)
{
	int     i;
	int     j;
	int     count;
	char    **new_arr;

	if (!(new_arr = (char**)malloc(sizeof(char*) * (size + 1))))
	    return (NULL);
	count = 0;
	i = 0;
	while (count++ < pass_flag)
		while (tmp[i++] != 10)
			;
	j = -1;
	while (++j < size)
		if(!(new_arr[j] = get_string(&tmp[i], j)))
		    return (NULL);
	new_arr[j] = 0;
	return (new_arr);
}

void    all_free(int blue_num, char **blue, int red_num, char **red)
{
	int i;

	i = -1;
	while (++i < blue_num)
		free(blue[i]);
	i = -1;
	while (++i < red_num)
		free(red[i]);
	free(blue);
	free(red);
}

int     ft_strcmp(char *s1, char *s2)
{
        while (*s1++ == *s2++)
                if (!*s1 && !*s2)
                        return (0);
        return (*(s1 - 1) - *(s2 - 1));
}

void    get_ans(int blue_num, char **blue, int red_num, char **red)
{
	int i;
	int j;
	int max;
	int count;

	max = 0;
	i = -1;
	while (++i < blue_num)
	{
		count = 1;
		j = i;
		while (++j < blue_num)
			if (!(ft_strcmp(blue[i], blue[j])))
				count++;
		j = -1;
		while (++j < red_num)
			if (!(ft_strcmp(blue[i], red[j])))
				count--;
		if (max < count)
			max = count;
	}
	write_num(max);
}

int     main(void)
{
	char    *s;
	int     blue_num;
	char    **blue;
	int     red_num;
	char    **red;

	s = malloc(1);
	if (!(s = get_data(s)))
	    return (-1);
	blue_num = get_num(s, 0);
	if (!(blue = get_strings(s, 1, blue_num)))
	    return (-1);
	red_num = get_num(s, blue_num + 1);
	if (!(red = get_strings(s, blue_num + 2, red_num)))
	    return (-1);
	get_ans(blue_num, blue, red_num, red);
	free(s);
	all_free(blue_num, blue, red_num, red);
	return (0);
}


Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<cstdio>
#include<queue> 
using namespace std;
int main(){
//	freopen("x.txt","r",stdin);
	int n;
	cin>>n;
	cout<<n/500*1000+n%500/5*5<<endl; 
	return 0;
}

Measured memory_bytes: 3612
#include <iostream>
#include <cstdio>
#include <string>
#include <sstream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <queue>
using namespace std;

int main() {
    vector<int> N(3);
    cin>>N[0]>>N[1]>>N[2];
    
    sort(N.begin(), N.end());
    
    int ans=N[0]+N[1];
    
    cout << ans << endl;
}


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

int main() {
  int k,a,b;
  cin >> k >> a >> b;
  if (a % k == 0) {
    cout << "OK";
  } else if ( ( k - (a % k) ) + a <= b ) {
    cout << "OK";
  } else {
    cout << "NG";
  }
}


Measured memory_bytes: 3584
function main()
  
  (N,M) = map(x -> parse(Int,x), split(readline()))
  
  L_max = 0
  R_min = 10^9
  
  for i in 1:M
    (L,R) = map(x -> parse(Int,x), split(readline()))
    L_max = max(L_max,L)
    R_min = min(R_min,R)
  end
  
  println(max(R_min - L_max + 1, 0))
  
end

main()

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

int main(void)
{
	while(true){
		int n, m;
		int tarou_sum = 0, hanako_sum = 0;
		int tarou_changed_sum, hanako_changed_sum;
		cin >> n >> m;
		if(n == 0 && m == 0) break;
		vector<int> tarou(n), hanako(m);
		for(int i = 0; i < n; i++){
			cin >> tarou[i];
			tarou_sum += tarou[i];
		}
		for(int i = 0; i < m; i++){
			cin >> hanako[i];
			hanako_sum += hanako[i];
		}

		bool found = false;
		int tarou_answer, hanako_answer;
		for(int i = 0; i < n; i++){
			for(int j = 0; j < m; j++){
				tarou_changed_sum = tarou_sum - tarou[i] + hanako[j];
	 			hanako_changed_sum = hanako_sum - hanako[j] + tarou[i];
	 			if(tarou_changed_sum == hanako_changed_sum){
	 				if(found){
	 					if(tarou_answer + hanako_answer > tarou[i] + hanako[j]){
	 						tarou_answer = tarou[i];
	 						hanako_answer = hanako[j];
	 					}
	 				}else{
	 					found = true;
	 					tarou_answer = tarou[i];
	 					hanako_answer = hanako[j];
	 				}
	 			}else{
	 				continue;
	 			}


			}
		}

		if(found){
			cout << tarou_answer << ' ' << hanako_answer << endl;
		}else{
			cout << -1 << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#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 INF 2e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;

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

int main()
{
	int x, y;
	cin >> x >> y;

	if (x % y == 0) cout << -1 << endl;
	else cout << x << endl;
}


Measured memory_bytes: 256
n,m = map(int,input().split())
x = list(map(int,input().split()))
x = sorted(x)

dx = [ x[i+1] - x[i] for i in range(0, len(x)-1) ]
if n >= m:
    ans = 0
else:
    ans = sum(sorted(dx)[:m-n])
print(ans)

Measured memory_bytes: 13968
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#define ll long long
#define ull unsigned long long
#define dd double
#define oo 1001007000
#define ff float
#define ooo 1000000100000000000
#define iii pair<ll,ll>
#define vii vector<ll>
#define viii vector<iii>
#define sss pair<str,str>
#define str string
#define sii set<ll>
#define siii set<iii>
#define st size_t
#define r0 return 0
#define pb push_back
#define sz size
using namespace std;

const char E='\n';
const int N=2015;
const int NN=1000001;
const ll md=998244353;


int main(){
    cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);
    int k;
    cin >> k;
    str s="1";
    if (k==1){
        cout << s << E;
        r0;
    }
    int n=1;
    for (int i=2;i<=k;i++){
        int pos=-1;
        for (int j=0;j<n-1;j++){
            if (s[j]!='9' && s[j]+1<=s[j+1]+1){
                pos=j;
                break;
            }
        }
        //cout << pos << "=";
        if (pos!=-1){
            s[pos]++;
            for (int j=pos-1;j>=0;j--){
                s[j]=max(s[j+1]-1,int('0'));
            }
        }else
        if (pos==-1 && s[n-1]!='9'){
            s[n-1]++;
            for(int j=n-2;j>=0;j--){
                s[j]=max(s[j+1]-1,int('0'));
            }
        }else
        if (pos==-1 && s[n-1]=='9'){
            n++;
            s="";
            for (int j=1;j<n;j++){
                s+='0';
            }
            s+='1';
        }
        //cout << s << E;
    }
    reverse(s.begin(),s.end());
    cout << s << E;
    r0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(a,b) for(int a=0; a<(b); ++a)
#define FWD(a,b,c) for(int a=(b); a<(c); ++a)
#define FWDS(a,b,c,d) for(int a=(b); a<(c); a+=d)
#define BCK(a,b,c) for(int a=(b); a>(c); --a)
#define ALL(a) (a).begin(), (a).end()
#define SIZE(a) ((int)(a).size())
#define VAR(x) #x ": " << x << " "
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll
#define gcd __gcd
#define x first
#define y second
#define st first
#define nd second
#define pb push_back

using namespace std;

template<typename T> ostream& operator<<(ostream &out, const vector<T> &v){ out << "{"; for(const T &a : v) out << a << ", "; out << "}"; return out; }
template<typename S, typename T> ostream& operator<<(ostream &out, const pair<S,T> &p){ out << "(" << p.st << ", " << p.nd << ")"; return out; }

typedef long long LL;
typedef pair<int, int> PII;
typedef long double K;
typedef vector<int> VI;

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

int n, m;

int main(){
	scanf("%d", &n);
	FWD(i,0,n){
		int a;
		scanf("%d", &a);
		if(a&1) ++m;
	}
	printf((m&1)?"NO\n":"YES\n");
	return 0;
}


Measured memory_bytes: 384
#!python3.4.3
import statistics
from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN

n = int(input())
x_list = list(map(int, input().split(' ')))

mean = statistics.mean(x_list)
mean = Decimal(str(mean)).quantize(Decimal('0'), rounding=ROUND_HALF_UP)
result = 0


for x in x_list:
  result += (x - mean)**2
  
print(result)

Measured memory_bytes: 5788
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
typedef long long ll;

int main(){
    string x ; 
    cin >> x ; 
    stack<int> s ; 
    int cnt = 0 ;
    for(int i=0;i<(int)x.size();i++){
    	int digit = x[i] - '0' ; 
    	debug() << imie(digit) ; 
    	if ( s.empty() ) s.push(digit);
    	else if ( s.top() == !digit ){
    		s.pop() ; 
    		cnt += 2 ; 
    	}
    	else{
    		s.push(digit) ; 
    	}
    }
    cout << cnt << endl;
    return 0 ;
}


Measured memory_bytes: 768
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set> 
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <iomanip>
using namespace std;
#define assem99 ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define ull unsigned long long
#define ld long double
#define ii pair<int, int>
#define pll pair<ll, ll>
#define vii vector<ii>
#define rep(i,a,b) for(int i=a; i<b; i++)
#define F first
#define S second
#define sz(a) (int)(a).size()
#define ReadFile freopen("input.txt","r",stdin)
#define WriteFile freopen("output.txt","w",stdout)
int x[] = { 0, -1, 0, 1, -1, 1, -1, 1 };
int y[] = { -1, 0, 1, 0, 1, -1, -1, 1 };
const int MOD = 1e9 + 7, N = 2e5 + 5;
const double pi = acos(-1);

int main()
{
	assem99;
	int n; cin >> n;
	int mx = 0;
	map<string, int> mp;
	rep(i, 0, n)
	{
		string s; cin >> s;
		mp[s]++;
		mx = max(mx, mp[s]);
	}
	for (auto it : mp) if (it.S == mx) cout << it.F << endl;

	return 0;
}


Measured memory_bytes: 23808
#include<iostream>
#include<queue>


using namespace std;
static const int N = 100;
static const int INFTY = (1<<21);

int n, M[N][N];
int d[N];

void bfs(int s) {
    queue<int> q;
    q.push(s);
    for ( int i = 0; i < n; i++) d[i] = INFTY;
    d[s] = 0;
    int u;
    while ( !q.empty() ) {
        u = q.front(); q.pop();
        for (int v = 0; v < n; v++) {
            if (M[u][v] == 0) continue;
            if (d[v] != INFTY) continue;
            d[v] = d[u] + 1;
            q.push(v);
        }
    }
    for ( int i = 0; i < n; i++) {
        cout << i+1 << " " << ( (d[i] == INFTY) ? (-1) : d[i] ) << endl;
    }
}


int main() {
    int u, k, v;

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

    for (int i = 0; i < n; i++){
        cin >> u >> k;
        u--;
        for (int j = 0; j < k; j++) {
            cin >> v;
            v--;
            M[u][v] = 1;
        }
    }

    bfs (0);

    return 0;
}

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

using namespace std;

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

int diri(int a, int d, int n) {
	int sum = 0;
	if(a == 1) {
		sum--;
	}

	while(1) {
		if(prime(a)) {
			sum++;
		}

		if(sum == n) {
			return a;
		}

		a += d;
	}
}

int main(void) {
	int a, d, n;
	while(1) {
		cin >> a >> d >> n;
		if(a == 0 and d == 0 and n == 0) {
			break;
		}

		int result = diri(a, d, n);
		cout << result << endl;
	}
	return 0;
}

Measured memory_bytes: 3000