akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <string>
#include <limits.h>
#include <vector>
#include <numeric>
#include<random>
#include<queue>



using namespace std;

#define lli long long int

vector<pair<long long int, long long int>> getPrimeElements(long long int num) {

	long long int firstnum = num;

	vector<pair<long long int, long long int>> result;
	pair<long long int, long long int> wk;

	if (num % 2 == 0) {
		wk.first = 2;
		wk.second = 0;
		while (num % 2 == 0) {
			wk.second++;
			num /= 2;
		}

		result.push_back(wk);
	}

	long long int waru = 3;

	while (true) {

		if (num % waru == 0) {
			wk.first = waru;
			wk.second = 0;
			while (num % waru == 0) {
				wk.second++;
				num /= waru;
			}

			result.push_back(wk);
		}
		waru += 2;

		if (waru * waru > num) break;

	}

	if (num != 1) {
		wk.first = num;
		wk.second = 1;
		result.push_back(wk);

	}

	return result;
}


int getKeta(int num) {

	if (num == 0)return 1;

	int res = 0;

	while (num > 0) {
		num /= 10;
		res++;
	}

	return res;
}

vector<int> bunkai(int num) {

	string str = to_string(num);
	vector<int> res;

	for (int i = 0; i < str.size(); i++) {
		int a = str[i] - '0';
		res.push_back(a);
	}

	return res;

}

struct SegmentTree {
private:
	int n;
	vector<long long int> node;
	int TANNI;

public:

	long long int Func(long long int a, long long int b) {
		return (a + b);
	}



	
	//元配列ｖをセグメント木で表現する。
	SegmentTree(vector<long long int> v, int tanni) {
		//最下段のノード数は元配列のサイズ以上になる最小の2冪　-> これを n とおく
        // セグメント木全体で必要なノード数は 2n-1 個である
		int sz = v.size();
		n = 1; while (n < sz) n *= 2;

		TANNI = tanni;
		node.resize(2 * n - 1, TANNI);

		//最下段に値を入れた後に、下の段から順番に値を入れる。
		//値を入れるには、自分の子の２値を参照すればよい。
		for (int i = 0; i < sz; i++)node[i + n - 1] = v[i];
		for (int i = n - 2; i >= 0; i--)node[i] = Func(node[2 * i + 1], node[2 * i + 2]);

	}

	void update(int x, long long int val) {
		//最下段のノードにアクセスする。葉の要素がｎ個。葉以外の要素がｎ－１なので、ｎ－１を足せばよい。
		x += (n - 1);

		//最下段のノードを更新したら、あとは親に上って更新していく。
		node[x] = val;
		while (x > 0) {
			x = (x - 1) / 2;
			node[x] = Func(node[2 * x + 1], node[2 * x + 2]);
		}
	}

	//[a, b)の半閉区間内では答えがどうなるか。
	//k := 自分がいるノードのインデックス
	//対象区間は[l,r)にあたる。
	long long int getAns(int a, int b, int k = 0, int l = 0, int r = -1) {

		//最初に呼び出された時の対象区間は[0,n)
		if (r < 0) r = n;

		//要求区間と対象区間が交わらない　⇒単位元を返す
		if (r <= a || b <= l) return TANNI;
		
		//要求区間が対象区間を完全に被覆　⇒対象区間を答えの計算に使う。
		if (a <= l && r <= b)return node[k];

		//要求区間が対象区間の一部を被覆する場合　⇒子の探索を行う。
		//左の子をvl, 右側の子をvrとしている。
		//新しい対象区間は、現在の対象区間を半分に割ったもの。
		int vl = getAns(a, b, 2 * k + 1, l, (l + r) / 2);
		int vr = getAns(a, b, 2 * k + 2, (l + r) / 2, r);

		return Func(vl, vr);
	}
};


int main()
{

	int k;
	cin >> k;
	
	queue<long long int> a;

	for (long long int i = 1; i < 10; i++)a.push(i);

	long long int ans = 0;

	for (long long int i = 0; i < k; i++) {

		ans = a.front();
		a.pop();

		long long int amari = ans % 10;

		if (amari != 0)a.push(ans * 10 + amari - 1);
		a.push(ans * 10 + amari);
		if (amari != 9)a.push(ans * 10 + amari + 1);
	}

	cout << ans << endl;


	return 0;
}




Measured memory_bytes: 1792
#include "bits/stdc++.h"
using namespace std;

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);
	
	int n, x, t;
	cin >> n >> x >> t;
	cout << t*(n/x + (n%x ? 1 : 0));
}

Measured memory_bytes: 3628
import java.util.Scanner;

class Main {
	static Node node;
	static Node root;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String ins;
		for (int i = 0; i < n; i++) {
			ins = sc.next();
			if (ins.equals("print")) {
				inorder(root);
				System.out.println();
				preorder(root);
				System.out.println();
			} else if (ins.equals("insert")) {
				Node z = new Node();
				z.key = sc.nextInt();
				insert(z);
			}

		}
	}
	static void inorder(Node node) {
		if (node == null) return;
		inorder(node.l);
		System.out.print(" " + node.key);
		inorder(node.r);
	}

	static void preorder(Node node) {
		if (node == null) return;
		System.out.print(" " + node.key);
		preorder(node.l);
		preorder(node.r);
	}

	static void insert(Node z) {
		if (root == null) {
			root = z;
			return;
		}
		Node y = null;
		Node x = root;
		while (x != null) {
			y = x;
			if (z.key < x.key) x = x.l;
			else x = x.r;
		}

		if (z.key < y.key) y.l = z;
		else y.r = z;
	}
}

class Node {
	int key;
	Node l;
	Node r;
	Node() {
		key = -1;
		l = null;
		r = null;
	}
}

Measured memory_bytes: 213984
#include<stdio.h>
#include<math.h>
int main(void)
{
	int n=0,i;
	double x[21], y[21],s=0;

	while (scanf("%lf,%lf",&x[n],&y[n])!=EOF){
		n++;
	}
	x[n] = x[0];
	y[n] = y[0];
	for (i = 0; i < n; i++) {
		s += (x[i] - x[i + 1])*(y[i] + y[i + 1]);
	}
	s = fabs(s);
	printf("%.6lf\n",s/2);
	return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define forin(in) for(int i=0; i<(int)in.size(); i++) cin>>in[i]
#define forout(out) for(int i=0; i<(int)out.size(); i++) cout<<out[i]<<endl
#define rep(i, n) for(int i=0; i<(n); i++)
int main(){
    int a, b; cin>> a >> b;
    for(int i=0; i<max(a, b); i++) cout<< min(a, b);
    cout<< endl;
}


Measured memory_bytes: 3608
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <math.h>
#include <sstream>
#include <numeric>
#include <string>
#include <cassert>
#include <bitset>

using namespace std;
typedef long long ll;

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

  int mn = P[0];
  int count = 1;

  for (int i = 1; i < N; ++i) {
    if (P[i] <= mn) {
      mn = P[i];
      count++;
    }
  }

  cout << count << endl;
  
  return 0;
}


Measured memory_bytes: 1024
(defun atgc-seq (lst-f x y)
  (let* (
         (n-f (nth (+ x y) lst-f)))
    (if (and n-f (cond ((char= n-f #\A) t)
              ((char= n-f #\T) t)
              ((char= n-f #\C) t)
              ((char= n-f #\G) t)
              (t nil)))
        (atgc-seq lst-f x (1+ y))
        y)))

(let* ((lst (concatenate 'list (read-line))))
  (princ (reduce #'max (loop :for a :from 0 :upto (1- (length lst)) :collect(atgc-seq lst a 0)))))

Measured memory_bytes: 12384
N = int(input())
S = input()

EP = [0]*(N+1)
WP = [0]*(N+1)
CP = [0]*N
for T in range(0,N):
    EP[N-T-1] = EP[N-T]+(S[N-1-T]=='E')
    WP[T+1] = WP[T]+(S[T]=='W')
for T in range(0,N):
    CP[T] = EP[T+1]+WP[T]
print(min(CP))

Measured memory_bytes: 44584
while True:
    m, f, r = map(int, input().split())
    if m == -1 and f == -1 and r == -1:
        exit()
    if m == -1 or f == -1:
        print('F')
        continue
    if m + f >= 80:
        print('A')
    elif 65 <= m + f < 80:
        print('B')
    elif 50 <= m + f < 65:
        print('C')
    elif 30 <= m + f < 50:
        if r >= 50:
            print('C')
        else:
            print('D')
    elif m + f < 30:
        print('F')


Measured memory_bytes: 5596
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
string s; 
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0),cout.tie(0);
	cin>>s;
	if(s=="ABC") cout<<"ARC";
	else cout<<"ABC";
	return 0;
}

Measured memory_bytes: 3624
import java.util.Scanner;

public class Main {

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

		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int x = sc.nextInt();
		int y = sc.nextInt();
		sc.close();
		int ans = 0;
		int min = x < y ? x : y;
		int minac = a <= c*2 ? a : c*2;
		int minbc = b <= c*2 ? b : c*2;
		
		if(a+b <= c*2) {
			ans = a*x + b*y;
		}else {
			ans = c*2*min + minac*(x-min) + minbc*(y-min); 
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 23764
import java.io.BufferedReader;
import java.io.InputStreamReader;
 
public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line;
        while ((line = br.readLine()) != null) {
            String[] arr = line.split(" ");
            int a = Integer.parseInt(arr[0]);
            String op = arr[1];
            int b = Integer.parseInt(arr[2]);
            if ("?".equals(op))
                break;
 
            if ("+".equals(op))
                System.out.println(a + b);
            else if ("-".equals(op))
                System.out.println(a - b);
            else if ("*".equals(op))
                System.out.println(a * b);
            else if ("/".equals(op))
                System.out.println(a / b);
        }
    }
}

Measured memory_bytes: 16916
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define REP(i,n) for (int i=0;i<(int)n; ++i)


typedef pair<int,int> pii;
int main() {
  int a, b;
  while(cin >> a>>b,a||b) {
    vector<pii> v1, v2;
    for (int i=1; i*i<=a; ++i) {
      if (a%i == 0) {
        v1.push_back(pii(i, a/i));
      }
    }
    for (int i=1; i*i<=b; ++i) {
      if (b%i == 0) {
        v2.push_back(pii(i, b/i));
      }
    }
    int res = 1<<29;
    REP(i,v1.size()) {
      REP(j, v2.size()) {
        vector<int> tmp;
        tmp.push_back(v1[i].first);
        tmp.push_back(v1[i].second);
        tmp.push_back(v2[j].first);
        tmp.push_back(v2[j].second);
        sort(tmp.begin(), tmp.end());
        int aa = 0;
        REP(k,3)
          aa += (tmp[k+1]-tmp[k]) * (tmp[k+1]-tmp[k]);
        res = min(res, aa);
      }
    }
    cout << res << endl;
  }
}

Measured memory_bytes: 908
N = int(input())
ans = [0 for _ in range(10050)]

for x in range(1, 105):
    for y in range(1, 105):
        for z in range(1, 105):
            v = x * x + y * y + z * z + x * y + y * z + z * x
            if v < 10050:
                ans[v] += 1

for i in range(N):
    print(ans[i + 1])


Measured memory_bytes: 74108
sent = map(str, raw_input())

for i in range(len(sent)-4):
    if sent[i] == 'a' and sent[i+1] == 'p' and sent[i+2] == 'p' and sent[i+3] == 'l' and sent[i+4] == 'e':
        sent[i], sent[i+1], sent[i+2], sent[i+3], sent[i+4], = 'p','e','a','c','h'
    elif sent[i] == 'p' and sent[i+1] == 'e' and sent[i+2] == 'a' and sent[i+3] == 'c' and sent[i+4] == 'h':
        sent[i], sent[i+1], sent[i+2], sent[i+3], sent[i+4], = 'a','p','p','l','e'

 
print ''.join(sent)    

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

void pass(int l, int x, int n);

int ans;
bool toru[8];
vector<int> road[8];
signed main()
{
    int n, m, a, b;

    cin >> n >> m;
    for(int i=0 ;i<m ;i++ ){
        cin >> a >> b;

        road[a-1].push_back(b-1);
        road[b-1].push_back(a-1);
    }
    pass(0, 0, n);

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

void pass(int l, int x, int n)
{   
    toru[x] = true;
    if(l == n-1){
        ans++;
    }
    else{
        for(int i=0 ;i<road[x].size() ;i++ ){
            if(toru[road[x][i]] == false){

                pass(l+1, road[x][i], n);
                toru[road[x][i]] = false;
            }
        }
    }

    return;
}

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

typedef long long ll;

const int Maxn = 3005;
const int Maxd = 4;

int R, C, K;
int B[Maxn][Maxn];
ll dp[Maxn][Maxn][Maxd];

int main()
{
    scanf("%d %d %d", &R, &C, &K);
    for (int i = 0; i < K; i++) {
        int r, c, val; scanf("%d %d %d", &r, &c, &val);
        B[r - 1][c - 1] = val;
    }
    for (int i = 0; i < R; i++)
        for (int j = 0; j < C; j++)
            for (int k = 0; k < Maxd; k++) {
                if (i + 1 < R && k + 1 < Maxd)
                    dp[i + 1][j][0] = max(dp[i + 1][j][0], dp[i][j][k] + B[i][j]);
                if (j + 1 < C && k + 1 < Maxd)
                    dp[i][j + 1][k + 1] = max(dp[i][j + 1][k + 1], dp[i][j][k] + B[i][j]);
                if (i + 1 < R)
                    dp[i + 1][j][0] = max(dp[i + 1][j][0], dp[i][j][k]);
                if (j + 1 < C)
                    dp[i][j + 1][k] = max(dp[i][j + 1][k], dp[i][j][k]);
            }
    ll res = 0;
    for (int k = 0; k < Maxd; k++)
        if (k + 1 < Maxd) res = max(res, dp[R - 1][C - 1][k] + B[R - 1][C - 1]);
        else res = max(res, dp[R - 1][C - 1][k]);
    cout << res << endl;
    return 0;
}


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

using namespace std;

int wa[100007];

int main()
{
    long long int n, i, j, q, tz, a, b, s=0;
    cin >> n;
    for(i=0; i<n; i++){
        cin >> tz;
        wa[tz]++;
        s+=tz;
    }
    cin >> q;
    for(i=0; i<q; i++){
        cin >> a >> b;
        s+=wa[a]*(b-a);
        wa[b]+=wa[a];
        wa[a]=0;
        cout << s << '\n';
    }
    return 0;
}


Measured memory_bytes: 3948
#define _USE_MATH_DEFINES
#include <iostream>
#include <algorithm>
#include <queue>
#include <stack>
#include <deque>
#include <climits>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
//#include <tuple>

#define INF INT_MAX>>1 
#define SIZE 100010
#define MOD 1000000007
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define rep2(i, from, to) for(int i=(from); i<(int)(to); i++)
#define all(obj) (obj).begin(), (obj).end()
#define lpair pair<ll, ll>
#define vint vector<ll>
#define vinput(name) for(int i=0; i<(int)(name.size()); i++) cin >> name[i];
#define voutput(name) for(int i=0; i<(int)(name.size()); i++) cout << name[i] << endl;
typedef long long ll;

using namespace std;

ll ans = 0;

int main(void){
	ll x, y, a, b, c; cin >> x >> y >> a >> b >> c;
	vector<lpair> app;
	rep(i, a){
		int t; cin >> t;
		app.push_back(make_pair(t, 1));
	}
	rep(i, b){
		int t; cin >> t;
		app.push_back(make_pair(t, 2));
	}
	rep(i, c){
		int t; cin >> t;
		app.push_back(make_pair(t, 0));
	}
	sort(all(app), [](auto l, auto r){return l.first > r.first; });

	int size = x+y;
	int i = 0;
	while(1){
		if(size <= 0) break;
		lpair p = app[i];
		if(p.second == 1){
			if(x > 0){
				ans += p.first;
				size--;
				x--;
			}
		} else if(p.second == 2){
			if(y > 0){
				ans += p.first;
				size--;
				y--;
			}
		} else{
			if(size > 0){
				ans += p.first;
				size--;
			}
		}
		i++;
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;

#define int long long
// #define double long double
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define FORR(i, a, b) for(ll i = (a); i > (b); --i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define bitcnt __builtin_popcount
#define SZ(x) ((ll)(x).size())
#define fi first
#define se second
#define All(a) (a).begin(), (a).end()
#define rAll(a) (a).rbegin(), (a).rend()
template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CCIN(...)                                                              \
    char __VA_ARGS__;                                                          \
    CIN(__VA_ARGS__)
#define DCIN(...)                                                              \
    double __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Printv(v)                                                              \
    {                                                                          \
        REP(x, v.size()) { cout << v[x] << (x == v.size() - 1 ? "\n" : " "); } \
    }
template <typename T = string> inline void eputs(T s) {
    cout << s << "\n";
    exit(0);
}
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    std::fill((T *)array, (T *)(array + N), val);
}
template <typename T> using PQG = priority_queue<T, vector<T>, greater<T>>;
template <typename T> using PQ = priority_queue<T>;

typedef long long ll;
typedef pair<ll, ll> PL;
typedef vector<PL> VPL;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<double> VD;

#define uni int;

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
const ll dx[] = {1, 0, -1, 0};
const ll dy[] = {0, 1, 0, -1};
#define PI 3.141592653589793238

VL x, y, a, b;
VL memo[26];

signed main() {
    SCIN(s, t);
    ll slen = s.length(), tlen = t.length();
    REP(i, slen) { memo[s[i] - 'a'].emplace_back(i); }
    REP(i, tlen) {
        if(memo[t[i] - 'a'].size() == 0) eputs(-1);
    }
    ll idx = -1, ans = 0;
    REP(i, tlen) {
        if(upper_bound(All(memo[t[i] - 'a']), idx) == memo[t[i] - 'a'].end()) {
            idx = -1;
            ans += slen;
            i--;
        } else {
            idx = *upper_bound(All(memo[t[i] - 'a']), idx);
        }
    }
    cout << ans + idx + 1 << "\n";
}


Measured memory_bytes: 1724
s=input()
res="AC"
if s[0]!="A":res="WA"
elif s[2:-1].count("C")!=1:res="WA"
else:
    li=list(s)
    li.remove("A")
    li.remove("C")
    for i in li:
        if i!=i.lower():
            res="WA"
print(res)

Measured memory_bytes: 9100
x, k, d = map(int, input().split())

mod = x % d
mod_d = d - mod

if x >= 0:
    if x - d * k >= 0:
        print(x - d * k)
    else:
        k -= (x - mod) // d
        if k % 2 == 0:
            print(mod)
        else:
            print(mod_d)
    
else:
    if x + d * k <= 0:
        print(abs(x + d * k))
    else:
        k -= (-x + mod) // d
        if k % 2 == 0:
            print(mod)
        else:
            print(mod_d)

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

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rep2(i, a, b) for (ll i = (a); i < (b); i++)
#define chmax(x, v)                                                            \
  do {                                                                         \
    x = max(x, v);                                                             \
  } while (0)
#define chmin(x, v)                                                            \
  do {                                                                         \
    x = min(x, v);                                                             \
  } while (0)
typedef uint64_t ull;
typedef int64_t ll;
typedef std::pair<ll, ll> PLL;

using namespace std;

ll mpow(ll x, ll y, ll m) {
  if (y == 0)
    return 1;
  else if (y % 2 == 1)
    return x * mpow(x, y - 1, m) % m;
  else
    return mpow(x * x % m, y / 2, m) % m;
}

template <std::int64_t M> class modint {
 public:
  int64_t a;

  explicit constexpr modint(const int64_t x = 0) noexcept
      : a((x % M + M) % M) {}
  constexpr int64_t &value() noexcept { return a; }
  constexpr const int64_t &value() const noexcept { return a; }
  constexpr modint operator+(const modint rhs) const noexcept {
    return modint(*this) += rhs;
  }
  constexpr modint operator-(const modint rhs) const noexcept {
    return modint(*this) -= rhs;
  }
  constexpr modint operator*(const modint rhs) const noexcept {
    return modint(*this) *= rhs;
  }
  constexpr modint operator/(const modint rhs) const noexcept {
    return modint(*this) /= rhs;
  }
  constexpr modint &operator+=(const modint rhs) noexcept {
    a += rhs.a;
    if (a >= M) {
      a -= M;
    }
    return *this;
  }
  constexpr modint &operator-=(const modint rhs) noexcept {
    if (a < rhs.a) {
      a += M;
    }
    a -= rhs.a;
    return *this;
  }
  constexpr modint &operator*=(const modint rhs) noexcept {
    a = a * rhs.a % M;
    return *this;
  }
  constexpr modint &operator/=(modint rhs) noexcept {
    int64_t exp = M - 2;
    while (exp) {
      if (exp % 2) {
        *this *= rhs;
      }
      rhs *= rhs;
      exp /= 2;
    }
    return *this;
  }
};

const ll M = 1000000007;
using mint = modint<M>;
ll N;
vector<ll> c;

signed main() {
  cin >> N;
  c.resize(N);
  rep(i, N) {
    cin >> c[i];
  }
  sort(begin(c),end(c));
  mint p(0); // X = S^T 、S = T^X において、T=0..0としたときの答えをpとする
  rep(i, N) {
    // 桁iの左右にある幅をl,rとする
    ll l = i;
    ll r = (N-l-1);

    mint num_bit; // = (2^r + 2^(r-1) * r) * 2^l
    {
      if (r > 0) {
        num_bit = mint(mpow(2, r, M)) + mint(mpow(2, r-1, M)) * mint(r);
      } else{
        num_bit = mint(1);
      }
      num_bit *= mint(mpow(2, l, M));
    }

    p += num_bit * mint(c[i]);
    // printf("i=%d num_bit=%d l=%d r=%d\n", i, num_bit.value(), l, r);
  }

  mint ans = p * mint(mpow(2, N, M));
  cout << ans.value() << endl;
  return 0;
}


Measured memory_bytes: 1792
while True:
    sum=1
    count=0
    n=int(input())
    if n==0:
        break
    for i in range(1,n+1):
        sum*=i
        i+=1
    while True:
        if sum%10==0:
            count+=1
            sum-=sum//10
        else:
            break
    print(count)


Measured memory_bytes: 5628
#include <iostream>
#include <fstream>
#include <typeinfo>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<25;
const double pi=acos(-1);
const double eps=1e-8;
const vi emp;

typedef pair<int,double> T;

int n;

int main(){
	while(1){
		cin>>n;
		if(!n) break;
		T ans(-1,inf);
		int num,w;
		double h;
		for(int i=0;i<n;i++){
			cin>>num>>h>>w;
			h/=100;
			double Sa=fabs(w/(h*h)-22);
			if(fabs(ans.second-Sa)<eps){
				if(ans.first>num) ans=T(num,Sa);
			}
			else if(ans.second>Sa) ans=T(num,Sa);
		}
		cout<<ans.first<<endl;
	}
}

Measured memory_bytes: 1228
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author silviase
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        FManyManyPaths solver = new FManyManyPaths();
        solver.solve(1, in, out);
        out.close();
    }

    static class FManyManyPaths {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            ModInt ans = new ModInt(0);
            ModComb mc = new ModComb(2000005);
            int r1 = in.nextInt();
            int c1 = in.nextInt();
            int r2 = in.nextInt();
            int c2 = in.nextInt();
            for (int i = r1; i <= r2; i++) {
                ans = ans.add(mc.combFac(c2 + i + 1, c2)).sub(mc.combFac(c1 + i, i + 1));
                // out.println(mc.combFac(c2+i+1,c2));
                // out.println(mc.combFac(c1+i,i+1));
            }

            out.println(ans.getVal());

        }

    }

    static class ModInt {
        long val;
        int MOD = (int) 1e9 + 7;

        public ModInt(long i) {
            this.val = (i + MOD) % MOD;
        }

        public ModInt mul(long l) {
            return new ModInt(this.val * l);
        }

        public ModInt add(ModInt m) {
            return new ModInt(this.val + m.getVal());
        }

        public ModInt sub(ModInt m) {
            return new ModInt(this.val - m.getVal());
        }

        public ModInt inv() {
            return this.pow(MOD - 2);
        }

        public ModInt pow(long l) {
            ModInt res = new ModInt(1);
            ModInt v = new ModInt(this.val);
            while (l > 0) {
                if (l % 2 != 0) {
                    res = res.mul(v.val);
                }
                v = v.mul(v.val);
                l /= 2;
            }
            return res;
        }

        public long getVal() {
            return val;
        }

        public String toString() {
            return Long.toString(val);
        }

    }

    static class ModComb {
        private int size;
        private ModInt[] fac;
        private ModInt[] inv;

        public ModComb(int n) {
            size = n;
            fac = new ModInt[n + 1];
            inv = new ModInt[n + 1];
            makeFac();
        }

        private void makeFac() {
            for (int i = 0; i <= size; i++) {
                if (i == 0) {
                    fac[i] = new ModInt(1);
                } else {
                    fac[i] = fac[i - 1].mul(i);
                }
                inv[i] = fac[i].inv();
            }
        }

        public ModInt combFac(int n, int k) {
            if (n < k) {
                return new ModInt(0);
            }
            return fac[n].mul(inv[k].getVal()).mul(inv[n - k].getVal());
        }

    }
}



Measured memory_bytes: 441288
#include <stdio.h>
#define MAX 10000

int parent(int);
int left(int);
int right(int);

int main(){
  int H, i, A[MAX + 1];

  scanf("%d", &H);
  for(i = 1; i <= H; i++) scanf("%d", &A[i]);

  for(i = 1; i <= H; i++){
    printf("node %d: ", i);
    printf("key = %d, ", A[i]);
    if(parent(i)) printf("parent key = %d, ", A[parent(i)]);
    if(left(i) <= H) printf("left key = %d, ", A[left(i)]);
    if(right(i) <= H) printf("right key = %d, ", A[right(i)]);
    printf("\n");
  }
  
  return 0;
}
int parent(int i){
  return i / 2;
}
int left(int i){
  return i * 2;
}
int right(int i){
  return i * 2 + 1;
}



Measured memory_bytes: 2048
#include <stdio.h>

int main(void)
{
    int a, b, c, d, e, f;
    double det, x, y;

    while (scanf("%d %d %d %d %d %d",
           &a, &b, &c, &d, &e, &f) != EOF) {
        det = a * e - b * d;
        x = (e * c + -b * f) / det;
        y = (-d * c + a * f) / det;
        printf("%.3f %.3f\n", x + 0, y + 0);
    }

    return 0;
}

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


int is_prime(int x)
{
    int square = sqrt(x);
    int i, j;

    if(x == 2)
        return 1;

    if(x < 2 || x % 2 == 0)
        return 0;

    for(i = 3; i <= square; i += 2){
        if(x % i == 0)
            return 0;
    }

    return 1;
}

int main(void)
{
    int a, d, n;

    while(1){
        int prime_no = 0;
        int prime_now = 0;
        scanf("%d %d %d", &a, &d, &n);

        if(a == 0 && d == 0 && n == 0)
            break;

        while(prime_no != n){
            if(is_prime(a)){
                prime_now = a;
                prime_no++;
            }

            a += d;
        }

        printf("%d\n", prime_now);
    }

    return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <utility>
#include <numeric>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#ifdef _DEBUG_
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl
#else
#define dump(val)
#endif

using namespace std;

typedef long long int ll;

template<typename T>
vector<T> make_v(size_t a, T b) {
    return vector<T>(a, b);
}
template<typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v(ts...))>(a, make_v(ts...));
}

using P = pair<int, int>;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    vector<ll> A(n);
    REP(i, 0, n) {
        cin >> A[i];
    }
    sort(A.begin(), A.end());
    vector<P> OP(m);
    REP(i, 0, m) {
        cin >> OP[i].second >> OP[i].first;
    }
    sort(OP.rbegin(), OP.rend());
    int pos = 0;
    REP (i, 0, m) {
        while (pos < n && A[pos] < OP[i].first && OP[i].second) {
            A[pos++] = OP[i].first;
            OP[i].second--;
        }
    }
    cout << accumulate(A.begin(), A.end(), 0LL) << endl;

    return 0;
}


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

int main() {
  bool    f = true;
  string  s;
  cin >> s;
  if (s.size() % 2 == 1) {
    f = false;
  } else {
    for(int i=0;i<s.size();i+=2) {
      if (s.at(i)!='h') f = false;
      if (s.at(i+1)!='i') f = false;
    }
  }
  if (f) cout << "Yes" << endl;
  else cout << "No" << endl;
}


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

using namespace std;

vector<vector<long long int>>path;

pair<long long int, long long int>recursive(set<long long int>used, set<long long int>now){
	if( now.size() == 0 ){
		return make_pair(0, 1);
	}
	set<long long int>next;
	long long int countmax = 1;
	for( auto s : now ){
		long long int count = 0;
		for( auto t : path[s] ){
			if( !used.count(t) ){
				next.insert(t);
				count++;
			}
		}
		countmax = max(count, countmax);
		used.insert(s);
	}
	auto ret = recursive(used, next);
	ret.first++;
	ret.second *= countmax;
	return ret;
}

int main(){
	long long int N;
	cin >> N;
	path = vector<vector<long long int>>(N);
	vector<pair<long long int, long long int>>p(N - 1);
	for( size_t i = 0; i < N - 1; i++ ){
		long long int a, b;
		cin >> a >> b;
		a--; b--;
		path[a].push_back(b);
		path[b].push_back(a);
		p[i] = make_pair(a, b);
	}
	pair<long long int, long long int>ans = make_pair(1LL << 60, 1LL << 60);
	for( size_t i = 0; i < N; i++ ){
		set<long long int>tmp;
		tmp.insert(i);
		auto ret = recursive(tmp, tmp);
		if( ans.first > ret.first || ( ans.first == ret.first&&ans.second > ret.second ) ){
			ans = ret;
		}
	}
	for( auto x : p ){
		set<long long int>tmp;
		tmp.insert(x.first);
		tmp.insert(x.second);
		auto ret = recursive(tmp, tmp);
		ret.second *= 2;
		if( ans.first > ret.first || ( ans.first == ret.first&&ans.second > ret.second ) ){
			ans = ret;
		}
	}
	cout << ans.first << " " << ans.second << endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define endl "\n"
#define ll long long int
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1000000007
#define inf 1000000000000000001;
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define f first
#define s second
#define MAXN 1000007
#define fr(i, s, e, st) for(ll (i) = (s); (i) < (e); (i) += (st))
#define fre(i, s, e, st) for(ll (i) = (s); (i) <= (e); (i) += (st))
#define fastio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);cout<<fixed;cout<<setprecision(10);
 
using namespace std;

int main()
{
    fastio;
    int T = 1;
    //cin>>T;
    while(T--){
        string n, m;
        cin>>n>>m;
        if(n>m)
            fr(i, 0, stoll(n), 1)
                cout<<m;
        else
            fr(i, 0, stoll(m), 1)
                cout<<n;
    }                
    return 0;
}



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

void Cont(){

    int A,fl5=0,fl7=0;
    for(int i=0;i<3;i++){
        cin >> A;
        if(A==5)fl5++;
        else if(A==7)fl7++;
    }
    if(fl5==2&&fl7==1)
        cout << "YES" << "\n";
    else
        cout << "NO" << "\n";
    
    
}

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


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>//sort,reverse
#include<utility>//pair
#include<queue>//queue,priority queue
#include<deque>//double_ended queue
using namespace std;
typedef long long LL;
int main()
{ 
    LL A,B;
    cin>>A>>B;
    //ビットデータ変換10^12<2^40より40ビット
    //まず2^kのデータを41桁作っておく
    LL n[41];
    LL k=1;
    for(int i=0;i<41;i++){
        n[i]=k;
        k=k*2;
    }
    //1からA-1まで、1からBまでの排他的論理和を計算
    A=A-1;
    int A1[40];
    int B1[40];
    for(int i=0;i<40;i++){A1[i]=0;B1[i]=0;}
    if(A%4==1||A%4==2){A1[0]=1;}
    if(B%4==1||B%4==2){B1[0]=1;}
    for(int i=1;i<40;i++){
        if(A%n[i+1]!=A%n[i]){A1[i]=((A%n[i]+1)%2);}
        if(B%n[i+1]!=B%n[i]){B1[i]=((B%n[i]+1)%2);}
    }
    //cout<<A1[0]<<A1[1]<<A1[2]<<endl;
    //引き算は足し算に同じ
    int C1[40];
    for(int i=0;i<40;i++){C1[i]=(A1[i]+B1[i])%2;}
    //数のデータに直す。
    LL c=0;
    for(int i=0;i<40;i++){
        c=c+n[i]*C1[i];
    }
    cout<<c<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long int ll;
typedef unsigned long long int ull;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> o_set;

#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define     int                 ll
#define     xx                  first
#define     yy                  second    
#define     all(a)              a.begin(),a.end()
#define     present(DT, val)    (DT.find(val) != DT.end()) //for set and map
#define     cpresent(DT, val)   (find(all(DT),val) != DT.end()) //vectors
#define     input               "/home/pollution/Desktop/WorkSpace/C++/Files/input.txt"
#define     output              "/home/pollution/Desktop/WorkSpace/C++/Files/output1.txt"
#define     error               "/home/pollution/Desktop/WorkSpace/C++/Files/error.txt"
#define     IO()                ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define     INF                 2e18
#define     MOD                 1000000007
#define     clr(x)              memset(x, 0, sizeof(x))
#define     out(a)              for (auto i: a) cout<<i<<' '; cout<<'\n'
#define     setd(val,n)         cout<<fixed<<setprecision(n)<<val<<'\n'

void solve(){
    int x;
    cin >> x;
    if(x==0){
    	cout << "1\n";
    }
    else{
    	cout << "0\n";
    }
}

signed main() { 
    IO();
    
    int t=1;
    //cin>>t;
    while(t--) solve();
    return 0; 
}

Measured memory_bytes: 3664
#include<iostream>
using namespace std;
 
int main(){
  int N,K;
  cin >> N >> K;
  K = K-1;
  
  string S;
  cin >> S;
  
  if(S[K]=='A'){
    S[K]='a';
  }else if(S[K]=='B'){
    S[K]='b';
  }else{
    S[K]='c';
  }
    
  cout << S;
  return 0;
}

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

typedef long long ll;
typedef vector<long long> VLL;
typedef vector<pair<int,int>> VP;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define MOD (1e9+7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
/*--------------------------------------------*/

ll N,M;

void pri(ll num){
  int s = to_string(num).size();
  
  rep(i,6 - s) cout << '0';
  cout << num;
}

int main(){
  cin >> N >> M;
  
  map<pair<ll,ll>,ll> m;
  
  vector<pair<ll,ll> > P(M),Q(M);
  rep(i,M){
    ll a, b;
    cin >> a >> b;
    P[i].first = a;
    P[i].second = b;
    Q[i].first = a;
    Q[i].second = b;
  }
  
  sort(ALL(P));
  
  m[P[0]] = 1;
  
  REP(i,M){
    if(P[i].first == P[i-1].first){
      m[P[i]] = m[P[i-1]] + 1;
    }else{
      m[P[i]] = 1;
    }
  }
  
  rep(i,M){
    pri(Q[i].first);
    pri(m[Q[i]]);
    cout << endl;
  }
  
}

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

int main(){
  int N, i;
  double ans;
  cin >> N;
  if(N%2 == 0){
    ans = N/2;
  } else {
    ans = N/2 + 1;
  }
  
  ans = ans/N;
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(ll i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll h;
  cin >> h;
  ll c = 0;
  while(h > 0) {
    c++;
    h /= 2;
  }
  cout << (1LL << c) - 1 << endl;
}

Measured memory_bytes: 3620
#include<iostream>
#include<algorithm>
#include<climits>
#include<vector>
#include<utility>
#include<cmath>
#include<cstring>
#include<map>
#include<sstream>
 
using namespace std;
 
bool is_count (int i) {
  		if(i%2 == 1){
          return 1;
        }
        if(i%3 == 0){
          return 1;  
        }else if(i%5 == 0){
          return 1;
        }
  return 0;
}

int main(){
size_t n_count=0;
int N;
  cin>>N;
  
  int H[N];  
    for(int i = 0; i < N; i++)
    cin>>H[i];
  
  vector<int>	v(H, H+N);
  
  n_count = std::count_if(v.begin(), v.end(), is_count);
  
  if (N == n_count){
  cout << "APPROVED" << endl;
  }else{
    cout << "DENIED" << endl;
  }
  
  
}


Measured memory_bytes: 256
///
// File:  c.go
// Author: ymiyamoto
//
// Created on Thu Dec 27 13:18:28 2018
//
package main

import (
	"fmt"
)

func main() {
	var H, W int
	fmt.Scan(&H, &W)

	graph := make([]string, H)
	for i := range graph {
		fmt.Scan(&graph[i])
	}

	for i := range graph {
		for j := range graph[i] {
			if graph[i][j] == '#' {
				valid := false
				for _, d := range []int{-1, 1} {
					if 0 <= i+d && i+d < H && graph[i+d][j] == '#' {
						valid = true
					}
					if 0 <= j+d && j+d < W && graph[i][j+d] == '#' {
						valid = true
					}
				}
				if !valid {
					fmt.Println("No")
					return
				}
			}
		}
	}

	fmt.Println("Yes")
}


Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){

  int N,K;
  cin>>N>>K;
  vector<int>h(N);
  for(int i=0;i<=N-1;i++){
  
    cin>>h[i];
  }
  sort(h.begin(),h.end());
  int ans=-1;
  int check=0;
  for(int i=K-1;i<=N-1;i++){
  
    check=h[i]-h[i-K+1];
    if(ans>check||ans==-1)ans=check;
  }
  cout<<ans;
  return 0;
}

Measured memory_bytes: 3696
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
 
 
void swap (int *x, int *y) {
  int temp;    
 
  temp = *x;
  *x = *y;
  *y = temp;
}
 
int gcd(int a,int b){
  if(a<b){
    swap(&a,&b);
  }
 
  if(b==0){
    return a;
  }
 
  int r=a%b;
  while(r!=0){
    a = b;
    b = r;
    r = (a%b);
  }
 
  return b;
}
 
/* クイックソート */
int dn(const void*a,const void*b){return*(int*)b-*(int*)a;}
 
 
int modpow(int a,int n,int mod){
  int ans=1;
  while(n>0){
    if(n & 1){
      ans=ans*a%mod;
    }
    a=a*a%mod;
    n/=2;
  }
  return ans;
}
 
int max(int a,int b){
  if(a<b){
    return b;
  }
  else{
    return a;
  }
}
 
int min(int a,int b){
  if(a<b){
    return a;
  }
  else{
    return b;
  }
}
 
void chmax(int *a,int b){
  if(*a < b){
    *a = b;
  }
 
  return;
}
 
void chmin(int *a,int b){
  if(*a > b){
    *a =b;
  }
 
  return;
}
 

int main(void){
  long int x,k,d;
  scanf("%ld%ld%ld",&x,&k,&d);
  long int len;
  if(x<0){
    len=-x;
  }else{
    len=x;
  }
  long int mvc=len/d;
  long int mod=len%d;
  long int dif=len-d*mvc;
  if(len==d && k%2==0){
    printf("%ld\n",len);
    return 0;
  }
  if(len==d && k%2==1){
    printf("0\n");
    return 0;
  }
  if(len<d){
    if(d<2*len && k%2==1){
      printf("%ld\n",d-len);
      return 0;
    }else if(d<2*len && k%2==0){
      printf("%ld\n",len);
      return 0;
    }else if(2*len<d && k%2==1){
      printf("%ld\n",d-len);
      return 0;
    }else if(2*len<d && k%2==0){
      printf("%ld\n",len);
      return 0;
    }
  }
  if(k<mvc){
    printf("%ld\n",len-k*d);
    return 0;
  }else{
    if((k-mvc)%2==1){
      printf("%ld\n",(mvc+1)*d-len);
      return 0;
    }else{
      printf("%ld\n",len-mvc*d);
      return 0;
    }
  }
}

Measured memory_bytes: 1732
n=int(input())
ab = []
for _ in range(n):
    a, b = (int(x) for x in input().split())
    ab.append([a, b])
ab = sorted(ab, key=lambda x: x[1])

limit = 0

for i, j in ab:
    limit += i
    if j < limit:
        print('No')
        exit()
print('Yes')

Measured memory_bytes: 89176
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < n; i++)
using ll = long long;
using namespace std;
const int INF = 1e9;

int numToDig(int a) {
    return to_string(a).size();
}

int main() {

    ll N;
    cin >> N;

    int ans = 10;
    for (int i = 1; i <= sqrt(N); i++) {
        if (N % i == 0) {
            ans = min(ans, max(numToDig(i), numToDig(N / i)));
        }
    }

    cout << ans << endl;

    return 0;
}

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

int main(){
    int n;
    cin >> n;
    if(n%10==2 || n%10==4 || n%10==5 || n%10==7 || n%10==9){
        cout << "hon" << endl;
        return 0;
    }
    else if(n%10==3){
        cout << "bon" << endl;
        return 0;
    }
    else{
        cout << "pon" << endl;
        return 0;
    }
}

Measured memory_bytes: 3624
#include<stdio.h>
#include<stdlib.h>

struct node{
  struct node *R;
  struct node *L;
  struct node *parent;
  int key;
};

typedef struct node * Node;

Node root;

Node tMin(Node);
Node tMax(Node);
Node tSea(Node,int);
Node tSor(Node);
void tDel(Node);
void insert(int);
void inorder(Node);
void preorder(Node);

int main()
{
  int n, i, x;
  char meirei[20];
  
  scanf("%d",&n);/*命令数入力*/
  
  for (i=0;i<n;i++)
    {
      scanf("%s",meirei);/*何の命令か入力*/
      
      if (meirei[0]=='f')/*findが入力された場合*/
	{
	  scanf("%d",&x);/*探す数入力*/
	  
	  Node t = tSea(root,x);/*xがあるかどうか探す*/
	  if ( t != NULL ) printf("yes\n");
	  else printf("no\n");
	}
      else if (meirei[0]=='i')/*insertが入力された場合*/
	{
	  scanf("%d", &x);
	  insert(x);/*二分木にroot追加*/
	}
      else if ( meirei[0] == 'p' )/*printが入力された場合*/
	{
	  inorder(root);/*中間順巡回*/
	  printf("\n");
	  preorder(root);/*先行順巡回*/
	  printf("\n");
	}
      else if ( meirei[0] == 'd' )/*dereteが入力された場合*/
	{
	  scanf("%d", &x);
	  tDel(tSea(root, x));/*削除*/
	}
    }

  return 0;
}

Node tMin(Node x)
{
  while(x->L!=NULL)
    {
      x=x->L;
    }
  return x;
}

Node tMax(Node x)
{
    while(x->R!=NULL)
    {
      x=x->R;
    }
  return x;
}

Node tSea(Node x, int k)
{
  if(x==NULL||k==x->key)return x;
  if(k<x->key)return tSea(x->L,k);
  else return tSea(x->R,k);
}

Node tSor(Node x)
{
  Node y;
  
  if(x->R!=NULL)return tMin(x->R);

  y=x->parent;
  while(y!=NULL&&x==y->R)
    {
      x=y;
      y=y->parent;
    }
  return y;
}

void tDel(Node z)
{
  Node y; // node to be deleted
  Node x; // child of y

  if(z->L==NULL||z->R==NULL)y=z;
  else y=tSor(z);

  if(y->L!=NULL)x=y->L;
  else x=y->R;

  if(x!=NULL)x->parent=y->parent;
  if(y->parent==NULL)root=x;
  else if(y==y->parent->L)y->parent->L=x;
  else  y->parent->R=x;

  if(y!=z)z->key=y->key;
}

void insert(int k)
{
  Node y = NULL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  
  z->key = k;
  z->L = NULL;
  z->R = NULL;

  while(x!=NULL)
    {
      y=x;
      if(z->key<x->key)x=x->L;
      else x=x->R;
    }
  z->parent=y;

  if(y==NULL)root=z;
  else if(z->key<y->key)y->L=z;
  else y->R=z;
}

void inorder(Node u)
{
  if(u==NULL)return;
  
  inorder(u->L);
  printf(" %d",u->key);
  inorder(u->R);
}
void preorder(Node u)
{
  if(u==NULL)return;
  printf(" %d",u->key);
  preorder(u->L);
  preorder(u->R);
}



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

int main() {
  int x,y,z;
  cin>>x>>y>>z;
  swap(x,y);
  swap(x,z);
  cout<<x<<" "<<y<<" "<<z<<endl;
}

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

int main() {
    cin >> s;
    bool flg = true;
    int slen = s.length();
    if(slen % 2 != 0) flg = false;

    if(flg) {
        for(int i = 0; i < slen; ++i) {
            if(i % 2 == 0) {
                if(s.at(i) != 'h') flg = false;
            }else {
                if(s.at(i) != 'i') flg = false;
            }
        }
    }

    if(flg) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

using namespace std;
int main(int argc, char const *argv[]) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  string ans;
  cin >> s;

  for (auto && c : s) {
    switch (c) {
    case 'A':
      ans += 'T';
      break;
    case 'T':
      ans += 'A';
      break;
    case 'G':
      ans += 'C';
      break;
    case 'C':
      ans += 'G';
      break;
    }
  }


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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) (v).begin(), (v).end()
using ll = long long;
constexpr int INF = 1e9;
constexpr long long LINF = 1e18;
constexpr long long MOD = 1e9 + 7;

signed main() {
    int n;
    cin >> n;
    ll a[n];
    map<ll, int> cnt;
    rep(i, n) {
        cin >> a[i];
        cnt[a[i]]++;
    }
    sort(a, a + n);
    reverse(a, a + n);
    int ans = 0;
    ll cur = 1LL << 33;
    rep(i, n) {
        if (cnt[a[i]] == 0) continue;
        while (a[i] < cur / 2) {
            cur /= 2;
        }
        if (cnt[cur - a[i]] > (cur == a[i] * 2)) {
            ans++;
            cnt[a[i]]--;
            cnt[cur - a[i]]--;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 30108
#include<bits/stdc++.h>
using namespace std;
string calc(int n){
  string s;
  int x=1;
  while(n){
    char c='0'+n%4;
    s=c+s;
    n/=4;
  }
  return s;
}
int main(){
  int n;
  while(cin>>n,n!=-1){
    if(n==0) cout << 0 << endl;
    else cout << calc(n) << endl;
  }
  return 0;
}

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

int main() {
    int N, M;
    string S;
    cin >> N >> M >> S;

    reverse(S.begin(), S.end());
    int idx = 0;
    vector<int> ans;
    while (idx != N) {
        for (int move = min(M, N - idx); move >= 0; move--) {
            if (move == 0) {
                cout << -1 << endl;
                return 0;
            }

            if (S[idx + move] == '0') {
                ans.push_back(move);
                idx += move;
                break;
            }
        }
    }

    for (int i = ans.size() - 1; i >= 0; i--) {
        cout << ans[i] << (i ? " " : "\n");
    }
}

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

using namespace std;
#define ll  long long
#define ld  long double
#define endl '\n'
#define FAST ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const ll MOD = 1e9 + 7;
const double PI = 3.141592653589793238463;
const int MAXN = 2e5 + 5;

void debug_out() {
    cerr << endl;
}

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

#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

int main() {
    FAST
    int n;
    cin>>n;
    int arr[n];
    map<int,vector<int>>m;
    for(int i=1;i<n;i++)
        cin>>arr[i];
    for(int i=1;i<n;i++)
    {
        m[arr[i]].push_back(i+1);
    }
    for(int i=0;i<n;i++)
    {
        cout<<m[i+1].size()<<endl;
    }
    return 0;
}


Measured memory_bytes: 26228