akhauriyash/Code-Regression huggingface dataset:
n = int(input())
a = list(map(int, input().split()))

import numpy as np
b = np.argsort(a)
idx = np.argsort(b)
for i in range(n):
    if idx[i] < n / 2:
        print(a[b[int(n / 2)]])
    else:
        print(a[b[int(n / 2) - 1]])


Measured memory_bytes: 26016
n=int(input())
m=[list(map(int,input().split()))for _ in[0]*n]
# m = [[-1 for i in range(n)] for j in range(n)]
d=[0]+[10**9]*n
b=[1]*n
a=0
while 1:
  u=-1
  for i in range(n):
    if b[i] and (u<0 or d[i]<d[u]):
      u=i
  if u<0:
    break
  b[u]=0
  a+=d[u]
  for v in range(n):
    t=m[u][v]
    if t+1 and d[v]>t:
      d[v]=t
print(a)




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

alias sread = () => readln.chomp();
alias Point2 = Tuple!(long, "y", long, "x");

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}

enum MOD = (10 ^^ 9) + 7;

void main()
{
    string Sn;
    long K;
    scan(Sn, K);
    long N = Sn.to!long();
    auto D = aryread();
    long[] iD;
    {
        bool[10] B;
        B[] = true;
        foreach (d; D)
            B[d] = false;
        foreach (i; 0 .. 10)
            if (B[i])
                iD ~= i;
    }
    long len = Sn.length;
    if ((cast(char)(iD.back + '0')).repeat().take(len).array().to!long() < N)
    {
        len++;
    }
    long ans = long.max;
    long p = iD[0] == 0;
    foreach (d; iD[p .. $])
        ans = ans.min(solve(N, iD, len, [d]));
    writeln(ans);
}

long solve(long N, long[] iD, long len, long[] tmp)
{
    if (tmp.length == len)
    {
        long x = tmp.map!(x => cast(char)(x + '0')).array().to!long();
        return N <= x ? x : long.max;
    }
    long ans = long.max;
    foreach (d; iD)
        ans = ans.min(solve(N, iD, len, tmp ~ d));
    return ans;
}


Measured memory_bytes: 764
#include <stdio.h>  
#include <string.h>
#define M 500000
#define NIL -1

typedef struct node_tbl
{
	int key,p,l,r;
} node;

node T[M+1];
int root=NIL;
int size=0;

void insert(int k){
	int y=NIL;
	int x=root;
	int z=size++;

	T[z].key=k;
	T[z].l=NIL;
	T[z].r=NIL;

	while (x!=NIL)
	{
		y=x;
		if (T[z].key<T[x].key) x=T[x].l;
		else                   x=T[x].r;
	}

	T[z].p=y;
	if (y==NIL) root=z;
	else{
		if (T[z].key<T[y].key)
			T[y].l=z;
		else
			T[y].r=z;
	}
}

void inorder(int u){
	if (u==NIL) return;
	inorder(T[u].l);
	printf(" %d", T[u].key);
	inorder(T[u].r);
}

void preorder(int u){
	if (u==NIL) return;
	printf(" %d", T[u].key);
	preorder(T[u].l);
	preorder(T[u].r);
}

int main(){
	char o[8];
	int n,x,i;
	scanf("%d", &n);
	
	for (i=0;i<n;i++){
		scanf("%s",o);
		if(!strcmp("insert",o)){
			scanf("%d",&x);
			insert(x);
        }
		else if(!strcmp("print",o)){
			inorder(root);
			printf("\n");
			preorder(root);
			printf("\n");
		}
	}
	return 0;
}



Measured memory_bytes: 9672
#include <iostream>
#include <string>
using namespace std;
int main(void){
    // Your code here!
    string a, b, c;
    cin >> a >> b >> c;
    if (a[a.size()-1] == b[0] && b[b.size()-1] == c[0]) {
        cout << "YES";
    } else {
        cout << "NO";
    }
}


Measured memory_bytes: 256
def ch(x):
    return ord(x)-ord("a")
def dch(x):
    return chr(x+ord("a"))

S = input().rstrip()
T = input().rstrip()

s0 = S[0]
cnt = 1
A1 = []
P = [-1]*26
k=0
for s in S[1:]:
    if s==s0:
        cnt += 1
    else:
        if P[ch(s0)] == -1:
            P[ch(s0)] = k
            k += 1
            A1.append((P[ch(s0)], cnt))
        else:
            A1.append((P[ch(s0)], cnt))
        cnt = 1
    s0 = s
if cnt == 1:
    if P[ch(s0)] == -1:
        P[ch(s0)] = k
        k += 1
        A1.append((P[ch(s0)], cnt))
    else:
        A1.append((P[ch(s0)], cnt))

t0 = T[0]
cnt = 1
B1 = []
P = [-1]*26
k=0
for t in T[1:]:
    if t==t0:
        cnt += 1
    else:
        if P[ch(t0)] == -1:
            P[ch(t0)] = k
            k += 1
            B1.append((P[ch(t0)], cnt))
        else:
            B1.append((P[ch(t0)], cnt))
        cnt = 1
    t0 = t
if cnt == 1:
    if P[ch(t0)] == -1:
        P[ch(t0)] = k
        k += 1
        B1.append((P[ch(t0)], cnt))
    else:
        B1.append((P[ch(t0)], cnt))

if A1==B1:
    print("Yes")
else:
    print("No")




Measured memory_bytes: 97012
#include<bits/stdc++.h>
#include<iostream>
#include<math.h>
#include<string>
using namespace std;
#define nl endl
#define in cin
#define out cout
#define ll long long
//sort(y,y+j, greater<int>());
ll x[1000000];
int main()
{
    ll a,b,c,d,e,i,j,k,k1,k2,k3,n,sq,mul,r;
    in>>a>>b>>c>>d;
    k=a*c;
    k1=a*d;
    k2=b*c;
    k3=b*d;
    out<<max(k,max(k1,max(k2,k3)))<<nl;

}


Measured memory_bytes: 3608
import itertools
import copy


def is_sorted(arr):
    for i in range(len(arr) - 1):
        if arr[i] > arr[i + 1]:
            return False
    return True


def main():
    n = int(input())
    ps = list(map(int, input().split()))

    if is_sorted(ps):
        print('YES')
        return

    for i, j in itertools.combinations(range(n), 2):
        ps_ = copy.deepcopy(ps)
        ps_[i], ps_[j] = ps_[j], ps_[i]
        if is_sorted(ps_):
            print('YES')
            return
    print('NO')
    return


main()

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

        using namespace std;

        #define pb push_back
        #define mp make_pair
        #define fr first
        #define sc second

        typedef long long int lli;

        lli n, m, a, b, p[200001], ans = 1;


        int main(){
            cin>>n;
            for(int i = 0;i<n;i++)
                cin>>p[i];
            a = p[0];
            for(int i = 1;i<n;i++){
                if(p[i] <= a){
                    ans++;
                    a = p[i];
                }
            }
            cout<<ans<<endl;
            return 0;
        }


Measured memory_bytes: 1792
#!/usr/bin/env ruby

dic = {}
while line = gets
  s, n = line.chomp.split
  if dic[s.to_sym]
    dic[s.to_sym] << n.to_i
  else
    dic[s.to_sym] = [n.to_i]
  end
end

dic.sort.each do |k, v|
  puts k
  puts v.sort.join(' ')
end

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(a) (a).begin(), (a).end()

using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;

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

int main() {
  int H, W;
  string S[51];
  cin >> H >> W;
  rep(i, H) cin >> S[i];

  rep(i, H) rep(j, W) {
    if (S[i][j] == '#') continue;
    int cnt = 0;
    rep(k, 8) {
      int nx = i + dx[k], ny = j + dy[k];
      if (0 <= nx && nx < H && 0 <= ny && ny <= W) {
        if (S[nx][ny] == '#') cnt++;
      }
    }
    S[i][j] = '0' + cnt;
  }

  rep(i, H) cout << S[i] << endl;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 7)

def solve(p, n, bt):
    if n < p:
        return 0
    pre = bt
    tmp = 0
    for i, v in enumerate([7, 5, 3]):
        q = 10*p + v
        bt |= 1<<i
        if q <= n and bt == 7:
            tmp += 1
        tmp += solve(q, n, bt)
        bt = pre
    return tmp

def main():
    n = int(input())
    print(solve(0, n, 0))

if __name__ == "__main__":
    main()

Measured memory_bytes: 9204
import java.util.Scanner;

public class Main {

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

		int N = sc.nextInt();
		int K = sc.nextInt();
		double[] P = new double[N];

		for (int i = 0; i < N; i++) {
			P[i] = (0.5 * sc.nextDouble()) + 0.5;
		}

		double FIRST = 0;
		for (int i = 0; i < K; i++) {
			FIRST += P[i];
		}
		double BEFORE = FIRST;
		double MAX = FIRST;

		for (int i = 1; i < N - K + 1; i++) {
			double EXP = BEFORE - P[i - 1] + P[i + K - 1];

			BEFORE = EXP;
			if (EXP > MAX) {
				MAX = EXP;
			}
		}

		System.out.println(String.format("%.10f", MAX));
		sc.close();
	}

}


Measured memory_bytes: 160484
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
//#include <math.h>
#include <algorithm>
#include <vector>
#pragma warning(disable:4996)
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define MOD 1000000007
using namespace std;
 
int main(int argc, char* argv[])
{
    long a,b,c,d;
    scanf("%ld %ld %ld %ld", &a, &b, &c, &d);
 
    if(abs(a-c)<=d || (abs(a-b)<=d && abs(b-c)<=d) ) {
        printf("Yes\n");
    }
    else {
        printf("No\n");
    }
    return 0;
}

Measured memory_bytes: 128
import java.io.InputStream;
import java.io.PrintWriter;
import java.lang.reflect.Array;
import java.math.BigDecimal;
import java.math.MathContext;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Scanner;
import java.util.Set;
import java.util.Stack;
import java.util.TreeMap;
import java.util.TreeSet;

import static java.util.Comparator.*;

public class Main {
    public static void main(String[] args) {
        PrintWriter out = new PrintWriter(System.out);
        Solver solver = new Solver(System.in, out);
        solver.solve();
        out.close();
    }
}
class Solver {
	Scanner sc;
	PrintWriter out;
    public Solver(InputStream in, PrintWriter out) {
    	sc = new Scanner(in);
    	this.out = out;
    }
    // ==================================================================
    public void solve() {
    	int K = ni();
    	int S = ni();
    	int ans = 0;
    	for (int i = 0; i <= K; i++) {
			for (int j = 0; j <= K; j++) {
				if(S >= (i+j) && S - i - j <= K)	ans++;
			}
		}
    	out.println(ans);
    }
    // ------------------------------------------
    // 入力
    // ------------------------------------------
    public int ni() {
    	return Integer.parseInt(sc.next());
    }
    public long nl() {
    	return Long.parseLong(sc.next());
    }
    public String ns() {
    	return sc.next();
    }
    public char[] nc() {
    	return sc.next().toCharArray();
    }
    public int[] ndi(int N) {
    	int[] ans = new int[N];
    	for (int i = 0; i < N; i++) {
			ans[i] = ni();
		}
    	return ans;
    }
    public long[] ndl(int N) {
    	long[] ans = new long[N];
    	for (int i = 0; i < N; i++) {
			ans[i] = nl();
		}
    	return ans;
    }
    public String[] nds(int N) {
    	String[] ans = new String[N];
    	for (int i = 0; i < N; i++) {
			ans[i] = ns();
		}
    	return ans;
    }
    public char[][] ndc(int N) {
    	char[][] ans = new char[N][];
    	for (int i = 0; i < N; i++) {
			ans[i] = nc();
		}
    	return ans;
    }
    public int[][] ndii(int N, int S) {
    	int[][] ans = new int[N][S];
    	for (int i = 0; i < N; i++) {
			for (int j = 0; j < S; j++) {
				ans[i][j] = ni();
			}
		}
    	return ans;
    }
}


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

int main(){
    int n, m;
    cin >> n >> m;
    vector<int> S(m);
    vector<char> C(m);
    for (int i = 0; i < m; i++) {
        cin >> S[i] >> C[i];
    }
    if (n == 1){
        for (int i = 0; i < 10; i++) {
            int flag = 1;
            string s = to_string(i);
            for (int j = 0; j < m; j++) {
                if(s[S[j]-1] != C[j]) flag = 0;
            }
            if(flag) {
                cout << i << endl;
                return 0;
            }
        }
    }
    else {
        for (int i = pow(10, n - 1); i < pow(10, n); i++) {
            int flag = 1;
            string s = to_string(i);
            for (int j = 0; j < m; j++) {
                if (s[S[j] - 1] != C[j]) flag = 0;
            }
            if (flag) {
                cout << i << endl;
                return 0;
            }
        }
    }
    cout << -1 << endl;
    return 0;

}


Measured memory_bytes: 512
#include <iostream>
#include <string>
using namespace std;
int main(){
    string s;
    cin>>s;
    int ans=0;
    if(s=="SUN")ans=7;
    else if(s=="MON")ans=6;
    else if(s=="TUE")ans=5;
    else if(s=="WED")ans=4;
    else if(s=="THU")ans=3;
    else if(s=="FRI")ans=2;
    else if(s=="SAT")ans=1;

    cout <<ans<<endl;
    }


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    long long int m,n,s,w;
    while(~scanf("%lld %lld",&n,&m))
    {
        if(m<=2*n)
            s=m/2;
        else
        {
            s=n;
            m=m-2*n;
            s=s+m/4;
        }
        printf("%lld\n",s);
    }
    return 0;
}


Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, int> P;
typedef pair<int, P> E;
#define MOD (1000000007ll)
#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a += b;
	if(a>=MOD){
		a -= MOD;
	}
}

vector<int> v;

int main(void){
	int n,k,m,i,ans=0;
	string s;
	v.push_back(0);
	cin >> n >> k;
	cin >> s;
	if(s[0]=='0'){
		v.push_back(0);
	}
	for(i=1; i<n; ++i){
		if(s[i-1]!=s[i]){
			v.push_back(i);
		}
	}
	if(s[n-1]=='0'){
		v.push_back(n);
	}
	v.push_back(n);
	m = v.l_ength();
	for(i=0; i<v.l_ength(); i+=2){
		ans = max(ans,v[min(i+2*k+1,m-1)]-v[i]);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1020
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <string>
#include <functional>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <cstdlib>
using namespace std;

typedef long long ll;

const double EPS = 1e-8;

struct fruit
{
    string name; 
    double rate;
};

bool operator>(const fruit &a, const fruit &b)
{
    if(fabs(a.rate - b.rate) < EPS) {
        return a.name < b.name;
    } else {
        return a.rate > b.rate;
    }
}


int main()
{
    int N, P, A, B, C, D, E, F, S, M;
    string L;
    while(cin >> N && N) {
        vector<fruit> vf;
        for(int i = 0; i < N; i++) {
            cin >> L >> P >> A >> B >> C >> D >> E >> F >> S >> M;
            int time = A + B + C + (D + E) * M;
            int cost = S * M * F - P;
            double rate = (double)cost / time;
            vf.push_back((fruit){L, rate});
        }
        sort(vf.begin(), vf.end(), greater<fruit>());
        for(int i = 0; i < N; i++)
            cout << vf[i].name << endl;
        cout << "#" << endl;
    }
    
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <vector>
#include <cmath>
#include <cctype>
#define rep(i,a,b) for(int i=(a);i<b;i++)
#define INF 1000000000
#define MAX_N 100000000
using namespace std;
bool debug=false;



unsigned long long solve(unsigned long long a,long long b,long long n){
  unsigned long long tmp=1;
  if(b>0){
    tmp=solve(a,b/2,n);
    if(b%2==0)tmp=(tmp*tmp)%n;
    else tmp=(((tmp*tmp)%n)*a)%n;
  }
  return tmp;
}

int main(){
  long long a,b;
  cin>>a>>b;
  cout<<solve(a,b,1000000007)<<endl;
  return 0;
}

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

#define fi first
#define se second
#define eb emplace_back
#define FOR(i, a, b) for(int i = a; i < (int) b; i++)
#define FORD(i, a, b) for(int i = a; i >= (int) b; i--)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;
typedef vector<vi> vvi;
typedef vector<vpii> vvpii;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef vector<pi64> vpi64;

const int M = 1e3 + 5;
const int N = (1 << 12) + 10;
int custo[M];
int bit[M];
int dp[N];

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int w, k, mask = 0;
    cin >> custo[i] >> k;
    for (int j = 0; j < k; j++) {
      int bau;
      cin >> bau;
      bau--;
      mask |= (1 << bau);
    }
    bit[i] = mask;
  }
  dp[0] = 0;
  for (int i = 1; i < N; i++) {
    dp[i] = 1e9;
  }
  for (int i = 0; i < m; i++) {
    int mask = bit[i];
    int w = custo[i];
    for (int j = 0; j < N; j++) {
      if (dp[j] > 1e8) continue;
      int nova_mask = (mask | j);
      dp[nova_mask] = min (dp[nova_mask], dp[j] + w);
    }
  }
  if (dp[(1 << n) - 1] > 1e8) cout << -1 << '\n';
  else cout << dp[(1 << n) - 1] << '\n';
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;
int dy[4]={1,0,-1,0};
int dx[4]={0,1,0,-1};
vector<vector<int>> graph;

bool sort_sec(const pair<int,int> &a,const pair<int,int> &b){
   if(a.second<b.second){
      return true;
   }
   return false;
}

void swap(int *a,int *b){
   int temp=*a;
   *a=*b;
   *b=temp;
}

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

int main(void){
   int N;
   cin>>N;
   vector<int> A(N);
   map<int,int> cnt;
   set<int> s;
   for(int i=0;i<N;i++){
      cin>>A[i];
      cnt[A[i]]++;
      s.insert(A[i]);
   }
   bool dp[1000006];
   memset(dp,true,sizeof(dp));
   for(int c:s){
         for(int j=2;j<=1000000;j++){
            if(c*j>1000000) break;
            dp[c*j]=false;
         }
   }
   int ans=0;
   for(int i=0;i<=1000000;i++){
      if(dp[i]==true&&cnt[i]==1){
         ans++;
      }
   }
   cout<<ans<<endl;
   return 0;
}


Measured memory_bytes: 61304
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0;i<static_cast<int>(n);++i)
#define per(i, n) for(int i=static_cast<int>(n)-1;i>=0;--i)
#define eee(a) (cerr<<(#a)<<": "<<(a)<<'\n');
#define ppp(a) (cout<<(a)<<'\n'); 
#define cop(a) for(auto x:(a)){cerr<<(x)<<'\n';}
using ll = long long;
constexpr int dx[4]={1,0,-1,0};
constexpr int dy[4]={0,1,0,-1};
constexpr ll MOD = 1e9+7;
constexpr ll Mod = 998244353;
constexpr int INF = 1e9;
constexpr ll LINF = 1e18;
constexpr double phi = (1+sqrt(5))/2;
constexpr double pi = 3.14159265358979323846264338327950288;
inline ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
inline ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
inline ll inverse(ll n,ll m=MOD){ll a=n,b=m,x=1,y=0;while(b){ll t=a/b;a-=t*b;swap(a,b);x-=t*y;swap(x,y);}return (a%m+m)%m;}
inline void Yes(){puts("Yes");}
inline void No(){puts("No");}
inline void Judge(bool b){b?Yes():No();}
inline void YES(){puts("YES");}
inline void NO(){puts("NO");}
inline void JUDGE(bool b){b?YES():NO();}
inline ll powmod(ll b, ll e, ll m=MOD){ll r=1;while(e>0){if(e&1)r=(r%m)*(b%m)%m;b=(b%m)*(b%m)%m;e>>=1;}return r;}
inline double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));}
inline double d2r(double d){return d*pi/180;}
inline double r2d(double r){return r*180/pi;}
template<class T>inline bool chmax(T &a, const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(b<a){a=b;return 1;}return 0;}
template<typename T1,typename T2>ostream& operator<<(ostream& s,const pair<T1, T2>& p){return s <<"("<<p.first<<", "<<p.second<<")";}
template<typename T> ostream& operator<<(ostream& s,const vector<T>& v){s<<'[';for(size_t i=0;i<v.size();++i){s<<v[i];if(i<v.size()-1)s<<", ";}s<<']';return s;}

int main(){
    cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(15);
    
    int n, m;
    cin >> n >> m;
    vector<int> s(m), c(m);
    rep(i, m){
        cin >> s[i] >> c[i];
        --s[i];
    }

    for (int i = 0; i < 1000; ++i){
        string x = to_string(i);
        int l = x.size();
        if(l == n){
            bool ok = true;
            for(int i = 0; i < m; ++i){
                if(x[s[i]]-'0' != c[i]) ok = false;
            }
            if(ok){
                cout << i << '\n';
                return 0;
            }
        }
    }
    cout << -1 << '\n';


    
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    std::deque<long long int> deq;
    int n;
    cin>>n;
    long long int a;
    for (int i=0;i<n;i++) {
        cin>>a;
        deq.emplace_back(a);
    }
    sort(deq.begin(),deq.end(),greater<long long int>());
    std::map<long long int, int> map;
    long long int tmp,max=0,next=0;
    int flag=0;
    for (int j=0;j<n;j++) {
        if (j==0) {
            tmp=deq[j];
            map.emplace(deq[j],1);
        } else {
            if (tmp==deq[j]) {
                map.at(deq[j])++;
                if (j==n-1&&map.at(deq[j])>=2) {
                    if (tmp>max) {
                        next=max;
                        max=tmp;
                    } else if (tmp>next) {
                        next=tmp;
                    }
                }
            } else {
                if (max==0&&map.at(tmp)>=4) {
                    cout<<tmp*tmp<<endl;
                    flag=1;
                    break;
                } else if (map.at(tmp)>=2) {
                    if (tmp>max) {
                        next=max;
                        max=tmp;
                    } else if (tmp>next) {
                        next=tmp;
                    }
                }
                tmp=deq[j];
                map.emplace(deq[j],1);
            }
        }
    }
    if (flag==0) {
        cout<<max*next<<endl;
    }
}

Measured memory_bytes: 7296
#include <iostream>
#include <set>
#include <vector>
#include <string>
#include <algorithm>
#include <iterator>
#include <map>
#include <utility>
#include <list>
#include <climits>
#include <bitset>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, n) for(auto i = (n).begin(); i != (n).end(); i++)
#define in_arr(type, a, n) copy_n(istream_iterator<type>(cin), n, (a).begin());
#define ll long long int

int main(){
    int W, H, n;
    cin >> W >> H >> n;
    int xr = W, yu = H, xl = 0, yd = 0;
    rep(i, n){
        int x, y, a;
        cin >> x >> y >> a;
        if(a == 1){
            xl = max(xl, x);
        }else if(a == 2){
            xr = min(x, xr);
        }else if(a == 3){
            yd = max(y, yd);
        }else if(a == 4){
            yu = min(yu, y);
        }
        if(xr <= xl || yu <= yd){
            cout << 0 << endl;
            return 0;
        }
    }
    cout << (xr - xl) * (yu - yd) << endl;
    return 0;
}


Measured memory_bytes: 256
inp = input().split(" ")
A, B, C, K = int(inp[0]), int(inp[1]), int(inp[2]), int(inp[3])

# print(A, B, C, K)

if A >= K:
  print(K)
  
elif A < K and K - A <= B:
  print(A)
  
else:
  print(A - (K - A - B))

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

typedef long long int lli;
typedef unsigned long long int ulli;
typedef pair<int,int> pii;
typedef priority_queue< int, vector< int >, greater< int > >  minHeap;

#define ones(x) __builtin_popcount(x)
#define onesl(x) __builtin_popcountl(x)
#define onesll(x) __builtin_popcountll(x)

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define scn(n) scanf("%d",&n)
#define scnll(n) scanf("%lld",&n)
#define scn2(n,m) scanf("%d%d",&n,&m)
#define scn3(n,m,w) scanf("%d%d%d",&n,&m,&w)
#define scn2ll(n,m) scanf("%lld%lld",&n,&m)
#define atoz(v) v.begin(),v.end()
#define ratoz(v) v.rbegin(),v.rend()
#define Fill(a,v) memset(a,v,sizeof(a))
#define fi first
#define se second
#define inf 1e9
#define pi acos(-1.0)
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define mod 1000000007
#define FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define bug(x) cerr << __LINE__ << " says: " << #x << " = " << (x) << "\n"

int Set(int N,int pos)
{
    return N=N | (1<<pos);
}
int reset(int N,int pos)
{
    return N = N & ~(1<<pos);
}
bool check(int N,int pos)
{
    return (bool)(N & (1<<pos));
}

inline int addmod(lli x,lli y)
{
    return (x%mod + y%mod)%mod;
}
inline int submod(lli x,lli y)
{
    return (x%mod - y%mod + mod)%mod;
}
inline int mulmod(lli x,lli y)
{
    return (x%mod * y%mod)%mod;
}


inline int nextSubMask(int i, int mask)
{
    return (i-1)&mask;   /// returns next  submask
}

template<typename T>
void we_r_done(T mssg)
{
    cout<<mssg;
    exit(0);
}


int main()
{
    ///freopen("output.txt","w",stdout);
 //  freopen("input.txt","r",stdin);
    FastIO;

    int n,k;

    while(cin>>n){
        lli a[n+1] , b[n+1];

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

        lli last = 0, ans = 0;
        for(int i=n; i>0; i--){
            int m = (a[i]+last)%b[i];
            if(m == 0) continue;
            ans += (b[i]-m);
            last += (b[i]-m);

        }
        cout<<ans<<endl;
    }

    return 0;
}

///sin and cos expect input in radians not degrees. so use , sin(degrees * pi / 180)
///using bs = bitset<MX>; // how many distinct number can be form?
///sort(atoz(v), [](const data x, const data y){return (x.a==y.a?x.b>y.b : x.a<y.a);});


Measured memory_bytes: 1792
import numpy as np
A, B, H, M = map(int, input().split())

h_rot = np.pi / 2 - (np.pi * (H * 30 + M / 2) / 180 )
m_rot = np.pi / 2 - np.pi * (6 * M) / 180 

x_diff = (A * np.cos(h_rot) - B * np.cos(m_rot)) ** 2
y_diff = (A * np.sin(h_rot) - B * np.sin(m_rot)) ** 2

print(np.sqrt(x_diff + y_diff))


Measured memory_bytes: 27116
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

void solve()
{
	int n, m;
	while(cin >> n >> m, n || m)
	{
		vector<int> Vec;
		for(int i = 0; i < n; ++i)
		{
			int price;
			cin >> price;
			Vec.push_back(price);
		}
		sort(Vec.begin(), Vec.end());
		int count = 1;
		int sum = 0;
		for(int i = Vec.size() - 1; i >= 0; --i)
		{
			if(count == m)
			{
				count = 1;
				continue;
			}
			sum += Vec[i];
			++count;
		}
		cout << sum << endl;
	}
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 1228
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int A[1002];
  int n,k;
  cin>>n>>k;
  for(int i=1;i<=n;i++) cin>>A[i];
  sort(A,A+n+1);
  for (int num=1;num<=k;num++)
  {
    A[0]+=A[num];
  }
  cout<<A[0];
}


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

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    long long n;
    cin >> n;
    if (n % 2 == 1) {
        cout << 0 << '\n';
    } else {
        // find number of factors of 5
        long long ans = 0;
        for (long long i = 10; i < 1e18; i *= 5) {
            ans += n / i;
        }
        cout << ans << '\n';
    }
    return 0;
}

Measured memory_bytes: 256
ii = lambda:int(input())
mi = lambda:list(map(int,input().split()))
ix = lambda x:list(input() for _ in range(x))
mix = lambda x:list(mi() for _ in range(x))
iix = lambda x:list(int(input()) for _ in range(x))
##########

def resolve():
    lst_x = mi()
    res = 0
    for i in range(len(lst_x)):
        if lst_x[i] == 0:
            res = i+1
            break
    print(res)

if __name__ == "__main__":
    resolve()

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

typedef long long ll;
const int N = 100054, mod = 1000000007;

int n, m, L;
int f[N];
char s[N];

inline void down(int &x, const int y) {x > y ? x = y : 0;}
inline void add(int &x, const int y) {x += y - mod, x += x >> 31 & mod;}
inline void sub(int &x, const int y) {x -= y, x += x >> 31 & mod;}

int main() {
	int i, j, u, v, ans = 0;
	scanf("%d%d%s", &L, &n, s);
	for (i = 0; i < n; ++i) s[i] = s[i] >> 4 & 1;
	if (*s) for (i = 0; i < n; ++i) s[i] ^= 1;
	for (j = 0; j < n && !s[j]; ++j);
	if (j == n) {
		for (u = 2, v = i = 1; i < L; ++i) j = u, u = v, add(v, j);
		return printf("%d\n", v), 0;
	}
	if (L & 1) return putchar(48), putchar(10), 0;
	m = j | 1, L /= 2;
	for (i = j + 1; i < n; ++i) if (s[i]) (i ^ j) & 1 || (down(m, i - j - 1), 0), j = i;
	assert(m & 1), m = (m + 1) / 2;
	for (f[1] = *f = i = 1; i < L; ++i)
		if (add(f[i + 1] = f[i], f[i]), i >= m) sub(f[i + 1], f[i - m]);
	for (i = std::max(L - m, 0); i < L; ++i) ans = (ans + ll(L - i) * f[i]) % mod;
	printf("%d\n", ans * 2 % mod);
	return 0;
}

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

#define MAX_N 10000
#define INF 10000000LL

long long n, j, x[MAX_N][MAX_N], p[MAX_N + 2], sum;

int matrix() {
	for (int i = 0; i < n; i++) { x[i][i] = 0; }
	for (int h = 2; h <= n; h++) {
		for (int i = 1; i <= n - h + 1; i++) {
			j = i + h - 1;
			x[i][j] = INF;
			for (int k = i; k < j; k++) {
				x[i][j] = min(x[i][j], x[i][k] + x[k + 1][j] + p[i - 1] * p[k] * p[j]);
			}
		}
	}
	sum = x[1][n];
	return sum;
}

int main() {
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> p[i - 1] >> p[i];
	}
	cout << matrix() << endl;
	return 0;
}

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

int n;

vector<string> key;
string s, t[50000], name[50000], str[50000];
int space[50000];
bool object[50000];

int line;
string ans;

bool solve(int keyIdx, int preIndent){
  if(keyIdx == key.size()){
    if(object[line - 1]) ans = "object";
    else                 ans = "string \"" + str[line - 1] + "\"";

    return true;
  }
  if(n <= line){
    return false;
  }

  int indent = space[line];

  if(indent <= preIndent){
    return false;
  }

  while(line < n && space[line] == indent){
    if(key[keyIdx] == name[line++]){
      return solve(keyIdx + 1, indent);
    }

    while(line < n && space[line] > indent){
      line++;
    }
  }

  return false;
}

int main(){
  string keys;
  getline(cin, keys);
  keys += ".";

  int idx = 1;

  while(idx < keys.length()){
    int nextPeriod = keys.find('.', idx);
    string tmp = keys.substr(idx, nextPeriod - idx);
    key.push_back(tmp);
    idx += tmp.length() + 1;
  }

  n = 0;

  while(getline(cin, t[n])){
    space[n] = 0;
    for(int i = 0; t[n][i] == ' '; i++, space[n]++);

    for(int i = space[n]; t[n][i] != ':'; i++){
      name[n] += t[n][i];
    }

    if(t[n][t[n].length() - 1] == ':'){
      object[n] = true;
    }
    else{
      str[n] = t[n].substr(space[n] + name[n].length() + 2);
    }

    n++;
  }

  line = 0;
  bool flg = solve(0, -1);

  if(flg){
    cout << ans << endl;
  }
  else{
    cout << "no such property\n";
  }
}

Measured memory_bytes: 2524
import java.io.IOException;
import java.util.Scanner;
class Main{
	public static void main(String[] args)throws NumberFormatException, IOException{
		Scanner scan = new Scanner(System.in);
		String textString = scan.next();
		char[] text = textString.toCharArray();
		int decreeTimes = scan.nextInt();
		int A = 0;
		int B = 0;
		String replaceText =  "";
		String answer = "";

		for (int i=0; i<decreeTimes; i++){
			String decree = scan.next();
			A = scan.nextInt();
			B = scan.nextInt();
			if(decree.equals("replace")){
				replaceText = scan.next();
				for(int j=0; j<(B-A+1); j++){
					text[A+j] = replaceText.charAt(j);
				}
			}
			else if(decree.equals("reverse")){
				char[] temp = (char[])text.clone();
				for(int j=0; j<B-A+1; j++){
					text[B-j] = temp[j+A];
				}
			}
			else if(decree.equals("print")){
				answer = "";
				for(int j=A; j<B+1; j++){
					System.out.print(text[j]);
				}
				System.out.println("");
			}
		}
	}
}

Measured memory_bytes: 33504
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <string>
#include <numeric>
#include <math.h>

using namespace std;
double condition = 0.0;

void func()
{
	string S;
	cin >> S;
	if (S[2] == S[3] && S[4] == S[5])
		cout << "Yes\n";
	else
		cout << "No\n";
}

int main() {
	//while(1)
	func();
	return 0;
}


Measured memory_bytes: 3064
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use {
    proconio::{marker::*, *},
    std::{cmp::*, collections::*, mem::*},
};

#[fastout]
fn main() {
    input! {//
        k:i64,
    }

    // modk ?
    let mut num = 7i64;
    for i in 1..1010100i64 {
        if num % k == 0 {
            println!("{}", i);
            return;
        } else {
            num = (num * 10 + 7) % k;
        }
    }
    println!("{}", -1);
}


Measured memory_bytes: 2176
#include<bits/stdc++.h>
using namespace std;
const int N=1e6+100;
#define ll long long 

ll a[N],p[N],d[N]; 
ll n,m;
int main()
{
	//int n,m;
	ios::sync_with_stdio(false);
	cin>>n>>m;
	d[0]=m;
	for(int i=1;i<=n;i++) 
	{
		cin>>a[i];
		d[i]=min(d[i-1],abs(d[i-1]-a[i]));//走1-i步的最小距离 
	}
	p[n+1]=1;//走x-n步最小不能的距离
	for(int i=n;i>=1;i--)
	{
		if(a[i]/2>=p[i+1]) p[i]=p[i+1];
		else p[i]=p[i+1]+a[i];
	} 
	int q;
	cin>>q;
	while(q--)
	{
		int x;
		cin>>x;
		if(d[x-1]>=p[x+1]) cout<<"YES"<<endl;
		else cout<<"NO"<<endl;
	}
	return 0;
} 

Measured memory_bytes: 18304
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <cmath>
#include <cstring>
#include <map>
#include <queue>
#include <string>
#define pb push_back
#define mod 1000000007
#define all(x) x.begin(),x.end()
#define inf (int)(1e9)
using namespace std;
typedef long long int ll;
typedef pair<int,int> pii;

int h,w,n;
int g[111][111];
int iro[111111];
int main(void){
  cin>>h>>w;
  cin>>n;
  int x;
  vector<int> a;
  for(int i=0;i<n;i++){
    cin>>x;
    a.pb(x);
  }
  x=0;
  for(int i=0;i<n;i++){
    for(int j=0;j<a[i];j++){
      iro[x++]=i+1;
    }
  }
  x=0;
  for(int i=0;i<h;i++){
    if(i%2==0){
      for(int j=0;j<w;j++){
	g[i][j]=iro[x++];
      }
    }
    else{
      for(int j=w-1;j>=0;j--){
	g[i][j]=iro[x++];
      }
    }
  }
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cout<<g[i][j]<<" ";
    }
    cout<<endl;
  }

  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
const int N = 3005;
int mod, a[N];
int powmod(int a, int b)
{
	int ans = 1;
	while(b)
	{
		if(b&1) ans = 1ll*ans*a%mod;
		a = 1ll*a*a%mod;
		b >>= 1;
	}
	return ans;
}
int inv(int x)
{
	return powmod(x, mod-2);
}
vector<int> mul(vector<int> p, int t) //return p*(x-t) O(n)
{
	int deg = (int)p.size();
	vector<int> r(deg+1, 0);
	for(int i=0; i<deg; i++) r[i+1] = (r[i+1] + p[i])%mod;
	for(int i=0; i<deg; i++) r[i] = (r[i] - 1ll*p[i]*t%mod + mod)%mod;
	return r;
}
vector<int> div(vector<int> p, int t) //return p/(x-t) O(n)
{
	int deg = (int)p.size();
	vector<int> r(deg-1, 0);
	for(int i=deg-1; i>0; i--)
	{
		p[i-1] = (p[i-1] + 1ll*t*p[i]%mod)%mod;
		r[i-1] = p[i];
	}
	return r;
}
int get(vector<int> f, int x) //return f(x) O(n)
{
	int ans = 0, tmp = 1, deg = (int)f.size();
	for(int i=0; i<deg; i++)
	{
		ans = (ans + 1ll*f[i]*tmp%mod)%mod;
		tmp = 1ll*tmp*x%mod;
	}
	return ans;
}
int main()
{
	scanf("%d", &mod);
	int p = mod;
	for(int i=0; i<p; i++) scanf("%d", &a[i]);
	vector<int> t = {0, 1}; //x
	for(int i=1; i<p; i++) t = mul(t, i);
	vector<int> f(p, 0);
	for(int i=0; i<p; i++)
	{
		if(!a[i]) continue;
		vector<int> g = div(t, i);
		int cur = inv(get(g, i));
		for(int i=0; i<(int)g.size(); i++) f[i] = (f[i] + 1ll*g[i]*cur%mod)%mod;
	}
	for(int x : f) printf("%d ", x);
	return 0;
}

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

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

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

ll S[505][505];

int main()
{
    ll N;
    cin >> N;
    memset(S, 0, sizeof(S));
    FOR(n, 10, 1)
    {
        ll p = pow(2LL, n);
        REP(i, N)
        {
            FOR(j, N, i + 1)
            {
                if (i % p != j % p)
                {
                    if (S[i][j] > 0)
                        continue;
                    S[i][j] = n;
                }
            }
        }
    }

    REP(i, N - 1)
    {
        FOR(j, N, i + 1)
        {
            cout << S[i][j] << " ";
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 2432
#include <stdio.h>
#define MAX 2000
#define TRUE 1
#define FALSE 0
int n, A[MAX];
int solve(int ,int );

int main( ){
  int i, q, m[MAX];
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&m[i]);

    if(solve(0,m[i])==TRUE) printf("yes\n");
    else printf("no\n");
  }
  return 0;
}


int solve(i,m){
  if(i >= n) return FALSE;
  else if(m - A[i] == 0) return TRUE;
  else{
    if( solve(i + 1, m) || solve(i + 1, m - A[i])) return TRUE;
	else return FALSE;
  }
}


  


      
      



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

#define ll long long int

ll P[55], S[55];

ll calc(int N, ll X)
{
    if (!X) return(0);
    if (X == S[N]) return(P[N]);
    ll mid = (S[N] + 1) / 2;
    if (X < mid) return(calc(N - 1, X - 1));
    if (X == mid) return(1 + P[N - 1]);
    return(P[N - 1] + 1 + calc(N - 1, X - S[N - 1] - 2));
}

int main()
{
    int N;
    ll X;
    cin >> N >> X;
    P[0] = S[0] = 1;
    for (int i = 1; i <= N; i++)
    {
        P[i] = 2 * P[i - 1] + 1;
        S[i] = 2 * S[i - 1] + 3;
    }
    cout << calc(N, X) << '\n';
    return(0);
}

Measured memory_bytes: 256
s = (input())

def check(s):
    for c in s:
        if not(c in ("A","C","G","T")):
            break
    else:
        return True
    return False

out = 0
for i in range(len(s)+1):
    for j in range(i+1,len(s)+1):
        tmp = check(s[i:j])
        if tmp:
            out = max(out,j-i)
print(out)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define sz(x) int(x.size())
#define pb push_back
#define ff first
#define ss second
typedef long long ll;

int main(){
	int n;cin>>n;
	vector<int>vec(n+1);
	for(int i=0;i<=n;i++)cin>>vec[i];
	vector<int>he(n);
	for(int i=0;i<n;i++)cin>>he[i];
	ll ans=0;
	for(int i=0;i<n;i++){
		ans+=min(vec[i],he[i]);
		he[i]-=min(vec[i],he[i]);
		ans+=min(he[i],vec[i+1]);
		vec[i+1]-=min(he[i],vec[i+1]);
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3960
#include<bits/stdc++.h>
using namespace std;
int a[101];
int main(){
	int n,m,ans=0;
	double sum=0.0;
	cin>>n>>m;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		sum+=a[i];
	}
	double x=(double)sum/(double)(4*m);
	for(int i=1;i<=n;i++){
		if(a[i]>=x) ans++;
	}
	if(ans>=m) cout<<"Yes";
	else cout<<"No";
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B,C,D;
  cin >> A >> B >> C >> D;
  if (A + B < C + D){
    cout << "Right" << endl;
  }
  else if (A + B > C + D){
    cout << "Left" << endl;
  }
  else if (A + B == C + D){
    cout << "Balanced" << endl;
  }
}

Measured memory_bytes: 256
def sub(A):
    m = max(A)
    for i in range(len(A)):
        if A[i] == m:
            A[i] -= len(A)
            m = -(10 ** 40)
        else:
            A[i] += 1

def main():
    K = int(input())
    if K == 0:
        return 2, [1, 1]
    if K == 1:
        return 2, [0, 2]
    if K < 50:
        return K, [K] * K
    k = K // 50
    t = [50 + k] * 50
    for _ in range(50 - (K % 50)):
        sub(t)
    return 50, t
    



N, A = main()
print(N)
print(*A)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define gc() getchar()
#define pc(a) putchar(a)
#define int long long
#define inf (1ll<<60)
inline int read()
{
    int x=0,f=1;
    char c=gc();
    while(c>'9'||c<'0')
    {
        if(c=='-') f=-f;
        c=gc();
    }
    while(c>='0'&&c<='9') x=x*10+c-'0',c=gc();
    return x*f;
}
int Num[25];
inline void write(int x)
{
    if(!x) {pc('0');return;}
    if(x<0) x=-x,pc('-');
    int top=0;
    while(x) Num[++top]=x%10,x/=10;
    while(top) pc(Num[top--]+'0');
    return;
}
#define ma 300005
char s[ma];
signed main()
{
   scanf("%s",s+1);
   int n=strlen(s+1);
   if(s[n]!='s') s[++n]='s';
   else s[++n]='e',s[++n]='s';
   for(int i=1;i<=n;i++) pc(s[i]);
}










Measured memory_bytes: 3756
import math
from decimal import Decimal
n, k = map(int, input().split())

ans = Decimal(0)
m = n+1

if n >= k:
    ans += Decimal((n - k + 1) / n)
    m = k
    
for i in range(1, m):
    x = math.ceil(math.log2(k/i))
    p = Decimal(1 / n) * Decimal((1 / 2) ** x)
    ans += p
    
print(ans)

Measured memory_bytes: 5076
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"sort"
	"strconv"
	"strings"
)

var (
	rb     rdBuffer
	reader *bufio.Reader
	writer *bufio.Writer
)

func solve() {
	n := rb.next()
	c := n[len(n)-1:]
	if c == "2" || c == "4" || c == "5" || c == "7" || c == "9" {
		fmt.Println("hon")
	} else if c == "0" || c == "1" || c == "6" || c == "8" {
		fmt.Println("pon")
	} else {
		fmt.Println("bon")
	}
}

/* template functions */

func main() {
	defer writer.Flush()
	solve()
}

func init() {
	rb = rdBuffer{
		buf: make([]string, 0, 64),
		cur: 0,
	}
	reader = bufio.NewReader(os.Stdin)
	writer = bufio.NewWriter(os.Stdout)
}

type rdBuffer struct {
	buf []string
	cur int
}

func (r *rdBuffer) readln() {
	line, err := reader.ReadString('\n')
	if err != nil {
		panic(err)
	}

	drop := 1
	if len(line) > 1 && line[len(line)-2] == '\r' {
		drop = 2
	}
	line = line[:len(line)-drop]

	r.cur = 0
	r.buf = strings.Split(line, " ")
}

func (r *rdBuffer) isFull() bool {
	if r.cur == len(r.buf) {
		return true
	}
	return false
}

func (r *rdBuffer) resetCur() {
	r.cur = 0
}

func (r *rdBuffer) next() string {
	if r.cur == 0 {
		r.readln()
	}
	res := r.buf[r.cur]
	r.cur++
	if r.isFull() {
		r.resetCur()
	}
	return res
}

func (r *rdBuffer) nexts() []string {
	r.readln()
	r.resetCur()
	return r.buf
}

func (r *rdBuffer) nextByte() byte {
	if r.cur == 0 {
		r.readln()
	}
	res := r.buf[r.cur][0]
	r.cur++
	if r.isFull() {
		r.resetCur()
	}
	return res
}

func (r *rdBuffer) nextInt() int {
	if r.cur == 0 {
		r.readln()
	}
	res, _ := strconv.Atoi(r.buf[r.cur])
	r.cur++
	if r.isFull() {
		r.resetCur()
	}
	return res
}

func (r *rdBuffer) nextInts() []int {
	r.readln()
	res := make([]int, len(r.buf))
	for i, _ := range r.buf {
		res[i], _ = strconv.Atoi(r.buf[i])
	}
	r.resetCur()
	return res
}

func (r *rdBuffer) nextFloat() float64 {
	if r.cur == 0 {
		r.readln()
	}
	res, _ := strconv.ParseFloat(r.buf[r.cur], 64)
	r.cur++
	if r.isFull() {
		r.resetCur()
	}
	return res
}

func (r *rdBuffer) nextFloats() []float64 {
	r.readln()
	res := make([]float64, len(r.buf))
	for i, _ := range r.buf {
		res[i], _ = strconv.ParseFloat(r.buf[i], 64)
	}
	r.resetCur()
	return res
}

func _max(x, y int) int {
	return int(math.Max(float64(x), float64(y)))
}

func _min(x, y int) int {
	return int(math.Min(float64(x), float64(y)))
}

func _abs(x int) int {
	return int(math.Abs(float64(x)))
}

// Searchable
// idx := lower_bound([]int{-199, -1, 0, 2, 4, 67, 100, 8435}, 60)
// => idx = 5
//
// No present
// idx := lower_bound([]int{-199, -1, 0, 2, 4, 67, 100, 8435}, 10000)
// => idx = 8
func lower_bound(a []int, x int) int {
	return sort.SearchInts(a, x)
}

func dump(value ...interface{}) {
	for _, v := range value {
		fmt.Fprintf(os.Stderr, "%#v\n", v)
	}
}

func Yes() {
	writer.WriteString("Yes\n")
}

func yes() {
	writer.WriteString("yes\n")
}

func No() {
	writer.WriteString("No\n")
}

func no() {
	writer.WriteString("no\n")
}


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

typedef long long LL;
typedef pair<int, int> II;

const int MAXN = (int)2e5 + 10;
int n, a[MAXN], f[MAXN];

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

    for (int i = 1; i <= n; ++i) {
        f[i] = -(int)1e9;
    }
    f[0] = 0;

    int ans = 0;
    for (int i = 1; i <= n; ++i) {
        ans = max(ans, f[a[i] - 1] + 1);
        f[a[i]] = max(f[a[i]], f[a[i] - 1] + 1);
    }

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

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;

using ll = long long;

ll gcd(ll a, ll b){
    if(a < b) std::swap(a, b);

    ll result = b;
    while(a % result != 0){
        result = a % b;
        a = b;
        b = result;
    }

    return result;
}

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

int main() {
    ll a, b;
    cin >> a >> b;
    cout << gcm(a, b) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <vector>

using namespace std;

#define pb push_back
#define mp make_pair
#define ll long long
#define ull unsigned ll
#define db double
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define PII pair<int, int>

const int N=1<<17;
int n,m,l,r;
int cnt[100005],ans[100005];
vector<int> dv[100005],back[100005];
int s[2*N];

void upd(int x,int l,int r,int pos,int val) {
    if (l+1>=r) {
        s[x]+=val;
        return;
    }
    int m=(l+r)>>1;
    if (pos>m) upd(2*x+1,m,r,pos,val);
    else upd(2*x,l,m,pos,val);
    s[x]=s[2*x]+s[2*x+1];
}

int query(int x,int l,int r,int lq,int rq) {
    if (lq<=l&&r<=rq) {
        return s[x];
    }
    if (lq>=r||rq<=l) {
        return 0;
    }
    int m=(l+r)>>1;
    return query(2*x,l,m,lq,rq)+query(2*x+1,m,r,lq,rq);
}

int main() {
    scanf("%d%d",&n,&m);
    for (int i=0;i<n;i++) {
        scanf("%d%d",&l,&r);
        cnt[r]++;
        back[l-1].pb(r);
    }

    for (int i=1;i<=m;i++) {
        for (int j=i;j<=m;j+=i) {
            dv[j].pb(i);
        }
    }

    for (int i=m;i>=1;i--) {
        upd(1,0,N,i,cnt[i]);
        for (int j=0;j<back[i].size();j++) {
            upd(1,0,N,back[i][j],-1);
        }
        for (int j=0;j<dv[i].size();j++) {
            int v=dv[i][j];
            ans[v]+=query(1,0,N,0,i+v-1);
        }
    }

    for (int i=1;i<=m;i++) {
        printf("%d\n",ans[i]);
    }
}

Measured memory_bytes: 17792
N = int(input())
l = []
for i in range(N):
	a, b = map(int, input().split())
	l.append((b, a))
l.sort()
t = 0
x = 0
for i in range(N):
	t += l[i][1]
	if t > l[i][0]:
		x = 1
		break
if x == 1:
	print('No')
else:
	print('Yes')

Measured memory_bytes: 29444
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define mp make_pair
#define PI pair<int,int>
#define poly vector<ll>
#define mem(a) memset((a),0,sizeof(a))
#define For(i,l,r) for(int i=(int)(l);i<=(int)(r);i++)
#define Rep(i,r,l) for(int i=(int)(r);i>=(int)(l);i--)
#define pb push_back
#define fi first
#define se second
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline ll read(){
	ll x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(ll a){
    if(a<0){
    	a=-a; putchar('-');
	}
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(ll a){write(a); puts("");}
inline void wri(ll a){write(a); putchar(' ');}
inline ull rnd(){
	return ((ull)rand()<<30^rand())<<4|rand()%4;
}
const int mod=998244353;
map<string,int> f,g;
int F(string s);
int G(string s){
	auto it=g.find(s); if(it!=g.end())return it->second;
	int n=s.length(); if(n==1)return s[0]+1;
	int ans=0;
	For(i,1,n-1)if(n%i==0){
		string zs;
		For(j,0,i-1){
			int zt=1;
			for(int k=j;k<n;k+=i)zt&=s[k];
			zs+=zt;
		}
		ans=(ans+F(zs))%mod;
	}
	return g[s]=ans;
}
int F(string s){
	auto it=f.find(s); if(it!=f.end())return it->second;
	int n=s.length(); if(!n)return 1;
	int ans=0;
	For(i,1,n){
		ans=(ans+(ll)G(s.substr(0,i))*F(s.substr(i,n)))%mod;
	}
	return f[s]=ans;
}
int main(){
	string s; cin>>s;
	for(auto &i:s)i-='0';
	cout<<F(s)<<endl;
}

Measured memory_bytes: 12928
#include<bits/stdc++.h>
using namespace std;
typedef long long ll ;
ll a[200000+5], s[200000+5];
ll const c=1e9+7;
int main()
{
    ll n, l, i, k, j, m ;
    cin >> n ;
    for(i=1; i<=n; i++)
    {
        cin >> a[i];
        s[i]=a[i];
        s[i]=(s[i]+s[i-1])%c;
    }
    m=0;
    for(i=2; i<=n; i++)
    {
        k=(a[i]*s[i-1])%c;
        m+=k;
        m%=c;
    }
    cout << m ;
    return 0;
}

Measured memory_bytes: 6744
#include <iostream>
#include <cstdio>
#include <vector>
#include <cstring>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <stack>
#include <set>
#include <queue>
#include <algorithm>
#include <deque>
#include <map>
#include <cmath>
#include <type_traits>
using namespace std;

#define INF 1e18
#define int long long

signed main() {
    int n, c, k; cin >> n >> c >> k;
    vector<int> t(n);
    for(int i = 0; i < n; i++) cin >> t[i];

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

    int i = 0;
    int ans = 0;
    while(i < n) {
        int range = t[i] + k;
        int cnt = 0;
        while(t[i] <= range &&  cnt < c) {
            cnt++;
            i++;
        }
        ans++;
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024