akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
//#include<ext/pb_ds/assoc_container.hpp>
//#include<ext/pb_ds/tree_policy.hpp>
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define MAX 2000005
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define pii pair<ll,ll>
#define vi vector<ll>
#define vp vector<pii>
#define all(v) v.begin(),v.end()
#define lb(v,x) lower_bound(all(v),x)
#define ub(v,x) upper_bound(all(v),x)
#define sz(x) (ll)x.size()
#define F first
#define S second
#define FOR(i,a,b) for(ll i=a;i<b;++i)
#define ROF(i,a,b) for(ll i=a;i>=b;--i)
#define trace(x) cerr<<#x<<": "<<x<<'\n';
typedef long long ll;
using namespace std;
//using namespace __gnu_pbds;
//#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>

ll mexp(ll a, ll b){
    ll ans=1;
    a%=MOD;
    while(b){
        if(b&1) ans=ans*a%MOD;
        b>>=1;
        a=a*a%MOD;
    }
    return ans;
}

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

const int N = 100005;

vi g[N];
ll dist[N];

ll dfs(int u){
    if(dist[u]!=-1){
        return dist[u];
    }
    ll d=0;
    for(int v:g[u]){
        d=max(d,dfs(v));
    }
    dist[u]=d+1;
    return dist[u];
}

int main(){
    IOS
    
    FOR(i,0,N+1){
        dist[i]=-1;
    }
    int n,m;
    cin>>n>>m;
    FOR(i,0,m){
        int x,y;
        cin>>x>>y;
        g[x].pb(y);
    }
    ll ans=0;
    FOR(i,1,n+1){
        ans=max(ans,dfs(i)-1);
    }
    cout<<ans;
    cerr<<1.0/CLOCKS_PER_SEC<<endl;
    return 0;
}

Measured memory_bytes: 8576
//** aman**/
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define dl          double
#define hell        1000000007
#define endl        '\n'
#define rep(i,a,b) for(int i=a;i<b;i++)
#define lb lower_bound
#define ub upper_bound
#define bs          binary_search
#define ios         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
int main(){
	int n;cin>>n;
	int ans=0,cnt=0,cnt1=0,cnt2=0;
	for(int i=0;i<n;i++){
		string s;cin>>s;
		int nn=s.size();
		for(int j=1;j<nn;j++){
			if(s[j-1]=='A'&&s[j]=='B')ans++;
		}
		if(s[0]=='B'&&s[nn-1]=='A')cnt++;
		if(s[0]!='B'&&s[nn-1]=='A')cnt1++;
		if(s[0]=='B'&&s[nn-1]!='A')cnt2++;
	}
	//cout<<ans<<endl;
	if(cnt1>0)cnt++,cnt1--;
	if(cnt2>0)cnt++,cnt2--;
	if(cnt>0)
	cout<<ans+cnt-1+min(cnt1,cnt2);
	else cout<<ans+min(cnt1,cnt2);
}

Measured memory_bytes: 256
import java.util.*;

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();
if(2 * B == A + C){
System.out.println("YES");
}else{
System.out.println("NO");
}

}
}

Measured memory_bytes: 23764
#-*-coding:utf-8-*-

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

    ab_list = []
    cd_list = []
    for _ in range(n):
        ab_list.append(list(map(int, input().split())))
    for _ in range(m):
        cd_list.append(list(map(int, input().split())))
    
    for i in ab_list:
        min_distance = float('inf')
        for j in range(m):
            distance = abs(i[0] - cd_list[j][0]) + abs(i[1] - cd_list[j][1])
            if distance < min_distance:
                min_distance = distance
                min_coord = j + 1
        print(min_coord)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include <algorithm>
#include <vector>
#include <cfloat>
#include <string>
#include <cmath>
#include <set>
#include <cstdlib>
#include <map>
#include <ctime>
#include <iomanip>
#include <functional>
#include <deque>
#include <iostream>
#include <cstring>
#include <queue>
#include <cstdio>
#include <stack>
#include <climits>
#include <sys/time.h>
#include <cctype>

using namespace std;

typedef long long ll;


#define EPS (1e-10)
#define equals(a, b) (fabs((a)-(b)) < EPS)

class Point {
 public:
  double x, y;

  Point(double x = 0, double y = 0): x(x), y(y) {}

  Point operator + (Point p) { return Point(x+p.x, y+p.y); }
  Point operator - (Point p) { return Point(x-p.x, y-p.y); }
  Point operator * (double a) { return Point(a*x, a*y); }
  Point operator / (double a) { return Point(x/a, y/a); }

  double norm() { return x*x+y*y; }
  double abs() { return sqrt(norm()); }

  bool operator < (const Point &p) const {
    return x != p.x ? x < p.x : y < p.y;
  }

  bool operator == (const Point &p) const {
    return fabs(x-p.x) < EPS && fabs(y-p.y) < EPS;
  }
};

typedef Point Vector;
typedef vector <Vector> Polygon;

class Segment {
 public:
  Point p1, p2;

  Segment(Point p1 = Point(), Point p2 = Point()): p1(p1), p2(p2) {}
};

double norm(Vector a) {
  return a.x*a.x+a.y*a.y;
}

double abs(Vector a) {
  return sqrt(norm(a));
}

// ?????????|a||b|cos
double cross(Vector a, Vector b) {
  return a.x*b.y-a.y*b.x;
}
// ?????????|a||b|sin
double dot(Vector a, Vector b) {
  return a.x*b.x+a.y*b.y;
}

// 1:???????¨??????? -1:????¨??????? 2:p2-p0-p1 -2:p0-p1-p2 0:p2???p0-p1???
int ccw(Point p0, Point p1, Point p2) {
  Vector a = p1-p0;
  Vector b = p2-p0;
  if (cross(a, b) > EPS) return 1;
  if (cross(a, b) < -EPS) return -1;
  if (dot(a, b) < -EPS) return 2;
  if (a.norm() < b.norm()) return -2;

  return 0;
}

// ??´?????????
bool isOrthogonal(Vector a, Vector b) {
  return equals(dot(a, b), 0.0);
}

bool isOrthogonal(Point a1, Point a2, Point b1, Point b2) {
  return isOrthogonal(a1-a2, b1-b2);
}

bool isOrthogonal(Segment s1, Segment s2) {
  return equals(dot(s1.p2-s1.p1, s2.p2-s2.p1), 0.0);
}

// ????????????
bool isParallel(Vector a, Vector b) {
  return equals(cross(a, b), 0.0);
}

bool isParallel(Point a1, Point a2, Point b1, Point b2) {
  return isParallel(a1-a2, b1-b2);
}

bool isParallel(Segment s1, Segment s2) {
  return equals(cross(s1.p2-s1.p1, s2.p2-s2.p1), 0.0);
}


int main() {
  int q;
  cin >> q;
  for (int i = 0; i < q; i++) {
    Segment s1, s2;
    cin >> s1.p1.x >> s1.p1.y >> s1.p2.x >> s1.p2.y
        >> s2.p1.x >> s2.p1.y >> s2.p2.x >> s2.p2.y;
    if (isParallel(s1, s2)) {
      cout << "2" << endl;
    }else if (isOrthogonal(s1, s2)) {
      cout << "1" << endl;
    }else {
      cout << "0" << endl;
    }
  }
}

Measured memory_bytes: 1220
import math
N,K = map(int,input().split())
A = list(map(int,input().split()))
a1 = max(A)
n = int(math.log2(max(a1,K)))+1
B = [0 for _ in range(n)]
for i in range(N):
    a = bin(A[i])[2:]
    for j in range(len(a)):
        if a[len(a)-1-j]=="1":
            B[j] += 1
x = bin(K)[2:]
y = ""
flag = 0
for i in range(len(x)):
    if flag==0:
        if x[i]=="0":
            y += x[i]
        else:
            if B[len(x)-1-i]<=N//2:
                y += x[i]
            else:
                y += "0"
                flag = 1
    else:
        if B[len(x)-1-i]<=N//2:
            y += "1"
        else:
            y += "0"
y = int(y,2)
cnt = 0
for i in range(N):
    cnt += y^A[i]
print(cnt)

Measured memory_bytes: 14596
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <utility>
using namespace std;
string s,t;
vector<pair<int,int>> v;
string alp = "abcdefghijklmnopqrstuvwxyz";
set<int> st;
int solve(int l,int r){
	st.clear();
	for(int i=l;i<r;i++){
		st.insert(s[i]-'a');
	}
	for(int i=0;i<26;i++){
		if(!st.count(i)){
			return i;
		}
	}
}
int main(){
	cin >> s;
	int i,j,n = s.size(),l,r = n;
	for(i=n-1;i>=0;i--){
		st.insert(s[i]-'a');
		if(st.size()==26){
			l = i;
			v.push_back({l,r});
			r = i;
			st.clear();
		}
	}
	v.push_back({0,r});
	st.clear();
	l = 0;
	for(i=v.size()-1;i>=0;i--){
		r = v[i].second;
		int x = solve(l,r);
		t.push_back(alp[x]);
		for(j=r;j<n;j++){
			if(s[j]-'a'==x){
				l = j + 1;
				break;
			}
			if(j==n-1) l = n;
		}
	}
	cout << t << endl;
}

Measured memory_bytes: 640
N = int(input())
A = list(map(int, input().split()))
# print(N, A)
ans = True
for a in A:
    if a % 2 == 0:
        if a % 3 != 0 and a % 5 != 0:
            ans = False
            break
if ans:
    print('APPROVED')
else:
    print('DENIED')


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

#define LOG(FMT...) fprintf(stderr, FMT)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

const int N = 300010;

int n;
int a[N], pre[N], cnt[N];
int last[2];

void gg() {
  puts("No");
  exit(0);
}

int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i)
    scanf("%d", &a[i]);
  for (int i = 1; i <= n; ++i)
    if ((a[i] ^ i) & 1)
      gg();
  last[0] = 0; last[1] = -1;
  for (int i = 1; i <= n; ++i) {
    if (i <= 2) pre[i] = a[i];
    else pre[i] = max(a[i], pre[i - 2]);
    if (pre[i] == i) {
      if (last[i & 1] < i - 2) {
        --cnt[last[i & 1] + 1];
        ++cnt[i];
      }
      last[i & 1] = i;
    }
  }
  for (int i = n; i; --i)
    if ((cnt[i] += cnt[i + 1]) > 1)
      gg();
  int a1 = 0, a2 = 0;
  for (int i = 1; i <= n; i += 2) {
    if (a[i] < a2) gg();
    if (a[i] < a1)
      a2 = a[i];
    else a1 = a[i];
  }
  a1 = 0; a2 = 0;
  for (int i = 2; i <= n; i += 2) {
    if (a[i] < a2) gg();
    if (a[i] < a1)
      a2 = a[i];
    else a1 = a[i];
  }
  puts("Yes");
  
  return 0;
}

/*
5 4 3 2 1
3 4 5 2 1
3 4 1 2 5

*/

Measured memory_bytes: 3840
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))


ans = 0
f = True
while f:
    f = False
    for i in range(N):
        a,b,c = B[(i-1)%N],B[i],B[(i+1)%N]
        if b > a+c and b > A[i]:
            if (b-A[i])%(a+c)==0:
                B[i] = A[i]
                ans += (b-A[i])//(a+c)
            else:
                ans += B[i]//(a+c)
                B[i] %= a+c
            f = True

if A != B:
    ans = -1
print(ans)

Measured memory_bytes: 118904
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)  //  repマクロ
#define leng(n) (int)(log10(n)+1)  //  桁数
using namespace std;

signed main() {
  vector<int> m(5);
  vector<int> n(5);
  rep(i, 5){
    cin >> m[i];
    n[i] = i;
  }
  int ans = 99999999;
  do {
    int minutes = 0;
    rep(i, 4) {
      minutes += (10*((m[n[i]] - 1)/10) + 10);
    }
    minutes += m[n[4]];
    ans = min(ans, minutes);
  } 
  while (next_permutation(n.begin(), n.end()));
  
  cout << ans << endl;
}

Measured memory_bytes: 256
from collections import defaultdict
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def MI1(): return map(int1, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

class BitSum:
    def __init__(self, n):
        self.n = n + 3
        self.table = [0] * (self.n + 1)

    def add(self, i, x):
        i += 1
        while i <= self.n:
            self.table[i] += x
            i += i & -i

    def sum(self, i):
        i += 1
        res = 0
        while i > 0:
            res += self.table[i]
            i -= i & -i
        return res

def main():
    def dfs(u=0,pu=-1):
        ll[u]=len(uu)
        uu.append(u)
        for v in to[u]:
            if v==pu:continue
            dfs(v,u)
        rr[u]=len(uu)

    def sumlr(l,r):
        return bit.sum(r-1)-bit.sum(l-1)

    n=II()
    cc=LI1()
    to=[[] for _ in range(n)]
    for _ in range(n-1):
        a,b=MI1()
        to[a].append(b)
        to[b].append(a)
    ll=[-1]*n
    rr=[-1]*n
    uu=[]
    dfs()
    bit=BitSum(n)
    for u in range(n):bit.add(u,1)
    ctou=defaultdict(list)
    for u,c in enumerate(cc):ctou[c].append(u)
    pn=lambda x:x*(x+1)//2
    for c in range(n):
        log=[]
        ans = pn(n)
        for u in sorted(ctou[c],key=lambda x:-ll[x]):
            us=1
            for v in to[u]:
                if ll[v]<ll[u]:continue
                vs=sumlr(ll[v],rr[v])
                ans-=pn(vs)
                us+=vs
            bit.add(ll[u],-us)
            log.append((ll[u],us))
        vs = sumlr(0,n)
        ans -= pn(vs)
        print(ans)
        for i,s in log:bit.add(i,s)

main()

Measured memory_bytes: 319228
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <climits>
#include <iostream>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <vector>
#include <sstream>
#include <typeinfo>
#include <fstream>

#define DIV 1000000007


using namespace std;

set<long long> memo[100005];
long long N;
long long ans;

int main(){
	cin >> N;
	for(int i = 0; i < N; i++){
		long long tmp;
		cin >> tmp;
		tmp--;
		if(memo[i].count(tmp) != 0){
			ans++;
		}
		memo[tmp].insert(i);
	}
	cout << ans << endl;
}



Measured memory_bytes: 9600
#ifdef LOCAL111
	#define _GLIBCXX_DEBUG
#else
	#pragma GCC optimize ("O3")
	#define NDEBUG
#endif
// #define _USE_MATH_DEFINES
#include <bits/stdc++.h>
const int INF = 1e9;
using namespace std;
template<typename T, typename U> ostream& operator<< (ostream& os, const pair<T,U>& p) { os << '(' << p.first << ' ' << p.second << ')'; return os; }

#define endl '\n'
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#ifdef LOCAL111
	#define DEBUG(x) cout<<#x<<": "<<(x)<<endl
	template<typename T> void dpite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
#else
	#define DEBUG(x) true
	template<typename T> void dpite(T a, T b){ return; }
#endif
#define F first
#define S second
#define SNP string::npos
#define WRC(hoge) cout << "Case #" << (hoge)+1 << ": "
template<typename T> void pite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
template<typename T> bool chmax(T& a, T b){if(a < b){a = b; return true;} return false;}
template<typename T> bool chmin(T& a, T b){if(a > b){a = b; return true;} return false;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

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

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}

const array<int, 4> dx = {0, 1, 0, -1};
const array<int, 4> dy = {1, 0, -1, 0};


typedef long long int LL;
typedef unsigned long long ULL;
typedef pair<int,int> P;

void ios_init(){
	//cout.setf(ios::fixed);
	//cout.precision(12);
#ifdef LOCAL111
	return;
#endif
	ios::sync_with_stdio(false); cin.tie(0);
}

int main()
{
	ios_init();
	int n, m;
	LL l;
	while(cin >> n >> m >> l) {
		const LL INF = 1e18;
		vector<vector<LL>> g(n, vector<LL>(n, INF));
		REP(i, n) g[i][i] = 0;
		REP(i, m) {
			int a, b;
			LL c;
			cin >> a >> b >> c;
			a--; b--;
			g[a][b] = g[b][a] = c;
		}

		int q;
		cin >> q;
		vector<int> s(q), t(q);
		REP(i, q) {
			cin >> s[i] >> t[i];
			s[i]--; t[i]--;
		}


		REP(k, n) REP(i, n) REP(j, n) chmin(g[i][j], g[i][k] + g[k][j]);
		vector<vector<LL>> dp(n, vector<LL>(n, INF));
		REP(i, n) REP(j, n) {
			if(g[i][j] <= l) {
				dp[i][j] = 0;
			}
		}
		REP(k, n) REP(i, n) REP(j, n) chmin(dp[i][j], dp[i][k] + dp[k][j] + 1);

		REP(i, q) {
			cout << (dp[s[i]][t[i]] == INF ? -1 : dp[s[i]][t[i]]) << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 2688
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main{
	public static void main(String[] args)throws IOException{
		InputStreamReader isr = new InputStreamReader(System.in);
		BufferedReader reader = new BufferedReader(isr);
		String string;
		
		int n, m, c, e, min;
		boolean judge;
		while(true){
			string = reader.readLine();
			n = Integer.valueOf(string.split(" ")[0]);
			m = Integer.valueOf(string.split(" ")[1]);
			if((n | m) == 0) break;
			
			int taro[] = new int[n];
			int hana[] = new int[m], sumT = 0, sumH = 0;
			c = e = 0;
			for(int i = 0; i < n; i++){
				taro[i] = Integer.valueOf(reader.readLine());
				sumT += taro[i];
			}
			for(int i = 0; i < m; i++){
				hana[i] = Integer.valueOf(reader.readLine());
				sumH += hana[i];
			}
			min = 114514;
			judge = false;
			for(int i = 0; i < n; i++){
				for(int j = 0; j < m; j++){
					if(sumT - taro[i] + hana[j] ==
					   sumH + taro[i] - hana[j] &&
					   taro[i] + hana[j] < min){
						
						if(!judge) judge = true;
						min = taro[i] + hana[j];
						c = taro[i];
						e = hana[j];
					}
				}
			}			
			if(judge){
				System.out.println(c + " " + e);
			}else{
				System.out.println(-1);
			}
		}
		
		reader.close();
	}
}

Measured memory_bytes: 24688
"use strict";

function Main(input) {
  let lines = input.split("\n");
  let numInfo = lines.shift().split(" ")[1];
  // 答えを調べる用のオブジェクト
  let ansObj = {};
  for(let i = 0; i < numInfo;i++){
    	let quesNum = lines[i].split(" ")[0];
    	let ansKind = lines[i].split(" ")[1];
    	if(ansObj[quesNum] === undefined){
          ansObj[quesNum] = `${ansKind}`;
        } else {
        ansObj[quesNum] += `,${ansKind}`;
        }
  }
  let WANum = 0;
  let ACNum = 0;
  // objectは直接要素数は取れないらしい
  let ansObjKeys = Object.keys(ansObj);
    for(let i = 0; i < ansObjKeys.length; i++){
      let targetKey = ansObjKeys[i];
      // 対象を配列として切り出したもの
      let target = ansObj[targetKey].split(",");
      // ACしている物のみカウントの対象になる
      if(target.indexOf('AC')!= -1){
        for(let j = 0; j < target.length; j++){
          if(target[j] == 'AC') {
            ACNum++;
            break;
          } else {
            WANum++;
          } 
        }
      }
    }
  console.log(`${ACNum} ${WANum}`);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

int diff(int a,int b)
{
  if(a>b)
    return a-b;
  return b-a;
}

int min(int a,int b)
{
  if(a<b)
    return a;
  return b;
}

int total_cost(int arr[],int n)
{ if(n==1)
   return 0;
  int* sol = new int[n];
  sol[0]=0;
  sol[1]=diff(arr[0],arr[1]);
  for(int i=2;i<n;i++)
  {
     sol[i] =min( sol[i-2]+diff(arr[i-2],arr[i]),sol[i-1]+diff(arr[i-1],arr[i]) );
  }
  return sol[n-1];
}
               
int main()
{
  int n;
  cin>>n;
  int* arr = new int[n];
  for(int i=0;i<n;i++)
    cin>>arr[i];
  cout<<total_cost(arr,n);
}

Measured memory_bytes: 1024
n,p=map(int,input().split())
def fact(n):
  arr=[]
  temp=n
  for i in range(2,int(-(-n**0.5//1))+1):
    if temp%i==0:
      cnt=0
      while temp%i==0:
        cnt+=1
        temp//=i
      arr.append([i,cnt])
  if temp!=1:
    arr.append([temp,1])
  if arr==[]:
    arr.append([n,1])
  return arr
l=fact(p)
t=1
for i in l:
  t=t*(i[0]**(i[1]//n))
print(t)

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

int main(){
    double w[] = {0,48,51,54,57,60,64,69,75,81,91,1e9};
    string s[] = {"light fly","fly","bantam","feather","light","light welter","welter","light middle","middle","light heavy","heavy"};
    double x;
    while(cin >> x){
        int i = 0;
        while(1){
            if(x < w[i+1] + 1e-6){
                cout << s[i] << endl;
                break;
            }
            i++;
        }
    }
    return 0;
}



Measured memory_bytes: 3172
/*      Welcome to my Code      */

#include <bits/stdc++.h>
#define ll                      long long int
#define i(a,n)                  int a=n;
#define l(a,n)                  ll a=n;
#define d(a,n)                  double a=n;
#define s(a)                    string a;
#define c(a)                    ll a; cin>>a;a
#define cd(a)                   double a; cin>>a;
#define cs(a)                   string a; cin>>a;
#define ci(a)                   cin>>a;
#define co(a)                   cout<<a;
#define cos(a)                  cout<<a<<" "
#define con(a)                  cout<<a<<endl
#define yes                     cout<<"YES"<<endl
#define no                      cout<<"NO"<<endl
#define nl                      cout<<endl
#define ca(arr,n)               for(ll i=0;i<n;i++) cin>>arr[i]
#define caa(arr,n)              c(n); ll arr[n]; for(ll i=0;i<n;i++) cin>>arr[i];
#define f0(i,a,n)               for(ll i=a;i>=n;i--)
#define f(i,n)                  for(ll i=0;i<n;i++)
#define f1(i,a,n)               for(ll i=a;i<n;i++)
#define lcm(a,b)                (a*b)/__gcd(a,b)
#define T                       ll t=1; cin>>t; while(t--)
#define fast                    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define ret(x)                  return cout<<x,0;

using namespace std;

int main()
{
    fast;
    c(x);c(k);c(d);
    x=abs(x);
    if(x/d>=k) con(x-(k*d));
    else
    {
        k=k-x/d;
        if(k%2!=0) con(abs(x%d-d));
        else con(x%d);
    }
    return 0;
}

/*It's not who I am underneath, but what I do that defines me

MMMMMMMMMMMMMMMMMMMMM.                             MMMMMMMMMMMMMMMMMMMMM
 `MMMMMMMMMMMMMMMMMMMM           M\  /M           MMMMMMMMMMMMMMMMMMMM'
   `MMMMMMMMMMMMMMMMMMM          MMMMMM          MMMMMMMMMMMMMMMMMMM'
     MMMMMMMMMMMMMMMMMMM-_______MMMMMMMM_______-MMMMMMMMMMMMMMMMMMM
      MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
      MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
      MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
     .MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM.
    MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
                   `MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM'
                          `MMMMMMMMMMMMMMMMMM'
                              `MMMMMMMMMM'
                                 MMMMMM
                                  MMMM
                                   MM
*/


Measured memory_bytes: 3632
def solve(string):
    n, *a = map(int, string.split())
    count = 0
    for _a in a:
        tmp = _a
        while tmp % 2 == 0:
            tmp /= 2
            count += 1
    return str(count)


if __name__ == '__main__':
    print(solve("\n".join([input(), input()])))


Measured memory_bytes: 41200
n = int(input())
ab = sorted([list(map(int, input().split())) for _ in range(n)], key=lambda x : x[1])
import numpy as np
a = np.cumsum([i[0] for i in ab])
b = np.array([i[1] for i in ab])
if sum(a<=b) == n:
  print("Yes")
else:
  print("No")

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

int main(){
  int str[2][11],a,b,str_u[11];
  
  scanf("%s %s",str[0],str[1]);
  scanf("%d %d",&a,&b);
  scanf("%s",str_u);
  
  if(strcmp(str[0],str_u) == 0){
    a--;
  }else{
    b--;
  }
  
  printf("%d %d\n",a,b);
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define re(i,a,b) for(int i=(a);i<(b);i++)
#define repd(i,a,b) for(int i=(a);i>=(b);i--)
#define ergomap(i,a) for(map<int,int>::iterator i=a.begin();i!=a.end();i++)
#define ergoset(i,a) for(set<int>::iterator i=a.begin();i!=a.end();i++)
#define ergo(i,a) for(int i=0;i<a.size();i++)
#define clr(a) memset(a,0,sizeof(a));
#define il inline
#define sz(a) ((int)s.size())
#define pb push_back 
#define w1 first
#define w2 second
#define addm(a,b,c) {a=a+b;if(a>=c)a-=c;}
typedef long long ll;typedef long double ld;typedef unsigned long long ull;
typedef pair<ll,ll> pa;
const int N=1e6+50,M=1e6+5,INF=1e9,mod=1e9+7;
const ll linf=1e18;
const double eps=1e-8l;
il int gmin(int &a,int b){if(a>b)a=b;}il ll gmin(ll &a,ll b){if(a>b)a=b;}il int gmax(int &a,int b){if(a<b)a=b;}il ll gmax(ll &a,ll b){if(a<b)a=b;}
il int max(int a,int b,int c){if(b>a)a=b;if(c>a)a=c;return a;}il int max(int a,int b){if(a>b)return a;return b;}il int min(int a,int b){if(a>b)return b;return a;}
il int read(){
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
il void read(ll&x){ll f=1,t=0;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){t=t*10+ch-'0';ch=getchar();}x=t*f;}il ll read(ll&x,ll&y){read(x);read(y);}
il void read(int&x){int f=1,t=0;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){t=t*10+ch-'0';ch=getchar();}x=t*f;}il int read(int&x,int&y){read(x);read(y);}
il void read(int&a,int&b,int&c){read(a);read(b);read(c);}il void read(ll&a,ll&b,ll&c){read(a);read(b);read(c);}
il ll qpow(ll a,ll b,ll p){ll ret=1;for(;b;b>>=1,a=a*a%p)if(b&1)ret=ret*a%p;return ret;}
il ll qmul(ll a,ll b,ll p){ll ret=0;for(;b;b>>=1,a=(a<<1)%p)if(b&1)addm(ret,a,p);return ret;}
il void judge(){
	freopen("game10.in","r",stdin);
	freopen("my.out","w",stdout);}
il void gen(){freopen("data.in","w",stdout);}
const double pi=acos(-1);
int n,m,pre[N],q[N];
char a[N],b[N];
int main(){//judge();
	read(n);scanf("%s%s",a+1,b+1);
	int diff=0;
	rep(i,1,n)if(a[i]!=b[i])diff=1;
	if(diff==0)return puts("0"),0;
	int j=n;
	repd(i,n,1){
		gmin(j,i);
		while(j&&a[j]!=b[i])j--;
		if(!j)return puts("-1"),0;
		pre[i]=j;
	}
	int ans=1,l=1,r=0;
	repd(i,n,1)if(pre[i]>pre[i-1]){
		while(l<=r&&q[l]-(r-l)>i)l++;
		if(pre[i]<i)
		q[++r]=pre[i],ans=max(ans,r-l+2);
	}
	cout<<ans<<endl;
}

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

#define debug(x) cout<<#x<<"="<<x<<endl
#define pii pair<int,int>
#define PQ priority_queue
#define ll long long
#define pb push_back
#define mp make_pair

int main(){
	int n,m,k;
	cin>>n>>m>>k;
	for (int i=0;i<=n;i++){
		for (int j=0;j<=m;j++){
			if (i*m+j*n-i*j*2==k){
				cout<<"Yes";
				return 0;
			}
		}
	}
	cout<<"No";
	return 0;
}

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

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

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <stdlib.h>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <climits>
#include <iomanip>
#include <deque>

using namespace std;

int64_t F(int64_t H)
{
  if (H == 1) {
    return 1;
  }
  else {
    return 1 + F(H / 2) * 2;
  }
}

int main()
{
  int64_t H;
  cin >> H;

  cout << F(H);
  return 0;
}


Measured memory_bytes: 256
n,k = map(int,input().split())
p = list(map(int,input().split()))
c = 0
for i in range(k):
    c += (p[i]+1)/2
ans = 0
for i in range(n-k+1):
    if i != 0:
        c += (p[i+k-1]-p[i-1])/2
    ans = max(ans,c)
print(ans)

Measured memory_bytes: 24804
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

class Card {
	String name;
	int value;
	
	Card(String name) {
		this.name = name;
		value = Integer.parseInt(name.substring(1));
	}
	
	@Override
	public String toString() {
		return name;
	}
}

public class Main {
	public static String listToString(List<Card> list) {
		StringBuilder sb = new StringBuilder();
		for (Card c : list) {
			sb.append(c);
			sb.append(' ');
		}
		sb.deleteCharAt(sb.length() - 1);
		sb.append('\n');
		return sb.toString();
	}
	
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		// BufferedReader br = new BufferedReader(new FileReader("in1.txt"));
		// BufferedReader br = new BufferedReader(new FileReader("in2.txt"));
		int N = Integer.parseInt(br.readLine());
		List<Card> C1 = new ArrayList<Card>();
		String[] line = br.readLine().split(" ");
		for (String name : line)
			C1.add(new Card(name));
		List<Card> C2 = new ArrayList<Card>();
		C2.addAll(C1);
		
		for (int i = 0; i < N - 1; i++) {
			// C1[0..i - 1]??????????????????
			for (int j = N - 1; j > 0; j--) {
				if (C1.get(j).value < C1.get(j - 1).value) {
					Card tmp = C1.get(j - 1);
					C1.set(j - 1, C1.get(j));
					C1.set(j, tmp);
				}
			}
		}
		
		for (int i = 0; i < N; i++) {
			// C2[0..i-1]??????????????????
			int mini = i;
			for (int j = i + 1; j < N; j++)
				if (C2.get(j).value < C2.get(mini).value)
					mini = j;
			Card tmp = C2.get(i);
			C2.set(i, C2.get(mini));
			C2.set(mini, tmp);
		}
		
		System.out.print(listToString(C1));
		System.out.println("Stable");
		System.out.print(listToString(C2));
		boolean is_stable = true;
		for (int i = 0; i < N; i++)
			if (C1.get(i) != C2.get(i)) {
				is_stable = false;
				break;
			}
		System.out.println(is_stable ? "Stable" : "Not stable");
	}
}

Measured memory_bytes: 17048
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n;
  cin >>n;
  if (n<=104) cout <<0 <<endl;
  else if (n<=134) cout << 1 <<endl;
  else if (n<=164)cout << 2 << endl;
  else if (n<=188) cout << 3<<endl;
  else if (n<=194)cout << 4<<endl;
  else cout <<5<<endl;
}

Measured memory_bytes: 256
a,v = map(int,input().split())
b,w = map(int,input().split())
t = int(input())
if v <= w:
    print("NO")
else:
    dis = abs(b-a)
    sp = abs(v-w)
    if 0 < dis/sp <= t:
        print("YES")
    else:
        print("NO")


Measured memory_bytes: 9172
/*
  NAME : RISHABH SINGH
  INSTITUTION : DELHI TECHNOLOGICAL UNIVERSITY
*/
#include "bits/stdc++.h"
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define int long long
#define pii pair<int, int>
#define bi __builtin_inf()
#define ll long long
#define mp make_pair
#define ss second
#define pb push_back
#define ff first
#define speed_cubing ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define um unordered_map
#define us unordered_set
#define bp __builtin_popcount
#define ld long double
#define rep(n) for (int i = 0; i < n; i++)
#define pll pair<ll, ll>
#define mx = 1e18;
#define lb(v, val) (lower_bound(v.begin(), v.end(), val) - v.begin())
#define ub(v, val) (upper_bound(v.begin(), v.end(), val) - v.begin())
#define PI 3.1415926535
typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> pbds;
ll powmod(ll base,ll exp,ll MOD){ll res=1;while(exp>0){if(exp%2==1) res=(res*base)%MOD;base=(base*base)%MOD;exp/=2;}return (res%MOD);}
#define sz(v) (int)v.size()
#define endl '\n'
const int mod = 998244353;
ll mul_inv(ll a,ll b = mod) {ll t1=a,t2=b,t3,v1=1,v2=0,v3;while(t2!=1){ll x=t1/t2;t3=t1-x*t2;v3=v1-x*v2;t1=t2,t2=t3;v1=v2,v2=v3;}return(v2+b)%b;}
const int N = 1e18;


int32_t main(){
   
   speed_cubing
   
   int n;
   cin>>n;

   int a[n];

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

   int ans = 1;

   sort(a,a+n);

   for(int i=0;i<n;i++){
      if(a[i]==0){
        ans = 0;
        break; 
      }
      if(a[i]<=N/ans)
        ans*=a[i];
      else{
        ans = -1;
        break; 
      }  
   }  

   cout<<ans; 
 
   return 0;
}

Measured memory_bytes: 4440
using System;
using System.Collections.Generic;

class Program
{
	static void Main(string[] args)
	{
		int N = int.Parse(Console.ReadLine());

		List<int> duplicateList = new List<int>();
		duplicateList.Add(0);


		int result;

		for (int i = 1; i <= N; i++)
        {
			result = 0;
			for(int x = 1;x <= i; x++)
            {
				for (int y = 1; y <= i; y++)
                {
					if ((x * x + y * y + x * y) > i) break;

					for (int z = 1; z <= i; z++)
                    {
						if ((x * x + y * y + z * z + x * y + y * z + z * x) > i) break;

						if((x*x + y*y + z*z + x*y + y*z + z*x) == i)
                        {
							if( x == y && y == z)
                            {
								bool flg = false;
								foreach(var j in duplicateList)
                                {
									if(j == x) flg = true;
								}
                                if (!flg)
                                {
									duplicateList.Add(x);
									result++;
								}
                            }
                            else
                            {
								result++;
                            }
                        }
                    }
				}
			}
			Console.WriteLine(result);
		}
	}
}

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

typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second

struct UF{
    int n;
    //正だったらその頂点の親,負だったら根で連結成分の個数
    vector<int> d;
    UF() {}
    UF(int N):n(N), d(N,-1){}
    int root(int v){
        if(d[v]<0) return v;
        return d[v]=root(d[v]);
    }
    bool unite(int X,int Y){
        X=root(X); Y=root(Y);
        if(X==Y) return false;
        if(size(X) < size(Y)) swap(X,Y);
        d[X]+=d[Y];
        d[Y]=X;
        return true;
    }
    int size(int v){ return -d[root(v)]; }
    bool same(int X,int Y){ return root(X)==root(Y); }
};

const int N=200000;
const ll INF=123456789012345LL;
ll dp[N];

typedef pair<int,int> pi;
typedef pair<ll,pi> edge;
vector<edge> e;

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

    fill(dp,dp+N,INF);

    while(Q--)
    {
        int a,b;
        ll c;
        scanf(" %d %d %lld", &a, &b, &c);

        e.pb(edge(c,pi(a,b)));
        dp[a]=min(dp[a],c+1);
        dp[b]=min(dp[b],c+2);
    }

    rep(_,2)rep(i,n) dp[i]=min(dp[i], dp[(i-1+n)%n]+2);
    rep(i,n) e.pb(edge(dp[i],pi(i,(i+1)%n)));

    sort(all(e));

    UF uf(n);
    ll ans=0;
    rep(i,e.size())
    {
        int a=e[i].se.fi, b=e[i].se.se;
        if(!uf.same(a,b))
        {
            uf.unite(a,b);
            ans+=e[i].fi;
        }
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 10092
#include <iostream>
using namespace std;
int N;
char S[305][305], S2[305][305];
void Read()
{
    cin >> N;
    cin.get();
    for(int i = 1; i <= N; i++)
    {
        cin.getline(S[i] + 1, 305);
    }
}

bool check(int x)
{
    for(int i = 1; i <= N; i++)
    {
        for(int j = 1; j <= N; j++)
        {
            int col = j+ x;
            if(col > N)
                col -= N;
            S2[i][col] = S[i][j];
        }
    }
    for(int i = 1; i <= N; i++)
    {
        for(int j = 1; j <= N; j++)
            if(S2[i][j] != S2[j][i])
                return 0;
    }
    return 1;
}

bool check2(int x)
{
    for(int i = 1; i <= N; i++)
    {
        for(int j = 1; j <= N; j++)
        {
            int line = i+ x;
            if(line > N)
                line -= N;
            S2[line][j] = S[i][j];
        }
    }
    for(int i = 1; i <= N; i++)
    {
        for(int j = 1; j <= N; j++)
            if(S2[i][j] != S2[j][i])
                return 0;
    }
    return 1;
}
void Solve()
{
    int ans = 0;
    for(int i = 0; i < N; i++)
    {
        bool val = check(i);
        if(val == 1)
            ans += (N - i);
        if(i == 0)
            continue;
        val = check2(i);
        if(val == 1)
            ans += (N - i);
    }
    cout << ans << "\n";
}
int main()
{
    Read();
    Solve();
    return 0;
}


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

int main(){
    int x;
    cin >> x;
    int cnt = 0;
    int xcp = x;
    cnt = xcp/100;
    xcp -= 100*cnt;
    bool aa = true;
    for(int i = 0;i < cnt;i++){
        if(xcp>=5){
            xcp-=5;
        }
        else{
            xcp = 0;
            break;
        }
    }
    if(xcp != 0) aa = false;
    if(aa) cout << "1";
    else cout << "0";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)


void solve(long long A, long long B, long long C, long long D){
    cout << min(A,B ) + min(C, D) << endl;
}

int main(){

    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long C;
    scanf("%lld",&C);
    long long D;
    scanf("%lld",&D);
    solve(A, B, C, D);
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n;
int main(){
	cin>>n;
	int ans=0;
	for(int i=1;i<=n;i++){
		if(i<10||(i<1000&&i>99)||(i<100000&&i>9999)){
			ans++;
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
//Author ::  ABHINAV3010 ::

#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define fast ios_base::sync_with_stdio(false)
typedef long long ll;
typedef pair<ll,ll> p;
ll mod=1000000007;
ll gcd(ll a,ll b)
{
    return (b==0)?a:gcd(b,a%b);
}
ll power(ll x, ll y, ll p=mod)
{ll res = 1;x = x % p;while (y > 0){if (y & 1){res = (res*x) % p;}y = y>>1;x = (x*x) % p;}return res;}
int main()
{
fast;
ll n;
cin>>n;
vector<ll>v;
for(ll i=0;i<n;i++)
{
    ll a;
    cin>>a;
    v.pb(a);
}
ll ans=1e15;
for(ll i=1;i<=100;i++)
{
    ll cal=0;
    for(ll j=0;j<n;j++)
    {
        cal+=(v[j]-i)*(v[j]-i);
    }
    ans=min(ans,cal);
}
cout<<ans<<endl;
return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
#include<complex>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 4000001;
const double eps = 1E-18;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

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

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};

class mint {
	long long x;
public:
	mint(long long x = 0) : x((x% MOD + MOD) % MOD) {}
	mint operator-() const {
		return mint(-x);
	}
	mint& operator+=(const mint& a) {
		if ((x += a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator-=(const mint& a) {
		if ((x += MOD - a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator*=(const  mint& a) {
		(x *= a.x) %= MOD;
		return *this;
	}
	mint operator+(const mint& a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint& a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint& a) const {
		mint res(*this);
		return res *= a;
	}

	mint operator^(const ll& t)const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}
	// for prime MOD
	mint inv() const {
		return pow(MOD - 2);
	}
	mint& operator/=(const mint& a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint& a) const {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream& os, const mint& m) {
		os << m.x;
		return os;
	}
};

///////////////////////////

int main() {
	ll N;
	cin >> N;
	N %= 10;

	if (N == 0 || N == 1 || N == 6 || N == 8) { cout << "pon" << endl; }
	else if (N == 3) { cout << "bon" << endl; }
	else { cout << "hon" << endl; }
	
}


Measured memory_bytes: 3636
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/* 
 * File:   main.c
 * Author: Ivan
 *
 * Created on July 19, 2018, 2:10 AM
 */

#include <stdio.h>
#include <stdlib.h>
#define MAX 5000001

/*
 * 
 */

int H, Heap[MAX];

void maxHeapify(int i);
void buildHeap();

int main(int argc, char** argv) {
    scanf("%d", &H);
    for (int i = 1; i <= H; ++i) scanf("%d", &Heap[i]);
    buildHeap();
    for (int i = 1; i <= H; ++i) printf(" %d", Heap[i]);
    printf("\n");
    return (EXIT_SUCCESS);
}

void maxHeapify(int i)
{
    int left, right, max, temp;
    left = i*2;
    right = i*2+1;
    
    if (left <= H && Heap[left] > Heap[i]) max = left;
    else max = i;
    if (right <= H && Heap[right] > Heap[max]) max = right;
    
    if (max != i)
    {
        temp = Heap[i];
        Heap[i] = Heap[max];
        Heap[max] = temp;
        maxHeapify(max);
    }
}

void buildHeap()
{
    for (int i = H/2; i >= 1; --i) maxHeapify(i);
}




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

#define TRACE(x) x
#define WATCH(x) TRACE(cout << #x" = " << x << endl)
#define WATCHR(a, b) TRACE(for (auto it=a; it!=b;) cout << *(it++) << " "; cout << endl)
#define WATCHC(V) TRACE({cout << #V" = "; WATCHR(V.begin(), V.end());})

#define all(x) (x).begin(), (x).end()

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

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

    int N, M;
    cin >> N >> M;
    N *= 2;

    vi vals(N);
    for (int i = 0; i < N; i++) {
        cin >> vals[i];
    }
    sort(all(vals));

    int lb = 0, ub = N / 2 - 1, rs = N / 2;
    while (lb <= ub) {
        int mi = (lb + ub) / 2;

        bool red = true;
        for (int i = mi * 2; i < N; i++) {
            red &= vals[i] + vals[N - 1 - i + mi * 2] >= M;
        }
        if (red) {
            rs = mi;
            ub = mi - 1;
        } else {
            lb = mi + 1;
        }
    }

    rs *= 2;
    int ans = 0;
    for (int i = 0; i < rs; i++) {
        ans = max(ans, vals[i] + vals[rs - 1 - i]);
    }
    for (int i = rs; i < N; i++) {
        ans = max(ans, vals[i] + vals[N - 1 - i + rs] - M);
    }
    cout << ans << endl;

    return 0;
}



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

int main(){
    int i,j;
    int N,L;
    cin >> N >> L;
    char s[N + 1][L + 1];
    char tmp[(N * L) + 1];
    
    for(i=0; i < N;i++){
        cin >> s[i];
    }

    for(i = 1; i < N; i++){
        for(j = 1; j < N; j++){
            if(strncmp(s[j - 1],s[j],L) > 0){
                strcpy(tmp, s[j - 1]);
                strcpy(s[j - 1], s[j]);
                strcpy(s[j], tmp);
            }
        }
    }

    for(i = 0;i < N; i++){
        cout << s[i];
    }
}

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

int main(){
  int a,b;
  cin >>a >>b;
  if(a==b) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


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

int main() {
	int N, A, B;
	int Plan1, Plan2;
	cin >> N >> A >> B;

	Plan1 = N * A;
	Plan2 = B;

	if (Plan1 <= Plan2) {
		cout << Plan1 << endl;
	}
	else if (Plan1 > Plan2) {
		cout << Plan2 << endl;
	}
}

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

/* 大文字を小文字に変換 */
char tolower(char c) {return (c + 0x20);}
/* 小文字を大文字に変換 */
char toupr(char c) {return (c - 0x20);}

// if('A'<=s[i] && s[i]<='Z') s[i] += 'a'-'A';

/*
string s = "abcdefg"
s.substr(4) "efg"
s.substr(0,3) "abc"
s.substr(2,4) "cdef"

// イテレータ要素のインデックス
distance(A.begin(), itr);
*/

int main()
{
    int N; cin >> N;
    P coor[N];
    rep(i,N){
        cin >> coor[i].first >> coor[i].second;
    }
    vector<int> v; 
    rep(i,N) v.push_back(i);
    sort(v.begin(), v.end());
    vector<double> sumv;
    do{
        // 各順列についての処理を記述する
        double sum = 0;
        rep(i,N-1){
            double d = sqrt((coor[v[i]].first - coor[v[i+1]].first)*(coor[v[i]].first - coor[v[i+1]].first) + (coor[v[i]].second - coor[v[i+1]].second)*(coor[v[i]].second - coor[v[i+1]].second)); 
            sum += d;
        }
        sumv.push_back(sum);
    }while(next_permutation(v.begin(), v.end()));   // 全ての順列を列挙することができる
    double av = 0;
    for(double s: sumv){
        av += (s / sumv.size());
    }
    printf("%.7lf\n", av);

    return 0;
}


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

using namespace std;

typedef long long ll;
#define sint(a) scanf("%d",&a)
#define sint2(a,b) scanf("%d %d",&a,&b)
#define sll(a) scanf("%lld",&a)
#define sll2(a,b) scanf("%lld %lld",&a,&b)
#define mem(a,i) memset(a,i,sizeof(a))
const double pi=acos(-1);
const int maxn=1e5;
int main()
{
    double a;
    while(cin>>a)
    {
        int flag=0;
        for(int i=0; i<maxn; i++)
            if(fabs(floor(i*1.08)-a)<0.00001)
            {
                flag=1;
                cout<<i<<endl;
                break;
            }
            else if(a<i*1.08)
                break;
        if(!flag)
            cout<<":("<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
#include <map>
#include <cmath>

using namespace std;

#define INF (int)1e9 + 7
#define int long long

char agct[4] = {'a', 'g', 'c', 't'};

bool is_taboo(string s)
{
    if (s.find("agc") != string::npos)
    {
        return true;
    }

    for (int i = 0; i < s.size() - 1; i++)
    {
        char c1 = s[i];
        char c2 = s[i + 1];
        s[i] = c2;
        s[i + 1] = c1;
        if (s.find("agc") != string::npos)
        {
            return true;
        }
        s[i] = c1;
        s[i + 1] = c2;
    }

    return false;
}

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

    //dp[i] ... size N string number of ans
    vector<map<string, int>> dp(N + 1);

    for (int i = 1; i <= N; i++)
    {
        if (i == 1)
        {
            for (int j = 0; j < 4; j++)
            {
                string add = "";
                dp[i][add + agct[j]] = 1;
            }
        }
        else if (i <= 5)
        {
            for (const auto x : dp[i - 1])
            {
                auto key = x.first;
                auto value = x.second;
                for (int j = 0; j < 4; j++)
                {
                    string sadd = key + agct[j];
                    if (!is_taboo(sadd))
                    {
                        if (dp[i].find(sadd) == dp[i].end())
                        {
                            dp[i][sadd] = dp[i - 1][key];
                        }
                        else
                        {
                            dp[i][sadd] += dp[i - 1][key];
                        }
                    }
                }
            }
        }
        else
        {
            for (const auto x : dp[i - 1])
            {
                auto key = x.first;
                auto value = x.second;
                for (int j = 0; j < 4; j++)
                {
                    string sadd = key + agct[j];
                    sadd = sadd.substr(1);
                    if (!is_taboo(sadd))
                    {
                        if (dp[i].find(sadd) == dp[i].end())
                        {
                            dp[i][sadd] = dp[i - 1][key];
                        }
                        else
                        {
                            dp[i][sadd] += dp[i - 1][key];
                        }
                        dp[i][sadd] %= INF;
                    }
                }
            }
        }
    }
    int ans = 0;
    for (const auto x : dp[N])
    {
        auto key = x.first;
        auto value = x.second;
        ans += value;
        ans %= INF;
    }

    cout << ans << endl;
}

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

int data[10];
bool sumilation(int left,int right,int num){
	if(num == 10) return true;
	
	if(left < data[num]){
		if(sumilation(data[num],right,num+1)) return true;
	} 
	if(right < data[num]){
		if(sumilation(left,data[num],num+1)) return true;
	}
	return false;
	
	
}

int main(){
	int times;
	cin >> times;
	for(int i=0;i<times;i++){
		for(int k=0;k<10;k++)
		cin >> data[k];
		if(sumilation(0,0,0) == true){
		cout << "YES" << endl;
		} else {
		cout << "NO" <<endl;
		}
		
		
	}

}

Measured memory_bytes: 1152