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

const ll MOD = 1e9 + 7;

int mpow(int base, int exp);
typedef  vector<int> vi;
typedef  vector<ll> vll;
typedef  vector<pair<ll,ll>> vpll;
typedef  vector<pair<int, int>> vpii;
typedef  pair<int, int> pii;
typedef  pair<ll, ll> pll;
typedef  unordered_map<ll, ll> umpll;
typedef  unordered_map<int, int> umpii;
typedef  unordered_map<ll, int> umpli;
typedef  unordered_set<int> usi;
typedef  unordered_set<ll> usll;
typedef  set<int> si;
typedef  set<ll> sll;
typedef  set<pair<int, int>> spii;
typedef  set<pair<ll, ll>> spll;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define fo(i,n) for(i = 0;i < n; i++)
#define Fo(i,k,n) for(i = k;k < n ? i < n : i > n; k < n ? i += 1 : i -= 1)
#define deb(x) cout << #x << " = " << x << endl
#define deb2(x, y) cout << #x << " = " << x << ", " << #y << " = " << y << endl
#define deb3(x, y, z) cout << #x << " = " << x << ", " << #y << " = " << y << ", "<< #z << " = " << z << endl

ll randGen(ll lower, ll upper) { return (rand() % (upper - lower + 1)) + lower; }
ll dir[4][2] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
// cout << fixed;
// cout.precision(10);
//******************          Function here          *********************//

   void solve(){
      int n, m;
      cin >> n >> m;
      vector<int> gp[n], vis(n, 0);
      for(int i = 0; i < m; i++) {
         int u, v;
         cin >> u >> v;
         u--, v--;
         gp[u].pb(v);
         gp[v].pb(u);
      }
      int ans = 0;
      for(int i = 0; i < n; i++) {
         if(vis[i] == 0) {
            queue<int> q;
            q.push(i);
            vis[i] = 1;
            int count = 0;
            while(!q.empty()) {
               int elem = q.front();
               q.pop();
               count += 1;
               for(auto j : gp[elem]) {
                  if(!vis[j]) {
                     vis[j] = 1;
                     q.push(j);
                  }
               }
            }
            ans = max(ans, count);
         }
      }
      cout << ans << endl;
   }

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

int main()
{
    #ifndef ONLINE_JUDGE
      string inputFile, outputFile;
      inputFile = "input.txt";
      outputFile = "output.txt";
      freopen(inputFile.c_str(), "r", stdin);
      freopen(outputFile.c_str(), "w", stdout);
    #endif

    int t = 1;
    // cin>>t;
    while(t-- >0){
      solve();
    }
    return 0;
}



/**********************   Utility Functions  *****************************/
   int mpow(int base, int exp) {
     base %= MOD;
     int result = 1;
     while (exp > 0) {
       if (exp & 1) result = ((ll)result * base) % MOD;
       base = ((ll)base * base) % MOD;
       exp >>= 1;
     }
     return result;
   }
/***********************************************************************/


Measured memory_bytes: 15568
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = input()

if N == N[::-1]:
	print("Yes")
else:
	print("No")


Measured memory_bytes: 5712
#include <bits/stdc++.h>
//For ordered_set
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define MOD 1000000007
#define test int t; cin>>t; while(t--)
#define init(arr,val) memset(arr,val,sizeof(arr))
#define loop(i,a,b) for(int i=a;i<b;i++)
#define loopr(i,a,b) for(int i=a;i>=b;i--)
#define loops(i,a,b,step) for(int i=a;i<b;i+=step)
#define looprs(i,a,b,step) for(int i=a;i>=b;i-=step)
#define ull unsigned long long int
#define ll long long int
#define P pair
#define PLL pair<long long, long long>
#define PII pair<int, int>
#define PUU pair<unsigned long long int, unsigned long long int>
#define L list
#define V vector
#define D deque
#define ST set
#define MS multiset
#define M map
#define UM unordered_map
#define mp make_pair
#define pb push_back
#define pf push_front
#define MM multimap
#define F first
#define S second
#define IT iterator
#define RIT reverse_iterator
#define FAST ios_base::sync_with_stdio(false);cin.tie();cout.tie();
#define FILE_READ_IN freopen("input.txt","r",stdin);
#define FILE_READ_OUT freopen("output.txt","w",stdout);
#define all(a) a.begin(),a.end()
#define ld long double
using namespace std;
// For ordered_set
using namespace __gnu_pbds;
template <typename T>
using ord_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
const ll maxn = 1e5;
const ll inf = 1e9;
const double pi = acos(-1);

int main(){
    ll n,k;
    cin>>n>>k;
    ll A[n];
    loop(i,0,n){
        cin>>A[i];
    }
    ll cache[k+1];
    init(cache,0);
    loop(i,0,k+1){
        loop(j,0,n){
            if(A[j]<=i && !cache[i-A[j]]){
                cache[i] = 1;
            }
        }
    }
    if(cache[k]==1){
        cout<<"First"<<endl;
    }
    else{
        cout<<"Second"<<endl;
    }
    return 0;
}

Measured memory_bytes: 1024
i;j;m;s;t[9<<14];main(){
for(;~scanf("%d",&t[i]);i++)i*(t[i]>m)?m=t[i]:0;
for(;++j<t[0]+2;)abs(t[j]-m/2)<abs(s-m/2)?s=t[j]:0;
printf("%d %d",m,s);}

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

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
#define FOR(i, n) for(int (i)=0; (i)<(n); (i)++)
#define FORI(i, n) for(int (i)=n-1; (i)>=0; (i)--)
#define FOR1(i, n) for(int (i)=1; (i)<=(n); (i)++)
//#define TEST
const ll MOD = 1e6+3;

ll powmod(ll a, ll n){
    ll rez = 1;
    while(n){
        if (n&1)
            rez = rez * a % MOD;
        a = a*a % MOD;
        n /= 2;
    }
    return rez;
}
ll inv(ll a){
    return powmod(a, MOD-2);
}

vector<ll> fact;
vector<int> cnt;
ll solve(ll x, ll d, ll n){
    if (x == 0)
        return 0;
    if (d==0)
        return powmod(x, n);
    ll y = x * inv(d) % MOD;
    int cntmod = (y+n-1)/MOD - (y-1)/MOD;
    if (cntmod>0)
        return 0;
    ll rez = powmod(d, n) * fact[y + n % MOD - 1] % MOD * inv(fact[y-1]) % MOD;
    return rez;
}

int main(int argc, char** argv) {
    //ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout << setprecision(15);
    if (argc == 2 && atoi(argv[1]) == 123456789) {
        freopen("d:\\code\\cpp\\stdin", "r", stdin);
        //freopen("d:\\code\\cpp\\stdout", "w", stdout);
    }

    fact.resize(3*MOD+1);
    fact[0] = 1;
    FOR1(i, 3*MOD) {
        ll x = i;
        while(x%MOD == 0)
            x/=MOD;
        fact[i] = fact[i-1] * x % MOD;
    }

    int Q;
    cin >> Q;
    FOR(t, Q){
        ll x, d, n;
        cin >> x >> d >> n;
        cout << solve(x, d, n) << '\n';
    }

    if (argc == 2 && atoi(argv[1]) == 123456789)        cerr << clock()*1.0/CLOCKS_PER_SEC << " sec\n";
    return 0;
}


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

int main()
{
    long long X;
    cin >> X;
    long long p = X / 500;
    long long q = X % 500;
    long long ans = p * 1000 + (q / 5) * 5;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#define _DEBUG
#include "bits/stdc++.h"
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0,a1,a2,a3,a4,x,...) x
#define debug_1(x1) cout<<#x1<<": "<<x1<<endl
#define debug_2(x1,x2) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<endl
#define debug_3(x1,x2,x3) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<endl
#define debug_4(x1,x2,x3,x4) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<endl
#define debug_5(x1,x2,x3,x4,x5) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<", "#x5<<": "<<x5<<endl
#ifdef _DEBUG
#define debug(...) CHOOSE((__VA_ARGS__,debug_5,debug_4,debug_3,debug_2,debug_1,~))(__VA_ARGS__)
#else
#define debug(...)
#endif
#define rep(index,num) for(int index=0;index<(int)num;index++)
#define rep1(index,num) for(int index=1;index<=(int)num;index++)
#define brep(index,num) for(int index=(int)num-1;index>=0;index--)
#define brep1(index,num) for(int index=(int)num;index>0;index--)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=(ll)1e+18+1;
int INF=1e+9+1;
int main(){
	int N;
	scan(N);
	prin(N/2+N%2);
	return 0;
}


Measured memory_bytes: 256
import sys
from collections import deque
import copy
import math
def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline



def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [A, P] = [int(input_raw[0]), int(input_raw[1])]
    print ((A*3) + P)/2
if __name__ == '__main__':
    main()


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

using namespace std;

struct Item {
	string name;
	int num, den;
};
bool comp(const Item &i1, const Item &i2) {
	if (i1.num * i2.den == i2.num * i1.den) return i1.name < i2.name;
	return i1.num * i2.den > i2.num * i1.den;
}

int main() {
	int N;
	while (cin >> N, N) {
		vector<Item> v;
		for (int i = 0; i < N; ++i) {
			string L;
			int P, A, B, C, D, E, F, S, M;
			cin >> L >> P >> A >> B >> C >> D >> E >> F >> S >> M;
			int T = A + B + C + (D + E) * M;
			v.push_back( (Item){L, (M*F*S-P), T} );
		}
		sort(v.begin(), v.end(), comp);
		for (int i = 0; i < N; ++i) {
			cout << v[i].name << endl;
		}
		cout << "#" << endl;
	}
}

Measured memory_bytes: 1220
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mt make_tuple
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<string,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef tuple<int,int,int> tp;
typedef vector<tp> vt;
typedef vector<vd> vvd;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-7;
const int inf=1e9;
const ll INF=2e18;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(){
	int n,m;
	cin>>n>>m;
	vi co(n);
	while(m--){
		int a,b;
		cin>>a>>b;
		a--;b--;
		co[a]++;
		co[b]++;
	}
	bool h=true;
	rep(i,n)if(co[i]%2)h=false;
	if(h)cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
}







Measured memory_bytes: 640
def main():
    a,b,c,x,y = map(int, input().split())

    ans = 10**10
    for i in range(0,max(x,y)*2+2, 2):
        tmp = i*c
        x_count = i//2
        y_count = i//2
        tmp += max(0,x-x_count)*a + max(0,y-y_count)*b
        ans = min(ans, tmp)
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 39152
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
ll A, B, C, D;
/* function */
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x;}
ll lcm(ll x, ll y) {return x / gcd(x, y) * y;}
ll f (ll x) { return B / x - (A-1) / x; }
/* main */
int main(){
    cin >> A >> B >> C >> D;
    // A <= x <= B で C or Dで割り切れる個数
    ll divCorD = f(C) + f(D) - f(lcm(C, D));
    // A ~ Bの個数 - (C or Dで割り切れる個数)
    cout << (B - A + 1) - divCorD << '\n';
}


Measured memory_bytes: 3596
using System;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] line1 = System.Console.ReadLine().Trim().Split(' ');
            int H = int.Parse(line1[0]);
            int W = int.Parse(line1[1]);
            string[] lines = new string[H];
            string sharp = "##";
            for (int i = 0; i < H; i++)
            {
                lines[i] = System.Console.ReadLine().Trim();
            }
            for (int i = 0; i < W; i++)
            {
                sharp += "#";
            }
            System.Console.WriteLine(sharp);
            for (int i = 0; i < H; i++)
            {
                System.Console.WriteLine("#" + lines[i] + "#");
            }
            System.Console.WriteLine(sharp);
        }
    }
}

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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};


int main()
{
    ll a,b,c,d,ans=0;
    cin>>a>>b>>c>>d;
    ll lc = c / __gcd(c,d) * d;
    ans = (b - b/c - b/d + b/lc) - 
        ((a-1) - (a-1)/c - (a-1)/d + (a-1)/lc);
    
    cout<<ans<<endl;
    return 0;
}

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

int main(){
  int x, y, s;
  while(cin >> x >> y >> s, s){
    int ans = 0;
    for(int i = 1; i <= 1000; i++){
      for(int j = 1; j <= 1000; j++){
	if((int)(i*(100.0 + x) /100.0)
	   + (int)(j*(100.0 + x) /100.0) != s)continue;
	//if(i*((100.0 + x)/100.0) + j * ((100.0 + x)/100.0) != s)continue;
	int tmp = (int)(i*(100.0 + y)/100.0) + (int)(j*(100.0 + y)/100.0);
	ans = max(ans, tmp);
      }
    }
    cout << ans << endl;
  }
  return 0;
}

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

using namespace std;

const int MAX_N = 10;
const long long MOD = 1e9 + 7;

typedef long long ll;

int N, M, ans = 0;
int p[MAX_N];
vector<int> s[MAX_N];

bool can(int mask) {
    for (int i = 0; i < M; i++) {
        int cur = 0;
        for (int x : s[i])
            cur ^= (mask >> x & 1);
        if (cur != p[i])
            return false;
    }
    return true;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    cin >> N >> M;
    for (int i = 0; i < M; i++) {
        int k; cin >> k;
        while (k--) {
            int x; cin >> x; x--;
            s[i].push_back(x);
        }
    }
    for (int i = 0; i < M; i++) cin >> p[i];
    for (int i = 0; i < (1 << N); i++)
        ans += can(i);
    cout << ans;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <math.h>
#include <iomanip>
using namespace std;

#define PI 3.14159265358979323846264338327950L

int res;

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

    int A, B, C, K;
    cin >> A >> B >> C >> K;
    if (K <= A)
    {
        res = K;
    }
    else
    {
        if (K - A <= B)
        {
            res = A;
        }
        else
        {
            res = A + 0 * (K - A) + (-1) * (K - A - B);
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 3144
#define _USE_MATH_DEFINES
#define INF 100000000
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>

using namespace std;

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

static const double EPS = 1e-8;

int main(){
	int n;
	while(~scanf("%d",&n)){
		if(n==0) break;
		int sum=0;
		for(int i=0;i<n/4;i++){
			int p;
			scanf("%d",&p);
			sum += p;
		}
		printf("%d\n",sum);
	}
}

Measured memory_bytes: 0
#include<stdio.h>
int main()
{
    int a,b,c,i;
    scanf("%d%d%d",&a,&b,&c);
    if(a>b && a>c)
    {
        i=a;
        i=(i*10)+b+c;
    }
    else if(c>b && c>a)
    {
        i=c;
        i=(i*10)+a+b;
    }
    else
    {
        i=b;
        i=(i*10)+a+c;
    }
    printf("%d",i);
    return 0;
}

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

using namespace std;
using ll = long long;
using ull = unsigned long long;

typedef pair<int, int>pi;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
typedef pair<P, P> PPP;

const ll MOD = 1e9 + 7;
const ll INF = 9e18;
const double DINF = 5e14;
const double eps = 1e-10;
const int di[4] = { 1,0,-1,0 }, dj[4] = { 0,1,0,-1 };

#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define pb push_back
#define eb emplace_back
#define fr first
#define sc second

int n, a, ans;
vector<int>p;

int main() {
	cin >> n;
	for (int i = 0;i < n;i++) {
		cin >> a;
		p.eb(a);
	}
	sort(ALL(p));
	for (int i = 0;i <= 100;i++) {
		int cnt = 0;
		for (int j = 0;j < n;j++) {
			if (p[j] >= i)cnt++;
		}
		if (cnt >= i)ans = i;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3152
#include <stdio.h>

int main() {
  int a, b;
  scanf("%d%d", &a, &b);
  if (a > b) {
    printf("a > b\n");
  } else if (a == b) {
    printf("a == b\n");
  } else {
    printf("a < b\n");
  }
  return 0;
}


Measured memory_bytes: 2128
import java.util.*;
 
public class Main {
  public static void main(String[] arguments) {
    
    Scanner sc = new Scanner(System.in);
    String name = sc.next();
    int N = Integer.parseInt(name);
    int rem = N%10;
    
    if (rem == 3) System.out.println("bon");
    else if (rem == 0 || rem == 1 || rem == 6 || rem == 8) System.out.println("pon");
    else System.out.println("hon");
  }
}

Measured memory_bytes: 35632
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

using namespace std;

#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i <= b; i++)
#define revrep(i, s) for (int i = s-1; i > 0; i--)
#define revrrep(i, s) for (int i = s-1; i >= 0; i--)
#define all(a)  begin((a)),end((a))
#define uniq(c) (c).erase(unique(all((c))), end((c)))

int distance(pair<int, int> student, pair<int, int> check_point)
{
    return abs(student.first - check_point.first) + abs(student.second - check_point.second);
}

int main()
{
    int N, M; cin >> N >> M;
    vector<pair<int, int>> AB, CD;
    rep (i, 0, N) {
        int a, b; cin >> a >> b;
        AB.push_back(make_pair(a, b));
    }
    rep (i, 0, M) {
        int c, d; cin >> c >> d;
        CD.push_back(make_pair(c, d));
    }

    rep (i, 0, N) {
        int min_distance = distance(AB[i], CD[0]), index = 1;
        rep (j, 1, M) {
            int current_distance = distance(AB[i], CD[j]);
            if (min_distance > current_distance) {
                index = j+1;
                min_distance = current_distance;
            }
        }
        cout << index << endl;
    }
}

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

#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)

using namespace std;

class Dice
{
public:
	int lab[6];
};

int main() {
	Dice dice;
	int q, i, j, a, b, ai, bi;
	//input
	rep(i,6) cin >> dice.lab[i];
	cin >> q;

	//process
	rep(i,q) {
		cin >> a >> b;
		rep(j,6) {
			if (dice.lab[j] == a) ai = j;
			if (dice.lab[j] == b) bi = j;
		}
		if ((ai==3&&bi==1)||(ai==1&&bi==2)||(ai==2&&bi==4)||(ai==4&&bi==3)) {
			cout << dice.lab[0] << endl;
		} else if ((ai==0&&bi==3)||(ai==3&&bi==5)||(ai==5&&bi==2)||(ai==2&&bi==0)) {
			cout << dice.lab[1] << endl;
		} else if ((ai==0&&bi==1)||(ai==1&&bi==5)||(ai==5&&bi==4)||(ai==4&&bi==0)) {
			cout << dice.lab[2] << endl;
		} else if ((ai==0&&bi==4)||(ai==4&&bi==5)||(ai==5&&bi==1)||(ai==1&&bi==0)) {
			cout << dice.lab[3] << endl;
		} else if ((ai==0&&bi==2)||(ai==2&&bi==5)||(ai==5&&bi==3)||(ai==3&&bi==0)) {
			cout << dice.lab[4] << endl;
		} else if ((ai==1&&bi==3)||(ai==3&&bi==4)||(ai==4&&bi==2)||(ai==2&&bi==1)) {
			cout << dice.lab[5] << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 1160
class BinaryIndexTree

  def initialize n, arr = [], init = 0, &block
    block = ->(a, b) { a + b } unless block_given?
    @fun = block

    @n = n
    @init = init

    @tree = Array.new(n+1) { init }
    arr.each.with_index(1) do |e, i|
      put(i, e)
    end
  end

  def put i, e
    while i <= @n
      @tree[i] = @fun.(@tree[i], e)
      i += i & -i
    end
  end

  def query i
    r = @init
    while i > 0
      r = @fun.(r, @tree[i])
      i -= i & -i
    end
    r
  end
end

n = gets.to_i
as = gets.split.map(&:to_i)
cs = as.sort.each.with_index(1).reduce({}) do |h, (a, i)|
  h[a] = i
  h
end

r = 0
bit = BinaryIndexTree.new(n)
as.each.with_index do |a, i|
  j = cs[a]
  r += i - bit.query(j)
  bit.put(j, 1)
end
puts r


Measured memory_bytes: 36364
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vint t(n+1,0);
    vint x(n+1,0);
    vint y(n+1,0);

    REP(i,n) cin >> t[i+1] >> x[i+1] >> y[i+1];
    REP(i,n){
        int ti = t[i+1]-t[i];
        int d = abs(x[i+1]-x[i]) + abs(y[i+1]-y[i]);
        if(ti>=d&&(ti-d)%2==0){

        }else{
            puts("No");
            return 0;
        }
    }
    puts("Yes");

    return 0;
}

Measured memory_bytes: 4496
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main(void)
{
  long long int n;
  scanf("%lld", &n);

  long long int m = (long long int)sqrt((double)n) + 1;

  long long int ans;

  for(long long int i = m; i >= 0; i--) {
    if(n % i == 0) {
      ans = i+(n/i)-2;
      break;
    }
  }

  printf("%lld\n",ans);
      
  return 0;
}


Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define _USE_MATH_DEFINES
#include <math.h>
#define rep(i,n) for(int i = 0;i < n;i++)
#define NIL = -1;

int digit(ll x) {
    if (x / 10 == 0) return 1;
    return digit(x / 10) + 1;
}

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

ll lcm(ll a,ll b){
    a / gcd(a,b) * b;
}
const ll mod = 1e9 + 7;
const ll INF = 1e9 + 7;

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


/////////////////////////////////////////////////////////////////////////////////////////
int a[100005];
int main(){
    int n;
    cin >> n;
    ll a,ans = 0;
    for (int i = 0;i < n;i++){
        cin >> a;
        while(a != 0){
            if (a % 2 != 0) break;
            if (a % 2 == 0){
                ans++;
            }
            a /= 2;
        }

    }

    cout << ans << endl;


}

Measured memory_bytes: 256
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
#define F first
#define S second
#define MK make_pair
const ll E=1e17+7;
const ll MOD=1000000007;



int main(){
    ll n,k;
    cin>>n>>k;
    vector<ll> a;
    for(int i=0;i<n;i++){
        ll b;
        cin>>b;
        a.push_back(b);
    }
    n-=1;
    k--;
    ll ans=n/k;
    if(n%k!=0){ans++;}
    cout<<ans<<endl;
    
    
    return 0;
}

Measured memory_bytes: 1400
def Shiftonly(numbers)
  count = 0
  counts = []
  numbers.each do |num|
    while num % 2 == 0 do
      num = num / 2
      count = count + 1
    end
    counts = counts.push(count)
    count = 0
  end
  p counts.min
end

amount = gets.chomp.to_i
numbers = gets.chomp.split(" ").map(&:to_i)
Shiftonly(numbers)

Measured memory_bytes: 1788
#include <iostream>
#include <vector>
#include <map>
#include <limits>
#include <cmath>
//#include <iomanip> // BUILD

int main(int argc, char** argv) {
  int H, W;
  std::cin >> H >> W;
  std::vector<std::vector<char>> map(H, std::vector<char>(W));
  for (auto& e : map) {
    for (auto& f : e) {
      std::cin >> f;
    }
  }
  int node_cnt {H*W};
  std::vector<std::vector<int>> dp(node_cnt, std::vector<int>(node_cnt, std::numeric_limits<int>::max()));
  for (auto i = 0;i < H;++i) {
    for (auto j = 0;j < W;++j) {
      if (map[i][j] == '.') {
        if (i-1>=0 && map[i-1][j] == '.') {
          dp[W*i+j][W*(i-1)+j] = 1;
          dp[W*(i-1)+j][W*i+j] = 1;
        }
        if (i+1<H && map[i+1][j] == '.') {
          dp[W*i+j][W*(i+1)+j] = 1;
          dp[W*(i+1)+j][W*i+j] = 1;
        }
        if (j-1>=0 && map[i][j-1] == '.') {
          dp[W*i+j][W*i+(j-1)] = 1;
          dp[W*i+(j-1)][W*i+j] = 1;
        }
        if (j+1<W && map[i][j+1] == '.') {
          dp[W*i+j][W*i+(j+1)] = 1;
          dp[W*i+(j+1)][W*i+j] = 1;
        }
      } else {//map[i][j] == '#'
        for (auto k = 0;k < node_cnt;++k) dp[W*i+j][k] = -1;
        for (auto k = 0;k < node_cnt;++k) dp[k][W*i+j] = -1;
      }
    }
  }
  for (bool is_update = true;is_update == true;) {
    is_update = false;
    for (auto i = 0;i < node_cnt;++i) {
      for (auto j = 0;j < node_cnt;++j) {
        if (i == j) continue;
        if (dp[i][j] == -1) continue;
        for (auto k = 0;k < node_cnt;++k) {
          if (dp[i][k] == std::numeric_limits<int>::max() || dp[k][j] == std::numeric_limits<int>::max()) continue;
          if (dp[i][k] == -1 || dp[k][j] == -1) continue;
          if (dp[i][k] + dp[k][j] < dp[i][j]) {
            dp[i][j] = dp[i][k] + dp[k][j];
            is_update = true;
          }
        }
      }
    }
  }
  int max_turn {};
  for (const auto& e : dp) {
    for (const auto& f : e) {
      if (f != std::numeric_limits<int>::max() )max_turn = std::max(max_turn, f);
//      std::cout << std::setw(3) << std::setfill(' ') << ((f == std::numeric_limits<int>::max())?0:f) << ' ';
    }
//    std::cout << '\n';
  }
  std::cout << max_turn << '\n';
}


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

int main(){
  string s;
  cin >> s;
  if(s.at(0)==s.at(1) && s.at(1)==s.at(2)){
    cout << "No" << endl;
  }
  else{
    cout << "Yes" << endl;
  }
}


Measured memory_bytes: 256
// Author :
// Date :
// Problem:
// Solution:
// Comment:

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <cmath>
#include <cstring>

#define pp push
#define pb push_back
#define mp make_pair
#define xx first
#define yy second

using namespace std;

string play(string str){
    string ans;
    string q;
    int d = 0;
    
    //cout << str << endl;
    
    for(int i = 0 ; i < str.size() ; i++){
        if(str[i] == '['){
            string strr,strrr;
            
            int cnt = 1;
            while(cnt > 0){
                i++;
                if(str[i] == '[') cnt++;
                else if(str[i] == ']') cnt--;
                
                if(cnt > 0) strr = strr + str[i];
            }
            
            //cout << "strr " << strr << endl;
            strr = play(strr);
            
            for(int j = strr.size()-1 ; j >= 0 ; j--) strrr += strr[j];
            
            ans += strrr;
        }
        if(str[i] >= 'A' && str[i] <= 'Z'){
            while(d < -(26)) d+=26;
            ans += (str[i] + d + 26 - 'A') % 26 + 'A';
            d = 0;
        }
        if(str[i] == '-') d--;
        else if(str[i] == '+') d++;
        
        if(str[i] == '?'){
            d = 0;
            ans += 'A';
        }
    }
    //cout << "ans" << ans << endl;
    
    return ans;
}

main(){
    string str;
    while(cin >> str){
        if(str[0] == '.') break;
        
        cout << play(str) << endl;
    }
    #ifdef GEREL
        for(;;);
    #endif

    return 0;
}

Measured memory_bytes: 1208
/* ex4_2
  sachiyan */

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


int main(void){
    int len_hour, len_minute, hour, minute;
    double degree, difference, radian, cosine, answer;
    double pi = acos(-1);
    scanf("%d %d %d %d", &len_hour, &len_minute, &hour, &minute);
    degree = 0.5*(60*hour + minute) - 6*minute;
    difference = fabs(degree);

    if (difference <= 180){
        radian = difference*(pi/180);
        answer = sqrt(len_hour*len_hour + len_minute*len_minute - 2*len_hour*len_minute*cos(radian));
        printf("%.20lf\n", answer);
    }
    else{
        radian = (360 - difference)*(pi/180);
        answer = sqrt(len_hour*len_hour + len_minute*len_minute - 2*len_hour*len_minute*cos(radian));
        printf("%.20lf\n", answer);
    }

    return 0;
}

Measured memory_bytes: 2612
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
 
using namespace std;
 
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define rep(i,n) REP(i, 0, n)
#define pb push_back
#define mp make_pair
#define all(r) (r).begin(),(r).end()
#define rall(r) (r).rbegin(),(r).rend()
#define fi first
#define se second
#define DBG(X) cout<<" "<<#X<<" : "<<X<<endl
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;

const int INF = 1e9;
const double EPS = 1e-8;
const int mod = 1e9 + 7;
const ll LINF = 1e18;

struct Input
{
	int n;char c;char str[10010];string s;ll l;double d;
	int nextInt(){scanf("%d", &n);return n;}
	ll nextLong(){scanf("%lld", &l);return l;}
	double nextDouble(){scanf("%lf", &d);return d;}
	char nextChar(){scanf("%c", &c);return c;}
	string next(){scanf("%s", str);return string(str);}
	string nextLine(){getline(cin, s);return s;}
};
Input in;

ll dp[310];
vector<int> v;

int main(){
	for(int i= 1; i <= 17; i++) v.pb(i * i);
	dp[0] = 1LL;
	for(int i = 0; i < v.size(); i++){
		for(int j = 0; j + v[i] < 310; j++){
			dp[j+v[i]] += dp[j];
		}
	}
	while(1){
		int n = in.nextInt();
		if(n == 0) break;
		printf("%lld\n", dp[n]);
	}
}

Measured memory_bytes: 1212
n = int(input())
s = []
for i in range(n):
    s.append(int(input()))
s.sort()
num = sum(s)
for i in range(n):
    if num % 10 != 0:
        print(num)
        exit()
    elif s[i] % 10 == 0:
        pass
    else:
        num -= s[i]
print(0)



Measured memory_bytes: 39732
#include <bits/stdc++.h>
//#include "Header.h"

#define pi 3.14159265358979323846264

#define ll long long
#define fori(n) for(long long i=0;i<n;i++)
#define forj(n) for(long long j=0;j<n;j++)

#define sp(n) setprecision(n)
#define mkp make_pair
#define mkt make_tuple

using namespace std;

bool isPrime(long long k){
    if(k<=1){return false;}
    if(k==2){return true;}
    if(k%2==0){return false;}
    long long i = 3;
   while (i*i <= k) {if (k % i == 0) {return false;}i += 2;}
return true;
}

ll binomialCoeff(ll n, ll k){
    ll C[n + 1][k + 1];ll i, j;
    for (i = 0; i <= n; i++){
        for (j = 0; j <= min(i, k); j++){
            if (j == 0 || j == i){C[i][j] = 1;}
            else{C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]);}}}
    return C[n][k];
 }

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

ll srihrg(ll n,ll k,ll m){
    ll ans;
    ans=1;
    fori(k){
        ans=(ans*n)%m;
    }
    return ans;
}

#define d7 1000000007
#define l7 998244353
vector<ll> primes;

void bfs(ll n, ll s, queue<ll> &q,
vector<bool> &used,
vector<ll> &d, vector<ll> &p, vector<vector<ll>> adj
         ){
q.push(s);
used[s] = true;
p[s] = -1;
while (!q.empty()) {
    ll v = q.front();
    q.pop();
    for (ll u : adj[v]) {
        if (!used[u]) {
            used[u] = true;
            q.push(u);
            d[u] = d[v] + 1;
            p[u] = v;
        }
    }
}}

int main(int argc, const char * argv[]) {
 //cout<<"Om\n";
 //Praise to Lord
 //make cin/cout faster
 ios_base::sync_with_stdio(false);
 cin.tie(NULL);cout.tie(NULL);
// code now
   
    
    ll n;
    cin>>n;
    ll x,y;
    cin>>x>>y;
    vector<vector<ll>> adj(n);
    fori(n-1){
        adj[i].push_back(i+1);
        adj[i+1].push_back(i);
    }
    adj[x-1].push_back(y-1);
    adj[y-1].push_back(x-1);
    vector<ll> vd(n);
    fori(n){
        vector<ll> d(n);
        vector<ll> p(n);
        queue<ll> q;
        vector<bool> used(n);
        bfs(n,i,q,used,d,p,adj);
        forj(n){
            if(j!=i){
                vd[d[j]]++;
            }
        }
    }
    fori(n-1){
        cout<<vd[i+1]/2<<endl;
    }
    
    
//code ends
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); i++)
#define itrep(type, it, t) for(type::iterator it=t.begin(); it!=t.end(); it++)
using namespace std;

#define MAX_N (2001)
#define MAX_DIST (20000)

struct edge {
    int to;
    int cost;
};

typedef pair<int, int> P;  // first: 最短距離, second: 頂点番号

vector<edge> G[MAX_N]; // 隣接リスト表現

int d[MAX_N]; // 始点sから各頂点への距離
int cnt[MAX_N]; // 始点への最短経路の数
void dijkstra(int s) {
    fill(d, d + MAX_N, MAX_N);
    d[s] = 0;  // 始点sへの最短距離は0

    fill(cnt, cnt + MAX_N, 0);
    cnt[s] = 1;  // 始点sへの最短経路数は1

    priority_queue<P, vector<P>, greater<P>> que;  // 距離が小さい順に取り出せるようgreater<P>を指定
    que.push(P(0, s));
    while (!que.empty()) {
        P p = que.top();
        que.pop();
        int v = p.second;  // 更新した頂点の中で距離が最小の頂点v
        if (d[v] < p.first) {
            continue;
        }
        for (auto e : G[v]) {  // 頂点vから出る辺eを走査
            if (d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost;
                que.push(P(d[e.to], e.to));
                cnt[e.to] = cnt[v];  // コストが更新された場合は直前の頂点への最短経路数で上書き
            } else if (d[e.to] == d[v] + e.cost) {
                cnt[e.to] += cnt[v];  // コストが一致する場合はこれまでの最短経路数を足し合わせ
            }
        }
    }
}


int main(void) {

    int N, X, Y;
    cin >> N >> X >> Y;

    for(int i=1; i<N; i++) {
        edge e1, e2;
        e1.to = i+1;
        e2.to = i;
        e1.cost = e2.cost = 1;
        G[i].push_back(e1);
        G[i+1].push_back(e2);
    }
    {
        edge e1, e2;
        e1.to = Y;
        e2.to = X;
        e1.cost = e2.cost = 1;
        G[X].push_back(e1);
        G[Y].push_back(e2);
    }

    int ans[MAX_N];
    fill(ans, ans + MAX_N, 0);
    for(int i=1; i<=N; i++) {
        dijkstra(i);
        rep(j, N+1) ans[ d[j] ]++;
    }

    for(int i=1; i<N; i++) {
        cout << (ans[i]/2) << endl;
    }

    return 0;
}



Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
using namespace std;
int inf = 1000000000;

long long count(vector<int> &a){
  long long cnt = 0;
  int n = a.size();

  if( n > 1 ){
    vector<int> b(a.begin(), a.begin()+n/2);
    vector<int> c(a.begin()+n/2, a.end());
    cnt += count(b);
    cnt += count(c);
    for(int i=0, j=0, k=0; i<n; i++){
      if( k == c.size() ) a[i] = b[j++];
      else if( j == b.size() ) a[i] = c[k++];
      else if( b[j] <= c[k] ) a[i] = b[j++];
      else{ a[i] = c[k++]; cnt += n/2 - j; }
    }
  }
  return cnt;
}

int main(void) {

  int n;
  cin >> n;
  vector<int> a(n);
  for(int i=0; i<n; i++) cin >> a[i];
  cout << count(a) << endl;
  return 0;
}

// EOF

Measured memory_bytes: 5276
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <vector>
#include <stack>
using namespace std;

int r, c;
int n;
typedef long long LL;

int type(int x, int y){
    if(x == 0) return 0;
    if(y == c) return 1;
    if(x == r) return 2;
    if(y == 0) return 3;
    return 4;
}

const LL mod = 1e9 + 7;

LL cal(int x, int y){
    int t = type(x, y);
    if(t == 0)
        return y;
    if(t == 1)
        return mod + x + y;
    if(t == 2)
        return 2LL * mod + x - y;
    if(t == 3)
        return 3LL * mod + y - x;
    return 0;
}

vector<pair<LL, int> > v;
stack<int> s;
int main(){
    //freopen("in/s1.txt", "r", stdin);
    cin >> r >> c;
    cin >> n;
    for(int i = 1;i <= n;i++){
        int a, b, c, d;
        scanf("%d%d%d%d", &a, &b, &c, &d);
        if(type(a, b) == 4 or type(c, d) == 4)
            continue;
        LL v1 = cal(a, b);
        LL v2 = cal(c, d);        
        if(v1 > v2)
            swap(v1, v2);
        v.push_back(make_pair(v1, i));
        v.push_back(make_pair(v2, -i));
    } 
    sort(v.begin(), v.end());
    //cout << "!!!" << endl;
    //for(int i = 0;i < v.size();i++){
    //    cout << i << " " << v[i].first << " " << v[i].second << endl;
    //}
    bool flag = false;
    for(int i = 0;i < v.size();i++){
        int id = v[i].second;
        LL pos = v[i].first;
        if(id < 0){
            int p = s.top();s.pop();
            if(p != -id)
                flag = true;
        }else{
            s.push(id);
        }
    }
    if(flag){
        cout << "NO" << endl;
    }else{
        cout << "YES" << endl;
    }
    return 0;
}


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

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

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

    int x = *max_element(a.begin(), a.end());
    int y = *min_element(a.begin(), a.end());

    cout << x - y << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

ll n,u,v;
ll t[100010],a[100010];
vector<ll>ch[100010];
void dep1(ll now,ll cnt){
	for(ll i=0;i<ch[now].size();i++){
		ll next=ch[now][i];
		if(t[next]!=0){
			continue;
		}
		t[next]=cnt+1;
		dep1(next,cnt+1);
	}
}
void dep2(ll now,ll cnt){
	for(ll i=0;i<ch[now].size();i++){
		ll next=ch[now][i];
		if(a[next]!=0){
			continue;
		}
		a[next]=cnt+1;
		dep2(next,cnt+1);
	}
}
int main() {
	cin>>n>>u>>v;
	u--;v--;
	for(ll i=0;i<n-1;i++){
		ll x,y;
		cin>>x>>y;
		x--;y--;
		ch[x].push_back(y);
		ch[y].push_back(x);
	}
	t[u]=a[v]=1;
	dep1(u,1);
	dep2(v,1);
	ll ans=0;
	for(ll i=0;i<n;i++){
		if(a[i]>t[i]){
			ans=max(ans,a[i]);
		}
	}
	cout << ans-2;
	return 0;
}

Measured memory_bytes: 14524
from bisect import *
from collections import *
from itertools import *
import functools
import sys
import math
from decimal import *
from copy import *
from heapq import *
from fractions import *
getcontext().prec = 30
MAX = sys.maxsize
MAXN = 1000010
MOD = 10**9+7
spf = [i for i in range(MAXN)]
spf[0]=spf[1] = -1
def sieve():
    for i in range(2,MAXN,2):
        spf[i] = 2
    for i in range(3,int(MAXN**0.5)+1):
        if spf[i]==i:
            for j in range(i*i,MAXN,i):
                if spf[j]==j:
                    spf[j]=i
def fib(n,m):
    if n == 0:
        return [0, 1]
    else:
        a, b = fib(n // 2)
        c = ((a%m) * ((b%m) * 2 - (a%m)))%m
        d = ((a%m) * (a%m))%m + ((b)%m * (b)%m)%m
        if n % 2 == 0:
            return [c, d]
        else:
            return [d, c + d]

def charIN(x= ' '):
    return(sys.stdin.readline().strip().split(x))

def arrIN(x = ' '):
    return list(map(int,sys.stdin.readline().strip().split(x)))

def ncr(n,r):
    num=den=1
    for i in range(r):
        num = (num*(n-i))%MOD
        den = (den*(i+1))%MOD

    return (num*(pow(den,MOD-2,MOD)))%MOD

def flush():
    return sys.stdout.flush()

'''*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*'''
n = int(input())
a = arrIN()
for i in a:
    if i%2==0:
        if not (i%3==0 or i%5==0):
            print("DENIED")
            break
else:
    print('APPROVED')

Measured memory_bytes: 44952
k = int(input())
ok = 10**18
ng = 0
while ok-ng>1:
    mid = (ok+ng)//2
    mx = list(map(int, list(str(mid))))
    n = len(mx)
    dp = [[[0]*2 for i in range(10)] for j in range(n+1)]
    for i in range(1, mx[0]):
        dp[1][i][0] = 1

    dp[1][mx[0]][1] = 1
    for i in range(1, n):
        for j in range(10):
            for d in range(10):
                if abs(j-d)<=1:
                    dp[i+1][d][0]+=dp[i][j][0]
            for d in range(mx[i]):
               if abs(j-d)<=1:
                   dp[i+1][d][0]+=dp[i][j][1]
            d = mx[i]
            if abs(j-d)<=1:
                dp[i+1][d][1]+=dp[i][j][1]
        for d in range(1, 10):
            dp[i+1][d][0]+=1
    res = 0
    for d in range(10):
        res+=dp[n][d][0]+dp[n][d][1]
    if res>=k:
        ok = mid
    else:
        ng = mid

print(ok)






Measured memory_bytes: 50928
/*
 * atcoder/abc106_2nd/c.cpp
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template <class T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }

string S;
ll K;
void solve() {
  cin >> S >> K;
  K--;
  int last1 = 0;
  if (S[last1] != '1') last1 = -1;
  else while (S[last1] == '1') last1++;
  if (last1 > 0) last1--;

  if (last1 == S.size()-1) {
    cout << "1" << endl;
    return;
  }

  if (last1 == -1) {
    cout << S[0] << endl;
    return;
  }

  if (last1 < K) {
    cout << S[last1+1] << endl;
    return;
  }

  cout << 1 << endl;
}
int main() {
  // cout.precision(15); cout << fixed;

  solve();

  return 0;
}


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


int dp[200005][4];


signed main()
{
 
ios_base::sync_with_stdio(false);
cin.tie(NULL);  
cout.tie(0);   
 
#ifndef ONLINE_JUDGE
    if(fopen("INPUT.txt","r"))
    {
    freopen ("INPUT.txt" , "r" , stdin);
    freopen ("OUTPUT.txt" , "w" , stdout);
    }
#endif      

    int n;
    cin>>n;
    int a[n+1];
    for(int i=1;i<=n;i++)
        cin>>a[i];
    for(int i=1;i<=n;i++)
    {
        if(a[i]==0)
        {
            dp[i][0]=dp[i-1][0];
            dp[i][1]=min(dp[i-1][0]+2,dp[i-1][1]+2);
            dp[i][2]=min({dp[i-1][0]+1,dp[i-1][1]+1,dp[i-1][2]+1});
            dp[i][3]=min({dp[i-1][0]+2,dp[i-1][1]+2,dp[i-1][2]+2,dp[i-1][3]+2});            
        }
        else
        {
            if(a[i]%2)
            {
                dp[i][0]=dp[i-1][0]+a[i];
                dp[i][1]=min(dp[i-1][0]+1,dp[i-1][1]+1);
                dp[i][2]=min({dp[i-1][0],dp[i-1][1],dp[i-1][2]});
                dp[i][3]=min({dp[i-1][0]+1,dp[i-1][1]+1,dp[i-1][2]+1,dp[i-1][3]+1});                            
            }
            else
            {
                dp[i][0]=dp[i-1][0]+a[i];
                dp[i][1]=min(dp[i-1][0],dp[i-1][1]);
                dp[i][2]=min({dp[i-1][0]+1,dp[i-1][1],dp[i-1][2]+1});
                dp[i][3]=min({dp[i-1][0],dp[i-1][1],dp[i-1][2],dp[i-1][3]});                
            }            
        }        
    }
    int mn=1e17;
    int tot=0;
    for(int i=n;i>=0;i--)
    {
        for(int j=0;j<4;j++)
            mn=min(mn,dp[i][j]+tot);
        tot+=a[i];
    }
    cout<<mn;


}

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

using namespace std;

int main(){
	string s;
	string t = "CODEFESTIVAL2016";
	while(cin >> s){
		int res = 0;
		for(int i=0;i<s.size();++i){
			if(s[i] != t[i]) ++res;
		}
		cout << res << endl;
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S,T; cin >> S >> T;
  int N = S.size();
  bool ans = true;
  for(int i=0; i<N; i++) {
    if(S[i] != T[i]) ans=false;
  }
  if(ans==true) cout << "Yes" << endl;
  if(ans==false) cout << "No" << endl;
}

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

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

        vector<int> a(s.size());
        rep(i,s.size()){
            a[i]=0;
        }

        int ans = 0;

        rep(i,s.size()){
            if(s[i]=='A' || s[i]=='C' || s[i]=='G' || s[i]=='T'){
                if(a[i-1]>0 && i>0){
                    a[i]=a[i-1]+1;
                }
                else{
                    a[i]++;
                }

            }
            ans = max(ans,a[i]);
        }
        cout << ans << endl;
        return 0;
    }

Measured memory_bytes: 3620
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var sc = bufio.NewScanner(os.Stdin)

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	line := nextLine()
	parts := strings.Split(line, " ")
	a, _ := strconv.Atoi(parts[0])
	b, _ := strconv.Atoi(parts[1])
	k, _ := strconv.Atoi(parts[2])

	ret := make([]int, 0)
	for i := 1; i < 101; i++ {
		if a%i == 0 && b%i == 0 {
			ret = append(ret, i)
		}
	}

	fmt.Println(ret[len(ret)-k])
}


Measured memory_bytes: 640
def insertion_sort(arr)
  i = 1
  while i < arr.size
    puts arr.join(' ')
    i.downto(1) do |j|
      break if arr[j] >= arr[j - 1]

      arr[j], arr[j - 1] = arr[j - 1], arr[j]
    end

    i += 1
  end

  arr
end

def main
  _n = gets.to_i
  arr = gets.split.map(&:to_i)

  puts insertion_sort(arr).join(' ')
end

main



Measured memory_bytes: 8868
#include<stdio.h>
int main(void){
    int a=0,x[5],i,c=0,d=0,e=0;
    while(1){
        a=0,c=0,d=0,e=0;
        for(i=0;i<5;i++){
            scanf("%d",&x[i]);
            switch(x[i]){
                case 0:
                goto end;
            case 1:
                if(c==0){
                    a++;
                    c++;
                }
                break;
                case 2:
                if(d==0){
                    a++;
                    d++;
                }
                break;
                case 3:
                if(e==0){
                    a++;
                    e++;
                }
            }
        }
        if(a!=2){
            for(i=0;i<5;i++)x[i]=3;
        }
        else{
            if(c==0){
                for(i=0;i<5;i++){
                    if(x[i]==2)x[i]=1;
                    else x[i]=2;
                }
            }
            if(d==0){
                for(i=0;i<5;i++){
                    if(x[i]==3)x[i]=1;
                    else x[i]=2;
                }
            }
            if(e==0){
                for(i=0;i<5;i++){
                    if(x[i]==1)x[i]=1;
                    else x[i]=2;
                }
            }
        }
        for(i=0;i<5;i++){
            printf("%d\n",x[i]);
        }
    }
    end:
    return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
#include <unordered_map>
typedef long long ll;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " \n"[i == n-1];}
#define printp(x,n) for(ll i = 0; i < n; i++){ cout << "(" << x[i].first << ", " << x[i].second << ") "; } cout << endl;
#define INF (1e18)
using namespace std;
const ll MOD = 1e9 + 7;
typedef pair<ll, ll> lpair;
ll f(ll n){
    return (n*n + 4) / 8;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    cin >> S;
    ll N = S.size();
    rep(i,0,N){
        if((N-1-i) % 2 != 0) continue;
        ll v = (N-1-i)/2;
        if(S.substr(0,v) == S.substr(v,v)){
            print(v*2);
            return 0;
        }
    }
}

Measured memory_bytes: 256