akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main(){
  int D; cin >> D;
  vector<int> c(26);
  for(int i=0; i<26; i++) cin >> c[i];
  vector<vector<int>> s(D,vector<int>(26));
  for(int i=0; i<D; i++){
    for(int j=0; j<26; j++){
      cin >> s[i][j];
    }
  }
  vector<vector<int>> lastc(D+1,vector<int>(26,0));
  vector<int> t(D);
  
    srand(std::time(nullptr));
  
  for(int i=1; i<=D; i++){
    
    int cont; /*cin >> cont;
    cont--;*/ cont=rand()%26;
    t[i-1]=cont;
    
    //lastcの更新
    for(int j=0; j<26; j++){
      if(j==cont) lastc[i][j]=i;
      else lastc[i][j]=lastc[i-1][j];
    }
  }
  
  int M=1000;//調整
  for(int i=0; i<M; i++){
    int d,q; /*cin >> d >> q; q--;
    */
    d=rand()%D+1; 
    q=rand()%26;
    int qold=t[d-1];
    
    int sat=0;
    
    sat = sat - s[d-1][qold];
    sat = sat + s[d-1][q];
    
    int lastcold = lastc[d-1][qold];
    for(int j=d; j<=D; j++){
      if(j==d){
        sat-=c[qold]*(j-lastcold);
      }
      else if(lastc[j][qold]==j){
        break;
      }
      else{
        sat-=c[qold]*(lastc[j][qold]-lastcold);
      }
    }
    
    for(int j=d; j<=D; j++){
      if(lastc[j][q]==j){
        break;
      }
      else{
        sat+=c[q]*(d-lastc[j][q]);
      }
    }
    
    if(sat>0){
      for(int j=d; j<=D; j++){
        if(j==d){
          lastc[j][qold]=lastc[j-1][qold];
        }
        else if(lastc[j][qold]==j){
          break;
        }
        else{
          lastc[j][qold]=lastc[j-1][qold];
        }
      }
      
      for(int j=d; j<=D; j++){
        if(j==d){
          lastc[j][q]=d;
        }
        else if(lastc[j][q]==j){
          break;
        }
        else{
          lastc[j][q]=lastc[j-1][q];
        }
      }
      
      t[d-1]=q;
    }
  }
  
  for(int i=0; i<D; i++){
    cout << t[i]+1 << endl;
  }
}

Measured memory_bytes: 3724
import bisect

def prime_set(n):
    primes = set(range(2, n+1))
    for i in range(2, int(n**0.5) + 1):
        primes.difference_update(range(i*2, n+1, i))
    return primes

X = int(input())
p = sorted(list(prime_set(10**5 + 10)))
print(p[bisect.bisect_left(p, X)])

Measured memory_bytes: 14440
#<D>wa
n, k = map(int,input().split())
r, s, p = map(int,input().split())
q = input()
d = {"r":p,"s":r, "p":s}
ans = 0
wins = [False] * k
for i in range(len(q)):
    if not wins[i % k] or q[i] != q[i - k]:
        ans += d[q[i]]
        wins[i % k] = True
    else:
        wins[i % k] = False
print(ans)        


Measured memory_bytes: 3956
A, B = [int(_) for _ in input().split()]
a = max(0, ((A - 1) // 4) * 4)
b = max(A, (B // 4) * 4)
ans = 0

for i in list(range(b, B + 1)) + list(range(a, A)):
    ans ^= i

print(ans)


Measured memory_bytes: 2940
N = int(input())
res = []
for i in range(N):
    Si, Pi = input().split(' ')
    resi = [i+1, Si, int(Pi)]
    res.append(resi)

res = sorted(res, key=lambda x: x[2], reverse=True)
res = sorted(res, key=lambda x: x[1])
for i in range(N):
    print(res[i][0])


Measured memory_bytes: 3060
def gya(n):
    return pow(n,pr-2,pr)
N=int(input())
A=list(map(int,input().split()))
pr=10**9+7
t=0
m=0
for i in A:
    t=(t+i)%pr
    m=(m+i**2)%pr
print(((t**2-m)*gya(2))%pr)

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

int N;
vector<int> A;
vector<int> B;
int main(){
	cin >> N;
	A = vector<int>(N + 1);
	B = vector<int>(N + 1);
	for (int i = 1; i <= N; i++)
	{
		cin >> A[i];
	}

	int count = 0;
	for (int i = N; i > 0; i--)
	{
		int sum = 0;
		for (int j = i + i; j <= N; j += i)
		{
			sum += B[j];
		}
		B[i] = (sum + A[i]) % 2;
		count += B[i];
	}
	
	cout << count << '\n';
	for (int i = 1; i <= N; i++)
	{
		if (B[i] == 1) cout << i << '\n';
	}
	cout << flush;

	cin >> N;
	return 0;
}

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

#define debug(...) fprintf(stderr, __VA_ARGS__)

#ifndef AT_HOME
#define getchar() IO::myGetchar()
#define putchar(x) IO::myPutchar(x)
#endif

namespace IO {
	static const int IN_BUF = 1 << 23, OUT_BUF = 1 << 23;

	inline char myGetchar() {
		static char buf[IN_BUF], *ps = buf, *pt = buf;
		if (ps == pt) {
			ps = buf, pt = buf + fread(buf, 1, IN_BUF, stdin);
		}
		return ps == pt ? EOF : *ps++;
	}

	template<typename T>
	inline bool read(T &x) {
		bool op = 0;
		char ch = getchar();
		x = 0;
		for (; !isdigit(ch) && ch != EOF; ch = getchar()) {
			op ^= (ch == '-');
		}
		if (ch == EOF) {
			return false;
		}
		for (; isdigit(ch); ch = getchar()) {
			x = x * 10 + (ch ^ '0');
		}
		if (op) {
			x = -x;
		}
		return true;
	}

	inline int readStr(char *s) {
		int n = 0;
		char ch = getchar();
		for (; isspace(ch) && ch != EOF; ch = getchar())
			;
		for (; !isspace(ch) && ch != EOF; ch = getchar()) {
			s[n++] = ch;
		}
		s[n] = '\0';
		return n;
	}

	inline void myPutchar(char x) {
		static char pbuf[OUT_BUF], *pp = pbuf;
		struct _flusher {
			~_flusher() {
				fwrite(pbuf, 1, pp - pbuf, stdout);
			}
		};
		static _flusher outputFlusher;
		if (pp == pbuf + OUT_BUF) {
			fwrite(pbuf, 1, OUT_BUF, stdout);
			pp = pbuf;
		}
		*pp++ = x;
	}

	template<typename T>
	inline void print_(T x) {
		if (x == 0) {
			putchar('0');
			return;
		}
		static int num[40];
		if (x < 0) {
			putchar('-');
			x = -x;
		}
		for (*num = 0; x; x /= 10) {
			num[++*num] = x % 10;
		}
		while (*num){
			putchar(num[*num] ^ '0');
			--*num;
		}
	}

	template<typename T>
	inline void print(T x, char ch = '\n') {
		print_(x);
		putchar(ch);
	}

	inline void printStr_(const char *s, int n = -1) {
		if (n == -1) {
			n = strlen(s);
		}
		for (int i = 0; i < n; ++i) {
			putchar(s[i]);
		}
	}

	inline void printStr(const char *s, int n = -1, char ch = '\n') {
		printStr_(s, n);
		putchar(ch);
	}
}
using namespace IO;

const int N = 200005;

int n;
std::vector<int> E[N];

int lim[3];
std::vector<int> p[3];
int ans[N];

void dfs(int u, int d, int fa = 0) {
	p[d].push_back(u);
	for (int v : E[u]) {
		if (v != fa) {
			dfs(v, 3 - d, u);
		}
	}
}

int main() {
	read(n);
	for (int i = 1; i < n; ++i) {
		int u, v;
		read(u), read(v);
		E[u].push_back(v), E[v].push_back(u);
	}
	lim[0] = lim[1] = lim[2] = n / 3;
	for (int i = 1; i <= n % 3; ++i) {
		++lim[i];
	}
	dfs(1, 1);
	for (int i = 1; i <= 2; ++i) {
		while ((int)p[i].size() > lim[i]) {
			p[0].push_back(p[i].back());
			p[i].pop_back();
		}
	}
	for (int i = 1; i <= 2; ++i) {
		if ((int)p[i].size() < lim[i]) {
			p[i].swap(p[0]);
			while ((int)p[i].size() > lim[i]) {
				p[0].push_back(p[i].back());
				p[i].pop_back();
			}
			break;
		}
	}
	for (int k = 1; k <= 3; ++k) {
		for (int i = k; i <= n; i += 3) {
			ans[p[k % 3][(i - k) / 3]] = i;
		}
	}
	for (int i = 1; i <= n; ++i) {
		print(ans[i], " \n"[i == n]);
	}
}


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

#include <math.h>
#include <stdlib.h>


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

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; }

//INT_MAX	2,147,483,647 = 2*1.0e9

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

    int N2 = N;
    int SN = 0;
    while (N2/10 != 0){
        SN += N2%10;
        N2/=10;
    }
    if(N2 != 0) SN += N2;
    
    if(N%SN == 0) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}


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

#define MOD 1000000007
#define MAX_P 200005
Int fact[MAX_P],inv[MAX_P],finv[MAX_P];;
Int extgcd(Int a,Int b,Int& x,Int& y){
  Int d=a;
  if(b!=0){
    d=extgcd(b,a%b,y,x);
    y-=(a/b)*x;
  }else{
    x=1;y=0;
  }
  return d;
}
Int mod_inverse(Int a,Int mod){
  Int x,y;
  extgcd(a,mod,x,y);
  return (mod+x%mod)%mod;
}

Int mod_pow(Int x,Int n,Int mod){
  Int res=1;
  while(n){
    if(n&1) (res*=x)%=mod;
    (x*=x)%=mod;
    n>>=1;
  }
  return res;
}

Int mod_inverse2(Int a,Int mod){
  return mod_pow(a,mod-2,mod);
}

void init(Int mod){
  fact[0]=1;
  for(Int i=1;i<MAX_P;i++)
    fact[i]=(fact[i-1]*i)%mod;

  inv[1]=1;
  for(Int i=2;i<MAX_P;i++)
    inv[i]=inv[mod%i]*(mod-mod/i)%mod;
  
  finv[0]=1;
  for(Int i=1;i<MAX_P;i++)
    finv[i]=finv[i-1]*inv[i]%mod;
}

Int mod_fact(Int n,Int mod,Int& e){
  e=0;
  if(n==0) return 1;
  Int res=mod_fact(n/mod,mod,e);
  e+=n/mod;
  if(n/mod%2!=0)return res*(mod-fact[n%mod]) %mod;
  return res*fact[n%mod]%mod;
}

Int mod_comb(Int n,Int k,Int mod){
  if(n==k||k==0) return 1;
  Int e1,e2,e3;
  Int a1=mod_fact(n,mod,e1),a2=mod_fact(k,mod,e2),a3=mod_fact(n-k,mod,e3);
  if(e1>e2+e3) return 0;
  return a1*mod_inverse(a2*a3%mod,mod)%mod;
}

Int mod_comb2(Int n,Int k,Int mod){
  Int res=1;
  for(Int i=0;i<k;i++){
    res*=(n-i)%mod;
    res%=mod;
    res*=mod_inverse(i+1,mod);
    res%=mod;
  }
  return res;
}

//only for prime mod
Int mod_comb3(Int n,Int k,Int mod){
  if(k<0||k>n) return 0;
  return fact[n]*finv[k]%mod*finv[n-k]%mod;
}

Int montmort(Int n,Int mod){
  Int res=0,inv=1;
  for(Int k=2;k<=n;k++){
    (inv*=mod_inverse(k,mod))%=mod;
    if(k%2) (res+=mod-inv)%=mod;
    else (res+=inv)%=mod;
  }
  for(Int i=1;i<=n;i++)
    (res*=i)%=mod;
  return res;
}

// calculate P(t) from given points in [0,N]
Int LagrangePolynomial(vector<Int> &y,Int t,const Int mod){
  init(mod);
  Int n=y.size()-1;
  Int num=1;
  for(Int i=0;i<=n;i++)
    num=num*((t-i)%mod)%mod;
  Int res=0;
  for(Int i=0;i<=n;i++){
    Int tmp=(y[i]*num%mod)*mod_inverse((t-i)%mod,mod)%mod;
    tmp=tmp*finv[i]%mod;
    tmp=tmp*finv[n-i]%mod;
    if((n-i)&1) tmp=mod-tmp;
    res=(res+tmp)%mod;
  }
  return res;
}

//INSERT ABOVE HERE
signed main(){
  Int n,k;
  cin>>n>>k;
  cout<<mod_pow(k,n,MOD)<<endl;
  return 0;
}



Measured memory_bytes: 3104
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;

/**
 *
 * @author saku
 */
public class Main {

    public static void main(String args[]) throws IOException {

        BufferedReader std = new BufferedReader(new InputStreamReader(System.in));
        String[] s = std.readLine().split(" ");
        int a = Integer.parseInt(s[0]);
        int b = Integer.parseInt(s[1]);
        int c = Integer.parseInt(s[2]);

        if (a < b && b < c) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 24228
n, m = gets.chomp.split.map(&:to_i)

array = []
n.times do
  a, b = gets.chomp.split.map(&:to_i)
  array << [a, b]
end

array.sort_by!{ |x| x[0] }

sum = 0
rest = m
array.each do |a, b|
  if rest - b <= 0
    sum += rest * a
    break
  end

  sum += a * b
  rest -= b
end

puts sum

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define each(it,v) for(auto &it : v)
#define mod 1000000007
#define all(v) (v).begin(),(v).end()
#define vi vector<int>
#define vl vector<long>
#define P pair<int,int>
using namespace std;

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define se second
#define fi first
#define ll long long int
#define INF INT_MAX
#define mod
#define chutiyaap ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;
bool sortbysec(const pair<ll,ll> &a,const pair<ll,ll> &b){return (a.second < b.second);}
ll gcd(ll a, ll b){if(a==0)return b;return gcd(b % a, a);}
int main()
{
	chutiyaap;
	ll a,b;cin>>a>>b;
	if(a+b==3)cout<<3;
	if(a+b==4)cout<<2;
	if(a+b==5)cout<<1;
}


Measured memory_bytes: 256
#include <iostream>
#include<sstream>
#include<vector>
#include<iterator>
#include<climits>
#include<algorithm>
using namespace std;

int main(void)
{
	int N, M, R;
	cin >> N >> M >> R;

	vector<int> route(R, 0);
	for(int i=0; i<R; i++)
	{
		int r;
		cin >> r;
		r--;

		route[i] = r;
	}
	sort(route.begin(), route.end());

	const int init = INT_MAX/2;
	vector<vector<int>> cost(N, vector<int>(N, init));
	for(int i=0; i<N; i++)
		cost[i][i] = 0;
	for(int i=0; i<M; i++)
	{
		int A, B, C;
		cin >> A >> B >> C;

		A--;
		B--;

		cost[A][B] = C;
		cost[B][A] = C;
	}

	for(int i=0; i<N; i++)
	{
		for(int j=0; j<N; j++)
		{
			for(int k=0; k<N; k++)
			{
				cost[j][k] = min(cost[j][k], cost[j][i]+cost[i][k]);
			}
		}
	}

	long long ret = INT_MAX;
	do
	{
		long long d = 0;
		for(int i=0; i<R-1; i++)
		{
			d += cost[route[i]][route[i+1]];
		}
		ret = min(ret, d);

	}while(next_permutation(route.begin(), route.end()));
	

	cout << ret << endl;

	return 0;
}


Measured memory_bytes: 512
/* 
        *** LONGEST COMMON PREFIX ***
*/

#pragma GCC optimize ("O3")

#pragma GCC optimize("Ofast")

/* 
   *********************************************************
    Code_Blooded Human == @{{ samrat_12   [  0_0  ^_^  ] }}
   *********************************************************
*/
#include <bits/stdc++.h>
#include<algorithm>
#include<queue>
#include<list>
#include<map>
#include <math.h>
#include<numeric>
using namespace std;
#define E "\n"
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define  ipfile    ifstream cin ("input.txt");std::cin.rdbuf(std::cin.rdbuf())
#define ll long long int
#define ull unsigned long long int
#define db long double
#define mod 1000000007
#define vll vector<ll>
#define all(v) v.begin(),v.end()
#define GCD(m,n) __gcd(m,n)
#define LCM(m,n) m*(n/GCD(m,n))
#define REVVEC(v) reverse(v.begin(),v.end())
#define REVARR(a) reverse(a,a+n)
#define maxc(v) max_element(all(v))
#define minc(v) min_element(all(v))
#define inputarr(a,n) for(int xxx=0;xxx<n;++xxx) cin>>a[xxx]
#define outputarr(a,n) for(int xxx=0;xxx<n;xxx++) cout<<a[xxx]<<" "
#define rep(i,m, n)    for(int i = m; i < (n); ++i)
#define sp setprecison(10)
#define cint(x) scanf("%ld",&x)
#define cstr(s) scanf("%s",s)
#define sz(s) (s.length())
#define vz(v) v.size()

void TestCase1()
{
    
    int n,cnt=0;
    cin>>n;
    string s;
    cin>>s;
    for(int i=0;i<=(sz(s)-3);i++)
    {
        if(s[i]=='A' and s[i+1]=='B' and s[i+2]=='C')
        cnt++;
    }
    cout<<cnt<<endl;
}

void TestCase2()
{
    
    
    
}

signed main()
{
    FAST
    
    //TestCase2();
    
    TestCase1();
    
    return 0;
}

Measured memory_bytes: 256
n = int(input())
l = list(map(int,input().split()))
l = sorted(l, reverse=False)

#logging.debug(l)
ans = 0
for i in range(n):
    for j in range(i+1, n):
        for k in range(j + 1, n):
#            logging.debug("{},{},{}".format(l[i],l[j],l[k]))
            if l[i] + l[j] > l[k] and l[i] != l[j] and l[j] != l[k] and l[i] != l[k]:
#                logging.debug("{},{}".format(l[i] + l[j],l[k]))
                ans += 1
#            logging.debug(ans)
print(ans)

Measured memory_bytes: 9196
#include<iostream>

using namespace std;

int main() {
	string A, B, C;
	cin >> A >> B >> C;

	char& Q = A.back();
	char& W = B.front();
	char& E = B.back();
	char& R = C.front();
	if (Q == W && E == R) {
		cout << "YES" << endl;
	}
	else cout << "NO" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
// #include <vector>
#include <string>
// #include <algorithm>
// #include <queue>
// #include <utility>
// #include <climits>
// #include <bitset>

using namespace std;
#define li long long int
#define FOR(i, a, b) for (int i = a ; i < b ; ++i)
#define REP(i, n) for (int i = 0 ; i < n ; ++i)

li gcd(li a,li b) {
    return a % b == 0 ? b : gcd(b, a % b);
}

int main(void) {
    string S;
    cin >> S;
    li n = S.length();

    li nums[10];
    FOR(i, 0, n) {
        char temp = S[i];
        nums[i] = temp - '0'; // 文字コードを数字にする
    }

    li ans = 999; // 大きい数
    FOR(i, 0, n - 2) {
        li num = nums[i] * 100 + nums[i + 1] * 10 + nums[i + 2];
        li diff = abs(num - 753);
        if (diff < ans) {
            ans = diff;
        }
    }
    cout << ans;
    return 0;
}

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

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

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

  int maxA = a[0];
  int maxI = 0;
  int minA = a[0];
  int minI = 0;
  for (int i = 1; i < N; i++) {
    if (a[i] > maxA) {
      maxA = a[i];
      maxI = i;
    }
    if (a[i] < minA) {
      minA = a[i];
      minI = i;
    }
  }

  vector<int> src, dst;
  src.reserve(2 * N);
  dst.reserve(2 * N);
  bool pos = maxA > 0 && maxA > -minA;
  int nA = pos ? maxA : minA;
  int nI = pos ? maxI : minI;
  for (int i = 0; i < N; i++) {
    if (i == nI) {
      continue;
    }
    a[i] += nA;
    src.push_back(nI);
    dst.push_back(i);
  }

  if (pos) {
    for (int i = 1; i < N; i++) {
      a[i] += a[i - 1];
      src.push_back(i - 1);
      dst.push_back(i);
    }
  } else {
    for (int i = N - 2; i >= 0; i--) {
      a[i] += a[i + 1];
      src.push_back(i + 1);
      dst.push_back(i);
    }
  }

  cout << src.size() << endl;
  for (int i = 0; i < src.size(); i++) {
    cout << src[i] + 1 << ' ' << dst[i] + 1 << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int a,b,c;
  cin>>a>>b>>c;
  if(b<c)swap(b,c);
  if(a<b)swap(a,b);
  if(a==7&&b==5&&c==5){
    cout<<"YES"<<endl;
  }
  else{
    cout<<"NO"<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
import time, random
now = time.time()

d = int(input())
clst = list(map(int, input().split()))
s = [list(map(int, input().split())) for _ in range(d)]
last = [0 for _ in range(26)]

def score_minus(d, q):
    minus = 0
    for i, (c, ls) in enumerate(zip(clst, last)):
        if i == q:
            continue
        minus += c * (d + 1 - ls)
    return minus

def check(t):
    def score_minus(d):
        minus = 0
        for c, ls in zip(clst, last):
            minus += c * (d - ls)
        return minus
        
    last = [0 for _ in range(26)]
    ans = 0
    for d, num in enumerate(t, start = 1):
        ans += s[d - 1][num - 1]
        last[num - 1] = d
        ans -= score_minus(d)
    return ans
    
t_lst = []
for i in range(d):
    tmp = -10 ** 10
    for q in range(26):
        tmp_score = s[i][q] - score_minus(i, q)
        if tmp_score > tmp:
            tmp = tmp_score
            max_q = q
    last[max_q] = i
    t_lst.append(max_q + 1)

ans = check(t_lst)

while time.time() - now < 1.8:
    d_change = random.randint(0, d - 1)
    q_change = random.randint(1, 26)
    old_d = t_lst[d_change]
    if old_d == q_change:
        continue
    t_lst[d_change]  = q_change
    ans_tmp = check(t_lst)
    if ans_tmp > ans:
        ans = ans_tmp
    else:
        t_lst[d_change] = old_d

for t in t_lst:
    print(t)


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

using namespace std;

//int→string
//string→int
//------------------------------------------
inline int toInt(string s) {
    int v;
    istringstream sin(s);
    sin >> v;
    return v;
}

template<class T>
inline string toString(T x) {
    ostringstream sout;
    sout << x;
    return sout.str();
}

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

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

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

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);

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

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;


int main() {

    int N; scanf("%d", &N);
    int count = 0;
    int data;
    REP(i, N){
        scanf("%d", &data);
        if(data%2==1){
            count++;
        }
    }

    if(count%2 == 0){
        printf("YES");
    }else{
        printf("NO");
    }
    return 0;
}











































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

using ll = long long;

int main() {
    int n, q, m;
    cin >> n;
    vector<int> A(n);
    rep(i, n) cin >> A[i];
    vector<bool> f(2001, false);
    rep(i, 1 << n) {
        int s = 0;
        rep(j, n) {
            if ((i >> j) & 1) s += A[j];
        }
        if (s < 2001) f[s] = true;
    }
    cin >> q;
    rep(i, q) {
        cin >> m;
        if (f[m]) cout << "yes\n";
        else cout << "no\n";
    }
}


Measured memory_bytes: 3104
#include<iostream>
#include<math.h>
#include<stdlib.h>
#include<string>
#include<limits.h>
#include<utility>
#include<vector>
//#include<bits/stdc++.h>
#include<tuple>
#include<queue>
#include<map>
#include<algorithm>
//#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define ALL(A) A.begin(),A.end()

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

bool _predicate(int a,const int& element) {
	return (element == a); // This will cause all elements to be deleted that are larger than 3
}
int main() {
	ll n = 0;
	cin >> n;
	ll ans = 0;
	rep(i, n) {
		ll N = n / (i+1);
		ll k = (N) * (i+1 + N * (i+1))/2;
		//cout << k << endl;
		ans += k;
	}
	/*for (ll s : sosuu) {
		cout << s << endl;
	}*/
	cout << ans << endl;
}

Measured memory_bytes: 3180
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define pb(a) push_back(a)
typedef long long ll;
typedef pair<ll,ll> P;
constexpr int INF = numeric_limits<int>::max()/2;
constexpr int MOD = 1e9+7;

vector<ll> dp(100010, INF);

int main(){
  ll n;
  cin >> n;
  dp[0] = 0;
  vector<ll> coins;
  ll c = 1;
  while(c <= n){
    coins.pb(c);
    c *= 6;
  }
  c = 9;
  while(c <= n){
    coins.pb(c);
    c *= 9;
  }
  VSORT(coins);

  REP(i, coins.size()){
    FOR(j, coins[i], n + 1) dp[j] = min(dp[j], dp[j - coins[i]] + 1);
  }
  cout << dp[n] << endl;
  return 0;
}


Measured memory_bytes: 1024
#include<iostream>
using namespace std;
int main(){
	int h,w;
	cin >> h >> w;
	int c[10][10];
	for(int i=0;i<10;i++){
		for(int j=0;j<10;j++){
			cin >> c[i][j];
		}
	}
	for(int k=0;k<10;k++){
		for(int i=0;i<10;i++){
			for(int j=0;j<10;j++){
				if(c[i][j]>c[i][k]+c[k][j])c[i][j]=c[i][k]+c[k][j];
			}
		}
	}
	int a;
	int res=0;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			cin >> a;
			if(a>=0)res+=c[a][1];
		}
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
# Nを数字で処理するバージョン
# 末尾の数字は10で割った余りになる
N=int(input())
if N%10 == 2:
    print("hon")
elif N%10 == 4:
    print("hon")
elif N%10 == 5:
    print("hon")
elif N%10 == 7:
    print("hon")
elif N%10 == 9:
    print("hon")
elif N%10 == 1:
    print("pon")
elif N%10 == 6:
    print("pon")
elif N%10 == 8:
    print("pon")
elif N%10 == 0:
    print("pon")
else:
    print("bon")


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

int gcd(unsigned int a, unsigned int b){
if(b==0){return a;}
return gcd(b,a%b);

}

int main() {
	unsigned int K;
  	cin >>K;
  	unsigned int ans;
  for(unsigned int i=1;i<=K;i++){
  	for(unsigned int j=1;j<=K;j++){
    	for(unsigned int l=1;l<=K;l++){
       ans+=gcd(gcd(i,j),l);
        
      
          
        }
    
    }
  
  }
  
  cout <<ans<<endl;
}

Measured memory_bytes: 3624
#include <stdio.h>

#define NIL -1

struct Node
{
  int p, l, r, s, deg;
};

struct Node T[25];

int Height(int);

int main()
{
  int i, n, node, l, r, dep, h, k;

  scanf("%d",&n);

  for(i = 0; i < n; i++)
    {
      T[i].p = NIL;
      T[i].l = NIL;
      T[i].r = NIL;
      T[i].s = NIL;
      T[i].deg = 0;
    }

  for(i = 0; i < n; i++)
    {
      scanf("%d%d%d",&node,&l,&r);
      if(l != NIL)
	{
	  T[node].l = l;
	  T[l].p = node;
	  T[r].s = l;
	  T[node].deg++;
	}
      if(r != NIL)
	{
	  T[node].r = r;
	  T[r].p = node;
	  T[l].s = r;
	  T[node].deg++;
	}
    }

  for(i = 0; i < n; i++)
    {
      printf("node %d: ",i);
      printf("parent = %d, ",T[i].p);
      printf("sibling = %d, ",T[i].s);
      printf("degree = %d, ",T[i].deg);
      k = i;
      dep = 0;
      while(T[k].p != NIL)
	{
	  k = T[k].p;
	  dep++;
	}
      printf("depth = %d, ",dep);
      h = Height(i);
      printf("height = %d, ",h);
      if(T[i].p == NIL)printf("root");
      else if(T[i].deg == 0)printf("leaf");
      else printf("internal node");
      printf("\n");
    }
  
  return 0;
}

int Height(int x)
{
  int hl = 0, hr = 0;
  
  if(x == NIL)return -1;

  hl = Height(T[x].l);
  hr = Height(T[x].r);

  if(hl > hr)return hl+1;
  else return hr+1;
}



Measured memory_bytes: 2148
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>
#include <cassert>
#include <functional>
#include <set>
#include <deque>
#include <list>
using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
#define LNF __LONG_LONG_MAX__
const ll MOD = 1000000007;
const int MAX = 200000;

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

// テーブルを作る前処理
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;
}
// 法mでのaの逆元を計算
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
//最大公約数
long long gcd(long long x, long long y){
    if(y==0) return x;
    else return gcd(y,x%y);
}
//最小公倍数
long long lcm(long long x, long long y){
    return x / gcd(x, y) * y;
}
// nが大きく,kが10^7程度の時の二項係数
long long com[200005];
void combination(long long n,long long k){
    com[0] = 1;
    for(int i=1;i<=k;i++){
        com[i] = (com[i-1]*(n-i+1)%MOD)*modinv(i,MOD)%MOD;
    }
}

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


Measured memory_bytes: 3620
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
char s1[1000005],s2[1000005],s3[1000005];
int main()
{
	scanf("%s%s%s",s1,s2,s3);
	if(s1[strlen(s1)-1]==s2[0]&&s2[strlen(s2)-1]==s3[0])printf("YES\n");
	else printf("NO\n");
	return 0;
}


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

int main() {
  int N;
  int t[110000], x[110000], y[110000];
  bool can = true;
  int dt, dist = 0;

  cin >> N;
  t[0] = x[0] = y[0] = 0;
  for (int i = 1; i <= N; i++) cin >> t[i] >> x[i] >> y[i];

  for (int i = 0; i < N; i++) {
    dt = t[i + 1] - t[i];
    dist = abs(x[i + 1] - x[i]) + abs(y[i + 1] - y[i]);
    if (dt < dist) can = false;
    if (dt % 2 != dist % 2) can = false;
  }

  if (can) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define SUM(a)  accumulate((a).begin(),(a).end(),0)
#define SORT(a) sort(ALL(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
typedef long long ll;
const int INF = 999999999;
const int MOD = (int)1e9 + 7;
const int EPS = 1e-9;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n,a,b;
  int ans = 0;
  cin >> n >> a >> b;
  FOR(i,1,n+1){
      int sum = 0;
      FOR(j,0,5){
          sum += (i / (int)pow(10,j))%10;
      }
      //cout << i <<" " << sum << endl; 
      if (a<=sum && sum <=b){
          ans+=i;
      }
  }
  cout << ans << endl;
}

Measured memory_bytes: 512
n, m = list(map(int, input().split()))
a = [input() for _ in range(n)]
b = [input() for _ in range(m)]
for i in range((n-m+1) ** 2):
    y = i//(n-m+1)
    x = i%(n-m+1)
    for j in range(m):
        if b[j] != a[y+j][x:x+m]:
            break
    else: 
        print('Yes')
        break
else: print('No')

Measured memory_bytes: 3064
#include <bits/stdc++.h> 
using namespace std; 
typedef long long ll;
const int mxN=1e9;
const ll mod = 1e9+7;


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int n,k;
    cin>>n>>k;

    vector<ll> v(n);

    for(int i=0;i<n;i++)cin>>v[i];

    ll dp[n][k+1];
    memset(dp,0,sizeof(dp));

    for(int i=0;i<n;i++)dp[i][0]=1;
    for(int i=0;i<=k;i++)dp[0][i]=1;

    for(int i=1;i<n;i++){
        for(int j=1;j<=k;j++){
            if(v[i-1]<j){
                dp[i][j] = (dp[i][j-1]+(dp[i-1][j]-dp[i-1][j-v[i-1]-1])+mod)%mod;
            }
            else dp[i][j]=(dp[i][j-1]+dp[i-1][j])%mod;
        }
    }

    if(k<=v[n-1]) cout<<dp[n-1][k]%mod;
    else cout<<(dp[n-1][k]-dp[n-1][k-v[n-1]-1]+mod)%mod;
}

Measured memory_bytes: 81600
# include <iostream>
# include <algorithm>
#include <array>
# include <cassert>
#include <cctype>
#include <climits>
#include <numeric>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr long long MOD = 1000000000 + 7;
constexpr long long INF = std::numeric_limits<long long>::max();
const double PI = acos(-1);
#define fir first
#define sec second
typedef pair<LL, LL> Pll;
typedef pair<LL, pair<LL, LL>> Ppll;
typedef pair<LL, pair<LL, bitset<100001>>> Pbll;
typedef pair<LL, pair<LL, vector<LL>>> Pvll;
typedef pair<LL, LL> Vec2;
struct Tll { LL first, second, third; };
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Mfor(i,mf) for(LL i=mf-1;i>=0;i--)
LL h, w, n, m, k, s, t, q, ans, sum, last=-1, cnt,a[1000000];
struct Edge { LL to,cost; };
vector<Edge>vec;
bool f=0;
void YN(bool f) {
	if (f)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
void yn(bool f) {
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}
int main() {
	cin >> n >> m;
	rep(i, n) {
		cin >> a[i];
		if(i&&last==-1)
			if (a[i] + a[i - 1]>=m) {
				last = i;
		}
	}
	if (last == -1)
		cout << "Impossible" << endl;
	else {
		cout << "Possible" << endl;
		rep(i, n-1) {
			if (i+1 != last)
				cout << i + 1 << endl;
			else break;
		}
		Mfor(i, n - 1) {
			if (i + 1 != last)
				cout << i + 1 << endl;
			else break;
		}
		cout << last << endl;
	}
	return 0;
}

Measured memory_bytes: 1664
#include<stdio.h>

void merge(long s[], int low, int middle, int high)
{
 int i;
 int j;
 long arr1[200005];
 long arr2[200005];
 int ind1=0;
 int ind2=0;

 for (i=low;i<=middle; i++) arr1[i-low]=s[i];
 for (i=middle+1; i<=high; i++) arr2[i-middle-1]=s[i];

 i=low;
 
 for(;;)
 {  
   if(arr1[ind1]<=arr2[ind2])
   {
     s[i++]=arr1[ind1++];
   }else{
     s[i++]=arr2[ind2++];
   }
   if(ind1>middle-low) break;
   if(ind2>high-middle-1) break;
 }
 for(j=ind1;j<=middle-low;j++) s[i++]=arr1[j];
 for(j=ind2;j<=high-middle-1;j++) s[i++]=arr2[j];

}


void mergesort(long s[], int low, int high)
{
 int middle;
 if(low<high)
 {
  middle=(low+high)/2;
  mergesort(s,low,middle);
  mergesort(s,middle+1,high);
  merge(s,low,middle,high);
 }
}

int main()
{
 int N;
 long D[200005];
 int M;
 long T[200005];
 int i;
 int start=0;
 int allfound=1;
 int found[200005];
 int j;

 scanf("%d",&N);
 for(i=0;i<N;i++) scanf("%ld",&D[i]);
 scanf("%d",&M);
 for(i=0;i<M;i++) scanf("%ld",&T[i]);
 for(i=0;i<M;i++) found[i]=0;

 mergesort(D,0,N-1);
 mergesort(T,0,M-1 );

 for(i=0;i<N;i++)
 {
  for(j=start;j<M;j++)
  {
   if(D[i]==T[j])
   {
    start=j+1;
    found[j]=1;
    break;
   }
   if(D[i]>T[j]) break;
  }
 }

 for(i=0;i<M;i++) 
 {
  if(found[i]!=1) 
  {
   allfound=0;  
   break;
  }
 }

 if(allfound==1)
 {
  printf("YES\n");
 }else{
  printf("NO\n");
 }

 return 0;
}


Measured memory_bytes: 6912
using System;
class Program{
    static void Main(){
        int how_many = int.Parse(Console.ReadLine());
        for(int i=0;i<how_many;i++){
            string str = Console.ReadLine();
            string[] stArray = str.Split(' ');
            int[] intArray = new int[3];
            int j;// This is count val for forloop.
            for(j=0;j<3;j++){
                intArray[j] = int.Parse(stArray[j]);
            }
            if(
                    intArray[0] * intArray[0]  == intArray[1] * intArray[1] + intArray[2] * intArray[2]
                    ||intArray[1] * intArray[1] == intArray[2] * intArray[2] + intArray[0] * intArray[0] 
                    ||intArray[2] * intArray[2] == intArray[0] * intArray[0] + intArray[1] * intArray[1]
                    ){
                Console.WriteLine("YES");
            }else{
                Console.WriteLine("NO");
            }
        }

    }

}

Measured memory_bytes: 9008
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>

using namespace std;

int main(void){
    int n;
    int a,b;
    
    cin >> n;
    
    if(n == 1){
        cout << "Hello World\n";
    }
    if(n == 2){
        cin >> a >> b;
        cout << a + b << endl;
    }
}

Measured memory_bytes: 888
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static System.Console;
using Pair = System.Collections.Generic.KeyValuePair<int, int>;



namespace AGC007_A
{
    class Program
    {
        static bool flag = false;
        static char[][] A;
        static int[,] K;
        static int H, W;
        static void Main(string[] args)
        {
            var t = scan;
            H = t[0]; W = t[1];

            A = new char[H][];

            K = new int[H, W];
            K[0, 0] = 1;
            for (int i = 0; i < H; i++)
            {
                A[i] = ReadLine().ToCharArray();
            }
            solve(0, 0);
            //Console.WriteLine(flag);
            for (int i = 0; i < H; i++)
            {
                for (int j = 0; j < W; j++)
                {
                    if (A[i][j] == '#')
                    {
                        if (K[i,j] == 0)
                        {
                            flag = false;
                        }
                    }
                }
            }
            if (flag)
            {
                Console.WriteLine("Possible");
            }
            else
            {
                Console.WriteLine("Impossible");
            }
            
            
        }
        static void solve(int h, int w)
        {
            if (h == H - 1 && w == W - 1) flag = true;
            if (h + 1 < H && A[h + 1][w] == '#')
            {
                solve(h + 1, w);
                K[h + 1, w] = 1;
            }
            else if (w + 1 < W && A[h][w + 1] == '#')
            {
                solve(h, w + 1);
                K[h, w + 1] = 1;
            }
        }

        static int[] scan { get { return Array.ConvertAll(Console.ReadLine().Split(), int.Parse); } }
    }
}


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

int main(){
  int a, b;
  cin>>a>>b;
  if(a!=1&&b!=1)
    cout<<1<<endl;
  if(a!=2&&b!=2)
    cout<<2<<endl;
  if(a!=3&&b!=3)
    cout<<3<<endl;
}

Measured memory_bytes: 3600
#include <iostream>
#define MOD 1000000007

using namespace std;

struct A
{
    long long nr_prim, exponent;
};

unsigned long long putere_x_la_k ( unsigned long long x, unsigned long long k );
unsigned long long combinari_de_n_luate_cate_k ( unsigned long long n, unsigned long long k );
long long indicator_Euler ( long long x );

int main()
{
    unsigned long long n, a, b, x, y, z;

    cin >> n >> a >> b;
    x = putere_x_la_k ( 2, n ) - 1;
    y = combinari_de_n_luate_cate_k ( n, a );
    z = combinari_de_n_luate_cate_k ( n, b );

    cout << ( x + 2 * MOD - y - z ) % MOD;

    return 0;
}

unsigned long long putere_x_la_k ( unsigned long long x, unsigned long long k )
{
    if ( k == 0 ) return 1;
    if ( k == 1 ) return x % MOD;
    else if ( k % 2 == 0 ) return putere_x_la_k ( ( ( x % MOD ) * ( x % MOD ) ) % MOD, k / 2 ) % MOD;
    else return ( ( x % MOD ) * putere_x_la_k ( ( ( x % MOD ) * ( x % MOD ) ) % MOD, k / 2 ) ) % MOD;
}

unsigned long long combinari_de_n_luate_cate_k ( unsigned long long n, unsigned long long k )
{
    unsigned long long i, x = 1, y = 1;
    unsigned long long X = 0, Y = 0;


    for ( i = 1 + max ( n - k, k ) ; i <= n ; i++ ) x = ( ( x % MOD ) * ( i % MOD ) ) % MOD;
    for ( i = 2 ; i <= min ( n - k, k ) ; i++ ) y = ( ( y % MOD ) * ( i % MOD ) ) % MOD;

    y = ( putere_x_la_k ( y, indicator_Euler ( MOD ) - 1 ) ) % MOD;

    return ( x * y ) % MOD;
}

long long indicator_Euler ( long long x )
{
    A v[15];
    long long i, rez = 1;

    for ( i = 0 ; i <= 13 ; i++ ) v[i] = { 0, 0 };
    if ( x % 2 == 0 )
    {
        v[++v[0].exponent].nr_prim = 2;
        while ( x % 2 == 0 )
        {
            x /= 2;
            v[v[0].exponent].exponent++;
        }
    }

    for ( i = 3 ; i * i <= x ; i += 2 )
        if ( x % i == 0 )
        {
            v[++v[0].exponent].nr_prim = i;
            while ( x % i == 0 )
            {
                x /= i;
                v[v[0].exponent].exponent++;
            }
        }

    if ( x != 1 ) v[++v[0].exponent].nr_prim = x, v[v[0].exponent].exponent = 1;

    for ( i = 1 ; i <= v[0].exponent ; i++ ) rez *= ( v[i].nr_prim - 1 ) * putere_x_la_k ( v[i].nr_prim, v[i].exponent - 1 );

    return rez;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;
public class Main
{
	int n;
	ArrayList<Integer> list[];
	private void solve()throws IOException
	{
		n=nextInt();
		list=new ArrayList[n+1];
		for(int i=1;i<=n;i++)
			list[i]=new ArrayList<>();
		for(int i=1;i<n;i++)
		{
			int u=nextInt();
			int v=nextInt();
			list[u].add(v);
			list[v].add(u);
		}
		out.println(dfs(1,-1)==0?"Bob":"Alice");
	}
	int dfs(int v,int p)
	{
		int ret=0;
		for(int vv:list[v])
			if(vv!=p)
				ret^=dfs(vv,v)+1;
		return ret;
	}

	 
	///////////////////////////////////////////////////////////

	public void run()throws IOException
	{
		br=new BufferedReader(new InputStreamReader(System.in));
		st=null;
		out=new PrintWriter(System.out);

		solve();
		
		br.close();
		out.close();
	}
	public static void main(String args[])throws IOException{
		new Main().run();
	}
	BufferedReader br;
	StringTokenizer st;
	PrintWriter out;
	String nextToken()throws IOException{
		while(st==null || !st.hasMoreTokens())
		st=new StringTokenizer(br.readLine());
		return st.nextToken();
	}
	String nextLine()throws IOException{
		return br.readLine();
	}
	int nextInt()throws IOException{
		return Integer.parseInt(nextToken());
	}
	long nextLong()throws IOException{
		return Long.parseLong(nextToken());
	}
	double nextDouble()throws IOException{
		return Double.parseDouble(nextToken());
	}
}

Measured memory_bytes: 73196
#include <iostream>
#include <list>
#include <vector>
#include <map>
#include <string>
#include <cmath>
#include <algorithm>

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

typedef long long ll;

using namespace std;

string stringSort(string s, int size){
	string sortedS;
	map<char, int> countMap;

	for (int i = 0; i < size; ++i)
	{
		sortedS[i] = 'a';
	}
	for (char c = 'a'; c <= 'z'; ++c)
	{
		countMap[c] = 0;
	}
	for (int i = 0; i < size; ++i)
	{
		char c = s[i];
		countMap[c]++;
	}
	for (char c = 'a'; c <= 'z'; ++c)
	{
		if (countMap[c] != 0)
		{
			REP(i, countMap[c])
			{
				sortedS += c;
			}
		}
	}

	return sortedS;
}

int main(){
    ll N;
    cin >> N;
    vector<string> sVec;
    ll ans = 0;	
    REP(i, N)
    {
    	string s;
    	cin >> s;
    	sVec.push_back(s);
    }

    // 各文字列を辞書順に並び替え
    REP(i, N)
    {
    	// 文字列の長さは10
    	sVec[i] = stringSort(sVec[i], 10);
    }

    sort(sVec.begin(), sVec.end() );

    ll sameCount = 1;
    REP(i, N - 1)
    {
    	if (sVec[i] == sVec[i + 1])
    	{
    		sameCount++;
    	}
    	else
    	{
    		if (sameCount != 1)
    		{
    			ans += sameCount * (sameCount - 1) / 2;
    			sameCount = 1;
    		}
    	}
    }

    if (sameCount != 1)
	{
		ans += sameCount * (sameCount - 1) / 2;
	}


    cout << ans << endl;
}


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

using namespace std;
using llong = long long;
using ldbl = long double;
using lpair = pair<llong, llong>;

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

template<typename T>
constexpr T inf = static_cast<T>(pow(10, static_cast<int>(log10(numeric_limits<T>::max())))) + 7;
constexpr llong mod = 1e9+7;

int main() {
  llong H, N;
  vector<llong> A;

  cin >> H >> N;
  A.resize(N);
  llong sum = 0;
  for (auto &in: A) {
    cin >> in;
    sum += in;
  }

  cout << (sum >= H ? "Yes": "No") << endl;

  return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define rrep(i,n) for(int i=1,i##_len=(n); i<=i##_len; ++i)
#define drep(i,n) for(int i=(n)-1; i>=0; --i)
#define srep(i,s,t) for(int i=(s);i<(t);++i)
#define rng(obj) (obj).begin(), (obj).end()
#define maxs(x,y) (x=max((x),(y)))
#define mins(x,y) (x=min((x),(y)))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x=max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T>>
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) vector<vector<T>>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using P = pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vp = vector<P>;
template <class T> inline istream& operator>>(istream&i,v(T)&v)
{ rep(j,sz(v))i>>v[j];return i;}
template <class T> string join(const v(T)&v)
{ stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template <class T> inline ostream& operator<<(ostream&o,const v(T)&v)
{ if(sz(v))o<<join(v); return o;}
template <class T1,class T2> inline istream& operator>>(istream&i ,pair<T1,T2>&v)
{ return i>>v.fi>>v.se;}
template <class T1,class T2> inline ostream& operator<<(ostream&o ,pair<T1,T2>&v)
{ return o<<v.fi<<","<<v.se;}
template <class T> inline ll suma(const v(T)& a) 
{ ll res(0); for(auto&& x:a) res += x; return res;}
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
const double eps = 1e-10;
#define dame {puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
const int MX = 200005;
#define fileio ifstream fio; if(argc>=2){fio.open(argv[1]); std::cin.rdbuf(fio.rdbuf());}
#define fastio ios_base::sync_with_stdio(false);
//----------------------------------------------------------------
void Main(){
  string s;
  cin>>s;
  int n = s.length();
  int ans=0;
  rep(i,n-1){
    if(s[i]!=s[i+1]){
      ans++;
    }
  }
  cout<<ans<<endl;
} int main(int argc,char* argv[]){ 
    fastio; fileio; Main();}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <queue>

#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i, s, n) for(int i=s; i<n; i++)
#define dup(x,y) (((x)+(y)-1)/(y)) // dup * y >= x なる最小のdup.
using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> s(M);
  vector<char> c(M);

  rep(i, M) cin >> s[i] >> c[i];

  vector<char> ans(N, 'x');

  rep(i, M) {
    if(s[i]-1>N) {
      cout << -1 << endl;
      return 0;
    } 

    if(ans[s[i]-1]=='x') {
      ans[s[i] - 1] = c[i];
    } else if(ans[s[i]-1]!=c[i]){
      cout << -1 << endl;
      return 0;
    }
  }

  if(ans[0]=='0' && N>1) {
    cout << -1 << endl;
    return 0;
  }

  rep(i, N) {
    if(ans[i]=='x') {
      if(i==0) {
        if(N>1) ans[i] = '1';
        else ans[i] = '0';
      }
      else ans[i] = '0';
    }
  }

  rep(i, N)  cout << ans[i];
  cout << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
stack<char>hyx;
int main()
{
    int n;
    cin>>n;
    string str;
    cin>>str;
    int len=str.length();
    string tmp(str);
    for(int i=len-1;i>=0;i--) {
        if (tmp[i]==')')
            hyx.push(')');
        else if (hyx.empty() || hyx.top() != ')') {
            str += ')';
            if (!hyx.empty())
                hyx.pop();
        } else hyx.pop();
    }
    while (!hyx.empty()) {
        str = '(' + str;
        hyx.pop();
    }
    cout <<str<<endl;
    return 0;
}

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

long long solve_dp(int m, vector<int>& a, vector<int>& b){
    vector<long long> dp(m + 1, 0);
    dp[0] = m;
    for (int i = 0; i < 3; i++){
        long long w = a[i];
        long long v = b[i] - a[i];
        for (int j = w; j < m + 1; j++){
            dp[j] = max(dp[j - w] + v, dp[j]);
        }
    }
    long long ans = 0;
    for (int i = 0; i < m + 1; i++){
        ans = max(ans, dp[i]);
    }
    return ans;
}

int main(){
    int n;
    cin >> n;
    vector<int> a(3);
    cin >> a[0] >> a[1] >> a[2];
    vector<int> b(3);
    cin >> b[0] >> b[1] >> b[2];
    long long ans;
    ans = solve_dp(n, a, b);
    ans = solve_dp(ans, b, a);
    cout << ans << endl;
}


Measured memory_bytes: 195584