akhauriyash/Code-Regression huggingface dataset:
import math


def nextString(text, p):
    if text[p] != 'z':
        text[p] = chr(ord(text[p])+1)
        return text
    else:
        text[p] = 'a'
        nextString(text, p - 1)

n = int(input())
base = 26

digit = math.floor(math.log(1+(base-1)*n, base))

position = int(n - (base**digit - 1) / (base  - 1))

txt = 'a' * digit

txt = list(txt)

for i in range(digit):
    txt[digit - i - 1] = chr(ord(txt[digit - i - 1])+(position % base))
    position = position // base

print(''.join(txt))


Measured memory_bytes: 8956
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;



int main(){
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    ll a,b;
    cin >> a >> b;
    if (a >= 13){
    	cout << b << endl;
    }
    else if (a >= 6){
    	cout << b/2 << endl;
    }
    else {
    	cout << 0 << endl;
    }
    cin >> a;
}

Measured memory_bytes: 256
#include <stdio.h>
int prime[1299710];
void SetPrime(int max){
    int i,o;
    for(i=4;i<=max;i+=2)
        prime[i]=1;
    for(i=3;i*i<=max;i+=2){
        if(prime[i]==0)
            for(o=i*2;o<=max;o+=i)
                prime[o]=1;
    }
}
int main(void){
    int num,sum,i;
    SetPrime(1299709);
    prime[0]=prime[1]=1;
    for(;scanf("%d",&num),num;){
        if(!prime[num])
            printf("0\n");
        else{
            for(sum=0,i=num;prime[i];i++,sum++);
            for(i=num-1;prime[i];i--,sum++);
            printf("%d\n",sum+1);
        }
    }
    return 0;
}

Measured memory_bytes: 5688
fun main(args: Array<String>) {
    // var numberTests = readLine()!!.toInt()
    // var results = mutableListOf<String>()

    // for (i in 0..numberTests-1) {
    var tmpLine = readLine()

    
    val result = experiment(tmpLine!!)
    // results.add(result)
    // }

    // for (result in results) {
        println(result)
    // }
}

fun experiment(input: String) : String {

    var result = if (isAtoZ(input)) "A" else "a"

    return result
}

fun isAtoZ(input: String) : Boolean {
    val regex = Regex(pattern = "[A-Z]")
    return regex.matches(input)
}

Measured memory_bytes: 35388
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size,n=1,init=nil) #nに配列の次元数、sizeに配列の大きさ、initに初期値を投げることでその配列を返す
  if n==1
    return Array.new(size){init}
  else
    return Array.new(n).map{Array.new(size){init}}
  end
end

loop do
  s=get_nsp
  break if s.join("")=="END OF INPUT"
  ans=[]
  cnt=0
  s.each do|c|
    unless c==" "
      cnt+=1
    else
      ans.push(cnt)
      cnt=0
    end 
  end
  ans.push(cnt)
  puts ans.join("")
end


Measured memory_bytes: 6876
// 
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <stack>
#include <queue>
#include <iomanip>
#include <set>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;

int main()
{
    int K, T;
    cin >> K >> T;
    vector<int> a(T);
    for (int i = 0; i < T; ++i) cin >> a[i];
    if (T == 1)
    {
        cout << a[0] - 1 << endl;
        return 0;
    }
    sort(a.begin(), a.end(), std::greater<int>());
    if (a[0] == a[1] || a[0] == a[1] + 1 )
    {
        cout << 0 << endl;
        return 0;
    }
    int s = 0;
    for (int i = 1; i < T; ++i)
    {
        s += a[i];
    }
    int ans = (s - a[0] + 1) >= 0 ? 0 : a[0] - s - 1;
    cout << ans << endl;
    return 0;
}

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

int main()
{
    int h,w;
    while(cin>>h>>w)
    {
        if(w==0)return 0;
        REP(i,w)cout<<"#";
        cout<<endl;
        REP(i,h-2)
        {
            REP(j,w)
            {
                if(j==0||j==w-1)cout<<"#";
                else cout<<".";
            }
            cout<<endl;
        }
        REP(i,w)cout<<"#";
        cout<<endl;
        cout<<endl;
    }
}




Measured memory_bytes: 3072
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <vector>
#include <queue>
#include <random>
#include <cstdint>
#include <bitset>
#include <iomanip>
#include <utility>
#include<map>
#include<functional>
#include<climits>
using namespace std;
typedef long long ll;
const int mod = 1000000007;

int main() {
	int a=0, b=0;
	string s;
	cin >> s;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == '0')a++;
		else b++;
	}
	cout << s.size() - abs(a - b) << endl;
}



Measured memory_bytes: 512
#include<stdio.h>
bool cr[1<<10];
bool t[10][10000],ft[10][10000];
int r,c;
int i,j;
int n;
int ct;
int tot;
int ans;

int max(int a,int b){
	if(a>=b)return a;
	else return b;
}

int main(){
	while(1){
		scanf("%d %d",&r,&c);
		if(r==0&&c==0)return 0;
		ans=-1;
		for(i=0;i<r;i++){
			for(j=0;j<c;j++){
				scanf("%d",&n);
				ft[i][j]=(n==1);
			}
		}
		for(i=0;i<r;i++)for(j=0;j<c;j++)t[i][j]=ft[i][j];
		for(i=0;i<1<<r;i++){
			tot=0;
			for(j=0;j<r;j++){
				if((i>>j)&1)for(int k=0;k<c;k++)t[j][k]=!t[j][k];
			}
			for(j=0;j<c;j++){
				ct=0;
				for(int k=0;k<r;k++)if(t[k][j])ct++;
				if(ct>(int)r/2)for(int k=0;k<r;k++)t[k][j]=!t[k][j];
				for(int k=0;k<r;k++)if(!t[k][j])tot++;
			}
			ans=max(ans,tot);
			for(j=0;j<r;j++)for(int k=0;k<c;k++)t[j][k]=ft[j][k];
		}
		printf("%d\n",ans);
	}
}

Measured memory_bytes: 1224
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,W;
  cin >> N >> W;
  long long v[110];
  long long w[110];
  long long dp[110][100010]={0};
  for(int i=0;i<N;i++){
    cin >> w[i] >> v[i];
  }
  for(int i=0;i<N;i++){
    for(int j=0;j<W+1;j++){
      if(j>=w[i]){
        dp[i+1][j]=max(dp[i][j-w[i]]+v[i],dp[i][j]);
      }
      else{
        dp[i+1][j]=dp[i][j];
      }
    }
  }
  cout << dp[N][W] << endl;
}

Measured memory_bytes: 86144
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
#include <map>
using namespace std;

int main() {
	int N, D, X, *a, sum = 0;

	cin >> N >> D >> X;;

	a = new int[N];

	for (int i = 0; i < N; i++) {
		cin >> a[i];
	}

	for (int i = 0; i < N; i++) {
		sum += (D - 1) / a[i] + 1;
	}

	cout << sum + X;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
using namespace std;
int main() {
  int n,x,a,b=0;
  bool flag = false;
  cin >> n;
  if(ceil(log10(n)) == floor(log10(n))){
      cout << 10 << endl;
      flag = true;
  }
  if(!flag){
    while(n){
      a = n%10;
      b += a;
      n /= 10;
    }
    cout << b << endl;
  }
}

Measured memory_bytes: 384
def a_good_integer(N):
    if N[0] == N[1] and N[1] == N[2]:
        return('Yes')
    elif N[1] == N[2] and N[2] == N[3]:
        return('Yes')
    else:
        return('No')
      
N = input()
print(a_good_integer(N))

Measured memory_bytes: 3060
/******tech_knight18_@11******/
/*I'm_not_the_only_traveller*/
/*who_has_not_repaid_his_debt*/
/*Take_me_back_to_The_Night_We_Met*/
#include<bits/stdc++.h>
using namespace std;
#define lld               long long int
#define ld                long double
#define pb                push_back
#define ppb               pop_back
#define mp                make_pair
#define F                 first
#define S                 second
#define nl                '\n'
#define all(c)            (c).begin(),(c).end()
#define rall(c)           (c).rbegin(),(c).rend()
#define sz(c)             (c).size()
#define tr(x,a)           for(auto &a : x)
#define psnt(x,a)         (x).find(a)!=(x).end()
#define vpsnt(x,a)        find(all(x),a)!=(x).end()
#define lexichar(x,y)     lexicographical_compare(x,x+strlen(x),y,y+strlen(y)) //modify the ranges
#define lexistr(x,y)      lexicographical_compare(x.begin(),x.end(),y.begin(),y.end()) 
#define MOD               1000000007
#define pi                3.1415926536
#define tod               1
#define itr(i,a,b)        for(lld i=a;i<=b;i++)
#define itrn(i,a,b)       for(lld i=a;i>=b;i--)
#define iot(n)            for(lld i=0;i<n;i++)
#define pls(n,arr)        lld arr[n]; iot(n)  cin>>arr[i];
#define bye               fflush(stdout)

typedef pair<lld,lld>     pii;
typedef pair<string,lld>  psi;
template <typename T>
bool mycomp(T x,T y){ 
   return (x==y);  //give your condition here
}
bool paircomp(const pair<lld,lld> &x,const pair<lld,lld> &y){ 
return x.second<y.second;
}

int main(){
       ios_base::sync_with_stdio(false);
             cin.tie(0);
            cout.tie(0);
      lld t=1; //cin>>t;  
      while(t--){
          lld n; cin>>n;
          lld hash[n+1]={0};
          for(lld i=1;i<=800;i++)
          {
              for(lld j=1;j<=800;j++){
                  for(lld k=1;k<=800;k++){
                      if(i*i+j*j+k*k+i*j+i*k+j*k>n) continue;
                      hash[i*i+j*j+k*k+i*j+i*k+j*k]++;
                  }
              }
          }
          itr(i,1,n)
            cout<<hash[i]<<nl;
          
      }
}


Measured memory_bytes: 3580
a = list(input())
b = list(input())
c = list(input())
d = "a"
while True:
    if d == "a":
        if len(a) == 0:
            print("A")
            exit()
        else:
            d = a.pop(0)
    elif d == "b":
        if len(b) == 0:
            print("B")
            exit()
        else:
            d = b.pop(0)
    elif d == "c":
        if len(c) == 0:
            print("C")
            exit()
        else:
            d = c.pop(0)


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



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

    vector<string> s(N);

    for(int i=0;i<N;i++){
        cin>>s.at(i);
        sort(s.at(i).begin(),s.at(i).end());
    }
    sort(s.begin(),s.end());

    long long co=0;
    long long sum=0;
    for(int i=1;i<N;i++){
        if(s.at(i)==s.at(i-1)){
            co++;
        }else{
            sum += (co*(co+1)/2);
            co=0;
        }
        if(i==N-1){
            sum += (co*(co+1)/2);
        }
    }
    cout<<sum<<endl;
}

Measured memory_bytes: 7296
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define db double
#define pint pair<int,int>
#define mk(x,y) make_pair(x,y)
#define fir first
#define sec second
#define Rep(x,y,z) for(int x=y;x<=z;x++)
#define Red(x,y,z) for(int x=y;x>=z;x--)
using namespace std;
const int Mod=998244353,Inv2=(Mod+1)/2;
char buf[1<<12],*pp1=buf,*pp2=buf,nc;int ny;
inline char gc() {return pp1==pp2&&(pp2=(pp1=buf)+fread(buf,1,1<<12,stdin),pp1==pp2)?EOF:*pp1++;}
//inline char gc(){return getchar();}
inline int read(){
	int x=0;for(ny=1;nc=gc(),(nc<48||nc>57)&&nc!=EOF;)if(nc==45)ny=-1;if(nc<0)return nc;
	for(x=nc-48;nc=gc(),47<nc&&nc<58&&nc!=EOF;x=(x<<3)+(x<<1)+(nc^48));return x*ny;
}int n,len,P[1<<18],S[1<<18],F[1<<18],Sump;
inline int Fp(int x,int k){int ans=1;for(;k;k>>=1,x=1ll*x*x%Mod)if(k&1)ans=1ll*ans*x%Mod;return ans;}
inline void Div(int&x){if(x&1)x=1ll*x*Inv2%Mod;else x>>=1;}
inline int Add(int x,int y){return x+y>=Mod?x+y-Mod:x+y;}
inline int Sub(int x,int y){return x<y?x-y+Mod:x-y;}
inline void FWT(int*F,int len,int opt){
	for(int i=1;i<len;i<<=1)for(int j=0;j<len;j+=i<<1)for(int k=0;k<i;k++){
		int x=F[i+j+k],y=F[j+k];F[j+k]=Add(x,y),F[i+j+k]=Sub(y,x);if(opt==-1)Div(F[j+k]),Div(F[i+j+k]);
	}
}
int main(){
//	freopen("std.in","r",stdin);
//	freopen("std.out","w",stdout);
	n=read(),len=1<<n;
	Rep(i,0,len-1)P[i]=read(),Sump=(Sump+P[i]);Sump=Fp(Sump,Mod-2);
	Rep(i,0,len-1)P[i]=1ll*P[i]*Sump%Mod;P[0]==0?P[0]=Mod-1:P[0]--;
	Rep(i,0,len-1)S[i]=Mod-1;S[0]=len-1;FWT(S,len,0),FWT(P,len,0);
	Rep(i,0,len-1)F[i]=1ll*S[i]*Fp(P[i],Mod-2)%Mod;FWT(F,len,-1);
	int tmp=Mod-F[0];Rep(i,0,len-1)cout<<(tmp+F[i])%Mod<<"\n";
	return 0;
}




Measured memory_bytes: 6520
//ABC155A
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <climits>
#include <cfloat>
#include <string>
#include <unordered_map>
using namespace std;

int main(){
	int a, b, c;
	cin >> a >> b >> c;
	set<int> x;
	x.insert(a);
	x.insert(b);
	x.insert(c);
	if(x.size() == 2){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
#define ALL(a)  (a).begin(),(a).end()
 
const ll mod = 1000000007;
const ll LINF = 1e13;
const ll LLINF = 1e18;
const ll ALPHABET = 26;
 
template <class T>
void Swap(T& r, T& l) {
  T tmp = r;
  r = l;
  l = tmp;
}
 
template<typename T>
istream& operator >> (istream& is, vector<T>& vec) {
  for (T& x : vec) is >> x; //for(int i=0; i<vec.size(); i++) is >> x[i]; とかでもいい
  return is;
}


int main(){
    ll n;
    cin >> n;
    vector<ll>p(n);
    cin >> p;


    ll ans = 0;

    for (ll i = 1; i < n -1; i++){
      if (p[i] >p[i+1]){
        if (p[i] < p[i-1])ans++;
      }
      if (p[i] > p[i-1]){
        if (p[i] < p[i+1])ans++;
      }
    }

    cout << ans;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 100;
ll a[N], b[N];
int main()
{
    ll n;
    cin >> n;
    for(ll i=1; i<=n; i++)
    {
        cin >> a[i];
        b[a[i]] = i;
    }
    ll cnt = 0;
    for(ll i=1; i<=n; i++)
    {
        if(b[i] != i)
        {
            cnt++;
        }
    }
    if(cnt>2)
    {
        cout << "NO" << endl;
    }
    else
    {
        cout << "YES" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<cstdio>
#include<utility>
#include<algorithm>
#include<map>
#include<set>
using namespace std;
#define rep(i,x,n) for(int i=x;i<n;i++)
#define all(L) L.begin(),L.end()
using ll=long long;

int N,M;
int X[100],Y[100],h[100];

void gcl(int& x,int& y){
    if(x<y) swap(x,y);
    while(y>0){
        int t=x%y;
        x=y;
        y=t;
    }
    return;
}


int main(){
    int n;cin>>n;
    vector<int> A(n);
    vector<int> B(n);
    vector<int> C(n);
    rep(i,0,n) cin>>A[i];
    rep(i,0,n) cin>>B[i];
    rep(i,0,n) cin>>C[i];
    sort(all(A),greater<int>());
    sort(all(B),greater<int>());
    sort(all(C),greater<int>());
    ll ans=0;
  ll b[n];
    int i=0,j=0,k=0;
    rep(i,0,n){
      
        while(B[j]>A[i]&&j<n){
            while(C[k]>B[j]&&k<n){
                k++;
            }
          b[j]=k;
          if(j!=0) b[j]+=b[j-1];
            j++;
        }
      if(j!=0) ans+=b[j-1];
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 2176
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE NumDecimals #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}

import Control.Applicative
import Control.Arrow
import Control.Monad
import Control.Monad.ST

import Data.Char
import Data.List
import Data.Maybe

import qualified Data.ByteString.Char8 as B

import Data.Array.ST.Safe
import Data.STRef

import Debug.Trace
import Text.Printf

readInt = readLn :: IO Int
readInteger = readLn :: IO Integer
readInts = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine
readIntegers = map ( fst . fromJust . B.readInteger ) . B.words <$> B.getLine

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

modifyArray a i f = writeArray a i =<< f <$> readArray a i

main = readInt >>= print . ( ^ 3 )

Measured memory_bytes: 508
#include <iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<string>
#include<math.h>

using namespace std;

struct node{
 int x;
 int time;
 bool operator <(node &B)
 {
     if(time<B.time) return true;
     if(time==B.time) return x<B.x;
     return false;
 }
};
int main()
{
    int n;cin>>n;
    set<int>nums;
    for(int i=0;i<n;i++)
{
    int a;
    cin>>a;
    if(nums.count(a))
    {
        nums.erase(a);
    }else
    nums.insert(a);
}
cout<<nums.size()<<endl;


return 0;
}



Measured memory_bytes: 4864
import java.util.Scanner;

public class Main {
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        while(true){
            int n = sc.nextInt();
            int x = sc.nextInt();
            int i = 1, j = 2, k = 3, co = 0;

            if(n==0 && x==0) break;
            for(i=1; i<=n-2; i++){
                for(j=i+1; j<=n-1; j++){
                    for(k=j+1; k<=n; k++){
                        if(i+j+k == x) co++;
                    }
                }
            }

            System.out.println(co);
            
        }
    }   
}


Measured memory_bytes: 26484
from math import *
h,w=map(int,input().split())
if h%3==0 or w%3==0:
    print(0)
    exit()
t=h*w/3
a=[floor(w/3),ceil(w/3)]
b=[floor(h/2),ceil(h/2)]
c=[floor(h/3),ceil(h/3)]
d=[floor(w/2),ceil(w/2)]
ans=float("inf")
for i in a:
    for j in b:
        a1=i*h
        a2=j*(w-i)
        a3=(h-j)*(w-i)
        tmp=max(abs(a1-a2),abs(a1-a3),abs(a3-a2))
        if tmp<ans:
            ans=tmp
for i in c:
    for j in d:
        a1=w*i
        a2=(h-i)*j
        a3=(w-j)*(h-i)
        tmp=max(abs(a1-a2),abs(a1-a3),abs(a3-a2))
        if tmp<ans:
            ans=tmp
for i in a:
    a1=i*h
    a2=i*h
    a3=h*w-a1-a2
    tmp=max(abs(a1-a2),abs(a1-a3),abs(a3-a2))
    if tmp<ans:
        ans=tmp
for i in c:
    a1=i*w
    a2=i*w
    a3=h*w-a1-a2
    tmp=max(abs(a1-a2),abs(a1-a3),abs(a3-a2))
    if tmp<ans:
        ans=tmp
print(ans)

Measured memory_bytes: 9276
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {

            //入力した値を数値変換する
            string str = Console.ReadLine();
            string[] strArray = new string[3];
            strArray = str.Split(' ');
            int[] intArray = Array.ConvertAll(strArray, int.Parse);

            int intSum = 0;

            // 確認用コード
            // 確認用コード
            var perm = new Permutation();
            var intList = new List<int>();

            foreach (var n in perm.Enumerate(new[] { 0, 1, 2 }))
            {
                intSum = intArray[n[0]] + Math.Abs(intArray[n[0]]- intArray[n[1]] ) + Math.Abs(intArray[n[1]]- intArray[n[2]])- intArray[n[0]];
                intList.Add(intSum);
            }


            intList.Sort();

            Console.WriteLine(intList[0]);

            

        }
    }

    public class Permutation
    {
        public IEnumerable<T[]> Enumerate<T>(IEnumerable<T> items)
        {
            return _GetPermutations<T>(new List<T>(), items.ToList());
        }

        private IEnumerable<T[]> _GetPermutations<T>(IEnumerable<T> perm, IEnumerable<T> items)
        {
            if (items.Count() == 0)
            {
                yield return perm.ToArray();
            }
            else
            {
                foreach (var item in items)
                {
                    var result = _GetPermutations<T>(perm.Concat(new T[] { item }),
                                                        items.Where(x => x.Equals(item) == false)
                                    );
                    foreach (var xs in result)
                        yield return xs.ToArray();
                }
            }
        }
    }
}


Measured memory_bytes: 28288
#include <bits/stdc++.h>
using namespace std;
#define N 1000
int c[N+1];
int a[N+1];
int main() {
	int n;
	cin >> n;
	for(int i = 1; i <= n; i++) {
		cin >> c[i];
		a[i] = 0;
	}
	int q;
	cin >> q;
	while(q--) {
		int t, x, d;
		cin >> t >> x >> d;
		if(t == 1) {
			a[x] += d;
			if(a[x] > c[x]) {
				cout << x << endl;
				return 0;
			}
		} else {
			a[x] -= d;
			if(a[x] < 0) {
				cout << x << endl;
				return 0;
			}
		}
	}
	cout << 0 << endl;
	return 0;
}


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

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

  int n;
  cin >> n;

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

  int count = 0;
  bool flag = false;
  while (1) {
    for (int i = 0; i < n; i++) {
      if (a[i] % 2 == 1) {
        flag = true;
        break;
      } else {
        a[i] = a[i] / 2;
      }
    }

    if (flag) {
      break;
    }

    count++;
  }

  cout << count << '\n';

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define fore(i, l, r) for (int i = (int)(l); i <= (int)(r); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;

int main(){
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    string s, p;
    cin >> s >> p;
    vector<string> sList;

    int index = 0;
    while(true){
        index = s.find(p[0], index);
        if(index == -1) break;
        sList.push_back(s.substr(index) + s.substr(0, index));
        index++;
    }

    for(string str : sList){
        if(str.find(p) <= 100){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    
}


Measured memory_bytes: 3228
from collections import defaultdict
N,M = (int(x) for x in input().split())
keta_num_str = [ (input().split()) for i in range(M) ]

#各桁をキー、数字を値の辞書にする
suuji = ""
num_str_dic = defaultdict(set)
kotae_dic ={ str(i):"0" for i in range(1,N +1) } #　各桁に初期値”０”を入力。一番右（１の位）は入力がなければ無し
if 1< N:
    kotae_dic["1"] = "1" # 2桁以上の時は左の桁は最低１
for i in keta_num_str:   
    num_str_dic[i[0]].add(i[1])


for i,v in num_str_dic.items():
    if 1 < len(v) : # 一つの桁に複数の値がある時はエラー
        kotae_dic ={}
        break
    
    else:
        kotae_dic[i] = list(v)[0]

# 表示
import math
if kotae_dic == {}: # 一つの桁に複数の値の時        
    print(-1)
else:
    kotae_dic_sorted = sorted(kotae_dic.items(),key=lambda x:int(x[0]))
    kotae_str = "".join( [i[1] for i in kotae_dic_sorted ] ) # 辞書の値を連結
    kotae_int =int(kotae_str)
    if kotae_int == 0 and 1< N: # "00"などはエラー、"0"はOK
        print(-1)
    elif kotae_int == 0 and N == 1:
        print("0")
    elif 10**(N-1) > kotae_int or kotae_int >= 10** N: # 桁があってない＝一番左の桁が”０”はエラー
        print(-1)
    elif kotae_dic["1"] == "0" and 1 < N: 
        kotae_dic["1"] ="1"
    elif 1000 <= kotae_int: # 答えが１０００以上はエラー
        print(-1)

    else:
        print(kotae_int)

Measured memory_bytes: 3316
import java.util.*;

public class Main {

    public static void main(String[] args) {
	    // write your code here
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int l = sc.nextInt();

        int sum = 0;
        ArrayList<Integer> values = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            int value = l + i;
            sum += value;
            values.add(value);
        }
        values.sort(Comparator.comparingInt(Math::abs));

        System.out.println(sum - values.get(0));
    }
}

Measured memory_bytes: 26964
#include <stdio.h>

int Min(int a, int b, int c){
  int min;
  min = a;
  if(min > b) min = b;
  if(min > c) min = c;
  return min;
}

int Max(int N){
  int i, A, B, P, g1, g2, g3;
  scanf("%d %d", &A, &B);
  g1 = g2 = g3 = 0;
  for(i = 0;i < N;i++){
    scanf("%d", &P);
    if(P <= A) g1++;
    else if(P <= B) g2++;
    else g3++;
  }
  return Min(g1, g2, g3);
}

int main(void){
  int N;
  scanf("%d", &N);
  printf("%d\n", Max(N));
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define repr(e,x) for(auto& e:x)
using namespace std;
typedef long long ll;
typedef long double ld;
//typedef pair<int,int> P;
int const INF=1001001001;
ll const LINF=1001001001001001001;
ll const MOD=1000000007;

ll N;
ll A[200000];

int main(){
    cin>>N;
    rep(i,N) cin>>A[i];

    ll ans=0;
    ll sup=0;
    rep(i,N){
        if(sup>A[i]){
            ans+=sup-A[i];
        }
        sup=max(sup,A[i]);
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 5156
from collections import deque
class Dinic:
    def __init__(self, N):
        self.N = N
        self.G = [[] for i in range(N)]

    def add_edge(self, fr, to, cap):
        forward = [to, cap, None]
        forward[2] = backward = [fr, 0, forward]
        self.G[fr].append(forward)
        self.G[to].append(backward)

    def add_multi_edge(self, v1, v2, cap1, cap2):
        edge1 = [v2, cap1, None]
        edge1[2] = edge2 = [v1, cap2, edge1]
        self.G[v1].append(edge1)
        self.G[v2].append(edge2)

    def bfs(self, s, t):
        self.level = level = [None]*self.N
        deq = deque([s])
        level[s] = 0
        G = self.G
        while deq:
            v = deq.popleft()
            lv = level[v] + 1
            for w, cap, _ in G[v]:
                if cap and level[w] is None:
                    level[w] = lv
                    deq.append(w)
        return level[t] is not None

    def dfs(self, v, t, f):
        if v == t:
            return f
        level = self.level
        for e in self.it[v]:
            w, cap, rev = e
            if cap and level[v] < level[w]:
                d = self.dfs(w, t, min(f, cap))
                if d:
                    e[1] -= d
                    rev[1] += d
                    return d
        return 0

    def flow(self, s, t):
        flow = 0
        INF = 10**9 + 7
        G = self.G
        while self.bfs(s, t):
            *self.it, = map(iter, self.G)
            f = INF
            while f:
                f = self.dfs(s, t, INF)
                flow += f
        return flow

def gcd(a,b):
    while b!=0:
        a,b = b,a%b
    return a

res = []
while True:
    m,n = map(int, input().split())
    if m==0 and n==0:
        break

    bl = []
    while len(bl)<m:
        bl.extend(list(map(int, input().split())))
    rl = []
    while len(rl)<n:
        rl.extend(list(map(int, input().split())))

    dinic = Dinic(m+n+2)
    s = n+m
    t = n+m+1
    for i in range(m):
        for j in range(n):
            if gcd(bl[i],rl[j])>1:
                dinic.add_edge(i,m+j,1)
    for i in range(m):
        dinic.add_edge(s,i,1)
    for j in range(m,n+m):
        dinic.add_edge(j,t,1)
    res.append(dinic.flow(s,t))

for r in res:
    print(r)



Measured memory_bytes: 39716
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cout << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cout<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 300010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 30;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
///////////////////////////////////////////////////////////////////////////////////////////////////

ll fac[MAX_N], inv[MAX_N], fiv[MAX_N]; //fiv:inv(fac(i))

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

ll invf(ll a) {
	return mod_pow(a, mod - 2);
}

void C_init(int n) {
	fac[0] = fac[1] = 1; inv[1] = 1;
	fiv[0] = fiv[1] = 1;
	rep(i, 2, n + 1) {
		fac[i] = fac[i - 1] * i % mod;
		inv[i] = mod - inv[mod % i] * (mod / i) % mod;
		fiv[i] = fiv[i - 1] * inv[i] % mod;
	}
}

ll C(int a, int b) { //assume a >= b
	if(a < b || a < 0 || b < 0) return 0;
	return fac[a] * fiv[b] % mod * fiv[a - b] % mod;
}

int H, W, N;
pi P[MAX_N];
ll dp[MAX_N];

void solve() {
	cin >> H >> W >> N;
	H--; W--;
	rep(i, 0, N) {
		int a, b;
		cin >> a >> b; a--; b--;
		P[i] = pi(a, b);
	}
	sort(P, P + N + 1);
	C_init(H + W);

	rer(i, N + 1, 0) {
		int a = P[i].fst, b = P[i].sec;
		dp[i] = C(H - a + W - b, W - b);
		rep(j, i + 1, N + 1) {
			int c = P[j].fst, d = P[j].sec;
			ADD(dp[i], mod - dp[j] * C(c - a + d - b, d - b) % mod);
		}
		// debug(dp[i], a, b);
	}
	cout << dp[0] << "\n";
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
	srand((unsigned int)time(NULL));
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}



Measured memory_bytes: 9216
def input_n
  gets.to_i               # 単一整数
end

def input_s
  gets.chomp              # 文字列。chompを付けないと改行文字がついてくる
end

def input_a
  gets.split.map(&:to_i)  # スペースで区切られた複数の整数
end

def input_o(num)
  num.times.map { gets.chomp }  # 縦に並んだ複数の整数。たまにある
end

def output_f(num)
  puts sprintf("%.12f", num)
end

n = input_n
s = input_o(n)
cnt = 0
a = {}
n.times do |i|
  if a[s[i]].nil?
    a[s[i]] = 1
    cnt += 1
  end
end
puts cnt


Measured memory_bytes: 46212
N = int(input())
A = [int(i) for i in input().split()]

count = 0
for i in A:
  if i % 2 == 0:
    if i % 3 != 0 and i % 5 != 0:
      count += 1

if count == 0:
  print('APPROVED')
else:
  print('DENIED')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
const ll INF = 1e9+100;
const ll INFL = 1e18+100;
const ll MOD = 1e9+7;
const bool debug = 0;
//-----------------------------------------------//

int main() {
	int a, b;
	cin >> a >> b;
	
	if (a > b) cout << a - 1 << endl;
	else if (a <= b) cout << a << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

int B = 400;
// バケット i は [i*B, (i+1)*B) の記録を持つ
// lazy[i] :=  バケットi の遅延を記録する
// 0 ... 加算の単位元(laze[i] == 0 ⇔ 消化しても伝播しない
//今回は本当に単位元なので例外処理的な扱いをしなくていい
vector<int> lazy(B, 0), a(100000, 0);
 
// a_s, ..., a_t に x を加算する
void add(int s, int t, int x)
{
    // s の属するバケット, t の属するバケット
    int st = s / B, gt = t / B;

    // st や gt に遅延を消化しておく
    // 遅延はパケットごとに考えるから, 遅延が存在⇔パケット内は全て等しい値が加算されている
    // したがって mi[st] = mi[st] + lazy[st] が成立
    for (int i = st * B; i < (st + 1) * B; i++) a[i] += lazy[st];
    lazy[st] = 0;

    for (int i = gt * B; i < (gt + 1) * B; i++) a[i] += lazy[gt];
    lazy[gt] = 0;
    
    //... || ... s ... t ... || ...
    //更新が同一パケット内で済むなら直接更新しても間に合う
    if (st == gt){
        for (int i = s; i <= t; i++) a[i] += x;
    }

    //... s ... || (被覆されるパケット) || ... t ...
    else{
        //端が属するパケット内は直接更新
        for (int i = s; i < (st + 1) * B; i++) a[i] += x;
 
        for (int i = gt * B; i <= t; i++) a[i] += x;

        //区間に被覆されるパケットについては加算を遅延に残す
        //addは結合法則を満たすのでlazyには消化されるまで何回も遅延を上乗せできる
        //該当パケットが参照されたときにlazy[i]を加算すればよい
        for (int i = st + 1; i < gt; i++){
            lazy[i] += x;
        }
    }
}
 
// a_s を返す
int find(int s){
    int st = s / B;

    // まずは端の遅延を消化
    for (int i = st * B; i < (st + 1) * B; i++) a[i] += lazy[st];
    lazy[st] = 0;
    return a[s];
}
 
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n, q;
    cin >> n >> q;
    REP(i, q){
        int type;
        cin >> type;
        if(type == 0){
            int s, t, x;
            cin >> s >> t >> x;
            add(s, t, x);
        }
        else{
            int s;
            cin >> s;
            cout << find(s) << endl;
        }
    }
    return 0;
}



Measured memory_bytes: 3252
function Main(input) {
    lines=input.split("\n");
    for(i in lines){
	if(lines[i]=="")break;
	n=lines[i].split(" ").map(function(x){return x-0;});
	sum=n[0]+n[1];
	console.log(sum.toString().length);
    }
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 9000
import math

N = int(input())

if math.floor(math.floor((N) / 1.08) * 1.08) == N:
    print(math.floor((N) / 1.08))
elif math.floor(math.floor((N+1) / 1.08) * 1.08) == N:
    print(math.floor((N+1) / 1.08))
else:
    print(":(")

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int a, b;
    cin >> a >> b;
    cout << 6-a-b << "\n";
    return 0;
}

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

int gcd(int m,int n)
{
	if(n==0) return m;
	return gcd(n,m%n);
}

int lcm(int m,int n)
{
	return m*n/gcd(m,n);
}

int main()
{
	int n,A[10];
	
	cin >> n;
	for(int i=0;i<=n-1;i++) cin >> A[i];
	int ans=A[0];
	for(int i=1;i<=n-1;i++) ans=lcm(ans,A[i]);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3100
/*
 * main.c
 *
 *  Created on: 2020/07/27
 *      Author: 113896
 */
#include <stdio.h>
#include <stdlib.h>

void initMatrix(long int** a, long int n, long int m) {
	for (long int i = 0; i < n; i++) {
		for (long int j = 0; j < m; j++) {
			a[i][j] = 0;
		}
	}
}

void printMatrix(long int** a, long int n, long int m) {
	for (long int i = 0; i < n; i++) {
		for (long int j = 0; j < m; j++) {
			printf("%ld", a[i][j]);
			if (j == m-1) printf("\n");
			else printf(" ");
		}
	}
}

int main() {

	long int n, m, l;
	scanf("%ld%ld%ld", &n, &m, &l);

	long int** A = (long int**)malloc(n * sizeof(long int*));
	long int** B = (long int**)malloc(m * sizeof(long int*));
	long int** C = (long int**)malloc(n * sizeof(long int*));

	for (long int i = 0; i < n; i++) {
		A[i] = (long int*)malloc(m * sizeof(long int));
	}

	for (long int i = 0; i < m; i++) {
		B[i] = (long int*)malloc(l * sizeof(long int));
	}

	for (long int i = 0; i < n; i++) {
		C[i] = (long int*)malloc(l * sizeof(long int));
	}

	initMatrix(A, n, m);
	initMatrix(B, m, l);
	initMatrix(C, n, l);

	for (long int i = 0; i < n; i++) {
		for (long int j = 0; j < m; j++) {
			scanf("%ld", &A[i][j]);
		}
	}

	for (long int i = 0; i < m; i++) {
		for (long int j = 0; j < l; j++) {
			scanf("%ld", &B[i][j]);
		}
	}

	for (long int i = 0; i < n; i++) {
		for (long int j = 0; j < l; j++) {
			C[i][j] = 0;
		}
 	}


	long int sum;
	for (long int i = 0; i < n; i++) {
		for (long int j = 0; j < l; j++) {
			sum = 0;
			for (long int k = 0; k < m; k++) {
				sum += A[i][k] * B[k][j];
//				printf("(%d, %d, %d): %d * %d = %d\n", i, k, j, A[i][k], B[k][j], A[i][k]*B[k][j]);
			}
			C[i][j] = sum;
		}
	}

	for (long int i = 0; i < n; i++) {
		for (long int j = 0; j < l; j++) {
			printf("%ld", C[i][j]);
			if (j == l-1) printf("\n");
			else printf(" ");
		}
	}

	return 0;
}




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

int main(){
  int d;
  cin >> d;
  if(d == 25){
    cout << "Christmas";
  }else if(d == 24){
    cout << "Christmas Eve";
  }else if(d == 23){
    cout << "Christmas Eve Eve";
  }else if(d == 22){
    cout << "Christmas Eve Eve Eve";
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
const double eps = 1e-8;
const int NINF = 0xc0c0c0c0;
const int INF  = 0x3f3f3f3f;
const ll  mod  = 1e9 + 7;
const ll  maxn = 1e6 + 5;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	string s,t;
	cin>>s>>t;
	s+=t[t.size()-1];
	if(s==t) cout<<"Yes\n";
	else cout<<"No\n";
	return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
	int n, m;
	cin >> n >> m;
	int arr[n], sum = 0;
	for(int i = 0; i < n; i++)
	{
		cin >> arr[i];
		sum += arr[i];
	}
	sort(arr,arr+n);
	if( (double)arr[ n - m ] < (double)sum/(4.0*m) )
		cout << "No";
	else
		cout << "Yes";
}

Measured memory_bytes: 3092
#include <iostream>
using namespace std;
int main(){
  int A[5];
  cin >> A[0] >> A[1] >> A[2] >> A[3]>> A[4];
  for(int i=0;i<5;i++){
    if(A[i] == 0)
      cout << i+1 << endl;
  }
  return 0;
}
                                 
                                 

Measured memory_bytes: 3580
#include<stdio.h>
int main(void){
  long long int n,m;
  scanf("%lld %lld",&n,&m);
  if(m<2*n){
    printf("%lld\n",m/2);
  }else{
    printf("%lld\n",(n+(m-2*n)/4));
  }
  return 0;
}

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

int main() {
  long long N, A, B;
  cin >> N >> A >> B;
  long long blue_ball = 0;
  long long set_num = N / (A + B);
  long long remain_ball = N % (A + B);
  
  blue_ball += set_num * A;
  blue_ball += min(A, remain_ball);
  cout << blue_ball << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main() {
  string a, b;
  //scanf("%s %s", &a, &b);
  cin >> a;
  cin >> b;
  int res = 0;
  for(int i = 0; i < 3; i++) {
    if(a[i] == b[i]) res++;
  }
  cout << res;
  return 0;
}


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

#define fr first
#define sc second
#define pb push_back
#define mk make_pair
#define sz(s) (int)s.size()
#define all(s) s.begin(), s.end()

using namespace std;

const int N = 1e5 + 5;

int n, sum, a[N], pr[N], sum2;

main()
{
    cin >> n;
    for( int i = 1; i <= n; i++ )
    {
        cin >> a[i];
        if( a[i] >= a[i - 1] )
            pr[ i ] = 1;
        sum += abs( a[i] - a[i - 1] );
    }
    for( int i = 1; i < n; i++ )
        sum2 += abs( a[i] - a[i - 1] );

    sum += abs( a[n] );
    sum2 += abs( a[n - 1] );
//    cout << sum << endl;
    for( int i = 1; i <= n; i++ )
    {
        int cnt = 0;
        if( pr[i] )
        {
            if( !pr[i + 1] )
                cnt += abs( a[i] - max( a[i - 1], a[ i + 1 ] ) ) * 2;
        }

        else
            if( pr[i + 1] )
                cnt += abs( a[i] - min( a[i - 1], a[ i + 1 ] ) ) * 2;
        if( i == n )
            cout << sum2 << endl;
        else
            cout << sum - cnt << endl ;
    }

}


Measured memory_bytes: 2048
#include<bits/stdc++.h>
using namespace std;
int main(){long long n,i,p=0;cin>>n;
string s;
cin>>s;

if(n%2==1)
cout<<"No";
else{
    for(i=0;i<n/2;i++){
        if(s[i]!=s[n/2+i]){
            p=1;break;
        }
    }if(p==1)
    cout<<"No";
    else
    cout<<"Yes";
}
    

    return 0;
}


Measured memory_bytes: 256
n = gets.to_i
arr = gets.split.map(&:to_i)
c = []
arr.each { |a| c[a] = c[a].to_i + 1 }
c.each.with_index(0) { |ct, idx| next if idx == 0; c[idx] = c[idx].to_i + c[idx-1].to_i }
result = []
arr.reverse.each do |a|
  result[c[a]-1] = a
  c[a] -= 1
end
puts result.compact.map(&:to_s).join(' ')


Measured memory_bytes: 193412
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define mod 1000000007
#define pb push_back
#define ff first
#define ss second
#define mp make_pair
#define all(x) x.begin(),x.end()
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
using namespace std;
 



int main()
{
    fastio
    ll k,a,b;
    cin>>k>>a>>b;
    
    ll i;
    int f=0;
    
    for(i=a;i<=b;i++)
    {
        if(i%k==0)
        {
            f=1;
            break;
        }
    }
    if(f)
    cout<<"OK\n";
    else
    cout<<"NG\n";
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  long int N ;
  long unsigned int product =1;
  cin>>N;
  long int arr[N];
  if(N<=1000000000000000&&N>=2){
  for(int i=0;i<N;i++){
      cin>>arr[i];
      if (arr[i]==0){
      product=0;
      i=N;
      }
      else if(arr[i]<=1000000000000000000/product&&arr[i]!=0){
      product=product*arr[i];
  }
    else{
      product=-1;
   }
  }
  if(product<=1000000000000000000){
      cout<<product;
  }
  
  else{
      cout<<-1;
  }
  }
  
return 0;
}


Measured memory_bytes: 4380
#include<iostream>
#include<string>
#include<algorithm>    
#include<cmath>
#include<map>
#include<vector>
#include<math.h>
#include<stdio.h>
#include<stack>
#include<queue>
#include<tuple>
#include<cassert>
#include<set>
#define int long long
using namespace std;
const int INF = 1000000000000;
const int mod = 1000000007;
int a[345678], b[345678], high[345678];
signed main() {
	int n, ans = 1; cin >> n;
	for (int h = 1; h <= n; h++) { cin >> a[h]; }
	for (int h = 1; h <= n; h++) { cin >> b[h]; }
	for (int h = 1; h <= n; h++) {
		if (a[h - 1] < a[h]) { high[h] = a[h]; }
	}
	for (int h = n; h > 0; h--) {
		if (b[h] > b[h + 1]) {
			if (high[h] != 0 && high[h] != b[h]) { cout << 0 << endl; return 0; }
			if (b[h] > a[h]) { cout << 0 << endl; return 0; }
			high[h] = b[h];
		}
	}
	for (int h = 1; h <= n; h++) {
		if (high[h] == 0) {
			ans *= min(a[h], b[h]); ans %= mod;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 5120
import bisect
from collections import deque
import math
n, d, A = map(int, input().split())
xh = []
for _ in range(n):
    x, h = map(int, input().split())
    xh.append([x, h])
xh.sort(key=lambda x: x[0])

monster_x = []
monster_hp = []
for i in range(n):
    monster_x.append(xh[i][0])
    monster_hp.append(xh[i][1])

dist = 2 * d
ans = 0
damage = 0
cum_damage = [0] * (n + 1)
for i in range(n):
    cum_damage[i + 1] += cum_damage[i]
    damage = cum_damage[i + 1] * A
    if damage < monster_hp[i]:
        min_attack_num = math.ceil((monster_hp[i] - damage) / A) 
        index = bisect.bisect_right(monster_x, monster_x[i] + dist)
        cum_damage[i + 1] += min_attack_num
        if index < n:
            t = min(index + 1, n)
            cum_damage[t] -= min_attack_num
        ans += min_attack_num

print(ans)

Measured memory_bytes: 117720
#include<stdio.h>
int main() {
  int n, s;
  float x[4], y[4], z;
  scanf("%d", &n);
  for (s = 0; s < n; s ++) {
    scanf("%f %f %f %f %f %f %f %f", &x[0], &y[0], &x[1], &y[1], &x[2], &y[2], &x[3], &y[3]);
    z = (y[0] - y[1]) * (x[2] - x[3]) - (x[0] - x[1]) * (y[2] - y[3]);
    if (z == 0) printf("YES\n");
    else printf("NO\n");
  }
  return 0;
}

Measured memory_bytes: 616
package main

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

var (
	readString func() string
	stdout     *bufio.Writer
)

func init() {
	readString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = readInt()
	}
	return b
}

func readLengthAndSlice() []int {
	n := readInt()
	return readIntSlice(n)
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func minInt(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func minUint(a, b uint) uint {
	if a < b {
		return a
	}
	return b
}

func minInt64(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

func minUint64(a, b uint64) uint64 {
	if a < b {
		return a
	}
	return b
}

func maxInt(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func maxUint(a, b uint) uint {
	if a < b {
		return b
	}
	return a
}
func maxInt64(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}

func maxUint64(a, b uint64) uint64 {
	if a < b {
		return b
	}
	return a
}

func absInt(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func absInt64(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

// readString() string
// readInt() int
// readIntSlice(n int) []int
// readLengthAndSlice() []int
func main() {
	defer stdout.Flush()

	n := readInt()
	k := readInt()

	if n%k == 0 {
		println(0)
	} else {
		println(1)
	}
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
int main() {

  string s;

  cin >> s;

  vector<int> Alp(26);

  for(int i=0;i<26;i++){
    Alp.at(i)=0;
  }//0で初期化

  for(int i=0;i<s.size();i++){
    Alp.at(int(s.at(i)-'a'))++;
  }//s中の文字をカウント

  bool all=true;//すべて登場しているかどうか

  for(int i=0;i<26;i++){
    if(Alp.at(i)==0){
      cout << (char)('a' + i) << endl;
      all=false;
      break;
    }
  }//表示

  if(all) cout << "None" << endl;//すべて登場していた場合

    
  

  return 0;
}

Measured memory_bytes: 512
# coding = utf-8
list1 = []

for n in range(6):

    list1.append(int(input()))

count = 0

for city1 in list1[:5]:
    for city2 in list1[:5]:
        if (city1 - city2 > list1[5] or city2 - city1 > list1[5]):
            print ':('
            count += 1
            break
    if count != 0:
        break
if count == 0:
    print 'Yay!'


Measured memory_bytes: 2696
#include <cstdio>
#include <iostream>
int main(){
	double x0,y0,x1,y1,x2,y2,xq,yq,x,y,m,a;
	char c;
	while(std::cin>>x1>>c>>y1>>c>>x2>>c>>y2>>c>>xq>>c>>yq){
		if (x1==x2){
			y=yq;
			x=x1;
		}
		else{
			m=(y2-y1)/(x2-x1);
			a=m*m+1;
			x0=m*x1-y1;
			y0=xq+m*yq;
			x=(m*x0+y0)/a;
			y=(-x0+m*y0)/a;
		}
		printf("%.5f %.5f\n",2*x-xq,2*y-yq);
	}
}

Measured memory_bytes: 1240
// Created by Nandu Vinodan
#include <bits/stdc++.h>

#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define rep(i,a,n) for(int i=a;i<=(n);++i)
#define repD(i,a,n) for(int i=a;i>=(n);--i)
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)
#define vi vector<int>
#define pi pair<int, int>
#define INF INT_MAX
#define _INF INT_MIN
#define TC 0 

using namespace std;
using ll = long long;

void testcase() {
    int n, m, x;
    cin >> n >> m >> x;

    vector<int> c(n);
    vector<vector<int> > a(n, vector<int>(m));

    rep (i, 0, n-1) {
    	rep (j, -1, m-1) {
    		if (j==-1)
    			cin >> c[i];
    		else
    			cin >> a[i][j];
    	}
    }

    int res = INT_MAX;
    for (int mask=0; mask < (1<<n);  mask++) {
    	int cost = 0;
    	vector<int> score(m);
    	for (int i=0; i<n; i++) {
    		if ((mask>>i) & 1) {
    			cost += c[i];
    			for (int k=0; k<m; k++)
    				score[k] += a[i][k];
    		}
    	}

    	bool ok = true;
    	for (int i=0; i<m; i++)
    		if (score[i] < x) {
    			ok = false;
    			break;
    		}

    	if (ok)
    		res = min(res, cost);
    }

    if (res == INT_MAX) cout << "-1";
    else cout << res << "\n";
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    if (TC)
        cin>>t;
    while(t--) {
        testcase();
    }
    return 0;
}

Measured memory_bytes: 3656
#include <stdio.h>
int main(void){
  int n,p[200][3],c[3][200][101]={0},i,j,k,ans;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<3;j++){
      scanf("%d",&p[i][j]);
      c[j][i][p[i][j]]++;
    }
  }
  for(i=0;i<n;i++){
    ans=0;
    for(j=0;j<3;j++){
      for(k=0;k<n;k++){
	if(i!=k&&c[j][k][p[i][j]])
	  break;
      }
      if(k==n)ans+=p[i][j];
    }
    printf("%d\n",ans);
  }
  return 0;
}

Measured memory_bytes: 844