akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;
using static System.Array;

class Program
{
    public static void Main()
    {
        var n = int.Parse(ReadLine());
        long result = 1;
        for(int i = 1; i <= n; i++)
        {
            result = (i * result) % 1000000007;
        }
        WriteLine(result);
    }
}


Measured memory_bytes: 11092
b1,b2,b3=map(int,input().split())
if b1==1:
    if b2==1:
        print("Open")
    else:
        print("Close")
if b1==0:
    if b2==0:
        if b3==1:
            print("Open")
        else:
            print("Close")
    if b2==1:
        print("Close")


Measured memory_bytes: 5596
#include "bits/stdc++.h"
using namespace std;

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(i = 0; i < n; i++)

const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

typedef long long ll;

// 4,8方向に探索する際に用いる配列
//int dx[4] = { 0,  0, 1, -1 };
//int dy[4] = { 1, -1, 0,  0 };
//int dx[8] = { 1, 0, -1,  0, 1, -1, -1,  1 };
//int dy[8] = { 0, 1,  0, -1, 1,  1, -1, -1 };

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

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

	sort(a, a + n);

	int b = (n % 2 == 0) ? a[n / 2 - 1] : a[(n + 1) / 2 - 1];

	long long f = 0;
	for (int i = 0; i < n; i++) f += abs(a[i] - b);

	cout << f << endl;

	return 0;
}



Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<unordered_map>
using namespace std;
typedef long long ll;
int main() {
	int h,w;
	cin>>h>>w;
	char a[101][100];
	for(int i=1;i<=h;i++){
		string s;
		cin>>s;
		for(int j=0;j<w;j++){
			a[i][j]=s[j];
		}
	}
	for(int i=1;i<=h*2;i++){
		for(int j=0;j<w;j++){
			cout<<a[(int)floor((i+1)/2.0)][j];
		}
		cout<<endl;
	}
}


Measured memory_bytes: 256
# abcde	s=input()	s='abcde'
# abcde	s=list(input())	s=['a', 'b', 'c', 'd', 'e']
# 5(1つだけ)	a=int(input())	a=5
# 1 2	| x,y = s_inpl()   |	x=1,y=2
# 1 2 3 4 5 ... n 　	li = input().split()	li=['1','2','3',...,'n']
# 1 2 3 4 5 ... n 　	li = inpl()	li=[1,2,3,4,5,...,n]
# FFFTFTTFF 　	li = input().split('T')	li=['FFF', 'F', '', 'FF']

# INPUT
# 3
# hoge
# foo
# bar
# ANSWER
# n=int(input())
# string_list=[input() for i in range(n)]

import math
import copy
from collections import defaultdict
from collections import Counter
from collections import deque
# 直積 A={a, b, c}, B={d, e}:のとき，A×B={(a,d),(a,e),(b,d),(b,e),(c,d),(c,e)}: product(A, B)
from itertools import product
# 階乗 P!: permutations(seq), 順列 {}_len(seq) P_n: permutations(seq, n)
from itertools import permutations
# 組み合わせ {}_len(seq) C_n: combinations(seq, n)
from itertools import combinations
from bisect import bisect_left, bisect_right
# import numpy as np

def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W

# 四方向: 右, 下, 左, 上
dy = [0, -1, 0, 1]
dx = [1, 0, -1, 0]

def i_inpl(): return int(input())
def s_inpl(): return map(int,input().split())
def l_inpl(): return list(map(int, input().split()))
INF = float("inf")

############
############
############

N, M = l_inpl()
A = l_inpl()
B, C = [], []

for _ in range(M):
    bi, ci = l_inpl()
    B.append(bi)
    C.append(ci)

for ai in A:
    B.append(1)
    C.append(ai)

D = zip(C, B)

D = sorted(D, reverse=True)

C, B = zip(*D)


cnt = 0
ans = 0
for i in range(N):
    if cnt + B[i] > N:
        v = N - cnt
    else:
        v = B[i]
    ans += C[i]*v
    cnt += B[i]
    if cnt >= N:
        break

print(ans)



Measured memory_bytes: 121092
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
//	freopen("output.txt", "w", stdout);
int main ()
{
    unsigned ll n,k;
    scanf("%llu %llu",&n,&k);
    if((n-k)==0)
    {
        cout<<0<<endl;
    }
    else if(n<k)
    {
        unsigned ll z=k&n;
        if(z==0)
            printf("%llu\n",n);
        else
        {
            ll v=n*2;
            if(v<k)
            {
                printf("%llu\n",n);
            }
            else
            {
                 ll x=k-n;
                printf("%lld\n",x);
            }
        }
       /* unsigned ll x=n-k;
        if(x<0)
            x*=-1;
        if(n>x)
        printf("%llu\n",x);
        else
             printf("%llu\n",n);*/
    }
    else
    {
        unsigned ll c=n%k;
        if(c==0)
        {
            cout<<0<<endl;
        }
       else
       {
        ll q;
        if(c>(k-c))
        {
            q=k-c;
        }
        else
            q=c;
            printf("%llu\n",q);
       }
    }
    return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;
class Main{
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		int N = saori.saori_hayami();
		int ans = 0;
		boolean flg = false;
		
		for(int i = 1;i <=9;i++){
			if(N % i == 0){
				ans = N/i;
				if(ans < 10){
					flg = true;
				}
			}
		}
		if(flg){
			System.out.println("Yes");
		} else{
			System.out.println("No");
		}
		
		
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

Measured memory_bytes: 21332
#include <stdio.h>
int main(){
    int big[6]={60,80,100,120,140,160};
    int weight[6]={2,5,10,15,20,25};
    int kin[6]={600,800,1000,1200,1400,1600};
    int i,s;
    while(1){
        int n,sum=0;
        scanf("%d",&n);
        if(n==0)break;
        for(i=0;i<n;i++){
            int x,y,h,w;
            scanf("%d %d %d %d",&x,&y,&h,&w);
            int tyou=x+y+h;
            for(s=0;s<6;s++){
                if(tyou<=big[s]&&weight[s]>=w){
                    sum+=kin[s];
                    break;
                }
            }
        }
        printf("%d\n",sum);
    }
    return 0;
}

Measured memory_bytes: 600
#include<stdio.h>
int main (void) {
  
  int N,A[100];
  double B[100];  //逆数の配列//
  
  //入力//
  scanf("%d", &N);
  for (int i = 0; i < N; i++) {
    scanf("%d", &A[i]);
  }
  
  //逆数の総和をaとする//
  double a = 0.0;
  for (int i = 0; i < N; i++) {
    B[i] = 1 / (double)A[i];
    a += B[i];
  }
  
  //逆数の総和の逆数をbとする//
  double b = 1 / a;
  
  //出力//
  printf("%f", b);
  
  return 0;
}

Measured memory_bytes: 128
#include <cstdio>
const int MAXN = 100;

using namespace std;

int bubbleSort(int A[], int N);

int main()
{
	int nums[MAXN];

	int n;
	scanf("%d", &n);

	for (int i = 0; i < n; i++)
	{
		scanf("%d", &nums[i]);
	}

	int sw = bubbleSort(nums, n);

	for (int i = 0; i < n; i++)
	{
		if (i != n - 1)
		{
			printf("%d ", nums[i]);
		}
		else
		{
			printf("%d", nums[i]);
		}
	}
	printf("\n%d\n", sw);

	return 0;
}


// 运行程序: Ctrl + F5 或调试 >“开始执行(不调试)”菜单
// 调试程序: F5 或调试 >“开始调试”菜单

// 入门提示: 
//   1. 使用解决方案资源管理器窗口添加/管理文件
//   2. 使用团队资源管理器窗口连接到源代码管理
//   3. 使用输出窗口查看生成输出和其他消息
//   4. 使用错误列表窗口查看错误
//   5. 转到“项目”>“添加新项”以创建新的代码文件，或转到“项目”>“添加现有项”以将现有代码文件添加到项目
//   6. 将来，若要再次打开此项目，请转到“文件”>“打开”>“项目”并选择 .sln 文件

int bubbleSort(int A[], int N)
{
	int sw = 0;
	int temp;
	
	bool flag = true;
	for (int i = 0; i < N - 1 && flag; i++)
	{
		flag = false;
		for (int j = N - 1; j > i; j--)
		{
			if (A[j] < A[j - 1])
			{
				temp = A[j];
				A[j] = A[j - 1];
				A[j - 1] = temp;
				flag = true;
				sw++;
			}
		}
	}

	return sw;
}



Measured memory_bytes: 2712
#include <stdio.h>

int main(void)
{
	int sum, x;
	int i;
	
	while (1) {
		scanf("%d", &sum);
		if (sum == 0) break;
		for (i = 1; i < 10; i++) {
			scanf("%d", &x);
			sum -= x;
		}
		printf("%d\n", sum);
	}
	return 0;
}

Measured memory_bytes: 600
import java.io.FileNotFoundException;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws FileNotFoundException {

		//    	File file = new File("src/in.txt");
		//    	Scanner sc = new Scanner(file);

		Scanner sc = new Scanner(System.in);

		int L = sc.nextInt();
		int R = sc.nextInt();

		if(R%2019==0||L%2019==0) {
			System.out.println("0");
			System.exit(0);
		}
		if((R-L)>=2018) {
			System.out.println("0");
			System.exit(0);
		}
		for(int i=L;i<=R;i++) {
			if(i%2019==0) {
				System.out.println("0");
				System.exit(0);
			}
		}
		int l = L%2019;
		int r = R%2019;
		int ans = 2018;
		for(int i=l;i<r;i++) {
			for(int j=i+1;j<=r;j++) {
				int tmp = (i*j)%2019;
				if(tmp<ans) {
					ans = tmp;
				}
			}
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 23892
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <stack>
#include <deque>
#include <queue>
#include <set>
#include <cmath>
#include <algorithm>
#include <map>
#include <list>

using namespace std;

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

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

#define MAX_S 8

const int value[ 4 ] = { 10, 50, 100, 500 };

int main()
{
	bool first = true;
	while( 1 ) {
		int coins[ 4 ];
		int price;
		cin >> price;
		if( !price ) break;
		if( !first ) cout << endl;
		first = false;
		REP( i, 4 ) cin >> coins[ i ];
		int sum = 0;
		REP( i, 4 ) sum += coins[ i ] * value[ i ];
		sum -= price;
		for( int i = 3; i >= 0; --i ) {
			int n = sum / value[ i ];
			sum -= n * value[ i ];
			coins[ i ] -= n;
		}
		REP( i, 4 ) if( coins[ i ] > 0 ) cout << value[ i ] << " " << coins[ i ] << endl;
	}
	return 0;
}

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


int main(){
	int x,n;
	cin >> x >> n;
	set<int> S;
	rep(i, n) {
		int tmp;
		cin >> tmp;
		S.insert(tmp);
	}
	int ans;
	rep(i,100){
		if(S.find(x-i) == S.end()){
			ans = x-i;
			break;
		}
		if(S.find(x+i) == S.end()){
			ans = x+i;
			break;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3640
def main():

    while True:

        num = [int(x) for x in input().split(' ')]

        if num[0] == 0 and num[1] == 0:
            break

        for i in range(num[0]):
            for j in range(num[1]):
                print('#', end='')
            print('')

        print('')

if __name__ == "__main__":
    main()


Measured memory_bytes: 7020
#include <bits/stdc++.h>
#define ll long long
#define ls id << 1
#define rs id << 1 | 1
#define mem(array, value, size, type) memset(array, value, ((size) + 5) * sizeof(type))
#define memarray(array, value) memset(array, value, sizeof(array))
#define pb(x) push_back(x)
#define st(x) (1LL << (x))
#define pii pair<int, int>
#define mp(a, b) make_pair((a), (b))
#define Flush fflush(stdout)
using namespace std;
const int N = 500050;
const int inf = 0x3f3f3f3f;
const ll llinf = 0x3f3f3f3f3f3f;
const ll mod = 1e9 + 7;
clock_t TIME_START, TIME_END;
void program_end()
{
#ifdef ONLINE
    printf("\nTime used: %.6lf(s)\n", ((double)TIME_END - TIME_START) / CLOCKS_PER_SEC);
    system("pause");
#endif
}
inline ll mi(ll a, ll b)
{
    ll ret = 1;
    while (b)
    {
        if (b & 1)
            ret *= a, ret %= mod;
        a *= a, a %= mod;
        b >>= 1;
    }
    return ret;
}
ll fac[N], inv[N];
ll n, m;
inline ll C(ll n, ll m)
{
    if (m > n)
        return 0;
    return fac[n] * inv[n - m] % mod * inv[m] % mod;
}
inline ll P(ll n, ll m)
{
    if (m > n)
        return 0;
    return fac[n] * inv[n - m] % mod;
}

void solve()
{
    fac[0] = 1, inv[0] = 1;
    for (int i = 1; i <= 500000; ++i)
        fac[i] = fac[i - 1] * i, fac[i] %= mod, inv[i] = mi(fac[i], mod - 2);
    cin >> n >> m;
    ll ans = P(m, n);
    ll flag = 1;
    int i = 0;
    ll tmp = 0;
    while (m - i >= 0 && n - i >= 0)
    {
        tmp+= (flag * (C(n, i) * P(m - i, n - i) % mod)) % mod;
        tmp += mod;
        tmp %= mod;
        flag = -flag;
        i++;
    }
    cout << ans * tmp % mod << endl;
}

int main()
{
    TIME_START = clock();
    int Test = 1;
    // cin >> Test;
    while (Test--)
        solve();
    TIME_END = clock();
    program_end();
    return 0;
}

Measured memory_bytes: 11424
#include<algorithm>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cstdio>
#include<iomanip>
#include<cmath>
using namespace std;

long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

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

map<long long, long long> costs;
long long solve(long long N, long long A, long long B, long long C, long long D, long long maxN, int depth) {
    if (depth == 100) {
        return 10e+18;
    }
    if (N == 1) {
        return D;
    } else if (costs[N] != 0) {
        return costs[N];
    }
    
    costs[N] = 10e+18;
    if (N < 10e+16 / D) {
        costs[N] = N * D;
    }
    if (N % 2 == 0) {
        costs[N] = min(costs[N], A + solve(N / 2, A, B, C, D, maxN, depth + 1));
    } else {
        if (N + 1 < maxN) {
            costs[N] = min(costs[N], D + A + solve((N+1) / 2, A, B, C, D, maxN, depth + 1));
        }
        costs[N] = min(costs[N], D + A + solve((N-1) / 2, A, B, C, D, maxN, depth + 1));
    }
    
    if (N % 3 == 0) {
        costs[N] = min(costs[N], B + solve(N / 3, A, B, C, D, maxN, depth + 1));
    } else {
        long long m = N % 3;
        if (N + (3 - m) < maxN) {
            costs[N] = min(costs[N],  (3 - m) * D + B + solve((N+ (3 - m)) / 3, A, B, C, D, maxN, depth + 1));
        }
        
        if (N > 3) {
            costs[N] = min(costs[N], m * D + B + solve((N-m) / 3, A, B, C, D, maxN, depth + 1));
        }
    }

    if (N % 5 == 0) {
        costs[N] = min(costs[N], C + solve(N / 5, A, B, C, D, maxN, depth + 1));
    } else {
        long long m = N % 5;
        if (N + (5 - m) < maxN) {
            costs[N] = min(costs[N],  (5 - m) * D + C + solve((N+ (5 - m)) / 5, A, B, C, D, maxN, depth + 1));
        }
        
        if (N > 5) {
            costs[N] = min(costs[N], m * D + C + solve((N-m) / 5, A, B, C, D, maxN, depth + 1));
        }
    }
//    cout << "returning " << costs[N] << " for " << N << endl;
    return costs[N];
}

int main(){
//    cout << fixed << setprecision(10);
    int T;
    cin >> T;
    long long N, A, B, C, D;
    for (int i = 0; i < T; i++) {
        cin >> N >> A >> B >> C >> D;
        costs = map<long long, long long>();
        cout << solve(N, A, B, C, D, N + 5, 0) << endl;
    }

    return 0;
}

Measured memory_bytes: 4444
import java.util.*;
import java.io.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        String[] s = sc.next().split("/");
        if(Integer.parseInt(s[0]) > 2019){
            pw.println("TBD");
        }else if(Integer.parseInt(s[0]) < 2019){
            pw.println("Heisei");
        }else if(Integer.parseInt(s[1]) < 5){
            pw.println("Heisei");
        }else{
            pw.println("TBD");
        }
        pw.flush();
    }
}

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;
    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken("\n");
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public double nextDouble() {
         return Double.parseDouble(next());
    }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    } 
}


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

bool isVowel(char c)
{
  if(c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o')
    return true;
  else
    return false;
}

int main()
{
  while(1){
    int n;
    cin >> n;
    if(n == 0) break;
    string s[n];
    string code[n];
    for(int i = 0; i < n; i++)
      cin >> s[i];
    set<string> c;
    bool flag = true;
    for(int i = 1; i <= 50; i++){
      c.clear();
      fill(code,code+n,"");
      for(int j = 0; j < n; j++){
        code[j] += s[j][0];
        for(int k = 0; k < (int)s[j].size()-1; k++)
          if(isVowel(s[j][k]))
            code[j] += s[j][k+1];
        if((int)code[j].size() >= i)
          code[j] = code[j].substr(0,i);
        c.insert(code[j]);
      }
      if((int)c.size() == n){
        cout << i << endl;
        flag = false;
        break;
      }
    }
    if(flag)
      cout << "-1" << endl;
  }
}

Measured memory_bytes: 1232
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <functional>
#include <numeric>
#include <iomanip>
#define fi first
#define se second
#define fcout(n) cout<<fixed<<setprecision((n))
using namespace std;
bool value(int y,int x,int R,int C){return 0<=y&&y<R&&0<=x&&x<C;}
typedef pair<int,int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long > vll;
typedef vector< vi > vvi;
double pie=acos(-1);
int INF=10000009;
int dx[4] = { 0,-1,0,1 };
int dy[4] = { -1,0,1,0 };
int main() {
	long double a,s[15],sum=0;
	while(true){
		cin>>a;
		if (cin.eof())break;
		s[0]=a;
		for(int i=1;i<10;i++){
			if(i%2!=0){
				s[i]=2.0*s[i-1];
			}
			else{
				s[i]=s[i-1]/3.0;
			}
		}
		for(int i=0;i<10;i++){
			sum+=s[i];
		}
		fcout(8)<<sum<<endl;
		sum=0;
	}	
}

Measured memory_bytes: 3160
#include <iostream>


int main() {


	std::cin.tie(nullptr); std::ios::sync_with_stdio(false);
	std::string A, B, C; std::cin >> A >> B >> C;


	if (A[A.size() - 1] == B[0] && B[B.size() - 1] == C[0])std::cout << "YES";
	else std::cout << "NO";


	return 0;


}

Measured memory_bytes: 384
/*
    Author: zxy_hhhh
    date: 2020/03/10
*/
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cctype>
#include<cmath>
#include<set>
#include<vector>
#include<map>
#include<queue>
#include<iostream>
#define ll long long
inline ll rd() {
    ll _x=0;int _ch=getchar(),_f=1;
    for(;!isdigit(_ch)&&(_ch!='-')&&(_ch!=EOF);_ch=getchar());
    if (_ch=='-'){_f=0;_ch=getchar();}
    for(;isdigit(_ch);_ch=getchar()) _x=_x*10+_ch-'0';
    return _f?_x:-_x;
}
void write(ll _x){if (_x>=10) write(_x/10),putchar(_x%10+'0'); else putchar(_x+'0'); }
inline void wrt(ll _x,char _p){if (_x<0) putchar('-'),_x=-_x; write(_x); if (_p) putchar(_p);}
#define maxn 500005
int n,K;
int mx[maxn<<2];
int a[maxn],in[maxn];
std::vector<int> G[maxn];
int p[maxn];
void update(int pos,int l,int r,int w,int v) {
    if (l==r) {
        mx[pos]=v;
        return ;
    }
    int mid=(l+r)>>1;
    if (w<=mid) update(pos<<1,l,mid,w,v);
    else update(pos<<1|1,mid+1,r,w,v);
    mx[pos]=std::max(mx[pos<<1],mx[pos<<1|1]);
}
int query(int pos,int l,int r,int ql,int qr) {
    if (r<ql||l>qr) return 0;
    if (ql<=l&&r<=qr) return mx[pos];
    int mid=(l+r)>>1;
    return std::max(query(pos<<1,l,mid,ql,qr),query(pos<<1|1,mid+1,r,ql,qr));
}
void torpo() {
    std::priority_queue<int> que;
    for(int i=1;i<=n;i++) if (in[i]==0) {
        que.push(i);
    }
    int pos=n;
    while(!que.empty()) {
        int now=que.top();que.pop();
        p[pos--]=now;
        for(auto i:G[now]) {
            in[i]--;
            if (in[i]==0) que.push(i);
        }
    }
}
int res[maxn];
int main() {
    n=rd(),K=rd();
    for(int i=1;i<=n;i++) a[rd()]=i;
    for(int i=1;i<=n;i++) {
        int A=a[query(1,1,n,std::max(a[i]-K+1,1),a[i])];
        int B=a[query(1,1,n,a[i],std::min(a[i]+K-1,n))];
        if (A) {
            G[a[i]].push_back(A);in[A]++;
            // printf("%d %d\n",a[i],A);
        }
        if (B) {
            G[a[i]].push_back(B);in[B]++;
            // printf("%d %d\n",a[i],B);
        }
        update(1,1,n,a[i],i);
    }
    torpo();
    for(int i=1;i<=n;i++) {
        res[p[i]]=i;
    }
    for(int i=1;i<=n;i++) {
        wrt(res[i],'\n');
    }
}

Measured memory_bytes: 43776
import sys
from collections import Counter

def main():
    input = sys.stdin.readline
    S = str(input().strip())
    c = Counter(S)
    
    for key in c:
        if c[key] % 2 == 1:
            return 'No'

    return 'Yes'


if __name__ == '__main__':
    print(main())


Measured memory_bytes: 3316
#include <stdio.h>

int p, q, a, n; /* 入力 */

/*
	p/q の単位分数への分割のうち、条件を満たす分割の個数を返す
	step 現在の単位分数の個数 (探索の深さ)
	bottom 探索する単位分数の分母の下限
	numer/denom 現在の単位分数の和
*/
int partition(int step, int bottom, int numer, int denom) {
	int s = 0; /* 条件を満たす分割の個数 */
	int i;

	if (step > n || denom > a) return 0; /* 条件を満たせないので探索を打ち切る */

	/* p/q と numer/denom の大小を比較する */
	if (p * denom < numer * q) return 0; /* 単位分数の和が p/q を超えたので打ち切る */
	else if (p * denom == numer * q) s++; /* 条件を満たす分割の一つ */

	/* 分母の小さい単位分数から順に探索する */
	for (i = bottom; i * denom <= a; i++) {
		s += partition(step + 1, i, numer * i + denom, denom * i);
	}

	return s;
}

int main(void) {
	int s; /* 条件を満たす分割の個数 */

	/* データセット毎の処理 */
	while (scanf("%d%d%d%d", &p, &q, &a, &n) == 4) {
		if (p < 1 || p > 800 || q < 1 || q > 800 || a < 1 || a > 12000 || n < 1 || n > 7) break;
		printf("%d\n", partition(0, 1, 0, 1));
	}

    return 0;
}

Measured memory_bytes: 600
#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;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define fi first
#define se second
#define mp make_pair
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long llong;
char moji[26]={'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'};
char moji2[26]={'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'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;
#define MOD llong(1e9+7)
#define MAX int(2 * 1e5 +5)
#define debug(x)  cout << #x << " = " << (x) << endl;
#define pi acos(-1.0)
#define int llong
#define INF llong(1e17)
template<class T> bool chmax(T &a,  T b) {if(a<b){a=b; return 1;} return 0;}
template<class T> bool chmin(T &a,  T b) {if(a>b){a=b; return 1;} return 0;}
bool Add(int &a,int b){a = (a + b) % MOD;}
void myprint(int* A,int A_num){
   REP(i,A_num) cout << A[i] << " ";
   cout << endl;
}

signed main(){
    string s;
    cin >> s;
    if(s[0] == 'S') cout << "Cloudy" << endl;
    else if(s[0] == 'C') cout << "Rainy" << endl;
    else cout << "Sunny" << endl;
}

Measured memory_bytes: 256
def the_closest_number_to_zero(lst):
    positive_lst = []
    negative_lst = []
    zero_lst = []
    n = len(lst)

    for i in range(n):
        number = lst[i]

        if number == 0:
            zero_lst.append(number)
        elif number > 0:
            positive_lst.append(number)
        else:
            negative_lst.append(number)

    if len(zero_lst) != 0:
        the_closest_number = 0
    else:
        positive_lst = sorted(positive_lst)
        negative_lst = sorted(negative_lst)

        if len(positive_lst) == 0:
            the_closest_number = negative_lst[-1]
        elif len(negative_lst) == 0:
            the_closest_number = positive_lst[0]
        else:
            positive = positive_lst[0]
            negative = negative_lst[-1]
            if abs(positive) >= abs(negative):
                the_closest_number = negative
            else:
                the_closest_number = positive

    return the_closest_number


def main():
    n, l = map(int, input().split())
    taste_lst = []

    for i in range(n):
        taste_lst.append(l+i)

    taste_total = sum(taste_lst)
    taste_bite = the_closest_number_to_zero(taste_lst)
    taste = taste_total - taste_bite

    print(taste)


if __name__ == '__main__':
    main()

Measured memory_bytes: 9260
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author TM
 */


#include <bits/stdc++.h>

using namespace std;

class CSplittingPile {
public:
    void solve(std::istream &cin, std::ostream &cout) {
        int n;
        cin >> n;
        vector<int> vec(n, 0);
        long long res = 1e+14;
        long long arai = 0;
        long long snuke = 0;

        for (int i = 0; i < n; ++i) {
            cin >> vec[i];
            arai += vec[i];
        }
        for (int j = 0; j < n - 1; ++j) {
            snuke += vec[j];
            arai -= vec[j];
            res = min(abs(arai - snuke), res);
        }
        cout << res << endl;
    }
};


int main() {
    CSplittingPile solver;
    std::istream &in(std::cin);
    std::ostream &out(std::cout);
    solver.solve(in, out);
    return 0;
}


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

using namespace std;

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

    int x,a,b;
    cin>>x>>a>>b;

    x=x-a;

    while(x-b>=0)
    {
        x=x-b;
    }

    cout<<x<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner sc = new Scanner(System.in);
        
        int D = sc.nextInt();
        int G = sc.nextInt();
        
        int[] p = new int[D];
        int[] c = new int[D];
        
        for(int i = 0; i < D; i++){
            p[i] = sc.nextInt();
            c[i] = sc.nextInt();
        }
        
        int ans = Integer.MAX_VALUE;
        
        for(int i = 0; i < 1 << D; i++){
            
            int k = i;
            int j = 0;
            int score = 0;
            int count = 0;
            int greatestJ = 0;
            
            while(k > 0){
                if( (k & 1) == 1 ){
                    score += p[j]*(j+1)*100 + c[j];
                    count += p[j];
                } else{
                    greatestJ = j;
                }
                k >>= 1;
                j++;
            }
            
            if( score >= G ){
                ans = Math.min(ans, count);
            }else{
                
                int plus = 0;
                int index = 0;
                if( j == D ){
                    plus = (greatestJ+1) * 100;
                    index = greatestJ;
                } else {
                    plus = (D -1 + 1) * 100;
                    index = D - 1;
                }
                
                if( (int)Math.ceil((double)(G - score) / plus) <= p[index] - 1 ){
                    ans = Math.min( ans, count + (int)Math.ceil((double)(G - score) / plus) );
                }
            }
        }
        
        System.out.println(ans);
    }
}


Measured memory_bytes: 23860
import numpy as np
n, a = int(input()), np.array(list(map(int,input().split())))
odd, div4 = len(np.where(a%2==1)[0]), len(np.where(a%4==0)[0])
ans = "Yes" if (n%2==0 and odd <= div4) or (n%2==1 and ((odd-1==div4 and odd+div4==n) or div4 >= odd)) else "No"
print(ans)

Measured memory_bytes: 23120
a,b,c,x = 4.times.map{gets.to_i}
count = 0
for i in 0..a
  for j in 0..b
    for k in 0..c
      if 500*i + 100*j + 50*k == x
        count += 1
      end
    end
  end
end
puts count

Measured memory_bytes: 3836
#include <iostream>
#include <cmath>

using namespace std;

int main()
{
    int N;  cin >> N;
    int fx = 0;

    int x = N;
    while(x > 0){
        fx += x % 10;   //下の桁から足していく
        x /= 10;
    }

    if ((N % fx) == 0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

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

int T;
int N, D;
int v[128];

int main() {
  cin >> T;
  for (int i=0; i<T; i++) {
    cin >> N >> D;
    for (int i=0; i<128; i++) v[i] = 0;
    v[D] = 1;
    for (int i=0; i<N-1; i++) {
      int max_s   = -1;
      int max_s_a = 0;
      int max_s_y = 0;
      for (int a=0; a<128; a++) {
        if (v[a] <= 0) continue;
        for (int y=0; y<128; y++) {
          int s = y + (a^y) - a;
          if (s > max_s) {
            max_s = s;
            max_s_a = a;
            max_s_y = y;
          }
        }
      }
      v[max_s_y]++;
      v[max_s_y ^ max_s_a]++;
      v[max_s_a]--;
    }
    int ans = 0;
    for (int i=0; i<128; i++) ans += i*v[i];
    cout << ans << "\n";
  }
  return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int s[100002];
int main(){
	int n,m,p=0,q=0;
	memset(s,0,sizeof(s));
	scanf("%d",&n);
	for(int i = 0;i < n;i++){
		scanf("%d",&m);
		if(m>p)
			p=m;
		s[m+1]++;
		s[m]++;
		s[m-1]++;
	}
	for(int i = 0;i <= p;i++)
		if(s[i]>q)
			q=s[i];
	printf("%d\n",q);
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <iomanip>
using namespace std;
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
typedef vector <int> vi;
typedef pair<int,int> ii;
typedef long long ll;
typedef long double ld;
const int mod = 1e9 + 7;
const ll inf = 3e18 + 5;
int add(int a, int b) { return (a += b) < mod ? a : a - mod; }
int mul(int a, int b) { return 1LL * a * b % mod; }

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

  int n;
  cin >> n;
  cout << 1ll * (n - 1) * n / 2;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,n,s) for(int i = s; i < (n); ++i)
#define rsrep(i,n,s) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<x<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;


int main() {
    int n, k;
    cin >> n >> k;
    vint v(n);
    rep(i, n) cin >> v[i];
    vll sum(n);
    sum[0] = v[0];
    srep(i, n, 1) sum[i] = sum[i-1] + v[i];
    ll ans = 0; 
    for (int a = 0; a <= min(k, n); ++a) {
        for (int b = 0; b <= min(k, n) - a; ++b) {
            priority_queue<int , vint, greater<int>> q;
            ll total = 0;
            rep(i, a) {
                total += v[i];
                q.push(v[i]);
            }
            rep(i, b) {
                total += v[n-i-1];
                q.push(v[n-i-1]);
            }
            int p = min(k - a - b, a + b);
            rep(i, p) {
                if (q.empty()) break;
                if (q.top() > 0) break;
                total -= q.top();
                q.pop();
            }
            ans = max(ans, total);
        }
    }
    cout << ans << endl;
    return 0;
}

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

#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define ALL(v) (v).begin(), (v).end()
#define INF 1e09

using namespace std;

int main(){
  int n, p;
  while(cin >> n and cin >> p and n + p){
    vector<int> a(n, 0);
    int m = p;
    bool flag = true;
    while(flag)
      REP(i, n){
        if(m > 0){ a[i%n]++; m--; }
        else { m = a[i%n]; a[i%n] = 0; }
        if(a[i%n] == p) { cout << i % n << endl; flag = false; break; }
      }
  }
}

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

using ll=long long;
const ll INF=1e10;
int main(){
    int n;
    ll z,w;
    cin>>n>>z>>w;
    vector<ll> a(n+2);
    a[0]=z,a[1]=w;
    for(int i=0;i<n;i++) cin>>a[i+2];
    n+=2;

    vector<vector<ll>> dp(n,vector<ll>(n));
    for(int i=0;i<n;i++) dp[i][n-1]=abs(a[i]-a[n-1]);
    for(int i=0;i<n;i++) dp[n-1][i]=abs(a[i]-a[n-1]);

    for(int k=n-2;k>=0;k--){
        ll v=INF;
        for(int j=k+1;j<n;j++){
            v=min(v,dp[k][j]);
        }
        for(int i=0;i<k;i++){
            dp[k][i]=v;
        }
        v=0;
        for(int j=k+1;j<n;j++){
            v=max(v,dp[j][k]);
        }
        for(int i=0;i<k;i++){
            dp[i][k]=v;
        }
    }
    cout<<dp[0][1]<<endl;
    return 0;
}

Measured memory_bytes: 31616
mojiretu = "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ"
output = ""
index = 0
N = int(input())
S = input()

for j in S:
  count = 0
  for i in mojiretu:
    if i == j:
      output = output + (mojiretu[count + N]) 
      break
    count = count + 1  
  index = index + 1

print(output)

Measured memory_bytes: 3060
package main

import (
	"bufio"
	"fmt"
	"os"
)

var sc = bufio.NewScanner(os.Stdin)

// 任意の要素数の文字列を読み込んでスライスで返す
func scanStrings(len int) (strings []string) {
	var str string
	for i := 0; i < len; i++ {
		fmt.Scanf("%s", &str)
		strings = append(strings, str)
	}
	return
}

// 任意の要素数の配列を読み込んでスライスで返す
func scanNums(len int) (nums []int) {
	var num int
	for i := 0; i < len; i++ {
		fmt.Scan(&num)
		nums = append(nums, num)
	}
	return
}

func reverse(s string) string {
	runes := []rune(s)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}

func main() {
	count := 0
	nmc := scanNums(3)
	b := scanNums(nmc[1])
	// fmt.Println(nmc)
	// fmt.Println(b)
	for i := 0; i < nmc[0]; i++ {
		a := scanNums(nmc[1])
		// fmt.Println(a)

		res := 0

		// m
		for i := 0; i < nmc[1]; i++ {
			res = res + a[i]*b[i]
		}
		res = res + nmc[2]

		if res > 0 {
			count++
		}

	}
	fmt.Println(count)
}


Measured memory_bytes: 640
n = int(input())
c = list(input())

left, right = 0, n - 1
cnt = 0
while True:
    while left < n and c[left] == 'R':
        left += 1
    while right >= 0 and c[right] == 'W':
        right -= 1
    if left >= right:
        break
    cnt += 1
    left, right = left + 1, right - 1
    
print(cnt)

Measured memory_bytes: 82688
#include <iostream>

using namespace std;

int n;
int cnt[100000];

int main() {
    cin >> n;
    for (int i = 0; i < n; ++i) {
        int a;
        cin >> a;
        if (a == 0) cnt[a]++, cnt[a+1]++;
        else if (a == 100000-1) cnt[a-1]++, cnt[a]++;
        else cnt[a-1]++, cnt[a]++, cnt[a+1]++;
    }

    int res = 0;
    for (int i = 0; i < 100000; ++i) {
        res = max(res, cnt[i]);
    }
    cout << res << "\n";
}


Measured memory_bytes: 640
#include <bits//stdc++.h>
using namespace std;
int main(void){
    int a,b,c,i,j;
    cin>>a>>b;
    int a1=0;
    int a2=a;
    for(i=0;i<b;i++){
        cin>>c>>j;
        if(c>a1)
        a1=c;
        if(j<a2)
        a2=j;
    }
    if(a2-a1+1>0)
    cout<<a2-a1+1<<endl;
    else
    cout<<"0"<<endl;
    
}


Measured memory_bytes: 384
#include <iostream>

using namespace std;

int main()
{
	long long K, A, B;
	cin >> K >> A >> B;

	if (B - A <= 2) {
		cout << 1 + K << endl;
	}
	else if (K + 1 <= A) {
		cout << 1 + K << endl;
	}
	else {
		long long R = K - (A - 1);
		long long ans = A + (R / 2) * (B - A) + (R % 2);
		cout << ans << endl;
	}
}


Measured memory_bytes: 256
/*
 * atcoder/abc140_2nd/d.cpp
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> ostream & operator << (ostream & out, vector<T> const & v) {
  for (auto &&a: v) out << a << " "; out << endl; return out;
}
template <class T> void dump(T &a) { cout << a << endl; }
template <class T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template <class T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }
template <class T, class T2>
void group(T &xs, vector<pair<T2, int> > &result) {
  int i=0, j;
  while (i<xs.size()) {
    j=i;
    while (j < xs.size() and xs[j] == xs[i]) j++;
    result.push_back({ xs[i], j-i });
    if (j==i) i++;
    i=j;
  }
}

/*
 * 全員が同じ方向を向いている時が幸福度最大でN-1なので、十分多数の操作を繰り返せば必ずこれは達成する.
 * 幸福度がN-1-1の時必ず+1の操作が存在する.
 * 幸福度がN-1-2以下の時必ず+2の操作が存在する.
 * よって、もともとの幸福度に2 * Kを足して、はみ出し場合にはN-1を解とすればよい.
 */
int N, K;
string S;
void solve() {
  cin >> N >> K >> S;
  vector<pair<char, int> > A;
  group(S, A);
  int ans = 0;
  for (auto&&a: A) ans += a.second - 1;
  ans += 2 * K;
  cout << min(ans, N-1) << endl;
}
int main() {
  // cout.precision(15); cout << fixed;

  solve();

  return 0;
}


Measured memory_bytes: 1528
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
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; }
//(a+b-1)/b
//priority_queue<ll, vector<ll>, greater<ll>> q;
using pl = pair<ll,ll>;
using vvb=vector<vector<bool>>;
using vb= vector<bool>;
ll f(ll a,ll b,ll p){
	if(b==0) return 1;
	if(b%2==0){
		ll t=f(a,b/2,p);
		return t*t%p;
	}
	return a*(f(a,b-1,p))%p;
} 

//__builtin_popcount()
signed main(){
	int n; cin>>n;
	string s; cin>>s;
	if(n==1){
		if(s=="0")cout<<1<<endl;
		else cout<<0<<endl;
		return 0;
	}
	string t=s;
	reverse(all(t));
	vl memo1(n),memo2(n);
	ll sum1=0,sum2=0;
	if(t[0]=='1')sum1=1,sum2=1;
	ll cnt=0;
	rep(i,0,n)cnt+=(s[i]=='1');
	if(cnt==1){

	}
	memo1[0]=1; memo2[0]=1;
	rep(i,1,n){
		memo1[i]=memo1[i-1]*2%(cnt+1);
		if(cnt-1>0)memo2[i]=memo2[i-1]*2%(cnt-1);
		if(t[i]=='1'){
			sum1+=memo1[i];
			sum1%=(cnt+1);
			sum2+=memo2[i];
			if(cnt-1>0)sum2%=(cnt-1);
		}
	}
	vl ans(n);
	rep(i,0,n){
		ll j;
		if(t[i]=='0'){
			j=sum1;
			j+=memo1[i];
			j%=(cnt+1);
		}
		else{
			j=sum2;
			j-=memo2[i];
			if(j<0)j+=(cnt-1);
			//if(cnt-1>0)j%=(cnt-1);
			if(cnt-1==0){
				ans[i]=0;
				continue;
			}
		}

		ll add=1;
		while(j>0){
			if(__builtin_popcount(j)==0){
				add++;
				break;
			}
			j%=__builtin_popcount(j);
			add++;
		}
		ans[i]=add;
	}
	reverse(all(ans));
	rep(i,0,n)cout<<ans[i]<<'\n';


	return 0;
}

Measured memory_bytes: 8312
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>

using namespace std;

int main(void) 
{
    long long a;
    double b;
    cin >> a >> b;

    int bb = int(b * 100 + 0.5);
    long long ans = (a * bb) / 100;

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

Measured memory_bytes: 3788
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>
 
using namespace std;
using ll =long long;

bool is_int_lround(double x){
  return std::lround(x)==x;
}
int ketasuu(int x){
  int n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}
ll gcd11(ll x, ll y){
  long long a= max(x,y), b=min(x,y), c=a%b;
  while( c!=0){
    a =b;
    b =c;
    c = a%b;
  }
  return b;
}

int ab(int x, int y){
  if(x>=y){
    return x-y;
  }
  else if(y>x){
    return y-x;
  }
}
int main(){
  int n;
  cin>> n;
  int a[n];
  int b[n];
  int c[n-1];
  int sum =0;
  for(int i=0;i<n;i++){
    cin >>a[i];
  }
  for(int i=0 ; i<n ; i++){
    cin >>b[i];
    sum += b[i];
  } 
  for(int i=0 ; i<n-1 ; i++){
    cin >>c[i];
  }
  for(int i =0; i<n-1 ;i++){
    if(a[i+1] ==a[i]+1){
      sum += c[a[i]-1];
    }
  }
  cout << sum <<endl;
}

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

int main() {
  int K, N;
  cin >> K >> N;
  int M = 0;
  vector<int> A(N);
  cin >> A.at(0);
  for (int i = 0; i < N; i++) {
    if (i < N - 1) {
      cin >> A.at(i + 1);
      if(M < A.at(i + 1) - A.at(i)) {
        M = A.at(i + 1) - A.at(i);
      }
    }
    else {
      if (M < A.at(0) + K - A.at(N - 1)) {
        M = A.at(0) + K - A.at(N - 1);
      }
    }
  }
  cout << K - M << endl;
}

Measured memory_bytes: 1152
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <queue>
#include <vector>
#include <stack>
#include <set>

using namespace std;

typedef long long ll;
#define mems(p) memset(p,0,sizeof(p))
#define mp make_pair

void fast()
{ios_base::sync_with_stdio(false);cin.tie(0);}

int main() {
	fast();
	ll r,d,x[20];
	cin>>r>>d>>x[0];
	for (int i = 1; i <= 10; ++i)
	{
		x[i]=r*x[i-1]-d;
		cout<<x[i]<<endl;
	}
}

Measured memory_bytes: 256
n = int(input())
d, x = map(int,input().split())
a = [int(input()) for _ in range(n)]

for i in range(n):
    s = 0
    f = 1
    while f <= d:
        x += 1
        f = s * (a[i]) + 1
        s += 1
    x -= 1
print(x)

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

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d = sc.nextInt();
		int e = Math.max(a, c);
		int f = Math.min(b, d);
		
		if (f >= e) {
			System.out.println(f - e);
		} else {
			System.out.println(0);
		}

	}
}


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

int main()
{
  int a,b;
  char op;
  while(1){
    cin >>a>>op>>b;
    
    if(op == '+'){
      cout<<a+b<<endl;
    }else if(op == '-'){
      cout<<a-b<<endl;
    }else if(op == '*'){
      cout<<a*b<<endl;
    }else if(op == '/'){
      cout<<a/b<<endl;
    }else{
      break;
    }
  }
  return 0;
}

Measured memory_bytes: 1160