akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define maxn 2510
struct arr
{
	int x,y;
	bool operator <(const arr &a) const
	{
		if (x!=a.x) return x<a.x;
			else return y<a.y;
	}
}a[maxn],b[maxn];
int n,m=0,i,j,ans=0,s=0;
int main()
{
	scanf("%d",&n);
	for (i=1;i<=n;i++)
		scanf("%d%d",&a[i].x,&a[i].y);
	for (i=1;i<=n;i++)
		for (j=i+1;j<=n;j++)
		{
			b[++m].x=a[i].x-a[j].x;
			b[m].y=a[i].y-a[j].y;
			if ((b[m].x<0) || ((b[m].x==0) && (b[m].y<0))) b[m].x=-b[m].x,b[m].y=-b[m].y;
		}
	sort(b+1,b+m+1);
	for (i=1;i<=m;i++)
	{
		if ((b[i].x==b[i-1].x) && (b[i].y==b[i-1].y)) s++;
			else s=1;
		if (s>ans) ans=s;
	}
	printf("%d\n",n-ans);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <cmath>
#define ll long long
using namespace std;

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

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

const int INF = 1LL << 30;

int main()
{
  int N, K;
  cin >> N >> K;
  vector<int> h(N);
  for (int i = 0; i < N; i++)
  {
    cin >> h[i];
  }

  vector<int> cost(N, INF);
  cost[0] = 0;

  for (int i = 1; i < N; i++)
  {
    for (int j = 1; j <= min(K, i); j++)
    {
      chmin(cost[i], cost[i - j] + abs(h[i] - h[i - j]));
    }
  }

  cout << cost[N - 1] << endl;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>
#define ref goto refrain
int main(){
	char a;
	int b=0,flag=0;
	refrain:
	scanf("%c",&a);
	if(flag==0&&a=='0') return 0;
	else if(a=='\n'){
		printf("%d\n",b);
		b=0;
		flag=0;
		ref;
	}
	flag=1;
	b+=atoi(&a);
	ref;
}

Measured memory_bytes: 548
#include<bits/stdc++.h>
using namespace std;
int a[200007];
int b[200007];
long long dp[200007];
long long sum[200007];
const long long mod =1e9+7;
int main(){
    dp[0]=1;
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        scanf("%d",&a[i]);
    int cnt=0;
    for(int i=1;i<=n;i++) {
		if(a[i]!=a[i-1])
            b[++cnt]=a[i];
	}
	for(int i=1;i<=cnt;i++){
        dp[i]=dp[i-1];
        dp[i]=(dp[i]+sum[b[i]])%mod;
        sum[b[i]]=(sum[b[i]]+dp[i-1])%mod;
	}
	printf("%lld",dp[cnt]);
    return 0;
}


Measured memory_bytes: 4992
import java.util.ArrayList;
import java.util.Scanner;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
 
        // 人々の座標
        int n;
        n = sc.nextInt();
        ArrayList<Integer> persons = new ArrayList<>();
 
        for (int i = 0; i < n; i++) {
            persons.add(sc.nextInt());
        }
 
        int target = 0;
        // 点Pの算出
        int min = 100;
        int max = 0;
 
        // min
        for (int i = 0; i < persons.size(); i++) {
            if (persons.get(i) <= min) {
                min = persons.get(i);
            }
        }
 
        // max
        for (int i = 0; i < persons.size(); i++) {
            if (persons.get(i) >= max) {
                max = persons.get(i);
            }
        }
 
        int targetMin = 0;
        // 点Pと各座標の算出
        for (int tenP = min; tenP < max; tenP++) {
        	target =0;
            for (int i = 0; i < persons.size(); i++) {
                target = target + (persons.get(i) - tenP) * (persons.get(i) - tenP);
            }
            if(tenP == min) {
              targetMin = target;
            }else if(targetMin > target) {
            	targetMin = target;
            }
        }
 
        System.out.println(targetMin);
    }
}

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

int main(){
  long long int N,A,B;
  cin>>N>>A>>B;
  if(A==0)cout<<0<<endl;
  else if(N%(A+B)<A)cout<<N/(A+B)*A+N%(A+B)<<endl;
  else cout<<N/(A+B)*A+A<<endl;
}




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

int main(){
vector<int> K(32);
K = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
int i;
cin >> i;
cout << K[i-1] << endl;

}

Measured memory_bytes: 256
n = int(input())
s=""
i = 1
if n == 0:
    print(0)

else:
    while n != 0:
        if n % ((-2)**i) == 0:
            s = "0" + s
        else:
            s = "1" + s
            n -= (-2)**(i-1)
        i += 1
    print(s)

Measured memory_bytes: 2940
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
using LL = long long;
int main()
{
	//freopen("..//data.in", "r", stdin);
	//freopen("..//data.out", "w", stdout);

	LL n;
	scanf("%lld", &n);

	LL sum = 0;
	for (int i = 1; i <= n; ++i)
	{
		if (!(i % 3 == 0 || i % 5 == 0))
			sum += i;
	}

	printf("%lld\n", sum);


	return 0;
}

Measured memory_bytes: 3828
#include <cstdio>
#include <iostream>
#define mod 1000000007
using namespace std;

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

int a[4003];
int main() {
    int n = read(), k = read();
    int res1 = 0, res2 = 0;
    for (int i = 1; i <= n; ++i) a[i] = read();
    for (int i = 1; i <= n; ++i) {
        for (int j = i + 1; j <= n; ++j) {
            if (a[i] > a[j]) res1++;
        }
        for (int j = 1; j <= n; ++j)
            if (a[i] > a[j]) res2++;
    }
    res1 = 1ll * res1 * k % mod;
    res2 = 1ll * k * (k - 1) / 2 % mod * res2 % mod;
    printf("%d\n", (res1 + res2) % mod);
    return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <cassert>
#include <memory>
#include <time.h>
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
const double EPS = 1e-9;
const double PI  = acos(-1.0);

vi get_primes(int n){
	vi primes(n);
	for(int i=2;i<n;i++)
		primes[i]=i;
	for(int i=2;i*i<n;i++)
		if(primes[i])
			for(int j=i*i;j<n;j+=i)
				primes[j]=0;
	return primes;
}

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

struct node{
	int cnt,last;
	node():cnt(0),last(0){}
	node(int cnt,int last):cnt(cnt),last(last){}
	bool operator<(const node &other)const{
		if(cnt==other.cnt){
			return last<other.last;
		}else{
			return cnt<other.cnt;
		}
	}
};

const int MAXSIZE=2000;
int main(){
	int m,n;
	vi primes=get_primes(1000000+10);
	while(cin>>m>>n,m|n){
		vvi f(MAXSIZE,vi(MAXSIZE));
		int cy=MAXSIZE/2,cx=MAXSIZE/2;
		int maxy=INT_MIN,maxx=INT_MIN,miny=INT_MAX,minx=INT_MAX;
		int dist=1,cnt=0,dir=0;
		pii start;
		FOR(num,1,m+1){
			f[cy][cx]=num;
			if(num==n){
				start=make_pair(cy,cx);
			}

			maxy=max(maxy,cy);
			maxx=max(maxx,cx);
			miny=min(miny,cy);
			minx=min(minx,cx);

			cy+=dy[dir];
			cx+=dx[dir];
			cnt++;
			if(cnt==dist){
				dir=(dir+1)%4;
				cnt=0;
				if(dir%2==0){
					dist++;
				}
			}
		}

		vector<vector<node> > dp(MAXSIZE,vector<node>(MAXSIZE,node(-1,-1)));
		int startNum=f[start.first][start.second];
		dp[start.first][start.second]=(primes[startNum]?node(1,startNum):node());
		REP(y,MAXSIZE){
			REP(x,MAXSIZE){
				if(dp[y][x].cnt==-1)continue;
				FOR(dx,-1,2){
					int xx=x+dx;
					int yy=y+1;
					if(yy>=miny&&xx>=minx&&yy<=maxy&&xx<=maxx){
						bool isprime=primes[f[yy][xx]]!=0;
						int ncnt=dp[y][x].cnt+isprime;
						int nlast=(isprime?f[yy][xx]:dp[y][x].last);
						dp[yy][xx]=max(dp[yy][xx],node(ncnt,nlast));
					}
				}
			}
		}

		//REP(i,MAXSIZE){
		//	REP(j,MAXSIZE){
		//		printf("%2d",dp[i][j].cnt);
		//	}
		//	cout<<endl;
		//}

		node ans;
		FOR(x,minx,maxx+1){
			ans=max(ans,dp[maxy][x]);
		}
		cout<<ans.cnt<<" "<<ans.last<<endl;
	}

}

Measured memory_bytes: 52156
#include <stdio.h>

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

    int n, i;
    long money, sum = 0,ave = 0;
    
    scanf("%d", &n);
    
    for (i = 0; i < n; i++) {
        scanf("%ld", &money);
        sum += money;
    }
    
    ave = sum / n;
    
    printf("%ld\n", ave);
    
    return 0;
}

Measured memory_bytes: 596
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
Scanner scan=new Scanner(System.in);
int a=scan.nextInt();
if(a==1) {
	
	System.out.println("Hello World");
}
else if(a==2) {
	int b=scan.nextInt();
	int c=scan.nextInt();
	System.out.println(b+c);
	
}
	}

}

Measured memory_bytes: 22612
#include<iostream>
#include<cmath>
#include<algorithm>
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll GCD(ll a,ll b)
{
	return b==0?a:GCD(b,a%b);
}
int main(){
	int n;
	cin>>n;
	ll sum=1;
	for(int i=0;i<n;i++){
		ll a;
		cin>>a;
		sum=sum/GCD(sum,a)*a;
	}
	cout<<sum<<endl;
} 

Measured memory_bytes: 256
def main():
    n = int(input())
    s = input()

    if n % 2 == 1:
        print("No")
        return

    if s[:len(s)//2] == s[len(s)//2:]:
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#define _USE_MATH_DEFINES
#include  <iostream>
#include  <algorithm>
#include  <climits>
#include  <vector>
#include  <string>
#include  <cstring>
#include  <stack>
#include  <queue>
#include  <cmath>
#include  <iomanip>
#include  <set>
#include  <map>
#include  <new>
#include <cstdint>

using namespace std;
#define rep(i,n)  for(int i = 0; i < n; i++)
#define lrep(i,n,m)  for(int i = n; i < m; i++)

using ll = long long;
using Vii = vector<vector<int> >;
using Gjudge = vector<vector<bool>>;
using Vi = vector<int>;
using Vl = vector<ll>;
using Vs = vector<string>;
using Vb = vector<bool>;
using the = pair<int, int>;

const int Mod = static_cast<int>(1e9 + 7);
const int INF = INT_MAX;
const int dx[4] = { -1,0,1,0 };
const int dy[4] = { 0,1,0,-1 };

int main()
{
	string s;
	cin >> s;
	char c = s[s.size() - 1];
	if (s[s.size() - 1] == '3') {
		cout << "bon" << endl;
	}
	else if (c == '0' || c == '1' || c == '6' || c == '8') {
		cout << "pon" << endl;
	}
	else {
		cout << "hon" << endl;
	}
}


Measured memory_bytes: 3624
/**
*    created: 27.06.2020 17:42:32
**/
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pcnt(bit) __builtin_popcountll(bit)
#define mod 1000000007
#define pi acos(-1.0)
using namespace std;
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return 1;} return 0;}
template<class T> bool chmin(T &a, const T &b) {if (b < a) {a = b; return 1;} return 0;}

signed main() {

    cin.tie(0);
    ios_base::sync_with_stdio(false);

    int n;
    cin >> n;
    int t[100000][3];
    rep(i,n) rep(j,3) cin >> t[i][j];
    int dp[101010][3];
    rep(i,n) {
        rep(j,3) rep(k,3) {
            if (j == k) continue;
            chmax(dp[i+1][k],dp[i][j]+t[i][k]);
        }
    }
    cout << max({dp[n][0], dp[n][1], dp[n][2]}) << endl;
    return 0;
}

Measured memory_bytes: 8232
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <set>
#include <queue>
#include <map>
#include <numeric>
#include <functional>
#include <math.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

#define INF ((int)1e9)
#define INFLL ((ll)1e18)
#define MOD (1000000007LL)


int main(int argc, const char * argv[]) {
    ios_base::sync_with_stdio(false);
    string S;
    cin >> S;
    
    ll Ret = 0;
    int nA = 0;
    for (int l = 0; l < S.length()-1; ++l) {
        if (S[l] == 'A') {
            ++nA;
        } else if (S[l] == 'B' && S[l+1] == 'C') {
            Ret += nA;
            ++l;
        } else {
            nA = 0;
        }
    }
    cout << Ret << endl;

    return 0;
}


Measured memory_bytes: 720
#include<bits/stdc++.h>
#pragma GCC optimize("O2")
using namespace std;
#define F first
#define S second
#define migmig ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long 
#define ld long double
#define pii pair <int ,int >
#define bug(x)  cout<<"passed "<<x<<endl;
#define ashar(x , y , z) cout<<setprecision(x)<<fixed<<y ; if (z==1) cout<<"\n" ;
#define ppi pair <pair <int, int > , int > 
long long const inf = 3e18, linf = 2e9, mod = 1e9+7 , inf2 = 1e12;
int const mxn = 5e5 + 10 ;
 
ll poww(ll a, ll b, ll md) {
    return (!b ? 1 : (b & 1 ? a * poww(a * a % md, b / 2, md) % md : poww(a * a % md, b / 2, md) % md));
}



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



Measured memory_bytes: 3624
import math
A, B, H, M = map(int, input().split())
angle = 6 * ((H * 5) - M) + 0.5 * M
res = math.sqrt(A**2 + B**2 - 2 * A * B * math.cos(math.radians(angle)))
print(format(res, '0<11'))

Measured memory_bytes: 9500
#include <stdio.h>
int main(){
	int a,b;
	scanf("%d %d",&a,&b);
	if(a>=-1000 && b<=1000){
		if(a<b){
			printf("a < b\n");
		}else if(a>b){
			printf("a > b\n");
		}else {
			printf("a == b\n");
		}
	}
	return 0;
}

Measured memory_bytes: 1812
#include<bits/stdc++.h>
using namespace std;
int main(){
    long A,B,K;
    cin >> A >> B >> K;
    long tmp1,tmp2;
    long out1,out2;
    tmp1=K-A;
    if(tmp1>0){
        tmp2=tmp1-B;
        if(tmp2>0){
            out1=0;
            out2=0;
        }else{
            out1=0;
            out2=B-tmp1;
        }
    }else{
        out1=A-K;
        out2=B;
    }
    cout << out1 << " " <<out2 <<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
    using namespace std;
    #define rep(i, n) for (int i = 0; i < (int)(n); i++)
     
    int main() {
      string A;
      cin >> A;
      int ans = 0;
      if (A[0] == '1') {
        ans ++;
      }
      if (A[1] == '1') {
        ans ++;
      }
      if (A[2] == '1') {
        ans ++;
      }
      cout << ans << endl;
	}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
int N,M;
int main(){
	cin >> N >> M;
	int t = M/N;
	int ans = 0;
	for(int i=1;i*i<=M;i++){
		if(M%i==0 && i<=t) ans = max(i,ans);
		if(M%i==0 && M/i<=t) ans = max(M/i,ans);
	}
	cout << ans << endl;
}

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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 62)
#define PI 3.14159265358979

typedef long long i64;
typedef pair<i64,i64> P;

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

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



int n, a[101010];
void solve(){
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	sort(a,a+n,greater<int>());
	
	i64 cnt = 0;
	for(int i = 0; i < n; i++){
		if(a[i] == a[i+1]){
			if(cnt != 0){
				cout << cnt*a[i] << endl;
				return;
			}
			cnt = a[i];
			i++;
		}
	}
	cout << 0 << endl;
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
using namespace std;
int gcd(int n, int m){
    if(n<m) swap(n,m);
    while(n%m!=0){
        int t=m;
        m=n%m;
        n=t;
    }
    return m;
}
signed main(){
    int N,X; cin>>N>>X;
    vector<int> x(N);
    rep(i, N) cin>>x.at(i);
    int ans=abs(x.at(0)-X);
    for(int i=1; i<N; i++){
        ans=gcd(ans, abs(x.at(i)-X));
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 768
'use strict';

function main(input) {
  const lines = input.split('\n');
  const N = parseInt(lines[0]);
  const l = lines[1]
    .split(' ')
    .map(Number)
    .sort((a, b) => a - b);

  const max = l.pop();
  const sum = l.reduce((prev, curr, i, arr) => prev + curr);
  console.log(max < sum ? 'Yes' : 'No');
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 7372
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
#define ll   long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define MAX 100000000000000000
#define MOD 1000000007
#define files  freopen("OUTPUT.TXT","r",stdin);
#define PI 3.141592653589793238462
#define INF 1000000000
using namespace std;
int n,m,i,x,y,z;
bool u[200005];
vector<int> g[200005];
bool tf;
void dfs(int i,int ro)
{
    ro++;
	if(i==n && ro<=3)
    {
    	cout<<"POSSIBLE";
    	tf=true;
	}
	else if(ro>2)
	{
		return;
	}
	u[i]=true;
    z++;
    for(int j=0;j<g[i].size();j++){
        if(!u[g[i][j]])
		{
			dfs(g[i][j],ro);
		}
    }
    return;
}
int main()
{
    cin>>n>>m;
    for(i=0;i<m;i++)
    {
        cin>>x>>y;
        g[x].push_back(y);
        g[y].push_back(x);
    }
    dfs(1,0);
    if(tf==false)
    {
    	cout<<"IMPOSSIBLE";
	}
    system("pause");
    return 0;
}

Measured memory_bytes: 12392
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rep3(i, l, n) for (int i = l; i < n; ++i)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define out(a) cout << a << endl
#define outa(a, n) rep(_, n) cout << a[_] << " "; cout << endl
#define SZ(v) (int)v.size()
#define inf (int)(1e9+7)

int main() {
    int n;
    cin >> n;
    vector<int> v;
    v.eb(0);
    rep(i, n) {
        int a;
        cin >> a;
        v.eb(a);
    }
    v.eb(0);
    int sum = 0;
    rep3(i, 1, SZ(v)) sum += abs(v[i] - v[i - 1]);
    // out(sum);
    rep3(i, 1, n + 1) {
        out(sum - abs(v[i] - v[i - 1]) - abs(v[i + 1] - v[i]) + abs(v[i + 1] - v[i - 1]));
    }
}


Measured memory_bytes: 1784
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int max_n=5005;
int n,a[3],b[3];
ll dp[80000000];
ll solve(int n)
{
    dp[0]=0;
    ll res=n;
    for(int i=0;i<=n;i++)dp[i]=0;
    for(int i=0;i<3;i++)
    {
        for(int j=0;j<=n;j++)
        {
            if(j>=a[i])dp[j]=max(dp[j],dp[j-a[i]]+b[i]);
            res=max(res,dp[j]+n-j);
        }
    }
    return res;
}
int main()
{
    scanf("%d",&n);
    for(int i=0;i<3;i++)scanf("%d",a+i);
    for(int i=0;i<3;i++)scanf("%d",b+i);
    n=solve(n);
    for(int i=0;i<3;i++)swap(a[i],b[i]);
    printf("%lld\n",solve(n));
    return 0;
}


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

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define REP(i, N) FOR(i, 0, N)
#define RREP(i, N) RFOR(i, N, 0)
#define FILL(A,value) memset(A,value,sizeof(A))
#define endl '\n'

#define ALL(V) V.begin(), V.end()
#define SZ(V) (int)V.size()
#define watch(x) cout << (#x) << " is " << (x) << endl
#define pb push_back
#define mp make_pair
#define Pi 3.14159265358979
#define A first
#define B second

typedef long long ll;
typedef vector <int> vi;
typedef vector<ll> vl;
typedef pair <int, int> pi;
typedef pair <ll, int> pl;
typedef pair <ll, ll> pll;
typedef pair <double, double> pd;

//change these according to prob constraints
const int INF = 0x3f3f3f3f;
const int MAX = 100005;
const int MAX1 = 1005;
const int MAX2 = 105;
const int LEN = 105;
const int BASE = 1000000000;
const double EPS = 1e-7;
const int MOD = 1000000007;
//g++ -std=c++11 your_file.cpp -o your_program

ll mypow(ll a, ll b){
	ll ans=1;
	while(b){
		if(b&1)
			ans=(ans*a)%MOD;
		b/=2;
		a=(a*a)%MOD;
	}
	return ans;
}

vi ct[26];
string s, t;

bool check(ll mid){
	int curr = 0;
	ll reps = 0;
	REP(i, SZ(t)){
		int pos = upper_bound(ALL(ct[t[i] - 'a']), curr) - ct[t[i] - 'a'].begin();
		if (pos == SZ(ct[t[i] - 'a'])){
			reps += SZ(s);
			curr = 0;
			pos = 0;
		}
		curr = ct[t[i] - 'a'][pos];
	}
	return (reps + curr) <= mid;
}

int main(void){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ifstream in("");
	ofstream out("");
	clock_t begin = clock();
	cin >> s >> t;
	REP(i, SZ(s)){
		ct[s[i] - 'a'].pb(i + 1);
	}
	REP(i, SZ(t)){
		if (SZ(ct[t[i] - 'a']) == 0) {
			cout << -1 << endl;
			return 0;
		}
	}
	ll lo = 1, mid, hi = (ll)SZ(s) * SZ(t), ans = 1e18;
	while (lo <= hi){
		mid = (lo + hi) / 2;
		if (check(mid)){
			ans = min(mid, ans);
			hi = mid - 1;
		}
		else {
			lo = mid + 1;
		}
	}
	cout << ans << endl;
	clock_t end = clock();
    double esecs = double(end - begin) / CLOCKS_PER_SEC;
    //cout << esecs << " seconds" << endl;
	return 0;	
}

Measured memory_bytes: 1228
N=int(input())
S=[0]*N
for i in range(N):
  S[i]=input()

S.sort()
#print(S)

max_count=0
cur_count=1
cur_str=[]
for i in range(N):
  if i==0:
    max_count=1
    cur_count=1
    cur_str=[S[0]]
  else:
    #S[i-1]
    if S[i]==S[i-1]:
      cur_count+=1
    else:
      cur_count=1
      
    if max_count<cur_count:
      max_count=cur_count
      cur_str=[S[i]]
    elif max_count==cur_count:
      cur_str+=[S[i]]
  #print(cur_str)
  #print(cur_count)
  #print(max_count)

for i in range(len(cur_str)):
  print(cur_str[i])

Measured memory_bytes: 20636
#include <algorithm>
#include <iostream>
#include <vector>
#include <bitset>
#include <set>
using namespace std;

typedef long long ll;
typedef pair <ll, ll> pii;

const ll MAX_N = 4e3 + 6, inf = 1e9 + 7;
string A, B;
bitset <MAX_N> a, b, c, d, Lf[MAX_N], Rt[MAX_N];
vector <pii> seg;
ll n, ans = inf;
pii Arr[MAX_N];
ll mx[MAX_N];

bool cmp (pii a, pii b) {
	return a.second < b.second;
}

int main() {
    ios::sync_with_stdio(false), cin.tie(0);
    cin >> A >> B;
    n = A.size();

    for (ll i = 0; i < n; i++) {
        a[i] = (A[n - i - 1] == '1');
        b[i] = (B[n - i - 1] == '1');
        d[i] = true;
    }
    ll tmp = b.count() + a.count();
    if (b.count() == 0) {
    	if (a.count() == 0)
    		cout << "0\n";
    	else
    		cout << "-1\n";

    	return 0;
    }

    for (ll i = 0; i < n; i++) {
    	ll ind = -1, cnt = 0;
    	for (ll j = i; ~j; j--, cnt++)
    		if (B[j] == '1') {
    			ind = j;
    			break;
    		}

    	if (ind == -1)
    		for (ll j = n - 1; ~j; j--, cnt++)
    			if (B[j] == '1') {
    				ind = j;
    				break;
    			}

    	Arr[i].first = cnt;
    	cnt = 0;
    	ind = -1;
    	for (ll j = i; j < n; j++, cnt++)
    		if (B[j] == '1') {
    			ind = j;
    			break;
    		}

    	if (ind == -1)
    		for (ll j = 0; j < n - 1; j++, cnt++)
    			if (B[j] == '1') {
    				ind = j;
    				break;
    			}

    	Arr[i].second = cnt;
  		if (A[i] == '1')
  			seg.push_back({Arr[i].second, Arr[i].first});
    }

    sort(seg.begin(), seg.end());
    for (ll i = seg.size() - 1; ~i; i--)
    	mx[i] = max(mx[i + 1], seg[i].second);

    for (ll len = 0; len < n; len++) {
    	ll res = inf;
    	for (ll i = len; i < n; i++) {
    		ll ind = upper_bound(seg.begin(), seg.end(), pii(i, inf)) - seg.begin();
    		res = min(res, i + (i - len) + (mx[ind] << 1));
    	}

        c = a;
        c = (c >> len) | ((c << (n - len)) & d);

        res += tmp - ((b & c).count() << 1);
        ans = min(ans, res);
    }

    seg.clear();
    for (int i = 0; i < n; i++)
    	if (A[i] == '1')
    		seg.push_back(Arr[i]);

	sort(seg.begin(), seg.end());
    for (ll i = seg.size() - 1; ~i; i--)
    	mx[i] = max(mx[i + 1], seg[i].second);

    for (ll len = 0; len < n; len++) {
    	ll res = inf;
    	for (ll i = len; i < n; i++) {
    		ll ind = upper_bound(seg.begin(), seg.end(), pii(i, inf)) - seg.begin();
    		res = min(res, i + (i - len) + (mx[ind] << 1));
    	}

        c = a;
        c = ((c << len) & d) | ((c << len) >> n);

        res += tmp - ((b & c).count() << 1);
        ans = min(ans, res);
    }

	cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
#include <math.h>

int main( void ){
	int n,t,a,h;
	int ans,i;
	double tmp,tmp2;

	scanf("%d",&n);
	scanf("%d%d",&t,&a);
	scanf("%d",&h);
	ans=1;
	tmp=t-h*0.006;
	for( i=2;i<=n;i++ ){
		scanf("%d",&h);
		tmp2=t-h*0.006;
		if( fabs(a-tmp)>fabs(a-tmp2) ){
			tmp = tmp2;
			ans = i;
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int k;
    string s;
    cin>>k>>s;
        if(s.size()<=k)
        {
            cout<<s<<endl;
            return 0;
        }
        else{
            cout<<s.substr(0,k)<<"..."<<endl;
        }



}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
long long a,b,n;
long long check(long long x)
{
	return a*x/b-a*(x/b);
}
int main()
{
	cin>>a>>b>>n;
	long long l=0,r=n,ans=0;
	while(r-l>=1000000)
	{
		long long lmid=l+(r-l)/3,rmid=r-(r-l)/3;
		if(check(lmid)<=check(rmid))
			l=lmid;
		else
			r=rmid;
	}
	while(l<=r&&l<=n)
	{
		ans=max(ans,check(l));
		l++;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3572
#include <iostream>
#include <string>

using namespace std;

int main() {
  int n; string s;
  cin >> n >> s;
  
  long long r = 0, g = 0, b = 0;
  for (int i = 0; i < n; ++i)
    if (s[i] == 'R') ++r;
  	else if (s[i] == 'G') ++g;
  	else ++b;
  
  long long ans = r*g*b;
  for (int i = 0; i < n-2; ++i) for (int j = i+1; j < n-1; ++j)
    if (2*j-i < n) {
      if (s[i] == 'R' and s[j] == 'G' and s[2*j-i] == 'B') --ans;
      if (s[i] == 'R' and s[j] == 'B' and s[2*j-i] == 'G') --ans;
      if (s[i] == 'G' and s[j] == 'R' and s[2*j-i] == 'B') --ans;
      if (s[i] == 'G' and s[j] == 'B' and s[2*j-i] == 'R') --ans;
      if (s[i] == 'B' and s[j] == 'R' and s[2*j-i] == 'G') --ans;
      if (s[i] == 'B' and s[j] == 'G' and s[2*j-i] == 'R') --ans;
    }
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3632
n, m = map(int, input().split())
x = list(map(int, input().split()))
x.sort()
l = []
if m<=n:
    print(0)
else:
    for i in range(0, m-1):
        l.append(x[i+1]-x[i])
    l.sort(reverse=True)
    for j in range(n-1):
        del l[0]
    print(sum(l))


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

int a, b;
int main()
{
    cin >> a >> b;
    if (a>=b){
    for (int i=1;i<=a;i++)
    {
        cout << b;
    }
    }
    else if (b>a)
    {
        for (int i=1;i<=b;i++)
            cout << a;
    }
    return 0;
}


Measured memory_bytes: 256
h,w = map(int,input().split())

al = []

for _ in range(h):
    a = list(input())
    al.append(a)
c = 0
job = []
for i in range(h):
    for j in range(w):
        if al[i][j] == "#":
            job.append((i, j))
            c += 1
ans = 0
while True:
    if c == h*w:
        print(ans)
        import sys
        sys.exit()
    ans += 1
    job2 = []
    for y, x in job:
        vec = [(-1, 0), (1, 0), (0, 1), (0, -1)]
        for v in vec:
            xx = v[0] + x
            yy = v[1] + y
            if 0 <= xx < w and 0 <= yy < h:
                if al[yy][xx] == ".":
                    al[yy][xx] = "#"
                    job2.append((yy,xx))
                    c += 1
    job = job2
            



Measured memory_bytes: 127916
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#include <cmath>
#include <queue>
#include <tuple>
#include <set>
#include <assert.h>
#include <sstream>
#include <string>
//#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>

#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i,i0,n) for(int (i)=(i0);(i)<(n);(i)++)
#define FORR(i,i0,n) for(int (i)=(n)-1; (i)>=(i0);(i)--)
#define SORT(x) sort(x.begin(),x.end())
#define SORTR(x) sort(x.begin(),x.end(),greater <>())
#define rn return
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple

using namespace std;
using ll = long long;
using P = std::pair<int,int>;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vvP = vector<vector<P>>;
using vP = vector<P>;
//using bint = boost::multiprecision::cpp_int;



// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    
    // for prime mod
    mint inv() const {
        return pow(mod-2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res/=a;
    }
};
// combination mod prime
struct combination {
    vector<mint> fact, ifact;
    combination(int n):fact(n+1),ifact(n+1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n]*ifact[k]*ifact[n-k];
    }
};




int main(){
    
    int n,k;
    cin >> n >> k;
    if (k>=n) { cout << 0; rn 0;}
    vi h(n);
    rep(i,n) cin >> h[i];
    SORTR(h);
    rep(i,k){
        h[i] = 0;
    }
    ll sum  =0;
    FOR(i,k,n){
        sum+= h[i];
    }
    
    cout << sum;
}



Measured memory_bytes: 1024
N = int(input())
polls = {}
for i in range(N):
  s = input()
  if s in polls:
    polls[s] += 1
  else:
    polls[s] = 1

max_count = max(polls.values())

results = []

for s in polls:
  if polls[s] == max_count:
    results.append(s)

results.sort()

for res in results:
  print(res)

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

#define MAXN 11

int n , m , k ;
string a[ MAXN ] ;

void input ( ) {
    cin >> n >> m >> k ;
    for ( int i = 0 ; i < n ; ++ i ) {
        cin >> a[ i ] ;
    }
}

void solve ( ) {
    int ans = 0 ;
    for ( int i = 0 ; i < (1<<n) ; ++ i ) {
        for ( int j = 0 ; j < (1<<m) ; ++ j ) {
            int cnt = 0 ;
            for ( int t = 0 ; t < n ; ++ t ) {
                for ( int z = 0 ; z < m ; ++ z ) {
                    if ( ( (1<<t) & i ) == 0 && ( (1<<z) & j ) == 0 ) {
                        cnt += ( a[ t ][ z ] == '#' ) ;
                    }
                }
            }
            if ( cnt == k ) { ++ ans ; }
        }
    }
    cout << ans << "\n" ;
}


int main ( ) {
    ios_base :: sync_with_stdio ( false ) ;
    cin.tie ( NULL ) ;
    input ( ) ;
    solve ( ) ;
    return 0 ;
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
int main(){
    int n;
    cin>>n;
    vector<string> s(n);
    rep(i,n) cin>>s[i];
    rep(i,n) sort(s[i].begin(),s[i].end());
    map<string,ll> B;
    rep(i,n) B[s[i]]++;
    ll ans=0,a;
    for(auto i=B.begin();i!=B.end();i++) a=i->second,ans+=a*(a-1)/2;
    cout<<ans;
}

Measured memory_bytes: 18176
// https://atcoder.jp/contests/abcXXX/tasks/abcXXX_x

#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using ull = unsigned long long;
using pll = pair<ll, ll>;

static const ll INF = 1001001001;
static const ll LLINF = 1001001001001001001;
static const ll MOD = (ll)1e9 + 7;
static const double EPS = 1e-9;

#define REP(i, n) for(ll i = 0; i < static_cast<ll>(n); ++i)
#define RANGE(i, m, n) for(ll i = (m); i <= static_cast<ll>(n); ++i)
#define RRANGE(i, m, n) for(ll i = static_cast<ll>(m); i >= static_cast<ll>(n); --i)
#define POSITIVE(x) (x)=((x) < 0) ? 0 : (x)

ll power(ll x, ll y) {
    ll ret = 1;
    while(y-- > 0) ret *= x;
    return ret;
}

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

ll extgcd(ll a, ll b, ll& x, ll& y) {
    x = 1; y = 0;
    assert(a >= 0);
    assert(b >= 0);
    if (b == 0) return a;
    ll X, Y;
    auto d = extgcd(b, a % b, X, Y);
    x = Y;
    y = X - (a / b) * Y;
    return d;
}

ll dx[4] = {0, 1, 0, -1};
ll dy[4] = {-1, 0, 1, 0};

struct vis {
    ll x_;
    ll y_;
    ll count_;
};

auto comp = [] (vis const& a, vis const& b) {
    return a.count_ > b.count_;
};

int run(istream& in, ostream& out) {
    ll H, W, Ch, Cw, Dh, Dw;
    in >> H >> W;
    in >> Ch >> Cw;
    in >> Dh >> Dw;
    Ch--;
    Cw--;
    Dh--;
    Dw--;
    vector<string> S{};
    S.resize(H);
    REP(i, H) {
        in >> S[i];
    }
    vector<vector<ll>> d(H, vector<ll>(W, INF));
    ll ans = -1;

    priority_queue<vis, std::vector<vis>, decltype(comp)> q{comp};
    q.emplace(vis{Cw, Ch, 0});
    while(!q.empty()) {
        auto v = q.top(); q.pop();
        auto x = v.x_;
        auto y = v.y_;
        auto count = v.count_;
        if (d[y][x] != INF) {
            continue;
        }
        d[v.y_][v.x_] = v.count_;
        if (y == Dh && x == Dw) {
            ans = count;
            break;
        }
        REP(i, 4) {
            auto xx = x + dx[i];
            auto yy = y + dy[i];
            if (xx >=0 && yy >=0 && xx < W && yy < H && S[yy][xx] == '.') {
                q.emplace(vis{xx, yy, count});
            }
        }
        RANGE(xxx, -2, 2) {
            RANGE(yyy, -2, 2) {
                if (xxx == 0 && yyy == 0) continue;
                auto xxxx = x + xxx;
                auto yyyy = y + yyy;
                if (xxxx >=0 && yyyy >=0 && xxxx < W && yyyy < H && S[yyyy][xxxx] == '.') {
                    q.emplace(vis{xxxx, yyyy, count+1});
                }
            }
        }
    }
    out << fixed << setprecision(10);
    out << ans << endl;
    return 0;
}

int main() {
    return run(cin, cout);
}


Measured memory_bytes: 19344
#include <functional>
#include <cstdio>
#include <queue>
typedef long long ll; 
std::priority_queue<ll> quel;
std::priority_queue<ll, std::vector<ll>, std::greater<ll> > quer; 
int l[100005], r[100005]; 
int main()
{
	// freopen("ARC070-E.in", "r", stdin); 
	int n; 
	scanf("%d", &n); 
	ll ans = 0, lazy_l = 0, lazy_r = 0; 
	for (int i = 0; i < n; i++)
	{
		scanf("%d%d", l + i, r + i); 
		if (!i)
		{
			quel.push(l[i]); 
			quer.push(l[i]); 
			continue; 
		}
		lazy_l -= r[i] - l[i]; 
		lazy_r += r[i - 1] - l[i - 1]; 
		ll x = quel.top() + lazy_l, y = quer.top() + lazy_r; 
		if (l[i] < x)
		{
			ans += x - l[i]; 
			quer.push(x - lazy_r); 
			quel.push(l[i] - lazy_l); 
			quel.push(l[i] - lazy_l); 
			quel.pop(); 
		}
		else if (l[i] > y)
		{
			ans += l[i] - y; 
			quel.push(y - lazy_l); 
			quer.push(l[i] - lazy_r); 
			quer.push(l[i] - lazy_r); 
			quer.pop(); 
		}
		else
		{
			quel.push(l[i] - lazy_l); 
			quer.push(l[i] - lazy_r); 
		}
	}
	printf("%lld\n", ans);
	return 0; 
}


Measured memory_bytes: 2796
#include <bits/stdc++.h>
#if ONLINE_JUDGE
#define DEBUG false
#else
#define DEBUG true
#endif
#define REP(i, k, n) for (int i = (int)(k); i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define rep1(i, n) REP(i, 1, n)
#define rREP(i, k, n) for (int i = (int)(n)-1; i >= k; i--)
#define rrep(i, n) rREP(i, 0, n)
#define all(x) (x).begin(),(x).end()
#define SORT(x) std::sort(all(x))
#define REV(x) std::reverse(all(x))
#define UNIQUE(x) x.erase(std::unique(all(x)), x.end());
#define MAX(x) *std::max_element(all(x))
#define MIN(x) *std::min_element(all(x))
#define LOWitr(x, n) std::lower_bound(all(x), n)
#define UPRitr(x, n) std::upper_bound(all(x), n)
#define cii(x) int x; std::cin >> x
#define cill(x) signed long long int x; std::cin >> x
#define cis(x) std::string x; std::cin >> x
#define co(x) std::cout << x << "\n"
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define truecheck assert
#define dump(x) if(DEBUG) std::cout<<#x<<" : "<<(x)<<"\n"
template<class T>using V = std::vector<T>;
template<class T>using VV = std::vector<std::vector<T>>;
template<class T>using Q = std::queue<T>;
template<class T>using PQ = std::priority_queue<T>;
template<class T,class U>using P = std::pair<T, U>;
template<class T,class U>using M = std::map<T, U>;
template<class T,class U>using UM = std::unordered_map<T, U>;
template<class T,class U>inline bool chmax(T &a, const U &b){if (a<b){a=b;return true;}return false;}
template<class T,class U>inline bool chmin(T &a, const U &b){if (b<a){a=b;return true;}return false;}
template<class T>inline void vcin(T &v){for(auto&& i : v) std::cin >> i;}
template<class T>inline void dumpv(const T& v, std::ostream& os = std::cout){
    if(DEBUG){
        os<<"{";
        std::for_each(all(v),[&os](typename T::value_type p){os<<p<<',';});
        os<<"}\n";
    }
}
using std::cin;
using std::cout;
using std::string;
using std::next_permutation;
using LL = signed long long int;
const int INF = INT_MAX, MOD = 1e9 + 7;
const LL LLINF = LLONG_MAX;
const double PI = M_PI;

void Main(){
    cii(n);
    string ans;
    n %= 10;
    if(n==3)ans="bon";
    else if (n==0)ans="pon";
    else if (n==1)ans="pon";
    else if (n==6)ans="pon";
    else if (n==8)ans="pon";
    else ans="hon";
    co(ans);

}

int main() {
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}

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

long long n, m, x, a[13][13], cost2[13], current[13];
bool visited[13];

long long solve(long long cost, int idx) {
	bool ok = true;
	for(int i = 1; i <= m; ++i) {
		current[i] += a[idx][i];
		if(current[i] < x)
			ok = false;
	}
	if(ok)
		return cost;
	long long answer = 2e18;
	for(int i = idx + 1; i <= n; ++i) {
		if(visited[i])
			continue;
		if(!visited[i]) {
			visited[i] = true;
			answer = min(answer, solve(cost + cost2[i], i));
		}
		visited[i] = false;
		for(int j = 1; j <= m; ++j)
			current[j] -= a[i][j];
	}
	return answer;
}

int main() {
	cin >> n >> m >> x;
	for(int i = 1; i <= n; ++i) {
		cin >> cost2[i];
		for(int j = 1; j <= m; ++j)
			cin >> a[i][j];
	}
	long long answer = solve(0, 0);
	cout << (answer == 2e18 ? -1 : answer);
}


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

int main() {
  int A, B, C, D;
  int L, R;
  cin >> A >> B >> C >> D;
  
  L = A + B;
  R = C + D;
  
  if (L > R) {
    cout << "Left" << endl;
  } else if (L == R){
    cout << "Balanced" << endl; 
  } else {
    cout << "Right" << endl; 
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int num[100001];
int main(){
	int n,k,q;
	cin>>n>>k>>q;
	for(int i=1;i<=q;i++){
		int x;
		cin>>x;
		num[x]++;
	}
	
	for(int i=1;i<=n;i++){
		if((long long)(k-q+num[i]) <= 0){
			cout<<"No";
		}
		else
			cout<<"Yes";
		cout<<endl;
	}

}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int c[105][105];
    int n;
    cin>>n;
    for(int i=1; i<=100; i++)
    {
        for(int j=1; j<=100; j++)
        {
            c[i][j]=(i+j)*(i+j);
        }
    }
    for(int i=1; i<=n; i++)
    {
        int cnt=0;
        for(int x=1; x<=sqrt(i); x++)
        {
            for(int y=x; y<=sqrt(i); y++)
            {
                for(int z=y; z<=sqrt(i); z++)
                {
                    if(c[x][y]+c[x][z]+c[y][z]==i*2)
                    {
                        if(x==y&&y==z)
                            cnt++;
                        else if(x!=y&&y!=z&&x!=z)
                            cnt+=6;
                        else
                            cnt+=3;
                    }
                }
            }
        }
        cout<<cnt<<endl;
    }
    return 0;
}


Measured memory_bytes: 3600
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
 
namespace  abcd
{
    class Program
    {
        static void Main(string[] args)
        {
			int a = int.Parse(Console.ReadLine());
			for(int f = 0;f<a;f++)
			{
			var cde = Console.ReadLine().Split().Select(int.Parse).ToArray();
			Array.Sort(cde);
			if(cde[0]*cde[0]+cde[1]*cde[1]==cde[2]*cde[2])
			Console.WriteLine("YES");
			else Console.WriteLine("NO");
		}
		}
	}
}

Measured memory_bytes: 9400
n=int(input())
x=input()
t=int(x,2)
c=x.count('1')
from functools import lru_cache
@lru_cache(None)
def f(x):
  if x==0: return 0
  return f(x%bin(x).count('1'))+1
a=t%-~c
b=0 if c<2 else t%~-c
for i in range(n):
  if int(x[i]):
    d=c-1
    if d<1: print(0)
    else: print(f((b-pow(2,n-i-1,d))%d)+1)
  else:
    d=c+1
    print(f((a+pow(2,n-i-1,d))%d)+1)

Measured memory_bytes: 12508
def sort(a, p, r):
    if p < r:
        q = partition(a, p, r)
        sort(a, p, q-1)
        sort(a, q+1, r)


def partition(a, p, r):
    pivot = a[r]
    i = p-1
    for j in range(p, r):
        if compare(pivot, a[j]) >= 0:
            i += 1
            a[i], a[j] = a[j], a[i]
    a[r], a[i+1] = a[i+1], a[r]
    return i+1

def compare(a,b):
    if a[0] > b[0]:
        return 1
    elif a[0] < b[0]:
        return -1
    else:
        return 0

n = int(raw_input())
a = []
suits = {}
for _ in range(n):
    suit, number = raw_input().split(' ')
    number = int(number)
    a.append((number, suit))
    if number not in suits:
        suits[number] = []
    suits[number].append(suit)

sort(a, 0, len(a)-1)

flag = True
for number, suit in a:
    correct_suit = suits[number].pop(0)
    if suit != correct_suit:
        flag = False
        break

if flag:
    print "Stable"
else:
    print "Not stable"

for number, suit in a:
    print suit, number

Measured memory_bytes: 23316
#include <bits/stdc++.h>
#define div1 1000000007
const long long INF = 1LL << 60;
using namespace std;
typedef long long ll;
typedef long double ld;
// a>b -> a==b;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
// a<b -> a==b;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int main(void)
{
    ll x;

    cin >> x;

    if(x<600) cout << 8 << endl;
    else if(x<800) cout << 7 << endl;
    else if(x<1000) cout << 6 << endl;
    else if(x<1200) cout << 5 << endl;
    else if(x<1400) cout << 4 << endl;
    else if(x<1600) cout << 3 << endl;
    else if(x<1800) cout << 2 << endl;
    else cout << 1 << endl;

    return 0;
}

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

int main(){
  int n;
  cin>>n;
  vector<int> a(n),b(n);
  rep(i,n) cin>>a[i]>>b[i];
  sort(a.begin(),a.end());
  sort(b.begin(),b.end());	
  double x=(a[n/2]+a[(n-1)/2])/2.0;
  double y=(b[n/2]+b[(n-1)/2])/2.0;
  if(n%2==0){
    x*=2;
    y*=2;
  }
  int ans=y-x+1;
  cout<<ans<<endl;
}

Measured memory_bytes: 4852
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int a, b, c, d;

    cin >> a >> b >> c >> d;
while((a>0) && (b > 0)){
    a = a - d;
    c = c - b;
}
    if(c < 1){
        cout << "Yes" << endl;
        return 0;
    }else if(a < 1){
        cout << "No" << endl;
    }
}


Measured memory_bytes: 3624
s = int(input())
x = []
n = 0
while True:

    if x.count(s):
        print(n+1)
        break
    else:
        x.append(s)
        n += 1
    if s % 2 == 0:
        s /= 2
    else:
        s = 3*s + 1

Measured memory_bytes: 2940
#include <stdio.h>

int main(void)
{
	int  a, b, c, emp;

	scanf("%d %d %d", &a, &b, &c);

	if (b > c) {
		emp = c;
		c = b;
		b = emp;
	}
	if (a > b) {
		emp = a;
		a = b;
		b = emp;
	}
	if (b > c) {
		emp = c;
		c = b;
		b = emp;
	}
	
	printf("%d\n", a + b);

	return 0;
}

Measured memory_bytes: 128
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
//const ll mod=998244353;
const ll mod=1000000007;
ll GCD(ll a,ll b) {return b ? GCD(b,a%b):a;}
ll LCM(ll c,ll d){return c/GCD(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
struct mint{
    using ull=unsigned long long int;
    ull v;
    mint(ll vv=0){s(vv%mod+mod);}
    mint& s(ull vv){
        v=vv<mod?vv:vv-mod;
        return *this;
    }
    //オーバーロード
    mint operator-()const{return mint()-*this;}//mint型にキャスト
    mint&operator+=(const mint&val){return s(v+val.v);}
    mint&operator-=(const mint&val){return s(v+mod-val.v);}
    mint&operator*=(const mint&val){
        v=ull(v)*val.v%mod;
        return *this;
    }
    mint&operator/=(const mint&val){return *this*=val.inv();}
    mint operator+(const mint&val){return mint(*this)+=val;}
    mint operator-(const mint&val){return mint(*this)-=val;}
    mint operator*(const mint&val){return mint(*this)*=val;}
    mint operator/(const mint&val){return mint(*this)/=val;}
    mint pow(ll n)const{
        mint res(1),x(*this);
        while(n){
            if(n&1)res*=x;
            x*=x;
            n>>=1;
        }
        return res;
    }
    mint inv()const{return pow(mod-2);}
    //拡張ユークリッドの互除法
    /* mint inv()const{
        int x,y;
        int g=extgcd(v,mod,x,y);
        assert(g==1);
        if(x<0)x+=mod;
        return mint(x);
    }*/
    friend ostream& operator<<(ostream&os,const mint&val){
        return os<<val.v;
    }//出力
    bool operator<(const mint&val)const{return v<val.v;}
    bool operator==(const mint&val)const{return v==val.v;}
    bool operator>(const mint&val)const{return v>val.v;}
};
mint dp[2005][2005];
int main(){
	int n,m;
	cin>>n>>m;
	V<int> a(n),b(m);
	for(int i=0;i<n;i++)cin>>a[i];
	for(int i=0;i<m;i++)cin>>b[i];
	dp[0][0]=1;
	mint sum=0;
	for(int i=0;i<n;i++){
		sum=0;
		for(int j=0;j<m;j++){
			if(a[i]==b[j]){
				dp[i+1][j+1]+=dp[i][j]+sum;
			}
			dp[i+1][j]+=dp[i][j];
			sum+=dp[i][j];
		}
		dp[i+1][m]+=dp[i][m];
	}
	for(int i=0;i<m;i++)dp[n][i+1]+=dp[n][i];
	// for(int i=0;i<=n;i++){
	// 	for(int j=0;j<=m;j++){
	// 		cout<<dp[i][j]<<" ";
	// 	}
	// 	cout<<"\n";
	// }
	cout<<dp[n][m]<<"\n";
}

Measured memory_bytes: 35040
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long n,a=-1;
  cin >> n;
  for(long i=2;i<500;i++) if(i*(i-1)/2==n) a=i;
  if(a==-1) {
    cout << "No" << endl;
    return 0;
  }
  cout << "Yes" << endl << a << endl;
  vector<vector<long>> ans(a,vector<long>(0));
  long x=1;
  for(long i=0;i<a;i++) {
    for(long j=i+1;j<a;j++) {
      ans[i].push_back(x);
      ans[j].push_back(x);
      x++;
    }
  }
  for(long i=0;i<a;i++) {
    cout << a-1 << " ";
    for(long j=0;j<a-1;j++) cout << ans[i][j] << " ";
    cout << endl;
  }
}

Measured memory_bytes: 5032