akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long int a,ans=1,max=1e18;
  int n;
  bool flag=false;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a;
    if(!a){
      ans=0;
      flag=false;
    }
    else if(ans>max/a)flag=true;
    ans*=a;
  }
  if(flag)cout<<"-1"<<endl;
  else cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3616
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <algorithm>
#include <random>
#include <chrono>
#include <iomanip>
#define lint long long int
#define FOR(x, to) for(int x=0; x<(int)(to); x++) // for簡略表記
#define DUMP(ar) for(int loop=0; loop<(int)ar.size(); loop++) cout << "[" << loop << "]:" << ar[loop] << endl // 配列一覧表示
#define DUMPL(ar) for(int loop=0; loop<(int)ar.size(); loop++) { cout << ar[loop]; if(loop<(int)ar.size()-1) cout << ' '; } cout << endl; // 配列一行一覧表示
#define COUT(x) cout << x << endl // 単要素出力
#define ALL(ar) ar.begin(), ar.end() // コンテナの全要素
#define LOOPD(i) cout << "ループ[" << i << "]回目---------------" << endl // ループ回数デバグ
using namespace std;
// cout << fixed << setprecision(4) で小数点以下4桁の桁そろえ
// cout << setw(5) << ... で表示形式を5桁に設定 5桁未満なら頭に空白がつく 5桁越なら先頭から5桁まで
// cout << setw(5) << setfill('0') << ... で空白部分の埋め文字に5を使う
// getline(cin, [変数]); で空白などを含む入力の受け取り(行ごとの受け取り)
// cin >> ws; でそこまでにストリームに残されたホワイトスペースを取り除く(=以降のgetlineの有効化)

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

    int n, a, b;
    cin >> n;
    if(n == 1){
        COUT("Hello World");
        return 0;
    }
    cin >> a >> b;

    
    COUT(a + b);
    

    return 0;
}

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

int main(){
  int64_t n,a,b,o;
  cin >> n >> a >> b;
  o = n/(a+b)*a;
  if(n%(a+b)>a){o=o+a;}else{o=o+(n%(a+b));}
  cout << o << endl;
}

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

using namespace std;

int main(){
	int q,i,a,b,j;
	string str,m_str,t_str;
	string a_str,b_str;
	string c;

	cin>>str;
	cin>>q;
	for(i = 0;i < q;i++){
		cin>>m_str;
		cin>>a>>b;
		if(m_str == "print")
			cout<<str.substr(a,b-a+1)<<endl;
		else if(m_str == "reverse"){
			reverse(str.begin()+a,str.begin()+b+1);
		}
		else if(m_str == "replace"){
			cin>>t_str;
			str.replace(str.begin()+a,str.begin()+b+1,t_str);
		}
	}
	return 0;
}

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

int main() {
  int n;
  cin >> n;
  double a,res;
  for(int i=0;i<n;i++){
    cin >> a;
    res+=1.0/a;
  }
  cout<<std::fixed<<std::setprecision(10)<< 1.0/res << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

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

		String line = sc.nextLine();

		char[] arr = new char[line.length()];

		for(int i = 0 ; i < line.length();i++) {
			arr[i] = line.charAt(i);
			if(Character.isLowerCase(arr[i])) {
				System.out.print(Character.toUpperCase(arr[i]));
			} else if(Character.isUpperCase(arr[i])) {
				System.out.print(Character.toLowerCase(arr[i]));
			} else {
				System.out.print(arr[i]);
			}
		}
		System.out.println();

	}

}



Measured memory_bytes: 26940
import java.util.*;

public class Main {
    
    
        
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        int c = Integer.parseInt(sc.next());
        
        if(c - (a - b) >= 0) {
            System.out.println(c - (a - b));
        }else {
            System.out.println(0);
        }
    }
    
}

Measured memory_bytes: 23764
#include<stdio.h>
int main(){
	int i,j,b[10],f=0,c=0;
	long a[10],num;
	a[0]=1;
	for(i=1;i<10;i++){
		a[i]=a[i-1]*8;
	}
	for(i=0;i<10;i++){
		b[i]=0;
	}
	for(;;){
		scanf("%ld",&num);
		if(num==0){
			break;
		}
		c=0;f=0;
		for(i=9;i>=0;i--){
			while(f==0){
				if(num>=a[i]){
					num-=a[i];
					c++;	
				}else{
					b[i]=c;
					c=0;
					f=1;
				}
			}
			f=0;
		}
		f=0;
		i=9;
		while(f==0){
			if(b[i]!=0){
				f=1;
				j=i;
			}
			i--;
		}
		for(i=j;i>=0;i--){              
			if(b[i]==4){
				b[i]+=1;
				printf("%d",b[i]);
			}else if(b[i]>=5){
				b[i]+=2;
				printf("%d",b[i]);
			}else{
				printf("%d",b[i]);
			}
		}
		printf("\n");
	}
		return 0;
}

Measured memory_bytes: 0
#include <cstdio>
#include <algorithm>

using namespace std;

int gcd(int x, int y){ return y == 0 ? x : gcd(y, x % y); }
int lcm(int x, int y){ return x / gcd(x, y) * y; }

int main()
{
	int x, y;
	while (~scanf("%d%d", &x, &y)){
		printf("%d %d\n", gcd(x, y), lcm(x, y));
	}
}

Measured memory_bytes: 1024
import java.math.BigInteger;
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.Scanner;

class Main {
    static final int MOD = 1000000007;
    static final int INF = 1 << 30;

    Main() {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        boolean ans = false;
        for (int a = 0; a <= 1000; a++) {
            if (a * a == Integer.parseInt(String.valueOf(A) + B))
                ans = true;
        }
        System.out.println(ans ? "Yes" : "No");
    }

    public static void main(String[] args) {
        new Main();
    }
}


Measured memory_bytes: 21972
#include<iostream>
#include<string>
#include<algorithm>    
#include<cmath>
#include<map>
#include<vector>
#include<math.h>
#include<stdio.h>
#include<stack>
#include<queue>
#include<tuple>
#include<cassert>
#include<set>
#include<functional>
//#include<bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1000000000000;
const int mod = 1000000007;
int dx[4] = { 1, 0, -1, 0 }, dy[4] = { 0, 1, 0, -1 };
int test[12345678], aa[12345678];
signed main() {
	int n, m, a, ans = 0; cin >> n >> m;
	for (int h = 0; h < n; h++) {
		cin >> a; test[a % m]++; aa[a]++;
	}
	ans += test[0] / 2; test[0] = 0;
	for (int h = 1; h < m; h++) {
		//cout << test[h] << ' ' << test[m - h] << endl;
		if (h != (m - h)) {
			int x = test[h], y = test[m - h];
			ans += min(x, y); test[h] -= min(x, y); test[m - h] -= min(x, y);
		}
		else {
			ans += test[h] / 2; test[h] = 0;
		}
		//cout << ans << endl;
	}
	for (int h = 1; h <= 100000; h++) {
		ans += min(test[h % m], aa[h]) / 2;
		test[h % m] -= aa[h] / 2 * 2; test[h % m] = max(test[h % m], (long long)0);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3072
/*　　　　　　　{:i:i:|i:i:/l/l--　 　 　--l/li:i:i|i:i:i:i}
　　　　　　 　 {:rx|:i:i ィi芥ミ 　 　 .ィi芥ミｉ:ｉ|ﾍ:i:i:}
.　　　 　 　 　 ｛ﾏ|ｉ:  {::’:} 　 　 　{:‘::} :ｉ:i:|〉｝:/
　　 　 　 　 　 乂|:i:| ｀¨¨¨¨´ 　 　　｀¨¨¨´  :i:ｉ:|ｼ/
　 　 　 　 　 　 ﾉ:|:i|　　　　　　′　　　 　   |:i:i:|ﾂ
　　　　　　　　/:/|:i:| ､　　　 　_ _ 　　　　  |:i:i:|
　 　 　　 　 /:/ .|:i:|/ ＼　　　 　 　     ｨ〔|:i:/
　　 　 　  　 〈;/ く刈＿ 个 　   -   　＜}　./|/_〉
　　     　　 r-っ'~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ|___
　　 　     /／ニつ　　　　　　 ､　　　　　　　ノﾆﾆ　＼
.　　　     |　　ニ⊃ 　./　/　 ──   /　/　　..⊆ﾆﾆ　　:|
.　　　     |　　丁´　 /|￣|￣  ─‐ /|￣|￣ 　 .￣|丁 　|
.　　　     |　　ﾉ.  　 |￣|￣  ─‐  |￣|￣ 　 　.|八 　|
.　　　     |　　||. 　 |￣|￣ |￣| |￣|￣ 　   .|　|
.　 　 　   |  　||   　￣￣￣　￣ 　￣￣￣　　  .|　|  |
.　 　 　  　    ||＿＿＿＿＿＿＿＿＿＿＿＿______|__　　 ',
　 　      ,′　 | ７ﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆ}  ,′
.　　     {　　　|/　}ﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆ{/ 　 　
*///讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐。
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <limits>

using namespace std;

#define rep(a) _rep(0,int(a))
#define repj(a) for(int j=0;j<int(a);j++)
#define repk(a) for(int k=0;k<int(a);k++)
#define _rep(a,b) for(int i=int(a);i<int(b);i++)
#define ll long long
#define fst first
#define snd second
#define pf(b) printf("%.12f\n",(double)b)
#define _GLIBCXX_DEBUG
const double pai = 3.1415926535897;
#define _cos(n) cos(n*pai/180)
#define l_b lower_bound
#define u_b upper_bound
#define b_s binary_search

//factorial(練習)　階乗
int fact(int n) {
	int a = 1;
	for (int i = 1;i <= n;i++) a *= i;
	return a;
}
int sa(int n, int m) {      //差！
	if (n < m)return m - n;
	else return n - m;
}
int keta(int num) {
	int n = 0;
	if (num == 0) {
		return 1;
	}
	while (num != 0) {
		num /= 10;
		n++;
	}
	return n;
}
int gcd(int n, int m) {
	
	int a = 0;
	return 0;
}

int x[5];

signed main() {
	rep(5) {
		cin >> x[i];
		if (x[i] == 0)cout << i + 1 << endl;
	}
}


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

using namespace std;

#define pb push_back
#define endl '\n'
#define all(x) (x).begin(),(x).end()
#define ff first
#define ss second
#define sz(x) (int)(x).size()
#define f(n) for(int i=0;i<n;++i)
#define f2(n) for(int j=0;j<n;++j)
#define f3(n) for(int k=0;k<n;++k)
#define F(i,x,n,y) for(int i=x;i<n;i+=y)
#define FF(i,x,n,y) for(int i=x;i>=n;i-=y)
#define fa(x,y) for(auto x:y)

typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long long ll;

//Warsaw debug template
#define LOCAL
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
    enable_if<sizeof dud<c>(0) x 1,debug&>::type operator<<(c i){
sim > struct rge {c b,e;};
sim > rge<c> range(c i, c j) {return rge<c>{i,j};}
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug{
#ifdef LOCAL
~debug() {cerr<<endl; }
eni(!=) cerr<< boolalpha << i; ris;}
eni(==) ris <<range(begin(i),end(i)); }
sim, class b dor(pair<b,c> d){
ris<<"("<<d.first<<","<<d.second<<")";
}
sim dor(rge<c> d){
    *this << "[";
    for(auto it=d.b;it!=d.e;++it)
        *this <<"," +(it==d.b)<< *it;
    ris<<"]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) "["<<#__VA_ARGS__":"<<(__VA_ARGS__)<<"]"
//End of debug template

int main(){
    ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    int n,x;
    cin>>n>>x;
    vi l(n);
    f(n) cin>>l[i];
    int cur=0;
    int ans=1;
    f(n){
        cur=l[i]+cur;
        if(cur>x) break;
        ++ans;
    }
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 3644
//be name khoda
//Pedram Sadeghian
// :)
#include <bits/stdc++.h>
using namespace std;

const int maxN = 1e5;
int n, m, k1, k2, dad[maxN], high[maxN], ans;
pair <int, pair <int, int> > P[maxN]; 
int root(int a){
	if (dad[a] == a)
		return a;
	dad[a] = root(dad[a]);
	return dad[a];
}
void merrge(int a, int b){
	if (high[root(a)] > high[root(b)])
		swap(a, b);
	int newhigh = high[root(b)];
	if (high[root(a)] == high[root(b)])
		newhigh++;
	dad[root(a)] = root(b);
	high[root(a)] = newhigh;
	return ;
}
int main(){
	ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> n >> m;
	for (int i = 0 ; i < m ; i++){
		cin >> k1 >> k2 >> P[i].first;
		P[i].second.first = k1;
		P[i].second.second = k2;
	}
	sort(P, P + m);
	for (int i = 0 ; i < n ; i++){
		dad[i] = i;
		high[i] = 1;
	}
	for (int i = 0 ; i < m ; i++){
		 if (root(P[i].second.first) != root(P[i].second.second)){
		 	ans += P[i].first;
		 	merrge(P[i].second.first, P[i].second.second);
		 }
	}
	cout << ans << endl;
}

Measured memory_bytes: 4392
A = [i for i in input()]
B = [i for i in input()]
C = [i for i in input()]

turn = 'a'
while True:

    if turn == 'a':
        try:
            turn = A.pop(0)
        except:
            print('A')
            exit(0)
    elif turn == 'b':
        try:
            turn = B.pop(0)
        except:
            print('B')
            exit(0)
    elif turn == 'c':
        try:
            turn = C.pop(0)
        except:
            print('C')
            exit(0)





Measured memory_bytes: 3060
#include <iostream>
using namespace std;
 
int main(){
  int N;
  cin >> N;
  int A[N+1];
  int L[N+1];
 
  for(int i=1;i<N+1;++i){
     cin >> A[i];
  }
  A[0]=-1;
  L[0]=-1;
  L[1]=A[1];
  int length=1;
   
  for(int i=1;i<N+1;++i){
    if(L[length] < A[i]) L[++length] = A[i];
    if(L[1] > A[i] ) L[1]=A[i];
    else{
      int l=1,r=length,mid;
      while(l<=r){
    mid = (l+r)/2;
    if(A[i] == L[mid] || A[i] == L[mid+1]) break;
    else if(A[i]<L[mid+1] && L[mid]<A[i]){
      L[mid+1] = A[i];
      break;
    }else if(A[i]<L[mid]) r=mid;
    else  if(A[i]>L[mid]) l=mid;
      }
    }
     
  }
   
  cout << length << endl;
}

Measured memory_bytes: 1940
import numpy as np
def resolve():
    n, k = map(int, input().split())
    h = list(map(int, input().split()))
    h = np.sort(h)[::-1]
    total = 0
    for i in range(n):
        if i < k:
            continue
        else:
            total += h[i]
    print(total)
resolve()

Measured memory_bytes: 34208
#include <iostream>

int main(){
  int n;
  std::cin >> n;
  std::string s[n];
  for(int i=0; i<n; i++){
    std::cin >> s[i];
  }
  int n_ac=0, n_wa=0, n_tle=0, n_re=0;
  for(int i=0; i<n; i++){
    if(s[i] == "AC"){n_ac++;}
    if(s[i] == "WA"){n_wa++;}
    if(s[i] == "TLE"){n_tle++;}
    if(s[i] == "RE"){n_re++;}
  }
  
  std::cout << "AC x " << n_ac << std::endl;
  std::cout << "WA x " << n_wa << std::endl;
  std::cout << "TLE x " << n_tle << std::endl;
  std::cout << "RE x " << n_re << std::endl;
  
  return 0;
}


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

int main(void) {
  ll N, M;
  cin >> N >> M;

  if(N == 1 && M == 1) {
    cout << 1 << endl;
  } else if(N == 1) {
    cout << M - 2 << endl;
  } else if(M == 1) {
    cout << N - 2 << endl;
  } else {
    cout << (N - 2) * (M - 2) << endl;
  }
}


Measured memory_bytes: 256
import bisect
import os
from collections import Counter, deque
from fractions import gcd
from functools import lru_cache
from functools import reduce
import functools
import heapq
import itertools
import math
import numpy as np
import re
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")

A, B = list(map(int, sys.stdin.readline().split()))
S = sys.stdin.readline().rstrip()

ok = True
ok &= len(S) == A + B + 1
ok &= S[A] == '-'
ok &= bool(re.match('^[0-9]*$', S[:A] + S[A + 1:]))
if ok:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 13644
#include <algorithm>
#include <cstdio>
#include <map>

using namespace std;

const int MOD = 1e9 + 7;
typedef long long ll;

map<ll, ll> m;

ll f(ll n) {
  return m[n] > 0 ? m[n]
                  : (m[n] = (f(n / 2) + f((n - 1) / 2) % MOD + f((n - 2) / 2)) %
                            MOD);
}

int main() {
  ll n;
  scanf("%lld", &n);
  m[0] = 1;
  m[1] = 2;
  printf("%lld\n", f(n));
  return 0;
}


Measured memory_bytes: 256
N=int(input())
t,x,y=0,0,0
s=0
for i in range(N):
  a,b,c=map(int,input().split())
  p,q=a-t,abs(b-x)+abs(c-y)
  if p<q or p%2!=q%2:
    s=1
    break
  t,x,y=a,b,c
print("No" if s else "Yes")

Measured memory_bytes: 46056
/********************/
/* K B G D E L T A */
/*     DA-IICT      */
/********************/
 
#include<bits/stdc++.h>
using namespace std;
using   ll=long long;
using   ld=long double;
#define fast           ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define endl           "\n"
#define F(i,n)         for(ll i=0;i<n;i++)
#define rep(i,a,b)     for(ll i=a;i<b;i++)
#define repp(i,a,b)    for(ll i=a;i>=b;i--)
#define pb             push_back
#define mp             make_pair
#define vll            vector<ll>
#define f              first
#define s              second
#define pll            pair<ll,ll>
#define ALL(v)         v.begin(),v.end()
#define ALLR(v)        v.rbegin(),v.rend()
#define pii            3.14159265358979323
#define mod            1000000007
 
void solve()
{
    ll n,ans=LLONG_MAX;

    cin>>n;

    for(ll i=1;i<=sqrt(n);i++)
    {
        if(n%i==0)
        {
            ans=min(ans,i+n/i-2);
        }
    }

    cout<<ans;
}
 
signed main(){
 
    fast;
 
    ll t=1;
 
    while(t--)
    {
        solve();
    }
 
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
  int a, b;

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

  if ((a * b) % 2 == 0)
  {
    printf("Even\n");
  }
  else
  {
    printf("Odd\n");
  }

  return 0;
}

Measured memory_bytes: 128
A,B,C = map(int,input().split())
L = [A,B,C]
L.sort(reverse = True)
print(L[0]-L[1]+(L[0]-(L[2]+L[0]-L[1]))//2 if (L[0]-(L[2]+L[0]-L[1])) % 2 == 0 else L[0]-L[1]+(L[0]-(L[2]+L[0]-L[1]))//2+2)

Measured memory_bytes: 3064
N=int(input())
A=list(map(int,input().split()))
ans=0
f=[1]*(N+1)
las=A[N]
g=[las]*(N+1)
flag=1
for i in range(0,N):
    f[i+1]=2*(f[i]-A[i])
for i in range(N,0,-1):
    g[i-1]=g[i]+A[i-1]
#print(f,g)
for i in range(N+1):
    if min(f[i],g[i])<=0:
        flag=0
        break
    ans=ans+min(f[i],g[i])
if g[N]>f[N]:
    flag=0
if flag==0:
    print(-1)
else:
    print(ans)

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

using namespace std;
typedef long double ld;

vector<vector<vector<ld>>> memo;
int n;

ld solve(vector<int>& v) {
    if(v[0] == n) return 0;
    if(memo[v[1]][v[2]][v[3]] != -1) return memo[v[1]][v[2]][v[3]];

    // Expected value to pick one at this step
    ld ans = (ld)n / (n-v[0]);

    for(int i = 1; i <= 3; i++) {
        if(v[i] == 0) continue;
        vector<int> next = v;
        next[i]--;
        next[i-1]++;
        // Expected value later if we pick up one w/ this val
        ans += ((ld)v[i] / (n-v[0])) * solve(next);
    }

    memo[v[1]][v[2]][v[3]] = ans;
    return ans;
}

int main() {
    cin >> n;
    vector<int> v(4,0);
    for(int i = 0; i < n; i++) {
        int t;
        cin >> t;
        v[t]++;
    }

    memo.resize(n+1, vector<vector<ld>>(n+1, vector<ld>(n+1,-1)));

    cout << fixed;
    cout.precision(10);
    cout << solve(v) << endl;
}


Measured memory_bytes: 433536
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define P pair<int,int>
using ll=int64_t;
using namespace std;
#define ketasuu(n) fixed<<setprecision(n)
#define btoe(p) p.begin(),p.end()
#define etob(p) p.rbegin(),p.rend()




int main(){
    int n; cin>>n;
    n%=10;
    if(n==3) cout<<"bon"<<endl;
    else if(n==0 || n==1 || n==6 || n==8) cout<<"pon"<<endl;
    else cout<<"hon"<<endl;
}

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

#[fastout]
fn main() {
    input! {//
        n:usize,m:usize,
       mut ab:[(usize,usize);n],
    }
    // +b されていく
    // a まで

    let mut v = Vec::new();
    for (a, b) in ab {
        v.push((a, b));
    }
    v.sort();
    let mut hp = BinaryHeap::new();
    let mut ind = 0;
    let mut ans = 0;
    for day in 1..=m {
        while ind < n && v[ind].0 <= day {
            hp.push(v[ind].1);
            ind += 1;
        }
        if let Some(x) = hp.pop() {
            ans += x;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 6380
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long
#define pii pair<int, int>
#define pll pair<long long, long long>
#define ull unsigned long long
#define mp make_pair
#define F first
#define S second
#define mod 1000000007



int main()
{
    int n, k;
    scanf("%d%d", &n, &k);

    vector<int> a(n+1);
    vector<ll> dp(k+1);

    dp[0] = 1;
    for(int i=1; i<n+1; i++)
    {
        scanf("%d", &a[i]);
        vector<ll> t(k+1);
        for(int j=k; j>=0; j--)
        {
            int tmp = dp[j];
            int L = j+1;
            int R = min(j+ a[i], k);
            if(L<=R)
            {
                t[L] += tmp;
                t[L] %= mod;
                if(R+1 <= k)
                {
                    t[R+1] -= tmp; 
                    if(t[R+1] < 0)
                        t[R+1] += mod;
                }
            }
        }

        ll pr_sum = 0;
        for(int i=0; i<=k; i++)
        {
            pr_sum += t[i];
            pr_sum %= mod;
            dp[i] += pr_sum;
            dp[i] %= mod;
        }
    }
    
    printf("%lld\n", dp[k]);
}


Measured memory_bytes: 1920
import java.util.*;
public class Main {

	public static void main(String[] args) 
	{
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int d = sc.nextInt();
		int arr[][] = new int[n][d];
		for(int i=0;i<n;i++)
		{
			for(int j=0;j<d;j++)
			{
				arr[i][j] = sc.nextInt();
			}
		}
		int count=0;
		double dist = 0;
		for(int i=0;i<n-1;i++)
		{
			for(int j = i+1;j<n;j++)
			{
				for(int k = 0;k<d;k++)
				{
					dist += (double)(Math.pow(arr[i][k]- arr[j][k],2));
				}
				dist = (double)Math.sqrt(dist);
				//System.out.println(dist);
				double ans = Math.ceil(dist);
				
				if(ans == dist)
					count++;
				dist=0;
			}
		}
		System.out.println(count);
		sc.close();
	}

}


Measured memory_bytes: 21972
#include<stdio.h>
#include<iostream>
using namespace std;

int N;
int main (){
    cin >> N;
    int ans = 2000000003;
    for(int i=1; i<N; i++){
        int a,b = i;
        a = N - b;
        int sum = 0;
        for(int j=0; j<6; j++){
            sum += a % 10 + b % 10;
            a /= 10;
            b /= 10;
        }
        ans = min( ans, sum );
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
# でつoO(YOU PLAY WITH THE CARDS YOU'RE DEALT..)
import sys
from math import gcd
M = 10**6
def main(N, A):
    g = 0
    for a in A:
        g = gcd(g, a)
    if g > 1:
        print('not coprime')
        return

    u = [False] * (M + 1)
    cc = [0] * (M + 1)
    for a in A:
        cc[a] += 1
    for n in range(2, M + 1):
        if u[n]: continue
        c = 0
        for nn in range(n, M + 1, n):
            u[nn] = True
            c += cc[nn]
        if c >= 2:
            print('setwise coprime')
            return
    print('pairwise coprime')

if __name__ == '__main__':
    input = sys.stdin.readline
    N = int(input())
    *A, = map(int, input().split())
    main(N, A)


Measured memory_bytes: 221524
N, K = map(int, input().split())
V = list(map(int, input().split()))
M = min(N, K)
ans = 0
for A in range(M+1):
    for B in range(M+1-A):
        C = K - (A+B)
        p = []
        m = []
        for i in range(A):
            if V[i] >= 0:
                p.append(V[i])
            else:
                m.append(V[i])
        for i in range(B):
            if V[N-1-i] >= 0:
                p.append(V[N-1-i])
            else:
                m.append(V[N-1-i])
        m.sort()
        if C < len(m):
            m = m[C:]
        else:
            m = [0]
        tmp = sum(m)+sum(p)
        ans = max(ans, tmp)
print(ans)


Measured memory_bytes: 42348
import Control.Monad
import Control.Monad.Primitive (PrimState)
import qualified Data.Vector.Unboxed.Mutable as MV
import qualified Data.ByteString.Char8 as B
import Data.Maybe (fromJust)

solve :: MV.MVector (PrimState IO) Int -> MV.MVector (PrimState IO) Bool -> Int -> Int -> IO (Int, Int)
solve mva mvb i count = do
    next <- MV.unsafeRead mva i
    if next == 1
        then return (next, count)
        else do
            b <- MV.unsafeRead mvb next
            if b
                then return (next, count)
                else do
                    MV.unsafeWrite mvb next True
                    solve mva mvb next (count + 1)
main :: IO ()
main = do
    n <- fst . fromJust . B.readInt <$> B.getLine
    mva <- MV.replicate n 0 :: IO (MV.MVector (PrimState IO) Int)
    mvb <- MV.replicate n False :: IO (MV.MVector (PrimState IO) Bool)
    forM_ [0..(n - 1)] $ \i -> do
        a <- fst . fromJust . B.readInt <$> B.getLine
        MV.write mva i (a - 1)
    (stop, count) <- solve mva mvb 0 0
    print $ if stop == 1 then count + 1 else -1


Measured memory_bytes: 1916
#include<algorithm>
#include<string>
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef vector<vector<int> > vvi;
typedef vector<int> vi;
typedef vector<string> vst;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
 
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};



int main(){
    int x,t;
    cin >> x >> t;

    double xd=x,td=t;

    double ans=xd/td;

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <string>
using namespace std;
 
#define LM 100000
 
struct process{
    string name;
    int qms;
};
 
struct queue{
    static const int QM=LM;
    process *q;
    //process q[QM];
    process *qend;
 
    process *head,*tail;
    queue(){
        q=new process[QM];
        if(q==NULL)err("q is NULL");
        qend=q+QM-1;
         
        head=q;
        tail=q;
    }
    ~queue(){
        delete[] q;
    }
    bool isEmpty(){return head==tail;}
    bool isFull(){return (head-1)==tail;}
    void err(const char *s){cerr<<s<<endl;exit(1);}
    void inc(process* &p){
        if(p==qend){
            p=q;
        }else{
            p++;
        }
    }
    void enqueue(process x){
        if(isFull())err("enqueue:full");
        *tail=x;
        inc(tail);
    }
    void enqueue(string name,int qms){
        const process tmp={name,qms};
        enqueue(tmp);
    }
    process dequeue(){
        if(isEmpty())err("dequeue:empty");
        const process ans=*head;
        inc(head);
        return ans;
    }
};
 
int main(){
    queue qe;
    process *fnsh;
    fnsh=new process[LM];
    if(fnsh==NULL)qe.err("external error");
    //process fnsh[LM];
    process *fp=fnsh;
    int n,q;
    cin>>n>>q;
    for(int i=0;i<n;i++){
        string name;
        int qms;
        cin>>name>>qms;
        qe.enqueue(name,qms);
    }
    int time=0;
    while(true){
        if(qe.isEmpty()){
            break;
        }
        process proc=qe.dequeue();
        //cout<<"pr"<<time<<"ms "<<proc.name<<" "<<proc.qms<<endl;
        if(proc.qms<=q){
            *fp=proc;
            fp->qms=time+proc.qms;
            fp++;
            time+=proc.qms;
        }else{
            proc.qms-=q;
            qe.enqueue(proc);
            time+=q;
        }
    }
    for(int i=0;i<n;i++){
        cout<<fnsh[i].name<<" "<<fnsh[i].qms<<endl;
    }
 delete[] fnsh;
    return 0;
}


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

int main () {
 int r,g,b;
 cin >>r>>g>>b;
 int set =r*100+g*10+b;
 if(set%4 ==0){
   cout<<"YES"<<endl;
 }else{
   cout<<"NO"<<endl;
 }
 
}


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

using namespace std;
typedef long long ll; //10^18
typedef unsigned long ul;

#define MOD 1000000007LL

ll totalSumFirst(ll x, ll y) {
  	x = x - 1;
 	return (y*(y+1) -  x*(x+1)) / 2;
}

ll totalSumSecond(ll x, ll y) {
  	x = x - 1;
  	return(y*(y+1)*(2*y+1) - x*(x+1)*(2*x+1))/6;
}
  
signed main()
{

	ll n, k;
	cin >> n >> k;
    
    ll ans = ((n+1) * totalSumFirst(k, n+1) - totalSumSecond(k, n+1) + (n - k + 2)) % MOD;

	cout << ans << endl;

	return 0;
}


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

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

    int n, m;
    cin >> n >> m;

    int x[m];
    rep(i, m) {
        cin >> x[i];
    }

    sort(x, x+m);
    int diff[m-1];
    rep1(i, m) diff[i-1] = x[i]-x[i-1];
       
    sort(diff, diff+m-1, greater<int>());
    int res = 0;
    rep(i, m-1) {
        if(i < n-1) res += 0;
        else res += diff[i];
    }

    cout << res << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define REP(i,n,N) for(int i = n; i < (int) N; i++)
#define p(s)		cout<<(s)<<endl
using namespace std;

int main() {
	string s;
	cin>>s;
	char c=s[0];
	int ans=0;
	REP(i,1,s.size()){
		if(c!=s[i]) {
			ans++;
			c=s[i];
		}
	}
	p(ans);
	return 0;
}


Measured memory_bytes: 512
#include<stdio.h>
int main(){
    int i,j,n,a[101],t,p=0;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&a[i]);
    }
    for(i=0;i<n-1;i++){
        for(j=0;j<n-i-1;j++){
            if(a[j]>a[j+1]){
                t=a[j];
                a[j]=a[j+1];
                a[j+1]=t;
                p++;
            }
        }
    }
    for(i=0;i<n;i++){
        printf("%d",a[i]);
        if(i==n-1){printf("\n");}
        else{printf(" ");}
    }
    printf("%d\n",p);
}


Measured memory_bytes: 2084
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i,m,n) for(int i = m - 1; i >= n; i--)
#define ALL(v) v.begin(), v.end()
#define itn int
#define Yes() cout << "Yes" << endl
#define No() cout << "No" << endl
#define YES() cout << "YES" << endl
#define NO() cout << "NO" << endl
#define println(x) cout << x << endl
#define print(x) cout << x << " "
template<typename T, typename U>
inline bool CMAX(T &m, U x) { if (m < x) { m = x; return true; } return false; }
template<typename T, typename U>
inline bool CMIN(T &m, U x) { if (m > x) { m = x; return true; } return false; }

typedef long long lint;
typedef long double ldouble;
const int INF = 1e9;
const lint LINF = 1e18;
const int MOD = 1e9+7;
int main(){
    lint a,b,v,w,t;
    cin >>a >> v >> b >> w >> t;
    lint ax,bx;
    if(v <= w){ NO(); return 0;}
    if(a > b){
        ax = -v * t + a;
        bx = -w * t + b;
        if(ax > bx)
            NO();
        else YES();
    }else{
        ax = v * t + a;
        bx = w * t + b;
        if(ax < bx){
            NO();
        }else YES();
    }
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
//---------------------------
using namespace std;
//---------------------------
#define REP(i,n) for(int i = 0; i < (n); i++)
#define P(x) cout << (x) << "\n"

#define MOD 1e9+7
#define PI acos(-1.0)
#define ll long long
#define INF 1000000001

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

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

  // ifstream in("input.txt");
  // cin.rdbuf(in.rdbuf());

  string N;cin>>N;
  if(N[0]==N[1] &&N[1]==N[2]){
    P("Yes");
    return 0;
  }
  if(N[1]==N[2] &&N[2]==N[3]){
    P("Yes");
    return 0;
  }
  P("No");
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

void operate(char str[]);

int main(void)
{
	char str[200000];
	int n;
	
	while (1){
		scanf("%d", &n);
		if (n == 0){
			break;
		}
		
		scanf("%s", str);
		
		while (n){
			operate(str);
			n--;
		}
		
		printf("%s\n", str);
	}
	return (0);
}

void operate(char str[])
{
	char tmp[200000];
	char c;
	int i, j, l, k;
	int tmplen;
	int count;
	
	memset(tmp, 0, sizeof(tmp));
	l = tmplen = 0;
	while (str[l] != '\0'){
		c = str[l];
		i = l;
		j = 0;
		while (c == str[i]){
			j++;
			i++;
		}
		
		count = 0;
		k = j;
		while (k){
			count++;
			k /= 10;
		}
		
		i = count;
		k = j;
		while (count){
			tmp[tmplen + count - 1] = k % 10 + '0';
			k /= 10;
			count--;
		}
		tmplen += i;
		tmp[tmplen] = c;
		tmplen++;
		l += j;
	}
	strcpy(str, tmp);
}

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

using ll = long long;
#define rep(i, j) for(int i=0; i < (int)(j); i++)
#define all(v) v.begin(),v.end()
template<class T> istream& operator >> (istream &is , vector<T> &v) { for(T &a : v) is >> a; return is; }

// 1-based index!
template<typename T>
struct BIT {
    vector<T> data;
    BIT(size_t n) {
        data.resize(n + 1, 0);
    }
    //sum of [1, i]
    T sum(int i){
        assert(0 <= i);
        T s = 0;
        for(; i > 0; i -= i & -i) s += data[i];
        return s;
    }
    //add x to index i
    void add(int i, T x){
        assert(0 < i);
        for(; i < (int)data.size(); i += i & -i) data[i] += x;
    }
};


class Solver {
  public:
    // m が中央値以下か？
    // <=> M := N * (N - 1) / 2 個の要素を持つ配列に、m 以上の要素が M / 2 個以上含まれるか？
    bool check(ll m, const vector<ll> &A) {
        ll N = A.size();
        ll M = N * (N + 1) / 2;
        vector<ll> sum(N + 1);
        rep(i, N) sum[i + 1] = sum[i] + (A[i] >= m ? 1 : -1);
        { // BIT で使えるように、sum[i] >= 1 となるようにする
            ll mn = *min_element(all(sum));
            rep(i, sum.size()) sum[i] = sum[i] - mn + 1;
        }
        BIT<ll> bit(*max_element(all(sum)));
        ll ans = 0; //
        rep(i, N + 1) {
            ans += bit.sum(sum[i]);
            bit.add(sum[i], 1);
        }
        return ans >= M / 2;
    }

    bool solve() {
        ll N; cin >> N;
        vector<ll> A(N); cin >> A;

        ll l = 0, r = *max_element(all(A)) + 1;
        while(l + 1 < r) {
            ll m = (l + r) / 2;
            (check(m, A) ? l : r) = m;
        }

        bool contain = false;
        rep(i, N) contain |= A[i] == l;
        assert(contain);

        cout << l << endl;

        return 0;
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    Solver s;
    s.solve();
    return 0;
}


Measured memory_bytes: 2672
# -*- coding: utf-8 -*-
 
## Library
 
import sys
from fractions import gcd
import math
from math import ceil,floor
import collections
from collections import Counter
import itertools

## input
 
# N=int(input())
# A,B,C,D=map(int, input().split())
# S = input()
# yoko = list(map(int, input().split()))
# tate = [int(input()) for _ in range(N)]
# N, M = map(int,input().split()) 
#    P = [list(map(int,input().split())) for i in range(M)]
 
H,W=map(int, input().split())
S = []

S.append(['.']*(W+2))
for _ in range(H):
    S.append(['.']+list(input())+['.'])
S.append(['.']*(W+2))

for i in range(1,H+1):
    for j in range(1,W+1):
        #print(i,j,S[i][j])
        if S[i][j] == "#" and S[i-1][j] == "." and S[i+1][j] == "." and  S[i][j-1] == "." and  S[i][j+1]== ".":
            print("No")
            sys.exit()

print("Yes")

Measured memory_bytes: 77376
#include "bits/stdc++.h"

using namespace std;
using ll = long long;
using IP = pair<int, int>;

const ll linf = 1LL << 62;
const int inf = 99999999;
const int dx[4] = { 1,0,-1,0 };
const int dy[4] = { 0,1,0,-1 };
const ll atcoder = 1e9 + 7;

#define Endl endl
#define mp make_pair
#define all(v) v.begin(),v.end()
#define pb push_back
#define pr(x) cout << x << endl
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
#define rep(i,n) for(int i= 0;i<n;i++)

template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T &val) {
	std::fill((T*)array, (T*)(array + N), val);
}

ll gcd(ll a, ll b) {//最大公約数
	if (a < b)swap(a, b);
	if (a%b == 0)return b;
	else gcd(b, a%b);
}

ll lcm(ll a, ll b) {//最小公倍数
	if (a < b)swap(a, b);
	return (a / gcd(a, b))*b;
}

int dist[310][310];
int a[310][310];

int main() {

	int n;
	cin >> n;

	rep(i, n) {
		rep(j, n) {
			cin >> a[i][j];
			dist[i][j] = a[i][j];
		}
	}

	rep(k, n) rep(i, n) rep(j, n) dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);

	rep(i, n) {
		rep(j, n) {
			if (dist[i][j] < a[i][j]) {
				pr(-1);
				return 0;
			}
		}
	}

	ll sum = 0;

	rep(i, n) {
		for (int j = i + 1; j < n;j++) {
			bool flag = true;
			rep(k, n) {
				if (i != k && j != k) {
					if (dist[i][j] == dist[i][k] + dist[k][j]) {
						flag = false;
						break;
					}
				}
			}
			if (flag)sum += dist[i][j];
		}
	}
	
	pr(sum);

	//system("pause");
	return 0;
}

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

using namespace std;

int main(){

    int n;
    cin >> n;
    vector<int> arr(n);
    for(int i = 0; i < n; i++)
        cin >> arr[i];
    int cnt = 0;
    for(int i = 0; i+2 < n; i++){
        if( (arr[i] <= arr[i+1] && arr[i+1] <= arr[i+2]) || (arr[i] >= arr[i+1] && arr[i+1] >= arr[i+2]) )
            cnt++;
    }
    cout << cnt ;
    return 0;
}


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

int main () {
  string s;
  cin >> s;

  int a=s[0]+s[1]+s[2];
  int b='a'+'b'+'c';

  if(a==b) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 256
N = int(input())
v_list = [int(i) for i in input().split()]
c_list = [int(i) for i in input().split()]

ans = 0
for i in range(N):
	if (v_list[i] - c_list[i]) > 0:
  	    ans += (v_list[i] - c_list[i])

print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
const int MAXN = 2e5+2;
unsigned long long nums[MAXN];
 
const long long MAXL = 1e18;
 
bool overflow(unsigned long long a, unsigned long long b) {
    if (ULLONG_MAX / a < b) {
        return true;
    }
    unsigned long long ans = a*b;
    if (ans>MAXL) {
        return true;
    }
    return false;
}
 
int main() {
    int n;
    scanf("%d", &n);
    for (int i=0; i<n; i++) {
        scanf("%llu", &nums[i]);
        if (0==nums[i]) {
            printf("0\n");
            return 0;
        }
    }
 
    long long ans=1;
    for (int i=0; i<n; i++) {
        if (true == overflow(ans, nums[i])) {
            printf("-1\n");
            return 0;
        }
        ans *= nums[i];
    }
 
    printf("%llu", ans);
 
    return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<double> gxi(N);
  for (int i=0; i<N; i++) {
    cin >> gxi[i];
  }
  
  sort(gxi.begin(), gxi.end());
  
  double val = ( gxi[0] + gxi[1] ) / 2;
  for (int i=2; i<N; i++) {
    val += gxi[i];
    val /= 2;
  }
  
  cout << val << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<string>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<math.h>
#include<utility>
using namespace std;


int main(){
    int n;
    cin >> n;
    int count = 0;

    while(true){
        if(pow(2, count) > n){
            break;
        }
        count++;
    }

    cout << pow(2, count-1) << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
    int n, k;
    
    scanf("%d %d",&n,&k);
    char s[n];

    scanf("%s",&s);

    if(s[k-1] == 'A'){
        s[k-1] = 'a';
    }else if(s[k-1] == 'B'){
        s[k-1] = 'b';
    }else if(s[k-1]== 'C'){
        s[k-1] = 'c';
    }
    printf("%s",s);

}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1LL << 60;
const int MAX = 1000000010;
const ll MOD = 1000000007;

int main() {
    int N; cin >> N;
    int ans = 1;
    for (int i = 1; i * i <= N; i++) {
        ans = i * i;
    }

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

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

int main() {
	
	string s,t;
	cin >> s >> t;
	int a,b;
	cin >> a >> b;
	string u;
	cin >> u;
	if(s==u) a--;
	else b--;
	cout << a << " " << b << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
const ll INF=100000000000000001;
const double PI=3.141592653589;


int main(){
  vector<int> a(5);
  rep(i,5) cin>>a[i];
  sort(a.begin(),a.end());
  // ☆昇順の配列の階上を全列挙
  int ans=100000009;
  do{
    int t=0;
    rep(i,5){
      t+=a[i];
      if(i!=4&&t%10!=0)
      t+=(10-a[i]%10);
    }
    ans=min(ans,t);
  }while(next_permutation(a.begin(),a.end()));

  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <stack> // s.top()
#include <bitset>
#include <queue> // s.front()
using namespace std;

typedef long long Int;
typedef pair<Int,Int> P;
#define print(x) cout<<(x)<<endl

#define INF10 10000000000
#define INF5 100000
#define EPS 1e-10
#define MOD 1000000007


int main() {
	int	a, b; cin >> a >> b;
	if (b%a == 0)print(a + b);
	else print(b - a);





	return 0;
}

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

template<typename T> void drop(const T &x){cout<<x<<'\n';exit(0);}

void solve() {
  int n;
  cin >> n;
  vector<long long> a(5);
  string s;
  while(n--) {
    cin >> s;
    if(s[0] == 'M') a[0]++;
    if(s[0] == 'A') a[1]++;
    if(s[0] == 'R') a[2]++;
    if(s[0] == 'C') a[3]++;
    if(s[0] == 'H') a[4]++;
  }

  long long ans = 0;
  for(int i=0; i<3; ++i) {
    for(int j=i+1; j<4; ++j) {
      for(int k=j+1; k<5; ++k) {
        ans += a[i]*a[j]*a[k];
      }
    }
  }
  cout << ans << '\n';
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int T=1;
  //cin >> T;
  while(T--) solve();

  return 0;
}


Measured memory_bytes: 3600
#include<iostream>
#include<algorithm>
using namespace std;
int a[200002];
int main()
{
	int c, n;
	cin >> c >> n;
	int i;
	for (i = 1; i <= n; i++) cin >> a[i];
	sort(a + 1, a + 1 + n);
	int ans = 0;
	for (i = 2; i <= n; i++)
	{
		ans = max(ans, a[i] - a[i - 1]);
	}
	ans = max(ans, c + a[1] - a[n]);
	cout << c- ans << endl;
	return 0;
}

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

int main(){
	string s;
	cin >> s;
	if(s.length() == 2)cout << s << endl;
	else cout << s[2] << s[1] << s[0] << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Programminng
{
    class AOJ_Volume0018
    {
        public static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split(' ');
            int[] number = new int[5];
            for (int i = 0; i < 5; i++)
            {
                number[i] = int.Parse(s[i]);
            }

            for (int i = 0; i < 5; i++)
            {
                for (int j = 4; j > i; j--)
                {
                    if (number[j] > number[j - 1])
                    {
                        int temp = number[j];
                        number[j] = number[j - 1];
                        number[j - 1] = temp;
                    }
                }
            }

            for (int i = 0; i < 4; i++)
            {
                Console.Write(number[i] + " ");
            }
            Console.WriteLine(number[4]);

        }
    }
}

Measured memory_bytes: 5612
#include <bits/stdc++.h>
#define forn(i,b) for(int i=0 ; i< b ;i++)
#define for1(i,b) for(int i=1 ; i<=b ;i++)
#define reps(i,a,b) for(int i=a ; i< b.length() ;i++)
typedef long long ll;
#define MOD 1000000007



using namespace std;

int main()
{

  char a;
  cin>>a;
  a=a+1;
  a=(char)a;
  cout<<a;

  return 0 ;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define  fi0 for(ll i=0;i<n;i++)
string s;
string strd(int n){
    string x;
    while(n){
        int d=n%10;
        x+=(d+'0');
        n/=10;
    }
    reverse(x.begin(),x.end());
    return x;
}
void digit()
{
    cin>>s;
    ll sum=0;
    for(int i=0;i<s.size();i++){
        char a=(char)s[i];
        int d=(int) a-'0';
        sum+=d;
    }
    if(sum%9==0)cout<<"Yes\n";
    else cout<<"No\n";
}
int main()
{
   ll n,m,k;
   cin>>n>>m>>k;
   n=abs(n);
        ll dd=min(n/k,m);
        m-=dd;
        n-=(dd*k);
      /// cout<<dd<<' '<<m<<' '<<endl<<n<<endl;
        if(m%2==0)cout<<n<<endl;
        else cout<<abs(k-n)<<endl;

 ///  cout<<m<<endl<<k
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define in insert
#define PI 3.1415926535897932384626433832795
#define F first
#define S second
#define aLL(str) (str).begin(), (str).end()
#define IOS                  \
    ios::sync_with_stdio(0); \
    cin.tie(0);              \
    cout.tie(0)
#define ll long long
#define ld long double
#define lcm(a, b) (a * b) / __gcd(a, b)
#define flu(i, a, b) for (ll i = a; i < b; i++)
#define blu(i, a, b) for (ll i = a; i >= b; i--)
#define upper(s) transform(s.begin(), s.end(), s.begin(), ::toupper)
#define lower(s) transform(s.begin(), s.end(), s.begin(), ::tolower)
#define Unique(X) (X).erase(unique(all(X)), (X).end())
#define all(v) v.begin(), v.end()
typedef vector<ll> vl;
typedef map<ll, ll> ml;
typedef vector<string> vs;
typedef vector<vector<int>> vvi;
char e = '\n';

const ll MOD = 1e9 + 7;

ll i, j, le;

int sv(int x)
{
    int n = 200000;
    bool prime[n + 1];
    memset(prime, true, sizeof(prime));

    for (int p = 2; p * p <= n; p++)
    {

        if (prime[p] == true)
        {
            for (int i = p * p; i <= n; i += p)
                prime[i] = false;
        }
    }
    if (prime[x])
        return 1;
    else
        return 0;
}

int main()
{
    IOS;
    int t;
    //cin >> t;
    t=1;
    while (t--)
    {
        ll n;
    cin >> n;
    vl num(1e3+100,1);
    flu(i,1,n+1){
        ll tem=i;
        flu(j,2,n+1){
            while(tem%j==0){
                num[j]++;
                tem/=j;
            }
        }
    }
    ll ans=1;
    flu(i,2,n+1){
        ans*=num[i];
        ans%=MOD;
    }
    cout << ans << e;
    }
    return 0;
}

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

template< typename T >
struct edge {
  int src, to;
  T cost;

  edge(int to, T cost) : src(-1), to(to), cost(cost) {}

  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}

  edge &operator=(const int &x) {
    to = x;
    return *this;
  }

  operator int() const { return to; }
};

template< typename T >
using Edges = vector< edge< T > >;
template< typename T >
using WeightedGraph = vector< Edges< T > >;
using UnWeightedGraph = vector< vector< int > >;
template< typename T >
using Matrix = vector< vector< T > >;
struct UnionFind {
  vector< int > data;
 
  UnionFind(int sz) {
    data.assign(sz, -1);
  }
 
  bool unite(int x, int y) {
    x = find(x), y = find(y);
    if(x == y) return (false);
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return (true);
  }
 
  int find(int k) {
    if(data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }
 
  int size(int k) {
    return (-data[find(k)]);
  }
};

template< typename T >
void warshall_floyd(Matrix< T > &g, T INF) {
  for(int k = 0; k < g.size(); k++) {
    for(int i = 0; i < g.size(); i++) {
      for(int j = 0; j < g.size(); j++) {
        if(g[i][k] == INF || g[k][j] == INF) continue;
        g[i][j] = min(g[i][j], g[i][k] + g[k][j]);
      }
    }
  }
}

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

  int n;
  cin >> n;
  Matrix<ll> a(n, vector<ll>(n, LLONG_MAX));
  Matrix<ll> mat(n, vector<ll>(n, LLONG_MAX));
  ll ans=0;
  rep(i,n)rep(j,n){
    cin >> a[i][j];
    ans+=a[i][j];
    mat[i][j]=a[i][j];
  }
  ans/=2;
  warshall_floyd(mat,LLONG_MAX);
  /*  rep(i,n){
    rep(j,n){
      cout << mat[i][j] << " ";
    }
    cout << "" << endl;
  }
  cout << ans << endl;*/
  //  ll ans=kruskal(edges, n, a, LLONG_MAX);
  int used[n][n];
  rep(i,n)rep(j,n) used[i][j]=0;
  for(int k = 0; k < n; k++) {
    for(int i = 0; i < n; i++) {
      for(int j = i+1; j < n; j++) {
        //if(g[i][k] == INF || g[k][j] == INF) continue;
	if(mat[i][j]!=a[i][j]){
	  cout << -1 << endl;
	  return 0;
	}
	if(i==j || j==k || k==i) continue;
	if(mat[i][j]==mat[i][k]+mat[k][j]&&(used[i][j]!=1)){
	  used[i][j]=1;
	  ans-=mat[i][j];
	}
      }
    }
  }
  cout << ans << endl;
  
  return 0;
    
}


Measured memory_bytes: 2048