akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int main(){
  char c;
  cin >> c;
  if(c == 'a' ||  c == 'i' ||  c == 'u' ||  c == 'e' ||  c == 'o' ){
    cout << "vowel" << endl;
  }
  else{
  cout << "consonant" << endl;
  }
}

Measured memory_bytes: 256
//
//  blue and red.cpp
//  my_programs
//
//  Created by Jiatuo Zou on 7/27/20.
//  Copyright © 2020 Jiatuo Zou. All rights reserved.
//

#include <iostream>
#include <algorithm>

int main()
{
    using namespace std;
    
    int x, y, a, b, c;
    long long int p[100000], q[100000], r[100000], combined[200000], sum = 0;
    cin >> x >> y >> a >> b >> c;
    for(int i = 0; i < a; i++){
        cin >> p[i];
    }
    for(int i = 0; i < b; i++){
        cin >> q[i];
    }
    for(int i = 0; i < c; i++){
        cin >> r[i];
    }
    sort(p, p + a);
    sort(q, q + b);
    sort(r, r + c);
    for(int i = a - 1; i >= a - x; i--){
        combined[a - 1 - i] = p[i];
    }
    for(int i = b - 1; i >= b - y; i--){
        combined[x + b - 1 - i] = q[i];
    }
    sort(combined, combined + x + y);
    for(int i = 0; i < x + y; i++){
        if(c - 1 - i >= 0 && combined[i] < r[c - 1 - i]){
            combined[i] = r[c - 1 - i];
        }
    }
    for(int i = 0; i < x + y; i++){
        sum += combined[i];
    }
    cout << sum << endl;
    return 0;
}


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

using namespace std;

const int MX = 200000;

int p[MX];

int main() {
	int n;
	ignore = scanf("%d", &n);
	for (int i = 0, x; i < n; i++) {
		ignore = scanf("%d", &x);
		p[x - 1] = i;
	}
	
	int ans = 0;
	for (int i = 0, f = 0, q = -1; i < n; q = p[i++]) {
		if (p[i] > q) f++;
		else f = 1;
		ans = max(ans, f);
	}
	
	printf("%d\n", n - ans);
	
	return 0;
}


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

#define rep(i, n) for (int i = 0; i < (n); ++i)

using namespace std;

using ll = long long;
using P = pair<int, int>;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  sort(a.rbegin(), a.rend());
  int nn = a.at(0);
  int nr = a.at(1);
  int mid = (nn + 1) / 2;
  for (int i = 1; i < n; ++i) {
    if (abs(a.at(i) - mid) < abs(nr - mid)) {
      nr = a.at(i);
    }
  }
  cout << nn << " " << nr << endl;
  return 0;
}


Measured memory_bytes: 640
function main(input) {
  var s = input[0]-0;
  var ans = 0;
  for(var i=1;i<s;i++){
    if(s-i>i) ans++;
  }
  console.log(ans);
}
 
main(require('fs').readFileSync('/dev/stdin', 'utf8').split("\n"))

Measured memory_bytes: 21064
n,m=map(int,input().split())
H=list(map(int,input().split()))
G=[[]for i in range(n)]
for i in range(m):
  a,b=map(int,input().split())
  a=a-1
  b=b-1
  G[a].append(b)
  G[b].append(a)
ans=0
for i in range(n):
  f=0
  for j in range(len(G[i])):
    if H[i]<=H[G[i][j]]:
      f=1
  if f==0:
    ans=ans+1
print(ans)

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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
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 == 0) return(b);
   else return(gcd(b, a%b));
}

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

int main()
{
    cout << fixed << setprecision(15);
    ll a, b, c, d;
    cin >> a >> b >> c >> d;

    cout << max(max(a*c, a*d), max(b*c, b*d)) << endl;
    return 0;
}

Measured memory_bytes: 3668
def examA():
    T, X = LI()
    ans = T/X
    print(ans)
    return

def examB():
    N = I()
    L = LI()
    ans = "Yes"
    if max(L)*2>=sum(L):
        ans = "No"
    print(ans)
    return

def examC():
    N, M = LI()
    X = LI(); X.sort()
    x = []
    for i in range(M-1):
        x.append(X[i+1]-X[i])
    x.sort()
    ans = 0
    if N>=M:
        ans = 0
    else:
        for i in range(M-N):
            ans += x[i]
    print(ans)
    return

def examD():
    N, K = LI()
    A = LI()
    d = defaultdict(int)
    maxl = len(bin(K)) -2
    if K==0:
        print(sum(A))
        exit()
    for a in A:
        for j in range(maxl):
            if a&1==1:
                d[j] +=1
            a >>=1
            if a==0:
                break
#    print(d)
    X = 0
    d0 = defaultdict(bool)
    cur = []
    for i in range(maxl):
        c = (2**i)*(N-d[i]*2)
        cur.append(max(0,c))
    curK = [0]*(maxl+1)
    curK[maxl-1] = cur[maxl-1]
    for i in range(maxl-2, -1, -1):
        if K & (1 << i) == (1 << i):
            curK[i] += curK[i + 1] + cur[i]
        else:
            d0[i] = True
            curK[i] += curK[i + 1]
    ansC = curK[0]
#    print(cur)
#    print(curK)
    for l in range(maxl):
        if d0[l]:
            continue
        now = curK[l+1]
        for i in range(l-1, -1, -1):
            now += cur[i]
        ansC = max(ansC,now)
    ans = ansC+sum(A)
    print(ans)
    return

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

if __name__ == '__main__':
    examD()


Measured memory_bytes: 63600
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

int make(vector<int> num)
{
	int s;
	s = 0;
	for (int i = 0; i < 4; i++){
		s = s * 10 + num[i];
	}
	
	return (s);
}

int main(void)
{
	vector<int> num(4);
	int n;
	int t;
	int ct;
	
	while (scanf("%d", &n) && n){
		
		if (n % 1111 == 0){
			printf("NA\n");
			continue;
		}
		
		ct = 0;
		while (n != 6174){
			ct++;
			t = n;
			for (int i = 0; i < 4; i++){
				num[i] = t % 10;
				t /= 10;
			}
			sort(num.rbegin(), num.rend());
			int L = make(num);
			sort(num.begin(), num.end());
			int S = make(num);
			n = L - S;
		}
		
		printf("%d\n", ct);
	}
	
	return (0);
}

Measured memory_bytes: 1060
package main

import "fmt"

func max(n, m int) (int, int) {
	if n > m {
		return n, m
	}
	return m, n
}

func main() {
	var n, m int
	fmt.Scan(&n, &m)

	var sum int
	if n >= 2 && m >= 2 {
		sum = (n - 2) * (m - 2)
	} else if n == 1 && m == 1 {
		sum = 1
	} else {
		max, min := max(n, m)
		sum = (max - 2) * min
	}

	fmt.Println(sum)
}


Measured memory_bytes: 512
import std.algorithm;
import std.array;
import std.container;
import std.conv;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void scan(T...)(ref T a) {
    string[] ss = readln.split;
    foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

void main() {
    int a, b; scan(a, b);

    if (1 <= a && a <= 9 && 1 <= b && b <= 9)
        writeln(a * b);
    else writeln("-1");
}


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

class Dice{
    private:
        std::vector<int> d;
    public:
        Dice(std::vector<int> a) {
            d = a;
            d.push_back(0); // tmp用
        }

        void N() {
            d.at(6) = d.at(1 - 1);
            d.at(1 - 1) = d.at(2 - 1);
            d.at(2 - 1) = d.at(6 - 1);
            d.at(6 - 1) = d.at(5 - 1);
            d.at(5 - 1) = d.at(6);
        }

        void S() {
            d.at(6) = d.at(1 - 1);
            d.at(1 -1 ) = d.at(5 - 1);
            d.at(5 - 1) = d.at(6 - 1);
            d.at(6 - 1) = d.at(2 - 1);
            d.at(2 - 1) = d.at(6);
        }

        void W() {
            d.at(6) = d.at(1 - 1);
            d.at(1 - 1) = d.at(3 - 1);
            d.at(3 - 1) = d.at(6 - 1);
            d.at(6 - 1) = d.at(4 - 1);
            d.at(4 - 1) = d.at(6);
        }

        void E() {
            d.at(6) = d.at(1 - 1);
            d.at(1 - 1) = d.at(4 - 1);
            d.at(4 - 1) = d.at(6 - 1);
            d.at(6 - 1) = d.at(3 - 1);
            d.at(3 - 1) = d.at(6);
        }

        int get_dice() {
            return d.at(0);
        }
 };

int main(void) {
    using namespace std;

    vector<int> a(6);
    for (int i = 0; i < 6; i++) {
        cin >> a.at(i);
    }
    Dice dice(a);

    string sign;
    cin >> sign;
    for (char ch: sign){
        if (ch == 'N') {
            dice.N();
        } else if (ch == 'S') {
            dice.S();
        } else if (ch == 'W') {
            dice.W();
        } else if (ch == 'E') {
            dice.E();
        }
    }
    printf("%d\n", dice.get_dice());
    return 0;
}


Measured memory_bytes: 3364
#include <bits/stdc++.h>
using namespace std;
int q[123456],c[123456];
int main(){
	int a,b,i,j,n;
	cin>>n;
	for (i=0;i<n;++i){
		cin>>q[i];
	}
	c[0]=0;
	c[1]=abs(q[1]-q[0]);
	for (i=2;i<n;++i){
		c[i]=min(abs(q[i]-q[i-1])+c[i-1],abs(q[i]-q[i-2])+c[i-2]);
		
	}
	cout <<c[n-1];
}

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

int main(){
	string n;
	cin >> n;
	rep(i,3){
		if(n[i] == '1'){
			n[i] = '9';
		}else if(n[i] == '9'){
			n[i] = '1';
		}

	}
	cout << n << endl;

	return 0;
}



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

vector<ll> divisor(ll n) {
  vector<ll> res;
  for(ll i = 1; i * i <= n; i++) {
    if(n%i == 0) {
      res.emplace_back(i);
      if(i != n / i) res.emplace_back(n / i);
    }
  }
  return res;
}

int main() {
  int n,m;
  cin >> n >> m;
  int ans = 1;
  vector<ll>div = divisor(m);
  sort(div.begin(),div.end());
  rep(i,div.size()){
    if(div[i] > m/n) break;
    if(m/div[i] >= n) ans = div[i];
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
N = int(input())
P = list(map(int,input().split()))

#任意の整数 j(1≤j≤i)に対して、 Pi≤Pj をみたすiの個数
inf = float("inf")
minimum = inf
counter = 0
for i in range(N):
    if P[i]<minimum:
        minimum = P[i]
        counter += 1

    

print(counter)

Measured memory_bytes: 75472
#include<bits/stdc++.h>
using namespace std;
int n;
string interact(vector<int>a)
{
	cout<<"? ";
	for(int i=0;i<a.size();i++)
		cout<<a[i]<<" ";
	cout<<endl;
	string res;
	cin>>res;
	return res;
}
string ask(int l,int r)
{
	vector<int>a;
	for(int i=l;i<=r;i++)
		a.push_back(i);
	return interact(a);
}
string solve(int n)
{
	string a1=ask(1,n);
	int at=0;
	for(int i=7;i>=0;i--)
	{
		int to=min(n+1,at+(1<<i));
		string a2=ask(to,to+n-1);
		if(a1==a2) at+=(1<<i);
	}
	
	vector<int>tmp1,tmp2;
	for(int i=at+1;i<=at+n-1;i++)
		tmp1.push_back(i);
	for(int i=1;i<at;i++)
		tmp2.push_back(i);
	for(int i=at+n+1;i<=2*n;i++)
		tmp2.push_back(i);
	
	string ans="";
	for (int i=1;i<=2*n;i++) 
	{
		if(at+1<=i&&i<=at+n-1) 
		{
			vector<int>cur=tmp2;
			cur.push_back(i);
			string res=interact(cur);
			if(res=="Blue") ans+="B";
			else ans+="R";
		}
		else 
		{
			vector<int>cur=tmp1;
			cur.push_back(i);
			string res=interact(cur);
			if(res=="Blue") ans+="B";
			else ans+="R";
		}
	}
	return ans;
}
signed main()
{
	scanf("%d",&n);
	string ans=solve(n);
	cout<<"! "<<ans;
	return 0;
}


Measured memory_bytes: 724
#[allow(unused_imports)]
use std::cmp::Ordering;

#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};

#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};

#[allow(unused_imports)]
use std::iter::FromIterator;

#[allow(unused_macros)]
macro_rules! min {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::min($x, min!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! max {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::max($x, max!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! get {
    ([$t: ty]) => {
        {
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            line.split_whitespace().map(|t|t.parse::<$t>().unwrap()).collect::<Vec<_>>()
        }
    };
    ([$t: ty];$n: expr) => {
        (0..$n).map(|_|get!([$t])).collect::<Vec<_>>()
    };
    ($t: ty) => {
        {
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t: ty),*) => {
        {
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap(),)*)
        }
    };
    ($t: ty; $n: expr) => {
        (0..$n).map(|_|get!($t)).collect::<Vec<_>>()
    };
    ($($t: ty),*; $n: expr) => {
        (0..$n).map(|_|get!($($t),*)).collect::<Vec<_>>()
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*).unwrap();
    }
}

const BIG_STACK_SIZE: bool = true;

#[allow(dead_code)]
fn main() {
    use std::thread;
    if BIG_STACK_SIZE {
        thread::Builder::new()
            .stack_size(32 * 1024 * 1024)
            .name("solve".into())
            .spawn(solve)
            .unwrap()
            .join()
            .unwrap();
    } else {
        solve();
    }
}

fn solve() {
    let m = get!(usize);
    let dc = get!(usize,usize;m);

    let mut sum = 0;
    let mut csum = 0;
    for (d, c) in dc {
        sum += d * c;
        csum += c;
    }
    println!("{}", csum - 1 + (sum - 1) / 9);
}


Measured memory_bytes: 12540
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iomanip>
#include <cmath>

using namespace std;
using ll = long long int;

template <class T> ostream &operator<<(ostream &os, vector<T> &v) {
  for (auto i = v.begin(); i != v.end(); i++) {
    os << *i << " ";
  }
  return os;
}


void solve(long long N, std::vector<long long> A){
  sort(A.begin(), A.end());
  vector<pair<ll, ll>> v;
  for(ll i=1; i+1<N; i++) {
    if(A[i]<0) {
      v.push_back(make_pair(A[N-1], A[i]));
      A[N-1] = A[N-1]-A[i];
    } else {
      v.push_back(make_pair(A[0], A[i]));
      A[0] = A[0] - A[i];
    }
  }
  v.push_back(make_pair(A[N-1], A[0]));
  std::cout << A[N-1]-A[0] << std::endl;
  for(auto p: v) {
    std::cout << p.first << " " << p.second << std::endl;
  }
}

int main(){
  long long N;
  scanf("%lld",&N);
  std::vector<long long> A(N);
  for(int i = 0 ; i < N ; i++){
    scanf("%lld",&A[i]);
  }
  solve(N, std::move(A));
  return 0;
}



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

using namespace std;

int main()
{
    long long a,b,c;
    cin>>a>>b>>c;
    if(a==b && b!=c || a==c && b!=c || b==c && a!=c)
        cout<<"Yes\n";
    else
        cout<<"No\n";

    return 0;
}



Measured memory_bytes: 256
import collections
import math
import re
import numpy
def ai():return input()#s
def a():return int(input())#a,n or k
def ma():return map(int, input().split())#a,b,c,d or n,k
def ms():return map(str, input().split())#,a,b,c,d
def lma():return list(map(int, input().split()))#x or y
def lms():return list(map(str, input().split()))#x or y
def say(i):return print("Yes" if i == 0 else "No")
def Say(i):return print("YES" if i == 0 else "NO")
k= []
l = []
f = 0
s=0
c=0
e =1

a,b,c=ma()
print((a*b)//2)

Measured memory_bytes: 12472
#include <cstdio>




int main(){

  int W, H, N, W0 = 0, H0 = 0;
  int x, y, a;

  scanf("%d%d%d", &W, &H ,&N);
  for(int i = 0; i < N; i++){
    scanf("%d%d%d", &x, &y, &a);

    if(a == 1 && x > W0) W0 = x;
    if(a == 2 && x < W ) W  = x;
    if(a == 3 && y > H0) H0 = y;
    if(a == 4 && y < H ) H  = y;

  }

  int A = W - W0;
  int B = H - H0;

  if(A <= 0 || B <= 0)
    printf("0\n");
  else
    printf("%d", A * B);

}


Measured memory_bytes: 128
#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 INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;


int main()
{
    ll n;
    cin >> n;
    ll count = 0;
    for (ll t = 1; t <= n; t += 2) {
        ll divisor_count = 0;
        for (ll i = 1; i <= (ll)floor(sqrt(t)); i++) {
            if (t % i == 0) {
                divisor_count++;
            }
        }
        if (divisor_count * 2 == 8) {
            count++;
        }
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define range(a) (a).begin(),(a).end()
#define print(A,x,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i]x;}cout<<endl;
#define pprint(A,y,m,n) rep(j,0,m){print(A[j],y,n);}
const long mod=1e9+7;
const int size=1e6;
const int inf=1e9;
int main(){
	int N;cin>>N;
	int A[N];pair<int,int> vp[N];
	rep(i,0,N){
		cin>>A[i];
		vp[i]={abs(A[i]),i};
	}
	int id=max_element(vp,vp+N)->second;
	cout<<2*N-1<<endl;
	rep(i,0,N){
		cout<<id+1<<" "<<i+1<<endl;
	}
	if(A[id]>0){
		rep(i,0,N-1){
			cout<<i+1<<" "<<i+2<<endl;
		}
	}else{
		for(int i=N-1;i>0;i--){
			cout<<i+1<<" "<<i<<endl;
		}
	}
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <cstring>
#include <algorithm>
#include <vector>
#include <map>

using namespace std;

vector<int> fPath[100016];
vector<int> rPath[100016];
int maxPath[100016];
int minV = 0;
int maxV = 0;

int main() {
	int N, M;
	scanf("%d%d", &N, &M);
	for(int i=0; i<M; ++i) {
		int x, y;
		scanf("%d%d", &x, &y);
		fPath[x-1].emplace_back(y-1);
		rPath[y-1].emplace_back(x-1);
	}
	vector<int> stack;
	for(int i=0; i<N; ++i) if(rPath[i].empty()) {
		stack.emplace_back(i);
	}
	int result = 0;
	while(stack.size()) {
		int i = stack.back();
		stack.pop_back();
		for(int v : fPath[i]) {
			maxPath[v] = max(maxPath[i]+1, maxPath[v]);
			result = max(result, maxPath[v]);
			for(int j=0; j<rPath[v].size(); ++j) {
				if(rPath[v][j]==i) {
					rPath[v][j] = rPath[v].back();
					rPath[v].pop_back();
					break;
				}
			}
			if(rPath[v].empty()) {
				stack.emplace_back(v);
			}
		}
	}
	printf("%d\n", result);

	return 0;
}


Measured memory_bytes: 11520
#include<bits/stdc++.h>
using namespace std;
int main(){
  int A,B,K;
  int cnt = 1;
  cin>>A>>B>>K;
  int comdiv[100];
  for(int i = 100;0<i;i--){
    if((A%i == 0)&&(B%i == 0)){
    comdiv[cnt] = i;
    cnt++;
    }
  }
  cout<<comdiv[K];
}

Measured memory_bytes: 384
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define FOR(n) for(int i=0;i<n;i++)
#define FORJ(n) for(int j=0;j<n;j++)
#define PRN(n) printf("%d\n",n)
#define PRF(n) printf("%lf\n",n)
#define PRL(n) printf("%lld\n",n)
#define PRS(s) printf("%s\n",s)
#define PRC(c) printf("%c",c)
#define INF 10000000000
#define mod 1000000007
typedef long long int ll;
ll u(const void *a, const void *b){return *(ll*)a-*(ll*)b;}
ll d(const void *a, const void *b){return *(ll*)b-*(ll*)a;}
ll min(ll a,ll b){
  if(a>b)return b;
  return a;
}
ll max(ll a,ll b){
  if(a>b)return a;
  return b;
}
ll gcd(ll a,ll b){
  if(!b)return a;
  return gcd(b,a%b);
}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
int kt(ll a){
  int sum=0;
  while(a){
    a/=10;
    sum++;
  }
  return sum;
}
int ks(ll a){
  int sum=0;
  while(a){
    sum+=a%10;
    a/=10;
  }
  return sum;
}
ll f(ll a){
  return a*(a+1)/2;
}
int main(void){
  int n;
  scanf("%d",&n);
  PRN((1+n)/2-1);
  return 0;
}


Measured memory_bytes: 128
using System;

namespace tst
{
    class Program
    {
        static void Main(string[] args)
        {   
            //lenに配列の要素数
            var len = int.Parse(Console.ReadLine());
            //str //5 2 4 6 1 3 
            string str = Console.ReadLine();
            //スペース区切りでstr配列に//5 2 4 6 1 3 
            string[] data = str.Split(' ');
            //str配列をint配列に
            int[] dt = new int[len];
            for(int i=0; i<=len-1; i++)
            {
                dt[i] = int.Parse(data[i]);
            }
            //入力の確認//最後に空白入れない
            Console.Write(dt[0]);
            for(int i=1; i<len; i++)
            {
                Console.Write(" "+dt[i]);
            }
            Console.WriteLine();

            //ソートのアルゴリズム
            for (int i=1; i<=len-1; i++)
            {   
                var v = dt[i];//dt[1]-dt[len-1]
                var j = i - 1;//dt[0]-dt[len-2]
                while (j >= 0 && dt[j] > v)//dt[i-1]>dt[i]
                {
                    dt[j + 1] = dt[j];
                    j--;
                }
                dt[j + 1] = v;
                //一回の試行結果
                Console.Write(dt[0]);
                for (int k = 1; k < len; k++)
                {
                    Console.Write(" " + dt[k]);
                }
                Console.WriteLine();
            }

        }
    }
}


Measured memory_bytes: 15944
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

int mod(int , int);
int fun(int * , int , int*);
int k;

int main()
{
	int H;
	cin>>H>>k;
	int h[H],memo[H];
	for(int i=0;i<H;i++)
	{
		cin>>h[i];
		memo[i]=-1;
	}
	memo[0]=0;
	memo[1]=mod(h[0],h[1]) ;
	cout<<fun(h,H-1,memo);
	return 0;
}
int fun(int h[],int n,int memo[])
{
	if(memo[n]!=-1) return(memo[n]) ;
	int min=INT_MAX,last,temp,i;
	if(n<k) last=n;
	else last=k;
	for(i=1;i<=last;i++)
	{
		temp=fun(h,n-i,memo)+mod(h[n],h[n-i]) ;
		if(temp<=min) min=temp; 
	}
	memo[n]=min ;
	return(memo[n]) ;
}
int mod(int a , int b)
{
	if(a>=b) return(a-b) ;
	return(b-a) ;
}

Measured memory_bytes: 10368
#include<iostream>
#include<string>
#include<string.h>
#include<algorithm>
#include<stdio.h>
#include<cmath>
#include<vector>

#define FOR(i, a, b) for(int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
using namespace std;

int main(void) {
	int n, a, b;
	int count = 0;
	int point = 0;
	string s;
	cin >> n >> a >> b >> s;
	FOR(i, 0, s.size()-1) {
		if (s[i] == 'c') {
			cout << "No" << endl;
		}
		else if (s[i] == 'a') {
			if (count < a + b) {
				cout << "Yes" << endl;
				count++;
			}
			else {
				cout << "No" << endl;
			}
		}
		else if (s[i] == 'b') {
			if (count < a + b) {
				if (point < b) {
					cout << "Yes" << endl;
					count++;
					point++;
				}
				else {
					cout << "No" << endl;
				}
			}
			else {
				cout << "No" << endl;
			}
		}
	}
	return 0;
}

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


int main(){
    int n;
    cin >> n;
    vector<int> x(n);
    vector<int> y(n); //xをソートしたもの
    vector<int> ans(n);
    rep(i,n){
        int c;
        cin >> c;
        x[i] = c;
        y[i] = c;
    }
    sort(y.begin(),y.end());

    rep(i,n){
      if(x[i] < y[n/2]) ans[i] = y[n/2];
      else ans[i] = y[n/2-1];
    }
    rep(i,n){
        cout << ans[i] << endl;
    }
}

Measured memory_bytes: 4480
#include<iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<vector>
#include<functional>
#include<iomanip>
#include<queue>
#include<cassert>
#include<tuple>
#include<set>
#include<map>
#include<list>
#include<bitset>
#include<utility>
#include<numeric>

#define PB push_back
#define all(a)  (a).begin(),(a).end()
#define ALL(v) begin(v), end(v)
#define dwn(a)  (a).begin(),(a).end(), greater<int>()
#define rep(i, m) for (int i = 0; i < m; i++)
#define REP(i, n, m) for (int i = n; i < m; i++)
#define V vector<int>
#define VV vector<V>
#define VVV vector<VV>

using namespace std;

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

const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
const int INF = (int)1e9;
const ll inf = (ll)1e18;
const ll MOD{ (ll)1e9 + 7 };
const long double EPS = 1e-10;

int h, w;
char s[51][51];
int d[51][51];

int bfs(int sy, int sx) {

	rep(y, h) {
		rep(x, w) {
			d[y][x] = INF;
		}
	}

	queue<P> que;
	que.push(P(sy, sx));
	d[sy][sx] = 0;

	while (!que.empty()) {
		P p = que.front();
		que.pop();

		if (p.first == h - 1 && p.second == w - 1) {
			break;
		}

		for (int i = 0; i < 4; i++) {
			int ny = p.first + dy[i];
			int nx = p.second + dx[i];
			if (0 <= nx && nx < w && 0 <= ny && ny < h && s[ny][nx] == '.' && d[ny][nx] == INF) {
				que.push(P(ny, nx));
				d[ny][nx] = d[p.first][p.second] + 1;
			}
		}
	}
	return d[h - 1][w - 1];
}

int main() {
	cin >> h >> w;
	int black = 0;
	rep(y, h) {
		rep(x, w) {
			cin >> s[y][x];
			if (s[y][x] == '#') {
				black++;
			}
		}
	}
	cout << max(-1, h * w - bfs(0, 0) - black - 1) << endl;
}

Measured memory_bytes: 256
// includes
#include <cstdio>
#include <cstdint>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <utility>
#include <functional>
#include <cmath>
#include <climits>
#include <bitset>
#include <list>

// macros
#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for(int i=((int)(n)-1);i>=0;i--)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())

using namespace std;

//  types
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
typedef pair<double, double> Pd;
 
// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;
const int mod = 1e9 + 7;

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

struct Graph{
  int n;
  vector<vector<int> > edge;
  vector<int> in_deg;
  Graph(int n_){
    n = n_;
    edge.resize(n);
    in_deg.resize(n, 0);
  }
  void adde(int at, int to){
    edge[at].push_back(to);
    in_deg[to]++;
  }
  vector<int> topological_sort(){
    stack<int> st;
    for(int i = 0; i < n; i++){
      if(in_deg[i] == 0)st.push(i);
    }
    vector<int> res;
    while(st.size()){
      int at = st.top(); st.pop();
      res.push_back(at);
      for(int j: edge[at]){
        in_deg[j]--;
        if(in_deg[j] == 0)st.push(j);
      }
    }

    return res;
  }
};
vector<int> es[100001];

int main(int argc, char const* argv[])
{
  int n, m;
  cin >> n >> m;
  Graph graph(n);
  rep(i, n + m -1){
    int a, b;
    cin >> a >> b;
    a--; b--;
    graph.adde(a, b);
    es[b].pb(a);
  }
  vector<int> vec = graph.topological_sort();
  vector<int> tt(n, 0);
  rep(i, n)tt[vec[i]] = i;
  vector<int> tr(n, -1);
  tr[vec[0]] = -2;
  FOR(i, 1, n){
    for(auto j: es[vec[i]]){
      if(tr[vec[i]] == -1 || tt[tr[vec[i]]] < tt[j])tr[vec[i]] = j;
    }
  }
  rep(i, n){
    if(tr[i] != -2)cout << tr[i] + 1 << endl;
    else cout << 0<< endl;
  }
	return 0;
}


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

int c_x=0,c_y=0,c_t=0;
int move_x=0,move_y=0;

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

	vector<int>t(n),x(n),y(n);
	for(int i=0; i<n;i++){
		cin >> t[i] >> x[i] >> y[i];
	}
	int move_x,move_y,pass_time,c_x=0,c_y=0,c_t=0;
	int move_sum;
	for(int i=0;i<n;i++){
		move_x=x[i]-c_x;
		move_y=y[i]-c_y;
		pass_time=t[i]-c_t;

		if(pass_time<move_x+move_y){
			cout << "No" << endl;
			return 0;
		}
		else{
			move_sum=move_x+move_y;
			if((move_sum%2==0 && pass_time%2!=0) ||(move_sum%2!=0 && pass_time%2==0)){
				cout << "No" << endl;
				return 0;
			}
		}
	}
	cout << "Yes" << endl;
	return 0;
}


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

using namespace std;

#define SZ(x) (int)(x.size())

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

int f(int a) {
  return (a * a + 4) / 8;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  string s; cin >> s;
  cout << s[0] << SZ(s)-2 << s[SZ(s)-1] << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
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 int INF=1001001001;
vector<pair<int64_t,int64_t>>pppp(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p; 
}
 
int main() {
  int N,K;
  cin>>N>>K;
  vector<int>p(N);
  for(int i=0;i<N;i++){
    cin>>p[i];
  }
  sort(p.begin(),p.end());
  int sum=0;
  for(int i=0;i<K;i++){
    sum+=p[i];
  }
  cout<<sum<<endl;
  return 0;
}

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

#define FAST ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define PER(j,n,a) for (int j=n-1;j>=a;j--)
#define REP(i,a,n) for (int i=a;i<n;i++)
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define show(x) cout<<(x)<<endl
#define UM unordered_map
#define PB push_back
#define V vector
#define EPS 1e-8
typedef unsigned long ul;
typedef long long ll;
typedef string str;
/*FIN*/

int main() {
	FAST;
	int N,W;
	cin>>N>>W;
	int w[N+1];
	ll v[N+1];
	REP(i,1,N+1) cin>>w[i]>>v[i];
	ll dp[N+1][W+1];
	REP(i,0,N+1) {
		REP(j,0,W+1) {
			if(min(i,j)==0)
				dp[i][j] = 0LL;
			else {
				dp[i][j] = dp[i-1][j];
				if(w[i] <= j)
					dp[i][j] = max(dp[i][j],v[i]+dp[i-1][j-w[i]]);
			}
		}
	}
	show(dp[N][W]);
	return 0;
}


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

int main(){
  while(true){
    string s1;
    cin >> s1;

    if(s1==".")
      break;

    string s2;
    cin >> s2;

    if(s1==s2){
      cout << "IDENTICAL" << endl;
      continue;
    }

    string t1 = s1;
    string t2 = s2;

    while(true){
      size_t d1b = t1.find('\"');
      if(d1b==string::npos)
        break;
      t1.replace(d1b,1,"@");

      size_t d1e = t1.find('\"');
      t1.replace(d1e,1,"@");

      size_t d2b = t2.find('\"');
      if(d2b==string::npos)
        break;
      t2.replace(d2b,1,"@");

      size_t d2e = t2.find('\"');
      t2.replace(d2e,1,"@");

      string u1 = s1;
      u1.replace(d1b+1, d1e-d1b-1, "");
      string u2 = s2;
      u2.replace(d2b+1, d2e-d2b-1, "");

      if(u1==u2){
        t1 = u1;
        t2 = u2;
        break;
      }
    }
    if(t1==t2){
      cout << "CLOSE" << endl;
    }
    else{
      cout << "DIFFERENT" << endl;
    }
  }
  return 0;
}



Measured memory_bytes: 3188
N, D = map(int, input().split())

XY = [tuple(map(int, input().split())) for _ in range(N)]
ans = 0

for xy in XY:
    L = ( xy[0]**2 + xy[1]**2 )**(1/2)
    if L <= D:
        ans += 1
        
print(ans)

Measured memory_bytes: 99988
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define INF 999999999
#define rep(i, n) for(int i = 0;i < n;i++)
#define pb(n) push_back(n)
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define Vecpr vector<pair<lli,lli>>
int main() {
  lli N,A,B=0;
  cin >>A>>N;
  string S;
  cin >>S;
  rep(i,A+N+1){
    if(S[i]=='-')B++;
  }
  if(B==1&&S[A]=='-')Out("Yes");
  else Out("No");
}

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

using namespace std;

int main(int argc, char const *argv[])
{
    int a[10], i;
    for (int i = 0; i < 10; ++i)
    {
        cin>>a[i];
    }
    sort(a,a+10);
    for (int i = 9; i > 6; i--)
    {
        cout<<a[i]<<endl;
    }
    return 0;
}

Measured memory_bytes: 3116
#include<bits/stdc++.h>
using namespace std;
int H,W;long a,b;long sum=0;
bool S[400][400];bool image;int check[400][400];
void search(int x,int y){
    if(x<0||x>=H||y<0||y>=W){
    }else if(check[x][y]==1){
    }else if(S[x][y]==image){
        check[x][y]=1;
        if(S[x][y]==true){
            a++;
        }else{
            b++;
        }image=!image;
        search(x-1,y);
        search(x+1,y);
        search(x,y-1);
        search(x,y+1);
        image=!image;
    }return;
}
int main(){
    cin>>H>>W;char temp;
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            cin>>temp;
            if(temp=='#'){
                S[i][j]=true;
            }else{
                S[i][j]=false;
            }check[i][j]=0;
        }
    }for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            if(check[i][j]==0){
                a=0;b=0;
                image=S[i][j];
                search(i,j);
                sum+=a*b;
           }
        }
    }cout<<sum<<endl;
}

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

int N, t, x, y, nx, ny, nt;

int main() {
    cin >> N;
    string ans = "Yes";
    for (int i = 0; i < N; i++) {
        cin >> t >> x >> y;
        int dist = abs(nx - x) + abs(ny - y);
        int grace = t - nt;
        if (dist > grace || (dist - grace) % 2) ans = "No";
        nx = x; ny = y; nt = t;
    }
    cout << ans << endl;
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

ll dp[100005][3];

void solve() {
    ll N;
    cin >> N;
    rep(i, N) {
        ll a, b, c;
        cin >> a >> b >> c;
        dp[i + 1][0] = max(dp[i][1] + a, dp[i][2] + a);
        dp[i + 1][1] = max(dp[i][0] + b, dp[i][2] + b);
        dp[i + 1][2] = max(dp[i][1] + c, dp[i][0] + c);
    }
    cout << max({dp[N][0], dp[N][1], dp[N][2]}) << '\n';
}

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


Measured memory_bytes: 5892
from bisect import *
n, m, k = map(int, input().split())
A = [0]
for x in map(int, input().split()):
    x += A[-1]
    if x > k: break
    A.append(x)
B = [0]
for x in map(int, input().split()):
    x += B[-1]
    if x > k: break
    B.append(x)
ans = 0
for i in range(len(A)):
    ans = max(ans, i + (bisect_right(B, k-A[i]) - 1))
print(ans)


Measured memory_bytes: 39756
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <math.h>
#include <assert.h>
#include <vector>
#include <queue>
#include <string>
#include <map>
#include <set>

using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-9;
static const double PI = acos(-1.0);

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define FOREQ(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define FORIT(it, c) for (__typeof((c).begin())it = (c).begin(); it != (c).end(); it++)
#define MEMSET(v, h) memset((v), h, sizeof(v))

int n;
bool visit[1010];
char strs[1010][1010];
bool seen[1010][1010];

void dfs(int from, int &node, int &edge) {
  visit[from] = true;
  node++;
  REP(to, n) {
    if (strs[from][to] == 'N') { continue; }
    if (!seen[from][to]) {
      edge++;
      seen[from][to]  = seen[to][from] = true;
    }
    if (visit[to]) { continue; }
    dfs(to, node, edge);
  }
}

int memo[1010][1010][2];
int calc(int odd, int even, int e) {
  if (odd + even == 1) { return 1; }
  if (memo[odd][even][e] != -1) { return memo[odd][even][e]; }
  int ret = 0;
  if (e == 1) { ret |= 1 ^ calc(odd, even, 0); }
  if (odd >= 2) {
    ret |= 1 ^ calc(odd - 2, even + 1, e);
  }
  if (even >= 2) {
    ret |= 1 ^ calc(odd, even - 1, e ^ 1);
  }
  if (odd >= 1 && even >= 1) {
    ret |= 1 ^ calc(odd, even - 1, e ^ 1);
  }
  return memo[odd][even][e] = ret;
}

int main() {
  while (scanf("%d", &n) > 0) {
    MEMSET(memo, -1);
    MEMSET(visit, false);
    MEMSET(seen, false);
    REP(y, n) {
      scanf("%s", strs[y]);
    }
    int odd = 0;
    int even = 0;
    int e = 0;
    REP(i, n) {
      if (visit[i]) { continue; }
      int node = 0;
      int edge = 0;
      dfs(i, node, edge);
      if (node % 2 == 0) { even++; }
      else { odd++; }
      int rest = node * (node - 1) / 2 - edge;
      rest = 0;
      if (rest % 2 == 1) { e ^= 1; }
    }
    if (calc(odd, even, e)) {
      puts("Taro");
    } else {
      puts("Hanako");
    }
  }
}

Measured memory_bytes: 10000
N = int(input())
li = []
for i in range(N):
  st = input().split()
  li.append([str(st[0]), int(st[1])])
X = str(input())
#print(N, X, li)

ans = 0
flag = 0

for i in range(len(li)):
  if flag == 1:
    ans += li[i][1]
  if X == li[i][0]:
    flag = 1
print(ans)
  

Measured memory_bytes: 3060
// ABC 143-C
// 2019.10.19 bal4u

#include <stdio.h>

#if 1
int getchar_unlocked(void);
#define gc() getchar_unlocked()
#else
#define gc() getchar()
#endif

int in() {   // 非負整数の入力
	int n = 0, c = gc();
	do n = 10 * n + (c & 0xf); while ((c = gc()) >= '0');
	return n;
}

void ins(char *s) { // 文字列の入力　スペース以下の文字で入力終了
	do *s = gc();
	while (*s++ > ' ');
	*(s-1) = 0;
}

char S[100005];

int main()
{
	int i, N, ans;
	
	N = in(), ins(S);
	ans = 1;
	for (i = 1; i < N; ++i) if (S[i] != S[i-1]) ++ans;
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 256
h, w = map(int, input().split())
a = [input() for _ in range(h)]
now = 0
ng = 0
for i in range(h):
    # print(now)
    # 限界まで伸ばせる点を探し、それより先に#がないことを確認
    extended = 0
    if a[i][now] != "#" or "#" in a[i][:now]:
        ng = 1
        # print(i, now)
        break
    for j in range(now, w):
        if not extended:
            if a[i][j] == "#":
                now = j
            else:
                extended = 1
        else:
            if a[i][j] == "#":
                #print(i, j)
                ng = 1
                break
        if i == h - 1 and j == w - 1 and a[i][j] == ".":
            ng = 1
    if ng:
        break
if ng:
    print("Impossible")
else:
    print("Possible")


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

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

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

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

const int mod =  1000000007;  //出力は (ans % mod + mod) % mod  (負の剰余を正にする)
const int inf = 1e9;
const long long INF = 1LL << 60;   // INF = 11

int main()
{
    int a,b; cin >> a >> b;
    char f[100][100];
    rep(i,100){
        rep(j,100){
            if(i < 50) f[i][j] = '.';
            else f[i][j] = '#';
        }
    }
    for(int i = 0; i < 50; i += 2){
        for(int j = 0; j < 100; j+=2){
            if(b > 1){
                f[i][j] = '#';
                b--;
            }
        }
    }
    for(int i = 51; i < 100; i += 2){
        for(int j = 0; j < 100; j+=2){
            if(a  > 1){
                f[i][j] = '.';
                a--;
            }
        }
    }
    cout << 100 << ' ' << 100 << endl;
    rep(i,100){
        rep(j,100) cout << f[i][j];
        cout << endl;
    }
}

Measured memory_bytes: 3620
N,A,B,C=map(int,input().split(" "))
INF=10**9
tmp=[int(input()) for _ in range(N)]
def calc(num,a,b,c):
    if(num==N):
        if(min(a,b,c)>0):
            return abs(A-a)+abs(B-b)+abs(C-c)-30
        else:
            return INF
    res=calc(num+1,a,b,c)
    res1=calc(num+1,a+tmp[num],b,c)+10
    res2=calc(num+1,a,b+tmp[num],c)+10
    res3=calc(num+1,a,b,c+tmp[num])+10
    return min(res,res1,res2,res3)
print(calc(0,0,0,0))


Measured memory_bytes: 3064
#include <iostream>
#define ll long long
using namespace std;

ll x[100010], v[100010];
ll cw1[100010], cw2[100010], acw1[100010], acw2[100010];

int main() {
	int N;
	ll C;
	cin >> N >> C;
	for(int i=0; i<N; ++i){
		cin >> x[i] >> v[i];
	}
	ll sum=0;
	for(int i=0; i<N; ++i){
		sum += v[i];
		cw1[i+1]=max(cw1[i], sum-x[i]);
		cw2[i+1]=max(cw2[i], sum-x[i]*2);
	}
	sum=0;
	for(int i=N-1; i>=0; --i){
		sum += v[i];
		acw1[i+1]=max(acw1[i+2], sum-(C-x[i]));
		acw2[i+1]=max(acw2[i+2], sum-(C-x[i])*2);
	}
	ll ans=0;
	for(int i=0; i<=N; ++i){
		ans=max(ans, cw2[i]+acw1[i+1]);
		ans=max(ans, cw1[i]+acw2[i+1]);
	}
	cout << ans << endl;
	return 0;
}

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

int main() {
    int n, k;
    string s;
    cin >> n >> k;
    cin >> s;
    vector<int> a;
    if (s[0] == '0') {
        a.push_back(0);  
    }
    int cnt = 0;
    for (int i = 0; i < n; ++i) {
        ++cnt;
        if (i < n - 1 && s[i] != s[i + 1]) {
            a.push_back(cnt);
            cnt = 0;            
        }
    }
    if (cnt) {
        a.push_back(cnt);  
    }
    //cout << "division: " << endl;
    /*for (int i = 0; i < a.size(); ++i) {
        cout << a[i] << ' ';
    }
    cout << endl;*/
    vector<int> suma(a.size() + 1, 0);
    for (int i = 1; i <= a.size(); ++i) {
        suma[i] = suma[i - 1] + a[i - 1];  
    }
      
    int ans = 0;
    for (int i = 0; i < a.size(); i += 2) {
        int r = i + 2 * k;        
        int cursum;
        if (r >= a.size()) {
            r = a.size() - 1;  
        }
        ans = max(ans, suma[r + 1] - suma[i]);
        //cout << "sum of interval [" << i << ", "<< r << "] -> " << suma[r + 1] - suma[i] << endl;
    }
    //cout << "ans = ";
    cout << ans;
    return 0;
}

Measured memory_bytes: 1272
#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <cstring>
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <list>  
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;  

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }

const int MAXN=100000;

int n;
int a[MAXN];

void run() {
	scanf("%d",&n); REP(i,n) scanf("%d",&a[i]);
	ll ret=LLONG_MAX;
	for(int s1=-1;s1<=+1;s1+=2) {
		int s=s1; ll sum=0,cur=0;
		REP(i,n) {
			sum+=a[i];
			if(s>0&&sum<=0) { ll now=-sum+1; sum+=now,cur+=now; }
			if(s<0&&sum>=0) { ll now=sum+1; sum-=now,cur+=now; }
			s=-s;
		}
		//printf("cur=%lld\n",cur);
		if(cur<ret) ret=cur;
	}
	printf("%lld\n",ret);
}

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


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

typedef long long ll;

priority_queue <int, vector<int>, less<int>> a1;
priority_queue <int, vector<int>, greater<int>> a2;

const int maxn = 2*100000 + 1;
int q, n = 0;
ll res = 0;

void solve(int a) {
        a1.push(a), a2.push(a);
        int x = a1.top(), y = a2.top();
        if (x > y) {
                a1.pop(); a2.pop();
                res += x-y;
                a1.push(y), a2.push(x);
        }
}

int main() {
        //freopen("F.INP", "r", stdin);
        //freopen("F.OUT", "w", stdout);
        ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);

        cin >> q;
        for (int i = 0; i < q; i++) {
                int x;
                cin >> x;
                if (x == 1) {
                        int a, b;
                        cin >> a >> b;
                        res += b;
                        solve(a);
                }
                else
                        cout << a1.top() << " " << res << '\n';
        }

        return 0;
}


Measured memory_bytes: 3828
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

func main() {
	buf := make([]byte, 1024*1024)
	sc.Buffer(buf, bufio.MaxScanTokenSize)
	sc.Split(bufio.ScanWords)
	defer out.Flush()

	counter := 0
	n := nextInt()
	L := make([]int, n)
	for i := 0; i < n; i++ {
		L[i] = nextInt()
	}

	for i := 0; i < n; i++ {
		for j := i + 1; j < n; j++ {
			for k := j + 1; k < n; k++ {
				if L[i] != L[j] && L[j] != L[k] && L[i] != L[k] {
					cos := (L[j]*L[j] + L[k]*L[k] - L[i]*L[i]) / (2 * L[k] * L[j])
					if cos == 0 {
						counter++
					}
				}
			}
		}
	}
	fmt.Fprintf(out, "%d\n", counter)
}

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func nextFloat64() float64 {
	a, _ := strconv.ParseFloat(next(), 64)
	return a
}

func reverse(s string) string {
	runes := []rune(s)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}

func quickSort(val []int) []int {
	if len(val) < 2 {
		return val
	}

	pivot := val[0]

	left := []int{}
	right := []int{}

	for _, v := range val[1:] {
		if pivot > v {
			left = append(left, v)
		} else {
			right = append(right, v)
		}
	}

	left = quickSort(left)
	right = quickSort(right)

	ret := append(left, pivot)
	ret = append(ret, right...)

	return ret
}


Measured memory_bytes: 1820
/**
 *
 * Contest - Problem X: Nome (link)
 *
 * Abridge version.
 *
 * Solution: text
 */
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using ii = pair<ll, ll>;

#define REP(i, a, b) for (int (i) = (a); (i) <= (b); (i)++)
#define REPN(i, N) for (int (i) = 0; (i) < N; (i)++)
#define DEC(i, b, a) for (int (i) = (b); (i) >= (a); (i)--)
#define DECN(i, N) for (int (i) = N - 1; (i) >= 0; (i)--)

#define LOG(var, sep) (cerr << #var << " = " << (var) << (sep))
#define LOGM(msg) (cerr << (msg))
#define LOGV(vec, sep) { cerr << #vec << " ="; for (const auto& v : (vec)) cerr << " " << v; cerr << (sep); }
#define LOGA(arr, N, sep) { cerr << #arr << " ="; for (int i = 0; i < N; ++i) cerr << " " << (arr)[i]; cerr << (sep); }
#define LOGA2(arr, N, M, sep) { cerr << #arr << " =\n"; for (int i = 0; i < N; ++i) { for (int j = 0; j < M; ++j) cerr << (arr)[i][j] << " "; cerr << endl; } cerr << (sep); }

ostream& operator<<(ostream& os, const ii& p)
{
    os << "(" << p.first << ", " << p.second << ")";
    return os;
}

const int MAX { 2000010 };
const ll oo { 1LL << 62 };
const int MOD { 1000000007 };

ll xs[MAX];

ll gcd(ll a, ll b)
{
    return b ? gcd(b, a % b) : a;
}

void solve(ll N, ll X)
{
    REPN(i, N)
        xs[i] -= X;

    auto d = 0;

    REPN(i, N)
        d = gcd(xs[i], d);

    cout << llabs(d) << endl;
}

int main()
{
    ios::sync_with_stdio(false);

    ll N, X;
    cin >> N >> X;

    REPN(i, N)
        cin >> xs[i];

    solve(N, X);

    return 0;
}


Measured memory_bytes: 1024