akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define fi first
#define se second
#define rep(i,s,n) for(int i = s;i<n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
const ll MOD=1000000007,INF=1e18;
 
int N,K=0,tmp=0,frag=1;

signed main() {
    IOS();
    cin>>N;
    vint a(N);
    rep(i,0,N)cin>>a[i];
    while(frag){
        frag=0;
        int x=0;
        rep(i,0,N){
            if(a[i]>=N){
                frag=1;
                int t=a[i]-N+1;
                if(t%N){
                    K+=t/N+1;
                    a[i]-=(t/N+1)*(N+1);
                    x+=t/N+1;
                }
                else{
                    K+=t/N;
                    a[i]-=t/N*(N+1);
                    x+=t/N;
                }
            }
        }
        rep(i,0,N)a[i]+=x;
    }
    cout<<K<<endl;
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    return 0;
}

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

class Main
{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    char C = sc.next().charAt(0);
    if (C == 'A') System.out.println("T");
    else if (C == 'T') System.out.println("A");
    else if (C == 'C') System.out.println("G");
    else System.out.println("C");
  }
}


Measured memory_bytes: 35696
void main() {
	auto N = ri;
	auto A = readAs!(int[]);
	auto arr = new int[](N+1);
	arr[0] = 3;
	long res = 1;
	const long MOD = 1000000007;
	foreach(v; A) {
		res *= arr[v]; res %= MOD;
		arr[v]--; arr[v+1]++;
	}
	res.writeln;
}

// ===================================

import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}

Measured memory_bytes: 4432
import java.util.Scanner;

public class Main {

    /**
     * @param args
     */
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        while(true){
            int N = sc.nextInt();
            if(N==0)break;
            int[] a = new int[N+1];
            for (int i = 0; i < N; i++) {
                a[i+1]=sc.nextInt();
            }
            double min = 1<<29;
            double e = 1e-10;
            int x=0,y=0,z=0;
            for (int i = 0; i <= 15; i++) {
                for (int j = 0; j <= 15; j++) {
                    for (int k = 0; k <= 15 ; k++) {
                        double H = calc(a,i,j,k);
                        if(min > H+e){
                            min = H;
                            x=i;
                            y=j;
                            z=k;
                        }
                    }
                }
            }
            System.out.println(x+" "+y+" "+z);
        }
    }
    static int m = 256;
    static double calc(int[] I,int s,int a,int c){
        double res = 0.0;
        int[] o = new int[257];
        int[] r = new int[I.length];
        r[0]=s;
        for (int j = 1; j < r.length; j++) {
            r[j] = (a*r[j-1]+c)%m;
        }
        for (int j = 1; j < I.length; j++) {
            o[(I[j]+r[j])%m]++;
        }
        for (int j = 0; j < o.length; j++) {
            if(o[j]!=0){
                double d = (double)o[j]/(I.length-1)*Math.log((double)o[j]/(I.length-1));
                res -= d;
            }
        }
        return res;
    }
}

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

int main(){
  int N;
  cin >> N ;
  
  if(N%2== 0){
    cout << 1.0/2.0 << endl;
  }
  if(N%2 == 1){
    cout <<((N+1.0)/2.0)/N << endl;
  }
}
    
  

Measured memory_bytes: 256
#include <stdio.h>
 
using namespace std;
 
int calcLimit(int n){
    int limit;
    for(limit=0;limit*limit<=n;limit++);
    return limit-1;
}
 
int main(){
    int n,count,limit;
 
    while(scanf("%d",&n)!=EOF){
        count=0;
        int* array = new int[n+1];
        for(int i=1;i<=n;i++)array[i]=0;
        limit = calcLimit(n);
        for(int i=2;i<=limit;i++){
            if(array[i] == 0)
            {
                for(int j=2*i;j<=n;j+=i){
                    if(array[j]==0){
                        array[j]=1;
                        count++;
                    }
                }
            }
        }
        printf("%d\n",n-(count+1));
    }
 
    return 0;
}


Measured memory_bytes: 59552
N=int(input())
List=[[0,0,0] for _ in range(N)]
for i in range(N):
    S,P=map(str,input().split())
    List[i][0]=i+1
    List[i][1]=S
    List[i][2]=int(P)
List.sort(key=lambda x:x[2],reverse=True)
List.sort(key=lambda x:x[1])
for i in range(N):
    print(List[i][0])

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

using namespace std;

int main(){
  
  int N;
  cin >> N;
  
  vector<long> H(N);
  int ans = 0, tmp = 0;
  cin >> H.at(0);
  
  for (int i = 1; i < N; i++){
    scanf("%d", &H.at(i));
    if(H.at(i-1) >= H.at(i)) {
      tmp++;
      ans = max(ans, tmp);
    }
    else tmp = 0;
  }
  
  cout << ans;
  
  return 0; 
}


Measured memory_bytes: 1024
#pragma warning(disable:4996)
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
const int maxn = 1007, maxm = 2007;
const int inf = 1e9 + 7;
int cnt = 1;
int head[maxn], vis[maxn], dfn[maxn], vis2[maxn];
//head[x]:点x连接的最后一条边号
//vis[x]:标记每次dfs访问过的点，以免重复搜索耗时
//dfn[x]:x的时间戳
//vis[x]2:dfs中标记访问过的次数，找环
int b[maxn];
struct edge
{
	int u, v, next;
}e[maxm];
void addedge(int u, int v)//前向星
{
	e[cnt].u = u;
	e[cnt].v = v;
	e[cnt].next = head[u];
	head[u] = cnt;
	cnt++;
}
vector<int> v;
int ans = inf;
void dfs(int x, int num)
{
	vis[x] = 1;//标记x访问过
	dfn[x] = num;
	for (int i = head[x]; i ; i = e[i].next)//遍历x点连接的所有边
	{
		int y = e[i].v;
		if (vis2[y] == 1)//y第二次被访问，说明形成环
		{
			if (dfn[x] - dfn[y] + 1 < ans)//ans记录最小环的大小
			{
				ans = dfn[x] - dfn[y] + 1;
				int sz = v.size();
				for (int i = 1; i <= ans; i++)
					b[i] = v[sz - i];//b[i]存最小环的点
			}
		}
		if (vis[y] == 0)//y没有访问过
		{
			vis2[y] = 1;
			v.push_back(y);
			dfs(y, num + 1);
		}
	}
	v.pop_back();
	vis2[x] = 0;
}
int main()
{
	int n, m;
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= m; i++)
	{
		int x, y;
		scanf("%d%d", &x, &y);
		addedge(x, y);
	}
	for (int i = 1; i <= n; i++)
	{
		if (vis[i] == 0)
		{
			v.clear();
			v.push_back(i);
			vis2[i] = 1;
			dfs(i, 1);
		}
	}
	if (ans == inf)
		printf("-1\n");
	else
	{
		printf("%d\n", ans);
		for (int i = ans; i >= 1; i--)
			printf("%d\n", b[i]);
	}
	return 0;
}

Measured memory_bytes: 764
#include <stdio.h>

int main(void){
    int p,q,r;

    scanf("%d %d %d",&p,&q,&r);
    
    if(p>=q && p>=r)
        printf("%d",q+r);
    else if(q>=p && q>=r)
        printf("%d",p+r);
    else
        printf("%d",p+q);
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <queue>
#include <numeric>
#include <string>
#include <string.h>
#include <map>
#include <set>
#include <functional>
#include <complex>
#include <stack>
#include <tuple>

#define ll long long int

using namespace std;

const int INF = (1<<25) - 1;

vector<int> bfs(int s, vector<pair<int, int>> &dirtys, vector<string> &field){
    int dh[] = {1, -1, 0, 0};
    int dw[] = {0, 0, 1, -1};

    int H = field.size(), W = field[0].size();
    vector<vector<int>> d(H, vector<int>(W, INF));
    pair<int, int> start = dirtys[s];
    
    queue<pair<int, int>> q;
    d[start.first][start.second] = 0;
    q.push(start);
    while(!q.empty()){
        pair<int, int> p = q.front(); q.pop();
        for(int i=0; i<4; i++){
            int nh = p.first + dh[i];
            int nw = p.second + dw[i];
            if(nh<0 || H<=nh || nw<0 || W<=nw || field[nh][nw]=='x' || d[nh][nw]!=INF)
                continue;
            d[nh][nw] = d[p.first][p.second] + 1;
            q.push(make_pair(nh, nw));
        }
    }
    
    vector<int> res(dirtys.size());
    for(int i=0; i<dirtys.size(); i++)
        res[i] = d[dirtys[i].first][dirtys[i].second];
    return res;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int W, H;
    while(cin>>W>>H, W|H){
        vector<string> field(H);
        for(string &r: field)
            cin >> r;
        
        //start???dirty??¨??????
        vector<pair<int, int>> dirtys;
        for(int i=0; i<H; i++)
            for(int j=0; j<W; j++)
                if(field[i][j] == 'o')
                    dirtys.push_back(make_pair(i, j));
                
        for(int i=0; i<H; i++)
            for(int j=0; j<W; j++)
                if(field[i][j] == '*')
                    dirtys.push_back(make_pair(i, j));
        
        vector<int> order(dirtys.size());
        for(int i=0; i<dirtys.size(); i++)
            order[i] = i;
            
        sort(order.begin()+1, order.end());
        
        vector<vector<int>> table(dirtys.size());
        for(int i=0; i<dirtys.size(); i++)
            table[i] = bfs(i, dirtys, field);
        
        int ans = INF;
        do{
            int tans = 0;
            for(int i=0; i<order.size()-1; i++)
                tans += table[order[i]][order[i+1]];
            ans = min(ans, tans);
        }while(next_permutation(order.begin()+1, order.end()));
        
        cout << (ans==INF ? -1 : ans) << endl;
    }
    
    return 0;
}

Measured memory_bytes: 1240
# -*- coding: utf-8 -*-
inf = 10**16
n = int(input())
edge = [[] for _ in range(n)]
for _ in range(n-1):
    a,b,c = map(int, input().split())
    a -= 1
    b -= 1
    edge[a].append((b,c))
    edge[b].append((a,c))

q,k = map(int, input().split())
k -= 1

d = [inf for _ in range(n)]
d[k] = 0
stack = [k]
while len(stack)>0:
    v = stack.pop()
    for u,c in edge[v]:
        if d[u]==inf:
            d[u] = d[v]+c
            stack.append(u)

res = []
for _ in range(q):
    x,y = map(int, input().split())
    x -= 1
    y -= 1
    res.append(d[x]+d[y])

for c in res:
    print(c)


Measured memory_bytes: 48196
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>

using namespace std;

#define PB push_back
#define ALL(v) (v).begin(), (v).end()
#define SZ size()
#define FOR(i, a, b) for(int (i) = (a); (i) < (b); (i)++)
#define REP(i, n) FOR((i), 0, (n))
#define GET(a) cin >> (a)
#define GET2(a, b) cin >> (a) >> (b)
#define GET3(a, b, c) cin >> (a) >> (b) >> (c)
#define SHOW(v) cout << (v) << endl
#define SHOW2(a, b) cout << (a) << " " << (b) << endl
#define SHOW3(a, b, c) cout << (a) << " " << (b) << " " << (c) << endl
#define MOD 1000000007
template<class T> void GETV(T &v) { REP(i, v.size()) { GET(v[i]); } }
template<class T> void SHOWV(T &v) { REP(i, v.size()) { SHOW(v[i]); } }

typedef long long ll;


int main()
{
	int n, a, b;
	cin >>  n >> a >> b;
	
	cout << (a > b ? b : a) << " " << (a + b > n ? a + b - n : 0) << endl;
	
    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<sstream>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<random>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())


int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	string s;
	cin >> s;
	
	rep(i,s.size()-1) {
		if (s[i]==s[i+1]) {
			cout << i + 1 << ' ' << i + 2 << endl;
			return 0;
		}if (i+2<s.size()&& s[i]==s[i+2]) {
			cout << i + 1 << ' ' << i + 3 << endl;
			return 0;
		}
	}
	cout << "-1 -1" << endl;

	return 0;
}

Measured memory_bytes: 512
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        int X = Integer.parseInt(sc.next());
        int[] d = new int[N];
        for(int i = 0; i < N; i++) {
            d[i] = Math.abs(Integer.parseInt(sc.next()) - X);
        }

        int D_max = d[0];
        for(int i = 1; i < d.length; i++) {
            D_max = D_max > d[i] ? gcd(D_max, d[i]) : gcd(d[i], D_max);
        }
        System.out.println(D_max);
    }

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


Measured memory_bytes: 47124
#include <iostream>
#include <set>

using namespace std;

int main()
{
	int x, n, cur, dif;

	cin >> x >> n;

	set<int, greater <int>> ps;

	while (n--)
	{
		cin >> cur;
		ps.insert(cur);
	}

	for (int i = 0; ; ++i)
	{
		if (!ps.count(x - i))
		{
			dif = -i;
			break;
		}
		else if (!ps.count(x + i))
		{
			dif = i;
			break;
		}
	}

	cout << x + dif << endl;
	
	return 0;	
}


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

using namespace std;

template <typename T> T gcd(T x, T y) {
  if (y == 0)
    return x;
  return gcd(y, x % y);
}

template <typename T> T lcm(T x, T y) {
  if (x == 0 || y == 0)
    return 0;
  return x / gcd(x, y) * y;
}

int main() {
  int N;
  cin >> N;
  vector<int> C(N + 1, 0), S(N + 1, 0), F(N + 1, 0);
  for (int i = 0; i < N - 1; i++) {
    cin >> C[i] >> S[i] >> F[i];
  }
  for (int i = 0; i < N; i++) {
    long ans = 0;
    for (int j = i; j < N - 1; j++) {
      if (ans < S[j]) {
        ans += S[j] - ans;
      }
      if (ans % F[j] != 0)
        ans += F[j] - ans % F[j];
      ans += C[j];
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 256
X = input()
ans = len(X)
N = len(X)
cnt_s = 0
cnt_t = 0
for i in range(N):
    if X[i] == "S":
        cnt_s += 1
    if X[i] == "T":
        cnt_t += 1
    
    if i < N -1:
        if X[i] == "T" and X[i + 1] == "S":
            ans -= 2 * min(cnt_s, cnt_t)
            cnt_s -= min(cnt_s, cnt_t)
            cnt_t = 0
    if i == N - 1:
        ans -= 2 * min(cnt_s, cnt_t)
    
print(ans)

Measured memory_bytes: 3500
W,H,N=map(int,input().split())
minx=0
maxx=W
miny=0
maxy=H
for i in range(1,N+1):
    x,y,a=map(int,input().split())
    if a==1:
        minx=max(minx,x)
    elif a==2:
        maxx=min(maxx,x)
    elif a==3:
        miny=max(miny,y)
    elif a==4:
        maxy=min(maxy,y)
ans=(maxx-minx)*(maxy-miny)
if maxx>=minx and maxy>=miny:
    print(ans)
elif maxx<=minx and maxy>=miny:
    print("0")
elif maxx>=minx and maxy<=miny:
    print("0")
elif maxx<=minx and maxy<=miny:
    print("0")

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

typedef long long ll;
typedef unsigned long long ull;

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> a(N), b(N), c(M), d(M);
    rep(i, N) cin >> a[i] >> b[i];
    rep(i, M) cin >> c[i] >> d[i];
    rep(i, N) {
        int mind = 1e9, ans;
        rep(j, M) {
            int md = abs(a[i] - c[j]) + abs(b[i] - d[j]);
            if (md < mind) {
                mind = md;
                ans = j + 1;
            }
        }
        cout << ans << "\n";
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define _p(...) (void)printf(__VA_ARGS__)
#define forr(x,arr) for(auto&& x:arr)
#define _overload3(_1,_2,_3,name,...) name
#define _rep2(i,n) _rep3(i,0,n)
#define _rep3(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,_rep3,_rep2,)(__VA_ARGS__)
#define _rrep2(i,n) _rrep3(i,0,n)
#define _rrep3(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define rrep(...) _overload3(__VA_ARGS__,_rrep3,_rrep2,)(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()
#define bit(n) (1LL<<(n))
#define sz(x) ((int)(x).size())
#define fst first
#define snd second
using ll=long long;
using pii=pair<int,int>;using pll=pair<ll,ll>;using pil=pair<int,ll>;using pli=pair<ll,int>;
using vs=vector<string>;using vvs=vector<vs>;using vvvs=vector<vvs>;
using vb=vector<bool>;using vvb=vector<vb>;using vvvb=vector<vvb>;
using vi=vector<int>;using vvi=vector<vi>;using vvvi=vector<vvi>;
using vl=vector<ll>;using vvl=vector<vl>;using vvvl=vector<vvl>;
using vd=vector<double>;using vvd=vector<vd>;using vvvd=vector<vvd>;
using vpii=vector<pii>;using vvpii=vector<vpii>;using vvvpii=vector<vvpii>;
template<class T,class U>istream&operator>>(istream&is,pair<T,U>&P){is>>P.fst;is>>P.snd;return is;}
template<class T>T read(){T t;cin>>t;return t;}
template<class T,class U>ostream&operator<<(ostream&o,const pair<T,U>&p){return o<<'('<<p.fst<<", "<<p.snd<<')';}
template<class T>ostream&operator<<(ostream&o,const vector<T>&t){o<<"{";rep(i,sz(t))o<<t[i]<<",";o<<"}"<<endl;return o;}
vs s_p_l_i_t(const string&s,char c){vs v;stringstream ss(s);string x;while(getline(ss,x,c))v.emplace_back(x);return move(v);}
void e_r_r(vs::iterator it){cerr<<endl;}
template<class T,class... Args>void e_r_r(vs::iterator it,T a,Args... args){cerr<<it->substr((*it)[0]==' ',it->length())<<" = "<<a<<", ";e_r_r(++it,args...);}
#define out(args...){vs a_r_g_s=s_p_l_i_t(#args,',');e_r_r(a_r_g_s.begin(),args);}
 
void Main() {
  int n = read<int>();
  vector<int> A(n);
  rep(i, n) A[i] = read<int>();

  vpii X;
  vl ans(n);
  {
    int ma = 0;
    rep(i, n) {
      if (A[i] > ma) {
        X.emplace_back(i, A[i]);
        ans[i] = A[i] - ma;
        ma = A[i];
        A[i] -= ans[i];
      }
    }
  }

  sort(all(A));
  vector<ll> R(sz(A)+1);
  rep(ii, sz(A)) R[ii+1] = R[ii] + A[ii];

  ll pval = 0;
  int plb = 0;
  forr(ia, X) {
    int idx = ia.fst;
    ll val = ia.snd;

    int lb = lower_bound(all(A), val) - A.begin();
    ll ar = (n - lb) * (val - pval);
    ll al = R[lb-1+1] - R[plb] - (lb - plb) * pval;
    //out(idx, val, lb, al, ar);

    ans[idx] += ar + al;

    plb = lb;
    pval = val;
  }

  rep(i, n) {
    _p(i+1<n?"%lld ":"%lld\n", ans[i]);
  }

}
int main() { cin.tie(nullptr); ios::sync_with_stdio(false); Main(); return 0; }



Measured memory_bytes: 3956
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
typedef long long ll;

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 long long INF = 1LL << 60;

int main(){
  set<int> st;

  rep(i, 3){
    int a; cin >> a;
    st.insert(a);
  }

  cout << st.size() << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#include<sstream>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-8;
const int inf=1e9;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
int main(){
	int n;
	while(cin>>n,n){
		vi a(n),b(n);
		rep(i,n)cin>>a[i];
		rep(i,n)cin>>b[i];
		sort(all(a));
		sort(all(b));
		reverse(all(a));
		reverse(all(b));
		int co=0,t=0;
		rep(i,n-1){	
			if(a[i]>b[t]){
				co++;
			}else t++;
			if(co>(i+1)/2){
				cout<<i+1<<endl;
				goto end;
			}
		}
		cout<<"NA"<<endl;
		end:;
	}
}

Measured memory_bytes: 1452
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>

using namespace std;

int main(void) {
	vector<long long>a, b;
	long long n, h, max, i, c, d;
	long double temp;
	long long  count = 0;

	cin >> n >> h;

	for (i = 0;i < n;i++) {
		cin >> c >> d;
		a.push_back(c);
		b.push_back(d);
	}

	max = 0;

	for (i = 0;i < n;i++) {
		if (max < a[i]) {
			max = a[i];
		}
	}

	sort(b.rbegin(), b.rend());

	for (i = 0;i < n;i++) {
		if (max < b[i]) {
			h -= b[i];
			count++;
		}
		if (h <= 0) {
			break;
		}
	}

	if(h > 0) {
		temp = (long double)h / max;
		count += floor(temp);

		if (ceil(temp) != floor(temp) ) {
			count++;
		}
	}

	cout << count << endl;

	return 0;
}

Measured memory_bytes: 2036
N, q_time = map(int, input().split())
b = []

for i in range(N):
    a = input().split()
    b.append(a)

cnt = 0
score = 0
while cnt < N:
    if int(b[cnt][1]) > q_time:
        b[cnt][1] = int(b[cnt][1]) - q_time
        delete = b.pop(cnt)
        b.append(delete)
        score += q_time
        #print(b)
    else:
        score += int(b[cnt][1])
        b[cnt][1] = score
        cnt += 1
        #print(b)

for i in b:
    print(*i)


Measured memory_bytes: 18672
#include<iostream>
#include<stdlib.h>
#include<queue>
using namespace std;

int main () {
  int a,b;
  while(cin>>a>>b,a|b){
    int x,y,m=0;
    int d[a*b]={};int k;cin>>k;
    for(int i=0;i<k;++i){
      cin>>x>>y;x--;y--;
      d[x+y*a]=1;
    }
    int t=a+b;
    int dp[2][a*b];
    for(int i=0;i<2;++i)for(int j=0;j<a*b;++j)dp[i][j]=0;
    dp[1-m][0]=1;
    while(t--){
      for(y=0;y<b;++y){
	for(x=0;x<a;++x){
	  if(d[x+y*a])continue;
	  if(dp[m][x+y*a]==0){
	    if(x>=1){dp[m][x+y*a]+=dp[1-m][(x-1)+y*a];}
	    if(y>=1){dp[m][x+y*a]+=dp[1-m][x+(y-1)*a];}
	  }
	}
      }
      for(int i=0;i<a*b;++i)dp[1-m][i]=dp[m][i];
      m=1-m;
    }
    cout<<dp[1-m][a*b-1]<<endl;
  }
}

Measured memory_bytes: 3092
W, H, N = map(int,input().split())
lx, rx = 0, W
dy, uy = 0, H

for i in range(N):
  x, y, a = map(int,input().split())
  if a == 1:
    lx = max(lx, x)
  elif a == 2:
    rx = min(rx, x)
  elif a == 3:
    dy = max(dy, y)
  elif a == 4:
    uy = min(uy, y)

w, h = rx - lx, uy - dy
if w <= 0 or h <= 0:
  print(0)
else:
  print(w*h)

Measured memory_bytes: 3064
#pragma region header
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define resort(v) sort((v).rbegin(), (v).rend())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
using ll = long long;
using P = pair<int, int>;
/* ----------------よく使う数字や配列----------------- */
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};
constexpr ll mod = 1e9+7;
constexpr ll inf = INT32_MAX/2;
constexpr ll INF = LLONG_MAX/2;
constexpr long double eps = DBL_EPSILON;
constexpr long double pi = 3.141592653589793238462643383279;
/* ----------------------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;
}
/* ----------------------end----------------------- */

/* --------------------ライブラリ-------------------- */
ll fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i % mod;
}
ll gcd(ll a, ll b) {        //最大公約数
    if(b == 0) return a;
    return gcd(b, a % b); 
}
ll lcm(ll a, ll b) {      //最小公倍数
    return a * b / gcd(a, b);
}
int keta(ll n) {        //桁数を求める
    if(n == 0) return 1;
    int count = 0;
    while(n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while(n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
/* ----------------------end----------------------- */
#pragma endregion
signed main() { 
    int n;cin >> n;
    vi a(n);
    rep(i, n)cin >> a[i];
    vi ans = a;
    sort(all(ans));
    map<int,int> mp;
    rep(i, n) {
        mp[ans[i]]=i%2;
    }
    int count = 0;
    rep(i, n) {
        if(mp[a[i]]!=i%2) count++;
    }
    cout << count/2 << endl;
    /*for(auto p:a)cout << p << ' ';
    cout << "\n";
    for(auto p:ans)cout << p << ' ';
    cout << "\n";*/
    return 0;
}

Measured memory_bytes: 11176
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<list>
#include<set>
#include<string>
using namespace std;
int gcd(int a, int b) {
	int c = a % b;
	while (c != 0) {
		a = b;
		b = c;
		c = a % b;
	}
	return b;
}
struct UnionFind {
	vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

	UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
		for (int i = 0; i < N; i++) par[i] = i;
	}

	int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
		if (par[x] == x) return x;
		return par[x] = root(par[x]);
	}

	void unite(int x, int y) { // xとyの木を併合
		int rx = root(x); //xの根をrx
		int ry = root(y); //yの根をry
		if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
		par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
	}

	bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
};
typedef long long ll;

ll M = 1000000007;

vector<ll> fac(300001); //n!(mod M)
vector<ll> ifac(300001); //k!^{M-2} (mod M)

ll mpow(ll x, ll n) {
	ll ans = 1;
	while (n != 0) {
		if (n & 1) ans = ans * x % M;
		x = x * x % M;
		n = n >> 1;
	}
	return ans;
}
ll comb(ll a, ll b) {
	if (a == 0 && b == 0)return 1;
	if (a < b || a < 0)return 0;
	ll tmp = ifac[a - b] * ifac[b] % M;
	return tmp * fac[a] % M;
}
// mod. m での a の逆元 a^{-1} を計算する
long long modinv(long long a) {
	long long b = M, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= M;
	if (u < 0) u += M;
	return u;
}
vector<vector<ll>> mul(vector<vector<ll>> a, vector<vector<ll>> b, int n) {
	int i, j, k, t;
	vector<vector<ll>> c(n);
	for (i = 0; i < n; i++) {
		for (j = 0; j < n; j++) {
			t = 0;
			for (k = 0; k < n; k++)
				t = (t + a[i][k] * b[k][j] % M) % M;
			c[i].push_back(t);
		}
	}
	return c;
}

template< typename Monoid >
struct SegmentTree {

	int sz;
	vector< Monoid > seg;

	const Monoid M1;

	SegmentTree(int n,  const Monoid &M1) :  M1(M1) {
		sz = 1;
		while (sz < n) sz <<= 1;
		seg.assign(2 * sz, M1);
	}

	void set(int k, const Monoid &x) {
		seg[k + sz] = x;
	}

	void build() {
		for (int k = sz - 1; k > 0; k--) {
			seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
		}
	}

	void update(int k, const Monoid &x) {
		k += sz;
		seg[k] = x;
		while (k >>= 1) {
			seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
		}
	}

	Monoid query(int a, int b) {
		Monoid L = M1, R = M1;
		for (a += sz, b += sz; a < b; a >>= 1, b >>= 1) {
			if (a & 1) L = f(L, seg[a++]);
			if (b & 1) R = f(seg[--b], R);
		}
		return f(L, R);
	}

	Monoid value(const int &k) const {
		return seg[k + sz];
	}

	Monoid f(Monoid a, Monoid b) {
		return a + b;
	}
};

int main() {
	ll n, i, sum, xsum, l, r, ans = 0, a[222222];
	cin >> n;
	for (i =0 ; i < n; i++)
		cin >> a[i];
	l = 0;
	r = 0;
	xsum = a[0];
	sum = a[0];
	while (l < n) {
		while (r < n-1) {
          int c=sum+a[r+1],d=xsum^a[r+1];
          if(c!=d)
            break;
			r++;
			sum += a[r];
			xsum = xsum ^ a[r];
		}
		ans += r - l + 1;
		sum -= a[l];
		xsum = xsum ^ a[l];
		l++;
	}
	cout << ans << endl;
}

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

using namespace std;
const int N=455;
ll dp[N][N];
ll pre[N];
ll a[N];

ll bt(int s , int e)
{
    if(s==e)
        return 0;
    ll &ret=dp[s][e];
    if(ret!=-1)
        return ret;
    ret=1e16+55;
    for(int i=s+1;i<=e;i++)
    {
        ret=min(ret,bt(s,i-1)+bt(i,e));
    }
    ret+=pre[e];
    if(s)
        ret-=pre[s-1];
    return ret;
}

int main()
{
    memset(dp,-1,sizeof dp);
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        pre[i]=a[i];
        if(i)
            pre[i]+=pre[i-1];
    }
    cout<<bt(0,n-1)<<endl;
    return 0;
}


Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

signed main(){
    int m;
    ll k;
    cin >> m >> k;
    if(k == 0){
        for(int i = 0; i < pow(2, m); i++){
            cout << i << " " << i << " ";
        }
        cout << endl;
        return 0;
    }
    if(m == 1){
        cout << -1 << endl;
        return 0;
    }
    if(pow(2, m) <= k){
        cout << -1 << endl;
        return 0;
    }
    cout << 0 << " " << k << " " << 0 << " ";
    for(int i = 1; i < pow(2, m); i++){
        if(i == k) continue;
        cout << i << " ";
    }
    cout << k << " ";
    for(int i = pow(2, m) - 1; i >= 1; i--){
        if(i == k) continue;
        cout << i << " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 1792
from pprint import pprint

n,w = map(int,input().split())

wv = [list(map(int,input().split())) for _ in range(n)]


dp_table = [[-float("inf")]*(w+1) for _ in range(n+1)]

dp_table[0] = [0]*(w+1)

#sum_w以下の重さの時のvalueの合計の最大を求めていく。

for i in range(1,n+1):
    for sum_w in range(w+1):
        #i番目の品物を選ばない場合
        dp_table[i][sum_w] = max(dp_table[i][sum_w], dp_table[i-1][sum_w])
        #i番目の品物を選ぶ場合
        if sum_w >= wv[i-1][0]:
            dp_table[i][sum_w] = max(dp_table[i][sum_w], dp_table[i-1][sum_w-wv[i-1][0]] + wv[i-1][1])
        else:
            continue


result = dp_table[n][w]
print(result)


Measured memory_bytes: 306968
//Dragon_warrior7(IITK)
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize ("-ffloat-store")
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//using namespace __gnu_pbds;
#define ll long long
#define pb push_back
#define nl cout << '\n'
#define sor(x) sort(x.begin(), x.end())
#define rev(v) reverse(v.begin(), v.end())
#define lb(v, temp) lower_bound(v.begin(), v.end(), temp)
#define ub(v, temp) upper_bound(v.begin(), v.end(), temp)
#define fi first
#define se second
#define llmax 1000000000000000000
#define pll pair<ll, ll> 
#define ull unsigned ll
#define vll vector<ll> 
#define rub cout << "\n------------------------------------\n"
#define deb(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) 
{
	cout << *it << " = " << a;
	nl;
	err(++it, args...);
}
//typedef  tree < int ,  null_type ,  greater<int> ,  rb_tree_tag ,  tree_order_statistics_node_update > oset;
void read(vector<ll> &v)
{
	for (int i = 0; i < v.size(); i++)
		cin >> v[i];
}
// const int mod=1e9+7;
// ll power(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
// ll modInverse(ll a){return power(a,mod-2);}
ll n,m,a,b,c,k,temp,x,y;
void solveforthiscase(const int & test)
{//deb(test);
cin>>n;
if(n<=1199)
{
    cout<<"ABC\n";
    return ;
}
if(n<=2799)
{
    cout<<"ARC";
    return ;
}
cout<<"AGC";






return ;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int test=1;
// 	cin>>test;
    for(int i=1;i<=test;i++)
    {
        solveforthiscase(i);
    }
}

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

using ll = int64_t;
#define int ll

#define FOR(i, a, b) for (int i = int(a); i < int(b); i++)
#define REP(i, b) FOR(i, 0, b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(), x.end()

using pi = pair<int, int>;
using vi = vector<int>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  REP(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

ll read() {
  ll i;
  scanf("%" SCNd64, &i);
  return i;
}

void printSpace() { printf(" "); }

void printEoln() { printf("\n"); }

void print(ll x, int suc = 1) {
  printf("%" PRId64, x);
  if (suc == 1)
    printEoln();
  if (suc == 2)
    printSpace();
}

string readString() {
  static char buf[3341000];
  scanf("%s", buf);
  return string(buf);
}

char *readCharArray() {
  static char buf[3341000];
  static int bufUsed = 0;
  char *ret = buf + bufUsed;
  scanf("%s", ret);
  bufUsed += strlen(ret) + 1;
  return ret;
}

template <class T, class U> void chmax(T &a, U b) {
  if (a < b)
    a = b;
}

template <class T, class U> void chmin(T &a, U b) {
  if (b < a)
    a = b;
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

signed main() {
  int k, s;
  std::cin >> k >> s;
  int ans = 0;
  for (int x = 0; x <= k; x++)
    for (int y = 0; y <= k; y++)
      if (s - x - y <= k && s - x - y >= 0)
        ans++;
  print(ans);
}


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

string a,b,d;
int c;

int main(){
	ios::sync_with_stdio(false);
	cin>>a>>b;
	d=a+b;
	for(int i=0;i<d.size();i++)
		c=c*10+(d[i]-'0');
	if((int)sqrt(c)*(int)sqrt(c)==c)
		cout<<"Yes";
	else
		cout<<"No";
	return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++)
    cin >> a.at(i);
  sort(a.begin(),  a.end());
  int alice = 0, bob = 0;
  for (int i = n-1;;) {
    alice += a.at(i);
    if (i == 0)
      break;
    i--;
    bob += a.at(i);
    if (i == 0)
      break;
    i--;
  }
  cout << alice - bob << endl;
  
}


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

public class Main {

	public static void main(String[] args) {

		Scanner text = new Scanner(System.in);
		
		int First = text.nextInt();
		int Second = text.nextInt();
		int Third = text.nextInt();
		
		int[] Sorttext = {First,Second,Third};
		Arrays.sort(Sorttext);
		System.out.println(Sorttext[0]+" "+Sorttext[1]+" "+Sorttext[2]);
	}

}

Measured memory_bytes: 26240
N, M = list(map(int, input().split()))
ABs = [0] * N
day_dic = {}

for i in range(N):
    ABs[i] = list(map(int, input().split()))

ABs = sorted(ABs, reverse=True, key=lambda x: x[1])

rewards = [0] * (M + 1)

count = 0
for AB in ABs:
    day, reward = AB
    if day <= M:
        if rewards[day] == 0:
            rewards[day] = reward
            day_dic[day] = day
            count += 1
        else:
            esti = day_dic.get(day)
            if esti is None:
                esti = day
            for i in range(esti, M + 1):
                if rewards[i] == 0:
                    rewards[i] = reward
                    day_dic[day] = i
                    count += 1
                    break
    if count == M:
        break

result = sum(rewards)
print(result)

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

#define int long long int
#define REP(i, n) for (int i(0); i < n; ++i)
#define REQ(i, a, b) for (int i(a); i <= b; ++i)


int32_t main(){
int n;
cin >> n;
string s,t;
cin >> s >> t;
for(int i(0);i<n;++i){
	cout << s[i] << t[i];
}
}

Measured memory_bytes: 256
BIG_NUM = 2 * 10**9

n = int(input())
table = list(map(int, input().split()))

vmax = - BIG_NUM
vmin = BIG_NUM
vsum = 0

for x in table:
    if x > vmax:
        vmax = x
    if x < vmin:
        vmin = x
    vsum += x

print("{} {} {}".format(vmin, vmax, vsum))


Measured memory_bytes: 6588
#include<bits/stdc++.h>
#include<iomanip>
#include<numeric>

using namespace std;
using ll = long long;
constexpr int mo = 1e9+7;
constexpr int  mod = mo;
constexpr int inf = 1<<30;
constexpr int mo2 = 998244353;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n;
    cin>>n;
    vector<int> d(n);
    for(auto&a : d) cin>>a;
    int sum = 0;
    for(int i=0;i<n-1;++i){
        for(int j=i+1;j<n;++j){
            sum += d[i]*d[j];
        }
    }
    cout << sum << endl;
    return 0;
}



Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main()
{
  string A,B;
  int a,b;
  string c;
  cin>>A>>B;
  cin>>a>>b;
  cin>>c;
  
  if(c==A)
    --a;
  else
    --b;
  
  cout<<a<<" "<<b;
}
  
  
  

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

int main(){
    long a,b;
    cin >> a >> b;
    long d=a/b,r=a%b;
    double f=(double)a/b;
    cout << d << ' ' << r << ' ' << fixed << setprecision(6) << f << endl;
    return 0;
}


Measured memory_bytes: 3264
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define debug(a) cout << #a << ": " << a << endl
#define sz(a) int(a.size())
#define rep(i,n) for(int i=0;i<n;i++)
#define forr(i, st, en) for(int i = st; i < en; i++)
#define all(v) (v).begin(),(v).end()
#define fast cin.tie(0); ios::sync_with_stdio(false)

int32_t main(){ fast;
	
	string s; cin>>s;
	int ans = 0;
	for(char x: s){
		ans += (x == '2');
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
# !/usr/bin/env python
# vim: set fileencoding=utf-8 :

"""
#
# Author:   Noname
# URL:      https://github.com/pettan0818
# License:  MIT License
# Created:  2016-09-28
#

# Usage
#
"""
import sys

def input_single_line():
    """Receive Inputs."""
    return input()

def input_two_line():
    """Receive Two Lined Inputs.
    Like this.

    N
    1 2 3 4 5
    """
    sys.stdin.readline()
    target = sys.stdin.readline()
    target = target.rstrip("\n")
    target = target.split(" ")

    return target


def search_lovers(target_list: list) -> None:
    """Search Simple.
    >>> target_list = [2, 3, 1]
    >>> search_lovers(target_list)
    0
    >>> target_list = [2, 1, 4, 3]
    >>> search_lovers(target_list)
    2
    >>> target_list = [5, 5, 5, 5, 1]
    >>> search_lovers(target_list)
    1
    """
    target_list = [int(i) - 1 for i in target_list]
    lovers = []
    ans = 0
    for i, n in enumerate(target_list):
        if target_list[n] == i:
            ans = ans + 1

    print(int(ans/2))


if __name__ == "__main__":
    import doctest
    doctest.testmod()

    target = input_two_line()

    search_lovers(target)



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

using namespace std;

typedef pair<int,int> pi;

const int maxn = 5010;

int n;
char s[maxn], t[maxn];

vector<pi> vec1, vec2;

int main() {
	scanf("%d", &n);
	scanf("%s%s", s+1, t+1);
	for (int i = 1; i <= n; i++) vec1.push_back(pi(i & 1, 0));
	if (vec1[n-1].first != (s[1] - '0')) vec1.push_back(pi(s[1] - '0', 0));
	for (int i = 1; i <= n; i++) {
		if (s[i] != s[i+1]) {
			vec1.push_back(pi((s[i] - '0')^1, i));
		}
	}
	for (int i = 1; i <= n; i++) vec1.push_back(pi(vec1[vec1.size()-1].first^1, n));
	vec2.push_back(pi(t[1] - '0', 0));
	for (int i = 1; i <= n; i++) {
		if (t[i] != t[i+1]) {
			vec2.push_back(pi((t[i] - '0')^1, i));
		}
	}
	int ans = 0x3f3f3f3f;
	int sz = int (vec2.size());
	for (int i = 0; i+sz-1 < vec1.size(); i++) {
		if (vec1[i].first != vec2[0].first) continue;
		int res = 0;
		for (int j = 0; j < sz; j++) res += abs(vec1[i+j].second - vec2[j].second);
		for (int j = 0; j < i; j++) res += abs(vec1[j].second - 0);
		for (int j = i+sz; j < vec1.size(); j++) res += abs(vec1[j].second - n);
		if (res < ans) ans = res;
	}
	printf("%d\n", ans);
	return 0;
}

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

#define PB push_back
#define CL(A,I) (memset(A,I,sizeof(A)))

#define FOR(i, m, n) for (int i=m; i < n; i++)
#define F(n) FOR(i,0,n)
#define FF(n) FOR(j,0,n)

#define D(X) cout<<"  "<<#X": "<<X<<endl;

using ll=long long;
using ii=pair<ll,ll>;
using vi=vector<ll>;
using vii=vector<ii>;

#define aa first
#define bb second

#define EPS (1e-9)
#define EQ(A,B) (A+EPS>B&&A-EPS<B)

ll arr[100005];
int main() {
	ll N;
	cin>>N;
	ll o, e;
	F(N){
		cin>>arr[i];
		if(arr[i]%2==0) e++;
		else o++;
	}
	e+=o/2;
	o=o%2;
	if(o==1 && e!=0){
		cout<<"NO"<<endl;
	}
	else{
		cout<<"YES"<<endl;
	}


    return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
 
#define oo 1e18
#define fi first
#define se second
#define sp(iiii) setprecision(iiii)
#define IO ios_base::sync_with_stdio(false); cin.tie(0)
#define ms(aaaa,xxxx) memset(aaaa,xxxx,sizeof(aaaa))
#define cntbit(xxxx) __builtin_popcount(xxxx)
#define getbit(xxxx,aaaa) ((xxxx>>(aaaa-1))&1)
#define _cos(xxxx) cos(xxxx*acos(-1)/180)
#define _sin(xxxx) sin(xxxx*acos(-1)/180)
#define _tan(xxxx) tan(xxxx*acos(-1)/180)
#define PE cout<<fixed
#define sqr(x) ((x)*(x))
 
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<pair<int,int>,int> piii;
typedef pair<long long,long long> pll;
typedef pair<pair<long long,long long>,long long> plll;
 
const ld pi=acos(-1);

ll i,res;
string s;

int main() {
    IO;
    cin>>s;
    for (i=0;i<s.length();i++) {
        if (s[i]=='p') {
            res--;
        }
    }
    res+=s.length()/2;
    cout<<res;
}
  

Measured memory_bytes: 3768
N, K = map(int, input().split())
S = input()
l = []
if S[0] == '0':
  l.append(0)
p = S[0]
cnt = 0
for c in S:
  if c == p:
    cnt += 1
  else:
    l.append(cnt)
    cnt = 1
  p = c
l.append(cnt)
if S[-1] == '0':
  l.append(0)

# print(l)
top = 0
ll = 2*K+1
m = min(ll, len(l))
for i in range(m):
  top += l[i]
# print(top)
t = top
for i in range(2, len(l)-(ll)+1, 2):
  t = t - l[i-2] - l[i-1] + l[i+ll-2] + l[i+ll-1]
  # print('%d: %d' % (i, t))
  if t > top:
    top = t
print(top)


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

int main() {
	int n; cin >> n;
	map<int, int>a; int cnt = 0;
	for (int i = 0, tmp; i < n; i++) {
		cin >> tmp;
		a[tmp]++;
		if (a[tmp] > 1)cnt++;
	}
	int ans = a.size();
	cout << (a.size() % 2 == 0 ? ans - 1 : ans) << endl;

	return 0;
}

Measured memory_bytes: 4992
l,r=map(int,input().split())
M=len(bin(r))-2
L=format(l,"b").zfill(M)
R=format(r,"b")
mod=10**9+7
dp=[[0 for l in range(70)] for i in range(5)]
if L[0]=="1":
  dp[2][0]=1
else:
  dp[3][0]=1
  dp[0][0]=1
for i in range(1,M):
  if L[i]=="1" and R[i]=="1":
    dp[1][i]=(dp[0][i-1]+dp[1][i-1])%mod
    dp[2][i]=(dp[2][i-1])%mod
    dp[3][i]=(2*dp[3][i-1])%mod
    dp[4][i]=(dp[3][i-1]+3*dp[4][i-1])%mod
  elif L[i]=="1" and R[i]=="0":
    dp[1][i]=dp[1][i-1]+dp[0][i-1]
    dp[3][i]=dp[3][i-1]
    dp[4][i]=(dp[4][i-1]*3)%mod
  elif L[i]=="0" and R[i]=="1":
    dp[0][i]=dp[0][i-1]
    dp[1][i]=(2*dp[1][i-1]+dp[2][i-1])%mod
    dp[2][i]=dp[2][i-1]
    dp[3][i]=(dp[2][i-1]+dp[3][i-1]*2)%mod
    dp[4][i]=(dp[0][i-1]+dp[1][i-1]+dp[3][i-1]+dp[4][i-1]*3)%mod
  else:
    dp[0][i]=dp[0][i-1]
    dp[1][i]=(dp[1][i-1]*2)%mod
    dp[2][i]=dp[2][i-1]
    dp[3][i]=(dp[3][i-1])%mod
    dp[4][i]=(dp[0][i-1]+dp[1][i-1]+dp[4][i-1]*3)%mod
ans=0
for i in range(5):
  ans+=dp[i][M-1]
  ans%=mod
print(ans)

Measured memory_bytes: 3192
import java.io.InputStream;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    resolve(System.in, System.out);
  }

  static void resolve(InputStream is, PrintStream pw) {
    Scanner sc = new Scanner(is);
    int n = Integer.parseInt(sc.next());
    long a[] = new long[n + 1];
    for (int i = 0; i < n; i++) {
      a[i + 1] = Integer.parseInt(sc.next());
    }
    Map<Long, Indexes> lx = new HashMap<>();
    Map<Long, Indexes> rx = new HashMap<>();
    for (int i = 1; i <= n; i++) {
      long l = i + a[i];
      long r = i - a[i];
      Integer iv = Integer.valueOf(i);
      lx.computeIfAbsent(l, k -> new Indexes()).add(iv);
      rx.computeIfAbsent(r, k -> new Indexes()).add(iv);
    }
    long ans = 0;
    for (Map.Entry<Long, Indexes> lEntry : lx.entrySet()) {
      Long k = lEntry.getKey();
      if (rx.containsKey(k)) {
        ans += lEntry.getValue().countMatches(rx.get(k));
      }
    }
    pw.println(ans);
  }

  static class Indexes {

    List<Integer> indexes;

    public Indexes() {
      indexes = new ArrayList<>();
    }

    void add(Integer i) {
      indexes.add(i);
    }

    int size() {
      return indexes.size();
    }


    long countMatches(Indexes other) {
      long ans = 0;
      for (Integer i : indexes) {
        int otherIndex = Collections.binarySearch(other.indexes, i);
        if (otherIndex >= 0) {
          ans += other.size() - otherIndex - 1;
        } else {
          ans += other.size() - (-otherIndex - 1);
        }
      }
      return ans;
    }
  }
}


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

#define M 1046527
#define NIL (-1)
#define L 14

char H[M][L];

int getChar(char ch) {
	if (ch == 'A') return 1;
	else if (ch == 'C') return 2;
	else if (ch == 'G') return 3;
	else if (ch == 'T') return 4;
	else return 0;
}

long long getKey(char str[]) {
	long long sum = 0, p = 1, i;
	for (i = 0; i < strlen(str); i++) {
		sum += p * (getChar(str[i]));
		p *= 5;
	}
	return sum;
}

int h1(int key) { return key % M; }
int h2(int key) { return 1 + (key % (M - 1)); }

int find(char str[]) {
	long long key, i, h;
	key = getKey(str);
	for (i = 0;; i++) {
		h = (h1(key) + i * h2(key)) % M;
		if (strcmp(H[h], str) == 0) return 1;
		else if (strlen(H[h]) == 0) return 0;
	}
	return 0;
}

int insert(char str[]) {
	long long key, i, h;
	key = getKey(str);
	for (i = 0;; i++) {
		h = (h1(key) + i * h2(key)) % M;
		if (strcmp(H[h], str) == 0) return 1;
		else if (strlen(H[h]) == 0) {
			strcpy(H[h], str);
			return 0;
		}
	}
	return 0;
}

int main()
{
	int i, n;
	char str[L], com[9];
	for (i = 0; i < n; i++) H[i][0] = '\n';
	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%s %s", com, str);

		if (com[0] == 'i') {
			insert(str);
		}
		else {
			if (find(str)) {
				printf("yes\n");
			}
			else {
				printf("no\n");
			}
		}
	}
	return 0;
}


Measured memory_bytes: 16792
#include<bits/stdc++.h>
#include<vector>
#define inf 10000000000000
#define ll unsigned long long
#define boostUP ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define fsr(i,n) for(ll i=0;i<n;i++)
#define fcr(i,a,b) for(int i=a;i<b;i++)
#define pb push_back
#define sz(arr) sizeof(arr)/sizeof(arr[0])
#define mod 1000000007;

using namespace std;
// lower_bound
// it returns pos of the elmnt which is not less then the query elmnt
int main() {
	int contests, rating;
	cin >> contests >> rating;
	int finalRating = 0;
	if(contests >= 10){
		finalRating = rating;
	}else{
		finalRating = rating + (100 * (10 - contests));
	}
	cout << finalRating << endl;
}



Measured memory_bytes: 3628