akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Linq;

namespace ABC153
{
    class D
    {
        static void Main(string[] args)
        {
            long H = long.Parse(Console.ReadLine());
            long res = 0;
            long index = 0;
            while (0 < H)
            {
                res += (long)Math.Pow(2, index);
                H /= 2;
                index++;
            }
            Console.WriteLine(res);
        }
    }
}


Measured memory_bytes: 11092
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long[] A = new long[N];
		for(int i=0;i<N;++i){
			A[i] = sc.nextLong();
		}
		sc.close();
		long ans = 0;
		for(int i=1;i<N;++i){
			if(A[i]<A[i-1]){
				ans += A[i-1] - A[i];
				A[i] += A[i-1] - A[i];
				//System.out.println(A[i]);
			}
		}
		System.out.println(ans);
	}
}



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

import heapq
import itertools
import operator


inf = float('inf')


# globals
N = 0


def set_inputs():
    global N
    N = get_int()
    return


def main():
    setrecursionlimit(100000)
    set_inputs()
    # ----------MAIN----------
    dp = [0] * (N + 1)
    ops = [
        1,
        6 ** 1, 6 ** 2, 6 ** 3, 6 ** 4, 6 ** 5, 6 ** 6,
        9 ** 1, 9 ** 2, 9 ** 3, 9 ** 4, 9 ** 5
    ]
    for i in range(1, N + 1):
        dp[i] = min(dp[i-j] for j in ops if i - j >= 0) + 1
    print(dp[N])
    return


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


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


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


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


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


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


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


if __name__ == '__main__':
    main()


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

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
using namespace boost::multiprecision;
typedef long long int ll;
typedef long double ld;
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; }
const long long INF = 1LL << 60;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
bool pairCompareSecond(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.second < secondElof.second;
}
#define MAX_N 100100
#define MOD 998244353
bool x[MAX_N];
ll num[MAX_N];
ll fibl[MAX_N]={0};
// 四方向への移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll fib(ll a){
    if (fibl[a]!=0)return fibl[a];
    if (a==0){
        return 0;
    }else if (a==1){
        return 1;
    }
    return fibl[a]=fib(a-1)+fib(a-2);
}

ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    return p;
}
 
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}
 
ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

void  base_num(ll data,ll base){
    if(data==0) return;
    ll next=abs(data)%abs(base);
    if(data<0) next=(abs(base)-next)%abs(base);
    base_num((data-next)/base,base);
    cout << next;
}

int main(){
    ll n;
    cin >> n;
    cpp_int a=1;
  	ll x[n];
  	for (ll i=0;i<n;i++)cin >> x[i];
  	sort(x,x+n);
    for (ll i=0;i<n;i++){
        a*=x[i];
      	if (a>1000000000000000000){
        	cout << -1 << endl;
        	return 0;
    	}
    }
    if (a>1000000000000000000){
        cout << -1 << endl;
    }else{
        cout << a << endl;
    }
    return 0;
}


Measured memory_bytes: 4440
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

	static class Task {
        public void solve(InputReader in, PrintWriter out) {
        	long a = in.nextLong();
        	long currentNum = a%1000;
        	a /= 1000;
        	long minDiff = Math.abs(currentNum-753);
        	
        	while(a > 0) {
        		long newDigit = a%10;
        		currentNum /= 10;
        		currentNum += newDigit*100;
        		minDiff = Math.min( Math.abs(currentNum-753), minDiff );
        		
        		a /= 10;
        	}
        	out.println(minDiff);
        }
    }
	
    public static void main(String argds[]) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(in, out);
        out.close();
    }

	static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;
        
        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }
        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }
 
        public int nextInt() {
            return Integer.parseInt(next());
        }
 
        public long nextLong() {
            return Long.parseLong(next());
        }
    }	
}

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

int main(){
    int n;
    cin >> n;
    long ans = 0;
    for(int i=1; i <= n; ++i){
        if(i%3 != 0 && i%5 != 0){    
            ans = ans + i;   
        }
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 3624
#include <stdio.h>

int main(){
    int D,N,ans=1,i;
    scanf("%d %d", &D,&N);
    for(i=0;i<D;i++){
        ans *= 100;
    }
    ans *= N;
    if(N==100) ans += ans/N;
    printf("%d", ans);
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(void){
  int n; cin>>n;
  vector<int> a(n);
  for(auto& i:a) cin>>i;
  unordered_map<int,int> m;
  for(auto& i:a){ ++m[i]; if(m[i]>1){ cout<<"NO"; return 0;}}
  cout<<"YES";
  return 0;
}

Measured memory_bytes: 12232
#include<stdio.h>
double x[22];
double y[22];
int main(){
	double a,b;
	int now=1;
	while(~scanf("%lf,%lf",&a,&b)){
		x[now]=a;
		y[now++]=b;
	}
	x[0]=x[now-1];
	x[now]=x[1];
	double S=0;
	for(int i=1;i<now;i++){
		S+=(x[i+1]-x[i-1])*y[i];
	}
	if(S<0)S=-S;
	printf("%.8lf",S/2.0);
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
const ll INF = 1LL<<60;
const ll MOD = 1e9+7;
int n;
int dgt(int x,int s){
    for(int i=0; i<n-s; i++){
        x/=10;
    }
    return x%10;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int m; cin>>n>>m;
    vector<int> s(m),c(m);
    for(int i=0; i<m; i++)cin>>s[i]>>c[i];
    int l,r;
    if(n==1){l=0;r=10;}
    if(n==2){l=10;r=100;}
    if(n==3){l=100;r=1000;}
    int ans = -1;
    for(int i=l; i<r; i++){
        bool flag = true;
        for(int j=0; j<m; j++){
            if(dgt(i,s[j])!=c[j]){flag = false;break;}
        }
        if(!flag)continue;
        ans = i;
        break;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
<?php
$n = (int)trim(fgets(STDIN));
$input = explode(' ', trim(fgets(STDIN)));

$ps = [];
foreach ($input as $v) {
	$ps[] = (int)$v;
}

$cnt = 0;
for ($i=1; $i < $n-1; $i++) { 
	if (max($ps[$i-1],$ps[$i],$ps[$i+1]) !== $ps[$i] && min($ps[$i-1],$ps[$i],$ps[$i+1]) !== $ps[$i]) {
		++$cnt;
	}
}
echo $cnt;

Measured memory_bytes: 4728
"""
map(int,input().split())

X = input().split()
x = []
for i in range(0,len(X)):
    x.append(X[i])

"""

def search(l, x):
    if x in l:
        return l.index(x)
    else:
        return -1

N = int(input())



ball = []

for n in range(N):
    x,y = map(int,input().split(" "))
    ball.append((x,y))

if N== 1:
    print(1)
    exit()

#最適p,q計算
pqList = []
pqCount = []
for i in range(0,N):
    for j in range(0,N):
        if i != j:
           i_x = ball[i][0]
           i_y = ball[i][1]
           j_x = ball[j][0]
           j_y = ball[j][1]
           s = search(pqList,(i_x-j_x,i_y-j_y))
           if s != -1 :
               pqCount[s] += 1
           else:
               pqList.append((i_x-j_x,i_y-j_y))
               pqCount.append(1)

print(int(N - (max(pqCount))))


Measured memory_bytes: 3316
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <functional>
using ll=long long;
#include <set>
using namespace std;
ll gcd(ll x,ll y){
    if(y==0){
        return x;
    }else{
        return gcd(y,x%y);
    }
}
int main(){
    int n;
    cin >> n;
    vector<ll> vec(n);
    vector<ll> vec1(n);
    vector<ll> vec2(n);
    for(int i=0;i<n;i++){
        cin >> vec[i];
    }
    for(int i=0;i<n;i++){
        if(i==0){
            vec1[i]=vec[0];
        }else{
            vec1[i]=gcd(vec1[i-1],vec[i]);
        }
    }
    for(int i=n-1;i>=0;i--){
        if(i==n-1){
            vec2[i]=vec[n-1];
        }else{
            vec2[i]=gcd(vec2[i+1],vec[i]);
        }
    }
    long long Max =vec1[n-2];
    Max = max(Max,vec2[1]);
    for(int i=1;i<n-1;i++){
        Max=max(Max,gcd(vec1[i-1],vec2[i+1]));
    }
    cout<<Max<<endl;
}

Measured memory_bytes: 2560
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <complex>
using namespace std;

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

#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp make_pair
#define ERASE(v,i) (v).erase(remove(all(v),i),(v).end())
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define each(it,c) for(typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define debug(x) cerr<<#x<<" = "<<(x)<<endl;
#define LINE cerr<<"LINE: "<<__LINE__<<endl;

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();}
template<class T> void preview(T a,T b){for(T it=a;it!=b;++it)cerr<<*it<<" ";cerr<<endl;}

const int INF = 100000000;
const double PI = acos(-1.0), EPS = 1e-10;

int main() {
	for(int n,m; cin >> n >> m, n || m;) {
		map<string, int> st_name;
		int idx = 3;

		string s, p, g;
		cin >> s >> p >> g;

		st_name[s] = 0;
		st_name[p] = 1;
		st_name[g] = 2;

		vector<vector<P> > edge(n);

		rep(i,m) {
			string a, b;
			int d, t;
			cin >> a >> b >> d >> t;
			int dist = (d / 40) + t;
			if(st_name.find(a) == st_name.end()) st_name[a] = idx++;
			if(st_name.find(b) == st_name.end()) st_name[b] = idx++;
			edge[st_name[a]].pb(mp(dist, st_name[b]));
			edge[st_name[b]].pb(mp(dist, st_name[a]));
		}

		vector<int> dist_a(n, INF);
		vector<int> dist_b(n, INF);
		{
			priority_queue<P, vector<P>, greater<P> > que;
			dist_a[0] = 0;
			que.push(P(0, 0));

			while(!que.empty()) {
				P p = que.top(); que.pop();
				int v = p.second;
				if(dist_a[v] < p.first) continue;
				each(it, edge[v]) {
					if(dist_a[it->second] > dist_a[v] + it->first) {
						dist_a[it->second] = dist_a[v] + it->first;
						que.push(P(dist_a[it->second], it->second));
					}
				}
			}
		}
		{
			priority_queue<P, vector<P>, greater<P> > que;
			dist_b[1] = 0;
			que.push(P(0, 1));

			while(!que.empty()) {
				P p = que.top(); que.pop();
				int v = p.second;
				if(dist_b[v] < p.first) continue;
				each(it, edge[v]) {
					if(dist_b[it->second] > dist_b[v] + it->first) {
						dist_b[it->second] = dist_b[v] + it->first;
						que.push(P(dist_b[it->second], it->second));
					}
				}
			}
		}

		cout << dist_a[1] + dist_b[2] << endl;
	}
	return 0;
}

Measured memory_bytes: 1120
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define debug(x) cerr << #x << " : " << x << '\n'

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef string str;
typedef pair<ll, ll> pll;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const ll Mod = 1000000007LL;
const int Maxn = 2e5 + 10;
const ll Inf = 2242545357980376863LL;
const ll Log = 30;

pll OK(pll A){
	//return A;
	return pll(A.F/__gcd(A.F,A.S), A.S/__gcd(A.F, A.S));
}
pll add(pll A, pll B){
	return OK(pll(A.F*B.S + A.S*B.F, A.S*B.S));
}
pll mx(pll A, pll B){
	return ((((ld) 1) * A.F / A.S) >= (((ld) 1) * B.F / B.S) ? A : B);
}


ll l[Maxn], r[Maxn], ind[Maxn];

vector<pll> V;
vector<ll> V2;

ll ps[Maxn];

int main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	ll n;
	cin >> n;
	ll a, b;
	ll sm = 0;
	for(int i = 0; i < n; i++){
		cin >> l[i] >> r[i];
		a=l[i];
		b=r[i];
		if(a < b){
			sm += (a - b);
			V.pb({b, i});
			V2.pb(b);
		} else {
			V.pb({a, i});
		}
	}
	
	sort(all(V));
	for(int i = 0; i < n; i++) ind[V[i].S] = i;
	ps[0] = V[0].F;
	for(int i = 1; i < n; i++) ps[i] = ps[i - 1] + V[i].F;
	//cerr << sm << '\n';
	//for(auto x : V) cerr << x.F << ' '; cerr << '\n';
	pll ans = {0, 1};
	pll A;
	ll sm2, d;
	
	ll L, R, mid, v;
	for(int i = 0; i < n; i++){
		sm2 = sm;
		
		if(l[i] < r[i]) d = r[i];
		else sm2 += (l[i] - r[i]), d = l[i];
		if(sm2 >= 0) continue;
		
		L = -1, R = n, mid;
		while(L + 1 < R){
			mid = (L + R) >> 1;
			v = ps[mid];
			if(mid >= ind[i]) v -= d;
			if(sm2 + v <= 0) L = mid;
			else R = mid;
		}
		ll C = L + 1;
		v = ps[L];
		if(L >= ind[i]) v -= d, C = L;
		ll al = -(sm2 + v);
		
		if(r[i] >= al) {
			ans = mx(ans,  OK({al + C*r[i],n*r[i]} ) );
		}
	}
	ans = OK(ans);
	cout << ans.F << " " << ans.S << '\n';
	return 0;
}



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

#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define INF 999999999
#define MOD 1000000007

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int iy[]={0, 0, 1, -1};
int ix[]={1, -1, 0, 0};

int n;
int cou[5], co;

int main(){
	for(int i=0;i<6;i++){
		cin >> n;
		cou[n]++;
	}
	for(int i=1;i<=4;i++){
		if(cou[i]==2) co++;
	}
	if(co==2) cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
#define MAXN 200000
const int MOD = 1000000007;
int n, m, a, b, fac[MAXN+50]={1}, inv[MAXN+50]={1, 1};
inline int C(int n, int m)
{
    return (LL)fac[n] * inv[m] % MOD * inv[n-m] % MOD;
}
int main()
{
    scanf("%d%d%d%d", &n, &m, &a, &b);
    for(int i=1; i<=n+m+5; i++) 
		fac[i] = (LL)fac[i-1] * i % MOD;
    for(int i=2; i<=n+m+5; i++)
		inv[i] = (LL)(MOD-MOD/i) * inv[MOD%i] % MOD;
	for(int i=2; i<=n+m+5; i++)
		inv[i] = (LL)inv[i-1] * inv[i] % MOD;
    int ans=0;
    for(int i=1; i<=n-a; i++)
		ans += (LL)C(i+b-2,b-1) * C(n-i+m-b-1,n-i)%MOD,
		ans %= MOD;
    printf("%d\n", ans);
    return 0;
}

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

using namespace std;

#define NOTFOUND -1
typedef vector<int> Vec;

bool check(Vec &p){
  int t = p[0];
  for(int i = 0 ; i < 8 ; i++){
    if(t != p[i+1]) return false;
  }
  if(p[9] != p[10] || p[9] != p[11] || p[10] != p[11]) return false;
  if(p[12] != p[13] || p[12] != p[14] || p[13] != p[14]) return false;
  if(p[15] != p[16] || p[15] != p[17] || p[16] != p[17]) return false;
  if(p[18] != p[19] || p[18] != p[20] || p[19] != p[20]) return false;
  t = p[21];
  for(int i = 0 ; i < 8 ; i++){
    if(t != p[22+i]) return false;
  }
  return true;
}

void roll(int N,Vec &v){
  if(N == 0){
    swap(v[0],v[23]);
    swap(v[3],v[26]);
    swap(v[6],v[29]);
    swap(v[9],v[20]);
    swap(v[15],v[17]);
  }else if(N == 1){
    swap(v[2],v[21]);
    swap(v[5],v[24]);
    swap(v[8],v[27]);
    swap(v[11],v[18]);
    swap(v[12],v[14]);
  }else if(N == 2){
    swap(v[0],v[27]);
    swap(v[1],v[28]);
    swap(v[2],v[29]);
    swap(v[14],v[15]);
    swap(v[18],v[20]);
  }else if(N == 3){
    swap(v[6],v[21]);
    swap(v[7],v[22]);
    swap(v[8],v[23]);
    swap(v[12],v[17]);
    swap(v[9],v[11]);
  }
}

int solve(Vec &puzzle){
  map<Vec,int> cost;
  queue<Vec> Q;
  cost[puzzle] = 0;
  Q.push(puzzle);
  while(!Q.empty()){
    Vec now = Q.front(); Q.pop();
    if(check(now)) return cost[now];
    for(int i = 0 ; i < 4 ; i++){
      Vec next = now;
      roll(i,next);
      if(!cost.count(next)){
        cost[next] = cost[now] + 1;
        Q.push(next);
      }
    }
  }
  return NOTFOUND;
}

int main(){
  int Tc;
  cin >> Tc;
  while(Tc--){
    Vec puzzle(30);
    for(int i = 0 ; i < 30 ; i++){
      cin >> puzzle[i];
    }
    cout << solve(puzzle) << endl;
  }
  return 0;
}

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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;

template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

template < typename T >
struct Edge {
    int from, to;
    T cost;
    Edge () {}
    Edge (int from, int to, T cost) : from(from), to(to), cost(cost) {}
    Edge (int to, T cost) : from(-1), to(to), cost(cost) {}
};

template < typename T >
vector<T> Dijkstra(int V, const vector<vector<Edge<T>>> &G, int s) {
    using Node = pair<T, int>;
    constexpr T INF = numeric_limits<T>::max();
    vector<T> d(V, INF);
    priority_queue<Node, vector<Node>, greater<Node>> pq;

    d[s] = 0;
    pq.emplace(0, s);
    while (!pq.empty()) {
        Node node = pq.top(); pq.pop();
        if (d[node.second] < node.first) continue;
        for (auto &e : G[node.second]) {
            T cost = e.cost + node.first;
            if (cost < d[e.to]) {
                d[e.to] = cost;
                pq.emplace(cost, e.to);
            }
        }
    }

    return (d);
}

vector<vector<Edge<int>>> G(500005);
vector<vint> groupA(100005), groupB(100005), groupC(100005);

int X, Y, Z, N, M, S, T;
int main() {
    cin >> X >> Y >> Z >> N >> M >> S >> T; --S, --T;
    
    for (int i = 0; i < N; i++) {
        int A, B;
        cin >> A >> B; --A, --B;
        groupA[A].push_back(i);
        groupB[B].push_back(i);
    }
    for (int i = 0; i < M; i++) {
        int C, D;
        cin >> C >> D; --C, --D;
        groupB[C].push_back(i + N);
        groupC[D].push_back(i + N);
    }
    
    for (int i = 0; i < max({X, Y, Z}); i++) {
        for (auto &v : groupA[i]) {
            G[v].emplace_back(i + 200000, 1);
            G[i + 200000].emplace_back(v, 0);
        }
        for (auto &v : groupB[i]) {
            G[v].emplace_back(i + 300000, 1);
            G[i + 300000].emplace_back(v, 0);
        }
        for (auto &v : groupC[i]) {
            G[v].emplace_back(i + 400000, 1);
            G[i + 400000].emplace_back(v, 0);
        }
    }

    vint ans = Dijkstra<int>(500000, G, S);
    int ansd = ans[N + T];
    if (ansd == numeric_limits<int>::max()) {
        cout << -1 << endl;
    } else {
        cout << ansd << endl;
    }

    return (0);
}


Measured memory_bytes: 48852
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int A = Integer.parseInt(sc.next());
        int B = Integer.parseInt(sc.next());

        int ans = A < 10 && B < 10 ? A * B : -1;
        System.out.println(ans);

    }
}

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

const ll MOD = 1000000007;
const ll MAX = 100100;
const double PI = 3.1415926;

#define vll vector<ll>
#define max_heap priority_queue<int>
#define min_heap priority_queue<int , vector<int>, greater<int> >
#define pb push_back
#define all(container) container.begin(), container.end()
// #define traverse( container, it) for( typeof(container.begin()) it = container.begin(); it!=container.end(); it++)
vll adj[MAX];
vll transpose[MAX];
ll depth[MAX];
ll visited[MAX];
ll n,m;

ll dfs_visit(ll s)
{
	visited[s] = 1;
	ll temp = 0;
	for(int x : adj[s])
	{
		if (!visited[x])
		{
			temp = max(temp, dfs_visit(x) + 1);
		}
		else
		{
			temp = max(temp, depth[x] + 1);
		}
	}
	depth[s] = temp;
	return temp;
}

ll dfs()
{
	ll c = 0;
	for(int i = 1; i <= n; i++)
	{
		if (!visited[i])
		{
			c = max(c,dfs_visit(i));
		}
	}
	return c;

}

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

	cin >> n >> m;
	ll x,y;
	memset(depth,0,sizeof(depth));
	memset(visited,0,sizeof(visited));
	for(int i = 0; i < m; i++)
	{
		cin >> x >> y;
		adj[x].push_back(y);
	}
	cout << dfs() << endl;
	return 0;
}

Measured memory_bytes: 11648
import java.util.*;
public class Main {

  public static void main(String[] args) { 
      Scanner sc = new Scanner(System.in);
      String s = sc.next();

      int oneCnt = 0;
      int zeroCnt = 0;
      for(char c : s.toCharArray())
        if(c == '0') zeroCnt++;
        else oneCnt++;
      System.out.println(Math.min(zeroCnt, oneCnt) * 2);
  }
}

Measured memory_bytes: 26184
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main() {
	int N;
	vector<int>V;
	cin >> N;
	int sum = 0;
	for (int i = 0; i < N; ++i) {
		int s;
		cin >> s;
		V.push_back(s);
		sum += s;
	}
	if (sum % 10 != 0) {
		cout << sum;
		return 0;
	}
	else {
		sort(V.begin(), V.end());
		for (int i = 0; i < N; ++i) {
			if (V[i] % 10 != 0) {
				cout << sum - V[i] << endl;
				return 0;
			}
		}
	}
	cout << 0 << endl;
}

Measured memory_bytes: 256
import re
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
import functools
def v(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
cnt = 0
ans = 0
inf = float("inf")

a=k()
print(a**3)


Measured memory_bytes: 10432
#include<bits/stdc++.h>
 
using namespace std;
 
#define INF 1000000007
#define LINF 1000000000000000007
 
typedef long long ll;
typedef pair<ll,ll> P;


string n;

int beki(int a, int b){
	int c = 1;
	for(int i = 0; i < b; i++){
		c *= a;
	}
	return c;
}

int main(){
	cin >> n;
	int a = 0, b = 0;
	for(int i = 0; i < n.size(); i++){
		a += (int)(n[i] - '0');
		b += (int)(n[i] - '0') * beki(10, n.size()-i-1);
	}
	
	cout << (b % a ? "No" : "Yes") << endl;
	
	return 0;
}

Measured memory_bytes: 256
package main
import (
  "fmt"
)

func main() {
  var N, M, X, Y int
  fmt.Scan(&N)
  fmt.Scan(&M)
  fmt.Scan(&X)
  fmt.Scan(&Y)
  
  x := make([]int, N)
  y := make([]int, M)
  for i := 0; i < N; i++ {
    fmt.Scan(&x[i])
  }
  for i := 0; i < M; i++ {
    fmt.Scan(&y[i])
  }
  
  start:
  for z := X+1; z <= Y; z++{
    for _, v := range x{
      if v >= z {
        continue start
      }
    }
    for _, v := range y {
      if v < z {
        continue start
      }
    }
    fmt.Print("No War")
    return
  }
  fmt.Print("War")
}

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

int main( ) {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t;
	long long n;
    t = 1;
    while(t--) {
	 cin >> n;
	 cout << (n * (n -1)) / 2 << endl;
    }
    return 0;
}


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

using ll=long long int;

constexpr int MAX_N=100000;

int n;
int street[MAX_N];

int sum;

int main() {
	std::cin>>n;
	char ch;
	for(int i=0;i<n;++i){
		std::cin>>ch;
		if(ch=='O'){
			street[i]=1;
		}
		else if(ch=='I'){
			street[i]=2;
			++sum;
		}
	}
	ll base=0;
	int count=0,count1=0;
	for(int i=0;i<n;++i){
		if(!street[i])
			++count;
		else if(street[i]==1){
			base+=count*(sum-count1);
		}
		else if(street[i]==2)
			++count1;
	}
	ll ans=0;

	count=0;

	for(int i=0;i<n;++i){
		if(!street[i])
			++count;
		else if(street[i]==1)
			ans+=count;
	}

	count=0;
	ll tmp=0;

	for(int i=n-1;i>=0;--i){
		if(street[i]==2)
			++count;
		else if(street[i]==1)
			tmp+=count;
	}


	ans=std::max(ans,tmp);

	tmp=0;
	count=0;
	count1=0;

	for(int i=0;i<n;++i){
		if(!street[i])
			++count;
		else if(street[i]==2)
			++count1;
		ans=std::max(ans,(ll)count*(sum-count1));
	}

	std::cout<<ans+base<<std::endl;

	return 0;
}

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

typedef long long ll;
// const int INF = 1e8;
const ll INF = 1LL << 60;
typedef pair<int, int> P;

vector<vector<ll>> g;
// 0: white
// 1: black

ll dp[100100];
ll N, M;

void dfs1(int idx, int par = -1) {
    dp[idx] = 1;

    for (int i = 0; i < g[idx].size(); i++) {
        int to = g[idx][i];
        if (to == par) continue;
        dfs1(to, idx);
        dp[idx] *= dp[to] + 1;
        dp[idx] %= M;
    }
}

ll ans[100100];
void dfs2(int idx, int par = -1) {
    ans[idx] = 1; 
    for (int i = 0; i < g[idx].size(); i++) {
        int to = g[idx][i];
        ans[idx] *= dp[to] + 1;
        ans[idx] %= M;
    }

    // 子供の数
    int n = g[idx].size();
    vector<ll> lft(n), rht(n);
    for (int i = 0; i < n; i++) {
        lft[i] = rht[i] = dp[g[idx][i]] + 1;
    }
    for (int i = 1; i < n; i++) {
        lft[i] *= lft[i - 1];
        lft[i] %= M;
    }
    for (int i = n - 2; i >= 0; i--) {
        rht[i] *= rht[i + 1];
        rht[i] %= M;
    }

    rep(i, n) {
        if (g[idx][i] == par) continue;

        // dp を更新する
        dp[idx] = 1;

        // 左に他の子供がいる場合
        if (i) {
            dp[idx] *= lft[i - 1];
            dp[idx] %= M;
        }

        // 右に他の子供がいる場合
        if (i + 1 < n) {
            dp[idx] *= rht[i + 1];
            dp[idx] %= M;
        }

        // 潜る
        dfs2(g[idx][i], idx);
    }
}

int main() {
    cin >> N >> M;
    g.resize(N);

    rep(i, N - 1) {
        ll x, y;
        cin >> x >> y;
        x--; y--;
        g[x].push_back(y);
        g[y].push_back(x);
    }
    dfs1(0);

    // rep(i, 5) {
    //     cout << dp[i] << endl;
    // }
    dfs2(0);

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

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

const int H = 30;
const int W = 30;
const int INF = 1 << 29;
const int dy[4] = {0, 1, 0, -1};
const int dx[4] = {1, 0, -1, 0};

struct state{
  int y,x,c,dir;
  state(int y=0, int x=0, int c=0, int d=0):y(y),x(x),c(c),dir(d){}
  bool operator < (const state &s) const {
    return c > s.c;
  }
};


int w, h, v[H][W], c[4];

bool check(int y, int x){
  if(y < 0 || y >= h) return false;
  if(x < 0 || x >= w) return false;
  return true;
}

int solve(){
  priority_queue<state> q;
  state u, u2;
  int d[H][W][4];
  
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      for(int k=0;k<4;k++){
        d[i][j][k] = INF;
      }
    }
  }
  d[0][0][0] = 0;

  for(q.push(state(0,0,0,0));!q.empty();){
    u = q.top();
    q.pop();

    if(u.y == h-1 && u.x == w-1) {
      return u.c;
    }
    
    if(v[u.y][u.x] != 4){
      u2 = u;
      u2.dir = (u.dir + v[u.y][u.x]) % 4;
      u2.y += dy[u2.dir];
      u2.x += dx[u2.dir];
      if(check(u2.y, u2.x) && d[u2.y][u2.x][u2.dir] > u2.c){
        d[u2.y][u2.x][u2.dir] = u2.c;
        q.push(u2);
      }
    }

    for(int i=0;i<4;i++){
      u2 = u;
      u2.dir = (u.dir + i) % 4;
      u2.y += dy[u2.dir];
      u2.x += dx[u2.dir];
      u2.c += c[i];
      if(check(u2.y, u2.x) && d[u2.y][u2.x][u2.dir] > u2.c){
        d[u2.y][u2.x][u2.dir] = u2.c;
        q.push(u2);
      }
    }
  }
 
  return -1;
}

int main(){
  while(cin >> w >> h && (w|h)){
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
        cin >> v[i][j];
      }
    }
    for(int i=0;i<4;i++) cin >> c[i];
    cout << solve() << endl;
  }
}

Measured memory_bytes: 1328
N = int(input())
A = input()
B = input()
C = input()
target_list = []
for a, b, c in zip(A, B, C):
    if a==b and b==c and c==a:
        target_list.append(3)
    elif a==b or b==c or c==a: 
        target_list.append(2)
    else:
        target_list.append(1)
print(N*3 - sum(target_list))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
const int maxn=110;
int n,a[maxn],ans=(1e9);
int main()
{
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>a[i];
	for(int i=-100;i<=100;i++)
	{
		int sum=0;
		for(int j=0;j<n;j++)
			sum+=(a[j]-i)*(a[j]-i);
		ans=min(ans,sum);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
using System;

class Program {
    const int mod = 1000000007;

    static void Main() {
        var s = int.Parse(Console.ReadLine());
        int[] ary = new int[1000000];

        ary[1] = s;
        for (int i = 2; i < ary.Length; i++) {
            ary[i] = Calc(ary[i-1]);
            for (int j = 1; j <= i; j++) {
                if (ary[i] == ary[j] && i != j) {
                    Console.WriteLine(i);
                    return;
                }
            }
        }
    }

    static int Calc(int n) {
        if (n % 2 == 0) {
            return n / 2;
        } else {
            return 3 * n + 1;
        }
    }
}

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

int main()
{long long n,q,k;
 string s;
 while(cin>>k>>s)
 {if(s.size()<=k)
  cout<<s<<endl;
  else
  cout<<s.substr(0,k).append("...")<<endl;
 }
return 0;
} 

Measured memory_bytes: 3572
#include <iostream>
#include<string>
#include<math.h>
#include<vector>
#include<algorithm>
#include<array>
#include<functional>
#include<iomanip>
#include<ios>
using namespace std;
#define FOR(i,n) for(int (i)=0;(i)<(n);(i)++)

typedef int value_type; /* ソートするキーの型 */

value_type med3(value_type x, value_type y, value_type z)
/* x, y, z の中間値を返す */
{
    if (x < y)
        if (y < z) return y; else if (z < x) return x; else return z; else
        if (z < y) return y; else if (x < z) return x; else return z;
}

void quicksort(value_type a[], int left, int right,value_type index[])
/* クイックソート
 * a     : ソートする配列 
 * left  : ソートするデータの開始位置
 * right : ソートするデータの終了位置
 * index: index配列
 */
{
    if (left < right) {
        int i = left, j = right;
        value_type tmp, pivot = med3(a[i], a[i + (j - i) / 2], a[j]); /* (i+j)/2ではオーバーフローしてしまう */
        while (1) { /* a[] を pivot 以上と以下の集まりに分割する */
            while (a[i] < pivot) i++; /* a[i] >= pivot となる位置を検索 */
            while (pivot < a[j]) j--; /* a[j] <= pivot となる位置を検索 */
            if (i >= j) break;
            tmp = a[i]; a[i] = a[j]; a[j] = tmp; /* a[i],a[j] を交換 */
            tmp = index[i]; index[i] = index[j]; index[j] = tmp;
            i++; j--;
        }
        quicksort(a, left, i - 1,index);  /* 分割した左を再帰的にソート */
        quicksort(a, j + 1, right,index); /* 分割した右を再帰的にソート */
    }
}


int dfs(int n,int N){
    if (n>N){
        return 0;
    }
    

    int ret;
    
    return ret;
}

int main(){
    int a,b,c,d,e,k;
    long mod = pow(10,9)+7;

    cin >>a>>b>>c>>d>>e>>k;
    
    bool x;
    if(e-a>k){
        x=false;
    }else{
        x=true;
    }

    string ans;
    if(x){
        ans="Yay!";
    }else{
        ans=":(";
    }
    std::cout << ans<< endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define LiangJiaJun main
#define ll long long
using namespace std;
deque<int>q;
int m,k;
int LiangJiaJun(){
    scanf("%d%d",&m,&k);
    int g=0;
    if((k<0||k>(1<<m)-1)||(m==1&&k==1))return puts("-1"),0;
    if(k==0){
        for(int i=0;i<=(1<<m)-1;i++)printf("%d ",i);
        for(int i=(1<<m)-1;i>=0;i--)printf("%d ",i);
        return puts(""),0;
    }
    q.push_front(k);
    for(int i=0;i<=(1<<m)-1;i++){
        if(i==k)continue;
        q.push_front(i);
        q.push_back(i);
    }
    q.push_back(k);
    while(!q.empty()){
        printf("%d ",q.front());
        q.pop_front();
    }
    return 0;
}



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

int main() {
    int n;
    cin >> n;
    vector<int> lst = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    cout << lst.at(n-1) << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main (void){
	int N;
	int i,j;
	scanf("%d",&N);
	int dish[20];
	int points[20];
	int add[20];
	for (i=0;i<N;i++){
		scanf("%d",&dish[i]);
	}
	for (i=0;i<N;i++){
		scanf("%d",&points[i]);
	}
	for (i=0;i<N;i++){
		scanf("%d",&add[i]);
	}
	int sum=0;
	for (i=0;i<N;i++){
		sum+=points[dish[i]-1];
		if ((i+1)<N && ((dish[i]==(dish[i+1])-1)))
		sum+=add[dish[i]-1];
	}
	printf("%d\n",sum);
	return 0;
}


Measured memory_bytes: 128
#define _USE_MATH_DEFINES
#include <cmath>
#include <iostream>
# include <bits/stdc++.h>
using namespace std;
long long powerexp(long long base, long long exp, int mod) {
   long long res = 1;
   while (exp > 0) {
      if (exp % 2 == 1)
         res= (res * base) % mod;
      exp = exp >> 1;
      base = (base * base) % mod;
   }
   return res;
}
int gcd(int a, int b)
{
    int c = a % b;
    while(c != 0)
    {
        a = b;
        b = c;
        c = a % b;
    }
    return b;
}
void PrintVector(vector<long long int> v,long long int n)
{
 
    for(int i=v.size()-1;i>=0;i--)
    {
        cout<<v[i]<<" ";
    }
    cout<<endl;
}
void Takevector(vector<long long int> &v,long long int n)
{
  for(long long int i=0;i <n;i++)
  { long long int number;
    cin>>number;
    v.push_back(number);
  }
}
typedef long long int ll;
typedef vector<long long int> vi;
#define sci(x)         int x;       scanf("%d", &x);
#define scii(x, y)     int x, y;    scanf("%d %d", &x, &y);
#define sciii(x, y, z) int x, y, z; scanf("%d %d %d", &x, &y, &z);
#define scl(x)         ll x;       scanf("%lld", &x);
#define scll(x, y)     ll x, y;    scanf("%lld %lld", &x, &y);
#define sclll(x, y, z) ll x, y, z; scanf("%lld %lld %lld", &x, &y, &z);
#define TC(x)          sci(x); while(x --)
#define rep(i, x, y)   for (__typeof(x) i = x; i <= y; i ++)
#define repi(i, x, y)  for (__typeof(x) i = x; i >= y; i --)
#define fore(itr, x)   for (__typeof(x.begin()) itr = x.begin(); itr != x.end(); itr ++)
#define forei(itr, x)  for (__typeof(x.end()) itr = x.end() - 1; itr != x.begin() - 1; itr --)
#define nl cout<<"\n";
int min(int x, int y)  
{  
    return (x < y)? x: y;  
      
}  
int main()
{
  
  
  int flag=1;
  ll sum=0;
  int flag1=0;
  ll tot=0;
  int ans=0;
  map<int,int>m;
  vi v;
  set<int>st;
  string s;
  int grey=0;
  int green=0;
  int yellow=0;
  int cyan=0;
  int red=0;
  int orange=0;
  int brown=0;
  int blue=0;
  int any=0;
  int n;
  cin>>n;
  while(n--){
  sci(m);
  if(m<400) grey++;
  else if(m<800) brown++;
  else if(m<1200) green++;
  else if(m<1600) cyan++;
  else if(m<2000) blue++;
  else if(m<2400) yellow++;
  else if(m<2800) orange++;
  else if(m<3200) red++;
  else if(m>=3200)any++;
}
int cnt=8;
  if(grey==0) cnt--;
  if(brown==0) cnt--;
  if(green==0) cnt--;
  if(cyan==0) cnt--;
  if(blue==0) cnt--;
  if(yellow==0) cnt--;
  if(orange==0) cnt--;
  if(red==0) cnt--;
  if(cnt>0){
  cout<<cnt<<" "<<any+cnt;}
  else{
    cout<<1<<" "<<any+cnt;
  }
  
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
  int i, j, k, c[5], t;
  while(scanf("%d", &c[0]) != EOF) {
    for(i = 1; i < 5; ++i) scanf(",%d", &c[i]);
    for(i = 0; i < 5; ++i) if(c[i] == 1) c[i] = 14;
    for(i = 0; i < 5; ++i) for(j = i + 1; j < 5; ++j) if(c[i] > c[j]) t = c[i], c[i] = c[j], c[j] = t;
    if((c[0] == c[1] && c[1] == c[2] && c[2] == c[3]) || (c[3] == c[4] && c[1] == c[2] && c[2] == c[3])) printf("four card\n");
    else if((c[0] == c[1] && c[1] == c[2] && c[3] == c[4]) || (c[0] == c[1] && c[2] == c[3] && c[3] == c[4])) printf("full house\n");
    else if((c[4] == c[3] + 1 || (c[4] == 14 && c[3] == 5)) && c[3] == c[2] + 1 && c[2] == c[1] + 1 && c[1] == c[0] + 1) printf("straight\n");
    else if((c[0] == c[1] && c[1] == c[2]) || (c[2] == c[3] && c[1] == c[2]) || (c[2] == c[3] && c[3] == c[4])) printf("three card\n");
    else if((c[0] == c[1] && c[2] == c[3]) || (c[0] == c[1] && c[3] == c[4]) || (c[1] == c[2] && c[3] == c[4])) printf("two pair\n");
    else if(c[0] == c[1] || c[1] == c[2] || c[2] == c[3] || c[3] == c[4]) printf("one pair\n");
    else printf("null\n");
  }
  return 0;
}


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

int main()
{
	int n, k;
	int b[18];

	cin >> n >> k;

	for (int i = 0; i < k; i++)
		cin >> b[i];

	for (long d = 0; d < (1 << n); d++) {

		bool f = 1;

		for (int i = 0; i < k; i++) {
			if (!(d & (1 << b[i]))) {
				f = 0;
				break;
			}
		}

		if (f) {
			cout << d << ":";

			for (int i = 0; i < n; i++) {
				if (d & (1 << i))
					cout << " " << i;
			}

			cout << endl;
		}
	}

	return 0;
}


Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T> void assign(V<T>& v, int n, const T& a = T()) { v.assign(n, a); }
template<class T, class... U> void assign(V<T>& v, int n, const U&... u) { v.resize(n); for (auto&& i : v) assign(i, u...); }

int main() {
  cin.tie(NULL); ios::sync_with_stdio(false);
  int n; cin >> n;
  VV<> g(n);
  for (int i = 0; i < n - 1; i++) {
    int x, y; cin >> x >> y, x--, y--;
    g[x].push_back(y);
    g[y].push_back(x);
  }
  V<> par(n, -1);
  queue<int> que;
  par[0] = n; que.push(0);
  while (!que.empty()) {
    int v = que.front(); que.pop();
    for (int w : g[v]) if (par[w] == -1) {
      par[w] = v; que.push(w);
    }
  }
  VV<> ch(n);
  for (int i = 1; i < n; i++) ch[par[i]].push_back(i);
  function<int(int)> dfs= [&](int v) {
    int res = 0;
    for (int w : ch[v]) {
      res ^= dfs(w) + 1;
    }
    return res;
  };
  cout << (dfs(0) ? "Alice" : "Bob") << '\n';
}

Measured memory_bytes: 17792
package main
import(
    "fmt"
)

func main(){
    var n, buf int
    fmt.Scan(&n)
    mp := make(map[int]bool)
    for i := 0; i < n; i++ {
        fmt.Scan(&buf)
        mp[buf] = true
    }
    fmt.Println(len(mp))
}

Measured memory_bytes: 1856
K=int(input())
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

def gcd_list(numbers):
    return reduce(math.gcd, numbers)

answer=0
for i in range(1,K+1):
    for j in range(1,K+1):
        for k in range(1,K+1):
            answer=answer+gcd(i,j,k)
print(answer)


Measured memory_bytes: 69988
object Main {

  def main(args: Array[String]) {
    val lines = io.Source.stdin.getLines
    val numLines = lines.next().toInt

    val result = lines.map(_.groupBy(identity).mapValues(_.length)).reduce(mergeMap).toList.sortBy(_._1).map((x) => x._1.toString * x._2).mkString("")

    println(result)
  }

  def mergeMap(map1: Map[Char, Int], map2: Map[Char, Int]): Map[Char, Int] = {
    val result = scala.collection.mutable.Map[Char, Int]()

    for ((k, v) <- map1) {
      if (map2 contains k) {
        result(k) = Math.min(v, map2(k))
      }
    }

    result.toMap
  }
}


Measured memory_bytes: 27336
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
void insertionsort(int *, int , int );
void shellsort(int *, int );
int cnt;
int main(){
	int n,i,tmp;
	int *data;
	scanf("%d",&n);
	data = malloc(sizeof(int)*n);
	for(i=0; i<n; i++){
		scanf("%d",(data+i));
	//	printf("%d\n",*(data+i));
	}
	//insertionsort(data,n,1);
	shellsort(data,n);
	for(i=0; i<n; i++){
		printf("%d\n",*(data+i));
	}	
	return 0;
}
void shellsort(int *A, int n){
	int m=0,G[n],i;
	G[0] = 1;
	//printf("n=%d",n);
	for(i = 1; G[i-1] <= n; i++){
		G[i] = (pow(3,i+1)-1)/2;
//		printf("%d\n",G[i-1]);
		m++;
	}
	printf("%d\n",m);
	for(i=0; i <= m-1; i++){
		insertionsort(A,n,G[m-i-1]);
	//	cnt++;
//		printf("G[%d]=",i);
		i < m-1 ? printf("%d ",G[m-i-1]) : printf("%d\n",G[m-i-1]);
	}
	printf("%d\n",cnt);
}
void insertionsort(int *A, int n, int g){
	int i,j,v;
	for(i = g; i <= n-1; i++){
		v = *(A+i);
		j = i - g;
		while(j >= 0 && *(A + j) > v){
			*(A + j + g)=*(A + j);
			j = j - g;
			cnt++;
		}
		*(A+j+g) = v;
	}
}

Measured memory_bytes: 4556
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string a;
    cin >> a;
    for (int i = 0; i < a.length(); i++)
    {
        if (a[i] == 'C')
        {
            for (int j = i; j < a.length(); j++)
            {
                if(a[j] == 'F')
                {
                    cout << "Yes";
                    return 0;
                }
            }
        }
    }
    cout << "No";
    return 0;
}

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

#define ll long long
#define ull unsigned long long
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(a,b) for(int a=0;a<(b);++a)
#define REP1(i,n) for(int i=1;i<=(n);++i)
#define debug(x) cerr<<#x<<": "<<x<<'\n'
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair
#define INF (1<<29)
#define PI 3.14159265358979
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

template<class T=int>
T in(){T x;cin>>x;return (x);}
template<class T>
void print(T& x){cout<<x<<'\n';}

const int MOD =(int)1e9+7;
const int MAX =510000;
ll fac[MAX],finv[MAX],inv[MAX];
void COMint(){
    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;
    }
}
ll 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;
}
ll gcd(ll a,ll b){
    if(b==0)return a;
    if(a>b){
        swap(a,b);
    }
    return gcd(a,b%a);
}
ll lcm(ll a,ll b){
    ll g;g=gcd(a,b);
    return a*b/g;
}
bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

bool compare_by_a(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<pair<int,ll>> vec[100000];
ll cost[100000];
void dfs(int now,ll COST){
    cost[now]=COST;
    int next;
    REP(i,vec[now].size()){
        next=vec[now][i].first;
        if(cost[next]<0){
            dfs(next,COST+vec[now][i].second);
        }
    }
}
int counter(int x){
    if(!x)return 0;
    return counter(x>>1)+(x&1);
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N=in();
    int M=in();
    vector<pair<int,int>> vec(N);
    int a;int b;
    for(auto&i:vec){
        cin>>a>>b;
        i=mp(a,b);
    }
    sort(all(vec));
    ll ans;ans=0;
    int cnt;cnt=0;
    REP(i,N){
        if(cnt+vec[i].second<=M){
            cnt+=vec[i].second;
            ans+=(ll)vec[i].first*vec[i].second;
        }else{
            ans+=(ll)(M-cnt)*vec[i].first;
            break;
        }
    }
    print(ans);
    return 0;
}


Measured memory_bytes: 4352
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		int N = int.Parse(Console.ReadLine());
		int[,]A = new int[N,N];
		for(var i=0;i<N;i++){
			string s = Console.ReadLine();
			for(var j=0;j<N;j++){
				A[i,j] = int.Parse(s.Substring(j,1));
			}
		}
		int[]D = new int[N];
		for(var i=0;i<N;i++){
			D[i] = 999;
		}
		int d1 = 0;
		D[0] = 0;
		var list = new List<int>();
		list.Add(0);
		int max = 0;
		int maxi = -1;
		while(list.Count>0){
			var list2 = new List<int>(list);
			list.Clear();
			foreach(var j in list2){
				for(var k=0;k<N;k++){
					if(A[j,k]==1){
						if(D[j]+1 < D[k]){
							D[k] = D[j]+1;
							if(D[k] > max){
                              	max = D[k];
                              	maxi = k;
                            }							
							list.Add(k);
						}
					}
				}
			}
		}
		Console.Error.WriteLine(max+" "+maxi);
		max = 0;
		maxi = -1;
		bool flag = true;
		for(var h=0;h<N;h++){
			d1 = h;
		//d1 = maxi;
		for(var i=0;i<N;i++){
			D[i] = 999;
		}
		D[d1] = 0;
		list = new List<int>();
		list.Add(d1);
		while(list.Count>0){
			var list2 = new List<int>(list);
			list.Clear();
			foreach(var j in list2){
				for(var k=0;k<N;k++){
					if(A[j,k]==1){
						if(D[j]+1 < D[k]){
							D[k] = D[j]+1;
							if(D[k] > max){
                              	max = D[k];
                              	maxi = k;
                            }
							list.Add(k);
						} else if(D[j]==D[k]){
                          	flag = false;
                        }
					}
				}
			}
		}
		}
		Console.Error.WriteLine(max+" "+maxi);
      	if(flag){
			Console.WriteLine(max+1);
        } else {
          	Console.WriteLine("-1");
        }
	}
}

Measured memory_bytes: 15284