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

const ll INF = 1LL << 60;
const ll MOD = ll(1e9)+7;


int main() {
    ll H, W, M;
    cin >> H >> W >> M;

    set<pair<ll, ll>> S;


    vector<ll> hnum(H,0);
    vector<ll> wnum(W,0);

    for (ll i = 0; i < M; i++) {
        ll a, b;
        cin >> a >> b;
        hnum.at(a-1)++;
        wnum.at(b-1)++;

        S.emplace(a, b);
    }

    ll hmax = 0;
    ll wmax = 0;
    vector<ll> hmaxindex;
    vector<ll> wmaxindex;
    
    for (ll i = 0; i < H; i++) {
        if (hnum.at(i) > hmax) {
            hmax = hnum.at(i);

            hmaxindex.clear();
            hmaxindex.shrink_to_fit();
            hmaxindex.emplace_back(i+1);
        } else if (hnum.at(i) == hmax) {
            hmaxindex.emplace_back(i+1);
        }

    }


    for (ll i = 0; i < W; i++) {
        if (wnum.at(i) > wmax) {
            wmax = wnum.at(i);

            wmaxindex.clear();
            wmaxindex.shrink_to_fit();
            wmaxindex.emplace_back(i+1);
        } else if (wnum.at(i) == wmax) {
            wmaxindex.emplace_back(i+1);
        }
    }

    ll ans = wmax + hmax - 1;


    for (ll i = 0; i < hmaxindex.size(); i++) {
        for (ll j = 0; j < wmaxindex.size(); j++) {
            
            bool is_dup = false;
            
            if (S.find({hmaxindex.at(i), wmaxindex.at(j)}) != S.end()) is_dup = true;

            if (!is_dup) {
                ans = wmax + hmax;
                cout << ans << endl;
                return 0;
            }
            
        }
    }
    
    

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

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

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

  int n, m;
  cin >> n >> m;
  vector<int> v(m);
  ll sum = 0;
  for (int i = 0; i < m; i++)
  {
    int a; cin >> a;
    v.at(i) = a;
    sum += a;
  }
  if(n < sum) cout << -1 << endl;
  else cout << n - sum << endl;

  return 0;
}

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

int l;
int x,y;
int tmp[25],sl=0;

int main ()
{
    //freopen("main.inp","r",stdin);
    //freopen("main.out","w",stdout);

    scanf("%d ",&l);

    int k=log2(l);

    while(l>0)
    {
        if(l%2==1)
            tmp[++sl]=x;
        x++;
        l/=2;
    }

    printf("%d %d\n",k+1,2*k-1+sl);

    for(int i=1; i<=k; ++i)
    {
        printf("%d %d %d\n",i,i+1,0);
        printf("%d %d %d\n",i,i+1,1<<(i-1));
    }

    y=1<<k;

    for(int i=1; i<sl; ++i)
    {
        printf("%d %d %d\n",tmp[i]+1,k+1,y);
        y+=1<<tmp[i];
    }
}


Measured memory_bytes: 256
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
bool ch(string s){
	int x=0;
	rep(i,s.size()){
		if(s[i]=='(') x++;else x--;
		if(x<0) return false;
	}
	return (x==0);
}
int main()
{
	int n,x=0;string s;cin>>n;
	cin>>s;
	rep(i,s.size()){
		if(s[i]=='(') x++;else x--;
	}
	if(x<0){
		rep(i,-x){
			s="("+s;
				//cout<<s<<endl;
		}
	}
		else if(x>0){
			rep(i,x) s+=")";
	}
	//cout<<s<<endl;
	while(!ch(s)) s="("+s+")";
	cout<<s<<endl;
}


Measured memory_bytes: 256
n=int(input())
a=["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","z"]
x=n
b=1
z=a[x%26-1]
x=x-26
while x>0:
    i=(x-1)//(26**b)
    y=i%26
    z+=a[y]
    b+=1
    x=x-(26**b)
t=z[::-1]
print(t)


Measured memory_bytes: 8972
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args)throws Exception{
        BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(input.readLine());
        boolean [] values = new boolean[101];
        int v;
        int count = 0;
        for (int i = 0; i < n; i++) {
            v = Integer.parseInt(input.readLine());
            if (!values[v])
                count++;
            values[v] = true;
        }
        System.out.println(count);
    }
}


Measured memory_bytes: 21460
#include <stdio.h>

int main(void){

  int n,m;
  int a,b;
  int i,j;

  for(;;){

    int map[21][21]={0},goable[21][21]={0};

    scanf("%d",&n);
    if(n==0)break;
    
    for(i=0;i<n;i++){
      scanf("%d %d",&a,&b); /*(a,b)???????????§?¨?(x,y)*/
      map[a][b]=1;
    }

    scanf("%d",&m);

    int x=10,y=10;
    char d;
    int l;
    (void)getchar();

    for(i=0;i<m;i++){
      scanf("%c %d",&d,&l);
      (void)getchar();
      if(d=='N'){
	for(j=0;j<=l;j++)goable[x][y+j]=1;
	y+=l;
      }
      else if(d=='E'){
	for(j=0;j<=l;j++)goable[x+j][y]=1;
	x+=l;
      }
      else if(d=='S'){
	for(j=0;j<=l;j++)goable[x][y-j]=1;
	y-=l;
      }
      else if(d=='W'){
	for(j=0;j<=l;j++)goable[x-j][y]=1;
	x-=l;
      }
    }

 
    int get=0;

    for(i=0;i<21;i++)
      for(j=0;j<21;j++)
	if(map[i][j]*goable[i][j]==1)
	  get++;

    if(get==n)puts("Yes");
    else puts("No");

  }

  return 0;
}

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

using namespace std;

int main()
{   
    int n;
    cin>>n;
    int a[n][3];
    for ( int i =0 ; i<= n-1; i++)
    {
        cin>>a[i][0]>>a[i][1]>>a[i][2];
    }
    int dp[n+1][3];
    memset(dp,0,sizeof(dp));
    dp[0][0] = a[0][0];
    dp[0][1] = a[0][1];
    dp[0][2] = a[0][2];
    for ( int i = 1; i<= n-1; i++)
    {
        for ( int j = 0; j<= 2; j++)
        {
            dp[i][j] = max(dp[i-1][(j+1)%3] + a[i][j],dp[i-1][(j+2)%3] + a[i][j] );
        }
    }
    cout<<max(dp[n-1][0], max(dp[n-1][1], dp[n-1][2]));
}


Measured memory_bytes: 5936
import java.util.*;

class Main
 {
	public static void main (String[] args)
	 {
        Scanner sc = new Scanner(System.in);
        long n, d;
        n = sc.nextLong();
        d = sc.nextLong();
        int ans = 0;
        for(int i = 0; i < n; i++) {
            long x, y;
            x = Math.abs(sc.nextLong());
            y = Math.abs(sc.nextLong());
            if(Math.sqrt(x*x + y*y) <= d) {
                ans++;
            }
        }
        System.out.println(ans);
	 }
}

Measured memory_bytes: 60456
n = int(input())
t, a = map(int,input().split())

h = list(map(int, (input().split())))
min = abs(a - (t - h[0]*0.006))
ans = 1

for i in range(1, n):
    if (min > abs(a - (t - h[i]*0.006))):
        min = abs(a - (t - h[i]*0.006))
        ans = i+1

print(ans)   

Measured memory_bytes: 3064
import sys
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt, ceil, floor
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache, reduce
from operator import xor
INF = float("inf")
sys.setrecursionlimit(10**7)

# 4近傍（右, 下, 左, 上）
dy = [0, -1, 0, 1]
dx = [1, 0, -1, 0]


def inside(y: int, x: int, H: int, W: int) -> bool: return 0 <= y < H and 0 <= x < W


color, depth, graph = [], [], {}
def func(v, d, c):
    if not color[v]:
        color[v] = c
    if depth[v] >= d or d == 0:
        return
    depth[v] = d
    for u in graph[v]:
        func(u, d - 1, c)


def main():
    global color, depth, graph
    N, M = map(int, input().split())
    graph = [[] for _ in range(N)]
    for _ in range(M):
        a, b = map(int, input().split())
        a -= 1
        b -= 1
        graph[a].append(b)
        graph[b].append(a)

    Q = int(input())
    q = []
    for _ in range(Q):
        v, d, c = map(int, input().split())
        q.append((v - 1, d, c))

    color = [0] * N
    depth = [0] * N
    for i in range(Q - 1, -1, -1):
        func(q[i][0], q[i][1], q[i][2])
    print(*color, sep="\n")

if __name__ == '__main__':
    main()


Measured memory_bytes: 39612
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
    return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
    return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
  ns = []
  while len(ns) < rantime:
    n = random.randint(ran1, ran2)
    if not n in ns:
      ns.append(n)
  return sorted(ns)

def rand_query(ran1, ran2, rantime):
  r_query = []
  while len(r_query) < rantime:
    n_q = rand_ints_nodup(ran1, ran2, 2)
    if not n_q in r_query:
      r_query.append(n_q)
  return sorted(r_query)

from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
import heapq
import math
from fractions import gcd
import random
import string
import copy
from itertools import combinations, permutations, product
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7

#############
# Main Code #
#############

N, K = getNM()
A = getList()

N_a = K - 1
root = N - 1

def judge(array):
    A_alta = copy.deepcopy(A)
    highest = A_alta[0]
    cnt = 0
    for i in range(1, N):
        if i in array and A_alta[i] <= highest:
            cnt += highest - A_alta[i] + 1
            A_alta[i] = highest + 1
            highest = A_alta[i]
        if A[i] > highest:
            highest = A[i]
    return cnt

ans = float('inf')
def comb_pow_2(i, array):
    global ans
    if i == N_a:
        ans = min(ans, judge(array))
        return
    # ここの4を変えてrootを変更
    last = 0
    if len(array) > 0:
        last = array[-1]

    for j in range(last + 1, root + 1):
        new_array = array + [j]
        comb_pow_2(i + 1, new_array)
comb_pow_2(0, [])
print(ans)

Measured memory_bytes: 87488
import java.util.Scanner;

/**
 * Created by khrom on 2017/06/17.
 */
public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int input = scanner.nextInt();
        for (int i = 3; i <= input; i++) {
            if (i % 3 == 0 || String.valueOf(i).contains("3")) System.out.print(" " + i);
        }
        System.out.println();
    }
}

Measured memory_bytes: 29224
#include<bits/stdc++.h>
#include <math.h>
#include <cmath>
#include <limits>
#include <iostream>
#include <assert.h>

#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
const ll INF=1000000000000000001;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};

int main(){

	int n;
	string s;
	string s2="ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ";
	string s3;

	cin>>n;
	cin>>s;
	rep(i,s.size()){
		rep(j,s2.size()){
			if(s[i]==s2[j]){
				s3+=s2[j+n];
				break;
			}
		}
	}
	cout<<s3<<endl;
	return 0;

}



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

int main()
{
	int k, n;
	while (1) {
		cin >> k;
		int 	c = k * (k - 1) / 2;
		int t = 0;
		if (k == 0)break;
		for (int i = 0; i < c; i++) {
			cin >> n;
			t += n;
		}
		cout << t / (k - 1) << endl;
	}
    return 0;
}



Measured memory_bytes: 3044
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

a,b,n = inpl()
x = min(b-1,n)
print(int((a*x)/b) - a*int(x/b))

Measured memory_bytes: 10500
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cmath>
#include <map>
#define ull unsigned long long
#define ll long long
using namespace std;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int ans=700;
    for(int i=0;i<3;i++){
        if(s[i]=='o'){
            ans+=100;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
using namespace std;
const int SIZEN = 100010;
typedef long long LL;
vector<int> v[SIZEN];
int col[SIZEN] = {0};
int N;
int plan[SIZEN] = {0},cnt = 0;
bool getstm(int x,int fa){
	if(x == N){plan[++cnt] = x;return true;}
	for(int i = 0;i < v[x].size();i++){
		int p = v[x][i];
		if(p == fa)continue;
		if(getstm(p,x)){plan[++cnt] = x;return true;}
	}
	return false;
}
queue<int> q;
int main(){
	scanf("%d",&N);
	if(N == 2){puts("Snuke");return 0;}
	for(int i = 1;i < N;i++){
		int s,t;scanf("%d%d",&s,&t);
		v[s].push_back(t);
		v[t].push_back(s);
	}
	memset(col,-1,sizeof col);
	getstm(1,0);
	reverse(plan+1,plan+1+cnt);
	int l = 1,r = cnt;
	col[1] = 0;col[N] = 1;
	int now = 1;
	while(l < r){
		l++;
		if(col[plan[l]]==-1){col[plan[l]] = 0;}
		else {now = 1;break;}
		r--;
		if(col[plan[r]]==-1){col[plan[r]] = 1;}
		else {now = 0;break;}
	}//for(int i = 1;i <= N;i++)printf("%d ",col[i]);printf("\n");
	for(int i = 1;i <= N;i++)if(col[i]!=-1)q.push(i);//for(int i = 1;i <= N;i++)printf("%d ",col[i]);printf("\n");
	while(!q.empty()){
		int now = q.front();q.pop();//printf("now = %d,col = %d\n",now,col[now]);
		for(int i = 0;i < v[now].size();i++){
			if(col[v[now][i]] == -1){col[v[now][i]] = col[now];q.push(v[now][i]);}	
		}
	}
	
	int black = 0,white = 0;
	for(int i = 1;i <= N;i++){
		black += col[i] == 0;
		white += col[i] == 1;
	}
	if(black > white)puts("Fennec");
	else if(black < white)puts("Snuke");
	else{
		if(now == 1)puts("Snuke");
		else puts("Fennec");
	}
	return 0;
}

Measured memory_bytes: 11520
#include <stdio.h>
char* F(char *b,int n,FILE *f){char *r=fgets(b,n,f);if(!r)return NULL;b[strlen(b)-1]=0;return r;}
char Q[29999],*q[9],L[29999];
n,old_indent=-1,depth=0;
main(){F(Q,sizeof(Q),stdin);q[0]=strtok(Q+1,".");for(n=1;;n++)if(!(q[n]=strtok(NULL,".")))break;for(;;){
	int indent=0;
	if(!F(L,sizeof(L),stdin))puts("no such property"),exit(0);
	for(;L[indent]==' ';indent++);
	if(old_indent>=indent)puts("no such property"),exit(0);
	char *name=strtok(L+indent,":"),*value=name+strlen(name)+1;
	if(!strcmp(name,q[depth]))if(old_indent=indent,depth++,depth==n)
		if(*value)printf("string \"%s\"\n",value+1),exit(0);
		else puts("object"),exit(0);
}}

Measured memory_bytes: 588
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<char, int> P;
const int mod = 1000000007;
const int INF = 1e12;

int dp[2010][2010][2];
int wIdx[2010][2010];
int bIdx[2010][2010];

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<P> d(2 * n);
    map<P, int> mp;
    rep(i, 0, 2 * n){
        cin >> d[i].first >> d[i].second;
        d[i].second--;
        mp[d[i]] = i;
    }
    rep(i, 0, n){
        wIdx[i][0] = mp[P('W', i)];
        bIdx[i][0] = mp[P('B', i)];
        rep(j, 0, 2 * n){
            if(d[j] == P('W', i)) break;
            if(d[j].first == 'W'){
                if(d[j].second < i){
                    wIdx[i][0]--;
                }
            }
        }
        rep(j, 0, 2 * n){
            if(d[j] == P('B', i)) break;
            if(d[j].first == 'B'){
                if(d[j].second < i){
                    bIdx[i][0]--;
                }
            }
        }
    }
    rep(i, 0, n){
        int nowbIdx = mp[P('B', i)];
        rep(j, 0, n){
            wIdx[j][i + 1] = wIdx[j][i];
            if(mp[P('W', j)] > nowbIdx) wIdx[j][i + 1]--;
        }
        int nowwIdx = mp[P('W', i)];
        rep(j, 0, n){
            bIdx[j][i + 1] = bIdx[j][i];
            if(mp[P('B', j)] > nowwIdx) bIdx[j][i + 1]--;
        }
    }
    
    rep(i, 0, n + 2) rep(j, 0, n + 2) rep(k, 0, 2) dp[i][j][k] = INF;
    dp[0][0][0] = dp[0][0][1] = 0;
    rep(i, 0, n + 1){
        rep(j, 0, n + 1){
            rep(k, 0, 2){
                //add white
                int nextIdx = i + j;
                if(i < n){
                    // dp[i + 1][j][0] = min(dp[i + 1][j][0], dp[i][j][k] + abs(nextIdx - wIdx[i][j]));
                    dp[i + 1][j][0] = min(dp[i + 1][j][0], dp[i][j][k] + wIdx[i][j]);
                    
                }
                //add black
                if(j < n){
                    dp[i][j + 1][1] = min(dp[i][j + 1][1], dp[i][j][k] + bIdx[j][i]);
                }
            }
        }
    }
    // rep(i, 0, n + 1){
    //     rep(j, 0, n + 1){
    //         rep(k, 0, 2){
    //             cout << i << ' ' << j << ' ' << k << ' ' << dp[i][j][k] << endl;
    //         }
    //     }
    // }
    int ans = min(dp[n][n][0], dp[n][n][1]);
    cout << ans << endl;
}

Measured memory_bytes: 126592
#include<bits/stdc++.h>
using namespace std;
const int N=3000+10;
int p=998244353,dp[N],n,s,x,ans;
int main(){
    scanf("%d%d",&n,&s);
    for(int i=1;i<=n;++i){
        scanf("%d",&x);
        dp[0]=i;
        for(int j=s;j>=x;--j)dp[j]=(dp[j]+dp[j-x])%p;
        ans=(ans+dp[s])%p;
    }
    printf("%d",ans);
    return 0;
}


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

int main(){
    int ab,bc,ca;
    cin>>ab>>bc>>ca;
    cout<<ab*bc/2<<endl;
}

Measured memory_bytes: 256
import sys
import math
import heapq
sys.setrecursionlimit(10**7)
INTMAX = 9223372036854775807
INTMIN = -9223372036854775808
DVSR = 1000000007
def POW(x, y): return pow(x, y, DVSR)
def INV(x, m=DVSR): return pow(x, m - 2, m)
def DIV(x, y, m=DVSR): return (x * INV(y, m)) % m
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def FLIST(n):
    res = [1]
    for i in range(1, n+1): res.append(res[i-1]*i%DVSR)
    return res

H,N=LI()
DP=[10**15]*(H+1)
DP[H] = 0
waza = [LI() for i in range(N)]

for i in range(N):
    for h in range(1, H+1)[::-1]:
        DP[max(0, h - waza[i][0])] = min(DP[max(0, h - waza[i][0])], DP[h] + waza[i][1])
print(DP[0])


Measured memory_bytes: 42732
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<string>
#include<functional>
#define rep(i,n,m) for(int i=(n);i<(int)(m);i++)
#define reps(i,n,m) for(int i=(n);i<=(int)(m);i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define fs first
#define sc second
#define lb lower_bound
#define ub upper_bound
#define LB(a,x) lb(all(a), x) - a.begin()
#define UB(a,x) ub(all(a), x) - a.begin()
#define printfdouble(x) printf("%.20f\n",(x))
#define chartoint(c) (int)((c) - '0')
#define chartoll(c) (long long)((c) - '0')
#define MOD 1000000007
#define itn int
#define enld endl
#define ednl endl
#define icn cin
#define cotu cout
#define Endl endl
#define stirng string
using namespace std;
typedef long long ll;
const double pi = 3.141592653589793;
using Graph = vector<vector<int>>;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return 1;} return 0;}
template<class T> bool chmin(T &a, const T &b){if(b<a){a=b; return 1;} return 0;}
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

struct edge{
    ll to;
    ll cost;
};

const ll INF = 1e18;

class Dijkstra {

public:
        vector<vector<edge>> graph; 
        vector<ll> dist;
        vector<ll> prev;


        Dijkstra(ll N){
            graph.resize(N);
            dist.resize(N, INF);
            prev.resize(N, -1);
        }

        void add_path(ll from, ll to, ll cost){
            graph[from].push_back({to, cost});
        }

        void solve(ll s){
            priority_queue<pair<ll,ll>, vector<pair<ll,ll>>, greater<pair<ll,ll>>> que;
            dist[s] = 0;
            que.push({0,s});

            while(!que.empty()){
                pair<ll,ll> v = que.top();
                que.pop();
                if(dist[v.second] < v.first) continue;
                rep(i,0,SZ(graph[v.second])){
                    edge e = graph[v.second][i];
                    if(dist[e.to] > dist[v.second] + e.cost){
                        dist[e.to] = dist[v.second] + e.cost;
                        prev[e.to] = v.second;
                        que.push({dist[e.to], e.to});
                    }
                }
            }
        }

        ll get_cost(ll v){
            return dist[v];
        }

        vector<ll> get_path(ll goal){
            vector <ll> path;
            for(ll cur = goal; cur != -1; cur = prev[cur]) path.push_back(cur); 
            reverse(all(path));
            return path;
        }
};


int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    ll N; cin >> N;
    Dijkstra G(N);
    rep(i,0,N-1){
        ll u,v,w; cin >> u >> v >> w;
        u--; v--;
        G.add_path(u,v,w);
        G.add_path(v,u,w);
    }

    G.solve(0);

    rep(i,0,N){
        if(G.get_cost(i) % 2 == 0){
            cout << 0 << enld;
        }else{
            cout << 1 << ednl;
        }
    }

    return 0;
}

Measured memory_bytes: 12352
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define fastio() ios_base::sync_with_stdio(false);
#define rmod(x, y) ((((x)%(y))+(y))%(y))
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef long double ld;
template<typename T, typename R = null_type, typename C = less<T>>
tree<T, R, C, rb_tree_tag, tree_order_statistics_node_update> ordered_set(){
	return tree<T, R, C, rb_tree_tag, tree_order_statistics_node_update>();
}

const int maxn = 1e4+5;
int n;
ll a[maxn], b[maxn];


int main(){
	scanf("%d", &n);
	ll dif = 0;
	for(int i = 0; i<n; i++) scanf("%lld", &a[i]), dif-= (ll)a[i];
	for(int i = 0; i<n; i++) scanf("%lld", &b[i]), dif+= (ll)b[i];
	if (dif<0 or (dif == 0 && !equal(a, a+n, b, b+n))) {puts("No"); return 0;}
	ll addcnt = 0;
	for(int i = 0; i<n; i++){
		if(a[i]<b[i]) {
			addcnt+= (b[i]-a[i]+1ll)/2ll;
			a[i] = b[i] + ((b[i]-a[i])%2ll);
		}
	}
	if (addcnt>dif) {puts("No"); return 0;}
	if (addcnt<dif) a[0] += 2ll*(dif-addcnt), addcnt = dif;
	for(int i = 0; i<n && addcnt>0; i++){
		if (b[i]<a[i]) {
			ll sub = min(a[i]-b[i], addcnt);
			b[i]+= sub;
			addcnt-= sub;
		}
	}
	if (equal(a, a+n, b, b+n)) puts("Yes");
	else puts("No");
	return 0;
}


Measured memory_bytes: 384
import sys, math
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial#, gcd
from bisect import bisect_left #bisect_left(list, value)
sys.setrecursionlimit(10**7)
enu = enumerate
MOD = 10**9+7
def input(): return sys.stdin.readline()[:-1]
def pri(x): print('\n'.join(map(str, x)))

N = int(input())
S = input()

Rs = []
Gs = []
Bs = []
for index, s in enu(S):
    if s == 'R':
        Rs.append(index+1)
    elif s == 'G':
        Gs.append(index+1)
    elif s == 'B':
        Bs.append(index+1)
#print(Rs, Gs, Bs)

cnt = len(Rs) * len(Gs) * len(Bs)
sBs = set(Bs)

for rr in Rs:
    for gg in Gs:
        r, g = sorted([rr, gg])

        pt1 = g + (g-r)
        pt2 = -1
        if (g-r)%2==0:
            pt2 = r + (g-r)//2
        pt3 = r - (g-r)

        chks = [val for val in [pt1, pt2, pt3] if val > 0]
        for chk in chks:
            if chk in sBs:
                cnt -= 1

print(cnt)



Measured memory_bytes: 9696
#include <stdio.h>
  
int main(void) {
    int a,b,c,i;
    int cnt;
    scanf("%d %d %d\n", &a, &b, &c);
    for(i=a,cnt=0;i<=b;i++) {
        if(c%i==0) cnt ++;
    }
    printf("%d\n", cnt);
      
    return 0;
}

Measured memory_bytes: 600
n =gets.to_i
a = gets.split.map(&:to_i).sort
cnt = Hash.new(0)

a.each do |v|
  cnt[v] += 1
end

if cnt.length == 1
  if cnt[0] == n
    puts "Yes"
  else
    puts "No"
  end
elsif cnt.length == 2 && n % 3 == 0
  puts cnt[0]==n/3 ? "Yes" : "No"
elsif cnt.length == 3 && n % 3 == 0
  flg = true
  cnt.each do |k,v|
    flg = false if v != n/3
  end
  k = cnt.keys
  30.times do |i|
    t = 0
    3.times do |j|
      t += k[j][i]
    end
    flg = false if !(t==2 || t==0)
  end
  puts flg ? "Yes" : "No"
else 
  puts "No"
end


Measured memory_bytes: 12592
#include<bits/stdc++.h>
#define yes cout<<"Yes"<<endl;
#define no cout<<"No"<<endl;
#define ll long long int
using namespace std;
int main()
{
    ll tc;
    ll a,b,c,n,x,y,z,cnt=0,sum=0;
    //cin>>n;for(int i=0;i<n;i++)cin>>arr[i];
    string str;
    cin>>str;


        if(str[0]=='R' && str[1]=='R' && str[2]=='S')
        {
            cout<<2<<endl;
        }
        else if( str[0]=='S'&&str[1]=='R' && str[2]=='R')
        {
            cout<<2<<endl;
        }else if(str[1]=='R' && str[2]=='R' && str[2]=='R')
        {
            cout<<3<<endl;
        }
        else if(str[0]=='S' && str[1]=='S' && str[2]=='S')
        {
            cout<<0<<endl;
        }
        else if(str[0]=='S' && str[1]=='R' && str[2]=='S')
        {
            cout<<1<<endl;
        }
        else cout<<1<<endl;



}



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

signed main() {
  int N;
  cin >> N;
  string S;
  cin >> S;
  
vector<string> num(1000);
for( int i = 0; i < 1000; i++ ){
if( i < 10 ) num.at(i) += "0";
if( i < 100 ) num.at(i) += "0";
num.at(i) += to_string(i);
}

int ans = 0;
bool one, two, san;
for( int i = 0; i < 1000; i++ ){
one = false;
two = false;
san = false;
for( int j = 0; j < N; j++ ){
if( one == false && S.at(j) == num.at(i).at(0) ) one = true;
else if( S.at(j) == num.at(i).at(1) && one == true && two == false ) two = true;
else if( S.at(j) == num.at(i).at(2) && one == true && two == true ) san = true;
}
if( one == true && two == true && san == true ){
ans++;
}
}

cout << ans << endl;
}

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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout<<setprecision(32);

	int n;
	cin>>n;
	vector<pair<int, int> > a[n];
	for(int i = 0; i < n; i++){
		int k; cin>>k;
		while(k--){
			int x, y;
			cin>>x>>y;
			x -= 1;
			a[i].push_back({x, y});
		}
	}
	int ans = 0;
	for(int mask = 0; mask < (1<<n); mask++){
		bool flg = true;
		for(int i = 0; i < n; i++){
			if(mask&(1<<i)){
				for(auto pp : a[i]){
					if(mask&(1<<pp.first)){
						if(!pp.second)flg = false;
					}else{
						if(pp.second)flg = false;
					}
				}
				if(!flg)break;
			}
		}
		if(flg)ans = max(ans, __builtin_popcount(mask));
	}
	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
typedef long long ll;

ll n;
ll dat[100005];
ll s1[100005];
ll s2[100005];

int main()
{
	ll a1 = 0;
	ll a2 = 0;

	scanf("%lld", &n);
	for (int i = 1; i <= n; i++) {
		scanf("%lld", &dat[i]);
	}

	for (int i = 1; i <= n; i++) {
		s1[i] = s1[i - 1] + dat[i];

		if (i & 1) {
			if (s1[i] <= 0) {
				a1 += llabs(s1[i] - 1);
				s1[i] = 1;
			}
		}
		else {
			if (s1[i] >= 0) {
				a1 += llabs(s1[i] + 1);
				s1[i] = -1;
			}
		}
	}

	for (int i = 1; i <= n; i++) {
		s2[i] = s2[i - 1] + dat[i];

		if (i & 1) {
			if (s2[i] >= 0) {
				a2 += llabs(s2[i] + 1);
				s2[i] = -1;
			}
		}
		else {
			if (s2[i] <= 0) {
				a2 += llabs(s2[i] - 1);
				s2[i] = 1;
			}
		}
	}

	printf("%lld\n", (a1 < a2 ? a1 : a2));

	return 0;
}


Measured memory_bytes: 2560
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int, int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
int dx[8] = { 1, 0, -1, 0, 1, -1, -1, 1 };
int dy[8] = { 0, 1, 0, -1, 1, 1, -1, -1 };
template <class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
struct io { io() { ios::sync_with_stdio(false); cin.tie(0); } };
const int INF = INT_MAX;
const ll LLINF = 1LL << 60;
const ll MOD = 1000000007;
const double EPS = 1e-9;

int main(void) {
	long long X;
	cin >> X;

	long long money = 100, year = 0;
	while (1) {
		if (money >= X) {
			cout << year << endl;
			return 0;
		}

		year++;
		money += money / 100;

	}

	return 0;
}

Measured memory_bytes: 3624
import java.util.*;
import java.io.*;
 
public class Main {
    public static void main (final String[] args) {
        final Scanner s = new Scanner(System.in);
      	int num = Integer.parseInt(s.next());
      
      	long result = 0;
      	
      	for(int i = 1; i <= num; i++)
          for(int j = 1; j <= num; j++)
            for(int k = 1; k <= num; k++) result += (long)(gcd(i,gcd(j,k)));
      	
      	System.out.println(result);
    }
  
  	public static int gcd(int x, int y) {
      	if (x < y) swap(x, y);
      	if (x % y == 0) return y;
      	else return gcd(y, x%y);
    }
  	
  	public static void swap(int x, int y) {
        int t = x;

        x = y;
        y = t;
    }
}

Measured memory_bytes: 35516
#include "iostream"
#include "vector"
#include "string"
#include "cstring"
using namespace std;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool black[50][50],white[50][50];
string in[50];
bool used[50][50];
int w,h;

void dfs(int y,int x,int f)
{
	if(f==1) white[y][x]=true;
	else black[y][x]=true;
	used[y][x]=true;
	for (int i = 0; i < 4; i++) {
		int nx=x+dx[i],ny=y+dy[i];
		if(0<=nx&&nx<w&&0<=ny&&ny<h&&!used[ny][nx]&&in[ny][nx]=='.')
			dfs(ny,nx,f);
	}
}

int main(void)
{
	while (cin>>w>>h,w) {
		memset(black,0,sizeof(black));
		memset(white,0,sizeof(white));
		for (int i = 0; i < h; i++) {
			cin>>in[i];
		}

		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				int f=0;
				if(in[i][j]=='W') f=1;
				else if(in[i][j]=='B') f=2;

				if(in[i][j]!='.')
				{
					memset(used,0,sizeof(used));
					dfs(i,j,f);
				}
			}
		}

		int Black=0,White=0;
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				if(in[i][j]!='B'&&black[i][j]&&!white[i][j]) Black++;
				else if(in[i][j]!='W'&&!black[i][j]&&white[i][j]) White++;
			}
		}
		cout<<Black<<" "<<White<<endl;
	}
	return 0;
}

Measured memory_bytes: 1316
s = input()
for i in range(len(s)):
    if i % 2 == 0:
        if s[i] != "R" and s[i] != "U" and s[i] != "D":
            print("No")
            break
    else:
        if s[i] != "L" and s[i] != "U" and s[i] != "D":
            print("No")
            break
else:
    print("Yes")


Measured memory_bytes: 3060
#include <atcoder/string>
#include <bits/stdc++.h>
using namespace std;
using namespace atcoder;
using ll = long long;

#define rep(i,n) for(ll i=0;(i)<(ll)n;(i)++)
const long long INF = 100000000000;

int main(){
  string s; cin >> s;
  vector<int> sa = suffix_array(s);
  auto lcp = lcp_array(s,sa);
  ll n = s.size();
  ll ans = n * (n+1) / 2;
  for(auto e : lcp){
    ans -= e;
  }
  cout << ans << endl;
  
}


Measured memory_bytes: 15604
#include<bits/stdc++.h>
#define MAX_N 100001
#define INF_INT 2147483647
#define INF_LL 9223372036854775807
#define REP(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
void init(int n);
int find(int n);
void unite(int x,int y);
bool same(int x, int y);
ll bpow(ll,ll,ll);
typedef vector<int> vec;
typedef vector<vec> mat;
mat mul(mat &A,mat &B);
mat pow(mat A,ll n);
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};


bool cmp_P(const P &a,const P &b){
  return a.second < b.second;
}
int main()
{
  ll N,a[200001],sum[200001],res=INF_LL; 
  cin >> N;
  REP(i,N)cin >> a[i];
  sum[0] = 0;
  REP(i,N)
    sum[i+1] = sum[i] + a[i];
  REP(i,N-1){
    res = min(res,abs(sum[N]-2*sum[i+1]));
  }
  cout <<  res << endl;
  
  
  return 0;
}

int par[MAX_N];
int ranks[MAX_N];

//n要素で初期化
void init(int n){
  REP(i,n){
    par[i] = i;
    ranks[i] = 0;
  }

}

//木の根を求める
int find(int x){
  if(par[x] == x){
    return x;
  }else{
    return par[x] = find(par[x]);
  }
}

void unite(int x,int y){
  x = find(x);
  y = find(y);
  if(x == y) return ;
  if(ranks[x] < ranks[y]){
    par[x] = y;
  }else{
    par[y] = x;
    if(ranks[x] == ranks[y]) ranks[x]++;
  }
}

bool same(int x, int y){
  return find(x) == find(y);
}

ll bpow(ll a, ll n,ll mod){
  int i = 0;
  ll res=1;
  while(n){
    if(n & 1)
      res = (res*a) % mod;
    a = (a*a) % mod;
    n >>= 1;
  }
  return res;
}
const int MOD = 1000000007;
mat mul(mat &A, mat &B){
  mat C(A.size(),vec(B[0].size()));
    REP(i,A.size())REP(k,B.size())REP(j,B[0].size()){
    C[i][j] = (C[i][j] + A[i][k] * B[k][j]) % MOD;
  }
  return C;
}

mat pow(mat A,ll n)
{
  mat B(A.size(),vec(A.size()));
  REP(i,A.size()){
    B[i][i] = 1;
  }
  while(n > 0){
    if ( n & 1) B = mul(B,A);
    A = mul(A,A);
    n >>= 1;
  }
  return B;
}


Measured memory_bytes: 3328
const main = (inputs) => {
  var array = inputs[0].split(" ");
  var X = Number(array);

  var num = 100;
  var count = 0;
  while (1) {
    var risoku = Math.floor(num * 0.01);
    num = num + risoku;
    count++;
    if (X <= num) break;
  }

  console.log(count);
}
main(require('fs').readFileSync('/dev/stdin', 'UTF-8').trim().split("\n"));

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

#define INIT_CAP 10
#define INF 1000000000

#define min(a, b) (((a) < (b)) ? (a) : (b))

typedef struct {
	int to, w;
} Edge;

typedef struct {
	Edge *elem;
	int cap, size;
} VecEdge;

typedef struct {
	int num, d;
} PairNumDis;

VecEdge adj[3600];
PairNumDis heap[32400];
int hsize;
int d[3600];

void init(int n) {
	while (n--)
		adj[n] = (VecEdge){malloc(sizeof(Edge) * INIT_CAP), INIT_CAP, 0};
}

void add(int from, int to, int w) {
	if (adj[from].size == adj[from].cap) {
		adj[from].cap <<= 1;
		adj[from].elem = realloc(adj[from].elem, sizeof(Edge) * adj[from].cap);
	}
	adj[from].elem[adj[from].size++] = (Edge){to, w};
}

void freeAll(int n) {
	while (n--)
		free(adj[n].elem);
}

void insert(int num, int d) {
	int i;
	for (i = hsize++; i > 0 && d < heap[i - 1 >> 1].d; i = i - 1 >> 1)
		heap[i] = heap[i - 1 >> 1];
	heap[i] = (PairNumDis){num, d};
}

int calcNextIdx(int i) {
	return i * 2 + 1 + (i * 2 + 2 < hsize && heap[i * 2 + 1].d > heap[i * 2 + 2].d);
}

PairNumDis delete(void) {
	int i;
	int nextIdx;
	const PairNumDis root = heap[0], last = heap[--hsize];

	for (i = 0; i * 2 + 1 < hsize && last.d > heap[nextIdx = calcNextIdx(i)].d; i = nextIdx)
		heap[i] = heap[nextIdx];
	heap[i] = last;

	return root;
}

void dijkstra(int n, int s) {
	int i;

	for (i = 0; i < n; i++)
		d[i] = INF;

	d[s] = 0;
	insert(s, 0);
	while (hsize > 0) {
		PairNumDis fromPair;

		fromPair = delete();
		if (fromPair.d > d[fromPair.num])
			continue;

		for (i = 0; i < adj[fromPair.num].size; i++) {
			Edge e = adj[fromPair.num].elem[i];
			if (fromPair.d + e.w < d[e.to]) {
				d[e.to] = fromPair.d + e.w;
				insert(e.to, d[e.to]);
			}
		}
	}
}

char field[60][30];

int main(void) {
	int i, j, k, l, m;
	int w, h;
	int min;

	while (scanf("%d %d", &w, &h), w) {
		for (i = 0; i < h; i++)
			for (j = 0; j < w; j++)
				scanf(" %c", field[i] + j);

		init(h * w * 2);
		for (i = 0; i < h; i++)
			for (j = 0; j < w; j++)
				for (k = 0; k < 2; k++)
					for (l = i - 2; l <= i + 2; l++)
						if (l >= 0 && l < h)
							for (m = (k ? j - 3 : j + 1); m <= (k ? j - 1: j + 3); m++)
								if (m >= 0 &&  m < w)
									if (abs(i - l) + abs(j - m) <= 3)
										if (field[l][m] == 'S' || field[l][m] == 'T')
											add(i * w + j + k * h * w, l * w + m + (k ^ 1) * h * w, 0);
										else if (field[l][m] != 'X')
											add(i * w + j + k * h * w, l * w + m + (k ^ 1) * h * w, field[l][m] - '0');

		min = INF;
		for (i = 0; i < w; i++)
			if (field[h - 1][i] == 'S')
				for (j = 0; j < 2; j++) {
					dijkstra(h * w * 2, (h - 1) * w + i + j * h * w);
					for (k = 0; k < w; k++)
						if (field[0][k] == 'T') {
							min = min(min, d[k]);
							min = min(min, d[k + h * w]);
						}
				}

		printf("%d\n", min == INF ? -1 : min);

		freeAll(h * w * 2);
	}

	return 0;
}

Measured memory_bytes: 1012
use std::io::*;
use std::cmp;

fn read<T: std::str::FromStr>() -> T {
    let stdin = stdin();
    let mut buf = String::new();
	stdin.lock().read_line(&mut buf);
	buf.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
	read::<String>().trim().split_whitespace()
        .map(|w| w.parse().ok().unwrap()).collect()
}

fn main() {
    let v = read_vec::<usize>();
    let (a,b,c) = (v[0],v[1],v[2]);
    let ea = a % 2;
    let eb = b % 2;
    let ec = c % 2;
    let s = ea + eb + ec;
    let max = cmp::max(cmp::max(a,b),c);
    let ds = 3 * max - a - b - c;
    let ans: usize;
    if s == 0 || s == 3 {
        ans = ds / 2;
    } else if s == 1 {
        if max%2 == 1 {
            ans = ds / 2;
        } else {
            ans = (ds + 3) / 2;
        }
    } else {
        if max%2 == 0 {
            ans = ds / 2;
        } else {
            ans = (ds + 3) / 2;
        }
    }
    println!("{}",ans);
}


Measured memory_bytes: 4352
a,b=map(int,input().split())
m=[0,2,0,1,0,1,0,0,1,0,1,0]
d=[31,30,28]
takahashi=0
for i in range(len(m)):
    for j in range(d[m[i]]):
        if i==j: takahashi+=1
        if a==i+1 and b==j+1: break
    if a==i+1: break
print(takahashi)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <numeric>
#include <set>
#include <list>
#include <bitset>
#include <cstdlib>
#include <map>
using ll = long long int;
using namespace std;

int main()
{
    int A, B;
    cin >> A >> B;
    if ((A <= 9) && (B <= 9))
    {
        cout << A * B << endl;
    }
    else
    {
        cout << -1 << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
sys.setrecursionlimit(1000000)
mod = 1000000007


#A
def A():
    a,b = LI()
    if not (a*b)%2:
        print("Even")
    else:
        print("Odd")
    return

#B
def B():
    s = S()
    print(s.count("1"))
    return

#C
def C():
    n = I()
    a = LI()
    f = 0
    for j in range(100000):
        for i in range(n):
            if a[i]%2:
                f = 1
                break
            a[i] //= 2
        if f:break
    print(j)
    return

#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == "__main__":
    C()


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

int main(void){
    // Your code here
    int h,w;
    cin>>h>>w;
    map<int,int> P1,P2;
    char maze[h][w];
    for(int i=0;i<h;i++){
        string s;
        cin>>s;
        for(int j=0;j<w;j++){
            maze[i][j]=s[j];
            if(maze[i][j]=='#'){
                P1[i]=1;
                P2[j]=1;
            }
        }
    }
    for(int i=0;i<h;i++){
        int rec=0;
        for(int j=0;j<w;j++){
            if(P1[i]==0 || P2[j]==0){rec++;continue;}
            cout<<maze[i][j];
        }
        if(rec!=w)cout<<endl;
    }
}

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

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

    for(int i = 0; i < k; i++){
        vector<int> after(n, 0);
        for(int j = 0; j < n; j++){
            after[max(0, j-a[j])]++;
            if(j+a[j]+1 < n) after[j+a[j]+1]--;
        }
        for(int j = 1; j < n; j++) after[j] += after[j-1];
        bool isalln = true;
        for(int i = 0; i < n; i++){
            a[i] = after[i];
            if(a[i] != n) isalln = false;
        }
        if(isalln) break;
    }

    for(int i = 0; i < n; i++){
        cout << a[i];
        if(i != n-1) cout << " ";
        else cout << endl;
    }
    return 0;
}

Measured memory_bytes: 4848
import Control.Monad
import Data.Bits
main = do
  [n,k] <- map read . words <$> getLine
  abs <- replicateM (fromInteger n) $ map read . words <$> getLine
  let f x = sum [b | [a,b] <- abs, x.|.a == x]
  print $ maximum $ f k : [
    f (clearBit k i .|. 2^i-1) | i <- [1..29], testBit k i]

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

#define sf scanf
#define pf printf
#define pb push_back
#define mp make_pair
#define PI ( acos(-1.0) )
#define mod 998244353LL
#define IN freopen("nocross.in","r",stdin)
#define OUT freopen("nocross.out","w",stdout)
#define FOR(i,a,b) for(i=a ; i<=b ; i++)
#define DBG pf("Hi\n")
#define INF 2000000000
#define i64 long long int
#define eps (1e-8)
#define xx first
#define yy second
#define off 2
#define sq(x) ((x)*(x))

using namespace __gnu_pbds;
using namespace std ;

typedef tree< pair<i64,i64>, null_type, less< pair<i64,i64> >, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

#define maxn 300005

int a[maxn] ;

int main()
{
    int i , j , k , l , m , n ;

    scanf("%d",&n) ;

    for(i=1 ; i<=n ; i++)
    {
        scanf("%d",&a[i]) ;
    }

    set<int> st ;
    map <int,int> M ;
    for(i=1 ; i<=n ; i++) st.insert( a[i] ) ;
    set <int> :: iterator it = st.begin() ;
    i =0 ;
    while( it != st.end() )
    {
        M[ *it ] = ++i ;
        it++ ;
    }

    for(i=1 ;  i<=n ; i++) a[i] = M[ a[i] ] ;

    int ans = 0 ;

    for(i=1 ; i<=n ; i++) ans += ( a[i]+i )%2 ;

    printf("%d\n",ans/2) ;

    return 0 ;
}


Measured memory_bytes: 10112
#include <iostream>

using namespace std;

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

	switch (N % 10) {
	case 2:
	case 4:
	case 5:
	case 7:
	case 9:
		cout << "hon" << endl;	break;
	case 0:
	case 1:
	case 6:
	case 8:
		cout << "pon" << endl;	break;
	case 3:
		cout << "bon" << endl;	break;
	}
	return 0;
}

Measured memory_bytes: 3608
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <cmath>
#include <ctime>
#include <vector>
#include <stack>

using namespace std;
////////////////*My library*////////////////////////
#define rep_to(a,i,n) for(int i=a;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define rep_r(i,n) for(int i=n-1;i>=0;i--)
#define debug(x) cout<<x<<endl
#define s_1(x) cin>>x
#define s_2(x,y) cin>>x>>y
////////////////////////////////////////////////////

////////////////////////
/*prime()*/
/*primecount()*/
/*sort()*/
/*imos???*/
/*????????¢?´¢*/
/*??±???????????¢?´¢*/
/*???????¨???????*/
///////////////////////
int main()
{
	int i=0,j=0;
	string str;
	char in[100][1000]={};
	vector<int>num[101];

	while(getline(cin,str))
	{
		int sum=0;
		rep(i,str.size()+1)
		{
			if(str[i]==',' || i==str.size())
			{
				num[j].push_back(sum);
				sum=0;
			}
			else if(str[i]!=',')
			{
				sum*=10;
				sum+=str[i]-'0';
			}
		}
		j++;
	}

	int dp[101][101]={};
	fill(dp[0],dp[101],0);

	dp[0][0]=num[0][0];

	rep_to(1,i,j)
	{
		rep(k,num[i].size())
		{
			dp[i][k]=num[i][k]+dp[i-1][k];
			if(i<=j/2 && k)dp[i][k]=max(dp[i][k],num[i][k]+dp[i-1][k-1]);
			if(i>j/2)dp[i][k]=max(num[i][k]+dp[i-1][k+1],dp[i][k]);
		}
	}
	cout<<dp[j-1][0]<<endl;
	return 0;
}

Measured memory_bytes: 1256
import queue
h,w,m = ( int(x) for x in input().split() )

h_array = [ 0 for i in range(h) ]
w_array = [ 0 for i in range(w) ]
ps = set()
for i in range(m):
    hi,wi = ( int(x)-1 for x in input().split() )
    h_array[hi] += 1
    w_array[wi] += 1
    ps.add( (hi,wi) )
h_great = max(h_array)
w_great = max(w_array)
h_greats = list()
w_greats = list()
for i in range( h ):
    if h_array[i] == h_great:
        h_greats.append(i)
for i in range( w ):
    if w_array[i] == w_great:
        w_greats.append(i)

ans = h_great + w_great - 1

escaper = False

for i in range( len(h_greats) ):
    hi = h_greats[i]
    for j in range( len(w_greats) ):
        wi = w_greats[j]
        if (hi,wi) not in ps:
            ans += 1
            escaper = True
            break
    if escaper:
        break

print(ans)

Measured memory_bytes: 84096
/* IN THE NAME OF ALLAH */
#include <bits/stdc++.h>
using namespace std;
int n,res,i;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
    cin>>n;
    int a[n],dp[n];
    for(i=0;i<n;i++)
    {
        cin>>a[i];
    }
    dp[0]=0;
    dp[1]=abs(a[0]-a[1]);
    for(i=2;i<n;i++)
    {
        dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]));
    }
    cout << dp[n-1] ;
    return 0;
}


Measured memory_bytes: 1024
n, l = map(int, input().split())
apple = list(range(l, l + n))
ans = 0
if 0 in apple:
  ans = sum(apple)
elif abs(apple[0]) < abs(apple[-1]):
  ans = sum(apple[1:])
else:
  ans = sum(apple[:-1])
print(ans)

Measured memory_bytes: 9116
n = int(input())
alst = list(map(int,input().split()))
alst.sort()
aj = alst[-1]
score = 10000000000
ai = -1
for i in range(n):
  s = abs(aj/2 - alst[i])
  if score > s:
    score = s
    ai = alst[i]
  else:
    print(aj,ai)
    break


Measured memory_bytes: 14432