akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define per(i,b,a) for(int i=b;i>=a;i--)
#define For(i,a,b) for(int i=a;i<=b;i++)
#define Forenska(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define sqr(x) ((x)*(x))
#define lowbit(x) ((x)&(-x))
#define GREATER(x) x,vector<x>,greater<x>
#define randIn(L,R) (((LL)rand()*rand())%(R-L)+L)
#define __lcm(a,b) ((a)/__gcd(a,b)*(b))
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pLL;
typedef vector<int> vec;
typedef vector<LL> vecL;
typedef vector<pii> vecP;
typedef vector<pLL> vecPL;
typedef vector<string> vecS;
typedef vector<vec> mat;
typedef complex<double> point;
const long double PI=3.14159265358979323846264338327950288419716939937510582097;
const LL INFLL=0x3f3f3f3f3f3f3f3f;
const int INF=0x3f3f3f3f;
const long double EPS=1e-10;
int read()
{
    int x=0;
    char ch=' ';
    bool flag=false;
    while(ch<'0' || ch>'9')
    {
        if(ch=='-')flag=true;
        ch=getchar();
    }
    while(ch>='0' && ch<='9')
    {
        x=(x<<3)+(x<<1)+ch-'0';
        ch=getchar();
    }
    return flag?-x:x;
}
const int MAX_N=200005;
int a[MAX_N],b[MAX_N],A[MAX_N],B[MAX_N];
int n;
int main()
{
	int ans=0;
	cin>>n;
	rep(i,0,n)cin>>a[i];
	rep(i,0,n)cin>>b[i];
	rep(i,0,29)
	{
		rep(j,0,n)A[j]=a[j]%(1<<(i+1));
		rep(j,0,n)B[j]=b[j]%(1<<(i+1));
		sort(B,B+n);
		int cnt=0;
		rep(j,0,n)
		{
			cnt+=lower_bound(B,B+n,(1<<i)*2-A[j])-lower_bound(B,B+n,(1<<i)-A[j]);
			cnt+=lower_bound(B,B+n,(1<<i)*4-A[j])-lower_bound(B,B+n,(1<<i)*3-A[j]);
		}
		if(cnt&1)ans|=1<<i;
	} 
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define meow(args...) fprintf(stderr, args)
typedef unsigned u32;
typedef unsigned long long u64;
const int N=1<<15;
const u32 P=1e9+7;
int popcnt[N], e[15], inside[N];
u32 lsh[106], f[N], g[N], h[N];
int main() {
	int n, m, tot;
	u32 ans;
	scanf("%d%d", &n, &m);
	tot=1<<n;
	lsh[0]=1;
	for(int i=1; i<=m; ++i) lsh[i]=lsh[i-1]*2%P;
	ans=lsh[m];
	for(int i=1; i<tot; ++i) popcnt[i]=popcnt[i/2]+(i&1);
	while(m--) {
		int x, y;
		scanf("%d%d", &x, &y);
		--x, --y;
		e[x]|=1<<y;
		e[y]|=1<<x;
	}
	for(int i=1; i<tot; ++i) {
		for(int j=0; j<n; ++j)
			if(i>>j&1)
				inside[i]+=popcnt[e[j]&i];
		inside[i]/=2;
	}
	for(int i=1; i<tot; i+=2) {
		f[i]=lsh[inside[i]];
		for(int j=i-1; j; j=(j-1)&(i-1))
			f[i]=(f[i]+(u64)(P-f[i-j])*lsh[inside[j]])%P;
	}
	for(int i=2; i<tot; i+=4) {
		g[i]=lsh[inside[i]];
		for(int j=i-2; j; j=(j-1)&(i-2))
			g[i]=(g[i]+(u64)(P-g[i-j])*lsh[inside[j]])%P;
	}
	for(int i=1; i<tot; i+=4)
		for(int j=tot-i-1; j; j=(j-1)&~i)
			if((j&2)&&inside[i+j]==inside[i]+inside[j])
				ans=(ans+(u64)(P-lsh[inside[tot-1-i-j]])*f[i]%P*g[j])%P;
	printf("%u\n", ans);
	return 0;
}


Measured memory_bytes: 768
#!/usr/bin/env python3
N, M = map(int, input().split())
V = [[int(j)-1 for j in input().split()] for i in range(M)]
# [[1, 2], ...] -> [[0, 1], ...]
ans = [0]*M
P = [-1]*N
size = [1]*N

def unite(a, b):
	a = find(a)
	b = find(b)
	if(size[a] < size[b]):
		a,b = b,a # swap
    # if(a != b and P[a] > P[b]):
    #    a,b = b,a
	# P[a] += P[b]
	size[a] += size[b]
	P[b] = a

def find(x):
	if(P[x] < 0):
		return x
	P[x] = find(P[x])
	return P[x]

def sizef(a):
	return size[find(a)]
    # return -P[find(a)] -> when(P[c]<0), representing c is parent and how many children it has
    #					 -> when(P[c]>=0), representing who is c's parent

t = N*(N-1)//2
for i in range(M):
	ans[M-1-i] = t
	u, v = V[M-1-i]
	if(find(u) == find(v)):
		continue
	else:
		t -= sizef(u)*sizef(v)
		unite(u, v)

print(*ans, sep = "\n") # * gets value 
						# sep means separate 

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

int main(){
  int n;
  string S, T;
  cin >> n;
  cin >> S;
  cin >> T;
  
  for (int i = 0; i < n; i++){
    cout << S[i] << T[i];
  }
  cout << "\n";
  
}

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

using vi=vector<int>;
using vvi=vector<vector<int>>;

int main(){
  priority_queue<int> pq;
  int n,m,ans=0;cin>>n>>m;
  vector<pair<int,int>> v(n);
  rep(i,n){
    int a,b;
    cin>>a>>b;
    v.at(i)=make_pair(a,b);
  }
  sort(v.begin(),v.end());
  int k=0;
  for(int i=1;i<=m;i++){
    while(k<n&&v.at(k).first==i){
      pq.push(v.at(k).second);
      k++;
    }
    if(!pq.empty()){
      ans+=pq.top();
      pq.pop();
    }
  }
  cout<<ans<<endl;
}
  


Measured memory_bytes: 1660
#include <utility>
#include <vector>
#include <iostream>
#include <algorithm>
#include <functional>
#include <map>
#include <set>
#include <list>
#include <string>
#define REP(i, n) for (int i = 0; i < n; i++)
using namespace std;

typedef long long ll;
typedef pair<ll, ll> Pll;

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

    int cnt = 0;
    string ret = "";
    for(int i =0; i < S.size(); i++) {
        string tmp = "";
        for (int j = i; j < S.size(); j++) {
            if (S[j] != 'A' && S[j] != 'C' && S[j] != 'G' && S[j] != 'T')
                break;

            tmp += S[j];
        }

        if (ret.size() < tmp.size()) ret = tmp;
    }

    cout << ret.size() << endl;
}

void cheatsheet()
{
    // loop
    // vector<int> vec(10);
    vector<int> vecloop;
    REP(i, 10)
    {
        vecloop.push_back(i);
    }

    // swap
    int a = 1;
    int b = 5;
    swap(a, b); // -> a = 5, b = 1

    // sort
    int arr[] = {1, 2, 3, 4, 5, 6, 7, 8, 9};
    sort(arr, arr + 9, greater<int>()); // 9 8 7 6 5 4 3 2 1

    // lower
    vector<int> vec(arr, end(arr));
    sort(vec.begin(), vec.end());
    cout << lower_bound(vec.begin(), vec.end(), 2)[0]; // 2

    // map
    map<Pll, ll> m;
    m[Pll(10, 100)] = 100;
}

Measured memory_bytes: 256
# UnionFind
class UnionFind:
    def __init__(self, n):
        '木の初期化をする'
        self.p = [-1] * n
        self.rank = [1]*n
        self.size = [1] * n

    def find(self, x):
        'x の親を返す'
        if self.p[x] == -1:
            return x
        else:
            self.p[x] = self.find(self.p[x])
            return self.p[x]

    def unite(self, x, y):
        'rankの低い親を高い方のの親にする'
        if not self.same(x,y):
            x = self.find(x)
            y = self.find(y)
            if self.rank[x] > self.rank[y]:
                x,y = y,x
            elif self.rank[x] == self.rank[y]:
                self.rank[y] += 1
            self.p[x] = y
            self.size[y] += self.size[x]
            return True
        else:
            return False

    def same(self, x, y):
        return self.find(x) == self.find(y)

# 入力
n, m = map(int, input().split())

# UnionFind構築
uf = UnionFind(n)
for _ in range(m):
    a, b = map(int, input().split())
    uf.unite(a - 1, b - 1)

# 連結部分の大きさの最大が答え
ans = 0
for i in range(n):
    ans = max(ans, uf.size[i])

# 出力
print(ans)


Measured memory_bytes: 15916
#include <bits/stdc++.h>
#define rep(X,N) for(ll X = 0; X < (N); X++)
#define PI (acos(-1.0))
#define pback push_back
#define mpair make_pair
#define divceil(A, B) ((A + (B - 1)) / B)
#define MODN 1000000007
#define ALL(V) (V).begin(),(V).end()
#define CERR if(false) cerr

typedef long long ll;

using namespace std;

int main(){

    int n;
    cin >> n;

    double mother = 0.0;

    rep(i,n){
        int tmp;
        cin >> tmp;

        mother += 1.0 / tmp;
    }

    cout << setprecision(12) << 1.0 / mother << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>

#define int long long
#define MOD7 1000000007
#define MOD9 1000000009

#define rep(i, n) for (int i = 0; i < (n); i++)
#define itrep(i, a) for (auto i = (a).begin(); i != (a).end(); i++)
#define REP(i, a, n) for (int i = (a); i <= (n); i++)
#define all(a) (a).begin(), (a).end()
#define mp(a, b) make_pair((a), (b))

using namespace std;

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

template<class T> void inputVector(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < v.size(); i++) cin >> v[i];
}

int dp[3010][3010];
int prv[3010][3010];

signed main() {
    string S, T;
    cin >> S >> T;

    REP(i, 1, S.size()) {
        REP(j, 1, T.size()) {
            if (dp[i - 1][j] < dp[i][j - 1]) {
                prv[i][j] = 0;
            } else {
                prv[i][j] = 1;
            }
            dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
            if (S[i - 1] == T[j - 1]) {
                dp[i][j] = max(dp[i][j], dp[i - 1][j - 1] + 1);
                prv[i][j] = 2;
            }
        }
    }

    string ret;
    int i = S.size();
    int j = T.size();
    while (ret.size() < dp[S.size()][T.size()]) {
        if (prv[i][j] == 0) {
            j--;
        } else if (prv[i][j] == 1) {
            i--;
        } else {
            ret += S[i - 1];
            i--;
            j--;
        }
    }

    reverse(all(ret));

    cout << ret << endl;

    return 0;
}


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

using namespace std;

int main() {

	int n;
	cin >> n;
	vector<int> a(n+2);
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
	}

	vector<int> b(n+2);
	vector<int> c(n+2);

	b[1] = a[1];
	for (int i = 2; i <= n; i++) {
		b[i] = b[i - 1] ^ a[i];
	}
	c[n] = a[n];
	for (int i = n-1; i >= 1; i--) {
		c[i] = c[i + 1] ^ a[i];
	}

	for (int i = 1; i <= n; i++) {
		
		int res;
		if (i == 1) { res = c[2]; }
		else if (i == n) { res = b[n - 1]; }
		else {
			res = b[i - 1] ^ c[i + 1];
		}
		if (i != 1) {
			cout << " " << res;
		}
		else {
			cout << res;
		}
	}
	cout << endl;

	return 0;

}

Measured memory_bytes: 5628
#include <iostream>
using namespace std;
using ll = long long;

#define rep(i,n) for(int i=0;i<(n);++i)
#define in(v) cin>>v;
#define out(v) cout<<v<<"\n"

template <typename T> T comb(T n, T k) {
  if (n < 2 * k)
    return comb(n, n-k);
  if (k == 0)
    return 1;
  return n * comb(n-1,k-1) / k;
}

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  int N, P; in(N); in(P);

  int count[2] = {0, 0};
  rep(i, N) {
    int a; in(a);
    a %= 2;
    ++count[a];
  }

  ll ans = 0;
  rep(i, count[1]) {
    if (2*i + P > count[1])
      break;
    ans += comb((ll)count[1], (ll)2*i+P);
  }
  ll ans2 = 1;
  rep(i, count[0]) {
    ans2 += comb((ll)count[0], (ll)i);
  }
  if (P == 0 && count[1] == 0)
    out(ans2);
  else
    out(ans*ans2);

  return 0;
}


Measured memory_bytes: 256
N = int(input())
A = enumerate(map(int,input().split()))
A = sorted(A,reverse=True,key=lambda x:x[1])

DP = [[0] * (N+1) for x in range(N+1)]

for i in range(1,N+1):
    b,a = A[i-1]
    b += 1
    for j in range(i+1):
        c = 0
        if i >= 1 and j >= 1:
            dst = j
            c = max(c,DP[i-1][j-1]+a*abs(b-dst))
        if i != j:
            dst = N - (i - j) + 1
            c = max(c,DP[i-1][j]+a*abs(b-dst))
        DP[i][j] = c

print(max(DP[N]))

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

int main() {
    ll n;
    cin >> n;
    double ans;
    rep(i,n) {
        double t;
        cin >> t;
        ans += 1/t;
    }
    printf("%.15f\n", 1/ans);
    return 0;
}


Measured memory_bytes: 3748
#include <iostream>
#include <numeric>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <map>
using namespace std;
using ll=long long;
#define rep(i,a,b) for(ll i=a;i<b;i++)
inline ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
inline constexpr int intpow(ll a,ll b){
    if(b==0) return 1;
    ll ans=intpow(a,b/2);
    return ans*ans*(b&1?a:1);
}
int main(){
  ll n,m,c;
  cin>>n>>m>>c;
  vector<ll> b(m);
  rep(i,0,m) cin>>b[i];
  ll a[n][m];
  rep(i,0,n) rep(j,0,m) cin>>a[i][j];
  ll cnt=0;
  rep(i,0,n){
      ll ans=c;
      rep(j,0,m){
          ans+=a[i][j]*b[j];
      }
      if(ans>0) cnt++;
  }
  cout<<cnt;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b)  for(int i=(a),i##formax=(b);i< i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formin=(b);i>=i##formin;i--)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max((x),(y))
#define mins(x,y) x=min((x),(y))
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define all(a) ((a).begin()),((a).end())
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define bit(n) (1LL<<(n))
typedef long long ll;
typedef __int128_t lll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>using P=pair<T,Y>;
template<class T,class Y>ostream& operator<<(ostream&o,P<T,Y>&p){return o<<"("<<p.fi<<","<<p.se<<")";}
template<class T>ostream& operator<<(ostream&o,V<T>&v){for(T&t:v)o<<t<<",";return o;}
template<class T>void uniq(V<T>&v){sort(all(v));v.erase(unique(all(v)), v.end());}
template<class A,size_t N,class T>void Fill(A(&a)[N],const T&v){fill((T*)a,(T*)(a+N),v);}

const int MOD = 1e9+7; //998244353;

lll gcd(lll a,lll b,lll&x,lll&y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll modInv(ll a,ll m=MOD){lll x,y;gcd(a,m,x,y);return(x%m+m)%m;}
ll modPow(lll a,lll n,ll m=MOD){lll p=1;for(;n;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return p;}
//V<ll>Fac,Rac;void setF(int n,int m=MOD){Fac=Rac=V<ll>(++n);Fac[0]=1;FOR(i,1,n)Fac[i]=Fac[i-1]*i%m;Rac[n-1]=modInv(Fac[n-1],m);FORR(i,n-1,1)Rac[i-1]=Rac[i]*i%m;}
//ll comb(int a,int b,int m=MOD){return a<b||b<0?0:Fac[a]*Rac[b]%m*Rac[a-b]%m;}

const int IINF = 1e9+6;
const ll LINF = 1e18;
const int N = 4000;
int n, s[N];
ll c[8];
string _s;
ll ans;

main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n >> _s;
  FOR(i, 0, n) s[i] = _s[i]%3;
  FOR(i, 0, n)FOR(j, i+1, n){
    int k=j*2-i;
    if(k>=n) break;
    if(s[i]!=s[j] && s[j]!=s[k] && s[k]!=s[i]) c[7]--;
  }
  c[0] = 1;
  FOR(i, 0, n){
    int p = 1<<s[i];
    FORR(j, 7, 1) if(j&p) c[j] += c[j^p];
  }
  cout << c[7] << endl;
}

Measured memory_bytes: 3628
import re
N, K = map(int, input().split())
S = input()
s_arr = list(map(len, re.findall(r'R+|L+',S)))
not_happies = len(s_arr)
happys = not_happies - K
if (not_happies-1)/2 <= K:
    ans = N-1
else:
    ans = N - (not_happies - 2*K)
print(ans)

Measured memory_bytes: 5656
n = gets.chomp.to_i

ary = []
sqrt = (n**(1/2.0)).floor
for i in 1..sqrt
    if n % i == 0
        ary << i
    end
end
ary_reverse = ary.reverse()
ary_reverse.each do |item|
    ary << n/item
end

sum = 0
ary.each do |num|
    if num == 1
        next
    end
    okiniiri = num-1
    syo = n/okiniiri
    amari = n%okiniiri
    # p [syo, amari]
    if syo == amari
        sum += okiniiri
    end
end
puts sum
# ary.length.times do |i|
#     if i != 0
#         if ary[i] - ary[i-1] != 1
#             # p ary[i]
#             sum += ary[i] - 1
#         end
#     end
# end

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

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

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	string s; cin>>s;
	cout<<s.substr(0,4)<<" "<<s.substr(4)<<"\n";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cctype>
#include <cstdlib>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#define rep(i, n) for(int i = 0; i < n; ++i)
using namespace std;

int comp(const void* a, const void* b){
	return *(int*)a - *(int*)b;
}

int main() {
	string n;
	cin >> n;
	rep(i, 3){
		if(n[i] == '1'){
			n[i] = '9';
		}else{
			n[i] = '1';
		}
	}
	cout << n << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>

using namespace std;

int main(){
	int N;
	cin >> N;
	int array[N];
	for(int i = 0; i <N; i++) cin >> array[i];
	int cnt = 0;
	for(int i = 0; i <= N-1; i++){
		for(int j = N-1;  j >= i+1; j--){
			if(array[j] < array[j-1]) {
				swap(array[j], array[j-1]);
				cnt++;
			}
		}
	}

	for(int i = 0; i < N-1; i++){
		printf("%d ", array[i]);
	}
	printf("%d\n", array[N-1]);
	printf("%d\n", cnt);

}

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

int main(void){

  int N,i;
  cin >> N;

  long long int array[N];

  for(i=0; i<N; i++) cin >> array[i];
  sort(array,array+N);

  long long int sum;
  sum = 0;

  for(i=0; i<N; i++) sum += array[i];

  int max,min;

  min = array[0];
  max = array[N-1];

  cout << min << " " << max << " " << sum << endl;
  
  return 0;

}

Measured memory_bytes: 1268
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int main()
{
	int n; cin>>n; int a[n],b[n],c[n];
	for (int i=0; i<n; i++)
		cin>>a[i]>>b[i]>>c[i];
	for (int i=n-1; i>0; i--)
	{
		a[i-1] = max(b[i],c[i])+a[i-1];
		b[i-1] = max(a[i],c[i])+b[i-1];
		c[i-1] = max(a[i],b[i])+c[i-1];
	}
	cout<<max({a[0],b[0],c[0]});
	return 0;
}

Measured memory_bytes: 1408
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <iostream>
#include <queue>

using namespace std;

struct Use {
  int t;
  int n;
  int m;
  int s;
  Use() {;}
  Use(int t, int n, int m, int s) : t(t), n(n), m(m), s(s) {;}
};

int n, m, r, q;
int pc[1001][1400];

int main() {
  while (scanf("%d %d", &n, &m), n | m) {
    memset(pc, -1, sizeof(pc));
    scanf("%d", &r);
    queue<Use> que;
    for (int i = 0; i < r; i++) {
      int a, b, c, d;
      scanf("%d %d %d %d", &a, &b, &c, &d);
      b--;
      que.push(Use(a, b, c, d));
    }
    for (int i = 540; i <= 1260; i++) {
      if (que.empty()) { break; }
      for (int j = 0; j < n; j++) {
        pc[j][i] = pc[j][i - 1];
      }
      while (!que.empty()) {
        Use use = que.front();
        if (use.t != i) { break; }
        que.pop();
        if (use.s == 1) {
          pc[use.n][i] = use.m;
        } else {
          pc[use.n][i] = -1;
        }
      }
    }
    scanf("%d", &q);
    for (int iter = 0; iter < q; iter++) {
      int ts, te, a;
      scanf("%d %d %d", &ts, &te, &a);
      int ans = 0;
      for (int t = ts; t < te; t++) {
        for (int i = 0; i < n; i++) {
          if (pc[i][t] == a) { ans++; break; }
        }
      }
      printf("%d\n", ans);
    }
  }
}

Measured memory_bytes: 6412
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<stdint.h>
#include<stdbool.h>
#include<tgmath.h>
#include<sys/queue.h>
#include<time.h>
#define ll long long
#define min(a, b) ((a) > (b) ? (b) : (a))
#define max(a, b) ((a) > (b) ? (a) : (b))
#define miin(a, b, c) min((a), min((b), (c)))
#define maax(a, b, c) max((a), max((b), (c)))
#define mod 1000000007

int h, w, n, a[11111], b[111][111];

main(){
    scanf("%d%d%d", &h, &w, &n);
    for(int i=0; i<n; i++){
        scanf("%d", &a[i]);
    }
    int t = 0, u = 0;
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            int v = u?j:w-1-j;
            b[i][v] = t+1;
            a[t]--;
            if(a[t] == 0){
                t++;
            }
        }
        u ^= 1;
    }
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            if(j)putchar(32);
            printf("%d", b[i][j]);
        }
        putchar(10);
    }
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
typedef long long ll;

int main() {
  int N;
  cin >> N;
  vector<int> A(N), B(N), C(N);

  REP(i, N) cin >> A.at(i);
  REP(i, N) cin >> B.at(i);
  REP(i, N) cin >> C.at(i);

  sort(all(A));
  sort(all(B));
  sort(all(C));

  ll ans = 0;
  REP(i, N) {
    ll a = lower_bound(all(A), B[i]) - A.begin();
    ll c = C.end() - upper_bound(all(C), B[i]);
    ans += a * c;
  }

  cout << ans << endl;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define err(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)

using namespace std;

typedef long long ll;


struct edge {
	int to;
	ll f, c;
	int back;
};

vector<vector<edge> > E;

void add(int a, int b, ll c) {
	int ia = (int)E[b].size();
	int ib = (int)E[a].size();
	E[a].push_back({ b, 0, c, ia });
	E[b].push_back({ a, 0, 0, ib });
	//err("%d %d %I64d\n", a, b, c);
}


const int dd = 107;
int N;
int used[3 * dd];

ll dfs(int v, int t, ll cmin) {
	if (v == t) return cmin;
	used[v] = 1;
	for (auto &e : E[v]) {
		if (!used[e.to] && e.f < e.c) {
			ll df = dfs(e.to, t, min(cmin, e.c - e.f));
			if (df) {
				e.f += df;
				E[e.to][e.back].f -= df;
				return df;
			}
		}
	}
	return 0;
}

ll findflow(int s, int t) {
	ll flow = 0;
	while (1) {
		fill(used, used + N, 0);
		ll df = dfs(s, t, 1e18);
		if (!df) break;
		flow += df;
	}
	return flow;
}

int main() {
	int n;
	cin >> n;
	
	vector<int> a(n + 1);
	for (int i = 1; i <= n; i++) cin >> a[i];
	
	ll sum = 0;
	int S = n + 1, T = n + 2;
	
	N = n + 3;
	E.resize(N);
	
	for (int i = 1; i <= n; i++) {
		for (int j = 2 * i; j <= n; j += i) {
			add(i, j, (ll)1e18);
		}
		if (a[i] > 0) add(i, T, a[i]), sum += a[i];
		else add(S, i, -a[i]);
	}
	cout << sum - findflow(S, T) << "\n";
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

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

        int N = sc.nextInt();
        int M = sc.nextInt();
        List<TreeMap> mapList = new ArrayList<TreeMap>();
        int[][] valAry = new int[M][2];

        for(int i = 0; i < N ; i++){
            TreeMap<Integer, Integer> map = new TreeMap<Integer, Integer>();
            mapList.add(map);
        }
        for(int i = 0; i < M ; i++){
            int P = sc.nextInt();
            int Y = sc.nextInt();
            mapList.get(P-1).put(Y, i);
            valAry[i][0] = P;
            valAry[i][1] = Y;
        }
        for(Map map : mapList){
            Iterator<Map.Entry<Object, Object>> it = map.entrySet().iterator();
            int i = 1;
            while (it.hasNext()) {
                Map.Entry<Object, Object> entry = it.next();
                entry.setValue(i);
                i++;
            }
            System.out.println();
        }
        for(int i = 0; i < M ; i++){
            System.out.println(format(valAry[i][0])+format((int)mapList.get(valAry[i][0]-1).get(valAry[i][1])));
        }

    }

    public static String format(int val){
        if(val > 99999) return "" + val;
        else if(val > 9999) return "0" + val;
        else if(val > 999) return "00" + val;
        else if(val > 99) return "000" + val;
        else if(val > 9) return "0000" + val;
        else if(val > 0) return "00000" + val;
        else return "";
    }
}

Measured memory_bytes: 107936
n=int(input())
ans=1
l=list(map(int,input().split()))
for x in l:
  if x==0:
    print(0)
    exit()
for x in l:
  ans=ans*x
  if(ans>1000000000000000000):
    break
if(ans>1000000000000000000):
  print(-1)
else:
  print(ans)


Measured memory_bytes: 84660
#include <iostream>
#include <vector>
#include <queue>
#include <utility>
#include <algorithm>

using namespace std;
typedef pair<int, int> pii;
struct Swimmer {
	int t, c, e;
	Swimmer(int t, int c, int e) : t(t), c(c), e(e) { }
};
const int INF = 1000000000;

int main(){
	while(true){
		int n;
		cin >> n;
		if(n == 0){ break; }
		vector<pii> input(n);
		for(int i = 0; i < n; ++i){
			cin >> input[i].first >> input[i].second;
		}
		queue<Swimmer> forward, backward;
		sort(input.begin(), input.end());
		for(int i = 0; i < n; ++i){
			int t = input[i].first, c = input[i].second;
			forward.push(Swimmer(t, c, t));
		}
		int answer = 0;
		while(!forward.empty() || !backward.empty()){
			int ft = (forward.empty() ? INF : forward.front().e);
			int bt = (backward.empty() ? INF : backward.front().e);
			int tm = min(ft, bt);
			answer = tm;
			queue<Swimmer> &q = (ft < bt) ? forward : backward;
			vector<pii> next;
			while(!q.empty() && q.front().e <= tm){
				Swimmer sw = q.front();
				q.pop();
				if(ft >= bt && --sw.c == 0){ continue; }
				next.push_back(pii(sw.t, sw.c));
			}
			sort(next.begin(), next.end());
			queue<Swimmer> &opp = (ft < bt) ? backward : forward;
			for(int i = 0; i < next.size(); ++i){
				int t = next[i].first, c = next[i].second;
				opp.push(Swimmer(t, c, t + tm));
			}
		}
		cout << answer << endl;
	}
	return 0;
}

Measured memory_bytes: 1224
def candy(arr, n, x):
	if sum(arr) == x:
		return n
	arr.sort()
	best = 0
	j = 0
	while(j < n):
		temp = x
		c = 0
		for i in range(j, n-1):
			if arr[i] < temp:
				c += 1
				temp -= arr[i]
			elif arr[i] == temp:
				c += 1
				break
			if i == n - 2:
				if temp == arr[n-1]:
					c += 1
		best = max(best, c)
		j += 1
	return best
n, x = map(int, input().split())
arr = list(map(int, input().split()))
print(candy(arr, n, x))

Measured memory_bytes: 9108
#include <iostream>
#include <vector>
#include <set>
#include <unordered_set>
#include <iterator>
#include <map>
#include <unordered_map>
#include <queue>
using namespace std;
#define Inf 1073741789

int N, M, V;
int *us, *vs, *xs;
unordered_set<int> dead;
// vector<vector<int> > es;
vector<int>* es;
// const int Inf = 1073741789;

int* dijkstra(int from)
{
	auto d = new int[V];
	// vector<int> d(V);
	// for (int i = 0; i < V; i++) d.push_back(Inf);
	for (int i = 0; i < V; i++) d[i] = Inf;
	priority_queue<pair<int, int> > queue;
	d[from] = 0;
	queue.emplace(from, 0);
	while (queue.size() > 0)
	{
		auto p = queue.top(); queue.pop();
		int u = p.first, tmp = d[u] + dead.count(u);
		if (d[u] < -p.second) continue;
		for (auto v : es[u]) if (d[v] > tmp) queue.emplace(v, -(d[v] = tmp));
	}
	return d;
}

int main()
{
	cin >> N >> M;
	//vector<set<int> > cs(N);
	auto cs = new set<int>[N];
	for (int i = 0; i < N; i++) cs[i].insert(-1);
	// for (int i = 0; i < N; i++)
	// {
	// 	cs.push_back(set<int>());
	// 	cs[i].insert(-1);
	// }
	us = new int[M];
	vs = new int[M];
	xs = new int[M];
	for (int i = 0; i < M; i++)
	{
		int a, b, c;
		cin >> a >> b >> c;
		us[i] = --a;
		vs[i] = --b;
		xs[i] = --c;
		cs[a].insert(c);
		cs[b].insert(c);
	}
	// vector<int> sep;
	auto sep = new int[N + 1];
	// sep.push_back(0);
	sep[0] = 0;
	for (int i = 0; i < N; i++) sep[i + 1] = sep[i] + cs[i].size();
	// for (int i = 0; i < N; i++) sep.push_back(sep[i] + cs[i].size());
	dead.insert(sep, sep + N + 1);
	// dead.insert(sep.begin(), sep.end());
	V = sep[N];
	// vector<map<int, int> > index;
	auto index = new map<int, int>[N];
	for (int i = 0, j = 0; i < N; i++) for (auto c : cs[i]) index[i].emplace(c, j++);
	// for (int i = 0, j = 0; i < N; i++)
	// 	{
	// 		index.push_back(map<int, int>());
	// 		for (auto c : cs[i]) index[i].emplace(c, j++);
	// 	}
	es = new vector<int>[V];
	// for (int i = 0; i < V; i++) es.push_back(vector<int>());
	for (int i = 0; i < M; i++)
		{
			int a = us[i], b = vs[i], c = xs[i], u = index[a][c], v = index[b][c];
			es[u].push_back(v);
			es[v].push_back(u);
		}
	for (int i = 0; i < N; i++)
		for (int j = sep[i] + 1; j < sep[i + 1]; j++)
		{
			es[j].push_back(sep[i]);
			es[sep[i]].push_back(j);
		}
	auto d = dijkstra(0);
	cout << (d[sep[N - 1]] == Inf ? -1 : d[sep[N - 1]]) << endl;
	delete[] d;
	delete[] cs;
	delete[] sep;
	delete[] index;
	delete[] us;
	delete[] vs;
	delete[] xs;
	delete[] es;
	return 0;
}


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

int main() {
    int max = -1000001, min = 1000001;
    long sum = 0;
    int count, input;

    cin >> count;
    for (int i = 0; i < count; i++) {
        cin >> input;
        sum += input;
        if (input >= max) {
            max = input;
        }

        if (input <= min) {
            min = input;
        }
    }
    cout << min << " " << max << " " << sum << endl;

    return 0;
}


Measured memory_bytes: 3112
#include<iostream>
#include<cstdio>
#include<vector>
using namespace std;
int n,d;
int ans=1e9;
int dep[2010];
int par[2010][20];
bool vis[2010];
vector<int>v[2010];
int dis[2010][2010];
int lca(int x,int y)
{
	if(dep[x]<dep[y])swap(x,y);
	for(int i=12;i>=0;i--)
	{
		if(dep[par[x][i]]>=dep[y])x=par[x][i];
	}
	if(x==y)return x;
	for(int i=12;i>=0;i--)
	{
		if(par[x][i]!=par[y][i])
		{
			x=par[x][i];y=par[y][i];
		}
	}
	return par[x][0];
}
int gtdis(int x,int y)
{
	return dep[x]+dep[y]-2*dep[lca(x,y)];
}
void dfs(int x)
{
	vis[x]=true;
	for(int i=0;i<v[x].size();i++)
	{
		int y=v[x][i];
		if(vis[y])continue;
		par[y][0]=x;
		dep[y]=dep[x]+1;
		dfs(y);
	}
}
int main()
{
	scanf("%d%d",&n,&d);
	for(int i=1;i<n;i++)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		v[x].push_back(y);
		v[y].push_back(x);
	}
	dfs(1);
	dep[0]=-1;
	for(int i=1;i<=12;i++)
	{
		for(int j=2;j<=n;j++)
		{
			par[j][i]=par[par[j][i-1]][i-1];
		}
	}
	for(int i=1;i<n;i++)
	{
		for(int j=i+1;j<=n;j++)dis[i][j]=dis[j][i]=gtdis(i,j);
	}
	if(d&1)
	{
		for(int i=1;i<=n;i++)
		{
			for(int j=0;j<v[i].size();j++)
			{
				int res=0;
				if(v[i][j]<=i)continue;
				for(int k=1;k<=n;k++)
				{
					if(k==i || k==v[i][j])continue;
					if(dis[k][i]>d/2 && dis[k][v[i][j]]>d/2)res++;
				}
				ans=min(ans,res);
			}
		}
	}
	else
	{
		for(int i=1;i<=n;i++)
		{
			int res=0;
			for(int j=1;j<=n;j++)
			{
				if(i==j)continue;
				if(dis[i][j]>d/2)res++;
			}
			ans=min(ans,res);
		}
	}
	printf("%d",ans);
}

Measured memory_bytes: 16256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
    ll i, ans, len;
    string s;
    cin >> s;
    len = s.length();
    for (i = 0, ans = 0; i < len; i++)
        ans += s[i] - '0';
    if (ans % 9)
        cout << "No\n";
    else
        cout << "Yes\n";
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
//#define inf 0x3f3f3f3f3f3f3f3f
#define inf 0x3f3f3f3f
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define inv(x) Power(x, mod - 2)
#define fi first
#define se second
#define N 200005

using namespace std;
typedef pair<int,int> Pair;
typedef long long ll;

const long double Pi = 3.14159265358979323846l;
const int mod = 1e9 + 7;
inline int add(int x, int y) { return (x += y) - (x >= mod ? mod : 0); }
inline void inc(int &x, int y) { (x += y) -= (x >= mod ? mod : 0); }
inline int mul(int x, int y) { return 1ll * x * y % mod; }
inline int Power(int x, int y) {
	int res = 1;
	while (y) {
		if (y & 1) res = mul(res, x);
		x = mul(x, x), y >>= 1;
	} return res;
}

template <class T> inline T	input() {
	T x; char ch; while (!isdigit(ch = getchar()));
	for (x = ch ^ 48; isdigit(ch = getchar()); x = x * 10 + (ch ^ 48));
	return x;
}

template <class T> inline void chkmin(T &x, T &y) { x = x < y ? x : y; }
template <class T> inline void chkmax(T &x, T &y) { x = x > y ? x : y; }

struct {
	inline operator int () { return input<int>(); }
	inline operator long long () { return input<long long>(); }
	template <class T> inline void operator () (T &x) { x = *this; }
	template<class T, class ...A> inline void operator () (T &x, A &...a)
	{ x = *this; this -> operator ()(a...); }
} read;

int n, a[N];
bool flag;

int main() {
	read(n);
	for (int i = 1; i <= n; ++i) read(a[i]);

	for (int i = 2; i <= n; ++i) flag |= a[i] != a[i - 1];
	if (!flag) {
		if (a[1] == n - 1 || a[1] * 2 <= n) return puts("Yes"), 0;
		else return puts("No"), 0;
	}

	int MAX = 0, cnt = 0;
	for (int i = 1; i <= n; ++i) chkmax(MAX, a[i]);
	for (int i = 1; i <= n; ++i) {
		if (MAX - a[i] > 1) return puts("No"), 0;
		if (a[i] == MAX) ++cnt;
	}

	debug("%d %d\n", MAX, cnt);
	if (MAX <= cnt / 2 + n - cnt && MAX > n - cnt) return puts("Yes"), 0;
	else return puts("No"), 0;
}


Measured memory_bytes: 640
/*
AuThOr Gwj
*/
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rl(a,b,c) for(int a=b;a>=c;--a)
#define LL long long
#define IT iterator
#define PB push_back
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
#define FREO freopen("check.out","w",stdout)
#define rep(a,b) for(int a=0;a<b;++a)
#define KEEP while(1)
#define SRAND mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define random(a) rng()%a
#define ALL(a) a.begin(),a.end()
#define POB pop_back
#define ff fflush(stdout)
#define fastio ios::sync_with_stdio(false)
#define debug_pair(A) cerr<<A.FIR<<" "<<A.SEC<<endl;
#define biggest(A,B) A=max(A,B)
#define smallest(A,B) A=min(A,B)
using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
typedef pair<mp,mp> superpair;
int n,k;
vector<LL> pos,neg,a1,a2;
const int MOD=1e9+7;
int main(){
	fastio;
	cin>>n>>k;
	if(n==k){
		LL tmp=1;
		rb(i,1,n){
			LL ai;
			cin>>ai;
			tmp*=ai;
			tmp%=MOD;
			tmp+=MOD;
			tmp%=MOD;
		}
		cout<<tmp<<endl;
		return 0;
	}
	rb(i,1,n){
		int ai;
		cin>>ai;
		if(ai<0)
			neg.PB(-ai);
		else{
			pos.PB(ai);
		}
	}	
	sort(ALL(pos));
	sort(ALL(neg));
	reverse(ALL(pos));
	reverse(ALL(neg));
	a1=pos;
	a2=neg;
	LL tmp=1;
	rep(i,pos.size()){
		pos[i]*=tmp;
		pos[i]%=MOD;
		tmp=pos[i];
	}
	tmp=1;
	rep(i,neg.size()){
		neg[i]*=tmp;
		neg[i]%=MOD;
		tmp=neg[i];
	}
	if((k&1)&&pos.empty()){
		
	reverse(ALL(a2));
	neg=a2;
	tmp=1;
	rep(i,neg.size()){
		neg[i]*=tmp;
		neg[i]%=MOD;
		tmp=neg[i];
	}
		cout<<MOD-neg[k-1]<<endl;
		return 0;//负数 
	}
	else{
		//正数
		LL res;
		bool ok=0;
		rb(i,0,neg.size()){
			if(i&1) continue;
			if(k-i<=pos.size()){
			if(i&&ok)
			if(a2[i-1]*a2[i-2]<a1[k-i]*a1[k-i+1]) break;
			if(i==0){
				res=pos[k-1];
			}
			else
			if(k-i-1>=0){
				res=pos[k-i-1]*neg[i-1]%MOD;
			}
			else{
				res=neg[i-1];
			}
				ok=1;
			} 
		} cout<<res<<endl;
	}
	return 0;
}


Measured memory_bytes: 6392
/* imports all std modules {{{*/
import
  std.algorithm,
  std.array,
  std.ascii,
  std.base64,
  std.bigint,
  std.bitmanip,
  std.compiler,
  std.complex,
  std.concurrency,
  std.container,
  std.conv,
  std.csv,
  std.datetime,
  std.demangle,
  std.encoding,
  std.exception,
  std.file,
  std.format,
  std.functional,
  std.getopt,
  std.json,
  std.math,
  std.mathspecial,
  std.meta,
  std.mmfile,
  std.net.curl,
  std.net.isemail,
  std.numeric,
  std.parallelism,
  std.path,
  std.process,
  std.random,
  std.range,
  std.regex,
  std.signals,
  std.socket,
  std.stdint,
  std.stdio,
  std.string,
  std.system,
  std.traits,
  std.typecons,
  std.uni,
  std.uri,
  std.utf,
  std.uuid,
  std.variant,
  std.zip,
  std.zlib;
/*}}}*/

/+---test
1905
---+/
/+---test
0112
---+/
/+---test
1700
---+/

void main(string[] args) {
  const S = readln.chomp;

  const l = S[0..2].to!int;
  const r = S[2..4].to!int;

  const yymm = 1 <= r && r <= 12;
  const mmyy = 1 <= l && l <= 12;

  if (yymm && !mmyy) {
    "YYMM".writeln;
  } else if (!yymm && mmyy) {
    "MMYY".writeln;
  } else if (yymm && mmyy) {
    "AMBIGUOUS".writeln;
  } else {
    "NA".writeln;
  }
}


Measured memory_bytes: 256
n, a, b = map(int, input().split())
ans = 0


def sum_(m):
    res = 0
    while m > 0:
        res += m % 10
        m //= 10
    return res


for i in range(0, n + 1):
    # if a <= sum([int(j) for j in str(i)]) <= b:
    if a <= sum_(i) <= b:
            ans += i
print(ans)


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


int main()
{
  ll n;
  cin >> n;
  ll ans = LONG_LONG_MAX;
  for (ll i = 1; i * i <= n; i++)
    if (n % i == 0)
      ans = min(ans, i - 1 + n / i - 1);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <fstream>
#include <cstdio>
using namespace std;
// vector<pair<int,int> > v;
// cin.ignore();//twice getline(cin,s);
// g++ iterator.cpp -std=c++17
// cout<<(A + B == C ? "YES" : "NO")<<endl;
// __gcd(a,b)
// string s=to_string(n);
// string p=s.substr(0,len);
// string q=s.insert(0,str);
// sort(arr, arr+n, greater<int>());
// cout<<fixed<<setprecision(9)<<pi<<endl
// const  double pi = acos(-1.0);
// sort(v.rbegin(),v.rend());
#define ff first
#define ss second
#define pb push_back
#define mk make_pair
#define vll vector<ll>
#define mll map<ll,ll >
#define mlli map<ll,ll>::iterator
#define size size()
#define endl "\n"
#define ll long long int
#define ld long double
void fast(){ios_base::sync_with_stdio(false);
cin.tie(NULL);cout.tie(NULL);}


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

	int pre = 0;
	int flag = -1;
	for(int i=0;i<n;i++)
	{
		int a,b;
		cin>>a>>b;
		if(a==b)
		{
			if(pre==0)
			{
				pre++;
			}
			else
			{
				pre++;
			}
			if(pre>=3)
			{
				flag=1;
			}
		}
		else
		{
			pre=0;
		}
	}

	if(flag==1)
	{
		cout<<"Yes"<<endl;
	}	
	else
	{
		cout<<"No"<<endl;
	}
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
//k<=x
int main(){
    int n,k;
    cin >> n >> k;
    double expectation[n];
    int p[n];
    double mx=0;
    double sum[n-k+1]={};

    for(int i=0; i<n; i++){
        cin >> p[i];
    }
    for(int i=0; i<n; i++){
        expectation[i]=((double)p[i]+1)/2;
    }
    /*for(int i=0; i<n; i++){
        cout << expectation[i] << "!";
    }*/
    for(int i=0; i<k; i++){
        sum[0]+=expectation[i];
    }
    mx=sum[0];
    /*cout << fixed << setprecision(6) << sum[0];*/
    for(int i=1; i<n-k+1; i++){
        sum[i]=sum[i-1]+expectation[k+i-1]-expectation[i-1];
        if(mx<sum[i])mx=sum[i];
    }
    /*cout << fixed << setprecision(6) << sum[0] << "!" << sum[1] << "!" << sum[2];*/
    cout << fixed << setprecision(6) << mx;
    cout << endl;
}


Measured memory_bytes: 4096
if __name__ == "__main__":
    al = list(input())
    bl = list(input())
    cl = list(input())

    game = {"a": al, "b": bl, "c": cl}

    turn = "a"

    for _ in range(10000):
        if len(game[turn]) == 0:
            print(turn.upper())
            break
        r = game[turn][0]
        game[turn] = game[turn][1:]
        turn = r


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



int main()
{   
    ll n;
    cin>>n;
    string ans;
    while(n)
    {
        n--;
        ans+='a'+n%26;
        n/=26;
    }
    reverse(ans.begin(),ans.end());
    cout<<ans<<endl;

  
    return 0;
}

Measured memory_bytes: 3632
//#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(){
    int n; cin>>n;
    stack<int> ans;
    if(n==0){
        cout<<0<<endl;
        return 0;
    }
    while(n!=0){
        if(n>0){
            ans.push(n%2);
            n=-(n/2);
        }
        else{
            ans.push((-n)%2);
            n=(-n+1)/2;
        }
    }
    while(!(ans.empty())){
        cout<<ans.top();
        ans.pop();
    }
    cout<<endl;
}


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

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

	if(u==s)
		cout << a - 1 << ' ' << b;
	else if(u==t)
		cout << a << ' ' << b - 1;
	else
		cout << a << ' ' << b;

	return 0;
}

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

int main(){
    
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    
    int N;
    cin >> N;
    vector<int> a(N+1);
    for(int i = 1; i <=N; i++){
        cin >> a[i];
    }
    
    int ans = 0;
    for(int j =2; j <= N; j++){
        ans^=a[j];
    }
    cout << ans << " ";
    
    for(int i = 2; i <= N; i++){
        int c = (ans^a[i])^a[1];
       ;
        cout << c << " ";
    }
    cout << endl;
 
}

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

#define max(a, b) ((a) > (b) ? (a) : (b))


void print_lcs(char *a, char *b, int a_len, int b_len) {
    int **memo = malloc(sizeof(int *) * 3001);
    for(int i = 0; i < 3001; i++) {
        memo[i] = malloc(sizeof(int) * 3001);
        memset(memo[i], 0, 3001 * sizeof(int));
    }
    
    for(int i = 0; i < a_len; i++) {
        for(int j = 0; j < b_len; j++) {
            if(a[i] == b[j]) {
                memo[i + 1][j + 1] = memo[i][j] + 1;
            } else {
                memo[i + 1][j + 1] = max(memo[i][j + 1], memo[i + 1][j]);
            }
        }
    }

    char result[3001];
    int result_len = 0;
    int c = b_len;
    int r = a_len;
    while(r > 0) {
        if(memo[r][c] == memo[r - 1][c]) {
            r--;
        } else if(memo[r][c] == memo[r][c - 1]) {
            c--;
        } else {
            c--;
            r--;
            result[result_len++] = a[r];
        }
    }
    result[result_len] = '\0';

    for(int i = result_len - 1; i >= 0; i--)
        putchar(result[i]);
    puts("");

    for(int i = 0; i < 3001; i++)
        free(memo[i]);

    free(memo);
}

int main(void) {
    char a[3001], b[3001];
    scanf("%s%s", a, b);
    
    int a_len = strlen(a);
    int b_len = strlen(b);

    print_lcs(a, b, a_len, b_len);
}


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

using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;

template<typename T, T mod>
struct modint {
private:
  T x;

public:
  modint(): x((T)0) {}
  modint(T y): x(y >= 0? y % mod: (mod - (-y) % mod) % mod) {}

  T get() {
    return x;
  }

  modint &operator+=(const modint &p) {
    if ((x += p.x) >= mod) x -= mod;
    return *this;
  }

  modint &operator-=(const modint &p) {
    if ((x += mod - p.x) >= mod) x -= mod;
    return *this;
  }

  modint &operator*=(const modint &p) {
    x = x * p.x % mod;
    return *this;
  }

  modint &operator/=(const modint &p) {
    *this *= p.inverse();
    return *this;
  }

  modint operator-() const { return modint(-x); }
  modint operator+(const modint &p) const {return modint(*this) += p; }
  modint operator-(const modint &p) const {return modint(*this) -= p; }
  modint operator*(const modint &p) const {return modint(*this) *= p; }
  modint operator/(const modint &p) const {return modint(*this) /= p; }

  bool operator==(const modint &p) const { return x == p.x; }
  bool operator!=(const modint &p) const { return x != p.x; }

  modint inverse() const {
    T a = x, b = mod, u = 1, v = 0, t;
    while (b > 0) {
      t = a / b;
      a -= t * b;
      swap(a, b);
      u -= t * v;
      swap(u, v);
    }
    return modint(u);
  }

  modint pow(int e) const {
    T a = 1, p = x;
    while(e > 0) {
      if (e % 2 == 0) {
	p = (p * p) % mod;
	e /= 2;
      } else {
	a = (a * p) % mod;
	e--;
      }
    }
    return modint(a);
  }
};

using mi = modint<ll, MOD>;

map<int, int> primeFactorize(int n) {
  map<int, int> ans;
  for (int i = 2; i * i <= n; ++i) {
    while (n % i == 0) {
      n /= i;
      ans[i]++;
    }
  }
  if (n > 1) {
    ans[n]++;
  }
  return ans;
}

int main() {
  int N;
  scanf("%d", &N);

  vector<int> a(N);
  for (int i = 0; i < N; ++i) scanf("%d", &a[i]);

  map<int, int> prime = primeFactorize(a[0]);
  for (int i = 1; i < N; ++i) {
    for (auto const &e: primeFactorize(a[i])) {
      prime[e.first] = max(prime[e.first], e.second);
    }
  }

  mi lcm = 1;
  for (auto const &e: prime) {
    for (int i = 0; i < e.second; ++i) {
      lcm *= e.first;
    }
  }

  mi ans = 0;
  for (int i = 0; i < N; ++i) {
    ans += lcm / a[i];
  }

  printf("%lld\n", ans.get());
  return 0;
}


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

int main(){
  string S;
  cin >> S;
  if(S.length() == 2) cout << S;
  if(S.length() == 3){
    reverse(S.begin() , S.end());
    cout << S;
  }
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner scan = new Scanner(System.in);
		
		long a,b,v,w,t,xa,xb;
		a = scan.nextLong();
		v = scan.nextLong();
		b = scan.nextLong();
		w = scan.nextLong();
		t = scan.nextLong();
		
		boolean canGet = false;
		//	trueのとき+方向へ追いかけっこする
		boolean vector = false;
			
			if(a < b) {
				vector = true;
			}
			
			//	鬼の方が遅い場合捕まえられない
			if(w >= v) {
				System.out.println("NO");
				return;
			}
			
			if((vector && (a+v*t >= b+w*t)) || (!vector && (b-w*t >= a-v*t))) {
				canGet =true;
			}else {
				canGet =false;
			}
		
		if(canGet) {
			System.out.println("YES");
		}else {
			System.out.println("NO");
		}
	}

}


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

namespace ConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine().ToCharArray();
            var b = Judge(s) && Judge(s.Take(s.Length / 2).ToArray());
            Console.WriteLine(b ? "Yes" : "No");
        }

        static bool Judge(char[] array)
        {
            for (int i = 0; i < array.Length / 2; i++)
            {
                if (array[i] != array[array.Length - i - 1]) return false;
            }
            return true;
        }
    }
}


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

#define ll long long int
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define vi vector<ll>
#define pb push_back
#define pii pair<ll,ll>
#define mp make_pair


int main()
{
    fastio;
    ll t=1;
    //cin>>t;
    while(t--)
    {
       string s,s1;
       cin>>s;
       cin>>s1;
       ll k=0,flag=0;
       for(auto i = s.begin();i!=s.end();i++)
       {
           if(*i != s1[k])
           {
               flag++;
           }
           k++;
       }
       if(flag)
       cout<<"No";
       else
       {
           cout<<"Yes";
       }
              
    }

    return 0;
}

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

#define DB(x) cerr << __LINE__ << ": " << #x << " = " << (x) << endl

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> PII;
typedef tuple<int, int, int> TP;
typedef vector<int> VI;
typedef double T;
typedef vector<T> VT;
typedef vector<VT> VVT;

const LL MOD = 1e9 + 7;
const double EPS = 1e-10;
mt19937 rng(7); // random generator using 7 for seed

int dp[3011][3011] = {};
pair<int, int> ij[3011][3011] = {};

string s, t;

void print(int i, int j) {
    if(i > 0 && j > 0) {
        if(s[i-1] == t[j-1]) {
            print(ij[i][j].first, ij[i][j].second);
            printf("%c", s[i-1]);
        } else {
            print(ij[i][j].first, ij[i][j].second);
        }
    }
}

int main() {
    cin >> s >> t;
    int n = s.size();
    int m = t.size();
    for(int i=1;i<=n;i++) {
        for(int j=1;j<=m;j++) {
            if(s[i-1] == t[j-1]) {
                dp[i][j] = dp[i-1][j-1] + 1;
                ij[i][j] = {i-1, j-1};
            } else {
                if(dp[i-1][j] > dp[i][j-1]) {
                    dp[i][j] = dp[i-1][j];
                    ij[i][j] = {i-1, j};
                } else {
                    dp[i][j] = dp[i][j-1];
                    ij[i][j] = {i, j-1};
                }
                // dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
            }
        }
    }
    print(n, m);
}


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

int main() {
  ll n,m;
  cin >> n >> m;
  
  vector<ll> hom(m);
  rep(i, m)
    cin >> hom.at(i);
  
  ll date=0;
  rep(i, m)
    date += hom.at(i);
  
  if(n < date)
    cout << -1 << endl;
  else
    cout << n - date << endl;
}

Measured memory_bytes: 3600