akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
using namespace  std;

void fnInput(vector<int> &rvnElm,  vector<int> &rvnTrg )
{
  int nElmCnt, nTrgCnt;
  cin >> nElmCnt;

  rvnElm.resize(nElmCnt);
  for (int i = 0; i < nElmCnt; i++)
    cin >> rvnElm[i];

  cin >> nTrgCnt;

  rvnTrg.resize(nTrgCnt);
  for (int i = 0; i < nTrgCnt; i++)
    cin >> rvnTrg[i];
}

void fnDPtblMake(vector<vector<int>> &rvvnDP, const vector<int> &cnrvnElm, int nMaxTrg)
{
  rvvnDP[cnrvnElm.size()][0] = 1;
  for (int j = 1; j <= nMaxTrg; j++)
    rvvnDP[cnrvnElm.size()][j] = 0;

  for (int i = cnrvnElm.size() - 1; i >= 0; i--)
    for (int j = 0; j <= nMaxTrg; j++)
      if (cnrvnElm[i] <= j)
        rvvnDP[i][j] = rvvnDP[i + 1][j] || rvvnDP[i + 1][j - cnrvnElm[i]];
      else
        rvvnDP[i][j] = rvvnDP[i + 1][j];

}

void fnExhSch(const vector<int> &cnrvnElm, const vector<int> &cnrvnTrg)
{
  vector<vector<int>> vvnDP(21, vector<int>(2001, -1));

  int nMaxTrg = cnrvnTrg[0]; 
  for (int i = 1; i < cnrvnTrg.size(); i++)
    nMaxTrg = max(nMaxTrg, cnrvnTrg[i]);

  fnDPtblMake(vvnDP, cnrvnElm, nMaxTrg);

  for (int i = 0; i < cnrvnTrg.size(); i++)
    if (vvnDP[0][cnrvnTrg[i]])
      cout << "yes" << endl;
    else
      cout << "no" << endl;
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  vector<int> vnElm, vnTrg;

  fnInput(vnElm, vnTrg);
  fnExhSch(vnElm, vnTrg);

  return 0;
}

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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsl(s) vector<pair<ll,ll>> (s);
#define pairss(s) vector<pair<string,string>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairspl(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsps(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsREV(s) (s).push_back(make_pair(bb,aa));
#define pairslREV(s) (s).push_back(make_pair(bb,aa));
#define pairssREV(s) (s).push_back(make_pair(bb,aa));
#define MOD 1000000007

int main()
{

	string s;
	cin >> s;
	fx(s.size()) {
		fyg(s.size(),x+1) {
			if (s[x]=='C'&&s[y]=='F') {
				ce("Yes")
					return 0;
			}
		}
	}
	ce("No")
    return 0;
}



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

#define rep(i,n) for(ll i=0;i<(n);++i)
using ll = long long;
using pll = pair<ll,ll>;
constexpr ll INF = (1LL<<60);
constexpr ll MOD = (1e9+7);
//constexpr ll MOD = (998244353);
template<class T> bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T> bool chmin(T &a,const T &b){if(a>b){a=b;return 1;}return 0;}
#if loc||debg||local||debug
void dump(){cerr<<endl;}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){cerr<<h<<", ";dump(forward<Ts>(t)...);}
#else
template<class T,class... Ts> void dump(T&& h, Ts&&... t){}
#endif
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T> ostream &operator<<(ostream& os,vector<T>const& v){for(auto const& vi:v)os<<vi<<" ";return os;}
template<class T>vector<T> vec(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto vec(size_t a, Ts... ts){return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...));}
template<class T>vector<T> _vec(size_t a,T v){return vector<T>(a,v);}
template<class T, class... Ts>auto _vec(size_t a, Ts... ts){return vector<decltype(_vec<T>(ts...))>(a, _vec<T>(ts...));}

int main(){

  ll h;
  cin>>h;

  ll mons = 1;
  ll hp = h;
  ll ans = 0;
  while(hp){
    hp /= 2;
    ans += mons;
    mons *= 2;
  }
  cout<<(ans)<<endl;

}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner scn=new Scanner(System.in);
		int n=scn.nextInt();
		String s=scn.next();
		if(n<3200) {
			System.out.println("red");
		}else {
			System.out.println(s);
		}
	}

}


Measured memory_bytes: 21716
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <utility>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>


using namespace std;

using ll = long long;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)


int main() {
	int n, m;
	cin >> n >> m;
	ll a[n];

	ll total = 0;

	rep(i, n) {
		cin >> a[i];
		total += a[i];
	}

	sort(&a[0],&a[n]);

	vector<pair<ll, ll> > cb;
	rep(i, m) {
		ll b;
		ll c;
		cin >> b >> c;
		cb.push_back(make_pair(c,b));
	}

	sort(cb.rbegin(),cb.rend());
	int i = -1;
	int num = 0;
	int j = 0;
	while (i < m && j < n) {
		if (num <= 0) {
			i++;
			num = cb[i].second;
			//cout << "val:" << cb[j].first << endl;
		}

		if (a[j] >= cb[i].first) {
			//cout << "aaa" << endl;
			break;
		}
		//cout << "from:" << a[j] << endl; 
		total -= a[j];
		total += cb[i].first;

		num--;
		j++;

		//cout << "i:" << i <<  " total:" << total << endl;
	}
	cout << total << endl;

	return 0;
}

Measured memory_bytes: 3188
package main

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

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer([]byte{}, math.MaxInt64)
}

func readInt() int {
	sc.Scan()
	r, _ := strconv.Atoi(sc.Text())
	return r
}

func factorial(n int) int {
	switch n {
	case 0, 1:
		return 1
	default:
		return n * factorial(n-1) % 1000000007
	}
}

func main() {
	n := readInt()
	fmt.Println(factorial(n))
}


Measured memory_bytes: 7168
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>
#include <cassert>


using namespace std;
#define SZ(x) (int)(x.size())
#define REP(i, n) for(int i=0;i<n;++i)
#define FOR(i, a, b) for(int i=a;i<b;++i)
#define RREP(i, n) for(int i=n-1;i>=0;--i)
#define RFOR(i, a, b) for(int i=b-1;i>=a;--i)

#define all(x) begin(x),end(x)
#define dump(x) cerr<<#x<<" = "<<(x)<<endl
#define debug(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<< endl;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;
const double eps = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;

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 (b < a) {
        a = b;
        return true;
    }
    return false;
}


template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> p) {
    os << p.first << ":" << p.second;
    return os;
}

template<class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    os << "[";
    REP(i, SZ(v)) {
        if (i) os << ", ";
        os << v[i];
    }
    return os << "]";
}

// edit

void solve() {
    int A, B, K;
    cin >> K >> A >> B;
    for(int i = A; i <= B; ++i){
        if(i % K == 0){
            cout << "OK" << endl;
            return;
        }
    }
    
    cout << "NG" << endl;

}


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
//    std::ifstream in("input.txt");
//    std::cin.rdbuf(in.rdbuf());

    solve();


    return 0;
}


Measured memory_bytes: 3100
#include<bits/stdc++.h>
using namespace std;
long long gcd(long long x,long long y){
	if(x%y==0)return y;
	return gcd(y,x%y);
}
long long exgcd(long long a,long long b,long long &x,long long &y){
	if(b==0){
		x=1,y=0;
		return a;
	}
	long long d=exgcd(b,a%b,y,x);
	y-=a/b*x;
	return d;
}
long long phi(long long x){
	int ans=1;
	for(int i=2;i*i<=x;i++){
		if(x%i==0){
			ans*=(i-1);
			x/=i;
			while(x%i==0)x/=i,ans*=i;
		}
	}
	if(x!=1)ans*=(x-1);
	return ans;
}
long long power(long long x,long long k,long long P){
	long long ans=1;
	while(k){
		if(k&1)(ans*=x)%=P;
		(x*=x)%=P;
		k>>=1;
	}
	return ans;
}
long long solve(long long a,long long m){
	if(m==1)return 1;
	long long M=phi(m);
	long long d=gcd(M,m);
	long long t=solve(a,d);
	long long At=power(a,t,m);
	long long x,y;
	exgcd(M/d,m/d,x,y);
	long long A=((At-t%M)/d*x)%m;
	long long ans=(__int128)t%M+A*M;
	ans%=m/d*M;
	ans+=m/d*M;
	ans%=m/d*M; 
	ans+=m/d*M; 
	return ans;
}
int main(){
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		long long x,m;
		scanf("%lld%lld",&x,&m);
		long long ans=solve(x,m);
		printf("%lld\n",ans);
	}
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <ctime>
#include <string>
#include <map>
#include <stack>
#include <queue>
#include <complex>

using namespace std;

typedef complex<double> xy_t;
int x, y;
int n;
xy_t P[100];
const int MAX = 10000000;

double cross_product(xy_t a, xy_t b) { return (conj(a)*b).imag(); }

int main(void){


	cin >> n;

	for(int i = 0; i < n; i++){
		cin >> x >> y;
		P[i] = xy_t(x, y);
	}
	
	double ans = 0;

	for(int i = 1; i < n - 1; i++){
		ans += 0.5 * cross_product(xy_t (P[i] - P[0]), xy_t (P[i + 1] - P[0]));
	}

	printf("%.1f\n", ans);
	
    return 0;
}

Measured memory_bytes: 1200
from collections import defaultdict
N, M = map(int, input().split())
d = defaultdict(list)
for _ in range(M):
    a, b = map(int, input().split())
    d[a].append(b)
    d[b].append(a)


def dfs(n, path):
    count = 0
    path.append(n)
    if len(path) == N:
        count += 1
        return count

    for i in range(len(d[n])):
        if d[n][i] not in path:
            count += dfs(d[n][i], path)
            path.pop()

    return count


print(dfs(1, []))


Measured memory_bytes: 9436
#include <cstdio>
#include <iostream>
using namespace std;
#define ref(i,x,y)for(int i=x;i<=y;++i)
int main()
{
	int n,ans=1,tmp=1;
	cin>>n;
	ref(i,1,n)
	{
		int s;
		cin>>s;
		ans=ans*3;
		if(s&1)tmp=tmp*1;else tmp=tmp*2;
	}
	ans-=tmp;
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
using ll = long long; 
using ld = long double;
#define endl "\n"
//#define int long long
#define ALL(x) sort(x.begin(),x.end())
#define RALL(x) sort(x.rbegin(),x.end())
#define _CRT_SECURE_NO_WARNINGS
#define rep(i, n) for (int i = 0; i < n; i++)
const int MOD = 1e9 + 7;
const ll INF = 1LL << 60;
const int inf = 1 << 25;
constexpr long double pi = 3.141592653589793238462643383279;
int dx[] = { 1,0,-1,0 };
int dy[] = { 0,1,0,-1 };
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;
}
ll fact_mod(ll n, ll mod) {
    ll f = 1; for (int i = 2; i <= n; i++) f = f * (i % mod) % mod;
    return f;
}
ll gcd(ll a, ll b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
    return a * b / gcd(a, b);
}
ll keta(ll n) {
    if (n == 0) return 1;
    ll count = 0;
    while (n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
ll ketasum(ll n) {
    ll sum = 0;
    while (n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
ll mch(ll n) {
    if (n == 1) return 1;
    else return n * mch(n - 1);
}
ll pow_mod(ll x, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = (res * x) % mod; //ビット演算(最下位ビットが1のとき)
        x = (x * x) % mod;
        n >>= 1; //右シフト(n = n >> 1)
    }
    return res;
}
ll inv_mod(ll a, ll mod) {
    ll b = mod, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= mod;
    if (u < 0) u += mod;
    return u;
}
bool is_prime(const unsigned n) {
    switch (n) {
    case 0: // fall-through
    case 1: return false;
    case 2: // fall-through
    case 3: return true;
    } // n > 3 が保証された
    if (n % 2 == 0 || n % 3 == 0) return false;
    for (unsigned i = 5; i * i <= n; i += 6) {
        if (n % i == 0) return false; // (6の倍数)-1
        if (n % (i + 2) == 0) return false; // (6の倍数)+1
    }
    return true;
}
//関数とか

//宣言とか
int n;
/*signed*/int main(void) {
    cin >> n;
    vector<int> x(n),tmp(n);
    rep(i, n) {
        cin >> x[i];
        tmp[i] = x[i];
    }
    sort(x.begin(),x.end());
    rep(i, n) {
        if (tmp[i] <= x[n / 2 - 1]) cout << x[n / 2] << endl;
        else cout << x[n / 2 - 1] << endl;
    }
    return 0;
}

Measured memory_bytes: 4756
#@YottyPG　Qiita
from collections import deque

N,M,K = map(int,input().split())
friend = [list(map(int,input().split())) for _ in range(M)]
block = [list(map(int,input().split())) for _ in range(K)]

f = [set() for _ in range(N+1)]
b = [set() for _ in range(N+1)]

for i,j in friend:
    f[i].add(j)
    f[j].add(i)
for i,j in block:
    b[i].add(j)
    b[j].add(i)

stack=deque()
ans = [0]*(N+1)
visited = [0]*(N+1)

for i in range(1,N+1):
    if visited[i]:
        continue
    link = {i}
    visited[i] = 1 
    stack.append(i)
    while stack:
        n = stack.pop()
        for j in f[n]:
            if visited[j]==0:
                stack.append(j)
                visited[j] = 1
                link.add(j)
    for i in link:
        ans[i] = len(link) - len(link & f[i]) - len(link & b[i]) - 1
print(*ans[1:])

Measured memory_bytes: 116828
#include <iostream>
#include <cstring>
#include <cstdio>
#include<utility>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
typedef pair<double,double>P_D;
#define PI 3.1415926535897932384626433832795
#define rep(i, n) for (int i = 0; i < n; i++)
#define reprev(i, n) for (int i = n - 1; i >= 0; i--)
#define ALL(a)  (a).begin(),(a).end()
#define MAX 100100
#define MAX_N 200100
#define SENTINEL 2000000000
#define NIL -1
const int MOD = 1e9+7;
const int INF = 1 << 29;
int n;
map<int,int>m;
int main(){
    int x;
    cin>>n;
    int ans=0;
    rep(i,n){
        cin>>x;
        if(!m.count(x)){
            m[x]=1;
        }
        else {
            m[x]++;
        }
    }
    for(auto p : m){
        auto key=p.first;
        auto value=p.second;
        if(value>key){
            ans+=value-key;
        }
        if(value<key){
            ans+=value;
        }
    }
    cout<<ans<<endl;
    return 0;

}

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

const long long INF=1e12;

int main() {
    int a, b, q;
    cin >> a >> b >> q;
    vector<long long> s(a+1),t(b+1);
    s[0]=-INF;
    t[0]=-INF;
    for ( int i=1; i<=a; i++ ) {
        cin >> s[i];
    }
    for ( int i=1; i<=b; i++ ) {
        cin >> t[i];
    }
    s.push_back(INF);
    t.push_back(INF);
    sort(s.begin(), s.end());
    sort(t.begin(), t.end());
    while ( q-- ) {
        long long x;
        cin >> x;
        int ai=lower_bound(s.begin(), s.end(), x)-s.begin();
        int bi=lower_bound(t.begin(), t.end(), x)-t.begin();
        long long sx[2], tx[2];
        sx[1]=s[ai]; sx[0]=s[ai-1];
        tx[1]=t[bi]; tx[0]=t[bi-1];
        long long ans=INF;
        for ( int i=0; i<2; i++ ) {
            for ( int j=0; j<2; j++ ) {
                ans=min(ans, abs(x-sx[i])+abs(sx[i]-tx[j]));
                ans=min(ans, abs(x-tx[j])+abs(tx[j]-sx[i]));
            }
        }
        cout << ans << '\n';
    }
    return 0;
}

Measured memory_bytes: 2912
L, R = map(int, input().split())
dp = [[[[0]*2 for _ in range(2)] for _ in range(2)] for _ in range(65)]
dp[0][0][0][0] = 1
MOD = 10**9+7

for i in range(64):
    Li = (L>>(63-i))&1
    Ri = (R>>(63-i))&1
    
    for j in range(2):
        for k in range(2):
            for l in range(2):
                for x in (range(2) if j else range(Li, 2)):
                    for y in range(2 if k else Ri+1):
                        if x==1 and y==0:
                            continue
                        
                        if l==0 and x==0 and y==1:
                            continue
                        
                        dp[i+1][j|(x>Li)][k|(y<Ri)][l|(x==1 and y==1)] += dp[i][j][k][l]
                        dp[i+1][j|(x>Li)][k|(y<Ri)][l|(x==1 and y==1)] %= MOD

ans = 0

for i in range(2):
    for j in range(2):
        for k in range(2):
            ans += dp[-1][i][j][k]
            ans %= MOD

print(ans)

Measured memory_bytes: 68408
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <string>
#include <string.h>
#include <bitset>
#include <map>
#include <climits>
#include <set>

using namespace std;

int main()
{
    int N;
    cin >> N;
    using integer = long;
    integer num_odd = 0;
    for (int i = 0; i < N; ++i)
    {
        integer n;
        cin >> n;
        if (n % 2)
        {
            ++num_odd;
        }
    }
    cout << (num_odd % 2 == 0 ? "YES" : "NO") << endl;
    return 0;
}

Measured memory_bytes: 256
//四則演算 #pragma GCC target("avx")
//並列計算 #pragma GCC optimize("O3")
//条件分岐を減らす #pragma GCC optimize("unroll-loops")
//浮動小数点演算 #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
using VS = vector<string>;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "-----------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10;
constexpr ld pi = 3.1415926535897932;
template<class T>inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; }return false; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& a : v)is >> a; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }
inline void print() { cout << "\n"; }
template<class T, class... Ts>inline void print(const T& a, const Ts&... ts) { cout << a << " "; print(ts...); }
template<class T>inline void print(const vector<T>& v) { for (int i = 0; i < v.size(); ++i)cout << v[i] << (i == v.size() - 1 ? "\n" : " "); }
template<class T>inline void print(const vector<vector<T>>& v) { for (auto& a : v)print(a); }
string reversed(const string& s) { string t = s; reverse(all(t)); return t; }

int main() {
    init();

    int h, n; cin >> h >> n;
    VI a(n), b(n);
    FOR(i, 0, n)cin >> a[i] >> b[i];

    VI dp(h + 1, INF);
    dp[0] = 0;
    FOR(i, 0, h)FOR(j, 0, n) {
        chmin(dp[min(i + a[j], h)], dp[i] + b[j]);
    }
    print(dp[h]);
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main()
{
int a,b;
cin>>a>>b;
if(a==1&&a!=b)
    cout<<"Alice\n";
 if(a>b&&b!=1)
    cout<<"Alice\n";
if(b>a&&a!=1)
cout<<"Bob\n";
if(b==1&&a!=b)
    cout<<"Bob\n";
    if(a==b)
        cout<<"Draw\n";
return 0;





}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define P(x) {if (debug) cout << x << endl;}
#define H(x) P(#x << ": " << (x))
#define FR(i,a,b) for (int i=(a); i<(b); i++)
#define F(i,n) FR(i,0,n)
#define DR(i,a,b) for (int i=(b); i-->(a);)
#define D(i,n) DR(i,0,n)
#define S(s) (int)(s).size()
#define ALL(v) v.begin(), v.end()
#define MI(a,v) a = min(a,v)
#define MA(a,v) a = max(a,v)
#define V vector
#define pb push_back
#define mt make_tuple
using namespace std;
template<class T> ostream& operator<<(ostream& os, V<T> v) {
    F(i,S(v)) os<<(i?" ":"")<<v[i]; return os;}
const bool debug = 0;

void dfs(V<V<int>> &g, int u, int par, V<int> &out) {
    if (S(g[u]) == 1) return;
    out.pb(u);
    for (int v : g[u]) if (v != par)
        dfs(g,v,u,out);
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int n; cin>>n;
    if (n == 2) {
        cout<<"1 2\n";
        return 0;
    }
    V<V<int>> g(n);
    F(i,n-1) {
        int a,b; cin>>a>>b;
        a--,b--;
        g[a].pb(b);
        g[b].pb(a);
    }
    V<int> deg(n);
    F(i,n) deg[i] = S(g[i]);
    F(i,n) if (S(g[i]) == 1) {
        H(i)
        deg[i] = 0;
        deg[g[i][0]]--;
    }
    H(deg)
    bool ok = true;
    V<int> starts;
    F(i,n) {
        if (deg[i] > 2)
            ok = false;
        else if (deg[i] == 1)
            starts.pb(i);
    }
    if (S(starts) == 0) {// star graph
        F(i,n) if (S(g[i]) != 1) {
            starts.pb(i);
        }
        assert(S(starts) == 1);
    }
    if (!ok) {
        cout<<"-1\n";
        return 0;
    }
    V<V<int>> cands;
    for (int x : starts) {
        V<int> path, pos;
        dfs(g, x, -1, path);
        pos.pb(0);
        int cur=1;
        F(i,S(path)) {
            int u = path[i], d = S(g[u])-2;
            P(u<<" "<<d)
            pos.pb(cur + d);
            FR(k,cur,cur+d)
                pos.pb(k);
            cur += d+1;
        }
        pos.pb(n-1);
        cur++;
        assert(cur == n);
        assert(S(pos) == n);
        H(pos)
        V<int> cand(n);
        F(i,n)
            cand[pos[i]] = i;
        cands.pb(cand);
    }
    assert(1 <= S(cands) && S(cands) <= 2);
    sort(ALL(cands));
    F(i,S(cands[0]))
        cout<<cands[0][i]+1<<" \n"[i==S(cands[0])-1];
}

Measured memory_bytes: 17476
#
# smbc2019 b
#
import sys
from io import StringIO
import unittest
import math


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """432"""
        output = """400"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """1079"""
        output = """:("""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """1001"""
        output = """927"""
        self.assertIO(input, output)


def resolve():
    N = int(input())

    for x in range(1, N+1):
        if math.floor(x*1.08) == N:
            print(x)
            break
    else:
        print(":(")


if __name__ == "__main__":
    # unittest.main()
    resolve()


Measured memory_bytes: 16124
n = int(input())
S = input()
re = 0
for s in S:
    if s == 'E':
        re += 1
lw = 0
c = len(S)
for i in range(n):
    if S[i]  == 'E':
        re -= 1
    c = min(c, re+lw)

    if S[i] == 'W':
        lw += 1
print(c)


Measured memory_bytes: 3672
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<stdio.h>
#include<utility>//swapでaとbの値を入れ替える
#define rep(i,n) for(int i=0;i<(n);i++)
#define ll long long
#define sort(s) sort(s.begin(),s.end())
#define r(s) reverse(s.begin(),s.end())
using namespace std;

int main(){
	int a;
	cin >> a;
	vector<double> s(a);
	double x=0;
	rep(i, a) {
		cin >> s[i];
		x += 1 / s[i];
	}
	double ans = 1 / x;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<vector>
#include<iomanip>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
#define ll long long
#define lf double
#define lg 20
#define maxn 65536*2
#define err {puts("-1");exit(0);};
int nxt[maxn][lg+5];int pos[maxn];int n,l,Q;
struct QUERY{
	int l,r,id;
}q[maxn];int ans[maxn];
void getlg()
{
	memset(nxt,0,sizeof(nxt));
	int r=1;
	for(int i=1;i<=n;i++)
	{
		while(pos[i]-pos[r]>l) r++;
		nxt[i][0]=r;
	//	cout<<i<<":"<<r<<"\n";
	}//cout<<"\n\n";
	nxt[1][0]=0;
	for(int i=1;i<=lg;i++)
		for(int j=1;j<=n;j++) 
			nxt[j][i]=nxt[nxt[j][i-1]][i-1];
	
}
int main()
{
	int Q;
	cin>>n;for(int i=1;i<=n;i++) scanf("%d",&pos[i]);
	cin>>l;cin>>Q;for(int i=1;i<=Q;i++) scanf("%d%d",&q[i].l,&q[i].r),q[i].id=i;
	getlg();
	for(int i=1;i<=Q;i++)
	{
		if(q[i].l<q[i].r) continue;
		int x=q[i].l;
		for(int j=lg;j>=0;j--)
		{
			if(nxt[x][j]>q[i].r)
				x=nxt[x][j],ans[q[i].id]+=(1<<j);
		}
		if(x>q[i].r) ans[q[i].id]++;
	}
	for(int i=1;i<=n;i++) pos[i]*=-1;
	reverse(pos+1,pos+n+1);
	getlg();
	for(int i=1;i<=Q;i++)
	{
		q[i].l=n-q[i].l+1,q[i].r=n-q[i].r+1;
		if(q[i].l<q[i].r) continue;
		int x=q[i].l;
		for(int j=lg;j>=0;j--)
		{
			if(nxt[x][j]>q[i].r)
				x=nxt[x][j],ans[q[i].id]+=(1<<j);
		}
		if(x>q[i].r) ans[q[i].id]++;
	}
	for(int i=1;i<=Q;i++) printf("%d\n",ans[i]);
    return 0;
}
/*
9
1 3 6 13 15 18 19 29 31
10
4
1 8
7 3
6 7
8 5
*/

Measured memory_bytes: 15744
#include<bits/stdc++.h>
using namespace std;
using ll=long long int;
int main()
{
    ll n,sum=0,q;
    cin>>n;
    //ll arr[n];
    ll freq[100001]={0};
    
    for(int i=0;i<n;i++)
    {
        ll x;
        cin>>x;
        
        freq[x]++;
        sum+=x;
       // arr[i]=x;
    }
    cin>>q;
    while(q--)
    {
        ll f,z;
        cin>>f>>z;
        freq[z]+=freq[f];
        ll k=z-f;
        sum+= k*freq[f];
        freq[f]=0;
        cout<<sum<<endl;
    }
    
    return 0;
}

Measured memory_bytes: 4408
N, M = map(int, input().split())
S = [-1]*N
for i in range(M):
    s,c = map(int, input().split())
    if S[s-1] == c:
        continue
    elif S[s-1] == -1:
        S[s-1] = c
    else:
        print(-1)
        exit()

if S[0] == 0:
    if N != 1:
        print(-1)
        exit()
if S[0] == -1:
    if N != 1:
        S[0] = 1
    else:
        S[0] = 0

for i in range(N):
    if S[i] == -1:
        S[i] = 0

print(*S,sep="")



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

int main() {
  char c;
  std::cin >> c;
  if (c == 'A') {
    std::cout << 'T' << std::endl;
  } else if (c == 'T') {
    std::cout << 'A' << std::endl;
  } else if (c == 'C') {
    std::cout << 'G' << std::endl;
  } else {
    std::cout << 'C' << std::endl;
  }
  return 0;
}


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

int main(){
  int a, b;
  cin >> a >> b;
  if (a < b) {
      cout << "a < b" << endl;
  } else if (a > b) {
      cout << "a > b" << endl;
  } else {
      cout << "a == b" << endl;
  }
  return 0;
}


Measured memory_bytes: 3100
import java.util.*;

public class Main{
    public static void main(String args[]){
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int X = scanner.nextInt() - 1;
        int Y = scanner.nextInt() - 1;
        int[] dis = new int[N];
        int[] count = new int[N];

        ArrayList<ArrayList<Integer>> g = new ArrayList<>();
        for(int i=0; i<N; i++){
            g.add(new ArrayList<>());
        }
        for(int i=0; i<N; i++){
            if(i!=0){
                g.get(i).add(i-1);

            }
            if(i!=N-1){
                g.get(i).add(i+1);
            }
        }
        g.get(X).add(Y);
        g.get(Y).add(X);

        for(int i=0;i<N;i++){
            for(int j=0;j<N;j++){
                dis[j] = N * 2;
            }
            dis[i] = 0;
            extend(g, i, dis);

            for(int j=0; j<N; j++){
                count[dis[j]]++;
            }
        }
        for(int i=1;i<N;i++){
            System.out.println(count[i]/2);
        }

    }
    public static void extend(ArrayList<ArrayList<Integer>> g, int current, int[] dis){
        for(Integer i: g.get(current)){
            if(dis[i] > dis[current] + 1){
                dis[i] = dis[current] + 1;
                extend(g, i, dis);
            }
        }
    }
}

Measured memory_bytes: 92992
def main():
    a, b, c, x, y = map(int, input().split())
    c *= 2
    if c >= a + b:
        print(a * x + b * y)
        return
    if x > y:
        if c > a:
            print(a * (x - y) + c * y)
        else:
            print(c * x)
    else:
        if c > b:
            print(b * (y - x) + c * x)
        else:
            print(c * y)


main()


Measured memory_bytes: 3060
let popcnt x =
  let x = (x land 0x5555555555555555) + ((x lsr 1) land 0x5555555555555555) in
  let x = (x land 0x3333333333333333) + ((x lsr 2) land 0x3333333333333333) in
  let x = (x land 0x0f0f0f0f0f0f0f0f) + ((x lsr 4) land 0x0f0f0f0f0f0f0f0f) in
  let x = (x land 0x00ff00ff00ff00ff) + ((x lsr 8) land 0x00ff00ff00ff00ff) in
  let x = (x land 0x0000ffff0000ffff) + ((x lsr 16) land 0x0000ffff0000ffff) in
  (x land 0x00000000ffffffff) + ((x lsr 32) land 0x00000000ffffffff)

let inf = 1145141919810

let () = Scanf.scanf "%d\n" @@ fun n ->
  let as_ = Array.init n @@ fun _ -> Scanf.scanf "%d " @@ fun a -> a in
  let bs = Array.init n @@ fun _ -> Scanf.scanf "%d " @@ fun b -> b in
  let dp = Array.make_matrix (1 lsl n) 51 inf in
  dp.(0).(0) <- 0;
  for mask = 0 to (1 lsl n) - 1 do
    let j = popcnt mask in
    for s = 0 to 50 do
      if dp.(mask).(s) < inf then begin
        for i = 0 to n - 1 do
          if mask land (1 lsl i) = 0 then begin
            let c = popcnt (((1 lsl i) - 1) land (lnot mask)) in
            let x = if i mod 2 = j mod 2 then as_.(i) else bs.(i) in
            if s <= x then
              dp.(mask lor (1 lsl i)).(x) <-
                min dp.(mask lor (1 lsl i)).(x) (c + dp.(mask).(s))
          end
        done
      end
    done
  done;
  let ans = Array.fold_left min inf dp.((1 lsl n) - 1) in
  Printf.printf "%d\n" @@ if inf <= ans then -1 else ans


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

int N;
vector<long long> x, y;

int solve() {
    if (N == 1) return 1;

    int res = N;
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < N; ++j) {
            if (i == j) continue;
            long long dx = x[j] - x[i], dy = y[j] - y[i];

            int sub = 0;
            for (int i2 = 0; i2 < N; ++i2) {
                for (int j2 = 0; j2 < N; ++j2) {
                    if (j2 == i2) continue;
                    if (dx == x[j2] - x[i2] && dy == y[j2] - y[i2]) ++sub;
                }
            }
            res = min(res, N - sub);
        }
    }
    return res;
}

int main() {
    cin >> N;
    x.resize(N); y.resize(N);
    for (int i = 0; i < N; ++i) cin >> x[i] >> y[i];
    cout << solve() << endl;
}
                                        



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
 
using namespace std;
#define MAXN 5000
#define MOD 1000000007
#define Trav(p) for(rint u = first[p], v; ~u; u = e[u].nex)
#define rint register int
#define gc() getchar()
inline int read(rint ans = 0, rint sgn = ' ', rint ch = gc())
{
	for(; ch < '0' || ch > '9'; sgn = ch, ch = gc());
	for(; ch >='0' && ch <='9';(ans*=10)+=ch-'0', ch = gc());
	return sgn-'-'?ans:-ans;
}
#define BUF_SIZE 1000000
#define _END fwrite(_Ob,1,_O-_Ob,stdout), _O = _Ob
#define Outc(a) (*_O++ = a)
char _Ob[BUF_SIZE+5], *_O = _Ob, _Os[25], *_Ot;
template <typename T> inline void Out(T x)
{
	if(!x){Outc('0'); return;} if(x < 0) Outc('-'), x = -x;
	for(_Ot = _Os; x; *_Ot++ = x%10+'0', x /= 10);
	for(; _Ot != _Os; Outc(*--_Ot)); if(_O-_Ob >= BUF_SIZE-50) _END;
}
int first[MAXN+5], sz[MAXN+5], mx[MAXN+5], A[MAXN+5], f[MAXN+5], fac[MAXN+5], efac[MAXN+5], sum, rt, num, tot, n, d, ans;
struct Edge{int to,nex; Edge(){} Edge(int _to, int _nex){to=_to,nex=_nex;}}e[(MAXN<<1)+5];
inline void Add(int a, int b){e[tot] = Edge(b,first[a]), first[a] = tot++, e[tot] = Edge(a,first[b]), first[b] = tot++;}
inline int fastpow(int s, int n){int a = 1; for(; n; n&1 ? a = 1ll*a*s%MOD : 0, s = 1ll*s*s%MOD, n >>= 1); return a;}
void DFS_sz(int p, int fa){sz[p] = 1, mx[p] = 0; Trav(p) if((v=e[u].to)-fa) DFS_sz(v,p), sz[p] += sz[v], mx[p] = max(mx[p],sz[v]);}
void DFS_rt(int p, int fa){(mx[p]=max(mx[p],sum-sz[p]))<mx[rt]?rt=p,num=1:num+=mx[p]==mx[rt]; Trav(p) if((v=e[u].to)-fa) DFS_rt(v,p);}
inline int C(int n, int k){return 1ll*fac[n]*efac[k]%MOD*efac[n-k]%MOD;} inline int sqr(int x){return 1ll*x*x%MOD;}
int main()
{
	n = read(), memset(first+1,-1,n<<2); for(rint i = 2; i <= n; Add(read(),read()), i++); DFS_sz(1,0), sum = sz[rt=1], DFS_rt(1,0);
	fac[0] = 1; for(rint i = 1; i <= n; fac[i] = 1ll*i*fac[i-1]%MOD, i++);
	if(num>1){printf("%lld\n",1ll*fac[n>>1]*fac[n>>1]%MOD); return 0;}
	efac[n] = fastpow(fac[n],MOD-2); for(rint i = n; i; efac[i-1] = 1ll*i*efac[i]%MOD, i--); sum = 0, f[0] = 1;
	Trav(rt) DFS_sz(v=e[u].to,rt), A[++d] = sz[v]; sort(A+1,A+d+1);
	for(rint i = 1, j, k; i <= d; i++)
		for(sum += A[i], j = sum; j; j--)
			for(k = 1; k <= j && k <= A[i]; k++)
				f[j] = (f[j]+1ll*f[j-k]*sqr(C(A[i],k))%MOD*fac[k])%MOD;
	for(rint k = 0; k <= sum; ans = (ans+(k&1?MOD-1ll:1ll)*fac[n-k]%MOD*f[k])%MOD, k++); printf("%d\n",ans); return 0;
}

Measured memory_bytes: 640
#![allow(unused_imports)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

pub trait InputValue {
    fn parse(s: &str) -> Self;
}

pub fn read<T: InputValue>() -> T {
    let mut buf = String::new();
    let _ = stdin().read_line(&mut buf);
    T::parse(&buf.trim())
}

pub fn readn<T: InputValue>(n: usize) -> Vec<T> {
    let mut vec = vec![];
    for _ in 0..n {
        vec.push(read());
    }
    vec
}

pub fn readnc<T: InputValue>() -> Vec<T> {
    let mut vec = vec![];
    let line: String = read();
    for token in line.split_whitespace() {
        vec.push(T::parse(token));
    }
    vec
}

macro_rules! parse_single_value {
    ($($t:ty),*) => {
        $(
            impl InputValue for $t {
                fn parse(s: &str) -> $t { s.parse().unwrap() }
            }
        )*
	}
}
parse_single_value!(i32, i64, f32, f64, usize, String);

macro_rules! parse_tuple {
	($($t:ident),*) => {
		impl<$($t),*> InputValue for ($($t),*) where $($t: InputValue),* {
			fn parse(s: &str) -> ($($t),*) {
				let mut tokens = s.split_whitespace();
				let t = ($($t::parse(tokens.next().unwrap())),*);
				t
			}
		}
	}
}
parse_tuple!(A, B);
parse_tuple!(A, B, C);
parse_tuple!(A, B, C, D);
parse_tuple!(A, B, C, D, E);

// ===

fn main() {
    let (a, b, c, d): (i32, i32, i32, i32) = read();
    if a+b > c+d {
        println!("Left");
    } else if a+b < c+d {
        println!("Right");
    } else {
        println!("Balanced");
    }
}


Measured memory_bytes: 4352
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(int i = 0; i < n; i++)



int main() {
    ll s4[201];
    vector<ll> s4_k;
    REP(i, 201){
        s4[i] = i * (i + 1) * (i + 2) / 6;
        if(s4[i] & 1){
            s4_k.push_back(i * (i + 1) * (i + 2) / 6);
            // cout << s4[i] << endl;
        }
    }
    vector<ll> dp1(1000001, INF), dp2(1000001, INF);
    dp1[0] = 0;
    REP(i, 201){
        REP(j, 1000001){
            if(s4[i] <= j){
                dp1[j] = min(dp1[j], dp1[j - s4[i]] + 1);
            }
        }
    }
    
    dp2[0] = 0;
    REP(i, s4_k.size()){
        REP(j, 1000001){
            if(s4_k[i] <= j){
                dp2[j] = min(dp2[j], dp2[j - s4_k[i]] + 1);
            }
        }
    }
    
    ll n;
    cin >> n;
    
    while(n != 0){
        cout << dp1[n] << ' ' << dp2[n] << endl;
        
        cin >> n;
    }
}



Measured memory_bytes: 18204
from fractions import gcd
from functools import reduce
 
def lcm(a,b):
    return (a*b)//gcd(a,b)
 
def lcm_list(l):
    return reduce(lcm, l)
 
 
def solve():
    N = int(input())
    T = [int(input()) for _ in range(N)]
    print(lcm_list(T))
    
solve()

Measured memory_bytes: 5076
<?php
$s = trim(fgets(STDIN));
$s = str_replace(array("\r\n","\r","\n"), '', $s);
$s = explode(" ", $s);

$n = $s[0];

$s = trim(fgets(STDIN));
$s = str_replace(array("\r\n","\r","\n"), '', $s);
$s = explode(" ", $s);

$d_list = $s;

sort($d_list);

$ret = $d_list[$n/2] - $d_list[$n/2 - 1];

echo($ret);

Measured memory_bytes: 16884
# 解説youtubeを見て実装

n = int(input())
a = list(map(int, input().split()))

all = a[0]
for i in range(1, n):
  all ^= a[i]
ans = []
for i in range(n):
  ans.append(str(all^a[i]))
#print(ans)
print(' '.join(ans))

Measured memory_bytes: 111368
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<pint> vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=n-1;i>=(0);i--)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define all(v) (v).begin(),(v).end()
#define eall(v) unique(all(v), v.end())
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
const int MOD = 1e9 + 7;
const int INF = 1e9;
const ll INFF = 1e18;

int H, W;
string s[110];

const int MAX_V = 10010; //必要な頂点数
struct Flow{
	struct edge{
		int to, cap, rev;
	};
	vector<edge> G[MAX_V];//隣接リスト
	bool used[MAX_V];
 
	void add_edge(int from, int to, int cap){
		G[from].push_back((edge){to, cap, (int)G[to].size()});//from -> to
		G[to].push_back((edge){from, 0, (int)G[from].size() - 1});//to -> from
	}
	//増加パスを探す
	int dfs(int v, int t, int f){
		if(v == t) return f;
		used[v] = true;
		for (int i = 0; i < G[v].size(); ++i){
			edge &e = G[v][i];
			if(!used[e.to] && e.cap > 0){
				int d = dfs(e.to, t, min(f, e.cap));
				if(d > 0){
					e.cap -= d;
					G[e.to][e.rev].cap += d;
					return d;
				}
			}
		}
		return 0;
	}
	//sからtへの最大流
	int max_flow(int s, int t){
		int flow = 0;
		while(1){
			memset(used, 0, sizeof(used));
			int f = dfs(s, t, INF);
			if(f == 0) return flow;
			flow += f;
		}
	}
};


int main(void){
	cin >> H >> W;
	rep(i, H)cin >> s[i];
	int sx, sy, tx, ty;
	rep(i, H)rep(j, W){
		if(s[i][j] == 'S'){
			sy = i, sx = j;
			s[i][j] = 'o';
		}else if(s[i][j] == 'T'){
			ty = i, tx = j;
			s[i][j] = 'o';
		}
	}
	if(sy == ty || sx == tx){
		printf("-1\n"); return 0;
	}

	Flow fw;
	rep(i, H){
		rep(j, W){
			if(s[i][j] == 'o'){
				fw.add_edge(i, H + j, 1);
				fw.add_edge(H + j, i, 1);
			}
		}
	}
	int start = H + W + 1, goal = H + W + 2;
	fw.add_edge(start, sy, INF), fw.add_edge(start, H + sx, INF);
	fw.add_edge(ty, goal, INF),  fw.add_edge(H + tx, goal, INF);

	int ret = fw.max_flow(start, goal);
	printf("%d\n", ret);
	return 0;
}

Measured memory_bytes: 1152
S=input()
res=0
for i in range(len(S)+1):
    for j in range(i):
        t=True
        s=S[j:i]
        for k in range(len(s)):
            if(s[k]!='A' and s[k]!='C' and s[k]!='G' and s[k]!='T'):
                t=0
                break
        if(t):
            res=max(res,len(s))
print(res)

Measured memory_bytes: 3064
import sys
from collections import *
import heapq
import math
import bisect
from itertools import permutations,accumulate,combinations,product
from fractions import gcd
def input():
    return sys.stdin.readline()[:-1]
mod=10**9+7

r1,c1,r2,c2=map(int,input().split())

# MOD combination
def cmb(n, r, mod=10**9+7):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

N = 10**6*2+2
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

def g(r,c):
    tmp=cmb(r+1+c+1,r+1)-1
    return tmp%mod

ans=0
ans+=g(r2,c2)
ans-=g(r2,c1-1)
ans-=g(r1-1,c2)
ans+=g(r1-1,c1-1)
ans%=mod
print(ans)

Measured memory_bytes: 224688
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const string ln = "\n";
constexpr int INF = 1001001001;
constexpr int MOD = 1000000007;

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

  string s;
  cin >> s;

  string ans = s.substr(0, 3);

  cout << ans << ln;

  return 0;
}

Measured memory_bytes: 3640
#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define _USE_MATH_DEFINES
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <math.h>
#include <complex>
#include <cassert>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> p;
typedef complex<double> com;
const int mod = 1e9 + 7;
const int MOD = 998244353;
const ll INF = 1e18;

template<class Abel> struct UnionFind {
	vector<int> par;
	vector<int> rank;
	vector<Abel> diff_weight;

	UnionFind(int n = 1, Abel SUM_UNITY = 0) {
		init(n, SUM_UNITY);
	}

	void init(int n = 1, Abel SUM_UNITY = 0) {
		par.resize(n); rank.resize(n); diff_weight.resize(n);
		for (int i = 0; i < n; ++i) par[i] = i, rank[i] = 0, diff_weight[i] = SUM_UNITY;
	}

	int root(int x) {
		if (par[x] == x) {
			return x;
		}
		else {
			int r = root(par[x]);
			diff_weight[x] += diff_weight[par[x]];
			return par[x] = r;
		}
	}

	Abel weight(int x) {
		root(x);
		return diff_weight[x];
	}

	bool issame(int x, int y) {
		return root(x) == root(y);
	}

	bool merge(int x, int y, Abel w) {
		w += weight(x); w -= weight(y);
		x = root(x); y = root(y);
		if (x == y) return false;
		if (rank[x] < rank[y]) swap(x, y), w = -w;
		if (rank[x] == rank[y]) ++rank[x];
		par[y] = x;
		diff_weight[y] = w;
		return true;
	}

	Abel diff(int x, int y) {
		return weight(y) - weight(x);
	}
};

int main() {
	int n, m; cin >> n >> m;
	UnionFind<int> uni(n);
	rep(i, 0, m) {
		int l, r, d;
		cin >> l >> r >> d;
		l--; r--;
		if (uni.issame(l, r)) {
			int dif = uni.diff(l, r);
			if (dif != d) {
				cout << "No" << endl;
				return 0;
			}
		}
		else {
			uni.merge(l, r, d);
		}
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 1408
n, m = map(int, input().split())

def get_divisors(num):
    f_divs, l_divs = [], []
    for i in range(1, int(num**0.5)+1):
        if not num % i:
            f_divs.append(i)
            if i != num // i:
                l_divs.append(num // i)
    return f_divs + l_divs[::-1]

for d in reversed(get_divisors(m)):
    if n * d <= m:
        print(d)
        break


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define FORR(i, n) for(ll i = (ll)n - 1LL; i >= 0LL; i--)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) begin(x), end(x)
using namespace std;
using ll = long long;
constexpr ll Mod = 998244353;
constexpr ll mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;
const double PI = acos(-1);
template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) {
    return a < b && (a = b, true);
}
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) {
    return a > b && (a = b, true);
}
/*-------------------------------------------*/

int n, m;
vector<int> G[10000];
int in[10000];

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

    cin >> n >> m;
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        G[a].push_back(b);
        in[b]++;
    }

    queue<int> que;
    vector<int> ans;
    rep(i, n) if(in[i] == 0) que.push(i);

    while(!que.empty()) {
        int v = que.front();
        ans.push_back(v);
        que.pop();
        for(int e : G[v])
            if(--in[e] == 0) que.push(e);
    }

    rep(i, n) cout << ans[i] << "\n";

    return 0;
}


Measured memory_bytes: 3796
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
using namespace std;
int a[60000];
int b[50000];
int i,j,k,p;
void getprime()
{
    k=2*i;
    while(k<55555)
    {
        if(a[k]==0)
            a[k]=1;
        k=k+i;
    }
}
void prime()
{
    for(i=2; i<55555; i++)
    {
        if(a[i]==0)
        {
            p=0;
            for(j=2; j<i; j++)
            {
                if(i%j==0)
                    break;
                else
                    p++;
            }
            if(p==i-2)
            {
                getprime();
            }
        }
    }
}
int main()
{
    int n,sum;
    scanf("%d",&n);
    prime();
    j=0;
    for(i=2; i<55555; i++)
    {
        if(a[i]==0)
        {
            b[j]=i;
            j++;
        }
    }
    i=0;
    j=0;
    while(i!=n)
    {
        if(b[j]%10==1)
        {
            if(i==0)
                printf("%d",b[j]);
            else
                printf(" %d",b[j]);
                i++;
        }
        j++;

    }
printf("\n");
    //cout << "Hello world!" << endl;
    //system("pause");
    return 0;
}


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

int N, T[500000];
long long comp;

void Merge(int *A, int left, int mid, int right)
{
	int n1 = mid - left;
	int n2 = right - mid;
	
	int L[n1 + 1], R[n2 + 1];
	for(int i = 0; i < n1; ++i)
	{
		L[i] = A[left + i];
	}
	for(int i = 0; i < n2; ++i)
	{
		R[i] = A[mid + i];
	}
	
	L[n1] = 1000000007, R[n2] = 1000000007;
	int i = 0, j = 0;
	for(int k = left; k < right; ++k)
	{
		if(L[i] < R[j])
		{
			A[k] = L[i++];
		}
		else
		{
			A[k] = R[j++];
			comp += n1 - i;
		}
	}
}

void MergeSort(int *A, int left, int right)
{
	if(left + 1 < right)
	{
		int mid = (left + right) / 2;
		MergeSort(A, left, mid);
		MergeSort(A, mid, right);
		Merge(A, left, mid, right);
	}
}

int main()
{
	cin >> N;
	for(int i = 0; i < N; ++i)
	{
		cin >> T[i];
	}
	
	comp = 0;
	MergeSort(T, 0, N);
	
	cout << comp << endl;

    return 0;
}



Measured memory_bytes: 4656