akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define PII pair<int, int>
#define LL long long
#define LD long double
#define VI vector<int>
#define VPII vector<PII>
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define pb pop_back
#define FOR(a,s,d) for (int a = (s); a <= (int)(d); ++a)
#define FORD(a,s,d) for (int a = (s); a >= (int)(d); --a)
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define ALL(x) x.begin(), x.end()
#define siz(x) ((int)x.size())
#define Sim template <class s
Sim, class d> ostream & operator<<(ostream &os, pair<s,d> x){return os << "<" << x.f << ", " <<
  x.s << "> ";}
Sim> auto operator<<(ostream &os, s x) -> typename enable_if<!is_same<s,string>::value,
  decltype(x.begin(), os)>::type
{ int o = 0; os << "{"; for (auto c : x) {if(o++) os << ", "; os << c;}return os << "} ";}
void dor() {cerr << endl;}
Sim, class ...t> void dor(s x, t...y) {cerr << x << " "; dor(y...);}
#ifdef DEB
#define debug(c...) dor(__FUNCTION__, ":", __LINE__, ": ", c)
#else
#define debug(...)
#endif

bool check(LL a, LL b, LL m)
{
  LL x1 = (m + 1) / 2;
  LL x2 = (m + 2) / 2;
  if (x1 >= a)
  {
    x1++;
  }
  if (x2 >= b)
  {
    x2++;
  }
  if (x1 > 2e9)
  {
    return false;
  }
  return a * b > x1 * x2;
}

void solve()
{
  LL a, b;
  scanf("%lld%lld", &a, &b);
  if (a > b)
  {
    swap(a, b);
  }
  LL st = 0, en = 2e18, mid = (st + en) / 2, r = 0;
  while (st <= en)
  {
    if (check(a, b, mid))
    {
      r = max(r, mid);
      st = mid + 1;
    }
    else
    {
      en = mid - 1;
    }
    mid = (st + en) / 2;
  }
  printf("%lld\n", r);
}

int main()
{
  //ios_base::sync_with_stdio(0);
  //cin.tie(0);
  int t;
  scanf("%d", &t);
  while (t--)
  {
    solve();
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <numeric>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))


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

    int n;
    s64 x;
    cin >> n >> x;

    vs64 a(n);
    rep (i, n) cin >> a[i];

    s64 ans = 0;
    rep (i, n - 1)
    {
        if (a[i] + a[i + 1] > x)
        {
            ans += a[i] + a[i + 1] - x;
            a[i + 1] = MAX(0, x - a[i]);
        }
    }

    cout << ans << "\n";

    return 0;
}



Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cstring>
using namespace std;
#define ll long long
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define FORL(i,x) for(int i=head[x];i;i=nxt[i])
#define clr(x,y) memset(x,y,sizeof(x))
#define in(a) a=read()
#define out(a) printf("%d\n",a)
inline ll read(){
	char c=getchar();ll f=1,x=0;
	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;
}
#define mod 1000000007
#define maxn 100010
#define inf (1<<30)
char s[maxn];
int main(){
	scanf("%s",s+1);
	int n=strlen(s+1);
	FOR(i,1,n)s[i]-='0';
	int ans=inf;
	FOR(i,1,n-2){
		int c=s[i]*100+s[i+1]*10+s[i+2];
		ans=min(ans,abs(c-753));
	}
	cout<<ans<<endl;
}
//5*5*3


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int a,b,c,d,e,f,g;
	int n;
	int i;
	int m;

	scanf("%d",&n);
	while(n!=0){
	a=b=c=d=e=f=g=0;
		for(i=0;i<n;i++){
			scanf("%d",&m);
			if(m<10){
				a++;
			}
			else if(m<20){
				b++;
			}
			else if(m<30){
				c++;
			}
			else if(m<40){
				d++;
			}
			else if(m<50){
				e++;
			}
			else if(m<60){
				f++;
			}
			else if(m>=60){
				g++;
			}
		}
	printf("%d\n%d\n%d\n%d\n%d\n%d\n%d\n",a,b,c,d,e,f,g);
	scanf("%d",&n);
	}
	
	return 0;
}

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

int main() {
    string s;
    cin>>s;
    if(s[0]==s[1] && s[2]==s[3] && s[0]!=s[2]) cout<<"Yes"<<endl;
    else if(s[0]==s[2] && s[1]==s[3] && s[0]!=s[1]) cout<<"Yes"<<endl;
    else if(s[0]==s[3] && s[2]==s[1] && s[0]!=s[1]) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 3628
#pragma region header
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define ts to_string
#define all(v) (v).begin(), (v).end()
#define vi vector<int>
#define vvi vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vs vector <string>
#define vvs vector <vector<string>>
#define pq  priority_queue<int>
using ll = long long;
/* ----------------よく使う数字や配列----------------- */
int dx[] = { 1,0,-1,0 };
int dy[] = { 0,1,0,-1 };
constexpr ll mod = 1e9 + 7;
constexpr long double pi = 3.141592653589793238462643383279;
/* ----------------------end----------------------- */
/* --------------------ライブラリ-------------------- */
ll fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i % mod;
}
ll gcd(ll a, ll b) {        //最大公約数
    if (b == 0) return a;
    return gcd(b, a % b);
}
ll lcm(ll a, ll b) {      //最小公倍数
    return a * b / gcd(a, b);
}
bool isprime(ll a)//素数判定、primeならtrue,違うならfalse
{
    if (a < 2) return false;
    else if (a == 2) return true;
    else if (a % 2 == 0) return false;
    double m = sqrt(a);
    for (int i = 3; i <= m; i += 2)
    {
        if (a % i == 0)
        {
            return false;
        }
    }
    // 素数である
    return true;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while (n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
ll kind(vi SYURUI) {//vector<int>型の配列の要素の種類数
    int size = SYURUI.size();
    sort(all(SYURUI));
    int cnt = 1;
    rep(i, size-1) {
        if (SYURUI[i] != SYURUI[i + 1])cnt++;
    }
    return cnt;
}
/* ----------------------end----------------------- */
#pragma endregion
signed main() {
    int A, B, C; cin >> A >> B >> C;
    if ((A<C && B>C) || (A > C && B < C))puts("Yes");
    else puts("No");
}






Measured memory_bytes: 3660
// https://atcoder.jp/contests/abc077/tasks/arc084_a
#include <bits/stdc++.h>

using namespace std;

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

#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<(b);i++)
#define repr(i,b,a) for(int i=int(b);i>=(a);i--)
#define all(x) x.begin(),x.end()

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

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool valid(int lx,int ux,int ly,int uy,int x,int y){
	return lx<=x&&x<ux&&ly<=y&&y<uy; 
}
ll power(ll x,ll p){
	if(p==0)return 1;
	ll res=power(x*x%mod,p/2);
	if(p%2==1)res=res*x%mod;
	return res;
}

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

	ll ans=0;
	rep(i,n){
		ll num_a = lower_bound(all(a), b[i]) - a.begin();
		ll num_c = c.end() - upper_bound(all(c), b[i]);

		ans += num_a*num_c;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 4548
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

int main() {
    int n,x;
    cin>>n>>x;
    ll a[n];
    rep(i,n) cin>>a[i];
    ll ans=0;
    for(int i=1;i<n;i+=2){
        if(a[i]+a[i-1]>x){
            ll y=a[i]+a[i-1]-x;
            ans+=y;
            if(y>a[i]){
                a[i]=0;
                y-=a[i];
                a[i-1]-=y;
            }
            else{
                a[i]-=y;
            }
        }
        if(i+1<n && a[i]+a[i+1]>x){
            ll y=a[i+1]+a[i]-x;
            ans+=y;
            if(y>a[i+1]){
                a[i+1]=0;
                y-=a[i+1];
                a[i]-=y;
            }
            else{
                a[i+1]-=y;
            }
        }
    }
    

    cout<<ans<<endl;
}



Measured memory_bytes: 1024
#include "bits/stdc++.h"
#define REP(i,n) for(int i=0;i< (n);i++)
#define REPR(i, n) for(int i = (n);i >= 0;i--)
#define FOR(i, m, n) for(int i = (m);i < (n);i++)
#define FORR(i, m, n) for(int i = (m);i >= (n);i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define ALL(obj) (obj).begin(),(obj).end()

using namespace std;

const int INF = 99999999;
const ll LINF = 9999999999999;

typedef pair<int, int> P;
typedef pair<ll, ll> LP;
int vx[4] = { 0,1,0,-1 };
int vy[4] = { 1,0,-1,0 };

string code, hint;
int num;

signed main() {

	std::ios::sync_with_stdio(false);
	std::cin.tie(0);

	cin >> code >> hint;
	num=0;

	REPR(i, code.length()-1) {
		if (code[i] == hint[hint.length()-num-1] || code[i] == '?') {
			num++;
		}
		else {
			num = 0;
			if (code[i] == hint[hint.length()-1]) {
				num = 1;
			}
			if (code[i] == hint[hint.length() - 2] && code[i+1]== '?') {
				num = 2;
			}
			if (code[i] == hint[hint.length() - 3] && code[i + 1] == '?' && code[i+2]=='?') {
				num = 3;
			}
			if (code[i] == hint[hint.length() - 4] && code[i + 1] == '?' && code[i + 2] == '?'&& code[i + 3] == '?') {
				num = 4;
			}

		}

		if (num == hint.length()) {
			//入る場所見つけました。
			code.replace(i, num, hint);
			//残りの?はaで置換。
			REP(j, code.length()) {
				if (code[j] == '?') code[j] = 'a';
			}

			cout << code <<endl;

			return 0;

		}
	}

	cout << "UNRESTORABLE" << endl;
	return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
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=200010;
const ll mod=1e9+7;


int main(){
  int n,m;
  cin >> n >> m;
  vector<string> a(n),b(m);
  rep(i,n){ cin>>a[i]; }
  rep(i,m){ cin>>b[i]; }
  
  rep(i,n-m+1){
    int cnt=0;
    auto pos = a[i].find(b[cnt]);
    bool flag=false;
    while(pos!=std::string::npos){
      flag=true;
      rep(j,m){
        if(a[i+j].substr(pos,m)!=b[j]){flag=false; break;}
      }
      if(flag){break;}
      pos = a[i].find(b[cnt],pos+b[cnt].length());
    }
    if(flag){ cout << "Yes" << endl; return 0; }
  }
  
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
/**
  @date Time-stamp: <2019-04-06 21:19:01 tagashira>
  @file a.cpp
  @brief https://atcoder.jp/contests/abc123/tasks/abc123_a
**/

#include <iostream>
#include <string>

using namespace std;

bool can_comm(string a, string b, string k) {
  int A = stoi(a);
  int B = stoi(b);
  int K = stoi(k);

  if (abs(A - B) <= K) {
    return true;
  } else {
    return false;
  }
}

int main(int argc, char* argv[]) {
  string a;
  cin >> a;
  string b;
  cin >> b;
  string c;
  cin >> c;
  string d;
  cin >> d;
  string e;
  cin >> e;
  string k;
  cin >> k;

  if (can_comm(a, b, k) &&
      can_comm(a, c, k) &&
      can_comm(a, d, k) &&
      can_comm(a, e, k) &&
      can_comm(b, c, k) &&
      can_comm(b, d, k) &&
      can_comm(b, e, k) &&
      can_comm(c, d, k) &&
      can_comm(c, e, k) &&
      can_comm(d, e, k)
      ) {
    cout << "Yay!"         << "\n";
  } else {
    cout << ":("         << "\n";
  }

  return 0;
}


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

int main() {
  using vi = vector<int>;
  using vs = vector<string>;
  using vvi = vector<vi>;
  using vvs = vector<vs>;
  using tsii = tuple<string, int, int>;
  using vtsii = vector<tsii>;
  
  int N, point;
  string city;
  cin >> N;
  vtsii vec(N);

  for (int i = 0; i < N; i++) {
    cin >> city >> point; 
    vec.at(i) = make_tuple(city, 100 - point, i + 1);
  }
  
  sort(vec.begin(), vec.end());
  
  for (auto elem: vec) {
    int j;
    tie(ignore, ignore, j) = elem;
    cout << j << endl;
  }
  
}

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

using namespace std;

int
main(void){
	int n; cin >> n;
	vector<vector<int> > vec(2, vector<int>(n));
	for(int i = 0; i < 2; i++){
		for(int j = 0; j < n; j++){
			cin >> vec[i][j];
		}
	}
	
	for(int i = 0; i < 2; i++){
		for(int j = 0; j < n; j++){
			if(i - 1 >= 0 && j - 1 >= 0){
				vec[i][j] = max(vec[i - 1][j], vec[i][j - 1]) + vec[i][j];
			}
			else if(j - 1 >= 0){
				vec[i][j] = vec[i][j - 1] + vec[i][j];
			}
			else if(i - 1 >= 0){
				vec[i][j] = vec[i - 1][j] + vec[i][j];
			}
		}
	}
	/*for(int i = 0; i < 2; i++){
		for(int j = 0; j < n; j++){
			cout << vec[i][j] << " ";
		}
		cout << endl;
	}*/
	cout << vec[1][n - 1];
}

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

long long mod = 1e9 + 7;

int main(){
    long long n ,k;
    cin >> n >> k;

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

    vector<long long> a2(2*n);
    for(long long i = 0; i < n; i++){
        a2[i] = a[i];
        a2[i+n] = a[i];
    }

    long long cnt_in = 0;
    for(long long i = 0; i < n; i++){
        for(long long j = i + 1; j < n; j++){
            if(a[i] > a[j]) cnt_in++;
        }
    }
    //printf("cnt_in %lld\n", cnt_in);

    long long cnt_2 = 0;
    for(long long i = 0; i < 2*n; i++){
        for(long long j = i + 1; j < 2*n; j++){
            if(a2[i] > a2[j]) cnt_2++;
        }
    }

    cnt_in %= mod;

    long long cnt_out = cnt_2 - 2 * cnt_in;
    //cnt_out += mod;
    cnt_out %= mod;

    //printf("cnt_out %lld\n", cnt_out);

    long long ans = (cnt_in * k)%mod + cnt_out * (k * (k-1)/2%mod);
    ans %= mod;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3624
#include <algorithm>
#include <iostream>

using namespace std;

int main() {
  string S[3];
  for (auto &s : S) {
    cin >> s;
    reverse(begin(s), end(s));
  }

  int t{};
  auto s = &S[t];
  while (!s->empty()) {
    t = s->back() - 'a';
    s->pop_back();
    s = &S[t];
  }

  cout << char('A' + t) << endl;

  return 0;
}


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

using namespace std;

typedef long long ll;

vector< vector<int> > G;
vector<int> C;

const ll inf = 1e18;

int N;
//ll ans[40][40];
ll ans = inf;
vector<bool> used1;
vector<int> used2;

ll dfs(int s, int t, int prev, ll cost) {
	if (cost >= ans) return ans;
	for (int i = 0; i < G[s].size(); ++i) {
		int v = G[s][i];
		if (v != prev && used1[v]) {
			return inf;
		}
	}
	if (used2[s]++ == 0) {
		cost += C[s];
	}
	for (int i = 0; i < G[s].size(); ++i) {
		int v = G[s][i];
		if (used2[v]++ == 0) {
			cost += C[v];
		}
	}
	if (cost >= ans) {
		--used2[s];
		for (int i = 0; i < G[s].size(); ++i) {
			--used2[G[s][i]];
		}
		return ans;
	}
	if (s == t) {
		--used2[s];
		for (int i = 0; i < G[s].size(); ++i) {
			--used2[G[s][i]];
		}
		return cost;
	}
	ll res = inf;
	for (int i = 0; i < G[s].size(); ++i) {
		int to = G[s][i];
		if (!used1[to]) {
			used1[to] = true;
			res = min(res, dfs(to, t, s, cost));
			used1[to] = false;
		}
	}
	--used2[s];
	for (int i = 0; i < G[s].size(); ++i) {
		--used2[G[s][i]];
	}
	if (s == 0 && t == N-1) ans = min(ans, res);
	if (s == 0) {
		assert(t == N-1);
		for (int i = 0; i < N; ++i) {
			assert(used2[i] == 0);
			assert(used1[i] == i==0);
		}
	}
	return res;
}

int main() {
	int M; cin >> N >> M;
	C.resize(N);
	G.resize(N);
	for (int i = 0; i < N; ++i) {
		cin >> C[i];
	}
	for (int i = 0; i < M; ++i) {
		int from, to; cin >> from >> to; --from, --to;
		G[from].push_back(to);
		G[to].push_back(from);
	}
//	fill(ans[0], ans[40], inf);
	used1 = vector<bool>(N, false); used1[0] = true;
	used2 = vector<int>(N, 0);
	cout << dfs(0, N-1, -1, 0) << endl;
}

Measured memory_bytes: 1240
a = gets.split.map(&:to_i).sort
ans = 0

ans += (a[2] - a[0]) / 2
a[0] += (a[2] - a[0]) / 2 * 2

ans += (a[2] - a[1]) / 2
a[1] += (a[2] - a[1]) / 2 * 2

d0 = a[2] - a[0]
d1 = a[2] - a[1]
if d0 + d1 == 1
    ans += 2
elsif d0 + d1 == 2
    ans += 1
end
p ans

Measured memory_bytes: 3836
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int ans = 0;
        int count = 1;
        while (count<b){
            count+=a-1;
            ans++;
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 35828
use std::collections::HashMap;

fn main() {
    let n: i64 = read();

    println!("{}", solve(n));
}

fn read<T: std::str::FromStr>() -> T {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).ok();
    buf.trim().parse().ok().unwrap()
}

fn solve(n: i64) -> i32 {
    // 条件から、pはNの素因数であり、zは p^e と書けるNの約数である。
    // N = p1^e1 * p2^e2 * ... * pn^en と素因数分解できたとすると、
    // zの候補は
    //   p1, p1^2, p1^3, ..., p1^e1,
    //   p2, p2^2, p2^3, ..., p2^e2,
    //   ...
    //   pn, pn^2, pn^3, ..., pn^en,
    // となる。
    //
    // まず z = p1 とすると、Nはp1で割り切れるためそれが1回。N = N/z となる。
    // 次は z = p1 とはできないため、z = p1^2 として同様に操作する。

    prime_factors(n)
        .iter()
        .map(|(&p, &c)| {
            let mut m = n;
            let mut cnt = 0;
            for i in 1..=(c + 1) / 2 {
                let k = p.pow(i as u32);
                if m % k != 0 {
                    break;
                }
                m /= k;
                cnt += 1;
            }
            cnt
        })
        .sum()
}

fn prime_factors(n: i64) -> HashMap<i64, i32> {
    let mut pf: HashMap<i64, i32> = HashMap::new();
    if n < 2 {
        return pf;
    }

    let mut k = n;

    while k % 2 == 0 {
        let v = pf.entry(2).or_insert(0);
        *v += 1;
        k /= 2;
    }

    for i in (3..=(k as f64).sqrt() as i64).step_by(2) {
        if k == 1 {
            break;
        }

        if pf.keys().any(|p| i % p == 0) {
            continue;
        }

        while k % i == 0 {
            let v = pf.entry(i).or_insert(0);
            *v += 1;
            k /= i;
        }
    }

    if k > 1 {
        pf.insert(k, 1);
    }

    pf
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn test_prime_factors_1() {
        let expected: HashMap<i64, i32> = vec![(2, 1)].into_iter().collect();
        assert_eq!(expected, prime_factors(2));
    }

    #[test]
    fn test_prime_factors_2() {
        let expected: HashMap<i64, i32> = vec![(2, 1), (3, 1)].into_iter().collect();
        assert_eq!(expected, prime_factors(6));
    }

    #[test]
    fn test_prime_factors_3() {
        let expected: HashMap<i64, i32> = vec![(3, 1), (5, 2), (7, 1)].into_iter().collect();
        assert_eq!(expected, prime_factors(525));
    }

    #[test]
    fn test_prime_factors_4() {
        let expected: HashMap<i64, i32> = vec![(2, 3), (3, 1), (5, 1)].into_iter().collect();
        assert_eq!(expected, prime_factors(120));
    }

    #[test]
    fn test_solve_1() {
        assert_eq!(3, solve(24));
    }

    #[test]
    fn test_solve_2() {
        assert_eq!(0, solve(1));
    }

    #[test]
    fn test_solve_3() {
        assert_eq!(3, solve(64));
    }

    #[test]
    fn test_solve_4() {
        assert_eq!(1, solve(1000000007));
    }

    #[test]
    fn test_solve_5() {
        assert_eq!(7, solve(997764507000));
    }
}


Measured memory_bytes: 2168
N=int(input())
a=list(map(int,input().split()))
ans=float("inf")
for r in range(0,N+1):
    test=0
    for j in range(0,N):
        test+=(a[j]+r+1)//(N+1)
    test-=r
    t=max(test,0)*(N+1)+r
    ans=min(ans,t)

print(ans)


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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

// Problem Specific Parameter:
ll a[1 << 18];
ll cmax[1 << 18][2];

ll ans[1 << 18];
const ll inf = 1LL << 50;

int main(void){
	int n;
	cin >> n;

	rep(i,1<<n) cin >> a[i], cmax[i][0] = cmax[i][1] = -inf;

	rep(i,n)rep(mask,1<<n){
		if(mask & (1 << i)){
			vector<ll> cand;
			rep(k,2) cand.push_back(cmax[mask][k]);
			rep(k,2) cand.push_back(cmax[mask ^ 1 << i][k]);
			cand.push_back(a[mask ^ 1 << i]);
			sort(rbegin(cand),rend(cand));
			rep(k,min<int>(cand.size(),2)) cmax[mask][k] = cand[k];
		}
	}


	rep(i,1 << n) chmax(ans[i],cmax[i][0] + a[i]);

	rep(i,1 << n) chmax(ans[i],cmax[i][0] + cmax[i][1]);

	rep(i,1,1<<n){
		chmax(ans[i],ans[i-1]);
		cout << ans[i] << endl;
	}
	
	return 0;
}

Measured memory_bytes: 11264
#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
    string s;
    cin>>s;
    for(int i=0;i<s.size();i++)
        if(i%2==0&&s[i]=='L'||i%2==1&&s[i]=='R')
            cout<<"No"<<endl,exit(0);
    cout<<"Yes"<<endl;
}


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

int main(){
    int n;
    cin >> n;
    vector<string> in(n); 
    vector<vector<int> > num(n,vector<int>(26,0));
    for(int i=0;i<n;i++){
        cin >> in[i];
        sort(in[i].begin(),in[i].end());
    }
    sort(in.begin(),in.end());
    long long ans = 0;
    long long tmp = 1;
    /*for(int i=0;i<n;i++){
        cout << in[i] << endl;
    }*/
    for(int i=0;i<n-1;i++){
        for(int j=0;j<10;j++){
            if(in[i][j] != in[i+1][j]){
                ans += (tmp)*(tmp-1)/2;
                tmp = 1;
                break;
            }   
            if(j == 9){
                tmp ++;
            }
        }
    }
    ans += tmp*(tmp-1)/2;
    cout << ans << endl;
    return 0;
}

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

using namespace std;

struct DATA{
  int x;
  int count;
};

void OddNumber(vector<DATA>&, int);
void EvenNnumber(vector<DATA>&, int);

int main(){
  int i, j, n, x, count;
  vector<DATA> data;

  while(1){
    cin >> n;
    if(n == 0) break;

    for(i=0; i<n; ++i){
      cin >> x;
      if(i%2 == 0) OddNumber(data, x);
      else EvenNnumber(data, x);
    }

    for(i=0, count=0; i<data.size(); ++i){
      if(data[i].x == 0)
	count += data[i].count;
    }

    cout << count << endl;
    data.clear();
  }
  return 0;
}

void OddNumber(vector<DATA>& data, int x){
  DATA _data;
  if(data.size() != 0 && x == data[data.size()-1].x){
    ++data[data.size()-1].count;
  }else{
    _data.x = x;
    _data.count = 1;
    data.push_back(_data);
  }
}

void EvenNnumber(vector<DATA>& data, int x){
  if(x == data[data.size()-1].x){
    ++data[data.size()-1].count;
  }else if(data.size() == 1){
      data[data.size()-1].x = x;
      ++data[data.size()-1].count;
  }else{
    data[data.size()-2].count += (data[data.size()-1].count + 1);
    data.pop_back();
  }
}

Measured memory_bytes: 908
import sys
import collections
import itertools
import math

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    N = int(input())
    S = input().strip()

    MOD = 10 ** 9 + 7

    c = collections.Counter(S)

    ans = 1
    for i in range(0, 27):
        ans *= c[chr(i + ord('a'))] + 1

    ans -= 1

    print(ans % MOD)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3572
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <queue>
using namespace std;
#define loop(i,N) for(ll (i)=0; (i)<(N);++(i))
struct TEMP_OMAZINAI_ { TEMP_OMAZINAI_() { std::ios::sync_with_stdio(false); std::cin.tie(0); } } TEMP__omazinai_instance__;
#define INF ((1LL<<61) + (1<<29))
#define YesNo(x) {std::cout << ((x)?"Yes":"No") << std::endl;}
#define YESNO(x) {std::cout << ((x)?"YES":"NO") << std::endl;}
#define OddEven(x) {std::cout << ((x)%2?"Odd":"Even") << std::endl;}
#define ODDEVEN(x) {std::cout << ((x)%2?"ODD":"EVEN") << std::endl;}
typedef long long int ll;
ll my_gcd(ll a, ll b) { return b ? my_gcd(b, a%b) : a; };
void TEMP_INPUT_IMPL_() {};
template <class T, class... Args> void TEMP_INPUT_IMPL_(T& dest, Args&... args) { cin >> dest; TEMP_INPUT_IMPL_(args...); }
void TEMP_OUTPUT_IMPL_() {};
template <class T, class... Args> void TEMP_OUTPUT_IMPL_(T dest, Args... args) { cout << dest << (sizeof...(Args) ? " " : ""); TEMP_OUTPUT_IMPL_(args...); }
#define in(type, ...) type __VA_ARGS__; TEMP_INPUT_IMPL_(__VA_ARGS__)
#define in_v(type, name, cnt) vector<type> name(cnt); loop(i, cnt) cin >> name[i];
#define sort_v(v) std::sort(v.begin(), v.end())
#define unique_v(v) v.erase(std::unique(v.begin(), v.end()), v.end()) //必ずソート後に実行
#define out(...) (TEMP_OUTPUT_IMPL_(__VA_ARGS__), std::cout<<std::endl)
#define set_fix(x) ((std::cerr<<std::fixed<<std::setprecision(x)),(std::cout<<std::fixed<<std::setprecision(x)))
//小さい方に寄る
#define space_op(x, y, a, b, c) ([](auto x_, auto y_, auto a_, auto b_, auto c_){if(x_<y_)return a_;if(x_>y_)return c_;return b_;}(x,y,a,b,c))
#define space_out(x, y, a, b, c) out(space_op(x, y, a, b, c))
 
 // ^^^ Template ^^^ //

int main() {
	in(string, x);
	int a = x[0]-'0'
	  , b = x[1]-'0'
	  , c = x[2]-'0'
	  , d = x[3]-'0';
	loop(t, 16){
		if(((t&1)?a:a)+((t&2)?b:-b)+((t&4)?c:-c)+((t&8)?d:-d) == 7){
			cout << a
			     << (t&2?'+':'-') << b
			     << (t&4?'+':'-') << c
			     << (t&8?'+':'-') << d
				 << "=7" << endl;
			return 0;
		}
	}
}



Measured memory_bytes: 256
import java.io.*;
import java.util.*;

class Solver {
  public long solve(long[] as) {
    HashMap<Long, Long> map = new HashMap<>();
    
    map.put(0L, 1L);
    long sum = 0;
    for (int i = 0; i < as.length; i++) {
      sum += as[i];
      map.put(sum, map.getOrDefault(sum, 0L) + 1);
    }
    
    long answer = 0;
    for (long count : map.values()) {
      answer += count * (count - 1) / 2;
    }
    return answer;
  }
}

public class Main {
  private static void execute(ContestReader reader, PrintWriter out) {
    int n = reader.nextInt();
    long[] as = reader.nextLongArray(n);
    out.println(new Solver().solve(as));
  }
  
  public static void main(String[] args) {
    ContestReader reader = new ContestReader(System.in);
    PrintWriter out = new PrintWriter(System.out);
    execute(reader, out);
    out.flush();
  }
}

class ContestReader {
  private BufferedReader reader;
  private StringTokenizer tokenizer;
  
  ContestReader(InputStream in) {
    reader = new BufferedReader(new InputStreamReader(in));
  }
  
  public String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }
  
  public int nextInt() {
    return Integer.parseInt(next());
  }
  
  public long nextLong() {
    return Long.parseLong(next());
  }
  
  public double nextDouble() {
    return Double.parseDouble(next());
  }
  
  public int[] nextIntArray(int n) {
    int[] array = new int[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextInt();
    }
    return array;
  }
  
  public long[] nextLongArray(int n) {
    long[] array = new long[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextLong();
    }
    return array;
  }
}

class Algorithm {
  private static void swap(Object[] list, int a, int b) {
    Object tmp = list[a];
    list[a] = list[b];
    list[b] = tmp;
  }
  
  public static <T extends Comparable<? super T>> boolean nextPermutation(T[] ts) {
    int rightMostAscendingOrderIndex = ts.length - 2;
    while (rightMostAscendingOrderIndex >= 0 &&
        ts[rightMostAscendingOrderIndex].compareTo(ts[rightMostAscendingOrderIndex + 1]) >= 0) {
      rightMostAscendingOrderIndex--;
    }
    if (rightMostAscendingOrderIndex < 0) {
      return false;
    }
    
    int rightMostGreatorIndex = ts.length - 1;
    while (ts[rightMostAscendingOrderIndex].compareTo(ts[rightMostGreatorIndex]) >= 0) {
      rightMostGreatorIndex--;
    }
    
    swap(ts, rightMostAscendingOrderIndex, rightMostGreatorIndex);
    for (int i = 0; i < (ts.length - rightMostAscendingOrderIndex - 1) / 2; i++) {
      swap(ts, rightMostAscendingOrderIndex + 1 + i, ts.length - 1 - i);
    }
    return true;
  }
}



Measured memory_bytes: 49104
#include <bits/stdc++.h>
using namespace std;
int dividable(int n){
	int count = 0;
	while(true){
		if (n %2 == 0) {count++; n=n/2;}
		else break;
	}
	return count;
}
int main(){
	
	int n, a, minimum=1e9;
	cin >> n;
	for (int i = 0; i<n; i++){
		cin >> a;
		minimum = min(dividable(a),minimum);
	}
	cout << minimum;
}



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

#define INF_LL 1e18
#define INF 1e9

#define REP(i, n) for(int i = 0;i < (n);i++)
#define FOR(i, a, b) for(int i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()

using namespace std;

using ll = long long;
using PII = pair<int, int>;

template<typename T>
void chmax(T &a, T &b){
	a = max(a, b);
}

template<typename T>
void chmin(T &a, T &b){
	a = min(a, b);
}

class Union_find{
private:
	vector<int> par;
	vector<int> rank;
	int n;

public:
	Union_find(int a){
		n = a;
		for(int i = 0;i < n;i++){
			par.push_back(i);
			rank.push_back(0);
		}
	}

	int find(int x){
		if(par[x] == x){
			return x;
		}else{
			return par[x] = find(par[x]);
		}
	}

	void unite(int x, int y){
		x = find(x);
		y = find(y);
		if(x == y) return;

		if(rank[x] < rank[y]){
			par[x] = y;
		}else{
			par[y] = x;
			if(rank[x] == rank[y]) rank[x]++;
		}
	}

	bool same(int x, int y){
		return find(x) == find(y);
	}
};

int f(ll a, ll b){
	int na = 0, nb = 0;
	while(a > 0){
		na++;
		a/=10;
	}
	while(b > 0){
		nb++;
		b/= 10;
	}
	return max(na, nb);
}

ll comb[51][51] = {};
int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, A, B;
	cin >> N >> A >> B;
	vector<ll> v;
	ll ave = 0;
	REP(i, N){
		ll a;
		cin >> a;
		v.push_back(a);
	}
	comb[0][0] = 1;
	REP(i, 51){
		comb[i][0] = 1;
		comb[i][i] = 1;
	}
	FOR(i, 1, 51){
		FOR(j, 1, i){
			comb[i][j] = comb[i-1][j-1]+comb[i-1][j];
		}
	}
	sort(all(v), greater<ll>());
	vector<ll> kind;
	int num = 0;
	REP(i, A){
		ave += v[i];
		if(kind.empty() || kind[kind.size()-1] != v[i]){
			kind.push_back(v[i]);
			num = 1;
		}else{
			num++;
		}
	}
	int num_ok = 0;
	REP(i, N){
		if(v[i] == kind[kind.size()-1])
			num_ok++;
	}
	cout << fixed  << setprecision(10) << double(ave)/A << endl;
	ll pat = 0;
	if(kind.size() > 1)
		pat += comb[num_ok][num];
	else{
		REP(i, min(num_ok-num+1, B-A+1)){
			pat += comb[num_ok][num+i];
		}
	}
	cout << pat << endl;
}


Measured memory_bytes: 256
import java.util.*;
import javax.lang.model.util.ElementScanner6;
import java.lang.Math;

public class Main {

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

        // 入力
        //int n = sc.nextInt();
        String n = sc.next();

        // 処理
        char m = n.charAt(n.length()-1);
        String out = "";
        switch(m) {
        case '2':
        case '4':
        case '5':
        case '7':
        case '9':
            out = "hon";
            break;
        case '3':
            out = "bon";
            break;
        default:
            out = "pon";
        }

        // 出力
        System.out.println(out);
    }
}


Measured memory_bytes: 35652
A, B, C, D = map(int, input().split())
def gcd(a, b):
    while b: 
      a, b = b, a % b
    return a

def calc(n):
    return n-n // C-n // D+n // (C*D//gcd(C, D))

print(calc(B) - calc(A-1))

Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();
// freopen("input.txt", "r", stdin);

ll round_up(ll num, ll r) {
    ll up = 1 + (num-1) / r;
    return up*r;
}

int main() {
    int n;
    ll a, b, a2, b2;
    cin >> n >> a >> b;
    for(int i = 1; i < n; i++) {
        cin >> a2 >> b2;
        ll ab_gcd = __gcd(a2, b2); // avoid overflow
        ll a2_reduct = a2 / ab_gcd;
        ll b2_reduct = b2 / ab_gcd;
        if (a2 == b2) {
            a = b = max(a, b);
        } else if (a2 < b2) {
            a = round_up(a, a2);
            ll tmp_b = (a / a2_reduct) * b2_reduct;
            if (tmp_b >= b) {
                b = tmp_b;
            } else {
                b = round_up(b, b2);
                a = (b/ b2_reduct) * a2_reduct;
            }
        } else {
            b = round_up(b, b2);
            ll tmp_a = (b/ b2_reduct) * a2_reduct;
            if (tmp_a >= a) {
                a = tmp_a;
            } else {
                a = round_up(a, a2);
                b = (a / a2_reduct) * b2_reduct;
            }
        }
        //cout << a << " " << b << endl;
    }
    cout << (a+b) << endl;
    return 0;
}




Measured memory_bytes: 256
program main
  implicit none
  integer :: N
  integer,allocatable :: X(:)
  integer :: mdist
  integer :: dist
  integer :: i,j
  read(*,*) N
  allocate( X(N) )
  read(*,*) X(:)
  mdist = 100**2*N
  do i = 1,maxval(X)
     dist = 0
     do j = 1, N
        dist = dist + (X(j)-i)**2
     end do
     if ( mdist > dist ) then
        mdist = dist
     end if
  end do
  write(*,'(i0)') mdist
  deallocate( X )
end program main


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

using ll = long long;

ll upper_bound(const vector<int>& stones)
{
    if (stones.size() == 1) return 0;
    const auto max = *max_element(begin(stones), end(stones));
    const auto sum = accumulate(begin(stones), end(stones), 0LL);
    if (max >= sum-max) return sum-max;
    else return sum/2;
}

int main()
{
    int N; cin >> N;

    auto stones = vector<int>(N);
    for (auto& x : stones) cin >> x;

    if (N == 2)
    {
        cout << (stones[0] == stones[1] ? "YES" : "NO") << endl;
        return 0;
    }

    auto adjacency_list = vector<vector<int>>(N);
    for (auto i = 0; i < N-1; i++)
    {
        int a, b; cin >> a >> b;
        a--; b--;
        adjacency_list[a].push_back(b);
        adjacency_list[b].push_back(a);
    }

    const function<bool(int, int)> dfs = [&](const int v, const int parent)
    {
        if (adjacency_list[v].size() == 1) return true;

        auto counts = vector<int>();
        for (auto child : adjacency_list[v]) if (child != parent)
        {
            if (!dfs(child, v)) return false;
            else counts.push_back(stones[child]);
        }

        const auto sum = accumulate(begin(counts), end(counts), 0LL);
        const auto a = sum - stones[v], b = 2*stones[v] - sum;
        stones[v] = int(b);
        return 0 <= a && a <= upper_bound(counts) && 0 <= b;
    };

    auto root = 0;
    while (adjacency_list[root].size() == 1) root++;
    cout << (dfs(root, -1) && stones[root] == 0 ? "YES" : "NO") << endl;
}


Measured memory_bytes: 16768
import java.io.*
import java.util.*

fun solve(N: Int, a: IntArray){
    val ag = a.groupBy{ it }
    var ans = 0
    for (map in ag){
        val quantity = map.value.size
        val k = map.key
        when{
            k > quantity -> { ans += quantity }
            k < quantity -> { ans += quantity - k }
            else -> {}
        }
    }
    println(ans)
    return
}


fun main(args: Array<String>) {
    fun StringArray(size: Int, init: (Int) -> String = { "\u0000" }): Array<String> {
        return Array<String>(size, init)
    }
    class Scanner(stream: InputStream) {
        private val reader = BufferedInputStream(stream).bufferedReader()
        private var st: StringTokenizer? = null
        fun next(): String {
            while (!(st?.hasMoreTokens() ?: false)) st = StringTokenizer(reader.readLine())
            return st!!.nextToken()
        }
    }
    val sc = Scanner(System.`in`)
    val N = sc.next().toInt()
    val a = IntArray(N)
    for (i in 0 until N) {
        a[i] = sc.next().toInt()
    }
    solve(N, a)
}



Measured memory_bytes: 47760
n,k = map(int,input().split())
ALL=[]
for i in range(k):
    d=int(input())
    A = list(map(int,input().split()))
    for ii in range(d):
        ALL.append(A[ii])
ans=list(set(list(range(1,n+1))) - set(ALL))
print(len(ans))

Measured memory_bytes: 67632
def patti(level):
    return 2 ** (level + 1) - 1


def burger(level):
    return 2 ** (level + 2) - 3


def get_ans(level, x, num_patti):
    if level == 0:
        return num_patti + x

    if x == 1 or x == 0:
        return num_patti
    elif x < 1 + burger(level - 1):
        x -= 1
        return get_ans(level - 1, x, num_patti)
    elif x == 1 + burger(level - 1):
        return patti(level - 1) + num_patti
    elif x == 1 + burger(level - 1) + 1:
        return patti(level - 1) + num_patti + 1
    elif x < 1 + burger(level - 1) + 1 + burger(level - 1):
        x -= 1 + burger(level - 1) + 1
        num_patti += 1 + patti(level - 1)
        tmp = get_ans(level - 1, x, num_patti)
        return tmp
    else:
        return num_patti + patti(level - 1) * 2 + 1


n, x = map(int, input().split())

print(get_ans(n, x, 0))

Measured memory_bytes: 3064
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub


import sys
# sys.setrecursionlimit(10**6)
# buff_readline = sys.stdin.buffer.readline
buff_readline = sys.stdin.readline
readline = sys.stdin.readline

INF = 2**62-1


def read_int():
    return int(buff_readline())


def read_int_n():
    return list(map(int, buff_readline().split()))


def read_float():
    return float(buff_readline())


def read_float_n():
    return list(map(float, buff_readline().split()))


def read_str():
    return readline().strip()


def read_str_n():
    return readline().strip().split()

def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N):
    N = int(str(N)[-1])
    if N in {2, 4, 5, 7, 9}:
        return 'hon'
    elif N in {0, 1, 6, 8}:
        return 'pon'
    return 'bon'


def main():
    N = read_int()
    print(slv(N))


if __name__ == '__main__':
    main()


Measured memory_bytes: 83724
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <bitset>
#include <random>
#include <chrono>
#include <complex>
#include <algorithm>
#include <utility>
#include <functional>
#include <cmath>
#include <cstring>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iomanip> 

using namespace std;

#define mp make_pair
#define pb push_back
#define forn(i, n) for(int i = 0; i < (int)(n); ++i)
#define for1(i, n) for(int i = 1; i < (int)(n); ++i)
#define nfor(i, n) for(int i = int(n) - 1; i >= 0; --i)
#define fore(i, l, r) for(int i = int(l); i < int(r); ++i)
#define correct(x, y, n, m) (0 <= x && x < n && 0 <= y && y < m)
#define all(x) (x).begin(), (x).end()
#define fst first
#define snd second
#define endl "\n"

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef long double ld;
typedef tuple<int,int,int> iii;

template<typename T> inline T abs(T a){ return ((a < 0) ? -a : a); }
template<typename T> inline T sqr(T a){ return a * a; }
template<class T> T gcd(T a, T b) { return a ? gcd (b % a, a) : b; }
template<class T> T lcm(T a, T b) { return a / gcd (a, b) * b; }
template<class T> T sign(T a) { return a > 0 ? 1 : (a < 0 ? -1 : 0); }

string to_string(string s) {
    return '"' + s + '"';
}
    
string to_string(const char* s) {
    return to_string((string) s);
}
    
string to_string(bool b) {
    return (b ? "true" : "false");
}
    
template <typename A, typename B>
string to_string(pair<A, B> p) {
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
    
template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for (const auto &x : v) {
        if (!first) {
            res += ", ";
        }
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}

void fastIO() {
    cin.sync_with_stdio(false);
    cin.tie(0);
}

template<typename T>
vector<T> make_unique(vector<T> v) {
    sort(all(v));
    return v.resize(unique(all(v)) - v.begin());
}

int nxt() {
    int x;
    cin >> x;
    return x;
}

const int dx[4] = {0, 0, 1, -1};
const int dy[4] = {1, -1, 0, 0};
const int dxKn[8] = {-2, -1, 1, 2,  2,  1, -1, -2};
const int dyKn[8] = { 1,  2, 2, 1, -1, -2, -2, -1};
const int dxK[8] = {0, 0, 1, -1, 1, 1, -1, -1};
const int dyK[8] = {1, -1, 0, 0, 1, -1, 1, -1};

const int MOD = int(1e9) + 7;
const int INF = int(1e9) + 100;
const ll INF64 = 2e18;
const ld PI = ld(3.1415926535897932384626433832795);
const ld e = ld(2.7182818284590452353602874713527);
const ld EPS = 1e-9;

//#############################
const int MAXN = 1000005;

int main() {
    fastIO(); 
    int x;
    forn(i,5){
        cin >> x;
        if (x == 0)
            cout << i+1 << endl;
    }

    return 0;
}

Measured memory_bytes: 3640
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("Failed to read bytes") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: usize = read();
    let a: Vec<usize> = (0..n).map(|_| read()).collect();
    let m: usize = read();
    let mut tmp = Vec::new();
    for bit in 0..1 << n {
        let mut sum = 0;
        for i in 0..n {
            if bit & 1 << i == 1 << i {
                sum += a[i];
            }
        }
        tmp.push(sum);
    }
    for _ in 0..m {
        if tmp.contains(&read()) {
            println!("yes");
        } else {
            println!("no");
        }
    }
}


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

int main() {
  int A,B;
  cin >> A>>B;
  int ans=0;
  for (int a=1;a < 10;a ++) {
    for (int b=0;b<10;b++) {
      for (int c=0;c<10;c++) {
        int x=10001*a+1010*b+100*c;
        if (A<=x&&x<=B) ans ++;
      }
    }
  }
  cout << ans << endl;
}

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

using LL = long long;

#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define FOR(i, a, b) for (int(i) = (a); (i) < (b); ++(i))
#define RFOR(i, a, b) for (int(i) = (a); (i) > (b); --(i))
#define SORT(x) sort(ALL((x)))
#define RSORT(x) sort(RALL((x)))
#define SZ(x) (int)(x).size()
#define debug(x) cerr << #x << " : " << x << '\n'

const int INF = 1e9;
const int MOD = 1e9 + 7;
const LL LINF = 1e18;

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

  LL ans;
  int W, a, b;
  cin >> W >> a >> b;

  if(a < b){
    if(a + W < b){
      ans = b - (a + W);
    } else {
      ans = 0;
    }
  } else {
    if(b + W < a){
      ans = a - (b + W);
    } else {
      ans = 0;
    }
  }

  cout << ans << '\n';

  return 0;
}

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

typedef long long ll;
typedef pair<int,int> p_int;
typedef pair<ll,ll> p_ll;
typedef tuple<ll,ll,ll> t3_ll;
int dx[] = {-1,0,1,0},dy[] = {0,1,0,-1};
int prime[] = {2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97};

int main() {
	int n;
	cin >> n;
	int pri[25];
	int nago = 0;
	int nigo = 0;
	int igo = 0;
	int go=0;
	int san=0;
	int ans = 0;
	for (int i = 0;i < 25;i++) {
		pri[i] = 0;
		int x = n;
		int cnt = 0;
		while (x != 0) {
			pri[i] += x / prime[i];
			x /= prime[i];
			cnt++;
		}
		pri[i]++;
		if (pri[i] >= 75) {
			nago++;
		} else if (pri[i] >= 25) {
			nigo++;
		} else if (pri[i] >= 15) {
			igo++;
		} else if (pri[i] >= 5) {
			go++;
		} else if (pri[i] >= 3) {
			san++;
		}
	}
	ans += nago;
	ans += (igo + nigo + nago) * (go + igo + nigo + nago - 1);
	ans += (nigo + nago) * (san + go + igo + nigo + nago - 1);
	ans += (go + igo + nigo + nago) * (go + igo + nigo + nago - 1) / 2 * (san + go + igo + nigo + nago - 2);
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <algorithm>

using namespace std;

int n, k;
int h[100021];
int dp[100021];

int main() {
    scanf("%d%d", &n, &k);
    for (int i = 1; i <= n; ++i)
        scanf("%d", &h[i]);
    for (int i = 2; i <= n; ++i) {
        dp[i] = 0x3f3f3f3f;
        for (int j = max(1, i - k); j < i; ++j) {
            dp[i] = min(dp[i], dp[j] + abs(h[i] - h[j]));
        }
    }
    printf("%d\n", dp[n]);
    return 0;
}

Measured memory_bytes: 896
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
struct node{
	int s,c;
}a[10];
int main(){
	int n,m,ans[10][2],flag=0,t=0;
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++){
		scanf("%d%d",&a[i].s,&a[i].c);
	}
	memset(ans,0,sizeof(ans));
	for(int i=1;i<=m;i++){
		if(ans[a[i].s][0]==0){
			ans[a[i].s][0]=1;
			ans[a[i].s][1]=a[i].c;
			t++;
		}
		else{
			if(ans[a[i].s][1]!=a[i].c){
				flag=1;
				break;
			}
		}
	}
	if(flag==1||t>n){
		printf("-1\n");
	}
	else{
		if(n==1){
			if(ans[1][0]==1){
				printf("%d\n",ans[1][1]);
			}
			else{
				printf("0\n");
			}
		}
		else{
			if(ans[1][0]==1&&ans[1][1]==0){
				printf("-1\n");
			}
			else{
				if(ans[1][1]==0){
					ans[1][1]=1;
				}
				for(int i=1;i<=n;i++){
					printf("%d",ans[i][1]);
				}
				printf("\n");
			}
		}
	}
	return 0;
}

Measured memory_bytes: 888
#include <iostream>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#define endl "\n"
using namespace std;

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

    int i;
    string s[n];
    for(i = 0; i < n; i ++)
    {
    	cin >> s[i];
    	cout << s[i] << endl;
    	cout << s[i] << endl;
    }
}

Measured memory_bytes: 256