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

#define F first
#define S second
#define pb push_back
#define eb emplace_back
#define PI 3.14159265359
#define sz(c) (int)c.size()
#define len(c) (int)c.length()
#define hcf(a, b) __gcd(a, b)
#define all(c) c.begin(), c.end()
#define vint vector<int>
#define vll vector<ll>
#define vpint vector<pair<int, int>>
#define vpll vector<pair<ll, ll>>
#define fr(it, a, b) \
    for (int it = (a); it < (b); it++)
#define tr(c, it) \
    for (auto it = c.begin(); it != c.end(); it++)
#define cpresent(c, e) (find(all(c), e) != c.end())
#define present(c, e) (c.find(e) != c.end())
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pi;
typedef unsigned long long lu;
const ll mod = 1e9 + 7;
int32_t main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, k;
    cin >> n >> k;
    vint a(n);
    fr(i, 0, n)
    {
        cin >> a[i];
    }
    int ln = 0, l = 1, r = 1e9;
    while (l <= r)
    {
        int ans = 0, m = (l + r) / 2;
        fr(i, 0, n)
        {
            if (a[i] > m)
                ans += a[i] / m;
        }
        if (ans <= k)
        {
            ln = m;
            r = m - 1;
        }
        else
        {
            l = m + 1;
        }
    }
    cout << ln << "\n";
    return 0;
}

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

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

    ll N, T;
    cin >> N >> T;
    ll t[N];
    rep(i,N) cin >> t[i];
    
    ll diff[N - 1];
    rep(i, N-1){
        diff[i] = t[i+1] - t[i];
    }
    
    ll ans = 0;
    rep(i,N-1){
        ans += min(T, diff[i]);
    }
    ans += T;
    
    cout << ans << endl;
    
    return 0;
}

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

#define rep(i, a, b) for (int i = (a), i##end = (b); i <= i##end; ++i)
#define per(i, a, b) for (int i = (a), i##end = (b); i >= i##end; --i)

mt19937 Rnd(chrono::high_resolution_clock::now().time_since_epoch().count());

template <typename T>
inline void chkmax(T &x, T y) { if (x < y) x = y; }

template <typename T>
inline void chkmin(T &x, T y) { if (x > y) x = y; }

inline int read() {
  #define nc getchar()
  int x = 0;
  char c = nc;
  while (c < 48) c = nc;
  while (c > 47) x = x * 10 + (c ^ 48), c = nc;
  return x;
  #undef nc
}

typedef long long ll;
int n,q;
ll ans;

map <int, int> mp;

void solve() {
  cin>>n;
  rep(i,1,n){
    int x=read();
    ans+=x,mp[x]++;
  }
  cin>>q;
  while(q--) {
    int x=read(),y=read();
    mp[y]+=mp[x];
    ans-=1ll*x*mp[x]-1ll*mp[x]*y;
    mp[x]=0;
    printf("%lld\n",ans);
  }
}

int main() {
//  int T = read();
//  while (T--) solve();
  solve();
  return 0;
}


Measured memory_bytes: 8160
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define db double
#define pii pair<int,int>
#define pli pair<ll,int>
#define pil pair<int,ll>
#define pll pair<ll,ll>
#define mat vector<vector<double>>
const int inf = 1 << 30;
const ll linf = 1e18;
const db EPS = 1e-7;
template<class T> void chmin(T& x, T y){if(x > y) x = y;}
template<class T> void chmax(T& x, T y){if(x < y) x = y;}

int N;
vector<int> G[200010];
vector<int> vs[2];
int ans[200010];
bool used[200010];

void dfs(int v, int p, int d){
    vs[d % 2].push_back(v);
    for(auto& u : G[v]){
        if(u == p) continue;
        dfs(u, v, d + 1);
    }
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> N;
    for(int i = 1; i < N; i++){
        int a, b;
        cin >> a >> b;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    dfs(1, 0, 0);

    if(vs[0].size() <= N / 3){
        int cnt = 3;
        for(auto u : vs[0]) ans[u] = cnt, used[cnt] = true, cnt += 3;
        
        cnt = 1;
        for(auto u : vs[1]){
            while(used[cnt]) cnt++;
            ans[u] = cnt;
            used[cnt] = true;
        }
    }else if(vs[1].size() <= N / 3){
        int cnt = 3;
        for(auto u : vs[1]) ans[u] = cnt, used[cnt] = true, cnt += 3;
        
        cnt = 1;
        for(auto u : vs[0]){
            while(used[cnt]) cnt++;
            ans[u] = cnt;
            used[cnt] = true;
        }
    }else{
        int o = 1, w = 2, t = 3;
        for(auto u : vs[0]){
            if(o > N){
                ans[u] = t;
                t += 3;
            }else{
                ans[u] = o;
                o += 3;
            }
        }

        for(auto u : vs[1]){
            if(w > N){
                ans[u] = t;
                t += 3;
            }else{
                ans[u] = w;
                w += 3;
            }
        }
    }
    for(int i = 1; i <= N; i++) cout << ans[i] << " ";
    cout << endl;
    return 0;
}

Measured memory_bytes: 21620
from collections import Counter, defaultdict
import sys

sys.setrecursionlimit(10 ** 5 + 10)
# input = sys.stdin.readline
from math import factorial
import heapq, bisect
import math
import itertools

import queue
from collections import deque


def main():
    num, submit = map(int, input().split())
    fin_flg = [0 for i in range(num + 1)]
    count_ac, count_wa = 0, 0

    for i in range(submit):
        a, b = input().split()
        a = int(a)
        if fin_flg[a] == -1:
            continue
        if b == "AC":
            count_ac += 1
            count_wa += fin_flg[a]
            fin_flg[a] = -1
        else:
            fin_flg[a] += 1

    print(count_ac, count_wa)




if __name__ == '__main__':
    main()


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

const int maxn = 205;
const int maxm = 1e5+115;

int n;
int A[maxn], K[maxn];
int ans[maxn];
int sg[2][maxm] = {0}, tmp[maxm];
int cnt[maxm];

void Init()
{
	scanf("%d", &n);
	for (int i = 1; i <= n; ++i) {
		scanf("%d%d", A + i, K + i);
	}
}

int Get1(int X, int P)
{
	while (1) {
		if (X < P) return 0;
		if (X % P == 0) return X / P;
		else X -= (X / P + 1);
	}
}

int Get2(int X, int P)
{
	while (1) {
		if (X < P) return 0;
		X -= (X % P) - (X % P) % (X / P + 1);
		if (X % P == 0) return X / P;
		X -= (X / P + 1);
	}
}

void Solve()
{
	int N = 3e4, Ans = 0;
	for (int i = 1; i <= n; ++i) {
		if (K[i] <= N) Ans ^= Get1(A[i], K[i]);
		else Ans ^= Get2(A[i], K[i]);
	}
	if (Ans == 0) puts("Aoki");
	else puts("Takahashi");
}

int main()
{
	Init();
	Solve();
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#define mod 1000000007
using namespace std;

int read() {
    int x = 0, f = 1;
    char c = getchar();
    while (c < '0' || c > '9') {
        if (c == '-') f = -1;
        c = getchar();
    }
    while (c >= '0' && c <= '9') {
        x = x * 10 + c - '0';
        c = getchar();
    }
    return x * f;
}

char s[200005];
int a[200005];
int main() {
    int n = read() * 2, tmp = 0, res = 1;
    scanf("%s", s + 1);
    for (int i = 1; i <= n; ++i) a[i] = (s[i] == 'B') ^ (i & 1);
    for (int i = 1; i <= n; ++i) {
        if (a[i] == 0)
            tmp++;
        else
            res = 1ll * res * tmp % mod, tmp--;
    }
    for (int i = 1; i <= n / 2; ++i) res = 1ll * res * i % mod;
    printf("%d\n", (!tmp) ? res : 0);
    return 0;
}

Measured memory_bytes: 1280
#include <iostream>
using namespace std;
int main(){
  int N;
  cin>>N;
  int i;
  int people[N]={};
  for(i=0;i<=N-1;i++){
  cin>>people[i];
  }
  int average=0;
  for(i=0;i<=N-1;i++){
  average+=people[i];
  }
  average/=N;
  int average2=average+1;
  int answer=0;
  int answer2=0;
  for(i=0;i<=N-1;i++){
  answer+=(average-people[i])*(average-people[i]);
      answer2+=(average2-people[i])*(average2-people[i]);
  }
  if(answer<=answer2){
  cout<<answer;
  }
  else{
  cout<<answer2;
  }
}

Measured memory_bytes: 3572
#include "bits/stdc++.h"
#define hhh cerr<<"hhh"<<endl
#define see(x) cerr<<(#x)<<'='<<(x)<<endl
using namespace std;
typedef long long ll;
typedef pair<int,int> pr;
inline int read() {int x=0,f=1;char c=getchar();while(c!='-'&&(c<'0'||c>'9'))c=getchar();if(c=='-')f=-1,c=getchar();while(c>='0'&&c<='9')x=x*10+c-'0',c=getchar();return f*x;}

const int maxn = 4e5+7;
const int inf = 0x3f3f3f3f;
const int mod = 1e9+7;

int a[18], b[18];
int p2[18], vis[18];

struct P{
    int v, x, h;
}p1[18];

int main() {
    int n=read();
    for(int i=0; i<n; ++i) a[i]=read();
    for(int i=0; i<n; ++i) b[i]=read();
    int ans=inf;
    for(int s=0; s<1<<n; ++s) {
        for(int i=0; i<n; ++i) {
            p1[i].v=p2[i]=(s>>i&1?b[i]:a[i]);
            p1[i].x=i; p1[i].h=s>>i&1;
        }
        sort(p2,p2+n);
        int tmp=0, f=1;
        for(int i=0; i<n; ++i) {
            int pos=-1;
            for(int j=i; j<n; ++j) {
                if(p1[j].v==p2[i]&&abs(p1[j].x-i)%2==p1[j].h) {
                    pos=j;
                    break;
                }
            }
            if(pos!=-1) {
                tmp+=abs(pos-i);
                for(int j=pos; j>i; --j) swap(p1[j-1],p1[j]);
            }
            else { f=0; break; }
        }
        if(f) ans=min(ans,tmp);
    }
    if(ans>100000) printf("-1\n");
    else printf("%d\n", ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int a[10];
bool check(int n){
	while(n!=0){
		if(a[n%10]){
			return 0;
		}
		n/=10;
	}
	return 1;
}
int main(){
	int x,y;
	int n;
	cin>>n>>x;
	for(int i=0;i<x;i++){
		cin>>y;
		a[y]=1;
	}
	while(!check(n))n++;
	cout<<n;
}

Measured memory_bytes: 256
import itertools
import bisect
N, K = [int(_) for _ in input().split()]
A = [int(_) for _ in input().split()]


def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5) + 1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n // i)

    divisors.sort(reverse=True)
    return divisors


divisors = make_divisors(sum(A))
for d in divisors:
    b = []
    for a in A:
        b += [a % d]
    b.sort()
    c = [0] + list(itertools.accumulate(b))
    il = bisect.bisect_left(c, K)
    if il >= len(c) or d * (len(c) - il - 1) - (c[-1] - c[il]) <= K:
        print(d)
        exit()


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
typedef long long int ll;
const int N=2e5+7;
int a[N];
int ans[N];
int main()
{

	ios_base:: sync_with_stdio(false); cin.tie(0);
	int n; cin>>n;

	for(int i=1; i<=n; i++) {
		cin>>a[i];
	}
	for(int i=n; i>=1; i--) {
		int cnt=0;
		for(int j=i; j<=n; j+=i) {
			cnt+=ans[j];
		}
		cnt%=2;
		if(cnt!=a[i]) {
			if(ans[i]==1) {
				cout<< -1<<endl;
				return 0;
			}
			else{
				ans[i]=1;
			}
		}
	}
	int an=0;
	for(int i=1; i<=n; i++) {
		an+=(ans[i]);
	}
	cout<<an<<endl;
	for(int i=1; i<=n; i++) {
		if(ans[i]) {
			cout<<i<<" ";
		}
	}
	if(an) cout<<endl;
	return 0;
}


Measured memory_bytes: 2432
s1 = input()
s2 = input()

list_s1 = list(s1)
list_s2 = list(s2)

len_s1 = len(s1)
len_s2 = len(s2)

change_count_min = len_s2

for i in range(len_s1 - len_s2 + 1):
    change_count = len_s2
    for j in range(len_s2):
        if list_s1[j+i] == list_s2[j]:
            change_count -= 1

    if change_count < change_count_min:
        change_count_min = change_count
print(change_count_min)


Measured memory_bytes: 9068
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using ll = long long;
const long long INF = 1LL << 60;
const int MOD = 1e9 + 7;

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; }



int main() {
    
    int N,K;
    cin >> N >> K;

    std::vector<int> A(N);
    rep(i,N){
        cin >> A.at(i);
    }

    std::vector<int> imos(N+1);
    std::vector<int> nextA(N);
    bool f = false;
    int c;

    rep(j,K){
        rep(i,N){
            imos[max(0,i-A[i])] += 1;
            imos[min(N,i+A[i]+1)] -= 1;
        }

        rep(i,N){
            if(i==0){
                imos[i] = imos[i];
            }else if(i > 0){
                imos[i] = imos[i-1]+imos[i];
            }
        }

        rep(i,N){
            A[i] = imos[i];
            imos[i] = 0;
        }
        imos[N] = 0;

        f = true;
        rep(i,N){
            if(N!=A[i]){
                f = false;
                break;
            }
        }
        if(f){
            break;
        }

    }
    rep(i,N){
        cout << A[i];
        if(i == N-1){
            cout << endl;
        }else{
            cout << " ";
        }
    }
    return 0;


}


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

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()

int calc(char c, string s)
{
	for (int i = 0; i < s.size(); ++i) {
		bool ok = 1;
		rep(j, s.size()) ok &= (s[j] == c);
		if (ok) {
			return i;
		}

		string t;
		int sz = s.size();
		rep(i, sz - 1) {
			if (s[i] == c || s[i+1] == c) {
				t.pb(c);
			} else {
				t.pb('?');
			}
		}
		s = t;
	}
}

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

	int ret = s.size();

	for (int c = 'a'; c <= 'z'; ++c) {
		ret = min(ret, calc(c, s));
	}

	cout << ret << endl;

	return 0;
}

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

int main(){
  int i, cnt, qwe[128];
  char str[64];

  qwe['y']=qwe['u']=qwe['i']=qwe['o']=qwe['p']=qwe['h']=qwe['j']=qwe['k']=qwe['l']=qwe['n']=qwe['m']=2;
  for(i=97; i<123; i++){
    if(qwe[i]!=2){
      qwe[i]=1;
    }
  }
  
  while(scanf("%s", str), str[0]!='#'){
    cnt=0;
    for(i=0; i<strlen(str)-1; i++){
      if(qwe[str[i]]!=qwe[str[i+1]]){
	cnt++;
      }
    }
    printf("%d\n", cnt);
  }
  
  return 0;
}

Measured memory_bytes: 540
#include<bits/stdc++.h>
#define rep(i,x,y) for (int i=(x);i<=(y);i++)
#define ll long long

using namespace std;

const int N=(1<<20)+100,mod=924844033;
int n,x,y,cnt,head[N],sz[N],fac[N],inv[N],a[N],b[N],w[N],r[N],ans[N],invn;
struct edge{int to,nxt;}e[N<<1];

void adde(int x,int y){
	e[++cnt].to=y; e[cnt].nxt=head[x]; head[x]=cnt;
}

void dfs(int u,int par){
	sz[u]=1;
	for (int i=head[u],v;i;i=e[i].nxt)
		if (v=e[i].to,v!=par) dfs(v,u),sz[u]+=sz[v];
}

int ksm(int x,int y){
	int s=1;
	for (;y;y>>=1,x=(ll)x*x%mod) if (y&1) s=(ll)s*x%mod;
	return s;
}

void init(int n){
	fac[0]=1;
	rep (i,1,n) fac[i]=(ll)fac[i-1]*i%mod;
	inv[n]=ksm(fac[n],mod-2);
	for (int i=n-1;~i;i--) inv[i]=(ll)inv[i+1]*(i+1)%mod;
}

int C(int n,int m){return (ll)fac[n]*inv[m]%mod*inv[n-m]%mod;}

void fft_init(int &n){
	int len=0; while (1<<len<n) len++; n=1<<len;
	int G=ksm(5,(mod-1)>>len); invn=ksm(n,mod-2);
	w[0]=w[n]=1;
	rep (i,1,n-1) w[i]=(ll)w[i-1]*G%mod,r[i]=(r[i>>1]>>1)|((i&1)<<len-1);
}

void fft(int *a,int all,int fl){
	rep (i,0,all-1) if (i<r[i]) swap(a[i],a[r[i]]);
	int n=2,m=1,x=all>>1;
	for (;n<=all;m=n,n<<=1,x>>=1)
		for (int i=0;i<all;i+=n)
			for (int k=0;k<m;k++){
				int t=(ll)w[fl?all-x*k:x*k]*a[i+m+k]%mod;
				a[i+m+k]=(a[i+k]+mod-t)%mod;
				a[i+k]=(a[i+k]+t)%mod;
			}
	if (fl) rep (i,0,all-1) a[i]=(ll)a[i]*invn%mod;
}

void solve(){
	memset(a,0,sizeof(a)),memset(b,0,sizeof(b));
	rep (i,2,n) a[sz[i]]++;
	rep (i,0,n) a[i]=(ll)a[i]*fac[i]%mod,b[i]=inv[i];
	reverse(b,b+n+1);
	int _n=2*n+1; fft_init(_n);
	fft(a,_n,0); fft(b,_n,0);
	rep (i,0,_n-1) a[i]=(ll)a[i]*b[i]%mod;
	fft(a,_n,1);
	rep (i,1,n) ans[i]=(ans[i]+mod-(ll)a[n+i]*inv[i]%mod)%mod;
}

int main(){
	scanf("%d",&n);
	rep (i,1,n-1) scanf("%d%d",&x,&y),adde(x,y),adde(y,x);
	dfs(1,0); init(n);
	rep (i,1,n) ans[i]=(ll)n*C(n,i)%mod;
	solve();
	rep (i,1,n) sz[i]=n-sz[i];
	solve();
	rep (i,1,n) printf("%d\n",ans[i]);
	return 0;
}
/*
这玩意为啥和998244353长那么像啊。。。
*/

Measured memory_bytes: 40832
k,a,b = map(int, input().split())

if a>b or k < a+1 or b-a <3:
    print(k+1)
    exit()
else:    
    hit = max([0,int((k-(a-1))/2)])
    ans = (b-a) *hit
    temp = k-(hit*2)
    print(ans+temp+1)
    

Measured memory_bytes: 2940
#include <algorithm>
#include <array>
#include <vector>
#include <iostream>
#include <fstream>
#include <string>
#include <cmath>
#include <functional>
#include <queue>

//AtCoderC++.cpp

using namespace std;



void Show(vector<bool> Ps) {
	for (int i = 0; i < Ps.size(); i++) {
		if (Ps[i]) {
			cout << "T" << endl;
		} else {
			cout << "F" << endl;
		}
	}
}

void Show(vector<vector<int>> Ns) {
	for (int i = 0; i < Ns.size(); i++) {
		for (int j = 0; j < Ns[i].size(); j++) {
			cout << Ns[i][j] << " ";
		}
		cout << endl;
	}
}

struct Code {
	Code() {
		sx = 0;
		sy = 0;
		dx = 0;
		dy = 0;
	}

	Code(int xx, int xy, int yx, int yy) {
		sx = xx;
		sy = xy;
		dx = yx;
		dy = yy;
	}
	int sx, sy, dx, dy;
	void Write() {
		cout << sx << " " << sy << " " << dx << " " << dy << endl;
	}
};

int main() {
	int H, W;
	cin >> H >> W;
	vector<vector<int>> Coins;
	Coins.resize(H);
//	vector<vector<bool>> Used;
//	Used.resize(H);
	for (int i = 0; i < H; i++) {
		Coins[i].resize(W);
//		Used[i].resize(W);
		for (int j = 0; j < W; j++) {
			cin >> Coins[i][j];
//			Used[i][j] = false;
		}
	}
	vector<Code> Codes;
	int Count = 0;
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (Coins[i][j] % 2 != 0) {
				if (j != W - 1 && Coins[i][j + 1] % 2 != 0) {
					Coins[i][j]--;
					Coins[i][j + 1]++;
					Codes.push_back(Code(i + 1, j + 1, i + 1, j + 2));
					Count++;
					continue;
				}
				if (i != H - 1 && Coins[i + 1][j] % 2 != 0) {
					Coins[i][j]--;
					Coins[i + 1][j]++;
					Codes.push_back(Code(i + 1, j + 1, i + 2, j + 1));
					Count++;
					continue;
				}
				if (j != W - 1) {
					Coins[i][j]--;
					Coins[i][j + 1]++;
					Codes.push_back(Code(i + 1, j + 1, i + 1, j + 2));
					Count++;
					continue;
				}
				if (i != H - 1) {
					Coins[i][j]--;
					Coins[i + 1][j]++;
					Codes.push_back(Code(i + 1, j + 1, i + 2, j + 1));
					Count++;
					continue;
				}
			}
		}
	}
	cout << Count << endl;
	for (int i = 0; i < Count; i++) {
		Codes[i].Write();
	}
}

Measured memory_bytes: 5104
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main() {
    ll n,k,ba; cin>>n>>k;
    vector<ll> a(n,0);
    rep(i,n) cin>>a[i];
    sort(al(a));
    ll l=1;
    for(ll i=1;i<=64;i++){
        l*=2;
        if(a[n-1]<=l-1 && k<=l-1){
            ba=l-1;
            l=i; break;
        } 
    }
    vector<ll> v1(l,0),v0(l,0),sum(l,0),sum2(l,0);
    ll r=1;
    rep(i,l){
        rep(j,n){
            if(a[j]&(1LL<<i)) v0[i]+=r;
            else v1[i]+=r;
        }
        r*=2;
    }
    sum[0]=max(v0[0],v1[0]);
    ll ans=v0[0];
    sum2[0]=(k&(1LL<<(l-1)) ? v1[l-1] : v0[l-1]);
    rep(i,l-1){
        sum2[i+1]=sum2[i]+(k&(1LL<<(l-2-i)) ? v1[l-2-i] : v0[l-2-i]);
        sum[i+1]=sum[i]+max(v0[i+1],v1[i+1]);
        ans+=v0[i+1];
    }
    ans=max(ans,sum2[l-1]);
    rep(i,l){
        ll cnt=0;
        if(k&(1LL<<(l-1-i))){
            cnt=v0[l-1-i];

            if(i!=0) cnt+=sum2[i-1];
            if(l-1-i!=0) cnt+=sum[l-2-i];
        }
        ans=max(ans,cnt);
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 1024
#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);

  for(int i=n-1; i>=0; i-=2)cout<<a.at(i)<<" ";
  if(n%2==0){
    for(int i=0; i<n; i+=2)cout<<a.at(i)<<" ";
  }else{
    for(int i=1; i<n; i+=2)cout<<a.at(i)<<" ";
  }
  cout<<endl;
}

Measured memory_bytes: 2944
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>

typedef unsigned int u32;
typedef int i32;
typedef unsigned long long int u64;
//typedef long long int i64;
typedef int i64;
typedef uint16_t u16;
typedef int16_t i16;
typedef uint8_t u8;
typedef int8_t i8;

const double PI = 3.141592653589793238463;

using namespace std;

const int MAXN = 1000500;
const int MAXVALUE = 1000000500;
//const long double EPS = 1e-7;

i64 mod = 1e9 + 7;

i64 T, n, m, k, a, b;
//i64 a[10]; // 97 : 122
//char b[10];


int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.precision(16);

	cin >> k >> a >> b;

	i64 x = a / k;

	if (a % k) {
		x += 1;
	}



	if (x * k <= b) {
		cout << "OK" << endl;
	}

	else {
		cout << "NG" << endl;
	}
	
	return 0;
}

Measured memory_bytes: 3124
n = int(input())


# 素因数分解する関数
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr


fct=factorization(n)


cnt = 0
tmp = 0
ma = 0
for t in fct:
    if t[0] == 1:
        break
    
    tmp = t[1]
    ma = 1
    while tmp >= ma:
        tmp -= ma
        ma += 1
        cnt += 1


print(cnt)


Measured memory_bytes: 9484
# coding:utf-8

import sys

INF = float('inf')
MOD = 10 ** 9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()


def main():
    n, k = LI()

    if k == 0:
        print(n ** 2)
        return 0

    res = 0
    for b in range(1, n + 1):
        p, r = divmod(n, b)
        ok = max(0, b - k)
        res += ok * p + max(0, r - k + 1)

    print(res)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#pragma GCC optimize ("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse4")
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
#define int ll
#define sz(x) (int)(x).size();
#define all(x) x.begin(), x.end()
#define trav(i,a) for(auto &i:a) 
inline int in(){int x;scanf("%lld",&x);return x;}
int f(int n)
{
	int ans=0;
	for(int i=(n/4)*4;i<=n;i++)
	ans^=i;
	return ans;
}
int32_t main()
{
	int a=in();int b=in();
	cout<<(f(a-1)^f(b));
	
}

Measured memory_bytes: 3768
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
using namespace std;
using ll=long long;

const ll INF = pow(10,18)+1;

#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

template<typename T> bool chmin(T& a, T b) {return a > b ? a = b, true : false;}
template<typename T> bool chmax(T& a, T b) {return a < b ? a = b, true : false;}
 
int main(){
    int A, B, K;
    cin >> A >> B >> K;
    int cnt = 0;
    int mx = max(A,B);
    int ans[100];
    FOR(i, 1, mx+1){
        if(A%i==0&&B%i==0){
            ans[cnt] = i;
            cnt++;
        }
    }
    cout << ans[cnt-K] << endl;
    return 0;
}

Measured memory_bytes: 256
n,a,b,c = map(int,input().split())
abc = [a,b,c]
l = [int(input()) for i in range(n)]
ans = 10**10

def bfs(use):
    global l,abc,ans
    if len(use)==n:
        mp = 0
        x = [0]*4
        c = [0]*4
        for i in range(n):
            x[use[i]]+=l[i]
            c[use[i]]+=1
        for i in range(3):
            if x[i]==0: 
                mp=10**10
                break
            else :mp += (c[i]-1)*10+abs(abc[i]-x[i])
        if ans>mp: ans=mp
    else:
        bfs(use+[0])
        bfs(use+[1])
        bfs(use+[2])
        bfs(use+[3])

bfs([])
print(ans)

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

int main()
{
    int n;
    cin>>n;
    vector<pair<int , int> > v(n);
    for(int i=0 ; i<n ;i++)
    {
        cin>>v[i].first>>v[i].second;
    }
    long  double avg =0;
    for(int i=0 ; i<n ; i++)
    {
        for(int j=0 ; j<n ; j++)
        {
            if( i!=j )
            {
                avg+=sqrt( ( v[i].first - v[j].first )*( v[i].first - v[j].first ) + ( v[i].second - v[j].second )*( v[i].second - v[j].second ) );
            }
        }
    }
    cout<<setprecision(10)<<avg/n<<endl;
    return 0;
}


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

int main() {
  string s;
  cin >> s;
  int cnt = 700;
  rep(i, s.size()) if (s[i] == 'o') {
    cnt += 100;
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 3544
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

struct Rest {
	int score;
	string name;
	int id;
} rest[10000];

int n;

bool cmp(const Rest& a, const Rest& b) {
	if(a.name == b.name) return a.score > b.score;
	return a.name < b.name;
}

void in() {
	cin >> n;
	for(int i = 0;i < n;i ++) {
		cin >> rest[i].name >> rest[i].score;
		rest[i].id = i+1;
	}
}

void solve() {
	sort(rest, rest+n, cmp);
	for(int i = 0;i < n;i ++) {
		cout << rest[i].id << endl;
	}
}

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


Measured memory_bytes: 512
# -*- coding: utf-8 -*-
N = int(raw_input())
T = map(int, raw_input().split())
M = int(raw_input())
PX = [map(int, raw_input().split()) for i in xrange(M)]

S = sum(T)
for P, X in PX:
    print S - (T[P - 1] - X)



Measured memory_bytes: 2568
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 5e2+5;
const ll INF = 2e18;

int main()
{
	int n;
	cin >> n;
	bool f = 0;
	while(n){
		int t = n%10;
		if(t == 7) f = 1;
		n /= 10;
	}
	printf("%s",f ?"Yes" :"No");
	return 0;
}


Measured memory_bytes: 3684
/* بِسْمِ اللَّهِ الرَّحْمَٰنِ الرَّحِيمِ */
//codeforces
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define FASTIO ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define mp make_pair
#define pb push_back
#define sz(v) ((int)v.size())
#define all(v) v.begin(), v.end()
void parseArray(ll* A,ll n){ for ( ll K = 0; K < n; K++){ cin >> A[K]; } }
ll modInverse(ll a, ll b){ return 1<a ? b - modInverse(b%a,a)*b/a : 1; }
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); }
ld dist(ll x, ll y, ll a, ll b){ return sqrt((x - a)*(x - a) + (y - b)*(y - b)); }
void debug(ll* a, ll n) { for ( int k = 0; k < n; k++ ){ cout << a[k] << " ";} cerr << "\n"; }

#define mod 1000000007
ll pow2(ll n) {
	ll ans = 1;
	ll p = 2;
	while (n) {
		if (n & 1)
			ans = (ans * p) % mod;
		p = (p * p) % mod;
		p %= mod;
		ans %= mod;
		n >>= 1;
	}
	return ans;
}

ll fac[222222];

ll cnk(ll n, ll k) {
	if (k == 0)
		return 1;
	return (fac[n] * modInverse(fac[k], mod) % mod * modInverse(fac[n - k], mod) % mod) % mod;
}

ll modBinomial(ll n, ll k, ll p) {
	// return C(n,k) mod p, assuming p is prime
	ll numerator = 1; // n*(n-1)* ... * (n-k+1)
	for(ll i=0;i<k;i++) numerator = (numerator*(n-i))%p;
	ll denominator = 1; // k!
	for(ll i=1;i<=k;i++) denominator = (denominator*i) %p;
	ll res = modInverse(denominator,p);
	res = (res*numerator)%p;
	return res;
}

int main(){
	FASTIO;
	ll n, a, b; cin >> n >> a >> b;
	fac[0] = 1;
	for ( int k = 1; k < 222222; k++ )
		fac[k] = (k * fac[k - 1]) % mod;
	ll ans = (pow2(n) - 1) % mod;
	ans = (ans - modBinomial(n, a, mod) + mod) % mod;
	ans = (ans - modBinomial(n, b, mod) + mod) % mod;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2048
#include <stdio.h>


int main(void){
	int N;
	scanf("%d",&N);
	int h[N];
	int i;
	int ans = 0;
	for(i=0;i<N;i++){
		scanf("%d",&h[i]);
	}
	int flag = 0;
	int check(){
		for(i=0;i<N;i++){
			if(h[i]!=0){
				return 1;
			}
		}
		return 0;
	}   
	while(check()>0){
		i = 0;
		while(h[i]==0 && i<N){
			i++;
		}
		while(h[i]!=0 && i<N){
			h[i]--;
			i++;
		}
		ans++;
	}
	printf("%d",ans);	
	
	//左から0が来るまで見ていく
	//0があったら1個手前の数を出す
	return 0;
}

Measured memory_bytes: 128
n,m=map(int,input().split())
p=[]
l=[1]*n
for i in range(m):
    P=list(input().split())
    p.append(P)

AC=0
WA=0

x=[0]*n

for i in range(m):
    if l[int(p[i][0])-1]==1:
        if p[i][1]=="WA":
            WA+=1
            x[int(p[i][0])-1]+=1
        else:
            AC+=1
            l[int(p[i][0])-1]=0

for i in range(n):
    if l[i]==1:
        WA-=x[i]

print(AC,WA)

Measured memory_bytes: 67288
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        long ans = 0L;
        for (int i = k+1; i <= n; i++) {
            ans += (i-k)*(n/i);
            ans += Math.max(0, n%i-k+1);
        }
        if(k==0)ans = (long)n*n;
        System.out.println(ans);
        sc.close();

    }

}


Measured memory_bytes: 21716
// Last Change: 03/28/2020 21:01:28.
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

int main() {
  string s;
  cin >> s;
  if (s[2] == s[3] and s[4] == s[5]) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 888
n = int(input())
a = list(map(int,input().split()))
a.sort()
ans = [0]*n
ans[n-1] = 1

su = 0
for i in range(n-1):
    su += a[i]
    if su*2 >= a[i+1]:
        ans[i] = 1
        
aa = 0
for i in range(n-1,-1,-1):
    if ans[i] == 1:
        aa += 1
    else:
        break

print(aa)

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

#define FOR(i,l,r) for(int i = (int) (l);i < (int) (r);i++)
#define ALL(x) x.begin(),x.end()
template<typename T> bool chmax(T& a,const T& b){ return a < b ? (a = b,true) : false; }
template<typename T> bool chmin(T& a,const T& b){ return b < a ? (a = b,true) : false; }
typedef long long ll;

const int BUCKET = 400,SIZE = 300;
int N,Q;
int bucketSum [BUCKET];
int A [100000];

void add(int idx,int val)
{
	A [idx] += val;
	bucketSum [idx / SIZE] += val;
}

int getSum(int l,int r)
{
	int res = 0;
	FOR(i,0,BUCKET){
		int bucket_l = i * SIZE,bucket_r = (i + 1) * SIZE;
		if(bucket_r <= l || r <= bucket_l) continue;
		if(l <= bucket_l && bucket_r <= r){
			res += bucketSum [i];
			continue;
		}
		FOR(j,bucket_l,bucket_r){
			if(l <= j && j < r){
				res += A [j];
			}
		}
	}
	return res;
}

int main()
{
	scanf("%d%d",&N,&Q);
	vector<int> ans;
	FOR(i,0,Q){
		int com,x,y;
		scanf("%d%d%d",&com,&x,&y);
		if(com == 0){
			add(x - 1,y);
		}
		else{
			ans.push_back(getSum(x - 1,y));
		}
	}

	FOR(i,0,ans.size()){
		printf("%d\n",ans [i]);
	}

	return 0;
}

Measured memory_bytes: 3756
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <map>
#include <sstream>
#include <queue>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <iterator>
#include <stack>
#include <list>
using namespace std;
#define F first
#define S second
const int INF=1000000000;
typedef long long int lli;
typedef pair<int,int> P;
const int mod=10007;
int dp[1000][1<<3];
int hoge(char c){
	if(c=='J') return 1;
	if(c=='O') return 2;
	if(c=='I') return 4;
}
int main(){
	int n;
	cin >> n;
	string s;
	cin >> s;
	memset(dp,0,sizeof(dp));
	for(int i=1; i<=7; ++i){
		if((hoge(s[0])&i)==0||(i&1)==0)continue;
		dp[0][i]=1;
	}
	for(int i=1; i<n; ++i){
		for(int j=1; j<=7; ++j){
			if((hoge(s[i])&j)==0) continue;
			for(int k=1; k<=7; ++k){
				if((j&k)==0) continue;
				dp[i][j]+=dp[i-1][k]%mod;
			}
		}
	}
	int ans=0;
	for(int i=1; i<=7; ++i){
		ans+=dp[n-1][i]%mod;
	}
	cout << ans%mod << "\n";
	return 0;
}

Measured memory_bytes: 1248
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <queue>
#include <vector>
#include <cmath>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <set>
#include <map>
#include <stack>

using namespace std;

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;}

typedef long long LL;
typedef pair<int, int> PII;

#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repl(i, n) for(LL i = 0; i < (LL)(n); i++)

int main(void){
  int n; cin >> n;
  LL a[n][3], dp[n+1][3];

  rep(i, n) {
    rep (j, 3) {
      cin >> a[i][j];
    }
  }

  for (int i = 0; i <= n; i++) {
    for (int j = 0; j < 3; j++) {
      dp[i][j] = 0;
    }
  }

  rep(i, n) {
    rep(j, 3) {
      rep(k, 3) {
        if (j == k) continue;
        chmax(dp[i+1][k], dp[i][j] + a[i][k]);
      }
    }
  }

  LL res = 0;
  rep(i, 3) chmax(res, dp[n][i]);
  cout << res << endl;

  return 0;
}

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

using namespace std;
// template for creating 2d vector
template<typename T>
vector<vector<T>> make_2d_vector(size_t rows, size_t cols, T init)
{ return vector< vector<T> >(rows, vector<T>(cols, init)); }



#define debug(x) cout << #x << "==" << x << endl;

const int inf = 100000000;

typedef long long ll;

int main() {
  ios::sync_with_stdio(false);

  int N, W;
  cin >> N >> W;

  vector<int> v(N), w(N);
  for(int i = 0; i < N; i++) { cin >> v[i] >> w[i]; }

  // dp[i][j] := i???????????§?????????????????£??????j????¶?????????????????????????????????§
  auto dp = make_2d_vector(N+1, W+1, 0);

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

      if( i == 0 || j == 0 ) { dp[i][j] = 0; }

      else {
        if( w[i-1] <= j ) {
          dp[i][j] = max(dp[i][j-w[i-1]] + v[i-1], dp[i-1][j]);
        } else {
          dp[i][j] = dp[i-1][j];
        }
      }

    }
  }

  cout << dp[N][W] << "\n";

  return 0;
}

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

char get_other(string s){
    return (s == "AB") ? 'C' : ((s == "BC") ? 'A' : 'B');
}

int main(void){
    ll n, a, b, c;
    map<char, ll> m;
    cin >> n >> a >> b >> c;
    m['A'] = a;
    m['B'] = b;
    m['C'] = c;
    vector<string> cmd(n);
    rep(i,n) cin >> cmd[i];
    string res;
    rep(i,n){
        string s = cmd[i];
        cin >> s;
        if (m[s[0]] == 0 && m[s[1]] == 0) {
            cout << "No" << endl;
            return 0;
        }
        if (i < n-1 && m[s[0]] == m[s[1]] && m[get_other(s)] == 0){
            char nxt_other = i == n-1 ? '?' : get_other(cmd[i+1]);
            char down = nxt_other;
            char up = (s[0] == nxt_other) ? s[1] : s[0];
            if (cmd[i] == cmd[i+1]) {
                down = s[0];
                up = s[1];
            }
            res += up;
            m[up]++;
            m[down]--;
        } else if (m[s[0]] < m[s[1]]) {
            res += s[0];
            m[s[0]]++;
            m[s[1]]--;
        } else {
            res += s[1];
            m[s[1]]++;
            m[s[0]]--;
        }
    }
    cout << "Yes" << endl;
    rep(i,n) {
        cout << char(res[i]) << endl;
    }
    return 0;
}


Measured memory_bytes: 6700
#include <iostream>
#include<queue>
#include<stack>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include<cassert>
#include<cmath>
#include<climits>
#include<iomanip>
#include<bitset>
#include<unordered_map>

using namespace std;

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define rep(i,j,n) for(ll (i)=(j);(i)<(n);(i)++)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define ll long long
#define ull unsigned long long
#define all(hoge) (hoge).begin(),(hoge).end()
typedef pair<ll, ll> P;
const long long INF = 1LL << 60;
const long long MOD = 1e9 + 7;
typedef vector<ll> Array;
typedef vector<Array> Matrix;


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;
}

//グラフ関連
struct Edge {//グラフ
	ll to, cap, rev;
	Edge(ll _to, ll _cap, ll _rev) {
		to = _to; cap = _cap; rev = _rev;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

//nCr,nPr,modの逆元
class Combination {
public:
	Array fact;//n！
	Array inv;//n!の逆元
	ll mod;
	Combination(ll n, ll _mod) {
		mod = _mod;
		fact.resize(n + 1);
		fact[0] = 1;
		REP(i, n) {
			fact[i + 1] = (fact[i] * (i + 1LL)) % mod;
		}
		inv.resize(n + 1);
		inv[n] = mod_inv(fact[n]);
		for (int i = n; i > 0; i--) {
			inv[i - 1] = inv[i] * i % mod;
		}
	}
	//modの逆元
	ll mod_inv(ll x) {
		ll n = mod - 2;
		ll res = 1LL;
		while (n > 0) {
			if (n & 1) res = res * x % mod;
			x = x * x % mod;
			n >>= 1;
		}
		return res;
	}
	ll nCr(ll n, ll r) {
		return ((fact[n] * inv[r] % mod) * inv[n - r]) % mod;
	}
	ll nPr(ll n, ll r) {
		return (fact[n] * inv[n - r]) % mod;
	}
	ll nHr(ll n, ll r) {
		//重複組み合わせ：n種類のものからr個取り出す組み合わせ
		return nCr(r + n - 1, r);
	}
};

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

	ll x, y;
	cin >> x >> y;

	Combination com(x, MOD);

	ll count = 0;
	
	for (ll i = 0; i * 2 <= x;i++) {
		ll j = x - 2 * i;
		//cout << i << " " << j << endl;
		if (i + j * 2 == y) {
			(count+=com.nCr(i+j,j))%=MOD;
		}
	}

	cout << count << endl;

	return 0;
}

Measured memory_bytes: 15872
S = raw_input()
l=len(S)
if S[:1] == 'A':
	AC = 1
	S = "a"+S[1:]
else:
	AC = 0
if S[2:l-1].count('C')==1:
	AC2 = 1
else:
	AC2 = 0
if S.find('C')>=2:
	S = S[:S.find('C')] + 'c' + S[S.find('C')+1:]
if S.islower():
	AC3 = 1
else:
	AC3 = 0
if AC+AC2+AC3 == 3:
	print 'AC'
else:
	print 'WA'

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

typedef pair<int, int> P;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repto(i, n) for(int i = 0; i <= (n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define mp make_pair
#define INF 1145141919
#define MOD 1000000007
#define DEBUG(x) cout << #x << ": " << x << endl;
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }

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

  int N, Q;
  cin >> N;
  map<ll, ll> m;
  vector<ll> A(N);
  rep(i, N) {
    cin >> A[i];
    m[A[i]]++;
  }
  ll ans = 0;
  for (auto ite = m.begin(); ite != m.end(); ite++) {
    // cout << ite->_1 << ' ' << ite->_2 << endl;
    ans += ite->_1 * ite->_2;
  }
  cin >> Q;
  vector<ll> B(Q);
  vector<ll> C(Q);
  rep(i, Q) {
    cin >> B[i] >> C[i];
  }
  rep(i, Q) {
    m[C[i]] += m[B[i]];
    ans += (C[i]-B[i])*m[B[i]];
    m.erase(B[i]);
    cout << ans << endl;
  }
}


Measured memory_bytes: 9528
#include <iostream>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <algorithm>

using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}

#ifndef ONLINE_JUDGE
#define dbg(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define dbg(x...)
#endif
#define  endl 			"\n"
#define  FOR(i, a, n)   for (ll i = a; i < n; i++)
#define  ROF(i, a, n)   for (ll i = a; i >= n; i--)
#define  all(x)         (x).begin(), (x).end()
#define  dline          cout<<"///REACHED///\n";

typedef long long ll;

const ll   MOD   =  1e+9+7;
const ll   INF   =  0x7f7f7f7f7f7f7f7f;
const int  INFi  =  0x7f7f7f7f;
const ll   MAXN  =  4e+5+7;

int x, n, q, ans, diff;
void solve() {
    cin >> x >> n;
    diff = ans = 1111;
    unordered_set<int> a;
    FOR(i, 0, n) cin >> q, a.insert(q);
    ROF(i, 101, 0) if (a.find(i) == a.end()) if (x-i <= diff) ans = min(ans, (int)i), diff = abs(x-i);
    cout << ans << endl;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int T=1;
    while (T--) {
        solve();
    }
    return 0;
}



Measured memory_bytes: 3648
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}

template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

// -------------------------------------------------------

int D;

int main()
{
    cin >> D;
    cout << "Christmas";
    for (int i = 25; i > D; i--)
    {
        cout << " Eve";
    }
    cout << endl;
}


Measured memory_bytes: 256
package main

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

func main() {
	L := ReadInt()
	v := float64(L) / 3
	fmt.Printf("%f\n", v*v*v)
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


Measured memory_bytes: 1840
import sys
input = sys.stdin.readline
n=int(input())
a=list(map(int, input().split()))
a.sort()
m=max(a)
arr=[0]*(m+1)
flag=[True]*(m+1)
ans=0
for i in range(n):
    if flag[a[i]]:
        arr[a[i]]+=1
        if not arr[a[i]]==1:
            continue
        for j in range(a[i]*2,m+1,a[i]):
            flag[j]=False
print(arr.count(1))

Measured memory_bytes: 34172
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
#include <unordered_map>
#include <random>
#include <iomanip>
  
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
  
using namespace std;
  
typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;
  
const int INF=1<<29;
const double EPS=1e-9;
  
const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};
 
int main() {
  ll N, M, D;
  cin >> N >> M >> D;
  double p;
  if (D == 0) {
    p = 1.0 / N;
  } else {
    p = (2.0 * (N - D)) / (N * N);
  }
  cout << fixed << setprecision(10) << p * (M - 1) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <map>

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;

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; }

using namespace std;

const ll BIG = 1000000007LL;

int inputValue(){
    int a;
    cin >> a;
    return a;
};

template<typename T>
void inputArray(T* p, int a){
    rep(i, a){
        cin >> p[i];
    }
};

template<typename T>
void inputVector(vector<T> * p, int a){
    rep(i, a){
        T input;
        cin >> input;
        p -> push_back(input);
    }
}

template <typename T>
void output(T a, int precision = 0) {
    if(precision > 0){
        cout << setprecision(precision)  << a << "\n";
    }
    else{
        cout << a << "\n";
    }
}

const int Max = 55;
int N;
ll x[Max], y[Max];
map<pair<ll, ll>, int> counts;

int main(int argc, const char * argv[]) {
    cin >> N;
    rep(i, N) {
        cin >> x[i] >> y[i];
    }

    rep(i, N) {
        repd (j, i + 1, N) {
            ll diffx = x[i] - x[j];
            ll diffy = y[i] - y[j];
            if (diffx < 0) {
                diffx *= -1;
                diffy *= -1;
            } else if (diffx == 0 && diffy < 0) {
                diffy *= -1;
            }

            counts[make_pair(diffx, diffy)] += 1;
        }
    }

    int maxc = 0;
    for (auto& c : counts)
    {
        //printf("%lld, %lld, %d\n", c.first.first, c.first.second, c.second);
        if (c.second > maxc) {
            maxc = c.second;
        }
    }

    output(N - maxc);

    return 0;
}

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

int main(void)
{
    int N, D;
    cin >> N >> D;
    int X[N], Y[N];
    for (int i = 0; i < N; i++) {
        cin >> X[i] >> Y[i];
    }

    int count = 0;
    for (int i = 0; i < N; i++) {
        if (sqrt(pow(X[i], 2) + pow(Y[i], 2)) <= D) {
            count++;
        }
    }
    cout << count << endl;
}


Measured memory_bytes: 5192
s = input()
x, y = list(map(int, input().split()))

X = []
Y = []
n = 0

for i in s:
    if i == 'T':
        (X if len(X) == len(Y) else Y).append(n)
        n = 0
    else:
        n += 1
(X if len(X) == len(Y) else Y).append(n)
s = X[0]
t = 0
X = sorted(X[1:], reverse=True)
Y = sorted(Y, reverse=True)

for i in X:
    s += i * (-1 if s > x else 1)
for i in Y:
    t += i * (-1 if t > y else 1)

if s == x and t == y:
    print ('Yes')
else:
    print ('No')


Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
#define sz 100100
int ar[sz];
int dp[sz];
int main()
{

    int n;
    scanf("%d", &n);

    for (int i = 0; i < n; ++i)
    {
        scanf("%d", &ar[i]);
    }

    for (int i = 0; i < n; ++i)
    {
        if (i == 0)
            continue;
        else if (i == 1)
            dp[1] = abs(ar[1] - ar[0]);
        else
            dp[i] = min(dp[i - 1] + abs(ar[i - 1] - ar[i]), dp[i - 2] + abs(ar[i - 2] - ar[i]));
    }

    cout << dp[n - 1];




    return 0;
}

Measured memory_bytes: 1024