akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<cstring>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
const int N=25,M=45,K=195,E=6,G=(1<<19)+5,md=1000000007,INF=0x3f3f3f3f;
int n,m;
int u[K],v[K],fr[N],nxt[M],em[M],fac[K],facn[K],nyc[K],f[2][G],g[G],h[2][G],fe[G],faw[N];
int dep[N],fa[E][N];
vector<int>dir[G];
inline void addedge(int u,int v,int i)
{
	nxt[i]=fr[u];
	fr[u]=i;
	em[i]=v;
}
void dfs0(int d)
{
	for(int j=fr[d];j!=0;j=nxt[j])
		if(em[j]!=fa[0][d])
		{
			fa[0][em[j]]=d;
			dep[em[j]]=dep[d]+1;
			faw[em[j]]=j>>1;
			dfs0(em[j]);
		}
}
inline int pow_fa(int a,int b)
{
	int i=0;
	while(b>0)
	{
		if(b&1)
			a=fa[i][a];
		i++;
		b>>=1;
	}
	return a;
}
inline int lca(int a,int b)
{
	if(dep[a]<dep[b])
		swap(a,b);
	a=pow_fa(a,dep[a]-dep[b]);
	for(int i=4;i>=0;i--)
		if(fa[i][a]!=fa[i][b])
		{
			a=fa[i][a];
			b=fa[i][b];
		}
	if(a==b)
		return a;
	else
		return fa[0][a];
}
int main()
{
	scanf("%d%d",&n,&m);
	fac[0]=facn[0]=fac[1]=facn[1]=nyc[1]=1;
	for(int i=2;i<=m;i++)
	{
		fac[i]=(ll)fac[i-1]*i%md;
		nyc[i]=(ll)(md-md/i)*nyc[md%i]%md;
		facn[i]=(ll)facn[i-1]*nyc[i]%md;
	}
	if(m==n-1)
	{
		int ans=(ll)(n-1)*m*(m+1)/2%md*fac[n-2]%md;
		printf("%d\n",ans);
		return 0;
	}
	for(int i=1;i<=m;i++)
	{
		scanf("%d%d",&u[i],&v[i]);
		if(i<n)
		{
			addedge(u[i],v[i],i*2);
			addedge(v[i],u[i],i*2+1);
		}
	}
	dfs0(1);
	for(int i=1;(1<<i)<=n;i++)
		for(int j=1;j<=n;j++)
			fa[i][j]=fa[i-1][fa[i-1][j]];
	for(int s=0;s<(1<<n-1);s++)
		for(int i=1;i<n;i++)
			if(s&(1<<i-1))
				fe[s]++;
			else
				dir[s].push_back(i);
	for(int i=n;i<=m;i++)
	{
		int s=0;
		int e=lca(u[i],v[i]);
		int x=u[i];
		while(x!=e)
		{
			s|=1<<faw[x]-1;
			x=fa[0][x];
		}
		x=v[i];
		while(x!=e)
		{
			s|=1<<faw[x]-1;
			x=fa[0][x];
		}
		g[s]++;
	}
	for(int i=1;i<n;i++)
		for(int j=0;j<(1<<n-1);j++)
			if(j&(1<<i-1))
				g[j]+=g[j^(1<<i-1)];
	int now=1,la=0;
	h[0][0]=1;
	for(register int i=1;i<=m;i++)
	{
		for(register int s=0;s<(1<<n-1);s++)
		{
			if(h[la][s]==0)
				continue;
			if(fe[s]+g[s]>=i)
			{
				f[now][s]=(f[now][s]+(ll)f[la][s]*(fe[s]+g[s]-i+1)%md)%md;
				h[now][s]=(h[now][s]+(ll)h[la][s]*(fe[s]+g[s]-i+1)%md)%md;
			}
			for(register auto j:dir[s])
			{
				f[now][s|(1<<j-1)]=((ll)f[now][s|(1<<j-1)]+f[la][s]+(ll)i*h[la][s]%md)%md;
				h[now][s|(1<<j-1)]=(h[now][s|(1<<j-1)]+h[la][s])%md;
			}
			f[la][s]=h[la][s]=0;
		}
		now^=1;
		la^=1;
	}
	printf("%d\n",f[la][(1<<n-1)-1]);
	return 0;
}

Measured memory_bytes: 60416
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef string str;
const long long INF = INT64_MAX;

#define REP(i, n) for(ll i=0;i<n;i++)
#define ASC(v) sort((v).begin(), (v).end())
#define DESC(v) sort((v).rbegin(), (v).rend())
#define UNIQ(v) ASC(v);erase(unique(v.begin(), v.end()), v.end())
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);

void solve() {
    str s;
    ll k;
    cin >> s >> k;
    for (int i = 0; i < s.size(); i++)
    {
        if(s[i] == 'a') continue;
        ll d = 'z' + 1 - s[i];
        if(d <= k) {
            k -= d;
            s[i] = 'a';
        }
    }
    if(k > 0) {
        k %= 26;
        s[s.size()-1] = s[s.size()-1] + k;
    }
    cout << s << endl;
}

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


Measured memory_bytes: 592
#include <bits/stdc++.h>
using namespace std;
#define GET_MACRO(_1, _2, _3, NAME, ...) NAME
#define _repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define _rep(i,n) _repl(i,0,n)
#define rep(...) GET_MACRO(__VA_ARGS__, _repl, _rep)(__VA_ARGS__)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cout<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cout<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream &o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream &o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 1120000000

int nxt[200005][26];
int dp[200005][26];

int main(){
  string s;
  cin>>s;
  int n = s.size();

  rep(i,26) nxt[n][i] = n;
  for(int i=n-1; i>=0; i--){
    rep(j,26) nxt[i][j] = nxt[i+1][j];
    nxt[i][s[i]-'a'] = i;
  }

  fill(dp[0], dp[n+1], 0);
  for(int i=n-1; i>=0; i--){
    int mn = INF;
    rep(j,26){
      dp[i][j] = dp[i+1][j];
      mn = min(mn, dp[i+1][j]);
    }
    dp[i][s[i]-'a'] = mn + 1;
  }

  int x = min_element(dp[0], dp[1]) - dp[0];
  int idx = 0;
  while(nxt[idx][x]<n){
    printf("%c", (char)x+'a');
    idx = nxt[idx][x]+1;
    x = min_element(dp[idx], dp[idx+1]) - dp[idx];
  }

  printf("%c\n", (char)x+'a');

  return 0;
}


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

int main(){
    long long n;
    cin >> n;
    vector<long long> a(n);

    for(long long i = 0; i < n; i++){
        cin >> a[i];
    }

    long long count = 0;
    long long i = 0;

    while(i < n){
        long long sum = 0;
        while(i < n and a[i] != 0){
            sum += a[i];
            i++;
        }
        count += sum/2;
        i++;
    }

    cout << count << endl;
    return 0;
}

Measured memory_bytes: 4028
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define square(x) pow(x,2.0)
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
#define max_queue(x) priority_queue<x>
#define min_queue(x) priority_queue<x, vector<x>, greater<x>>
#define big_sort(v) sort(all(v), [](int a, int b) { return a > b; })//大きい順にソート
using ll = long long;
using vi = vector<ll>;
using vvi = vector<vi>;
using vs = vector<string>;
using vd = vector<long double>;
#define co(x) cout << x << endl;
#define cins(n,v) rep(i,n){cin >> v.at(i);}
#define couts(v) rep(i,v.size()){cout << v.at(i) << endl;}
// aよりもbが大きいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}
/*
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
*/
int main() {
  ll a,b,c,d,ans=-1e18;
  cin >> a>>b>>c>>d;
  if(a<0&&c<0){ans=a*c;}
  if(b>0&&d>0){ans=max(ans,b*d);}
  ans = max(ans,b*c);
  ans = max(ans,a*d);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3668
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
#include<cmath> 
#include<cstring>
#define ll long long
using namespace std;
ll n, x, y, dis[2010][2010], cnt[2010];
ll min(ll a, ll b)
{
	return a < b ? a : b;
}
int main(){
	while(cin >> n >> x >> y)
	{
		memset(dis, 0, sizeof(dis));
		memset(cnt, 0, sizeof(cnt));
		for(int i = 1; i <= n; i++)
		{
			for(int j = i + 1; j <= n; j++)
			{
				if(i < x && j < x)
				{
					dis[i][j] = dis[j][i] = abs(i - j);
				}
				else if(i < x && j >= x && j <= y)
				{
					dis[i][j] = dis[j][i] = min(abs(j - i), abs(y - j) + abs(x - i) + 1);
				}
				else if(i < x && j > y)
				{
					dis[i][j] = dis[j][i] = abs(x - i) + abs(j - y) + 1;
				}
				else if(i >= x && i <= y && j >= x && j <= y)
				{
					dis[i][j] = dis[j][i] = min(abs(j - i), abs(x - i) + 1 + abs(y - j));
				}
				else if(i >= x && i <= y && j > y)
				{
					dis[i][j] = dis[j][i] = min(abs(j - i), abs(x - i) + 1 + abs(j - y));
				}
				else if(i > y && j > y)
				{
					dis[i][j] = dis[j][i] = abs(j - i);
				}
				cnt[dis[i][j]]++;
			}
		}
		for(int k = 1; k < n; k++)
			cout << cnt[k] << endl;
	}
	return 0;
}

Measured memory_bytes: 31872
#include <stdio.h>
#include <cassert>
#include <algorithm>
#include <functional>

int main(){
    int input_R, input_G, input_B, input_N;
    int r_box, g_box, c_box;
    int set_num = 0;

    scanf("%d %d %d %d", &input_R, &input_G, &input_B, &input_N);

    for(int r_count = 0; r_count <= input_N / input_R; r_count++){
        for(int g_count = 0
            ;
            g_count <= input_N / input_G
            && r_count*input_R + g_count*input_G <= input_N
            ;
            g_count++){
                if( (input_N - r_count*input_R - g_count*input_G) % input_B == 0 ){
                    set_num++;
                }
            // for(int b_count = 0; b_count <= input_N / input_B; b_count++){
            //     if( input_R * r_count
            //         + input_G * g_count
            //         + input_B * b_count
            //         ==
            //         input_N){
            //             set_num++;
            //         }
            //     // printf("%d %d %d %d %d\n", r_count, g_count, b_count, input_R * r_count+ input_G * g_count+ input_B * g_count, set_num);
            
        }
    }
    printf("%d", set_num);
    return(0);
}

Measured memory_bytes: 128
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def S(): return input().rstrip()
def LS(): return S().split()
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = 1e10
    
#solve
def solve():
    n = II()
    a = IR(n)
    if sum(map(lambda x: x & 1, a)):
        print("first")
    else:
        print("second")
    return


#main
if __name__ == '__main__':
    solve()


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

int main(){

    //データ定義
    int numA;
    int numB;

    //データ入力
    cin >> numA >> numB;

    //大小関係を出力
    if(numA == numB){
        cout << "a == b" << endl;
    }else if(numA > numB){
        cout << "a > b" << endl;
    }else{
        cout << "a < b" << endl;
    }

    return 0;
}


Measured memory_bytes: 3100
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int y = sc.nextInt();
        int z = sc.nextInt();
        int k = sc.nextInt();
        long[] a = new long[x];
        long[] b = new long[y];
        long[] c = new long[z];
        long[] array1 = new long[x * y];
        long[] array2;
        
        for (int i = 0; i < x; i++) {
            a[i] = sc.nextLong();
        }
        for (int i = 0; i < y; i++) {
            b[i] = sc.nextLong();
        }
        for (int i = 0; i < z; i++) {
            c[i] = sc.nextLong();
        }
        
        int l = 0;
        for (int i = 0; i < x; i++) {
            for (int j = 0; j < y; j++) {
                array1[l] = a[i] + b[j];
                l++;
            }
        }
        Arrays.sort(array1);
        
        array2 = new long[Math.min(k, x * y) * z];
        l = 0;
        for (int i = array1.length - 1; i > array1.length - 1 - Math.min(k, x * y) ; i--) {
            for (int j = 0; j < z; j++) {
                array2[l] = array1[i] + c[j];
                l++;
            }
        }
        Arrays.sort(array2);
        
        for (int i = array2.length - 1; i > array2.length - 1 - k; i--) {
            System.out.println(array2[i]);
        }
    }
}


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

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> p(N);
  for (int i = 0; i < N; i++) {
  	cin >> p[i];
  }
  sort(p.begin(), p.end());
  int count = 0;
  for (int i = 0; i < K; i++) {
  	count += p[i];
  }
  cout << count << endl;
}


Measured memory_bytes: 3576
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n;i>0;i--)
#define rep1(i,s,n) for(int i=s;i<n;i++)
#define max0(a,b,c) max(max(a,b),c)
#define min0(a,b,c) min(min(a,b),c) 
using namespace std;
using Graph = vector<vector<int>>;
typedef long long lint;
typedef long long ll;
typedef long double ldouble;
typedef vector<int> vec;
typedef vector<ll> lvec;
typedef vector<pair<int,int>> pvec;
typedef vector<pair<ll,ll>> plvec;
typedef vector<string> svec;

int main(){
    int n,ans=0;
    cin>>n;
    lvec a(n);
    rep(i,n) cin>>a[i];
    sort(a.begin(),a.end());
    int t=-1,k=0;
    while(k<n-1){
        if(a[k]==a[k+1]){
            k++;
            continue;
        }else{
            if(k-t>a[k]) ans+=k-t-a[k];
            else if(k-t<a[k]) ans+=k-t;
            t=k;
            k++;
        }
    }
    if(n-1-t>a[n-1]) ans+=n-1-t-a[n-1];
    else if(n-1-t<a[n-1])ans+=n-1-t;
    cout<<ans;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <string>

using namespace std;

struct Card
{
    char suit, value;
};
void trace(struct Card C[], int N)
{
    int i;
    for (i = 0; i < N; i++)
    {
        if (i > 0)
            cout << " ";
        cout << C[i].suit << C[i].value;
    }
    cout << endl;
}

void BubbleSort(struct Card C[], int N)
{
    for (int i = 0; i < N; i++)
    {
        for (int j = N - 1; j > i; j--)
        {
            if (C[j].value < C[j - 1].value)
            {
                swap(C[j], C[j - 1]);
            }
        }
    }
}

void SelectionSort(struct Card C[], int N)
{
    for (int i = 0; i < N; i++)
    {
        int minj = i;
        for (int j = i; j < N; j++)
        {
            if (C[j].value < C[minj].value)
            {
                minj = j;
            }
        }
        swap(C[i], C[minj]);
    }
}

void check(struct Card Org[], struct Card C[], int N)
{

    for (int i = 0; i < N - 1; i++)
    {
        for (int j = i + 1; j < N; j++)
        {
            for (int a = 0; a < N - 1; a++)
            {
                for (int b = a + 1; b < N; b++)
                {
                    //iとjのループは配列中に同じ数字があるか調べている。
                    //同じ数字があるときに、a,bのループでカードが逆転しているか調べる。
                    //同じカードのペア（i,b）、（j,a）ができるときは逆転している。
                    //必ず、jはiより後ろ、bはaより後ろ、の関係なので、
                    if (Org[i].value == Org[j].value && Org[i].suit == C[b].suit && Org[i].value == C[b].value && Org[j].suit == C[a].suit && Org[j].value == C[a].value)
                    {

                        cout << "Not stable" << endl;

                        return;
                    }
                }
            }
        }
    }

    cout << "Stable" << endl;
}

int main()
{
    Card C[100], C2[100], Org[100];
    int N, sw;
    cin >> N;

    for (int i = 0; i < N; i++)
    {
        cin >> C[i].suit >> C[i].value;
        C2[i] = C[i];
        Org[i] = C[i];
    }

    BubbleSort(C, N);
    trace(C, N);
    check(Org, C, N);
    SelectionSort(C2, N);
    trace(C2, N);
    check(Org, C2, N);
}


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

#define MAX(X,Y) ((X)>(Y)?(X):(Y))
#define MIN(X,Y) ((X)<(Y)?(X):(Y))
#define ABS(X) ((X)>0?(X):-(X))

#define Q 1000000007

int main(void){
  string l;
  int n;
  long long dp[1000010][2]; // bit,eq
  
  cin >> l;
  n = l.size();
  dp[0][0] = 0;
  dp[0][1] = 1;
  for (int i=1; i<=n; i++){
    // eq
    if (l[i-1]=='0') dp[i][1] = dp[i-1][1];
    else dp[i][1] = (dp[i-1][1]*2)%Q;
    // less
    dp[i][0] = (dp[i-1][0]*3)%Q;
    if (l[i-1]=='1') dp[i][0] += dp[i-1][1];
//    cout << dp[i][0] << " " << dp[i][1] << endl;
  }
  cout << ((dp[n][0]+dp[n][1])%Q) << endl;
  return 0;
}

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

int n,m;
vector<int> V[100005];
int dp[100005];

int dfs(int ind){

	// printf("ind:%d\n",ind );
	if(dp[ind] != 0)
		return dp[ind];

	int max_path = 0;
	for (int i = 0; i < V[ind].size(); ++i)
	{
		int path = dfs(V[ind][i]);
		max_path = max_path > path ? max_path:path;
	}

	dp[ind] = max_path + 1;
	return dp[ind];
}

int main(){

	scanf("%d %d",&n,&m);
	for (int i = 0; i < m; ++i)
	{
		int u,v;
		scanf("%d %d",&u,&v);
		V[u].push_back(v);
	}


	int max_path = 0;
	for (int i = 0; i <= n; ++i)
	{
		int path = dfs(i);
		// printf("path:%d\n",path );
		if(path > max_path)
			max_path = path;
	}


	printf("%d\n",max_path-1);
}

Measured memory_bytes: 8192
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(), A.end()

using namespace std;

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

const int MAX_N = (int)1e5 + 5;
bool a[MAX_N];

int main()
{
	memset(a, false, sizeof(a));
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int N; cin >> N;
	vector<int> p(N, 0);
	rep (i, N){
		cin >> p[i];
	} // end rep

	rep (i, N){
		a[i] = (p[i] == i + 1);
	} // end rep

	int i = 0;
	int res = 0;
	while(i < N){
		if (a[i]){
			if (i + 1 < N && a[i+1]){
				++res;
				++i;
			}else{
				++res;
			} // end if
		} // end if
		++i;
	} // end while

	cout << res << endl;	

	return 0;
}

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

int main(void) {
  
  int l, i, n[3];
  i=0;
  
  while(cin >> l) {
    n[i] = l;
    i++;
    if(i == 2){
      break;
    }
  }
  if((n[0] * n[1]) % 2 == 0) {
    cout << "Even" << endl;
  }
  else {
    cout << "Odd" << endl;
  }
}
    

Measured memory_bytes: 256
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

const int MOD = 1000000007, INF = 1111111111; 
using namespace std;
using lint = long long;

template <class T>
class CuSum {
private:
	vector<T> cusum;
public:
	// Constructors 
	CuSum(vector<T> const &vec) : cusum(vec.size() + 1) {
		for (int i = 0; i < (int)(vec.size()); i++) cusum[i + 1] = cusum[i] + vec[i];
	}
	CuSum(int N) : cusum(N + 1) {}
	void add(int i, T x) { cusum[i + 1] += x; }
	void init() { for (int i = 0; i < (int)(cusum.size()); i++) cusum[i + 1] += cusum[i]; }

	// partial sum of 0-indexed [l, r] 
	T operator()(int l, int r) {
		if (r < l || r < 0) {
			assert(0);
			return T(0);
		}
		else return cusum[r + 1] - cusum[l];
	}
	// 0-indexed
	T operator[](int i) { return cusum[i + 1]; }
	T back() { return cusum.back(); }
};

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N;
	cin >> N;

	vector<int> row1(N+1), row2(N+1);
	for (int i = 0; i < N; i++) cin >> row1[i];
	for (int i = 0; i < N; i++) cin >> row2[i];

	CuSum<int> r1(row1), r2(row2);

	int ans = 0;
	for (int i = 0; i < N; i++) {
		ans = max(ans, r1(0, i) + r2(i, N - 1));
	}

	cout << ans << "\n";

	return 0;
}

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

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

	int N;
	int i,j;
	int tmp;
	int counter=0;
	bool flag;
	double ave;
	string answer;
	string given;

	cin >> N;
	cin >> given;

	if(N%2){
		cout << "No" << endl;
		return 0;
	}

	flag=true;
	for(i=0;i<N/2;i++){
		if(given[i]!=given[i+(N/2)]){
			flag=false;
			break;
		}
	}
	
	answer=flag?"Yes":"No";
	cout << answer << endl;

	return 0;
}



Measured memory_bytes: 256
function Main(input) {
    input = input.split("\n")
    const n = parseInt(input[0])
    var A = input[1].split(" ")
    
    var tmp = {}
    for (var i=0;i<100000;i++){
        tmp[i]=0
    }

    for (var i=0;i<n;i++){
        var a = parseInt(A[i])
        tmp[a-1]++
        tmp[a]++
        tmp[a+1]++
    }

    var ans = 0
    for (var i=0;i<100000;i++){
        ans = Math.max(ans,tmp[i])
    }
    
    console.log(ans)

}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 27196
import java.util.Scanner;

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

        for(int i = 0; i < a.length; i++){
            a[i] = sc.nextInt();
        }

        for(int i = a.length - 1; i >= 0; i--){
            System.out.print(a[i]);
            if(i != 0) System.out.print(" ");
        }

        System.out.println();
        sc.close();
    }
}


Measured memory_bytes: 26364
#include <stdio.h>
int main(void){
  int row,column,i,j,rblack[100],cblack[100];
  char matrix[100][100];
  scanf("%d %d",&row,&column);
  for(i=0;i<100;i++){
    rblack[i] = 0;
    cblack[i] = 0;
  }
  for(i=0;i<row;i++){
    for(j=0;j<column;j++){
      scanf(" %c",&matrix[i][j]);
      if(matrix[i][j] == '#'){
        rblack[i] += 1;
        cblack[j] += 1;
      }
    }
  }
  for(i=0;i<row;i++){
    for(j=0;j<column;j++){
      if(rblack[i] != 0 && cblack[j] != 0){
        printf("%c",matrix[i][j]);
      }
    }
    if(rblack != 0){
      printf("\n");
    }
  }
  return 0;
}


Measured memory_bytes: 128
"""
arr = list(map(int, input().split()))
n,k=map(int, input().split())
"""
import math
import sys
# input = sys.stdin.readline

############ ---- Input Functions ---- ############
def inp():
    return(int(input()))
def inlt():
    return(list(map(int,input().split())))
def insr():
    s = input()
    return(list(s[:len(s) - 1]))
def invr():
    return(map(int,input().split()))

length_path = int(input())
path = inlt()
dp = [float('inf')] * length_path
dp[0] = 0
for i in range(length_path):
    for j in range(i+1, i + 2 + 1):
        if j < length_path:
            dp[j] = min(dp[j], dp[i] + abs(path[j] - path[i]))
print(dp[length_path - 1])

Measured memory_bytes: 53436
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long k,n,x;
  x=0;
  cin >> n >> k;
  vector<int> vec(n);
  for (int i = 0; i < n; i++) {
    cin >> vec.at(i);
  }
  
  if(k>=n)cout << 0 << endl;
  else{sort(vec.begin(), vec.end());
  
   for (int i = 0; i < n-k; i++) {
    x+=vec.at(i);
  }
  
  cout << x << endl;
  }
  
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
int main(){ 
    string a,b;
    cin>>a>>b;
    if(a.size()<b.size()){
    cout<<"LESS";
    return 0;
    }else if(a.size()>b.size()){
        cout<<"GREATER";
        return 0;
    }
    REP(i,a.size()){
    if(a[i]!=b[i]){
        if(a[i]-'0'>b[i]-'0'){
            cout<<"GREATER";
            return 0;
        }else{
            cout<< "LESS";
            return 0;
        }
    }
    }
    cout<<"EQUAL";
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <ctime>
#include <cassert>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define fs first
#define sc second
#define INF 1000000000
#define MOD 1000000007
#define EPS 0.00000001

int main() {
    int N, K; cin >> N >> K;
    vector<int> H(N);
    int cnt = 0;
    for(int i=0; i<N; i++){
        int h; cin >> h;
        if(h>=K) cnt++;
    }
    
    cout << cnt << endl;
    return 0;
}



Measured memory_bytes: 640
#include <bits/stdc++.h>
#define forn(i, n) for (int i = 0; i<(int)n; ++i)
#define forr(i, t, n) for (int i = t; i<n; ++i)
#define rmod(x, y) (((x%y)+y)%y)
#define pb push_back
#define emp emplace_back
#define ppb pop_back
#define len(v) int(v.size())
#define all(v) (v).begin(),(v).end()
#define ri(x) scanf("%d",&(x))
#define rii(x,y) scanf("%d %d",&(x),&(y))
#define riii(x,y,z) scanf("%d %d %d",&(x),&(y),&(z))
#define rl(x) scanf("%lld",&(x))
#define rll(x,y) scanf("%lld %lld",&(x),&(y))
#define rlll(x,y,z) scanf("%lld %lld %lld",&(x),&(y),&(z))
using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;
void fastio(){ios_base::sync_with_stdio(false); cin.tie(0);}

const long double PI = acos(-1);
const long long MOD = 1000000000 +7;
const int maxn = 1024;

int main() {
	string s;
	cin >> s;
	if (s == "SUN") puts("7");
	else if (s == "MON") puts("6");
	else if (s == "TUE") puts("5");
	else if (s == "WED") puts("4");
	else if (s == "THU") puts("3");
	else if (s == "FRI") puts("2");
	else if (s == "SAT") puts("1");
	
	return 0;
}

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

int H, W, res = 0;
vector<string> Grid_c(2010);
vector<vector<int>> Grid_i(2010, vector<int>(2010, 0));


void seri_Row(void){
    for(int i = 0; i < H; i++){
        int j = 0;
        while(j < W){
            int k = 0;
            while(j+k < W && Grid_c[i][j+k] != '#') ++k;
            for(int l = j; l < j+k; l++) Grid_i[i][l] += k;
            j += k+1;
        }
    }
    return ;
}



void seri_Column(void){
    for(int i = 0; i < W; i++){
        int j = 0;
        while(j < H){
            int k = 0;
            while(j+k < H && Grid_c[j+k][i] != '#') ++k;
            for(int l = j; l < j+k; l++) Grid_i[l][i] += k;
            j += k+1;
        }
    }
    return ;
}



int main(){
    cin >> H >> W;
    for(int i = 0; i < H; i++) cin >> Grid_c[i];

    seri_Row();
    seri_Column();
  

    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++) res = max(res, Grid_i[i][j]-1);
    }

    cout << res << endl;
    return 0;
}

Measured memory_bytes: 20224
#include <algorithm>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <ctime>
#include <deque>
#include <iostream>
#include <list>
#include <map>
#include <memory.h>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <unordered_map>
#include <unordered_set>
using namespace std;
typedef long double LD;
typedef long long LL;
typedef pair<LL, LL> pll;
typedef pair<int, int> pii;
typedef vector<int> vi;
#ifdef LOCAL
#define DEBUG(x) { cerr << "# " << #x << ": " << x << endl;}
#else
#define DEBUG(x)
#endif
mt19937_64 mt(time(0));
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/
const int mod = 998244353;
const int MAXN = 3123;
LL dp[MAXN][MAXN];






int main() {
  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  cout.precision(10); cout << fixed;
#ifdef LOCAL
  freopen("../test.txt", "r", stdin);
    // freopen("../output.txt", "w", stdout);
#endif
  int a, b, c, d; cin >> a >> b >> c >> d;
  dp[a][b] = 1;
  for (int tot = a+b+1; tot <= c+d; tot++) {
    for (int i = a; i <= min(tot, c); i++) {
      int j = tot - i;
      if (j > d) continue;
      if (j < b) break;
      dp[i][j] = (dp[i-1][j] * j % mod + dp[i][j-1] * i % mod) % mod;
      dp[i][j] = (dp[i][j] - dp[i-1][j-1] * (i-1) % mod * (j-1) % mod + mod) % mod;
    }
  }
  cout << dp[c][d] << endl;







/*---------------------------------------Coding Space End------------------------------------------*/
#ifdef LOCAL
  cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s." << endl;
#endif
  return 0;
}
/* author:  txingml */
/* picture is from hamayanhamayan(CF handle) */


Measured memory_bytes: 76308
import java.lang.reflect.Array;
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] arr = new int[N];
		for(int i = 0;i<N;i++)arr[i] = sc.nextInt();
		int output = 0;
		int temp = 0;
		int var = arr[0];
		for(int i = 1;i<N;i++) {
			if(var>=arr[i]) {
				temp++;
			}
			else {
				
				if(output<=temp) {
					output = temp;
				}
				temp =0;
			}
			var = arr[i];
		}
		if(output < temp)output = temp;
		System.out.println(output);

	}
	

}


Measured memory_bytes: 52104
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;


int main()
{

	int n;
	cin >> n;

	int arr[n][3];
	for (int i = 0; i < n; i++)
	{
		cin >> arr[i][0] >> arr[i][1] >> arr[i][2];
	}
	if (n == 1)
	{
		cout << max(arr[0][0], max(arr[0][1], arr[0][2]));

	}
	else {
		for (int i = 1; i < n; i++)
		{
			for (int j = 0; j < 3; j++)
			{
				int x = (j + 1) % 3;
				int y = (j + 2) % 3;
				arr[i][j] += max(arr[i - 1][x], arr[i - 1][y]);
			}
		}

		cout << max(arr[n - 1][0], max(arr[n - 1][1], arr[n - 1][2])) << endl;


	}



}









Measured memory_bytes: 1408
#include<iostream>

int main()
{
    int *x = new int[3001];
    int *y = new int[3001];
    int i;
    for(i = 0; i < 3000; i++)
    {
        std::cin>>x[i]>>y[i];
        if((x[i]<0 & 10000<x[i])&(y[i]<0 & 10000<y[i]))
        {
            std::cout<<"Wrong Number!"<<std::endl;
            return -1;
        }
        else if (x[i]==0 & y[i]==0) {
            break;
        }
    }

    for(int j = 0; j < i; j++)
    {
        if (x[j]>y[j]) {
            std::cout<<y[j]<<" "<<x[j]<<std::endl;
        }else
        {
            std::cout<<x[j]<<" "<<y[j]<<std::endl;
        }        
    }
    
    
    return 0;
}


Measured memory_bytes: 3040
#include <iostream>
#include <bits/stdc++.h>
#include <math.h>

using namespace std;

int main(){
    double n,k;
    cin>>n>>k;
    vector<double> hoge(n);
    for(double i=0;i<n;i++){
        cin>>hoge[i];
        hoge[i]=(1+hoge[i])/2;
    }
    
    vector<double> hoges(n+1,0);
    for(double i=0;i<n;i++){
        hoges[i+1]=hoges[i]+hoge[i];
    }
    
    double ans=0;
    double preans=0;
    
    for(double i=0;i<n-k+1;i++){
        preans+=hoges[i+k]-hoges[i];
        ans=max(preans,ans);
        preans=0;
    }
    
    cout<<fixed<<setprecision(10)<<ans<<endl;
    
    return 0;
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
#define int long long
using namespace std;
int mod=998244353;

int binpow(int a, int b) 
{
	int ans=1, cac=a;
	while(b)
	{
		if(b%2==1)
		{
			ans=(ans*cac)%mod;
		}
		cac=(cac*cac)%mod;
		b/=2;
	}
	return ans;
}
int n,k;
int dp[2005][2005],h[2005][2005],dr[2005],gt[4005],inv[4005];
int lmao(int n,int m)
{
	if(n==0&&m==0) return 1;
	if(n<=0||m<0) return 0;
	return ((gt[n+m-1]*inv[m])%mod*inv[n-1])%mod;
}
int solve(int val)
{
	int ans=0;
	if(val&1)
	{
		for(int i=1; i<=k; i++) 
		{
			dr[i]=(dp[val/2][i]+dp[val/2][i-1])%mod;
		}
		dr[0]=1;
		for(int i=0; i<=k; i++)
		{
			ans=(ans+lmao(n-val,k-i)*dr[i]%mod)%mod;
		}
	}
	else for(int i=0; i<=k; i++)
	{
		ans=(ans+lmao(n-val,k-i)*dp[val/2][i]%mod)%mod;
	}
	return ans;
}

signed main()
{
	gt[0]=1;
	for(int i=1;i<=4000;i++)
	{
		gt[i]=(gt[i-1]*i)%mod;
	}
	inv[4000]=binpow(gt[4000],mod-2);
	for(int i=3999;i>=0;i--) 
	{
		inv[i]=inv[i+1]*(i+1)%mod;
	}
	cin>>n>>k;
	dp[0][0]=1;
	for(int i=0;i<=k;i++) h[0][i]=1;
	for(int i=1;i<=n/2;i++)
	for(int j=0;j<=k;j++)
	{
		if(j>0) dp[i][j]=2*h[i-1][j-1]%mod;
		dp[i][j]=(dp[i][j]+dp[i-1][j])%mod;
		h[i][j]=(h[i][j-1]+dp[i][j])%mod;
	}
	for(int i=2;i<=2*n;i++)
	{
		int cac=i-1;
		if(cac>n)
		{
			cac=2*n-cac;
		}
		cout<<solve(cac)<<'\n';
	}
	return 0;
}

Measured memory_bytes: 35072
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <string>
#include <utility>
#include <map>
#include <queue>
#include <list>
#include <functional>
#include <numeric>
#include <stack>
#include <tuple>

using namespace std;
int dx[4] = { -1,0,1,0 };
int dy[4] = { 0,1,0,-1 };
const int INF = 100000000;
const long long LINF = 1000000000000000000;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-6;
using pii = std::pair<int, int>;
using ll = long long;
using pLL = std::pair<ll, ll>;
#define SORT(v) std::sort(v.begin(), v.end())
#define RSORT(v) std::sort(v.rbegin(), v.rend())

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

    map<char, int> mp;
    for (auto i = 0; i < 4; ++i) {
        mp[s[i]]++;
    }
    if (mp.size() == 2) {
        for (auto i = mp.begin(); i != mp.end(); ++i) {
            if (i->second != 2) {
                cout << "No" << endl;
                return 0;
            }
        }
        cout << "Yes" << endl;
    }
    else {
        cout << "No" <<endl;
    }
    
    return 0;

}


Measured memory_bytes: 256
// #include <bits/stdc++.h>
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <tuple>
#include <map>
#include <math.h>
#include <algorithm> // std::sort, std::min, std::next_permutation, std::lower_bound
#include <iomanip> // std::setprecision
#include <cmath> // std::ceil
#include <numeric> // std::gcd, std::lcm
#include <limits> // std::numeric_limits<long int>::max()
#include <unordered_map>
#include <map>
#include <cmath> // std::atan2
// #include <utility> // std::pair

using namespace std;
typedef long long ll;
#define INF 1999999999
#define MODA 1000000007 
#define rep(i,n) for (long long i = 0; i < (n); ++i)

int main() {
  ll N;
  cin >> N;
  std::vector<string> S(N);
  rep(i, N) cin >> S[i];

  rep(i, N) sort(S[i].begin(), S[i].end());
  map<string, ll> groups;
  for (int i=0; i<S.size(); ++i) {
    groups[S[i]]++;
  }
  ll ans = 0;
  for (const auto group : groups) {
    // cerr << group.first <<" "<< group.second << endl;
    ll n = group.second;
    ans += n * (n - 1) / 2;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 18176
import sys
import numpy as np

def input():
    return sys.stdin.readline()[:-1]

h, w, k = map(int, input().split())
s_li = [list(input()) for _ in range(h)]

def bin_list(num, keta):
    return [i for i, x in enumerate(map(int, format(num, f'0{keta}b'))) if x==1]

cnt = 0
for row in range(2**h):
    for col in range(2**w):
        tmp = np.array(s_li)
        tmp[bin_list(row, h),:] = '.'
        tmp[:,bin_list(col, w)] = '.'
        if np.count_nonzero(tmp=='#')==k:
            cnt += 1
print(cnt)

Measured memory_bytes: 26680
#include <bits/stdc++.h>
#include <stdio.h>
#define ff(i,x,y)for(int i=x;i<y+1;i++)
#define fs(i,x,y)for(int i=x;i>y-1;i--)
#define all(x) x.begin(),x.end()
#define Ins(x) inserter(x,x.begin())
using namespace std;
int n,q1,q2;
int main()
{
    scanf("%d",&n);
    ff(i,1,n)
    {
        int num;
        scanf("%d",&num);
        if(num%2)
        q1++;
        if(num%4==0)
        q2++;
    }
    if(q2+1==q1&&q2+q1==n)
    printf("Yes");
    else if(q2>=q1)
    printf("Yes");
    else
    printf("No");
    return 0;
}


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

int main()
{
  int r, D, x_2000;
  cin >> r >> D >> x_2000;
  vector<long long int> ans(10);
  ans[0] = r * x_2000 - D;
  for (int i = 1; i < 10; i++)
  {
    ans[i] = r * ans[i - 1] - D;
  }
  for (int i = 0; i < 10; i++)
  {
    cout << ans[i] << endl;
  }
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
using namespace std;
//讨厌数字的数组
int hate[10];

//检测这个元素值是否为喜欢的元素
bool like(int n){
	while(n>0){
		if(hate[n%10])
			return false;
		n/=10;
		}
	return true;
	}
int main()
{
	int N,K,x;
	cin>>N>>K;
	for(int i=1;i<=K;++i){
		cin>>x;
		//将hate数组中，x对应的元素值修改为1，表示不喜欢x
		hate[x]=1;
		}
	while(!like(N)){
		++N;
		}
	cout<<N;
	return 0;
	}

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

ll n,w,t[105],v[105],rez,pr0[105],pr1[105],pr2[105],pr3[105],br1,br2,br3,br4;
vector<ll> p[4];

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

    cin>>n>>w;
    for(ll i=1;i<=n;i++)
    {
        cin>>t[i]>>v[i];
        if(t[i]==t[1])
        {
            p[0].push_back(v[i]);
            br1++;
        }
        else if(t[i]==t[1]+1)
        {
            p[1].push_back(v[i]);
            br2++;
        }
        else if(t[i]==t[1]+2)
        {
            p[2].push_back(v[i]);
            br3++;
        }
        else
        {
            p[3].push_back(v[i]);
            br4++;
        }
    }
    for(ll i=0;i<4;i++)
    {
        sort(p[i].begin(),p[i].end());
        p[i].push_back(0);
        reverse(p[i].begin(),p[i].end());
    }

    for(ll i=1;i<p[0].size();i++)
        pr0[i]=pr0[i-1]+p[0][i];
    for(ll i=1;i<p[1].size();i++)
        pr1[i]=pr1[i-1]+p[1][i];
    for(ll i=1;i<p[2].size();i++)
        pr2[i]=pr2[i-1]+p[2][i];
    for(ll i=1;i<p[3].size();i++)
        pr3[i]=pr3[i-1]+p[3][i];

    for(ll i1=0;i1<=br1;i1++)
    {
        for(ll i2=0;i2<=br2;i2++)
        {
            for(ll i3=0;i3<=br3;i3++)
            {
                for(ll i4=0;i4<=br4;i4++)
                {
                    if(i1*t[1]+i2*(t[1]+1)+i3*(t[1]+2)+i4*(t[1]+3)<=w)
                        if(pr0[i1]+pr1[i2]+pr2[i3]+pr3[i4]>rez)
                            rez=pr0[i1]+pr1[i2]+pr2[i3]+pr3[i4];
                }
            }
        }
    }

    cout<<rez<<endl;

    return 0;
}


Measured memory_bytes: 3572
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10, gcd
from itertools import permutations, combinations, product, accumulate, combinations_with_replacement
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
#from fractions import gcd
def debug(*args):
    if debugmode:
        print(*args)
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def FLOAT(): return float(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 1, 0, -1, 1, -1, -1, 1]
dy = [1, 0, -1, 0, 1, -1, 1, -1]
debugmode = True

h1, m1, h2, m2, k = MAP()
strt = h1 * 60 + m1
end = h2 * 60 + m2
print(end - strt - k)

Measured memory_bytes: 68380
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int a[200100],b[200100],n,c[200100],d[200100],ans=0;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",&a[i]);
	for(int i=1;i<=n;i++)scanf("%d",&b[i]);
	for(int i=1;i<=29;i++)
	{
		int k=1<<i,sum=0;
		for(int j=1;j<=n;j++)c[j]=a[j]%k,d[j]=b[j]%k;
		sort(d+1,d+n+1);
		for(int j=1;j<=n;j++)
		{
			int k2=k>>1;//k2~k k2+k~无限 
			int L1=lower_bound(d+1,d+n+1,k2-c[j])-d;
			int R1=lower_bound(d+1,d+n+1,k-c[j])-d-1;
			int L2=lower_bound(d+1,d+n+1,k2+k-c[j])-d;
			int R2=n;
			sum+=R1-L1+1+R2-L2+1;
		}
		ans+=(1<<(i-1))*(sum&1);
	}
	printf("%d",ans);return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define MOD 1000000007
#define N 100010
using namespace std;
long long dp[N][15],rem[10][13];
string s;
void fd()
{
	long long i,j,k;
	for(i=0;i<10;i++)
	{
		for(j=0;j<13;j++)
		{
			for(k=0;k<13;k++)
			{
				if((k*10+i)%13==j)
				{
					rem[i][j]=k;
					break;
				}
			}
		}
	}
}
void cvt(long long x,long long st)
{
	long long i;
	for(i=0;i<13;i++)
	{
		dp[st][i]=(dp[st][i]+dp[st-1][rem[x][i]])%MOD;
	}
}
int main(){
	long long i,j;
	fd();
	cin>>s;
	memset(dp,0,sizeof(dp));
	if(s[0]=='?')
	{
		for(i=0;i<10;i++)
		{
			dp[0][i]=1;
		}
	}
	else
	{
		dp[0][s[0]-'0']=1;
	}
	for(i=1;i<s.size();i++)
	{
		if(s[i]!='?')
		{
			cvt(s[i]-'0',i);
		}
		else
		{
			for(j=0;j<10;j++)
			{
				cvt(j,i);
			}
		}
	}
	cout<<dp[s.size()-1][5]<<endl;
	return 0;
}

Measured memory_bytes: 12160
n,m = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)
cnt = 0
sum = a.inject(:+)
base = sum/(4.0*m)
n.times do |i|
    if a[i] >= base
        cnt += 1
    end
end
if cnt >= m
    puts "Yes"
else 
    puts "No"
end


Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std ;
#define ll long long
#define rep(i,a) for(i = 0 ; i < a ; i++)
#define whln(t) while(t--)
#define whlp(t) while(t++)
#define ff first
#define ss second



int main(){
	#ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout); 
	#endif
	
	ll x,a,b,flag=0;


	cin>>x;

	for(a = -501; a<502;a++){
		flag = 0 ;
		for(b=-501; b <502;b++){
			if(x ==(pow(a,5)-pow(b,5))){
				flag =1 ;
				break;

			}
		}
		if(flag==1)
			break;

	}

	cout<<a<<" "<<b<<"\n";






		
    //your code here
    return 0;
	
}

Measured memory_bytes: 4060
<?php

fscanf(STDIN, '%d%d', $a, $b);
if($a==$b){
    echo 'Draw';
        }
elseif ($a == 1) {
        echo 'Alice';
} elseif($b == 1) {
  
        echo 'Bob';
    } elseif($a>$b) {
        echo 'Alice';
    }else{
         echo 'Bob';
}

Measured memory_bytes: 3576
#include <stdio.h>
#include <vector>
 
using namespace std;
 
struct Node{
    Node(){
        parent = -1;
        depth = num_of_children = 0;
    }
    int parent;
    int depth;
    vector<int> children;
    int num_of_children;
};
 
void calcDepth(Node nodes[],int root_id){
    for(int i = 0;i < nodes[root_id].num_of_children;i++){
        nodes[nodes[root_id].children[i]].depth = nodes[root_id].depth+1;
        calcDepth(nodes,nodes[root_id].children[i]);
    }
}
 
int main(){
    int n,id,k,child_id,root_id;
    scanf("%d",&n);
    Node nodes[n];
 
    for(int i = 0; i < n; i++){
        scanf("%d %d",&id,&k);
        for(int j = 0; j < k; j++){
            scanf("%d",&child_id);
            nodes[id].children.push_back(child_id);
            nodes[id].num_of_children++;
            nodes[child_id].parent = id;
        }
    }
 
    for(root_id = 0; root_id < n; root_id++){
        if(nodes[root_id].parent == -1) break;
    }
 
    calcDepth(nodes,root_id);
 
    for(int i = 0; i < n; i++){
        if(nodes[i].parent == -1){
            printf("node %d: parent = -1, depth = 0, root, ",i);
        }else if(nodes[i].num_of_children == 0){
            printf("node %d: parent = %d, depth = %d, leaf, ",i,nodes[i].parent,nodes[i].depth);
        }else{
            printf("node %d: parent = %d, depth = %d, internal node, ",i,nodes[i].parent,nodes[i].depth);
        }
        printf("[");
        for(int j = 0; j < nodes[i].num_of_children-1; j++){
            printf("%d, ",nodes[i].children[j]);
        }
        if(nodes[i].num_of_children > 0){
            printf("%d",nodes[i].children[nodes[i].num_of_children-1]);
        }
        printf("]\n");
    }
}


Measured memory_bytes: 7432
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;
typedef long long LL;
typedef pair<double, int> P;
typedef pair<int, int> PII;
static const double EPS = 1e-8;
static const int INF = 1e8;
#define FOR(i,k,n) for (int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
struct edge { 
  int to;
  double cost; 
  edge(int t,double c){
    to = t;
    cost = c;
  }
};
int main(void){
  int d[1001];
  int prev[1001];
  map<int,int> nti;
  int itn[1001];
  int V;
  int m;
  while(cin>>V){
    vector<edge> G[1001];
    if(V==0) break;
    vector<PII> point(V);
    REP(i,V){
      int x,y;
      cin>>itn[i]>>x>>y;
      nti[itn[i]] = i;
      point[i] = PII(x,y);
    }
    REP(i,V)REP(j,V){
      if(i==j) continue;
      double distance = (point[i].first-point[j].first)*(point[i].first-point[j].first) +
        (point[i].second-point[j].second)*(point[i].second-point[j].second);
      if(distance>50*50) continue;
      distance = sqrt(distance);
      G[i].push_back(edge(j,distance));
      G[j].push_back(edge(i,distance));
    }
    cin>>m;
    while(m--){
      int s,g;
      cin>>s>>g;
      s = nti[s]; g = nti[g];
      priority_queue<P, vector<P>, greater<P> > que;
      fill(d,d+V,INF);
      fill(prev,prev+V,-1);
      d[s] = 0;
      que.push(P(0,s));
      while(!que.empty()){
        P p = que.top(); que.pop();
        int v = p.second;
        if(d[v]<p.first) continue;
        REP(i,G[v].size()){
          edge e = G[v][i];
          if(d[e.to]>d[v]+e.cost){
            d[e.to] = d[v] + e.cost;
            prev[e.to] = v;
            que.push(P(d[e.to],e.to));
          }
        }
      }
      if(d[g]==INF){
        cout<<"NA"<<endl;
      }else{
        vector<int> ans;
        for(int t = g; t!=-1; t = prev[t]) ans.push_back(itn[t]);
        reverse(ans.begin(),ans.end());
        REP(i,ans.size()){
          if(i) cout<<" ";
          cout<<ans[i];
        }
        cout<<endl;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 0
#include<stdio.h>
#define N 100000
struct card
{
	char suit;
	int number;
};
struct card L[N/2+2];
struct card R[N/2+2];
struct card A[N];
struct card B[N]; 
int partition(struct card A[],int p,int r)
{
	int i=p-1;
	int j;
	struct card t;
	int x=A[r].number;
	for(j=p;j<r;j++)
	{
		if(A[j].number<=x)
		{
			i++;
			t=A[j];
			A[j]=A[i];
			A[i]=t;	
		}
	}
	t=A[r];
	A[r]=A[i+1];
	A[i+1]=t;
	return i+1;	
}
void quicksort(struct card A[],int p,int r)
{
	if(p<r)
	{
		int q;
		q=partition(A,p,r);
		quicksort(A,p,q-1);
		quicksort(A,q+1,r);
	}
}
void merge(struct card A[],int l,int m,int r)
{
	int i,j;
	for(i=0;i<m-l;i++)
	{
		L[i]=A[l+i];
	}
	for(i=0;i<r-m;i++)
	{
		R[i]=A[m+i];
	}
	i=j=0;
	int k=l;
	while(i!=m-l||j!=r-m)//没用标记法做 
	{
	//	cnt++;
		if(i==m-l)
		{
			A[k]=R[j];
			j++;k++;
		}
		else if(j==r-m)
		{
			A[k]=L[i];
			i++;k++;
		}
		else
		{
			if(L[i].number<=R[j].number)
			{
				A[k]=L[i];
				k++;i++;
			}
			else
			{
				A[k]=R[j];
				k++;j++;
			}
		}
	}
}
void mergesort(struct card A[],int l,int r)
{
	if(r-l>1)
	{
		int m;
		m=(l+r)/2;
		mergesort(A,l,m);
		mergesort(A,m,r);
		merge(A,l,m,r);
	}
}
int main()
{
	int n,i;
	scanf("%d",&n);
	getchar();
	for(i=0;i<n;i++)
	{
		scanf("%c %d",&A[i].suit,&A[i].number);
		getchar();
	}
	for(i=0;i<n;i++)
	{
		B[i]=A[i];
	}
	quicksort(A,0,n-1);
	mergesort(B,0,n);
	int s=0;
	for(i=0;i<n;i++)
	{
		if((B[i].suit)!=(A[i].suit))
		{
			s=1;
			break;
		}
	}
	if(s==0)
	{
		printf("Stable\n");
	}
	else
	printf("Not stable\n");
	for(i=0;i<n;i++)
	{
		printf("%c %d\n",(A[i].suit),A[i].number);
	}
	return 0; 
} 



Measured memory_bytes: 4040