akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;


int main(){


    string d, t, s, k, g;
    
    int i, j, f, ch;

    vector<string> a;


    cin >> d >> t;


    if( d.size() < t.size()  ){

        cout << "UNRESTORABLE" << endl;

        return 0;

        }


    for( i = 0 ; i <= d.size() - t.size() ; i = i + 1 ){

         k = d.substr( i, t.size() );

         ch = 1;

         for( j = 0 ; j < t.size() ; j = j + 1 ){

              if( k.at(j) != t.at(j) && k.at(j) != '?' ){

                  ch = 0;

                  }

              }

         if( ch == 1 ){        

             g = d.substr( 0, i ) + t + d.substr( i + t.size() , d.size() - t.size() - i );

             for( f = 0 ; f < g.size() ; f = f + 1 ){

                  if( g.at(f) == '?' ) g.at(f) = 'a' ;

                  }

             a.push_back(g);

             }

         }


    if( a.size() == 0 ){

        cout << "UNRESTORABLE" << endl;

        return 0;

        }


    sort( a.begin(), a.end() );


    cout << a.at(0) << endl;


    return 0;

    }


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const long long INF = 1LL << 60;
const int mod = 1e9 + 7;

int main()
{
    ll n, ans = 0;
    cin >> n;
    for (ll i = 0; i < n; i++)
    {
        if ((i + 1) % 3 == 0 || (i + 1) % 5 == 0)
        {
            continue;
        }
        else
        {
            ans += (i + 1);
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3588
from collections import defaultdict

blue = defaultdict(int)
red = defaultdict(int)

for i in range(int(input())):
    blue[input()] += 1

for i in range(int(input())):
    red[input()] +=1

max_key = max(blue.items(), key=lambda x:x[1]-red[x[0]])[0]

print(max(0, blue[max_key]-red[max_key]))

Measured memory_bytes: 3316
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;



int main() {
	while (1) {
		int n; cin >> n; if (n==0) break;
		
		int W, H; cin >> W >> H;
		
		vector<int> X(n), Y(n);
		for (int i=0; i<n; i++) cin >> X[i] >> Y[i];
		
		int S, T; cin >> S >> T;
		
		int ans = 0;
		for (int x = 1; x <= W - S + 1; x++) {
			for (int y = 1; y <= H - T + 1; y++) {
				
				int cnt = 0;
				for (int i = 0; i<n; i++) {
					if (x <= X[i] && X[i] <= x+S-1 && y <= Y[i] && Y[i] <= y+T-1) cnt++;
				}
				ans = max(ans, cnt);
			}
		}
		
		cout << ans << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1196
#include <iostream>
#include <algorithm>
#include <iterator>
#include <string>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <functional>
#include <cctype>
#include <climits> // INT_MAX ...
#include <cstring> // 

using namespace std;

int main() {
	int n;
	cin >> n;
	vector<int> p(n);
	for (int &x : p) cin >> x;
	int mn = p[0], ans = 0;
	for (int &x : p) {
		if (x <= mn) {
			ans++;
			mn = min(mn, x);
		}

	}
	cout << ans << endl;


	return 0;
}


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

using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector <string> vs;

#define forl(i,a,b) for (int i = a; i < b; i++)
#define rfor(i,b,a) for (int i = b; i >= a; i--)
#define f first
#define s second
//#define pb push_back
#define mp make_pair
#define srt(x) sort(x.begin(), x.end())
#define sumup(x) accumulate(x.begin(), x.end(), 0)
#define PI 3.141592653589793238
#define MOD 1000000007

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n; cin>>n;
    n = 1000 - n%1000;
    if(n==1000) {cout<<0<<"\n"; return 0;}
    cout<<n<<"\n";
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
#include <queue>
#include <cstring>

#define mp make_pair
#define pb push_back
#define p push

#define FOR(a, c) for(int a = 0;a<c;a++)
#define ll long long int

#define getI(a) scanf("%d",&a)
#define getII(a, b) scanf("%d%d",&a,&b)
#define getIII(a, b, c) scanf("%d%d%d",&a,&b,&c)
#define getL(a) scanf("%lld",&a)
#define getLL(a, b) scanf("%lld%lld",&a,&b)
#define getLLL(a, b, c) scanf("%lld%lld%lld",&a,&b,&c)
#define BEND(c) (c).begin(),(c).end()
#define BEND2(c) (c).rbegin(),(c).rend()
#define fi first
#define se second
#define pi 3.1415926535897932384626
#define getS(a) scanf("%s",a)
#define pfi(a) printf("%d",a);
#define pfii(a, b) printf("%d%d",a,b);
#define pfl(a) printf("%lld",a);
#define pfll(a, b) printf("%lld%lld",a,b);
#define pfd(a) printf("%lf",a);
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);

#define sag (sol|1)
#define sol (root<<1)
#define ort (bas+son)/2
#define SIZE  ( int)(1e9 + 7)
#define MAXN (ll) (1e5+5)

using namespace std;

typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector <vector<int>> vvi;
typedef vector<long long> vl;
typedef vector <pair<int, int>> vpi;
typedef vector <pair<long long, long long>> vpl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector <vi> graph;
int ar[1000000]={1};
void func (){
    for (int i = 1; i <1000000; ++i) {
        ar[i]=(31*ar[i-1]);
    }

}
int rabin (string s , string t){
    int bas = 31;

    int hasht =0;
    for (int i = 0; i <t.size() ; ++i) {
        hasht=(hasht +  ( (ar[i]) * (t[i] - 'a' + 1 )));
    }
    vi pre(s.size(),0);
    for (int j = 0; j <s.size() ; ++j) {
        if(j == 0){
            pre[j] = s[j] -'a' +1;
            continue;
        }

        pre[j] = ( pre[j-1] + (ar[j]) * (s[j]- 'a' + 1)) ;

    }
    int ans =0;
    for (int k = 0; k <= s.size() -t.size() ; ++k) {

        if ( k == 0){
            if(pre[t.size()-1] == hasht)ans++;
            continue;
        }
        //cout << (hasht *  ar[k]);
        //cout <<" "<<pre[k+t.size()-1] - pre[k-1] <<endl;
        if(((hasht *  ar[k]) ) == (pre[k+t.size()-1] - pre[k-1] ) )ans++;
    }
    return ans;

}


int main(){
    IOS
    func();
        ll n ;
        cin >>n;
        string s;
        string t= "ABC";
        cin >>s;


        ll ans = rabin(s,t);




        cout <<ans<<"\n";



    return 0;
}

Measured memory_bytes: 4224
x,n= map(int,input().split())
p = list(map(int,input().split()))
ans,i = 0,0

while True:
    if x-i not in p:
        ans = x-i
        break
    if x+i not in p:
        ans = x+i
        break
    i = i+1
    
print(ans)

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

vector<vector<int>> make_array(int min_n, int max_n, int length) {
    vector<vector<int>> ans;
    if (length == 1) {
        for (int i = min_n; i < max_n; i++) {
            ans.push_back({i}); 
        }
    }
    else {
        for (int i = min_n; i < max_n; i++){
            vector<vector<int>> ans_sub = make_array(i, max_n, length-1);
            for (int j = 0; j < ans_sub.size(); j++){
                ans_sub[j].insert(ans_sub[j].begin(), {i});
                ans.push_back(ans_sub[j]);
            }
        }
    }
    return ans;
}


int main(){
    int N, M, Q;
    cin >> N >> M >> Q;
    vector<int> a(Q);
    vector<int> b(Q);
    vector<int> c(Q);
    vector<int> d(Q);
    for (int i = 0; i < Q; i++){
        cin >> a[i] >> b[i] >> c[i] >> d[i];
    }
    
    vector<vector<int>> ans_array = make_array(1, M+1, N);

    int ans_max = 0;
    for (int i = 0; i < ans_array.size(); i++){
        int ans = 0;
        if (ans_array[i][0] != 1) break;
        for (int j = 0; j < Q; j++){
            if (ans_array[i][b[j]-1] - ans_array[i][a[j]-1] == c[j]) {
                ans += d[j];
            }
        }
        ans_max = max(ans, ans_max);
    }
    cout << ans_max << endl;
}




Measured memory_bytes: 12872
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define FASTINOUT ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const ll mod = 1e9+7;
const int N=2e5+9;
int main()
{
    FASTINOUT;
    int x;
    cin>>x;
    int y[x];
    for (int i=0;i<x;i++)
        cin>>y[i];
    sort(y,y+x);
    cout<<y[x/2]-y[x/2-1];
    return 0;
}


Measured memory_bytes: 640
from collections import Counter
n = int(input())
vl = [int(i) for i in input().split()]
oc = Counter(a for i, a in enumerate(vl) if i % 2 == 0)
ec = Counter(a for i, a in enumerate(vl) if i % 2 == 1)
ol = sorted(((v, k) for k, v in oc.items()), reverse=True)
el = sorted(((v, k) for k, v in ec.items()), reverse=True)

if ol[0][1] != el[0][1]:
    print(n - ol[0][0] - el[0][0])
else:
    res = 1 << 30
    if len(ol) == len(el) == 1:
        res = n // 2
    if len(ol) > 1:
        res = min(res, n - ol[1][0] - el[0][0])
    if len(el) > 1:
        res = min(res, n - ol[0][0] - el[1][0])
    print(res)

Measured memory_bytes: 23008
#include<bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define repk(i,k,n) for (ll i = k; i < (ll)(n); ++i)
#define INF 5000000010
#define MOD 1000000007
typedef long long  ll;

using namespace std;

vector<ll> ans;
map<ll, vector<ll>> m;
queue<ll> q;

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

	ll N, M;
	cin >> N >> M;

	ans.assign(N, INF);

	vector<ll> A(M), B(M);
	rep(i, M) {
		cin >> A[i] >> B[i];
		A[i] --;
		B[i] --;

		m[A[i]].push_back(B[i]);
		m[B[i]].push_back(A[i]);
	}

	q.push(0);
	ans[0] = 0;
	while (q.size()) {
		ll index = q.front();
		q.pop();
		rep(i, m[index].size()) {
			if (ans[m[index][i]] == INF) {
				ans[m[index][i]] = index + 1;
				q.push(m[index][i]);
			}
		}
	}

	bool flg = true;
	rep(i, N) {
		if (ans[i] == INF) {
			flg = false;
		}
	}


	if (flg) {
		cout << "Yes" << endl;
		repk(i, 1, N) {
			cout << ans[i] << endl;
		}
	}
	else {
		cout << "No" << endl;

	}
	

	return 0;
}

Measured memory_bytes: 22512
N = int(input())
A = list(map(int, input().split(" ")))

A.sort()
if len(A) % 2 == 1:
  odd = True
else:
  odd = False

value = 1

if odd:
  for i in range(len(A)//2):
    if A[2*i+1] == A[2*i+2] and A[2*i+1] == 2*i+2:
      value *= 2
    else:
      value *= 0
      break
  if A[0] != 0:
    value *= 0
else:
  for i in range(len(A)//2):
    if A[2*i] == A[2*i+1] and A[2*i] == 2*i+1:
      value *= 2
    else:
      value *= 0

print(value % (10**9+7))

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

using namespace std;

#define ll long long
#define endl '\n'
#define pb push_back
#define inf 1e9

int main ()
{
    char a, b; cin >> a >> b;
    string A = "", B = "";

    for (int i = 0; i < (int)(b - '0'); i++)
        A += a;
    for (int i = 0; i < (int)(a - '0'); i++)
        B += b;

    cout << (A < B ? A : B) << endl;

    return 0;
}


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

using namespace std;

int main(void) {
  int n, ve[100001], vo[100001];
  cin >> n;

  memset(ve, 0, sizeof(ve));
  memset(vo, 0, sizeof(vo));

  for (int i = 0; i < n; i++) {
    int v; cin >> v;

    if (i & 1) {
      vo[v]++;
    } else {
      ve[v]++;
    }
  }

  int ov[2], on[2], ev[2], en[2];
  memset(on, 0x7f, sizeof(on));
  memset(en, 0x7f, sizeof(en));
  on[0] = en[0] = n/2;

  for (int i = 0; i <= 100000; i++) {
    if (on[0] > n/2 - vo[i]) {
      on[1] = on[0];
      on[0] = n/2 - vo[i];
      ov[1] = ov[0];
      ov[0] = i;
    } else if(on[1] > n/2 - vo[i]) {
      on[1] = n/2 - vo[i];
      ov[1] = i;
    }
    if (en[0] > n/2 - ve[i]) {
      en[1] = en[0];
      en[0] = n/2 - ve[i];
      ev[1] = ev[0];
      ev[0] = i;
    } else if(en[1] > n/2 - ve[i]) {
      en[1] = n/2 - ve[i];
      ev[1] = i;
    }
  }

  if (ev[0] != ov[0]) {
    cout << en[0] + on[0] << endl;
  } else {
    cout << min(en[0] + on[1], en[1] + on[0]) << endl;
  }

  return 0;
}

Measured memory_bytes: 1024
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n,m = list(map(int, input().split()))
ab = [tuple(map(int, input().split())) for _ in range(n)]
ans = 0
c = 0
ab.sort(key = lambda x: (x[0], -x[1]))
from heapq import heappop as hpp, heappush as hp
class HST:
    def __init__(self, ascending=True):
        self._h = []
        self._q = []
        self.ascending = ascending
    def push(self, v):
        if not self.ascending:
            v *= -1
        hp(self._h, v)
    def remove(self, v):
        if not self.ascending:
            v *= -1
        hp(self._q, v)
    def top(self):
        while self._q and self._q[0]==self._h[0]:
            hpp(self._q)
            hpp(self._h)
        if not self._h:
            res = None
        else:
            res = self._h[0]
            if not self.ascending:
                res *= -1
        return res
h = HST(ascending=False)
ans = 0
ab = ab[::-1]
# print(ab)
for c in range(m, -1, -1):
    while ab and ab[-1][0]+c<=m:
        a,b = ab.pop()
        h.push(b)
    val = h.top()
    if val is not None:
        ans += val
        h.remove(val)
print(ans)

Measured memory_bytes: 100300
#include <algorithm>
#include <array>
#include <cmath>
#include <iostream>
#include <limits>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <stack>
#include <unordered_map>
#include <utility>
#include <vector>

using f64 = double;

using std::cout;
using std::cerr;
using std::cin;
using std::endl;
template <class T>
constexpr T pi = static_cast<T>(3.141592653589793);

int main()
{
    f64 a, b, x;
    cin >> a >> b >> x;

    f64 rad = 0;
    if (a * a * b <= x * 2.0)
    {
        rad = atan(2.0 * (a * a * b - x) / (a * a * a));
    }
    else
    {
        rad = atan(a * b * b / (2.0 * x));
    }

    printf("%.10f\n", 180.0 * rad / pi<f64>);

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
int main() {
int n,ar[100000];
cin>>n;
for(int i=0;i<n;i++)cin>>ar[i];
int q;
cin>>q;
int cnt[100001];
memset(cnt,0,sizeof(cnt));
long long sum=0;
for(int i=0;i<n;i++){
cnt[ar[i]]++;sum+=ar[i];}
while(q--){
   int a,b;
   cin>>a>>b;
   //if(cnt[a]!=0){
   sum+=cnt[a]*(b-a);
   cnt[b]+=cnt[a];
   cnt[a]=0;
   cout<<sum<<endl;
}
	return 0;
}


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

int main(){
  int n, i;
  cin>>n;
  for(i=1; i<=n; i++){
    int x = i;
    if ( x % 3 == 0 ){
      cout << " " << i;
      continue;
    }
    while(x){
      if ( x % 10 == 3 ){
        cout << " " << i;
	break;
      }
      else x /= 10;
    }
  }
  cout << endl;
}



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

int main() {
  vector<int> cs(3);
  int v = 0;
  for(int i = 0; i < 3; ++i) {
    cin >> cs[i];
    v += cs[i];
  }
  if(v % 2 == 1) {
    cout << "No" << endl;
    return 0;
  }
  v /= 2;
  for(auto c : cs) {
    if(v == c) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
char s[100005];
int n;
queue<int>que;
int main() {
	cin >> (s + 1);
	n = strlen(s + 1);
	if(s[1] == '0' || s[n] == '1') {
		puts("-1");
		return 0;
	}
	int i;
	for(i = 2; i < n - 1; ++i) if(s[i] != s[n - i]) {
		puts("-1");
		return 0;
	}
	for(i = 2; i <= n; ++i) if(s[i] != '0') que.push(i);
	que.push(n);
	for(i = 1; i < n; ++i) {
		if(i == que.front()) que.pop();
		cout << i << " " << que.front() << endl;
	}
	return 0;
}

Measured memory_bytes: 1920
#include <bits/stdc++.h>
#define REP(i,n,N) for(int i=n;i<N;i++)
#define p(S) cout<<(S)<<endl
using namespace std;

int main(){
	long long int N;
	cin>>N;
	int ans=1;
	while(N>3){
		ans++;
		if(N%3!=0){
			N/=3;
			N++;
		}else N/=3;
	}
	p(ans);

	return 0;
}

Measured memory_bytes: 3104
#include<iostream>
#include<string>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)


int r, s, p;

char win(char u){
    if (u == 'r'){
        return 'p';
    }else if(u == 's'){
        return 'r';
    }else{
        return 's';
    }
}

int point(char u){
    if (u == 'r'){
        return r;
    }else if(u == 's'){
        return s;
    }else{
        return p;
    }
}

int main(){
    int n, k;
    cin >> n >> k;

    cin >> r >> s >> p;
    string t;
    cin >> t;
    string rsp = "rsp";
    string opt = "";
    rep(i, n){
        if (i - k >= 0 && i + k < n){
            if (opt[i-k] == win(t[i])){
                rep(j, 3){
                    if (rsp[j] != opt[i-k] && rsp[j] != win(t[i+k])){
                        opt += rsp[j];
                        break;
                    }
                }
            }else{
                opt += win(t[i]);
            }
        }else if (i - k >= 0 && i + k >= n){
            if (opt[i-k] == win(t[i])){
                rep(j, 3){
                    if (rsp[j] != opt[i-k]){
                        opt += rsp[j];
                        break;
                    }
                }
            }else{
                opt += win(t[i]);
            }   
        }else{
            opt += win(t[i]);
        }
    }
    // cout << opt << endl;
    int ans = 0;
    rep(i, n){
        if (win(t[i]) == opt[i]){
            ans += point(opt[i]);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define REP(i, n) for (long long i = 0; i < (long long)n; i++)
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using Vecl = vector<ll>;
using Graph = vector<vector<int>>;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll K;
  cin >> K;
  ll num = 0;
  queue<ll> que;
  REP(i, 9) que.push(i + 1);
  while (K > 0) {
    num = que.front();
    //    cout << num << " ";
    if (num % 10 != 0) que.push(10 * num + num % 10 - 1);
    que.push(10 * num + num % 10);
    if (num % 10 != 9) que.push(10 * num + num % 10 + 1);
    que.pop();
    K--;
  }
  cout << num << endl;
  return 0;
}

Measured memory_bytes: 1792
def solve():
    N = int(input())

    left = [[] for _ in range(N + 1)]
    right = [[] for _ in range(N + 1)]

    left_len = 0

    s = 0
    for _ in range(N):
        k, l, r = map(int, input().split())
        k -= 1

        mi = min(l, r)
        l -= mi
        r -= mi

        s += mi
        if r:
            k = N - 2 - k
            if k < 0: continue
            right[k].append(r)
        else:
            left[k].append(l)
            left_len += 1

    def additional_happiness(src, len_):
        """src: 二重リスト, 設置可能な位置の制約が厳しい->緩い順の候補リスト
        """
        from heapq import heappop, heappush

        ret = 0

        h = []
        while len(src) > len_:
            cands = src.pop()
            for v in cands:
                heappush(h, -v)

        for cands in reversed(src):
            for v in cands:
                heappush(h, -v)
            if h:
                x = heappop(h)
                ret -= x
        return ret

    s += additional_happiness(left, left_len)
    s += additional_happiness(right, N - left_len)

    return s


def main():
    import sys
    input = sys.stdin.readline

    T = int(input())

    ans = []
    for _ in range(T):
        res = solve()
        ans.append(res)

    print(*ans, sep='\n')


if __name__ == '__main__':
    main()


Measured memory_bytes: 46604
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")

#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<bits/stdc++.h>

using namespace std;
using namespace __gnu_pbds;

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> myds;

#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define int long long
#define F first
#define S second
#define vec(x) vector<x> 
#define pi(x,y) pair<x,y>
#define pqq(x) priority_queue<x> 
#define min_heap(x) priority_queue<x, vector<x>, greater<x> >
#define all(x) x.begin(),x.end()
#define rep(i,x,y) for(int i=x;i<y;i++)
#define repd(i,x,y,k) for(int i=x;i<y;i+=k)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define rev(x) reverse(all(x))
#define uniq(x) x.resize(distance(x.begin(),unique(all(x))))
#define full(x,a) memset(x,a,sizeof(x))
#define lcm(x,y) ((x*y)/__gcd(x,y))
#define mod 1000000007
#define bitcount __builtin_popcountll
#define pb push_back
#define indexof order_of_key
#define valueat find_by_order

int dx[4]={0,0,1,-1};
int dy[4]={1,-1,0,0};
int dxx[8]={0,0,1,-1,-1,-1,1,1};
int dyy[8]={1,-1,0,0,-1,1,1,-1};

int gcdextended(int a,int b,int &x,int &y){if(!a){x=0,y=1;return b;}int x1,y1;int ans=gcdextended(b%a,a,x1,y1);x=y1-(b/a)*x1;y=x1;return ans;}
int inv(int a){int x,y;int ans=gcdextended(a,mod,x,y);return(x%mod+mod)%mod;}
int nCr(int n,int k){int res=1;k=(k>n-k)?n-k:k;rep(i,0,k){res*=(n-i);res/=(i+1);}return res;}
int POW(int x,int y){int res=1;x=x%mod;while(y>0){if(y&1)res=(res%mod*x)%mod;y=y>>1;x=(x*x)%mod;}return res;}
//void seive(){prime[0]=0;prime[1]=0;rep(i,2,10002)prime[i]=1;for(int i=2;i*i<=10000;i++){if(prime[i]){for(int j=i*i;j<=10000;j+=i)prime[j]=0;}}} 

int a,b;

void input(){
	cin>>a>>b;
}

void solve(){
	rep(i,1,1000001){
		if(floor(i*0.08)==a && floor(i*0.1)==b){
			cout<<i<<endl;
			return;
		}
	}
	cout<<-1<<endl;
}

main(){
	fastio;
	int t=1;
	while(t--){
		input();
		solve();
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
const long long mod=1e9+7;
#define ll long long
using namespace std;
int lim=0;

/*ll power(ll n)
{
    if(n==0) return 0%mod;
    if(n==1) return 1%mod;
    return ((power(n-1)%mod) + (power(n-2)%mod ))%mod;
}
int main()
{
    ll n;cin>>n;
    cout<<power(n%mod)%mod;
}*/
ll pw(ll x,ll n)
{
    ll res=1;
    while(n)
    {
        if(n&1) res=res*x*1ll%mod;
        x=x*x*1ll%mod;
        n/=2;
    }return res;
}
int main()
{
    int a,b;scanf("%d %d",&a,&b);
    printf("%d",((b*2)<a)?(a-(b*2)):0);
}
// C++ program to find sum of two large numbers.
/*#include<bits/stdc++.h>
using namespace std;

// Function for finding sum of larger numbers
string findSum(string str1, string str2)
{
    // Before proceeding further, make sure length
    // of str2 is larger.
    if (str1.length() > str2.length())
        swap(str1, str2);

    // Take an empty string for storing result
    string str = "";

    // Calculate length of both string
    int n1 = str1.length(), n2 = str2.length();

    // Reverse both of strings
    reverse(str1.begin(), str1.end());
    reverse(str2.begin(), str2.end());

    int carry = 0;
    for (int i=0; i<n1; i++)
    {
        // Do school mathematics, compute sum of
        // current digits and carry
        int sum = ((str1[i]-'0')+(str2[i]-'0')+carry);
        str.push_back(sum%10 + '0');

        // Calculate carry for next step
        carry = sum/10;
    }

    // Add remaining digits of larger number
    for (int i=n1; i<n2; i++)
    {
        int sum = ((str2[i]-'0')+carry);
        str.push_back(sum%10 + '0');
        carry = sum/10;
    }

    // Add remaining carry
    if (carry)
        str.push_back(carry+'0');

    // reverse resultant string
    reverse(str.begin(), str.end());

    return str;
}

// Driver code
int main()
{
    string str1 ,str2 ;
    cin>>str1>>str2;
    cout << findSum(str1, str2);
    return 0;
}
*/
// CPP program to find (a^b) % MOD where a and
// b may be very large and represented as strings.




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int r, g, b;
  cin >> r >> g >> b;
  int sum = 100 * r + 10 * g + b;
  if (sum % 4 == 0) {
  	cout << "YES" << endl;
  }else {
  	cout << "NO" << endl;
  }
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#define N 10000
int main(){
  int i,n,j,num[N],count=0;
  scanf("%d",&n);
  
  for(i=n;i>0;i--){
    scanf("%d",&num[i]);
    if(num[i]!=2&&num[i]%2==0) count++;
    else{
      for(j=3;j<=sqrt(num[i]);j+=2){
	if(num[i]%j==0){
	  count++;
	  break;
	}
      }
    }
  }
  printf("%d\n",n-count);
  return 0;
}



Measured memory_bytes: 2140
#include <iostream>
#include <vector>
#include <set>
using namespace std;
int main(){
  int n, m;
  cin >> n >> m;
  string s, t;
  cin >> s;
  int l = 0, r = 1;
  vector< set<int> > L(n+1);
  for(int i = 0; i < m; ++i){
    cin >> t;
    if(t == "R++"){
      ++r;
    }
    if(t == "R--"){
      --r;
    }
    if(t == "L++"){
      ++l;
    }
    if(t == "L--"){
      --l;
    }
    L[r-l].insert(l);
  }
  int ans = 0;
  for(int i = 1; i <= n; ++i){
    set<string> S;
    for(set<int>::iterator itr = L[i].begin(); itr != L[i].end(); ++itr){
      S.insert(s.substr(*itr,i));
    }
    ans += S.size();
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 31576
var
	N,M,i,j,cnt,now:Longint;
	u,v,pr,sz:Array[1..50]of Longint;
function find(u:Longint):Longint;
begin
	if pr[u]<>u then pr[u]:=find(pr[u]);
	find:=pr[u];
end;
function unite(u,v:Longint):Boolean;
begin
	u:=find(u);
	v:=find(v);
	if u=v then unite:=false else begin
		if sz[u]<sz[v]then begin
			inc(sz[v],sz[u]);
			pr[u]:=v;
		end else begin
			inc(sz[u],sz[v]);
			pr[v]:=u;
		end;
		unite:=true;
	end;
end;
begin
	read(N,M);
	for i:=1 to M do read(u[i],v[i]);
	cnt:=0;
	for i:=1 to M do begin
		for j:=1 to N do begin
			pr[j]:=j;
			sz[j]:=1;
		end;
		now:=N-1;
		for j:=1 to M do if(i<>j)and unite(u[j],v[j])then dec(now);
		if now>0 then inc(cnt);
	end;
	writeln(cnt);
end.


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

int main(){
  int A, B;
  cin >> A >> B;
  
  //int plus, minus, multi;
  int ans = A+B;
  ans = max(ans, A-B);
  ans = max(ans, A*B);
  cout << ans << endl;

}



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

#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
// pll pp; -> (pp.first,pp.second)
// vector<vl> pp(n,vl(2)); sort(pp.begin(),pp.end(),[](vl a,vl b){return a[0]<b[0];});

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define RREP(i,n) for(ll (i)=(n)-1;(i)>=0;(i)--)
#define FOR(i,a,b) for(ll (i)=(a);(i)<(b);(i)++)
#define FORR(i,a,b) for(ll (i)=(b)-1;(i)>=(a);(i)--)
#define DEBUG(x) cout << #x << ": " << x << endl
#define CHMAX(a,b) a=max((a),(b))
#define CHMIN(a,b) a=min((a),(b))
/*}}}*/
int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  REP(i,s.length()){
    char c = s[i];
    int od = c-'A';
    od = (od+n)%26;
    char d = 'A'+od;
    cout << d;
  }
  
  //cout << fixed << setprecision(10);
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
   int a,b,c;
   cin >> a >> b >> c;
   if(a > b){
        if(b > c){
            cout << c << " " << b << " " << a << endl;
	    return 0;
            } else if(c > a){
            cout << b << " " << a << " " << c << endl;
	    return 0;
	    } else{
	      cout << b << " " << c << " " << a << endl;
	      return 0;
	    }
   }
   if(a < b){
     if(b < c){
       cout << a << " " << b << " " << c << endl;
       return 0;
     } else if(c < a){
       cout << c << " " << a << " " << b << endl;
       return 0;
     } else{
       cout << a << " " << c << " " << b << endl;
       return 0;
     }
   }
}
	    


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

using namespace std;

#define ll long long
#define PI 3.14159265358979323846264338327950L

int n,m,a;

void solve(){

    cin >> n >> m;


    int ans = n;
    for (int i = 0; i < m; i++)
    {
        cin >> a;
        ans -= a;
        if(ans < 0){
            cout << -1 << endl;
            return;
        }
    }
    
    cout << ans << endl;

}





int main(){

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

    solve();

}

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


public class Main{
    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);
        int K = sc.nextInt();
        int S = sc.nextInt();
        int[] s = new int[K+1];
        int res = 0;
        for(int x=0;x<=K;x++){
            for(int y=0;y<=K;y++){
                if(S-x-y>=0 && S-x-y<=K) res++;
            }
        }

        out.println(res);

        out.flush();
    }

}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}

Measured memory_bytes: 21076
#include<iostream>
using namespace std;
int n,m,cnt;
int k[30],a[30],c[35];
int main(){
    cin>>n>>m;
    for(int i=0;i<n;i++){
        cin>>k[i];
        for(int j=0;j<k[i];j++){
            cin>>a[j];
            c[a[j]]++;
        }
    }
    for(int i=1;i<=m;i++){
        if(n==c[i])cnt++;
    }
    cout<<cnt<<endl; 
}

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

#define f(i,a,b) for( ll i = a; i < b ; i++ ) 
#define af(i,a,b) for( ll i = a; i >= b ; i--)
#define rep(i,a,b,k) for(ll i = a; i < b ; i+= k )
#define arep(i,a,b,k) for( ll i = a; i >= b ; i-= k)
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz(a) (ll) a.size()
#define all(a) a.begin(), a.end()
#define sor(a) sort( a.begin(), a.end() )
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define inter ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr)

// policy-based
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;	


using namespace std;


typedef long long ll; // int or long long
typedef long double ld;
typedef pair<ll,ll> ii ;
typedef vector<ll>  vi ;
typedef vector<ii> vii ;

/*
typedef tree<
ll,
null_type,
less<ll>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
*/
 
const ll MAX = 2e5;
const ll inf = 1e12;
const ll mod = 1e9+7;


int main(){
	fastio;
	ll a,b,c,k,x = 0;
	cin >> a >> b >> c >> k;
	while(b <= a) b*=2,x++;
//	cout << x << "  " << k << " " << b<< endl;
	while(c <= b) c*=2,x++;
	if(x > k) cout << "No\n";
	else cout << "Yes\n";
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ll long long int
const int INF = 2147483647;

using namespace std;

typedef std::vector<std::vector<int>> graph;

int n;
bool cycle(int i, vector<bool> &checked, vector<bool> &ch, const graph &g)
{
  if (checked[i])
    return true;
  if (ch[i])
    return false;
  ch[i] = true;
  checked[i] = true;
  bool ans = false;
  for (auto v : g[i])
  {
    ans = ans || cycle(v, checked, ch, g);
  }
  checked[i] = false;
  return ans;
}

int dfs(int i, int len, const graph &g, vector<int> &dp)
{
  if (dp[i] != 0)
    return len + dp[i];
  int ans = len;
  for (auto v : g[i])
    ans = max(ans, dfs(v, len + 1, g, dp));
  dp[i] = ans - len;
  return ans;
}

int f(int i, int j)
{
  if (j < i)
  {
    int tmp = j;
    j = i;
    i = tmp;
  }
  int ans = n * (i - 1) - i * (i - 1) / 2;
  return ans + j - i - 1;
}

int main()
{
  cin >> n;
  graph g(n * (n - 1) / 2);
  vector<bool> in(n * (n - 1) / 2, false);
  REP(i, n)
  {
    vector<int> a(n - 1);
    REP(j, n - 1)
    {
      cin >> a[j];
    }

    FOR(j, 1, n - 1)
    {
      g[f(i + 1, a[j - 1])].push_back(f(i + 1, a[j]));
      in[f(i + 1, a[j])] = true;
    }
  }

  vector<bool> ch(n * (n - 1) / 2);
  vector<bool> checked(n * (n - 1) / 2);
  REP(i, n * (n - 1) / 2)
  {
    if (ch[i])
      continue;
    if (cycle(i, checked, ch, g))
    {
      cout << -1 << endl;
      return 0;
    }
    checked.assign(n * (n - 1) / 2, false);
  }

  // 最長パスの計算
  int ans = 0;
  vector<int> dp(n * (n - 1) / 2, 0);
  REP(i, n * (n - 1) / 2)
  {
    if (dp[i] != 0)
      continue;
    ans = max(ans, dfs(i, 1, g, dp));
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 29824
import sys
def main():
    input = sys.stdin.readline
    n = int(input())
    v = [[0]+[]*(n+1) for i in range(n+1)]
    for i in range(n-1):
        a,b,c = map(int,input().split())
        v[a].append([b,c])
        v[b].append([a,c])

    q,k = map(int,input().split())
    l = [k]
    while l:
        now = l.pop()
        for i in v[now][1:]:
            if v[i[0]][0] == 0:
                v[i[0]][0] = i[1]+v[now][0]
                l.append(i[0])

    for i in range(q):
        x,y = map(int,input().split())
        print(v[x][0]+v[y][0])

if __name__ == '__main__':
    main()


Measured memory_bytes: 91732
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
typedef long long LL;

template<typename T>
istream& operator >> (istream& is, vector<T>& vs){
  for(T& v: vs) is >> v;
  return is;
}

int main() {
  LL N, K; cin >> N >> K;
  vector<LL> V(N); cin >> V;

  LL vmax = 0;
  for (int L = 0; L <= min(N, K); ++L) {
    for (int R = 0; R + L <= min(N, K); ++R) {
      priority_queue<LL> que;
      LL sum = 0;
      for (int i = 0; i < L; i++) {
        sum += V[i];
        if (V[i]<0) que.push(-V[i]);
      }
      for (int i = 0; i < R; i++) {
        int r = N - i - 1;
        sum += V[r];
        if (V[r]<0) que.push(-V[r]);
      }
      for (int k = 0; k < K - (L + R); ++k) {
        if (que.empty()) break;
        sum += que.top(); que.pop();
      }
      vmax = max(vmax, sum);
    }
  }
  cout << vmax << endl;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = (1<<30)-1;
const ll INF = (1LL<<60)-1;
const ld EPS = 1e-10;
template<typename T> bool chmax(T &x, const T &y) {return (x < y)? (x = y, true) : false;};
template<typename T> bool chmin(T &x, const T &y) {return (x > y)? (x = y, true) : false;};

const int MAX_V = 1e5;
vector<int> es[MAX_V];
int sz[MAX_V];
int ans = 0;

int dfs1(int now, int pre){
    if(es[now].size() == 1){
        sz[now] = 1;
        return 1;
    }
    int ret = 0;
    for(auto &e: es[now]){
        if(e == pre) continue;
        ret += dfs1(e, now);
    }
    sz[now] = ret;
    return ret;
}

void dfs2(int now, int pre){
    int flag = 0;
    for(auto &e: es[now]){
        if(e == pre) continue;
        if(sz[e] == 1 && !flag){
            flag++;
            continue;
        }
        elif(sz[e] == 1) ans++;
        else dfs2(e, now);
    }
}

int main(){
    int N;
    cin >> N;
    rep(i, N-1){
        int u, v; cin >> u >> v;
        es[u].pb(v), es[v].pb(u);
    }
    int root = -1;
    rep(i, N){
        if(es[i].size() >= 3) root = i;
    }
    if(root == -1) {cout << 1 << endl; return 0;}
    dfs1(root, -1);
    dfs2(root, -1);
    cout << ans << endl;
}

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

main(){
  int i,k;
  vector<int> x(5);
  for(i=0;i<5;i++) cin >> x[i];
  cin >> k;
  if(x[4] - x[0] > k) cout << ":(" << endl;
  else cout << "Yay!" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

int main() {
  string x;
  for ( ; ; ) {
    cin >> x;
    if (0 == x.compare("0")) break;
    int result = 0;
    for (auto c : x) {
      result += (c - '0');
    }
    cout << result << endl;
  }
  return 0;
} 



Measured memory_bytes: 3184
N = int(input())
P = [[0,0,0]]
for i in range(N):
    t,x,y = map(int,input().split())
    P.append([t,x,y])
judge = True
for i in range(1,N+1):
    dt = P[i][0] - P[i-1][0]
    dist = abs(P[i][1] - P[i-1][1]) + abs(P[i][2] - P[i-1][2])
    if (dt % 2 == 0 and dist % 2 == 0 and dist <= dt) or (dt % 2 == 1 and dist % 2 == 1 and dist <= dt):
        judge = True
    else:
        judge = False
if judge:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 25436
#include <stdio.h>
int main(){
    int a[3000],b[3000],c,k,l;
    l =0; 
    while(1){
        scanf("%d %d",&k,&c);

        if(k == 0 && c == 0){ 
            break;
        }   
        if(k < c){ 
            a[l]=k;
            b[l]=c;
        }else{
            a[l]=c;
            b[l]=k;
        }   
        l++;

    }   
    for(k=0;k<l;k++){
        printf("%d %d\n",a[k],b[k]);
    }   
}

Measured memory_bytes: 2600
import numpy as np

N = int(input().rstrip())
h = [int(i) for i in input().rstrip().split()]

check = [0]*N
height = [0]*N
count = 0

while True:
  check = [1 if h[i] == height[i] else 0 for i in range(N)]
  if check.count(1) == N:
    break
  count += 1
  for i in range(N):
    if check[i] == 0:
      height[i] += 1
      if i<N-1 and check[i+1] == 1:
        break
  #print(height)
  
  
print(count)

Measured memory_bytes: 27092
N, A, B, C, D = map(int, input().split())
S = input()


#%%
flag = True
# A -> Cの間に#が二連続するパターン
if '##' in S[A-1:C]:
    flag = False
# B -> Dの間に#が二連続するパターン
if '##' in S[B-1:D]:
    flag = False

# A, Bの位置交換が必要な時
if C > D:
    if '...' not in S[B-2:D+1]:
    # B,Dの間に連続する3つの'.'が必要
        flag = False

if flag:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 40816
#include <stdio.h>
#include <string.h>

int main(){
	char p[100];
	char s[100];
	char p1[200];

	scanf("%s", p);
	scanf("%s", s);
	strcat(p1,p);
	strcat(p1,p);
	
	if(strstr(p1,s))
		printf("Yes\n");
	else
		printf("No\n");
	return 0;
}

Measured memory_bytes: 532
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define LL long long
#define endl "\n"

using namespace std ;

int main( void )
{

 /*   #ifndef ONLINE_JUDGE
        freopen( "input.txt" , "r" , stdin ) ;
        freopen( "output.txt" , "w" , stdout ) ;
    #endif // ONLINE_JUDGE
*/
    ios_base::sync_with_stdio( false ) ;

    cin.tie( NULL ) ;

    cout.tie( NULL ) ;

    int boxes , children ;

    cin >> boxes >> children ;

    map<LL,LL> M ;

    vector<LL> v( boxes ) ;

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

    LL sum = 0LL ;

    M[sum]++ ;

    for( int i = 0 ; i < boxes ; i++ )  sum = ( sum + v[i] ) % children , M[sum]++ ;

    LL ans = 0LL ;

    for( auto i = M.begin() ; i != M.end() ; i++ )  {

        LL x = i->second ;

        ans += (x*x-x)/2LL ;

    }

    cout << ans << endl ;

    return 0 ;

}



Measured memory_bytes: 4992
#include<stdio.h>
int main()
{
    int i,j;
    scanf("%d",&i);
    if(i >= 1 && i <= 9)
    {
        printf("%d\n",i);
    }
    else if(i >= 10 && i <= 99)
    {
        printf("9\n");
    }
    else if(i >= 100 && i <= 999)
    {
        i = (i - 100) + 1;
        j = i + 9;
        printf("%d\n",j);
    }
    else if(i >= 1000 && i <= 9999)
    {
        printf("909\n");
    }
    else if(i >= 10000 && i <= 99999)
    {
        i = (i - 10000) + 1;
        j = i + 909;
        printf("%d\n",j);
    }
    else if(i >= 100000 && i <= 999999)
    {
        printf("90909\n");
    }
    return 0;
}


Measured memory_bytes: 1728
X,Y=map(int, input().split())
if (X+Y)%3!=0:
  print(0)
  exit()
n=(X+Y)//3
flg=True
for i in range(n+1):
  if 2*i +(n-i) == X:
    right=i
    up=n-i
    flg=False
    break
  elif 2*(n-i)+i == X:
    up=i
    right=n-i
    flg=False
    break
if flg:
  print(0)
  exit()
  

def cmb(n, r, mod):
    if r<0 or r>n :
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, n + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

a = cmb(n,right,mod)
print(a)


Measured memory_bytes: 82428
//#pragma GCC optimize("O3")
#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define all(x) x.begin(),x.end()
#define F first
#define S second
#define fo(i,n) for(int i=0;i<(n);i++)
#define inp(a) int a;cin>>a;
#define inpa(a,n)vector<int> a(n);fo(i,n)cin>>a[i];
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
using namespace std;
#define int ll
// #define MAX 20
#define INF (int)1e18

template<class T> ostream& operator<<(ostream& cout,vector<T> V)
{cout<<"[ ";for(auto v:V)cout<<v<<' ';return cout<<']';}
template<class L,class R> ostream& operator<<(ostream& cout,pair<L, R> P)
{return cout<<'('<<P.F<<','<< P.S<<')';}


signed main()
{
	fio
	vector<int> a={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
	inp(n)
	cout<<a[n-1]<<'\n';
	printclock;
}

Measured memory_bytes: 256
def main():
	s = input()

	n = len(s)

	start = -1
	end = n

	for i in range(0, n, 1):
		if s[i] == "A":
			start = i
			break

	for i in range(n - 1, -1, -1):
		if s[i] == "Z":
			end = i
			break
	
	print(end - start + 1)


  
if __name__ == "__main__":
  	main()

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

using namespace std;
typedef long long ll;

int main()
{
  ll N, T;
  cin >> N >> T;
  vector<ll> c(N), t(N);
  for (ll j=0; j < N; ++j) {
    cin >> c[j] >> t[j];
  }
  ll cost = 10000;
  for (ll j=0; j < N; ++j) {
    if (t[j] <= T) cost = min(c[j], cost);
  }
  if (cost > 1000) {
    cout << "TLE" << endl;
  } else {
    cout << cost << endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long n,a,b,i,fatigue = 0;
    cin>>n>>a>>b;
    long long x[n + 1];
    for(i = 1; i <= n; i++)
        cin>>x[i];
    for(i = 2; i <= n; i++)
        fatigue+=min(b,a*(x[i] - x[i - 1]));
    cout<<fatigue<<endl;
    return 0;
}


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

using namespace std;

int main()
{
  int h, w, ah, aw;
  while(cin >> h >> w, h || w){
    ah = aw = 1000;
    for(int i = 1; i <= 150; i++){
      for(int j = i+1; j <= 150; j++){
    if(i*i + j*j > h*h + w*w || i*i + j*j == h*h + w*w && i > h){
      if(i*i + j*j < ah*ah + aw*aw || i*i + j*j == ah*ah + aw*aw && i < ah) ah = i, aw = j;
    }
      }
    }
    cout << ah << " " << aw << endl;
  }
  return 0;
}

Measured memory_bytes: 2944
using System;

class A
{
	static void Main()
	{
	  var h = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
      int max = -1000*1000 - 1;
      
      if( max < h[0]+h[1] ){
        max = h[0]+h[1];
      }
      if( max < h[0]-h[1] ){
        max = h[0]-h[1];
      }
      if( max < h[0]*h[1] ){
        max = h[0]*h[1];
      }
      //Console.WriteLine(h[0] == h[1] ? "Yes" : "No");
      Console.WriteLine(max);
	}
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)
typedef long long ll;

int main() {
    int a,b,c,x,y; cin >> a >> b >> c >> x >> y;
    int h = (a + b) / 2;
    if(h < c){
        cout << a*x + b*y << endl;
    }else{
        ll ans = 0;
        int MIN = min(x,y);
        ans += c*MIN*2;
        if(x > y){
            if(a > c*2){
                ans += (x-y)*c*2;
                cout << ans << endl;
            }else{
                ans += (x-y)*a;
                cout << ans << endl;
            }
        }
        else if(y > x){
            if(b > c*2){
                ans += (y-x)*c*2;
                cout << ans << endl;
            }else{
                ans += (y-x)*b;
                cout << ans << endl;
            }
        }
        else{
            cout << ans << endl;
        }
    }
}

Measured memory_bytes: 256
S = input()

lis = []

keta = len(S)-1

if keta == 0:
    print (S)
    
else:
    
    for i in range(2 ** keta):
        
        lis.append(format(i,"b").zfill(keta))
        
    #print (lis)
    
    ans = 0
    
    for i in lis:
        
        Q = S[0]
        
        for j in range(len(S)-1):
            
            if i[j] == "1":
                ans += int(Q)
                Q = ""
            
            Q += S[j + 1]
            
        ans += int(Q)
        
        Q = ""
        
    print (ans)


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

using namespace std;


int main(){
	char mozi[20];
	int last;
	scanf("%s",mozi);

	for(int i=0;mozi[i] != '\0';i++){
		last = i;
	}

	for(int i=last;0 <= i;i--){
		printf("%c",mozi[i]);
	}

	printf("\n");

	return 0;
}

Measured memory_bytes: 3056
def f(a, b)
  a > b ? a : b
end

n = gets.to_i
c = []
n.times {
  x, y = gets.split.map &:to_i
  c << [x - y, x + y]
}

d = c.transpose
max = f(d[0].max - d[0].min, d[1].max - d[1].min)
puts max

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

using namespace std;

int main(){
  string s;
  cin >> s;
  vector<bool> al(26,false);
  
  for(int i = 0; i < s.size(); i++){
    al[s[i] - 'a'] = true;
  }
  
  bool exsisted = false;
  char ans;
  for(int i = 0; i < 26; i++){
    if(!al[i]){
      ans = i + 'a';
      exsisted = true;
      break;
    }
  }
  if(!exsisted) cout << "None";
  else cout << ans;
}


Measured memory_bytes: 512
import java.util.Scanner;

public class Main {

	static int n,p;
	public static void main(String[] args) {
		Scanner cin = new Scanner(System.in);
		while(true){
			n=cin.nextInt();
			p=cin.nextInt();
			int pp=p;
			if(n+p==0)break;
			int ans=0;
			int[] person=new int[n];
			int idx=0;
			while(true){
				if(p==0){
					p=person[idx];
					person[idx]=0;
				}
				else{
					p--;
					person[idx]++;
				}
				if(person[idx]==pp){
					ans=idx;
					break;
				}
				idx=(idx+1)%n;
				ans++;
			}
			System.out.println(ans);
		}
			

	}

}

Measured memory_bytes: 20424