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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

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



void solve() {
	ll K,N; cin >> K >> N;
    vector<ll> vec(N);
    rep(i,N){
        cin >> vec[i];
    }
    ll ans=0;
    rep(i, N-1){
        ans = max(ans, vec[i+1]-vec[i]);
    }
    ans = max(ans, abs(vec[0]+(K -vec[N-1])));

    cout << K - ans << endl;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


Measured memory_bytes: 5888
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
int main()
{
	int x,a,b;
	int ca,cb;
	scanf("%d%d%d",&x,&a,&b);
	ca=abs(x-a);
	cb=abs(x-b);
	if(ca<cb)
	{
		printf("%c",'A');
	}
	else
	{
		printf("%c",'B');
	}
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

main(){
  int H,W;
  int i,j;
  for(;;){
    scanf("%d %d",&H,&W);
    if(H==0 && W==0) {
      break;
    }else{
      for(i=0;i<H;i++){
        for(j=0;j<W;j++){
          printf("#");
        }
        printf("\n");
      }
      printf("\n");
    }
  }
}



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

int x[] = {0,1,0,-1} ;
int y[] = {1,0,-1,0} ;
bool M[21][21] ;
int H , W ;
bool valid( int r , int c ){
	if( r < H && r >= 0 && c < W && c >= 0 ) return true ;
	else return false ;
}
bool v[21][21] ;
int BFS( int r , int c ){
	for( int i = 0 ; i < H ; i++ ){
		for( int j = 0; j < W ; j++ ){
			v[i][j] = 0;
		}
	}
	queue < pair < int , int > > q ;
	q.push({r,c});
	v[r][c] = 1 ;
	q.push({-1,-1});
	int cnt = 0 ;
	while(!q.empty()){
		pair < int , int > p = q.front() ;
		q.pop() ;
		if( p.first == -1 ){
			cnt++ ;
			if( !q.empty() ){
				q.push({-1,-1});
				continue ;
			}
			else{
				break ;
			}
		} 
		r = p.first ;
		c = p.second ;
		
		for( int i = 0 ; i < 4 ; i++ ){
			int R = r + x[i] ;
			int C = c + y[i] ;
			if(valid(R,C)&& M[R][C] && !v[R][C]){
				q.push({R,C});
				v[R][C] = 1 ;
			}
		}
	}
	return cnt - 1 ;

}

int main(){
	
	cin >> H >> W ;
	char c ;
	for( int i = 0 ; i < H ; i++ ){
		for( int j = 0; j < W ; j++ ){
			cin >> c ;
			if( c == '.') M[i][j] = 1 ;
		}
	}
	int ans = 0 ;
	for( int i = 0 ; i < H ; i++ ){
		for( int j = 0; j < W ; j++ ){
			if( M[i][j]){
				int x = BFS(i,j);
				ans = max(ans,x);
			}
		}
	}
	cout << ans << endl ;

	return 0 ;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int cnt = 0;
void Print(vector<int>m){
  for(int i = 0; i < m.size(); i++){
    if(i)cout << ' ';
    cout << m[i];
  }
  cout << endl;
}
void InsertSort(vector<int>&a, int step){
  for(int i = step; i < a.size(); i++){
    int k = a[i], j = i-step;
    while(j >= 0 and a[j] > k){
      a[j+step] = a[j];
      j -= step;
      cnt++;
    }
    a[j+step] = k;
  }
}
int main(){
  int n;
  cin >> n;
  vector<int>a(n);
  for(int i = 0; i < n; i++){
    cin >> a[i];
  }
  vector<int>m;
  int x = n;
  if(x == 1){
    m.push_back(1);
  }else{
    while(x > 1){
      m.push_back(x / 2);
      x /= 2;
    }
  }
  for(auto step: m){
    InsertSort(a, step);
  }

  cout << m.size() << endl;

  Print(m);

  cout << cnt << endl;

  for(auto i: a){
    cout << i << endl;
  }
}


Measured memory_bytes: 6788
H,W,K = map(int,input().split())
C = [input() for i in range(H)]

cnt = sum(row.count('#') for row in C)

ans = 0
for b in range(1<<(H+W)):
    h,w = divmod(b,(1<<W))
    st = set()
    for i in range(H):
        if h&(1<<i):
            for j in range(W):
                if C[i][j] == '#':
                    st.add((i,j))
    for j in range(W):
        if w&(1<<j):
            for i in range(H):
                if C[i][j] == '#':
                    st.add((i,j))
    if len(st)==cnt - K:
        ans += 1
print(ans)

Measured memory_bytes: 9228
#include<iostream>
#include<algorithm>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<sstream>
#include<set>
#include<queue>
using namespace std;
typedef long long ll;
typedef pair<int,int>PII;
typedef pair<ll,ll>PLL;
#define make_pair mkp;


int main(){
	string s;
	cin>>s;
	if(s[2]==s[3]&&s[4]==s[5]){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}

	return 0;
}

Measured memory_bytes: 256
N = 3
A = [int(N) for N in input().split()]
C =[0]*3
C[0]=A[1]
C[1]=A[0]
C[2]=A[2]
A[0]=C[2]
A[1]=C[1]
A[2]=C[0]
for i in range(3):
    print(A[i])

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define eb emplace_back
#define pb push_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define chmin(x,y) if(x>y)x=y
#define chmax(x,y) if(x<y)x=y
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef priority_queue<ll> PQ;
typedef priority_queue<ll,vector<ll>,greater<ll>> SPQ;
using vi=vector<ll>;
using vvi=vector<vector<ll>>;
using vc=vector<char>;
using vvc=vector<vector<char>>;
const ll inf=100100100100;
const int Inf=1001001001;
const int mod=1000000007;
int main(){
    int n,k;cin>>n>>k;
    vi a,b;
    string s;cin>>s;
    rep(i,n){
        if(s[i]=='1'){
            if(i==0)a.pb(i);
            else if(s[i-1]=='0')a.pb(i);
            if(i==n-1)b.pb(i);
            else if(s[i+1]=='0')b.pb(i);
        }
    }
    ll ans=0;
    rep(i,a.size()-k){
      chmax(ans,b[i+k]-a[i]+1);
    }
    if(a.size()<k){
      chmax(ans,n);
    }
    else{
        chmax(ans,b[k-1]+1);
        chmax(ans,n-a[a.size()-k]);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1404
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
Sum=sum(b)
for i in range (0,len(a)-1):
  if a[i]+1==a[i+1]:
    number=a[i]
    Sum+=c[number-1]
print(Sum)

Measured memory_bytes: 9192
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
	// your code goes here
	ll n,testCase;
	string s;
    cin>>n;
	vector<int>v;
	map<int,int>mp;
	for(int i=0;i<n;i++)
	{
		int x;
		cin>>x;
		mp[x]++;
		v.push_back(x);
	}
	bool f=false;
	for(int i=0;i<v.size();i++)
	{
		if(mp[v[i]]>=2)
		{
			cout<<"NO"<<endl;
			f=true;
			break;
		}
	}
  if(!f){
		cout<<"YES"<<endl;
	}
}

Measured memory_bytes: 10356
N = int(input())
l = list(map(int,input().split()))

l.insert(0,0)
l.append(0)
ans = 0

for i in range(N+1):
  ans += abs(l[i+1]-l[i])

for i in range(N):
  if l[i] <= l[i+1] <= l[i+2] or \
  l[i] >= l[i+1] >= l[i+2]:
    print(ans)
  elif l[i] <= l[i+1]:
    print(ans-abs(l[i+1]-max(l[i],l[i+2]))*2)
  else:
    print(ans-abs(l[i+1]-min(l[i],l[i+2]))*2)

Measured memory_bytes: 14048
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <iostream>
#include <climits>
#include <cfloat>

using namespace std;


int main()
{
	char* button[] = { "", "',.!?", "abcABC", "defDEF", "ghiGHI", "jklJKL"
		, "mnoMNO", "pqrsPQRS", "tuvTUV", "wxyzWXYZ" };

	char buf[11111];
	while (scanf("%s", buf) != EOF)
	{
		int count = 0;
		int prev = buf[0] - '0';
		for (int i = 0; i <= strlen(buf); ++i)
		{
			int push = buf[i] - '0';

			if (push == prev)
			{
				++count;
				if (push == 0 && count > 1)
					putchar(' ');
			}
			else if (push != prev)
			{
				if (prev != 0)
					putchar(button[prev][(count-1) % strlen(button[prev])]);
				count = 1;
			}

			prev = push;
		}

		printf("\n");
	}

	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define REP(i, n) for(int i = 1; i < (int)(n); ++i)
using namespace std;

int main() {
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    while (A > 0 && C > 0) {
        C -= B;
        if (C <= 0) {
            cout << "Yes" << endl;
            return 0;
        }
        A -= D;
        if (A <= 0) {
            cout << "No" << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
#include<cstdio>
using namespace std;
int main()
{
    long long int i,j,k,x,c=0,n;
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>k>>x;
        c+=(x-k)+1;
    }
    cout<<c<<endl;
    return 0;

}



Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<queue>
#include<map>
using namespace std;
typedef long long ll;
#define N 200002
struct edge{int to,nxxt;}e[N];
int n,m,head[N],cnt=1,dep[N],siz[N],sx,sy,leh,fa[N],col[N];
int sz[N][2],b[N],tot;
inline void ins(int u,int v){e[cnt].to=v;e[cnt].nxxt=head[u];head[u]=cnt++;}
void df5(int te,int la)
{siz[te]=dep[te];
	for(int i=head[te];i;i=e[i].nxxt)
	{
		int j=e[i].to;if(j==la)continue;dep[j]=-dep[te];
		df5(j,te);siz[te]+=siz[j];
	}
}
void dfs(int te,int la)
{
	for(int i=head[te];i;i=e[i].nxxt)
	{
		int j=e[i].to;if(j==la)continue;
		if(dep[j]!=-1){sx=te,sy=j;continue;}
		dep[j]=dep[te]+1;fa[j]=te;col[j]=-col[te];dfs(j,te);
	}
}
void clfs(int te,int la)
{
	for(int i=head[te];i;i=e[i].nxxt)
	{
		int j=e[i].to;if(j==la||(sx==te&&sy==j)||(sx==j&&sy==te))continue;
		clfs(j,te);sz[te][0]+=sz[j][0],sz[te][1]+=sz[j][1];
	}
}
void clf5(int te,int la)
{siz[te]=col[te];
	for(int i=head[te];i;i=e[i].nxxt)
	{
		int j=e[i].to;if(j==la||(sx==te&&sy==j)||(sx==j&&sy==te))continue;
		clf5(j,te);siz[te]+=siz[j];
	}
}
int main()
{
	scanf("%d%d",&n,&m);
	if(m==n-1)
	{
		for(int i=1;i<n;i++)
		{
			int x,y;scanf("%d%d",&x,&y);
			ins(x,y);ins(y,x);
		}
		dep[1]=1;df5(1,1);
		ll ans=0;for(int i=2;i<=n;i++)ans+=abs(siz[i]);
		if(siz[1])ans=-1;printf("%lld\n",ans);return 0;
	}
	for(int i=1;i<=m;i++)
	{
		int x,y;scanf("%d%d",&x,&y);
		ins(x,y);ins(y,x);
	}memset(dep,-1,sizeof(dep));dep[1]=0;
	fa[1]=1;col[1]=1;dfs(1,1);
	int tx=sx,ty=sy;
	while(dep[tx]>dep[ty])tx=fa[tx],leh++;
	while(dep[ty]>dep[tx])ty=fa[ty],leh++;
	while(tx^ty)tx=fa[tx],ty=fa[ty],leh+=2;
	if(leh%2==0)
	{
		int wt=0,bl=0;
		for(int i=1;i<=n;i++)
		{
			if(dep[i]&1)wt++;else bl++;
		}
		if(abs(wt-bl)&1){puts("-1");return 0;}
		clf5(1,1);ll tv=siz[1]/2;
		col[sx]-=tv,col[sy]-=tv;
		ll ans=abs(tv);
		clf5(1,1);
		for(int i=2;i<=n;i++)ans+=abs(siz[i]);
		printf("%lld\n",ans);return 0;
	}
	for(int i=1;i<=n;i++)sz[i][1]=col[i];
	sz[sx][0]=1;sz[sy][0]=-1;clfs(1,1);
	if(sz[1][0]||sz[1][1]){puts("-1");return 0;}
	ll ans=0;b[++tot]=0;
	for(int i=1;i<=n;i++)
	{
		if(!sz[i][0])ans+=abs(sz[i][1]);
		else
		{
			if(sz[i][0]==1)b[++tot]=-sz[i][1];
			else b[++tot]=sz[i][1];
		}
	}
	sort(b+1,b+1+tot);ll xv=b[(tot+1)/2];
	for(int i=1;i<=n;i++)if(sz[i][0])ans+=abs(xv*sz[i][0]+sz[i][1]);
	printf("%lld\n",ans+abs(xv));
}
/*
6 6
1 2
2 3
3 1
1 4
1 5
1 6
*/

Measured memory_bytes: 11776
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;
import java.util.Set;
import java.util.HashMap;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        GoodSequence solver = new GoodSequence();
        solver.solve(1, in, out);
        out.close();
    }

    static class GoodSequence {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            HashMap<Long, Long> map = new HashMap<>();
            for (int i = 0; i < n; i++) {
                long a = in.nextLong();
                map.put(a, map.getOrDefault(a, 0L) + 1);
            }

            long result = 0;
            Set<Long> keys = map.keySet();
            for (Long key : keys) {
                Long v = map.get(key);
                if (key < v) {
                    result += Math.min(v, v - key);
                } else if (v < key) {
                    result += v;
                }
            }
            out.println(result);
        }

    }
}



Measured memory_bytes: 64792
n,m=map(int,input().split())
students=[]
checkpoints=[]
for i in range(n):
  a,b=map(int,input().split())
  students.append((a,b))
for i in range(m):
  c,d=map(int,input().split())
  checkpoints.append((c,d))
dist_min=[]
for i in range(n):
  dist=[]
  for j in range(m):
    dist.append(abs(students[i][0]-checkpoints[j][0])+abs(students[i][1]-checkpoints[j][1]))
  dist_min.append(dist.index(min(dist))+1)
for i in range(n):
  print(dist_min[i])

Measured memory_bytes: 3064
x1, y1, x2, y2 = map(int, input().split())

x3, y3 = x2 - (y2-y1), y2 + (x2-x1)
x4, y4 = x1 - (y2-y1), y1 + (x2-x1)

print(x3, y3, x4, y4)


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

int main() {
  int x, a, b;
  cin >> x >> a >> b;
   if (b <= a) cout << "delicious" << endl;
  else if (b - a <= x) cout << "safe" << endl;
  else cout << "dangerous" << endl;
  return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
int main(){
  int N;
  cin >> N;
  int ans=0;
  rep(i,N){
    int a;
    cin >> a;
    while(a%2==0){
      ans++;
      a/=2;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
def gcd(*numbers): reduce(math.gcd, numbers)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
count = 0
ans = 0

A, B, N = I()

print(math.floor(A*min(B-1,N)/B))


Measured memory_bytes: 10096
#include <stdio.h>
#include <math.h>
#include <string.h>

int main(void)
{
	int ginkou;
	double year;
	int bank_num;
	int syurui;
	double nenri;
	double max;
	int max_bank;
	double money[100];
	int i;
	
	while (1)
	{
		scanf("%d", &ginkou);
		
		if (ginkou == 0){
			break;
		}
		
		scanf("%lf", &year);
		
		memset(money, 0, sizeof(money));
		max = 0;
		for (i = 0; i < ginkou; i++){
			scanf("%d%lf%d", &bank_num, &nenri, &syurui);
			
			if (syurui == 1){
				money[i] = 1.00 + year * (nenri / 100);
			}
			else {
				money[i] = pow(1.00 + (nenri / 100), year);
			}
			
			if (money[i] > max){
				max = money[i];
				max_bank = bank_num;
			}
		}
		
		printf("%d\n", max_bank);
	}
	
	return (0);
}

Measured memory_bytes: 0
#include "iostream"
#include "string.h"
using namespace std;
 
int main(){
 
  string N;
  
  cin >> N;
 
  if(N[N.size()-1] == '3') cout <<"bon";
  else if(N[N.size()-1] == '0' || N[N.size()-1] == '1' || N[N.size()-1] == '6' || N[N.size()-1] == '8') cout <<"pon";
  else cout << "hon";
  
  
  return 0;
  
}

Measured memory_bytes: 3628
N, K, Q = map(int, input().split())
points = [K-Q]*(N)
for i in range(Q):
    A = int(input())
    A -= 1
    points[A] += 1
# print(points)
for p in points:
    if p >0:
        print("Yes")
    else:
        print("No")

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

int main() {
  vector<int> a(4);
  while (cin >> a[0] >> a[1] >> a[2] >> a[3]) {
    map<int, int> mp;
    for (int i = 0; i < 4; ++i) mp[a[i]] = i + 1;
    int hit = 0, blow = 0;
    for (int i = 0; i < 4; ++i) {
      int b; cin >> b;
      if (mp[b] > 0) {
        ++( (i + 1 == mp[b]) ? hit : blow );
      }
    }
    cout << hit << ' ' << blow << endl;
  }
  return 0;
}



Measured memory_bytes: 3120
//
//  main.cpp
//

#include <algorithm>
#include <array>
#include <assert.h>
#include <iomanip>
#include <iostream>
#include <limits>
#include <math.h>
#include <memory>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = int64_t;
using ull = uint64_t;

template<typename T>
vector<T> make_vec_nd(T init, ll size) {
    return vector<T>(size, init);
}
template<typename T, typename... Args>
auto make_vec_nd(T init, ll size, Args... rest) {
    auto inner = make_vec_nd(init, rest...);
    return vector<decltype(inner)>(size, inner);
}

#define rep(i,a,b) for(ll i=(a);i<(b);i++)
#define rrep(i,a,b) for(ll i=(a)-1;i>=(b);i--)

int main() {
    ll X;
    cin >> X;
    ll Y = X % 100;
    auto dp = make_vec_nd(numeric_limits<ll>::max(), 6, 101);
    dp[0][0] = 0;
    rep(n,1,6) {
        rep(y,0,101) {
            dp[n][y] = dp[n-1][y];
            if (y >= n) {
                dp[n][y] = min(dp[n][y], 1+dp[n][y-n]);
            }
        }
    }
    ll sum = dp[5][Y];
    if (sum <= X/100) {
        cout << 1 << endl;
    } else {
        cout << 0 << endl;
    }
}



Measured memory_bytes: 256
_ = input()
l = map(int,raw_input().strip().split())
n = int(raw_input())
for x in xrange(n):
	a = map(int,raw_input().strip().split())
	temp = l[a[0]-1]
	l[a[0]-1] = a[1]
	print(sum(l))
	l[a[0]-1] = temp

Measured memory_bytes: 2568
N = input()
A = input().split(" ")
B = input().split(" ")
C = input().split(" ")
total = 0


for i in range(int(N)):
    #print(i)
    #print(B[int(A[i])-1])
    total = total + int(B[int(A[i])-1])
    if i > 0 and i < int(N) and int(A[i-1]) == int(A[i])-1:
        #print(C[int(A[i-1])-1])
        #print(int(A[i-1]))
        total = total + int(C[int(A[i-1])-1])

print(total)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#include<string>
#define ll long long
#define lld long double
#define llu unsigned long long int
#define pb push_back
#define mp make_pair
#define fir first
#define sec second
#define gll(a,n) for(ll i=0;i<n;i++) cin>>a[i];
#define mod 1000000007
#define mod1 998244353
#define pi 3.1415926535897
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("B-small-attempt0.in", "r", stdin);freopen("output.txt", "w", stdout);
    //std::cout << std::setprecision(9);
    //std::cout << std::fixed;
    ll n,i;
    cin>>n;
    ll a[n];
    gll(a,n);
    ll sum=0;
    for(i=0;i<n;i++)
        sum+=a[i];
    ll ans=LONG_LONG_MAX,cnt=0;
    for(i=0;i<n;i++)
    {
        cnt+=a[i];
        ll x=sum-cnt;
        ans=min(ans,abs(cnt-x));
    }
    cout<<ans;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll a[200000];

void f()
{
    int i;
    for(i=1;i<=9;i++)
        a[i]=i;
    int k=10;
    for(i=1;k<=100000;i++)
    {
        int t=a[i]%10;
        for(int j=-1;j<2;j++)
        {
            if(t+j>=0&&t+j<=9)
                a[k++]=a[i]*10+t+j;
        }
    }
}

int main()
{
    int n;
    f();
    while(cin>>n)
    {
        cout<<a[n]<<endl;
    }
    return 0;
}


Measured memory_bytes: 1024
n,m=map(int,input().split())
w={}
for i in range(m):
    a,b=map(int,input().split())
    if a in w: w[a].add(b)
    else: w[a]=set([b])
    if b in w: w[b].add(a)
    else: w[b]=set([a])

d=[-1]*(n+1)
p=set([1])
q=set([])
d[1]=0
f=1
while 1:
    if f%2:
        for i in p:
            for j in w[i]:
                if d[j]==-1 or f<d[j]:
                    d[j]=f
                    q.add(j)
        p=set([])
        if len(q)==0: break
    else:
        for i in q:
            for j in w[i]:
                if d[j]==-1:
                    d[j]=f
                    p.add(j)
        q=set([])
        if len(p)==0: break
    f+=1
#print(d)
print("Yes")
for i in range(2,n+1):
    for j in w[i]:
        if d[j]+1==d[i]:
            print(j)
            break


Measured memory_bytes: 138660
#include<bits/stdc++.h>
using namespace std;
typedef long long lint;
template<typename TP>inline void read(TP &tar)
{
	TP ret=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){ret=ret*10+(ch-'0');ch=getchar();}
	tar=ret*f;
}
template<typename TP,typename... Args>inline void read(TP& t,Args&... args){read(t),read(args...);}
namespace RKK
{
const int N=200011;

struct pat
{
	int x,y,p;
	pat(int x=0,int y=0,int p=0):x(x),y(y),p(p){}
	bool operator<(const pat &a)const{return x*a.y-a.x*y<0;}
}pt;
int n,fa[N],a[N],bc[N],f[N],size[N];int find(int x){return f[x]==f[f[x]]?f[x]:f[x]=find(f[x]);}
priority_queue<pat> q;
lint ans;
int main()
{
	read(n);for(int i=2;i<=n;i++) read(fa[i]);for(int i=1;i<=n;i++) read(a[i]),f[i]=i,size[i]=1;
	for(int i=2;i<=n;i++)if(!a[i]) f[i]=find(fa[i]),size[f[i]]+=size[i];
	for(int i=1;i<=n;i++)if(a[i]) bc[i]=1,size[i]--,ans+=size[i];
	for(int i=2;i<=n;i++)if(a[i]) q.push(pat(size[i],bc[i],i));
	for(int i=1;i<=n;i++) fa[i]=find(fa[i]);for(int i=1;i<=n;i++) f[i]=i;
	while(!q.empty())
	{
		pt=q.top(),q.pop();
		int x=pt.p,y=find(fa[x]);
		if(!y||pt.x!=size[x]) continue;
		ans+=1ll*bc[y]*size[x],size[y]+=size[x],bc[y]+=bc[x],f[x]=y;
		q.push(pat(size[y],bc[y],y));
	}
	printf("%lld\n",ans);
	return 0;
}
}
int main(){return RKK::main();}

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

int main() {
    cin.tie(0)->sync_with_stdio(false);

    string s;
    cin >> s;
    int n = s.size();

    REP(i, n) {
        if (s[i] == '?') cout << 'D';
        else cout << s[i];
    }
    cout << '\n';
    return 0;
}

Measured memory_bytes: 3752
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<complex>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
#include <numeric>
using namespace std;
using Complex = complex<double>;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1145141919810364364LL;
const double EPS = 1e-10;
double PI = acos(-1.0);
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)

class Point {
public:
	double x, y;

	Point(double x = 0, double y = 0) :x(x), y(y) {}
	Point operator + (Point p) { return Point(x + p.x, y + p.y); }
	Point operator - (Point p) { return Point(x - p.x, y - p.y); }
	Point operator * (double a) { return Point(a*x, a*y); }
	Point operator / (double a) { return Point(a / x, a / y); }
	bool operator < (Point p) { return (x != p.x) ? (x < p.x):(y < p.y); }
	bool operator == (Point p) { return (fabs(x-p.x) < EPS) && (fabs(y-p.y) < EPS); }
	
	double abs() { return sqrt(norm()); }
	double norm() { return x * x + y + y; }
	double equals(double a, double b) { return fabs(a-b) < EPS; }

	double dot(Point b) { return x * b.x + y * b.y; }
	double cross(Point b) { return x * b.y - y*b.x; }

	bool isOrthogonal(Point b) { return equals(this->dot(b),0.0); }
	bool isParallel(Point b) { return equals(this->cross(b),0.0); }

};
typedef Point Vector;


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

	int Q;
	cin >> Q;
	for (int i = 0; i < Q; i++) {
		int xp0, yp0, xp1, yp1, xp2, yp2, xp3, yp3;
		cin >> xp0 >> yp0 >> xp1 >> yp1 >> xp2 >> yp2 >> xp3 >> yp3;
		Vector v0(xp0, yp0);
		Vector v1(xp1, yp1);
		Vector v2(xp2, yp2);
		Vector v3(xp3, yp3);
		v0 = v0 - v1;
		v2 = v2 - v3;
		if (v0.isParallel(v2))puts(2);
		else if (v0.isOrthogonal(v2))puts(1);
		else puts(0);
	}
	return 0;
}


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

using namespace std;


#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()

#define int long long

#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second

template <typename T>
void print(T x)
{
	std::cout << x <<" " ;
}


template <typename T>
void println(T x)
{
	std::cout << x << "\n";
}


signed main(void) {
	char s;
	cin >> s;
	printf("%c", s+1);
}

Measured memory_bytes: 384
#include <stdio.h>
#define MAX 100000
#define NIL -1

typedef struct{
  int p;
  int l;
  int r;
}Tree;

Tree T[MAX];


 /*??±????????°??????*/
int getDepth(int x){

  int dep=0;

  while(T[x].p != NIL){
    x = T[x].p;
    dep++;
  }
  return dep;
}

void Print(x){

  int a;
 
  if(T[x].p == NIL) printf("node %d: parent = %d, depth = %d, root, ",x,T[x].p,getDepth(x));
  else if(T[x].l == NIL) printf("node %d: parent = %d, depth = %d, leaf, ",x,T[x].p,getDepth(x));
  else printf("node %d: parent = %d, depth = %d, internal node, ",x,T[x].p,getDepth(x));   
 
  printf("[");
  a = x;
 
  if(T[a].l != NIL){
    printf("%d", T[x].l);
    if(T[T[x].l].r == NIL) printf("]\n");
    else printf(",");
    a = T[a].l;

    while(T[a].r != NIL){
      printf(" %d",T[a].r);
      if(T[T[a].r].r == NIL) printf("]\n");
      else printf(",");
      a = T[a].r;
    }
  }
   
  else printf("]\n");
}


int main(void){

  int n,i,j,a,b,c,r;

  scanf("%d",&n);
  for(i = 0; i < n; i++){
    T[i].p = NIL;
    T[i].l = NIL;
    T[i].r = NIL;    
  }

  for(i = 0; i < n; i++){
    scanf("%d %d",&a,&b);
    for(j = 0; j < b; j++){
      scanf("%d",&c);
      T[c].p = a;
      if(j == 0) T[a].l = c;
      else if (j >= 1) T[r].r = c;
      r = c;
    }
  }

  //for(i = 0; i <n; i++) getDepth(i);
  for(i = 0; i <n; i++) Print(i);

  return 0;
}

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

int main(){
  int a, b,c,k;
  cin >> a >> b >> c >> k;
  int q=max(a,c);
  int p=max(a,b);
  int key = max(q,p);
  int ans = a+b+c-key;
  for(int i=0;i<k;i++){key = 2*key;}
  cout << ans+key << endl;
}

Measured memory_bytes: 256
package main

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

func main() {
	sc := NewScanner()

	n := sc.ReadInt()
	m := sc.ReadInt()
	q := sc.ReadInt()
	abcds := make([]ABCD, q)
	for i := 0; i < q; i++ {
		a := sc.ReadInt()
		b := sc.ReadInt()
		c := sc.ReadInt()
		d := sc.ReadInt()
		abcds[i] = ABCD{a, b, c, d}
	}

	combinations := generateCombinations(1, m, n, 0)

	maxScore := 0
	for _, combi := range combinations {
		score := computeScore(abcds, combi)
		if score > maxScore {
			maxScore = score
		}
	}

	fmt.Println(maxScore)
}

func generateCombinations(min, max, n, nCur int) []SeqA {
	if nCur == n {
		return []SeqA{make(SeqA, n)}
	}

	combinations := make([]SeqA, 0)
	for i := min; i <= max; i++ {
		combinationsForI := generateCombinations(i, max, n, nCur+1)
		for _, combi := range combinationsForI {
			combi[nCur] = i
		}
		combinations = append(combinations, combinationsForI...)
	}
	return combinations
}

func computeScore(abcds []ABCD, seqA SeqA) int {
	totalD := 0
	for _, abcd := range abcds {
		if seqA[abcd.B-1]-seqA[abcd.A-1] == abcd.C {
			totalD += abcd.D
		}
	}
	return totalD
}

type SeqA []int

type ABCD struct {
	A int
	B int
	C int
	D int
}

// util
// *   math/simple

func Abs(x int) int {
	if x >= 0 {
		return x
	}
	return -x
}

func Min(values ...int) int {
	if len(values) == 0 {
		panic("no values")
	}
	min := values[0]
	for _, v := range values {
		if v < min {
			min = v
		}
	}
	return min
}

func Max(values ...int) int {
	if len(values) == 0 {
		panic("no values")
	}
	max := values[0]
	for _, v := range values {
		if v > max {
			max = v
		}
	}
	return max
}

func Pow(base int, exponent uint) int {
	answer := 1
	for i := uint(0); i < exponent; i++ {
		answer *= base
	}
	return answer
}

// *   io

type Scanner struct {
	bufScanner *bufio.Scanner
}

func NewScanner() *Scanner {
	bufSc := bufio.NewScanner(os.Stdin)
	bufSc.Split(bufio.ScanWords)
	bufSc.Buffer(nil, 100000000)
	return &Scanner{bufSc}
}

func (sc *Scanner) ReadString() string {
	bufSc := sc.bufScanner
	bufSc.Scan()
	return bufSc.Text()
}

func (sc *Scanner) ReadInt() int {
	bufSc := sc.bufScanner
	bufSc.Scan()
	text := bufSc.Text()

	num, err := strconv.Atoi(text)
	if err != nil {
		panic(err)
	}
	return num
}


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

int main(){
  int k, x, start, end;
  cin >> k >> x;
  start = x - (k - 1);
  end = x + (k - 1);
  if (start < -1000000){
    start = -1000000;
  }
  if (end > 1000000){
    end = 1000000;
  }

  for (int i = start; i <= end; i++){
    if(i == end){
      cout << i << endl;
    }else{
      cout << i << " ";
    }
  }
}

Measured memory_bytes: 256
N = int(input())
P = list(map(int, input().split()))

isPossible = True
for k in range(N-1):
    if P[k] > P[k+1]:
        isPossible = False
if isPossible:
    print("YES")
    exit()


for i in range(N):
    for j in range(i+1, N):
        newList = P.copy()
        newList[i], newList[j] = newList[j], newList[i]
        isPossible = True
        for k in range(N-1):
            if newList[k] > newList[k+1]:
                isPossible = False

        if isPossible:
            print("YES")
            exit()
print("NO")


Measured memory_bytes: 67684
#include<stdio.h>
int main(void)
{
	long int  i,n;
	long long int num;

	scanf("%ld", &n);
	num = 1;
	for (i =1; i <= n; i++)
	{
		num = num*i;
		num = num % (1000000000 + 7);

	}
	
	printf("%lld\n", num);

	return 0;
}

Measured memory_bytes: 128
// 失敗するからこそ そこから立ち向かって行く強さがあってそんな強さが本当の強さだと私は思うから
// ぜったいあきらめない
#if defined(DAIJOBU)
#include "/home/ichigo/includes.hpp"
#include "/home/ichigo/debug.hpp"
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#include <bits/stdc++.h>
#define deb(x...)
#endif
#define FIO {ios::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);}

using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());


int main(){
	FIO
	
	int a, b, c;
	set<int> s;
	cin >> a >> b >> c;
	s.insert({a, b, c});
	cout << s.size() << '\n';
	return 0;
}


Measured memory_bytes: 256
while True:
	m, f, r = map(int, input().split())

	if m == -1 and f == -1 and r == -1:
		break
	
	if m == -1 or f == -1:
		print('F')
	elif m + f >= 80:
		print('A')
	elif 65 <= m + f < 80:
		print('B')
	elif 50 <= m + f < 65:
		print('C')
	elif 30 <= m + f < 50:
		if r >= 50:
			print('C')
		else:
			print('D')
	elif m + f < 30:
		print('F')



Measured memory_bytes: 5596
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		long Inf = (long) 1e18;
		
		long[] clk = new long[N + 1];
		long[] clkm = new long[N + 1];
		for(int i=0;i<=N;i++) clkm[i] = -Inf;
		
		clkm[0] = 0;
		for(int i=0;i<N;i++){
			clk[i + 1] = clk[i] - (X[i] - (i > 0 ? X[i - 1] : 0)) + V[i];
			clkm[i + 1] = Math.Max(clkm[i], clk[i + 1]);
		}
		
		long[] iclk = new long[N + 1];
		long[] iclkm = new long[N + 1];
		for(int i=0;i<=N;i++) iclkm[i] = -Inf;
		
		iclkm[0] = 0;
		for(int i=0;i<N;i++){
			iclk[i + 1] = iclk[i] - ((C - X[N - 1 - i]) - (i > 0 ? (C - X[N - 1 - (i - 1)]) : 0)) + V[N - 1 - i];
			iclkm[i + 1] = Math.Max(iclkm[i], iclk[i + 1]);
		}
		
//Console.WriteLine("clk:{0}",String.Join(" ",clk));		
//Console.WriteLine("clkm:{0}",String.Join(" ",clkm));		
//Console.WriteLine("iclk:{0}",String.Join(" ",iclk));		
//Console.WriteLine("iclkm:{0}",String.Join(" ",iclkm));		
		
		long max = iclkm[N];
		for(int i=0;i<N;i++){
			long c = clk[i+1];
			c -= X[i];
			c += iclkm[N - (i + 1)];
//Console.WriteLine("clk - iclk : i:{0}, c;{1}",i, c);			
			max = Math.Max(max, c);
		}
		
		max = Math.Max(max, clkm[N]);
		for(int i=0;i<N;i++){
			long c = iclk[i+1];
			c -= C - X[N - 1 - i];
			c += clkm[N - (i + 1)];
//Console.WriteLine("iclk - clk : i:{0}, c;{1}",i, c);			
			max = Math.Max(max, c);
		}
		
		Console.WriteLine(max);
		
	}
	int N;
	long C;
	long[] X,V;
	public Sol(){
		var d = rla();
		N = (int) d[0]; C = d[1];
		X = new long[N];
		V = new long[N];
		for(int i=0;i<N;i++){
			d = rla();
			X[i] = d[0]; V[i] = d[1];
		}
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 19780
import sys
a,b,c = map(int, input().split())
if a == b and b == c:
    count=0
    print(count)
    sys.exit()
    
ls = [a,b,c]
ls.sort(reverse=True)
count = 0

if (ls[1]-ls[2])%2 != 0:
    ls[2] = ls[2]+1
    ls[0] = ls[0]+1
    count +=1

while ls[1] - ls[2] >= 2:
    ls[2] += 2
    count += 1

if ls[1] - ls[2] == 1:
    ls[2] += 1
    count +=1

dif = ls[0] - ls[1]
count = count + dif

print(count)

Measured memory_bytes: 3064
n = gets.to_i
dp = Array.new(n+1,n)
dp[0] = 0
0.upto(n-1) do |i|
  dp[i+1] = dp[i]+1 if dp[i+1] > dp[i]+1
  bit6 = 6
  while i+bit6 <= n
    dp[i+bit6] = dp[i]+1 if dp[i+bit6] > dp[i]+1
    bit6 *= 6
  end
  bit9 = 9
  while i+bit9 <= n
    dp[i+bit9] = dp[i]+1 if dp[i+bit9] > dp[i]+1
    bit9 *= 9
  end
end
puts dp[n]


Measured memory_bytes: 14868
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#include <algorithm>
using namespace std;

int main(){
    int n;
    cin >> n;
    if(n % 2 == 0){
        cout << n << endl;
    } else {
        cout << 2*n << endl;
    }
    return 0;
}


Measured memory_bytes: 256
// Best practice
 
#include<bits/stdc++.h>
 
#define int         long long
#define pb          push_back
#define pf          emplace_front
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
#define pii 		pair<int,int>
#define psi 		pair<string,int>
#define vi 			vector<int>
#define vpii  		vector<pii>
#define vvi 		vector<vi>
#define sz(x)	    (int)(x).size()
#define x           first
#define y           second
#define endl        '\n'
#define tezz        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define MOD         1000000007
#define hell        998244353
#define prec(n) 	fixed<<setprecision(n)
#define ini(a, i) 	memset(a, i, sizeof(a))
#define output(x)   cout << (x ? "YES" : "NO")<<endl;
using namespace std;
 
#define debug(vec) cout<<(#vec)<<" : [ "; for (auto& i: vec) cout<<i<<" "; cout<< "]" << endl
#define debugp(vec) cout<<(#vec)<<" : [ "; for (auto& i: vec) cout<<"("<<i.x<<","<<i.y<<")"<<" "; cout<< "]" << endl
#define trace(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args);cout << endl; }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << "[" << *it << ": " << a << "]\t";
    err(++it, args...);
}
 
// const int dx[4] = { -1, 1, 0, 0};
// const int dy[4] = {0, 0, -1, 1};
// int dX[] = { -1, -1, -1, 0, 0, 1, 1, 1 };
// int dY[] = { -1, 0, 1, -1, 1, -1, 0, 1 };
 
 
// Code from Here -------------------------------------------------------------------------------
 
int dp[200005];

int count(string s, int c){
	int n=s.length(), pw=1, ans=0;
	for(int i=n-1; i>=0; i--){
		if(s[i]=='1'){
			ans+=pw;
			ans%=c;
		}
		// trace(c, ans);
		pw*=2;
		pw%=c;
	}
	return ans;
}

signed main() {
	tezz
 

	int n;
	cin >> n;
	string s;
	cin >> s;
	int m=0, c=0;
	for(int i=0; i<n; i++){
		if(s[i]=='1')c++;
	}
	int ans[n], pw1=1, pw2=1, pw3=1;
	dp[0]=0;
	dp[1]=dp[2]=1;
	for(int i=3; i<=200002; i++){
		dp[i] = dp[i%__builtin_popcount(i)]+1;
	}	
	int x1;
	if(c>1)x1 = count(s, c-1);
	int x2 = count(s, c);
	int x3 = count(s, c+1);
	// if(c==0){
	// 	for(int i=0; i<n; i++)cout << 1 << endl;
	// 		return 0;
	// }
	for(int i=n-1; i>=0; i--){
		int C=c;
		if(s[i]=='0'){
			ans[i]=dp[(x3 + pw3)%(c+1)]+1;
		}
		else{
			if(c<=1){
				ans[i] = 0;
			}
			else ans[i]=dp[((x1 - pw1 + c-1)%(c-1)+(c-1)%(c-1))]+1;
		}		
		// trace(pw1, pw2, pw3);
		pw1*=2;pw2*=2;pw3*=2;
		if(c>1)pw1%=(c-1);
		pw2%=(c);pw3%=(c+1);
	}
	// trace(x1, x2, x3);
	for(int i=0; i<n; i++)cout << ans[i] << endl;
 
	return 0;
}  

Measured memory_bytes: 6856
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef vector<long long> vi;
const int MX = 2e5 + 5;
#define f(i, x, n) for (int i = x; i < n; i++)
#define int long long
#define w(t)  \
    int t;    \
    cin >> t; \
    while (t--)
#define pb push_back
#define endl "\n"
#define yes cout << "YES" << endl
#define no cout << "NO" << endl

int32_t main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else
    // online submission
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    int x;
    cin >> x;
    if (x >= 400 && x < 600)
    {
        cout << "8" << endl;
    }
    else if (x >= 600 && x < 800)
    {
        cout << "7" << endl;
    }
    else if (x >= 800 && x < 1000)
    {
        cout << "6" << endl;
    }
    else if (x >= 1000 && x < 1200)
    {
        cout << "5" << endl;
    }
    else if (x >= 1200 && x < 1400)
    {
        cout << "4" << endl;
    }
    else if (x >= 1400 && x < 1600)
    {
        cout << "3" << endl;
    }
    else if (x >= 1600 && x < 1800)
    {
        cout << "2" << endl;
    }
    else if (x >= 1800 && x < 2000)
    {
        cout << "1" << endl;
    }

    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << "s\n";
    return 0;
}


Measured memory_bytes: 3808
#include <stdio.h>
#include <string.h>

int main()
{
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	bool f = 0;
	for (int i = 0;i <= 100;i++)
	{
		if (i * a % b == c) f = 1;
	}
	if (f) puts("YES");
	else puts("NO");
	return 0;
}

Measured memory_bytes: 128
"use strict";

function Main(input) {
	input = input.split(" ");
    const a = parseInt(input[0], 10);
    const b = parseInt(input[1], 10);
    const k = parseInt(input[2], 10);

    let candidateCount = 0;
    let answer = 0;
    for (let i = 100; i > 0; i--) {
        if (a % i == 0 && b % i == 0) {
            candidateCount++;
        }

        if (candidateCount == k) {
            answer = i;
            break;
        }
    }

    console.log(answer);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
object Main {
  def main(args: Array[String]): Unit = {
    val in = io.Source.fromInputStream(System.in).getLines()
    val N = in.next().toInt
    val A = in.next().split(' ') map (_.toInt)
    System.out.println(solve(N, A))
  }

  def solve(N: Int, A: Array[Int]): Int = {
    ((-100 to 100) map { i =>
      (A.indices map { j =>
        val d = i - A(j)
        d * d
      }).sum
    }).min
  }
}

Measured memory_bytes: 26032
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<stack>
using namespace std;

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

signed main() {
	int N;
	int a[100005];
	cin >> N;
	REP(i, N) {
		cin >> a[i];
	}

	int ans = 1;
	int inc = 1;
	for (int i = 1;i < N;i++) {
		if (a[i] > a[i - 1]) {
			inc++;
		}
		else if (a[i] < a[i - 1]) {
			inc = 1;
		}

		//cout << inc << endl;

		ans = max(ans, inc);
	}

	int dec = 1;
	for (int i = 1;i < N;i++) {
		if (a[i] < a[i - 1]) {
			dec++;
		}
		else if (a[i] > a[i - 1]) {
			dec = 1;
		}

		//cout << dec << endl;

		ans = max(ans, dec);
	}


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

Measured memory_bytes: 3864
import math
n=int(input())
a=[int(i) for i in input().split()]
b=[1 if i + 1 ==j else 0 for i,j in enumerate(a)]

n=0
x=0
for i in b:
  if i==1:
    n+=1
  else:
    if n!=0:
      x+=math.ceil(n/2)
    n=0

print(x+math.ceil(n/2))

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

// Define
using ll = int64_t;
using ul = uint64_t;
using ld = long double;
const ll MOD = 1e9 + 7;
const ll INF = LONG_MAX;
const ul MAX = ULONG_MAX;
const char nl = '\n';

#define elif else if
#define def inline auto
#define run __attribute__((constructor)) def _

// Debug
#define debug(x) cerr << (x) << " (L:" << __LINE__ << ")" << '\n'

// Loop
#define inc(i, a, n) for (ll i = (a), _##i = (n); i < _##i; ++i)
#define dec(i, a, n) for (ll i = (a), _##i = (n); i > _##i; --i)
#define rep(i, n) inc(i, 0, n)
#define be(c) begin(c), end(c)

// Stream
#define fout(n) cout << fixed << setprecision(n)
#define fasten cin.tie(0), ios::sync_with_stdio(0)

// Speed
run() { fasten, fout(10); }
#pragma GCC optimize("-O3")
#pragma GCC target("avx")

// Math
inline ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

signed main(){
    using pii = pair<int, int>;
    const pii npos(-1, -1);
    int N;
    cin >> N;
    vector<pii> rs(N), bs(N);
    rep(i, N) cin >> rs[i].first >> rs[i].second;
    rep(i, N) cin >> bs[i].first >> bs[i].second;

    int ans = 0;
    sort(be(bs));
    rep(i, N) {
        const auto& b = bs[i];
        int maxy = -1;
        int match = -1;
        rep(j, N) {
            if (rs[j] == npos) continue;
            if (rs[j].first < b.first && rs[j].second < b.second &&
                maxy < rs[j].second) {
                maxy = rs[j].second;
                match = j;
            }
        }
        if (-1 < maxy) {
            rs[match] = npos;
            ++ans;
        }
    }
    cout << ans << nl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
#define rep(i, a, b) for(int i = a, i##_END_ = b; i < i##_END_; ++i)
#define per(i, a, b) for(int i = (b)-1, i##_BEGIN_ = a; i >= i##_BEGIN_; --i)
#define foreach(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); ++it)
#ifdef Leefir
	#define ast(x) assert(x)
	#define dig(...) fprintf(stderr, __VA_ARGS__)
#else
	#define ast(x) ;
	#define dig(...) ;
#endif
#define showtime dig("%.6lf\n", clock()/(double)CLOCKS_PER_SEC);
typedef long long ll;
typedef double db;
const int inf = (int)1e9;
const ll linf = (ll)1e18;
typedef pair<int, int> pii;
typedef vector<int> vi;
#define x first
#define y second
#define pb(x) push_back(x)
#define sz(x) (int)(x).size()

template<class TAT>
inline void read(TAT &res){
	char c; res = 0;
	bool neg = false;
	while(c = getchar(), c != '-' && (c < '0' || c > '9'));
	if(c == '-') neg = true, c = getchar();
	do res = (res*10) + (c^48);
	while(c = getchar(), c >= '0' && c <= '9');
	if(neg) res = -res;
}
template<class TAT>
inline void print(TAT x){
	if(x == 0){ putchar('0'); return;}
	if(x < 0){ putchar('-'); x = -x;}
	static char stk[30];
	int top = 0;
	while(x) stk[++top] = x%10^48, x /= 10;
	while(top) putchar(stk[top--]);
}
namespace Program{

const int N = (int)1e5;
//1 <= R, C <= 1e8
int r, c, n;
typedef pair<pii, int> pr;
pr w[N*2+5];
inline bool on(int x, int y){
	return (x==0||x==r) || (y==0||y==c);
}
void input(){
	int _n; scanf("%d %d %d", &r, &c, &_n);
	n = 0;
	rep(i, 0, _n){
		int x0, y0, x1, y1;
		read(x0); read(y0); read(x1); read(y1);
		if(on(x0, y0) && on(x1, y1)){
			w[n<<1] = pr(pii(x0, y0), n);
			w[n<<1|1] = pr(pii(x1, y1), n);
			n++;
		}
	}
}
int f(pii a){
	int x = a.x, y = a.y;
	if(y==0) return x;
	if(x==r) return r+y;
	if(y==c) return r+c+(r-x);
	if(x==0) return r+c+r+(c-y);
	ast(false);
}
bool cmp(pr a, pr b){
	return f(a.x) < f(b.x);
}
void Main(){
	dig("______________________________E\n"); 
	input();
	if(n){
		sort(w, w+2*n, cmp);
		static int stk[N*2+5]; int top = 0;
		bool mark[N+5]; memset(mark, false, sizeof mark);
		rep(i, 0, 2*n){
			int t = w[i].y;
			if(!mark[t]){
				mark[t] = true;
				stk[++top] = t;
			}else{
				if(stk[top] != t){ puts("NO"); return;}
				--top;
			}
		}
	}
	puts("YES");
}

} //namespace Program
/*
2s & 256M

*/
int main(){
#ifdef Leefir
	dig("**********************define Leefir**********************\n");
	freopen("data.in", "r", stdin);
//	freopen("data.out", "w", stdout);
#endif
	srand(time(NULL));
	
	Program::Main();
	
	return 0;
}


Measured memory_bytes: 2816
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = (a); i <= (b); ++i)
#define per(i, a, b) for (int i = (a); i >= (b); --i)
#define pb push_back
#define mp make_pair
#define pr pair<int, int>
#define x first
#define y second
using namespace std;

template<typename T>
void read(T& n){
  char ch; int sign = 1;
  while (!isdigit(ch = getchar())) if (ch == '-') sign = -1;
  n = ch - '0';
  while (isdigit(ch = getchar())) n = n * 10 + ch - '0';
  n *= sign;
}
typedef long long ll;
const int INF = 1e9 + 7;
int n;
char s[15];

int ask(int x){ 
  printf("%d\n", x);
  fflush(stdout);
  scanf("%s", s);
  if (!strcmp(s, "Vacant")) exit(0);
  return !strcmp(s, "Male");
}

int main(){
  read(n);
  int s = ask(0);
  int l = 0, r = n;
  while(l + 1 < r){
    int mid = (l + r) >> 1;
    int x = ask(mid);
    if ((mid - l + 1) & 1){
      if (s == x) l = mid, s = x;
      else r = mid;
    } else {
      if (s != x) l = mid, s = x;
      else r = mid;
    }
  }
  return 0;
}

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

const int N=1e5+5;
int n,k;
char s[N];

int main()
{
	scanf("%d%d",&n,&k);int i;
	scanf("%s",s+1);
	for(i=1;i<=n;++i)
	{
		if(i!=k) printf("%c",s[i]);
		else printf("%c",s[i]+32);
	}printf("\n");
	return 0;
}

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

int main()
{
  int n;
  cin >> n;
  set<string> S;
  string s;
  for(int i = 0; i < n; i++){
    cin >> s;
    S.insert(s);
  }
  cout << S.size() << endl;
  return 0;
}


Measured memory_bytes: 19084