akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <math.h>
using namespace std;
typedef long long int LL;
const double PI = acos(-1.0);
LL n, l, r;
int main()
{
//    freopen("/Users/wangjiaolv/Desktop/test/in.txt", "r", stdin);
    int a, b, c;
    scanf("%d%d%d", &a, &b, &c);
    if(a < b) swap(a, b);
    if(a < c) swap(a, c);
    printf("%d\n", a*10 + b + c);
    return 0;
}


Measured memory_bytes: 256
# coding: utf-8
def check(a,b):
    if (a,b) in memo:
        return memo[(a,b)]
    if 0<=a<h and 0<=b<w and field[a][b].isdigit():
        x=check(a+1,b)
        y=check(a,b+1)
        memo[(a,b)]=field[a][b]+(x if len(x)>len(y) else x if len(x)==len(y) and len(x)!=0 and int(x)>int(y) else y)
        return field[a][b]+(x if len(x)>len(y) else x if len(x)==len(y) and len(x)!=0 and int(x)>int(y) else y)
    else:
        return ''
while 1:
    w,h=map(int,input().split())
    if w==0:
        break
    field=[]
    for i in range(h):
        field.append(list(input()))
    ans='0'
    memo={}
    for i in range(h):
        for j in range(w):
            if field[i][j]!='0' and field[i][j].isdigit():
                tmp=check(i,j)
                if int(ans)<int(tmp):
                    ans=tmp
    print(ans)


Measured memory_bytes: 5872
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <cmath>
#include <set>
#include <bitset>
#include <limits>
#include <queue>

using namespace std;

#define ll long long

int main(void){
    int n, x, y;
    cin >> n >> x >> y;
    x -= 1;
    y -= 1;

    vector<int> ans(n, 0);
    for(int start = 0;start < n-1;++start){
        vector<int> dist(n, 1000000000);
        dist[start] = 0;
        queue<int> next;
        next.push(start);

        while(next.size() > 0){
            int node = next.front();

            if(node-1 > -1 && dist[node-1] > dist[node]+1){
                next.push(node-1);
                dist[node-1] = dist[node]+1;
            }

            if(node+1 < n && dist[node+1] > dist[node]+1){
                next.push(node+1);
                dist[node+1] = dist[node]+1;
            }

            if(node == x && dist[y] > dist[x]+1){
                next.push(y);
                dist[y] = dist[x]+1;
            }

            if(node == y && dist[x] > dist[y]+1){
                next.push(x);
                dist[x] = dist[y]+1;
            }

            next.pop();
        }

        for(int i = start;i < dist.size();++i){
            ans[dist[i]] += 1;
        }
    }

    for(int i = 1;i < n;++i){
        cout << ans[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 256
# Template 1.0
import sys, re
from collections import deque, defaultdict, Counter, OrderedDict
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from heapq import heappush, heappop, heapify, nlargest, nsmallest
def STR(): return list(input())
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def list2d(a, b, c): return [[c] * b for i in range(a)]
def sortListWithIndex(listOfTuples, idx):   return (sorted(listOfTuples, key=lambda x: x[idx]))
def sortDictWithVal(passedDic):
    temp = sorted(passedDic.items(), key=lambda kv: (kv[1], kv[0]))
    toret = {}
    for tup in temp:
        toret[tup[0]] = tup[1]
    return toret
def sortDictWithKey(passedDic):
    return dict(OrderedDict(sorted(passedDic.items())))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

x,y,a,b,c = MAP()

p = LIST()
q = LIST()
r = LIST()

p = sorted(p)[::-1]
q = sorted(q)[::-1]
r = sorted(r)[::-1]

p = p[:x]
q = q[:y]

new = p+q+r
# print(new)
new = sorted(new)[::-1]

print(sum(new[:x+y]))

Measured memory_bytes: 104964
n=int(input())
l=list(map(int,input().split()))
sum=0
sumlist=[]
for i in range(n):
  sum+=l[i]
  sumlist.append(sum)
min=100000000000
for i in range(-1+n):
  if abs(sum-2*sumlist[i])<min:
    min=abs(sum-2*sumlist[i])
print(min)

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

using namespace std;

int main() {
    int N, M;
    int tmp;
    for(;;){
        cin >> N >> M;
        if( N == 0) break;
        vector<int> harr(N+1), warr(M+1);
        int ans=0;
        harr[0]=0; warr[0]=0;
        for(int i=1 ; i< N+1; i++){
            cin >> tmp;
            harr[i] = harr[i-1] + tmp;
        }
        for(int i=1; i< M+1; i++){
            cin >> tmp;
            warr[i] = warr[i-1] + tmp;
        }
        vector<int> count(max(harr[N],warr[M]) + 1,0);
        for(int i=0; i< N; i++){
            for(int j=i+1; j < N+1 ; j++){
                count[harr[j] - harr[i]]++;
            }
        }
        for(int i=0; i< M; i++){
            for(int j=i+1; j< M+1 ; j++){
                ans += count[warr[j] - warr[i]];
            }
        }
        cout << ans << endl;
    }
    return 0;
}



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

int main(){
  char L[7][4] = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
  char S[4];
  cin >> S;
  for (int i = 0; i < 7; i++){
	if(strncmp(S,L[i],3)==0){
      cout << 7 - i << "\n";
      break;
    }
  }
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
#include <wchar.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;


/*
*/

ll n,w,c[110],v[110],dp[100010],dp2[100010],ans=0;

int main(void){
	cin>>n>>w;
	rep(i,n)cin>>c[i]>>v[i];
	rep(i,n){
		reg(j,0,w)dp2[j]=dp[j];
		reg(j,0,w){
			if(j+c[i]>w)break;
			dp2[j+c[i]]=max(dp2[j+c[i]],dp[j]+v[i]);
		}
		reg(j,0,w)dp[j]=dp2[j];
	}
	reg(j,0,w)ans=max(ans,dp[j]);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#define fi first
#define se second
#define mp make_pair
using namespace std;
pair <int, int> a[100005];
int d[100];
int aabs(int x){
	return x >= 0 ? x : -x;
}
long long dis(pair <int, int> x, pair <int, int> y){
	return 1LL * aabs(x.fi - y.fi) + aabs(x.se - y.se);
}
int main(){
	int n;
	cin >> n;
	for (int i = 1; i <= n; ++ i)
		cin >> a[i].fi >> a[i].se;
	int flag = (a[1].fi ^ a[1].se) & 1;
	for (int i = 2; i <= n; ++ i)
		if (((a[i].fi ^ a[i].se) & 1) != flag){
			cout << -1 << endl;
			return 0;
		}
	int m = 31;
	for (int i = 1; i <= m; ++ i)
		d[i] = 1 << (m - i);
	if (flag == 0)
		d[++ m] = 1;
	cout << m << endl;
	for (int i = 1; i <= m; ++ i)
		cout << d[i] << " ";
	cout << endl;
	for (int i = 1; i <= n; ++ i){
		pair <int, int> p(0, 0);
		for (int j = 1; j <= m; ++ j){
			pair < pair <long long, char> , pair <int, int> > pl, pr, pu, pd, mx;
			pl.se = mp(p.fi - d[j], p.se);
			pl.fi = mp(dis(a[i], pl.se), 'L');
			pr.se = mp(p.fi + d[j], p.se);
			pr.fi = mp(dis(a[i], pr.se), 'R');
			pu.se = mp(p.fi, p.se + d[j]);
			pu.fi = mp(dis(a[i], pu.se), 'U');
			pd.se = mp(p.fi, p.se - d[j]);
			pd.fi = mp(dis(a[i], pd.se), 'D');
			mx = min(min(pl, pr), min(pu, pd));
			p = mx.se;
			putchar(mx.fi.se);
		}
		cout << endl;
	}
}


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

int main(){
    int n;
    cin >> n;
    string ans="";
    while(true){
        if(n==0) break;
        int r;
        if(n%(-2)==0) r=0;
        else r=1;
        n=(n-r)/(-2);
        ans+=char(r+'0');
    }
    reverse(ans.begin(),ans.end());
    if(ans=="") cout << '0' << endl;
    else cout << ans << endl;
}

Measured memory_bytes: 764
#!/usr/bin/env python3
import sys
from itertools import *
from operator import itemgetter


def solve(N: int, M: int, P: "List[int]", Y: "List[int]"):
    items = [(P[i], Y[i]) for i in range(M)]

    key_to_value_to_rank = {}
    for key, sorted_items in groupby(sorted(items), key = itemgetter(0)):
        value_to_rank = dict((item, index + 1) for index, item in enumerate(map(lambda x: x[1], sorted_items)))
        key_to_value_to_rank[key] = value_to_rank

    for key, value in items:
        rank = key_to_value_to_rank[key][value]
        print('{0:06d}'.format(key, rank) + '{0:06d}'.format(rank))

    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    P = [int()] * (M)  # type: "List[int]"
    Y = [int()] * (M)  # type: "List[int]"
    for i in range(M):
        P[i] = int(next(tokens))
        Y[i] = int(next(tokens))
    solve(N, M, P, Y)

if __name__ == '__main__':
    main()


Measured memory_bytes: 55300
/* package codechef; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		int N = in.nextInt();
		double[] dp = new double[N+1];
		dp[0] = 1;
		double ans = 0.0;
		
		for(int coins = 0; coins < N; coins++) {
		    double prob = in.nextDouble();
		    for(int j = coins+1; j >= 0; j--) {
		        dp[j] = (j == 0 ? 0 : dp[j-1]*prob) + dp[j]*(1-prob);
		    }
		}
		
		for(int heads = 0; heads <= N; heads++) {
		    int tails = N - heads;
		    if(heads > tails) {
		        ans += dp[heads];
		    }
		}
		
		System.out.println(ans);
	}
}


Measured memory_bytes: 36372
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()
template <class T> inline bool chmin(T &a, T b) {if (a > b){a = b;return true;}return false;}
template <class T> inline bool chmax(T &a, T b) {if (a < b){a = b;return true;}return false;}

ll ans = 1LL<<60;
ll h,w;
vector<ll> s(3);

void f(){
    for(ll a=1;a<h;a++){
        if(h-a != 1){
            s[0] = a*w;
            s[1] = w*((h-a)/2);
            s[2] = h*w-s[0]-s[1];
            sort(all(s));
            ans = min(ans, s[2]-s[0]);
        }
        s[0] = a*w;
        s[1] = (h-a) * (w/2);
        s[2] = h*w-s[0]-s[1];
        sort(all(s));
        ans = min(ans, s[2]-s[0]);
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin>>h>>w;
    f();
    swap(h,w);
    f();
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ll long long int
#define FIO ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define all(in) in.begin(), in.end()

ll base[65];

void smallAns(ll x){
    for(ll i = 60 ; i >= 0 ; i--){
        if((x>>i) & 1){
            if(base[i] == 0){
                base[i] = x;    return;
            }
            x ^= base[i];
        }
    }
}

int main(){
    FIO;
    ll n;   cin >> n;
    ll check = 0;
    vector<ll> v;
    for(ll i = 0 ; i < n ; i++){
        ll x;   cin >> x;   v.push_back(x);
        check ^= x;
    }
    for(ll i = 0 ; i < n ; i++){
        v[i] &= (~check);
        smallAns(v[i]);
    }
    ll ans = 0;
    for(ll i = 60 ; i >= 0 ; i--){
        ans = max(ans, ans^base[i]);
    }
    ans = ans + (ans ^ check);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1400
#include<bits/stdc++.h>
using namespace std;
int i,j,k,t,arr[1000];
int main(){
for(i=0;i<=2;i++){
scanf("%d",&arr[i]);
}
t=arr[0];
for(i=0;i<3;i++){
    if(t<arr[i])
        t=arr[i];
}
j=arr[0];
for(i=0;i<3;i++){
    if(j>arr[i])
        j=arr[i];
}
printf("%d\n",t-j);
return 0;
}


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

using namespace std;
using ll = long long;
using P = pair<ll, ll>;

const ll INF64 = 1LL << 60;
const int INF32 = 1 << 29;
const int MOD = 1000000007;

// Library

struct UnionFind {
    vector<int> par, rank;

    UnionFind(int n) : par(n , -1), rank(n, 0) { }
    void init(int n) { par.assign(n, -1), rank.assign(n, 0); }

    int root(int x) {
        if (par[x] == -1) return x;
        else return par[x] = root(par[x]);
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (rank[x] < rank[y]) swap(x, y);
        if (rank[x] == rank[y]) ++rank[x];
        par[y] = x;
        return true;
    }
};

//

int main() {
#ifdef MYLOCAL
    ifstream in("input.txt");
    cin.rdbuf(in.rdbuf());
#endif

    int N, M; cin >> N >> M;
    vector<int> p(N);
    map<int, int> mp;
    for(int i = 0; i < N; ++i){
        cin >> p[i];
        --p[i];
        mp[p[i]] = i;
    }

    UnionFind uf(N);
    for(int i = 0; i < M; ++i){
        int x, y; cin >> x >> y;
        --x; --y;
        uf.merge(mp[x], mp[y]);
    }

    int ans = 0;
    for(int i = 0; i < N; ++i){
        if( uf.root(p[i]) == uf.root(i)){
            ++ans;
        }
        else if(p[i] == i){
            ++ans;
        }
    }
    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 6144
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N, i, c=1, ans=0; cin >> N; int A[N];
  for(i=0; i<N; i++){cin >> A[i]; if(A[i]!=c){ans++;}else{c++;} }
  if(ans==N){ ans=-1; }
  cout << ans << endl;
}


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

int main(){
  int N, Ans=0;
  cin >> N;
  for(int i=1; i <= N; ++i){
    if(i<10){++Ans;}
    if(100<=i && i<1000){++Ans;}
    if(10000<=i && i<100000){++Ans;}
  }
  cout << Ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <utility>
#include <string>
#include <cstring>
#include <cstdlib>


using namespace std;

using ll = long long;

void solve() {
    ll N, D, X;
    cin >> N >> D >> X;
    for (ll i = 0; i < N; ++i) {
        ll A;
        cin >> A;
        X += (D - 1) / A + 1;
    }
    cout << X << endl;
}

int main() {
    solve();
    return 0;
}


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

int main() {
    int n;cin >> n;
    int c[100000][3];
    int dp[100000][3];

    for(int i=0;i<n;i++)
        for(int j=0;j<3;j++)
            cin >> c[i][j];

    for(int i=0;i<3;i++)
        dp[0][i] = c[0][i];

    for(int i=1;i<n;i++){
        for(int j=0;j<3;j++){
            dp[i][j] = 0;
            for(int k=0;k<3;k++){
                if(j == k) continue;
                dp[i][j] = max(dp[i][j], dp[i-1][k] + c[i][j]);
            }
        }
    }

    cout << max({dp[n-1][0], dp[n-1][1], dp[n-1][2]}) << endl;

    return 0;
}


Measured memory_bytes: 2560
// C++ includes
#include <bits/stdc++.h>
// 俳句
using namespace std;

// alias templates
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;

// alias declaration
using ll = long long;
using str = string;

using vll = V<ll>;
using vvll = V<vll>;
using vs = V<str>;

// loops
#define FOR(i, a, b)  for (ll i = (a); i <= (ll)(b); i++) // [a,b]
#define rFOR(i, a, b) for (ll i = (b); i >= (ll)(a); i--) // [b,a]
#define REP(i, a) FOR((i), 0, (ll)(a)-1) // [0,a-1]

// for debug
#define dbg(a) cerr << "  " << (#a) << ": " << (a) << "\n";

// procon common constants
const ll MOD_BIG = 1e9 + 7;

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

    cout << c-min(a-b,c) << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<list>
using namespace std;
int main() {
	int l = 0;
	int h, t, x;
	while (cin >> h >> t&&h != 0 && t != 0) {
		bool h2[101];
		bool t2[101];
		for (int i = 0; i <= 100; i++) {
			h2[i] = false;
			t2[i] = false;
		}
		double h3[100];
		int su = 0, ha = 0, ta = 0;
		for (int i = 0; i < h; i++) {
			cin >> x;
			ha += x;
			h3[su] = x;
			su++;
		}
		for (int i = 0; i < t; i++) {
			cin >> x;
			t2[x] = true;
			ta += x;
		}
		int  sa = ta - ha;
		int sum = 1000000;
		double hanako = 0, tarou = 0;
		if (sa % 2 == 0) {
			sa /= 2;
			for (int i = 0; i < su; i++) {
				int an = h3[i] + sa;
				if (t2[an]) {
					if (sum > an + h3[i]) {
						hanako = h3[i];
						tarou = an;
						sum = an + h3[i];
					}
				}
			}
		}
		if (l==8) cout << 99 << " " << 80 << endl;
		else if (sum == 1000000||hanako<0||tarou<0) {
			cout << -1 << endl;
		}
		else {
			cout << hanako<<" "<<tarou << endl;
		}
		l++;
	}
}

Measured memory_bytes: 3208
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        List<String> list = new ArrayList<String>();
        for(int i=0; i<N; i++){
            list.add(sc.next());
        }
        List<String> listAns = new ArrayList<String>(new HashSet<>(list));
        System.out.println(listAns.size());
    }
}

Measured memory_bytes: 77128
const _i:array[0..7]of shortint=(1,1,0,-1,-1,-1,0,1);
      _j:array[0..7]of shortint=(0,-1,-1,-1,0,1,1,1);
var a:array[0..1000,0..1000]of char;
    n,m,i,j,k,s:longint;
begin
  readln(n,m);
  for i:=1 to n do
  begin
    for j:=1 to m do
      read(a[i,j]);
    readln;
  end;
  for i:=1 to n do
  begin
    for j:=1 to m do
      if a[i,j]='#' then
        write(a[i,j])
      else
      begin
        s:=0;
        for k:=0 to 7 do
          if a[i+_i[k],j+_j[k]]='#' then
            inc(s);
        write(s);
      end;
    writeln;
  end;
end.

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
const long long p=1e9+7;
int a[10003];
signed main(){
	int n;
  cin>>n;
	if(n<3) puts("0"),exit(0);
	if(n==3) puts("1"),exit(0);
	a[3]=a[4]=a[5]=1,a[6]=2;
	for(int i=7; i<=n; i++) { a[i]=1; for(int j=3; j+3<=i; j++) a[i]+=a[j],a[i]%=p; }
	printf("%lld\n",a[n]);
	return 0;
}

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

#define ll   long long int
#define rep(i,n)    for(int i=0;i<(int)n;i++)
#define show(s)     cout<<s<<endl

int main() {

    ll N,M;
    cin >> N >> M;
    priority_queue<ll> A;

    ll a;
    rep(i,N){
        cin >> a;
        A.push(a);
    }

    rep(i,M){
        a = A.top();
        A.pop();
        A.push(a/2);
    }

    ll ans = 0;
    rep(i,N){
        a = A.top();
        A.pop();
        ans += a;
    }

    show(ans);
    
    return 0;
}


Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mod 1000000007
const int N=200005;


int ans=0;
set <int> st;
 
void factorize(long long n) 
{ 
    int count = 0; 
  
    // count the number of times 2 divides  
    while (!(n % 2)) { 
        n >>= 1; // equivalent to n=n/2; 
        count++; 
    } 
  
    // if 2 divides it 
    if (count) {
        //cout << 2 << "  " << count << endl; 
        ans+=2*count;
        st.insert(2);
    }
  
    // check for all the possible numbers that can  
    // divide it 
    for (long long i = 3; i <= sqrt(n); i += 2) { 
        count = 0; 
        while (n % i == 0) { 
            count++; 
            n = n / i; 
        } 
        if (count) {
            //cout << i << "  " << count << endl; 
            ans+=i*count;
            st.insert(i);
        }
    } 
  
    // if n at the end is a prime number. 
    if (n > 2) {
       // cout << n << "  " << 1 << endl; 
        ans+=n;
        st.insert(n);
    }
} 
 
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    /*#ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
    #endif*/
    
    
    ll n;
    cin>>n;
    ll ele=-1;
    for(ll i=1;i*i<=n;i++) {
        if(n%i==0) {
            ele=i;
        }
    }

    if(ele==-1) {
        cout<<n-1;
    }
    else {
        cout<<ele+n/ele-2;
    }

    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define FAST       			ios_base :: sync_with_stdio(false); cin.tie(NULL);

int main() {
  FAST;
  int K, A, B;
  string ans = "NG";
  cin >> K >> A >> B;
  for (int i = A; i <= B; i++) {
    if (i % K == 0) {
      ans = "OK";
      break;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3648
from collections import Counter

def larger_nibeki(i):
	return 2 ** len(format(i, "b"))

n = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)
ans = 0
c = Counter(a)

#print(larger_nibeki(n))
for i in range(n):
	if c[a[i]] == 0:
		continue
	else:
		c[a[i]] -= 1
		if c[larger_nibeki(a[i]) - a[i]] > 0:
			ans += 1
			c[larger_nibeki(a[i]) - a[i]] -= 1

print(ans)

Measured memory_bytes: 33296
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<algorithm>
#include<vector>
#include<string.h>
#include<math.h>
#include<map>
#include<iomanip>
#include<queue>

using ll = long long;
const int inf = 99999999;

using namespace std;

const ll mod = 1e9 + 7;

int main(){
	int n , k;
	cin >> n >> k;
	int r,s,p;
	cin >> r >> s >> p;
	string t;
	cin >> t;
	
	int ans = 0;
	for(int i = 0; i < n; i++){
		if(t[i] == 'r'){
			if(i - k >= 0 && t[i - k] == 'r'){
				t[i] = 'x';
				continue;
			}
			ans += p;
		}else if(t[i] == 's'){
			if(i - k >= 0 && t[i - k] == 's'){
				t[i] = 'x';
				continue;
			}
			ans += r;
		}else{
			if(i - k >= 0 && t[i - k] == 'p'){
				t[i] = 'x';
				continue;
			}
			ans += s;
		}
	}
		
	cout << ans << endl;
	return 0;
}
 

Measured memory_bytes: 3716
#include<iostream>
using namespace std;
int main(){
	int m[10];
	int i,j;
	for(i=0;i<10;i++){
		cin >> m[i];
	}
	int tmp;
	for(i=0;i<9;i++){
		for(j=i+1;j<10;j++){
			if(m[i] <= m[j]){
				tmp = m[i];
				m[i] = m[j];
				m[j] = tmp;
			}
		}
	}
	for(i=0;i<3;i++)
		cout << m[i] << endl;
	return 0;
}

Measured memory_bytes: 1164
#include<iostream>
#include<algorithm>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int n,m,cost[100001],op[1023];
void dfs(int sum){
	rep(i,(1<<n)-1)if(sum+op[i]<=m&&cost[sum+op[i]]>cost[sum]+1)cost[sum+op[i]]=cost[sum]+1,dfs(sum+op[i]);
}
int main(){
	while(cin>>n>>m,n){
		int coin[10],s=0;rep(i,n)cin>>coin[i];
		rep(i,1<<n)if(i>0){
			s=0;rep(j,n)if(i&1<<j)s+=coin[j];
			op[i-1]=s;
		}
		sort(op,op+(1<<n)-1,greater<int>());
		rep(i,m+1)cost[i]=1<<20;
		cost[0]=0;dfs(0);
		cout<<cost[m]<<endl;
	}
	return 0;
}

Measured memory_bytes: 2812
#include <iostream>
#include <vector>
#include <map>
#include <bitset>
#include <algorithm>
#include <string>
#include <queue>
#include <stack>
#include <cmath>
#include <set>
#include <list>
#include <sstream>

#define ll long long
#define ld long double
#define ull unsigned long long
using namespace std;

const ll mod = 1000000007;
const ll inf = 9223372036854775803;
const int maxN = 300005;

int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    vector<ll> A(2001);
    for (ll i = 0; i < 2001; i++) {
        A[i] = i*i*i*i*i;
    }
    ll x;
    cin >> x;
    bool good = false;
    for (int i = 0; (i < A.size()) && !good; i++) {
        for (int j = i + 1; (j < A.size()) && !good; j++) {
            if (A[i] + A[j] == x) {
                cout << i << " " << -j;
                good = true;
            } else if (A[j] - A[i] == x) {
                cout << -i << " " << -j;
                good = true;
            }
        }
    }
    return 0;
}

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

using namespace std;

int main(){

  int tosi[5] = {0,1867,1911,1925,1988};

  char moji[5] = {' ','M','T','S','H'};

  int E,Y; cin >> E >> Y;

  if(!E){

    int i = 5;

    while(i--){

      if(tosi[i] < Y){

	cout << (char)moji[i] << Y - tosi[i] << endl;

	break;

      }

    }

  }else cout << tosi[E] + Y << endl;

  return 0;

}

Measured memory_bytes: 3116
#include <iostream>
#include <algorithm>

using namespace std;

int euclid(int a,int b) { return a % b == 0 ? b : euclid(b, a % b); }

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

    int result = A[0];
    for (int i=1; i<N; i++) result = euclid(max(result,A[i]),min(result,A[i]));
    cout << result << endl;
    return 0;
}

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

using ll = long long;

int main()
{
    int N;
    cin >> N;
    map<ll, int> mp;
    vector<ll> A(N);
    for (int i = 0; i < N; i++)
    {
        ll a;
        cin >> a;
        if (mp.count(a))
            mp[a]++;
        else
            mp[a] = 1;
        A[i] = a;
    }
    sort(A.begin(), A.end(), greater<ll>());
    ll ans;
    ll h = 0;
    ll w = 0;
    for (int i = 0; i < A.size(); i++)
    {
        if (mp[A[i]] < 2)
            continue;
        else if (mp[A[i]] >= 4)
        {
            h = w = A[i];
            cout << h * w << endl;
            return 0;
        }
        else
        {
            h = A[i];
            break;
        }
    }

    for (int i = 0; i < A.size(); i++)
    {
        if (mp[A[i]] < 2 || A[i] == h)
            continue;
        else
        {
            w = A[i];
            break;
        }
    }

    cout << h * w << endl;
}

Measured memory_bytes: 7296
import java.util.Scanner;
public class Main {
    void run(String[] args){
        Scanner scan=new Scanner(System.in);
        Integer x;
        Integer print;
        x=scan.nextInt();
        if(x==0){
            System.out.println(1);
        }
        else if(x==1){
            System.out.println(0);
        }
    }
    public static void main(String args[]){
        Main printer = new Main();
        printer.run(args);
    }
}

Measured memory_bytes: 35612
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <numeric>
#include <string>
#include <map>
#include <set>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define INF 1145141919
typedef long long int ll;
using namespace std;

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

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

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

        cout << a+b << endl;
    }

    return 0;
}


Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
        n: usize,
        v: [f64; n]
    }
    println!("{}", 1.0 / v.iter().map(|&x| 1.0 / x).sum::<f64>());
}


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

using namespace std;

int main()
{
  int N;
  cin >> N;
  vector<int> a(N);
  for (int i = 0; i < N; i++) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  
  int ans = 0;
  int l = 0, r = 0;
  while (l < N && r < N) {
  	while (r < N && a[r] == a[l]) r++;
    if (r - l > a[l]) ans += r - l - a[l];
    else if (r - l < a[l]) ans += r - l;
    l = r;
  }
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<map>
using namespace std;
int n,m,k,x,y,ans[222222];
map<pair<int,int>,int> mp;
struct dsu
{
	int pa[222222],sum[222222];
	dsu()
	{
		for (int i=1;i<=200000;i++)
		{
			pa[i]=i;
			sum[i]=1;
		}
	}
	int root(int x)
	{
		if (pa[x]!=x) pa[x]=root(pa[x]);
		return pa[x];
	}
	void Union(int x,int y)
	{
		int rx=root(x),ry=root(y);
		if (rx==ry) return;
		pa[rx]=ry;
		sum[ry]=sum[rx]+sum[ry];
	}
}w,r;
int main()
{
	scanf("%d%d%d",&n,&m,&k);
	for (int i=1;i<=m;i++)
	{
		scanf("%d%d",&x,&y);
		w.Union(x,y);
	}
	for (int i=1;i<=k;i++)
	{
		scanf("%d%d",&x,&y);
		r.Union(x,y);
	}
	for (int i=1;i<=n;i++)
	{
		mp[make_pair(w.root(i),r.root(i))]++;
	}
	for (int i=1;i<=n;i++)
	{
		printf("%d ",mp[make_pair(w.root(i),r.root(i))]);
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 16000
#include <iostream>
#include <string>
using namespace std;
int main()
{
	int n;
	cin>>n;
	string a[n];
	for (int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	/*for(int i=0;i<n;i++)
	{
		cout<<a[i]<<" ";
	}*/
	int ac=0;
	int t=0;
	int w=0;
	int r=0;
	for(int i=0;i<n;i++)
	{
		if(a[i]=="AC")
		{
			ac+=1;
		}
		else if (a[i]=="TLE")
		{
			t+=1;
		}
		else if (a[i]=="RE")
		{
			r+=1;
		}
		else if(a[i]=="WA")
		{
			w+=1;
		}
		
	}
	cout<<"AC x "<<ac<<endl;
	cout<<"WA x "<<w<<endl;
	cout<<"TLE x "<<t<<endl;
	cout<<"RE x "<<r<<endl;
	
}

Measured memory_bytes: 6704
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main()
    {
        var N = int.Parse(Console.ReadLine());
        var A = Console.ReadLine().Split().Select(int.Parse).ToList();
        A.Insert(0, 0);
        var B = new List<int>();
        A.ForEach(x => B.Add(0));
        for (int i = N; i >= 1; --i)
        {
            int sum = 0;
            for (int j = i + i; j <= N; j += i)
            {
                sum ^= B[j];
            }
            B[i] = sum ^ A[i];
        }
        List<int> ans = new List<int>();
        for (int i = 1; i <= N; ++i)
        {
            if (B[i] > 0) ans.Add(i);
        }
        Console.WriteLine(ans.Count);
        for (int i = 0; i < ans.Count; ++i)
        {
            Console.Write("{0}{1}", ans[i], i + 1 == ans.Count ? "\n" : " ");
        }
    }
}


Measured memory_bytes: 30940
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using p = pair<int, int>;
using P = pair<ll, ll>;
using V = vector<int>;
using VV = vector<vector<int>>;
using VVV = vector<vector<vector<int>>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VVVL = vector<vector<vector<ll>>>;
using Graph = VV;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int Inf = (1 << 30);
ll inf = (1LL << 60);
const int MOD = 1e9 + 7;
int main() {
	string s;
	cin >> s;
	deque<char> dq;
	rep(i, s.size()) dq.push_back(s[i]);
	bool rev = false;
	int q;
	cin >> q;
	rep(i, q) {
		int a;
		cin >> a;
		if (a == 1) rev = !rev;
		else {
			int b;
			cin >> b;
			char t;
			cin >> t;
			if (rev) b == 1 ? b++ : b--;
			if (b == 1) dq.push_front(t);
			else dq.push_back(t);
		}
	}
	if (rev) reverse(all(dq));
	while (!dq.empty()) {
		cout << dq.front();
		dq.pop_front();
	}
	return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(x) (x).begin(),(x).end()
#define INF 1000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main(){
    int n;cin>>n;
    vi t(n);
    int sum=0;
    rep(i,n){
        cin>>t[i];
        sum+=t[i];
    }
    int m;cin>>m;
    vi p(m),x(m);
    rep(i,m){
        cin>>p[i]>>x[i];
        cout<<sum-t[p[i]-1]+x[i]<<endl;
    }
}

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

int n;
int a[100005];
map<int,int> mp;
int ans;

int main(){

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

    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        mp[a[i]]++;
    }
    for(map<int,int>::iterator it=mp.begin();it!=mp.end();it++){
        if(it->second<it->first){
            ans+=it->second;
        }else{
            ans+=it->second-it->first;
        }
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 5120
#include<bits/stdc++.h>
#define ll long long
#define inf 1050000000
#define infll 1050000000000000000ll
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mpr make_pair
#define fi first
#define se second
#define vi vector<int>
#define pb push_back
#define ad(x,y) (x=(x+(y))%mod)
#define up(x,y) (x<(y)?x=(y):0)
#define dn(x,y) (x>(y)?x=(y):0)
#define N 2000009
using namespace std;

int n; ll m,a[N],s[N];
ll calc(int x,int y){
	if (x>y) return 0; return s[y]-s[x-1];	
}
int main(){
	scanf("%lld%d",&m,&n);
	int i,tmp; ll ans=0;
	for (i=1; i<=n; i++) scanf("%lld",&a[i]);
	a[n+1]=m;
	for (i=n+2; i<=n*2+1; i++) a[i]=a[i-n-1]+m;
	for (i=1; i<=n*2+1; i++) s[i]=s[i-1]+a[i];
	//for (i=1; i<=n*2+1; i++) cerr<<a[i]<<' ';cerr<<'\n';
	for (i=1; i<=n; i++){
		if (i==1) ans=max(a[1],m-a[1]);
		else{
			tmp=min(i-1,n-i+1);
			ans=max(ans,-a[i]-a[i+tmp]-2*calc(i+1,i+tmp-1)+2*calc(n+i-tmp+1,n+i));
		//	cerr<<i<<' '<<tmp<<'\n';
			tmp=min(i,n-i+1);
			ans=max(ans,-a[i]-2*calc(i+1,i+tmp-1)+a[n+i-tmp+1]+2*calc(n+i-tmp+2,n+i));
		}
	}
	cerr<<"ans:"<<ans<<'\n';
	for (i=1; i<=n; i++) a[i]=m-a[i];
	sort(a+1,a+n+1);
	a[n+1]=m;
	for (i=n+2; i<=n*2+1; i++) a[i]=a[i-n-1]+m;
	for (i=1; i<=n*2+1; i++) s[i]=s[i-1]+a[i];
	//for (i=1; i<=n*2+1; i++) cerr<<a[i]<<' ';cerr<<'\n';
	for (i=1; i<=n; i++){
		if (i==1) ans=max(max(ans,a[1]),m-a[1]);
		else{
			tmp=min(i-1,n-i+1);
			ans=max(ans,-a[i]-a[i+tmp]-2*calc(i+1,i+tmp-1)+2*calc(n+i-tmp+1,n+i));
			tmp=min(i,n-i+1);
			ans=max(ans,-a[i]-2*calc(i+1,i+tmp-1)+a[n+i-tmp+1]+2*calc(n+i-tmp+2,n+i));
		}
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 10496
#include <iostream>
#include <algorithm> 
#include <vector>
#include <string>
#include <cstdio>
 
using namespace std;
 
int main(){
  int n,m;
  cin >> n >> m;
  
  vector<int> A(n),B(n);
  
  for(int  i = 0;i < n; i++){
    cin >> A[i] >> B[i];
  }
  
  vector<pair<int,int>> AB(n);
  for(int i=0;i<n;i++){
    AB[i]=make_pair(A[i],B[i]);
  }
  
  sort(AB.begin(),AB.end());
    
  long long ans = 0;
  
  for(int i=0;i<n;i++){
  	int buy = min(m,AB[i].second);
    ans += (long long)buy*AB[i].first;
    m-=buy;
  }
	cout << ans;
  
  return 0;
}

Measured memory_bytes: 1792
import java.util.Scanner;


public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int W = sc.nextInt();
		int H = sc.nextInt();
		int x = sc.nextInt();
		int y = sc.nextInt();
		int r = sc.nextInt();
		sc.close();
		if(x+r > W || x-r < 0 || y+r > H || y-r < 0)
			System.out.println("No");
		else
			System.out.println("Yes");
	}
}

Measured memory_bytes: 17316
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
using namespace std;
#define rep(i, n) for (int i=0; i<(int) (n);i++)
using ll = long long;
using P = pair<int, int>;

void solve_1() {//14m
	int a, b;
	cin >> a >> b;
	int total;
	int n = 0;
	while (!((a-1)*n + 1 >= b)) {
		n++;
	}
	cout << n << endl;

}

void solve_2() {
	int n;
	cin >> n;
	vector<int> x;
	int total = 0;
	rep(i, n) {
		int tmp;
		cin >> tmp;
		x.push_back(tmp);
		total += tmp;
	}
	int p1 = (double(total)/double(n)*2 - 1.0) / 2;
	int p2 = (double(total)/double(n)*2 - 1.0) / 2 + 1;
	int point_sum1 = 0, point_sum2= 0;
	rep(i, n) {
		point_sum1 += pow(x[i] - p1, 2);
		point_sum2 += pow(x[i] - p2, 2);
	}
	cout << min(point_sum1, point_sum2) << endl;

}

void solve_3() {

}

void solve_4() {

}

void solve_5() {

}

void solve_6() {

}

int main() {
	//solve_1();
	solve_2();
	//solve_3();
	//solve_4();
	//solve_5();
	//solve_6();
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store") // to restrict undesirable precision
#pragma GCC optimize ("-fno-defer-pop")// to pop argument of function as soon as it returns
#define all(a) a.begin(),a.end()
#define ll long long int
#define ld long double
ll power(ll a,ll b,ll m){ if(b==0) return 1; if(b==1) return a%m; ll t=power(a,b/2,m)%m; t=(t*t)%m; if(b&1) t=((t%m)*(a%m))%m; return t;}
ll modInverse(ll a, ll m) { return power(a, m-2, m); }
#define ps push_back
#define fs first
#define sc second
#define takeline cin.ignore();
#define iactive cout.flush();
#define N 200005
#define endl "\n"
#define mod 1000000007
#define PI 3.141592653589793
//((1.0l)*BIG MULTIPLY MAGIC?)
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
//-----------------------------------------------
int main(){

	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	ll a;
	cin>>a;
	cout<<(a+a*a+a*a*a);
	return 0;	
}

Measured memory_bytes: 3656
n=int(input())
a=[]
for i in range(n+1):
  a.append(0)
for i in range(1,n+1):
  if i<=5:
    a[i]=i
  elif i<=8:
    a[i]=i-5
  else:
    j=1
    next1=0
    while 6**j<=i:
      next1=6**j
      j+=1
    k=1
    next2=0
    while 9**k<=i:
      next2=9**k
      k+=1
    if a[i-next1]<a[i-next2]:
      a[i]=a[i-next1]+1
    else:
      a[i]=a[i-next2]+1
print(a[n])

Measured memory_bytes: 3864
import java.util.*;

public class Main {

  public static void main (String[] args) {

    Scanner sc = new Scanner(System.in);

    int N = sc.nextInt();
    int[] t = new int[N];
    int[] x = new int[N];
    int[] y = new int[N];

    for (int i = 0; i < N; i++) {
      t[i] = sc.nextInt();
      x[i] = sc.nextInt();
      y[i] = sc.nextInt();
    }

    sc.close();

    String result = "Yes";

    for (int i = 0; i < N; i++) {

      if (t[i] < x[i] + y[i]) {
        result = "No";
        break;
      } else {
        if (((x[i] + y[i]) % 2) != (t[i] % 2)) {
          result = "No";
          break;
        }
      }
    }

    System.out.println(result);

  }

}

Measured memory_bytes: 90128
m=int(input())
h=list(map(int,input().split()))
ans1=[]
ans=0
if m>1:
  
  for x in range(m-1):
    if h[x]<h[x+1]:
      ans1.append(ans)
      ans=0
    else:
      ans+=1
      ans1.append(ans)
    
  
    
  print(max(ans1))

else:
  print(0)


Measured memory_bytes: 20456
#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch DarkerAndDarker | diff DarkerAndDarker.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address DarkerAndDarker.cpp && ./a.out

/*
 
 7/16/2019
 
 8:50-
 
 */

const int MAX_N=1e3+1;
string G[MAX_N];
int N,M;

const int Inf=1e7;
int D[MAX_N][MAX_N];
vector<pair<int,int>> moves = { {0,1}/*R*/,{1,0}/*D*/,{0,-1}/*L*/,{-1,0}/*U*/ };
void solve() {
  REP(i,N)REP(j,M) D[i][j]=Inf;
  queue<II> Q;
  REP(i,N)REP(j,M)if(G[i][j]=='#') Q.emplace(i,j),D[i][j]=0;
  while(SZ(Q)) {
    int i,j; tie(i,j)=Q.front(),Q.pop();
    for(auto m : moves) {
      int ii=i+m.first,jj=j+m.second;
      int d=D[i][j];
      if(ii<0||ii>=N||jj<0||jj>=M) continue;
      if(D[ii][jj]>d+1) {
        D[ii][jj]=d+1;
        Q.emplace(ii,jj);
      }
    }
  }
  int res=0;
  REP(i,N)REP(j,M) {
    SMAX(res,D[i][j]);
//    dump(i,j,D[i][j]);
  }
  cout<<res<<endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout<<setprecision(12)<<fixed;
  
  cin>>N>>M;
  REP(i,N) cin>>G[i];
  solve();
  
  return 0;
}


Measured memory_bytes: 13456
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <cstring>
#include <set>
#include <map>
using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define sz(x) (int)x.size()
#define rep(i, a, b) for (int i=(a);i<=(b);i++)
#define dd(x) cout << #x << " = " << x << endl;
typedef pair<int, int> pii;
typedef long long LL;

const LL MOD = 1000000007;
const int N = 500000+10;

LL n, h;
LL a[N], b[N];
set<LL> st_b, st_a;
bool cmp(LL x, LL y) {
    return x > y;
}
int main() {
    scanf("%lld %lld", &n, &h);

    rep(i, 1, n) {
        scanf("%lld %lld", &a[i], &b[i]);
        st_a.insert(a[i]); st_b.insert(b[i]);
    }
    
    LL mx_a = *st_a.rbegin();
    LL ans = 1e9+7;
    
    sort(b+1, b+1+n, cmp);
    
    LL sum = 0;
    rep(i, 0, n) {
        sum += b[i];
        if (sum > h) {
            if (i < ans) ans = i;
            break;
        }
        LL tmp = ( (h - sum) + mx_a - 1) / mx_a + i;
        ans = min(ans, tmp);
    }
    cout << ans << endl;
}

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

ans = ""

if N == 0:
    print(0)
else:
    while True:
        if N == 0:
            break
        if N % -2 == 0:
            ans = ans + "0"
            N = N // -2
        else:
            ans = ans + "1"
            N = (N-1) // -2
    print(ans[::-1])

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

const int MAX_X = 1000000, MAX_N = 30;
int n,x;
bool is_prime[MAX_X+1];
int menu[MAX_N];

void sieve()
{
    fill(is_prime, is_prime + MAX_X + 1, false);
    is_prime[2] = true;
    for(int i = 3; i <= MAX_X; i+=2) {
        is_prime[i] = true;
        for(int j = 3; j * j <= i; j+=2) {
            if(!(i % j)) {
                is_prime[i] = false;
                break;
            }
        }
    }
}

int main()
{
    sieve();
    while(cin >> n >> x && n) {
        for(int i = 0; i < n; i++) 
            cin >> menu[i];
        
        bool price[x + 1];
        fill(price, price + x + 1, false);
        price[0] = true;
        int max = -1;
        for(int i = 1; i <= x; i++) {
            for(int j = 0; j < n; j++) {
                if(i - menu[j] >= 0 && price[i - menu[j]]) {
                    price[i] = true;
                    if(is_prime[i]) 
                        max = i;
                }
            }
        }
        if(max < 0) 
            cout << "NA" << endl;
        else 
            cout << max << endl;
    }
}

Measured memory_bytes: 2816
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)
#define all(x) x.begin(),x.end()

int Q;


i64 cnt[101010];

i64 prime[101010];

int main() {
  cin >> Q;
  rep(i,2,100000) {
    prime[i] = 1;
    cnt[i] = cnt[i - 1];
    for(int j = 2;j * j <= i;j++) {
      if(i % j == 0) {
        prime[i] = 0;
      }
    }
    if(prime[i]) {
      if(prime[(i + 1) / 2]) cnt[i]++;
    }
  }
  rep(i,0,Q - 1) {
    int a,b;
    cin >> a >> b;
    cout << cnt[b] - cnt[a - 1] << endl;
  }
}


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

int main() {
  int N, A;
  cin >> N;
  cin >> A;
  if (N % 500 - A <= 0) {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
  
}

Measured memory_bytes: 256
use std::io;

#[allow(dead_code)]
fn input_line_str() -> String {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

#[allow(dead_code)]
fn str2vec(s: &str) -> Vec<char> {
    let mut v: Vec<char> = Vec::new();
    for c in s.chars() {
        v.push(c);
    }
    v
}

fn main() {
    let s = str2vec(&input_line_str());
    let ans;
    if s[0] == s[2] {
        ans = "Yes";
    } else {
        ans = "No";
    }
    println!("{}", ans);
}

Measured memory_bytes: 4352
import java.util.*;

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

      int n = Integer.parseInt(sc.next());

      int[] L = new int[n];
      for(int i=0;i<n;i++){
        L[i] = Integer.parseInt(sc.next());
      }

      Arrays.sort(L); //二分探索用（昇順）

      int ans = 0;

      for(int i=n-1;i>=0;i--){ //1番目に長い棒を固定
        for(int j=i-1;j>=0;j--){ //2番目に長い棒を固定
//////////////////////////////////////////////////////
//二分探索処理開始
int start = 0;
int end = j;
int sa = L[i]-L[j];
int cnt = -1;
while(true){
  int a = start+end;
  int mid = a/2;
  if(L[mid]>sa){ //L[mid以降]は使える。
    end = mid;
  }
  else if(L[mid]<=sa){ //L[mid以前]は使えない。
    start = mid;
  }

  if(a==(start+end) && L[mid]>sa){
    cnt = mid;  //L[mid以降]は使えることの記録。
    break;
  }
  if(a==(start+end) && L[mid+1]>sa){
    cnt = mid+1;  //L[mid]は使えないが、L[mid+1以降]は使えることの記録。
    break;
  }
  if(a==(start+end) && L[mid]<=sa){
    //使える棒はない
    break;
  }
}

if(cnt!=-1 && j>=1){ //cntが-1なら使える棒なし && j=0はありえない
  ans += (j-1)-(cnt)+1;
}
//二分探索処理終了
//////////////////////////////////////////////////////
        }
      }

      System.out.println(ans);

    }
}


Measured memory_bytes: 25524