akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <cstring>
#define ll long long
#define pa pair<int,int>
using namespace std;
int a[1001];
int len(int x)
{
    int ans = 0;
    while(x)
    {
        ans++;
        x>>=1;
    }
    return ans-1;
}
int main()
{
    int n;
    cin>>n;
    ll ans = 0;
    for(int i = 1;i<=n;i++)
    {
        int x;
        cin>>x;
        if(x % 2 == 0) ans += __builtin_ctz(x);
    }
    cout<<ans<<endl;
    return 0;
}


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

using ll = long long;
using ull = unsigned long long;
using st = string;
using db = double;
using vll = vector<long long>;
using vvll = vector<vll>;
using vchar = vector<char>;
#define rep(i, m, n) for (int i = (int)(m); i < (int)(n); i++)
#define vrep(vec) for(auto& i : vec)
#define vin(vec) for(auto& i : vec) cin >> i
#define all(v) v.begin(), v.end()
ll mod = 1000000007;

int main(){
  ll n, a, b;
  cin >> n >> a >> b;
  ll ans;
  if(n % (a + b) >= a) ans = n / (a + b) * a + a;
  else ans = n / (a + b) * a + n % (a + b);
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#define int long long

int MOD(int a, int M){
	a %= M;
	return a >= 0 ? a : a + M;
}

int power(int a, int N, int M){
	if(N == 0){
		return 1;
	}
	else if(N % 2 == 0){
		return power(MOD(a * a, M), N / 2, M);
	}
	else{
		return MOD(a * power(a, N - 1, M), M);
	}
}

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

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

//オイラーのφ関数
//M以下でMと互いに素なものの個数を求める
int Eulers_phi_function(int M){
	int i, j, ans = 1;
	for(i = 2; i * i <= M; i++){
		for(j = 0; M % i == 0; j++, M /= i);
		if(j > 0){
			for(ans *= i - 1; j > 1; j--, ans *= i);
		}
	}
	if(M > 1){
		ans *= M - 1;
	}
	return ans;
}

typedef struct {
	int s;
	int t;
}pair;

//拡張ユークリッドの互除法
//ax + by = gcd(x, y) となる(a, b)を求める
//x > 0, y >= 0 を仮定している
pair Extension_Euclidean(int x, int y){
	if(y == 0){
		return (pair){1, 0};
	}
	else{
		pair p = Extension_Euclidean(y, x % y);
		return (pair){p.t, p.s - p.t * (x / y)};
	}
}

int CRT(int a, int b, int N, int M){
//	printf("(a, b, N, M) = (%lld, %lld, %lld, %lld)\n", a, b, N, M);
//	printf("lcm(N, M) = %lld\n", lcm(N, M));
	pair p = Extension_Euclidean(N, M);
//	printf("p = (%lld, %lld)\n", p.s, p.t);
//	printf("p.s * N + p.t * M = %lld\n", p.s * N + p.t * M);
//	printf("gcd(N, M) = %lld\n", gcd(N, M));
	int x = a + MOD(((b - a) / gcd(N, M)) * p.s, M / gcd(N, M)) * N;
//	printf("x = %lld\n", x);
//	printf("x = %lld mod %lld\n", MOD(x, N), N);
//	printf("x = %lld mod %lld\n", MOD(x, M), M);
	return x;
}

int solve(int A, int M){
//	printf("(A, M) = (%lld, %lld)\n", A, M);
	int x, y;
	if(M == 1){
		x = 100;
	}
	else{
		int phiM = Eulers_phi_function(M);
		y = solve(A, gcd(M, phiM));
//		printf("power(%lld, %lld, %lld) = %lld\n", A, y, M, power(A, y, M));
		x = CRT(power(A, y, M), MOD(y, phiM), M, phiM);
//		printf("xsub = %lld\n", x);
		if(x < 100){
			x += lcm(M, phiM) * (100 / lcm(M, phiM) + 1);
		}
	}
//	printf("power(%lld, %lld, %lld) = %lld\n", A, x, M, power(A, x, M));
//	printf("MOD(%lld, %lld) = %lld\n", x, M, MOD(x, M));
//	printf("x = %lld\n", x);
	return x;
}

signed main(){
	int Q, q, A, M;
	scanf("%lld", &Q);
	for(q = 0; q < Q; q++){
		scanf("%lld%lld", &A, &M);
//		printf("phi(%lld) = %lld\n", M, Eulers_phi_function(M));
//		int x = A, y = M;
//		pair p = Extension_Euclidean(x, y);
//		printf("%lld * %lld + %lld * %lld = %lld\n", p.s, x, p.t, y, gcd(x, y));
		int x = solve(A, M);
		printf("%lld\n", x);
//		printf("power(%lld, %lld, %lld) = %lld\n", A, x, M, power(A, x, M));
//		printf("MOD(%lld, %lld) = %lld\n", x, M, MOD(x, M));
	}
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
typedef long long lint;
typedef unsigned int uint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
typedef unsigned long long ulint;
#define endl '\n'
#define fst first
#define sed second
#define pb push_back
#define mp make_pair
#define rint register int
#define newline putchar('\n')
#define leave_space putchar(' ')
#define all(x) (x).begin(), (x).end()
#define reveal(x) cerr << #x << " = " << (x) << endl
#define rep(it, f, e) for (rint it = (f); it <= (e); ++it)
#define per(it, f, e) for (rint it = (f); it >= (e); --it)
const lint MAX = 1e9;
int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL), cout.tie(NULL);
	lint s;
	cin >> s; 
	if (s <= MAX) {
		cout << "0 0 1 0 0 " << s << endl;
	} else {
		lint c = (s + MAX - 1) / MAX;
		cout << "0 0 " << MAX << " " << 1 << " " << MAX * c - s << " " << c << '\n';
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define vi vector <int>
#define si set <int>
#define mii map <int,int>
#define pii pair <int,int>
#define endl "\n"
#define ZERO 0ll
#define FOR(P,Q) for(int P=0;P<(Q);P++)
#define FORR(P,Q) for(int P=1;P<=(Q);P++)
#define rep(P,R,Q) for(int P=(R);P<=(Q);P++)
#define repb(P,R,Q) for(int P=(R);P>=(Q);P--)
#define pb push_back
#define eb emplace_back
#define bug(j) cerr<<j<<" "
#define NL cerr<<endl
#define D1(arr,a) rep(i,1,a) bug(arr[i]) 
typedef long long ll;
typedef long double ld;
using namespace std;


    
int32_t main()
{
	ios_base::sync_with_stdio(0);
	cout.tie(0);
	cin.tie(0);
	#ifndef ONLINE_JUDGE
	freopen("error.txt","w",stderr);
	#endif
	//change ll to int before using string builtin operations
	int tces=1;
	//cin>>tces;
	while(tces--){
		string s;
		cin>>s;
		FOR(i,3){
			// cout<<s[i];
			if(s[i]=='B')
				cout<<'R';
			else if(s[i]=='R')
				cout<<'B';
			else 
				cout<<s[i];

		}

	}
	
return 0;
}

Measured memory_bytes: 3612
#include"bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp> 
using namespace __gnu_pbds; 
using namespace std;

#define double long double
#define int long long
#define pb push_back 
#define Z(c) (int)(c).size()
#define L(c) c[Z(c)-1]
#define F first
#define S second
#define nl "\n"
#define mii map<int,int> 
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define rep(i,iv,n) for(int (i)=(iv);(i)<(n);++(i))
#define FO fflush(stdout) 
#define D1(x) cerr <<"At line "<<__LINE__<<" "<<#x<<"="<<x<<nl
#define D2(x,y) cerr <<"At line "<<__LINE__<<" "<<#x<<"="<<x<<" "<<#y<<"="<<y<<nl
#define D3(x,y,z) cerr <<"At line "<<__LINE__<<" "<<#x<<"="<<x<<" "<<#y<<"="<<y<<" "<<#z<<"="<<z<<nl
#define tr(it,ct) for(auto &(it) : (ct))
#define pi acos(-1)
#define prt(ct) for(auto &(it) : (ct)) cerr<<it<<" "; cerr<<nl
#define prtp(ct) for(auto &(it) : (ct)) cerr<<it.F<<" "<<it.S<<nl; cerr<<nl

typedef vector< int > vi;
typedef vector< vi > vvi;
typedef pair< int,int > pii;
typedef vector< pii > vp;
typedef tree<int, null_type, less<int>, rb_tree_tag, 
             tree_order_statistics_node_update> baap;

void swap(char &a,char &b)
{ auto tm=a; a=b; b=tm; }

void min(int &a,int b)
{ a=(a<b?a:b); }

void max(int &a,int b)
{ a=(a>b?a:b); }

  const int mod=1000000007;
  const int mod2=998244353;
  const int INF=1e16+18;
  const int N=1e5+15;
  const int M=1e2+12;
  
 int val[M][N];

 void fft()              
 { 
   int n,w; cin>>n>>w;

   for(int i=0;i<n;++i){
     int x,y; cin>>x>>y;

     for(int j=0;j<=w;++j)
     max(val[i+1][j],val[i][j]);
     for(int j=0;j<=w-x;++j)
     max(val[i+1][j+x],val[i][j]+y);

   //  D2(i+1,val[i+1][w]);
   }
 
   cout<<val[n][w];

 }

signed main()
{ 
   ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
   
   int tc=1;                         
 //  cin>>tc;

  rep(i,1,tc+1)
  { // cout<<"Case #"<<i<<": ";
   fft();
   if(i<tc)
   cout<<nl;
  }
  
 return 0; 
}

Measured memory_bytes: 79488
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=1000010;
const ll mod=1e9+7;


int main(){
  ll n,m,d;
  cin >> n >> m >> d;
  ld ans = 2 * (n-d) * (m-1);
  ans /= n;
  ans /= n;
  if(d==0) ans/=2;
  cout << fixed << setprecision(10) << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <limits.h>
#include <math.h>
int acs(const void *a, const void *b) { return *(int *)a - *(int *)b; }                            /* 1,2,3,4.. */
int des(const void *a, const void *b) { return *(int *)b - *(int *)a; }                            /* 8,7,6,5.. */
int cmp_char(const void *a, const void *b) { return *(char *)a - *(char *)b; }                     /* a,b,c,d.. */
int cmp_str(const void *a, const void *b) { return strcmp(*(const char **)a, *(const char **)b); } /* aaa,aab.. */
#define min(a, b) (a < b ? a : b)
#define max(a, b) (a > b ? a : b)
#define rep(i, l, r) for (int i = l; i < r; i++)
#define MAX 100001
#define MOD 998244353

typedef long long int lli;

lli zyou(lli a, lli x)
{
  lli ans = 1;
  rep(i, 0, x) ans = (ans * a) % MOD;
  return ans;
}

int main(void)
{
  lli n, d[MAX];
  scanf("%lld", &n);

  lli kyori[MAX] = {0}; // kyori[i]:頂点1からの距離がiの個数
  lli len = 0;
  rep(i, 0, n)
  {
    scanf("%lld", &d[i]);
    len = max(len, d[i]);
    kyori[d[i]]++;
  }

  lli ans = 1;
  rep(i, 0, len)
  {
    if (kyori[i] == 0)
    {
      ans = 0;
      break;
    }
    ans = (ans * (zyou(kyori[i], kyori[i + 1]) % MOD)) % MOD;
  }
  if (kyori[0] != 1 || d[0] != 0)
    ans = 0;
  printf("%lld\n", ans % MOD);
  return 0;
}


Measured memory_bytes: 1664
#include <iostream>
#include <algorithm>
#include <queue>
using namespace std;
signed main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    int n,m,a1;
    double sum=0;
    cin>>n>>m;
    priority_queue<int> a;
    for(int i=0;i<n;i++){
        cin>>a1;
        a.push(a1);
        sum+=a1;
    }
    for(int i=0;i<m;i++){
        if(a.top()<sum/(4*m)){
            cout<<"No"<<'\n';
            return 0;
        }
        a.pop();
    }
    cout<<"Yes"<<'\n';
    return 0;
}

Measured memory_bytes: 3632
# -*- coding: utf-8 -*-

# 素因数分解(試し割り法)
def prime_factorize(n):
    result = []
    if n % 2 == 0:
        t = 0
        while n % 2 == 0:
            n //= 2
            t += 1
        result.append((2, t))
    for i in range(3, int(n ** 0.5) + 1, 2):
        if n % i != 0:
            continue
        t = 0
        while n % i == 0:
            n //= i
            t += 1
        result.append((i, t))
        if n == 1:
            break
    if n != 1:
        result.append((n, 1))
    return result

n = int(input())
ans = 0
for p, e in prime_factorize(n):
    i = 1
    while e >= i:
        ans += 1
        e -= i
        i += 1
print(ans)


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

#define rep(i,n) for(int i=0; i<n; i++)
#define rept(i,a,b) for(int i=a; i<b; i++)
#define ll long long

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

	int ans = 0;
	int x[100][100];
	rep(i,n){
		rep(j,d){
			cin >> x[i][j];
		}
	}

	int len ;
	rep(k,n-1){
		for(int i = k; i < n-1; i++){
			len = 0.0;
			rep(j ,d){
				len += (x[k][j] - x[i+1][j])*(x[k][j] - x[i+1][j]);
			}
			if(ceil(sqrt(len)) == floor(sqrt(len))){
				ans ++;
			}
		}
	}



	cout << ans << endl;



    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
	map<double, int> n_t;
	int num;
	double t;
	vector<double> rank, all;
	for( int r = 0; r < 3; r++ ){
		for( int i = 0; i < 8; i++ ){
			cin >> num >> t;
			n_t[t] = num;
			rank.push_back(t);
		}
		sort(rank.begin(), rank.end());
		vector<double>::iterator it = rank.begin();
		cout << n_t[*it] << ' ' << *it << endl;
		//rank.erace(it);
		it++;
		cout << n_t[*it] << ' ' << *it << endl;
		it++;
		for( ; it != rank.end(); it++ ){
			all.push_back(*it);
		}
		rank.clear();
	}
	sort(all.begin(), all.end());
	vector<double>::iterator it = all.begin();
	cout << n_t[*it] << ' ' << *it << endl;
	it++;
	cout << n_t[*it] << ' ' << *it << endl;

	return 0;
}

Measured memory_bytes: 1316
#include <iostream>
using namespace std;
int main() {
	int a, b, c, tmp;
	cin >> a >> b >> c;
	tmp = a;
	a = b;
	b = tmp;
	tmp = a;
	a = c;
	c = tmp;
	cout << a << " " << b << " " << c << endl;
	return 0;
}

Measured memory_bytes: 256
N = int(input())
words = {}
for i in range(N):
  name = input()
  if name not in words:
    words[name] = 1
  elif name in words:
    words[name] += 1
    
res_name = []
Max = max(words.values())
for i in words.keys():
  if words[i] == Max:
    res_name.append(i)
res_name = sorted(res_name)
for i in res_name:
  print(i)

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

int main(){
	long long n;
	cin>>n;
	if(n%2) cout<<0;
	else{
		long long two = 0;
		long long five = 0;
		long long curr = 2;
		while(curr<=n){
			two+=n/curr;
			curr*=2;
		}
		curr = 10;
		while(curr<=n){
			five+=n/curr;
			curr*=5;
		}
		cout<<min(five,two);
	}
}

Measured memory_bytes: 3600
def factorization(n):
    a = n
    p = 2
    res = []
    while a != 1:
        cnt = 0
        while a % p == 0:
            cnt += 1
            a //= p
        if cnt:
            res.append([p, cnt])
        p += 1
        if a != 1 and p * p > n:
            res.append([a, 1])
            break
    return res

N, P = map(int, input().split())
L = factorization(P)
S = 1
for i in L:
    S *= i[0] ** (i[1] // N)
print(S)

Measured memory_bytes: 9200
#include <iostream>
#include <vector>
#include <cmath>
#include <array>
#include <functional>
#include <algorithm>
#include <numeric>
#include <string>
#include <stack>

int main()
{
	int H, W;
	std::cin >> H >> W;

	std::vector<std::string> grid;
	for (size_t i = 0; i < H; i++)
	{
		std::string str;
		std::cin >> str;
		grid.push_back(str);
	}

	for (int i = 0; i < H; i++)
	{
		for (int j = 0; j < W; j++)
		{
			if (grid.at(i).at(j) == '.')
			{
				int num = 0;
				for (int y = -1; y <= 1; y++)
				{
					for (int x = -1; x <= 1; x++)
					{
						if (y == 0 && x == 0)
						{
							continue;
						}
						if (i + y < 0 || H <= i + y)
						{
							continue;
						}
						if (j + x < 0 || W <= j + x)
						{
							continue;
						}

						if (grid.at(i + y).at(j + x) == '#')
						{
							num++;
						}
					}
				}
				grid.at(i).at(j) = std::to_string(num).at(0);
			}
		}
	}

	for (std::string& str : grid)
	{
		std::cout << str << std::endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
#pragma warning(disable:4786)
#pragma warning(disable:4996)
#include<list>
#include<bitset>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<functional>
#include<string>
#include<cstring>
#include<cstdlib>
#include<queue>
#include<utility>
#include<fstream>
#include<sstream>
#include<cmath>
#include<stack>
#include<assert.h>
using namespace std;

#define MEM(a, b) memset(a, (b), sizeof(a))
#define CLR(a) memset(a, 0, sizeof(a))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define ABS(X) ( (X) > 0 ? (X) : ( -(X) ) )
#define S(X) ( (X) * (X) )
#define SZ(V) (int )V.size()
#define FORN(i, n) for(i = 0; i < n; i++)
#define FORAB(i, a, b) for(i = a; i <= b; i++)
#define ALL(V) V.begin(), V.end()
#define IN(A, B, C)  ((B) <= (A) && (A) <= (C))

typedef pair<int,int> PII;
typedef pair<double, double> PDD;
typedef vector<int> VI;
typedef vector<PII > VP;

#define AIN(A, B, C) assert(IN(A, B, C))

//typedef int LL;
typedef long long int LL;
//typedef __int64 LL;

int grid[302][302];
int cnt[302], banned[302];
int n, m;

int main()
{
	scanf("%d %d", &n, &m);
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++) {
			scanf("%d", &grid[i][j]);
		}
	}

	int ans = n;
	for (int x = 1; x <= m; x++) {
		int now = -1;
		CLR(cnt);
		for (int i = 1; i <= n; i++) {
			for (int j = 1; j <= m; j++) {
				if (banned[grid[i][j]]) continue;
				cnt[grid[i][j]]++;
				break;
			}
		}
		for (int i = 1; i <= m; i++) {
			if (cnt[i] == 0) continue;
			if (now == -1 || cnt[now] < cnt[i]) {
				now = i;
			}
		}
		//printf(">>%d\n", now);
		ans = MIN(ans, cnt[now]);
		banned[now] = 1;
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 640
import sys
## io
IS = lambda: sys.stdin.readline().rstrip()
II = lambda: int(IS())
MII = lambda: list(map(int, IS().split()))
MIIZ = lambda: list(map(lambda x: x-1, MII()))
## dp
INIT_VAL = 0
MD2 = lambda d1,d2: [[INIT_VAL]*d2 for _ in range(d1)]
MD3 = lambda d1,d2,d3: [MD2(d2,d3) for _ in range(d1)]
## math
DIVC = lambda x,y: -(-x//y)
DIVF = lambda x,y: x//y

def main():
    s, w = MII()
    if w >= s: print('unsafe')
    else: print('safe')

if __name__ == '__main__':
    main()

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

using lint = long long int;

int main(){
    string alphabets="abcdefghijklmnopqrstuvwxyz";
    string S;
    int Slen;
    map <int,char> mp;
    map <char,int> mp2;
    for(int i=0;i<26;i++){
        mp[i] = alphabets[i];
        mp2[alphabets[i]] = i;
    }

    cin >> S;
    Slen = S.size();
    for(int i=0;i<Slen;i++){
        mp.erase(mp2[S[i]]);
    }
    
    if(!mp.empty()){
        auto itr = mp.begin();
        cout << S + itr->second << endl;
        return 0;
    }
    else{
        for(int i=Slen-1;i>=0;i--){
            mp[mp2[S[i]]] = S[i];
            for(int j=mp2[S[i]]+1;j<26;j++){
                if(mp.find(j)!=mp.end()){
                    S.erase(i);
                    cout << S + mp[j] << endl;
                    return 0;
                }
            }
            S.erase(i);
        }
    }
    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define debug(x) cerr << "[(" << __LINE__ << ") " << (#x) << "]: " << x << endl;

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

    int n, p;
    string s;
    cin >> n >> p >> s;

    vector<int> dp(p);
    dp[0]++;

    ll ans = 0;
    ll duh = 1, cur = 0;

    if (p == 2 || p == 5) {
        for (int i=1; i<n+1; i++) {
            if (p == 2 && (s[i-1]-'0') % 2 == 0) ans += i;
            if (p == 5 && (s[i-1]-'0') % 5 == 0) ans += i;
        }
    } else { 
        for (auto c=s.rbegin(); c!=s.rend(); c++) {
            cur += (*c - '0') * duh;
            cur %= p;

            duh *= 10;
            duh %= p;

            ans += dp[cur];
            dp[cur]++;
        }
    }
    
    cout << ans << "\n";
}


Measured memory_bytes: 3784
import numpy as np
input()
A = np.array(input().split(), np.int16) - 1
B = np.array(input().split(), np.int16)
C = np.array(input().split(), np.int16)
print(B.sum() + C[A[:-1][A[1:] - A[:-1] == 1]].sum())

Measured memory_bytes: 12396
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9
#define PI 3.14159265359
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
#define ALLR(v) v.rbegin(),v.rend()
typedef long long ll;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//isPrime
//modpow modinv
//getDigit
int main() {
  cout << fixed << setprecision(10);
  ll x;
  cin >> x;
  int n = 1000;
  for(ll a=-n; a<=n; a++){
    for(ll b=-n; b<=n; b++){
      if(a*a*a*a*a-b*b*b*b*b==x){
        cout << a  << " " << b << endl;
        return 0;
      }
    }
  }
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define ll long long
#define rep(i, n) for(int i=0; i<n; i++)
#define REP(i, n) for(int i=0; i<=n; i++)
#define repr(i, n) for(int i=n; i>0; i--)
#define REPR(i, n) for(int i=n; i>=0; i--)
const ll INF = 1LL<<60;
const int INT_INF = 1e9;
const ll MOD = 1e9+7;
template<class T> void puts(T x) { std::cout << x << std::endl; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;

int main() {
    int n; cin >> n;
    string s[51];
    rep(i, n) cin >> s[i];
    rep(i, n) sort(s[i].begin(), s[i].end());

    string ans = "";
    for (char a = 'a'; a <= 'z'; ++a) {
        int na = 100;
        for (int i = 0; i < n; i++) {
            int tmp = 0;
            for (int p = 0; p < s[i].length(); p++) {
                if (s[i][p] == a) tmp++;
            }
            chmin(na, tmp);
        }
        rep(_, na) ans += a;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int num = scanner.nextInt();
		int count = 0;

		boolean cards[][] = new boolean[4][13];
		for (int i = 0; i < num; i++) {
			String mark = scanner.next();
			int n = scanner.nextInt();
			int m = 0;
			if (mark.equals("S")) {
				m = 0;
			} else if (mark.equals("H")) {
				m = 1;
			} else if (mark.equals("C")) {
				m = 2;
			} else if (mark.equals("D")) {
				m = 3;
			}
			cards[m][n - 1] = true;
		}
		while (count < 52 - num) {
			for (int m2 = 0; m2 <= 3; m2++) {
				for (int n2 = 0; n2 <= 12; n2++) {
					if (cards[m2][n2] == false) {
						if (m2 == 0) {
							System.out.println("S" + " " + (n2 + 1));
							count = count + 1;
						} else if (m2 == 1) {
							System.out.println("H" + " " + (n2 + 1));
							count = count + 1;
						} else if (m2 == 2) {
							System.out.println("C" + " " + (n2 + 1));
							count = count + 1;
						} else if (m2 == 3) {
							System.out.println("D" + " " + (n2 + 1));
							count = count + 1;
						}
					}
				}
			}
		}
		scanner.close();
	}

}



Measured memory_bytes: 26240
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//typedef __int128 lll;
#define print(i) cout << "debug: " << i << endl
#define close() ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define mem(a, b) memset(a, b, sizeof(a))
const ll mod = 1e9 + 7;
const int maxn = 2e6;
const int inf = 0x3f3f3f3f;

double dis(ll a, ll b)
{
    return sqrt(a * a + b * b);
}

int main()
{
    ll n, d; cin >> n >> d;
    int res = 0;
    for(int i = 1; i <= n; i++)
    {
        ll x, y; cin >> x >> y;
        if(dis(x, y) <= d) res++;
    }
    cout << res << endl;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
#define mod 1000000007
#define INF LLONG_MAX
#define ll long long
#define ln cout<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
using namespace std;
ll dx[4]={1,0,-1,0};
ll dy[4]={0,1,0,-1};
 
int main(){
  int a,b;
	cin>>a;
  cout<<a*180-360<<endl;
}


Measured memory_bytes: 3572
from collections import deque
lis = deque()
num = int(input())
for _ in range(num):
  command = input().split()
  if command[0]=='deleteFirst':
    lis.popleft()
  elif command[0]=='deleteLast':
    lis.pop()
  elif command[0]=='insert':
    lis.insert(0, command[1])
  elif command[0]=='delete':
    try:
        lis.remove(command[1])
    except:
        pass
print(' '.join(lis))


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

using namespace std;


using ll = long long;

constexpr ll inf = 0;


class DynamicRMQ {
 public:
  explicit DynamicRMQ(int n): u(n * 2, inf) {}
  void clear() {
    std::fill(u.begin(), u.end(), inf);
  }
  void modify(int p, ll v) {
    for (u[p += u.size() / 2] = v; p > 1; p >>= 1) {
      u[p >> 1] = std::max(u[p], u[p ^ 1]);
    }
  }
  ll query(int l, int r, ll res = inf) {// [l, r)
    const int n = u.size() >> 1;
    assert(r <= n && l < n && l < r);
    for (l += n, r += n; l < r; l >>= 1, r >>= 1) {
      if (l & 1) res = std::max(res, u[l++]);
      if (r & 1) res = std::max(res, u[--r]);
    }
    return res;
  }
 private:
  std::vector<ll> u;
};

const int MAX = 2 * 100010; 
vector<int> a(MAX);

vector<vector<int>> g(MAX);
vector<stack<int>> h(MAX);

vector<int>ans(MAX);

DynamicRMQ tree(MAX);

void dfs(int cur, int par){
	int x = tree.query(0,a[cur]) + 1;
	h[cur].push(tree.query(a[cur],a[cur] + 1));
	tree.modify(a[cur],x);
	ans[cur] = tree.query(0,MAX - 1);
	for(int v : g[cur]){
		if(v!=par){
			dfs(v,cur);
		}
	}
	tree.modify(a[cur],h[cur].top());
	h[cur].pop();
}


int main(){
	int n; cin >> n;
	vector<pair<int,int>> b(n+1);
	for(int i = 0; i < n; i++){
		cin >> b[i+1].first;	
		b[i+1].second = i+1;
	}
	sort(b.begin(),b.end());
	int q = 0;
	for(int i = 1; i <= n; i++){
		if(i==1){
			a[b[i].second] = ++q;
		}else{
			if(b[i].first==b[i-1].first){
				a[b[i].second] = q;	
			}else{
				a[b[i].second] = ++q;	
			}
		}		
	}
	for(int i = 1; i < n; i++){
		int x,y; cin >> x >> y;
		g[x].push_back(y);
		g[y].push_back(x);
	}
	dfs(1,0);
	for(int i = 1; i <= n; i++){
		cout << ans[i] << "\n";
	}
	return 0;
}


Measured memory_bytes: 172232
#include<iostream>
using namespace std;
int B,N,C,Y,Z,i,X;

int main(){
cin>>N>>C;
N+=1;
  while( C-- ){
  cin>>X;
  B+=X;
}
Z=B/N;

if(B%N>0){
    Z+=1;
}
cout<<Z<<endl;
return 0;
}


Measured memory_bytes: 3108
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashMap;

public class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());
        HashMap map = new HashMap<String, Integer>();
        for (int i = 0; i < n; i++) {
            map.put(br.readLine(), i);
        }

        System.out.println(map.size());
    }
}


Measured memory_bytes: 65828
#!/usr/bin/env python3
import sys


def solve(n: int, a: "List[int]"):
    def _solve(op):
        from itertools import cycle
        ab = 0
        for aa in map(lambda a_o: a_o[0]*a_o[1], zip(a, cycle(op))):
            ab -= aa
            if ab >= 0:
                yield ab + 1
                ab = -1
            ab = abs(ab)
    return min(sum(_solve([1, -1])), sum(_solve([-1, 1])))

# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    n = int(next(tokens))  # type: int
    a = [int(next(tokens)) for _ in range(n)]  # type: "List[int]"
    print(solve(n, a))

if __name__ == '__main__':
    main()


Measured memory_bytes: 16116
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define REP(i,a,b) for(int i=int(a);i<(int)b;++i)
#define Graph vector<vecctor<ll>>
#define pairs vector<pair<ll,ll>>
#define pb push_back



using namespace std;
using ll = long long;
const ll INF = 1e18;
const double PI = acos(-1);

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
ll n,k;
vector<ll>a;
bool ok(ll x){
    ll cnt = 0;
    rep(i,n){
        cnt += (a[i]-1)/x;
    }
    if(cnt <= k)return true;
    else return false;
}

ll search(){
    ll top=INF,bottom=0;
    while(top-bottom > 1){
        ll mid = top+bottom;
        mid /= 2;
        if(ok(mid)){
            top = mid;
        }else{
            bottom = mid;
        }
    }
    return top;
}

int main(void)
{
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    cin >> n >> k;
    a.resize(n);
    rep(i,n){
        cin >> a[i];
    }
    cout << search() << endl;
    



    return 0;
}


Measured memory_bytes: 4744
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n,i;
  cin >> n;
vector<int> d(n);
  for(i=0;i<n;++i)
  {
  cin >> d.at(i);
  }
  
  sort(d.begin(),d.end());
    
    cout << d.at(n/2)-d.at(n/2-1);

return 0;
}

Measured memory_bytes: 3784
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue = BinaryHeap!(Array!long, "a<b");
// dfmt on

void main()
{
    long A, B;
    scan(A, B);
    long g = gcd(A, B);
    auto f = factorize(g);
    writeln(f.keys.length + 1);
}

/// 素因数分解
long[long] factorize(long x)
{
    assert(0 < x, "x is negative");
    long[long] ps;
    while ((x & 1) == 0)
    {
        x /= 2;
        ps[2] = (2 in ps) ? ps[2] + 1 : 1;
    }
    for (long i = 3; i * i <= x; i += 2)
        while (x % i == 0)
        {
            x /= i;
            ps[i] = (i in ps) ? ps[i] + 1 : 1;
        }
    if (x != 1)
        ps[x] = (x in ps) ? ps[x] + 1 : 1;
    return ps;
}


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

// alias templates
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;

// alias declaration
using ll = long long;
using str = string;

using vll = V<ll>;
using vvll = V<vll>;
using vs = V<str>;

// loops
#define FOR(i, a, b)  for (ll i = (a); i <= (ll)(b); i++) // [a,b]
#define rFOR(i, a, b) for (ll i = (b); i >= (ll)(a); i--) // [b,a]
#define REP(i, a) FOR((i), 0, (ll)(a)-1) // [0,a-1]

// for debug
#define dbg(a) cerr << "  " << (#a) << ": " << (a) << "\n";

// procon common constants
const ll MOD_BIG = 1e9 + 7;

int main(void){
    ll n,d,dis,cnt=0;
    cin >> n >> d;
    vvll x(n+1,vll(d+1));
    FOR(i, 1, n){
        FOR(k, 1, d){
            cin >> x[i][k];
        }
    }
    // puts("x:---");
    // FOR(i, 1, n){
    //     FOR(k, 1, d){
    //         cout << x[i][k] << endl;
    //     }
    //     puts("-");
    // }
    // puts("---");
    FOR(i, 1, n){
        FOR(j, i+1, n){
            dis = 0;
            FOR(k, 1, d){
                dis += (x[i][k]-x[j][k])*(x[i][k]-x[j][k]);
            }

            //cout << i << "," << j << endl;;
            //dbg(dis);
            if(((ll)sqrtl(dis))*((ll)sqrtl(dis)) == dis){
                cnt++;
            }
        }
    }

    cout << cnt << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
#define ll  long long 
#define ull unsigned long long int
#define boost ios_base::sync_with_stdio(false);	cin.tie(NULL);	cout.tie(NULL)
#define vi vector<int>
#define P push_back
#define F first
#define S second
#define debug(x) cout<<x<<" "
#define pi vector<pair<int,int> >
#define all(a) a.begin(),a.end()
#define int ll
#define vvi vector<vector<int>>
using namespace std;
using namespace __gnu_pbds;
typedef tree <pair<int,int>, null_type,less<pair<int,int>>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
ll const mod=1e9+7;
int powi(int i,int b){
    int res=1;
    while(b){
        if(b&1)res*=i,res%=mod;
        b>>=1;
        i*=i;
        i%=mod;
    }
    return res;
}
// map<int,int> m;
// ll fact(int n){
// 	//if(n==0)return 0;
// 	if(n<=1)return 1;
// 	if(m[n]!=0)return m[n];
// 	return (n*fact(n-1))%mod;
// }
// int ncr(int n,int r){
//     int h=fact(n);
//     int v=fact(r);
//     int j=fact(n-r);
//     v*=j;
//     v%=mod;
//     v=powi(v,mod-2);
//     return (h*v)%mod;
// }
// vi ar(2000000);
// vi sz(2000000);
// int root(int a){
//     if(ar[a]==a)return a;
//     return ar[a]=root(ar[a]);
// }
// int merge(int a,int b){
//     int h=root(a),j=root(b);
//     int ans=sz[h]*sz[j];
//     sz[j]+=sz[h];
//     if(h!=j){
//         ar[h]=j;
//     }
//     return ans;
// } 
void solve(){
    int n;
    cin>>n;
    ll ans=1;
    vector<ll> v(n+1);
    v[1]=1;
    for(int i=2;i*i<=n;i++){
        if(v[i])continue;
        for(int j=i*2;j<=n;j+=i)v[j]=i;
    }
    for(int i=2;i<=n;i++){
        if(v[i]==0){
            ans+=2*i;
            v[i]=2;
            continue;
        }
        int tem=i,cn=0;
        while(tem%v[i]==0){
            tem/=v[i];cn++;
        }
        ans+=v[tem]*(cn+1)*i;
        v[i]=v[tem]*(cn+1);
    }
    cout<<ans;
}
signed main(){
    boost;
    int t=1;
    //freopen("input.txt", "r", stdin);
    //cin>>t;
    for(int _=1;_<=t;_++){
        //cout<<"Case #"<<_<<": ";
        solve();
        cout<<"\n";
    }
    
    return 0;
}

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

int main()
{
    int a,b,c;
    cin >> a >> b >> c;
    int res = 0;
    a-=c;
    while (true) {
        if (a>=b+c){
            a-=b;
            res++;
        }
        a-=c;
        if (a<=0) break;
    }
    cout << res;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define rep(i,n) for(int i=0;i<n;i++)
#define mod 1000000007 // 10^9+7
#define INF 99999999999 //10^12-1
#define dev 998244353 //tenka1
#define P pair<int,int>
#define prique priority_queue
int n,k;
signed main(){
    cin>>n>>k;
    int ans=n-k+1;
    cout<<ans<<endl;
    return 0;
}


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

int N;
string S;

string subSolve(const string &s) {
    if (s[0] == 'a') {
        string res = "";
        int prev_a = -1;
        int a_num = 0, b_num = 0;
        bool search_a = true;
        for (int i = 0; i < s.size(); ++i) {
            if (s[i] == 'a') {
                if (search_a) {
                    res += "a";
                    prev_a = a_num;
                    search_a = false;
                }
                ++a_num;
            }
            else {
                if (!search_a) {
                    if (b_num == prev_a) {
                        res += "b";
                        search_a = true;
                    }
                }
                ++b_num;
            }
        }
        return res;
    }
    else {
        string res = "";
        for (int i = 0; i*2 < s.size(); ++i) {
            string tmp = "";
            int a_num = 0, b_num = 0;
            for (int j = 0; j < s.size(); ++j) {
                if (s[j] == 'a') {
                    if (a_num >= i) tmp += s[j];
                    ++a_num;
                }
                else {
                    if (b_num >= i) tmp += s[j];
                    ++b_num;
                }
            }
            res = max(res, tmp);
        }
        return res;
    }
}

int main() {
    cin >> N >> S;
    int iter = 0;
    vector<string> vec;
    string tmp = "";
    bool exist = false;
    for (int i = (int)S.size()-1; i >= 0; --i) {
        tmp += S[i];
        if (S[i] == 'a') ++iter;
        else --iter;
        if (iter == 0) {
            reverse(tmp.begin(), tmp.end());
            if (tmp[0] == 'a' && exist) { tmp = ""; continue; }
            if (tmp[0] == 'b') exist = true;
            string ma = subSolve(tmp);
            vec.push_back(ma);
            tmp = "";
        }
    }
    
    vector<string> dp; dp.assign(N+1, "");
    for (int i = 0; i < vec.size(); ++i) {
        dp[i+1] = max(dp[i+1], dp[i]);
        dp[i+1] = max(dp[i+1], vec[i] +dp[i]);
    }
    cout << dp[vec.size()] << endl;
}


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


int main(void)
{
	int a, b, c, k; cin >> a >> b >> c >> k;
	
	if(k <= a + b)
		cout << min(k, a) << "\n";
	else
		cout << 2 * a + b - k << "\n";
	
	
	
	return 0;
}


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

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

using namespace std;

int n, c[(int)1e5 + 7], a[(int)1e5 + 7], w;
long long d[(int)2e5 + 7], mx;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> w;
    for(int i = 1; i <= n; i++)
        cin >> a[i] >> c[i];
    for(int i = 1e5 + 6; i > 0; i--)
        d[i] = 1e9 + 7;
    for(int i = 1; i <= n; i++)
    for(int j = 1e5 + 6; j >= 0; j--)
        if(d[j] != 1e9 + 7)
            d[j + c[i]] = min(d[j + c[i]], d[j] + a[i]);
    for(int j = 0; j <= 1e5 + 6; j++)
        if(d[j] <= w)
            mx = j;
    cout << mx;
}


Measured memory_bytes: 1024
/* 
(1)80ð´¦éüÍÉÎÅ«Ä¢È¢±Æ
(2)µ©à100ÈãÌüÍª é±Æ
(3)80Ì9+1ÌoverflowoÉsïª é±Æ@±Ì3_ðC³µÄÝÄº³¢
*/

#include <stdio.h>
#include <string.h>

int main(void)
{
	char n[1010];
	int num1[81], num2[81];
	int i, j, max;
	int roop1, roop2, ch;
	
	scanf("%d\n", &roop1);

	for (roop2 = 0; roop2 < roop1; roop2++){
		//@zñú»
		memset(num1, 0, sizeof(num1));
		memset(num2, 0, sizeof(num2));
		memset(n, '0', sizeof(n));
		max = 0;
		
		scanf("%s", n);
		ch = strlen(n);

		/* chª80æèå«¢©Ç¤©`FbN
		 * maxª80ðz¦Ä¢½êÍoverflowð\¦·éÌÅlði[·éKvªÈ¢D
		 */
		if(ch > 80) {
			max = -1;
		}
		else {
			max = ch;
			i = 0;
			for (j = (ch - 1); -1 < j ; j--){
				num1[i] = (n[j] - '0');
				// printf("%dFF%d_n", i, num1[i]);
				i++;
			}
		}
		
		scanf("%s", n);
		ch = strlen(n);
		/* chª80æèå«¢©Ç¤©`FbN
		 * ùÉmaxª-1©Ç¤©à±±Å`FbN
		 */
		if(ch > 80 || max == -1) {
			max = -1;
		}
		else if (max <= ch) {
			max = ch;
		}
		if(max != -1) {
			i = 0;
			for (j = (ch- 1); -1 < j; j--){
				num2[i] = (n[j] - '0');
				// printf("%dFF%d_n", i, num2[i]);
				i++;
			}
		}

		/* maxª-1CÂÜèüÍª80æèàå«¢êÍ±±ÅD
		 */
		if(max == -1) {
			printf("overflow\n");
			continue;
		}
		
		for(i = 0; i < 80; i++){
			num1[i] += num2[i];
			if (10 <= num1[i]) {
				num1[i + 1] += 1;
				num1[i] %= 10;
			}
		}
		
		max--;
		if (num1[80] == 0){
			if (num1[max + 1] == 0){
				for (i = max; -1 < i; i--){
					printf("%d", num1[i]);
				}
				printf("\n");
			}
			else {
				max++;
				for (i = max; -1 < i; i--){
					printf("%d", num1[i]);
				}
				printf("\n");
			}
		}
		else {
			printf("overflow\n");
		}
	}
	
	return (0);
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e18;
long long best[1003], c[2003];
int a[2003], b[2003];

int main(){

    cin.sync_with_stdio(0); cin.tie(0); cout.tie(0);

    int n, m; cin >> n >> m;

    for(int i = 1; i <= n; ++i)
        best[i] = -INF;
    for(int i = 0; i < m; ++i)
        cin >> a[i] >> b[i] >> c[i];

    best[1] = 0;

    for(int i = 0; i < n; ++i){
        for(int j = 0; j < m; ++j){
            if(best[a[j]] == -INF) continue;
            if(best[a[j]] + c[j] > best[b[j]]){
                best[b[j]] = c[j] + best[a[j]];
                if(i == n - 1 && b[j] == n){
                    cout << "inf";
                    return 0;
                }
            }
        }
    }

    cout << best[n];

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
using namespace std;

typedef long long ll;
typedef double db;
typedef long double ldb;

template<class T> inline void checkmin(T &a,const T &b){if(b<a) a=b;}
template<class T> inline void checkmax(T &a,const T &b){if(b>a) a=b;}

const int inf=1e9+10;
const int maxn=2010;

int n,x;
bool f[maxn];

int main(){
	scanf("%d%d",&x,&n);
	for(int i=0;i<n;i++){
		int a;
		scanf("%d",&a);
		f[a]=1;
	}
	int ans=inf;
	for(int i=0;i<=x+1000;i++){
		if(abs(ans-x)>abs(i-x)&&(!f[i])) ans=i;
		if(abs(ans-x)==abs(i-x)&&(!f[i])&&i<ans) ans=i;
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 3828
#include <stdio.h>
#include <iostream>

using namespace std;

#define REP(a, i, n) for (int i = a; i < n; ++i)

int main() {
    int X, Y;
    scanf("%x %x", &X, &Y);

    if (X == Y) {
        cout << "=" << endl;
    } else if (X > Y) {
        cout << ">" << endl;
    } else {
        cout << "<" << endl;
    }

    return 0;
}


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

int main() {
    int n,m;
    int64_t x;
    cin >> n >> m >> x;
    vector<int64_t> c(n);
    vector<vector<int64_t>> a(n, vector<int64_t> (m));
    rep(i,n) {
        cin >> c[i];
        rep(j,m) cin >> a[i][j];
    }
    
    const int64_t INF = 100100100100100;
    // int64_t min_c = 100100100100100;
    int64_t min_c = INF;
    for(int tmp=0;tmp < (1 << n) ;tmp++) {
        bitset<12> s(tmp);
        vector<int64_t> vec(m);
        int64_t sum_c = 0;
        rep(i,n){
            if(s.test(i)) {
                rep(j,m) vec[j] += a[i][j];
                sum_c += c[i];
            }
        }
        bool ok = true;
        for(auto v:vec) {
            if(v < x) ok = false;
        }
        if(ok) min_c = min(min_c,sum_c);
    }
    // if(min_c != 100100100100100) cout << min_c << endl;
    if(min_c != INF) cout << min_c << endl;
    else cout << "-1" << endl;

    return 0;
}

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

int main()
{
	long long A, V, B, W, T;
	cin >> A >> V >> B >> W >> T;

	long long d = abs( A - B );
	long long v = V - W;
	string ans = "NO";
	if( v > 0 ) {
		if( v * T >= d ) ans = "YES";
	}

	cout << ans << endl;
}


Measured memory_bytes: 3628
#include <stdio.h>

int main(){
	int him, A, B;
	scanf("%d %d %d", &him, &A, &B);
	int jwb1, jwb2;
	
	if(him - A < 0){
		jwb1 = (him - A) * -1;
	}else if(him - A >= 0){
		jwb1 = him - A;
	}
	
	if(him - B < 0){
		jwb2 = (him - B) * -1;
	}else if (him - B >= 0){
		jwb2 = him - B;
	}
	
	if(jwb1 < jwb2){
		printf("A\n");
	} else {
		printf("B\n");
	}
	return 0;
}

Measured memory_bytes: 3120
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#include<map>
#include<set>
#define MOD 1000000007
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(10);
}
#define MAX 1010000
#define MOD 1000000007

ll fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++){
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

long long COM(int n, int k){
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
ll modinv(ll a, ll m){
  ll b=m,u=1,v=0;
  while(b){
    ll t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  u%=m;
  if(u<0) u+=m;
  return u;
}
ll af[MAX],bf[MAX],hand[MAX];
signed main(){
  init_io();
  ll n,a,b,c,ans=0,vc,adr,bdr;
  COMinit();
  cin >> n >> a >> b >> c;
  af[0] = bf[0] = hand[0] = 1;
  vc = (100*modinv(100-c,MOD))%MOD;
  adr = a*modinv(a+b,MOD);
  bdr = b*modinv(a+b,MOD);
  adr %= MOD;
  bdr %= MOD;
  for(ll i=1;i<=2*n;i++){
    af[i] = af[i-1]*adr;
    bf[i] = bf[i-1]*bdr;
    hand[i] = hand[i-1]*modinv(100,MOD);
    af[i] %= MOD;
    bf[i] %= MOD;
    hand[i] %= MOD;
  }
  for(ll i=n;i<2*n;i++){
    ll tmp=0;
    tmp = (af[n]*bf[i-n])%MOD + (af[i-n]*bf[n])%MOD;
    tmp %= MOD;

    tmp *= COM(i-1,n-1);
    tmp %= MOD;

    tmp *= i;
    tmp %= MOD;

    tmp *= vc;
    tmp %= MOD;

    ans += tmp;
    ans %= MOD;
  }
  cout << ans << endl;
}


Measured memory_bytes: 34816
n = gets.to_i
dict = {}
ans = 0
n.times do
  s = gets.chomp.split('').sort.join('')
  if dict.fetch(s,nil).nil?
    dict[s] = 0
  else
    dict[s] += 1
  end
end
dict.values.each do |v|
  ans += (0..v).inject(:+)
end
puts ans

Measured memory_bytes: 19196
#include <bits/stdc++.h>
using namespace std;
struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20);} } fast;


int main() {
    char c;
    int cnt1 = 0, a;
    string s;
    long long k;
    cin >> s;
    cin >> k;
    for (int i = 0; i < s.size(); i++){
        if (s[i] == '1'){
            cnt1++;
        }
        if (cnt1 >= k){
            cout << 1 << endl;
            return 0;
        }
        if (s[i] != '1'){
            c = s[i];
            a = c - '0';
            cout << c << endl;
            return 0;       
        }
    }
}

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

int main()
{
	long long n;
	cin >> n;
	long long ar[n+5];
	long long res = 1;
	for(int i = 0; i < n; i++)
	{
		cin >> ar[i];
		if(ar[i] == 0) {cout << "0"; return 0;}
		if(ar[i] <= 1000000000000000000/res) res *= ar[i];
		else {res = -1; continue;}
	}	
	cout << res;
	return 0;
}

Measured memory_bytes: 4416
#include <iostream>
#include <vector>

using namespace std;

int main()
{
	int n, x;
	cin >> n >> x;
	
	vector<int> a(n);
	for(int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	
	long long ans = 0;
	for(int i = 0; i < n; i++)
	{
		if(a[i] > x)
		{
			ans += a[i] - x;
			a[i] -= a[i] - x;
		}
	}
	
	for(int i = 1; i < n; i++)
	{
		long tmp = a[i];
		if(tmp + a[i - 1] > x)
		{
			ans += tmp + a[i - 1] - x;
			a[i] -= tmp + a[i - 1] - x;  
		}			
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define X first
#define Y second
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
const ll N = 100005, inf = 1e18;

ll n, c[N], m = inf, ans;

vector<pll> adj[N];

void calc (ll C, ll P) {
	c[C] = 1;
	for(auto &X : adj[C]) {
		ll T, V; tie(T, V) = X;
		if(T == P) continue;
		calc(T, C);
		c[C] += c[T];
	}
}

void solve (ll C, ll P, ll L) {
	ans += 2 * L * min(c[C], n-c[C]);
	pll mx = {-1, -1};
	for(auto &X : adj[C]) {
		ll T, V; tie(T, V) = X;
		if(T == P) continue;
		mx = max(mx, {c[T], V});
	}
	mx = max(mx, {n-c[C], L});
	if(2*mx.X == n) m = min(m, mx.Y);
	else if(2*mx.X < n) {
		for(auto &X : adj[C]) m = min(m, X.Y);
	}
	for(auto &X : adj[C]) {
		ll T, V; tie(T, V) = X;
		if(T == P) continue;
		solve(T, C, V);
	}
}

int main()
{
	scanf("%lld",&n);
	for(ll i=1;i<n;i++) {
		ll A, B, C;
		scanf("%lld%lld%lld",&A,&B,&C);
		adj[A].push_back({B, C});
		adj[B].push_back({A, C});
	}
	calc(1, 0);
	solve(1, 0, 0);
	printf("%lld\n",ans-m);
}


Measured memory_bytes: 13952
a = []
while True:
    n = int(input())
    if n == 0:
        break
    else:
        goukei = 0
        v = 0
        s = list(map(int, input().split()))
        for i in range(len(s)):
            goukei = goukei + s[i] #合計
        ave = goukei / n           #平均
        for i in range(len(s)):
            v = v + pow(s[i]-ave,2)/n  #分散
        a.append(pow(v,1/2))  #標準偏差

for i in a:
    print(i)


Measured memory_bytes: 5668
#include <iostream>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <queue>
#include <map>
 
using namespace std;
typedef long long int ll;
typedef pair <int,int> pii;
typedef pair<ll,ll> pll;
 
 
/*bool compare_function(const pair<int, int> a, const pair<int, int> b)
{
    return a.first < b.first;
}*/
// use case
//sort(V.begin(), V.end(), compare_function);
 
/*struct compare
{
    bool operator ()(const pair<int, int> &a, const pair<int, int> &b) {
    if (a.second-a.first==b.second-b.first)
    {
        return a.first>b.first;
    }
    return a.second-a.first < b.second-b.first;}
};
priority_queue <pair<int,int>, vector <pair<int,int>>, compare> Q;*/
 
/*void print1(vector <int> X)
{
    for (int i=0; i<X.size(); i++)
    {
        cout<<X[i]<<" ";
    }
    cout<<endl;
    return;
}
 
void print2(vector <vector <int>> X)
{
    for (int i=0; i<X.size(); i++)
    {
    for (int j=0;j<X[i].size();j++) {
        cout<<X[i][j]<<" ";}
    cout<<endl;}
    return;
}*/

string s(int a) {
	if (a==2 || a==4 || a==5 || a==7 || a==9) {return "hon";}
	if (a==0 || a==1 || a==6 || a==8) {return "pon";}
	return "bon";
	}
 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin>>n;
    cout<<s(n%10)<<endl;
    return 0;
}


Measured memory_bytes: 3652