akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")

#include <bits/stdc++.h>

// 汎用マクロ
#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for (long long i=0, i##_len=(n); i<i##_len; i++)
#define RANGE(i,is,ie) for (long long i=(is), i##_end=(ie); i<=i##_end; i++)
#define DSRNG(i,is,ie) for (long long i=(is), i##_end=(ie); i>=i##_end; i--)
#define UNIQUE(v) { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); }
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return true;} return false; }
template<class T> bool chmin(T &a, const T &b) {if (a > b) {a = b; return true;} return false; }
#define INF 0x7FFFFFFF
#define LINF 0x7FFFFFFFFFFFFFFFLL
#define Yes(q) (q ? "Yes" : "No")
#define YES(q) (q ? "YES" : "NO")
#define DUMP(q) cerr << "[DEBUG] " #q ": " << (q) << " at " __FILE__ ":" << __LINE__ << endl
#define DUMPALL(q) { cerr << "[DEBUG] " #q ": ["; REP(dumpall_i, (q).size()) { cerr << q[dumpall_i] << (dumpall_i == (q).size() - 1 ? "" : ", "); } cerr << "] at " __FILE__ ":" << __LINE__ << endl; }
template<class T> T gcd(const T &a, const T &b) { return a < b ? gcd(b, a) : b ? gcd(b, a % b) : a; }
template<class T> T lcm(const T &a, const T &b) { return a / gcd(a, b) * b; }

// gcc拡張マクロ
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll

// エイリアス
using  ll = long long;
using ull = unsigned long long;
using  ld = long double;
using namespace std;

// モジュール


// 処理内容
int main() {
    
    ll n, a, b, c, d; cin >> n >> a >> b >> c >> d;
    string s; ll sl; cin >> s; sl = s.size();
    a--; b--; c--; d--; // 0-indexed

    vector<bool> dpa(sl, false);
    vector<bool> dpb(sl, false);
    dpb[b] = true;
    REP(i, sl) {
        if (!dpb[i]) continue;
        if (i+1 < sl) if (s[i+1] != '#') dpb[i+1] = true;
        if (i+2 < sl) if (s[i+2] != '#') dpb[i+2] = true;
    }
    dpa[a] = true;
    REP(i, sl) {
        if (!dpa[i]) continue;
        if (i+1 < sl) if (s[i+1] != '#') dpa[i+1] = true;
        if (i+2 < sl) if (s[i+2] != '#') dpa[i+2] = true;
    }

    if (c < d) {
        cout << Yes(dpa[c] && dpb[d]) << endl;
    } else {

        bool can_jumpover = false;
        RANGE(i, b-1, d-1) {
            if (s[i] == s[i+1] && s[i+1] == s[i+2] && s[i] == '.') {
                can_jumpover = true;
                break;
            }
        }
        cout << Yes(dpa[c] && dpb[d] && can_jumpover) << endl;

    }
    
}

Measured memory_bytes: 640
from itertools import product

S = list(input())
N = len(S)

ans = 0
for adds in product([0, 1], repeat=N - 1):
    eqn = [""] * (2 * N - 1)
    eqn[::2] = S[:]
    for i, has_add in enumerate(adds):
        if has_add:
            eqn[2 * i + 1] = "+"
        else:
            eqn[2 * i + 1] = ""
    ans += eval("".join(eqn))
print(ans)


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

#define YES(condition) if(condition) cout << "YES" << endl; else cout << "NO" << endl
#define Yes(condition) if(condition) cout << "Yes" << endl; else cout << "No" << endl
#define POSS(condition) if(condition) cout << "POSSIBLE" << endl; else cout << "IMPOSSIBLE" << endl
#define Poss(condition) if(condition)cout << "Possible" << endl; else cout << "Impossible" << endl
#define First(condition) if(condition)cout << "First" << endl; else cout << "Second" << endl
#define negative(condition, num) if(condition)cout << -1 << endl; else cout << num << endl
int character_count(string text, char character){ int ans = 0; for(int i = 0; i < text.size(); i++){ ans += (text[i] == character); } return ans; }
long power(long base, long exponent, long module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ long root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position move_pattern[4] = {{-1, 0}, {0, 1}, {1, 0}, {0, -1}};
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++){ ans += to_string(*i) + " "; } ans.pop_back(); cout << ans << endl; }
long gcd(long a, long b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }}
#define mod long(1e9 + 7)
#define bitcount(n) __builtin_popcount(n)

int main(){
    int N, M, X;
    cin >> N >> M >> X;
    int A[M];
    for(int i = 0; i < M; i++){
        cin >> A[i];
    }
    cout << min(int(lower_bound(A, A + M, X) - A), M - int(lower_bound(A, A + M, X) - A)) << endl;
}


Measured memory_bytes: 256
/*input
4
1 2 3 4
*/

#include <bits/stdc++.h>

using namespace std;

typedef unsigned long long int ull;
typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb push_back
#define mp make_pair
#define pq priority_queue
#define fi first
#define se second
#define INF    1<<30
#define NEGINF -(1<<30)
#define LINF   1<<60
#define EPS 1e-10
#define PI 2 * acos(0)
#define NULO -1
#define endl '\n'

const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}

int cmp(double x, double y = 0, double tol = EPS){ return (x <= y + tol) ? (x + tol < y) ? -1 : 0 : 1; }


ll esq[212345], dir[212345];

int main(){
	ll n, a, d=0, e=0, md;
	
	scanf("%lld", &n);

	rep(i, 0, n){
		scanf("%lld", &a);
		if(i==0) md = a;
		else{
			if(n&1){
				//printf("impar\n");
				if(i&1){
					dir[d] = a;
					d++;
					//printf("i impar\n");
					
				}else{
					//printf("i par\n");
					esq[e] = a;
					e++;
				}

			}else{
				if(i&1){
					esq[e] = a;
					e++;
				}else{
					dir[d] = a;
					d++;
				}
			}
		}
	}

	per(i, 0, e){
		printf("%lld ", esq[i]);
	}
	printf("%lld", md);
	rep(i, 0, d){
		printf(" %lld", dir[i]);
	}
	puts("");



return 0;
}

Measured memory_bytes: 3712
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque, OrderedDict
from copy import deepcopy
from fractions import gcd
from functools import lru_cache, reduce
from math import ceil, floor
from sys import setrecursionlimit

import heapq
import itertools
import operator


# globals
inf = float('inf')
N, K = [], []
C = []


def set_inputs():
    global N, K, C
    while True:
        n, k = get_li()
        if n == k == 0:
            break
        N.append(n)
        K.append(k)
        c = get_data(k, [int])
        C.append(c)
    return


def sgn(n):
    if n == 0:
        return 0
    if n > 0:
        return 1
    return -1


def main():
    setrecursionlimit(100000)
    set_inputs()
    # ----------MAIN----------
    for n, k, c in zip(N, K, C):
        c.sort()
        ans = 0
        if c[0] == 0:
            tmp = 1
            for v1, v2 in zip(c[1:], c[2:]):
                if v2 - v1 == 1:
                    tmp += 1 * sgn(tmp)
                    if abs(tmp) > abs(ans):
                        ans = tmp
                elif v2 - v1 == 2:
                    if tmp > 0:
                        tmp = -tmp - 2
                    else:
                        tmp = -3
                else:
                    tmp = 1
            if ans > 0:
                ans += 1
            ans = abs(ans)
        else:
            tmp = 1
            for v1, v2 in zip(c, c[1:]):
                if v2 - v1 == 1:
                    tmp += 1
                    ans = max(ans, tmp)
                else:
                    tmp = 1
        print(ans)
    return


def get_int():
    return int(input())


def get_float():
    return float(input())


def get_str():
    return input().strip()


def get_li():
    return [int(i) for i in input().split()]


def get_lf():
    return [float(f) for f in input().split()]


def get_lc():
    return list(input().strip())


def get_data(n, types, sep=None):
    if len(types) == 1:
        return [types[0](input()) for _ in range(n)]
    return list(zip(*(
        [t(x) for t, x in zip(types, input().split(sep=sep))]
        for _ in range(n)
    )))


if __name__ == '__main__':
    main()



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

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

lis = make_divisors(n)

a = lis.pop()
b = n//a
ans = a+b-2

print(ans)


Measured memory_bytes: 3268
#include<iostream>
#include <string>

using namespace std;

//state dp[position][activity]
//transition dp[position][activity] = max(dp[position - 1][another activity]) + value

const int N = 1e5 + 5;
int dp[N][3];

int main()
{
	int n;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < 3; j++)
		{
			int v;
			cin >> v;
			if (i)
				for (int k = 0; k < 3; k++)
				{
					if (k == j)
						continue;
					dp[i][j] = max(dp[i][j], dp[i - 1][k]);
				}
			dp[i][j] += v;
		}
	}
	cout << max(dp[n - 1][0], max(dp[n - 1][1], dp[n - 1][2]));
	return 0;
}


Measured memory_bytes: 1408
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int w = sc.nextInt();
        int[] W = new int[n];
        long[] V = new long[n];
        for(int i = 0; i < n; i++) {
            W[i] = Integer.parseInt(sc.next());
            V[i] = Integer.parseInt(sc.next());
        }
        long[][] dp = new long[n + 10][w + 10];
        for(int i = 0; i < n ; i++) {
            for(int j = 0; j <= w; j++) {
                if(j - W[i] >= 0) {
                    dp[i + 1][j] =
                            Math.max(dp[i + 1][j], Math.max(dp[i][j - W[i]] + V[i], dp[i][j]));
                } else {
                    dp[i + 1][j] = Math.max(dp[i + 1][j], dp[i][j]);
                }
            }
        }
        System.out.println(dp[n][w]);
    }
}


Measured memory_bytes: 124500
#include <iostream>
#include <iomanip>
#include <string>
#include <map>
#include <unordered_map>
#include <cmath>
#include <algorithm>

typedef long long ll;
typedef long double ld;

using namespace std;
int main()
{
  ll n, a[200010], cnt = 0;
  cin >> n;
  for (int i = 0; i < n; ++i) cin >> a[i];
  for (int i = 0; i < n; ++i) if (cnt + 1 == a[i]) ++cnt;
  if (cnt == 0) cout << "-1";
  else cout << n - cnt;
}


Measured memory_bytes: 5200
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
typedef pair<int, int> P_i;
typedef pair<double,double> P_d;
#define rep(i,n) for(int i=0;i<(n);++i)
#define alrep(i,j,n) for(int i=0;i<(n);++i)for(int j=i+1;j<(n);++j)
#define Yes cout << "Yes" << endl;
#define No cout << "No" << endl;int ans=0;
#define answer cout << ans << endl;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const int MOD=1e9+7;
const long long INF = 1LL << 60;

signed main(){
  int n; cin >> n;
  vector<int> a(n);
  rep(i,n){
    cin >> a[i];
  }
  vector<int> list;
  for(auto e:a){
    auto it=lower_bound(list.begin(),list.end(),e);
    if(it==list.end()) list.push_back(e);
    else *it=e;
  }
  cout << list.size() << endl;
  return 0;
}



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

int a[200001];

int main(){
	int n;
	cin >> n;
	int mx = -1;
	for (int i = 1; i <= n; i++){
		cin >> a[i];
		mx = max(a[i], mx);
	}
	int num = 0;
	int mx2 = -1;
	for (int i = 1; i <= n; i++){
		if (a[i] == mx) num++;
		else {
			mx2 = max(a[i], mx2);
		}
	}
	for (int i = 1; i <= n; i++){
		if (a[i] == mx && num == 1){
			cout << mx2 << endl;
		}
		else cout << mx << endl;
	}
	return 0;
} 

Measured memory_bytes: 2432
n = int(input())
accum = 0
a = [0 for i in range(n)]
b = [0 for i in range(n)]

for i in range(n):
    ta,tb = map(int,input().split())
    a[i] = ta
    b[i] = tb

a.reverse()
b.reverse()


for i in range(n):
    if (a[i]+accum)%b[i] == 0:
        continue
    else:
        accum+=b[i]-(a[i]+accum)%b[i]

print(accum)

Measured memory_bytes: 11048
#include <stdio.h>
#define N 200000
 
typedef struct {
  int time;
  char name[20];
} node;
 
node queue[N];
int start = 0;
int end = 0;
 
void enqueue( node x )
{
  queue[end++] = x;
  if ( end == N )
    end = 0;
}
 
node dequeue()
{
  int tmp = start++;
  if ( start == N )
    start = 0;
  return queue[tmp];
}
 
int emptyp()
{
  return start == end;
}
 
int main( void )
{
  int n, q, i;
  scanf( "%d", &n );
  scanf( "%d", &q );
 
  node a;
  for ( i = 0; i < n; i++ ) {
    scanf( "%s", a.name );
    scanf( "%d", &a.time );
    enqueue( a );
  }
 
  int time = 0;
 
  while( !emptyp() ) {
    a = dequeue();
    if ( a.time > q ) {
      a.time -= q;
      time += q;
      enqueue( a );
    } else {
      time += a.time;
      printf( "%s %d\n", a.name, time );
    }
  }
 
  return 0;
}


Measured memory_bytes: 6184
#include<bits/stdc++.h>
#define ll int
using namespace std;

int main(){
    ll n,k;
    cin>>n>>k;
    ll a[n+5],b[n+5];
    for(ll i=0;i<n;i++){
        cin>>a[i];
    }
    b[0]=0;
    for(ll i=1;i<n;i++){
        b[i]=b[i-1]+abs(a[i]-a[i-1]);
        for(ll j=max(0,i-k);j<i-1;j++){
            b[i]=min(b[i],b[j]+abs(a[i]-a[j]));
        }
    }
    cout<<b[n-1]<<endl;
}

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

using namespace std;

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

const int N = 10 + 10;

int b[N][N];

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	set <int> a;
	for (int i = 0; i <= 10000; ++i)
		a.insert(i * i);
	int n, d;
	cin >> n >> d;
	int ans = 0;
	for (int i = 0; i < n; ++i)
	{
		for (int j = 0; j < d; ++j)
			cin >> b[i][j];
		for (int j = 0; j < i; ++j)
		{
			int sum = 0;
			for (int k = 0; k < d; ++k)
				sum += (b[i][k] - b[j][k]) * (b[i][k] - b[j][k]);
			if (a.find(sum) != a.end())
				++ans;
		}
	}
	cout << ans;
}

Measured memory_bytes: 768
//------------------------------------------------------------------------------MANAS UNIYAL---------------------------------------------------------
//																				NEVER GIVE UP
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);	cin.tie(NULL);	cout.tie(NULL);
#define ll long long
#define pb push_back
#define fi first
#define se second
#define pii pair<ll,ll>
#define INF 0x3f3f3f3f
#define mod 100000007
#define testcases() ll t; cin>>t; while(t--)
#define debug1(x) cout<<#x<<" "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<"\n";
#define rep(i,start,end) for(ll i=start;i<end;i++)
 
//----------------------------------------------------------------------------------------------------------------------------------------------------

int main()
{
	fast;
	int n;
    cin>>n;
	string str;
	unordered_map<string, int> mp;
	for(int i=0;i<n;i++){
		cin>>str;
		if(mp.find(str)==mp.end()){
			mp[str]=1;
		} else {
			mp[str]++;
		}
	}
	int maxx = -INF;
	vector<string> ans;
	for(auto it: mp){
		maxx = max(maxx, it.se);
	}
	for(auto it: mp){
		if(it.se == maxx)
			ans.pb(it.fi);
	}
	sort(ans.begin(),ans.end());
	for(string it: ans){
		cout<<it<<"\n";
	}
	return 0;
}

Measured memory_bytes: 25284
#include <string>
#include <cstdio>
#include <unordered_map>
#include <deque>
#include <algorithm>
using namespace std;
typedef int key;

void main2(int n){
	unordered_map<key,deque<pair<key,long long>>>m;
	for(;n;n--){
		int s1,s2,d;
		scanf("%d%d%d",&s1,&s2,&d);
		m[s1].emplace_back(s2,d);
		m[s2].emplace_back(s1,-d);
	}
	for(;!m.empty();){
		auto s=m.begin()->first;
		deque<pair<key,long long>>st={{s,0}};
		unordered_map<key,long long>memo={{s,0}};
		for(;!st.empty();){
			auto p=*st.rbegin();st.pop_back();
			auto cur=p.first;long long d=p.second;
			for(auto &e:m[cur]){
				if(memo.find(e.first)==memo.end()){
					st.emplace_back(e.first,d+e.second);
					memo[e.first]=d+e.second;
				}else if(memo[e.first]!=d+e.second){
					puts("No");
					return;
				}
			}
		}
		for(auto &e:memo)m.erase(m.find(e.first));
	}
	puts("Yes");
}
int main(){int n;for(;~scanf("%d%d",&n,&n)/*&&n*/;)main2(n);}

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

int main(){
	int n, c=0;
	cin >> n;
	for(int i=1; ; i++){
		c += i;
		if(n<=c){
			string s(i, ')');
			s += string(i, '(');
			swap(s[i-(c-n)], s[i]);
			cout << s << endl;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 3300
#include <stdio.h>

int main()
{
    int i;
    int x,y;
    int temp = 0;
    
    for(i=0;i<10000;i++)
    {
        scanf("%d%d",&x,&y);
        
        if((x==0)&&(y==0))
        {
            return 0;
        }
        else
        {
            if(x>=y)
            {
                temp = x;
                x = y;
                y= temp;
                
            }
            printf("%d %d\n",x,y);
        }
    }
    return 0;
}

Measured memory_bytes: 600
import math

n = int(input())

x1 = math.floor(n // 1.08)
x2 = x1 + 1

if math.floor(x1 * 1.08) == n:
  print(x1)
elif math.floor(x2 * 1.08) == n:
  print(x2)
else:
  print(':(')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <unistd.h>
 
using namespace std;
 
typedef long long ll;
typedef pair<ll,ll> P;
 
long long int INF = 3e18;
double Pi = 3.1415926535897932384626;
 
vector<ll> G[550010];
//vector<P> tree[500010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop
 
int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "DRUL";
//ll bit[500005];
//↓,→,↑,←
 
 
#define p(x) cout<<x<<"\n";
#define el cout<<endl;
#define pe(x) cout<<(x)<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<(x);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define CLEAR(a) a = decltype(a)(); 
 
 
ll mod = 998244353;
 
ll rui(ll number1,ll number2){
 
    if(number2 == 0){
        return 1;
    }else{
        ll number3 = rui(number1,number2 / 2);
        number3 *= number3;
        number3 %= mod;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod;
        }
        return number3;
    }
}
ll gcd(ll number1,ll number2){
 
    if(number1 > number2){
        swap(number1,number2);
    }
    if(number1 == 0 || number1 == number2){
        return number2;
    }else{
        return gcd(number2 % number1,number1);
    }
}
void YES(bool condition){
 
    if(condition){
        p("YES");
    }else{
        p("NO");
    }
    return;
}
void Yes(bool condition){
 
    if(condition){
        p("Yes");
    }else{
        p("No");
    }
    return;
}
 
/*
ll fact[800005],rfact[800005];
 
void c3_init(){
    fact[0] = rfact[0] = 1;
    for(ll i=1; i<=800000; i++){
        fact[i] = (fact[i-1]*i) % mod;
    }
    rfact[800000] = rui(fact[800000],mod - 2);
    for(ll i=800000; i>=1; i--){
       rfact[i-1] = rfact[i] * i;
       rfact[i-1] %= mod;
    }
    return;}
ll c3(ll n,ll r){
    return (((fact[n] * rfact[r]) % mod ) * rfact[n-r]) % mod;}
*/
 
ll n,m,num,sum,a,b,c,d,e,g,h,w,i,j,q,r,l;
ll k,ans;
ll x[500005],y[500005],z[500005];
bool used[500005];
char s[500005];

int main(){
    cin >> n;
    for(int i=0;i<n;i++){
    	cin >> x[i];
    }
    sort(x,x+n);
    for(int i=0;i<n;i++){
    	// maximum : = x[i];
    	for(int j=0;j<i-1;j++){
    		y[x[j] + x[i-1]] ++;
    	}
    	for(int j=x[i]+1;j<=2000;j++){
    		ans += y[j];
       	}
    }
    p(ans);
    return 0;
}











Measured memory_bytes: 17664
#include <bits/stdc++.h>
#define int long long
#define INT_MAX INT64_MAX
#define INT_MIN INT64_MIN
#define PI 3.14159265358979323846
#define CLK clock_t clk = clock();//Start of main
#define OCLK cerr << "Time (in ms): " << (double)(clock() - clk) * 1000.0 / CLOCKS_PER_SEC << '\n';//End of main
#define MOD 1000000007
/* DEFINE cout */
#define pln cout << "===============================\n"
#define on cout<<"\n"
#define os cout<<" "
#define o2(a,b) cout<<a<<" "<<b
#define o(a) cout << a
#define bitcount __builtin_popcount
/* DEFINE cout */
#define endl "\n"
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);//fastio
using namespace std;
struct hash_pair { // use pair as key in unordered_map<pair<int,int>,int,hash_pair>;
    template <class T1, class T2>
    size_t operator()(const pair<T1, T2>& p) const
    {
        auto hash1 = hash<T1>{}(p.first);
        auto hash2 = hash<T2>{}(p.second);
        return hash1 ^ hash2;
    }
};
bool prime[10000001];
int P=MOD-2;
int factorial[10000001]={0};
int powerFunction(int x,int y){
    int res = 1;
    int p = MOD;
    x = x % p;
    while (y > 0){
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
void sieveFunction(int maxLimit){
    memset(prime, true, sizeof(prime));
    prime[0] = prime[1]=false;
    for(int i=2; maxLimit >= i ; i++){
        if(prime[i]){
            for(int j=2*i ; maxLimit >= j ; j+=i)
                prime[j]=false;
        }
    }
}
void factorialFunction(int maxLimit){
    factorial[0]=1;
    for(int i=1 ; i <= maxLimit ; i++)
        factorial[i]=(factorial[i-1]*i)%MOD;
    return;
}
int gcd(int a, int b){
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
signed main(){
    int n;
    cin >> n;
    int arr[n];
    int xr = 0;
    for(int i=0; n>i; i++){
        cin >> arr[i];
        xr ^= arr[i];
    }
    for(int i=0; n>i; i++){
        cout << (arr[i]^xr) << ' ';
    }
    on;
    
}






Measured memory_bytes: 5152
#include<bits/stdc++.h>
#define maxn 410
#define mod 1000000007
using namespace std;
int f[maxn][maxn<<1],m,c[maxn][maxn],n,a[maxn],b[maxn],g[maxn][maxn][maxn];
int vis[maxn];
void upd(int& x,int y){
	if((x+=y)>=mod)x-=mod;
}
int main(){
	scanf("%d",&n),m=n/3;
	for(int i=1;i<=n;++i)scanf("%d",&a[i]);
	for(int i=1;i<=n;++i)scanf("%d",&b[i]);
	g[0][0][0]=f[0][0]=1;
	for(int i=0;i<=m;++i)
		for(int j=0;j<=m*2;++j){
			upd(f[i+1][j],f[i][j]);
			upd(f[i][j+1],1ll*f[i][j]*max(i*2-j,0)%mod);
		}
	for(int i=1;i<=n;++i){
		int cur=i;
		memset(vis,0,sizeof(vis));
		for(int j=1;j<=i;++j)vis[a[j]]++;
		for(int j=1;j<=n;++j){
			if(!vis[b[j]])cur++;
			vis[b[j]]++;
			if(vis[a[i]]==1&&vis[b[j]]==1)c[i][j]=cur;
		}
	}
	for(int i=0;i<=n;++i)
		for(int j=0;j<=n;++j)if(i||j)
			for(int k=0;k<=m;++k){
				g[i][j][k]=(1ll*(i?g[i-1][j][k]:0)+(j?g[i][j-1][k]:0)-(i&&j?g[i-1][j-1][k]:0)+mod)%mod;
				if(i&&j&&k&&c[i][j])g[i][j][k]=(g[i][j][k]+1ll*g[i-1][j-1][k-1]*(n-3*(m-k)-c[i][j]))%mod;
			}
	printf("%d",1ll*(g[n][n][m])*f[m][m*2]%mod);
}

Measured memory_bytes: 266496
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>

using namespace std;

int main(){
	int N;
	cin>>N;
	
	vector<int> x(N),y(N);
	vector<long long int> h(N);
	long long int max_h=0;
	for(int i=0;i<N;i++){
		cin>>x[i]>>y[i]>>h[i];
		max_h=max(max_h,h[i]);
	}

	long long int mx_val=0;
	for(int H=max_h;;H++){
		for(int Cx=0;Cx<=100;Cx++){
			for(int Cy=0;Cy<=100;Cy++){
				bool flg=true;
				for(int i=0;i<N;i++){
					if(h[i]!=max(H-abs(x[i]-Cx)-abs(y[i]-Cy),0)){
						flg=false;
					}
				}
				if(flg){
					cout<<Cx<<" "<<Cy<<" "<<H<<endl;
					return 0;
				}
			}
		}
	}
	return 0;
}

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

int main()
{
	long long lnA,lnB;
	cin >> lnA;
	cin >> lnB;
	if (1 == lnA)
		lnA += 13;
	if (1 == lnB)
		lnB += 13;

	if (lnA > lnB)
		cout << "Alice";
	else if (lnA == lnB)
		cout << "Draw";
	else
		cout << "Bob";

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
const double PI=3.14159265358979323846;
const long long INF = 1LL << 60;

int main() {
	int64_t A, B, N;
	cin >> A >> B >> N;
	int64_t x, y, z;

	if (B <= N+1) {
		std::cout << floor(A*(B-1)/B)-A*floor((B-1)/B) << '\n';
	} else {
		std::cout << floor(A*N/B)-A*floor(N/B) << '\n';
	}
}


Measured memory_bytes: 3780
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
using ll = long long;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const int inf = (1<<30)-1;
const ll INF = (1LL<<60)-1;
const double pi = acos(-1.0);
const double EPS = 1e-10;
template<typename T> bool chmax(T &x, const T &y) {return (x < y)? (x = y, true) : false;};
template<typename T> bool chmin(T &x, const T &y) {return (x > y)? (x = y, true) : false;};

int main(){
    int H, W;
    cin >> H >> W;
    set<pii> s;
    map<int, int> mp;
    rep(i, W){
        s.emplace(i, i);
        mp[0]++;
    }
    rep(i, H){
        int L, R; cin >> L >> R; L--;
        set<pii>::iterator it = s.lower_bound(pii(L, 0));
        int M = -1;
        while(it != s.end() && (*it).first < R){
            pii p = *it;
            chmax(M, p.second);
            int d = p.first-p.second;
            if(--mp[d] == 0) mp.erase(d);
            it = s.erase(it);
        }
        if(M != -1){
            s.emplace(R, M);
            mp[(R == W? inf : R-M)]++;
        }
        int ans = (*mp.begin()).first;
        cout << (ans == inf? -1 : ans+i+1) << endl;
    }
}

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

#define int long long
#define rep(i,l,r) for(int i=(int)(l);i<(int)(r);i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
template<class T>bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,T b){if(a>b){a=b;return 1;}return 0;}

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;

const int inf = 1LL<<60;
const int mod = 1e9 + 7;
const double eps = 1e-9;

/*{
}*/

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

	map<char, int> cnt;
	rep(i, 0, 4){
		cnt[s[i]]++;
	}

	bool ans = true;
	for(auto i : cnt){
		if(i.second != 2) ans = false;	
	}

	cout << (ans ? "Yes" : "No") << endl;

	return 0;
}


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


int A[1000][1000];

int main(){
	int n;
	cin >> n;
	for(int i=0;i<2;i++){
		for(int j=0;j<n;j++){
			cin >> A[i][j];
		}
	}
	
	for(int i=1;i<n;i++){
		A[0][i]+=A[0][i-1];
	}
	
	for(int i=1;i<2;i++){
		for(int j=0;j<n;j++){
			if(j==0) A[i][j]+=A[i-1][j];
			else{
				A[i][j]+=max(A[i-1][j],A[i][j-1]);
			}
		}
	}
	
	cout << A[1][n-1] << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define int long long
#define vec(a,n) vector<int> (a)((n));
#define Vec(a,n) vector<string> (a)((n));
#define twovec(a,n,m) vector<vector<int>> a(n,vector<int>(m,0));
#define Twovec(a,n,m) vector<vector<double>> a(n,vector<double>(m,0));
#define P pair<int,int>
#define All(a) (a).begin(),(a).end()
#define Sort(a) sort(All(a));
#define Reverse(a) reverse(All(a));
#define PQ(n) priority_queue<P,vector<P>,greater<P>> (n)
#define pq(n) priority_queue<int> (n)
#define print(a) cout << (a) << endl
#define printD(a) cout << setprecision(15) << (a) << endl;
using namespace std;
int max_int = 2147483647;
int prime = 998244353;
void Debug(auto a);
double PI = 3.14159265358979;
void input(vector<auto>& a,int n);
int n;


signed main(){
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    int k;
    cin >> n >> k;
    vec(a,n);
    int ans = 0;
    REP(i,n){
        int x;
        cin >> x;
        if(x >= k)ans++;
    }
    print(ans);



    return 0;
}

void Debug(auto a){
    cout << "{ ";
    for(auto b: a){
        cout << b << " ";
    }
    cout << "}" << endl;
}

void input(vector<auto>& a,int n){
    REP(i,n){
        cin >> a[i];
    }
}


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

int main()
{
    int n, m;
    cin >> n >> m;
    int sum = 0;
    while (n != 0){
        sum++;
        n /= m;
    }
    cout << sum << 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;
using ll = long long;
using P = pair<int, int>;

int n;
const int MAX_N = 10;
vector<int> a(MAX_N);

int dfs(int d, int seki) {
  if (d == n) {
    if (seki % 2 == 0)
      return 1;
    else
      return 0;
  }

  int cnt = 0;
  rep(i, 3) { cnt += dfs(d + 1, seki * (a[d] + (-1 + i))); }
  return cnt;
}

int main() {
  cin >> n;
  rep(i, n) cin >> a[i];
  cout << dfs(0, 1) << endl;
  return 0;
}


Measured memory_bytes: 256
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<unordered_map>
#include<array>
#include<map>
#include<bitset>
#include<iomanip>
#include<list>
#include <numeric>
using namespace std;
typedef unsigned long long int ulint;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
#define RE return 0
//ios::sync_with_stdio(false);
//std::cin.tie(0);
//<< setprecision(20)
const int mod=(int)1000000007;
const llint big=(llint)(2.19e16)+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double ena=2.71828182845904523536;
const long double eps=1e-7;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
template <class T> void soun(T& ar)
{sort(ar.begin(),ar.end());ar.erase(unique(ar.begin(),ar.end()),ar.end());}
llint gcd(llint a,llint b){if(a%b==0){return b;}else{return gcd(b,a%b);}}
llint lcm(llint a,llint b){return a/gcd(a,b) *b;}
template<class T,class U> auto LB(T& ve,U in){return lower_bound(ve.begin(),ve.end(),in);}
template<class T,class U> auto UB(T& ve,U in){return upper_bound(ve.begin(),ve.end(),in);}
template<class T,class U> auto LBI(T& ve,U in){return LB(ve,in)-ve.begin();}
template<class T,class U> auto UBI(T& ve,U in){return UB(ve,in)-ve.begin();}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
using pli=pair<llint,int>;
using daic=priority_queue<pli,vector<pli>,greater<pli>>;
int main(void){
	int n;cin>>n;
	llint ans=0;
	//「中心」を考えるためにいろいろします
	llint sl,sr;cin>>sl>>sr;
	llint schu=sl+sr;
	llint maes=sr-sl;
	multiset<llint> hd;
	multiset<llint> mg;
	llint hos=0;
	hd.ins(schu);mg.ins(schu);
	for(int i=1;i<n;i++){
		llint l,r;cin>>l>>r;
		llint chu=l+r;
		llint han=maes+r-l;
		maes=r-l;
		if((*mg.begin()+hos)<chu-han){
			ans+=chu-han-(*mg.begin()+hos);
			llint it=(*mg.begin())+hos;
			mg.era(mg.begin());
			hd.ins(it+hos+han+han);
			hos+=han;
			mg.ins(chu-hos);
			mg.ins(chu-hos);
		}else if((*hd.rbegin()-hos)>chu+han){
			ans+=(*hd.rbegin()-hos)-chu-han;
			llint it=(*hd.rbegin())-hos;
			hd.era(prev(hd.end()));
			mg.ins(it-hos-han-han);
			hos+=han;
			hd.ins(chu+hos);
			hd.ins(chu+hos);
		}else{
			hos+=han;
			hd.ins(chu+hos);
			mg.ins(chu-hos);
		}
		
		
	}
	cout<<ans/2<<endl;
	RE;
}

Measured memory_bytes: 9600
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.Deque;
import java.util.Iterator;

class Parser {
    private static final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    private static final Iterator<String> stringIterator = br.lines().iterator();
    private static final Deque<String> inputs = new ArrayDeque<>();

    void fill() throws IOException {
        if(inputs.isEmpty()){
            if(!stringIterator.hasNext()) throw new IOException();
            inputs.addAll(Arrays.asList(stringIterator.next().split(" ")));
        }
    }

    Integer parseInt() throws IOException {
        fill();
        if(!inputs.isEmpty()) {
            return Integer.parseInt(inputs.pollFirst());
        }
        throw new IOException();
    }

    Double parseDouble() throws IOException {
        fill();
        if(!inputs.isEmpty()) {
            return Double.parseDouble(inputs.pollFirst());
        }
        throw new IOException();
    }

    String parseString() throws IOException {
        fill();
        return inputs.pollFirst();
    }

}

public class Main {


    public static void main(String[] args) throws IOException {
        Parser parser = new Parser();

        int N = parser.parseInt();

        int[] p = new int[N];
        for(int i = 0; i < N; i++){
            p[i] = parser.parseInt() - 1;
        }

        int ans = 0;
        int idx = 0;
        while(idx < N){
            if(p[idx] == idx){
                ans += 1;
                idx += 2;
                continue;
            }
            idx += 1;
        }

        System.out.print(ans);
    }
}


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

void solve(std::istream &in, std::ostream &out);

int main() {
#ifdef LOCAL
  freopen("../IO/e.in", "r", stdin);
//  freopen("../IO/e.out", "w", stdout);
#else
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(nullptr);
  std::cout.tie(nullptr);
#endif
  solve(std::cin, std::cout);
  return 0;
}


template <class D, D INF>
struct Dijkstra {
  vector<D> res;

  template <class E>
  Dijkstra(const vector<vector<E>> &g, int s) {
    int n = (int)g.size();
    res = vector<D>(n, INF);
    using P = pair<D, int>;
    priority_queue<P, vector<P>, greater<P>> q;
    q.push(P(0, s));
    res[s] = 0;
    while (!q.empty()) {
      P p = q.top();
      q.pop();
      if (res[p.second] < p.first) continue;
      for (E e : g[p.second]) {
        if (p.first + e.dist < res[e.to]) {
          res[e.to] = p.first + e.dist;
          q.push(P(res[e.to], e.to));
        }
      }
    }
  }
};

struct edge_t {
  int to;
  int64_t dist;
  edge_t() = default;
  edge_t(int to, int64_t dist) : to(to), dist(dist) {}
};

constexpr int MAX = 55 * 55;
vector<vector<edge_t>> g(52 * MAX);

void solve(std::istream &in, std::ostream &out) {
  int n, m, s;
  in >> n >> m >> s;
  s=min(MAX - 1, s);
  for (int i = 0, u, v, a, b; i < m; ++i) {
    in >> u >> v >> a >> b;
    int ui = u * MAX, vi = v * MAX;
    for (int j = a; j < MAX; ++j) {
      g[ui + j].emplace_back(vi + j - a, b);
      g[vi + j].emplace_back(ui + j - a, b);
    }
  }
  for (int i = 1, c, d; i <= n; ++i) {
    in >> c >> d;
    c = min(MAX - 1, c);
    int ind = i * MAX;
    int mi = ind + MAX - 1;
    for (int j = 0; j < MAX; ++j) {
      g[ind + j].emplace_back(min(mi, ind + j + c), d);
    }
  }
  int st = MAX + s;
  auto res = Dijkstra<int64_t, numeric_limits<int64_t>::max() / 2>(g, st).res;
  for (int i = 2; i <= n; ++i) {
    int id = i * MAX;
    int64_t mn = numeric_limits<int64_t>::max();
    for (int j = id; j < id + MAX; ++j) {
      mn = min(mn, res[j]);
    }
    out << mn << '\n';
  }
}



Measured memory_bytes: 27940
#include<iostream>
#include<string>
using namespace std;
 
int main(){
    string s1,s2;
    cin>>s1;
    cin>>s2;
    int num[2];
    cin>>num[0];
    cin>>num[1];
    string r;
    cin>>r;
  	if(r==s1){
      num[0]--;
    }else if(r==s2){
      num[1]--;
    }
    cout<<num[0]<<" "<<num[1]<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define fsp(x) fixed << setprecision(x)
#define xout cerr
const ll inf = LLONG_MAX;
const long double pi = acosl(-1);
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

//#include <vector>
struct union_find {
    std::vector<long long> parent; // 頂点 i の直接の親
    std::vector<long long> size; // 頂点 i を含む連結成分の頂点数
    long long m; // 連結成分の数

    union_find(long long n) {
        for (long long i = 0; i < n; i++) {
            parent.push_back(i);
            size.push_back(1);
        }
        m = n;
    }

    long long root_of(long long n) {
        if (parent[n] == n) return n;
        return parent[n] = root_of(parent[n]); // パス圧縮
    }

    bool is_united(long long a, long long b) {return (root_of(a) == root_of(b));}

    void unite(long long a, long long b) {
        a = root_of(a); b = root_of(b);
        if (a == b) return;
        m--;
        if (size[a] < size[b]) std::swap(a, b); // マージテク
        size[a] += size[b];
        parent[b] = a;
    }
};

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    //const ll p = 1e9 + 7;
    //const ll p = 998244353;
    
    ll n, k, l;
    cin >> n >> k >> l;
    vector<vector<ll>> v(k, vector<ll>(2)), w(l, vector<ll>(2));
    for (ll i = 0; i < k; i++) {
        cin >> v[i][0] >> v[i][1];
        v[i][0]--; v[i][1]--;
    }
    for (ll i = 0; i < l; i++) {
        cin >> w[i][0] >> w[i][1];
        w[i][0]--; w[i][1]--;
    }
    
    union_find uf1(n), uf2(n);
    for (ll i = 0; i < k; i++) uf1.unite(v[i][0], v[i][1]);
    for (ll i = 0; i < l; i++) uf2.unite(w[i][0], w[i][1]);
    
    vector<vector<ll>> roots(n, vector<ll>(2));
    for (ll i = 0; i < n; i++) {
        roots[i][0] = uf1.root_of(i);
        roots[i][1] = uf2.root_of(i);
    }
    
    map<vector<ll>, ll> mp;
    for (ll i = 0; i < n; i++) mp[roots[i]]++;
    
    vector<ll> ans(n);
    for (ll i = 0; i < n; i++) ans[i] = mp[roots[i]];
    
    for (ll i = 0; i < n - 1; i++) cout << ans[i] << " ";
    cout << ans.back() << endl;
}


Measured memory_bytes: 52212
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
char H[1046527][14];
int getchar(char ch)
{
	if(ch=='A') return 1;
	if(ch=='C') return 2;
	if(ch=='G') return 3;
	if(ch=='T') return 4;
	else return 0;
}
long long getkey(char str[])
{
	long long num=0,p=1,i;
	for(i=0;i<strlen(str);i++)
	{
		num+=p*(getchar(str[i]));
		p*=5;
	}
	return num;
}
int h1(int key){return key%1046527;}
int h2(int key){return 1+(key%(1046527-1));}
int find(char str[])
{
	long long key,i,h;
	key=getkey(str);
	for(i=0;;i++)
	{
		h=(h1(key)+i*h2(key))%1046527;
		if(strcmp(H[h],str)==0) return 1;
		else if(strlen(H[h])==0) return 0;
	}
	return 0;
}
int insert(char str[])
{
	long long key,i,h;
	key=getkey(str);
	for(i=0;;i++)
	{
		h=(h1(key)+i*h2(key))%1046527;
		if(strcmp(H[h],str)==0) return 1;
		else if(strlen(H[h])==0)
		{
			strcpy(H[h],str);
			return 0;
		}
	}
	return 0;
}
int main()
{
	int i,n,h;
	char str[14],com[9];
	for(i=0;i<1046527;i++)
	{
		H[i][0]='\0';
	}
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%s %s",com,str);
		if(com[0]=='i')
		{
			insert(str);
		}else
		{
			if(find(str))
			printf("yes\n");
			else{
				printf("no\n");
			}
		}
	}
	return 0;
}

Measured memory_bytes: 17416
#include <iostream>
using namespace std;
#include <string>
#include <vector>
#include <algorithm>
#include <map>
typedef long long ll;
#include <cmath>


int main(int argc, char *argv[])
{
	int n;
	cin >> n;
	

	cout<< (n+1)/2<<endl;
	return 0;
}


Measured memory_bytes: 256
fn main() {
    let std_in = std::io::stdin();
    let mut br = std::io::BufReader::new(std_in.lock());

    let N = rn::<usize>(&mut br);
    let mut adjs: Vec<Vec<(usize, usize)>> = vec![Vec::new(); N];
    for _ in 0..N-1 {
        let tmp = rvn::<usize>(&mut br);
        let (u, v, w) = (tmp[0] - 1, tmp[1] - 1, tmp[2] % 2);
        adjs[u as usize].push((v, w));
        adjs[v as usize].push((u, w));
    }

    let mut sol = vec![0; N];
    let mut visited = vec![false; N];
    let mut que = VecDeque::<usize>::new();
    que.push_back(0);
    while !que.is_empty() {
        let now = que.pop_front().unwrap();
        visited[now] = true;
        for next in &adjs[now] {
            let v = next.0;
            let w = next.1;
            if visited[v] {continue;}
            sol[v] = sol[now] ^ w;
            que.push_back(v);
        }
    }
    for i in 0..N {
        println!("{}", sol[i]);
    }
}


//////////////////////////////////////////////////////////////////////////////////
use std::io::{BufReader, BufRead, StdinLock};
use std::collections::vec_deque::VecDeque;

#[allow(dead_code)]
fn rs(br: &mut BufReader<StdinLock>) -> Vec<char> {
    let mut buf = String::new();
    br.read_line(&mut buf).ok();
    buf.trim().chars().collect()
}

#[allow(dead_code)]
fn rn<T: std::str::FromStr>(br: &mut BufReader<StdinLock>) -> T {
    let mut buf = String::new();
    br.read_line(&mut buf).ok();
    buf.trim().parse().ok().unwrap()
}

#[allow(dead_code)]
fn rvs(br: &mut BufReader<StdinLock>) -> Vec<Vec<char>> {
    let mut buf = String::new();
    br.read_line(&mut buf).ok();
    buf.trim().split_whitespace().map(|e| e.chars().collect()).collect()
}

#[allow(dead_code)]
fn rvn<T: std::str::FromStr>(br: &mut BufReader<StdinLock>) -> Vec<T> {
    let mut buf = String::new();
    br.read_line(&mut buf).ok();
    buf.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}



Measured memory_bytes: 14716
#include <cstdio>
#include <vector>

using namespace std;

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

    vector <int> boats[no_of_islands + 1];

    for(int i = 1; i <= no_of_boat_services; i++)
    {
        int boat_1, boat_2;
        scanf("%d %d", &boat_1, &boat_2);

        boats[boat_1].push_back(boat_2);
        boats[boat_2].push_back(boat_1);
    }

    vector <int> reachable_from_1(no_of_islands + 1, false);
    for(int i = 0; i < boats[1].size(); i++)
        reachable_from_1[boats[1][i]] = true;

    vector <int> reachable_from_n(no_of_islands + 1, false);
    for(int i = 0; i < boats[no_of_islands].size(); i++)
        reachable_from_n[boats[no_of_islands][i]] = true;

    int reachable = false;
    for(int i = 2; i < no_of_islands; i++)
    {
        if(reachable_from_1[i] && reachable_from_n[i])
            reachable = true;
    }

    printf(reachable ? "POSSIBLE\n" : "IMPOSSIBLE\n");
    return 0;
}


Measured memory_bytes: 13552
from collections import deque
H,W = map(int,input().split())
S = [list(input()) for i in range(H)]
went = [[False]*W for i in range(H)]
queue = deque()#append/popleft/(h,w,turn)
queue.append((0,0,0))
went[0][0] = True
dist = -1
while queue:
    curh,curw,curturn = queue.popleft()
    if curh==H-1 and curw == W-1:
        dist = curturn
        break
    for dx,dy in ((1,0),(0,1),(-1,0),(0,-1)):
        newh,neww = curh+dx,curw+dy
        if 0<=newh<H and 0<=neww<W and not went[newh][neww]\
        and S[newh][neww]==".":
            went[newh][neww] = True
            queue.append((newh,neww,curturn+1))

white = sum([s.count(".") for s in S])
if dist == -1:print(-1)
else:print(white - dist - 1)

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

bool exists(vector<long long> &pos, long long w, long long x, long long y){
    return binary_search(pos.begin(), pos.end(), x + w * y);
}

int main(void){
    long long h, w, n;
    cin >> w >> h >> n;
    vector<long long> pos(n);
    long long x, y;
    for(int i = 0; i < n; i ++){
        cin >> x >> y;
        pos[i] = (x-1) + w * (y-1);
    }
    sort(pos.begin(), pos.end());

    vector<int> d(h, w);
    d[0] = 1;
    for(int j = 1; j < h; j ++){
        d[j] = d[j-1] + 1;
        while(d[j] < w && exists(pos, w, d[j] - 1, j)) d[j] ++;
        if(d[j] == w) break;
    }

    int m = w;
    for(int i = 0; i < n; i ++){
        int x = pos[i] % w;
        if(x < m && x >= d[pos[i] / w]) m = x;
    }
    
    cout << m << "\n";
}


Measured memory_bytes: 2560
N = int(input())
N1 = N + 1
N2 = N1 * N
S0 = N2 / 2
# print(int(S0))

Na = N//3
N1a = Na + 1
N2a = N1a * Na
S0a = 3 * N2a / 2
# print(int(S0a))

Nb = N//5
N1b = Nb + 1
N2b = N1b * Nb
S0b = 5 * N2b / 2
# print(int(S0b))

Nc = N//15
N1c = Nc + 1
N2c = N1c * Nc
S0c = 15 * N2c / 2
# print(int(S0c))

S = S0 - S0a - S0b + S0c

print(int(S))

Measured memory_bytes: 9200
'use strict'
function Main(input) {
  const arr = input.split(" ");
  
  let count5 = 0;
  let count7 = 0;
  
  arr.forEach(a => {
    if(a == 5){
      count5++;
    }else if(a == 7){
      count7++;
    }
  });

  if(count5 == 2 && count7 == 1){
    console.log("YES");
    }else{
    console.log("NO");
  }
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
#include <iostream>/*{{{*/
#include <bits/stdc++.h>
#define REP(i, x) for(int i = 0; i < (int)(x); i++)
#define REPS(i,x) for(int i = 1; i <= (int)(x); i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define RFOR(i, m, n) for(int i = m;i >= n;i--)
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define FILL(x,y) memset(x,y,sizeof(x))
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define PB(a) push_back(a)
#define debug(x) cerr << __LINE__ << ": " << #x << " -> " << x << '\n'
#define INF 999999999
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};/*}}}*/

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

  sort(ALL(s));
  sort(ALL(t));
  reverse(ALL(t));

  if (s<t){cout << "Yes" << endl;}
  else{cout <<"No"<< endl;}

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    int a[n];
    int i,j,minv=9999999;
    int suma=0,sumb=0;
    for(int i=0;i<n;i++)cin>>a[i];
    for(int i=1;i<n;i++){
        suma=0;
        sumb=0;
        for(int j=0;j<i;j++)suma+=a[j];
        for(int j=i;j<n;j++)sumb+=a[j];
        minv=min(minv,abs(suma-sumb));
    }
    cout<<minv;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define REP(i,n) for (ll i = 0; i < (n); ++i)
#define RREP(i, n) for (ll i = (n) - 1; i >= 0; --i)
#define ALL(v) (v).begin(), (v).end()
template<class T>
using reverse_priority_queue = priority_queue<T, vector<T>, greater<T>>;

const string YES = "Yes";
const string NO = "No";

int main(){
    string s;
    cin >> s;
    if(s.size() < 2 || s.size() % 2 == 1){
        cout << NO << endl;
        return 0;
    }
    REP(i, s.size()){
        if(i % 2 == 0){
            if(s.at(i) != 'h'){
                cout << NO << endl;
                return 0;
            }
        }else{
            if(s.at(i) != 'i'){
                cout << NO << endl;
                return 0;
            }
        }
    }
    cout << YES << endl;
    return 0;
}


Measured memory_bytes: 3596