akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, m, n) for(int i = m; i < (n); i++)
#define print(x) cout << (x) << endl;
#define printa(x,n) for(int i = 0; i < n; i++){ cout << (x[i]) << " ";} cout << endl;
#define printa2(x,m,n) for(int i = 0; i < m; i++){ for(int j = 0; j < n; j++){ cout << x[i][j] << " ";} cout << endl;}
#define printp(x,n) for(int i = 0; i < n; i++){ cout << "(" << x[i].first << ", " << x[i].second << ") "; } cout << endl;
#define INF (1e18)
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
typedef struct{
    int x;
    int y;
} P;
typedef struct{
    ll to;
    ll cost;
} edge;
typedef pair<ll, ll> lpair;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    ll a[100010];
    cin >> N;
    rep(i,0,N){
        cin >> a[i];
    }
    sort(a,a+N);
    ll sum[100010] = {};
    rep(i,0,N){
        sum[i+1] = sum[i] + a[i];
    }
    ll ans = 0;
    for(int i = N-1; i >= 0; i--){
        if(i == N-1){
            ans++;
        }else{
            ll val = sum[i+1];
            if(val * 2 >= a[i+1]){
                ans++;
            }else{
                print(ans);
                return 0;
            }
        }
    }
    print(ans);

}


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

typedef long long Int;
typedef pair<int,int> PII;
typedef vector<int> VInt;
 
#define FOR(i, a, b) for(i = (a); i < (b); ++i)
#define RFOR(i, a, b) for(i = (a) - 1; i >= (b); --i)
#define EACH(it, a) for(auto it = (a).begin(); it != (a).end(); ++it)
#define CLEAR(a, b) memset(a, b, sizeof(a))
#define SIZE(a) int((a).size())
#define ALL(a) (a).begin(),(a).end()
#define MP make_pair

bool check(string& S, int limit)
{
	int i;
	int a = 0, b = limit, step = 1;
	FOR(i, 0, SIZE(S))
	{
		if(S[i] == '0')
		{
			--a;
			--b;
		}
		else if(S[i] == '1')
		{
			++a;
			++b;
		}
		else
		{
			--a;
			++b;
		}
		if(a < 0) a += step;
		if(b > limit) b -= step;
		if(a > b) return false;
		if(a == b) step = 2;
	}
	return true;
}

void SolveTest(int test)
{
	string S;
	cin >> S;
	int mn = 0, mx = SIZE(S);
	while(mx - mn > 1)
	{
		int md = (mx + mn)/2;
		if(check(S, md)) mx = md;
		else mn = md;
	}
	cout << mx << endl;
}

int main()
{
	int T, t;
	T = 1;
	FOR(t, 0, T) SolveTest(t);
	return 0;
};

Measured memory_bytes: 5340
#include <bits/stdc++.h>
using namespace std;
#define rep(i, m, n) for (int i = m; i < n; ++i)
const int MOD = 1000000007;

long long solve(vector<long long> &V, int n) {
    long long res = 0;
    rep(i, 0, n) {
        res += V[i] * (i - n + i + 1);
        res %= MOD;
    }
    return res;
}

int main() {
    int N, M;
    cin >> N >> M;
    vector<long long> X(N);
    rep(i, 0, N) cin >> X[i];
    vector<long long> Y(M);
    rep(i, 0, M) cin >> Y[i];
    long long ans = solve(X, N) * (solve(Y, M)) % MOD;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1792
#include <cstdio>
#include <algorithm>
#include <vector>
#include <map>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define all(a) (a).begin(), (a).end()

using ll = long long;
constexpr ll mod = 1000000007;

ll N;
ll A[1000010];
ll prod = 1;

ll fact[1000010], inv[1000010];
std::map<ll, ll> mp;

ll powMod( ll x, ll y )
{
  ll ret = 1;

  while( y > 0 )
  {
    if( y & 1 )
      ret = (ret*x)%mod;

    x = (x*x)%mod;
    y >>= 1;
  }

  return ret;
}

ll comb( ll n, ll k )
{
  if( !n )
    return 1;
  if( n > k )
    return 1;

  return fact[n]*inv[k]%mod*inv[n-k]%mod;
}

int main()
{
  scanf( "%lld", &N );
  rep( i, N )
    scanf( "%lld", A+i );

  std::vector<ll> arr;
  ll p = 0;

  mp[-1] = 3;

  rep( i, N )
  {
    prod = prod*(mp[A[i]-1]-mp[A[i]]) % mod;

    ++mp[A[i]];
  }
  
  //printf( "prod: %lld\n", prod );

  //rep( i, 3 )
    //printf( "%lld ", arr[i] );

  //puts("");

  //printf( "p: %lld, prod; %lld\n", p, prod );

  printf( "%lld\n", prod%mod );

  return 0;
}

Measured memory_bytes: 10624
A,B,C=map(x->parse(Int,x),split(readline()))
if A==B==C
	println(A%2>0 ? 0 : -1)
else
	cnt=0
	while A%2+B%2+C%2==0
		A,B,C=div(B+C,2),div(C+A,2),div(A+B,2)
		cnt+=1
	end
	println(cnt)
end


Measured memory_bytes: 110600
N, M = map(int, input().split())
X = list(map(int, input().split()))

X.sort()

if N >= len(X):
    print(0)
    quit()

i = 0
dif = [0]*(M-1)
for i in range(M-1):
    dif[i] = X[i+1] - X[i]
    i += 1

dif.sort(reverse=1)
sum = sum(dif)

for i in range(N-1):
    sum = sum - dif[i]

print(sum)

Measured memory_bytes: 13960
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;

void solve1() {
	int A, B, C;
	cin >> A >> B >> C;
	if (A == B) {
		cout << C << endl;
	}
	else if (A == C)
	{
		cout << B << endl;
	}
	else
	{
		cout << A << endl;
	}
}

void solve2() {
	int H, W;
	cin >> H >> W;
	vector<string> map;
	string empty = "";
	for (int i = 0; i < W+2; i++)
	{
		empty += ".";
	}
	map.push_back(empty);

	for (int i = 0; i < H; i++)
	{
		string s;
		cin >> s;
		map.push_back("." + s + ".");
	}
	map.push_back(empty);


	for (int i = 1; i <= H; i++)
	{
		for (int j = 1; j <= W; j++)
		{
			int count = 0;
			if (map[i][j] == '#') {
				continue;
			}
			int dx[] = { -1,1,0,0,-1,-1,1,1 };
			int dy[] = { 0,0,-1,1,-1,1,-1,1 };
			for (int k = 0; k < 8; k++)
			{
				if (map[i + dx[k]][j + dy[k]] == '#') {
					count++;
				}
			}
			map[i][j] = '0' + count;
		}
	}
	for (int i = 1; i <= H; i++)
	{
		for (int j = 1; j <= W; j++)
		{
			cout << map[i][j];
		}
		cout << endl;
	}
}

void solve3() {

}

void solve4() {

}

int main() {
	//solve1();
	solve2();
	//solve3();
	//solve4();

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define ll long long
#define debug(x) cout<<x<<endl;
#define int ll
const ll INF = 1e18;
const ll mod = 1e9 + 7;
const ll N = 2e5 + 5;
 
int32_t main()
{
	#ifndef ONLINE_JUDGE
		freopen("a.in","r",stdin);
	#endif
	ios::sync_with_stdio(false);
 
 	int n,w;
 	cin>>n>>w;
 	vector<int> cost(n), val(n);
 	for(int i=0;i<n;i++)
 		cin>>cost[i]>>val[i];

 	vector<vector<int> > dp(n, vector<int>(w+1, 0));
 	for(int j=cost[0];j<=w;j++)
 		dp[0][j] = val[0];
 	
 	for(int i=1;i<n;i++)
 	{
 		for(int j=0;j<cost[i];j++)
 			dp[i][j] = dp[i-1][j];
 		for(int j=cost[i];j<=w;j++)
 			dp[i][j] = max(dp[i-1][j], dp[i-1][j-cost[i]] + val[i]);
 	}

 	cout<<dp[n-1][w]<<endl;
 
	return 0;
}

Measured memory_bytes: 82440
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        n %= 500;
        int a = sc.nextInt();
        if (a >= n) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 23636
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
typedef  long long ll;
ll gcd(ll x,ll y){
   if(y==0) return x;
   else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
   return x/gcd(x,y)*y;
}
using namespace std;
int main(){ 
   int n;
   cin>>n;
   vector<int> a(n);
   rep(i,n){
      cin>>a[i];
   }
   sort(a.begin(),a.end());

   int alice=0,bob=0;
   if(n%2==0){
      rep(i,n){
         i%2==0? bob+=a[i]:alice+=a[i];
      }
   }
   else{
      rep(i,n){
         i%2==0? alice+=a[i]:bob+=a[i]; 
      }
   }
   cout<<alice-bob;


   
   return 0;
}

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

using namespace std;

#define FAST() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

vector<int>digits;
int n,sz,ans=INT_MAX;

void Check(int cur,int pos)
{
    if(pos > sz)
    {
        if(cur >= n)ans=min(ans,cur);
        return;
    }
    for(int x : digits)Check(cur*10+x,pos+1);
}

int main()
{
    FAST();
    int i,k,x;
    bool mark[10]={0};
    cin >> n >> k;
    for(i=0;i<k;i++)
    {
        cin >> x;
        mark[x]=1;
    }
    for(i=0;i<10;i++)
    {
        if(!mark[i])digits.emplace_back(i);
    }
    sz=to_string(n).size();
    Check(0,1);
    if(ans < INT_MAX)cout << ans;
    else
    {
        if(digits[0] == 0)cout << digits[1];
        else cout << digits[0];
        for(i=0;i<sz;i++)cout << digits[0];
    }
    return 0;
}


Measured memory_bytes: 3724
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <iomanip>
#include <bitset>
#include <set>
#include <map>
#include <stdio.h>
#include <numeric>
#include <cstring>

#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define MOD 1000000007 //10^9+7
using namespace std;
using ll = long long;
using PII = pair<int, int>;
using PLL = pair<ll, ll>;
const int INF = numeric_limits<int>::max();
const ll INFL = numeric_limits<ll>::max();


// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}

//greatest common divisor
long long gcd(ll a, ll b) 
{
    if (a % b == 0) {
        return b;
    } else {
        return gcd(b, a % b);
    }
}

//least common multiple
long long lcm(ll a, ll b)
{
    return a / gcd(a, b) * b ;
}

ll factorial(ll n) {
    ll res = 1;
    for (ll i = 1; i <= n; i++) {
        res *= i;
    }
    return res;
}

int main()
{
    int n, m; cin >> n >> m;
    vector<ll> x(m);
    rep(i,m) cin >> x[i];
    sort(x.begin(), x.end());
    vector<ll> d(m-1);
    
    rep1(i,m) d[i-1] = abs(x[i] - x[i-1]);
    sort(d.begin(),d.end());

    ll ans = 0;
    rep(i,m-1-n+1) {
        ans += d[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4612
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9
#define PI 3.14159265359
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
#define ALLR(v) v.rbegin(),v.rend()
typedef long long ll;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//isPrime
//modpow modinv
//getDigit
int main() {
  cout << fixed << setprecision(10);
  int x1,y1,x2,y2;
  cin >> x1 >> y1 >> x2 >> y2;
  int dx = -y2+y1;
  int dy = x2-x1;
  cout << x2+dx << " ";
  cout << y2+dy << " ";
  cout << x1+dx << " ";
  cout << y1+dy << endl;
}


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

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int a = stdIn.nextInt(); //500円の枚数
		int b = stdIn.nextInt(); //100円の枚数
		int c = stdIn.nextInt(); //50円の枚数
		int x = stdIn.nextInt(); 
		int cnt = 0;
		
		for(int i = 0; i <= a; i++) {
			for(int j = 0; j <= b; j++) {
				for(int k = 0; k <= c; k++) {
					if(x == (i*500)+(j*100)+(k*50)) {
						cnt++;
					}
				}
			}
		}
		
		System.out.println(cnt);
		
		
		
		
	}

}


Measured memory_bytes: 21972
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main(){
    ll n,k,i;
    cin>>n;
    ll a[n];
    for(i=0;i<n;++i)
        cin>>a[i];
    ll ans = 0;
    for(i=1;i<=n;++i){
        if(i%2 && a[i-1]%2)
            ans ++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3628
#include<iostream>
#include <cmath>
using namespace std;
int main()
{
    int n, d;
    cin >> n >> d;
  
    int x[10][10];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < d; j++) {
        cin >> x[i][j];
      }
    }
  
    int dis, dis_tmp, root;
    int count = 0;
    for (int i = 0; i < n-1; i++) {
      for (int j = i+1; j < n; j++) {
        dis = 0;
        for (int k = 0; k < d; k++) {
          dis_tmp = x[i][k] - x[j][k];
          dis += dis_tmp * dis_tmp;
        }
        root = floor(sqrt(dis));
        if (root * root == dis) count++;
      }
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define INF 1000000000
#define MOD 1000000007
int dx[4]={1,0,-1,0},dy[4]={0,-1,0,1};
using namespace std;
int main(void){
    int n;
    string s;
    cin>>n>>s;
    int w[n]={},e[n]={};
    for(int i=0;i<n;i++){
        if(s[i]=='W'){
            w[i]=1;
        }else{
            e[i]=1;
        }
    }
    for(int i=1;i<n;i++){
        w[i]+=w[i-1];
        e[i]+=e[i-1];
    }
    int ans=INF;
    for(int i=0;i<n;i++){
        int tmp=0;
        if(i)tmp+=w[i-1];
        tmp+=e[n-1]-e[i];
        ans=min(ans,tmp);
    }
    cout<<ans<<endl;
 return 0;   
}

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

int main() {
    ll N;
	cin >> N;

	vector<pair<ll,int> > x;
	ll num = N; 
    int cnt = 0;
	for (ll i = 2; i*i <= N; i++){
        int cnt = 0;
        while(num % i == 0){
            num /= i;
            cnt++;
        }
        x.emplace_back(i,cnt);
	}
    if(num != 1){
        x.emplace_back(num,1);
    }
    int ans = 0;
    for(auto p: x){
        int c = p.second;
        int k = 1;
        while(k <= c){
            ans++;
            c -= k;
            k++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 19780
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define rREP(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    char a,b,c;
    cin >> a >> b >> c;
    cout << a - '0' + b - '0' + c - '0' << endl;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys


N = int(input())
print(0)
s = input()

def judge(x):
    print(x)
    l = input()
    if l=='Vacant':
        sys.exit()
    if x%2 == 0:
        if l == s:
            return True
        else:
            return False
    else:
        if l==s:
            return False
        else:
            return True            
    


ok = 0
ng = N-1
while (abs(ok-ng)>1):
    mid = (ok+ng)//2
    if judge(mid):
        ok = mid
    else:
        ng = mid
        
print(N-1)
l = input()

Measured memory_bytes: 3660
#include <stdio.h>

int main()
{
  int a, b, c;

  scanf("%d%d%d", &a, &b, &c);

  if ( a < b && b < c ) {
    
    printf("Yes\n");

  } else {
  
    printf("No\n");
  
  }

  return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define ppb pop_back
#define INF 1e18
typedef long long ll;

using namespace std;

int main(int argc,char* argv[])
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n;
    string s;
    cin>>n>>s;
    ll sum=0;

    int i =0;
    while(i<s.size())
    {
        sum++;
        char x = s[i];
        while(x == s[i])i++;
    }

    cout<<sum<<endl;

    return 0;
}

Measured memory_bytes: 512
n = int(input())
h = list(map(int, input().split()))
ans = 0
cnt = 0
while sum(h) != 0:
    #print(ans, h)
    #if cnt == 10: break
    cnt += 1
    beg = 0  # 始点
    i = 0
    mn = 200
    while i < n:
        if h[i] == 0:
            if mn != 200:
                ans += mn
                for j in range(beg, i):
                    h[j] -= mn
                mn = 200
            beg = i + 1  # 始点の書き換え
        else: mn = min(mn, h[i])
        i += 1
    if mn != 200:
        ans += mn
        for j in range(beg, n):
            h[j] -= mn
print(ans)



Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <numeric>
#include <algorithm>
using namespace std;

int main() {
	int n;
	cin >> n;
	
	vector<long long int> v(n);
	for(int i=0;i<n;i++){
		cin >> v[i];
	}
	
	long long int min = *min_element(v.begin() , v.end());
	long long int max = *max_element(v.begin() , v.end());
	
	long long int sum = 0;
	for(int i=0;i<n;i++){
		sum += v[i];
	}
	
	cout << min << ' ' << max << ' ' << sum << endl;
}

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

int main()
{
  int N ;
  cin>>N ;
  vector<pair<int,int>>X(N) ;
  for(int i=0;i<N;i++){
    cin>>X.at(i).first ;
    X.at(i).second=i  ;
  }
  sort(X.begin(),X.end()) ;
  //for(int i=0;i<N;i++) cout<<"("<<X.at(i).first<<","<<X.at(i).second<<")"<<endl ;
  vector<int>C(N) ;
  for(int i=0;i<N;i++){
    if(i<N/2) C.at(X.at(i).second)=X.at(N/2).first ;
    else C.at(X.at(i).second)=X.at(N/2-1).first ;
  }
  for(int i=0;i<N;i++) cout<<C.at(i)<<endl ;
  
  return 0 ;
}

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

long long n, m;
vector<int> G[101010];
bool f[101010][2];

inline int in() {
  int x;
  cin >> x;
  return x;
}

void dfs(int v = 0, int d = 0) {
  if (f[v][d]) return;
  f[v][d] = true;

  for (auto to : G[v]) {
    dfs(to, (d + 1) & 1);
  }
}

int main() {
  cin >> n >> m;

  for (int i = 0; i < m; ++i) {
    int a = in() - 1, b = in() - 1;
    G[a].push_back(b);
    G[b].push_back(a);
  }

  dfs();

  if (f[0][1]) {
    cout << n * (n - 1) / 2 - m << endl;
  } else {
    int cnt = 0;
    for (int i = 0; i < n; ++i) {
      if (f[i][0]) cnt++;
    }

    cout << cnt * (n - cnt) - m << endl;
  }
}


Measured memory_bytes: 7168
N=int(input())
h=list(map(int,input().split()))
dp=[10**10 for i in range(N)]
dp[0]=0
for i in range(N-1):
    if i<N-1:
        dp[i+1]=min(dp[i+1], dp[i]+abs(h[i+1]-h[i]))
    if i<N-2:
        dp[i+2]=min(dp[i+2], dp[i]+abs(h[i+2]-h[i]))
print(dp[N-1])

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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

int next_combination(int bit) {
    int x = bit & -bit, y = bit + x;
    return (((bit & ~y) / x) >> 1) | y;
} /*(1<<k)-1から列挙*/

int main(){
    int n, m, q;
    cin >> n >> m >> q;
    vector<int> a(q), b(q), c(q), d(q);
    for (int i = 0; i < q; ++i) {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
        a[i]--; b[i]--;
    }

    int bit = (1<<n)- 1;
    int res = 0;
    while (bit < 1<<(n+m-1)){
        int now = 1;
        vector<int> A;
        for (int i = 0; i < n+m-1; ++i) {
            if (bit & (1<<i)) A.push_back(now);
            else now++;
        }

        int tmp = 0;
        for (int i = 0; i < q; ++i) {
            if (A[b[i]] - A[a[i]] == c[i]) tmp += d[i];
        }
        chmax(res, tmp);

        bit = next_combination(bit);
    }
    cout << res << endl;
}

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

int main() {
  int N;
  cin >> N;
  if(N<=111){
    cout << 111 << endl;
  }else if(N<=222){
    cout << 222 << endl;
  }else if(N<=333){
    cout << 333 << endl;
  }else if(N<=444){
    cout << 444 << endl;
  }else if(N<=555){
    cout << 555 << endl;
  }else if(N<=666){
    cout << 666 << endl;
  }else if(N<=777){
    cout << 777 << endl;
  }else if(N<=888){
    cout << 888 << endl;
  }else if(N<=999){
    cout << 999 << endl;
  }
}

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

int main()
{
	int N;
	cin >> N;
	vector<int> a(N + 1);
	for (int i = 0; i < N; i++) {
		cin >> a[i + 1];
	}
	for (int i = N; i >= 1; i--) {
		for (int j = i + i; j <= N; j += i) {
			a[i] -= a[j];
		}
	}
	vector<int> res;
	bool ng = false;
	for (int i = 1; i <= N; i++) {
		if (a[i] & 1) res.push_back(i);
	}
	if (ng) {
		cout << -1 << endl;
		return 0;
	}
	cout << res.size() << endl;
	for (int i = 0; i < (int)res.size(); i++) {
		cout << res[i] << " \n"[i + 1 == (int)res.size()];
	}
	return 0;
}


Measured memory_bytes: 2424
#include<stdio.h>
#define N 8
#define FREE 0
#define NOT_FREE 1
void putQueen(int);
void initialization(void);
void print(void);

int row[N],col[N],dpos[2*N-1],deng[2*N-1];
int judge[N][N];

int main(){
    int i,j,k,r,c;
    
    initialization();

    for(i=0;i<N;i++){
        for(j=0;j<N;j++){
            judge[i][j] = 0;
        }
    }

    scanf("%d",&k);

    for(i=0;i<k;i++){
        scanf("%d%d",&r,&c);
        judge[r][c] = 1;
    }

    putQueen(0);

    return 0;
}
void initialization(){
    int i;

    for(i=0;i<N;i++){
        row[i] = col[i] = FREE;
    }
    for(i=0;i<2*N-1;i++){
        dpos[i] = deng[i] = FREE;
    }
}
void print(){
    int i,j;

    for(i=0;i<N;i++){
        for(j=0;j<N;j++){
            if(judge[i][j] == 1){
                if(row[i] != j){
                    return;
                }
            }
        }
    }
    for(i=0;i<N;i++){
        for(j=0;j<N;j++){
            if(row[i] == j){
                printf("Q");
            }
            else{
                printf(".");
            }
        }
        printf("\n");
    }
}
void putQueen(int i){
    int j;

    if(i == N){
        print();
        return;
    }
    for(j=0;j<N;j++){
        if(col[j] == NOT_FREE ||
        dpos[i+j] == NOT_FREE || deng[i-j+N-1] == NOT_FREE){
            continue;
        }
        row[i] = j;
        col[j] = dpos[i+j] = deng[i-j+N-1] = NOT_FREE;
        putQueen(i+1);
        col[j] = dpos[i+j] = deng[i-j+N-1] = FREE;
    }
}


Measured memory_bytes: 2108
#include <bits/stdc++.h>
#define ll long long

using namespace std;

int main(){
    int n, count = 0;
    cin >> n;
    int a[n];
    for (int i = 0; i < n; i++){
        cin >> a[i];
    }
    sort(a, a+n);
    for(int i = 0; i < n;){
        if(a[i] == a[i+1]){
            i+=2;
        }else{
            count++;
            i++;
        }
    }
    cout << count;


    return 0;
}


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

#define MAX 1000000
int T[4][MAX + 5];
int convert(char[], int*);
int hashSearch(int, int);
int hashInsert(int, int);
int hash(int, int);

int main()
{
	int n;
	int i, ix;
	int count = 0;
	int store, find;

	scanf("%d", &n);
	char tempCmd[13];
	char tempChar[13];

	for (i = 0; i < n; i++) {
		scanf("%s %s", tempCmd, tempChar);
		if (tempCmd[0] == 'i') {
			store = convert(tempChar, &ix);
			if (hashInsert(store, ix) != -1) count++;
		}
		if (tempCmd[0] == 'f') {
			find = convert(tempChar, &ix);
			(hashSearch(find, ix) == -1) ? printf("no\n") : printf("yes\n");
		}
	}
	return 0;
}

int convert(char source[], int *ix) {
	int i;
	int value = 0;
	int p = 1;

	for (i = 0; i < strlen(source); i++) {
		int coef = 0;
		switch (source[i]) {
		case 'A': coef = 1;
			break;
		case 'T': coef = 2;
			break;
		case 'C': coef = 3;
			break;
		case 'G': coef = 4;
			break;
		}
		if (i == strlen(source) - 1) *ix = coef - 1;
		value += coef * p;
		p *= 5;
	}
	return value;
}

int hashInsert(int k, int row) {
	int i = 0;
	while (1) {
		int hashKey = hash(k, i);
		if (T[row][hashKey] == 0) {
			T[row][hashKey] = k;
			return hashKey;
		}
		i++;
	}
	return -1;
}

int hashSearch(int k, int row) {
	int i = 0;
	while (1) {
		int hashKey = hash(k, i);
		if (T[row][hashKey] == k) return hashKey;
		if (T[row][hashKey] == 0 || i >= MAX) return -1;
		i++;
	}
	return -1;
}

int hash(int k, int i) {
	int hash1 = k % MAX;
	int hash2 = 1 + k % (MAX - 1);
	int ans = ((hash1 + i * hash2) % MAX);
	if (ans < 0) ans *= -1;
	return ans;
}






Measured memory_bytes: 17240
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> int_pair;
typedef pair<ll,ll> ll_pair;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
const ll inf = 1e9+7;
const ll N=100001;
ll n,h,a[N],b[N],ans=0,d=0;
priority_queue<ll> q;
ll amax=0;

int main(){
	cin>>n>>h;
	FOR(i,0,n){
		cin>>a[i]>>b[i];
		if(amax<a[i])amax=a[i];
	}
	FOR(i,0,n){
		if(b[i]>amax)q.push(b[i]);
	}
	while(q.size()){
		if(h<=0)break;
		h-=q.top();
		q.pop();
		ans++;
	}
	if(h>0){
		ll ama=h%amax;
		ans+=h/amax;
		if(ama)ans++;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 2936
using System;
using System.Linq;

namespace B___Can_you_solve_this
{
    class Program
    {
        static void Main(string[] args)
        {
            var N_M_C = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
            int N = N_M_C[0], M = N_M_C[1], C = N_M_C[2];
            var Bm = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
            var Anm = new int[N].Select(_ => Console.ReadLine().Split().Select(int.Parse).ToArray()).ToArray();
            int sum = 0, count = 0;

            for (int n = 0; n < N; n++)
            {
                sum = C;

                for (int m = 0; m < M; m++)
                    sum += Anm[n][m] * Bm[m];

                if (sum > 0)
                    count++;
            }

            Console.WriteLine(count);
        }
    }
}


Measured memory_bytes: 13524
Program ABC159C
   implicit none
   integer::L,i,j
   real(8)::Vmax=0,xmax,ymax,zmax,x,y,z,V

      read *,L
      do i=1,100
         x=real(L)*real(i)/100.0
         do j=1,100
            y=(real(L)-x)*real(j)/100.0
            z=real(L)-x-y
            V=x*y*z
            if (V>Vmax) then
               Vmax=V
               xmax=x
               ymax=y
               zmax=z
            end if
         end do
      end do

      do i=-50,50
         x=xmax+real(L)*real(i)/10000.0
         do j=-50,50
            y=ymax+real(L)*real(j)/10000.0
            z=real(L)-x-y
            V=x*y*z
            if (V>Vmax) then
               Vmax=V
            end if
         end do
      end do

      print *,Vmax
      stop

   End Program ABC159C

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

int main(){
    int h, w;
    cin >> h >> w;

    vector<vector<char> > s(h+2, vector<char>(w+2, '.'));
    for(int i=1; i<=h; i++){
        for(int j=1; j<=w; j++){
            cin >> s[i][j];
        }
    }

    int d1[] = {1, 1, 1, -1, -1, -1, 0, 0}, d2[] = {1, 0, -1, 1, 0, -1, 1, -1};
    for(int i=1; i<=h; i++){
        for(int j=1; j<=w; j++){
            if(s[i][j] == '#'){
                cout << '#';
            }else{
                int num = 0;
                for(int k=0; k<8; k++){
                    if(s[i+d1[k]][j+d2[k]] == '#'){
                        num++;
                    }
                }
                cout << num;
            }
        }
        cout << endl;
    }
  
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<cmath>
#include<algorithm>
int main(void)
{
	int N, S[110], A = 1, k = 0;
	scanf("%d", &N);
	for (int i = 0; i < N; i++)
	{
		scanf("%d", &S[i]);
	}
	for (int i = 0; i < N - 1; i++)
	{
		if (i == 0)
		{
			k = S[0];
		}
		if (k <= S[i + 1])
		{
			k = S[i + 1];
			A++;
		}
	}

	printf("%d", A);
	return 0;
}

Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }
struct Card {
	char c;
	int v;
	Card(){}
	Card(char c, int v) :c(c), v(v) {}
	bool operator>(const Card &p) const{
		return v > p.v;
	}
	bool operator==(const Card &p)const {
		return c == p.c&&v == p.v;
	}

};
ostream &operator<<(ostream &os, const Card &p) {
	os << p.c << p.v;
	return os;
}
void BubbleSort(vector<Card>v) {
	vector<Card>w(v);
	for (int i = 0; i < w.size(); i++) {
		for (int j = w.size() - 1; j > i; j--) {
			if (w[j - 1] > w[j])swap(w[j - 1], w[j]);
		}
	}
	rep(i, 0, w.size())cout << w[i] << (i == w.size() - 1 ? '\n' : ' ');

	for(int i=0;i<w.size()-1;i++)for(int j=i+1;j<w.size();j++)
		for(int a=0;a<w.size()-1;a++)for(int b=a+1;b<w.size();b++)
			if (w[i] == v[b] && w[j] == v[a] && w[i].v == w[j].v) {
				dump(i, j, a, b);
				cout << "Not stable" << endl;
				return;
			}
	cout << "Stable" << endl;
	return;
}

void SelectionSort(vector<Card>v) {
	vector<Card>w(v);
	rep(i, 0, w.size()) {
		int index = i;
		rep(j, i + 1, w.size())if (w[index] > w[j])index = j;
		swap(w[index], w[i]);
	}

	rep(i, 0, w.size())cout << w[i] << (i == w.size() - 1 ? '\n' : ' ');

	for (int i = 0; i<w.size() - 1; i++)for (int j = i + 1; j<w.size(); j++)
		for (int a = 0; a<w.size() - 1; a++)for (int b = a+1; b<w.size(); b++)
			if (w[i] == v[b] && w[j] == v[a] && w[i].v == w[j].v) {
				cout << "Not stable" << endl;
				return;
			}
	cout << "Stable" << endl;
	return;
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N; cin >> N;
	vector<Card>cards;
	rep(i, 0, N) {
		char c; int v;
		cin >> c >> v;
		cards.emplace_back(Card(c, v));
	}
	BubbleSort(cards);
	SelectionSort(cards);
	return 0;
}

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

#define ll long long
#define endl '\n'
#ifndef _WINDOWS
// no getchar_unlocked on Windows so just call getchar
#define getchar getchar_unlocked
#endif

template <typename Func>
inline void loop(int e, Func&& f) {
    for (int i = 0; i < e; i++) {
        std::forward<Func>(f)(i);
    }
}
template <typename Func>
inline void loop(int s, int e, Func&& f) {
    for (int i = s; i < e; i++) {
        std::forward<Func>(f)(i);
    }
}
template <typename T>
inline void scanpn(T& num) {
    register int c;
    num = 0;
    c = getchar();
    for (; (c > 47 && c < 58); c = getchar()) num = num * 10 + c - 48;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    priority_queue<int> nums;
    int tmp, sum = 0;
    for (int i = 0; i < n; i++) {
        cin >> tmp;
        sum += tmp;
        nums.push(tmp);
    }
    double base = (double)sum / (4 * m);
    for (int i = 0; i < m - 1; i++) {
        nums.pop();
    }
    if (nums.top() < base) {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }
    return 0;
}


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

#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define intll int long long
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main() {
  intll n , k ;
  cin >> n >> k ;
  n = n % k ;
  
  while( abs(n - k) < n ) {
    n = abs(n-k) ;
  }
  
  cout << n ;
  
    

}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
 
int main(void){
   char cards[201],sub[200];
   int i,m,h,len;
    
   while(scanf("%s",cards),strcmp(cards,"-")){
       scanf("%d",&m);
       len=strlen(cards);
       for(i=0;i<m;i++) {
           scanf("%d",&h);
           strcpy(sub,&cards[h]);
           strcat(sub,cards);
           sub[len]='\0';
           strcpy(cards,sub);
       }
       printf("%s\n",cards);
   }
    
    return 0;
}


Measured memory_bytes: 2104
/*
 * Owner   : Tatsuhiro Hashimoto
 * Created : 2020-05-02 (Thu)
 */

#include <bits/stdc++.h>
using namespace std;

#define endl "\n"
#define FSP(n) cout << fixed << setprecision(n);
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
static inline ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b);}
static inline ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
#define prepare cin.tie(0); cout.tie(0); ios::sync_with_stdio(false);

ull X;

void solve() {
    int cnt = 0;
    ull ans = 100;
    while(true) {
        ans += ans * 0.01;
        cnt++;
        if (ans >= X) break;
    }
    cout << cnt << endl;
}

signed main() {
    prepare
    cin >> X;
    solve();
}

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

int main(){
  string s;
  cin >> s;
  if (s.size()>3){
    if ((s.at(0)=='Y' && s.at(1)=='A') && (s.at(2)=='K' && s.at(3)=='I')){
      cout << "Yes" << endl;}
    else cout << "No" << endl;
  }
  else cout << "No" << endl;
}


Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func main() {
	sc.Split(bufio.ScanWords)
	sc.Scan()
	s := sc.Text()
	n := len(s)
	if string(s[0]) == "A" {
	} else {
		fmt.Println("WA")
		return
	}

	if strings.Count(string(s[2:n-1]), "C") == 1 {
	} else {
		fmt.Println("WA")
		return
	}

	for i := 0; i < n; i++ {
		if string(s[i]) == "A" || string(s[i]) == "C" {
			continue
		}
		if s[i] < 97 {
			fmt.Println("WA")
			return
		}
	}

	fmt.Println("AC")
}


Measured memory_bytes: 640
package main

import (
  "math"
  "fmt"
)

func main() {
  var m, k int
  fmt.Scanf("%d %d\n", &m, &k)
  max := int(math.Pow(2, float64(m)))
  if k >= max {
    fmt.Print("-1\n")
    return
  }
  if k == 1 && m == 1 {
    fmt.Print("-1\n")
    return
  }
  if k == 0 && m == 1 {
    fmt.Print("0 0 1 1\n")
    return
  }
  digits := []int{}
  for i := 0; i < int(max); i++ {
    digits = append(digits, i)
  }
  for _, i := range digits {
    if i == k {
      continue
    }
    fmt.Print(i, " ")
  }
  fmt.Print(k, " ")
  for left, right := 0, len(digits)-1; left < right; left, right = left+1, right-1 {
  	digits[left], digits[right] = digits[right], digits[left]
  }
  for _, i := range digits {
    if i == k {
      continue
    }
    fmt.Print(i, " ")
  }
  fmt.Print(k, "\n")
}


Measured memory_bytes: 8320
from collections import deque
V,E = map(int,input().split())
G = [[] for _ in range(V)]
reached = [False]*V
indeg = [0]*V
for _ in range(E):
    s,t = map(int,input().split())
    G[s].append(t)
    indeg[t] += 1
out = []

def bfs(s):
    Q = deque()
    Q.append(s)
    reached[s] = True
    while Q:
        u = Q.popleft()
        out.append(u)
        for v in G[u]:
            indeg[v] -= 1
            if indeg[v] == 0 and reached[v] == False:
                reached[v] = True
                Q.append(v)

def topologicalSort():
    for u in range(V):
        if indeg[u] == 0 and reached[u] == False: bfs(u)

topologicalSort()
for i in out: print(i)


Measured memory_bytes: 9276
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int c = sc.nextInt();
        int[] b = new int[m];
        for (int i = 0; i < m; i++) {
            b[i] = sc.nextInt();
        }

        int ans = 0;
        for (int i = 0; i < n; i++) {
            int candidate = c;
            for (int j = 0; j < m; j++) {
                int a = sc.nextInt();
                candidate += a * b[j];
            }
            if (candidate > 0) {
                ans++;
            }
        }
        System.out.println(ans);

        sc.close();
    }

}


Measured memory_bytes: 22612
#include <iostream>
using namespace std;
int main( ){
  int H,W;
  while(true){
     cin>>H;
     cin>>W;
     if(H==0 && W==0){
         break;
     }
        for ( int i = 0; i < H; i++ ){
            
            for ( int j = 0; j < W; j++ ){
                cout << "#";
            }
            cout<<endl;
        }
        cout << endl;
  }
}



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

int main() {
	string S;
	cin >> S;
	int C_0 = 0, C_1 = 0;
	for (int i = 0; i < S.size(); i++) {
		if (S[i] == '0')C_0++;
		if (S[i] == '1')C_1++;
	}
	cout <<2* min(C_0, C_1) << endl;
	return 0;
}

Measured memory_bytes: 512
///By Stephan Ramirez dsramirezc@unal.edu.co
#include<bits/stdc++.h>
#define ms(a,v) memset(a,v,sizeof a)
#define ll long long
#define N 101
using namespace std;
int n;
ll s[N][3];
int main(){
	#ifdef LOCAL
		freopen("in.txt","r",stdin);
		//freopen("out.txt","w",stdout);
	#endif
    scanf("%d",&n);
    for(int i=0;i<n;i++)
        scanf("%lld %lld %lld",&s[i][0],&s[i][1],&s[i][2]);
    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            set<ll> st;
            ll mx=1e10;
            bool flag=true;
            int ind=-1;
            for(int k=0;k<n;k++){
                if(s[k][2]>0){
                    ll h=s[k][2]+abs(i-s[k][0])+abs(j-s[k][1]);
                    ind=k;
                    st.insert(h);
                }else{
                    mx=min(mx,abs(i-s[k][0])+abs(j-s[k][1]));
                }
            }
            if(st.size()==1 && s[ind][2]+abs(i-s[ind][0])+abs(j-s[ind][1])>0 && s[ind][2]+abs(i-s[ind][0])+abs(j-s[ind][1])<=mx){
                cout<<i<<" "<<j<<" "<<s[ind][2]+abs(i-s[ind][0])+abs(j-s[ind][1])<<endl;
                return 0;
            }
        }
    }

	return 0;
}



Measured memory_bytes: 256
# -*- coding: utf-8 -*-
s = int(input())
l = [s]
a = s
for i in range(2, 1000000):
  if(a%2==0):
    b = int(a/2)
  else:
    b = 3*a+1

  if(b in l):
    print(i)
    break
  else:
    l.append(b)
    a = b


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

bool isKaibun(string s) {
  string x = s.substr(0, s.size() / 2);
  string y;
  if (s.size() % 2 == 0) {
    y = s.substr(s.size() / 2, s.size() / 2);
  } else {
    y = s.substr(s.size() / 2 + 1, s.size() / 2);
  }
  //cout << s << ":" << x << " " << y << endl;
  reverse(y.begin(),y.end());
  if (x == y) {
    return true;
  } else {
    return false;
  }
}

int main() {
  string S;
  cin >> S;
  bool a = false, b = false, c = false;
  a = isKaibun(S);
  b = isKaibun(S.substr(0, (S.size() - 1) / 2));
  c = isKaibun(S.substr((S.size() + 3) / 2 - 1, S.size() - ((S.size() + 3) / 2) + 1));
  //cout << a << " " << b << " " << c << endl;
  if (a && b && c) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
a, b, c = gets.split.map(&:to_i).sort!
a, b = c - a, c - b

diva, a = a.divmod(2)
divb, b = b.divmod(2)
ans = diva + divb

case a + b
when 2
  ans += 1
when 1
  ans += 2
end

puts ans


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

int main(){
  int64_t n,l=1LL,ll=2LL,tmp;
  cin >> n;
  for(int i=2;i<=n;i++){
    tmp = l;
    l = l+ll;
    ll = tmp;
  }
  cout << l << endl;
}
  

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007
using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
typedef pair<double,int> Pdi;
const ll INF=100000000000000001;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
priority_queue<Pdi,vector<Pdi>,greater<Pdi>> que;
vector<Pli> v[18];
P2 xy[MAX_N]={};
ll dp[1<<18]={};
string str[100000];
typedef pair<int,int> O;
typedef pair<O,O> P;
int main() {
	int n,x;
	int a[101];
	cin>>n>>x;
	rep(i,n){
		cin>>a[i];
	}
	sort(a,a+n);
	int t=0;
	int y=x;
	rep(i,n){
		if(y>=a[i]){
			t++;
			y-=a[i];
		}else{
			y=0;
		}
	}
	if(y>0)--t;
	cout<<t<<endl;
	return 0;
}


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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

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

  int R;
  std::cin >> R;

  int res = R * R;
  std::cout << res << std::endl;
}


Measured memory_bytes: 256
#include<stdio.h>

int fib(int);
int n;

int main(){
  int i,fib[44];

  scanf("%d",&n);

  fib[0] = 1;
  fib[1] = 1;

  for(i=2;i<=n;i++)
    fib[i] = fib[i-1] + fib[i-2];

  printf("%d\n",fib[n]);

  return 0;
}

/*int fib(int i){
  int f;
  if(i == 0|i == 1)
    return 1;

  for(i=3;i<=n;i++){
    f = fib(i-1)+fib(i-2);
  }

  return f;
}*/



Measured memory_bytes: 2112
#include <bits/stdc++.h>
#define N 101
#define INF 1e9
using namespace std;
int n,g[N][N],ans;
vector<int> V;

void calc(){
  int sum=0;
  for(int i=0;i<V.size();i++){
    int mn=INF;
    for(int j=0;j<V.size();j++)if(i!=j) mn=min(mn,g[V[i]][V[j]]);
    sum+=mn;
  }
  ans=max(ans, (V.size()>1)*sum);
}


vector<bool> used(N);
void solve(int pos){
  if(pos==n){calc();return;}
  solve(pos+1);
  if(used[pos])V.push_back(pos),solve(pos+1),V.pop_back();
}

vector<int> G[N];
int can[N];
set<vector<bool> > S;
void dfs(int pos,int cnt){
  int flg=1,len=G[pos].size();
  used[pos]=1;
  if(S.count(used)){used[pos]=0;return;}
  S.insert(used);
  for(int i=0;i<len;i++) can[G[pos][i]]++;
  
  for(int i=0;i<len;i++){
    int nx=G[pos][i];
    if(!used[nx]&&can[nx]==cnt)flg=0,dfs(nx,cnt+1);
  }
  if(flg)solve(0);
  used[pos]=0;
  for(int i=0;i<len;i++) can[G[pos][i]]--;
}


int main(){
  int m;
  cin>>n>>m;
  for(int i=0,a,b,c;i<m;i++){
    cin>>a>>b>>c;
    a--,b--;
    G[a].push_back(b);
    G[b].push_back(a);
    g[a][b]=g[b][a]=c;
  }
  for(int i=0;i<n;i++)dfs(i,1);
  cout <<ans<<endl;
  return 0;
}

Measured memory_bytes: 4996
import java.util.Scanner;

public class Main {

    
    public static void main(String[] args) {
     Scanner scanner = new Scanner(System.in);
     int a = scanner.nextInt();
     int b = scanner.nextInt();
     int c = scanner.nextInt();
     int d = scanner.nextInt();
       if(a*b > c*d){
           System.out.println(a*b);
       } else if(a*b<c*d){
           System.out.println(c*d);
       } else if(a*b == c*d){
           System.out.println(a*b);
       }
       
    }
    
}


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

int main()
{
  ll n, p;
  cin >> n >> p;
  vector<ll> a(n);
  bool flag = true;
  for (auto &e : a)
  {
    cin >> e;
    if (e % 2 == 1)
      flag = false;
  }

  if (flag)
  {
    if (p)
      cout << 0 << endl;
    else
      cout << (ll)pow(2, n) << endl;
  }
  else
    cout << (ll)pow(2, n - 1) << endl;

  return 0;
}

Measured memory_bytes: 256
X,N = map(int,input().split())

if N==0:
    print(X)
    exit()

p = list(map(int,input().split()))
q = [i for i in range(-1000,1000)]
li = set(p) ^ set(q)
tmp = 0
ans = 0
while(1):
    if X-tmp in li:
        ans = X-tmp
        break
    elif X+tmp in li:
        ans = X+tmp
        break
    tmp += 1
print(ans)

Measured memory_bytes: 9320
#include <bits/stdc++.h>
#define ll long long
#define lsb(x) (x & -x)

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //freopen("a.in", "r", stdin);

    int n, k;
    cin >> n >> k;
    vector<int> v(n + 1, 0);
    for(int i = 1; i <= n; i ++)
        cin >> v[i];

    vector<int> dp(k + 1, 0);
    for(int s = 1; s <= k; s ++)
        for(int i = 1; i <= n; i ++) {
            if(s >= v[i] && dp[s - v[i]] == 0) {
                dp[s] = 1;
                break;
            }
        }
    if(dp[k] == 1)
        cout << "First";
    else
        cout << "Second";

    return 0;
}


Measured memory_bytes: 640
N = int(input())
s = [input() for i in range(N)]
M = int(input())
t = [input() for i in range(M)]
s_set = list(set(s))
t_set = list(set(t))
check_list = []
for i in s_set:
    check_list.append(s.count(i) - t.count(i))
print(max(max(check_list), 0))

Measured memory_bytes: 3064
#include <stdio.h>
#include <stdlib.h>

void insert(int *,int);
void heapIncreaseKey(int *,int, int);
int extractMax(int *);
void maxHeapify(int *, int);

int h=0;

int main()
{
  int H[1400000];
  char c[7];
  int extract[600000];
  int i,j=0,k;

  while(1){
    scanf("%s",c);

    if(c[0]=='e'&& c[1]=='n') break;

      else if(c[0]=='e') {
      extract[j]=extractMax(H);
      j++;
      }

    else if(c[0]=='i'){
      scanf("%d",&k);
      insert(H,k);
    }
  }
  /* output */
  for(i=0;i<j;i++) printf("%d\n",extract[i]);

  return 0;
}

void insert(int *A,int k){
  h=h+1;
  A[h]=(-1)*(1.0/0.0);
  heapIncreaseKey(A,h,k);
}

void heapIncreaseKey(int *A,int i, int key){
  int B;

  if(key<A[i])  fprintf(stderr,"new key issamller than current key");
  A[i] = key;
  while(i>1 && A[i/2] < A[i]){
    B=A[i];
    A[i]=A[i/2];
    A[i/2]=B;
    i=(i/2);
  }
}

int extractMax(int *A){
  int max;
  if(h<1) fprintf(stderr,"heap underflow");
  max = A[1];
  A[1] = A[h];
  h--;
  maxHeapify(A,1);
  return max;
}

void maxHeapify(int *A, int i){
  int l,r,largest;
  int B;
  l = 2*i;
  r = 2*i+1;
  // 左の子、自分、右の子で値が最大のノードを選ぶ
  if(l <= h && A[l]>A[i]) largest=l;
  else largest = i;
  if(r <= h && A[r]>A[largest]) largest = r;
  if(largest!=i){
    B=A[i];
    A[i]=A[largest];
    A[largest]=B;

    maxHeapify(A, largest); // 再帰的に呼び出し
  }
}

Measured memory_bytes: 8032
#![allow(unused_imports)]
#![allow(non_snake_case)]
#![allow(dead_code)]
use std::cmp::*;
use std::collections::*;
use std::io::*;
use std::mem::*;
use std::num::*;
use std::ops::*;
use std::rc::*;
use std::string::*;

fn main() {
    let X : usize = read();

    let mut s : usize = 100;
    for i in (1..99999) {
        s +=  s/ 100;
        if (s >= X){
            println!("{}",i);
            break;
        }

    }

}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

fn gcd(mut a: u64, mut b: u64) -> u64 {
    if a < b {
        std::mem::swap(&mut a, &mut b)
    }
    if b == 0 {
        a
    } else {
        gcd(b, a % b)
    }
}
fn yn(val: bool) {
    if val {
        println! {"Yes"}
    } else {
        println! {"No"}
    }
}

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

using namespace std;

int n,m,cnt;
set<int> st;
int main(){
    cin >> n;
    for (int i = 1; i <= n; i++){
        cin >> m;
        cnt++;
        st.insert(m);
    }
    if (cnt == st.size()){
        cout << "YES";
    }
    else {
        cout << "NO";
    }

    return 0;
}

Measured memory_bytes: 9600