akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define pb push_back
#define f first
#define se second
#define pll pair<ll, ll>
#define pii pair<int, int>


using namespace std;

const int N = 3e5 + 123;
const ll mod = 1e9 + 7;
const ll inf = 1e17;


ll n, a[N], p[N];


ll get(int l, int r) {
	return p[r] - p[l - 1];
}


ll getval(int l, int m, int r) {
	return abs(get(l, m) - get(m + 1, r));
}


int getopt(int l, int r) {
	int opt = l, L = l, R = r - 1, M; 
	pair<ll, int> ans = {inf, 0};
	while (L <= R) {
		M = (L + R) / 2;
		ans = min(ans, {abs(get(l, M) - get(M + 1, r)), M});
		if (M == R) {
			R = M - 1;
			continue;
		}
		if (getval(l, M, r) > getval(l, M + 1, r))
			L = M + 1;
		else
			R = M - 1;
	}
	return ans.se;
}


int main() {
	ios_base::sync_with_stdio(NULL); cin.tie(NULL); cout.tie(NULL);
//	freopen("input.txt", "r", stdin);
	cin >> n;
	p[0] = 0;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		p[i] = p[i - 1] + a[i];
	}
	ll ans = inf;
	for (int i = 2; i <= n - 2; i++) {
		int optl = getopt(1, i), optr = getopt(i + 1, n);
		ll mx, mn;
		mx = max(max(get(1, optl), get(optl + 1, i)), max(get(i + 1, optr), get(optr + 1, n)));
		mn = min(min(get(1, optl), get(optl + 1, i)), min(get(i + 1, optr), get(optr + 1, n)));
		ans = min(ans, mx - mn);
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 3840
import numpy as np

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

a.sort()
pos = a[a>0]
zero = a[a==0]
neg = a[a<0]
negpos = (neg*(-1))[::-1]

lenn = len(neg)
lenz = len(zero)
lenp = len(pos)

nnres = lenn * lenp
nzres = int(lenz*(lenn+lenp)+lenz*(lenz-1)/2)
npres = int(lenn*(lenn-1)/2 + lenp*(lenp-1)/2)

if k<=nnres:
    def count_nnres(x):
        cnt = np.searchsorted(neg,x//pos,side='right').sum()
        return int(cnt)
    left = -10**18
    right = -1
    while left+1<right:
        mid = (left+right)//2
        nebefore = count_nnres(mid)
        if nebefore >= k:
            right = mid
        elif nebefore < k:
            left = mid
    print(right)
    
elif nnres<k<=nnres+nzres:
    print(0)
    
elif nnres+nzres<k:
    def count_npres(x):
        cnt = 0
        cnt += int(np.searchsorted(pos,x//pos,side='right').sum() - ((x//pos)>=pos).sum())//2
        cnt += int(np.searchsorted(negpos,x//negpos,side='right').sum() - ((x//negpos)>=negpos).sum())//2
        return cnt
    k -= nnres+nzres
    left = 1
    right = 10**18
    while left+1<right:
        mid = (left+right)//2
        nebefore = count_npres(mid)
        if nebefore >= k:
            right = mid
        elif nebefore < k:
            left = mid
    print(right)

Measured memory_bytes: 32332
#include <stdio.h>

int main(){
	int A, B, C;
	scanf("%d %d %d", &A, &B, &C);
	if(A == B && A == C) printf("No");
	else if(A == B && C != A) printf("Yes");
	else if(A == C && B != A) printf("Yes");
	else if(B == C && A != B) printf("Yes");
	else if(A != B && B != C) printf("No"); 
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define ll long long int
#define M 1000000007
#define mod 998244353
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pi pair<ll,ll>
#define endl "\n"
using namespace std;
const ll N=1000010;

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

    vector<bool> p(N,1);
    p[0]=p[1]=0;
    vector<int> val(N,1);
    for(ll i=2;i<N;++i){
        if(p[i]){
            val[i]*=2;
            for(ll j=i+i;j<N;j+=i){
                p[j]=0;
                ll count=1;
                ll ch=j;
                while(ch%i==0){
                    ++count;
                    ch/=i;
                }
                val[j]*=count;
            }
        }
    }

    ll n;
    cin>>n;
    ll ans=0;
    for(ll c=1;c<n;++c){
        ans+=val[n-c];
    }
    cout<<ans;

    return (0);
}


Measured memory_bytes: 7092
#include <bits/stdc++.h>
#define ll long long int
#define maxy __LONG_LONG_MAX__
#define mod 1000000007
using namespace std;
int main() {
    ll n,k;
	cin>>n>>k;
	ll a[n],dp[n];
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	// for(int i=0;i<k;i++)
	// {
	// 	dp[i]=abs(a[i]-a[0]);
	// }
	dp[0]=0;
	dp[1]=abs(a[1]-a[0]);
	ll ans=0;
	if(k>=n)
	{
		cout<< abs(a[n-1]-a[0]);
		return 0;
	}
	for(int i=2;i<n;i++)
	{
		dp[i]=INT_MAX;
		for(int j=i-1;j>=i-k;j--)
		{
			if(j>=0)
			dp[i]=min((int)dp[j]+abs(a[i]-a[j]),dp[i]);
			//cout<<mini<<endl;
		}
		
		//dp[i]=mini;
		//ans+=mini;
	}
	cout<<dp[n-1]<<endl;
    return 0;
}


Measured memory_bytes: 1792
import java.util.*;

public class Main{
	Scanner sc = new Scanner(System.in);
	
	private void doit(){
		
		while(true){
			int n = sc.nextInt();
			int m = sc.nextInt();
			if((n|m) == 0) break;
			char [] chair = new char[n];
			Arrays.fill(chair, '#');
			for(int ii = 0; ii < m; ii++){
				char c = sc.next().charAt(0);
				switch(c){
				case 'A':
					for(int i = 0; i < n; i++){
						if(chair[i] == '#'){
							chair[i] = 'A';
							break;
						}
					}
					break;
				case 'B':
					boolean isSit = false;
					for(int i = n-1; i >= 0; i--){
						if(chair[i] == '#'){
							if(i == n-1 || chair[i+1] != 'A'){
								if(i == 0 || chair[i-1] != 'A'){
									isSit = true;
									chair[i] = 'B';
									break;
								}
							}
						}
					}
					if(! isSit){
						for(int i = 0; i < n; i++){
							if(chair[i] == '#'){
								chair[i] = 'B';
								break;
							}
						}
					}
					break;
				case 'C':
					int ind = -1;
					for(int i = 0; i < n; i++){
						if(chair[i] != '#'){
							if(i + 1 != n && chair[i + 1] == '#'){
								ind = i;
								chair[i+1] = 'C';
								break;
							}
							else if(i != 0 && chair[i-1] == '#'){
								ind = i;
								chair[i - 1] = 'C';
								break;
							}
						}
					}
					if(ind == -1){
						if(n % 2 == 1){
							chair[(1 + n) / 2 - 1] = 'C';
						}
						else{
							chair[n / 2] = 'C';
						}
					}
					break;
				case 'D':
					int max = -1;
					int ind2 = -1;
					for(int i = 0; i < n; i++){
						if(chair[i] != '#') continue;
						boolean flga = false;
						int disa = 0;
						for(int j = i + 1;; j++){
							if(j == n){
								flga = true;
								break;
							}
							if(chair[j] != '#'){
								break;
							}
							else{
								disa++;
							}
						}
						boolean flgb = false;
						int disb = 0;
						for(int j = i-1;; j--){
							if(j == -1){
								flgb = true;
								break;
							}
							if(chair[j] != '#'){
								break;
							}
							else{
								disb++;
							}
						}
						int res = Math.min(disa, disb);
						if(flga && flgb){
							res = n;
						}
						else if(flga){
							res = disb;
						}
						else if(flgb){
							res = disa;
						}
						if(max < res){
							max = res;
							ind2 = i;
						}
					}
					chair[ind2] = 'D';
					break;
				}
			}
			for(int i = 0; i < n; i++){
				System.out.print(chair[i]);
			}
			System.out.println();
		}
		
	}

	private void debug(Object... o) { System.out.println("debug = " + Arrays.deepToString(o)); }

	public static void main(String[] args) {
		new Main().doit();
	}
}

Measured memory_bytes: 29796
#include <iostream>

using namespace std;

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

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

  cout << A[0];
  for (int i = 1; i < n; i++) {
    cout << " " << A[i];
  }
  cout << endl;

  for (int i = 1; i < n; i++) {
    int v = A[i];

    int j = i - 1;
    while (j >= 0 && A[j] > v) {
      A[j + 1] = A[j];
      j--;
    }
    A[j + 1] = v;

    cout << A[0];
    for (int k = 1; k < n; k++) {
      cout << " " << A[k];
    }
    cout << endl;
  }

  return 0;
}

Measured memory_bytes: 1164
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std;
int Q, l, r, s[100009]; bool p[100009];
int main() {
	cin >> Q;
	for (int i = 2; i <= 100000; i++) p[i] = true;
	for (int i = 2; i * i <= 100000; i++) {
		if (!p[i]) continue;
		for (int j = i * i; j <= 100000; j += i) {
			p[j] = false;
		}
	}
	for (int i = 1; i <= 100000; i += 2) {
		if (p[i] && p[(i + 1) / 2]) s[i] = 1;
	}
	for (int i = 1; i <= 100000; i++) s[i] += s[i - 1];
	for (int i = 0; i < Q; i++) {
		cin >> l >> r;
		cout << s[r] - s[l - 1] << endl;
	}
	return 0;
}

Measured memory_bytes: 1152
#include<queue>
#include<stack>
#include<math.h>
#include<cmath>
#include<bitset>
#include<stdio.h>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<iostream>
#include<utility>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int main(){
  int INF=1000000000;
  int n,m,x,i,j,c[20],a;
  vector<vector<int> > g(20);
  scanf("%d %d %d\n",&n,&m,&x);
  for(i=0;i<n;i++){
    scanf("%d ",&c[i]);
    for(j=0;j<m;j++){
      scanf("%d ",&a);
      g[i].push_back(a);
    }
  }
  int ans=1000000000;
  for(int tmp=0;tmp<(1<<n);tmp++){
    bitset<13> s(tmp);
    int sum1=0;
    vector<int> sum(20);
    for(i=0;i<n;i++){
      if(s[i]==1){
        sum1+=c[i];
        for(j=0;j<m;j++){
          sum[j]+=g[i][j];
        }
      }
    }
    int k=0;
    for(i=0;i<m;i++){
      if(sum[i]<x){
        k=1;
      }
    }
    if(k==0){
      ans=min(ans,sum1);
    }
  }
  if(ans==INF){
    printf("-1\n");
    return 0;
  }
  printf("%d\n",ans);
  return 0;
}

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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep_r(i, n) for(int i = n-1; i >= 0; i--)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((ll)(x).size())
#define bit(n) (1LL<<(n))
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define INF bit(60)
#define pb push_back
#define mod 1000000007

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

using namespace std;
using uif=uint_fast64_t;
using ll=long long int;
using tTree=__gnu_pbds::tree< ll , __gnu_pbds::null_type, less< ll >, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update>;

int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mod;a=1ll*a*a%mod;}while(b>>=1);return ans;}
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}

int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


#define FACSIZE 2002

ll invfac[FACSIZE];
ll fac[FACSIZE];

ll mod_pow(ll ,ll );
ll mod_add(ll ,ll );
ll mod_mul(ll ,ll );
ll mod_div(ll ,ll );
void make_fact(ll );
void make_invfact(ll );



int main(void){

  ll n;
  cin>>n;
  using pa=pair<ll,ll>;
  vector<pa> vec(n);
  ll lM=LLONG_MIN,rm=LLONG_MAX;
  rep(i,n){
    cin>>vec[i].first>>vec[i].second;
    lM=max(lM,vec[i].first);
    rm=min(rm,vec[i].second);
  }
  sort(begin(vec),end(vec));

  vector<ll> umin(n);
  vector<ll> dmin(n);

  rep(i,n){
    if(i==0) dmin[i]=vec[i].second;
    else dmin[i]=min(dmin[i-1],vec[i].second );
  }
  rep_r(i,n){
    if(i==n-1) umin[i]=vec[i].second;
    else umin[i]=min(umin[i+1],vec[i].second );
  }
  /*
  for(auto x:umin) cout << x << " ";
  cout << endl;
  for(auto x:dmin) cout << x << " ";
  cout << endl;
  */
  ll ans=0;

for(ll i=0;i<n;i++) ans=max(ans, max(rm-lM+1,0LL) + ( vec[i].second-vec[i].first +1) );

for(ll i=0;i<n-1;i++){
  ans = max(ans, max(dmin[i]-vec[i].first+1,0LL)+max( umin[i+1]-vec[n-1].first+1,0LL )  );
 }

  cout << ans << endl;

  return 0;

}

ll mod_pow(ll x,ll r){
  if(r==0) return 1;
  else if(r==1) return x%mod;
  else if(r%2==0){
    ll t=mod_pow(x,r/2)%mod;
    return t*t %mod;
  } 
  else{
    ll t=mod_pow(x,r/2)%mod;
    ll k= t*t %mod;
    return k*x%mod;
  } 
}
ll mod_add(ll a,ll b){
  return (a+b)%mod;
}

ll mod_mul(ll a,ll b){
  return (a*b)%mod;
}

ll mod_div(ll a,ll b){
  return mod_mul(a,mod_pow(b,mod-2));
}

void make_fact(ll n){
  fac[0]=1;
  rep(i,n){
    fac[i+1]=mod_mul(fac[i],i+1);
  }  
}

void make_invfact(ll n){
  invfac[n]= mod_pow( fac[n] ,mod-2);
  for(int i=n-1;i>=0;i--){
    invfac[i]=mod_mul(invfac[i+1],i+1);
  }

}


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

class Work {
  public:
    int reward;
    int latency;
    bool empty() const { return latency == 0; }
    Work() { latency = 0; }
    Work(int _reward, int _latency) {
      reward = _reward;
      latency = _latency;
    }
    Work(const Work& w) {
      reward = w.reward;
      latency = w.latency;
    }
};

bool has_smaller_reward(const Work& a, const Work& b)
{
  return a.reward < b.reward;
}

bool has_larger_reward(const Work& a, const Work& b)
{
  return a.reward > b.reward;
}

bool has_smaller_latency(const Work& a, const Work& b)
{
  return a.latency < b.latency;
}

bool has_larger_latency(const Work& a, const Work& b)
{
  return a.latency > b.latency;
}

int main()
{
  int nworks, ndays;
  cin >> nworks >> ndays;
  vector<Work> work(nworks);
  for (int i = 0; i < nworks; i++) {
    cin >> work.at(i).latency >> work.at(i).reward;
  }
  sort(work.begin(), work.end(), has_larger_latency);
  priority_queue<Work, vector<Work>, decltype(&has_larger_reward)> pq(&has_larger_reward);
  for (int i = 0; i < nworks; i++) {
    int cap = ndays - work.at(i).latency + 1;
    if ((int)pq.size() < cap) {
      pq.push(work.at(i));
    } else {
      if (!pq.empty() && pq.top().reward < work.at(i).reward) {
        pq.pop();
        pq.push(work.at(i));
      }
    }
  }
  int result = 0;
  while (!pq.empty()) {
    result += pq.top().reward;
    pq.pop();
  }
  cout << result << '\n';
  return 0;
}


Measured memory_bytes: 2168
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
using namespace std;

int M;
typedef vector<vector<int>> mat;

mat mul(mat &a, mat &b){
	mat c(a.size(), vector<int>(b[0].size()));
	rep(i,a.size()){
		rep(k,b.size()){
			rep(j,b[0].size()){
				c[i][j] = (c[i][j] + a[i][k] * b[k][j]) % M;
			}
		}
	}
	return c;
}

mat pow(mat a, int n){
	mat b(a.size(), vector<int>(a.size()));
	rep(i,a.size()){
		b[i][i] = 1;
	}
	while(n > 0){
		if(n & 1) b = mul(b,a);
		a = mul(a, a);
		n >>= 1;
	}
	return b;
}

int n, x, b, c, t;

int solve(mat o){
	mat a(n, vector<int>(n));
	a[0][0] = b;
	a[0][1] = c;
	range(i,1,n - 1){
		a[i][i - 1] = x;
		a[i][i] = b;
		a[i][i + 1] = c;
	}
	a[n - 1][n - 2] = x;
	a[n - 1][n - 1] = b;

	//for(auto i : a){ for(auto j : i){ cout << j << ' '; } cout << endl; } cout << endl;

	a = pow(a,t); //??????A???n??????
	//for(auto i : a){ for(auto j : i){ cout << j << ' '; } cout << endl; } cout << endl;
	o = mul(a,o);
	rep(i,n){
		if(i) cout << ' ';
		cout << o[i][0];
	}
	cout << endl;
	//return a[1][0];
	return 1;
}

int main(){
	while(cin >> n >> M >> x >> b >> c >> t, n){
		mat o(n, vector<int>(1));
		rep(i,n){
			cin >> o[i][0];
		}
		solve(o);
	}
}

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

using namespace std;

using ll = long long;

// Longest Common Subsequence between X=x_1...x_m and Y=y_1...y_n
// O(mn)
// ALDS_1_10_C: verified
int main(){
    ll Q; cin >> Q;
    for(ll q=0;q<Q;q++){
        string X, Y; cin >> X >> Y;
        ll m = X.size(), n = Y.size();
        vector<vector<ll> > dp(m + 1, vector<ll>(n + 1));
        for(ll i=1;i<=m;i++){
            for(ll j=1;j<=n;j++){
                if(X[i-1] == Y[j-1]){
                    dp[i][j] = max(max(dp[i][j-1], dp[i-1][j]), dp[i-1][j-1] + 1);
                }else{
                    dp[i][j] = max(dp[i][j-1], dp[i-1][j]);
                }
            }
        }
        cout << dp[m][n] << endl;
    }
}


Measured memory_bytes: 10824
def solve(s, a, b):
    if a % b == 0:
        return s + ((a // b) * 2 - 1) * b
    if b % a == 0:
        return s + ((b // a) * 2 - 1) * a
    elif a > b:
        s += (a // b) * 2 * b
        return solve(s, a % b, b)
    else:
        s += (b // a) * 2 * a
        return solve(s, a, b % a)

n, x = map(int, input().split())
print(solve(n, n - x, x))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
#define INF 200000000000
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()

bool compare(pair<int, int> a, pair<int, int> b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}
// 入力



vector<int> Eratosthenes( const int N )
{
    vector<bool> is_prime( N + 1 );
    for( int i = 0; i <= N; i++ )
    {
        is_prime[ i ] = true;
    }
    std::vector<int> P;
    for( int i = 2; i <= N; i++ )
    {
        if( is_prime[ i ] )
        {
            for( int j = 2 * i; j <= N; j += i )
            {
                is_prime[ j ] = false;
            }
            P.emplace_back( i );
        }
    }
    return P;
}
//100003
int main()
{
    int N;
    cin >> N;
    for( const auto &x: Eratosthenes( 100004 ) )
    {
        if(x>=N){
            cout << x<<endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 3656
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <regex>
#include <vector>

#define fix(n)          cout<<fixed<<setprecision(n)
#define rep(i,n)        for (int i = 0; i < (n); ++i)
#define all(a)          (a).begin(), (a).end()
#define sort(a)         sort(all(a))
#define uniq(a)         sort(a);(a).erase(unique(all(a), (a).end())
#define reverse(a)      reverse(all(a))
#define ctos(c)         string(1, (c))
#define out(d)          cout << (d)
#define outl(d)         std::cout<<(d)<<"\n"
#define YES()           cout << "YES" << endl
#define NO()            cout << "NO" << endl
#define Yes()           cout << "Yes" << endl
#define No()            cout << "No" << endl
#define ceil(x, y)      ((x + y - 1) / (y))
#define debug(x)        cerr << #x << ": " << (x) << '\n'
#define debug2(x, y)    cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v)          for (size_t _ = 0; _ < v.size(); ++_){ cerr << #v << "[" << _ << "] : " << v[_] << '\n'; }
#define pb              push_back
#define fst             first
#define int             long long

using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;

const ll MOD = 1000000007; // 10^9 + 7
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

ll mod_pow(ll x, ll n, ll m) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * x % m;
    x = x * x % m;
    n >>= 1;
  }
  return res;
}

void solve() {
  ll n; cin >> n;
  vector<ll> d(n); rep(i, n) cin >> d[i];

  if (d[0] != 0) {
    outl(0);
    return;
  }

  const ll MAX = 100000;
  vector<ll> nums(MAX + 1, 0);
  rep(i, n) nums[d[i]]++;

  if (nums[0] != 1) {
    outl(0);
    return;
  }

  ll ans = 1;
  const int MOD = 998244353;
  for (int i = 1; i <= MAX; i++) {
    ans = ans * mod_pow(nums[i-1], nums[i] ,MOD) % MOD;
  }
  outl(ans);
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));
  fix(12);

  solve();
}


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

int main()
{
    string s, t;
    cin >> s >> t;

    sort(s.begin(), s.end());
    sort(t.begin(), t.end(), greater<char>());


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

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 998244353
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int main(){
  ll N;cin>>N;
  ll i,j,k,l;
  ll x[N],y[N];
  ll ans=0;
  rep(i,N) cin>>x[i]>>y[i];
  rep(i,N){
    for(j=i+1;j<N;j++){
      ll dx=x[i]-x[j], dy=y[i]-y[j];
      //cout<<dx<<dy<<endl;
      ll tmp=0;
      rep(k,N){
        rep(l,N){
          if(x[k]-x[l]==dx and y[k]-y[l]==dy) tmp++;
          ans=max(tmp,ans);
        }
      }
    }
  }
  ans=N-ans;
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int c[6];
	int i;
	int sum;

	for (i = 0; i < 6; i++){
		scanf("%d", &c[i]);
	}
	
	sum = c[5] * 500 + c[4] * 100 + c[3] * 50 + c[2] * 10 + c[1] * 5 + c[0] * 1;
	
	if (sum >= 1000){
		printf("1");
	}
	else {
		printf("0");
	}
	printf("\n");
	
	return (0);
}

Measured memory_bytes: 572
#include <iostream>
#include <iomanip>
#include <climits>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <list>
#include <stack>
#include <string>
#include <functional>
#include <numeric>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <unordered_map>
#include <random>
#define _USE_MATH_DEFINES
#include <math.h>
#include <complex>

using namespace std;

#define INF (int)1e8
#define _INF (int)-1e8  
#define INFLL (long long)1e15
#define _INFLL (long long)-1e15
#define Loop(i, n) for(int i = 0; i < (int)n; i++)
#define Loop1(i, n) for(int i = 1; i <= (int)n; i++)
#define Loopr(i, n) for(int i = (int)n - 1; i >= 0; i--)
#define Loopr1(i, n) for(int i = (int)n; i >= 1; i--)
#define bitmanip(m,val) static_cast<bitset<(int)m>>(val)
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> P;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;

/*******************************************************/

// clockwise
int medium(int a, int b, int n) {
  if (b <= a) b += n;
  return (a + b) / 2 % n;
}

int sign_of(string s) {
  if (s == "Male") return 0;
  else return 1;
}

int main() {
  int n; cin >> n;
  int left = 0, right = 0, l_sign, r_sign, m_sign;
  int m;
  string response;
  cout << 0 << endl;
  cin >> response;
  if (response == "Vacant") return 0;
  l_sign = sign_of(response);
  r_sign = sign_of(response);
  while (true) {
    m = medium(left, right, n);
    cout << m << endl;
    cin >> response;
    if (response == "Vacant") return 0;
    m_sign = sign_of(response);
    if (abs(m - left) % 2 == 0) {
      if (m_sign != l_sign) {
        right = m;
        r_sign = m_sign;
      }
      else {
        left = m;
        l_sign = m_sign;
      }
    }
    else {
      if (m_sign != l_sign) {
        left = m;
        l_sign = m_sign;
      }
      else {
        right = m;
        r_sign = m_sign;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 852
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static String Y = "Yes";
	public static String N = "No";
	public static long MOD = (long) (Math.pow(10, 9) + 7);
	public static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {

		int n = ni();

		long[] l = new long[n];
		for (int i = 0; i < n; i++) {
			l[i] = nl();
		}

		Arrays.sort(l);

		if (n <= 2) {
			out(0);
			return;
		}

		long ans = 0;

		for (int i = 0; i < n - 2; i++) {
			for (int j = i + 1; j < n - 1; j++) {
				for (int k = j + 1; k < n; k++) {
					if (l[i] != l[j] && l[i] != l[k] && l[j] != l[k]) {
						if (l[k] < l[i] + l[j]) {
							ans++;
						}
					}
				}
			}
		}

		out(ans);

	}

	/*
	 * 以下メソッド集
	 */

	public static void permutation(String q, String ans) {
		// Base Case
		if (q.length() <= 1) {
			System.out.println(ans + q);
		}
		// General Case
		else {
			for (int i = 0; i < q.length(); i++) {
				permutation(q.substring(0, i) + q.substring(i + 1),
						ans + q.charAt(i));
			}
		}
	}

	static char[][] same(char[][] c, int h, int w) {

		char[][] a = new char[h][w];
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				a[i][j] = c[i][j];
			}
		}
		return a;

	}

	static int countkuro(char[][] c) {

		int count = 0;
		for (char[] cc : c) {
			for (char ccc : cc) {
				if ('#' == ccc) {
					count++;
				}
			}
		}
		return count;
	}

	static void debug() {

		out("---");
	}

	static void debug(Object a) {

		out("-------");
		out(a);
		out("-------");
	}

	static int ketasuu(int n) {

		String str = "" + n;
		return str.length();
	}

	static int account(String str) {

		String target = "AC";
		int count = 0;
		int len = str.length();
		for (int i = 0; i < len - 1; i++) {
			if (target.equals(str.substring(i, i + target.length()))) {
				count++;
			}
		}
		return count;
	}

	static int ni() {

		return sc.nextInt();
	}

	static long nl() {

		return sc.nextLong();
	}

	static double nd() {

		return sc.nextDouble();
	}

	static String n() {

		return sc.next();
	}

	static char[] nc() {

		return sc.next().toCharArray();
	}

	static int kaijo(int n) {

		if (n == 0 || n == 1) {
			return 1;
		} else {
			return n * kaijo(n - 1);
		}
	}

	static int fib(int n) {

		return (n == 1 || n == 0) ? n : fib(n - 2) + fib(n - 1);
	}

	static long lcm(long m, long n) {

		return m * n / gcd(m, n);
	}

	static int lcm(int m, int n) {

		return m * n / gcd(m, n);
	}

	static long gcd(long a, long b) {

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

	static int gcd(int a, int b) {

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

	static void out(Object obj) {
		System.out.println(obj);
	}

	static void outn(Object obj) {
		System.out.print(obj);
	}

	static double max(double d, double e) {

		return Math.max(d, e);
	}

	static long max(long a, long b) {

		return Math.max(a, b);
	}

	static long min(long d, long e) {

		return Math.min(d, e);
	}

	static int min(int a, int b) {

		return Math.min(a, b);
	}
}

class XY {

	int h;
	int c;

	XY(int h, int c) {
		this.h = h;
		this.c = c;
	}
}


Measured memory_bytes: 36840
import bisect

def main():
    n = int(input())
    li = [int(a) for a in input().split()]
    q = int(input())

    for _ in range(q):
        k = int(input())
        l = bisect.bisect_left(li, k)
        u = bisect.bisect_right(li,k)
        print("{0} {1}".format(l, u))
main()



Measured memory_bytes: 17204
# AOJ 0600 Baumkuchen
# Python3 2018.7.3 bal4u

import sys
from sys import stdin
input = stdin.readline

n = int(input())
a = [int(input()) for i in range(n)]
su = sum(a)
p = [0]*(n+1)
s = [0]*(n+1)
l, r = 0, su+1
while l + 1 < r:
	m = (l+r) >> 1
	for i in range(0, n):
		if i == 0: s[i] = p[i] = 0
		else:
			p[i] = p[i-1] - 1
			s[i] = s[i-1] - a[i-1]
			
		while s[i] < m:
			ii = i + p[i];
			if ii >= n: ii -= n
			s[i] += a[ii]
			p[i] += 1

	f = 0	
	for i in range(n):
		ii = i + p[i];
		if ii >= n: ii -= n
		if su-s[i]-s[ii] >= m:
			f = 1
			break
	if f: l = m
	else: r = m
print(l)


Measured memory_bytes: 18072
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using piii = pair<int, pair<int, int>>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
template <typename T>
using Graph = vector<vector<T>>;
const int MOD = 1e9 + 7;

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

    int N;
    cin >> N;
    vector<int> cnt(26, 1);
    for (int i = 0; i < N; ++i) {
        char c;
        cin >> c;
        cnt[c - 'a']++;
    }

    ll ans = 1;
    for (auto i : cnt)
        (ans *= i) %= MOD;
    ans--;
    if (ans < 0)
        ans += MOD;

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


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


int main(){
  string S;
  cin >> S;
  int len = S.size();
  int ans = 1000;
  for(int ii=0; ii<len-2; ii++){
    int cur = stoi(S.substr(ii, 3));
    if(abs(cur-753) < ans){
      ans = abs(cur-753);
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
N=int(input())
As=input().split()
# N=5
# As=[1, 2, 1, 3, 5]
# As=[1, 3, 5, 2, 1, 3, 2, 8, 8, 6, 2, 6, 11, 1, 1]

from collections import defaultdict
dic=defaultdict(int)
for k in As:
	dic[k]+=1
c=0
for k, v in dic.items():
	if v>2:
		t=((v-1)//2)*2
		# print(v,v-t)
		# dic[k]=v-t
		v=v-t
	if v==2:
		c+=1
l=len(dic)
if c%2==0:
	print(l)
else:
	print(l-1)


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

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

Measured memory_bytes: 3996
#include <iostream>
#include <algorithm>
#define rep(a,b,c) for(int a=b;a<=c;a++)
using namespace std;

#define ll long long
#define mod 1000000007



int main(){


ll a,b;

cin>>a>>b;

if(abs(a-b)<=1){
	cout<<"Brown";
}   else{
	cout<<"Alice";
}

}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <time.h>
#include <stdio.h>
#include <vector>
#define int long long
#define sys system("PAUSE")
using namespace std;
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
int mypow(int x, int y) {
	if (y == 0)return 1;
	if (y % 2)return mypow(x, y - 1)*x;
	else return mypow(x, y / 2)*mypow(x, y / 2);
}
int Max(int x, int y) {
	if (x > y)return x;
	else return y;
}
int Min(int x, int y) {
	if (x < y)return x;
	else return y;
}
int kai(int x) {
	int cnt=1;
	if (x == 0)return 1;
	cnt = kai(x - 1);
	return x * cnt;
}
int prime(int n) {
	for (int i = 2; i*i <= n; i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
void prime_factor(int n){
	int cnt = 1;
	map<int, int>res;
	int m = n;
	for (int i = 2; i<= n; i++) {
		if(prime(i)){
			while (m%i == 0) {
				++res[i];
				m /= i;
			}
		}
	}
	cout << n <<":"<< endl;
	for (int i = 2; i<= n; i++) {
		if (res[i]) {
			cout << i << " " << res[i] << endl;
		}
	}
	cout << endl;
}
/*Library End!*/

signed main() {
	int n, a, b;
	cin >> n;
	if (n == 1) {
		cout << "Hello World" << endl;
		sys;
		return 0;
	}
	else {
		cin >> a >> b;
		cout << a + b << endl;
	}
	sys;
	return 0;
}

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

const int mxN=105;
int n,ans;
int a[mxN],b[mxN];

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

    cin>>n;

    for(int i=0;i<n-1;i++){
        cin>>b[i];

    }
    a[0]=a[1]=b[0];
    ans+=2*b[0];
    for(int i=1;i<n-1;i++){
        //cout<<b[i]<<"\n";
        if(b[i]<a[i]){
            ans-=a[i];
            a[i]=b[i];
            ans+=a[i];
        }
        a[i+1]=b[i];
        ans+=a[i+1];
    }

    cout<<ans;


}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    long long int a,b,c,x,y;
    cin>>a>>b>>c>>x>>y;
    //普通に買う場合
    long long int sum_normal;
    sum_normal=x*a+y*b;
    //ABピザを使う場合
    long long int sum_AB;
    if (x==y) {
        sum_AB=c*x*2;
    } else if (x<y) {
        sum_AB=min(c*x*2+b*(y-x),c*y*2);
    } else {
        sum_AB=min(c*y*2+a*(x-y),c*x*2);
    }
    cout<<min(sum_normal,sum_AB)<<endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    int answer = 0;
    if (s.equals("SUN")){
      answer = 7;
    } else if (s.equals("MON")){
      answer = 6;
    } else if (s.equals("TUE")){
      answer = 5;
    } else if (s.equals("WED")){
      answer = 4;
    } else if (s.equals("THU")){
      answer = 3;
    } else if (s.equals("FRI")){
      answer = 2;
    } else if (s.equals("SAT")){
      answer =1;
    }
    System.out.println(answer);
  }
}

Measured memory_bytes: 22868
#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};
const int INF = 1<<29;
#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;
}
//最大公約数
int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }
//最小公倍数
int lcm(int x, int 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(){
    int N,K; cin >> N >> K;
    int a=0,c=0;
    double out=0;
    for(int i=1;i<=N;i++){
        double tmp = 1.0/N;
        int c=i;
        while(c<K){
            c *= 2;
            tmp /= 2;
        }
        out += tmp;
    }
    printf("%.10lf\n",out);
    return 0;
}


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

int main(){
	int r,g,b;
	cin >> r >> g >> b;
	if((10*g+b)%4 == 0) cout << "YES" << endl;
	else cout << "NO" << endl;
}

Measured memory_bytes: 256
from math import sqrt


def func(N, p1, p2):
    if N == 0:
        return 0
    s = ((2*p1[0]+p2[0])/3, (2*p1[1]+p2[1])/3)
    t = ((p1[0]+2*p2[0])/3, (p1[1]+2*p2[1])/3)
    x = (t[0]-s[0])/2-sqrt(3)*(t[1]-s[1])/2+s[0]
    y = sqrt(3)*(t[0]-s[0])/2+(t[1]-s[1])/2+s[1]
    u = (x, y)
    func(N-1, p1, s)
    print(*s)
    func(N-1, s, u)
    print(*u)
    func(N-1, u, t)
    print(*t)
    func(N-1, t, p2)


N = int(input())
print(*(0.0, 0.0))
func(N, (0.0, 0.0), (100.0, 0.0))
print(*(100.0, 0.0))



Measured memory_bytes: 5760
#include <cstdlib>
#include <cstdio>
#include <iostream>

typedef int type;
using namespace std;
const bool isDebug = true;

void showArray(type A[], int N){
    for(int i=0; i<N; i++){
        printf("%d", A[i]);
        if(i != N-1) printf(" ");
    }
    printf("\n");
}

void insertionSort(type A[], int N){
    
    for(int i=0; i<N; i++){

        type v = A[i];
        int j = i-1;
        while(j>=0 && A[j]>v){
            A[j+1] = A[j];
            j--;
        }
        A[j+1] = v;
        if(isDebug) showArray(A, N);
    }
}

#define MAX_N 100
int N;
int A[MAX_N];
void input(){
    cin >> N;
    for(int i=0; i<N; i++){
        cin >> A[i];
    }
}

int main(){
    input();
    insertionSort(A, N);
    return 0;
}

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

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF (LLONG_MAX - 1e5)

using namespace std;

int N, M;
vector<int> G[100005];
bool used[100005];

int dfs(int s, deque<int> &q) {
    used[s] = true;
    q.push_back(s);
    REP(i, G[s].size()) {
        if (used[G[s][i]]) continue;
        return dfs(G[s][i], q);
    }
    return s;
}

bool judge(deque<int> &q) {
    int front = q.front();
    REP(i, G[front].size()) {
        if (used[G[front][i]]) continue;
        q.push_front(G[front][i]);
        used[q.front()] = true;
        return false;
    }
    int back = q.back();
    REP(i, G[back].size()) {
        if (used[G[back][i]]) continue;
        q.push_back(G[back][i]);
        used[q.back()] = true;
        return false;
    }
    return true;
}

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

    cin >> N >> M;
    REP(i, M) {
        int a, b;
        cin >> a >> b;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    deque<int> q;
    int a = dfs(1, q);
    while (!judge(q)) {}

    cout << q.size() << endl;
    REP(i, q.size()) {
        if (i != 0) cout << " ";
        cout << q[i];
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 10112
from fractions import gcd

def main():
    n = int(input())
    a = list(map(int, input().split()))
    left = [0]
    right = [0]
    for i in range(1, n):
        g = gcd(left[-1], a[i - 1])
        left.append(g)
    for i in range(n - 2, -1, -1):
        g = gcd(right[-1], a[i + 1])
        right.append(g)
    right.reverse()
    m = 0
    for i in range(0, n):
        m = max(m, gcd(left[i], right[i]))
    print(m)
    
if __name__ == '__main__':
    main()

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

int main() {
    string S;
    cin >> S;
    long cont = 0;
    vector<size_t> rainy;
    for (auto i = 0; i < S.length(); ++i) {
        if (S[i] == 'R') {
            ++cont;
        }
        else {
            rainy.push_back(cont);
            cont = 0;
        }
    }
    rainy.push_back(cont);
    cout << *max_element(rainy.cbegin(), rainy.cend()) << endl;
}

Measured memory_bytes: 3596
#include<cstdio>
const int N=1e5+5,M=2*N;
int n,i,et,he[N],sg[N];
struct edge{int l,to;}e[M];
int read(){
	char c=getchar();int k=0;for (;c<48||c>57;c=getchar());
	for (;c>47&&c<58;c=getchar()) k=(k<<3)+(k<<1)+c-48;return k;
}
void dfs(int x,int fa){
	for (int i=he[x];i;i=e[i].l) if (e[i].to!=fa)
		dfs(e[i].to,x),sg[x]^=sg[e[i].to]+1;
}
int main(){
	for (n=read(),i=1;i<n;i++){
		int x=read(),y=read();
		e[++et].l=he[x];he[x]=et;e[et].to=y;
		e[++et].l=he[y];he[y]=et;e[et].to=x;
	}
	dfs(1,0);
	puts(sg[1]?"Alice":"Bob");
}

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

int m[4][3][10];

int main()
{
  memset(m,0,sizeof(m));
  int n;
  cin >> n;
  for(int i=0; i<n; i++){
    int b,f,r,v;
    cin >> b >> f >> r >> v;
    m[b-1][f-1][r-1] += v;
  }
  for(int i=0; i<4; i++){
    if(i != 0) cout << "####################" << endl;
    for(int j=0; j<3; j++){
      for(int k=0; k<10; k++){
        cout << " " << m[i][j][k];
      }
      cout << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1164
void main(){
	int n = _scan();
	int[string] dic;
	foreach(i; 0..n){
		dic[readln().chomp()]++;
	}
	dic.length.writeln();
}

import std.stdio, std.conv, std.algorithm, std.numeric, std.string, std.math;

// 1要素のみの入力
T _scan(T= int)(){
	return to!(T)( readln().chomp() );
}

// 1行に同一型の複数入力
T[] _scanln(T = int)(){
	T[] ln;
	foreach(string elm; readln().chomp().split()){
		ln ~= elm.to!T();
	}
	return ln;
}


Measured memory_bytes: 23640
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define int ll
#define double long double
#define YES {cout<<"YES"<<'\n';}
#define NO {cout<<"NO"<<'\n';}
#define Yes {cout<<"Yes"<<'\n';}
#define No {cout<<"No"<<'\n';}
#define yes {cout<<"yes"<<'\n';}
#define no {cout<<"no"<<'\n';}
void YN(bool flg){cout<<(flg?"YES":"NO")<<'\n';}
void Yn(bool flg){cout<<(flg?"Yes":"No")<<'\n';}
void yn(bool flg){cout<<(flg?"yes":"no")<<'\n';}
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
#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 out(n) {cout << n << '\n';}
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<VI> VVI;
const int MOD = 1000000007;
const long long INF = 10e10;
const double PI = acos(-1.0);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
int ABS(int a) {if(a<0) a = -a; return a;}
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }
int POW(int a, int n) { int r = 1; while (n > 0) { if (n & 1)r *= a; a *= a; n /= 2; }return r; }
int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*素因数分解*/map< int, int >prime_factor(int n){map< int, int > ret;for(int i = 2; i * i <= n; i++) {while(n % i == 0) {ret[i]++;n /= i;}}if(n != 1) ret[n] = 1;return ret;}
/*約数の個数*/int divisor_number(int n){auto p = prime_factor(n); int res = 1; for(auto x:p)res*=(x.second+1); return res;}
/*約数列挙*/vector<int> divisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------ライブラリとか----------------

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(15);

    char x,y; cin >> x >> y;
    if(x>y) out('>');
    if(x==y) out('=');
    if(x<y) out('<');

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main (String[] args) {
		Scanner scan = new Scanner (System.in);
		int count = 0;
		final int n = scan.nextInt();
		int[] dataS = new int[n + 1];
		
		for (int i = 0; i < n; i++) {
			dataS[i] = scan.nextInt();
		}
		
		final int q = scan.nextInt();
		
		for (int i = 0; i < q; i++) {
			final int search = scan.nextInt();
			count += LinearSearch (dataS, search);
		}
		scan.close();
		System.out.println(count);
	}
	
	public static int LinearSearch ( int[] data, int s) {
		
		int i = 0;
		int n = data.length - 1;
		data[n] = s;
		
		while (data[i] != s) {
			
			i++;
			if (i == n) return 0;
		}
		
		return 1;
	}
}



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

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

    auto monsters = vector<int>(n + 1);
    auto heroes = vector<int>(n);
    for (auto &m : monsters)
        cin >> m;
    for (auto &h : heroes)
        cin >> h;

    auto counter = 0LL;
    for (int i = n - 1; i >= 0; i--) {
        auto kill = min(monsters[i + 1], heroes[i]);
        counter += kill;
        monsters[i + 1] -= kill;
        heroes[i] -= kill;
        kill = min(monsters[i], heroes[i]);
        counter += kill;
        monsters[i] -= kill;
        heroes[i] -= kill;
    }

    cout << counter;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <vector>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
#define MOD 1000000007 
//ll dx[4] = {1,-1,0,0};
//ll dy[4] = {0,0,1,-1};

/*ll pasc[100][100];
ll getPasc(ll n,ll k){
  if(pasc[n][k]!=0){
    return pasc[n][k];
  }else{
    pasc[n][k] = getPasc(n-1,k-1)+getPasc(n-1,k);
    return pasc[n][k];
  }
}*/


ll n;
ll a[100000];
ll solve(ll i,ll sum){
  if(i==0){
    if(a[i]==0){
      return min(1+solve(i+1,-1),1+solve(i+1,1));
    }else if(a[i]>0){
      return min(solve(i+1,a[i]),a[i]+1+solve(i+1,-1));
    }else{
      return min(solve(i+1,a[i]),1-a[i]+solve(i+1,1));
    }
    return solve(i+1,sum);
  }else if(i==n-1){
    if(sum>0&&sum+a[i]<0){
      return 0;
    }else if(sum>0&&sum+a[i]>=0){
      return abs(-1-sum-a[i]);
    }else if(sum<0&&sum+a[i]>0){
      return 0;
    }else{
      return abs(1-sum-a[i]);
    }
  }else{
    if(sum>0&&sum+a[i]<0){
      return solve(i+1,sum+a[i]);
    }else if(sum>0&&sum+a[i]>=0){
      return abs(-1-sum-a[i])+solve(i+1,-1);
    }else if(sum<0&&sum+a[i]>0){
      return solve(i+1,sum+a[i]);
    }else{
      return abs(1-sum-a[i])+solve(i+1,1);
    }
  }
}

int main(){
  cin>>n;
  REP(i,n){
    cin>>a[i];
  }
  ll ans = solve(0,0);
  cout<<ans<<endl;

  return 0;
}

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

void print(vector<int> vec) {
	cout << vec[0];
	for(int i = 1; i < vec.size(); ++i) {
		cout << " " << vec[i];
	}
	cout << endl;
}

void BubbleSort(vector<int> &vec,int &count) {
	bool flag = true;
	int n = vec.size();
	int j = 0;
	while (flag) {
		flag = false;
		for (int i = n - 1; i >j; --i) {
			if (vec[i - 1] > vec[i]) {
				swap(vec[i - 1], vec[i]);
				++count;
				flag = true;
			}
		}
		++j;
	}
}

int main() {
	int n;
	cin >> n;
	vector<int> vec;
	for (int i = 0; i < n; ++i) {
		int tmp;
		cin >> tmp;
		vec.push_back(tmp);
	}
	int count = 0;
	BubbleSort(vec, count);
	print(vec);
	cout << count << endl;

	return 0;
}


Measured memory_bytes: 3120