akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <bits/stdc++.h>

using namespace std;

typedef double db;
typedef long long ll;
typedef long double ld;
typedef unsigned int ui;
typedef unsigned long long ull;

typedef pair < db, db > pdd;
typedef pair < db, ld > pdl;
typedef pair < ld, db > pld;
typedef pair < ld, ld > ldp;

typedef pair < ll, ll > pll;
typedef pair < int, ll > pil;
typedef pair < ll, int > pli;
typedef pair < int, int > pii;

#define F first
#define S second

#define en end()
#define bg begin()

#define rev reverse
#define mp make_pair
#define pb push_back

#define y1 y1234567890
#define um unordered_map

#define all(x) x.bg, x.en
#define sz(x) (int)x.size()
#define len(x) (int)strlen(x)

#define sqr(x) ((x + 0ll) * (x))
#define sqrd(x) ((x + 0.0) * (x))

#define forn(i, n) for (int i = 1; i <= n; i++)

const ll inf = (ll)1e18;
const ll mod = (ll)1e9 + 7;

const db eps = (db)1e-9;
const db pi = acos(-1.0);

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

const int N = 100500;

vector < int > g[N];
bool was[N], u[N][11];
int n, m, q, st[N], d[N], c[N], ans[N];

void rec(int v, int dist, int col) {
	if (!was[v]) {
		was[v] = 1;
		ans[v] = col;
	}
	u[v][dist] = 1;
	if (!dist)
		return;
	for (auto to : g[v])
		if (!u[to][dist - 1])
			rec(to, dist - 1, col);
}

int main() {
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);
	//freopen(".err", "w", stderr);

	//srand(time(NULL));

	cin.tie(NULL);
	cout.tie(NULL);
	ios_base::sync_with_stdio(false);

	//cout << setprecision(10) << fixed;
	
	cin >> n >> m;

	for (int i = 1; i <= m; i++) {
		int x, y;
		cin >> x >> y;
		g[x].pb(y);
		g[y].pb(x);
	}

	cin >> q;

	for (int i = 1; i <= q; i++)
		cin >> st[i] >> d[i] >> c[i];

	for (int i = q; i >= 1; i--)
		if (!u[st[i]][d[i]])
			rec(st[i], d[i], c[i]);

	for (int i = 1; i <= n; i++)
		cout << ans[i] << "\n";
	
	//cerr << (clock() + 0.0) / CLOCKS_PER_SEC;

	return 0;
}


Measured memory_bytes: 9208
#include<iostream>
#include<string.h>

int main() 
{
  std::string N;
  std::cin >> N;
  
 char b = N[N.length()-1];
//  std::cout << b;
//  int a =  atoi( N[N.length()-1]);

  if(b == '2' || b=='4'|| 
   b == '5' || b=='7'|| 
   b == '9'){  
    std::cout << "hon";
    return 0;
  }
  else if(
  b == '0' ||  b == '1' ||
    b == '6' ||  b == '8' )
  {
      std::cout << "pon";
    return 0;
  }    
  else if(b =='3')
  {
    std::cout << "bon";
    return 0;
  }
  
  return 0;  
}

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

#define INF 1000000000

using namespace std;

int n, u, v, a, b;

vector< vector<int> > e;
vector<int> takahashi, aoki;

void distance_from_aoki(int c, int p) {
    aoki.at(c) = aoki.at(p) + 1;
    for (auto i = e.at(c).begin(); i != e.at(c).end(); ++i) if (*i != p) distance_from_aoki(*i, c);
}

void distance_from_takahashi(int c, int p) {
    takahashi.at(c) = takahashi.at(p) + 1;
    if (takahashi.at(c) >= aoki.at(c)) takahashi.at(c) = INF;
    for (auto i = e.at(c).begin(); i != e.at(c).end(); ++i) if (*i != p) distance_from_takahashi(*i, c);
}

int main() {
    ios::sync_with_stdio(false);
    int ans = 0;
    cin >> n >> u >> v;
    e.resize(n + 1);
    takahashi.resize(n + 1);
    aoki.resize(n + 1);
    takahashi.at(0) = -1;
    aoki.at(0) = -1;
    for (int i = 1; i < n; ++i) {
        cin >> a >> b;
        e.at(a).push_back(b), e.at(b).push_back(a);
    }
    distance_from_aoki(v, 0);
    distance_from_takahashi(u, 0);
    for (int i = 1; i <= n; ++i) if (aoki.at(i) >= takahashi.at(i)) ans = max(ans, aoki.at(i) - 1);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 11648
#include <iostream>
#include <cstdio>
#include <sstream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <cctype>
#include <stack>
#include <bitset>
#include <unordered_set>
#include <map>
#include <set>
#include <cmath>
//#include <bits/stdc++.h>

using namespace std;
typedef long long lolo;
typedef pair<int,int> pii;
typedef pair<double,double> pdd;
typedef unsigned long long ulolo;

const int maxn = (int)1e5 + 5;
const lolo maxx = (lolo)10000001;
const int maxm =(int)2e3 + 5;
const int INF = 0x3f3f3f3f;
const lolo inf = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-6;
const int MOD = (int)1e6 + 3;

template<class T>
inline void read(T &x) {
    x = 0; T flag = 1;char c;
    do { c = (char) getchar(); if (c == '-') break; } while (c < '0' || c > '9');
    if (c == '-') { c = '0', flag = -1;}
    do { x = x * 10 + c - '0';c = (char) getchar();} while (c >= '0' && c <= '9');
    x *= flag;
}
template<class T>
inline void out(T x) {
    if (x > 9) out(x / 10);
    x = x % 10;
    putchar('0' + x);
}

char g[1005][1005];
int dx[4]={0, 0, -1, 1};
int dy[4]={1, -1, 0, 0};
queue<pii> Q;
int main() {
    int n,m;
    read(n);read(m);
    for (int i = 0; i < n; ++i) {
        scanf("%s", g[i]);
        for (int j = 0; j < m; ++j) {
            if (g[i][j]=='#') {
                Q.push(make_pair(i, j));
            }
        }
    }
    int ccnt = Q.size();
    int ncnt = 0, ans = 0;
    while (!Q.empty()) {
        pii x = Q.front();Q.pop();
        for (int i = 0; i < 4; ++i) {
            int nx = x.first+dx[i], ny = x.second+dy[i];
            if (nx<0||nx>=n||ny<0||ny>=m||g[nx][ny]=='#') {
                continue;
            }
            g[nx][ny]='#';
            Q.push(make_pair(nx, ny));
        }
        if (++ncnt==ccnt) {
            ncnt=0;
            ccnt = Q.size();
            ++ans;
        }
    }
    printf("%d\n", ans-1);
    return 0;
}


Measured memory_bytes: 9360
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		int N = scan.nextInt();
		long K = scan.nextLong();
		int[] A = new int[N + 1];
		int[] counts = new int[N + 1];
		int count = 0;
		int loop = 0;

		for (int i = 1; i <= N; i++) {
			A[i] = scan.nextInt();
			counts[i] = -1;
		}

		int current = 1;
		while (true) {
			if (count == K) {
				System.out.println(current);
				System.exit(0);
			}
			if (counts[current] != -1) {
				loop = count - counts[current];
				break;
			}
			counts[current] = count;
			current = A[current];
			count++;
		}

		K -= count;
		long num = K % loop;

		for (int i = 0; i < num; i++) {
			current = A[current];
		}

		System.out.println(current);
 	}
}

Measured memory_bytes: 61124
s = str(input())
s = ''.join(list(reversed(s)))

t = 0
while t <= len(s):
    if s[t:t+5] == 'maerd':
        t += 5
        continue
    elif s[t:t+7] == 'remaerd':
        t += 7
        continue
    elif s[t:t+5] == 'esare':
        t += 5
        continue
    elif s[t:t+6] == 'resare':
        t += 6
        continue
    elif t == len(s):
        print('YES')
        quit()
    else:
        break
print('NO')

Measured memory_bytes: 3956
/*
 * GCA : "Computer is artificial subject absolutely,Math is God"
 */
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <climits>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <cctype>
#include <utility>
#include <ctime>
using namespace std;
#ifdef DEBUG
#define VAR(a,b) __typeof(b) a=(b)
#define debug(...) printf("DEBUG: "),printf(__VA_ARGS__)
#else
#define VAR(a,b) __typeof(b) a=(b)
#define debug(...)
#endif
typedef unsigned int uint;
typedef long long int Int;
typedef unsigned long long int UInt;
#define Set(a,s) memset(a,s,sizeof(a))
#define Pln() printf("\n")
#define For(i,x)for(int i=0;i<x;i++)
#define CON(x,y) x##y
#define M 25
#define PB push_back
#define oo INT_MAX
#define FOR(a,b) for(VAR(a,(b).begin());a!=(b).end();++a)
#define eps 1e-9
#define X first
#define Y second
inline bool xdy(double x,double y){return x>y+eps;}
inline bool xddy(double x,double y){return x>y-eps;}
inline bool xcy(double x,double y){return x<y-eps;}
inline bool xcdy(double x,double y){return x<y+eps;}
const Int mod=1000000007;
int n;
char str[M][M];
int mz[M][M];
int pnt[M];
bool nonused[M];
bool substr(int x,int y){
	int xlen=strlen(str[x]);
	int ylen=strlen(str[y]);
	string sx(str[x]),sy(str[y]);
	if(ylen>xlen)return false;
	for(int i=0;i<=xlen-ylen;i++){
		if(sx.substr(i,ylen)==sy)return true;
	}
	return false;
}
int count_w(int x,int y){
	int len=strlen(str[x]);
	int len2=strlen(str[y]);
	for(int i=max(0,len-len2);str[x][i];i++){
		bool suc=true;
		int j,k;
		for(j=i,k=0;str[x][j]&&str[y][k];j++,k++){
			if(str[x][j]!=str[y][k]){
				suc=false;
				break;
			}
		}
		if(suc)return k;
	}
	return 0;
}
int dp[1<<15][15];
int dfs(int s,int now,int dep){
//	debug("%d %d\n",now,dep);
	if(s==(1<<n)-1){
		return 0;
	}
	if(dp[s][now]!=-1)return dp[s][now];
	int minans=-1,t;
	for(int i=0;i<n;i++){
		if(i!=now&&!((s>>i)&1)){
			int h;
			if((h=dfs(s|(1<<i),i,dep+1))!=-1){
				t=h+strlen(str[pnt[i]])-mz[now][i];
			}
			if(minans==-1||t<minans){
				minans=t;
			}
		}
	}
	return dp[s][now]=minans;
}
void solve(){
	Set(nonused,0);
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			if(i==j)continue;
			if(substr(i,j))nonused[j]=1;
		}
	}
	int cnt=0;
	for(int i=0;i<n;i++){
		if(!nonused[i])pnt[cnt++]=i;
	}
	n=cnt;
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			if(i==j)continue;
			mz[i][j]=count_w(pnt[i],pnt[j]);
//			debug("%d %d %d\n",i,j,mz[i][j]);
		}
	}
	Set(dp,-1);
	int ans=oo;
//	ans=dfs(1,0,0);
	for(int i=0;i<n;i++){
		int t=strlen(str[pnt[i]])+dfs(1<<i,i,0);
		ans=min(ans,t);

	}
	printf("%d\n",ans);
}
int main() {
	ios_base::sync_with_stdio(0);
	while(~scanf("%d",&n)&&n){
		for(int i=0;i<n;i++)scanf("%s",str[i]);
		Set(mz,0);
		solve();
	}

















}

Measured memory_bytes: 3192
nkc = list(map(int, input().split()))
s = input()
ok = [i for i in range(nkc[0]) if s[i]=='o']

L = []
today = -1000000
for x in ok:
    if x-today >= nkc[2]+1:
        today = x
        L.append(x)
    if len(L) == nkc[1]:
        break

R = []
today = 1000000
ok.reverse()
for x in ok:
    if today-x >= nkc[2]+1:
        today = x
        R.append(x)
    if len(R) == nkc[1]:
        break

R.reverse()
for i in range(nkc[1]):
    if L[i] == R[i]:
        print(L[i]+1)

Measured memory_bytes: 15848
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#define MOD 1000000007

using namespace std;

int main(void){
  long long int N;
  int i;
  long long int tmp;

  cin>>N;

  vector<long long int> t(N);
  vector<long long int> a(N);

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

  if(t[i-1]!=a[0]) {
    cout<<"0\n";
    return 0;
  }
  tmp=1;

  long long int t1,t2,a1;

  t1=t[0];
  t2=t[1];
  a1=a[1];
  for(i=2;i<N;i++){
    if(t1>t2||a1<a[i]){  cout<<"0\n"; return 0;}
    if(t2>t1&&a1<t2){  cout<<"0\n"; return 0; }
    if(a1>a[i]&&a[i]>t[i]){  cout<<"0\n"; return 0; }
    if(t1==t2&&a1==a[i]) tmp=(tmp*min(t2,a[i]))%MOD;
    a1=a[i];
    t1=t2;
    t2=t[i];
  }

  cout<<tmp<<endl;
  return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <math.h>
int main(void)
{
	int n,x[100],y[100],i,t;
	double d1=0,d2=0,d3=0,di=0;
	scanf("%d",&n);
	for(i=0;i<n;i++)
{
		scanf("%d",&x[i]);
	}
	for(i=0;i<n;i++)
{
		scanf("%d",&y[i]);
	}
	for(i=0;i<n;i++)
{
		t=x[i]-y[i];
		if(t<0)
			t=-t;
		d1+=t;
		d2+=t*t;
		d3+=t*t*t;
		if(di<t) di=t;
	}
	d2=pow(d2,1./2);
	d3=pow(d3,1./3);
	printf("%.6f\n%.6f\n%.6f\n%.6f\n",d1,d2,d3,di);
	return 0;
}


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

int main(){
    string w, t;
    int ans = 0;
    cin >> w;
    while (cin >> t){
        if (t == "END_OF_TEXT") break;
        else{
            for (int i=0; i<t.size(); i++)
                t[i] = tolower(t[i]);
        }
        if (t == w) ans += 1;
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;
#define ll long long

int main(){
    ll cnt = 0;
    ll N, L, D, tmp;
    ll dim[11][11];
    ll eat = 10000, sum = 0;
    ll ans = 0;
    cin >> N >> D;
    for(int i = 0; i < N; i++){
        for(int j = 0; j < D; j++){
            cin >> dim[i][j];
        }
    }
    for(int i = 0; i < N - 1; i++){
        for(int j = i + 1; j < N; j++){
            tmp = 0;
            for(int k = 0; k < D; k++){
                tmp += pow(abs(dim[i][k]-dim[j][k]),2);
            }
            if(ceil(sqrt(tmp)) == floor(sqrt(tmp)))cnt++;
        }
    }
    cout << cnt << endl; 
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    ll K, A, B;
    cin >> K >> A >> B;
    // K回叩く
    ll a1 = 1 + K;

    // A - 1times punch
    K = max(0LL, K - (A-1));
    // A -> 1yen -> B -> 1yen ...
    ll a2 = A + (K / 2) * (B - A) + (K % 2);
    cout << max(a1, a2) << '\n';
}


Measured memory_bytes: 3612
#include<iostream>
#include<stdio.h>
#include<cmath>
using namespace std;

int main(){
  long int  H,count=0;

  cin>>H;
  int i=0;
  while(H>0){
    count += pow(2,i);
    H = H/2;
    i++;
  }
  cout<<count<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<set>
#include<cmath>
#include<iomanip>
using namespace std;

int INF = 1e9 + 7;

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

vector<vector<bool>> g(60, vector<bool>(60, false));
vector<bool> visit(60, false);
vector<int> a(60), b(60);

int n, m;

void dfs(int x) {
	visit[x] = true;

	for (int i = 1; i <= n; i++) {
		if (g[x][i] == false) continue;
		if (visit[i] == true) continue;

		dfs(i);
	}
}

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

	for (int i = 1; i <= m; i++) {
		cin >> a[i] >> b[i];
		g[a[i]][b[i]] = g[b[i]][a[i]] = true;
	}

	int ans = 0;
	for (int i = 1; i <= m; i++) {
		g[a[i]][b[i]] = g[b[i]][a[i]] = false;

		for (int j = 1; j <= n; j++) visit[j] = false;
		
		dfs(1);

		bool x = false;
		for (int j = 1; j <= n; j++) {
			if (visit[j] == false) {
				x = true;
			}
		}

		if (x) ans++;

		g[a[i]][b[i]] = g[b[i]][a[i]] = true;
	}
	cout << ans << endl;
}

Measured memory_bytes: 384
while True:
    num_H, num_W = list(map(int, input().split()))
    if num_H == num_W == 0:
        exit()
    num_W1 =num_W -2
    print("#" * num_W)
    for count in range(num_H - 2):
        print("#" + "." * num_W1 + "#")
    print("#" * num_W)
    print("")



Measured memory_bytes: 5612
#include <bits/stdc++.h>
#define debug(x) cerr << "\n" \
                      << #x << ": " << x << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define int long long
#define print(x) cout << (x) << endl
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = (1LL << 30);
const ll MOD = 1000000007;

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

/*
 */
int N;
vector<int> A;
int suma = 0;

int getA(int ind)
{
    if (ind < 0)
        return A[N - 1];
    if (ind >= N)
        return A[0];
    else
        return A[ind];
}
void setA(int ind, int val)
{
    if (ind < 0)
        A[N - 1] = val;
    if (ind >= N)
        A[0] = val;
    else
        A[ind] = val;
}


void solve()
{

    vector<int> rain(N);
    int tmp = 0;
    for (int i = 1; i < N; ++i) {
        if (i % 2) tmp += A[i]*2;
    }
    rain[0] = suma - tmp;
    for (int i = 1; i < N; ++i) {
        rain[i] = A[i-1]*2 - rain[i-1];
    }


    for (auto x: rain){
        cout<<x<<" ";
    }
    cout<<endl;
}
signed main()
{
    cin >> N;
    rep(i, N)
    {
        int tmp;
        cin >> tmp;
        suma += tmp;
        A.push_back(tmp);
    }
    solve();
    return 0;
}

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
typedef long long ll;
#define pb push_back
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}
const double PI=acos(-1);

void solve(){
    ll n, m; cin >> n >> m;
    vector<pair<ll, ll>> st, ch;
    REP(i, n){
        ll a, b;
        cin >> a >> b;
        st.pb({a, b});
    }
    REP(i, m){
        ll c, d;
        cin >> c >> d;
        ch.pb({c, d});
    }

    REP(i, n){
        ll tmp = 1000000000;
        ll minind = 100;
        for(ll j=0; j<m; j++){
            ll dist = abs(st[i].first - ch[j].first) + abs(st[i].second - ch[j].second);
            if(dist < tmp){
                tmp = dist;
                minind = j+1;
            }
        }
        cout << minind << endl;
    }
}

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

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <string>
#include <sstream>
#include <iomanip>
#include <complex>
using namespace std;

#define ll long long
#define vvi vector< vector<int> >
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back 
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

string IntToString(ll int number){
  stringstream ss;
  ss << number;
  return ss.str();
}

string tmp;
string tmp2;

int main(){
	int q,cnt;
	cin >> q;
	REP(i,q){
		
		cin >> tmp;
		tmp2 = tmp;
		cnt = 0;
		while(tmp.size()!=1){
			int mmax = -1;
			FOR(i,1,tmp.size()){
				string st1,st2;
				FOR(j,0,i) st1 += tmp[j];
				FOR(j,i,tmp.size()) st2 += tmp[j];
				mmax = max(mmax,stoi(st1)*stoi(st2));
			}
			cnt++;
			tmp = IntToString(mmax);
			/*if(tmp==tmp2){
				cnt = -1;
				break;
			}*/
		}
		
	cout << cnt << endl;
	}
	return 0;
}

Measured memory_bytes: 1236
#include <iostream>
#include<string>
using namespace std;
int main(void){
    int A,B,C,K;
    int score = 0;
    int n = 0;
    int temp;
    
    cin >> A >> B >> C >> K;
    
    temp = A - max(0, A - K);
    n += temp;
    score += temp;
    if(n < K){
        temp = B - max(0, (n + B) - K);
        n += temp;
    }
    if(n < K){
        temp = C - max(0, (n + C) - K);
        n += temp;
        score -= temp;
    }
    
    cout << score << endl;
    
    return 0;
}

Measured memory_bytes: 3604
#include<iostream>
#include<algorithm>
#include<cmath>
typedef long long ll;
using namespace std;
int main() {
	string s;
	cin >> s;
	int k;
	cin >> k;
	int x=0;
	int i = 0;
	while (i!=k) {
     x = s[i] - '0';
	 if (x != 1) {
		 break;
	 }
		i++;
	}
	if (i == k) {
		cout << "1" << endl;
	}
	else {
		cout << x << endl;
	}
	return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var in string
	fmt.Scan(&in)

	for i, v := range in {
		if i%2 == 0 && v == 76 {
			fmt.Println("No")
			return
		} else if i%2 == 1 && v == 82 {
			fmt.Println("No")
			return
		}
	}
	fmt.Println("Yes")
}


Measured memory_bytes: 512
//#include <bits/stdint.h>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <bitset>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef long long LL;

typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
const LL MOD = 1e9+7; 
//vector <vector<int>> x(20, vector<int> (20)), y(20,vector<int> (20));
/*int counter_1 (int x) {
    if(x == 0) return 0;
    return counter_1(x >> 1) + (x & 1);
}*/
int main(){
  int n;
  LL y;
  cin >> n >> y;
  bool flg=false;
  VI ans(3,-1);
  REP(i,n+1){
    if(i*10000>y) break;
    REP(j,n+1){
      if(i*10000+j*5000>y) break;
      int k = n-i-j;
      if(k<0) continue;
      LL cnt=i*10000+j*5000+k*1000;
      if(cnt==y){
        ans[0]=i;
        ans[1]=j;
        ans[2]=k;
        flg=true;
        break;      
      }
    }
    if(flg)break;
  }
  REP(i,2){
    cout << ans[i] << ' ';
  }
  cout << ans[2] << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<queue>
using namespace std;
const int N=1e6+10;
typedef pair<int,int> pii;
int n,m,ans;pii p[N];
priority_queue<int> Q;
int size[N],ll;
#define lc x<<1
#define rc x<<1|1
void add(int x,int l,int r,int p){
	size[x]++;
	if (l==r) return;
	int mid=(l+r)>>1;
	if (p>mid) add(rc,mid+1,r,p);else add(lc,l,mid,p);
}
int query(int x,int l,int r,int p){
	if (r<p||size[x]==r-l+1) return 0;
	if (l==r) return l;
	int mid=(l+r)>>1,ans=query(lc,l,mid,p);
	return ans?ans:query(rc,mid+1,r,p);
}
int main()
{
	scanf("%d%d",&m,&n);ans=m;
	for (int i=1;i<=m;i++) scanf("%d%d",&p[i].first,&p[i].second);
	sort(p+1,p+m+1);
	ll=n;
	for (int i=1;i<=m;i++){
		int x=query(1,1,n,p[i].second);
		if (x) add(1,1,n,x),ll--;else Q.push(p[i].first);
	}
	for (int i=ll;i;i--)
		if (!Q.empty()&&Q.top()>=i) Q.pop();
	printf("%d\n",(int)Q.size());
	return 0;
}

Measured memory_bytes: 7036
#include<cmath>
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<functional>
#define INF 1e16
#define N (1000000000+7)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> Q;


ll gcd(ll a, ll b) {
    if(b==0) return abs(a);
	else return gcd(b, a%b);
}

int main(void){
    int n;
    cin>>n;
    ll ans = 0;
    for(int i=0;i<n;i++){
        int x;
        cin>>x;
        while(x%2==0)ans++,x/=2;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
class Main
{
    static BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
	static FastScanner sc=new FastScanner(br);
    static PrintWriter out=new PrintWriter(System.out);
	static Random rnd=new Random();
	
    public static void main(String args[]) throws Exception
    {
		long a=sc.nextLong(),b=sc.nextLong(),x=sc.nextLong();
		if(a==0)
		{
			out.println((b/x)+1);
		}
		else if(a==1)
		{
			out.println(b/x);
		}
		else
		{
			long val1=(b/x),val2=((a-1)/x);out.println(val1-val2);
		}
		out.close();
    }
}
class FastScanner
{
    BufferedReader in;
    StringTokenizer st;

    public FastScanner(BufferedReader in) {
        this.in = in;
    }
	
    public String nextToken() throws Exception {
        while (st == null || !st.hasMoreTokens()) {
            st = new StringTokenizer(in.readLine());
        }
        return st.nextToken();
    }
	
	public String next() throws Exception {
		return nextToken().toString();
	}
	
    public int nextInt() throws Exception {
        return Integer.parseInt(nextToken());
    }

    public long nextLong() throws Exception {
        return Long.parseLong(nextToken());
    }

    public double nextDouble() throws Exception {
        return Double.parseDouble(nextToken());
    }
}

Measured memory_bytes: 8020
n, m = gets.chomp.split.map &:to_i
h = Hash.new(0)
a = gets.chomp.split.map{|u|u.to_i%m}
y = Array.new(n,0)
c = 0
ans = 0
(1..n).each do |i|
  c += a[-i]
  c %= m
  y[-i] = c
  h[c] += 1
end

(0...n).each do |i|
  ans += (h[y[i]] - 1)
  h[y[i]] -=1
  ans += 1 if(y[i] == 0)
end

p ans

Measured memory_bytes: 13452
#include<iostream>
#include<string>
using namespace std;
int main()
{
    double n;
    while(cin>>n){
        if(48.0>=n)cout<<"light fly"<<endl;
        else if(51>=n)cout<<"fly"<<endl;
        else if(54>=n)cout<<"bantam"<<endl;
        else if(57>=n)cout<<"feather"<<endl;
        else if(60>=n)cout<<"light"<<endl;
        else if(64>=n)cout<<"light welter"<<endl;
        else if(69>=n)cout<<"welter"<<endl;
        else if(75>=n)cout<<"light middle"<<endl;
        else if(81>=n)cout<<"middle"<<endl;
        else if(91>=n)cout<<"light heavy"<<endl;
        else cout<<"heavy"<<endl;
    }
}

Measured memory_bytes: 1220
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<bool> vb;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define in insert
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e9 + 5;
const int  N = 2e5 + 314;
void foo(){
    int n, m;
    cin>>n>>m;
    vi v(n+1);
    vi cnt(n+1);
    int ok=0, wa=0;
    for(int i = 0; i < m; i++){
        int x;string c;
        cin>>x>>c;
        if(c=="AC")v[x]=1;
        else{
            if(!v[x])cnt[x]++;
        }
    }
    for(int i = 1; i <= n; i++){
        if(v[i]){
            ok++;
            wa+=cnt[i];
        }
    }
    cout<<ok<<" "<<wa;
}
int main(){
    speed;
    int t=1;
    //cin>>t;
    while(t--)foo();
}

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

using namespace std;

int main() {
    int a, b;
    while (cin >> a >> b) {
        long long c = a + b;
        int d = 0;
        while (c) {
            c /= 10;
            d ++;
        }
        cout << d << endl;
    }
    return 0;
}

Measured memory_bytes: 1160
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC_115
{
    class Program
    {
        static void Main(string[] args)
        {
            int D;

            D = int.Parse(Console.ReadLine());


            if (D == 25)
                Console.Write("Christmas");
            else if (D == 24)
                Console.Write("Christmas Eve");
            else if (D == 23)
                Console.Write("Christmas Eve Eve");
            else if (D == 22)
                Console.Write("Christmas Eve Eve Eve");

            Console.ReadKey();

























        }
    }
}


Measured memory_bytes: 11092
#include <stdio.h>
int main(){
	char S[3];
  int j=0,k=0;
  	
  for(int i=0;i<3;i++){
    scanf("%s",S);
    if(S[i]=='A')
      j++;
    else
      k++;
  }
  
  if(j==3 || k==3)
    printf("No");
  else
    printf("Yes");
  

}
  

Measured memory_bytes: 128
using System;
class Program
{
  static void Main()
  {
    int N = int.Parse(Console.ReadLine());
    string[] A = Console.ReadLine().Split(' ');
    double a = 0;
    for (int i = 0; i < N; i++)
    {
      a += 1 / double.Parse(A[i]);
    }
    Console.WriteLine(1 / a);
  }
}

Measured memory_bytes: 11220
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <cmath>
#include <iostream>
#include <set>
#include <stack>
#include <queue>
#include <numeric>
#include <deque>
#include <cstring>
#include <iterator>
#include <map>
#include <cstdlib>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <complex>
#include <bitset>
#include <chrono>
using namespace std;

//const int mod=1000000007;
const int mod=998244353;



int main()
{   ios_base::sync_with_stdio(false);cin.tie(NULL);
    long long int t,n,m,k,q,x,a,b,c,d;
    cin>>k>>n;
    vector<int> vec(2*n);
    for (int i=0; i<n; i++) {
        cin>>vec[i];
        vec[i+n]=vec[i]+k;
    }
    c=1e9;
    for (int i=1; i<2*n; i++) {
        c=min((int)c, (int)k-abs(vec[i]-vec[i-1]));
    }
    
    
    cout<<c<<"\n";
    return 0;
    
    
}
    


Measured memory_bytes: 1792
#include<stdio.h>

int main(void)
{
	int i, j;
	for (i = 1; i <= 9; i++)
	{
		for (j = 1; j <= 9; j++)
		{
			printf("%dx%d=%d\n", i, j, i*j);
		}
	}
	return 0;
}

Measured memory_bytes: 524
//  SMOKE SHISHA PLAY FIFA  // 
#include<bits/stdc++.h>
using namespace std;

typedef long long int ll;
typedef long double ld;

#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define pll pair<ll,ll>
#define MP make_pair
#define ff first
#define ss second
#define PB push_back
#define mod 1000000007
#define lp(i,start,end) for(ll i=start;i<=end;i++) 
#define deb1(a) cout<<#a<<" = "<<(a)<<endl;
#define deb2(a,b) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<endl;
#define deb3(a,b,c) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<", "<<#c<<" = "<<(c)<<endl;


ll modu(ll a, ll b)
{
	ll ans =1;
	while(b>0)
	{
		if(b&1)
		ans = (ans*a)%mod;
		b/=2;
		a = (a*a)%mod;
	}
	return ans;
}

int main()
{
	fastio
	ll n,a=0,w=0,t=0,r=0;
	cin >> n;
	lp(i,1,n){
		string s;
		cin>>s;
		if(s=="AC")
			a++;
		else if(s=="WA")
			w++;
		else if(s=="TLE")
			t++;
		else if(s=="RE")
			r++;

	}
	cout<<"AC x "<<a<<endl;
	cout<<"WA x "<<w<<endl;
	cout<<"TLE x "<<t<<endl;
	cout<<"RE x "<<r<<endl;

	return 0;	
}


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

#define BUF_SIZE 1024
typedef std::stack<int> IntStack;

int main(){
    IntStack iStack;
    char b[BUF_SIZE];
    for(int i=0;i<BUF_SIZE;i++)b[i]='e';
    bool numFLG=false;
    fgets(b,BUF_SIZE,stdin);
    int s=0,op1=0,op2=0;
    int count=0;
    for(int i=0;b[i]!='e';i++){
        if(b[i]>='0'&&b[i]<='9'){
            s=s*10+(b[i]-'0');
            numFLG=true;
        }
        else{
            if(numFLG){
                iStack.push(s);
                s=0;
                numFLG=false;
            }
            if(b[i]=='+'){
                op2=iStack.top();
                iStack.pop();
                op1=iStack.top();
                iStack.pop();
                iStack.push(op1+op2);
            }
            else if(b[i]=='-'){
                op2=iStack.top();
                iStack.pop();
                op1=iStack.top();
                iStack.pop();
                iStack.push(op1-op2);           
            }
            else if(b[i]=='*'){
                op2=iStack.top();
                iStack.pop();
                op1=iStack.top();
                iStack.pop();
                iStack.push(op1*op2);              
            }
        }

    }
    op1=iStack.top();
    printf("%d\n",op1);
}


Measured memory_bytes: 3216
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
int main(){
    string s;
    cin >> s;
    int count = 0;
    for(int i = 0;i<s.length();i++){
        if(s[i] == '1'){
            count++;
        }
    }
    cout << count << endl;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main() 
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
    int n;
    cin>>n;
    multiset<string> s;
    string temp;
    for(int i=0;i<n;i++)
    {
        cin>>temp;
        sort(temp.begin(),temp.end());
        s.insert(temp);
    }
    ll ans=1, fans=0;
    auto it3 = s.end();
    it3--;
    for(auto it=s.begin();it!=it3;it++)
    {
        auto it2 = it;
        it2++;
        if(*it==*(it2))
        {
            ans++;
        }
        else
        {
            fans += (ans)*(ans-1)/2;
            ans = 1;
            
        }
    }
    cout<<fans+(ans)*(ans-1)/2;
    return 0;
}











Measured memory_bytes: 9600
import numpy as np
import sys

count=0
N=int(sys.stdin.readline().rstrip())
P=[int(i) for i in sys.stdin.readline().split()]
minval=np.max(P)
for i in range(0,N):
  if minval>=P[i]:
    minval=P[i]
    count+=1
print(count)

Measured memory_bytes: 34568
#include<iostream>
#include<set>
#include<vector>
#include<cmath>
#include<complex>
#include<string>
#include<algorithm>

using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define pb push_back

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vvi;


int main(void)
{
  int n,m,c,ans = 0;
	ll x = 0;
	int a[21][21];
	int b[21];

  cin >> n >> m >> c;
	rep(i,m) cin >> b[i];
	rep(i,n){
		x = c;
		rep(j,m){
			cin >> a[i][j];
			x += a[i][j]*b[j];
		}
		if(x>0) ans++;
	}

  cout << ans << endl;
  return 0;
}


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



int main(){
        ll x,y,a,b,c;
        cin >> x >> y >> a >> b >> c;
        vector<ll> p(a),q(b),r(c);
        rep(i,a) cin >> p[i];
        rep(i,b) cin >> q[i];
        rep(i,c) cin >> r[i];
        sort(p.begin(),p.end(),greater<ll>());
        sort(q.begin(),q.end(),greater<ll>());
        sort(r.begin(),r.end(),greater<ll>());
        while(p.size() > x) p.pop_back();
        while(q.size() > y) q.pop_back();

        //rep(i,x) cout << p[i] << " ";
        //rep(i,y) cout << q[i] << " ";

        ll ans = 0;
        ll cnt = x + y ;
        
        int i =0,j = 0,k = 0;
        while(cnt > 0){
            if(i < x && j < y && k < c){
                if(p[i] >= q[j] && p[i] >= r[k]){
                        ans += p[i];
                        i++;
                }
                else if(q[j] >= p[i] && q[j] >= r[k]){
                        ans += q[j];
                        j++;
                }
                 else if(r[k] >= p[i] && q[j] <= r[k]){
                       ans += r[k];
                        k++;
                }
            }else if(i < x && j < y){
                    if(p[i] <= q[j]){
                            ans += q[j];
                            j ++;
                    }
                    else{
                            ans += p[i];
                            i ++;
                    }
            }else if(i < x && k < c){
                    if(p[i] <= r[k]){
                            ans += r[k];
                            k++;
                    }else{
                            ans += p[i];
                            i ++;
                    }
            }else if(j < y && k < c){
                    if(q[j] <= r[k]){
                            ans += r[k];
                            k++;
                    }else{
                            ans += q[j];
                            j ++;
                    }
            }else if(i < x){
                    ans += p[i];
                    i ++;
            }else if(j < y){
                    ans += q[j];
                    j++;
            }else if(k < c){
                    ans += r[k];
                    k ++;
            }
        -- cnt;
        //cout << cnt << endl;
        //cout << ans << endl;
        }

        cout << ans << endl;



        return 0;
}






Measured memory_bytes: 2560
n = int(input())
a = list(map(int, input().split()))

c1 = 0
sum = 0
for i in range(n):
    sum += a[i]
    if i % 2 == 1:
        if sum <= 0:
            c1 += 1 - sum
            sum = 1
    else:
        if sum >= 0:
            c1 += 1 + sum
            sum = -1

c2 = 0
sum = 0
for i in range(n):
    sum += a[i]
    if i % 2 == 1:
        if sum >= 0:
            c2 += 1 + sum
            sum = -1
    else:
        if sum <= 0:
            c2 += 1 - sum
            sum = 1

print(min(c1, c2))

Measured memory_bytes: 14468
N, M, X, Y = map(int, input().split())
x = sorted(list(map(int, input().split())), reverse = True)
y = sorted(list(map(int, input().split())))

if X < x[0] < y[0] <= Y and (not X in y) and (not Y in x):
  print("No War")
else:
  print("War")  

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

abl = []

for _ in range(n):
    a,b = map(int,input().split())
    abl.append((a+b, a, b))

abl = sorted(abl, reverse=True)

ans = 0
for i in range(n):
    if i % 2 == 0:
        ans += abl[i][1]
    else:
        ans -= abl[i][2]

print(ans)




Measured memory_bytes: 62168
use std::io;

fn main() {
    let mut input = String::new();
    io::stdin().read_line(&mut input).unwrap();
    let days: i32 = match input.trim() {
        "SUN" => 7,
        "MON" => 6,
        "TUE" => 5,
        "WED" => 4,
        "THU" => 3,
        "FRI" => 2,
        "SAT" => 1,
        _ => 0,
    };
    println!("{}", days);
}


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

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

#define pb push_back
#define rep(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, n) for(int i = a; i < (n); i++)
#define mod (ll)(1e9+7)
#define int ll

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

ll n, a[50];

int solve (int i, int m) {
  if (m == 0) return 1;
  if (i >= n) return 0;
  ll res = solve(i + 1, m) || solve(i + 1, m - a[i]);
  return res;
}

signed main() {
	ll q, m;
  cin >> n;
  rep(i, n) cin >> a[i];
  cin >> q;
  rep(i, q) {
    cin >> m;
    if (solve(0, m)) cout << "yes" << endl;
    else cout << "no" << endl;
  }

  return 0;
}


Measured memory_bytes: 3220
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long n,a,b;
	cin>>n>>a>>b;
	long long A=n%(a+b),B=n/(a+b);
	if(A==0)
	{
		cout<<B*a;
		return 0;
	}
	else if(A>=a)
	{
		cout<<B*a+a;
		return 0;
	}
	else if (A<a)
	{
		cout<<B*a+A;
		return 0;
	}
 } 

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

int main(void) {
    int N, K;
    long long A[200000];
    long long prev = 0;
    long long tmp = 0;

    scanf("%d %d", &N, &K);
    for(int i = 0; i < N; i++) {
        scanf("%lld", &A[i]);
    }

    for(int i = K + 1; i <= N; i++) {
        if( A[i - 1] > A[i - (K + 1)] ) {
            printf("Yes\n");
        }
        else {
            printf("No\n");
        }
    }

    return 0;
}


Measured memory_bytes: 3224
#include<iostream>
int64_t N,P,p,i,r,v,m[1<<20];std::string S;main(){std::cin>>N>>P>>S;if(10%P)for(*m=p=1;N--;r+=m[v=(v+(S[N]-48)*(p=(p*10)%P))%P]++);else for(;i<N;r+=(S[i++]-8)%P?0:i);std::cout<<r;}

Measured memory_bytes: 644
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<cmath>
#include<queue>
#include<stack>
#include<list>

#define endl "\n"
using namespace std;
using ll = long long;
const ll MOD = 1e9+7;

int main(){
    int n,q;
    cin>>n>>q;
    ll a[n],x[q];
    for(int i=0;i<n;i++) cin>>a[i];
    for(int i=0;i<q;i++) cin>>x[i];
    
    for(int i=0;i<q;i++){
        int right = 0;
        ll ans = 0;
        ll sum = 0;
        for(int left = 0;left < n;left++){
            while(right < n && sum + a[right] <= x[i]){
                sum += a[right];
                right++;
            }
            ans += right - left;
            if(left != right) sum -= a[left];
            else right++;
        }
        cout<<ans<<endl;
    }
}


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

void dfs(int cur,int pre,vector<vector<int>> &T,vector<int> &cnt){
    if(pre != -1){
        cnt[cur] += cnt[pre];
    }

    for(auto a : T[cur]){
        if(a == pre) continue;
        dfs(a,cur,T,cnt);
    }
}

int main(){
    int N,Q;
    cin>>N>>Q;
    vector<vector<int>> T(N);

    for(int i=0; i<N-1; i++){
        int a,b;
        cin>>a>>b;
        a--,b--;
        T[a].push_back(b);
        T[b].push_back(a);
    }

    vector<int> cnt(N,0);

    for(int i=0; i<Q; i++){
        int p,x;
        cin>>p>>x;
        p--;
        cnt[p] += x;
    }

    dfs(0,-1,T,cnt);

    for(int i=0; i<N; i++){
        cout<<cnt[i]<<" ";
    }

    cout<<endl;

    return 0;
}

Measured memory_bytes: 26624
package main

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

func main() {
	var n int
	fmt.Scan(&n)
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	as := make([]int, n)
	for i := range as {
		sc.Scan()
		as[i], _ = strconv.Atoi(sc.Text())
	}
	var bs int
	for i := 2; i < n; i++ {
		bs ^= as[i]
	}
	a, b := as[0], as[1]
	if a+b < bs || (a+b-bs)%2 == 1 {
		fmt.Println(-1)
		return
	}
	base := (a + b - bs) / 2
	if base&bs > 0 {
		fmt.Println("-1")
		return
	}
	for base < b {
		var sk int
		for i := 0; i <= 50; i++ {
			k := bs & (1 << uint(i))
			if k > 0 {
				sk += k
			}
			if base+sk >= b {
				base += k
				break
			}
		}
		if base+sk < b {
			fmt.Println(-1)
			return
		}
	}
	ans := base - b
	if ans >= 0 && ans < a {
		fmt.Println(ans)
	} else {
		fmt.Println(-1)
	}
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}


Measured memory_bytes: 1848
n,m = map(int,input().split())
c = [0]*(n+1)
for i in range(m):
    a,b = map(int,input().split())
    c[a] += 1
    c[b] += 1

for i in c:
    if i%2:
        print("NO")
        exit()
print("YES")

Measured memory_bytes: 9588
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            //Out.Flush();
            Read();
        }

        static void Solve()
        {
            var N = Sarray()[0];
            var strings = new List<string>();
            for (var i = 0; i < N; ++i)
            {
                var t = ReadLine().ToCharArray();
                Array.Sort(t);
                strings.Add(string.Join("", t));
            }
            strings.Sort(StringComparer.OrdinalIgnoreCase);
            var ans = 0L;
            var nums = 1L;
            for (var i = 0; i < N - 1; ++i)
            {
                if (strings[i] == strings[i + 1])
                {
                    ++nums;
                }
                else
                {
                    ans += nums * (nums - 1) / 2;
                    nums = 1;
                }
            }
            ans += nums * (nums - 1) / 2;
            WriteLine(ans);
        }


        static long Mod = (long)1e9 + 7;
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static public (T1 a, T2 b) Slice<T1, T2>()
        {
            var t = ReadLine().Split();
            return (
            (T1)Convert.ChangeType(t[0], typeof(T1)),
            (T2)Convert.ChangeType(t[1], typeof(T2)));
        }
        static public (T a, T b) Slice2<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)));
        }
        static public (T a, T b, T c) Slice3<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)));
        }
    }
}

Measured memory_bytes: 51280
#include <bits/stdc++.h>
#define MAX 10001
using namespace std;
int ata[MAX], n, q, a, b, c;

void build(){
    for(int i=0;MAX>i;i++){
        ata[i]=i;
    }
}

int find_set(int v){
    if(v==ata[v]){
        return v;
    }
    return ata[v]=find_set(ata[v]);
}

void union_set(int b, int c){
    b=find_set(b);  c=find_set(c);
    if(b!=c){
        ata[c]=b;
    }
}

int main(){
    ios::sync_with_stdio(false);    cin.tie(NULL);  cout.tie(NULL);
    build();    cin >> n >> q;
    for(int i=0;q>i;i++){
        cin >> a >> b >> c;
        if(a){
            cout << (find_set(b)!=find_set(c) ? 0 : 1) << "\n";     continue;
        }
        union_set(b, c);
    }
}


Measured memory_bytes: 3280
#include <iostream>
#include <cstdio>
#include <string>
#include <cmath>
#include <cctype>
#include <cstdlib>
#include <stack>
#include <queue>
#include <vector>
#include <algorithm>
#include <list>
#include<map>
#include<set>
using namespace std;

int euqrid(int i, int j) {
    if (i > j) swap(i, j);
    while (j % i > 0) {
        j %= i;
        swap(j, i);
    }
    return i;
}

int main() {
    int n, a, m;
    cin >> n;
    vector<int> v;
    for (int i = 0; i < n; i++) {
        cin >> a;
        v.push_back(a);
    }
    m = v[0];
    for (int i = 1; i < n ;i++) {
        m = euqrid(m, v[i]);
    }
    cout << m << endl;
}



Measured memory_bytes: 892
#include <stdio.h>
int n;
int reverse(int x)
{
	int cx=0;
	while (x)
	{
		cx=cx*10+x%10;
		x/=10;
	}
	return cx;
}
int main()
{
	scanf("%d",&n);
	if (n==reverse(n))
	{
		puts("Yes");
	}
	else
	{
		puts("No");
	}
	return 0;
}

Measured memory_bytes: 128
N,M,C = map(int, input().split())

B = [int(i) for i in input().split()]

ans = 0

for n in range(N):
    c = C
    A = [int(i) for i in input().split()]
    for m in range(M):
        c += B[m]*A[m]
    if c > 0:
        ans += 1

print(ans)

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

int main()
{	

	int s,k;
	cin>>k>>s;
	int ans=0;
	for(int x=0;x<=k;x++)
	{
		for(int y=0;y<=k;y++)
	{
		int z=s-x-y;
		if(z>=0 and z<=k)ans++;
	}
	}
	cout<<ans;
}

Measured memory_bytes: 256
def count(k):
    ret=0
    while k%2==0:
        k//=2
        ret+=1
    return ret
def gcd(x,y):
    if x<y:
        x,y=y,x
    if y==0:
        return x
    return gcd(y,x%y)
def lcm(x,y):
    return x*y//gcd(x,y)

def main():
    n,m=map(int,input().split())
    A=tuple(map(int,input().split()))
    cnt=count(A[0])
    for a in A:
        if cnt!=count(a):
            return 0
    l=A[0]//2
    for a in A:
        l=lcm(l,a//2)
    if m<l:
        return 0
    return (m-l)//(l*2)+1
    
if __name__=='__main__':
    print(main())

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

#define int long long 
#define pb push_back
#define S second
#define F first
#define f(i,n) for(int i=0;i<n;i++)
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define vi vector<int>
#define pii pair<int,int>

int a[11][1003];
int b[11][1003];


int h,w,k;

int go(int v)
{
    memset(b,0,sizeof(b));
    
    int id = 0;
    
    f(i,h)
    {
      f(j,w) b[id][j]+=a[i+1][j+1];
      if(((1LL<<i) & v) > 0) id++;   
    }
    
    id++;
    
    //we have id arrays of size w
    int res = 0;
    vi sz(id,0);
    
    f(i,w)
    {
        f(j,id) sz[j]+=b[j][i];
     
        
        
        f(j,id) if(sz[j] > k)
        {
            res++;
            f(kk,id) sz[kk] = b[kk][i];
            break;
        }
        
        
        f(j,id) if(b[j][i] > k) return 1e9;        
    }
    
    return res;
}

void solve()
{
    cin >> h >> w >> k;
    
    string s[h];
    
    f(i,h) cin >> s[i];
    f(i,h) f(j,w) a[i+1][j+1] = (s[i][j] == '1');
    
    int res = 1e9; 
    
    for(int i=0;i<(1LL<<(h-1));i++) 
    {
        int kk = __builtin_popcount(i);
        res = min(res, kk + go(i));
    }
    
    cout << res;
}

signed main()
{
    fast;
    
    int t = 1;
    
//    cin >> t;
    
    while(t--)
        
    solve();
}

Measured memory_bytes: 384
#include <stdio.h>

int main(void){
  int a[3];
  int temp;
  scanf("%d %d %d", &a[0], &a[1], &a[2]);
  for(int i = 0; i < 3; i++){
    for(int j = i + 1; j < 3; j++){
      if(a[i] < a[j]){
	temp = a[i];
	a[i] = a[j];
	a[j] = temp;
      }
    }
  }

  printf("%d\n", a[1] + a[2]);

  return 0;
}

Measured memory_bytes: 128