akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int week = sc.nextInt();
        double result = 100000;
        double debt = check(week, result);
        System.out.println((int)debt);
    }

    public static double check(int week, double result){
        if(week == 0)
            return result;
        else
            return check(--week, Math.ceil(result * 1.05 / 1000) * 1000);
        }
    }



Measured memory_bytes: 26160
#include <stdio.h>
#include <stdlib.h>
#define LENGTH 1200

int is_lowercase(char c) {
    if ('a' <= c && c <= 'z') {
        return 1;
    }
    return 0;
}

int is_uppercase(char c) {
    if ('A' <= c && c <= 'Z') {
        return 1;
    }
    return 0;
}

int main(void)
{
    char *str;
    char *s_ptr;

    str = (char *)malloc(sizeof(char) * LENGTH);

    fgets(str, LENGTH, stdin);

    s_ptr = str;
    while (*s_ptr != '\0') {    
        if (is_lowercase(*s_ptr)) {
            *s_ptr = *s_ptr - 'a' + 'A';
        } else if (is_uppercase(*s_ptr)) {
            *s_ptr = *s_ptr - 'A' + 'a';
        }
        s_ptr++;
    }

    printf("%s", str);

    return 0;
}


Measured memory_bytes: 2052
#include<stdio.h>
#include<string.h>
int main(){
  int l,c=0;
  char s[100];
  scanf("%s",s);
  l=strlen(s);
  if(s[0]=='A' && s[l-1]>='a' && s[l-1]<='z' && s[1]>='a' && s[1]<='z'){
    for(int i=2;i<=l-2;i++){
      if(s[i]=='C') c++;
    }
    if(c==1) puts("AC");
    else puts("WA");
  }
    else puts("WA\n");
    return 0;
}


Measured memory_bytes: 128
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>

#define rep(i, n) for(int i = 0; i < (n); ++i)

using namespace std;

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

const int enum_max_n = 14348907;
const int st_max_n = 1 << 24;

int n;
ll d;
ll x[30];
ll y[30];
ll ax[enum_max_n];
ll ay[enum_max_n];
ll bx[enum_max_n];
int st_n;
ll by[st_max_n * 2 - 1];

int enum_cn;
ll* enum_cx;
ll* enum_cy;
void enumerate(ll dx, ll dy, int i){
	if(i == enum_cn){
		*(enum_cx++) = dx;
		*(enum_cy++) = dy;
	}
	else{
		enumerate(dx, dy, i + 1);
		enumerate(dx + x[i], dy + y[i], i + 1);
		enumerate(dx - x[i], dy - y[i], i + 1);
	}
}

ll st_init(int k, int a, int b){
	if(b - a == 1){
		return by[k];
	}
	ll p = st_init(k * 2 + 1, a, (a + b) / 2);
	ll q = st_init(k * 2 + 2, (a + b) / 2, b);
	return by[k] = min(p, q);
}

ll st_query(int s, int t, int k, int a, int b){
	if(t <= a || b <= s){
		return 0;
	}
	if(s <= a && b <= t){
		return by[k];
	}
	ll p = st_query(s, t, k * 2 + 1, a, (a + b) / 2);
	ll q = st_query(s, t, k * 2 + 2, (a + b) / 2, b);
	return min(p, q);
}

int main(){
	scanf("%d%lld", &n, &d);
	rep(i, n){
		scanf("%lld%lld", &x[i], &y[i]);
	}

	int enum_an = n / 2;
	int enum_bn = n - enum_an;
	int an = (int)pow(3, enum_an);
	int bn = (int)pow(3, enum_bn);

	st_n = 1;
	while(st_n < bn){
		st_n <<= 1;
	}

	enum_cn = enum_an;
	enum_cx = ax;
	enum_cy = ay;
	enumerate(0, 0, 0);

	enum_cn = n;
	enum_cx = bx;
	enum_cy = by + st_n - 1;
	enumerate(0, 0, enum_an);

	vector<P> v(bn);
	rep(i, bn){
		v[i] = P(bx[i], by[i + st_n - 1]);
	}
	sort(v.begin(), v.end());
	rep(i, bn){
		bx[i] = v[i].first;
		by[i + st_n - 1] = v[i].second;
	}

	st_init(0, 0, st_n);

	ll result = 0;
	rep(i, an){
		int s = lower_bound(bx, bx + bn, -d - ax[i]) - bx;
		int t = upper_bound(bx, bx + bn, d - ax[i]) - bx;
		if(s < t){
			result = max(-ay[i] - st_query(s, t, 0, 0, st_n), result);
		}
	}
	printf("%lld\n", result);
	return 0;
}

Measured memory_bytes: 823688
#include <stdio.h>
int n;
void cut(int a[],int k){
	int b[200]={0},i,j;
	for(i=0;i<2*n-k;i++){
		b[i]=a[i+k];
	}
	for(j=0;i<2*n;i++,j++){
		b[i]=a[j];
	}
	for(i=0;i<2*n;i++){
		a[i]=b[i];
	}
}
void riffle(int a[]){
	int b[200]={0},i;
	for(i=0;i<n;i++){
		b[2*i]=a[i];
		b[2*i+1]=a[n+i];
	}
	
	for(i=0;i<2*n;i++){
		a[i]=b[i];
	}
}
int main(void){
	int c[200],i,m,k;
	scanf("%d",&n);
	for(i=0;i<2*n;i++){
		c[i]=i+1;
	}
	scanf("%d",&m);
	while(m--){
		scanf("%d",&k);
		if(!k){
			riffle(c);
		}
		else{
			cut(c,k);
		}
	}
	for(i=0;i<2*n;i++){
		printf("%d\n",c[i]);
	}
	return 0;
}

Measured memory_bytes: 600
//
//  main.cpp
//  kyougi
//
//  Created by 寺林 一旭 on 2018/08/27.
//  Copyright © 2018年 寺林 一旭. All rights reserved.
//

#include <iostream>
#include <vector>
#include <algorithm>
#include <stdio.h>
using namespace std;
int main() {
    
    string num;
    vector<int> list;
    while(getline(cin, num))
    {
  
        int a,b;
        sscanf(num.c_str(), "%d %d",&a,&b);
        
        cout << a-b <<endl;
    }
   
    
    return 0;
}



Measured memory_bytes: 3288
N, M = map(int, input().split())
P = []
for i in range(M):
    a, b, c = map(int, input().split())
    P.append((a-1, b-1, -c))

Cost = [float("inf") for i in range(N)]
V = [False for i in range(N)]
Cost[0] = 0
for i in range(N-1):
    for j in P:
        if Cost[j[0]] != float("inf") and Cost[j[1]] > Cost[j[0]] + j[2]:
            if Cost[j[1]] != float("inf"):
                V[j[1]] = True
            Cost[j[1]] = Cost[j[0]] + j[2]     
        if V[j[0]] == True:
            V[j[1]] = True
ans = -Cost[N-1]

for j in P:
    if Cost[j[0]] != float("inf") and Cost[j[1]] > Cost[j[0]] + j[2]:
        if Cost[j[1]] != float("inf"):
            V[j[1]] = True
        Cost[j[1]] = Cost[j[0]] + j[2]    
    if V[j[0]] == True:
        V[j[1]] = True

print("inf" if V[N-1] else ans)

Measured memory_bytes: 3436
#include<bits/stdc++.h>
#define PI acos(-1.0)
#define pb push_back
#define F first
#define S second
using namespace std;
typedef long long ll;
const int N=2e5+5;
const int MOD=1e9+7;
ll a[N],sum[N];
//set<ll>st;
int main(void){
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);

    for(int i=1;i<=3;i++)   cin >> a[i];
    sort(a+1,a+1+3);
    ll ans=0;
    while(a[1]+2<=a[3]) ans++,a[1]+=2;
    while(a[2]+2<=a[3]) ans++,a[2]+=2;
    if(a[1]==a[3]){
        if(a[2]==a[1]){

        }
        else{
            ans+=2;
        }
    }
    else{
        if(a[2]==a[1])  ans++;
        else    ans+=2;
    }
    cout <<ans << endl;

    return 0;
}


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

using namespace std;

typedef long long ll;

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

    int n,m;cin>>n>>m;
    vector<ll> a(n),imos(m+10,0);
    map<ll,ll> mp;
    for(int i=0;i<n;i++){
        cin>>a[i];
        a[i]--;
    }
    ll cnt=0; // x=0 の時のコスト
    for(int i=1;i<n;i++){
        cnt += min((a[i]+m-a[i-1])%m, 1+a[i]);
        if(a[i-1]<a[i]){
            if(a[i]-a[i-1]>=2){
                imos[a[i-1]+1]++;
                imos[a[i]]--;
            }
        }
        else{
            imos[a[i-1]+1]++;
            imos[0]++;
            imos[a[i]]--;
        }
        mp[a[i]] += (a[i]+m-a[i-1])%m -1;
    }
    for(int i=1;i<=m;i++){
        imos[i] += imos[i-1];
    }
    ll res=cnt;
    for(int i=0;i<m-1;i++){
        cnt -= imos[i];
        cnt += mp[i];
        res=min(res,cnt);
    }
    cout<<res<<endl;
}


Measured memory_bytes: 8064
// B - Nice Shopping
#include <bits/stdc++.h>

using namespace std;

int main(int argc, char *argv[])
{
	ios::sync_with_stdio(false); cin.tie(0);
	int A, B, M;
	cin >> A >> B >> M;
	vector<int> a(A), b(B), c(M), x(M), y(M);
	for (int i = 0; i < A; i++) cin >> a[i];
	for (int i = 0; i < B; i++) cin >> b[i];
	for (int i = 0; i < M; i++) cin >> x[i] >> y[i] >> c[i];
	int min_a = -1, min_b = -1;
	for (int i = 0; i < A; i++) if (min_a < 0 || a[i] < min_a) min_a = a[i];
	for (int i = 0; i < B; i++) if (min_b < 0 || b[i] < min_b) min_b = b[i];
	int ans = min_a + min_b;

	for (int i = 0; i < M; i++)
		ans = min(ans, a[x[i] - 1] + b[y[i] - 1] - c[i]);

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 2176
#include <iostream>
#include<vector>
#include<climits>
#include<algorithm>
#include<bitset>
#include<cmath>
#include<functional>
#include <numeric>
#define FORi(N) for(int i=0;i<N;++i)
using namespace std;
using ll = long long;
ll gcd(ll m,ll n){
  if(n==0)return abs(m);
  return(gcd(n,m%n));
}
int main(){
  ll N;
  cin>>N;
  ll sum =-N;
  FORi(N){
    ll tmp;
    cin>>tmp;
    sum+=tmp;
  }
  cout<<sum<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <map>
#include <set>
#include <ctime>
#include <cmath>
#include <queue>
#include <stack>
#include <ctime>
#include <string>
#include <vector>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
//#include <random>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
#define PB push_back
#define MP make_pair
#define INF 1073741824
#define inf 1152921504606846976
#define pi 3.14159265358979323846
//#pragma comment(linker,"/STACK:10240000,10240000")
//mt19937 rand_(time(0));
const int N=3e5+7,M=2e6;
const long long mod=1e9+7;
inline int read(){int ret=0;char ch=getchar();bool f=1;for(;!isdigit(ch);ch=getchar()) f^=!(ch^'-');for(;isdigit(ch);ch=getchar()) ret=(ret<<1)+(ret<<3)+ch-48;return f?ret:-ret;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll ksm(ll a,ll b,ll mod){int ans=1;while(b){if(b&1) ans=(ans*a)%mod;a=(a*a)%mod;b>>=1;}return ans;}
ll inv2(ll a,ll mod){return ksm(a,mod-2,mod);}//逆元
//int head[N],NEXT[M],ver[M],tot;void link(int u,int v){ver[++tot]=v;NEXT[tot]=head[u];head[u]=tot;}

int n;
ll dp[3100][3100][3];
ll a[3100];
void dfs(int x,int y){
    int tmp=n-y+x-1;
//    cout<<tmp<<' '<<x<<' '<<y<<endl;
    if(x==y) {
        if(tmp%2==0) dp[x][x][0]=a[x],dp[x][x][1]=0;
        else dp[x][x][1]=a[x],dp[x][x][0]=0;
        return ;
    }
    if(dp[x][y][1]!=-1&&dp[x][y][0]!=-1) return ;
    dfs(x+1,y);
    dfs(x,y-1);
    if(tmp%2==0){
        if(dp[x+1][y][0]+a[x]-dp[x+1][y][1]>dp[x][y-1][0]+a[y]-dp[x][y-1][1]){
            dp[x][y][0]=dp[x+1][y][0]+a[x];
            dp[x][y][1]=dp[x+1][y][1];
        }
        else {
            dp[x][y][0]=dp[x][y-1][0]+a[y];
            dp[x][y][1]=dp[x][y-1][1];
        }
    }
    else {
        if(dp[x+1][y][1]+a[x]-dp[x+1][y][0]>dp[x][y-1][1]+a[y]-dp[x][y-1][0]){
            dp[x][y][1]=dp[x+1][y][1]+a[x];
            dp[x][y][0]=dp[x+1][y][0];
        }
        else {
            dp[x][y][1]=dp[x][y-1][1]+a[y];
            dp[x][y][0]=dp[x][y-1][0];
        }
    }
}
int main(){
    //freopen("1.txt","r",stdin);
    //ios::sync_with_stdio(false);
    scanf("%d",&n);
    memset(dp,-1,sizeof(dp));
    for(int i=1;i<=n;i++){
        scanf("%lld",&a[i]);
    }
    dfs(1,n);
//    for(int i=1;i<=n;i++){
//        for(int j=1;j<=n;j++) cout<<dp[i][j][0]<<' '<<dp[i][j][1]<<endl;
//        cout<<endl;
//    }
    printf("%lld\n",dp[1][n][0]-dp[1][n][1]);
    //cout << "time: " << (long long)clock() * 1000 / CLOCKS_PER_SEC << " ms" << endl;
    return 0;
}




Measured memory_bytes: 225664
#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
int main(void)
{
	int a,b;
	cin>>a;
	b=a/100;
	b=b*111;
	if(a>b) b=b+111;
	cout<<b<<endl;
	return 0;
}

	

Measured memory_bytes: 256
import math
n = int(input())
lis = list(map(int, input().split()))

avg1 = math.ceil(sum(lis)/len(lis))
avg2 = math.floor(sum(lis)/len(lis))

ans1 = 0
ans2 = 0
for i in lis:
    ans1 += (i-avg1)**2
    ans2 += (i-avg2)**2

print(min(ans1, ans2))


Measured memory_bytes: 9000
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <algorithm>
#include <functional>

using namespace std;

#define INF (1 << 30)
#define INFL (1LL << 62)
#define MOD7 1000000007
#define MOD9 1000000009
#define EPS 1e-10

using ll = long long;
using ull = unsigned long long;

int main() {
    double a, b;
    cin >> a >> b;
    cout << (int)ceil((b - 1) / (a - 1)) << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define bug cout<<"woc"<<endl

using namespace std;
typedef long long ll;

const int MAX_K=1e5+5;
ll a[MAX_K];

int main(void)
{
    ll k;
    cin >>k;
    for(int i=1;i<=k;i++)
        scanf("%lld",&a[i]);
    reverse(a+1,a+1+k);
    ll mmin=2,mmax=2;
    for(int i=1;i<=k;i++){
        mmax=(mmax/a[i]+1)*a[i]-1;
        if(mmin%a[i])
        mmin=mmin/a[i]*a[i]+a[i];
    }
    if(mmax>=mmin)  cout<<mmin<<" "<<mmax<<endl;
    else    cout<<"-1"<<endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
struct Info
{
	int A,B;
    Info(int a,int b)
    {
        A=a;
      	B=b;
    }
};

bool cmp(const Info &a, const Info &b)
{
    return a.A < b.A;
}

int main() {
  long N,M;
  cin>>N>>M;
  
  vector<Info> info;
  for(int i=0;i<N;i++){
    int a,b;
    cin>>a>>b;
    info.push_back(Info(a,b));
  }
  sort(info.begin(),info.end(),cmp);
  long count=0;
  long money=0;
  for(int i=0;i<N;i++){
    for(int j=0;j<info[i].B;j++){
      count++;
      money+=info[i].A;
      if(count>=M)break;
    }
    if(count>=M)break;
  }
  cout<<money<<endl;
}

Measured memory_bytes: 1400
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <string>
#include <cstring>
#define MAX_V 1010
#define INF 100000000000000
using namespace std;

struct edge {long long to,cap,rev;};

vector<edge> G[MAX_V];
long long level[MAX_V],iter[MAX_V];

void add_edge(int from, int to, long long cap){
	G[from].push_back((edge){to,cap,(long long)G[to].size()});
	G[to].push_back((edge){from,0,(long long)G[from].size()-1});
}

void bfs(int s){
	memset(level,-1,sizeof(level));
	queue<int> que;
	level[s] = 0;
	que.push(s);
	while(!que.empty()){
		int v = que.front();
		que.pop();
		for(int i=0;i<G[v].size();i++){
			edge &e = G[v][i];
			if(e.cap>0 && level[e.to]<0){
				level[e.to] = level[v] + 1;
				que.push(e.to);
			}
		}
	}
}

long long dfs(int v, int t, long long f){
	if(v==t) return f;
	for(int i = iter[v];i<G[v].size();i++){
		edge &e = G[v][i];
		if(e.cap>0 && level[v]<level[e.to]){
		int d = dfs(e.to,t,min(f,e.cap));
			if(d>0){
				e.cap -= d;
				G[e.to][e.rev].cap += d;
				return d;
			}
		}
	}
	return 0;
}
	
long long max_flow(int s, int t){
	long long flow = 0;
	for(;;){
		bfs(s);
		if(level[t]<0) return flow;
		memset(iter,0,sizeof(iter));
		long long f;
		while((f=dfs(s,t,INF))>0){
			flow += f;
		}
	}
}
int main(){
	int i,n,m;
	string u;
	cin >> n >> m >> u;
	for(i=1;i<=n;i++){
		int a; cin >> a;
		if(u[i-1]=='L'){
			add_edge(0,i,a);
			add_edge(i,n + 1,0);
		}else{
			add_edge(0,i,0);
			add_edge(i,n + 1,a);
		}
	}
	for(i=0;i<m;i++){
		int s,t,b;
		cin >> s >> t >> b;
		if(s>t) swap(s,t);
		add_edge(t,s,b);
	}
	cout << max_flow(0,n + 1) << endl;
}


Measured memory_bytes: 3376
class UnionFind():
    def __init__(self, N):
        self.par = [i for i in range(N)]
        self.rank = [0 for _ in range(N)]
        self.size = [1 for _ in range(N)]

    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]
    
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x != y:
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
            elif self.rank[x] < self.rank[y]:
                x, y = y, x
            self.par[y] = x
            self.size[x] += self.size[y]

    def is_same(self, x, y):
        return self.find(x) == self.find(y)
    
    def get_size(self, x):
        x = self.find(x)
        return self.size[x]

N, M = map(int, input().split())
ab = [list(map(int, input().split())) for i in range(M)]

ans = 0
for i in range(M):
    uf = UnionFind(N)
    temp = ab[:i] + ab[i+1:]
    for a, b in temp:
        uf.union(a-1, b-1)
    
    for i in range(N-1):
        if uf.is_same(i, i+1) == False:
            ans += 1
            break

print(ans)

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


typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ldb;

#define pb push_back
#define popb pop_back
#define si size()
#define be begin()
#define en end()
#define le length()
// #define mp make_pair
#define mt make_tuple
#define fi first
#define se second

#define forz(i,n) for( int i=0;i<n;i++)
#define forl(i, n) for(int i = 1; i<= n; i++)
#define deci(n)  fixed<<setprecision(n)
#define high(n) __builtin_popcount(n)
#define parity(n) __builtin_parity(n)
#define ctz(n)  __builtin_ctz(n)
#define mod 1000000007
#define mod2 998244353
#define kira ios::sync_with_stdio(0), cin.tie(0),cout.tie(0)

using namespace std;

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

int main()
{
	// cpc();
	lli n, m, sum = 0;
	cin >> n ;
	std::vector<lli> v(n - 1);
	std::vector<lli> w(n, 0);
	forz(i, n - 1)
	{
		cin >> v[i];
		w[v[i] - 1]++;
	}
	forz(i, n)
	{
		cout << w[i] << endl;
	}
	return 0;
}

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

int main(void){
	int h, w;
	while(1){
		cin >>h >>w;
		if(h==0 && w==0){
			break;
		}
		for(int i=0; i<h; i++){
			for(int j=0; j<w; j++){
				cout <<"#";
			}
			cout <<endl;
		}
		cout <<endl;
	}
	return 0;
}

Measured memory_bytes: 1152
using System;
class Program
 {
   static void Main(string[] args)
   {
     string s,t,stmp;
     
     bool flag = false;

     s = Console.ReadLine();
     stmp = s;
     t = Console.ReadLine();

     for(int i = 0 ; i < s.Length ; i++)
     {
       stmp = s.Substring(s.Length-1) + s.Substring(0,s.Length-1);
       if(stmp == t)
       {
         flag = true;
       }
       s = stmp;
       
     }
     
     if(flag == false) 
     {
       Console.WriteLine("No");
     }else{
       Console.Write("Yes");   
     }
    }
 }

Measured memory_bytes: 13140
from collections import deque

N, Q = map(int, input().split())
Tree = [[] for i in range(N)]
for i in range(N-1):
    a, b = map(int, input().split())
    Tree[a-1].append(b-1)
    Tree[b-1].append(a-1)
    
count = [0 for i in range(N)]
for i in range(Q):
    p, x = map(int, input().split())
    count[p-1] += x

d = deque()
d.append(0)
visited = set()
while d:
    now = d.pop()
    visited.add(now)
    for v in Tree[now]:
        if v not in visited:
            d.append(v)
            count[v] += count[now]
            
print(*count)

Measured memory_bytes: 118936
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  int arr[n-1];
  unordered_map <int,int> mp;
  for(int i=0; i<n-1; i++)
  {
    cin>>arr[i];
    mp[arr[i]]++;
  }
  for(int i=1; i<=n; i++)
  {
    cout<<mp[i]<<"\n";
  }
}


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

using namespace std;


int main() {
    string s;
    cin >> s;
    int n = s.size();
    bool ok = false;
    for(int i = 0; i < n; i++) {
        string x = "";
        for(int j = 0; j < n; j++) {
            for(int k = 0; k < n; k++) {
                if(i <= k && k <= j) {
                    continue;
                } else {
                    x += s[k];
                }
            }
            if(x == "keyence") {
                ok = true;
            }
            x = "";
        }
    }
    if(ok) {
        puts("YES");
    } else {
        puts("NO");
    }
    return 0;
}

Measured memory_bytes: 3576
#include <cstdlib>
#include <iostream>
#include <string>
#include <typeinfo>

using namespace std;

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

    string N;
    cin >> N;

    int l = N.size();
    if (l == 1)
    {
        cout << N << endl;
        return 0;
    }

    bool all_nine = false;
    if (N[0] == '1')
    {
        for (int i = 0; i < l; ++i)
        {
            all_nine = N[i] == '9';
        }
        if (all_nine)
        {
            cout << 1 + 9 * (l - 1) << endl;
        }
        else
        {
            cout << 9 * (l - 1) << endl;
        }
    }
    else
    {
        for (int i = 0; i < l; ++i)
        {
            all_nine = N[i] == '9';
        }
        if (all_nine)
        {
            cout << stoi(N.substr(0, 1)) + 9 * (l - 1) << endl;
        }
        else
        {
            cout << stoi(N.substr(0, 1)) - 1 + 9 * (l - 1) << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import array
from bisect import *
from collections import *
import fractions
import heapq
from itertools import *
import math
import random
import re
import string
import sys

A = int(input())
B = int(input())
s = set([A, B])
for i in range(1, 4):
    if i not in s:
        print(i)




Measured memory_bytes: 6992
#include <iostream>
#include <fstream>
#include <vector>
#include <cstring>
#include <algorithm> // sort
#include <unistd.h>
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
#define pii pair<int,int>
#define vl vector<ll>
#define vvl vector< vector<ll> >
#define REP(i, n) for (long long i = 0; i < (n); i++) 
#define all(c) c.begin(),c.end()
#define fio() cin.tie(0); ios::sync_with_stdio(false);

static const ll INF = 1000000000000000000LL;
static const ll MOD = 1000000007;

int main()
{
    int a,b,c;
    cin >> a >> b >> c;
    string res = "No";

    if(a == b && b != c)res = "Yes";
    if(b == c && c != a)res = "Yes";
    if(c == a && a != b)res = "Yes";

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
N,W=map(int,input().split())
dp=[[0]*(W+1) for _ in range(N+1)]
for i in range(N):
  w,v=map(int,input().split())
  for j in range(W+1):
    if j-w>=0:
      dp[i+1][j]=max(dp[i][j],dp[i][j-w]+v)
    else:
      dp[i+1][j]=dp[i][j]
print(max(dp[N]))



Measured memory_bytes: 119916
t_hp, t_atk, a_hp, a_atk = map(int, input().split())

while True:
    a_hp = a_hp - t_atk
    if a_hp <= 0:
        print('Yes')
        break
    t_hp = t_hp - a_atk
    if t_hp <= 0:
        print('No')
        break

Measured memory_bytes: 9028
#include<bits/stdc++.h>
using namespace std ;
#define ll long long
#define pb push_back
ll chk (ll n) {
    ll p = 0 ;
    while(n/10) {
        p++ ;
        n/=10 ;
    }
    return p ;

}

int main() {
    ll  n ;
    cin >> n ;
    ll ans = 1 ;
    ll i;
    vector<ll>v(n) ;
    for (i = 0  ; i< n ; i++) cin >> v[i] ;
    sort(v.begin(),v.end()) ;
    if (v[0]==0) return cout << 0 << endl , 0 ;
    ans = v[0] ;

    for (i = 1 ; i< n; i++) {
        ll x = chk(ans) + chk(v[i]) ;
        ans*=v[i] ;
        if ((x==18 and ans!= (ll) 1e18) or ans> (ll) 1e18) return cout << -1 << endl ,0 ;
    }
    cout << ans << endl ;


    return 0 ;
}


Measured memory_bytes: 4052
#include <cmath>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <vector>
#include <algorithm>
#include <iostream>
using namespace std;
const int MaxN = 1e5 + 5;
typedef long long LL;
char a[MaxN];
LL vis[200];
LL p[200];
void Check(char x){
	if(x == 'M') p[1]++;
	else if(x == 'A') p[2]++;
	else if(x == 'R') p[3]++;
	else if(x == 'C') p[4]++;
	else if(x == 'H') p[5]++;

}
int main(){
	int n;
	scanf("%d",&n);
	for(int i = 1; i <= n; i++){
		scanf(" %s",&a);
		Check(a[0]);
	}
		LL ans = p[1]*p[2];
		LL sum = ans*p[3]+ans*p[4]+ans*p[5];
		ans = p[1]*p[3];
		sum =sum + ans*p[4]+ans*p[5];
		ans = p[2]*p[3];
		sum= sum+ans*p[4]+ans*p[5];
		sum = sum + p[2]*p[4]*p[5]+p[3]*p[4]*p[5]+p[1]*p[4]*p[5];
		printf("%lld\n",sum);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e15;
typedef long long ll;
typedef long double ld;
typedef pair <ll, ll> pii;

void faster()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

const ll MAXN = 1e6 + 10;
const ll N = 4000 + 10;
const ll MN = 200 + 10;
const ll mod = 1e6;

ll a[MAXN * 2];
bool mark[3 * MAXN];

int main()
{
	faster();
	ll x , k , ans = 0;
	cin >> k >> x;
	for (int i = -1e6; i <= 1e6; i++)
	{
		if(abs(x - i) < k)
			cout << i << " ";
	}
	cout << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



#define SIZE 200005

ll N,T;
ll A[SIZE];

int main(){

	scanf("%lld %lld",&N,&T);

	ll ans = 0;

	for(ll i = 0; i < N; i++){

		scanf("%lld",&A[i]);
		if(i == 0)continue;

		ans += min(T,A[i]-A[i-1]);
	}

	ans += T;

	printf("%lld\n",ans);

	return 0;
}


Measured memory_bytes: 5280
//C99 or C++98
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <limits.h>

#define forn(i,n)               for( int i=0 ; i < n ; i++ )
#define ms(ara_name,value) memset(ara_name,value,sizeof(ara_name))
#define min(a,b)                ((a)>(b) ? (b) : (a) )
#define max(a,b)                ((a)>(b) ? (a) : (b))
#define INF                     1<<29

const int N = 1000;
int n;
double dp[N][N];
int p[N][2];
double d[N][N];
bool vis[N][N];
double calc(int p1,int p2)
{
    int v= max(p1,p2)+1;
    if(v==n-1){
        return d[p1][v] + d[p2][v];
    }
    if(vis[p1][p2]) return dp[p1][p2];
    double r= INF;
    dp[p1][p2] = min( d[p1][v] + calc(v,p2) , d[p2][v] + calc(p1,v));
    vis[p1][p2] = 1;
    return dp[p1][p2];
}
 
int main()
{
 
    while(scanf("%d",&n)==1) {
        for(int i=0;i<n;i++) {
            scanf("%d%d",&p[i][0],&p[i][1]);
        }
        forn(i,n)forn(j,n){
            d[i][j] = sqrt((p[i][0]- p[j][0]) * (p[i][0] - p[j][0]) + (p[i][1]-p[j][1])*(p[i][1]-p[j][1]));
        }
        ms(vis,0);
        printf("%f\n", calc(0,0));
    }
    return 0;
}

Measured memory_bytes: 19428
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <fstream>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int n;
    string s, t;
    cin >> n >> s >> t;
    for (int i = 0; i < n; i++) cout << s[i] << t[i];
}


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

int main(){
    long long int n;
    cin >> n;
    long long int ans=n-1;

    for(long long int i=sqrt(n); i>0; i--){
        if(n%i==0){
            ans=n/i+i-2;
            break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3672
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n = int(readline())
a = list(map(int,readline().split()))
s = a[0]+a[1]
if n == 2:
  if a[0] < a[1] or s%2 == 1:
    print(-1)
  else:
    print(a[0]-s//2)
  exit()
  
c = 0
for i in a[2:]:
  c ^= i

sc = (s-c)//2
if s < c or (s-c)%2 == 1 or c&sc:
  print(-1)
  exit()

bb = a[0].bit_length()
x = ''
chk = 0
for i in range(bb-1,-1,-1):
  if not (c>>i&1)|(sc>>i&1):
    x += '0'
  elif not c>>i&1 and sc>>i&1:
    x += '1'
    chk += 2**i
  else:
    x += '?'
  
for i in range(bb):
  if x[i] == '?':
    if a[0] >= chk+2**(bb-1-i):
      chk += 2**(bb-1-i)

ans = a[0]-chk
print(ans if a[0] > ans >= 0 else -1)

Measured memory_bytes: 9224
#include <bits/stdc++.h>
#define ll          long long int
#define uu          first
#define vv          second
#define pii         pair<int,int>
#define pll         pair<ll,ll>
#define fastio      ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
const int INF = 1e9;
const ll MOD = 1e9 + 7;

const int N = 1e6 + 6;

int main()  {
    fastio;
    int n;
    cin>>n;
    vector<int>vec(n);
    for(int i =0 ; i < n ; i++) cin>>vec[i];
    ll ans = 0;
    for(int i =1 ; i <n ; i++ ) {
        ans += max(0 , vec[i-1] - vec[i]);
        vec[i] = max(vec[i] , vec[i-1]);
    }
    cout<<ans<<'\n';
    return 0;
    
}

Measured memory_bytes: 3944
#include <iostream>
#include <algorithm>
#include <math.h>
using namespace std;
typedef long long ll;

string suffle(string s, int n, int x)
{
    string t = s;
    for (int i = 0; i < x+1; i++)
    {
        t[n-x+i] = s[i];
    }
    for (int i = 0; i < n-x; i++)
    {
        t[i] = s[i + x];
    }
    return t;
}

int main()
{
    int n, x, len;
    string s;
    int status = 1;
    while (status)
    {
        cin >> s;
        len = s.size();
        if (s == "-")
            status = 0;
        else
        {
            cin >> n;
            for (int i = 0; i < n; i++)
            {
                cin >> x;
                s = suffle(s, len, x);
            }
            cout << s << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3212
#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(int i = 0; i < n; i++)
#define Rep(i, n) for(int i = 1; i < n; i++)
#define In(vec) rep(i, n) cin>>vec[i];
#define ANS(s) cout << s << endl
#define inc(a, b) cin >> a >> b;

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

using ii = pair<int, int>;
using ll = long long;
using vi = vector<int>;
using vd = vector<double>;
using vb = vector<bool>;
using vl = vector<ll>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vii = vector<pair<int, int>>;

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
ll LCM(ll a, ll b) { return (a * b) / GCD(a, b); }
int round_int(int a, int b) { return (a + (b - 1)) / b; }


// 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 };

constexpr auto MAX = 100010;

// ────────────────────────────────────────────────────

int main() {
	int n, a; cin >> n >> a;
	vi k(n); int cnt = 0;
	rep(i, n) {
		cin >> k[i];
		if (k[i] >= a) cnt++;
	}
	ANS(cnt);
}


Measured memory_bytes: 640
from collections import deque
N,*L = map(int, open(0).read().split())
dic = [[] for i in range(N+1)]
for a,b in zip(*[iter(L)]*2):
  dic[a].append(b)
  dic[b].append(a)
q = deque([1])
dist = [-1]*(N+1)
dist[1] = 0
while q:
  p = q.popleft()
  for v in dic[p]:
    if dist[v]==-1:
      q.append(v)
      dist[v] = dist[p]+1
u = max(range(1,N+1),key=lambda x:dist[x])
q = deque([u])
dist = [-1]*(N+1)
dist[u] = 0
while q:
  p = q.popleft()
  for v in dic[p]:
    if dist[v]==-1:
      q.append(v)
      dist[v] = dist[p]+1
M = max(dist)
if M%3==1:
  print('Second')
else:
  print('First')

Measured memory_bytes: 52236
def s():
 def b(M,x,y,n):
  M[x][y]=0;a=n
  if M[x-1][y]:a=max(a,b(M,x-1,y,n+1))
  if M[x][y-1]:a=max(a,b(M,x,y-1,n+1))
  if M[x+1][y]:a=max(a,b(M,x+1,y,n+1))
  if M[x][y+1]:a=max(a,b(M,x,y+1,n+1))
  M[x][y]=1
  return a
 for e in iter(input,'0'):
  n,m=int(e),int(input())
  P=[[0]*(n+2)for _ in[0]*(m+2)]
  for i in range(m):P[i+1][1:-1]=map(int,input().split())
  print(max(b(P,i,j,1)for i in range(1,m+1)for j in range(1,n+1)if P[i][j]))
if'__main__'==__name__:s()


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

using namespace std;
#define ll long long
int main()
{
int n;
cin>>n;
map<string,int>m;
while(n--)
{
    string h;
    cin>>h;
    m[h]++;
}
int mx=0;
for(auto j=m.begin();j!=m.end();j++)
{
    mx=max(mx,j->second);
}
set<string> s;
for(auto i=m.begin();i!=m.end();i++)
{
   if(i->second==mx)
    s.insert(i->first);
}
for(auto i=s.begin();i!=s.end();i++)
{
   cout<<*i<<endl;

}

    return 0;
}


Measured memory_bytes: 35712
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; (i) < (n); ++ (i))
#define loop(i,a,n) for (int i = (a); (i) < (n); ++ (i))
#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF (int)1e9
#define MOD 0
//#define int ll
using namespace std;
typedef vector<int> vi;

signed main(){
    int a[5],k;
    cin.tie(0);
    ios::sync_with_stdio(false);
    rep(i,5) {
        cin >> a[i];
    }
    cin >> k;
    rep(i,5) {
        for(int j = i+1;j < 5;j++) {
            if(a[j]-a[i] > k) {
                puts(":(");
                return 0;
            }
        }
    }
    puts("Yay!");
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <atcoder/all>
using ll = long long;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) x.begin(),x.end()
using namespace std;
using namespace atcoder;

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

    int N,Q;
    cin >> N >> Q;
    dsu d(N);
    rep (i, Q) {
        int t,u,v;
        cin >> t >> u >> v;
        if (t == 0) {
            d.merge(u, v);
        }
        else {
            if (d.same(u, v)) {
                cout << 1 << endl;
            }
            else {
                cout  << 0 << endl;
            }
        }
    } 
    return 0;
}

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

int main(){
	int N,K;
	cin >> N >>K;
	string s;
	cin >> s;
	
	if(s[K-1] == 'A') s[K-1] = 'a';
	if(s[K-1] == 'B') s[K-1] = 'b';
	if(s[K-1] == 'C') s[K-1] = 'c';
	
	cout << s << endl;
	
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
bool check(string s){
	for(int i=0;i<s.length();i++){
		if(s[i]==s[i+1])
			return false;
		else
			continue;
	}
	return true;
}
int main(void){
		ios_base::sync_with_stdio(false);
		cin.tie(0);
		string s;
    cin>>s;
		check(s)?cout<<"Good":cout<<"Bad";
		check(s);
		return 0;
}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

#define F first
#define S second
#define PB push_back
#define MK make_pair
#define REP(i, a, b) for (int i=a; i < b; i++)


bool sort_by(pi c, pi d){
	return c.S < d.S;
}

int main() {
	ll n, t;
	cin >> n >> t;
	ll prev =  0, now, ans = 0;
	REP(i, 0, n){
		cin >> now;
		if(i > 0) ans += min(t, now-prev);
		prev = now;
	}
	cout << ans +t;
		
		
		

}


Measured memory_bytes: 256
n=int(input())
s=input()
shurui=[]
for i in range(len(s)-1):
  zenhan=s[0:i+1]
  kouhan=s[i+1:len(s)]
  kaburu=[]
  kaburu.clear()
  a=0
  for j in range(len(zenhan)):
    if kouhan.count(zenhan[j]) != 0 and kaburu.count(zenhan[j])==0:
      a+=1
      kaburu.append(zenhan[j])
  shurui.append(a)
print(max(shurui))
    

Measured memory_bytes: 9192
//#define sort(nums) sort(nums.begin(),nums.end())
#include <bits/stdc++.h>
#define mod 1000000007
#define deb(x) cout<<#x<<" "<<x<<endl
using namespace std;
using ll = long long int;

void jets(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}



int main(){
// #ifndef ONLINE_JUDGE
//     freopen("input.txt", "r", stdin);
//     freopen("output.txt", "w", stdout);
// #endif
    jets();
    int n;
    cin>>n;
    std::vector<int> vec(n,0);
    for(int i=0;i<n;i++)
    	cin>>vec[i];
    int dp[n]={0};
    dp[0]=0;
    dp[1]=abs(vec[1]-vec[0]);
    ll ans=0;
    for(int i=2;i<n;i++){
    	dp[i]=min(dp[i-1]+abs(vec[i]-vec[i-1]),dp[i-2]+abs(vec[i]-vec[i-2]));
    	
    }
    cout<<dp[n-1]<<endl;


    return 0;
}

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

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	intl x,y,z;
	cin>>x>>y>>z;
	cout<<z<<" "<<x<<" "<<y<<"\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define rep2(i,n) for(int i=0;i<=n;i++)
#define repr(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define double long double
#define INF 1e10
#define MOD 1e9+7
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; }
using Graph = vector<vector<int>>;
int lcm(int a,int b){
 int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
}
  }
  return d*e/f;
    }
signed main(){
int a,b;
  cin>>a>>b;
  cout<<lcm(a,b);
}

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

using namespace std;

#define ll long long

const ll mod  = 1e9 + 7;
const ll INF = 1e14;

void solve(){

    int n; cin >> n;
    
    if(n % 10 == 3) cout << "bon";
    else if(n % 10 == 0 || n % 10 == 1 || n % 10 == 6 || n % 10 == 8) cout << "pon";
    else cout << "hon";

}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    //int test; cin >> test;
    //for(int t = 1; t <= test; ++t){
        solve();    
    //}

	return 0;
}



Measured memory_bytes: 3580
# import math
# import decimal
# import queue
# import bisect
# import heapq
# import time
# import itertools

mod = int(1e9+7)

def main():
    s = input()
    x = len(s)
    t = ['x'] * x
    print(''.join(t))
    return

if __name__=='__main__':
    main()


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

int main(){
  int A,B,C,D;
  int compare1, compare2;
  cin >> A >> B >> C >> D;
  
  if(A <= B ){
    compare1 = A;
  }else{
    compare1 = B;
  }

  if(C <= D ){
    compare2 = C;
  }else{
    compare2 = D;
  }

  cout << compare1 + compare2 << endl;
  return 0;
}
    

  
      

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<queue>
#include<string>
#include<algorithm>

using namespace std;

int main(){
    long long n, a[100009], y[100009];
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> a[i];
        if(i%2==0){
            y[0]+=a[i];
        }
        else{
            y[0]-=a[i];
        }
    }
    y[0] /= 2;
    y[n-1] = a[n-1] - y[0];
    for(int i=n-2;i>=1;i--){
        y[i] = a[i] - y[i+1];
    }
    for(int i=0;i<=n-1;i++){
        cout << 2*y[i] << ' ';
    }
    cout << endl;
}


Measured memory_bytes: 2816
N = int(input())
lstA = [int(s) for s in input().split()]
lstB = [int(s) for s in input().split()]
count=0
for i in range(N):
  ##まず前半を倒す
  pow_i=min([lstA[i],lstB[i]])
  count=count+pow_i
  power_rest=lstB[i]-pow_i
  ###後半を倒す
  pow_isuc=min([lstA[i+1],power_rest])
  count=count+pow_isuc
  lstA[i+1]=lstA[i+1]-pow_isuc
print(count)
  


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

/* メモリ食い過ぎ注意 */
#define int long long

typedef long long ll;

int euclid(int a, int b)
{
    if (a < b)
        euclid(b, a);
    if (b == 0)
        return a;
    int r;
    while ((r = a % b))
    {
        a = b;
        b = r;
    }
    return b;
}

/* define const */
const ll INF = (1ll << 60);
const ll MOD = (ll)1e9 + 7;
/* end defineing */

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

    bool f = true;
    int cnt = 0;
    while (f)
    {
        for (int i = 0; i < n; i++)
        {
            if (a[i] % 2 != 0)
                f = false;
        }
        if (!f)
            break;

        for (int i = 0; i < n; i++)
        {
            a[i] /= 2;
        }
        cnt++;
    }
    cout << cnt << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <vector>

using namespace std;


int main()
{
    int n,m;
    scanf("%d %d",&n,&m);
    vector<pair<int,int>> pairs(m);
    for(int i=0;i<m;i++)
    {
        int a,b;
        scanf("%d %d",&a,&b);
        pairs[i]=make_pair(b,a);
    }

    sort(pairs.begin(),pairs.end());

    bool bridge[100000]={};
    int ans=0;
    for(int i=0;i<m;i++)
    {
        bool judge=true;
        for(int j=pairs[i].second-1;j<=pairs[i].first-2;j++)
        {
            if(bridge[j])
            {
                judge=false;
                break;
            }
        }
        if(judge)
        {
            bridge[pairs[i].first-2]=true;
            ans++;
        }
    }
    printf("%d\n",ans);

}

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

using namespace std;

vector<int> A, B, choosen;

int main ()
{
    int x, y, a, b, c; cin >> x >> y >> a >> b >> c;
    int v;

    for (int i = 0; i < a; i++)
        cin >> v, A.push_back(v);

    sort(A.begin(), A.end());
    reverse(A.begin(), A.end());

    for (int i = 0; i < x; i++)
        choosen.push_back(A[i]);

    for (int i = 0; i < b; i++)
        cin >> v, B.push_back(v);

    sort(B.begin(), B.end());
    reverse(B.begin(), B.end());

    for (int i = 0; i < y; i++)
        choosen.push_back(B[i]);

    for (int i = 0; i < c; i++)
        cin >> v, choosen.push_back(v);

    sort(choosen.begin(), choosen.end());
    reverse(choosen.begin(), choosen.end());

    long long sum = 0;
    for (int i = 0; i < (x+y); i++)
        sum += choosen[i];

    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 3188
N, Q = map(int,input().split())
S = list(input())
T = [0] * (N+1)
count = 0


for i in range(N-1):
    if S[i] == 'A':
        if S[i+1] == 'C':
            count += 1
    T[i+1] = count
    a = count



for j in range(Q):
    l,r = map(int,input().split())
    sum_AC = T[r-1] - T[l-1]
    print(sum_AC)
        

Measured memory_bytes: 6876
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,a,n) for(ll i = a;i < n;i++)
#define rrep(i,a,n) for(ll i = n; i >= a;i--)
#define index_check(i,n) if(i > n-1 || i < 0) continue; 
#define LINF 1e18
#define INF 1e9
using namespace std;

#define fs first
#define sc second

using P = pair<ll,ll>;
using PQ = priority_queue<P,vector<P>,greater<P>>;

signed main(){
    double a,b,x;
    cin >> a >> b >> x;
    
    if(2*x/a >= a*b) cout << setprecision(15) << atan(2*b/a-2*x/a/a/a)*180/acos(-1) << endl;
    else cout << setprecision(15) << atan(a*b*b/2/x)*180/acos(-1) << endl;

    return 0;
}

Measured memory_bytes: 384
import itertools as it
n = int(input())
towns = []
for i in range(n):
    towns.append(list(map(int,input().split())))
ans = 0
count = 0
for ts in it.permutations(towns):
    for i in range(len(ts)-1):
        ans += ((ts[i][0]-ts[i+1][0])**2+(ts[i][1]-ts[i+1][1])**2)**0.5
    count += 1
print(ans/count)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  int n;
  cin >> n;
  int r[n][3];
  rep(i, 0, n) rep(j, 0, 3) cin >> r[i][j];
  vector<vector<int>> ans(n + 1, vector<int>(3, 0));

  rep(i, 0, n) {
    rep(j, 0, 3) {
      rep(k, 0, 3) {
        if (j == k)
          continue;
        else
          chmax(ans[i + 1][k], ans[i][j] + r[i][k]);
      }
    }
  }

  cout << max({ans[n][0], ans[n][1], ans[n][2]}) << endl;
}


Measured memory_bytes: 6912
/*
* Author : MaxSally
*/
/********   All Required Header Files ********/
#include<bits/stdc++.h>
using namespace std;
/*******  All Required define Pre-Processors and typedef Constants *******/
#define SCD(t) scanf("%d",&t)
#define SCLD(t) scanf("%ld",&t)
#define SCLLD(t) scanf("%lld",&t)
#define SCC(t) scanf("%c",&t)
#define SCS(t) scanf("%s",t)
#define SCF(t) scanf("%f",&t)
#define SCLF(t) scanf("%lf",&t)
#define mem(a, b) memset(a, (b), sizeof(a))
#define rep(i, j, k) for (int i = j ; i <= k ; ++i)
#define rrep(i, j, k) for (int i = j; i >= k; --i)
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define foreach(i, a) for(auto i: a)
#define forEach(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define in(A, B, C) assert( B <= A && A <= C)
#define mp make_pair
#define pb push_back
#define inf (int) (1e9 + 7)
#define epsi 1e-9
#define PI 3.1415926535897932384626433832795
#define mod 1000000007
#define read(type) readInt<type>()
#define io ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long int
#define left tuyiuoi
#define right fgjhk
#define ss second
#define ff first
#define debug(a) cout << #a << ": " << a << endl
#define debuga1(a, l, r) rep(i, l, r) cout << a[i] << " "; cout << endl
#define Flag(n) cout << "here " << n << endl
const double pi=acos(-1.0);
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<ll, ll> pll;
typedef vector<string> vs;
typedef vector<pii> vii;
typedef vector<pll> vpll;
typedef vector<vi> vvi;
typedef map<int,int> MPII;
typedef set<int> SETI;
typedef multiset<int> MSETI;
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int  uint64;

const int N = 200005;
int a[N];

int main(){
    io;
   // freopen("input.txt", "r", stdin);
    int n; cin >> n;
    int totalXOR = 0;
    rep(i, 1, n){
        cin >> a[i];
        totalXOR ^= a[i];
    }
    rep(i, 1, n){
        cout << (totalXOR^a[i]) << " ";
    }

    return 0;
}


Measured memory_bytes: 4412
#include <stdio.h>
#define MAX 100000
#define SENTINEL 2000000000

struct Card {
  char suit;
  int value;
};

struct Card L[MAX/2+2], R[MAX/2+2];

void merge(struct Card A[], int n, int left, int mid, int right) {
  int i, j, k;
  int n1 = mid - left;
  int n2 = right - mid;
  for(i=0;i<n1;i++) L[i] = A[left + i];
  for(i=0;i<n2;i++) R[i] = A[mid  + i];
  L[n1].value = R[n2].value = SENTINEL;
  i = j = 0;
  for(k=left; k<right; k++) {
    if(L[i].value <= R[j].value) {
      A[k] = L[i++];
    } else {
      A[k] = R[j++];
    }
  }
}

void mergeSort(struct Card A[], int n, int left, int right) {
  if(left+1 < right) {
    int mid = (left+right) / 2;
    mergeSort(A,n,left,mid);
    mergeSort(A,n,mid, right);
    merge(A,n,left,mid,right);
  }
}

int partition(struct Card A[], int n, int p, int r) {
  int i, j;
  struct Card t, x;
  x = A[r];
  i = p-1;
  for(j=p; j<r; j++) {
    if(A[j].value <= x.value) {
      i++;
      t=A[i]; A[i]=A[j]; A[j]=t;
    }
  }
  t=A[i+1]; A[i+1]=A[r]; A[r]=t;
  return i+1;
}

void quickSort(struct Card A[], int n, int p, int r) {
  int q;
  if(p<r) {
    q = partition(A,n,p,r);
    quickSort(A,n,p,q-1);
    quickSort(A,n,q+1,r);
  }
}

int main() {
  int n, i, v;
  struct Card A[MAX], B[MAX];
  char S[10];
  int stable = 1;

  scanf("%d", &n);

  for(i=0;i<n;i++) {
    scanf("%s %d",S,&v);
    A[i].suit =  B[i].suit  = S[0];
    A[i].value = B[i].value = v;
  }

  mergeSort(A,n,0,n);
  quickSort(B,n,0,n-1);

  for(i=0;i<n;i++) {
    // マージソートとクイックソートの結果を比べる
    if(A[i].suit != B[i].suit) stable = 0;
  }
  

  if(stable==1) printf("Stable\n");
  else printf("Not stable\n");
  for(i=0;i<n;i++) {
    printf("%c %d\n",B[i].suit,B[i].value);
  }

  return 0;
}


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

int main(){
    int64_t N;
    cin >> N;
    int64_t ans = 0;
    rep2(i, 1, N + 1){
        if(i % 3 == 0 || i % 5 == 0){
            continue;
        }
        ans += i;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3624
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtcoderCS
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();

            long[] arg = s.Split().Select(a => long.Parse(a)).ToArray();

            long X = arg[0];
            long K = arg[1];
            long D = arg[2];

            long Xabs = Math.Abs(X);

            if(Xabs / D > K)
            {
                long mod = Xabs % D;
                Xabs -= mod;
                Xabs /= D;
                Xabs -= K;
                Xabs *= D;
                Xabs += mod;
                Console.WriteLine(Xabs);
                return;
            }

            long cand1 = Xabs % D;
            long cand2 = Math.Abs(cand1 - D);

            if ((K - (Xabs - cand1) / D) % 2 == 0)
            {
                Console.WriteLine(cand1);
            }
            else
            {
                Console.WriteLine(cand2);
            }
        }
    }
}


Measured memory_bytes: 28144
import Data.List

solve :: Int -> Int -> Int
solve d n = head $ drop (n - 1) $ filter (\x -> x `mod` 100^(d + 1) /= 0) [100^d, 100^d*2..]

main :: IO ()
main = do
  [d, n] <- map read . words <$> getLine
  print $ solve d n

Measured memory_bytes: 508
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod=1e9+7;
const int maxn=1e5+10;
int a[maxn];
int m,n;
int main()
{
    cin>>n>>m;
    cout<<max(n+m,max(n-m,m*n));

    return 0;
}


Measured memory_bytes: 256