akhauriyash/Code-Regression huggingface dataset:
def common_multiple(x, y):
    for i in range(2, min(x, y)+1):
        if x % i == 0 or y % i == 0:
            return common_multiple(x // i if x % i  == 0 else x, y // i if y % i == 0 else y) * i
    return x * y

a = input().split(" ")
A, B, C, D = int(a[0]) - 1, int(a[1]), int(a[2]), int(a[3])

M = common_multiple(C, D)
B0 = B // C + B // D - B // M
A0 = A // C + A // D - A // M
print(B - A - B0 + A0)


Measured memory_bytes: 9136
import sys
import decimal
input = sys.stdin.readline
def ii(): return int(input())
def mi(): return map(int, input().rstrip().split())
def lmi(): return list(map(int, input().rstrip().split()))
def li(): return list(input().rstrip())
def debug(*args, sep=" ", end="\n"): print("debug:", *args, file=sys.stderr, sep=sep, end=end) if not __debug__ else None
def exit(*arg): print(*arg); sys.exit()
# template

def main():
    decimal.getcontext().prec = 100
    a, b = input().split()
    a = int(a)
    b = decimal.Decimal(b)
    # print(a, b)
    print(int(b*a))
    return

if __name__ == "__main__":
    main()


Measured memory_bytes: 10076
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <random>
#include <iomanip>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<pair<ll,ll> > vpll;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
typedef map<int, int> mii;
typedef set<int> si;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STLL(s) strtoll(s.c_str(), NULL, 10)
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int
// #define endl '\n';
#define fi first
#define se second
#define NONVOID [[nodiscard]]
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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;}
template <class T> inline void dump(T &v){irep(i, v){cout<<*i<<((i==--v.end())?'\n':' ');}}
inline string getline(){string s; getline(cin,s); return s;}
inline void yn(const bool b){b?fin("yes"):fin("no");}
inline void Yn(const bool b){b?fin("Yes"):fin("No");}
inline void YN(const bool b){b?fin("YES"):fin("NO");}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;



int main() {

    double r;
    cin>>r;
    cout<<r*2*MATHPI<<endl;
}


Measured memory_bytes: 3788
#include<iostream>
#include <string>
#include <vector>
#include <cmath>
#define ll long long

using namespace std;

int main(){
  ll N, K, r, s;
  cin >> N >> K;
  vector<int> A(N+1, 0), B(N+1, N+1), C(N+1, N+1);
  //B[i]はi番目に訪れる街。C[i]は街iを訪れる順番。
  for (ll i = 1; i <= N; i++) {
    cin >> A[i];
  }

  B[0] = 1;
  C[1] = 0;
  for (ll i = 1; i <= N; i++) {
    B[i] = A[B[i-1]];
    if (C[B[i]] == N+1) {
      C[B[i]] = i;
    }else{
      s = C[B[i]];
      r = i - s;
      break;
    }
  }

  if (K <= s) {
    cout << B[K] << endl;
  }else{
    cout << B[s + ((K-s)%r)] << endl;
  }

  return 0;
}


Measured memory_bytes: 5612
#include<bits/stdc++.h>
using namespace std;
int main() {
	double x1, y1, x2, y2;
	cin >> x1 >> y1 >> x2 >> y2;
	double x, y;
	x = x2 - x1;
	y = y2 - y1;
	double r;
	r = x * x + y * y;
	r = sqrt(r);
	cout << setprecision(10)<< r << endl;
	return 0;
}


Measured memory_bytes: 3236
process.stdin.resume();
process.stdin.setEncoding('utf8');
// Your code here!
function main(input) {
    var x = input.split('/');
    x[0] = '2018';
    console.log(x[0] + '/' + x[1] + '/' + x[2]);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 21192
#include<iostream>
#include<vector>
#include<math.h>

class ShellSort{
private:
    std::vector<int> dataSet;
    std::vector<int> vecG;
    int m;
    int changeCount;
public:
    ShellSort(std::vector<int> vec);
    std::vector<int> getVector();
    std::vector<int> getVectorG();
    int getM();
    int getChangeCount();
    void insertionSort(int g);
    void shellSort();
};

ShellSort::ShellSort(std::vector<int> vec){
    this->dataSet = vec;
    this->changeCount = 0;
}

int ShellSort::getChangeCount(){
    return this->changeCount;
}

int ShellSort::getM(){
    return this->m;
}

std::vector<int> ShellSort::getVector(){
    return this->dataSet;
}

std::vector<int> ShellSort::getVectorG(){
    return this->vecG;
}

void ShellSort::insertionSort(int g){
    for(int i = g;i < dataSet.size();i++){
        int v = dataSet[i];
        int j = i - g;
        while(j >= 0 && dataSet[j] > v){
            dataSet[j+g] = dataSet[j];
            j = j - g;
            changeCount++;
        }
        dataSet[j + g] = v;
    }
}

void ShellSort::shellSort(){
    
    for(int i = 0;i < 100;i++){
        if(i == 0){
            double d = ((double)dataSet.size() / 2);
            vecG.push_back(ceil(d) + 1);
        }else{
            vecG.push_back((vecG[i - 1] / 2) - 1);
        }
        if(vecG[i] <= 0){
            vecG[i - 1] = 1;
            vecG.pop_back();
            m = i;
            break;
        }
    }

    for(int i = 0;i < m;i++){
        insertionSort(vecG[i]);
    }
}

void showVector(std::vector<int> vec){
    for(int i = 0;i < vec.size();i++){
        std::cout << (i ? " " : "") << vec[i];
    }
    std::cout << std::endl;
}

int main(){
    
    int content;

    std::cin >> content;

    std::vector<int> vec;

    for(int i = 0;i < content;i++){
        int input;
        std::cin >> input;

        vec.push_back(input);
    }

    ShellSort ss = ShellSort(vec);
    ss.shellSort();

    std::cout << ss.getM() << std::endl;
    showVector(ss.getVectorG());
    std::cout << ss.getChangeCount() << std::endl;
    for(int i : ss.getVector()){
        std::cout << i << std::endl;
    }

    return 0;
}

Measured memory_bytes: 14640
#include <iostream>
#include <string>
#include <map>

using namespace std;

bool judge()
{
    int c_count = 0;
    string chara;
    cin >> chara;
    for (int i = 0; i < 4; i++)
    {
        c_count = 0;
        for (int j = 0; j < 4; j++)
        {
            if( i == j) continue;
            if (chara[i] == chara[j])
                c_count++;
        }
        if (c_count != 1)
            return false;
    }
    return true;
}

int main()
{
    if (judge())
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}


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

int main(){
     
	int x[5], k;
	for (int i = 0; i < 5; i++) cin >> x[i];
	cin >> k;

	for (int i = 0; i < 5; i++) {
		for (int j = 5; j > 0; j--) {
			if (x[j - 1] - x[i] > k) {
				cout << ":(" << endl;
				goto owari;
			}
		}
	}
	
	cout << "Yay!" << endl;

	owari:

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
string s;
int l;
int main()
{
    cin>>s;
    l=s.size();
    for(int i=0;i<l;i++)
    {
        if(s[i]=='C')
        {
            for(int j=i+1;j<l;j++)
            {
                if(s[j]=='F')
                {
                    cout<<"Yes";
                    return 0;
                }
            }
        }
    }
    cout<<"No";
    return 0;
}

Measured memory_bytes: 256
from heapq import heappush, heappop

n = int(input())
A = list(map(int, input().split()))

MX = 2005
f_inf = float('inf')
dp = [[0 for _ in range(MX)] for _ in range(MX)]
dp[0][0] = 0

hq = []
for i in range(n):
    heappush(hq, (-A[i], i))

ans = 0
for i in range(n):
    x, pi = heappop(hq)
    for l in range(i+1):
        r = i-l
        dp[i+1][l+1] = max(dp[i+1][l+1], dp[i][l] + (pi-l)*A[pi])
        dp[i+1][l] = max(dp[i+1][l], dp[i][l] + ((n-r-1)-pi)*A[pi])

ans = 0
for i in range(n+1):
    ans = max(ans, dp[n][i])
print(ans)

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

int main(){
    int n,down = 0,count = 0;
    cin >> n;
    vector<long long>a(n),b(n),margin;
    long long a_all = 0,b_all = 0,shotage = 0;
    for(int i = 0;i < n;i++){
        cin >> a[i]; 
    }
    for(int i = 0;i < n;i++){
        cin >> b[i];
        if(a[i] < b[i])shotage += b[i] - a[i],down++;
        else if(a[i] > b[i])margin.push_back(a[i] - b[i]);
    }

    sort(margin.begin(),margin.end(),greater<long long>());

    for(int i = 0;i < (int)margin.size();i++){
        if(shotage <= 0)break;
        shotage -= margin[i];
        count++;
    }

    if(shotage > 0){
        cout << -1 << endl;
        return 0;
    }
    
    cout << down + count << endl;
}


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

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

using namespace std;

using ll = long long;
using P = pair<int , int>;
  
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);

  int s, t; cin >> s >> t;

  cout << (s>t ? "safe" : "unsafe") << endl;
}


Measured memory_bytes: 3640
//==========================Head files==========================
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#include<queue>
#include<cmath>
#include<set>
#include<iostream>
#include<map>
#define LL long long
#define db double
#define mp make_pair
#define pr pair<int, int>
#define fir first
#define sec second
#define pb push_back
#define ms(i, j) memset(i, j, sizeof i)
using namespace std;
//==========================Templates==========================
inline int read() {
    int x = 0, f = 1; char c = getchar();
    while(c < '0' || c > '9'){if (c == '-') f = -1; c = getchar();}
    while(c >= '0' && c <= '9'){x = x * 10 + c - '0'; c = getchar();}
    return x * f;
}
inline LL readl() {
    LL x = 0, f = 1; char c = getchar();
    while(c < '0' || c > '9'){if (c == '-') f = -1; c = getchar();}
    while(c >= '0' && c <= '9'){x = x * 10 + c - '0'; c = getchar();}
    return x * f;
}
int power(int a, int b) {
	int ans = 1;
	while (b) {
		if(b & 1) ans = ans * a;
		b >>= 1; a = a * a;
	}
	return ans;
}
int power_mod(int a, int b, int mod) {
	a %= mod;
	int ans = 1;
	while (b) {
		if(b & 1) ans = (ans * a) % mod;
		b >>= 1, a = (a * a) % mod;
	}
	return ans;
}
LL powerl(LL a, LL b) {
	LL ans = 1ll;
	while (b) {
		if(b & 1ll) ans = ans * a;
		b >>= 1ll;a = a * a;
	}
	return ans;
}
LL power_modl(LL a, LL b, LL mod) {
	a %= mod;
	LL ans = 1ll;
	while (b) {
		if(b & 1ll) ans = (ans * a) % mod;
		b >>= 1ll, a = (a * a) % mod;
	}
	return ans;
}
LL gcdl(LL a, LL b) {return b == 0 ? a : gcdl(b, a % b);}
LL abssl(LL a) {return a > 0 ? a : -a;}
int gcd(int a, int b) {return b == 0 ? a : gcd(b, a % b);}
int abss(int a) {return a > 0 ? a : -a;}
//==========================Main body==========================
#define LD "%I64d"
#define D "%d"
#define pt printf
#define sn scanf
#define pty printf("YES\n")
#define ptn printf("NO\n")
//==========================Code here==========================
int h, w, A, B;
int main() {
	cin >> h >> w >> A >> B;
	if (A > w / 2 || B > h / 2) puts("-1"); else {
		for (int i = 1; i <= B; ++i) {
			for (int j = 1; j <= A; ++j) printf("1");
			for (int j = A + 1; j <= w; ++j) printf("0");
			puts("");
		}
		for (int i = B + 1; i <= h; ++i) {
			for (int j = 1; j <= A; ++j) printf("0");
			for (int j = A + 1; j <= w; ++j) printf("1");
			puts("");
		}
	}
	return 0;
}

Measured memory_bytes: 1280
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<math.h>
using namespace std;
 
int main() {
	int n;
	cin >> n;
	int a[100000];
	int m = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		m = i;
	}
  m++;
	sort(a, a + m);
 
	int b[100000][2] = {};
	int k = 0;
	for (int i = 0; i < n; i++) {
			if (i == 0) {
				b[0][0] =a[i];
				b[0][1] = 1;
			}
			else if (a[i] == a[i - 1]) {
				b[k][1]++;
			}
			else {
				k++;
				b[k][1]++;
				b[k][0] = a[i];
			}
		
	}
	int ans = 0;
	for (int i = 0; i < 100000; i++) {
		if (b[i][0] == 0) {
			break;
		}
		if (b[i][0] > b[i][1]) {
			ans += b[i][1];
		}
		else if (b[i][0] < b[i][1]) {
			ans += b[i][1] - b[i][0];
		}
	}
	cout << ans << endl;
	getchar();
	getchar();
	return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
#include<vector>
int main()
{
    long long n,k,i,ans=0,c=0;
    cin>>n>>k;
    int a[n+2];
    vector<int>v;
    for(i=0;i<n;i++)
    {
        cin>>a[i];
    }
    sort(a,a+n);
    for(i=0;i<n;i++)
    {
        c++;
        ans=1;
        while(a[i+1]==a[i])
        {
            i++;
            ans++;
        }
        v.push_back(ans);
    }
    if(c<=k)
    {
        cout<<0<<endl;
    }
    else
    {
        sort(v.begin(),v.end());
        ans=0;
        for(i=0;i<(c-k);i++)
        {
            ans+=v[i];
        }
        cout<<ans<<endl;
    }
    return 0;
}


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

int main(){
  int i,j;ll cnt=0;
  ll k,a,b;
  cin>>k>>a>>b;
  if(2>=b-a || a>=k){
    cout<<1+k;
    return 0;
  }
  k-=a-1;
  cnt+=a;
  cnt+=(b-a)*(k/2);
  cout<<cnt+k%2;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(void)
{
	int road[7][2];
	int i,j;
	int flg;
	int len;
	int a[100];
	char p[100];
	
	road[0][0]=2;
	road[0][1]=3;
	road[1][0]=5;
	road[1][1]=3;
	road[2][0]=6;
	road[2][1]=4;
	road[3][0]=2;
	road[3][1]=6;
	road[4][0]=1;
	road[4][1]=5;
	road[5][0]=3;
	road[5][1]=2;
	scanf("%s",p);
	while(p[0]!='#'){
		len=strlen(p);
		for(i=0;i<len;i++){
			a[i]=p[i]-'0';
		}
	/*	for(i=0;i<len;i++){
			printf("%d ",a[i]);
		}	*/	
		j=0;
		flg=0;
		for(i=0;i<len;i++){
			j=road[j][a[i]];
		//	printf("j=%d\n",j);
			if(j==6){
				flg=1;
				break;
			}
		}
		if(flg==1 || j!=5){
			printf("No\n");
		}
		else {
			printf("Yes\n");
		}
		scanf("%s",p);
	}
	return 0;
}

Measured memory_bytes: 948
N,*D=map(int,open(0).read().split())
c=[0]*N
for i in D:c[i]+=1
m=max(D)
if D[0]>0 or c[0]>1:print(0);exit()
a=1
for i in range(m):a*=c[i]**c[i+1]
print(a%998244353)


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

import sys
if sys.version_info.minor >= 5: from math import gcd
else: from fractions import gcd

def input(): return sys.stdin.readline().strip()
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N=INT()
A=LIST()

# 予め左右から累積GCDを取っておく
L=[0]*(N+2)
for i in range(N):
    L[i+1]=gcd(L[i], A[i])
R=[0]*(N+2)
for i in range(N-1, -1, -1):
    R[i+1]=gcd(R[i+2], A[i])

# 1箇所除いてどうなるかを全部試しても、各回GCD1回ずつで済む
ans=0
for i in range(N):
    ans=max(ans, gcd(L[i], R[i+2]))
print(ans)


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

#define rep(n) for(int i=0;i<n;i++)
#define repp(j, n) for(int j=0;j<n;j++)
#define reppp(i, m, n) for(int i=m;i<n;i++)
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define MOD 1000000007
#define EPS 1e-9
 
using namespace std;

typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> Pii;
struct edge{int from, to; ll cost;};

int main(){
    std::ios::sync_with_stdio(0); cin.tie(0);
    int n,a;
    cin >> n >> a;
    if(n%500 <= a){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}


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

#define rep(i, N) for (int i = 0; i < N; i++)
#define pb push_back

typedef long long ll;
typedef pair<ll, int> ll_i;
struct edge { int v, w; };
const ll INF = LLONG_MAX / 3;
const int MOD = 1e9 + 114514;

string solve(char b, char c, int angle, int len) {
	double theta = angle / 180.0 * acos(-1);
	double dx = len * cos(theta), dy = len * sin(theta);
	double x = 2/sqrt(3) * (dx * sqrt(3)/2 - dy * 1/2);
	double y = 2/sqrt(3) * dy;
	char d = ('B' + 'C' + 'D') - (b + c);
	vector<vector<char>> unko(100, vector<char>(100));
	rep(i, 100) rep(j, 100) {
		if (i % 2 == 0 && j % 2 == 0) unko[i][j] = 'A';
		if (i % 2 == 0 && j % 2 == 1) unko[i][j] = b;
		if (i % 2 == 1 && j % 2 == 0) unko[i][j] = c;
		if (i % 2 == 1 && j % 2 == 1) unko[i][j] = d;
	}
	int i = x, j = y, k = x + y;
	string s;
	s.pb(unko[i + 1][j]), s.pb(unko[i][j + 1]);
	if (k % 2 == 0) s.pb(unko[i][j]);
	else s.pb(unko[i + 1][j + 1]);
	sort(s.begin(), s.end());
	return s;
}

int main() {
	vector<string> ans(2);
	rep(t, 2) {
		string e; int angle, len;
		cin >> e >> angle >> len;
		ans[t] = solve(e[0], e[1], angle, len);
	}
	// cout << ans[0] << ' ' << ans[1] << endl;
	cout << (ans[0] == ans[1] ? "YES" : "NO") << endl;
}

Measured memory_bytes: 3440
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define watch(x) cout << #x << " is " << x << endl;
#define print(a, l, r)          \
	for (int i = l; i < r; i++) \
		cout << a[i] << (i == (r - 1) ? endl : " ");
const long long M = 1000000007;
int main()
{

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

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

	bool dp[n][2];
	fill(&dp[0][0], &dp[0][0] + n * 2, false);

	dp[0][0] = dp[0][1] = true;

	for (int i = 1; i < n; i++)
	{
		if (dp[i - 1][0])
		{
			if (a[i - 1] <= a[i])
				dp[i][0] = true;

			if (a[i - 1] <= (a[i] - 1))
				dp[i][1] = true;
		}

		if (dp[i - 1][1])
		{
			if ((a[i - 1] - 1) <= a[i])
				dp[i][0] = true;

			if ((a[i - 1] - 1) <= (a[i] - 1))
				dp[i][1] = true;
		}
	}
	/* for (int i = 0; i < n; i++)
	{
		cout << dp[i][0] << " " << dp[i][1] << endl;
	} */
	cout << ((dp[n - 1][0] || dp[n - 1][1]) ? "Yes" : "No") << endl;

	return 0;
}

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

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


Measured memory_bytes: 256
n_yen, k = map( int, input().split( ' ' ) )
unlike_numbers = set( map( int, input().split( ' ' ) ))

#like_numbers = set(range(10)) - unlike_numbers
#print( like_numbers )

n_yen_str = str( n_yen )
each_strs = [ int( each ) for each in n_yen_str ]
#print ( each_strs )

for paid_yen in range( n_yen, 10* n_yen ):
	paid_yen_str = str( paid_yen )

	each_digit_strs = set( [int( each_digit ) for each_digit in paid_yen_str ] )
	if len( unlike_numbers & each_digit_strs ) == 0 :
		print( paid_yen )
		break


Measured memory_bytes: 3060
import sys
import math

sys.setrecursionlimit(1000000)


def solve(N):
    k = N % 10
    if k == 3:
        return "bon"
    if k in (0, 1, 6, 8):
        return "pon"
    return "hon"


if __name__ == "__main__":
    N = int(input())
    print(solve(N))

Measured memory_bytes: 9172
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;

#define MAX_N 705

vector<vi> g(MAX_N);
bool c = true; //is bipartite graph

int used[MAX_N];
int cnt[2];

void dfs(int now){
    cnt[used[now]]++;
    rep(i,g[now].size()){
        int ne = g[now][i];
        if(used[ne] == -1){
            used[ne] = 1 - used[now];
            dfs(ne);
        }else if(used[ne] == used[now]){
            c = false;
            return;
        }
    }
}

vector<pii> p;

bool is_bipartite(int n){
    rep(i,n) used[i] = -1;
    rep(i,n)if(used[i]==-1){
        used[i] = 0;
        cnt[0] = cnt[1] = 0;
        dfs(i);
        if(c==false) return false;
        p.push_back(pii(cnt[0],cnt[1]));
    }

    return true;
}


int main(void) {
    int i,j;
    int n, m;
    cin >> n >> m;
    int d[700][700];
    rep(i,n)rep(j,n)d[i][j]=1;
    rep(i,m){
        int a,b;
        cin >> a >> b;
        a--,b--;
        d[a][b]--;
        d[b][a]--;
    }
    rep(i,n)rep(j,n)if(d[i][j]==1 && i!=j){
        g[i].push_back(j);
    }


    if(is_bipartite(n) == false){
        cout << -1 << endl;
        return 0;
    }

    int dp[705][705] = {};
    dp[0][0] = 1;
    rep(i,p.size())rep(j,705)if(dp[i][j]){
        dp[i+1][j+p[i].first]++;
        dp[i+1][j+p[i].second]++;
    }
    int ans = INF;
    rep(i,n+1)if(dp[p.size()][i]){
        ans = min(ans, i*(i-1)/2 + (n-i)*(n-i-1)/2);
    }
    cout << ans << endl;
}


Measured memory_bytes: 6784
#include <iostream>
#include <string.h>
#include <stdlib.h>

#define INC(i, a, b) for(int (i) = (a); (i) < (b); ++(i))
#define DEC(i, a, b) for(int (i) = (a); (i) > (b); --(i))
#define REP(i, n)    INC(i, 0, n)
#define comp(a, b) int comp(const void *(a), const void *(b))

typedef unsigned int uint;
typedef unsigned long ul;
typedef long long  ll;
typedef unsigned long long ull;

const int MOD = 1e9 + 7;

using namespace std;

void TFprint(bool b, std::string T, std::string F){
    if(b){
        cout << T << endl;
    }else{
        cout << F << endl;
    }
}

int abs(int x){
    return x > 0? x : -x;
}

int max(int a, int b){
    return a > b? a : b;
}

int min(int a, int b){
    return a < b? a : b;
}


int main(){
    char num[10];
    cin >> num;
    int N = atoi(num);
    int d_sum = 0;
    REP(i, strlen(num)) {
        d_sum += num[i] - '0';
    }
    TFprint(N % d_sum == 0, "Yes", "No");
    return 0;
}

Measured memory_bytes: 256
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
from bisect import bisect_left, bisect_right
import random
from itertools import permutations, accumulate, combinations
import sys
import string



INF = float('inf')
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 998244353


n, m = LI()
total = m * 3

fac = [1] * (total+n+1)
inv = [1] * (total+n+1)
for i in range(total+n):
    fac[i+1] = fac[i]*(i+1)%mod

inv[total+n]=pow(fac[-1], mod-2, mod)
for j in range(total+n-1, -1, -1):
    inv[j]=inv[j+1]*(j+1)%mod



def comb(n, r):
    if r > n:
        return 0
    return fac[n] * inv[n - r] * inv[r] % mod


ans = comb(total+n-1, n-1)
for i in range(m + 2, min(n + 1, total + 1)):
    if (total - i) % 2 == 0:
        ans -= comb(n, i) * comb(n + (total - i) // 2 - 1, n - 1) % mod
        ans %= mod


ret = 0
for i in range(m):
    ret = (ret + comb(i + n - 2, n - 2)) % mod


ans -= (ret * n) % mod
print(ans % mod)

Measured memory_bytes: 80988
using System;
using System.Collections.Generic;
using System.Linq;
 
static class MainClass {
  static Action yes = Yes;
  static Action no = No;
  
  public static void Main (string[] args) {
    //var temp = Console.ReadLine().Split(' ').Select(int.Parse);
    var N = Console.ReadLine().ToCharArray();
    var K = Console.ReadLine();

    for(var i = 0; i < N.Length; i++){
      N = N.Select((x, index) => {return index == 0 ? N[N.Length - 1] : N[index - 1];}).ToArray(); 
      var str = new String(N);
      if(str == K){
        yes();
        return;
      }
    }
    var ans = no;
    ans();

  }
  private static void Yes(){
    Console.WriteLine("Yes");
  }
  private static void No(){
    Console.WriteLine("No");
  }
}

Measured memory_bytes: 13268
import java.util.*;
public class Main{
  public static void main(String[] args) {
    Scanner sc=new Scanner(System.in);
    int a,b,c,d,e,k,temp;
    a=sc.nextInt();
    b=sc.nextInt();
    c=sc.nextInt();
    d=sc.nextInt();
    e=sc.nextInt();
    k=sc.nextInt();
      if(a-b>0){
        temp=a;
        a=b;
        b=temp;
      }
      if(a-c>0){
        temp=a;
        a=b;
        b=temp;
      }if(a-d>0){
        temp=a;
        a=b;
        b=temp;
      }if(a-e>0){
        temp=a;
        a=b;
        b=temp;
      }

      if(e-b<0){
        temp=e;
        e=b;
        b=temp;
      }if(e-c<0){
        temp=e;
        e=b;
        b=temp;
      }if(e-d<0){
        temp=e;
        e=b;
        b=temp;
      }
    if(e-a<=k){
      System.out.println("Yay!");
    }else{
      System.out.println(":(");
    }
  }
}


Measured memory_bytes: 21716
#include <cstdio>
int n, x, d;
int main() {
	scanf("%d%d", &n, &x);
	if(x==1 || x==2*n-1) return puts("No"), 0;
	puts("Yes");
	d = n-x; n += n-1;
	for(int i=0; i<n; i++) printf("%d\n", (i-d+n)%n+1);
}

Measured memory_bytes: 1408
n=int(input())
def xor(x,y):
  bitx=[]
  bity=[]
  num1,num2=x,y
  while num1!=0:
    bitx.append(num1%2)
    num1//=2
  while num2!=0:
    bity.append(num2%2)
    num2//=2
  m=max(len(bitx),len(bity))
  while len(bitx)<m+1:
    bitx.append(0)
  while len(bity)<m+1:
    bity.append(0)
  ans=0
  for i in range(m):
    if bitx[i]!=bity[i]:
      ans+=2**i
  return ans
from collections import defaultdict
import sys
d=defaultdict(int)
l=list(map(int,input().split()))
if n%3!=0:
  for i in range(n):
    if l[i]!=0:
      print("No")
      sys.exit()
  print("Yes")
  sys.exit()
for i in l:
  d[i]+=1
if len(d)>3:
  print("No")
elif len(d)==3:
  b=True
  l1=[]
  for i in d:
    l1.append(i)
    if d[i]!=n/3:
      b=False
  if l1[0]!=xor(l1[1],l1[2]) or l1[1]!=xor(l1[0],l1[2]) or l1[2]!=xor(l1[0],l1[1]):
    b=False
  if b:
    print("Yes")
  else:
    print("No")
elif len(d)==2:
  if d[0]!=n/3:
    print("No")
  else:
    print("Yes")
else:
  if d[0]==n:
    print("Yes")
  else:
    print("No")

Measured memory_bytes: 14484
/*
  A - Restaurant
  <http://abc055.contest.atcoder.jp/tasks/abc055_a>
*/

#include <stdio.h>

int main(int argc, char const *argv[]) {

  int N;
  int x,y;

  scanf("%d", &N);
  x = 800*N;
  y = (N/15)*200;
  printf("%d\n", x-y);
  
  return 0;
}


Measured memory_bytes: 128
S=input()
Q=int(input())
q=[list(input().split()) for i in range(Q)]

top=[]
bot=[]
cnt=0
for i in range(Q):
    if q[i][0]=='1':
        cnt+=1
    if q[i][0]=='2':
        if cnt%2==0:
            if q[i][1]=='1':
                top+=q[i][2]
            if q[i][1]=='2':
                bot+=q[i][2]
        else:
            if q[i][1]=='1':
                bot+=q[i][2]
            if q[i][1]=='2':
                top+=q[i][2]

if cnt%2==1:
    ans=[S[::-1]]
    bot=bot[::-1]
    print(''.join(bot+ans+top))
else:
    ans=[S]
    top=top[::-1]
    print(''.join(top+ans+bot))

Measured memory_bytes: 34292
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N=200005;
ll n,a[N];
ll sum[N],ans;
ll INF=1e9+7;
int main()
{
	cin>>n;
	for (int i=0;i<n;++i) cin>>a[i];
    for (int i=n-1;i>=0;--i) sum[i]=(sum[i+1]+a[i])%INF;
    //for (int i=0;i<n;++i) cout<<sum[i]<<" ";
    for (int i=0;i<n-1;++i)
    {
        ans%=INF;
        ans+=a[i]*sum[i+1]%INF;
        ans%=INF;
    }
    cout<<ans;
	return 0;
}

Measured memory_bytes: 6744
fun main(args : Array<String>) {
    val (H, W) = readLine()!!.split(" ").map { it.toInt() }
    val map = Array(H, { CharArray(W)})
    (0..(H-1)).forEach { h ->
        val row = readLine()!!
        row.forEachIndexed{ w, char ->
            map[h][w] = char
        }
    }

    val infoRow = Array(H, { IntArray(W)})
    val infoColumn = Array(H, { IntArray(W)})

    (0..(H-1)).forEach { h ->
        var isCounting = false;
        var countingFrom = -1
        var countingTo = -1
        var counter = 0
        (0..(W-1)).forEach {w ->
            if (map[h][w] == '.') {
                if (!isCounting) {
                    counter = 1
                    isCounting = true
                    countingFrom = w
                    countingTo = w
                } else {
                    counter++
                    countingTo = w
                }
            }

            if (map[h][w] == '#') {
                if (!isCounting) {
                } else {
                    // Store the result
                    (countingFrom..countingTo).forEach {
                        infoRow[h][it] = counter
                    }
                    counter = 0
                    isCounting = false
                }
            }
        }
        if (isCounting) {
            (countingFrom..countingTo).forEach {
                infoRow[h][it] = counter
            }
        }
    }

    (0..(W-1)).forEach {w ->
        var isCounting = false;
        var countingFrom = -1
        var countingTo = -1
        var counter = 0
        (0..(H-1)).forEach { h ->
            if (map[h][w] == '.') {
                if (!isCounting) {
                    counter = 1
                    isCounting = true
                    countingFrom = h
                    countingTo = h
                } else {
                    counter++
                    countingTo = h
                }
            }

            if (map[h][w] == '#') {
                if (!isCounting) {
                } else {
                    // Store the result
                    (countingFrom..countingTo).forEach {
                        infoColumn[it][w] = counter
                    }
                    counter = 0
                    isCounting = false
                }
            }
        }
        if (isCounting) {
            (countingFrom..countingTo).forEach {
                infoColumn[it][w] = counter
            }
        }
    }


    var max = Int.MIN_VALUE
    (0..(H-1)).forEach { h ->
        (0..(W-1)).forEach {w ->
            if (map[h][w] != '#') {
                val count = infoRow[h][w] + infoColumn[h][w] - 1
                max = Math.max(max, count)
            }
        }
    }

    println(max)
}


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

def readInts():
  return [int(s) for s in input().split(" ")]

def main():
  N = readInts()[0]
  d = readInts()
  d.sort()

  l = N // 2 - 1
  r = N // 2

  print(d[r] - d[l])


if __name__ == "__main__":
  main()


Measured memory_bytes: 14428
#include <bits/stdc++.h>
 
const double pi = 3.141592653589793238462643383279;
 
 
using namespace std;
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
 
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
 
//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007
 
 
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
 
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
const double EPS = 1E-10;
 
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)


//ここから編集
 
const int MAX = 2000010;
long long 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;
}

int N, T;
vector<ll>A(100010);
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  cin >> N >> T;
  REP(i,N) cin >> A[i];

  ll mi = A[0];
  int ct=0;
  int mx = 0;
  for(int i=0; i<N; i++){
    mi = min(mi, A[i]);
    if(mx < A[i]-mi){
      mx = A[i]-mi;
      ct=1;
    }else if(mx == A[i]-mi){
      ct++;
    }
  }
  cout << ct << endl;
  return 0;
}

Measured memory_bytes: 3852
#include<cstdio>
#include<cstring>
#include<algorithm>
#define N 100010
#define ll long long
#define inf 1000000000000000000LL
using namespace std;
int n, flag[N], w[N], nxt[N];
ll ans, now, s[N];
char S[10];
int main(){
	scanf("%d", &n); memset(flag, 0, sizeof(flag));
	for(int i=1; i<=n; i++){
		scanf("%d", &w[i]);
		if(i<=n-1){scanf("%s", S+1); if(S[1]=='-')flag[i+1]=1;}
	}
	s[0]=0; for(int i=1; i<=n; i++)s[i]=s[i-1]+w[i];
	now=n+1;
	for(int i=n; i; i--){nxt[i]=now; if(flag[i])now=i;}
	ans=inf; now=0;
	for(int i=1; i<=n; i++)if(flag[i]){
		ans=min(ans, now+s[nxt[i]-1]-s[i-1]);
		now+=w[i];
	}
	if(ans==inf)ans=0;
	printf("%lld", s[n]-ans*2);
	return 0;
}

Measured memory_bytes: 2176
/*
https://atcoder.jp/contests/dp/tasks/dp_c*/
#include<bits/stdc++.h>
using namespace std;
int dp[100005][3];

int main()
{
	int n;
	cin >> n;
	int a[n][3];
	for(int i=0;i<n;i++)for(int j=0;j<3;j++)cin >> a[i][j];
	dp[0][0]=a[0][0];dp[0][1]=a[0][1];dp[0][2]=a[0][2];
    for(int i=1;i<n;i++)
    {
    	for(int j=0;j<3;j++)
    	{    int mx=0;
    		for(int k=0;k<3;k++)
    		{
    			if(j==k)continue;
    			mx=max(mx,dp[i-1][k]);
    		}
    		dp[i][j]=a[i][j]+mx;
    	}
    }
    cout << max(max(dp[n-1][0],dp[n-1][1]),dp[n-1][2]) << endl;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
bitset<100000050>z;


void sieve()
{
    long long int i,j;

    z[0]=1;
    z[1]=1;
    z[2]=0;
    for(i=4; i<=100000000; i+=2)
        z[i]=1;

    for(i=3; i<=10000; i+=2)
    {
        if(z[i]==0)
        {
            for(j=i*i; j<=100000000; j=j+2*i)
            {
                z[j]=1;
            }


        }
    }

}
int main()
{
    sieve();
    long long int n,num,cnt;

    while(scanf("%lld",&n)!=EOF)
    {
        cnt=0;
        while(n--)
        {
            scanf("%lld",&num);
            if(z[num]==0)
            {

                cnt++;
            }
        }

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

    return 0;
}

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

#define LL long long
#define LD long double
#define SC(t,x) static_cast<t>(x)
#define AR(t) vector < t >
#define PII pair < int, int >
#define PLL pair < LL, LL >
#define PIL pair < int, LL >
#define PLI pair < LL, int >
#define MP make_pair
#define PB push_back
#define PF push_front
#define POB pop_back
#define POF pop_front
#define PRF first
#define PRS second
#define INIT(ar,val) memset ( ar, val, sizeof ( ar ) )
#define lp(loop,start,end) for ( int loop = start; loop < end; ++loop )
#define lpd(loop,start,end) for ( int loop = start; loop > end; --loop )
#define lpi(loop,start,end) for ( int loop = start; loop <= end; ++loop )
#define lpdi(loop,start,end) for ( int loop = start; loop >= end; --loop )
#define qmax(a,b) (((a)>(b))?(a):(b))
#define qmin(a,b) (((a)<(b))?(a):(b))
#define qabs(a) (((a)>=0)?(a):(-(a)))

const int INF = 0x3fffffff;
const int SINF = 0x7fffffff;
const long long LINF = 0x3fffffffffffffff;
const long long SLINF = 0x7fffffffffffffff;
const int MAXN = 2007;

int n;
int ke, la[MAXN];
int a[MAXN];
bool g[MAXN][MAXN];
AR(int) ar[MAXN];
bool vis[MAXN];

void init ();
void input ();
void work ();

void dfs ( int now, AR(int) &ans );

void join ( AR(int) &a, AR(int) &b );

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



int main()
{
	init();
	input();
	work();
}



void init ()
{
	// Init Everything Here
	
	ios::sync_with_stdio ( false );
}

void input ()
{
	// input method
	
	scanf ( "%d", &n );
	lpi ( i, 1, n ) scanf ( "%d", &a[i] );
}

void work ()
{
	// main work
	
	sort ( a+1, a+1+n );
	
	lpi ( i, 1, n ) lpi ( j, 1, n ) if ( i ^ j ) g[i][j] = gcd ( a[i], a[j] ) ^ 1;
	
	AR(int) ans, ret;
	lpi ( i, 1, n ){
		if ( !vis[i] ){
			dfs ( i, ret );
			join ( ans, ret );
		}
	}
	
	for ( auto x : ans ) printf ( "%d ", a[x] );
	putchar ( '\n' );
}



void dfs ( int now, AR(int) &ans )
{
	ans.clear ();
	AR(int) ret;
	vis[now] = true;
	lpi ( v, 1, n ){
		if ( g[now][v] && !vis[v] ){
			dfs ( v, ret );
			join ( ans, ret );
		}
	}
	reverse ( ans.begin (), ans.end () );
	ans.PB ( now );
	reverse ( ans.begin (), ans.end () );
}



void join ( AR(int) &a, AR(int) &b )
{
	int na = a.size (), nb = b.size ();
	AR(int) ans ( na + nb );
	int ni = 0, nj = 0;
	lp ( i, 0, na + nb ){
		if ( nj == nb || ( ni < na && a[ni] > b[nj] ) ) ans[i] = a[ni], ++ni;
		else ans[i] = b[nj], ++nj;
	}
	a.swap ( ans );
}

Measured memory_bytes: 4608
N, M = map(int, input().split())

A = list(map(int, input().split()))

BC = []

for j in range(M):
    b, c = map(int, input().split())
    BC.append((b, c))
    
sorted_BC = sorted(BC, reverse=True, key=lambda item: item[1])

candidate = []
count = N
for bc in sorted_BC:
    b = bc[0]
    c = bc[1]
    if count >= 0:
        candidate.extend([c] * b)
        count = count - b
    else:
        break
    
candidate.extend(A)

print(sum(sorted(candidate, reverse=True)[:N]))

Measured memory_bytes: 27884
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long int  w,h,x,y;
  cin>>w>>h>>x>>y;
  double p=w*h/(double)2;
  cout<<fixed<<setprecision(6)<<p<<" ";
  cout<<(w==x+x && h==y+y);
  return 0;
}

Measured memory_bytes: 256
Mod  = 10**9
i = 0
ans = 0
while ans<Mod:
    i+=1
    ans = i**5 - (i-1)**5
#print(i)->120

i = 0
ans = 0
while ans<Mod:
    i-=1
    ans = i**5-(i-1)**5
#print(i)->-119


x = int(input())
Kouho = [int(i) for i in range(-120,121,1)]
for i in Kouho:
    for j in Kouho:
        if i**5-j**5==x:
            print(i,j)
            exit()

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

void sieve(ll n)
{
	vector<ll> v(n+1,1);
	for(ll i=2;i<=n;i++)
	{
		for(ll j=i;j<=n;j+=i)
		{
			v[j]++;
		}
	}
	ll sum=0;
		for(ll i=1;i<=n;i++)
	sum+=i*v[i];
	cout<<sum;
}
int main()
{
	
	ll n;
	cin>>n;
	sieve(n);

	
	
	
}

Measured memory_bytes: 81340
#include<bits/stdc++.h>
#include<cmath>
#include<cstring>
#include<climits>
#define int long long
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);
#define asc(a,n) sort(a,a+n);
#define dsc(a,n) sort(a,a+n,comp);
#define fo(i,x,y) for(int i=x;i<y;i++)
#define inarr(x) int n; cin>>n; int x[n]; fo(i,0,n){cin>>x[i];}
#define test int t; cin>>t; while(t--)
using namespace std;

int basic(){freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);return 0;}
bool comp(int a,int b){return a>b;}



int32_t main()
{ //basic(); 
  fast;
  int x; cin>>x; int store; int flag=0;
  fo(i,1,x)
  {
    if(pow(i,5)>=x){store=i; break;}
  }
  fo(i,-1000,1001)
  {
    fo(j,-1000,1001){if((pow(i,5)-pow(j,5))==x) {cout<<i<<" "<<j; flag=1;break;}}
    if(flag==1){break;}
  }


  
  return 0;
}






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

#define repeat(i, x) for (int64_t i = 0; (i) < (int64_t)(x); (i)++)

int64_t calcCost(vector<int>& a) {
    int64_t cost = 0;
    repeat (i, a.size() - 1) {
        cost += abs(a[i + 1] - a[i]);
    }
    return cost;
}

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

    int n;
    cin >> n;

    vector<int> a(n);
    repeat (i, n) {
        cin >> a[i];
    }

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

    if (n == 2) {
        cout << abs(a[0] - a[1]) << endl;
        return 0;
    }

    if (n == 3) {
        cout << max({
                        abs(a[0] - a[1]) + abs(a[1] - a[2]),
                        abs(a[0] - a[2]) + abs(a[1] - a[0]),
                        abs(a[1] - a[2]) + abs(a[0] - a[2])}) << endl;
        return 0;
    }

    int64_t ans = 0;

    if (n % 2 == 0) {
        {
            vector<int> seq;
            seq.push_back(a[n / 2 - 1]);
            int idxl = 0, idxr = n - 1;
            while (idxl < n / 2 - 1) {
                seq.push_back(a[idxr--]);
                seq.push_back(a[idxl++]);
            }
            seq.push_back(a[n / 2]);

            ans = max(ans, calcCost(seq));
        }
    } else {
        {
            vector<int> seq;
            seq.push_back(a[n / 2 - 1]);
            int idxl = 0, idxr = n - 1;
            while (idxl < n / 2 - 1) {
                seq.push_back(a[idxr--]);
                seq.push_back(a[idxl++]);
            }
            seq.push_back(a[idxr--]);
            seq.push_back(a[idxr--]);

            ans = max(ans, calcCost(seq));
        }
        {
            vector<int> seq;
            seq.push_back(a[n / 2 + 1]);
            int idxl = 0, idxr = n - 1;
            while (idxr > n / 2 + 1) {
                seq.push_back(a[idxl++]);
                seq.push_back(a[idxr--]);
            }
            seq.push_back(a[idxl++]);
            seq.push_back(a[idxl++]);

            ans = max(ans, calcCost(seq));
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1520
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N = int(input())
As = list(mapint())

median = sum(As)/N
lis = [(abs(a-median), i) for i, a in enumerate(As)]
lis.sort()
print(lis[0][1])

Measured memory_bytes: 62044
#include<bits/stdc++.h>
#define rep(i, n) for(int (i)=0 ;i <(n); ++(i))
#define REP(i,m,n) for(int (i) = (m); (i) <= (n); ++(i))
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)? "YES":"NO")
typedef long long ll;
using namespace std;

int main() {
  int a, b;
  char op;
  cin >> a >> op >> b;
  if(op == '+') {
    cout << a + b << endl;
  } else {
    cout << a - b << endl;
  }

  return 0;
}

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

int main() {
  
    int n, m, x;
    int s = 0;
    
    cin >> n >> m;

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

    for(int i = 0; i < n; i++){
        s += vs[i];
    }

    sort(vs.begin(), vs.end());
    x  = m - s;

    cout << n+x/vs[0] << endl;
    
    return 0;
}


Measured memory_bytes: 3572
#![allow(unused_parens)]
#![allow(unused_imports)]
#![allow(non_upper_case_globals)]
#![allow(non_snake_case)]
#![allow(unused_mut)]
#![allow(unused_variables)]
#![allow(dead_code)]

use itertools::Itertools;
use proconio::input;
use proconio::marker::{Chars, Usize1};

#[allow(unused_macros)]
#[cfg(debug_assertions)]
macro_rules! mydbg {
    //($arg:expr) => (dbg!($arg))
    //($arg:expr) => (println!("{:?}",$arg));
      ($($a:expr),*) => {
          eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
      }
}
#[cfg(not(debug_assertions))]
macro_rules! mydbg {
    ($($arg:expr),*) => {};
}

macro_rules! echo {
    ($($a:expr),*) => {
          $(println!("{}",$a))*
      }
}

use std::cmp::*;
use std::collections::*;
use std::ops::{Add, Div, Mul, Sub};

#[allow(dead_code)]
static INF_I64: i64 = 92233720368547758;
#[allow(dead_code)]
static INF_I32: i32 = 21474836;
#[allow(dead_code)]
static INF_USIZE: usize = 18446744073709551;
#[allow(dead_code)]
static M_O_D: usize = 1000000007;
#[allow(dead_code)]
static PAI: f64 = 3.1415926535897932;

trait IteratorExt: Iterator {
    fn toVec(self) -> Vec<Self::Item>;
}

impl<T: Iterator> IteratorExt for T {
    fn toVec(self) -> Vec<Self::Item> {
        self.collect()
    }
}

trait CharExt {
    fn toNum(&self) -> usize;
    fn toAlphabetIndex(&self) -> usize;
    fn toNumIndex(&self) -> usize;
}
impl CharExt for char {
    fn toNum(&self) -> usize {
        return *self as usize;
    }
    fn toAlphabetIndex(&self) -> usize {
        return self.toNum() - 'a' as usize;
    }
    fn toNumIndex(&self) -> usize {
        return self.toNum() - '0' as usize;
    }
}

trait VectorExt {
    fn joinToString(&self, s: &str) -> String;
}
impl<T: ToString> VectorExt for Vec<T> {
    fn joinToString(&self, s: &str) -> String {
        return self
            .iter()
            .map(|x| x.to_string())
            .collect::<Vec<_>>()
            .join(s);
    }
}

trait StringExt {
    fn get_reverse(&self) -> String;
}
impl StringExt for String {
    fn get_reverse(&self) -> String {
        self.chars().rev().collect::<String>()
    }
}

trait UsizeExt {
    fn pow(&self, n: usize) -> usize;
}
impl UsizeExt for usize {
    fn pow(&self, n: usize) -> usize {
        return ((*self as u64).pow(n as u32)) as usize;
    }
}

fn main() {
    use itertools_num::ItertoolsNum as _;
    input! {
       N: usize,
       A:[usize;N],
    }

    let mut ans: usize = 0;

    for i in 0..N {
        if (i + 1) % 2 == 1 && A[i] % 2 == 1 {
            ans += 1;
        }
    }

    echo!(ans);
}


Measured memory_bytes: 2116
import std.algorithm;
import std.container;
import std.conv;
import std.functional;
import std.math;
import std.meta;
import std.random;
import std.range;
import std.stdio;
import std.string;
import std.traits;
import std.typecons;

auto solve(uint N, uint Q, uint[] a, uint[] b, uint[] p, uint[] x){
    auto edges = new uint[][](N + 1, 0);
    foreach (ai, bi; zip(a, b)) {
        edges[ai] ~= bi;
        edges[bi] ~= ai;
    }

    auto nodes = new uint[](N + 1);
    foreach (pi, xi; zip(p, x)) {
        nodes[pi] += xi;
    }

    auto visited = new bool[](N + 1);
    dig(nodes, edges, 1, 0, visited);

    return nodes[1 .. $].map!(to!string).join(" ");
}

void dig(uint[] nodes, uint[][] edges, uint nodei, uint acc, bool[] visited) {
    visited[nodei] = true;
    acc = (nodes[nodei] += acc);
    foreach (childi; edges[nodei]) {
        if (visited[childi])
            continue;
        dig(nodes, edges, childi, acc, visited);
    }
}

void main(){
    auto input = stdin.byLine.map!split.joiner;

    uint N;
    N = input.front.to!uint;
    input.popFront;

    uint Q;
    Q = input.front.to!uint;
    input.popFront;

    uint[] a = new uint[](cast(size_t) (N-1));
    uint[] b = new uint[](cast(size_t) (N-1));
    foreach (i; 0 .. cast(size_t) (N-1)) {
        a[i] = input.front.to!uint;
        input.popFront;
        b[i] = input.front.to!uint;
        input.popFront;
    }

    uint[] p = new uint[](cast(size_t) (Q));
    uint[] x = new uint[](cast(size_t) (Q));
    foreach (i; 0 .. cast(size_t) (Q)) {
        p[i] = input.front.to!uint;
        input.popFront;
        x[i] = input.front.to!uint;
        input.popFront;
    }

    static if (is(ReturnType!solve == void))
        solve(N, Q, a, b, p, x);
    else
        solve(N, Q, a, b, p, x).writeln;
}


Measured memory_bytes: 45436