akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>

using namespace std;

int s[3001], g[3001];

int d[3001][2];

signed main() {
	int n, a, b;
	cin >> n >> a >> b;
	s[0] = a;
	g[0] = b;
	for (int i = 1; i <= n; i++) {
		cin >> s[i];
		g[i] = s[i];
	}
	d[n - 1][0] = abs(s[n - 1] - s[n]);
	d[n - 1][1] = abs(g[n - 1] - g[n]);
	for (int i = n - 2; i >= 0; i--) {
		d[i][0] = abs(s[i] - s[n]);
		d[i][1] = abs(g[i] - g[n]);
		for (int j = n - 1; j > i; j--) {
			d[i][0] = min(d[j][1], d[i][0]);
			d[i][1] = max(d[j][0], d[i][1]);
		}
	}
	cout << d[0][1];
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	static Scanner s =new Scanner(System.in);
	public static void main(String[] $){
		int N=s.nextInt(), M=s.nextInt(); //N:頂点数、　M:追加の辺の数
		int[] in=new int[N]; //各頂点の入次数
		int[] ret=new int[N]; // 返却用の配列
		HashMap<Integer, ArrayList<Integer>> lis = new HashMap<Integer,ArrayList<Integer>>(); //各頂点についてその行き先を保持
		for(int i=0;i<N-1+M;i++){
			int from =s.nextInt()-1, to=s.nextInt()-1; //それぞれの頂点番号 1~N を 0~N-1
			in[to]++;
			if (lis.containsKey(from)) lis.get(from).add(to);
			else {
				ArrayList<Integer> al = new ArrayList<Integer>();
				al.add(to);
				lis.put(from, al);
			}
		}
		// 根は入次数が０のはず。もともと根付き木であるからちょうど1つ存在。
		int root=0;
		for(int i=0;i<N;i++)
			if(in[i]==0) root=i;
		//
		ArrayDeque<Integer> q=new ArrayDeque<>(); //両端キュー
		q.add(root);
		while(!q.isEmpty()){
			int p=q.poll(); //先頭要素を取得し削除
			if (!lis.containsKey(p)) continue;
			for(int o:lis.get(p)){ //pの各々の子らに対し、
				if(--in[o]==0){ // p以外に親がいない、pを親のノードのリストから消す
					ret[o]=p+1; //pの番号を代入
					q.add(o); 
				}
			}
		}
		// for回さずに表示できる
		Arrays.stream(ret).forEach(System.out::println);
	}
}


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

int main(){
    int n;
    cin >> n;
    int x = n / 1.08;
    if((int)(x*1.08) == n) cout << x << endl;
    else if((int)((x+1)*1.08) == n) cout << x+1 << endl;
    else cout << ":(" << endl;
    
    return 0;
}


Measured memory_bytes: 256
n,T = list(map(int,input().split()))
ans = 10000
for i in range(n):
  c,t = map(int,input().split())
  if(t<=T):
    ans=min(ans,c)
  else:
    None
if(ans == 10000):
  print("TLE")
else:
  print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n==0) return 1;
    ll res=modpow(x, n/2);

    if(n%2==0) return res*res%mod;
    else return res*res%mod*x%mod;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };


// 線分 ab の偏角 返り値は[-π, π]
double argument(const pair<double, double> &a, const pair<double, double> &b){
    double ax=a.first, ay=a.second, bx=b.first, by=b.second;
    return atan2(by-ay, bx-ax);
}

/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */



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

    int a, b, c; cin >> a >> b >> c;
    if(a == b && a == c) cout << "No" << endl;
    else if(a == b || a == c || b == c) cout << "Yes" << endl;
    else cout << "No" << endl; 
    return 0;
}

Measured memory_bytes: 256
W, H, N = map(int, raw_input().split())
d = [map(int, raw_input().split()) for _ in range(N)]

r = []
for i in range(H):
    l = []
    for j in range(W):
        l.append(0)
    r.append(l)

for i in d:
    if i[2] == 1:
        for j in range(i[0]):
            for k in range(H):
                r[k][j] = 1
    elif i[2] == 2:
        for j in range(i[0],W):
            for k in range(H):
                r[k][j] = 1
    elif i[2] == 3:
        for j in range(i[1]):
            for k in range(W):
                r[j][k] = 1
    else:
        for j in range(i[1],H):
            for k in range(W):
                r[j][k] = 1

a = 0
for i in range(W):
    for j in range(H):
        if r[j][i] == 0:
            a += 1
print a


Measured memory_bytes: 2696
#include <iostream>
int a[100001];

using namespace std;
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  for (int i = 1; i < n+1; ++i) {
    cin >> a[i];
  }
  
  bool is_pass = false;
  int next_val = a[1];
  int cnt = 1;
  for (int i = 0; i < n-1; ++i) {
    if (next_val == 2) {
      is_pass = true;
      break;
    }
    next_val = a[next_val];
    cnt++;
  }
  
  if (!is_pass) cnt = -1;
  cout << cnt << endl;

  return 0;
}

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

using namespace std;
using ll =long long;
using db = double;
using vll = vector<long long>;

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; }
#define che(a,string) cout<<"//"<<string <<"=="<<(a)<<"//" <<endl;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define leftunique(a) {SORT(a);(a).erase(unique((a).begin(),(a).end()),(a).end());}
//leftuniqueは配列から同じ要素のものを取り除く 例 4 6 2 1 3 4 1 2 なら 1 2 3 4 6 になる
#define debug(x)  cout << #x << " = " << (x) << endl;
bool IsInt(double a){int b = a/1;if(a==b){return true;}else {return false;}}
bool coY() {cout <<"POSSIBLE"<<endl;}
bool coN(){cout <<"IMPOSSIBLE"<<endl;}
const int mod = 1e9 + 7;
const ll INF = 1LL << 60;
//ここから書き始める

int main()
{
	int n,m;
	cin >> n>> m;
	int latte[200000] = {}, malta[200000] ={};
	rep(i,m){
		int a , b;
		cin >> a >> b;
		--a,--b;
		if(a==0) latte[b] = true;
		if(b==n-1) malta[a] = true;
	}

	rep(i,n){
		if(latte[i] && malta[i]){
			coY();
			return 0 ;
		}
	}
	coN();
}


Measured memory_bytes: 1792
N, *AB = map(int, open(0).read().split())
A = sorted(a for a in AB[::2])
B = sorted(b for b in AB[1::2])
if N % 2:
    print(B[N // 2] - A[N // 2] + 1)
else:
    print(B[N // 2 - 1] + B[N // 2] - A[N // 2 - 1] - A[N // 2] + 1)


Measured memory_bytes: 55180
r, c = map(int, input().split())
sheet = [[0] * c for i in range(r)]
for i in range(r):
    list = input().split()
    for j in range(c):
        sheet[i][j] = int(list[j])

for i in range(r):
    sum = 0
    for j in range(c):
        sum += sheet[i][j]
        print(sheet[i][j], end=' ')
    print(sum)
total = 0
for j in range(c):
    sum = 0
    for i in range(r):
        sum += sheet[i][j]
    total += sum
    print(sum, end=' ')
print(total)




Measured memory_bytes: 6240
n = int(input())
list_A = list(map(int, input().split()))
list_C = [0, 0, 0]

for num in list_A:
    if num % 4 == 0:
        list_C[2] += 1
    elif num % 2 == 0:
        list_C[1] += 1
    else:
        list_C[0] += 1

ans = "Yes"

if list_C[1] == 0:
    if list_C[2] == 0:
        if list_C[0] != 0:
            ans = "No"
    if list_C[2] == 1:
        if list_C[0] > 2:
            ans = "No"
    if list_C[2] > 1:
        if list_C[0] > list_C[2] + 1:
            ans = "No"
else:
    if list_C[0] > list_C[2]:
        ans = "No"

print(ans)

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

int main(){
	string t; cin>>t;
	int k=t.size();
	string s;
	rep(i,k){
		if(t[i]=='?') s+="D";
		else s+=t[i];
	}
	cout<<s<<endl;
}

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

int main()
{
   int a,b,c,d;
   cin >>a;
   cin >>b;
   c=(a*b);
   d=(c%2);
   if (d==0)
   {
     cout << "Even"<< endl;
   }
   else 
   {
     cout << "Odd"<< endl;
   }
   return 0;
}

Measured memory_bytes: 3536
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define imfor(i, n) for(int i = 0; i < n; i++)
using namespace std;
 
int main() {
    int x, a, b;
    cin >> x >> a >> b;
    if (abs(x - a) < abs(x - b)) {
        cout << "A" << endl;
    }
    else {
        cout << "B" << endl;
    }
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(s, i, n) for(int i = s; i < (int)(n); i++)

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

	int num = 0, dim = 0;
	cin>>num>>dim;
    int point[11][11];
    REP(n, num) 
    {
        REP(d, dim)
        {
            cin >> point[n][d];
        }    
    }

    int ret = 0;
    REP(n, num) 
    {    
        FOR(n + 1, n2, num) 
        {
            int norm = 0;
            REP(d, dim)
            {
                int dir = point[n][d] - point[n2][d];
                norm += dir * dir;
            }
            bool flag = false;
            REP(k, norm)
            {
                if((k + 1) * (k + 1) == norm)
                {
                    flag = true;
                    break;
                }
            }
            if(flag) ret++;                
        }
    }
    std::cout << ret << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<vector>
#include<string.h>
#include<algorithm>
using namespace std;
char str[1100];
int c[1100];
int g[60][60];
int G[60][60];
int in[60];
int out[60];
int UF[60];
int FIND(int a){
	if(UF[a]<0)return a;
	return UF[a]=FIND(UF[a]);
}
void UNION(int a,int b){
	a=FIND(a);b=FIND(b);if(a==b)return;UF[a]+=UF[b];UF[b]=a;
}
int liv[60];
bool chk(int at){
	for(int i=0;i<60;i++)UF[i]=-1;
	for(int i=0;i<60;i++)liv[i]=0;
	for(int i=0;i<60;i++)for(int j=0;j<60;j++){
		if(G[i][j]){
			liv[i]=liv[j]=1;
			UNION(i,j);
		}
	}
	for(int i=0;i<60;i++)for(int j=0;j<60;j++)if(liv[i]&&liv[j]&&FIND(i)!=FIND(j))return false;
	for(int i=0;i<60;i++)if(liv[i]&&FIND(at)!=FIND(i))return false;
	return true;
}
int L[5100];
int R[5100];
int main(){
	while(1){
		scanf("%s",str);
		if(str[0]=='#')return 0;
		int n=strlen(str);
		if(n<=2){
			printf("No Results\n");continue;
		}
		for(int i=0;i<60;i++)for(int j=0;j<60;j++)g[i][j]=0;
		for(int i=0;i<n;i++){
			if('a'<=str[i]&&str[i]<='z')c[i]=str[i]-'a';
			else c[i]=str[i]-'A'+26;
		}
		for(int i=0;i<n-1;i++)g[c[i]][c[i+1]]=1;
		for(int i=0;i<60;i++)in[i]=out[i]=0;
		int m=0;
		for(int i=0;i<60;i++)for(int j=0;j<60;j++){
			if(g[i][j]){
				m++;
				in[j]++;out[i]++;
			}
		}
		int pc=0;
		int mc=0;
		int pt=0;
		int pa=0;
		int ma=0;
		for(int i=0;i<60;i++){
			if(out[i]>in[i]){
				pc++;pt+=out[i]-in[i];
				pa=i;
			}else if(in[i]>out[i]){
				mc++;
				ma=i;
			}
		}
		for(int i=0;i<5100;i++)L[i]=R[i]=0;
	//	for(int i=0;i<60;i++)if(in[i]||out[i])printf("%d %d\n",in[i],out[i]);
	//	printf("%d %d %d %d\n",pc,mc,pt,pa);
		if(pc==0&&mc==0){
			printf("%d\n",m+1);continue;
		}
		int ret=m+pt;
		if(pc>1||mc>1){
			printf("%d\n",ret);continue;
		}
		g[ma][pa]+=pt-1;
		m+=pt-1;
		int at=pa;
		for(int i=0;i<60;i++)for(int j=0;j<60;j++)G[i][j]=g[i][j];
		
		for(int i=0;i<m;i++){
			for(int j=0;j<60;j++){
				if(!G[at][j])continue;
				G[at][j]--;
				if(chk(j)){
					at=j;
					L[i]=j;
					break;
				}else G[at][j]++;
			}
		}
		at=pa;
		for(int i=0;i<60;i++)for(int j=0;j<60;j++)G[i][j]=g[i][j];
		//for(int i=0;i<m;i++)printf("%d %d\n",L[i],R[i]);
		for(int i=0;i<m;i++){
			for(int j=59;j>=0;j--){
				if(!G[at][j])continue;
				G[at][j]--;
				if(chk(j)){
					at=j;
					R[i]=j;
					break;
				}else G[at][j]++;
			}
		}
	//	for(int i=0;i<m;i++)printf("%d %d\n",L[i],R[i]);
		bool ok=false;
		for(int i=0;i<m;i++){
			if(L[i]!=R[i])ok=true;
		}
		if(m+1<n)ok=true;
		if(ok)printf("%d\n",m+1);
		else printf("%d\n",m+2);
	}
}

Measured memory_bytes: 1052
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n-1);i>=0;i--)
#define FOR(i,n,m) for(int i=n;i<=(int)(m);i++)
#define RFOR(i,n,m) for(int i=(int)(n);i>=m;i--)
#define all(x) (x).begin(),(x).end()
#define sz(x) int(x.size())
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;
vector<int> dy={1,0,-1,0};
vector<int> dx={0,1,0,-1};
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

int n;
string s;
int f(int len){
    deque<string> que;
    map<string,int> mp;
    rep(i,n-len+1){
        que.push_back(s.substr(i,len));
        if(sz(que)==len){
            if(mp[que.back()]>0) return true;
            mp[que.front()]++;
            que.pop_front();
        }
    }
    return false;
}

int main(){
    cin>>n>>s;
    int ng = n, ok = 0;
    
    while (ng - ok > 1) {
        int mid = (ng + ok) / 2;
        (f(mid) ? ok : ng) = mid;
    }
    
    cout<<ok<<endl;
}


Measured memory_bytes: 6528
// Gaurav Aggarwal

/*
useful stl
array<ll,size> ar;         //size(),front(),back(),fill(),empty()
deque<ll> d                //push_back(),push_front(),pop_front(),pop_back()
vector<ll> v(size,val);    //push_back(),*max_element(v.begin(),v.end()),accumulate(v.begin(),v.end(),0)
stack<ll> g;               //push(),pop(),top(),size(),empty()         LIFO
queue<ll> q;               //push(),size(),front(),back(),empty()      FIFO
priority_queue<ll> pq
*/

#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<ll,ll> ipair;
typedef pair<long,long> lpair;
typedef pair<double,double> pdd;
#define scan(x) do{while((x=getchar_unlocked())<'0'); for(x-='0'; '0'<=(_=getchar_unlocked()); x=(x<<3)+(x<<1)+_-'0');}while(0)
char _;
#define For(i, a, b) for(__typeof (a) i=a; i<=b; i++)
#define mod 1000000007
#define PI 3.141592653589793238462643383279502884 
#define debug1(a) cout<<a<<"\n";
#define debug2(a,b) cout<<a<<" "<<b<<"\n";
#define debug3(a,b,c) cout<<a<<" "<<b<<" "<<c<<"\n";
#define debug_arr(a,n) {for(__typeof (n) i=0; i<n; ++i) {cout<<a[i]<<" ";}}
#define inp_arr(a,n) for(__typeof (n) i=0; i<n; ++i) {cin>>a[i];}
#define beg_arr(a,n) for(__typeof (n) i=0; i<n; ++i) {a[i] = 0;}

ll power(ll x, ll y) 
{ 
    ll res = 1;   
    while (y > 0) { 
        if (y & 1) 
            res = (res*x)%mod; 
        y = y>>1;
        x = (x*x)%mod; 
    } 
    return res%mod; 
}


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

    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);
    // freopen("out.txt", "w", stdout); 
    // #endif  

    int n;
    cin>>n;

    int a[n];
    inp_arr(a,n);

    int maxi = a[0];

    int ans = 1;
    for(int i=1;i<n;++i) {
        if(a[i] >= maxi) {
            ++ans;
            maxi = a[i];
        }
    }   

    cout<<ans;


    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod=1000000007;
ll e[40];
ll gyaku(ll a){
  ll ret=1;
  ll now=a;
  for(ll i=0;i<40;i++){
    if(e[i])ret*=now;
    ret%=mod;
    now*=now;
    now%=mod;
  }
  return ret;
}
ll nck(ll n,ll k){
  if(2*k>n)k=n-k;
  ll ret=1;
  for(ll i=0;i<k;i++){
    ret=ret*(n-i);
    ret%=mod;
    ret*=gyaku(i+1);
    ret%=mod;
  }
  return ret;
}
int main(){
  ll h,w,a,b;cin>>h>>w>>a>>b;
  
  ll r=mod-2;
  for(ll i=0;;i++){
    e[i]=r%2;
    r/=2;
    if(r==0)break;
  }
  ll ans=0;
  ll no=nck(h+w-2-b,w-1-b);
  for(ll i=0;i<h-a;i++){
    ans+=no;
    ans%=mod;
    no*=i+b;
    no%=mod;
    no*=gyaku(i+1);
    no%=mod;
    no*=h-i-1;
    no%=mod;
    no*=gyaku(h+w-2-i-b);
    no%=mod;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
int n;
vector <vector<int> > pat;
vector <int> curr;

void dfs (int now )
{
	if (now == 0 ){
		pat.push_back (curr );
		return;
	} // end if

	int last = now;
	if (!curr.empty() )
		last = curr.back();

	for (int i = min (now, last ); i >= 1; i-- ){
		curr.push_back (i );
		dfs (now-i );
		curr.pop_back();
	} // end for
}

int main()
{
	while (1 ){
		pat.clear();
		scanf ("%d", &n );
		if (n == 0 ) break;
		
		curr.clear();
		dfs (n );

		rep (i, pat.size() ){
			rep (j, pat[i].size() ){
				printf ("%d", pat[i][j] );
				if (j != pat[i].size() - 1 )
					printf (" ");
			} // end rep
			printf ("\n" );
		} // end rep
	} // end loop
		
	return 0;
}

Measured memory_bytes: 0
// Atcorder B-Battle

/*
高橋君 HP: A, Pow: B
青木君 HP: C, Pow: D
0以下で敗北
高橋君が勝ちで'Yes', 負けで'No'
1<= A,B,C,D <= 100
*/
#include <stdio.h>
void battle(int t_attack, int my_hp); // 戦闘
int main() {
  int a, b, c, d; // 変数宣言
  scanf("%d%d%d%d", &a, &b, &c, &d); // 標準入力

  // if ((a/d)>(c/d)||(a%d)>(c%d)) {
  
  // if ((a/d)>(c/b)||(a%d)>=(c%b)) {
  //   printf("Yes");
  // } else {
  //   printf("No");
  // }

  for(int i=0; a>0&&c>0; i++) { // 戦闘ループ
  // printf("%d %d %d %d\n",a,b,c,d);
    if (i%2==0) {
      c-=b; // 高橋君→青木君 : 攻撃
    } else {
      a-=d; // 青木君→高橋君 : 攻撃
    }
  }
  if (a<=0) { // 結果
    printf("No\n");
  } else {
    printf("Yes\n");
  }
  return 0;
}

// oh |ω・)
// oh, だめだわ


Measured memory_bytes: 1628
using System;

namespace _1_1c
{
    class Program
    {
        static void Main(string[] args)
        {
            int piyo=1;
            int perimeter = 0;
            string ab;
            string[] side;
            ab=Console.ReadLine();
            
            side= ab.Split(' ');
            foreach( string hoge in side)
            {
                piyo = piyo * int.Parse(hoge);
                perimeter += int.Parse(hoge)*2;
            }
            
            
            Console.WriteLine("{0} {1}",piyo,perimeter);
        }
    }
}



Measured memory_bytes: 15880
#include<stdio.h>
int main()
{
    int a,b,c,n,m;
    scanf("%d %d %d",&a,&b,&c);
    n=(b-a);
    m=(c-b);
    if(n==m)
        printf("YES\n");
    else
        printf("NO\n");
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <stdio.h>
#include <cmath>

using namespace std;

int main() {
	double x1, y1, x2, y2, distance, height, length;

	cin >> x1 >> y1 >> x2 >> y2;

	height = (double)y2 - y1;
	length = (double)x2 - x1;

	distance = sqrt(height * height + length * length);

	printf("%lf", distance);

	return 0;
}


Measured memory_bytes: 3276
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;

typedef long long ll;
typedef vector<int> vi;

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

int main(){
    int k, x;
    cin >> k >> x;

    for(int i = x-k+1; i < x+k; i++){
        cout << i << " ";
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
  int a, b;
  cin >> a >> b;
  if ( ( a * b ) % 2 == 0 ) {
    cout << "Even" << endl;
  }
  else if ( ( a * b ) % 2 == 1 ) {
    cout << "Odd" << endl;
  }
  return 0;
}

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

using namespace std;

struct Question {
    int l;
    int r;
};

int main() {
    int N, Q;
    cin >> N, cin >> Q;
    string s;
    cin >> s;
    struct Question q[Q];
    for (int i = 0; i < Q; ++i) {
        int l, r;
        cin >> l, cin >> r;
        q[i] = {l, r};
    }
    int counts[s.length()];
    for (int i = 0; i < s.length(); ++i) counts[i] = 0;
    int count = 0;
    for (int i = 0; i < s.length() - 1; ++i) {
        if (s[i] == 'A' && s[i+1] == 'C') ++count;
        counts[i+1] = count;
    }
    for (int i = 0; i < Q; ++i) cout << counts[q[i].r-1] - counts[q[i].l-1] << endl;
    return 0;
}

Measured memory_bytes: 2176
#include<bits/stdc++.h>
using namespace std;
#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif
#define int long long

signed main(){

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

  bitset<2020 * 2020> dp;
  dp[0] = true;
  for(int i = 0; i < n; i++){
    dp |= dp << a[i];
  }

  for(int i = (sum+1)/2; i < n * 2020; i++){
    if(dp[i]){
      cout << i << endl;
      return 0;
    }
  }

  return 0;
}


Measured memory_bytes: 1920
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll inf = 3e18;
const char sp = ' ';

string S;

int main() {
	cin >> S;
	for (int i = 0; i < 7; i++) {
		string T;
		for (int k = 0; k < i; k++) {
			T += S[k];
		}
		for (int k = i; k < 7; k++) {
			T += S[S.size() - 7 + k];
		}
		if (T == "keyence") {
			cout << "YES" << endl;
			return 0;
		}
	}
	cout << "NO" << endl;
	return 0;
}

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

using namespace std;

#define PB push_back
#define f first
#define s second
#define what_is(x) cerr << #x << " is " << x << endl;

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

const int INF = 1000000007;
const ll MOD = 1000000007;

int ct[200005], ct2[200005];
void solve_test()
{
    int n;
    cin >> n;
    int a[n], b[n];
    multiset<pair<int, pii>> s;
    vector<pii> sorted_ct;
    vector<int> v[n];

    for(int i=0; i<n; i++)
    {
        cin >> a[i];
        a[i]--;
        ct[a[i]]++;
        v[a[i]].PB(i);
    }
    for(int i=0; i<n; i++)
    {
        cin >> b[i];
        b[i]--;
        ct2[b[i]]++;
    }
    int it[n];
    memset(it, 0, sizeof(it));
    int ans[n];
    for(int i=0; i<n; i++)
    {
        ans[i] = -1;
    }
    for(int i=0; i<n; i++)
    {
        if(ct[i] + ct2[i] > n)
        {
            cout << "No\n";
            return;
        }
        if(ct2[i] > 0)
            s.insert({-(ct[i] + ct2[i]), {ct2[i], i}});
    }

    for(int i=0; i<n; i++)
    {
        if(ct[i])
            sorted_ct.PB({ct[i], i});
    }
    sort(sorted_ct.begin(), sorted_ct.end(), greater<pii>());
    for(pii p : sorted_ct)
    {
        int num = p.f;
        while(num && !s.empty())
        {
            auto pos = s.begin();
            pair<int, pii> c = *pos;
            if(c.s.s == p.s)
            {
                if(s.size() == 1)
                    break;
                ++pos;
            }
            assert(pos != s.end());
            c = *pos;
            s.erase(pos);
            int t = min(num, c.s.f);
            num -= t;
            c.s.f -= t;
            ct2[c.s.s] -= t;
            if(c.s.f > 0)
            {
                s.insert(make_pair(c.f + t, make_pair(c.s.f, c.s.s)));
            }
            for(int i=0; i<t; i++)
            {
                ans[v[p.s][it[p.s]++]] = c.s.s;
            }
        }
        if(num)
        {
            cout << "No\n";
            return;
        }
        auto x = s.find(make_pair(-(ct[p.s]+ct2[p.s]), make_pair(ct2[p.s], p.s)));
        if(x != s.end())
        {
            s.erase(x);
        }
        ct[p.s] = 0;
//        what_is(p.s);
//        what_is(ct2[p.s]);
        if(ct2[p.s] > 0)
        {
            s.insert({INF, {ct2[p.s], p.s}});
        }

    }
    cout << "Yes\n";
    for(int i=0; i<n; i++)
    {
        cout << ans[i]+1 << " ";
    }



}

signed main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    int tests;
    tests = 1;
    //cin >> tests;
    while(tests--)
    {
        solve_test();
    }
    return 0;
}


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

def num2alpha(n):
    if n <= 26:
        return chr(96 + n)
    elif n % 26 == 0:
        return num2alpha(n // 26 - 1) + chr(122)
    else:
        return num2alpha(n // 26) + chr(96 + n % 26)

print(num2alpha(n))

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

using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)
#define repa(i,a,n) for(int i=(a);i<(n);i++)
#define rrep(i,n) for(int i=n;i>=0;i--)
#define rrepa(i,a,n) for(int i=n;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007
#define cmax(a,b) a=max(a,b)
#define cmin(a,b) a=min(a,b)
#define vc vector

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int,int> pi;

int main(){

    int n,m;
    cin>>n>>m;

    vi p(m);
    vc<string> s(m);
    rep(i,m)cin>>p[i]>>s[i];

    vi pena(n+1,0);

    int ac=0,wa=0;

    rep(i,m){
        if(pena[p[i]]==-1)continue;

        if(s[i]=="AC"){
            ac++;
            wa+=pena[p[i]];
            pena[p[i]]=-1;
        }else{
            pena[p[i]]++;
        }
    }

    cout<<ac<<" "<<wa<<"\n";

    return 0;
}

Measured memory_bytes: 6528
// AUTHOR : Kishan Srivastav
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define in freopen("input.txt", "r", stdin)
#define out freopen("output1.txt", "w", stdout)
#define ios ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);


int main() {
	ios
#ifndef ONLINE_JUDGE
	in;
	out;
#endif
	int n;
	cin>>n;
	int d[n];
	for (int i = 0; i < n; i++){
		cin>>d[i];
	}
	int sum = 0;
	for (int i = 0; i < n; ++i){
		for (int j = i+1; j < n; j++){
			sum = sum + (d[i]*d[j]);
		}
	}
	cout<<sum<<endl;
}

Measured memory_bytes: 3620
import java.util.*;

public class Main{
    public static void main(String[] args){
       Scanner sc = new Scanner(System.in);
       int A = sc.nextInt();
       int B = sc.nextInt();
       if(A == 1 || B == 1){
        if((A == 1) && (B != 1)){
             System.out.println("Alice");
        }else if(A == 1 && B == 1){
             System.out.println("Draw");
        }else{
             System.out.println("Bob");
        }
    }else{
        if(A > B){
            System.out.println("Alice");
        }else if(A == B){
            System.out.println("Draw");
        }else{
            System.out.println("Bob");
        }
    }  
}
}   

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

#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define P pair<int,int>
#define Abs(a,b) max(a,b)-min(a,b)
#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 Cout(x) cout<<(x)<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl
#define possible(n) cout << ((n) ? "possible" : "impossible"  ) << endl

typedef long long ll;

using namespace std;

const int INF = 1e9,MOD = 1e9 + 7;
const ll LINF = 1e18;

//long long int kaizyo(long long int hh){
  //  cmp=1;
    //while(hh>1){
      //  cmp=(cmp*hh)%MOD;
        //hh--;
    //}
    //return cmp;
//}

//while(x!=0){
            //sum+=x%10;
           // x/=10;
        //}
        //各桁の和

//pair<int,int> p[100000];
//P r[100000];
//cin >> tmp;
//p[i]=make_pair(tmp,i);
//cout << p[i].second+1 << endl;//ペアの右側つまりiを出力

//s.find(w[i])==string::npos
//findの使い方

//for(int i=0;i<n;i++){
   // b[i]=x%2;
    //x/=2;
  //}二進数

long long int n,cnt=0,ans=0,a,b,c,cmp,cmpp,m,h,w,x,y,sum=0,pos;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
string alph("CODEFESTIVAL2016"),s;

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

       cin >> s;
       rep(i,s.size()){
           if(s[i]!=alph[i]){
               ans++;
           }
       }
       Cout(ans);
return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <map>
#include <queue>
#include <cmath>
#include <iomanip>

#define MOD (1000000007)

using namespace std;

typedef long long ll;
typedef pair<ll, ll> tup;
const int MAX = 510000;

long long fac[MAX], finv[MAX], inv[MAX];


ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}


// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

map<ll,ll> prime;//素因数分解でそれぞれの素数がいくつ出てきたかを保存するmap

//O(√n)
//整列済み(mapはkeyで自動で整列される)
void prime_factorize(ll n){
    if(n<=1) return;
    ll l=sqrt(n);
   for(ll i=2;i<=(ll)(l);i++) { //
        if(n%i==0){
        prime_factorize(i);prime_factorize(ll(n/i));return;
        }
    }
    //mapでは存在しないkeyの場合も自動で構築される
    prime[n]++;return;
}


int main() {
    ll N;
    cin >> N;

    vector<ll> A(N), B(N);
    for(ll i = 0; i < N; i++) {
        cin >> A[i] >> B[i];
    }

    sort(A.begin(), A.end());
    sort(B.begin(), B.end());

    double mid_min = 0;
    double mid_max = 0;

    if(N % 2 == 0) {
        mid_min = (A[N/2] + A[N/2 - 1]) /2.0;
        mid_max = (B[N/2] + B[N/2 - 1]) /2.0;
    } else {
        mid_min = A[(N-1)/2];
        mid_max = B[(N-1)/2];
    }


    if(N % 2 == 0) {
        cout << (ll) ((mid_max - mid_min) * 2.0  + 1.0)<< endl;
    } else {
        cout << (ll) ((mid_max - mid_min)   + 1.0)<< endl;
    }






    return 0;    
}



Measured memory_bytes: 6432
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cassert>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define rep(i,n) FOR(i,0,n)
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define vint vector<int>
#define vdouble vector<double>
#define vstring vector<string>
using namespace std;

#include<map>
#include<set>
#include<queue>

typedef long long ll;
typedef unsigned long long ull;

const int MAX_N = 1000000;

class Program{

	int N;
	string answer;
	char ret[MAX_N];

	char nextchr(char center, char ans, char left){

		if ((center == 'S' && ans == 'o') || (center == 'W' && ans == 'x')){
			return left;
		}
		else{
			return (left == 'S' ? 'W' : 'S');
		}
	}

	bool check(char center, char ans, char left, char right){
		return right == nextchr(center, ans, left);
	}

	bool run(char first, char second){

		ret[0] = first;
		ret[1] = second;
		for (int i = 2; i < N; i++){
			ret[i] = nextchr(ret[i - 1], answer[i - 1], ret[i - 2]);
		}

		return (check(ret[0], answer[0], ret[N - 1], ret[1]) &&
			check(ret[N - 1], answer[N - 1], ret[0], ret[N - 2]));
	}

public :
	
	void main() {

		cin >> N;
		cin >> answer;

		bool success = false;

		if (!success){
			success = run('S', 'S');
		}
		if (!success){
			success = run('S', 'W');
		}
		if (!success){
			success = run('W', 'S');
		}
		if (!success){
			success = run('W', 'W');
		}

		if (success){
			rep(i, N){
				cout << ret[i];
			}
			cout << endl;
		}
		else{
			cout << -1 << endl;
		}

	}

};

int main() {
	Program p;
	p.main();
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
 
typedef pair<int, int> p;
 
int main() {
	cin.tie(0);
    ios::sync_with_stdio(false);

    vector<int> a(20);

    for(int i = 0; i < 3; i++) {
        int A;
        cin >> A;
        a[A]++;
    }

    if(a[5] == 2 && a[7] == 1) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 3596
from collections import Counter
 
n = int(input())
d = list(map(int, input().split()))
m = int(input())
t = list(map(int, input().split()))
 
counter1 = Counter(d)
counter2 = Counter(t)
 
for k, v in counter2.items():
    if counter1[k] < v:
        print('NO')
        exit()
print('YES')

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

int main(void){
	ios::sync_with_stdio(false);
	int N,i,j,k;
	cin >> N;
	int d[N];
	for (i = 0; i < N; i++) cin >> d[i];
	sort(d, d + N, greater<int>());
	j = 1;
	k = 0;
	for (i = 0; i < N-1; i++) {
		if (d[i] != d[i + 1]) j++;
	}

	cout << j << endl;
	return 0;
}


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

main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int A, B, C, K; cin >> A >> B >> C >> K;
    if(K < A) cout << K;
    else if(K <= A + B) cout << A;
    else cout << A-(K-(A+B));
}

Measured memory_bytes: 3624
#include <cstdio>
#include <climits>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <list>
#include <set>
#include <bitset>
#include <iterator>
#define loop(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define debug(x)  cout << #x << " = " << (x) << endl;

using namespace std;
using LL = long long;
using ULL = unsigned long long;

int main() {
    int n; cin >> n;
    vector<int> a(n), b(n), c(n - 1);
    rep(i, n) {
        cin >> a[i];
    }
    rep(i, n) {
        cin >> b[i];
    }
    rep(i, n - 1) {
        cin >> c[i];
    }
    LL ans = 0;
    rep(i, n) {
        ans += b[a[i] - 1];
        if (i != n - 1) {
            if (a[i + 1] == a[i] + 1) ans += c[a[i] - 1];
        }

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


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

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (size_t i = 0; i < size_t(n); i++)
#define forn1(i,n) for (size_t i = 1; i <= size_t(n); i++)
#define popcnt __builtin_popcount
#define ffs __builtin_ffs
#define ctz __builtin_ctz
#define clz __builtin_clz
#define all(a) (a).begin(), (a).end()
 
using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pil = pair<int,ll>;
using pll = pair<ll,ll>;
template <typename T> using vec = vector<T>;
using vi = vec<int>;
using vl = vec<ll>;
template <typename T> using que = queue<T>;
template <typename T> using deq = deque<T>;
 
template <typename T> T id(T b) {return b;};
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}
template <typename S, typename K> bool contains(S s, K k) { return s.find(k) != s.end(); }
void fastio() { ios_base::sync_with_stdio(false); cin.tie(nullptr); }
constexpr ll TEN(int n) { if (n == 0) return 1LL; else return 10LL*TEN(n-1); }

const ll MAX_N = 200000;
int n;
ll a[MAX_N];
ll s[MAX_N];

int main()
{
    fastio();

    cin >> n;
    forn(i,n) cin >> a[i];

    s[0] = a[0];
    forn1(i,n-1) {
        s[i] = s[i-1] + a[i];
    }

    ll ans = LLONG_MAX;
    forn(i,n-1) {
        ll x = s[i];
        ll y = s[n-1] - x;
        chmin(ans, abs(x - y));
    }

    cout << ans << endl;

    return 0;
}


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

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

#define all(x) (x).begin(),(x).end()

void chmin(int &a, int b) {
  if (a > b) a = b;
}

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
  // freopen("out", "w", stdout);
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(n, 2e9);
  for (int i = 0; i < n - 1; i++) {
    int t; cin >> t;
    chmin(a[i], t);
    chmin(a[i + 1], t);
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    ans += a[i];
  }
  cout << ans << '\n';
}


Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define Rep(i,a,b) for(register int i=(a);i<=int(b);++i)
#define Dep(i,a,b) for(register int i=(a);i>=int(b);--i)
#define rep(i,a,b) for(register int i=(a);i<int(b);++i)
#define mem(x,v) memset(x,v,sizeof(x))
#define gc getchar
#define pc putchar
#define fi first
#define se second
#define debug(x) cout << #x" = " << x << endl;
#define pp(x,y) cout << "pp: " << x << " " << y << endl;
#define rank __RAnK
inline ll read(){
	register ll x=0,f=1;register char c=gc();
	for(;!isdigit(c);c=gc())if(c=='-')f=-1;
	for(;isdigit(c);c=gc())x=(x<<1)+(x<<3)+(c^48);
	return x*f;
}
#define rd read
void write(ll x){if(x<0)x=-x,pc('-');if(x>=10)write(x/10);putchar(x%10+'0');}
void writeln(ll x){write(x);puts("");}
int cnt1[100005],cnt2[100005],b[100005],c[100005],a[100005];
int n;
bool cmp1(int a,int b){
	return cnt1[a] > cnt1[b];
}
bool cmp2(int a,int b){
	return cnt2[a] > cnt2[b];
}
int check(int a,int b){
	if(a==b) return n+1;
	return n - cnt1[a] - cnt2[b];
}
int main(){
	n = rd();
	Rep(i,1,n) a[i] = rd();
	for(int i=1;i<=n;i+=2){
		cnt1[a[i]]++;
	}
	for(int i=2;i<=n;i+=2){
		cnt2[a[i]]++;
	}
	Rep(i,1,100000){
		b[i] = i;
		c[i] = i;
	}
	sort(b+1,b+1+100000,cmp1);
	sort(c+1,c+1+100000,cmp2);
	int ans = 0x3f3f3f3f;
	ans = min(ans,check(b[1],c[1]));
	ans = min(ans,check(b[2],c[1]));
	ans = min(ans,check(b[1],c[2]));
	ans = min(ans,check(b[2],c[2]));
	writeln(ans);
	return 0;
}

Measured memory_bytes: 2176
#include "bits/stdc++.h"

using namespace std;

struct Edge
{
    int from, to, cost;
    Edge(int from, int to, int cost) : from(from), to(to), cost(cost) {}
};

using Edges = std::vector<Edge>;
using Graph = std::vector<Edges>;
using P = std::pair<int, int>;
constexpr int INF = 1e9;

vector<int> bfs01(const Graph &g, int s)
{
    int n = g.size();

    vector<int> d(n, INF);
    deque<int> que;
    que.push_back(s);
    d[s] = 0;
    while (!que.empty())
    {
        int cur = que.front();
        que.pop_front();
        for (auto p : g[cur])
        {
            int dst = p.to, w = p.cost;
            assert(w == 0 || w == 1);
            if (d[dst] != INF)
                continue;
            if (w == 0)
            {
                d[dst] = d[cur];
                que.push_front(dst);
            }
            else
            {
                d[dst] = d[cur] + 1;
                que.push_back(dst);
            }
        }
    }
    return d;
}

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

    int n;
    cin >> n;
    Graph g(n);
    for (int i = 0; i < n - 1; i++)
    {
        int u, v, w;
        cin >> u >> v >> w;
        w %= 2;
        u--;
        v--;
        g[u].push_back(Edge(u, v, w));
        g[v].push_back(Edge(v, u, w));
    }
    auto d = bfs01(g, 0);
    for (int i = 0; i < n; i++)
    {
        cout << d[i] % 2 << endl;
    }
}


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

int main() {
	int n;
	cin >> n;
	long* num = new long[n];
	for (int i = 0; i < n; i++)
		cin >> num[i];
	int primeNum(long*, int);
	cout << primeNum(num, n) << endl;
	return 0;
}

int primeNum(long* num, int n) {
	int count = 0;
	bool b;
	for (int i = 0; i < n; i++) {
		for (long j = 2; j <= sqrt(num[i]); j++) {
			b = true;
			if (num[i] % j == 0) {
				b = false;
				break;
			}
		}
		if (b) count++;
	}
	return count;
}


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



int main() {
    vector<int> a(9);
    rep(i,9) {
        cin >> a[i];
    }
    
    int n;
    cin >> n;
    vector<int> b(n);
    rep(i,n) {
        cin >> b[i];
    }
    
    rep(i,9) {
        rep(j,n) {
            if(a[i] == b[j])
                a[i] = 0;
        }
    }
    
    bool tf = false;
    if((a[0] == 0 && a[1] == 0 && a[2] == 0) ||
       (a[3] == 0 && a[4] == 0 && a[5] == 0) ||
       (a[6] == 0 && a[7] == 0 && a[8] == 0) ||
       (a[0] == 0 && a[3] == 0 && a[6] == 0) ||
       (a[1] == 0 && a[4] == 0 && a[7] == 0) ||
       (a[2] == 0 && a[5] == 0 && a[8] == 0) ||
       (a[0] == 0 && a[4] == 0 && a[8] == 0) ||
       (a[2] == 0 && a[4] == 0 && a[6] == 0))
        tf = true;
    
    if(tf)
        cout << "Yes" ;
    else
        cout << "No" ;
    
    
    return 0;
}


Measured memory_bytes: 3636
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        int x = sc.nextInt();
        for (int i = x - k + 1; i <= x + k -1; i++) {
            System.out.print(i + " ");
        }
    }
}


Measured memory_bytes: 21844
def bfs(n, links):
    painted = set()
    fq = {0}
    sq = {n - 1}
    fs, ss = 0, 0
    while True:
        nfq, nsq = set(), set()
        for v in fq:
            cfq = links[v] - painted
            if cfq:
                fs += len(cfq)
                painted.update(cfq)
                nfq.update(cfq)
        fq = nfq
        for v in sq:
            csq = links[v] - painted
            if csq:
                ss += len(csq)
                painted.update(csq)
                nsq.update(csq)
        sq = nsq
        if not fq:
            ss = n - fs
            break
        if not sq:
            fs = n - ss
            break
    return fs > ss


n = int(input())
links = [set() for _ in range(n)]
for _ in range(n - 1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    links[a].add(b)
    links[b].add(a)
print('Fennec' if bfs(n, links) else 'Snuke')


Measured memory_bytes: 42368
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<string.h>
#include<math.h>
#include<map>
#include<iomanip>
#include<queue>

const long long INF = 1e17+7;
const long long MOD = 1e9+7;
const double PI=acos(-1);

using namespace std;

int main(){
	
	long long n;
	cin >> n;
	vector<long long> a(n);
	for(long long i=0;i<n;i++){
		cin >> a[i];
	}
	
	sort(a.begin(),a.end());
	
	long long ans = 1;
	for(long long i=0;i<n;i++){
		if(a[i]==0){
			cout << "0" << endl;
			return 0;
		}
		if(a[i]<=1000000000000000000/ans){
			ans*= a[i];
		}else{
			cout << "-1" << endl;
			return 0;
		}
		if(ans>=1000000000000000001){
			cout << "-1" << endl;
			return 0;
		}
	}
	cout << ans << endl;	
	
	return 0;
}


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

namespace ABC123C
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = BigInteger.Parse(Console.ReadLine());
            var a = BigInteger.Parse(Console.ReadLine());
            var b = BigInteger.Parse(Console.ReadLine());
            var c = BigInteger.Parse(Console.ReadLine());
            var d = BigInteger.Parse(Console.ReadLine());
            var e = BigInteger.Parse(Console.ReadLine());

            var teiinn = new[] { a, b, c, d, e };
            teiinn = teiinn.Select(x => teiinn.Min()).ToArray();

            var times = teiinn.Select(x => n / x + (n % x == 0 ? 0 : 1)).ToArray();

            var minTime = new BigInteger[teiinn.Length];


            minTime[0] = times[0];

            for (int i = 1; i < times.Length; i++)
            {
                if (minTime[i - 1] * teiinn[i] < minTime[i - 1] * teiinn[i - 1])
                {
                    var rem = BigInteger.Min(BigInteger.Min(minTime[i - 1] * teiinn[i - 1], n) - BigInteger.Min(minTime[i - 1] * teiinn[i], n), n);

                    minTime[i] = minTime[i - 1] + (rem / teiinn[i]) + (rem % teiinn[i] == 0 ? 0 : 1);
                }
                else
                {
                    minTime[i] = minTime[i - 1] + 1;
                }
            }

            Console.WriteLine(minTime.Last());
        }
    }
}


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

typedef long long ll;

 
int main(){
  int n, k;
  cin >> n >> k;
  int l[n];
  for(int i=0; i<n; i++) cin >> l[i];
  sort(l, l+n, greater<int>());
  int ans = 0;
  for(int i=0; i<k; i++){
    ans += l[i];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
// 基本テンプレート
 
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
using namespace std;
 
#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;

int X;
bool solve(int x) {
    // 回数が X 以下であれば良い
    int cnt = 0;
    while(x > 2) {
        cnt++;
        x = (x - 1) / 2;
    }
    return cnt <= X;
}
 
signed main() {
    cin >> X;
    int ub = INF, lb = 0;
    while(ub - lb > 1) {
        int mid = (ub + lb) / 2;
        if(solve(mid)) lb = mid;
        else ub = mid;
    }
    cout << lb << endl;
    return 0;
}

Measured memory_bytes: 256