akhauriyash/Code-Regression huggingface dataset:
#include<algorithm>
#include<iostream>
#include<vector>
using namespace std;

vector<long long> input(long long N){
    long long i;
    vector<long long> output(N);
    for(i=0;i<N;i++)cin>>output[i];
    return output;
}

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

int main(){
    long long i,j;
    long long N,K;
    long long C_min=-1;
    long long C_max=0;
    long long C_mid;
    long long K_sim;
    vector<long long> A,F,C;
    cin>>N>>K;
    A=input(N);
    F=input(N);
    C.resize(N);
    sort(A.begin(),A.end());
    sort(F.begin(),F.end(),greater<long long>());

    for(i=0;i<N;i++){
        C[i]=A[i]*F[i];
        if(C[i]>C_max)C_max=C[i];
    }

    C_max+=1;

    while(true){
        K_sim=0;
        C_mid=(C_max+C_min)/2;
        for(i=0;i<N;i++){
            if(max(0,C[i]-C_mid)%F[i]==0){
                K_sim+=max(0,C[i]-C_mid)/F[i];
            }else{
                K_sim+=max(0,C[i]-C_mid)/F[i]+1;
            }
        }
        if(K_sim>K){
            C_min=C_mid;
        }else{
            C_max=C_mid;
        }

        if(C_max-C_min<=1)break;
    }
    
    cout<<C_max<<endl;
    return 0;
}

Measured memory_bytes: 4992
#include<iostream>
#include<algorithm>
#include<functional>

using namespace std;

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

	int a[3];

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

	sort(a, a + 3, greater<int>());

	int ans = a[0] * 10 + a[1] + a[2];

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
a,b,c,d = map(int, input().split())

if b <= 0 and d > 0:
    if c >= 0:
        print(b * c)
    else:
        print(a * c)
elif b > 0 and d <= 0:
    if a >= 0:
        print(a * d)
    else:
        print(a * c)
elif b <= 0 and d <= 0:
    print(a * c)
elif b == 0 or d == 0:
    print(0)
else:
    if c < 0 and a < 0:
        print(max(a * c,b * d))
    else:
        print(b * d)

Measured memory_bytes: 9200
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<string>
#include<cstdio>
#include<vector>
#include<queue>
#include<cmath>
#include<set>
#include<map>
using namespace std;
typedef long long LL;
const int N = 6e3+10;
inline int read()
{
	register int x = 0 , f = 0; register char c = getchar();
	while(c < '0' || c > '9') f |= c == '-' , c = getchar();
	while(c >= '0' && c <= '9') x = (x << 3) + (x << 1) + c - '0' , c = getchar();
	return f ? -x : x;
}
int n;
int pa[N] , pb[N] , id[N] , nx[N];
string s , f[N];
int main()
{
	cin >> n; cin >> s; s = " " + s;
	int cnta = 0 , cntb = 0;
	for(int i = 1 ; i <= n * 2 ; ++i)
		if(s[i] == 'a') pa[id[i] = ++cnta] = i; else pb[id[i] = ++cntb] = i;
	pa[n + 1] = pb[n + 1] = 2 * n + 1; id[n * 2 + 1] = n + 1;
	for(int i = 1 , j = 0 ; i <= n + 1 ; ++i)
		while(j < min(pa[i] , pb[i])) nx[++j] = i;
	for(int i = n ; i >= 1 ; --i)
	{
		if(pb[i] < pa[i])
		{
			int j = pb[i];
			for( ; pb[id[j]] < pa[id[j]] && (id[j] <= i || pa[id[j] - 1] > pb[id[j]]) ; ++j)
				if(id[j] >= i) f[i] += s[j];
			f[i] += f[id[j]];
		}
		else
		f[i] = "ab" + f[nx[pb[i] + 1]];
		f[i] = max(f[i] , f[i + 1]);
	}
	cout << f[1] << '\n';
	return 0;
}

Measured memory_bytes: 14720
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include <cmath>
#include <math.h>

using namespace std;
const long long INF = (long long) (1e18)+1;

int main() {
  int x,n;
  cin >> x >> n;
  if (n==0) {
    cout << x << endl;
    return 0;
  }

  vector<int> nums(101, 0);
  for (int i=0; i<n; ++i) {
    int temp;
    cin >> temp;
    nums[temp] = 1;
  }

  if (!nums[x]) { // doens't invluce the x
    cout << x << endl;
    return 0;
  }

  int ans;
  int i = 0;
  while (true) {
    int cur = x - i;
    if (!nums[cur]) {
      ans = cur;
      break;
    }

    cur = x + i;
    if (!nums[cur]) {
      ans = cur;
      break;
    }
    i++;
  }

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

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


/// File input & output /////
#define fRead(x)        freopen("x.txt","r",stdin)
#define fWrite(x)       freopen ("x.txt","w",stdout)

#define mt              make_tuple
#define ld              long double
#define ll              long long
#define ull             unsigned long long
#define ff              first
#define ss              second
#define pb              push_back
#define INF             2e16
#define PI              acos(-1.0)
#define mp              make_pair
#define pii             pair<int,int>
#define pll             pair<LL,LL>


#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(a,min(b,min(c,d)))
#define max4(a,b,c,d)   max(a,max(b,max(c,d)))
#define SQR(a)          ((a)*(a))
#define FOR(i,a,b)      for(int i=a;i<=b;i++)
#define ROF(i,a,b)      for(int i=a;i>=b;i--)
#define REP(i,b)        for(int i=0;i<b;i++)
#define MEM(a,x)        memset(a,x,sizeof(a))
#define ABS(x)          ((x)<0?-(x):(x))

#define SORT(v)         sort(v.begin(),v.end())
#define REV(v)          reverse(v.begin(),v.end())


#define FASTIO        ios_base::sync_with_stdio(0);cin.tie(nullptr);




///..................Sort by second element in a pair in decending order............. ///
bool SortbySecDesc(const pair<long long,long long > &a, const pair<long long,long long > &b)
{
    return a.second>b.second;
}

///.........................first element of pair in descending order..........................//////
bool sortinrev(const pair<int,int> &a,
               const pair<int,int> &b)
{
       return (a.first > b.first);
}



///.............................................................TEMPLATE................................................./////

int main()
{
    FASTIO;

    ll n;

    cin >> n;

    ll ans = 100;

    double per = 0.01;

    ll count = 0;



    while(1)
    {
        if(ans>=n)
        {
            break;
        }

        ans += (ans*0.01);

        count++;
    }

    cout << count << endl;




    return 0;
}



Measured memory_bytes: 3652
import java.util.HashMap;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner((System.in));
		int n = sc.nextInt();
		String s = sc.next();
		int ans = 0, cnt = 0;
		HashMap<String, Integer> a = new HashMap<String, Integer>();

		for (int i = 0; i < n - 1; i++) {
			cnt = 0;
			a.clear();
			for (int j = 0; j < i; j++) {
				if (s.substring(i).contains(s.substring(j, j + 1))) {
					if (a.get(s.substring(j, j + 1)) == null) {
						a.put(s.substring(j, j +1), 1);
					}
				}
			}
			cnt = a.size();
			if (ans < cnt) {
				ans = cnt;
			}
		}

		System.out.println(ans);

		sc.close();
	}
}


Measured memory_bytes: 23892
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
ll inf =  1e9;


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

 ll sum = 0;
 for(ll i=0;i<n;i++) sum += a[i];

 map<ll,ll> t;
 for(ll i=0;i<n;i++){
  t[a[i]]++;
 }
 ll q;
 cin>>q;
 for(ll i=0;i<q;i++){
  ll b,c;
  cin>>b>>c;
  sum += (c-b)*t[b];
  t[c] += t[b];
  t[b] = 0;
  cout<<sum<<endl;

 }

    return 0;
}


Measured memory_bytes: 10044
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
 
int main() {
 
   ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
   
	ll a;
	
	cin >> a;
	
	cout << (a+(a*a)+(a*a*a)) << endl;
   
return 0;   
}


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

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

return 0;
}


Measured memory_bytes: 4740
#include <bits/stdc++.h>
#include <cassert>
typedef long long int ll;
using namespace std;

// @@ !! LIM()

int main(/* int argc, char *argv[] */) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  ll n; cin >> n;
  vector<ll> a(n);
  bool haszero = false;
  for (ll i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] == 0) haszero = true;
  }
  if (haszero) {
    cout << 0 << endl;
    return 0;
  }
  ll lim = ll(1e18);
  ll ans = 1;
  for (ll i = 0; i < n; i++) {
    if (lim / ans >= a[i]) ans *= a[i];
    else {
      cout << -1 << endl;
      return 0;
    }
  }
  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 3956
using System;
using System.Linq;

namespace ConsoleApp1
{

    class Program
    {

        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var n = input[0];
            var k = input[1];

            var cookies = new int[n];

            for (int i = 0; i < k; i++)
            {
                var d = int.Parse(Console.ReadLine());
                var input1 = Console.ReadLine().Split().Select(int.Parse).ToArray();
                for (int j = 0; j < d; j++)
                    cookies[input1[j] - 1]++;
            }

            int res = 0;
            for (int i = 0; i < n; i++)
                if (cookies[i] == 0)
                    res++;

            Console.WriteLine(res);
        }

    }
}



Measured memory_bytes: 28316
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
#define Priq priority_queue<int,vi,greater<int>>
#define pb push_back
#define mp make_pair
#define INF (1ll<<60)
signed main(){
  int N; cin>>N;
  string S; cin>>S;
  int ans=0;
  vi R(N+1),G(N+1),B(N+1);
  REP(i,1,N){
    R[N-i]=R[N-i+1];
    G[N-i]=G[N-i+1];
    B[N-i]=B[N-i+1];
    if(S[N-i]=='R') R[N-i]++;
    else if(S[N-i]=='G') G[N-i]++;
    else B[N-i]++;
  }
  rep(i,0,N-2){
    rep(j,i+1,N-1){
      set<char> s;
      s.insert('R');
      s.insert('G');
      s.insert('B');
      s.erase(S[i]);
      s.erase(S[j]);
      if(s.size()==1){
        char X=*s.begin();
        if(X=='R'){
          ans+=R[j];
        }
        else if(X=='B'){
          ans+=B[j];
        }
        else{
          ans+=G[j];
        }
        int k=j+j-i;
        if(k<N&&S[k]==X) ans--;
      }
    }
  }
  cout<<ans<<endl;
  }



Measured memory_bytes: 3660
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <limits.h>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <set>
#include <vector>

using namespace std;
typedef long long ll;
const int maxn = 1e4 + 7;
vector<ll> ans;
int main(void)
{
    ll a, b, c ,d;
    cin >> a >> b >> c >> d;
    ll x1 = b * d; ans.push_back(x1);
    ll x2 = a * c; ans.push_back(x2);
    ll x3 = a * d; ans.push_back(x3);
    ll x4 = b * c; ans.push_back(x4);
    sort(ans.begin(), ans.end());
    cout << ans[3];
    return 0;
}

Measured memory_bytes: 3192
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb emplace_back
#define INF (1e9+1)

int main(){
    int n;
    cin>>n;
    vector<int> v(n);
    rep(i,n)cin>>v[i];
    sort(all(v));

    int sum = 0;
    rep(i,n-1)sum+=v[i];

    if(v.back()<sum)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<map>
#include<string>
#include<sstream>
using namespace std;
int inf = 1000000000;

int cnt(string s, string t){
  vector<bool> sa(26, false);
  for(int i=0; i<s.size(); i++){
    if( sa[s[i]-'a'] ) continue;
    sa[s[i]-'a'] = true;
  }
  vector<bool> ta(26, false);
  for(int i=0; i<t.size(); i++){
    if( ta[t[i]-'a'] ) continue;
    ta[t[i]-'a'] = true;
  }
  int ret = 0;
  for(int i=0; i<26; i++){
    if( sa[i] && ta[i] ) ret++;
  }
  cerr << ret << endl;
  return ret;
}

int main(){

  int n;
  string s;
  cin >> n >> s;
  int ans = 0;
  for(int i=1; i<n; i++){
    string ss = s.substr(0, i);
    string t = s.substr(i, n-i);
    cerr << ss << " " << t << endl;
    ans = max(ans, cnt(ss, t));
  }
  cout << ans << endl;

  return 0;
}





//


Measured memory_bytes: 256
N = int(input())
A = [int(input()) for _ in range(N)]

if A[0] != 0:
    print(-1)
    exit()
ans = A[-1]
now = A[-1] + 1

for a in A[::-1]:
    now -= 1
    if a > now:
        ans += a
        now = a
    elif a < now:
        ans = -1
        break

print(ans)

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

typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 28;

// ====================================================================

int main() {
  string s, t;
  cin >> s >> t;
  cout << t + s << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define max(p,q) ((p)>(q)?(p):(q))
#define min(p,q) ((p)<(q)?(p):(q))
#define chmax(a,b) ((a)=(a)>(b)?(a):(b))
#define chmin(a,b) ((a)=(a)<(b)?(a):(b))
#define abs(p) ((p)>=(0)?(p):(-(p)))
#define MOD 1000000007
ll power(ll a,ll b){ll r=1;rep(i,b){r*=a;}return r;}
#define swap(a,b) do{ll w=(a);(a)=(b);(b)=w;}while(0)

//your code here!
ll F(ll A, ll B){
    ll a=0, b=0;
    while(A){
        A /= 10;
        a++;
    }
    while(B){
        B /= 10;
        b++;
    }
    return max(a,b);
}

int main(void){
    ll N;
    scanf("%lld", &N);
    ll ansmin=1e15;
    for(ll i=1; i*i<=N; i++) {
        if(N%i == 0){
            ll B=N/i;
            chmin(ansmin, F(i, B));
        }
    }
    printf("%lld\n", ansmin);
    return 0;
}

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

int main()
{
    string s;
    cin >> s;
    int l = s.size();
    string ans = "AC";

    if (s[0] != 'A')
    {
        ans = "WA";
    }

    int cnt = 0;
    for (int i = 1; i < l; i++)
    {
        if (isupper(s[i]))
        {
            if (i == 1 || i == l - 1 || s[i] != 'C')
            {
                ans = "WA";
            }

            cnt++;

        }
    }

    if (cnt != 1)
    {
        ans = "WA";
    }

    cout << ans << endl;
}

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

typedef long long ll;

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> s(M), c(M);
    rep(i, M) cin >> s[i] >> c[i];
    rep(i, 1000) {
        if (N == 1 && i > 9) break;
        if (N == 2 && i < 10) continue;
        if (N == 2 && i > 99) break;
        if (N == 3 && i < 100) continue;
        string t = to_string(i);
        bool f = false;
        rep(j, M) {
            if ((int) (t[s[j] - 1] - '0') != c[j]) f = true;
        }
        if (f) continue;
        cout << i << endl;
        return 0;
    }
    cout << "-1\n";
}

Measured memory_bytes: 256
n, q = map(int, input().split())
s = input()
dic = {}
t_list = []
d_list = []

for i in range(q):
    t, d = input().split()
    t_list.append(t)
    if d == 'L':
        d_list.append(-1)
    else:
        d_list.append(1)


def find_pos(left, right):
    return left + (right - left - 1) // 2


def calc(sites, ts, ds, _n, _q):
    def check(idx):
        num = idx
        for j in range(_q):
            site = sites[num]
            if ts[j] == site:
                num += ds[j]
            if num < 0:
                return False
            if num > n - 1:
                return True
        return True

    def func(left, right):
        assert left > -1
        assert right < _n + 1
        if right - left == 1:
            if check(left):
                return left
            else:
                return right
        pos = find_pos(left, right)
        if check(pos):
            return func(left, pos + 1)
        else:
            return func(pos + 1, right)
    return func


f1 = calc(s, t_list, d_list, n, q)
f2 = calc(s[::-1], t_list, [-i*1 for i in d_list], n, q)
print(n - f1(0, n) - f2(0, n))


Measured memory_bytes: 8560
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <math.h>

#define min(x,y) ((x)<(y)?(x):(y))

int main(int argc, char *argv[])
{
    int a[10];
    int b;
    int c;
    int i;
    int ans;

    scanf("%d %d %d %d %d", &a[0], &a[1], &a[2], &a[3], &a[4]);

    ans = 0;
    c = 10;
    for(i = 0; i < 5; i++) {
        if (a[i] % 10 == 0) {
            b = a[i];
        } else {
            b = (a[i] / 10 + 1) * 10;
            c = min(c, a[i] % 10);
        }
        ans += b;
    }

    ans = ans - 10 + c;

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

    return 0;
}


Measured memory_bytes: 256
def bin_search(m, s, left, right):
    if left <= right:
        n = (left + right) // 2
        if s[n] == m:
            return True
        elif m < s[n]:
            return bin_search(m, s, left, n-1)
        else:
            return bin_search(m, s, n+1, right)


n = int(input())
s = [int(x) for x in input().strip().split(" ")]

q = int(input())
t = [int(x) for x in input().strip().split(" ")]

count = 0
for i in t:
    if bin_search(i, s, 0, len(s)-1):
        count += 1

print(count)


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

int main(void)
{
	string cards;
	int m, h;

	while (cin >> cards, cards!="-"){
		int n=cards.size();
		cin >> m;
		int s = 0;
		for (int i=0; i<m; i++){
			cin >> h;
			s += h;
		}
		s %= n;
		cout<<cards.substr(s,n)+cards.substr(0,s)<<endl;
	}
	return 0;
}

Measured memory_bytes: 1212
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner kb = new Scanner(System.in);
		String n = kb.next();
		int k = kb.nextInt();
		
		String num = Integer.toString(Integer.parseInt(n,10),k);
		System.out.println(num.length());
	}
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

const int N=1e3+5;
const int MOD=1e9+7;

int n, a, b, c, d;
int cache[N][N], cache2[N][N];
int fact[N], invfact[N], store[N][N];

int pow(int a, int b, int m)
{
	int ans=1;
	while(b)
	{
		if(b&1)
			ans=(ans*a)%m;
		b/=2;
		a=(a*a)%m;
	}
	return ans;
}

int modinv(int k)
{
	return pow(k, MOD-2, MOD);
}

void precompute()
{
	fact[0]=fact[1]=1;
	for(int i=2;i<N;i++)
	{
		fact[i]=fact[i-1]*i;
		fact[i]%=MOD;
	}
	invfact[N-1]=modinv(fact[N-1]);
	for(int i=N-2;i>=0;i--)
	{
		invfact[i]=invfact[i+1]*(i+1);
		invfact[i]%=MOD;
	}
	for(int i=1;i<N;i++)
	{
		int val=modinv(fact[i]);
		store[i][0]=1;
		for(int j=1;j<N;j++)
			store[i][j]=(store[i][j-1]*val)%MOD;
	}
}

int nCr(int x, int y)
{
	if(y>x)
		return 0;
	int num=fact[x];
	num*=invfact[y];
	num%=MOD;
	num*=invfact[x-y];
	num%=MOD;
	return num;
}

int dp2(int n, int r, int take)
{
	int ans=fact[n] * invfact[n-r*take];
	ans%=MOD;
	int den=store[r][take];
	ans*=den;
	ans%=MOD;
	return ans;
}

int dp(int remaining, int freq)
{
	if(remaining==0)
		return 1;
	if(freq==b+1)
		return 0;
	int &ans=cache[remaining][freq];
	if(ans!=-1)
		return ans;
	ans=dp(remaining, freq+1);
	for(int i=c;i<=d;i++)
	{
		int take=i*freq;
		if(take>remaining)
			continue;
		int ways=dp2(remaining, freq, i);
		ways*=dp(remaining-take, freq+1);
		ways%=MOD;
		ways*=invfact[i];
		ways%=MOD;
		ans+=ways;
	}
	ans%=MOD;
	return ans;
}

int32_t main()
{
	IOS;
	precompute();
	memset(cache, -1, sizeof(cache));
	memset(cache2, -1, sizeof(cache2));
	cin>>n>>a>>b>>c>>d;
	int ans=dp(n, a);
	cout<<ans;
	cerr<<(double)clock()/CLOCKS_PER_SEC;
	return 0;
}


Measured memory_bytes: 24064
#include <iostream>
using namespace std;
bool flag;
int i,j,k,n;
string s;
string out;
char button[9][5]={{'.',',','!','?',' '},
{'a','b','c'},
{'d','e','f'},
{'g','h','i'},
{'j','k','l'},
{'m','n','o'},
{'p','q','r','s'},
{'t','u','v'},
{'w','x','y','z'}
} ;
int main(){
	cin >> n;
	for(int p=0;p<n;p++){
		cin >> s;
		flag=false;
		i=-1;
		j=k=0;
		while(k!=s.size()){
			switch(s[k]){
				case'1':
				if(i==0){
					j++;
				}else{
					j=0;
					i=0;
				}
				if(j==5)j=0;
				break;
				case'2':
				if(i==1){
					j++;
				}else{
					j=0;
					i=1;
				}
				if(j==3)j=0;
				break;
				case'3':
				if(i==2){
					j++;
				}else{
					j=0;
					i=2;
				}
				if(j==3)j=0;
				break;
				case'4':
				if(i==3){
					j++;
				}else{
					j=0;
					i=3;
				}
				if(j==3)j=0;
				break;
				case'5':
				if(i==4){
					j++;
				}else{
					j=0;
					i=4;
				}
				if(j==3)j=0;
				break;
				case'6':
				if(i==5){
					j++;
				}else{
					j=0;
					i=5;
				}
				if(j==3)j=0;
				break;
				case'7':
				if(i==6){
					j++;
				}else{
					j=0;
					i=6;
				}
				if(j==4)j=0;
				break;
				case'8':
				if(i==7){
					j++;
				}else{
					j=0;
					i=7;
				}
				if(j==3)j=0;
				break;
				case'9':
				if(i==8){
					j++;
				}else{
					j=0;
					i=8;
				}
				if(j==4)j=0;
				break;
				case'0':
				if(i!=-1)cout <<button[i][j];
				flag=true;
				i=-1;
				break;
			}
			k++;
		}
		if(flag)cout <<endl;

	}

	return  0;
}

Measured memory_bytes: 3128
#include<bits/stdc++.h>
using namespace std;
int getDistance(int x1, int x2, int y1, int y2) {
  return abs(x1-x2)+abs(y1-y2);
}
main(){
  int N,M;
  cin>>N>>M;
  vector<pair<int,int>>students(N);
  for(int i=0;i<N;++i){
    int a,b;
    cin>>a>>b;
    students[i]=make_pair(a,b);
  }
  vector<pair<int,int>>points(M);
  for(int i=0;i<M;++i){
    int c,d;
    cin>>c>>d;
    points[i]=make_pair(c,d);
  }
  for(const auto&student:students){
    int distance_min=numeric_limits<int>::max();
    int index_min=-1;
    for(int i=0;i<M;++i){
      int x_stu=student.first;
      int y_stu=student.second;
      int x_poi=points[i].first;
      int y_poi=points[i].second;
      int distance=getDistance(x_stu,x_poi,y_stu,y_poi);
      if(distance<distance_min){
        distance_min=distance;
        index_min=i;
      }
    }
    cout<<index_min+1<<endl;
  }
}


Measured memory_bytes: 256
s = list(input())
s.reverse()
str = ""
for i in s:
    str+=i
str = str.replace("resare","")
str = str.replace("esare","")
str = str.replace("remaerd","")
str = str.replace("maerd","")
if len(str)==0:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 3956
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define RREP(i, s, n) for (int i = s; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
#define maxs(x,y) x = max(x, y)
#define mins(x,y) x = min(x, y)
using namespace std;
using ll = long long;
typedef pair<int, int> pint;
typedef pair<ll, ll> pll;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;
const int inf = (1<<29);

int main() {

    int x, y;
    cin >> x >> y;

    int ans = 0;
    if (x == 1) ans += 300000;
    if (x == 2) ans += 200000;
    if (x == 3) ans += 100000;
    if (y == 1) ans += 300000;
    if (y == 2) ans += 200000;
    if (y == 3) ans += 100000;
    if (x == 1 && y == 1) ans += 400000;
    




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

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

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

using ll = long long;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int INF = 1<<30;
const ll mod = 1000000007LL;

int main() {
  int X,N;
  cin>>X>>N;
  map<int,bool> m;
  for(int i = 0; i < N; i++){
    int x;
    cin>>x;
    m[x]=true;
  }
  int t = X, s = X+1;
  while(m[t]) t--;
  while(m[s]) s++;
  if(abs(t-X)<=abs(s-X)) cout<<t<<endl;
  else cout<<s<<endl;
}

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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define sz size()
#define pb(x) push_back(x) 
#define bg begin()
#define ed end()
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define mp(x,y) make_pair(x,y)
const ll MOD=1000000007;

ll maxx(ll x,ll y,ll z){
	return max(max(x,y),z);
}
ll minn(ll x,ll y,ll z){
	return min(min(x,y),z);
}
ll gcd(ll x,ll y){
	if(x%y==0) return y;
    else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
	return x*(y/gcd(x,y));
}
ll myceil(ll x,ll y){//yがいくつ集まったらx以上になるか
	if(x<=y) return 1;
	else if(x%y==0) return x/y;
	else return x/y+1;
}

//a,b x
int main(){
	vector<ll> A(3);
	rep(i,3) cin>>A[i];
	sort(A.bg,A.ed);
	if(A[0]==5 && A[1]==5 && A[2]==7) cout<<"YES";
	else cout<<"NO";
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <math.h>

int Pow(int n, int m);
int Max(int N[], int n);
int Sum(int N[], int n);

#define St 500

int main()
{
	int a = 0, b = 0;
	scanf("%d%d", &a, &b);
	printf("%d", a - b + 1);

	return 0;
}

int Pow(int n, int m) {
	int ret = 1;

	for (int i = 0; i < m; i++) {
		ret *= n;
	}

	return ret;
}

int Max(int N[], int n) {
	int max = 0;

	for (int i = 0; i < n; i++) {
		max = max < N[i] ? N[i]: max;
	}

	return max;
}

int Sum(int N[], int n) {
	int sum = 0;

	for (int i = 0; i < n; i++) {
		sum += N[i];
	}

	return sum;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <cassert>
#include <functional>
#include <numeric>
#include <limits>
#include <iomanip>
#include <queue>
#include <cmath>
#include <math.h>
#include <string>
#include <cmath>
#include <bitset>
#include <set>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const long long INF = 1LL << 60;
using pll = pair<long long, long long>;
typedef long long ll;
#define min(a, b) ((a) < (b) ? (a) : (b))
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

vector<int> p;
bool canMake(int num, int val) {
	if (num == 0) {
		// 0番目までで作れるのは0だけ！
		return val == 0;
	}
	// num-1番目までで、val-p[num-1]かvalが作れたらOK
	return canMake(num - 1, val - p[num - 1]) || canMake(num - 1, val);
}

int main() {
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	// cout << std::fixed << std::setprecision(15);

	set<int>st;
	int N; cin >> N;
	int tmp;
	for (int i = 0; i < N; i++) {
		cin >> tmp;
		st.insert(tmp);
	}

	cout << st.size() << endl;
 	// for (auto x : st) {
	//	cout << x;
	//}

	return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
int main () {
    long long N, P;
    cin >> N >> P;
    long long ans = 1;
    long long pp = P;
    for (long long i = 2; i * i <= P; i++) {
        int k = 0;
        while (pp % i == 0) {
            pp /= i;
            k++;
        }
        ans *= pow(i, k/N);
    }
    if (N == 1) ans *= pp;
    cout << ans << endl;
}

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

using namespace std;
typedef long long ll;

#define rep(i, N) for (int i = 0; i < (int)N; i++)
const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

struct edge { ll to; ll cost; };

int main() {
  int N, M, P; cin >> N >> M >> P;
  vector<edge> adj[N], radj[N];
  rep(i,M) {
    int A, B; cin >> A >> B; A--; B--;
    ll C; cin >> C; C-=P;
    adj[A].push_back({B,C});
    radj[B].push_back({A,C});
  }

  bool able[N] = {}; able[0] = true;
  queue<int> q; q.push(0);
  while(!q.empty()) {
    int now = q.front(); q.pop();
    for (auto x: adj[now]) {
      if (able[x.to]) continue;
      q.push(x.to);
      able[x.to] = true;
    }
  }
  bool rable[N] = {}; rable[N-1] = true;
  queue<int> rq; rq.push(N-1);
  while(!rq.empty()) {
    int now = rq.front(); rq.pop();
    for (auto x: radj[now]) {
      if (rable[x.to]) continue;
      rq.push(x.to);
      rable[x.to] = true;
    }
  }
  bool a[N]; rep(i,N) a[i] = able[i] && rable[i];

  ll r1[N], r2[N];
  ll dis[N]; fill_n(dis,N,-1*LLINF); dis[0] = 0;
  bool isf = true;
  rep(i,N) {
    rep(i,N) {
      for(auto x: adj[i]) {
        if (able[x.to]) {
          dis[x.to] = max(dis[x.to], dis[i] + x.cost);
        }
      }
    }
    if (i==N-2) rep(i,N) r1[i] = dis[i];
    if (i==N-1) rep(i,N) r2[i] = dis[i];
  }

  // rep(i,N) cout << a[i] << " "; cout << endl;
  bool ok = true; rep(i,N) if (a[i]&&r1[i]!=r2[i]) ok = false;
  ll result = (ok) ? max((ll)0, r1[N-1]) : -1;
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 768
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <iostream>
#include <climits>
#include <cstring>
#include <functional>

using namespace std;

using ll = long long;

#define rep(i, N) for(int i = 0;i < N;i++)
#define LARGE INT_MAX / 2

int N, M;
string red[100];
string blue[100];

int ans;

int main() {
	cin >> N;
	rep(i, N) {
		cin >> blue[i];
	}
	cin >> M;
	rep(i, M) {
		cin >> red[i];
	}
	rep(i, N) {
		int num = 0;
		rep(j, N) {
			if (blue[i] == blue[j]) {
				num++;
			}
		}
		rep(j, M) {
			if (red[j] == blue[i]) {
				num--;
			}
		}
		ans = max(ans, num);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>    // cin, cout
#include <string>    // string, stoi, to_string
#include <algorithm>    // sort, lower_bound, heap, min, next_permutation 
#include <functional>    // greater, less
#include <vector>    // vector
#include <stack>    // stack
#include <queue>    // queue
#include <list>    // list
#include <map>    // map
#include <set>    // set
#include <tuple>    // tuple
#include <bitset>    // bitset
#include <cstdio>  // fopen, printf, scanf, puts
#include <cmath>    // sin, exp, log, pow, sqrt
#include <iomanip>    // setfill, setbase
#include <ctime>    // clock

using namespace std;
using pii = pair<int, int>;
using ti = tuple<int, int, int>;

const double eps=1e-14;
const int mod = 1e9 + 7;
const int inf = ((1<<30));
const long long linf = (1LL<<60);

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int flag[n];
    for(int i=0; i<n; i++){
        int d1, d2;
        cin >> d1 >> d2;
        if(d1 == d2) flag[i] = 1;
        else flag[i] = 0;
    }
    bool ok = false;
    int cnt=0;
    for(int i=0; i<n; i++){
        if(flag[i] == 1) cnt++;
        else cnt = 0;

        if(cnt >= 3){
            ok = true;
            break;
        }
    }
    if(ok) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


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

#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long hoge = 0; (hoge) < (n); ++ (hoge)) cerr << #x << "[" << hoge << "]: " << x[hoge] << '\n'

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> Pll;
typedef vector<ll> vll;
const ll INF = LLONG_MAX/10;
const ll MOD = 1e9+7;

ll N;
vector<vll> G;
ll degree[100010];

ll dp[100010];
bool dfs(ll v,ll p,const ll &x){
  bool ret=true;
  vll V;
  for(ll u:G[v])if(p!=u){
    ret &= dfs(u,v,x);
    V.push_back(dp[u]+1);
  }
  if(!V.size())return ret;
  if(!ret)return false;
  sort(V.begin(),V.end());
  if(V.size()&1){
    ll low=-1,high=V.size();
    while(high-low>1){
      ll mid = (low+high)/2;
      bool isok=V[mid]<=x;
      ll l=0,r=V.size()-1;
      for(ll i=0;i<V.size()/2;i++){
        if(l==mid){
          l++;
        }
        if(r==mid){
          r--;
        }
        isok &= V[l]+V[r]<=x;
        l++;
        r--;
      }
      if(isok){
        high = mid;
      }else{
        low = mid;
      }
    }
    if(high==V.size()){
      return false;
    }
    dp[v] = V[high];
  }else{
    bool isok=true;
    ll l=0,r=V.size()-1;
    for(ll i=0;i<V.size()/2;i++){
      isok &= V[l]+V[r]<=x;
      l++;
      r--;
    }
    if(!isok){
      //cerr<<"!!"<<endl;
      ret &= V.back()<=x;
      V.pop_back();
      ll low=-1,high=V.size();
      while(high-low>1){
        ll mid = (low+high)/2;
        isok=V[mid]<=x;
        l=0,r=V.size()-1;
        for(ll i=0;i<V.size()/2;i++){
          if(l==mid){
            l++;
          }
          if(r==mid){
            r--;
          }
          isok &= V[l]+V[r]<=x;
          l++;
          r--;
        }
        if(isok){
          high = mid;
        }else{
          low = mid;
        }
      }
      if(high==V.size()){
        return false;
      }
      dp[v] = V[high];
    }
  }
  ret &= dp[v]<=x;
  return ret;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin>>N;
  G.resize(N);
  for(ll i=0;i<N-1;i++){
    ll a,b;cin>>a>>b;a--;b--;
    G[a].push_back(b);
    G[b].push_back(a);
    degree[a]++;
    degree[b]++;
  }
  int root=0;
  ll A=0;
  for(ll i=0;i<N;i++){
    if(degree[i]&1){
      A++;
      root=i;
    }
  }
  A /= 2;
  ll low=-1,high=N;
  while(high-low>1){
    ll mid=(high+low)/2;
    //debug(mid);
    fill(dp,dp+N,0);
    if(dfs(root,-1,mid)){
      high = mid;
    }else{
      low = mid;
    }
    //debugArray(dp,N);
  }
  cout<<A<<" "<<high<<endl;
  return 0;
}


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

template<typename T_char>
T_char ToUpper(T_char cX){return toupper(cX);}

int main(){
  int n;
  cin >> n;
  vector<string> s(n);
  for(int i=0; i<n; ++i) cin >> s[i];

  int m;
  cin >> m;
  vector<string> t(m);
  for(int i=0; i<m; ++i) cin >> t[i];

  string str, ans_str;
  int mx=0;

  for(int i=0; i<n; ++i){
    int cnt = 0;
    str = s[i];
    for(int j=0; j<n; ++j){
      if(str==s[j]) cnt++;
    }
    for(int k=0; k<m; ++k){
      if(str==t[k]) cnt--;
    }
    if(cnt>=mx){
      mx = cnt;
      ans_str = str;
    }
  }

  cout << mx << endl;
}

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

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, m, d;
    cin >> n >> m >> d;
    double ans;
    if(d == 0) ans = (double)(m - 1) / n;
    else ans = (double)(m - 1) * 2 * (n - d)  / (n * n);
    cout << fixed << setprecision(10) << ans << endl;

    return 0;
}


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

int main() {
  int A, B, C, X;
  cin >> A >> B >> C >> X;

  int ans = 0;

  for (int i = 0; i <= A; i++) {
    for (int j = 0; j <= B; j++) {
      for (int k = 0; k <= C; k++) {
        if (500 * i + 100 * j + 50 * k == X) ans++;
      }
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int MAXN=2005,MAXM=4005;
int n,k,ncnt=0;
bool vis[MAXN];
struct edge
{
	int v,nxt;
	edge(){}
	edge(int vv,int nn)
	{
		v=vv,nxt=nn;
	}
}E[MAXM];
int w[MAXN];
void addedge(int u,int v)
{
	E[++ncnt]=edge(v,w[u]);
	w[u]=ncnt;
}
int dfs1(int u,int f,int d)
{
	int re=1;
	if(d==0)
		return re;
	for(int i=w[u];i;i=E[i].nxt)
	{
		int v=E[i].v;
		if(v!=f)
		{
			re+=dfs1(v,u,d-1);
		}
	}
	return re;
}
int dfs2(int u,int f,int d)
{
	int re=0;
	if(d==0)
		return 1;
	for(int i=w[u];i;i=E[i].nxt)
	{
		int v=E[i].v;
		if(v!=f)
		{
			re+=dfs2(v,u,d-1);
		}
	}
	return re;
}
int main()
{
	//freopen("shorten.in","r",stdin);
	//freopen("shorten.out","w",stdout);
	scanf("%d %d",&n,&k);
	for(int i=1;i<n;i++)
	{
		int u,v;
		scanf("%d %d",&u,&v);
		addedge(u,v);
		addedge(v,u);
	}
	int zans=0;
	for(int i=1;i<=n;i++)
	{
		int o=dfs1(i,0,(k/2));
		if(k&1)
		{
			int op=0;
			for(int j=w[i];j;j=E[j].nxt)
				op=max(op,dfs2(E[j].v,i,k/2));
			o+=op;
		}
		zans=max(zans,o);
	}
	printf("%d\n",n-zans);
	fclose(stdin);
	fclose(stdout);
}

Measured memory_bytes: 256
using System;
class ITP1_10_A
{
    static void Main()
    {
        string[] input = Console.ReadLine().Split(' ');
        double x1 = double.Parse(input[0]);
        double y1 = double.Parse(input[1]);
        double x2 = double.Parse(input[2]);
        double y2 = double.Parse(input[3]);
        double dx = x2 - x1;
        double dy = y2 - y1;
        Console.WriteLine(Math.Sqrt(dx * dx + dy * dy));
    }
}

Measured memory_bytes: 5748
m = int(input())
C, D = [], []
for i in range(m):
    d, c = map(int, input().split())
    C.append(c)
    D.append(d)


x = sum([C[i] * D[i] for i in range(m)])
ans = sum(C) - 1 + (x - 1) // 9
print(ans)

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

using namespace __gnu_pbds;
using namespace std;
using namespace std::chrono;

#define ll long long
#define ld long double
#define pq priority_queue
#define ff first
#define ss second
#define pb push_back
#define pb push_back
#define all(c) (c).begin(), (c).end()
#define sz(c) ((ll)c.size())
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

#ifdef LL
const ll inf = 1e9;
#else 
const ll inf = 1e18;
#endif

const int mod = 1e9 + 7;
const int mod2 = 998244353;

typedef pair<ll, ll> ii;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<vii> vvii;

high_resolution_clock::time_point curTime() { return high_resolution_clock::now(); }
bool sortbysec(const pair<int,int> &a,const pair<int,int> &b){return (a.second < b.second);} //Just add this as a third argument to sort() while sorting an array of pairs; NO NEED FOR ANY ARGUMENTS;
template <typename T>
T fact(T a, T mod){ int res = 1, i; for (i = 2; i <= a; i++){ res *= i; res%=mod;} return res; }
template <typename T>
ll powmod(T a,T b,ll m){ ll ans=1; while(b>0){if(b&1){ans*=a;ans%=m;}a*=a;a%=m;b>>=1;} return ans; }
template <typename T>
ll power(T a, T b){ ll ans=1; while(b>0){if(b&1){ans*=a;}a*=a;b>>=1;}return ans;}
template <typename T>
T gcd(T a,T b){ return (b?__gcd(a,b):a); }
template <typename T>
T lcm(T a, T b){ return (a*(b/gcd(a,b))); }
template <typename T>
T cl(T a, T b){ return (a+b-1)/b; }
template <typename T>
T set_bits(T a)
{ return __builtin_popcount(a); }
template <typename T>
T add_self(T& a, T b, T mod){ a+=b; if(a>=mod){ a-=mod; } }
template <typename T>
T to_upper(T s){ transform(s.begin(), s.end(), s.begin(), ::toupper); return s; }
template <typename T>
T to_lower(T s){ transform(s.begin(), s.end(), s.begin(), ::tolower); return s; }



int main()
{
    ios_base :: sync_with_stdio(false);
    cin.tie(NULL);
    auto startTime = curTime();

    int n;
    cin>>n;

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

    //dp[i][j] is the value of X-Y if the initial array was the segment i,j

    vvi dp(n+1,vi(n+1));
    for(int i=n;i>0;i--)
    {
        for(int j=i;j<=n;j++)
        {
            if(i==j) dp[i][j] = a[i-1];
            else
            {
                dp[i][j] = max(a[i-1] - dp[i+1][j], a[j-1] - dp[i][j-1]);
            }
        }
    }

    cout<<dp[1][n]<<endl;

    auto stopTime = curTime();
    auto duration = duration_cast<microseconds>(stopTime - startTime);
    //cout<<"Program ran for "<<(ld)duration.count()/1e6<<" "<<"seconds"<<endl;
}


Measured memory_bytes: 73668
#include<iostream>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++)
	cin>>a[i];
	int eh,count=0;
	do{
		eh=0;
		for(int i=0;i<n;i++){
			if(a[i]%2==0){
				a[i]=a[i]/2;
			}
			else{
				eh=1;
				break;
			}
		}
		if(eh==0)count++;
	}while(eh==0);
	cout<<count;
}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
	int N;
    int k;
    vector<int> A;
    scanf("%d", &N);
    for (int i=0; i < N; i++) {
        scanf("%d", &k);
        A.push_back(k);
    }
    for (int i=1; i < N; i++) {
        for (int i=0; i < N; i++) {
            if (i == N-1) {
                printf("%d\n", A.at(i));
            } else {
                printf("%d ", A.at(i));
            }
        }
        int v = A.at(i);
        int j = i-1;
        while (j >= 0 && v < A.at(j)) {
            A.at(j+1) = A.at(j);
            j--;
        }
        A.at(j+1) = v;
    }
    for (int i=0; i < N; i++) {
        if (i == N-1) {
            printf("%d\n", A.at(i));
        } else {
            printf("%d ", A.at(i));
        }
    }
	return 0;
}


Measured memory_bytes: 2688
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
#include<tuple>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;





int main(){
    ll n,q;
    cin>>n>>q;
    vector<ll> a(n);
    for(auto &i:a){cin>>i;}
    sort(a.begin(),a.end());
    vector<ll> sum(n,0);
    vector<ll> sum2(n,0);
    sum[0]=a[0];
    sum2[0]=a[0];
    sum2[1]=a[1];
    for(int i=1;i<n;i++){sum[i]=a[i]; sum[i]+=sum[i-1];}
    for(int i=2;i<n;i++){sum2[i]=a[i]; sum2[i]+=sum2[i-2];}
    while(q--){
        ll x;
        cin>>x;
        if(x>=a.back()){cout<<sum2.back()<<endl; continue;}
        ll l=1,r=n;
        while(r-l>3){
            ll m=l+(r-l)/2;
            if(m&1){
                ll k=a[n-m/2-1];
                ll L=lower_bound(a.begin(),a.end(),x-(k-x))-a.begin();
                if(n-L>=m){l=m;}
                else{r=m-1;}
            }
            else{
                ll k=a[n-m/2];
                ll L=lower_bound(a.begin(),a.end(),x-(k-x))-a.begin();
                if(n-L>=m){l=m;}
                else{r=m-1;}
            }
        }
        //cout<<x<<" "<<l<<" "<<r<<endl;
        for(ll i=r;i>=l;i--){
            if(i&1){
                ll k=a[n-i/2-1];
                ll L=lower_bound(a.begin(),a.end(),x-(k-x))-a.begin();
                if(n-L>=i){
                    ll ans=sum.back();
                    if(n-i/2-2>=0){
                        ans-=sum[n-i/2-2];
                    }
                    if(n-i-2>=0){ans+=sum2[n-i-2];}
                    cout<<ans<<endl;
                    break;
                }
                else{continue;}
            }
            else{
                ll k=a[n-i/2];
                ll L=lower_bound(a.begin(),a.end(),x-(k-x))-a.begin();
                if(n-i/2-L>=i/2){
                    ll ans=sum.back();
                    if(n-i/2-1>=0){
                        ans-=sum[n-i/2-1];
                    }
                    if(n-i-1>=0){ans+=sum2[n-i-1];}
                    cout<<ans<<endl;
                    break;
                }
                else{continue;}
            }
        }
    }
    
    
    
    
    return 0;
}


Measured memory_bytes: 4096
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include<cmath>
#include<limits>
#define ll long long
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define int_INF 2147483647
#define pint_INF 2000000000
#define ll_INF 	9223372036854775807
#define MOD 1000000007
#define vi vector<int>
#define vvi vector<vector<int>>
#define vll vector<long long>
#define pii pair<int,int>
#define vpii vector<pair<int,int>>
#define vvc vector<vector<char>>
#define sysp system("PAUSE")
using namespace std;

bool check(int x, int y, vvc test, vvc table){
    for(int p = 0; p < test.size(); p++){
        for(int q = 0; q < test.size(); q++){
            if(table[p+x][q+y] == test[p][q]){
                continue;
            }else{
                return false;
            }
        }
    }

    return true;
}

int main(){
    int N,M; cin >> N >> M;
    vector<vector<char>> table(N,vector<char>(N));

    rep(i,N) rep(j,N) cin >> table[i][j];

    vector<vector<char>> test(M,vector<char>(M));

    rep(i,M) rep(j,M) cin >> test[i][j];

    int K = N - M;
    bool flag = false;
    for(int k = 0; k <= K; k++){
        for(int l = 0; l <= K; l++){
            if(check(k,l,test,table)){
                flag = true;
            }
        }
    }

    if(flag){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    sysp;
}

Measured memory_bytes: 504
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    int A, B;
    cin >> A >> B;
    cout << (B - 1 + A - 1 - 1) / (A - 1) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int i, n, a[10001], max = -1000001, min = 1000001;
    long long int sum = 0;

    scanf("%d",&n);
    for(i = 0; i < n; i++){
        scanf("%d", &a[i]);
        sum += a[i];
        if(a[i] > max) max = a[i];
        if(a[i] < min) min = a[i];
    }

    printf("%d %d %lld\n", min, max, sum);

    return 0;
}


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

int main(){
	int N, i;
	scanf("%d", &N);
	vector<int> ans(N, 0);
	for(i = 1; i < N; i++){
		int A;
		scanf("%d", &A);
		ans[A - 1]++;
	}
	for(i = 0; i < N; i++){
		printf("%d\n", ans[i]);
	}
	return 0;
}

Measured memory_bytes: 4068
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
    	try(Scanner sc = new Scanner(System.in)) {
    		int[] a = new int[5];
    		for(int i=0; i<5; i++) {
    			a[i]=sc.nextInt();
    		}
    		int k = sc.nextInt();
    		boolean flag = true;
    		for(int i=0; i<5; i++) {
    			for(int j=0; j<5; j++) {
    				if(i==j) continue;
    				int dis = Math.abs(a[i]-a[j]);
    				if(dis>k)	flag=false;
    			}
    		}
    		System.out.println(flag? "Yay!" : ":(");
    	}
    }
}

Measured memory_bytes: 21972
n=int(input())
if n%10==2 or n%10==4 or n%10==5 or n%10==7 or n%10==9:
  print("hon")
elif n%10==0 or n%10==1 or n%10==6 or n%10==8:
  print("pon")
else:
  print('bon')

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

typedef long long ll;

const int N = 5e5;

string s;
int arr[N+5];

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> s;
	memset(arr,-1,sizeof(arr));
	queue<int> qx,qv;
	for(int i=0;i<=s.size();i++){
		if((i==0 || s[i-1] == '>') && (i==s.size() || s[i] == '<')){
			qx.push(i);
			qv.push(0);
//			cout << "PUSH " << i << endl;
			arr[i] = 0;
		}
	}
	while(!qx.empty()){
		int id = qx.front(); qx.pop();
		int nv = qv.front(); qv.pop();
		if(id!=0 && arr[id-1] == -1 && ((id > 1 && s[id-2] == s[id-1]) || id==1)){
			arr[id-1] = nv+1;
			qx.push(id-1); qv.push(nv+1);
		}
		if(id!=s.size() && arr[id+1]==-1 && ((id == s.size()-1 ) || (id < s.size()-1 && s[id] == s[id+1]))){
			arr[id+1] = nv+1;
			qx.push(id+1); qv.push(nv+1);
		}
	}
	ll ret = 0;
	for(int i=0;i<=s.size();i++){
		if(arr[i] == -1) arr[i] = max(arr[i-1],arr[i+1])+1;
		ret += (ll)(arr[i]);
//		printf("%d ",arr[i]);
	}
//	printf("\n");
	printf("%lld\n",ret);
	return 0;
}


Measured memory_bytes: 3740