akhauriyash/Code-Regression huggingface dataset:
import sys
import numpy as np
import math
def main():
  input = sys.stdin.readline
  N, K =map(int,input().split())
  p = []
  for d in range(1,N+1):
    if d >= K:
      p.append(1/N)
    else:
      m = np.log2((K-1)/d)
      n = math.ceil(m)
      if m != n:
        p.append( 1/N * 1/2 ** n)
      else:
        p.append( 1/N * 1/2 ** (n+1))        
  print(sum(p))
main()	

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

void printvec(vector<int> a){
    int n = a.size();
    for(int i=0; i<n; i++){
        cout << a[i];
        if(i!=n-1){
            cout << " ";
        }
    }
    cout << endl;
}

int main(){
    vector<int> a;
    string s;
    int n1, n2;
    while(cin>>s){
        if(s == "+"){
            n1 = a.back();
            a.pop_back();
            n2 = a.back();
            a.pop_back();
            a.push_back(n1+n2);
        }else if(s == "-"){            
            n1 = a.back();
            a.pop_back();
            n2 = a.back();
            a.pop_back();
            a.push_back(n2-n1);
        }else if(s == "*"){           
            n1 = a.back();
            a.pop_back();
            n2 = a.back();
            a.pop_back();
            a.push_back(n1*n2);
        }else{
            a.push_back(atoi(s.c_str()));
        }
        //printvec(a);
    }
    cout << a[0] << endl;
}


Measured memory_bytes: 3208
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] nums = new int[n];
		for(int arrayIndex = 0; arrayIndex < n; arrayIndex++) {
			nums[arrayIndex] = sc.nextInt();
		}
		boolean flag = true;
		int swapCount = 0;
		while(flag) {
			flag = false;
			for(int j = n - 1; j > 0; j--) {
				if(nums[j] < nums[j - 1]) {
					int work = nums[j];
					nums[j] = nums[j - 1];
					nums[j - 1] = work;
					flag = true;
					swapCount++;
				}
			}
		}
		printArray(nums);
		System.out.println(swapCount);
	}
	public static void printArray(int[] array) {
		int arrayLength = array.length;
		for(int index = 0; index < arrayLength - 1; index++) {
			System.out.print(array[index] + " ");
		}
		System.out.println(array[arrayLength - 1]);
	}
}

Measured memory_bytes: 26312
#include <bits/stdc++.h>
using namespace std;
 
int main(){
int A, B , C, D, E, cnt, dnt;
cnt = 0; 
dnt = 0;  
int d[5];
int e[5];  
int mi = 9;  
  
    for(int i = 0;i < 5;i++){
  cin >> d[i];
    }

    for(int i = 0;i < 5;i++){
      e[i] = d[i] % 10;
      if(e[i] == 0)cnt++;
      if(e[i] != 0){
      mi = min(mi, e[i]);
      }
    }
  
    if(mi == e[0]){
      dnt++;
      cout << d[0] + (d[1] / 10) * 10 + 10 + (d[2] / 10) * 10 + 10 + (d[3] / 10) * 10 + 10 + (d[4] / 10) * 10 + 10 - cnt * 10<< endl;
    }
      
    else if((mi == e[1])&&dnt == 0){
      dnt++;
      cout << (d[0] / 10) * 10 + 10 + d[1] + (d[2] / 10) * 10 + 10 + (d[3] / 10) * 10 + 10 + (d[4] / 10) * 10 + 10 - cnt * 10 << endl;
    }  
      
    else if((mi == e[2])&&dnt == 0){
      dnt++;
      cout << (d[0] / 10) * 10 + 10 + (d[1] / 10) * 10 + 10 + d[2] + (d[3] / 10) * 10 + 10 + (d[4] / 10) * 10 + 10 - cnt * 10 << endl;
    }  
    
    else if((mi == e[3])&&dnt == 0){
      dnt++;
      cout << (d[0] / 10) * 10 + 10 + (d[1] / 10) * 10 + 10 + (d[2] / 10) * 10 + 10 + d[3] + (d[4] / 10) * 10 + 10 - cnt * 10 << endl;
    }
      
    else if((mi == e[4])&&dnt == 0){
      cout << (d[0] / 10) * 10 + 10 + (d[1] / 10) * 10 + 10 + (d[2] / 10) * 10 + 10 + (d[3] / 10) * 10 + 10 + d[4] - cnt * 10 << endl;
    } 
    
    else
      cout << d[0] + d[1] + d[2] + d[3] + d[4] << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(long long i=0;i<x;i++)
#define repn(i,x) for(long long i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
vector<pair<string,P> >vec;

void solve(string S, string T){
	ll res = 0;
	rep(i, S.length()) {
		if (S[i] == T[i]) res++;
	}
	cout << res << endl;
}

int main(){	
	string T;
	string S;
	cin >> S;
	cin >> T;
	solve(S, T);
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <string.h>
#include <ctype.h>
#include <algorithm>

using namespace std;

int main() {
  int a,b,c;
  cin >> a >> b >> c;
  if(a == 5) {
    if(b == 5 && c == 7) cout << "YES";
    else if(b == 7 && c == 5) cout << "YES";
    else cout << "NO";
  }
  else if(b == 5) {
    if(a == 5 && c == 7) cout << "YES";
    else if(a == 7 && c == 5) cout << "YES";
    else cout << "NO";
  }
  else if(c == 5) {
    if(a == 5 && b == 7) cout << "YES";
    else if(a == 7 && b == 5) cout << "YES";
    else cout << "NO";
  }

  
  //cout << m << endl;
}

Measured memory_bytes: 3636
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<utility>
#include<set>
#include<stack>
#include<queue>
#include<deque>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<bitset>
#include<sstream>
#include<list>
#include<climits>

using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define nrep(i,i0,n) for(int i=(i0);i<(int)(n);++i)
typedef vector<int> vi; typedef pair<int,int> pii; typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vii;
typedef long long ll;


int main(){
	int n;cin>>n;
	int col[9]={};
	rep(i,n){
		int t;cin>>t;
		t/=400;
		int tmp=min(t,8);
		col[tmp]++;
	}
	int mini=0;
	rep(i,8)if(col[i]>0)mini++;
	printf("%d %d\n",max(mini,1),mini+col[8]);
	return 0;
}



Measured memory_bytes: 256
#include<cstdio>
inline int abs(int x){return x<0?-x:x;}
inline void chk(int &x,int y){if(y<x)x=y;}
int n,k,H[100005];
int dp[100005];
int main(){
	scanf("%d%d",&n,&k);
	for(int i=0;i<n;++i)scanf("%d",&H[i]);
	for(int i=1;i<n;++i){
		dp[i]=1e9;
		for(int j=1;j<=k;++j)if(i>=j)chk(dp[i],dp[i-j]+abs(H[i]-H[i-j]));
	}
	printf("%d\n",dp[n-1]);
	return 0;
}

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

int main(){
    long long X ;
    cin >> X ;
    int ans = 0 ;
    long long val = 100 ;
    while(val < X){
        val *= 1.01 ;
        ans ++ ;
    }
    cout << ans << "\n";
}

Measured memory_bytes: 3576
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int n = s.nextInt();
		s.close();
		int numbers = 0;
		if(n <= 9) {
			numbers = n;
		}else if(n <= 99) {
			numbers = 9;	
		}else if(n <= 999) {
			numbers = n - 90;
		}else if(n <= 9999) {
			numbers = 909;
		}else if(n <= 99999){
			numbers = n - 9000 - 90; 
		}else {
			numbers = 90909;
		}
		System.out.println(numbers);
	}

}


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

using namespace std;

int gcd(int a,int b) {
    if(a==0) return b;
    return gcd(b%a,a);
}


int main() {
    int K;
    cin>>K;
    long long res = 0;
    for(int c=1;c<=K;c++) {
        for(int c2=1;c2<=K;c2++) {
            int g = gcd(c,c2);
            for(int c3=1;c3<=K;c3++) {
                res += gcd(g,c3);
            }
        }
    }
    cout<<res;
}


Measured memory_bytes: 3672
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

char *trichrjoin(char a, char b, char c)
{
  int i = 0;
  char *s;
  s = (char *)malloc(sizeof(char)*(4));
  s[0] = a;
  s[1] = b;
  s[2] = c;
  s[3] = '\0';
  return (s);
}

int main()
{
  char s[11];
  scanf("%s",&s);
  int i = 0;
  char *buf = 0;
  char *tmp = 0;
  int num = 0;
  int diff = 0;
  int min = 1000;
  while (s[i+2])
  {
    tmp = buf;
    buf = trichrjoin(s[i], s[i+1], s[i+2]);
    free(tmp);
    num = atoi(buf);
    diff = abs(num - 753);
    if (diff < min)
      min = diff;
    i++;
  }
  printf("%d",min);
  
}

Measured memory_bytes: 1728
import numpy as np
from copy import deepcopy
temp=list(map(int, input().split()))
R=temp[0]
C=temp[1]

color=np.zeros((R,C)).astype(int)

for i in range(R):
  temp=input()
  a=np.zeros(C).astype(int)
  for j in range(C):
      if temp[j]=='#':
        a[j]=1
      else:
        a[j]=0
  color[i]=a
  
def Adj(u):
  adj=[]
  for v in [(u[0]-1,u[1]),(u[0]+1,u[1]),(u[0],u[1]-1),(u[0],u[1]+1)]:
      if v[0]>=0 and v[0]<R and v[1]>=0 and v[1]<C:
        adj.append(v)
  return adj  

def BFS(s,c,d):
  ma=0
  Q=[s]
  while Q !=[]:
    u=Q[0]
    del Q[0]
    if d[u[0],u[1]]>ma:
      ma=d[u[0],u[1]]
    for v in Adj(u):  
      if c[v[0],v[1]]==0:
        c[v[0],v[1]]=1
        d[v[0],v[1]]=d[u[0],u[1]]+1
        Q.append(v)
  return ma
        
def main():
  ma=0
  for sx in range(R):
    for sy in range(C):
      if color[sx,sy]==0:
        d=np.zeros((R,C)).astype(int)
        c=deepcopy(color)
        c[sx,sy]=1
        ma=max(BFS((sx,sy),c,d),ma)
  print(ma)

main()


Measured memory_bytes: 12500
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;
const array<pair<int,int>,4> fd{make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 
//ll

int main(){
  int n, a[100];cin>>n;rep(i,n)cin>>a[i];
  int ans = 0;
  repd(i,1,n+1){
    if(a[i-1] == a[i]){
      a[i] = (a[i-1] + 1)%10000;
      if(a[i] == a[i+1])a[i] = (a[i]+1)%10000;
      ans++;
    }
  }
  cout << ans << endl;
}




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

using namespace std;

using ll = long long;
const int N = 200200;
const ll inf = 4e18;

int n;
ll k;
int a[N];
int last[N];
pair<ll, int> nxt[64][N];
bool was[N];

int main() {
   ios_base::sync_with_stdio(false);
   cin >> n >> k;
   for (int i = 0; i < n; ++i) {
      cin >> a[i];
   }
   for (int i = 2 * n - 1; i >= 0; --i) {
      if (i < n) {
         int cur = last[a[i]];
         nxt[0][i] = {cur / n, cur % n};
         if (nxt[0][i].second == n - 1) {
            nxt[0][i].first++;
            nxt[0][i].second = 0;
         } else {
            nxt[0][i].second++;
         }
      }
      last[a[i % n]] = i;
   }
   for (int j = 1; j < 60; ++j) {
      for (int i = 0; i < n; ++i) {
         pair<ll, int> l = nxt[j - 1][i];
         pair<ll, int> r = nxt[j - 1][l.second];
         nxt[j][i] = {min(l.first + r.first, inf), r.second};
      }
   }
   pair<ll, int> cur = {0, 0};
   for (int i = 59; i >= 0; --i) {
      if (cur.first + nxt[i][cur.second].first < k) {
         cur.first += nxt[i][cur.second].first;
         cur.second = nxt[i][cur.second].second;
      }
   }
   assert(cur.first == k - 1);
   int st = cur.second;
   vector<int> ans;
   for (int i = st; i < n; ++i) {
      if (!was[a[i]]) {
         ans.push_back(a[i]);
         was[a[i]] = true;
      } else {
         while (true) {
            int u = ans.back();
            was[u] = false;
            ans.pop_back();
            if (u == a[i]) {
               break;
            }
         }
      }
   }
   for (int v : ans) cout << v << " ";
}


Measured memory_bytes: 194164
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<climits>
#include<set>

#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 FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
using namespace std;
typedef pair<int, int> pii;
typedef long long int ll;
typedef pair<ll,ll> pll;
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};
#define MOD 1000000007
#define ARRAY_MAX 100005

const int INF = 1e9+7;


int main(){

    int w,h,n;
    cin >> w >> h >> n;
    vector<int> x(n),y(n);
    for(int i = 0;i < n;i++){
        cin >> x[i] >> y[i];
    }
    int ans = 0;
    for(int i = 0;i < n-1;i++){

        int xx = x[i+1] - x[i];
        int yy = y[i+1] - y[i];
        //cout << xx << " " << yy << endl;
        if(xx > 0 && yy > 0){
            int mini = min(xx,yy);
            ans += mini;
            ans += (xx + yy - 2*mini);
        }else if(xx < 0 && yy < 0){
            int mini = min(abs(xx),abs(yy));
            //cout << i << " " << mini << endl; 
            ans += mini;
            ans += (abs(xx) + abs(yy) - 2*mini);
        }else{
            ans += abs(xx) + abs(yy);
        }
        //cout << "ans = " << ans << endl;
    }
    cout << ans << endl;
    

    return 0;
}


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const int inf = 1e9;
const ll INF = 1e18;
const double pi = 3.14159265358979323846;
#define rep(i,n) for(ll i=0;i<n;i++)

int main(){
	ll a,b,c;cin>>a>>b>>c;
	ll x=c-a-b;
	if(x>0&&4*a*b<x*x) cout<<"Yes"<<"\n";
	else cout<<"No"<<"\n";
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
public static void main(String[] args){
  Scanner sc = new  Scanner(System.in);
int a = sc.nextInt();
int b = sc.nextInt();
if(a > b){
  System.out.println("a > b");
}else if(a < b){
  System.out.println("a < b");
}else{
  System.out.println("a == b");
}

}

}


Measured memory_bytes: 26112
#include<iostream>
using namespace std;
int main(){
	int n,m;
	cin >> n >> m;
	int a[50],b[50],c[50],d[50];
	for(int i=0;i<n;i++){
		cin >> a[i] >> b[i];
	}
	for(int i=0;i<m;i++){
		cin >> c[i] >> d[i];
	}
	
	for(int i=0;i<n;i++){
		int ans=1e9;
		int ansp=0;
		for(int j=0;j<m;j++){
			int x=abs(a[i]-c[j]);
			int y=abs(b[i]-d[j]);
			if(ans>x+y){
				ans=x+y;
				ansp=j+1;
			}
		}
		cout << ansp << endl;
	}
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		String s = sc.next();
		int x = 0;
		int max = 0;

		char[] ch = s.toCharArray();

		for (int i = 0; i < n; i++) {
			if (ch[i] == 'I') {
				x = x + 1;
			} else if (ch[i] == 'D') {
				x = x - 1;
			}
			if (max < x) {
				max = x;
			}
		}
		System.out.println(max);
	}
}

Measured memory_bytes: 21844
#include<math.h>
#include<stdio.h>
int main(void){;
	double S,l,r;
	scanf("%lf",&r);
	S = r*r*atan(1.0)*4.0;
	l = 2.0*r*atan(1.0)*4.0;
	printf("%lf %lf\n",S,l);
	return 0;
}

Measured memory_bytes: 648
#pragma region include
#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <tuple>
#include <bitset>

#include <queue>
#include <complex>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <fstream>
#include <random>
//#include <time.h>
#include <ctime>
#pragma endregion //#include
/////////
#define REP(i, x, n) for(int i = x; i < n; ++i)
#define rep(i,n) REP(i,0,n)
/////////
#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
#pragma endregion //typedef
////定数
const int INF = (int)1e9;
const LL MOD = (LL)1e9+7;
const LL LINF = (LL)1e18;
const double PI = acos(-1.0);
const double EPS = 1e-9;
/////////
using namespace::std;

void solve(){
	int N;
	cin >> N;
	vector<LL> A(N);
	LL sum = 0;
	for(int i=0;i<N;++i){
		cin >> A[i];
		sum += A[i];
	}
	LL Asum = 0;
	LL ans = LINF;
	for(int i=0;i<N-1;++i){
		Asum += A[i];
		LL Bsum = sum-Asum;
		if( ans > abs(Asum-Bsum) ){
			ans = abs(Asum-Bsum);
		}
	}
	cout << ans << endl;
}

#pragma region main
signed main(void){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}
#pragma endregion //main()


Measured memory_bytes: 1792
#include <stdio.h>

int main(){
   int x,y,z;
 
   scanf("%d",&x);
   y=x%100;
   z=x/100;
   if ((y%5==0 && y/5<=z) || (y%5>0 && y/5+1<=z)) puts("1");
   else          puts("0");
   return 0;
}


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

int x, y;
int modify(int n) { return n < 0 ? 2000000000 : n; }

int main() {
  cin >> x >> y;
  cout << min({
    modify(y - x),
    1 + modify(y - (-x)),
    1 + modify((-x) - y),
    2 + modify(x - y)
  }) << endl;
}


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

using namespace std;
typedef long long ll;

const int MAX_N=1e5+5;
char s[MAX_N];
vector<int> pos;
int main(void){
    int n,q;
    cin >>n>>q;
    cin >> s+1;
    for(int i=1;i<=n-1;i++){
        if(s[i]=='A'&&s[i+1]=='C'){
            pos.push_back(i);
        }
    }
    while(q--){
        int l,r;
        scanf("%d%d",&l,&r);
        /// [l,r-1]的个数
        int ll=lower_bound(pos.begin(),pos.end(),l)-pos.begin();
        int rr=upper_bound(pos.begin(),pos.end(),r-1)-pos.begin();

        printf("%d\n",rr-ll);
    }

    return 0;
}


Measured memory_bytes: 1276
$line = <STDIN>;
chomp $line;
$N=scalar($line);
$line = <STDIN>;
chomp $line;
$S=$line;

$wc=0;
for($i=0;$i<$N;$i++){
	$wc+=1 if(substr($S,$i,1) eq "W");
	$wc[$i]=$wc;
}

$ec = $N-$wc[$N-1];
$mc = $ec-(1-$wc[0]);

for($i=1;$i<$N;$i++){
	$toEast = $wc[$i-1];
	$toWest = $ec-($i+1-$wc[$i]);
	$c = $toEast+$toWest;
	$mc=$c if ($mc>$c);
	#print "$toEast $toWest $c \n";
}

print "$mc\n";


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

using namespace std;

int main(){
  while(1){

    int le=0,ri=0,count=0;
    string str;
    cin>>str;
    if(str[0]=='#') break;
  
    for(int i=0;i<str.size();i++){
      if(i==0){
	if (str[i]=='q' || str[i]=='w' || str[i]=='e' || str[i]=='r' ||
	    str[i]=='t' || str[i]=='a' || str[i]=='s' || str[i]=='d' ||
	    str[i]=='f' || str[i]=='g' || str[i]=='z' || str[i]=='x' ||
	    str[i]=='c' || str[i]=='v' || str[i]=='b') le=1;
	else ri=1;
      }
      if(i>0){
	if(ri==1 &&( str[i]=='q' || str[i]=='w' || str[i]=='e' || str[i]=='r' ||
		     str[i]=='t' || str[i]=='a' || str[i]=='s' || str[i]=='d' ||
		     str[i]=='f' || str[i]=='g' || str[i]=='z' || str[i]=='x' ||
		     str[i]=='c' || str[i]=='v' || str[i]=='b')){
	  count++;
	  le=1;
	  ri=0;
	}
	else if(le==1 && (str[i]=='y' || str[i]=='u' || str[i]=='i' || str[i]=='o' ||
			  str[i]=='p' || str[i]=='h' || str[i]=='j' || str[i]=='k' ||
			  str[i]=='l' || str[i]=='n' || str[i]=='m')){
	  count++;
	  ri=1;
	  le=0;
	}
      }
    }
    cout<<count<<endl;
  }
  return 0;
}
  

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

Measured memory_bytes: 3080
import java.util.LinkedList;
import java.util.Scanner;

public class Main {
	private Scanner sc;
	
	private LinkedList<Integer> stack;
	
	public static void main(String[] args) {
		new Main();
	}
	
	public Main() {
		sc = new Scanner(System.in);
		stack = new LinkedList<Integer>();
		
		while (sc.hasNext() == true) {
			int inst = Integer.parseInt(sc.next());
			
			if (inst == 0) {
				System.out.println(stack.pop());
			} else {
				stack.push(inst);
			}
		}
	}
}

Measured memory_bytes: 25956
#include <cmath>
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cassert>
#include <deque>
#include <queue>
#include <map>
#include <utility>
#include <set>
// g++ -std=c++11 <filename>
#define FOR(j,k,n) for (int j = k; j < (int)(n); j++)
#define MAXN 100000000000000000
#define newl printf("\n")
#define fi first
#define se second
#define test(t)  int t; cin>>t; for(int tes = 0; tes < t; tes++)
#define fio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
typedef long long int lli;
typedef pair<lli,lli> plli;
void inn(long long int &ix) {scanf("%lld",&ix);}
void inn(long long int &ix,long long int &iy) {scanf("%lld%lld",&ix,&iy);}
void inn(int &ix) {scanf("%d",&ix);}
void inn(int &ix,int &iy) {scanf("%d%d",&ix,&iy);}
void inn(long double & ix) {scanf("%LF",&ix);}
void outt(long long int ix) {printf("%lld",ix);}
void outt(long long int ix, char cx) {printf("%lld%c",ix,cx);}
void outt(int ix) {printf("%d",ix);}
void outt(int ix, char cx) {printf("%d%c",ix,cx);}
void outt(long double ix, char cx){printf("%.9LF%c",ix,cx);}
void outt(long double ix){printf("%.9LF",ix);}
void pline() {printf("\n");}

const int MM = 1200000;
lli m,n,k,p1,p2,p3,p,f,a[MM];
string s,s1,s2;
vector <lli> v;
map <lli,lli> mp;
int main(){
	// Have you solved the problem completely?    
   inn(n);
   for(int i=0; i<n; i++)
   {
   		inn(a[i]);
   		mp[a[i]]++;
   		if(mp[a[i]]>=2)
   		{
   			v.push_back(a[i]);
   			mp[a[i]] -= 2;
   		}
   }
   sort(v.begin(), v.end());
   if(v.size() < 2)
   	printf("0");
   else
   	outt(v[v.size()-1]*v[v.size()-2], ' ');
   return 0;
}


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

int main(){
    int n,m;
    cin>>n>>m;
    priority_queue<int> pq;
    for (int i = 0; i < n; ++i) {
        int t;
        cin>>t;
        pq.push(t);
    }
    while(m>0){
        auto i=pq.top();
        pq.pop();
        i/=2;
        pq.push(i);
        --m;
    }

    long long ans=0;
    while(!pq.empty()){
        ans+=pq.top();
        pq.pop();
    }

    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 892
#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <map>
#include <numeric>
#include <algorithm>
#include <stdio.h>

int main(void){
  std::string s,code = "CODEFESTIVAL2016";
  int ans=0;
  std::cin >> s;
  for(int i=0;i<16;i++){
    if(s.at(i)!=code.at(i)){
      ans++;
    }
  }
  std::cout << ans;
  return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef map<ll,ll>::iterator itll;
typedef long double ld;
typedef map<ll,ll> mapll;

#define con continue
#define pb push_back
#define fi first
#define se second
#define fr front()
#define INF 1000000000000000000
#define all(vl) vl.begin(),vl.end()
#define m_p make_pair 
#define sz(a) sizeof(a)
#define forn(mp,it) for(it = mp.begin();it!=mp.end();it++)
#define FOR(i,a,n) for(ll i=a;i<n;i++) 
#define FORE(i,a,n) FOR(i,a,n+1)
#define Endl endl
#define eNdl endl
#define enDl endl
#define endL endl

int main()
{
	ll n;
	cin>>n;
	vector<ll> t;
	vector<ll> vl(n);
	FOR(i,0,n)cin>>vl[i];
	t = vl;
	sort(all(vl));
	reverse(all(vl));
	FOR(i,0,n)
	{
		if(t[i] == vl[0])cout<<vl[1]<<endl;
		else cout<<vl[0]<<endl;
	}
	return 0;
}


Measured memory_bytes: 6300
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		// 要素の入力、格納
		int N = sc.nextInt();
		int a[] = new int[N];
		for (int i = 0; i < N; i++) {
			a[i] = sc.nextInt();
		}
		int alice = 0;
		int bob = 0;
		int ans = 0;
		Arrays.sort(a);

		for (int i = 0; i < N; i++) {
			if (i % 2 == 0) {
				alice += a[N - 1 - i];
			} else {
				bob += a[N - 1 - i];
			}
		}
		ans = alice - bob;

		// 出力
		System.out.println(ans);
	}
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
// URDL
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

int main(){
  int p, q, r; cin >> p >> q >> r;
  cout << min({p+q, q+r, r+p}) << endl;
  return 0;
}




// EOF


Measured memory_bytes: 256
#include<stdio.h>

int solve(int, int,int *,int);

int main()
{
  int i,n,q;
  int A[2000],M[2000];
 
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&M[i]);
  }
 
  for(i=0;i<q;i++){
    if(solve(0,M[i],A,n)){
      printf("yes\n");
    }
    else printf("no\n");
  }
  return 0;
}

int solve(int i,int m,int *A,int n)
{
    int S=0;
    if(m==0)return 1;
    if(i>=n)return 0;
    else{
	S+=solve(i+1,m,A,n);
	S+=solve(i+1,m-A[i],A,n);
    }
    return S;
}



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


ll N,K;
string S;
string ans="";
bool flag=false;



bool visited[2005][2005];
P mem[2005][2005];

P rec(int l,int r){
  if(visited[l][r])return mem[l][r];
  visited[l][r]=true;

  if(l==r){
    return mem[l][r]=P(1,1);
  }

  if(l-1==r){
    return mem[l][r]=P(0,1);
  }
  
  if(S[l]==S[r]){
    P tmp=rec(l+1,r-1);
    tmp.first+=2;
    return mem[l][r]=tmp;
  }

  P pa=rec(l+1,r);
  P pb=rec(l,r-1);
  if(pa.first<pb.first){
    pa.first+=2;
    return mem[l][r]=pa;
  }else if(pa.first>pb.first){
    pb.first+=2;
    return mem[l][r]=pb;
  }else if(pa.first==pb.first){
    pa.first+=2;
    pa.second+=pb.second;
    if(pa.second>K)pa.second=K+1;
    return mem[l][r]=pa;
  }
}


void dfs(int l,int r,ll k){
  if(l==r){
    if(k!=1)flag=true;

    ans+=S[l];
    return;
  }

  if(l-1==r){
    if(k!=1)flag=true;

    return;
  }

  if(S[l]==S[r]){
    ans+=S[l];
    dfs(l+1,r-1,k);
    return;
  }

  P lp=mem[l+1][r];
  P rp=mem[l][r-1];

  if(lp.first < rp.first){
    ans+=S[l];
    dfs(l+1,r,k);
    return;
  }

  if(lp.first > rp.first){
    ans+=S[r];
    dfs(l,r-1,k);
    return;
  }

  if(S[l]<S[r]){
    if(k<=lp.second){
      ans+=S[l];
      dfs(l+1,r,k);
      return;
    }
    k-=lp.second;
    if(k<=rp.second){
      ans+=S[r];
      dfs(l,r-1,k);
      return;
    }
    flag=true;
    return;
  }else if(S[l]>S[r]){
    if(k<=rp.second){
      ans+=S[r];
      dfs(l,r-1,k);
      return;
    }
    k-=rp.second;
    if(k<=lp.second){
      ans+=S[l];
      dfs(l+1,r,k);
      return;
    }
    flag=true;
    return;
  }

}

int main(){
  cin>>S>>K;
  N=S.size();
  P p=rec(0,N-1);
  dfs(0,N-1,K);
  if(flag){
    cout<<"NONE"<<endl;
  }else{
    int size=ans.size();
    if(p.first%2==1){
      for(int i=0;i+1<size;i++)cout<<ans[i];
      for(int i=size-1;i>=0;i--)cout<<ans[i];
      cout<<endl;
    }else{
      for(int i=0;i<size;i++)cout<<ans[i];
      for(int i=size-1;i>=0;i--)cout<<ans[i];
      cout<<endl;
    }

  }
  return 0;
}

Measured memory_bytes: 70008
#include<bits/stdc++.h>
#define rep(i,n,m) for(int i = (n); i <(m); i++)
#define rrep(i,n,m) for(int i = (n) - 1; i >=(m); i--)
#define pvec(vec) {for (auto v: vec) cout << v << ' '; cout << endl;}
#define pivec(vec) {rep(i, 0, vec.size()) cout << i << ':' << vec[i] << ' '; cout << endl;}

using namespace std;
using ll = long long;

int main()
{
    string s, t;
    cin >> s >> t;

    int cnt = 0;
    rep(i, 0, s.size())
        if (s[i] != t[i]) ++cnt;

    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3916
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 2e5 + 7;
const double pi = acos(-1);
const int mod = 1e9 + 7;
const double eps = 1e-8;
const int inf = 0x3f3f3f3f;

int vis[maxn];

int main(){
	memset(vis,0,sizeof(vis));
	int n;
	scanf("%d",&n);
	for(int i = 2;i <= n;i++){
		int x;
		scanf("%d",&x);
		vis[x]++;
	}
	for(int i = 1;i <= n;i++){
		printf("%d\n",vis[i]);
	}
	return 0;
}

Measured memory_bytes: 4608
import math


def median(array):
    if N % 2:
        return array[N // 2]
    else:
        return sum(array[N // 2 - 1: N // 2 + 1])


N = int(input())
A, B = [], []
for _ in range(N):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)
A.sort()
B.sort()
x = median(A)
y = median(B)
print(y - x + 1)

Measured memory_bytes: 25364
#include<iostream>
#include<climits>
#include<vector>
#include<list>
#include<functional>
#include<algorithm>
#include<string>
#include<cmath>
#include<complex>
#include<set>
#include<map>
#include<stack>
#include<queue>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

class question {
public:
	int N;
	vector<ll> a;
	
	void ans() {
		cin >> N;
		a.resize(3 * N);
		REP(i, 3 * N) cin >> a[i];
		sort(a.begin(), a.end());
		ll res = 0;
		REP(i, N) res += a[3 * N - 2 - 2 * i];
		cout << res << "\n";
	}

};

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	question q;
	q.ans();
	
	return 0;
}



Measured memory_bytes: 2560
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;

namespace MyProject
{
    class Program
    {
        static void Main(string[] args)
        {
#if Local
            var sw = new Stopwatch();
            sw.Start();
            Console.SetIn(new StreamReader("input.in"));
#endif

            var solver = new Solver();
            solver.Solve();
#if Local
            Console.WriteLine($"{sw.ElapsedMilliseconds}ms");
#endif
        }
    }

    class Solver
    {
        public void Solve()
        {
            var items = Console.ReadLine().Split().Select(elem => int.Parse(elem)).ToArray();
            var N = items[0];
            var M = items[1];
            var answer = N == M ? "Yes" : "No"; 

            Console.WriteLine(answer);
        }
    }
}


Measured memory_bytes: 13268
// IlyM
 
#include <bits/stdc++.h>
 
#define sz(x) ((int)((x).size()))
#define all(x) x.begin(),x.end()
#define ll long long
#define mp make_pair
#define pb push_back
#define se second
#define fi first
#define ms(a,b) memset(a,b,sizeof(a)) 
#define trav(a,b) for(auto a:b)

using namespace std;
 
const int N=1e5+5,mod=1e9+7,MOD=0;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
int n,a[N],dp[N];
int main()
{
    // ifstream fin ("problem.in"); ofstream fout ("problem.out");
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin>>n;
	for (int i=1;i<=n;i++) cin>>a[i];
	dp[n-1]=abs(a[n-1]-a[n]);
	for (int i=n-2;i>=1;i--) dp[i]=min(dp[i+1]+abs(a[i]-a[i+1]),dp[i+2]+abs(a[i]-a[i+2]));
	cout<<dp[1];
    return 0;
}
 


Measured memory_bytes: 1024
#include <atcoder/modint>
#include <atcoder/lazysegtree>

#include <cstdio>
#include <vector>

using mint = atcoder::modint998244353;

struct S { mint b; int size; };
struct F { mint a, b; };

S e() { return {0, 0}; }
F id() { return F{1, 0}; }
S op(S a, S b) { return {a.b + b.b, a.size + b.size}; }
S mapping(F f, S x) { return S{f.a * x.b + f.b * x.size, x.size}; }
F composition(F f, F g) { return F{f.a * g.a, f.a * g.b + f.b}; }


int main() {
	int N, Q;
	scanf("%d %d", &N, &Q);
	
	std::vector<S> A(N);
	for (int i = 0; i < N; ++i) {
		int a;
		scanf("%d", &a);
		A[i] = {a, 1};
	}
	
	atcoder::lazy_segtree<S, op, e, F, mapping, composition, id> seg(A);
	
	while (Q--) {
		int q, l, r;
		scanf("%d %d %d", &q, &l, &r);
		if (q == 0) {
			// [l, r) に対して a_i = b * a_i + c
			int c, d;
			scanf("%d %d", &c, &d);
			seg.apply(l, r, F{c, d});
		}
		else {
			// [l, r) 
			printf("%lld\n", seg.prod(l, r).b.val());
		}
	}
	
	return 0;
}

Measured memory_bytes: 19360
#include <bits/stdc++.h>
#include<cmath>
#define N 100005
#define A 1000005
#define MOD 998244353 //1000000007 // //100000000
#define INF 1000000000000000000
#define ll long long
//#define M_PI 3.141592653589793238463

using namespace std;

#define pii pair<ll, ll>
#define piii pair<ll, pii>
#define ft first
#define sd second
#define pb push_back
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n-1; i >= 0; i--)
#define itr(it, x) for(auto it = x.begin(); it != x.end(); it++)
#define mem(a, b) memset(a, (ll)b, sizeof(a))
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define edge(v, x, y) v[x].pb(y); v[y].pb(x);
#define popcount __builtin_popcount
#define ANS(s) {cout << s << "\n"; return;}

//~~~~~~fancy print~~~~~~~//
#define printpii(a) cout << a.ft << " " << a.sd << endl;
#define printpiii(a) cout << a.ft << " " << a.sd.ft << " " << a.sd.sd << endl;
#define print(a, n) rep(i, n) cout << a[i] << " "; cout << endl;
#define printv(v) for(auto x: v)cout << x << " "; cout << endl;
#define printm(a, n, m) rep(i, n) { rep(j, m) cout << a[i][j] << "\t"; cout << endl;}

ll dx[4] = {0, 0, 1, -1};
ll dy[4] = {1, -1, 0, 0};

void fast(){ios_base::sync_with_stdio(false);cin.tie(0);cout << setprecision(12) << fixed;}


void solve(){
    string s;
    cin >> s;
    ll x = 0, y = 0, z = 0, w= 0;
    for(auto a: s){
        if(a == 'N') y++;
        else if(a == 'S') x++;
        else if(a == 'E') z++;
        else w++;
    }
    ll f = 0;
    if(x > y) swap(x, y);
    if(z > w) swap(z, w);
    if(x == 0 && y != 0) ANS("No");
    if(z == 0 && w != 0) ANS("No");
    //if(x && y%x != 0) ANS("No");
    //if(z && w%z != 0) ANS("No");
    ANS("Yes");
}
main(){
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif*/
    fast();
    ll t = 1; //cin >> t;
    while(t--){
        solve();
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>
#define ms(a,b) memset(a,b,sizeof(a))
using namespace std;
typedef long long ll;
const int maxn = 10000 + 5;

int a[maxn], n;

int main(){
    cin >> n;
    for (int i = 0; i < n; cin >> a[i++]);
    ll sum = 0;
    for (int i = 0; i < n; i++){
        int x = a[i];
        while (x % 2 == 0){
            sum++;
            x /= 2;
        }
    }
    cout << sum;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define debug(x) cout << #x << " = " << x << '\n'

using ll = long long;
using namespace std;

const int N = 3010;
int dp[N][N];
char s[N], t[N];

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

#ifdef LOCAL_DEFINE
	freopen("in.txt", "r", stdin);
#endif

	cin >> s >> t;
	int n = strlen(s), m = strlen(t);

	for (int i = 0; i < n; ++i)
	{
		for (int j = 0; j < m; ++j)
		{
			if (s[i] == t[j]){
				dp[i + 1][j + 1] = 1 + dp[i][j];
			}
			dp[i + 1][j + 1] = max(max(dp[i + 1][j + 1], dp[i][j + 1]), dp[i + 1][j]);
		}
	}

	string ans;

	int i = n, j = m;
	while (i != 0 && j != 0)
	{
		if (dp[i][j] == dp[i][j - 1]) {
			--j;
		}
		else if (dp[i][j] == dp[i - 1][j]){
			--i;
		}
		else {
			ans += s[i - 1];
			--i;
			--j;
		}
	}
	reverse(ans.begin(), ans.end());
	cout << ans << '\n';

	return 0;
}

Measured memory_bytes: 35584
import math
import itertools
from collections import deque
import bisect
import heapq

def IN(): return int(input())
def sIN(): return input()
def lIN(): return list(input())
def MAP(): return map(int,input().split())
def LMAP(): return list(map(int,input().split()))
def TATE(n): return [input() for i in range(n)]
ans = 0

def bfs(sx,sy):
    d = [[-1] * w for i in range(h)]
    MAX = 0

    dx = [1, 0, -1, 0]
    dy = [0, 1, 0, -1]

    que = deque([])
    que.append((sx, sy))#スタート座標の記録
    d[sx][sy] = 0#スタートからスタートへの最短距離は0

    while que:#中身がなくなるまで
        p = que.popleft()
       
        for m in range(4):#現在地から4方向の移動を考える
            nx = p[0] + dx[m]
            ny = p[1] + dy[m]

            if 0 <= nx < h and 0 <= ny < w:
              if maze[nx][ny] != "#" and d[nx][ny] == -1:
                que.append((nx, ny))#↑格子点からでない＆壁でない＆まだ通ってない
                d[nx][ny] = d[p[0]][p[1]] + 1

    for k in range(h):
      MAX = max(max(d[k]),MAX)
      
    return MAX

h, w = map(int, input().split())
maze = [lIN() for i in range(h)]

for i in range(h):#sx座標指定0~h-1
  for j in range(w):#sy座標指定0~w-1
    if maze[i][j] == '.':
      ans = max(bfs(i,j),ans)
      
print(ans)

Measured memory_bytes: 3316
#include <iostream>
#include <vector>
#include <algorithm>
#define int long long

using namespace std;

signed main(){
    int n, a;
    cin >> n;
    int A[n]={0};
    //nums.resize(n);
    for(int i=0;i<n-1;i++){
        cin >> a;
        A[a-1]++;
    }

    for(int i=0;i<n;i++){
        cout << A[i] << endl;
    }
    
    return 0;
}       

Measured memory_bytes: 5200
#include<iostream> 
#include<algorithm> 
using namespace std;
int a[110];
int main()
{
    int n;
    cin>>n;
    n=n*2;
    for(int i=1;i<=n;i++)
	{
        cin>>a[i];
    }
    sort(a+1,a+n+1);
    int js=0;
    for(int i=1;i<=n;i+=2)
	{
        js+=a[i];
    }
    cout<<js<<endl;
    return 0; 
}

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

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))

#define INF 2e9
#define INF_LL 1LL<<60
#define ll long long
#define MAX_V
const double PI=3.14159265358979323846;

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int i=0;i<(n-1);i++) cout << (vec)[i] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain; 

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

    ll r = a%b;
    while(r!=0){
        a = b;
        b = r;
        r = a % b;
    }

    return b;
}

int main() {
    string s;
    cin >> s;
    char temae = s[0];
    int ans = 0;

    REPN(i, 1, s.length()) {
        if(temae != s[i]) {
            ans++;
            temae = s[i];
        }
    }

    cout << ans << endl;

}
 

Measured memory_bytes: 512
package main

import (
	"fmt"
	"bufio"
	"os"
	"strconv"
)

//=====I/O=====

var (
	sc = bufio.NewScanner(os.Stdin)
	wr = bufio.NewWriter(os.Stdout)
)

func scanInt() int {
	sc.Scan()
	a,_ := strconv.Atoi(sc.Text())
	return a
}

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ { res[i] = scanInt() }
	return res
}

func scanText() string {
	sc.Scan()
	return sc.Text()
}

func printInts(a ...int) {
	for i, e := range a {
		fmt.Fprint(wr, e)
		if i != len(a)-1 { fmt.Fprint(wr, " ") }
	}
	fmt.Fprintln(wr)
	wr.Flush()
}

//=====main=====

func main() {
	sc.Split(bufio.ScanWords)

	x, y := scanInt(), scanInt()

	if (x+y)%3 != 0 {
		fmt.Println(0)
	} else {
		if (x+y)/3 > x || (x+y)/3 > y {
			fmt.Println(0)
			return
		}
		facInit(x+y)
		fmt.Println(comb((x+y)/3, (x+y)/3*2-y))
	}

}

const mod = 1000000007

var (
	fac []int
	ifac []int
)


func facInit(n int) {
	fac = make([]int,n+1)
	ifac = make([]int,n+1)
	
	mpow := func (x,n int) int {
		a := 1
		for {
			if n&1 == 1 {
				a = a*x %mod
			}
			x = x*x %mod
			n = n >> 1
			if n == 0 {
				break
			}
		}
		return a
	}

	fac[0] = 1
	ifac[0] = 1
	for i := 0; i < n; i++ {
		fac[i+1] = fac[i]*(i+1)%mod
		ifac[i+1] = ifac[i]*mpow(i+1,mod-2)%mod
	}
}

func comb(a,b int) int {
	if a == 0 && b == 0 {
		return 1
	}
	return (fac[a]*ifac[b]%mod)*ifac[a-b]%mod
}


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

int main()
{
    int k, a, b;
    cin >> k >> a >> b;
    bool ok = false;
    for(int i = a; i <= b; i += 1)
    {
        if(i%k == 0)
        {
            ok = true;
            break;
        }
    }
    if(ok == true)
    {
        cout << "OK" << endl;
    }
    else
    {
        cout << "NG" << endl;
    }
    return 0;
}


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

int main(){
  int h1,h2,m1,m2,k;
  cin >> h1 >> m1 >> h2 >> m2 >> k;
  int cnt = 60*(h2 - h1);
  if (m2 >= m1) cnt += m2 -m1;
  else cnt += - m1 + m2; 
  
  cout << cnt -k << endl;
}   

Measured memory_bytes: 3636
#include <stdio.h>

int main(){
	int k;
	int x;
	int sum;
	scanf("%d", &k);
	scanf("%d", &x);
	int total = k * 500;
	if(x <= total){
		printf("Yes""\n");
	}
  	else{
      	printf("No""\n");
    }
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int dp[1<<20][20];
int n,cost[20][20];
string s[20];

int rec(int S,int x){
  if(S==(1<<(n+1))-1)return 0;
  if(dp[S][x]!=-1)return dp[S][x];
  int ans=0;
  for(int i=0;i<n;i++){
    if(S>>i&1)continue;
    int re;
    if(cost[x][i]==s[i].size())re=rec(S+(1<<i),x);
    else re=rec(S+(1<<i),i);
    ans=max(ans,re+cost[x][i]);
  }
  return dp[S][x]=ans;
}


int c(string a,string b){
  for(int i=0;i<a.size();i++){
    int sum=0;
    int f=1;
    for(int j=0;j<b.size();j++){
      int ni=i+j;
      if(ni>=a.size())break;
      if(a[ni]!=b[j]){
	f=0;
	break;
      }
      sum++;
    }
    if(f)return sum;
  }
  return 0;
}

int main(){
  queue<int> q;
  while(cin>>n,n){
    int sum=0;
    for(int i=0;i<(1<<20);i++)
      for(int j=0;j<20;j++)
	dp[i][j]=-1;
    for(int i=0;i<n;i++){
      cin>>s[i];
      sum+=s[i].size();
    }
    for(int i=0;i<n;i++){
      for(int j=0;j<n;j++){
	cost[i][j]=c(s[i],s[j]);
      }
    }
    int ans=0;
    for(int i=0;i<n;i++){
      ans=max(ans,rec(1<<i,i));
    }
    q.push(sum-ans);
  }
  while(!q.empty()){
    cout<<q.front()<<endl;
    q.pop();
  }
  return 0;
}



Measured memory_bytes: 84932
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = (0); i < (n); ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define chmin(a, b) a = min(a, b)
#define chmax(a, b) a = max(a, b)
#define DEBUG(val) cout << #val << " : " << val << endl
#define MOD 1000000007

int main() {
  int n;
  int a[105][4];
  cin >> n;
  REP(i, n) { cin >> a[i][0] >> a[i][1] >> a[i][2]; }
  ll cx, cy, ans_h, h;
  REP(i, 101) {
    REP(j, 101) {
      REP(k, n) {
        h = a[k][2] + abs(a[k][0] - i) + abs(a[k][1] - j);
        if (h < 1) continue;
        REP(s, n + 1) {
          if (s == n) {
            cx = i;
            cy = j;
            ans_h = h;
            break;
          }
          if (a[s][2] != max((ll)0, h - abs(a[s][0] - i) - abs(a[s][1] - j))) {
            break;
          }
        }
      }
    }
  }

  cout << cx << " " << cy << " " << ans_h << endl;
}

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

int main(){
  int n;
  cin >> n;
  if(n==1 || n==2 || n==3 || n==4 || n==5 || n==6 || n==7 || n==8 || n==9 || n==10 || n==12 || n==14 || n==15 || n==16 || n==18 || n==20 || n==21 || n==24 || n==25 || n==27 || n==28 || n==30 || n==32 || n==35 || n==36 || n==40 || n==42 || n==45 || n==48 || n==49 || n==54 || n==56 || n==63 || n==64 || n==72 || n==81)cout << "Yes";
  else cout << "No";
  return 0;
}

Measured memory_bytes: 256
///who is the king ??? *** << t.mohammad >> *** ///
/*
                  00                                                                                                            00
                 00                               00                                                                           00
            0000000000                           00                                                                           00
           0000000000   000       000           00                        000       000  000       000                       00
              00       0000     0000           00         000000         0000     0000  0000     0000   000000              00
             00       00 00   00 00    000    00        00000000        00 00   00 00  00 00   00 00  00000000       00000000
            00       00  00 00  00   00000   000000    00    000       00  00 00  00  00  00 00  00  00    000     0000000000
           00       00   000   00  00   00  00000000  00    0000      00   000   00  00   000   00  00    0000    00     0000
          00       00         00  00   00  00    00  00    00 00     00         00  00         00  00    00 00   00     00 00
         00  00   00         00   00000   00    00  00000000  00    00         00  00         00  00000000  00  000000000  00
        00  00   00         00    000    00    00   000000    00   00         00  00         00   000000    00  0000000    00
*/
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std ;
#define int long long int
typedef long double ld ;
#define ff first
#define ss second
#define setp(t) cout << setprecision(t) << fixed ; 
int const N = 1e5 + 100 ;
int a[N] , dp[N] ;
int32_t main() {
	ios::sync_with_stdio(false) , cin.tie(0) , cout.tie(0) ;
	int n , k ;
	cin >> n >> k ;
	for (int i = 0 ; i < n ; i++) {
		cin >> a[i] ;
	}
	for (int i = 1 ; i < n ; i++) {
		int mn = INFINITY ;
		for (int j = i - 1 ; j >= max((int)0 , i - k) ; j--) {
			mn = min(mn , dp[j] + abs(a[i] - a[j])) ;
		}
		dp[i] = mn ;
	}
	return cout << dp[n - 1] , 0 ;
}


Measured memory_bytes: 1792
#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
input:
6 9
0 1 1
0 2 3
1 2 1
1 3 7
2 4 1
1 4 3
3 4 1
3 5 1
4 5 6

output:
5
"""

import sys
import heapq as hp

WHITE, GRAY, BLACK = 0, 1, 2


def generate_adj_table(v_table):
    for each in v_table:
        v_from, v_to, edge_weight = map(int, each)
        init_adj_table[v_from][v_to] = edge_weight
        init_adj_table[v_to][v_from] = edge_weight

    return init_adj_table


def prim_span_tree():
    distance[init_v] = 0
    distance_heap = []
    hp.heappush(distance_heap, (0, init_v))

    while distance_heap:
        current_vertex = hp.heappop(distance_heap)[1]

        color[current_vertex] = BLACK

        for adj_vertex, adj_weight in adj_table[current_vertex].items():
            if color[adj_vertex] is not BLACK:
                if adj_weight < distance[adj_vertex]:
                    distance[adj_vertex] = adj_weight
                    parent[adj_vertex] = current_vertex
                    color[adj_vertex] = GRAY
                    hp.heappush(distance_heap, (adj_weight, adj_vertex))

    return distance


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    vertices, edges = map(int, _input[0].split())
    v_info = map(lambda x: x.split(), _input[1:])

    parent = [-1] * vertices
    distance = [float('inf')] * vertices
    color = [WHITE] * vertices
    init_v = 0

    init_adj_table = tuple(dict() for _ in range(vertices))
    adj_table = generate_adj_table(v_info)
    print(sum(prim_span_tree()))

Measured memory_bytes: 38924
s = input()
odd = ''
even = ''
for i in range(len(s)):
    if i%2 == 0:
        odd = odd + s[i]
    else:
        even  = even + s[i]

odd_black_count = odd.count('0')
odd_white_count = odd.count('1')
even_black_count = even.count('0')
even_white_count = even.count('1')

print(min((odd_white_count + even_black_count),(odd_black_count + even_white_count)))


Measured memory_bytes: 3316
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime> 
#include <memory.h>
#include <assert.h>

using namespace std;

using ll = long long;
using pii = pair<int, int>;
const int INF = 1e9 + 1;
const ll LLINF = 1e18 + 1;

int main() {
    string s;
    cin >> s;

    int ans = 0;
    for(int i = 0; i < s.size(); i++) {
        if(s[i] == '+') ans++;
        if(s[i] == '-') ans--;
    }
 
    cout << ans << endl;

    return 0;
}

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

int main() {
    int n,m;
    cin>>n>>m;
    vector<int>a(m),b(m);
    vector<vector<int>>ro(n);
    rep(i,m)cin>>a[i]>>b[i];
    //input
    rep(i,m){
        ro[a[i]-1].push_back(b[i]-1);
        ro[b[i]-1].push_back(a[i]-1);//+1 at last
    }
    //graph
    vector<int>torch(n,-1);
    torch[0]=0;//do not output
    queue<int>que;
    que.push(0);
    //bfs
    int v,s;
    while(!que.empty()){
        v=que.front();//start from v;
        que.pop();
        s=ro[v].size();
        rep(i,s){//go to ro[v][i]
            if(torch[ro[v][i]]==-1){
                torch[ro[v][i]]=v;
                que.push(ro[v][i]);
            }
        }
    }
    
    cout<<"Yes"<<endl;
    for(int i=1;i<n;i++){
        cout<<torch[i]+1<<endl;
    }
    
	return 0;
}


Measured memory_bytes: 11612