akhauriyash/Code-Regression huggingface dataset:
n = int(input())
a = [int(x) for x in input().split()]
key = 10**9

for i in range(n):
  b = a[i]
  c = 0
  while b%2 == 0:
    b //= 2
    c += 1
  if key > c:
    key = c
print(key)

Measured memory_bytes: 3060
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#pragma warning (disable: 4996)
using namespace std;
 
int N;
int A[1 << 19];
int B[1 << 19];
int LA[1 << 19], RA[1 << 19];
int LB[1 << 19], RB[1 << 19];
int cnt[1 << 19];
 
int main() {
	cin >> N;
	for (int i = 0; i < N; i++) cin >> A[i];
	for (int i = 0; i < N; i++) cin >> B[i];
	for (int i = 1; i <= N; i++) { LA[i] = (1 << 28); RA[i] = -(1 << 28); }
	for (int i = 1; i <= N; i++) { LB[i] = (1 << 28); RB[i] = -(1 << 28); }
	for (int i = 0; i < N; i++) { LA[A[i]] = min(LA[A[i]], i); RA[A[i]] = max(RA[A[i]], i); }
	for (int i = 0; i < N; i++) { LB[B[i]] = min(LB[B[i]], i); RB[B[i]] = max(RB[B[i]], i); }
 
	// 自明な No の判定
	for (int i = 0; i < N; i++) {
		if (LA[i] == (1 << 28) || LB[i] == (1 << 28)) continue;
		int p1 = RA[i] - LA[i] + 1;
		int p2 = RB[i] - LB[i] + 1;
		if (p1 + p2 > N) { cout << "No" << endl; return 0; }
	}
 
	for (int i = 1; i <= N; i++) {
		if (LA[i] == (1 << 28) || LB[i] == (1 << 28)) continue;
		int cr = (RA[i] + 1) - LB[i] - 1; while (cr < 0) cr += N;
		int cl = (LA[i] - (RB[i] - LB[i] + 1)) - LB[i] + 1; while (cl < 0) cl += N;
		if (cl > cr) cr += N;
		cnt[cl + 0] += 1;
		cnt[cr + 1] -= 1;
	}
	for (int i = 1; i <= N * 2; i++) cnt[i] += cnt[i - 1];
 
	// 判定
	int flag = -1;
	for (int i = 0; i < N; i++) {
		if (cnt[i] + cnt[i + N] == 0) flag = i;
	}
	if (flag == -1) {
		cout << "No" << endl;
		return 0;
	}
 
	// 出力
	cout << "Yes" << endl;
	for (int i = 0; i < N; i++) {
		if (i) cout << " ";
		cout << B[(i - flag + N) % N];
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 9824
import bisect
N=int(input())
A,B,C=[sorted(map(int,input().split())) for _ in range(3)]

p,q=0,0
xB=[None]*N

for i in range(N):
	while p < N and A[p] < B[i]:
		p += 1
	xB[i] = p

p,q=0,0
xC=[None]*N

for i in range(N):
	while p < N and B[p] < C[i]:
		q += xB[p]
		p += 1
	xC[i] = q

print(sum(xC))


Measured memory_bytes: 23348
#include <iostream>
#include <map>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <math.h>
#include <string>
using namespace std;
          

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string a;
    cin >> a;
    int b[26] = {} , c = 0 , d;
    for ( int i = 0 ; i < a.length() ; i++ ) {
        d = a[i];
        b[d - 97]++;
    }
    for ( int i = 0 ; i < 26; i++ ) {
        if (  b[i] % 2 == 1 ) {
            c = 1;
            break;
        }
    }
    if ( c == 1 ) cout << "No\n";
    else cout << "Yes\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>

using namespace std;

int n;
int a[500000];
int pos[500000];
long long ans;
int L[500000];
int R[500000];

int main()
{
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> a[i];
    for (int i = 1; i <= n; i++) pos[a[i]] = i;
    for (int i = 1; i <= n; i++) L[i] = i - 1;
    for (int i = 1; i <= n; i++) R[i] = i + 1;
    for (int i = n; i >= 1; i--)
    {
        long long LL = L[pos[i]], RR = R[pos[i]];
        ans += (pos[i] - LL) * (RR - pos[i]) * i;
        L[RR] = LL;
        R[LL] = RR;
    }
    cout << ans;
}


Measured memory_bytes: 5760
a[181],b1[1000000],b2[1000000];
void ite(n){
	int m,k,l,i;
	b1[0] = b2[0] = 0;
	for(m=1;m<=n;m++){
		i = 0;
		k = l = -1;
		for(i=1;i<181;i++){
			if(m >= a[i] && b1[m-a[i]] >= 0 && (k < 0 || b1[m-a[i]] + 1 < k))
				k = b1[m-a[i]] + 1;
			if((a[i]&1) && m >= a[i] && b2[m-a[i]] >= 0 && (l < 0 || b2[m-a[i]] + 1 < l))
				l = b2[m-a[i]] + 1;
		}
		b1[m] = k;
		b2[m] = l;
	}
}

main(n){
	for(n=1;n<181;n++)a[n]=n*(n+1)*(n+2)/6;
	ite(999999);
	for(;scanf("%d",&n),n;)printf("%d %d\n",b1[n],b2[n]);
	exit(0);
}

Measured memory_bytes: 8032
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define INF 1LL << 60;

int main() {
  int n;
  cin >> n;
  int h[100010];
  for (int i = 0; i < 100010; i++) cin >> h[i];

  ll dp[100010];
  for (int i = 0; i < 100010; i++) dp[i] = INF;

  dp[0] = 0;
  for (int i = 0; i < n; i++) {
    dp[i + 1] = min(dp[i + 1], dp[i] + abs(h[i] - h[i + 1]));
    dp[i + 2] = min(dp[i + 2], dp[i] + abs(h[i] - h[i + 2]));
  }

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


Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define o(a) cout << a << endl
#define int long long
#define first first
#define second se
using namespace std;
typedef pair<int, int> P;
typedef vector<int> vi;

signed main(){
    set<int> st;
    rep(i, 0, 3){
        int a;
        cin >> a;
        st.insert(a);
    }
    o(st.size());
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<vector>
#include<string>

using namespace std;

struct O{
    int id, time, p;
};

int n;
vector<O> a;
int p[100005];
vector<string> ans;

int main(){
    ios::sync_with_stdio(false);
    cin >> n; cin >> n;
    for (int i = 0; i < n; i++){
        O tmp;
        tmp.id = i;
        cin >> tmp.p >> tmp.time;
        a.push_back(tmp);
        ans.push_back("");
    }
    auto get_len = [](int x){ int p = 0; while (x) x /= 10, p++; return p;};
    sort(a.begin(), a.end(), [](O a, O b){return a.time < b.time;});
    for (int i = 0; i < n; i++){
        int len_id = get_len(a[i].p), len_od = get_len(++p[a[i].p]);
        for (int j = 0; j < 6 - len_id; j++) ans[a[i].id] += "0";
        ans[a[i].id] += to_string(a[i].p);
        for (int j = 0; j < 6 - len_od; j++) ans[a[i].id] += "0";
        ans[a[i].id] += to_string(p[a[i].p]);
    }
    for (int i = 0; i < n; i++) cout << ans[i] << endl;
}

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

int main(){
	int a[3];cin>>a[0]>>a[1]>>a[2];
	sort(a,a+3);
	if(a[0]==5 && a[1]==5 && a[2]==7) cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	return 0;
}


Measured memory_bytes: 256
//edpc_d.cpp
//Sat Jan 12 15:37:27 2019

#include <iostream>
#include <string>
#include <queue>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

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

	ll w[n+1],v[n+1];
	w[0] = 0LL; v[0] = 0LL;
	for (int i=1;i<n+1;i++){
		cin >> w[i] >> v[i];
	}

	ll dp[W+1];
	fill(dp,dp+W+1,0);
	for (int i=1;i<n+1;i++){
		for (int j=W;j>0;j--){
			if (w[i]<=j){
				dp[j] = max(dp[j-w[i]]+v[i],dp[j]);
			}
		}
	}

	ll ans = 0;
	for (int i=1;i<W+1;i++){
//		cout << dp[i] << " ";
		if (ans < dp[i]){
			ans = dp[i];
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define FOR(i, m, n) for (int i = m; i < (n); i++)
#define RFOR(i, m, n) for (int i = (m - 1); i >= 0; i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
typedef long long ll;
const int mod = 1e9 + 7;
const ll INF = 1000000000000000000LL;

ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }

ll lcm(ll a, ll b) { return a * b / gcd(a, b); }

ll factorial(ll n) {
  ll answer = 1;
  while (n > 1) {
    answer *= n;
    answer %= mod;
    n--;
  }
  return answer;
}

ll combination(ll n, ll r) {
  return factorial(n) / (factorial(r) * factorial(n - r));
}

ll permutation(ll n, ll r) { return factorial(n) / factorial(n - r); }

template <typename T>
void remove(std::vector<T>& vector, unsigned int index) {
  vector.erase(vector.begin() + index);
}

map<ll, ll> prime_factor(ll n) {
  map<ll, ll> ret;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if (n != 1) ret[n] = 1;
  return ret;
}
// for (auto p : prime_factor(n)) {
//	while (p.second--) {
//		cout << p.first << endl;
//	}
//}

vector<ll> divisor(ll n) {
  vector<ll> ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

bool compare_by_b(pair<ll, ll> a, pair<ll, ll> b) {
  if (a.second != b.second) {
    return a.second < b.second;
  } else {
    return a.first < b.first;
  }
}

vector<ll> Eratosthenes(const ll N) {
  bool is_prime[1000000 + 1];
  vector<ll> P;
  for (ll i = 0; i <= N; i++) {
    is_prime[i] = true;
  }
  for (ll i = 2; i <= N; i++) {
    if (is_prime[i]) {
      for (ll j = 2 * i; j <= N; j += i) {
        is_prime[j] = false;
      }
      P.emplace_back(i);
    }
  }
  return P;
}

typedef vector<int> ivec;
typedef vector<string> svec;
typedef vector<ll> lvec;

int main() {
  int n;
  cin >> n;
  lvec a(n);
  REP(i, n) { cin >> a[i]; }
  ll count1 = 0;
  ll count2 = 0;
  ll count4 = 0;
  REP(i, n) {
    if (a[i] % 4 == 0) {
      count4++;
    } else if (a[i] % 2 == 0) {
      count2++;
    } else {
      count1++;
    }
  }
  if (count4 != 0 && count4 + 1 >= count1) {
    count4 -= count1;
    if (count2 % 2 == 0) {
      puts("Yes");
    } else if (count4 + 1 >= count2 % 2) {
      puts("Yes");
    } else {
      puts("No");
    }
  } else {
    if (count1 == 0) {
      puts("Yes");
    } else {
      puts("No");
    }
  }
  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
int main(){	
	ios_base::sync_with_stdio(false);
	    cin.tie(NULL);
	    ll a , b , k;
	    cin >> a >> b >> k;
	    cout << max(0LL , a - k) << " " << max(0LL , b - max(0LL , k - a)) << endl;
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;

class Program
{
    const string Yes = "Yes";
    const string No = "No";
    const char White = '.';
    const char Black = '#';
    const long Mod = 1000000007;

    static void Main(string[] args) {
#if DEBUG
        MyDebugger.Test(process, "../TextFile1.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    static object process(TextReader input) {
        var spl = input.ReadLine().Split(' ');
        var a = int.Parse(spl[0]);
        var b = int.Parse(spl[1]);
        var c = int.Parse(spl[2]);
        
        var aa = 0;
        while(aa < 100000) {
            aa += a;
            if(aa % b == c) return "YES";
        }

        return "NO";
    }

    static int[] ToIntArray(string strs, int n) {
        var ret = new int[n];
        var spl = strs.Split(' ');
        for (int i = 0; i < n; i++)
            ret[i] = int.Parse(spl[i]);
        return ret;
    }
}


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

int main()
{
    size_t n;
    cin >> n;
    vector<double> x(n), y(n);
    for (auto&& i : x) {
        cin >> i;
    }
    for (auto&& i : y) {
        cin >> i;
    }

    double p1 = 0;
    double p2 = 0;
    double p3 = 0;
    double pn = 0;
    for (size_t i = 0; i < n; i++) {
        double tmp = abs(x[i] - y[i]);
        p1 += tmp; // p1
        p2 += pow(tmp, 2);
        p3 += pow(tmp, 3);
        pn = max(abs(x[i] - y[i]), pn); //p4
    }
    printf("%0.5lf\n", p1);
    printf("%0.5lf\n", sqrt(p2));
    printf("%0.5lf\n", pow(p3, 1.0 / 3.0));
    printf("%0.5lf\n", pn);
}



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

#define ALL(V) (V).begine(),(V).end()
#define SORT(V) sort(ALL(V))
#define REV(V) reverse(ALL(V))
#define RSORT(V) SORT(V);REV(V)

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

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

#define SZ(x) ((int)(x).size())

typedef vector<int> vi;
typedef long long ll;

double PI = 3.1415;

/* 入力 */
int N,M;

void calc()
{
    cin >> N >> M;
    vi A(M);
    rep(i,M) cin >> A[i];
    ll sum = accumulate(A.begin(),A.end(),0);
    if(N < sum) cout << "-1\n";
    else cout << N - sum << endl;
    return;
}

int main()
{
    calc();
}

Measured memory_bytes: 3636
#include<stdio.h>
#include<math.h>
#include<string.h>
int nxpt(char *s){
  int i,l=strlen(s),max=0,f[260]={0};
  for(l--;l+1&&max<=s[l];l--)f[max=s[l]]++;
  if(l<0)return 0;
  f[s[l]]++;
  for(i=s[l]+1;f[i]==0;i++);
  f[s[l]=i]--;
  for(i=0;s[++l];f[s[l]=i]--){
    while(f[i]==0)i++;
  }
  return 1;
}
int main(){
  int n,i,j,x[10],y[10];
  double l=0,d[10][10],e=0;
  char c[10]={};
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d %d",&x[i],&y[i]);
    c[i]='0'+i;
  }
  for(i=0;i<n;i++){
    for(j=0;j<n;j++)d[i][j]=hypot(x[i]-x[j],y[i]-y[j]);
  }
  do{
    
    for(i=1;i<n;i++){
      l+=d[c[i-1]-'0'][c[i]-'0'];
      //printf("%lf\n",l);
    }
    e++;
  }while(nxpt(c));
  printf("%.10lf\n",l/e);
  return 0;
}
    


Measured memory_bytes: 128
from functools import reduce
from fractions import gcd
import math
import bisect
import itertools
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
INF = float("inf")


def main():
    N = int(input())

    P = [0] * 5
    for i in range(5):
        P[i] = int(input())
    
    res = 4 + math.ceil(N / min(P))
    print(res)        


if __name__ == '__main__':
    main()

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

#define rep(i, s, n) for (int i = s; i < (int)(n); i++)
using namespace std;
// using ll = long long int;

void inv(vector<int>& v) {
    int length = v.size();
    for (int i = 0; i < length; i++) {
        cin >> v[i];
    }
}
void inv(vector<int>& v, int length) {
    for (int i = 0; i < length; i++) {
        cin >> v[i];
    }
}

int main() {
    int n, r;
    do {
        cin >> n >> r;
        if (n == 0 && r == 0) break;

        int ans = 0;
        // rep(x, 1, n - 2) {
        //     rep(y, x + 1, n - 1) {
        //         rep(z, y + 1, n) {
        //             if (x + y + z == r) ans++;
        //         }
        //     }
        // }
        for (int x = 1; x <= n - 2; x++) {
            for (int y = x + 1; y <= n - 1; y++) {
                for (int z = y + 1; z <= n; z++) {
                    if (x + y + z == r) ans++;
                }
            }
        }
        cout << ans << endl;
    } while (true);

    return 0;
}



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

using namespace std;

#define S scanf
#define P printf
#define G getline
#define SZ size()
#define C clear()
#define B begin()
#define F front()
#define T top()
#define E end()
#define EM empty()
#define V vector
#define Q queue
#define DQ deque
#define PQ priority_queue
#define ST stack
#define FI first
#define SE second
#define PI acos(-1)
#define PS push
#define PP pop()
#define PSF push_front
#define PSB push_back
#define PPF pop_front()
#define PPB pop_back()
#define MP make_pair
#define LL long long int
#define ULL unsigned long long int
#define PII pair<int,int>
#define PSI pair<string,int>
#define PIS pair<int,string>
#define PLI pair<long long int,int>
#define PLL pair<long long int,long long int>
#define MII map<int,int>
#define MSI map<string,int>
#define MIS map<int,string>
#define MLI map<long long int,int>
#define FAST() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)





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






int main()
{
    FAST();

//    freopen("input.txt","r",stdin);
//    freopen("input.txt","w",stdout);

    int i,n,ans=0,cnt=0;
    cin >> n;
    int a[n+2];
    for(i=1;i<=n;i++)
    {
        cin >> a[i];
    }
    for(i=1;i<n;i++)
    {
        if(a[i] >= a[i+1])
        {
            cnt++;
        }
        else
        {
            ans=max(ans,cnt);
            cnt=0;
        }
    }
    ans=max(ans,cnt);
    cout << ans;
    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define pb push_back
#define fr first
#define sc second
#define all(x) x.begin(), x.end()
#define skip continue
#define NAME "code"
#define tabs(a, b) ((a<b) ? (b-a) : (a-b))
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
 
void faster(){
   	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
 
const ull INF = 1e9;
const ll MOD = 1e9 + 7;
const ll MAXN = 3e5 + 123;
const ld EPS = 1e-12;
const int dx[4] = {-1, 0, 0, 1};
const int dy[4] = {0, -1, 1, 0};
 
int n, A[MAXN], c[MAXN], root, sum;
vector<pair<int, int>> g[MAXN];

void dfs(int v, int pr){
	c[v] = A[v] * ((g[v].size() != 1) + 1);

	int *b_edge = NULL;

	for(int i = 0; i < g[v].size(); ++i){
		if(g[v][i].fr != pr){
			dfs(g[v][i].fr, v);
			c[v] -= c[g[v][i].fr];
			g[v][i].sc = c[g[v][i].fr];
		}
		else{
			b_edge = &g[v][i].sc;
		}
	}

	if(b_edge != NULL)
		*b_edge = c[v];

	if(c[v] < 0){
		cout << "NO\n";
		exit(0);
	}
}

void check(int v){
	int sum = 0, mx = 0;

	for(int i = 0; i < g[v].size(); ++i){
		sum += g[v][i].sc;
		mx = max(g[v][i].sc, mx);
	}

	if(sum & 1 || mx > sum / 2){
		cout << "NO\n";
		exit(0);
	}
}

void solve(){
	cin >> n;

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

	for(int i = 2, u, v; i <= n; ++i){
		cin >> u >> v;
		g[u].pb({v, 0});
		g[v].pb({u, 0});
	}

	if(n == 2){
		cout << ((A[1] == A[2]) ? "YES" : "NO");
		return;
	}

	for(int i = 1; i <= n; ++i)
		if(g[i].size() != 1)
			root = i;

	dfs(root, 0);

	if(c[root] != 0){
		cout << "NO\n";
		return;
	}

	for(int i = 1; i <= n; ++i)
		if(g[i].size() > 1)
			check(i);

	cout << "YES\n";
}
 
int main(){
 
	faster();
 
	int T = 1;
	// cin >> T;
	
	while(T--){
		solve();
	}
 
	return 0;
}

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

#define fi  first
#define se  second
#define mp  make_pair
#define pb  push_back

typedef long long ll;
typedef queue <int> qi;
typedef vector <int> vi;
typedef map <int, int> mii;
typedef pair <int, int> pii;
typedef map <char, int> mci;
typedef map <string, int> msi;
typedef pair <string, int> psi;
typedef map <string, string> mss;
typedef unsigned long long ull;

const ll mod = 10e9+7;
const double eps = 1e-11;
const double PI = 2 * acos(0.0);

int main() {
    int n, c = 0;
    cin >> n;

    mci fux;

    for (int i = 0; i < n;i++) {
        char x;
        cin >> x;
        if (fux[x] == 0) {
            c++;
            fux[x]++;
        }
    }

    if (c == 4) puts("Four");
    else puts("Three");
}


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

constexpr bool scrib_enabled = false;

template <class T>
void scrib_impl(char const* title, T v){
    if (! scrib_enabled) return;
    cout << title << " ...... " << v << endl;
}
#define SCRIB(EXPR) (scrib_impl(#EXPR, (EXPR)))

using bint = int64_t;

bool is_prime(bint v) {
    if (v == 2) {
        return true;
    }
    bint r = static_cast<bint>(sqrt(v)+1);
    bint d;
    for (d=2; d<=r; d++) {
        if (v%d == 0) return false;
    }
    
    return true;
}

bint next_prime(bint c) {
    bint i = c;
    while(true) {
        if (is_prime(i)) {
            return i;
        }
        i++;
    }
}

int main() {
    bint v;
    cin >> v;
    cout << next_prime(v) << endl;
    
    SCRIB(is_prime(1));
    SCRIB(is_prime(2));
    SCRIB(is_prime(3));
    SCRIB(is_prime(756));
    SCRIB(is_prime(757));
    SCRIB(is_prime(758));
    SCRIB(next_prime(1));
    SCRIB(next_prime(2));
    SCRIB(next_prime(3));
    SCRIB(next_prime(756));
    SCRIB(next_prime(757));
    SCRIB(next_prime(758));
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define lli long long int
#define REP(i,s,n) for(lli i=s;i<n;i++)
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define TO_STRING(VariableName) # VariableName
#define LOG(x) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<endl;
#define LOG2(x,y) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<endl;
#define LOG3(x,y,z) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;
#define LOG4(w,x,y,z) if(DEBUG)cout<<TO_STRING(w)<<"="<<w<<" "<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;
 
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; }

lli d;
lli c[26];
lli s[370][26];
lli t[370];
lli lastDay[26];
std::chrono::system_clock::time_point start;

lli score(){

	lli ans = 0;
	REP(i,0,26)lastDay[i]=0;

	REP(i,1,d+1){
		ans += s[i-1][t[i-1]];

		lastDay[t[i-1]] = i;
		REP(j,0,26){
			ans -= c[j]*(i-lastDay[j]);
		}
		//cout<<ans<<endl;
	}
	return ans;
}

void dummyDayInput(){

	REP(i,0,d){
		cin>>t[i];
		//t[i]=1;
		t[i]--;
	}

}

void input(){
	cin>>d;
	REP(i,0,26)cin>>c[i];
	REP(i,0,d){
		REP(j,0,26){
			cin>>s[i][j];
		}
	}
}

void dummyDayChangeInput(){
	lli m;
	cin>>m;

	REP(i,0,m){
		lli d,q;
		cin>>d>>q;
		d--,q--;
		t[d] = q;
		cout<<score()<<endl;
	}
}

void init(){
	REP(i,0,365){
		lli maxD = -1;
		lli maxScore = -INF;
		REP(j,0,26){
			if(maxScore<s[i][j]+c[j]*(i-lastDay[j]+1) ){
				maxScore = s[i][j]+c[j]*(i-lastDay[j]+1);
				maxD = j;
			}
		}
		t[i] = maxD;
		lastDay[maxD] = i;
	}
}

void outputT(){
	REP(i,0,d){
		cout<<t[i]+1<<endl;
	}
}

int main(){

	ios::sync_with_stdio(false);
	std::cin.tie(nullptr);
	start = std::chrono::system_clock::now();
	mt19937 mt{std::random_device{}()};

	const lli T = 1950*1000;

	input();
	init();

	uniform_int_distribution<int> contestDist(0,25);
	uniform_int_distribution<int> dayDist(0,d-1);

	lli prevScore=score();

	lli cnt = 0;
	bool check = false;

	while(1){
        if(check || cnt%10000==0){
	        std::chrono::system_clock::time_point now = std::chrono::system_clock::now();
    	    double elapsed = std::chrono::duration_cast<std::chrono::microseconds>(now-start).count();
    	    if(elapsed > 1700*1000){
    	    	check = true;
    	    }
        	if(elapsed > T)break;
        }

        lli contestD = contestDist(mt);
        lli dayD     = dayDist(mt);

        LOG2(contestD,dayD);

        lli prevContest = t[dayD];
        t[dayD] = contestD;

        lli nowScore = score();
        if(prevScore>nowScore){
        	t[dayD] = prevContest;
        }
        else{
        	prevScore = nowScore;
        }
        cnt++;
	}

	outputT();
	//dummyDayInput();
	//score();
	//dummyDayChangeInput();
 
	return 0;
}

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

int main(){
	int n,ans;
	cin>>n;
	if(n%2==0){
		ans=n*n/4;
	}
	else{
		int m=(n-1)/2;
		ans=m*(m+1);
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <fstream>
#include <vector>
#include <deque>
#include <assert.h>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
#include <utility>
#include <math.h>
#include <bitset>
#include <iomanip>
#include <complex>
using namespace std;
//#define int long long
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long double ld;
typedef long long ll;
#define X first
#define Y second
#define all(o) o.begin(), o.end()
#define endl '\n'
#define IOS ios::sync_with_stdio(0), cin.tie(0)
const int maxn = 2e5 + 10;
vi adj[maxn]; 
string s;

int mark[maxn], cnt[2][maxn];

int32_t main(){
	IOS;
	
	int n, m;
	cin >> n >> m;
	cin >> s;
	for(int i=0; i<m; i++){
		int u, v;
		cin >> u >> v;
		u--, v--;
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
	set<int> st;
	for(int i=0; i<n; i++){
		int ok0 = 0, ok1 = 0;
		for(int u : adj[i]){
			if(s[u] == 'A')
				cnt[0][i]++;
			else
				cnt[1][i]++;
		}
		if(cnt[0][i] == 0 || cnt[1][i] == 0){
			st.insert(i);
			mark[i] = true;
		}
	}
	while(st.size()){
		//cout << ":D" << v << endl;
		auto v = *st.begin();
		st.erase(v);
		//cout << ":D" << v << endl;
		for(auto u : adj[v]){
			if(s[v] == 'A'){
				cnt[0][u]--;
				if(cnt[0][u] == 0 && !mark[u]){
					mark[u] = true;
					st.insert(u);
				}
			}
			else{
				cnt[1][u]--;
				if(cnt[1][u] == 0 && !mark[u]){
					mark[u] = true;
					st.insert(u);
				}
			}
		}
	}
	for(int i=0; i<n; i++)
		if(!mark[i]){
			cout << "Yes" << endl;
			return 0;
		}
	cout << "No" << endl;


}

Measured memory_bytes: 18128
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i ++)
#define irep(i,n) for (int i = (int)(n) - 1;i >= 0;--i)
using namespace std;
using ll = long long;
using PL = pair<ll,ll>;
using P = pair<int,int>;
constexpr int INF = 1000000000;
constexpr long long HINF = 1000000000000000;
constexpr long long MOD = 1000000007;// = 998244353;
constexpr double EPS = 1e-4;
constexpr double PI = 3.14159265358979;

int main() {
    int N; cin >> N;
    vector<ll> dp(N + 1);
    dp[0] = 2; dp[1] = 1;
    for (int i = 2;i <= N;++i) {
        dp[i] = dp[i - 1] + dp[i - 2];
    }
    cout << dp[N] << '\n';
    return 0;
}

Measured memory_bytes: 3624
import std.stdio, std.range, std.conv, std.string, std.array, std.functional, std.math;
import std.algorithm.comparison, std.algorithm.iteration, std.algorithm.mutation, std.algorithm.searching, std.algorithm.setops, std.algorithm.sorting;
import std.container.binaryheap;
import std.typecons; 

struct Pair{
    long a;
    long b;
}
void main()
{
    auto input = readln().strip.split.to!(long[]);
    const N = input[0];
    const M = input[1];
    auto list = uninitializedArray!(Pair[])(M);
    foreach(i; 0..M) {
        input = readln().strip.split.to!(long[]);
        list[i] = Pair(input[0], input[1]);
    }

    long[] resList;
    UnionFind unionFind = new UnionFind(N+1);
    long count = N*(N-1)/2;
    foreach_reverse(e; list) {
        if(unionFind.same(e.a, e.b))
        {
            resList ~= count;
            continue;
        }

        resList ~= count;
        count -= unionFind.count(e.a)*unionFind.count(e.b);
        unionFind.unite(e.a, e.b);
    }
    foreach_reverse(res; resList) {
        writeln(res);
    }
}

class UnionFind{
    private long[] list;

    this(long n)
    {
        list.length = n;
        list.fill(-1);
    }

    void unite(long a, long b)
    {
        list[root(a)] += list[root(b)];
        list[root(b)] = root(a);
    }

    bool same(long a, long b)
    {
        return root(a) == root(b);
    }

    long count(long n)
    {
        return -list[root(n)];
    }

    private long root(long n)
    {
        if(list[n] < 0)
        {
            return n;
        }

        return list[n] = root(list[n]);
    }
}

Measured memory_bytes: 6908
a = gets.chomp.split('')
['-', '+'].repeated_permutation(3) do |e|
    s = ""
    (a.size() - 1).times {|i| s += a[i] + e[i]}
    s += a[-1]
    if eval(s) == 7
        puts "#{s}=7"
        break
    end
end


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

public class Solution
{
    public static void Main()
    {
        var vals = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        var N = vals[0];
        var K = vals[1];
        var A = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();

        for (int k = 0; k < K; k++)
        {
            var B = new long[N];
            for (int i = 0; i < N; i++)
            {
                var l = Math.Max(0, i - A[i]);
                var r = Math.Min(i + A[i] + 1, N);

                B[l]++;
                if (r < N)
                {
                    B[r]--;
                }
            }

            for (int i = 1; i < N; i++)
            {
                B[i] += B[i - 1];
            }

            A = B;
            if (B.All(b => b == N))
            {
                break;
            }
        }

        Console.WriteLine(string.Join(" ", A));
    }
}

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

#define  ll         long long
#define  llu        unsigned long long
#define  mod        1000000007
#define  pi         ((2.0)*acos(0.0))
#define  pb         push_back
#define  pf         push_front
#define  eb         emplace_back
#define  mp         make_pair
#define  all(x)     (x).begin(),(x).end()
#define  X          first
#define  Y          second

/*loop*/
#define  fr(i,m,n)   for(ll i=m;i<n;++i)

/*output shortcuts*/
#define  nl         "\n"
#define  Yes        cout<<"Yes\n"
#define  yes        cout<<"yes\n"
#define  YES        cout<<"YES\n"
#define  No         cout<<"No\n"
#define  no         cout<<"no\n"
#define  NO         cout<<"NO\n"

ll a[10000000];


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

    ll n,k;
    cin>>n>>k;

    ll a[n];
    fr(i,0,n)
    cin>>a[i];

    ll dp[n];
    dp[n-1]=0;

    for(ll i=n-2; i>=0; i--)
    {
        ll p=LONG_MAX;

        fr(j,1,k+1)
        {
            if(i+j >= n)
                break;
            p = min( (dp[i+j] + abs(a[i]-a[i+j]) ) ,p );
            dp[i]=p;
        }
    }

    cout<<dp[0]<<nl;

return 0;
}




Measured memory_bytes: 5184
import java.util.*;
 
class Main {
   public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);
     
     int a = sc.nextInt();
     int b = sc.nextInt();
     
     int cnt = 0;
     if (a <= b)
       cnt = a;
     else
       cnt = a-1;
     
     System.out.println(cnt);
   }
}

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

int main() {
	int N, A[100000], count = 0;
	map<int, int> mp;
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		mp[A[i]] = i;
	}
	sort(A, A + N);
	for (int i = 0; i < N; i++) {
		count += abs(mp[A[i]] - i) % 2;
	}
	cout << count / 2;
}

Measured memory_bytes: 5376
var lines = require("fs").readFileSync("/dev/stdin", "utf8").split("\n");

var n=lines[0]|0;
var s=lines.slice(1);

function good(a,b){
    for(var i=0;i<n;++i){
        for(var j=0;j<n;++j){
            if(s[(i+a)%n][(j+b)%n]!==s[(j+a)%n][(i+b)%n])return 0;
        }
    }
    return 1;
}

var ans=0;
for(var a=0;a<n;++a){
    ans+=good(a,0)*n;
}
console.log(ans);


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

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

Measured memory_bytes: 256
a = int(input())
list = list(map(int,input().split()))
gcd = int(list[0])
for i in range(a):
	m = list[i] 
	n = gcd
	while n != 0:
		m,n = n,m%n
	if(m<gcd):
		gcd = m
print(gcd)

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

typedef vector<int> vi;

bool rec(vi cur){
	int sum=0;
	for(auto &i:cur) sum+=i;
	if(sum<=2){
		for(auto &i:cur) if(i==2) return true;
		return false;
	}

	bool res=false;
	rep(i,7){
		if(cur[i]&&cur[i+1]&&cur[i+2]){
			vi next=cur;
			rep(j,3) next[i+j]--;
			res|=rec(next);
		}
	}
	rep(i,9){
		if(cur[i]>=3){
			vi next=cur;
			next[i]-=3;
			res|=rec(next);
		}
	}
	return res;
}

string s;

int main(void){
	while(cin >> s){
		if(cin.eof()) break;
		vi cur(9);
		rep(i,s.size()) cur[s[i]-'1']++;
		vi ans;
		rep(i,9){
			vi next=cur;
			next[i]++;
			bool ok=true;
			rep(j,9) if(next[j]>4) ok=false;
			if(!ok) continue;
			if(rec(next)) ans.push_back(i+1);
		}
		if(ans.size()==0)
			puts("0");
		else{
			rep(i,ans.size()) cout << (i?" ":"") << ans[i];
			cout << endl;
		}
	}
	return 0;
}

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

int main() {
    int n;
    int c[32], v[32];
    scanf("%d", &n);
    for (int i = 0; i < n; i++)
        scanf("%d", &v[i]);
    for (int i = 0; i < n; i++)
        scanf("%d", &c[i]);
    int ans = 0;
    for (int i = 0; i < n; i++)
        if (c[i] < v[i])
            ans += v[i] - c[i];
    printf("%d\n", ans);

    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,a) for(int i=0;i<(a);i++)
const ll MOD=1000000007;


// dp[i]:iの子の，iと違う色の総和の最小値
int N, X[1010], dp[1010];
vector<vector<int> > G(1010);
// from[i]:親の色の子の総和がiの時の，親と違う色の子の総和の最小値
int from[5050], to[5050];
const int INF=1e9;

int main(){
  cin>>N;
  rep(i,N-1){
    int p; cin>>p; p--;
    G[p].push_back(i+1);
  }
  rep(i,N) cin>>X[i];
  for(int i=N-1;i>=0;i--){
    rep(j,5050) from[j]=INF;
    from[0]=0;
    for(auto v:G[i]){
      rep(j,5050) to[j]=INF;
      rep(j,5002) if(from[j]<INF){
        int x=min(5001,j+X[v]), y=min(5001,j+dp[v]);
        to[x]=min({to[x], from[j]+dp[v], 5001});
        to[y]=min({to[y], from[j]+X[v], 5001});
      }
      swap(from,to);
    }
    dp[i]=INF;
    rep(j, X[i]+1) dp[i]=min(dp[i],from[j]);
    if(dp[i]==INF){
      cout<<"IMPOSSIBLE\n";
      return 0;
    }
  }
  cout<<"POSSIBLE\n";
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pint;

ll v[51];
long double fact[51];
long double fact_init(int n){
    long double ret=1.0;
    fact[0]=1;
    FOR(i,1,n+1){
        ret*=i;
        fact[i]=ret;
    }
    return ret;
}
long double comb(int n,int r){
    if(n<r) return 0;
    return fact[n]/fact[n-r]/fact[r];
}
int main(){
    int n,a,b;
    cin>>n>>a>>b;
    rep(i,n) cin>>v[i];
    sort(v,v+n,greater<ll>());
    double sum=0;
    rep(i,a) sum+=v[i];
    sum/=a;
    fact_init(50);
    int cnt0=count(v,v+n,v[0]);
    int cnta=count(v,v+n,v[a-1]);
    int ap;
    rep(i,n) if(v[a-1]==v[i]){
        ap=i;break;
    }
    long double sc;
    if(v[0]!=v[a-1]) sc=comb(cnta,a-ap);
    else{
        FOR(i,a,min(cnt0,b)+1) sc+=comb(cnt0,i);
    }
    cout<<fixed<<setprecision(12)<<sum<<endl;
    cout<<fixed<<setprecision(0)<<sc<<endl;
    return 0;
}

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

using namespace std;

const long long NMAX = 1e5;
const long long BMAX = 60;

long long v[NMAX+2], N, K;
long long ans = 0;
long long nr[BMAX+2], sp_nr[BMAX+2], best_sp[BMAX+2];

int main()
{
    cin >> N;
    for( int i = 1;   i<= N;  ++i ) {
        cin >> v[i];
        ans += v[i];
    }
    for( int i = 1;  i <= N;  ++i ) {
        if( v[i] >= ans - v[i] ) {
            cout << "No\n";
            return 0;
        }
    }
    cout << "Yes\n";
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define FASTINOUT ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const ll mod = 1e9+7;
const int N=2e5+9;
int main()
{
    FASTINOUT;
    string s;
    cin>>s;
    int one=count(s.begin(),s.end(),'1');
    int zero=count(s.begin(),s.end(),'0');
    if (!one||!zero)
        cout<<0<<endl;
    else
        cout<<min(one,zero)*2;
    return 0;
}


Measured memory_bytes: 512
#include <queue>
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;

typedef pair<int, int> pii;
#define fi first
#define se second
#define mp make_pair

const int MAXN = 500;
const int MAXM = MAXN*MAXN;
const int dx[] = {0, 0, 1, -1};
const int dy[] = {1, -1, 0, 0};

bool a[MAXN + 5][MAXN + 5];
int d[MAXN + 5][MAXN + 5], N;

void update(int x, int y) {
	queue<pii>que; que.push(mp(x, y));
	while( !que.empty() ) {
		pii f = que.front(); que.pop();
		for(int i=0;i<4;i++) {
			pii g = mp(f.fi + dx[i], f.se + dy[i]);
			if( d[f.fi][f.se] + a[f.fi][f.se] < d[g.fi][g.se] )
				d[g.fi][g.se] = d[f.fi][f.se] + a[f.fi][f.se], que.push(g);
		}
	}
}

int P[MAXM + 5], M;
int main() {
	scanf("%d", &N), M = N*N;
	for(int i=1;i<=M;i++)
		scanf("%d", &P[i]);
	for(int i=1;i<=N;i++)
		for(int j=1;j<=N;j++)
			d[i][j] = min(min(i - 1, j - 1), min(N - i, N - j)), a[i][j] = 1;
	
	int ans = 0;
	for(int i=1;i<=M;i++) {
		int x = (P[i] - 1) / N + 1, y = (P[i] - 1) % N + 1;
		ans += d[x][y], a[x][y] = 0, update(x, y);
	}
	printf("%d\n", ans);
}

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

#define loop(i,a,b) for(ll i=a; i<b; i++)
#define rloop(i,a,b) for(ll i=a; i>b; i--)
#define all(var) var.begin(), var.end()
#define eloop(var) for(auto elem : var)
#define debug(x) cerr<<#x<<" ----> "<<x<<endl;
#define TC ll tt; cin>>tt; while(tt--)
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ size()
#define SET(a) memset(a,-1,sizeof(a))
#define CLR(a) memset(a, 0, sizeof(a))
#define INF 0x7fffffff
#define LINF 2000000000000000007
#define MOD 1000000007
#define MAX 100005
typedef long long ll;
typedef long double ld;
#define pll pair<ll,ll>
#define vll vector<ll>
#define vpl vector< pll >

char find(ll n) {
    if(n==0)
        return 'z';
    else 
        return 'a'+n-1;
}
string s;
void solve(ll n) {
    if(n==0)
        return ;
    s += find(n%26);
    if(n%26==0)
        solve((n/26)-1);
    else
        solve(n/26);
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    // TC
    {
        ll n;
        cin>>n;
        solve(n);
        reverse(all(s));
        cout<<s<<'\n';
    }
    return 0;
}

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

const int L = 128;
int L2 = 0;

int cnt[64];
char S[64];
int indx[256];

int query(string x){
    printf("? %s\n", x.c_str());
    fflush(stdout);
    int y;
    scanf("%d", &y);
    return y;
}

string rec(int s, int e){
    if(s == e){
        string temp = "";
        for(int i = 0; i < cnt[s]; i ++){
            temp += S[s];
        }
        return temp;
    }else{
        int m = (s+e)>>1;
        string str1 = rec(s, m);
        string str2 = rec(m+1, e);

        string res = "";
        int len1 = str1.size();
        int len2 = str2.size();
        int L3 = len1+len2;

        int indx1 = 0;
        int indx2 = 0;

        while(indx1 < len1 || indx2 < len2){
            if(indx1 == len1){
                res += str2[indx2++];
            }else if(indx2 == len2){
                res += str1[indx1++];
            }else{
                string temp = res + str1[indx1] + str2.substr(indx2);
                int qres = query(temp);
                if(qres == L2-(int)temp.size()){
                    res += str1[indx1++];
                }else{
                    res += str2[indx2++];
                }
            }
        }

        return res;
    }
}

int main(){
    int cnt2 = 0;
    for(int i = 'a'; i <= 'z'; i ++){
        indx[i] = cnt2;
        S[cnt2] = i;
        cnt2 ++;
    }
    for(int j = 'A'; j <= 'Z'; j ++){
        indx[j] = cnt2;
        S[cnt2] = j;
        cnt2 ++;
    }
    for(int k = '0'; k <= '9'; k ++){
        indx[k] = cnt2;
        S[cnt2] = k;
        cnt2 ++;
    }

    for(int i = 0; i < cnt2; i ++){
        string temp = "";
        for(int j = 0; j < L; j ++){
            temp += S[i];
        }
        int res = L-query(temp);
        cnt[i] = res;
        L2 += cnt[i];
    }

    string ans = rec(0, cnt2-1);
    printf("! %s\n", ans.c_str());
    fflush(stdout);
    return 0;
}


Measured memory_bytes: 3760
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <random>
#include <unordered_map>
#include <unordered_set>
#define all(a) a.begin(),a.end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define pb push_back
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;
typedef complex<ld> com;
constexpr int inf = 1000000010;
constexpr ll INF = 1000000000000000010;
constexpr ld eps = 1e-12;
constexpr ld pi = 3.141592653589793238;
template<class T, class U> inline bool chmax(T &a, const U &b) { if (a < b) { a = b; return true; } return false; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if (a > b) { a = b; return true; } return false; }


signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);

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

Measured memory_bytes: 3612
#include <iostream>
#include <cstdio>
#include <map>

using namespace std;

typedef long long ll;
const ll M = 1000000007;
ll n;
map<ll, ll> d;

ll f(ll p)
{
    if(p == 0) return 1;
    if(p == 1) return 2;
    if(d[p] > 0) return d[p];
    if(p % 2 == 0) return d[p] = (f(p / 2) + f(p / 2 - 1) * 2 % M) % M;
    return d[p] = (f(p / 2) * 2 % M + f(p / 2 - 1)) % M;
}

int main()
{
    scanf("%lld", &n);
    printf("%lld", f(n));
    return 0;
}


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++)
/*
*/

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

ll lcm(ll a, ll b){
  return a/gcd(a,b) * b;
}
ll func2(ll n){
  ll res = 0;
  while(n%2 == 0){
    n /= 2;
    res++;
  }
  return res;
}

ll zyou(ll a,ll b){//a＾b
  ll res = 1;
  for(int i = 1;i<=b;i++){
    res *= a;
  }
  return res;
}
struct Edge{
  int to;
  int weight;
  Edge(int t, int w) : to(t),weight(w){ }
};

typedef pair<int,int> P;
using Graph = vector<vector<Edge>>;

ll calc(ll a, ll b, ll p){//aのb乗をpで割った余り
  if(b == 0) return 1;

  else if(b%2 == 0){
    ll d = calc(a,b/2,p);
    return (d*d)%p;
  }
  else if(b%2 == 1){
    return (a * calc(a,b-1,p))%p;
  }
}



bool is_prime(int n){//nが素数であるかどうか判定 iで割り切れると素数でない
    if(n == 1) return false;//1は例外
    for(int i = 2;i*i <= n;i++){
        if(n%i == 0) return false;
    }
    
    return true;
}
int dfs(int x,int y,int H,int W,vector<vector<char>> &masu){
  if(masu[x][y] == '#'){

  }
}
bool palin(string S){
  int n = S.size();
  bool flag = true;
  if(n%2 == 0){
    for(int i = 0;i<=n/2-1;i++){
      if(S[i] != S[n-i-1]){
        flag = false;
        break;
      }
    }
  }
  else if(n%2 == 1){
    for(int i = 0;i<=n/2-1;i++){
      if(S[i] != S[n-i-1]){
        flag = false;
        break;
      }
    }
  }
  return flag;
}
int main(){
  int N;
  cin >> N;
  vector<int> a(N);
  rep(i,N){
    cin >> a[i];
  }
  int c = 0;
  for(int i = 0;i<N;){
    if(a[i] == a[i+1]){
      c++;
      i += 2;
    }
    else i++;
  }
  cout << c << endl;
  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define prArr(Arr,n) for(int _=0;_<n;_++)   cout<<(Arr)[_]<<" ";
#define f first
#define s second
using namespace std;
const int INF=(int)0x3f3f3f3f;
const int MOD=(int)1e9+7;
const double eps=1e-9;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n,x,t,ans;
    cin>>n>>x>>t;
    ans=n*t/x;
    ans+=t-1;
    ans/=t;
    ans*=t;
    cout<<ans;
    return 0;
}


Measured memory_bytes: 3644
import java.util.*;

public class Main {
    private static final int INF = 114514;

    public void main(Scanner sc) {
        int n = sc.nextInt();
        int ma = sc.nextInt();
        int mb = sc.nextInt();

        int map[][] = new int[401][401];
        for (int i = 0; i <= 400; i++) {
            Arrays.fill(map[i], INF);
        }

        map[0][0] = 0;
        for (int i = 0; i < n; i++) {
            int a = sc.nextInt();
            int b = sc.nextInt();
            int c = sc.nextInt();
            for (int j = 400; j >= a; j--) {
                for (int k = 400; k >= b; k--) {
                    map[j][k] = Math.min(map[j][k], map[j - a][k - b] + c);
                }
            }
        }

        int ans = INF;
        for (int i = 1; (ma * i <= 400) && (mb * i <= 400); i++) {
            ans = Math.min(ans, map[i * ma][i * mb]);
        }
        System.out.println(ans == INF ? -1 : ans);
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        new Main().main(sc);
        sc.close();
    }
}


Measured memory_bytes: 23252
#include<bits/stdc++.h>
using namespace std;
int main(){
  string S;
  cin>>S;
  if(S=="SUN")cout<<"7"<<endl;
  if(S=="MON")cout<<"6"<<endl;
  if(S=="TUE")cout<<"5"<<endl;
  if(S=="WED")cout<<"4"<<endl;
  if(S=="THU")cout<<"3"<<endl;
  if(S=="FRI")cout<<"2"<<endl;
  if(S=="SAT")cout<<"1"<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O3")
#pragma GCC target("sse4")

typedef long double LD;
typedef long long LL;
typedef pair<int, int> PII;
typedef pair<LD, LD> PDD;
typedef pair<LL, LL> PLL;
typedef vector<int> VI;
typedef vector<LL> VLL;
typedef vector<LD> VLD;
typedef vector<string> VS;
typedef vector<PII> VPII;
typedef vector<PLL> VPLL;
#define MP make_pair
#define PB push_back
#define X first
#define Y second
#define prev fake_prev
#define left fake_left
#define right fake_right

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define REP(i, t) FOR(i, 0, t)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())
#define FILL(a, value) memset(a, value, sizeof(a))

const LD PI = acos(-1.0);
const LD EPS = 1e-6;
const LL INF = 1e9;
const LL LINF = 1e18;
const LL mod = 1e9 + 7;
const LL MAX = 1e5 + 47;

LL n;
VLL a;

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//freopen("In.txt", "r", stdin);
	
	cin >> n;
	a.resize(n);
	FOR(i, 0, n)
		cin >> a[i];
		
	sort(ALL(a));
	PLL ans;
	ans.X = a[n - 1];
	LL t = a[n - 1];
	
	VLL::iterator it = lower_bound(ALL(a), t/2);
	LL v = *it;
	if (it == a.begin())
	{
		ans.Y = a[0];
	}
	else
	{
		--it;
		LL s = *it;
		if (v < ans.X && v - (t + 1)/2 <= t/2 - s)
			ans.Y = v;
		else
			ans.Y = s;
	}
	
	cout << ans.X <<" " << ans.Y << endl;
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
ll f(ll a, ll b){
    if(a>b) swap(a, b);
    ll d = b/a;
    if(b%a==0) return (2*d - 1)*a;
    else return 2*d*a+f(a, b%a);
}
int main(){
    ll n, x; cin>>n>>x;
    cout<<n+f(x, n-x)<<endl;
}

Measured memory_bytes: 256
import std.stdio, std.string, std.array, std.conv, std.algorithm, std.typecons, std.range, std.container, std.math, std.algorithm.searching, std.functional,std.mathspecial;
     
    void main(){
        auto NAB=readln.split.map!(to!int).array;
        auto Xs=readln.split.map!(to!long).array;
        auto res=0L;
        foreach(i;0..NAB[0]-1){
            res+=min(NAB[1]*(Xs[i+1]-Xs[i]),NAB[2]);
        }
        writeln(res);
    }

Measured memory_bytes: 4220
#include <stdio.h>
#include <string.h>
#include <math.h>
int main()
{
	int n,sum=0,i=0;
	scanf("%d",&n);
	int a[n],b[n];
	for(i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
	}
	for(i=0;i<n;i++)
	{
		scanf("%d",&b[i]);
	}
	for(i=0;i<n;i++)
	{
		if(a[i]>b[i])
		{
			sum+=a[i]-b[i];
		}
	}
	printf("%d",sum);
} 

Measured memory_bytes: 128
use proconio::input;

fn main() {
    input! {
        n: usize,
        m: usize,
        x: u64,
        cass: [(u64, [u64; m]); n],
    }

    let ans = (0..1 << n)
        .flat_map(|bits| {
            let mut yen = 0;
            let mut levels = vec![0; m];
            for i in 0..n {
                if (bits >> i) & 1 == 1 {
                    let (c, r#as) = &cass[i];
                    yen += c;
                    for j in 0..m {
                        levels[j] += r#as[j];
                    }
                }
            }
            if levels.iter().all(|&l| l >= x) {
                Some(yen)
            } else {
                None
            }
        })
        .min();

    if let Some(ans) = ans {
        println!("{}", ans);
    } else {
        println!("-1");
    }
}


Measured memory_bytes: 2188