akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>

using namespace std;

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

	for (int i = 0; i < (1 << n); i++) {
		vector<int> v;
		int count = 0;

		for (int j = 0; j < n; j++) {
			if (i & (1 << j)) {
				v.push_back(j);
				count++;
			}
		}

		if (count == k) {
			cout << i << ":";
			for (int k = 0; k < v.size(); k++) {
				cout << " " << v[k];
			}
			cout << endl;
		}
	}
}


Measured memory_bytes: 3132
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

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

const ll MOD=1e9+7;
const ll INF=1e18;
const double pi=acos(-1);
const double eps=1e-10;

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

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

    // [lb, ub]
    vector<string> s(n+10);
    int lb=0, ub=n-1;
    for(int i=0; i<18; i++){
        int mid = (lb + ub) / 2;

        cout << mid << endl;
        cin>>s[mid];

        if(s[mid] == "Vacant") return 0;

        if(i == 0){
            cout << lb << endl;
            cin>>s[lb];

            if(s[lb] == "Vacant") return 0;

            cout << ub << endl;
            cin>>s[ub];

            if(s[ub] == "Vacant") return 0;
        }
        

        if(((mid - lb) % 2 == 0 && s[lb] != s[mid]) || ((mid - lb) % 2 == 1 && s[lb] == s[mid])){
            ub = mid;
        }
        if(((ub - mid) % 2 == 0 && s[mid] != s[ub]) || ((ub - mid) % 2 == 1 && s[mid] == s[ub])){
            lb = mid;
        }
    }
}

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

bool g[1000][1000];

vector<int> extract_cycle(vector<int>& path) {
	if (path.size() <= 1) {
		return vector<int>();
	}

	int v = path[path.size() - 1];
	for (int i = path.size() - 2; i >= 0; --i) {
		if (g[v][path[i]]) {
			vector<int> cycle(path.size() - i);
			copy(path.begin() + i, path.end(), cycle.begin());

			return cycle;
		}
	}

	return vector<int>();
}

vector<int> find_cycle(int n, int start, vector<int>& path) {
	path.push_back(start);

	vector<int> cycle = extract_cycle(path);
	if (!cycle.empty()) {
		return cycle;
	}
	
	for (int dest = 0; dest < n; ++dest) {
		if (g[start][dest]) {
			vector<int> cycle = find_cycle(n, dest, path);
			if (!cycle.empty()) {
				return cycle;
			}
		}
	}

	path.pop_back();

	return vector<int>();
}

int main() {
	memset(g, false, sizeof(g));

	int n, m;
	cin >> n >> m;

	for (int i = 0; i < m; ++i) {
		int a, b;
		cin >> a >> b;
		g[a - 1][b - 1] = true;
	}

	vector<int> min;

	for (int i = 0; i < n; ++i) {
		vector<int> p;
		vector<int> cycle = find_cycle(n, i, p);

		if (min.empty() || (!cycle.empty() && cycle.size() < min.size())) {
			min = cycle;
		}
	}

	if (min.empty()) {
		cout << -1;
		return 0;
	}

	cout << min.size() << endl;
	for (int c : min) {
		cout << c + 1 << endl;
	}
	
	return 0;
}


Measured memory_bytes: 1408
#define _CRT_SECURE_NO_WARNINGS

/* include ***********************/
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>

/* define *************************/
//for
#define REP(i,n) for(int i=0,i##_len=(int)(n);i<i##_len;i++)
#define REPS(i,n) for(int i=1,i##_len=(int)(n);i<=i##_len;i++)
#define RREP(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define RREPS(i,n) for(int i=(int)(n);i>0;i--)
#define FOR(i,s,n) for(int i=(int)(s),i##_len=(int)(n);i<i##_len;i++)

//printf
#define PRINTD(d) printf("%d\n",(d))
#define PRINTL(d) printf("%lld\n",(d))

//memset
#define m0(s) memset(s,0,sizeof(s))
#define ml(s) memset(s,63,sizeof(s))
#define fill(s,c) memset(s,c,sizeof(s))

#define INF 1e9

typedef long long ll;


int diff[4][2] = {
	{ 0, -1 },
	{ -1, 0 },
	{ 1, 0 },
	{ 0, 1 },
};

int Min(int a, int b) {
	return (a)<(b) ? (a) : (b);
}
ll Max(ll a, ll b) {
	return (a) > (b) ? (a) : (b);
}
void Swap(int *a, int *b) {
	int tmp = *a;
	*a = *b;
	*b = tmp;
}

int main() {
	int n, m;
	scanf("%d%d", &n,&m);

	ll score[1000][3];
	REP(i, n) {
		scanf("%lld%lld%lld", &score[i][0], &score[i][1],&score[i][2]);
	}
	ll ans = 0;
	ll tmps[8][1000];
	REP(i, n) {
		REP(j, 8) {
			ll tmp = 0;
			tmp += (j & 1) ? score[i][0] : (score[i][0] * -1);
			tmp += ((j>>1) & 1) ? score[i][1] : (score[i][1] * -1);
			tmp += ((j>>2) & 1) ? score[i][2] : (score[i][2] * -1);
			tmps[j][i] = tmp;

			RREPS(k, i) {
				if (tmps[j][k] > tmps[j][k - 1]) {
					ll a = tmps[j][k - 1];
					tmps[j][k - 1] = tmps[j][k];
					tmps[j][k] = a;
				}
			}
			/*
			printf("%d %d\n", i, j);
			REP(k, 8) {
				REP(l, m) {
					PRINTL(tmps[k][l]);
				}
				puts("");
			}
			*/
		}
	}

	ll tmpans[8] = { 0 };
	REP(i, 8) {
		REP(j, m) {
			tmpans[i] += tmps[i][j];
			//PRINTL(tmpans[i]);
		}
		//puts("");
		ans = Max(ans, tmpans[i]);
	}
	PRINTL(ans);
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cassert>
#define InfL 1000000000
#define InfLL 1000000000000000000LL
#define mod 1000000007
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rrep(i,n) for(int (i)=(n-1);(i)>=(0);(i)--)
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<db> vd;

ll A, B, C;
void upd(string s, char c) {
	if (c == 'A') {
		A++;
		(s == "AB") ? B-- : C--;
	}
	if (c == 'B') {
		B++;
		(s == "AB") ? A-- : C--;
	}
	if (c == 'C') {
		C++;
		(s == "AC") ? A-- : B--;
	}
	return;
}

int main() {
	int N;
	cin >> N;
	cin >> A >> B >> C;
	vector<char> ans(N);
	vector<string> S(N);
	rep(i, N) cin >> S[i];
	rep(i, N) {
		int X, Y, x, y;
		if (S[i] == "AB") X = A, Y = B, x = 0, y = 1;
		if (S[i] == "BC") X = B, Y = C, x = 1, y = 2;
		if (S[i] == "AC") X = A, Y = C, x = 0, y = 2;
		ans[i] = 'A';
		if (X > Y) ans[i] += y;
		else if (X < Y) ans[i] += x;
		else {
			if (X + Y == 0) {
				cout << "No" << endl;
				return 0;
			}
			if (X + Y == 2) {
				string Snxt;
				if (S[i] == "AB") Snxt = "BC";
				if (S[i] == "BC") Snxt = "AC";
				if (S[i] == "AC") Snxt = "BC";
				if (i != N - 1 && S[i + 1] == Snxt) ans[i] += y;
				else ans[i] += x;
			}
			else ans[i] += x;
		}
		upd(S[i], ans[i]);
	}
	cout << "Yes" << endl;
	rep(i, N)
		cout << ans[i] << endl;
	return 0;
}

Measured memory_bytes: 6428
from collections import Counter
import sys
sys.setrecursionlimit(5000000)

S = list(input())
L = len(S)
A = Counter(S)

nCr = {}
def cmb(n, r):
    if r == 0 or r == n: return 1
    if r == 1: return n
    if (n,r) in nCr: return nCr[(n,r)]
    nCr[(n,r)] = cmb(n-1,r) + cmb(n-1,r-1)
    return nCr[(n,r)]

if L == 1:
    print(1)
else:
    ans = cmb(L, 2) + 1
    for v in A.values():
        if v == 1: continue
        ans -= cmb(v, 2)
    print(ans)

Measured memory_bytes: 195476
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
#define Max 1000001
#define inf INT_MAX
#define llinf LONG_LONG_MAX
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define pb push_back
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define endl '\n'
const ll N=2e5+5,mod=1000000007,bit=60;
signed main()
{
    fast;
    ll pro=1,temp,t,i,j,l,r,n,m,mid,z,k,x,y,rem,carry=0,ind,ans=0,mx=-llinf,mn=llinf,cnt=0,curr=0,prev,next,sum=0,flag=1,i1=-1,i2=-1,u,v;
    cin>>n;
    ll a[n+1];
    for(i=1;i<=n;i++)
    {
    	cin>>x;
    	a[x]=i;
    }
    for(i=1;i<=n;i++)
    {
    	cout<<a[i]<<' ';
    }
    cout<<endl;
	return 0;
}

Measured memory_bytes: 1664
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[] p = new int[n];
		Arrays.setAll(p, i -> sc.nextInt());
		
		int cnt = 0;
		for (int i = 0; i < n - 2; i++) {
			int[] arr = new int[3];
			for (int j = 0; j < 3; j++) {
				arr[j] = p[i + j];
			}
			
			Arrays.sort(arr);
			if (arr[1] == p[i + 1]) cnt++;
		}
		
		System.out.println(cnt);
		
		sc.close();
	}
	
}




Measured memory_bytes: 32236
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
ios_base::sync_with_stdio(0);
int n,a,b;
cin>>n>>a>>b;
if(n+a+b>21)
{
    cout<<"bust";
}
    else
        cout<<"win";

 return 0;
}


Measured memory_bytes: 256
/*************************************************************************
  > File Name: C.cc
  > Author: Riho.Yoshioka
  > Mail:   riho.yoshioka@yandex.com
  > Created Time: Sat 16 Jul 2016 08:39:04 PM CST
*************************************************************************/
#include <bits/stdc++.h>
typedef long long LL;
using namespace std;

const int N = 2005;
int n, k, mx, cnt, vis[N], now;
vector<int> edge[N];

void dfs(int x, int p, int dep = 1) {
  if (dep * 2 > k) {
    cnt++;
    return ;
  }
  vis[x] = now;
  int cnt = 0;
  for (auto y: edge[x]) if (y != p) {
    dfs(y, x, dep + 1);
    cnt++;
  }
}

int main() {
  ios::sync_with_stdio(0);
  cin >> n >> k;
  for (int i = 0; i < n - 1; i++) {
    int x, y;
    cin >> x >> y;
    edge[x].push_back(y);
    edge[y].push_back(x);
  }
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    mx = 0;
    now = vis[i] = i;
    for (auto &y: edge[i]) {
      cnt = 0;
      dfs(y, i), mx = max(mx, cnt);
    }
    int res = 0;
    for (int j = 1; j <= n; j++) if (vis[j] == i) res++;
    if (k % 2 == 0) mx = 0;
    ans = max(ans, res + mx);
  }
  cout << n - ans << endl;

  return 0;
}


Measured memory_bytes: 384
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
	return list(map(int,input().split()))
def m(): #複数文字
	return map(int,input().split())
def onem(): #Nとかの取得
	return int(input())
def s(x): #圧縮
	a = []
	if len(x) == 0:
		return []
	aa = x[0]
	su = 1
	for i in range(len(x)-1):
		if aa != x[i+1]:
			a.append([aa,su])
			aa = x[i+1]
			su = 1
		else:
			su += 1
	a.append([aa,su])
	return a
def jo(x): #listをスペースごとに分ける
	return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
	return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False

def pow_k(x, n):
    ans = 1
    while n:
        if n % 2:
            ans *= x
        x *= x
        n >>= 1
    return ans

"""
def nibu(x,n,r):
	ll = 0
	rr = r
	while True:
		mid = (ll+rr)//2

	if rr == mid:
		return ll
	if (ここに評価入れる):
		rr = mid
	else:
		ll = mid+1
"""

n,k = m()

a = l()

a.sort()

mina = []

pra = []

for i in range(len(a)):
	if a[i] >= 0:
		pra.append(a[i])
	else:
		mina.append(a[i])

lp = len(pra)

lm = len(mina)
ans = 1
if lp == 0:
	if k % 2 != 0:
		for i in range(0,k,2):
			if i == k-1:
				i = -(1+i)
				ans *= mina[i]
			else:
				i = -(1+i)
				ans *= (mina[i]*mina[i-1]) % mod
			ans %= mod
		print(ans % mod)
	else:
		for i in range(0,k,2):
			ans *= (mina[i]*mina[i+1]) % mod
			ans %= mod
		print(ans % mod)
elif lp == 1:
	if n == k:
		ans *= pra[0]
		for i in range(0,lm,2):
			if i == lm-1:
				i = -(1+i)
				ans *= mina[i]
			else:
				i = -(1+i)
				ans *= (mina[i]*mina[i-1]) % mod
			ans %= mod
		print(ans % mod)
	else:
		if k % 2 == 0:
			for i in range(0,k,2):
				ans *= (mina[i]*mina[i+1]) % mod
				ans %=  mod
			print(ans % mod)
		else:
			ans *= pra[0] 
			for i in range(0,k-1,2):
				ans *= (mina[i]*mina[i+1]) % mod
				ans %=  mod
			print(ans % mod)
else:
	cp = lp-1
	cm = 0
	
	for _ in range(k):
		if cp != -1 and cm != lm:
			if abs(mina[cm]) <= pra[cp]:
				if cp == 0:
					if (k-lp) % 2 == 0:
						cp -= 1
					else:
						cm += 1
				else:
					cp -= 1
			else:
				if cm == lm-1:
					if lm % 2 == 0:
						cm += 1
					else:
						cp -= 1
				else:
					
					cm += 1
		elif cp != -1:
			cp -= 1
		elif cm != lm:
			cm += 1
			
		else:
			break
	if cm % 2 != 0:
		if cp == lp-1:
			cp -= 1
			cm -= 1

		else:
			if cp != -1 and cm != lm:
				if pra[cp+1] == 0: 
					cp += 1
					cm += 1
				elif pra[cp]*pra[cp+1] <= -mina[cm]*-mina[cm-1]:
					cp += 1
					cm += 1
				else:
					cp -= 1
					cm -= 1
			elif cp != -1:
				cp -= 1
				cm -= 1
			elif cm != lm:
				cp += 1
				cm += 1

	ii = -2
	for i in range(0,cm,2):
		if i == cm-1:
			ii = i
			continue
		ans *= (mina[i] * mina[i+1]) % mod
		ans %= mod
	for i in range(lp-1,cp,-1):
		ans *= pra[i] % mod
		ans %= mod
	if ii == cm-1:
		ans *= mina[ii]
		ans %= mod

		
	print(ans)






Measured memory_bytes: 112372
#include<cstdio>
using namespace std;

int n, c, s[100000], t[100000], cc[100000], sm[200002], tt[200002];

int main() {
	scanf("%d%d", &n, &c);
	for (int i = 0; i < n; i++) {
		scanf("%d%d%d", &s[i], &t[i], &cc[i]);
	}

	for (int i = 1; i <= c; i++) {
		for (int j = 0; j < 200002; j++)tt[j] = 0;
		for (int j = 0; j < n; j++)if (cc[j] == i)tt[s[j] * 2 - 1]++, tt[t[j] * 2]--;
		for (int j = 1; j < 200002; j++)tt[j] += tt[j - 1];
		for (int j = 0; j < 200002; j++)if (tt[j] > 0)sm[j]++;
	}
	int mx = 0;
	for (int j = 0; j < 200002; j++)if (mx < sm[j])mx = sm[j];
	printf("%d\n", mx);

	return 0;
}

Measured memory_bytes: 2944
package main

import (
	"fmt"
	"math"
)

func main(){
	var N,t,x,y int
	fmt.Scan(&N)

	t0 := 0
	x0 := 0
	y0 := 0
	f:=true
	for n:=0;n<N;n++{
		fmt.Scan(&t, &x, &y)
		//fmt.Println("t ",t-t0)
		//fmt.Println("x ",math.Abs(float64(x-x0)))
		//fmt.Println("y ",math.Abs(float64(y-y0)))
		T := t-t0
		XY := int(math.Abs(float64(x-x0))+math.Abs(float64(y-y0)))

		if T<XY || T%2 != XY%2{
			f=false
			break
		}
		t0 = t
		x0 = x
		y0 = y
	}
	if f {
		fmt.Print("Yes")
	}else{
		fmt.Print("No")
	}
}

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

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

#define pb push_back
#define rep(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, n) for(int i = a; i < (n); i++)
#define mod (ll)(1e9+7)
#define int ll
#define INF 100000000

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

signed main() {
	ll m, f, b, result = 0;
  cin >> m >> f >> b;
  if(m < b) {
    result = b - m;
  }
  if (f < result) {
    cout << "NA" << endl;
    return 0;
  }
  cout << result << endl;
	return 0;
}


Measured memory_bytes: 3188
"use strict";
var input=require("fs").readFileSync("/dev/stdin","utf8");
var cin=input.split(/ |\n/),cid=0;
function next(){return +cin[cid++];}
function nextstr(){return cin[cid++];}
function nextbig(){return BigInt(cin[cid++]);}
function nexts(n,a){return a?cin.slice(cid,cid+=n):cin.slice(cid,cid+=n).map(a=>+a);}
function nextm(h,w,a){var r=[],i=0;if(a)for(;i<h;i++)r.push(cin.slice(cid,cid+=w));else for(;i<h;i++)r.push(cin.slice(cid,cid+=w).map(a=>+a));return r;}
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill().map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill().map(x=>"+r+")";return eval(r);}

function gcd(a,b){return b?gcd(b,a%b):a;}

var mod = 1e9+7;
function mul(a,b){return ((a>>16)*b%mod*65536+(a&65535)*b)%mod;}
function pow(a,n){for(var r=1;n;a=mul(a,a),n>>=1)if(n&1)r=mul(a,r);return r;}
function mput(n){return (n%mod+mod)%mod;}

var myOut = main();
if(myOut !== undefined)console.log(myOut);

function main(){
  var n = next();
  var az = 0, bz = 0, z = 0;
  var map = {};
  for(var i = 0; i < n; i++){
    var a = nextbig(), b = nextbig();
    if(a === 0n && b === 0n){z++; continue;}
    if(a === 0n){az++; continue;}
    if(b === 0n){bz++; continue;}
    var c = gcd(a,b);
    a /= c, b /= c;
    if(a < 0)a = -a, b = -b;
    if(map[a]){
      if(map[a][b])map[a][b]++;
      else map[a][b] = 1;
    }else{
      map[a] = {};
      map[a][b] = 1;
    }
  }
  var ans = pow(2,az) + pow(2,bz) - 1;
  for(var i in map){
    for(var j in map[i]){
      var t = 0;
      if(j < 0){
        if(map[j.slice(1)] && map[j.slice(1)][i])continue;
      }else{
        if(map[j] && map[j]["-"+i])t = pow(2,map[j]["-"+i])-1;
      }
      t += pow(2,map[i][j]);
      ans = mul(ans,t);
    }
  }
  return mput(ans-1+z);
}

Measured memory_bytes: 199612
n, t = map(int, input().split())
people = list(map(int, input().split()))
people.append(people[-1]+ t+1)
if n == 1:
    print(t)
else:
    time = 0
    for i in range(n+1):
        if i ==0:
            togire = False
            start = people[i]
            continue
        if people[i] - people[i-1] > t:
            togire = True
            time += people[i-1] - start + t
            start = people[i]
        else:
            togire = False
    print(time)

Measured memory_bytes: 26708
N, M = map(int, input().split())
MOD = 10 ** 9 + 7
if N > M:
    N, M = M, N
if abs(N - M) >= 2:
    print(0)
else:
    MOD = 10 ** 9 + 7
    P = 100005
    fact = [0] * P
    fact[0] = 1
    for i in range(1, P):
        fact[i] = fact[i - 1] * i
        fact[i] %= MOD

    if N == M:
        print(fact[N] * fact[M] * 2 % MOD)
    elif N + 1 == M:
        print(fact[N] * fact[M] % MOD)


Measured memory_bytes: 6900
#include<iostream>
using namespace std;
int main () {
char a,b;
cin>>a>>b;
if(a =='H'&& b =='D'){
    cout<<'D'<<endl;
}
else if(a=='D' && b=='H' ){
    cout<<'D'<<endl;
}
else if (a=='H' && b=='H'){
    cout<<'H'<<endl;
}
else {
    cout<<'H'<<endl;
}
}


Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<vector>
#include<stack> 
#include<cstdio>
using namespace std;
string a;
int main()
{
	vector<char>q;
	while(cin>>a)
	{
		int len=a.size();
		for(int i=0;i<len;i++)
		{
			if(a[i]=='0')
				q.push_back('0');
			else if(a[i]=='1')
				q.push_back('1');
			else if(!q.empty())	
				q.pop_back();
		}
		int j=q.size();
		for(int i=0;i<j;i++)
		{
			cout<<q[i];
		}
		cout<<endl;
	}
	return 0;
}

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

int main()
{
	long long a,b,c;
	cin >> a>>b>>c;
	if (a%2==0||b%2==0||c%2==0)
		cout << 0 << endl;
	else
		cout << min(a*b,min(a*c,b*c)) << endl;
	return 0;
}

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

string a[3];
int main(){
    rep(i, 3){
            cin >> a[i];
    }
    cout << a[0][0] <<a[1][1] << a[2][2] << endl;
}

Measured memory_bytes: 3624
#include<stdio.h>
#include<string.h>
int main(void)
{
	int a,s,d,f,g,h,j,i;
	char z[201],x[201];
	scanf("%s",z);
	while(z[0]!='-'){
		a=strlen(z);
		scanf("%d",&s);
		for(i=0;i<s;i++){
			scanf("%d",&d);
			f=a-d;
			for(j=0;j<d;j++){
				x[f]=z[j];
				f++;
			}
			g=0;
			for(j=d;j<a;j++){
				x[g]=z[j];
				g++;
			}
			for(j=0;j<a;j++){
				z[j]=x[j];
			}
		}
		printf("%s\n",z);
		scanf("%s",z);
	}
	return 0;
}

Measured memory_bytes: 1012
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		List<Integer> a = new ArrayList<>();
		int n = sc.nextInt();
		for(int i=0;i<n;i++) {
			int com = sc.nextInt();
			switch(com) {
			case 0:
				int x = sc.nextInt();
				a.add(x);
				break;
			case 1:
				x = sc.nextInt();
				System.out.println(a.get(x));
				break;
			case 2:
				a.remove(a.size()-1);
				break;
			}
		}
	}
}




Measured memory_bytes: 140176
n = int(input())
m,a,r,c,h = 0,0,0,0,0
for i in range(n):
    s = input()[0]
    if s=='M':m+=1
    elif s=='A':a+=1
    elif s=='R':r+=1
    elif s=='C':c+=1
    elif s=='H':h+=1
x = [m,a,r,c,h]
ans = 0
for i in range(5):
    for j in range(i):
        for k in range(j):
                ans += x[i]*x[j]*x[k]
print(ans)

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

#define pb push_back
#define mp make_pair
#define fs first
#define se second
#define pi 2*acos(0)
#define PI 3.14159265358979323846264338

typedef long long ll;
typedef unsigned long long ull;
typedef pair < int , int > pii;
typedef pair < ll , ll > pll;
const int N = 1000010;
const int MX = 123456;
const int mod = (int)1e9 + 7;
const int base = 1023456789;
const ull BS1 = 10000019ULL;
const int INF = (1 << 30);

template < class T > inline void fastScan(T &x){
    register char c = getchar();
    int neg = 0; x = 0;
    for(   ; (c < 48 || c > 57) && (c != '-'); c = getchar());
    if(c == '-') { neg = 1; c = getchar(); }
    for(   ; c > 47 && c < 58; c = getchar()){
        x = (x << 1) + (x << 3) + c - 48;
    }
    if(neg) x = -x;
}

int fx[]={1,-1,0,0};
int fy[]={0,0,-1,1};

int ans;
int n;

int inp[12];

void go(int pos, int hand){
    if(pos > n){
        if(hand % 2 == 0) ans++;
        return ;
    }
    go(pos + 1, hand * (inp[pos] - 1));
    go(pos + 1, hand * (inp[pos]));
    go(pos + 1, hand * (inp[pos] + 1));
}

int main(){
    fastScan(n);
    for(int i = 1; i <= n; i++){
        fastScan(inp[i]);
    }
    ans = 0;
    go(1, 1);
    printf("%d\n", ans);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+10;
const int INF=1e9+7;
int D[N];
int main()
{
	//freopen("/home/zz7/CFInput","r",stdin);
	int n,m;scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)D[i]=INF;
	for(int i=0;i<m;i++){
		int a,b;
		scanf("%d%d",&a,&b);
		D[a]=min(D[a],b);
	}int sum=0,L=-1;
	for(int i=1;i<=n;i++){
		if(D[i]!=INF){
			if(i<L)L=min(L,D[i]);
			else sum++,L=D[i];
		}
	}cout<<sum<<'\n';
}




Measured memory_bytes: 640
#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <utility>
#include <complex>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <tuple>
#include <bitset>
#include <limits>
#include <algorithm>
#include <array>
#include <random>
#include <complex>
#include <regex>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define fcout cout << fixed << setprecision(10)
#define rep(i,n)    for(int i=0; i<(int)n; i++)
#define mp(a,b) make_pair(a,b)
#define pb push_back
const ll inf = 1e18;
const ll mod = 1e9 + 7;



int main(){
    int n;
    string s;
    cin >> n >> s;
    int ans=0;
    rep(i, 10) rep(j, 10) rep(k, 10){
        int flag=0;
        for(int l=0; l<n; l++){
            int num = s[l]-'0';
            if( num == k && flag==2) flag=3;
            if( num == j && flag==1) flag=2;
            if( num == i && flag==0) flag=1;
            // printf("%d%d%d num=%d flag=%d\n", i,j,k, num, flag);
        }
        if(flag==3){
            ans++;
            // printf("%d%d%d flag=%d\n", i,j,k, flag);
        }
    }
    cout << ans << endl;
}
	


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

bool isKaibun(string s) {
  int l = s.size();
  for (int i = 0; i < l / 2; i++) {
    if (s.at(i) != s.at(l - i - 1))
      return false;
  }
  return true;
}

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

  int n = s.size();

  if (!isKaibun(s)) {
    cout << "No" << endl;
    return 0;
  }

  if (!isKaibun(s.substr(0, (n - 1) / 2))) {
    cout << "No" << endl;
    return 0;
  }

  if (!isKaibun(s.substr((n + 3) / 2 - 1, (n - 1) / 2))) {
    cout << "No" << endl;
    return 0;
  }

  cout << "Yes" << endl;
}

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

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

const ll mod =  1000000007;  //ansを出力する時は (ans % mod + mod) % mod とする(負の剰余を正にする)
const int inf = 1e9;
const long long INF = 1LL << 60;   // INFの値は1152921504606846976

int n;
vector<vector<pair<int,int>>> G;
vector<int> color;

void dfs(int now, int pre, int pre_color){
    int now_color = 1;
    for(auto next : G[now]){
        if(pre == next.first) continue;
        if(now_color == pre_color) now_color++;
        color[next.second] = now_color;
        dfs(next.first,now,now_color);
        now_color++;
    }
}

int main()
{
    cin >> n;
    G.resize(n);
    color.resize(n-1);
    rep(i,n-1){
        int a,b; cin >> a >> b;
        a--; b--;
        G[a].push_back({b,i});
        G[b].push_back({a,i});
    }
    int k = 0;
    rep(i,n){
        k = max(k,(int)G[i].size());
    }
    cout << k << endl;
    dfs(0,-1,-1);
    rep(i,n-1) cout << color[i] << endl;
}

Measured memory_bytes: 8320
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int H, W; cin >> H >> W;
    int cnt[26] = {};
    rep(i, H) {
        rep(j, W) {
            char c; cin >> c;
            cnt[c - 'a']++;
        }
    }
    sort(cnt, cnt + 26);
    int need1 = ((H % 2) && (W % 2));
    int need2 = ((H % 2) * W / 2 + (W % 2) * H / 2);
    int need4 = (H * W - need1 - need2 * 2) / 4;
    //cout << need1 << " " << need2 << " " << need4 << endl;
    rep(i, 26) {
        while(cnt[i] >= 4 && need4 > 0) {
            cnt[i] -= 4;
            need4--;
        }
        while(cnt[i] >= 2 && need2 > 0) {
            cnt[i] -= 2;
            need2--;
        }
        while(cnt[i] >= 1 && need1 > 0) {
            cnt[i]--;
            need1--;
        }
    }
    if (need4 == 0 && need2 == 0 && need1 == 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


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

#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1000000007
#define inf 1000000000000000001
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define f first
#define s second

using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

/*****************************************************START******************************************************************/


int main()
{
	std::ios::sync_with_stdio(false);
	cin.tie(0);
	int T = 1 ;
	 //cin >> T;
	// cin.ignore(); must be there when using getline(cin, s)
	while (T--)
	{
		int l,r,d , ans = 0; cin >> l >> r >> d;
		for(int i=l ; i<= r; i++){
			if(i%d == 0)ans++;
		}
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 3628
#include<iostream>
#include<stack>
using namespace std;
char och[] = { '0','i','x','c','m' };
int getn(const char * s)
{
	int result = 0;
	int i;
	int pfx;
	for (i = 0; s[i] != 0; i++)
	{
		pfx = 1;
		if (s[i] >= '2'&&s[i] <= '9')
			pfx = s[i++] - '0';
		switch (s[i])
		{
			case 'm':
				result += pfx * 1000;
				break;
			case 'c':
				result += pfx * 100;
				break;
			case 'x':
				result += pfx * 10;
				break;
			case 'i':
				result += pfx;
				break;
		}
	}
	return result;
}
void putn(int n)
{
	stack<int> s;
	int t = n;
	while (t != 0)
	{
		s.push(t % 10);
		t /= 10;
	}
	int i = s.size();
	while (!s.empty())
	{
		int t = s.top();
		s.pop();
		if (t == 0)
		{
			i--;
			continue;
		}
		if (t >= 2)
			printf("%d", t);
		printf("%c", och[i]);
		i--;
	}
	printf("\n");
}
int main()
{
	//freopen("input.txt", "r", stdin);
	int T;
	scanf("%d", &T);
	while(T--)
	{
		char str1[15], str2[15];
		int n1, n2;
		scanf("%s", str1);
		scanf("%s", str2);
		n1 = getn(str1);
		n2 = getn(str2);
		putn(n1 + n2);
	}
	return 0;
}

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

using namespace std;

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


int main(){
	while(true){
		int maxX,maxY;
		cin >> maxX >> maxY;			if(!maxX&&!maxY) return 0;

		int tizu[maxX+2][maxY+2];
		FOR(y,0,maxY+2){
			FOR(x,0,maxX+2){
				if(x==0||x==maxX+1||y==0||y==maxY+1){tizu[x][y]=1;continue;};
				cin >> tizu[x][y];
			}
		}

		int dp[maxX+2][maxY+2];
		FOR(y,0,maxY+2){
			FOR(x,0,maxX+2){
				dp[x][y]=0;
				if(x==0||x==maxX+1){
					continue;
				}
				if(y==0){
					continue;
				}
				if(y==1){
					if(tizu[x][y]==0) dp[x][y]+=1;
					continue;
				}
				if(y==maxY+1){
					if(tizu[x][y-1]==0) dp[x][y]+=dp[x][y-1];
					if(tizu[x][y-1]==2) dp[x][y]+=dp[x][y-1];
					if(tizu[x][y-2]==2) dp[x][y]+=dp[x][y-2];
					continue;
				}
				if(tizu[x][y]==0){
					if(tizu[x-1][y-1]==0) dp[x][y]+=dp[x-1][y-1];
					if(tizu[x][y-1]==0)   dp[x][y]+=dp[x][y-1];
					if(tizu[x+1][y-1]==0) dp[x][y]+=dp[x+1][y-1];
					if(tizu[x][y-2]==2)   dp[x][y]+=dp[x][y-2];
					continue;
				}
				if(tizu[x][y]==1){
					continue;
				}
				if(tizu[x][y]==2){
					if(tizu[x][y-1]==0) dp[x][y]+=dp[x][y-1];
					if(tizu[x][y-2]==2) dp[x][y]+=dp[x][y-2];
					continue;
				}
			}
		}
/*
		FOR(y,0,maxY+2){
			FOR(x,0,maxY+2){
				cout << dp[x][y];
			}
			cout << endl;
		}
*/


		int res = 0;
		FOR(x,1,maxX+1){ res += dp[x][maxY+1];};
		cout << res << endl;

	}
}

Measured memory_bytes: 1160
#include<stdio.h>
#include<stdlib.h>
int main()
{
int a, b, c, d;

scanf("%d", &a);
scanf("%d", &b);
scanf("%d", &c);
scanf("%d", &d);

if((abs(b - a) <= d)&&(abs(c - b) <= d) || (abs(a - c) <= d))
    printf("Yes\n");
else
    printf("No\n");
}

Measured memory_bytes: 128
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>


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

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

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



int main() {
    int x1, x2, y1, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    cout << x2 - (y2 - y1) << ' ' << y2 + (x2 - x1) << ' ' << x1 - (y2 - y1) << ' ' << y1 + (x2 - x1) << endl;
}

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

template<typename T>
ostream& operator<<(ostream &os, vector<T> &v){
	string sep = " ";
	if(v.size()) os << v[0];
	for(int i=1; i<v.size(); i++) os << sep << v[i];
	return os;
}

#ifdef DBG
void debug_(){ cout << endl; }
template<typename T, typename... Args>
void debug_(T&& x, Args&&... xs){
	cout << x << " "; debug_(forward<Args>(xs)...);
}
#define dbg(...) debug_(__VA_ARGS__)
#else
#define dbg(...)
#endif

int main() {
	ios_base::sync_with_stdio(false);
	cout << setprecision(20) << fixed;

	int a, b;
	cin >> a >> b;
	cout << a * b << endl;
	return 0;
}


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

using namespace std;

int main(){
    int n;
    string s;
    cin >> n;
    cin >> s;
    for (int i = 0; i < s.length(); i++){
        s[i] += n;
        if(s[i] > 90){
            s[i] -= 26;
        }
    }
    cout << s;
    return 0;
}


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

int main() {
  int N,M,sum = 0;
  
  cin >> N >> M;
  int A[M];
  for(int i = 0; i < M; i++){
    cin >> A[i];
  }
  
  for(int i = 0; i < M; i++){
    sum += A[i];
  }
  
  if(N < sum){
    cout << -1 << endl;
  }
  
  else{
    cout << N - sum << endl;
  }
  
  
}


Measured memory_bytes: 3632
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <memory>

//#define int long long

//#define ENABLE_TRACE
#ifdef ENABLE_TRACE
#define TRACE cout << __func__ << "()" << endl;
#define TRACE1(a) cout << __func__ << "(" << a << ")" << endl;
#define TRACE2(a, b) cout << __func__ << "(" << a << ", " << b << ")" << endl;
#else
#define TRACE
#define TRACE1(a)
#define TRACE2(a, b)
#endif  // #ifdef ENABLE_TRACE

using namespace std;

// Greatest Common Divisor
int Gcd(int a, int b) {
	TRACE2(a, b);
	if (a % b == 0) return b;
	return Gcd(b, a % b);
}

void Main()
{
	double l;
	cin >> l;
	cout << fixed << pow((l / 3), 3) << endl;
}

int32_t main()
{
	Main();
	return 0;
}



Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <string>

using namespace std;

int main()
{
	int n;
	
	scanf("%d", &n);
	
	while(n-- > 0){
		
		char num[10];
		
		scanf("%s", num);
		
		sort(num, num+8);
		
		int min;
		min = atoi(num);
		
		int max;
		reverse(num, num+8);
		max = atoi(num);
		
		printf("%d\n", max - min);
	}
}

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

using ll = long long int;
using bigint = int64_t;

#define pll pair<ll, ll>
#define vll vector<ll>
#define vpll vector<pll>
#define lob lower_bound
#define upb upper_bound
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define pf push_front
#define ins insert
#define mp make_pair
#define w(t) cin >> t;while(t--)
#define bitcount __builtin_popcount
#define endl "\n"
#define sz(s) (int)s.size()
#define mem(n,m) memset(n,m,sizeof(n))
#define deb(x) cout << #x << " = " << x << endl;
#define rep(i,n) for(ll i = 0; i <= n; i++)
#define ren(i,n) for(ll i = n-1; i >= 0; i--)
#define all(x) x.begin(),x.end()
#define fo(i, a, b) for(ll i = a; i <= b; i++)
#define ffo(i, a, b) for(ll i = a; i >= b; i--)
#define ffi(i,a,b,c) for(ll i = a ; i <= b ; i += c)
#define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
const int MOD = 1000000007;

void io_set() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}

void solve() {
    ll a, b, c, x, count = 0;
    cin >> a >> b >> c >> x;
    rep(i, a) {
        rep(j, b) {
            rep(k, c) {
                if(!i && !j && !k)  continue;
                ll total = (500 * i + 100 * j + 50 * k);
                if (total == x) {
                    count++;
                }
            }
        }
    }
    cout << count << endl;
}

int main() {
    IOS;
    //io_set();
    ll tt = 1;
    //cin >> tt;
    while (tt--) {
        solve();
    }
    return 0;
}

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

typedef long long LL;

#define FOR(i, a, b) for (int i = (a), i##_END_ = (b); i <= i##_END_; i++)
#define DNF(i, a, b) for (int i = (a), i##_END_ = (b); i >= i##_END_; i--)

template <typename Tp> void in(Tp &x) {
	char ch = getchar(), f = 1; x = 0;
	while (ch != '-' && (ch < '0' || ch > '9')) ch = getchar();
	if (ch == '-') ch = getchar(), f = -1;
	while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
	x *= f;
}

template <typename Tp> void out(Tp x) {
	if (x > 9) out(x / 10);
	putchar(x % 10 + '0');
	return;
}

template <typename Tp> Tp Max(const Tp &x, const Tp &y) {return x > y ? x : y;}
template <typename Tp> Tp Min(const Tp &x, const Tp &y) {return x < y ? x : y;}
template <typename Tp> bool chkmax(Tp &x, Tp y) {return x >= y ? 0 : (x=y, 1);}
template <typename Tp> bool chkmin(Tp &x, Tp y) {return x <= y ? 0 : (x=y, 1);}

const int MAXN = 1010;

int n, fa[MAXN], val[MAXN];
int head[MAXN], data[MAXN << 1], nxt[MAXN << 1], cnt;

int minx[2][MAXN];

void add(int x, int y)
{
	nxt[cnt] = head[x]; data[cnt] = y; head[x] = cnt++;
	nxt[cnt] = head[y]; data[cnt] = x; head[y] = cnt++;
}

int sb[2][2][5010];

void dfs(int now, int pa)
{
	for (int i = head[now]; i != -1; i = nxt[i]) {
		if (data[i] == pa) continue;
		dfs(data[i], now);
	}
	
	memset(sb, 0x3f, sizeof sb);

	bool is = 0;
	sb[0][0][0] = 0;
	sb[0][1][0] = 0;

	for (int i = head[now]; i != -1; i = nxt[i]) {
		if (data[i] == pa) continue;
		
		int X = val[data[i]], Y = minx[1][data[i]];

		is ^= 1;
		memset(sb[is], 0x3f, sizeof sb[is]);
		
		FOR(j, X, val[now]) chkmin(sb[is][0][j], sb[is ^ 1][0][j - X] + minx[0][data[i]]);
		FOR(j, Y, val[now]) chkmin(sb[is][0][j], sb[is ^ 1][0][j - Y] + val[data[i]]);

		X = val[data[i]]; Y = minx[0][data[i]];

		FOR(j, X, val[now]) chkmin(sb[is][1][j], sb[is ^ 1][1][j - X] + minx[1][data[i]]);
		FOR(j, Y, val[now]) chkmin(sb[is][1][j], sb[is ^ 1][1][j - Y] + val[data[i]]);
	}

	FOR(i, 0, val[now]) {
		chkmin(minx[0][now], sb[is][0][i]);
		chkmin(minx[1][now], sb[is][1][i]);
	}

	if (minx[0][now] == 0x3f3f3f3f && minx[1][now] == 0x3f3f3f3f) {puts("IMPOSSIBLE"); exit(0);}
}

int main()
{
	in(n);
	memset(head, -1, sizeof head);
	
	FOR(i, 2, n) in(fa[i]), add(fa[i], i);
	FOR(i, 1, n) in(val[i]);

	memset(minx, 0x3f, sizeof minx);
	
	dfs(1, 0);

	puts("POSSIBLE");
	
	return 0;
}


Measured memory_bytes: 384
//18, 08, 2018, 09:12:15 Rafaelcs cpp
#include <bits/stdc++.h>

using namespace std;
typedef pair<int, int> pii;
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    
    string s;   
    ll k;

    cin >> s >> k;

    for(int i = 0 ; i < s.length() ; i++){
        if(k == 1){
            cout << s[i] << endl;
            return 0;
        }else if(s[i] != '1'){
            cout << s[i] << endl;
            return 0;
        }else{
            k--;
        }
    }

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;


public class Main {

	static int[] memo;
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int n = s.nextInt();
		memo = new int[n+1];
		System.out.println(function(n));
	}

	public static int function(int n) {
		if(n==0 || n==1) {
			memo[n] = 1;
			return 1;
		}

		if(memo[n]!=0) {
			return memo[n];
		}else {
			memo[n] = function(n-1) + function(n-2);
		}
		return memo[n];
	}

}

Measured memory_bytes: 17356
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod 1000000007
main()
{
    ll n,i,ans=0;
    cin>>n;ll cnt=n;
    ll ara[n+1];
    for(i=1;i<=n;i++)cin>>ara[i];
    sort(ara+1,ara+n+1);
    for(i=n;i>=1;i--)
    {
        if(cnt==0)break;
       if(i==n)
       {
           cnt-=2;ans+=ara[i];continue;
       }
       if(cnt>=2)
       {
           ans=ans+2*ara[i];cnt-=2;
       }
       else
       {
           ans+=ara[i];cnt--;
       }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 5192
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define ArraySizeOf(array)     (sizeof(array) / sizeof(array[0]))
#define res(i,n) for(int i=n;;i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define REV(i,n) for(int i=n-1;i>0;i--)
#define req(i,n,m) for(int i=n;i<m;i++)
#define REQ(i,n,m,l) for(int i=n;i<m;i+=l) 
#define _GLIBCXX_DEBUG
int INF = 1e9 + 7;
unsigned NthDayOfWeekToDay(unsigned n, unsigned dow, unsigned dow1)
{
    unsigned day;
    if (dow < dow1) dow += 7;
    day = dow - dow1;
    day += 7 * n - 6;
    return day;
}
signed gcd(long long x, long long y) {
    if (y == 0)return x;
    return gcd(y, x % y);
}
signed lcm(long long x, long long y) {
    return x / gcd(x, y) * y;
}
unsigned DayToWeekNumber(unsigned day)
{
    return (day - 1) / 7 + 1;
}
unsigned AnotherDayOfWeek(unsigned day, unsigned day0, unsigned dow0)
{
    return (dow0 + 35 + day - day0) % 7;
}
using namespace std;
signed main() {
    string S; cin >> S;
    int a = 0;
    int b = 0;
    int c = 0;
    int d = 0;
    rep(i, S.size()) {
        if (S.at(i) == 'S')a=1;
        if (S.at(i) == 'N')b=1;
        if (S.at(i) == 'E')c=1;
        if (S.at(i) == 'W')d=1;
    }
    cout << (a == b && c == d ? "Yes" : "No") << endl;
}

Measured memory_bytes: 3584
#include <stdio.h>
#include <stdlib.h>

#define MOD_BY 1000000007

int add(int a, int b) {
	return a + b - MOD_BY * (a + b >= MOD_BY);
}

int mul(int a, int b) {
	int r = 0;
	while (b > 0) {
		if (b & 1) r = add(r, a);
		a = add(a, a);
		b >>= 1;
	}
	return r;
}

int pou(int a, int b) {
	int r = 1;
	while (b > 0) {
		if (b & 1) r = mul(r, a);
		a = mul(a, a);
		b >>= 1;
	}
	return r;
}

int inv(int a) {
	return pou(a, MOD_BY - 2);
}

int dexibu(int a, int b) {
	return mul(a, inv(b));
}

int kaizyou_cache_max = 0;
int* kaizyou_cache = NULL;

int kaizyou(int a) {
	if (a > kaizyou_cache_max) {
		int i;
		kaizyou_cache = realloc(kaizyou_cache, sizeof(int) * (a + 1));
		if (kaizyou_cache == NULL) exit(2);
		for (i = kaizyou_cache_max + 1; i <= a; i++) {
			kaizyou_cache[i] = mul(kaizyou_cache[i - 1], i);
		}
		kaizyou_cache_max = a;
	}
	return kaizyou_cache[a];
}

int main(void) {
	int X, Y;
	int a, b;
	kaizyou_cache = malloc(sizeof(int));
	if (kaizyou_cache == NULL) return 2;
	kaizyou_cache[0] = 1;
	if (scanf("%d%d", &X, &Y) != 2) return 1;
	a = 2 * X - Y;
	b = 2 * Y - X;
	if (a < 0 || b < 0 || a % 3 != 0 || b % 3 != 0) {
		puts("0");
		return 0;
	}
	a /= 3;
	b /= 3;
	printf("%d\n", dexibu(kaizyou(a + b), mul(kaizyou(a), kaizyou(b))));
	return 0;
}

/*

    a + 2 * b = X
2 * a +     b = Y

b = (2 * X - Y) / 3
a = (2 * Y - X) / 3

*/

/*

999999 333333

*/


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


#define li          long long int
#define uli         unsigned long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;


int main() {
    li res = 0;
    li n;
    cin >> n;
    li now = 1;
    rin{
        li a;
        cin >> a;
        if (now == a) {
            now++;
        } else{
            res++;
        }
    }
    cout << (res == n ? -1 : res) << endl;


    return 0;
}


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

using namespace std;
typedef long long LL;

#ifdef BTK
#define DEBUG if(1)
#else
#define CIN_ONLY if(1)
struct cww {cww() {CIN_ONLY{ios::sync_with_stdio(false); cin.tie(0);}}
}star;
#define DEBUG if(0)
#endif

#define ALL(v) (v).begin(),(v).end()
#define REC(ret, ...) std::function<ret (__VA_ARGS__)>
template <typename T>inline bool chmin(T &l, T r){bool a = l>r; if (a)l = r; return a;}
template <typename T>inline bool chmax(T &l, T r){bool a = l<r; if (a)l = r; return a;}
template <typename T>istream& operator>>(istream &is, vector<T> &v){for (auto &it : v)is >> it;return is;}

class range {private: struct I { int x; int operator*() { return x; }bool operator!=(I& lhs) { return x<lhs.x; }void operator++() { ++x; } }; I i, n;public:range(int n) :i({ 0 }), n({ n }) {}range(int i, int n) :i({ i }), n({ n }) {}I& begin() { return i; }I& end() { return n; }};
using V = vector<int>;
using VV = vector<V>;

int main() {
	int R, C;
	cin >> R >> C;
	VV a(R,V(C));
	cin >> a;
	V b, c, d, e;
	auto f=[&](int x,int y, int z, int w) {
		b.push_back(x+1);
		c.push_back(y+1);
		d.push_back(z+1);
		e.push_back(w+1);
		a[x][y]--;
		a[z][w]++;

	};
	for (int i : range(R)) {
		for (int j : range(C)) {
			if (a[i][j] % 2) {
				if (j < C - 1) {
					f(i, j, i, j + 1);
				}
				else if (i < R - 1) {
					f(i, j, i + 1, j);
				}
			}
		}
	}
	cout << b.size() << endl;
	for (int i : range(b.size())) {
		cout << b[i] << " ";
		cout << c[i] << " ";
		cout << d[i] << " ";
		cout << e[i] << endl;

	}
	return 0;
}


Measured memory_bytes: 5224
#include <bits/stdc++.h>
#define maxn 100005
#define mod 998244353
#define ll long long
using namespace std;

typedef pair<int, int> P;

int n;
vector<P> v[maxn];
bool c[maxn];
bool used[maxn];

void dfs(int now)
{
    used[now] = 1;
    for (int i = 0; i < v[now].size(); i++)
    {
        if (used[v[now][i].first])
            continue;
        int x = v[now][i].first;
        int w = v[now][i].second;
        if (w % 2 == 0)
            c[x] = c[now];
        else
            c[x] = !c[now];
        dfs(x);
    }
}

int main()
{
    cin >> n;
    for (int i = 0; i < n - 1; i++)
    {
        int x, y, w;
        scanf("%d%d%d", &x, &y, &w);
        v[x].push_back(P(y, w));
        v[y].push_back(P(x, w));
    }
    dfs(1);
    for (int i = 1; i <= n; i++)
        printf("%d\n", c[i]);

    return 0;
}

Measured memory_bytes: 8192
import sys
n=int(input())
lis=list(map(int,input().split()))
if 0 in lis :
  print(0)
  sys.exit()
x=1
for i in range(n):
  x*=lis[i]
  if  x>10**18:
    print(-1)
    sys.exit()
print(x)

Measured memory_bytes: 21644