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

int main() {
	int N, M, counter=0;
	cin >> N >> M;
	vector<int> a(M), b(M), c(N+1);
	for(int i = 0; i <= N; i++) {
		c.at(i)=0;
	}
	for(int i = 0; i < M; i++) {
		cin >> a.at(i) >> b.at(i);
	}
	for(int i = 0; i < M; i++) {
		if(a.at(i) == 1) {
			c.at(b.at(i)) = 1;
		}
	}
	for(int i = 0; i < M; i++) {
		if(b.at(i) == N) {
			if(c.at(a.at(i)) == 1) {
				counter = 1;
				break;
			}
		}
	}
	if(counter == 1) {
		cout << "POSSIBLE" << endl;
	}
	else {
		cout << "IMPOSSIBLE" << endl;
	}
}

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

#define ms(s, n) memset(s, n, sizeof(s))
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORd(i, a, b) for (int i = (a) ; i >= (b); i--)
#define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define sz(a) int((a).size())
#define present(t, x) (t.find(x) != t.end())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define sp system("pause")
#define prec(n) fixed<<setprecision(n)
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vii;
const int MOD = (int) 1e9 + 7;
const int INF = (int) 1e9;
const ll LINF = (ll) 1e18;
const ld PI = acos((ld) -1);
const ld EPS = 1e-9;

void TimeExecution() {
    cout << "\n\n===>> Time Execution: " << clock() / (double)1000 << " sec(s).";
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    /*
    #ifndef ONLINE_JUDGE
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif
    */
    int a, b;
    cin >> a >> b;
    int i = 1, res = 0;
    while(i < b)
    {
        i += a - 1;
        res++;
    }
    cout << res;
    return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**6)

n, a, b = map(int, input().split())
def pop_count(x):
	res = 0
	for i in range(17):
		res += ((x>>i)%2 == 1)
	return res
if (pop_count(a^b)) % 2 == 0:
	print("NO")
else:
	print("YES")
	def f(m, x, y):
		if m == 1:
			if x == 0:
				return [0, 1]
			else:
				return [1, 0]

		res = [x]
		for i in range(m):
			if (x>>i) % 2  != (y>>i) % 2:
				diff = i
				break
		s = (x % (2**diff)) + (((x // (2**(diff+1))) * 2**(diff+1)) >> 1)
		t = (y % (2**diff)) + (((y // (2**(diff+1))) * 2**(diff+1)) >> 1)
		#return s, t
		u = s^1
		left = f(m-1, s, u)
		right = f(m-1, u, t)
		#print(left, right)
		x_bit, y_bit = (x>>diff) % 2, (y>>diff) % 2
		left = [l % (2**diff) + (2**diff * x_bit) + (((l // (2**diff)) * 2**diff) << 1) for l in left]
		right = [r % (2**diff) + (2**diff * y_bit) + (((r // (2**diff)) * 2**diff) << 1) for r in right]
		return left + right
	print(*f(n, a, b))

Measured memory_bytes: 12068
//1974
#include<bits/stdc++.h>
#define li long int
using namespace std;
int main()
{ 
	  li n,c=0,i,l;
	  cin>>n;
	  
	  li a[n],b[n];
	  long long int REQ=0,EX=0;
	  vector <li>req,ex;
	  for(i=0;i<n;i++)
	  	cin>>a[i];
	  	
	  for(i=0;i<n;i++)
	  	cin>>b[i];	
	  
	  for(i=0;i<n;i++)
	  	{
	  		if(a[i]-b[i]>0)
	  		ex.push_back(a[i]-b[i]),EX+=a[i]-b[i] ;
	  		
	  		if(a[i]-b[i]<0)
		  	req.push_back( b[i]-a[i]),REQ+=b[i]-a[i];
		  
		  }

		if(REQ>EX)
		cout<<-1;
		else 
		{
			l=ex.size();
			sort(ex.begin(),ex.end());
			l-=1;
			while(REQ>0)
			{REQ-=ex[l--];
			c++;	
			}
			cout<<req.size()+c;
			
			
			
			
			
		}


	  
	 
	 
}

Measured memory_bytes: 2812
#include <iostream>
#include <cmath> 
#include <string>
#include<bits/stdc++.h> 
#define ll long long 
//deepaz
using namespace std;
//int num = stoi(a); -> str to int
//a = to_string(num); -> int to str
//total += c-48; -> char to int

//comparison func
bool comp(int x,int y){
	return x<y;
}
//char to int
int to_int(char c){
	return c;
}
//minimum in array
int getMin(long long arr[], int n,long long idx){ 
	long long res;
    for (int i = idx; i <= n; i++) 
        res = min(res, arr[i]); 
    return res; 
}
//get divisors of number 
int divisors(int n){
	long long cnt = 0;
	for(int i=1;i<sqrt(n);i++){
		if(n%i==0){
			cnt++;
		}
	}
	return cnt;
}
//find if prime
bool isPrime(ll n){
	for(int i=2;i<=sqrt(n);i++){
		if(n%i==0){
			return false;
		}
	}
	return true;
}
//display prime in faster way
void dispPrime(ll n){
	long long num = 1e6;
	bool prime[num+num];
	memset(prime,true,sizeof(prime));
	for(int i=2;i*i<num+num;i++){
		if(prime[i]){
			for(int j=i*2;j<num+num;j+=i){
				prime[j] = false;
			}
		}
	}
	ll k = 2;
	ll cnt = 0;
	while(true){
		if(prime[k]){cnt++;cout<<k<<" ";}
		if(cnt==n){break;}
		k++;
	}
}


int main(){
	ll t;
	cin>>t;
	ll ac=0,wa=0,tle=0,re=0;
	while(t--){
		string st;
		cin>>st;
		if(st=="AC"){
			ac++;
		}
		else if(st=="WA"){
			wa++;
		}
		else if(st=="TLE"){
			tle++;
		}
		else{
			re++;
		}
	}
	cout<<"AC x "<<ac<<"\n";
	cout<<"WA x "<<wa<<"\n";
	cout<<"TLE x "<<tle<<"\n";
	cout<<"RE x "<<re<<"\n";
	return 0;
}






Measured memory_bytes: 3748
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <queue>

typedef unsigned long long ULLONG;
typedef long long LLONG;
static const LLONG MOD_NUM = 1000000007;

template<class _T> static void getint(_T& a) {
	const char* fmt = " %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld";
	}

	if (scanf(fmt, &a) < 0) {
		printf("g1int Error\n");
	}
}
template<class _T> static void getint(_T& a, _T& b) {
	const char* fmt = " %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld";
	}

	if (scanf(fmt, &a, &b) < 0) {
		printf("g2int Error\n");
	}
}
template<class _T> static void getint(_T& a, _T& b, _T& c) {
	const char* fmt = " %d %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld %lld";
	}

	if (scanf(fmt, &a, &b, &c) < 0) {
		printf("g3int Error\n");
	}
}

static void AGC032A();

#if 1
int main()
{
	AGC032A();
	fflush(stdout);
	return 0;
}
#endif

static void AGC032A()
{
	int N;
	getint(N);

	std::vector<int> bn(N, 0), ans(N, 0);
	for (int i = 0; i < N; i++) {
		getint(bn[i]);
	}

	int nowLen = N;
	for (int i = N; i > 0; i--) {
		bool match = false;
		for (int j = i; j > 0; j--) {
			if (j == bn[j - 1]) {
				bn.erase(bn.begin() + (j - 1));
				ans[i - 1] = j;
				match = true;
				break;
			}
		}
		if (!match) {
			printf("-1\n");
			return;
		}
	}
	for (int i = 0; i < N; i++) {
		printf("%d\n", ans[i]);
	}
}


Measured memory_bytes: 256
def get_answer(ki):
    """
    n = ki[0][0]
    q = ki[0][1]
    n_data = ki[1:-q]
    q_index = [0] * n
    for qq in ki[-q:]:
        q_index[qq[0] - 1] += qq[1]
    """
    k0 = ki[0].split(" ")
    n = int(k0[0])
    q = int(k0[1])
    q_index = [0] * n
    for k in ki[-q:]:
        k = k.split(" ")
        q0 = int(k[0])
        q1 = int(k[1])
        q_index[q0 - 1] += q1

    score = [0] * n

    """
        assert get_answer(["4 3",
                       "1 3", "1 4", "2 3",
                       "2 10", "1 100", "3 1"]) == "100 111 101 100"
    """
    t_index = []
    for i in range(0, n + 1):
        t_index.append([])
    n_data = ki[1:-q]
    for ki_n in n_data: #ki[1:-q]:
        k = ki_n.split(" ")
        n0 = int(k[0])
        n1 = int(k[1])
        t_index[n0].append(n1)
        t_index[n1].append(n0)

    t_stack = [1]
    s_stack = [0]
    r_flag = [0] * n
    while len(t_stack) > 0:
        i = t_stack.pop()
        s = s_stack.pop()
        if r_flag[i - 1]:
            continue
        r_flag[i - 1] = 1
        s += q_index[i - 1]
        score[i - 1] += s
        t_stack += t_index[i]
        s_stack += [s] * len(t_index[i])

    ss = [str(s) for s in score]
    return " ".join(ss)

# b05 1923 ms
# b05 1382 ms
if __name__ == "__main__":
    input_ki = []
    while True:
        try:
            input1 = input()
            if not input1:
                break
            if len(input1) == 0:
                break
            #s = input1.split(" ")
            #input_ki.append([int(s[0]), int(s[1])])
            input_ki.append(input1)
        except EOFError:
            break
    print(get_answer(input_ki))


Measured memory_bytes: 109472
N,K,*A = `dd`.split.map &:to_i
A.unshift(0)
counts = Array.new(N+1, nil)
counts[1] = 0
i = 1
n = 0
jumped = false
while (n < K) do
  j = A[i]
  if i == j
    puts j; exit
  end
  n += 1
  #puts "#{n}: #{i} -> #{j}"
  i = j
  next if jumped
  if counts[i]
    c = counts[i]
    t = n - c
    d = (K - n) / t * t
    #puts "n(#{c},#{t},#{d}): #{n} -> #{n+d}"
    n += d
    jumped = true
  else
    counts[i] = n
  end
end

puts i

Measured memory_bytes: 31224
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define abdelrahman010 ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long long ll;
using namespace std;
const int N = 1e5 + 5;

int main() {
    abdelrahman010
    long double r;
    cin >> r;
    cout << fixed << setprecision(9) << 2 * acos(-1) * r;
    return 0;
}

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

using namespace std;

#define ll long long
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define endl '\n'
#define Endl '\n'
#define cont continue
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) a*b/__gcd(a,b)
#define pb push_back
#define mp make_pair
#define mem(x) memset(x, 0, sizeof(x))

const ll inf=1e18;
const int mod=1e9+7;
inline int bigmod(int B,int P){int R=1;while(P>0){if(P&1){R=(R*B)%mod;}P>>=1;B=(B*B)%mod;}return R;}
const int mxn = 2e5+10;

//ll fact[mxn];
//ll in_fact[mxn];
//fact[0] = 1;
//for(ll i = 1; i < mxn; i++) {
	//fact[i] = (i*fact[i-1])%mod;
//}
//in_fact[mxn-1] = bigmod(fact[mxn-1],mod-2);
//for(ll i = mxn-2; i >= 0; i--) {
	//in_fact[i] = (in_fact[i+1] * (i+1))%mod;
//}
//ll c(ll n,ll r) {
	//ll ans = (fact[n] * (in_fact[r] * in_fact[n-r]%mod))%mod;
	//return ans;
//}


int main(){
    fast;
	//freopen ("input.txt", "r", stdin);
	//freopen ("output.txt", "w", stdout);
    int tt = 1;
    //cin>>tt;
    for(int tc = 1; tc <= tt; tc++) {
        string s;
        cin>>s;
        int c= 0, ans =0;
        for(int i = 0; i < 3; i++) {
			if(s[i] == 'R') c++;
			else c = 0;
			ans = max(ans,c);
		}
		cout<<ans<<endl;
        
        
    }



return 0;
}


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

typedef long long ll;

#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define tt int t; cin>>t; while(t--)
#define nl cout<<"\n";
#define sp cout<<" ";
#define rep(i, a, b) for(long long i=a; i<b; i++)

const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
double PI = 4*atan(1);

int main()
{
    optimize();

    int n;
    string s;
    cin>> n>> s;

    for( int i=0; i<s.size(); i++)
    {
        s[i]=( s[i] + n <= 'Z' ? s[i]+ n : s[i]+ n-26);
    }

    cout << s << '\n';

    return 0;
}




Measured memory_bytes: 3640
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<cstdio>
#include<queue>
#include<deque>
#include<map>
#include<stack>
#include<set>
#include<utility>
using namespace std;
typedef pair<int,int> ii;
typedef long long ll;
typedef pair<ll,ll> P;
typedef unsigned long long int ull;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
const int MAXN=100000;
const int MAXE=100000;
const int MAXV=10000;
const int INF=1e9;
const ll MOD=1e9+7;

struct UnionFind {
    vector<int> par,rank;
    vector<ll> cnt;
    UnionFind(int n):par(n),rank(n,0),cnt(n,1){
        for(int i=0;i<n;++i) par[i]=i;
    }
    int root(int x){
        if(par[x]==x) return x;
        return par[x]=root(par[x]);
    }
    void unite(int x,int y){
        int rx=root(x),ry=root(y);
        if(rx==ry) return ;
        if(rank[rx]<rank[ry]){
            par[rx]=ry;
            cnt[ry]+=cnt[rx];
        }else{
            par[ry]=rx;
            cnt[rx]+=cnt[ry];
        }
        if(rank[rx]==rank[ry]) rank[rx]++;
    }
    bool same(int x,int y){
        return root(x)==root(y);
    }
    int count(int x){
        return cnt[root(x)];
    }
};
struct edge{
    int a,b,y;
    edge(){};
    edge(int a,int b,int y):a(a),b(b),y(y){};
    bool operator<(const edge& rhs){
        return y<rhs.y;
    }
};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N,M;cin>>N>>M;
    vector<pair<int,int> > bri(M);
    for(int i=0;i<M;++i){
        cin>>bri[i].first>>bri[i].second;
        bri[i].first--;bri[i].second--;
    }
    UnionFind uf(N);
    vector<ll> ans(M,0);
    ans[M-1]=N*(N-1)/2;
    for(int i=M-2;i>=0;--i){
        int a=bri[i+1].first,b=bri[i+1].second;
        ans[i]=ans[i+1];
        if(!uf.same(a,b)){
            ans[i]=ans[i]-uf.count(a)*uf.count(b);
            uf.unite(a,b);
        }
    }
    for(int i=0;i<M;++i){
        cout<<ans[i]<<endl;
    }
}

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


public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
			int N = sc.nextInt();

			int[] A = new int[N];
			for(int i = 0 ; i < N ; i++){
				A[i] = sc.nextInt();
			}
		sc.close();

		Arrays.sort(A);

		long a = 0;
		long b = 0;
		int count = 0;
		for(int i = N-1 ; i >= 1 ; i--){
			if(A[i] == A[i-1] && count == 0){
				a = A[i];
				count ++;
				if(A[i-1] == A[i-2] && A[i-2] == A[i-3]){
					b = A[i];
					break;
				}
			}
			if(A[i] != a && A[i]==A[i-1] && count == 1){
				b = A[i];
				break;
			}
		}
		long ans = a*b;
		System.out.println(ans);

	}
}


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

#define PI acos(-1)
#define hell 1000000007
#define io ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define fix(n) cout << fixed << setprecision(n)
#define mset(a,n) memset(a,n,sizeof a)
#define rep(i,a,b) for (__typeof((b)) i=(a);i<(b);i++)
#define repp(i,a,b,p) for(__typeof((b)) i=(a);i<(b);i+=p)
#define ren(i,a,b) for(__typeof((a)) i=(a);i>=(b);i--)
#define renn(i,a,b,p) for(__typeof((a) i=(a);i>=(b);i-=p)
#define ADD(a,b,c) ((a)%c+(b)%c)%c
#define SUB(a,b,c) ((a)%c-(b)%c+c)%c
#define MUL(a,b,c) (((a)%c)*((b)%c))%c
#define lbd lower_bound
#define ubd upper_bound
#define ll long long
#define ld long double
#define pb push_back
#define fi first
#define se second
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define all(v) (v).begin(), (v).end()
#define sz(x) (ll)x.size()
#define endl "\n"
#define out(n) cout<<n<<" "
#define outl(n) cout<<n<<endl
#define line cout<<endl
#define bug(n) {outl(n);return;}
#define N 200005
ll n,a[N],b[N];
vll v;
void solve(){
    cin>>n;
    rep(i,1,n+1)cin>>a[i];
    rep(i,n/2+1,n+1)b[i]=a[i];
    ren(i,n/2,1){
        ll c=0;
        repp(j,2*i,n+1,i)c+=b[j];
        if(a[i]!=c%2)b[i]=1;
    }
    rep(i,1,n+1){
        if(b[i])v.pb(i);
    }
    outl(sz(v));
    for(auto i:v)out(i);
}
void prep(){
    
}
int main(){
    io;
    ll t=1;
    // cin>>t;
    prep();
    fix(12);
    while(t--)
        solve();
    return 0;
}

Measured memory_bytes: 4980
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
const int INF = 2147483647;//int max
const int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;


int main() {
    string s;
    cin >> s;
    if(s[0] == s[1] || s[1] == s[2] || s[2] == s[3])cout << "Bad\n";
    else cout << "Good\n";
    return 0;
}

/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/

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

using namespace std;

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

int h, w;
int alpha[26];
int red, blue, green;

vector<int> odd, even, four;

int main(){
    cin >> h >> w;
    red = (h/2) * (w/2);
    
    blue = 0;
    if(h%2 == 1){
        blue += w/2;
    }
    if(w%2 == 1){
        blue += h/2;
    }

    if(h%2==1 && w%2==1){
        green = 1;
    } else {
        green = 0;
    }

    REP(i, 26) alpha[i] = 0;
    REP(i, h){
        REP(j, w){
            char a;
            cin >> a;
            alpha[a - 'a'] += 1;
        }
    }

    REP(i, 26){
        if(alpha[i]>0){
            if(alpha[i]%4==0){
                four.push_back(i);
            } else if (alpha[i]%2==0){
                even.push_back(i);
            } else {
                odd.push_back(i);
            }
        }
    }

    bool flag = true;
    if(odd.size()==1 && green==1){
        if((alpha[odd[0]]-1) == 0){
            green = 1;
        } else if((alpha[odd[0]]-1)%4 == 0){
            four.push_back(odd[0]);
        } else {
            even.push_back(odd[0]);
        }
    } else if(odd.size()==0 && green==0){
        green = 0;
    } else {
        flag = false;
    }

    if(even.size()>blue){
        flag = false;
    } else {
        blue -= even.size();
    }

    if(blue%2 == 1) flag = false;

    if(flag){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
#define PB push_back
int N;
int A[1000][999];
vector<pair<int,int>> chi[1000][1000];
int par_n[1000][1000] = {};

bool solving[1000][1000];
int dp[1000][1000] = {};
int solve(int a, int b) {
	if (solving[a][b]) {
		cout << -1 << endl;
		exit(0);
	}
	if (dp[a][b] != 0) return dp[a][b];
	solving[a][b] = true;
	int ret = 0;
	for (int i = 0; i < chi[a][b].size(); i++) {
		ret = max(ret, solve(chi[a][b][i].first, chi[a][b][i].second));
	}
	solving[a][b] = false;
	return dp[a][b] = ret + 1;
}

int main() {
	cin >> N;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N - 1; j++) {
			cin >> A[i][j];
			A[i][j]--;
		}
	}
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N - 1 - 1; j++) {
			int a = i;
			int b = A[i][j];
			if (a > b) swap(a, b);
			int c = i;
			int d = A[i][j + 1];
			if (c > d) swap(c, d);
			chi[a][b].PB({c, d});
			par_n[c][d]++;
		}
	}

	int ans = 0;
	for (int i = 0; i < N; i++) {
		int a = i;
		int b = A[i][0];
		if (a > b) swap(a, b);
		ans = max(ans, solve(a, b));
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 52096
import std.algorithm;
import std.array;
import std.ascii;
import std.container;
import std.conv;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.typecons;
void log(A...)(A arg) { stderr.writeln(arg); }
int size(T)(in T s) { return cast(int)s.length; }

void main() {
    int N, M, R; readf("%d %d %d\n", &N, &M, &R);
    auto Rs = readln.chomp.split(" ").map!((a) => a.to!int - 1).array;
    auto G = new int[][](N, N);
    foreach (ref L; G) L[] = int.max / 8;
    foreach (i; 0 .. M) {
        int a, b, c; readf("%d %d %d\n", &a, &b, &c);
        a--; b--;
        G[a][b] = G[b][a] = c;
    }
    foreach (k; 0 .. N) {
        foreach (i; 0 .. N) {
            foreach (j; 0 .. N) {
                G[i][j] = min(G[i][j], G[i][k] + G[k][j]);
            }
        }
    }

    sort(Rs);
    long ans = long.max / 8;
    do {
        long cost = 0;
        foreach (i; 0 .. (R - 1)) {
            int from = Rs[i];
            int to = Rs[i + 1];
            cost += G[from][to];
        }
        ans = min(ans, cost);
    } while (Rs.nextPermutation);
    writeln(ans);
}


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

#define sieve_ul int(1e6)
#define endl "\n"
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define debug(x) do{cout<<#x<<" is "<<x<<endl;}while(false);
#define debugarr(x) do{ cout<<#x<<" array is \n";for(auto varl: x)cout<<varl<<' ';cout<<endl;}while(false);

// ll sieve_arr[sieve_ul + 10];
// vector<ll> primes;

ll fastexp(ll b, ll e)
{
    ll ans = 1;
    ll lpow = b;

    while(e)
    {
        if(e & 1)
            ans *= lpow;
        lpow *= lpow;
        e = (e >> 1);
    }
    return ans;
}

bool isprime(ll x)
{
    for(ll i=2; i <= sqrt(x); i++)
        if(x%i == 0)
            return false;
    return true;
}

// void sieve()
// {
//     primes.clear();
//     memset(sieve_arr, -1, sizeof(sieve_arr));

//     for(int i=2; i<= sieve_ul; i++)
//     {
//         if(sieve_arr[i] == -1)
//             for(int j=2; j*i <= sieve_ul; j++)
//                 sieve_arr[i*j] = 1;
//     }

//     for(int i=2; i<= sieve_ul; i++)
//         if(sieve_arr[i] == -1)
//             primes.push_back(i);
// }
vector<int> factorize(int n) {
    vector<int> res;
    for (int i = 2; i * i <= n; ++i) {
        while (n % i == 0) {
            res.push_back(i);
            n /= i;
        }
    }
    if (n != 1) {
        res.push_back(n);
    }
    return res;
}

static bool cmp(pair<ll,ll>& a,pair<ll,ll>& b)
{
    return sqrt(a.first*a.first+a.second*a.second) <= sqrt(b.first*b.first+b.second*b.second);
}

void solve()
{
    ll n;
    cin>>n;
    vector<ll> arr(n);
    
    for(ll i=0;i<n;i++)
        cin>>arr[i];
    
    ll cnt = arr[0];
    ll ans = 0;
    
    for(ll i=1;i<n;i++)
    {
        if(arr[i]>=cnt)
            cnt = arr[i];
        else
            ans += cnt-arr[i];
    }
    
    cout<<ans;
}

int main()
{

    //ll tc;
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    //cin>>tc;

    //for(ll i=1;i<=tc;i++)
    //{
        solve();
    //}

}

Measured memory_bytes: 4792
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,o,n) for(long long i = o;i<n;i++)
#define oneforall ios::sync_with_stdio(false);cin.tie(0);
#define all(v) (v).begin(),(v).end()
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define int long long 
const long long inf=1e18;
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
typedef vector<int> vi;
typedef vector<long long> vl;
typedef long long ll;
typedef vector<pair<long, long > > vpll;
typedef vector<pair<int, int > > vpii;
#define FORR(x,arr) for(auto& x:arr)
#define ZERO(a) memset(a,0,sizeof(a))





//3111111111111111111111111111111

	int dp[100031][2];
	int mo = 1000000007;
	void solve(){

		
		ins(morty);
		dp[0][1] = 1;
		FOR(i,0,morty.size()){
			if(morty[i] == '1'){
				dp[i+1][1] = (dp[i][1]*2)%mo;
				dp[i+1][0]+=dp[i][1];
				dp[i+1][0]+=(dp[i][0]*3)%mo;
				dp[i+1][1]%=mo;
				dp[i+1][0]%=mo;
			}
			else{
				dp[i+1][1] = dp[i][1];
				dp[i+1][0] = (dp[i][0]*3)%mo;
				dp[i+1][1]%=mo;
				dp[i+1][0]%=mo;
			}
		}
		out((dp[morty.size()][1]+dp[morty.size()][0])%mo);		









	}	























int32_t main() {
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall 
	oneforall

	solve();
	


	return 0;
}


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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<=(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define Eback(s) s.erase(s.end()-1,s.end())
#define rev(v) reverse(all(v))
#define minvec(v) *min_element(all(v))
#define maxvec(v) *max_element(all(v))
#define pb push_back
#define pf push_front
#define mod 1000000007
#define m_p make_pair
#define DOUBLE fixed << setprecision(15)
#define OK puts("OK")
#define OK1 puts("OK1")
#define OK2 puts("OK2")
#define SIZE(s) (int)s.size()
#define INF ((1LL<<62)-(1LL<<31))
#define zero(x,n) setw(x) << setfill('0') << n

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<ll,ll>> vpll;
typedef vector<string> vs;
const double pi = acos(-1.0);

template<class A, class B>
ostream& operator<<(ostream& ost, const pair<A, B>&p) {
	ost << "{" << p.first << ", " << p.second << "} ";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost, const vector<T>&v) {
	ost << "{";
	for (int i = 0; i<(int)v.size(); i++) {
		if (i)ost << " ";
		ost << v[i];
	}
	ost << "} \n";
	return ost;
}

template<class A, class B>
ostream& operator<<(ostream& ost, const map<A, B>&v) {
	ost << "{";
	for (auto p:v) {
		ost << "{" << p.first << ", " << p.second << "} ";
	}
	ost << "} ";
	return ost;
}

template<class T>
inline bool chmax(T& a, T b){if(a<b){a=b;return true;} return false;}

template<class T>
inline bool chmin(T& a, T b){if(a>b){a=b;return true;} return false;}

ll gcd(ll x, ll y) {return __gcd(x,y);}
ll lcm(ll x, ll y) {return x/__gcd(x,y)*y;}

int main()
{
	ll w,h;
	vpll v;
	while(1){
		cin >> h >> w;
		if(h==0 && w==0) break;
		v.pb(m_p(h,w));
	}
	rep(i,SIZE(v)){
		rep(j,v[i].first){
			if(j==0 || j==v[i].first-1){
				rep(k,v[i].second) cout << "#";
			}
			else{
				rep(k,v[i].second) cout << (k==0||k==v[i].second-1?"#":".");
			}
			cout << endl;
		}
		cout << endl;
	}
	return 0;
}


Measured memory_bytes: 3108
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define per(i, n) for(ll i=((ll)(n))-1; i>=0; i--)
#define perf(i, n) for(ll i=((ll)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
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;


long long gcd(long long a, long long b){
    if(a < b) swap(a, b);
    if(a%b == 0) return b;
    return gcd(a%b, b);
}

long long lcm(long long a, long long b){
    return (a*b)/gcd(a, b);
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    ll cnt_a = 0, cnt_b = 0;

    // ~Bまでに含まれるC,Dで割れない整数の数
    cnt_b = b - b/c - b/d + b/lcm(c,d); 

    // (A-1)までに含まれるC,Dで割れない整数の数
    cnt_a = (a-1) - (a-1)/c - (a-1)/d + (a-1)/lcm(c,d);

    // [A,B]に含まれるC,Dで割れない整数の数
    cout << cnt_b - cnt_a << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template<class T> ostream& operator<<(ostream &os, vector<T> V) { os << "[ "; 
	for(auto v:V)os << v << " "; return os << "]";
}
template<class T> ostream& operator<<(ostream &os, set<T> S){ os << "{ "; 
	for(auto s:S) os<<s<<" ";  return os<<"}"; 
}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {
	return os<<"("<<P.first<<","<< P.second << ")";
}
template<class L, class R> ostream& operator<<(ostream &os, map<L,R> M) {
	os<<"{ ";for(auto m:M)os<<"("<<m.F<<":"<<m.S<<")";
	return os<<"}";
}
#define cerr cout
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...) 1
#endif
#define ll long long
#define ld long double
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define I insert 
#define pb push_back
#define F first
#define S second
#define endl "\n"
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define For(i,n) for(int i=0;i<(int)n;++i)
#define Rev(i,n) for(int i=(int)n-1;i>=0;--i)
#define Rep(i,n) for(int i=1;i<=(int)n;++i)
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef vector<pii> vpii;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

const int mx = 1e9;
int main(){
	fio; cout<<fixed<<setprecision(25);	
	int n, k , s; cin >> n >> k >> s;
	for(int i = 0;i < k ; ++i)
		cout << s << ' ';
	for(int i = k ; i < n ; ++i){
		if(s != mx)
			cout << mx << ' ';
		else
			cout << 1 << ' ';
	}
	cout << endl;











	return 0;
}


Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int N;
  cin>>N;
  int time[N];
  for(int i=0;i<N;i+=1)
  {
    cin>>time[i];
  }
  int m;
  cin>>m;
  int p[m],x[m];
  for(int i=0;i<m;i+=1)
  {
    int sum=0;
    cin>>p[i];
    cin>>x[i];
    for(int j=0;j<N;j+=1)
    {
      if(j==p[i]-1)
        sum+=x[i];
      else
        sum+=time[j];
    }
    cout<<sum<<'\n';
  }
  return 0;
}

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

#define rep(i, s, n) for(int i = s; i < n; ++i)
#define rrep(i, n) for(int i = n - 1; i > -1; --i)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
using namespace std;
const long long INF = 1000000000;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<int, int> P;

int main() {
    int a;
    string s;
    cin >> a >> s;
    if(a < 3200) cout << "red" << endl;
    else cout << s << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

void solve() {
  int n;
  cin >> n;
  vector<pii> v(n);
  rep(i,n){
    cin >> v[i].first;
    v[i].second = i+1;
  }
  sort(ALL(v));
  rep(i,n) cout << v[i].second << " ";
  cout << endl;
}

int main() {
  solve();
  return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll, ll> Pll;
typedef pair<int, Pii > P1;

#define rep(i,n) for(int i=0;i<n;i++)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define mp1(a,b,c) P1(a,P(b,c))
#define get_arsize(a) (sizeof(a)/sizeof(a[0]))

const ll MOD = 1000000007;
const double EPS = 1e-10;
const int MAX = 200000;

int main() {
  ll n;
  cin >> n;
  vector<ll> a(n, 0);
  ll sum = 0;
  rep(i, n) {
    cin >> a[i];
    sum ^= a[i];
  }
  //cout << sum << endl;
  rep(i,n) {
    ll ans = sum ^ a[i];
    cout << ans;
    if (i != n-1) {
      cout << " ";
    } else {
      cout << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 4812
#include <bits/stdc++.h>
using namespace std;
static const int INF = 2147483647;
static const int NIL = -1;
static const int MOD = 1000000007;
typedef long long ll;
typedef pair<int,int> P;
#define int ll 
 
 
signed main(){
    int n;
    scanf("%lld",&n);
    if(n%2==0){
        printf("%lld %lld %lld\n",n/2,n,n);
        return 0;
    }
 
    for(int i=1;i<=3500;i++){
        for(int k=1;k<=3500;k++){
            if((4*i*k-n*i-n*k)!=0){
                if((n*i*k)%(4*i*k-n*i-n*k)==0 && (n*i*k)/(4*i*k-n*i-n*k)>=0){
                    printf("%lld %lld %lld",i,k,(n*i*k)/(4*i*k-n*i-n*k));
                    return 0;
                }
            }
        }
    }
 
    printf("FAILURE\n");
}

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

using namespace std;

int main(){
        int N, K, X, Y;
        cin>>N>>K>>X>>Y;
        int res=0;
        if(N<=K){
                res+=X*N;
        }
        else{
                res+=X*K+Y*(N-K);
        }
        cout<<res<<endl;
        return 0;
}


Measured memory_bytes: 256
import sys

input = sys.stdin.readline


def main():
    S = input().rstrip()
    T = input().rstrip()

    S_table = {}
    T_table = {}
    ans = "Yes"
    for s, t in zip(S, T):
        # S
        if s in S_table:
            if S_table[s] != t:
                ans = "No"
        else:
            S_table[s] = t
        # T
        if t in T_table:
            if T_table[t] != s:
                ans = "No"
        else:
            T_table[t] = s

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3632
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
using namespace std;

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


const int BIG_NUM = 1e8;
const ll INF = 1000000000000000000;

const int ALPHABET = 26;

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

	int ans = 0;

	int p = a;
	for (int i = 0; i < 3; i++) {
		ans += p;
		p *= a;
	}

	cout << ans << endl;

}

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

#define sz(a) int((a).size())
#define all(c) c.begin(), c.end()
#define ll long long
#define pb push_back
#define zoom                          \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define pl pair<ll, ll>
#define MOD 1000000007
#define endl "\n"
#define ff first
#define ss second
#define trace1(x) cerr << #x << ": " << x << endl
#define trace2(x, y) cerr << #x << ": " << x << " | " << #y << ": " << y << endl
#define trace3(x, y, z) cerr << #x << ":" << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl
#define trace4(a, b, c, d) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl
#define trace5(a, b, c, d, e) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl
#define trace(v)                                   \
    for (auto it = v.begin(); it != v.end(); it++) \
        cerr << *it << " ";                        \
    cerr << endl;
#define tr(container, it) \
    for (typeof(container.begin()) it = container.begin(); it != container.end(); it++)

#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

typedef pair<int, int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpi;
typedef vector<pll> vpl;
typedef vector<vi> vvi;

void solve()
{
    int x;
    cin>>x;

    if(x>=30)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

int main()
{
    zoom;
    ll t=1;
    //cin >> t;

    while (t--)
    {
        solve();
    }
}

Measured memory_bytes: 3648
// 失敗するからこそ そこから立ち向かって行く強さがあってそんな強さが本当の強さだと私は思うから
#ifdef DAIJOBU
#include "/home/v-o_o-v/deb.h"
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#include <bits/stdc++.h>
#define deb(x...)
#endif 

using namespace std;

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

	int a[4], b[4];
	while(cin >> a[0] >> a[1] >> a[2] >> a[3] >> b[0] >> b[1] >> b[2] >> b[3]){
		int hit = 0, blow = 0;
		for(int i = 0; i < 4; i++){
			if(b[i] == a[i])hit++;
			else if(find(a, a + 4, b[i]) - a != 4)blow++;
		}
		cout << hit << ' ' << blow << '\n';
	}
	return 0;
}


Measured memory_bytes: 3104
#include <bits/stdc++.h>
#define pb push_back
#define all(a) a.begin(),a.end()
#define forn(i,n) for(int i=0;i<int(n);i++)
#define forr(i,n) for(int i=int(n-1);i>=0;i--)
#define fora(i,a,b) for(int i=int(a);i<=int(b);i++)
#define forb(i,a,b) for(int i=int(a);i>=int(b);i--)
#define mod 1000000007
using namespace std;
using ll=long long int;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<ll> vii;
typedef pair<ll ,ll> pii;
template<typename T>
string ts(T v)
{
	string res="{";
	bool r=true;
	for(const auto &x:v)
	{
		if(!r)res+=",";
		r=false;
		res+=to_string(x);
	}
	res+="}";
	return res;
}
void solve()
{
	ll n;
	cin>>n;
	vii div(n+1,1);
	for(ll i=1;i<=n;i++)
	{
		for(ll j=2*i;j<=n;j+=i)
		{
			div[j]++;
		}
	}
	ll ans=0;
	fora(i,1,n)ans+=i*div[i];
	cout<<ans<<endl;
}
int main()
{
	#ifndef ONLINE_JUDGE
    freopen("ip.txt", "r", stdin);
    freopen("op.txt", "w", stdout);
    #endif
    ios::sync_with_stdio(0); 
    cin.tie(0); 
    cout.tie(0);
    int t=1;
   // cin>>t;
    while(t--)
   	solve();
}


Measured memory_bytes: 81308
import java.util.*;
 
public class Main {
	public static void main(String[] args) throws Exception{
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
        int m = sc.nextInt();
        int[] a = new int[m];
        int[] b = new int[m];
        Set<Integer> mid = new HashSet<>(); 
        Set<Integer> goal = new HashSet<>(); 
        for(int i = 0; i < m; i++){
        	a[i] = sc.nextInt();
            b[i] = sc.nextInt();
            if(a[i] == 1){
            	mid.add(b[i]);
            }else if(b[i] == n){
            	goal.add(a[i]);
            }
        }
        ArrayList<Integer> list = new ArrayList<>();
        for(int x : goal){
        	list.add(x);
        }
        for(int i = 0; i < list.size(); i++){
            if(mid.contains(list.get(i))){
            	System.out.println("POSSIBLE");
                return;
            }
        }
        System.out.println("IMPOSSIBLE");
	}
}

Measured memory_bytes: 74984
#include <bits/stdc++.h>
#define int long long

using namespace std;

int h=0;
int res=0;
int x=1;

signed main()
{
	cin >> h;			
	while (h)
	{
		res+=x;		
		x*=2;
		h/=2;
	}	
	cout << res;
	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
main(){
  long n,a,b;
  cin>>n>>a>>b;
  vector<long> x(n);
  for(auto&i:x)cin>>i;
  vector<long>dist(n-1);
  for(int i=0;i<n-1;++i){
    dist[i]=x[i+1]-x[i];
  }
  long ans=0;
  for(auto d:dist){
    ans += min(d*a,b);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 1792
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;

const int inf = numeric_limits<int>::max() /4;
const ll linf = numeric_limits<ll>::max() /4;
const ull ulinf = numeric_limits<ull>::max()/4;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.end(), v.begin());
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - a) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
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; }

vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

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


int main(){

    int n;
    cin >> n;
    ll a[100005] = {};

    ll ans = 0;
    rep(i,0,n)cin >> a[i];

    rep(i,0,n-1){
        ans += a[i]/2;
        a[i] %= 2;
        if(a[i] == 1 && a[i+1] > 0){
            ans++;
            a[i+1]--;
        }
       /* ll s = min(a[i],a[i+1]);
        ans += s;
        a[i] -= s;
        a[i+1] -= s;
        ans += a[i]/2;*/
    }
    ans += a[n-1]/2;
    P(ans);
   
	return  0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cmath>
#include <math.h>
using namespace std;
int main()
{
    int a,b,c,sum;
    cin>>a>>b>>c>>sum;
    int num=0;
    a++,b++,c++;
    while(a--)
    {
        int b1=b;
        while(b1--)
        {
            int c1=c;
            while(c1--)
            {
                if(a*500+b1*100+c1*50==sum) num++;
            }
        }
    }
    cout<<num<<endl;
    return 0;
}


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

ll modpow(ll a, ll b , ll mod){
  if(b == 0) return 1;
  ll res = modpow(a, b/2, mod);
  if(b%2){
    res = res * res % mod;
    res = res * a % mod;
  }else {
    res = res * res % mod;
  }
  return res;
}

ll nCk(ll n, ll k){
  ll x = 1;
  ll y = 1;
  for(ll i = 0;i < k;i++){
    x= x*(n-i)%MOD;
    y= y*(i+1)%MOD;
  }
  //cout<<MOD<<" "<<n<<" "<<k<<" "<<x<<" "<<y<<endl;
  return (x*modpow(y, MOD-2, MOD)%MOD);
}

int main(){
  ll n, a, b;
  scanf("%lld%lld%lld", &n, &a, &b);
  ll ans = modpow(2, n, MOD);
  //cout<<nCk(n, a)<<" "<<nCk(n, b)<<endl;
  ans-= (nCk(n, a) + nCk(n, b))% MOD;
  if(ans<0) ans+=MOD;
  printf("%lld\n", ans -1);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define mp make_pair
#define inf 1000000007
using namespace std;
int used[114514];
signed main(){
	int n,k;
	cin>>n>>k;
	vector< pair<int,int> > sus;
	for(int i=0;i<n;i++){
		int x,y;
		cin>>x>>y;
		sus.pb(mp(y,x));
	}
	sort(sus.begin(),sus.end());
	reverse(sus.begin(),sus.end());
	vector<ll> fir;
	priority_queue<ll> dup;
	ll sum=0;
	for(int i=0;i<k;i++){
		if(used[ sus[i].second ] == 0){
			used[ sus[i].second ] = 1;
			fir.push_back(sus[i].first);
			sum += sus[i].first;
		}
		else{
			dup.push(-sus[i].first);
			sum += sus[i].first;
		}
	}
	vector<ll> anss;
	anss.pb(sum+fir.size()*fir.size());
	for(int i=k;i<sus.size();i++){
		if(used[sus[i].second]==0 && !dup.empty()){
			used[sus[i].second] = 1;
			sum -= -dup.top();
			dup.pop();
			fir.push_back(-sus[i].first);
			sum+=sus[i].first;
			anss.pb(sum+fir.size()*fir.size());
		}
	}
	sort(anss.begin(),anss.end());
	cout<<anss[anss.size()-1]<<endl;
	return 0;
}

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

const int mod = pow(10,9) + 7;

int main(){
  int s;
  cin >> s;
  
  vector<int> dp(s+1);
  dp[0] = 1;
  rep(i, s+1){
    rep(j, i-2){
      dp[i] = (dp[i] + dp[j]) % mod;
    }
  }
  cout << dp[s] << endl;
  return 0;
}

Measured memory_bytes: 3564
#include <bits/stdc++.h> 
#include <chrono>
using namespace std;
 
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
 
//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef long long LL;
typedef pair<LL, LL> PLL;
 
//container util
//------------------------------------------
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
#define ALL(a)  (a).begin(),(a).end()
//constant
//--------------------------------------------
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

int main(){
    int K;cin>>K;
    string S;cin>>S;
    if(SZ(S)<=K){
        cout<<S<<endl;
    }else{
        string res=S.substr(0,K);
        res+="...";
        cout<<res<<endl;
    }
    return 0;
}

Measured memory_bytes: 3600
num=[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]
k=int(input())
print(num[k-1])

Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
long long n,a,ans;
int main () {
	scanf("%lld",&n);
	ans=1;
	int flg=0;
	for (int i=1;i<=n;i++) {
		scanf("%lld",&a);
		if (ans&&1000000000000000000ll/ans<a) {flg=1;}
		else {
			ans*=a;
		}
	}
	if (ans==0) {printf("%lld\n",0);}
	else if (flg) {printf("-1\n");return 0;}
	else {
		printf("%lld\n",ans);
	}
	return 0;
}

Measured memory_bytes: 3812
#include <iostream>
#include <vector>

using namespace std;

int main() {
  vector<int> arr;  
  for (int i = 0; i < 10000; ++i) {
    int in;
    cin >> in;
    if (in == 0) {
      break;
    }
    arr.emplace_back(in);
  }
  for (int i = 0; i < arr.size(); ++i) {
    cout << "Case " << i+1 << ": " << arr[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 3260
num_arr = []
while (line = gets) do
  num = line.split.map(&:to_i)
  num_arr += num
end

d1 = (num_arr[1].to_f/num_arr[3]).ceil
d2 = (num_arr[2].to_f/num_arr[4]).ceil

if d1 > d2
  p num_arr[0] - d1
else
  p num_arr[0] - d2
end

Measured memory_bytes: 8644
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<ll>;
using vii = vector<vi>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1000000007;
template<class T> void print(const T& t){ cout << t << endl; }
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; }

int main(){
  ll n, k;
  cin >> n >> k;
  vi h(n);
  rep(i,n){
    cin >> h[i];
  }
  sort(all(h));
  ll ans = 0;
  if(n<=k){
    print(0);
  }
  else{
    rep(i,n-k){
      ans += h[i];
    }
    print(ans);
  }
}

Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int[] dice = { scanner.nextInt(), scanner.nextInt(), scanner.nextInt(), scanner.nextInt(), scanner.nextInt(),
				scanner.nextInt() };
		int num = scanner.nextInt();
		for (int i = 0; i < num; i++) {
			int up = scanner.nextInt();
			int front = scanner.nextInt();
			if ((up == dice[3] && front == dice[1]) || (up == dice[4] && front == dice[3])
					|| (up == dice[2] && front == dice[4]) || (up == dice[1] && front == dice[2])) {
				System.out.println(dice[0]);
			} else if ((up == dice[0] && front == dice[3]) || (up == dice[2] && front == dice[0])
					|| (up == dice[5] && front == dice[2] || (up == dice[3] && front == dice[5]))) {
				System.out.println(dice[1]);
			} else if ((up == dice[0] && front == dice[1]) || (up == dice[4] && front == dice[0])
					|| (up == dice[5] && front == dice[4] || (up == dice[1] && front == dice[5]))) {
				System.out.println(dice[2]);
			} else if ((up == dice[0] && front == dice[4]) || (up == dice[1] && front == dice[0])
					|| (up == dice[5] && front == dice[1] || (up == dice[4] && front == dice[5]))) {
				System.out.println(dice[3]);
			} else if ((up == dice[0] && front == dice[2]) || (up == dice[3] && front == dice[0])
					|| (up == dice[5] && front == dice[3] || (up == dice[2] && front == dice[5]))) {
				System.out.println(dice[4]);
			} else if ((up == dice[1] && front == dice[3]) || (up == dice[2] && front == dice[1])
					|| (up == dice[4] && front == dice[2] || (up == dice[3] && front == dice[4]))) {
				System.out.println(dice[5]);
			}

		}

	}
}



Measured memory_bytes: 26256