akhauriyash/Code-Regression huggingface dataset:
#ifdef _MSC_VER
#define _CRT_SECURE_NO_WARNINGS
#endif
#include<bits/stdc++.h>
#include<chrono>
#include<unordered_map>
#include<random>
#include<complex> 
using namespace std;
#define ll long long
#define ld long double
#define ull unsigned ll 
#define endl '\n'
#define mk make_pair
void fast_in_out() {
	std::ios_base::sync_with_stdio(NULL);
	cin.tie(NULL); cout.tie(NULL);
}
int dx[] = { 0,0,-1,1,-1,1,-1,1,0 };
int dy[] = { -1,1,0,0,-1,-1,1,1,0 };
int lx[] = { 2, 2, -1, 1, -2, -2, -1, 1 };
int ly[] = { -1, 1, 2, 2, 1, -1, -2, -2 };
const ld eps = 1e-9;
const int N = 1e5 + 50, M = 1e5 + 10, mod = 1e9 + 7;
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll t = gcd(a, b); return t ? (a / t * b) : 0; }
int get(int x) {
	int lst = 0;
	while (x) {
		lst = x % 10;
		x /= 10;
	}
	return lst;
}
int main() {
	fast_in_out();
//	cout << fixed << setprecision(6);
	map<pair<int, int>,int>mp;
	int n; cin >> n;
	for (int i = 1; i <= n; i++) {
		int l = i % 10;
		int r = get(i);
		mp[{r, l}]++;
	}
	ll ans = 0;
	for (int i = 1; i <= 9; i++) {
		for (int j = 1; j <= 9; j++) {
			ll x = mp[{i, j}];
			ll y = mp[{j, i}];
			ans += (x * y);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <string>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <set>

using namespace std;

int main() {
    int N, L;
    string ans;
    cin >> N >> L;
    vector<string> s(N);
    for (int i = 0; i < N; i++) {
        cin >> s.at(i);
    }

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

    for (int i = 0; i < N; i++) {
        ans += s.at(i);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
def main():
    x,y = map(int,input().split())
    ans = 10**10
    if x<=y:
        ans = min(ans,y-x)
    if -x<=y:
        ans = min(ans,1+y-(-x))
    if x<=-y:
        ans = min(ans,-y-x+1)
    if -x<=-y:
        ans = min(ans,-y-(-x)+2)
    print(ans)

if __name__ == '__main__':
    main()



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

typedef struct Node
{
	int key;
	Node *parent, *left, *right;
}Node;

Node *root, *NIL;

void insert(int key)
{
	Node *y = NIL;
	Node *x = root;
	Node *z;
	z = (Node *)malloc(sizeof(Node));
	z->key = key, z->left = NIL, z->right = NIL;

	while (x != NIL)
	{
		y = x;
		if (z->key < x->key)
			x = x->left;
		else
			x = x->right;
	}
	z->parent = y;

	if (y == NIL)
		root = z;
	else if (z->key < y->key)
		y->left = z;
	else
		y->right = z;
}

void inOrder(Node *node)
{
	if (node == NIL) return;
	inOrder(node->left);
	cout << " " << node->key;
	inOrder(node->right);
}

void preOrder(Node *node)
{
	if (node == NIL) return;
	cout << " " << node->key;
	preOrder(node->left);
	preOrder(node->right);
}

Node *find(int key)
{
	Node *x = root;
	while (x != NIL && key != x->key)
	{
		if (key < x->key)
			x = x->left;
		else
			x = x->right;
	}
	return x;
}

Node *getMinimum(Node *x)
{
	while (x->left != NIL)
		x = x->left;
	return x;
}

Node *getSuccessor(Node *x)
{
	if (x->right != NIL)
		return getMinimum(x->right);
	
	Node *y = x->parent;
	while (y != NIL && x == y->right)
	{
		x = y;
		y = y->parent;
	}
	return y;
}

void deleteNode(Node *z)
{
	Node *x, *y;
	if (z->left == NIL || z->right == NIL) y = z;
	else y = getSuccessor(z);

	if (y->left != NIL)
		x = y->left;
	else
		x = y->right;

	if (x != NIL)
		x->parent = y->parent;

	if (y->parent == NIL)
		root = x;
	else
	{
		if (y == y->parent->left)
			y->parent->left = x;
		else
			y->parent->right = x;
	}
	if (y != z)
		z->key = y->key;

	free(y);
}

int main()
{
	int n;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		string order;
		cin >> order;
		if (order == "insert")
		{
			int key;
			cin >> key;
			insert(key);
		}
		else if (order == "print")
		{
			inOrder(root);
			cout << endl;
			preOrder(root);
			cout << endl;
		}
		else if (order == "find")
		{
			int key;
			cin >> key;
			Node *x = find(key);
			if (x == NIL) cout << "no" << endl;
			else cout << "yes" << endl;
		}
		else if (order == "delete")
		{
			int key;
			cin >> key;
			deleteNode(find(key));
		}
	}

	return 0;
}


Measured memory_bytes: 21880
fn read<T: std::str::FromStr>()->T{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();

    s.trim().parse().ok().unwrap()
}


fn main(){

    let (n, y) = {
        let s: String  = read();
        let mut ws = s.split_whitespace();
        let n:i64 = ws.next().unwrap().parse().unwrap();
        let k:i64 = ws.next().unwrap().parse().unwrap();
    
        (n, k)
    };

    let mut find = false;

    for i in 0..n+1{
        for j in 0..n-i+1{
            let k = n - i - j;
            if i*10000 + j*5000 + k*1000 == y {
                find = true;
                println!("{} {} {}", i, j, k);
                break;
            }
        }

        if find == true{
            break;
        }
    }

    if find == false {
        println!("-1 -1 -1");
    }
}




Measured memory_bytes: 4352
package main

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

func main() {
	a := readi()
	b := readi()
	c := readi()
	fmt.Println(c, a, b)
}

// IO---------------------------------------------------

func readi() (n int) {
	fmt.Scan(&n)
	return
}

func readf() (n float64) {
	fmt.Scan(&n)
	return
}

func reads() (n string) {
	fmt.Scan(&n)
	return
}

var rdr = bufio.NewReaderSize(os.Stdin, 1000000)

func readLine() string {
	buf := make([]byte, 0, 1000000)
	for {
		l, p, e := rdr.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func readSlice() []string {
	return strings.Split(readLine(), " ")
}

func atoi(a []string) (b []int) {
	b = make([]int, len(a))
	for i := range a {
		b[i], _ = strconv.Atoi(a[i])
	}
	return
}

func atof(a []string) (b []float64) {
	b = make([]float64, len(a))
	for i := range a {
		b[i], _ = strconv.ParseFloat(a[i], 64)
	}
	return
}

func readSlice2(n int) (a []int, b []int) {
	a = make([]int, n)
	b = make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i], &b[i])
	}
	return
}

func readFloatSlice2(n int) (a []float64, b []float64) {
	a = make([]float64, n)
	b = make([]float64, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i], &b[i])
	}
	return
}

func yesOrNo(b bool) {
	if b {
		fmt.Println("Yes")
		return
	}
	fmt.Println("No")
}

func yesorNO(b bool) {
	if b {
		fmt.Println("YES")
		return
	}
	fmt.Println("NO")
}

func yesorno(b bool) {
	if b {
		fmt.Println("yes")
		return
	}
	fmt.Println("no")
}

// calc---------------------------------------------------

func abs(a int) int {
	if a > 0 {
		return a
	}
	return -a
}

func ave(a []int) (ave int) {
	for i := 0; i < len(a); i++ {
		ave += a[i]
	}
	ave /= len(a)
	return
}

func eq(a []string, b []string) bool {
	for i := 0; i < len(a); i++ {
		if a[i] != b[i] {
			return false
		}
	}
	return true
}

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

func max(a ...int) int {
	max := a[0]
	for i := 1; i < len(a); i++ {
		if max < a[i] {
			max = a[i]
		}
	}
	return max
}

func min(a ...int) int {
	min := a[0]
	for i := 1; i < len(a); i++ {
		if min > a[i] {
			min = a[i]
		}
	}
	return min
}

func mid(a []int) int {
	sort.Ints(a)
	return a[len(a)/2]
}

func sum(a []int) (ans int) {
	for i := range a {
		ans += a[i]
	}
	return
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S,C,K,S2;
  int Q,T,F,r;
  // rはひっくりかえす判定 1なら順番　-1ならさかさま
  r=1;
  cin >> S >> Q;
  T=0;
  F=0;
  C=S2="";
  for (int i=0;i<Q;i++) {
    
	cin >> T;
	if (T==1) {
	 r=r*-1;
	}
	else {
	 cin >> F >> C;
	 if (F*r==1 || F*r==-2) {S2+=C;}
	 else {S+=C;}
	}
	
  }
  
  //reverse(S2.begin(),S2.end());
  //S2+=S;
  
  //if (r==-1) {
   //for (int j=S2.length(); j>0;j--) {
    //K=K+S2.at(j-1);
  // }
   //cout << K << endl;
  //}
  //else {cout << S2 << endl;}
  
  if (r==1) {
    reverse(S2.begin(),S2.end());
	cout << S2 << S << endl;
  }
  else  {
    reverse(S.begin(),S.end());
	cout << S << S2 << endl;
  }
  
  
}


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

#define int long long
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

/* short */
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define F first
#define S second
#define gcd __gcd
#define SIZE(x) ll((x).size())
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define SUM(x) accumulate(ALL(x), 0)

/* REPmacro*/
#define FOR(i, a, b) for (int i = (a); i < (int)(b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define RFOR(i, a, b) for (int i = (a); i >= (int)(b); --i)
#define RREP(i, n) RFOR(i, n, 0)
#define EACH(i, n) for (auto&& i : n)

/* alias */
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using str = string;


/* const */
const int INF = 1001001001;
const int MOD = 1e9 + 7;
const double EPS = 1e-9;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};

/* func */
template <typename T = int> inline T in(){T x; cin >> x; return x;}
template <typename T> inline void print(const T& x){cout << x << "\n";}
inline void printvec(const vi& vec){REP(i, SIZE(vec)) cout << vec.at(i) << ((i == SIZE(vec)) ? "\n" : " ");}
inline int lcm(int a, int b){return a / gcd(a, b) * b;}
bool is_prime(int n){if (n < 2) return false;FOR(i, 2, (int)(sqrt(n) + 1)){if (n % i == 0) return false;}return true;}


signed main(){
  int N = in();
  vi B(N-1); EACH(i, B) i = in();
  
  vi A(N);
  A.at(0) = B.at(0);
    FOR(i, 0, N-1){
      A.at(i) = min(A.at(i), B.at(i));
      A.at(i+1) = B.at(i);
    }
  
  print(SUM(A));
}

Measured memory_bytes: 384
from collections import deque
import numpy as np

H, W = map(int, input().split())
grid = [input() for _ in range(H)]

ini = -1
q = deque()

dy = (-1, 0, 1, 0)
dx = (0, 1, 0, -1)
ans = 0

for y in range(H):
    for x in range(W):
        dist = [[ini for _ in range(W)] for _ in range(H)]
        if grid[y][x] == "#": continue
        dist[y][x] = 0
        q.append((y, x))

        while(len(q) > 0):
            oy, ox = q.popleft()
            for di in range(4):
                ny = oy + dy[di]
                nx = ox + dx[di]

                if (ny < 0 or ny >= H or nx < 0 or nx >= W): continue
                if grid[ny][nx] == "#": continue
                if dist[ny][nx] != ini: continue

                dist[ny][nx] = dist[oy][ox] + 1
                q.append((ny, nx))

        ans = max(np.max(dist), ans)

print(ans)

Measured memory_bytes: 27000
import sys
input = sys.stdin.readline
import numpy as np
def print_ans(N, ar):
    """Test Case
    >>> print_ans(7, ["beat", "vet", "beet", "bed", "vet", "bet", "beet"])
    beet
    vet
    >>> print_ans(8, ["buffalo", "buffalo", "buffalo", "buffalo", "buffalo", "buffalo", "buffalo", "buffalo"])
    buffalo
    >>> print_ans(7, ["bass", "bass", "kick", "kick", "bass", "kick", "kick"])
    kick
    >>> print_ans(4, ["ushi", "tapu", "nichia", "kun"])
    kun
    nichia
    tapu
    ushi
    """
    dict = {}
    for a in ar:
        if a in dict:
            dict[a] = dict[a] + 1
        else:
            dict[a] = 0
    max_val = max(dict.values())
    key_list = sorted([key for key in dict if dict[key] == max_val])
    for key in key_list:
        print(key)


    
    

if __name__ == '__main__':
    N = int(input().rstrip())
    ar = [ input().rstrip() for _ in range(N)]
    print_ans(N, ar)




Measured memory_bytes: 44484
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

int main(){
  int N,X;cin >> N >> X;
  vector<int> L(N);REP(i,N) cin >> L[i];
  int D = 0;
  int count = 0;
  REP(i,N+1){
    if(D <= X){
      count++;
    }else{
      break;
    }
    D += L[i];
  }
  cout << count << '\n';
}


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

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

typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//定数
#define INF 1000000000 //10^9:極めて大きい値,∞
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

string S;

void rev(int l, int r){
    string temp=S;
    int e=r-l;
    for(int i=0;i<=e;i++){
        S[l+i]=(temp[r-i]=='R')? 'L' : 'R';
    }
}

int main(){
    int N,K;
    cin>>N>>K;
    cin>>S;
    int g=1;
    char c=S[0];
    for(int i=1;i<N;i++){
        if(S[i]!=c){
            g++;
            c=S[i];
        }
    }
    rep(i,K){
        g=max(1,g-2);
        if(g==0) break;
    }
    int ans=N-1-(g-1);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3812
#include <bits/stdc++.h>
using namespace std;
#define int long long 
#define Rep(i, N) for(int i = 0; i < N; i++)

inline int llabs(int n) { return n < 0 ? -n : n; }

signed main()
{
  int x, y;
  int ans = 0;

  int ax, ay;

  cin >> x >> y;
  ax = llabs(x), ay = llabs(y);
  
  if(ax < ay) {
    if(x < 0LL) ans++;
    if(y < 0LL) ans++;
    cout << ay - ax + ans << endl;
  } else if(ax == ay) {
    cout << 1LL << endl;
  } else {
    if(x > 0LL) ans++;   
    if(y > 0LL) ans++;
    cout << ax - ay + ans << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#define MOD 1000000007
using namespace std;
long long mod_pow(long long a,long long n,long long mod){
    long long res=1;
    while(n>0){
        if(n&1){
            res=res*a%mod;
        }
        a=a*a%mod;
        n>>=1;
    }
    return res;
}
int main(){
    int n,k;
    cin>>n>>k;
    long long cnt[100001];
    long long sum=0;
    for(int i=k;i>=1;i--){
        int x=k/i;
        cnt[i]=mod_pow(x,n,MOD);
        int j=2;
        while(j*i<=k){
            if(cnt[i]<cnt[j*i]){
                cnt[i]+=MOD;
            }
            cnt[i]-=cnt[j*i];
            j++;
        }
    }
    for(int i=1;i<=k;i++){
        sum+=i*cnt[i]%MOD;
    }
    cout<<sum%MOD<<endl;
    return 0;
}

Measured memory_bytes: 4408
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;

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

	int n, a, b, c, d;
	cin >> n >> a >> b >> c >> d;
	--a; --b; --c; --d;
	string str;
	cin >> str;

	bool fail = (c < a || d < b);
	if (str[a] == '#' || str[b] == '#' || str[c] == '#' || str[d] == '#') fail = true;
	if (a == b || c == d) fail = true;

	for (int i = a; i < c; ++i) {
		if (str[i] == '#' && str[i+1] == '#') fail = true;
	}
	for (int i = b; i < d; ++i) {
		if (str[i] == '#' && str[i+1] == '#') fail = true;
	}
	if (! fail) {
		if (a < b && d < c) {
			bool can_pass = false;
			for (int i = b; i <= d; ++i) {
				if (str[i-1] == '.' && str[i] == '.' && str[i+1] == '.') can_pass = true;
			}
			if (! can_pass) fail = true;
		} else if (b < a && c < d) {
			bool can_pass = false;
			for (int i = a; i <= c; ++i) {
				if (str[i-1] == '.' && str[i] == '.' && str[i+1] == '.') can_pass = true;
			}
			if (! can_pass) fail = true;
		}
	}
	if (fail) cout << "No\n";
	else cout << "Yes\n";
}


Measured memory_bytes: 892
# ABC063 C - Bugged
N = int(input())
A = [int(input()) for _ in range(N)]

L = []
s = sum(A)

for a in A:
    if a%10 != 0:
        L.append(a)
L.sort()

if not L:
    print(0)
else:
    if s%10 == 0:
        for l in L:
            s -= l
            if s%10 != 0:
                print(s)
                exit()
    else:
        print(s)

Measured memory_bytes: 3064
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
def main():
    q = deque()
    s = S()
    for c in s:
        q.append(c)
    Q = I()
    backward = False
    for _ in range(Q):
        query = LS()
        if int(query[0]) == 1:
            backward = not backward
            continue
        _, f, c = query
        f = int(f)
        if backward and f == 1:
            # ushiro ni tsuika
            q.append(c)
        if backward and f == 2:
            # mae ni tsuika
            q.appendleft(c)
        if not backward and f == 1:
            # mae
            q.appendleft(c)
        if not backward and f == 2:
            # ushiro
            q.append(c)
    if not backward:
        ans = ''.join(q)
    else:
        q.reverse()
        ans = ''.join(q)
    print(ans)
main()



Measured memory_bytes: 10680
package main

import "fmt"

func main() {
	var a, b, c, d, e, f int
	fmt.Scan(&a, &b, &c, &d, &e, &f)

	a *= 100
	b *= 100

	max := 0.0
	ansM := a
	ansS := 0
	for i := 0; a*i <= f; i++ {
		for j := 0; a*i+b*j <= f; j++ {
			w := a*i + b*j
			for k := 0; w+c*k <= f; k++ {
				for l := 0; w+c*k+d*l <= f; l++ {
					s := c*k + d*l
					if s > w*e/100 {
						continue
					}
					t := float64(s) / float64(w+s)
					if t > max {
						max = t
						ansM, ansS = w+s, s
					}
				}
			}
		}
	}

	fmt.Println(ansM, ansS)
}


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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

int h, w, a[500][500];
vector<pair<int, int>> v;

int main() {
	cin >> h >> w;
	inc(i, h) {
	inc(j, w) {
		cin >> a[i][j];
	}
	}
	
	inc(i, h) { if(i % 2 != 0) { reverse(a[i], a[i] + w); } }
	
	inc(i, h) {
	inc(j, w) {
		if(i == h - 1 && j == w - 1) { break; }
		if(a[i][j] % 2 != 0) {
			int ii, jj;
			if(j < w - 1) { ii = i; jj = j + 1; } else { ii = i + 1; jj = 0; }
			v.EB(i, j);
			v.EB(ii, jj);
			a[ii][jj]++;
		}
	}
	}
	
	cout << v.size() / 2 << "\n";
	inc(k, v.size()) {
		int i = v[k].FI;
		int j = v[k].SE;
		if(i % 2 != 0) { j = w - 1 - j; }
		i++; j++;
		cout << i << " " << j << (k % 2 == 0 ? " " : "\n");
	}
	
	return 0;
}


Measured memory_bytes: 5104
fn main() {
  let (_n, k) = {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    let mut ws = s.split_whitespace();
    let n: usize = ws.next().unwrap().parse().unwrap();
    let k: usize = ws.next().unwrap().parse().unwrap();
    (n, k)
  };

  let s = {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim_right().to_owned()
  };

  for (i, c) in s.chars().enumerate() {
    if i + 1 == k {
      let d = c as i64 + ('a' as i64 - 'A' as i64);
      print!{"{}", d as u8 as char};
    } else {
      print!{"{}", c};
    }
  }
}


Measured memory_bytes: 4352
def gcd(m,n):
    x= max(m,n)
    y= min(m,n)
    if x%y == 0:
        return y
    else:
        while not x%y==0:
            z=x%y
            x= y
            y=z
        else:
            return z
def lcm(x, y):
    return (x * y) // gcd(x, y)


a,b,c,d = map(int,input().split())
lcm = lcm(c,d)
c_i=a//c
d_i=a//d
cd_i=a//lcm
if not a%c==0:
    c_i+=1
if not a%d==0:
    d_i+=1
if not a%lcm==0:
    cd_i+=1

c_f=b//c
d_f=b//d
cd_f=b//lcm

print(b-a-(c_f+d_f-cd_f-c_i-d_i+cd_i+1)+1)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  long long n;
  cin >> n;
  vector<long long>ruiseki(12);
  ruiseki.at(0)=1;
  for(int i=1;i<12;i++){
    ruiseki.at(i)=pow(26,i);
    ruiseki.at(i)+=ruiseki.at(i-1);
  }
  int keta=0;
  for(int i=0;i<12;i++){
    if(n>=ruiseki.at(i)){
      keta=i+1;
    }
    else{
      break;
    }
  }
  n-=ruiseki.at(keta-1);
  string ans;
  for(int i=0;i<keta;i++){
    ans.push_back('a'+n%26);
    n/=26;
  }
  reverse(ans.begin(),ans.end());
  cout << ans << endl;
}


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

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define dbg(x) cerr << #x << ": " << x << endl;
#define dbg2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define dbg3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define dbgB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

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 (b<a) { a = b; return 1; } return 0; }

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

// ------------------------------------------------------------------------------------------

using pss = pair<string, string>;

int n;
string s;
map<pss, int> mp;
map<pss, int> tmp;

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

   // 左半分{Red→, ←Brue}
   rep (mask, 1<<n) {
      string a, b;
      rep (i, n) {
         if (mask & (1<<i)) {
            a.push_back(s[i]);
         } else {
            b.push_back(s[i]);
         }
      }
      reverse(all(b));
      mp[{a, b}]++;
   }

   ll ans = 0;
   string t = s;
   t = t.substr(n, 2*n);
   rep (mask, 1<<n) {
      string a, b;
      rep (i, n) {
         if (mask & (1<<i)) {
            a.push_back(t[i]);
         } else {
            b.push_back(t[i]);
         }
      }
      reverse(all(a));
      ans += mp[{a, b}];
   }

   cout << ans << endl;

   return 0;
}

Measured memory_bytes: 87040
#include<stdio.h>
int main(void)
{
	int i,x=0;
	char s[5];
	scanf("%s",s);
	for(i=0;i<4;i++){
		if(s[i]=='+'){
			x=x+1;
		}
		else {
			x=x-1;
		}
	}
	printf("%d\n",x);
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h>
#define MAX 2000001
#define VMAX 10000

int main(){
  unsigned short *A, *B;
  int C[VMAX+1];
  int n, i, j;

  scanf("%d", &n);

  A = malloc(sizeof(short)*n+1);
  B = malloc(sizeof(short)*n+1);

  for(i=0;i<=VMAX;i++)C[i]=0;

  for(i=0;i<n;i++){

    scanf("%hu",&A[i+1]);
    C[A[i+1]]++;
  }

  for(i=1;i<=VMAX;i++)C[i]=C[i]+C[i-1];

  for(j=n;j>=1;j--){
    B[C[A[j]]]=A[j];
    C[A[j]]--;
  }
  for(i=1;i<=n;i++){
    if(i>1)printf(" ");
    printf("%d",B[i]);
  }
  printf("\n");
  

  return 0;
}



Measured memory_bytes: 9620
inputstr1 = input().split()
n = inputstr1[0]
k = inputstr1[1]
s = input()
 
N = int(n)
K = int(k)

ret = ""

for i in range(N):
  if i != K-1:
    ret += s[i]
  else:
    ret += s[i].lower()

print(ret)

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

#define ll long long
#define vi vector<int>
  
using namespace std;                           

int n, k, a[1000001];
ll cnt;

int main (){
	cin >> n >> k;
	for(int i = 1; i <= n; i++){
		cin >> a[i];
	}
	sort(a + 1, a + n + 1);
	for(int i = 1; i <= n - k; i++){
		cnt += a[i];
	}
	cout << cnt;
	return 0;
}

Measured memory_bytes: 1024
#pragma GCC optimize("Ofast")
#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()
#define ln '\n'
const long long MOD = 1000000007LL;
//const long long MOD = 998244353LL;
typedef long long ll;
typedef unsigned long long ull; 
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
template<class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true;} return false; }
template<class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true;} return false; }
///////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    ll N,A,B; cin >> N >> A >> B;
    ll k = N/(A+B);
    ll p = N%(A+B);
    ll ans = k*A;
    if (p >= A) ans += A;
    else ans += p;
    cout << ans << ln;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define fi first
#define se second
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define pf push_front
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define SZ(x) (int)(x).size()
#define ft front()
#define bk back()
#define endl '\n'
#define FOR(a, b, c) for (auto(a) = (b); (a) < (c); ++(a))
#define ROF(a, b, c) for (auto(a) = (b); (a) > (c); --(a))
#define F0R(a, b) FOR ((a), 0, (b))
#define R0F(a, b) ROF ((a), (b), -1)
#define CEIL(a, b) ((a) + (b)-1) / (b)
#define SET(a, b) memset((a), (b), sizeof(a))
template <class t>
bool ckmin(t& a, const t& b) {
    return a > b ? a = b, true : false;
}
template <class t>
bool ckmax(t& a, const t& b) {
    return a < b ? a = b, true : false;
}
#ifndef DEBUG
#define DEBUG 0
#endif
#define dout \
    if (DEBUG) std::cerr
#define dvar(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
template <class a, class b>
ostream& operator<<(ostream& o, const pair<a, b>& p);
template <class T>
struct IsC {
    template <class C>
    static char test(typename C::const_iterator*);
    template <class C>
    static int test(...);
    static const bool value = sizeof(test<T>(0)) == sizeof(char);
};
template <>
struct IsC<string> {
    static const bool value = false;
};
template <class C>
typename enable_if<IsC<C>::value, ostream&>::type operator<<(ostream& o,
                                                             const C& c) {
    o << '{';
    for (auto it = c.begin(); it != c.end();)
        o << *it << (++it != c.end() ? ", " : "}");
    return o;
}
template <class a, class b>
ostream& operator<<(ostream& o, const pair<a, b>& p) {
    return o << '(' << p.fi << ", " << p.se << ')';
}

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

    int s, w;
    cin >> s >> w;
    cout << (s > w ? "safe" : "unsafe") << endl;

    return 0;
}


Measured memory_bytes: 3640
using System.Linq;
using System;

class Program
{
    static long MOD = 1000000007;
    static long[] fact;
    
    // x^y (mod m)
    static long ModPow(long x, long y, long m)
    {
        long ans = 1;

        while (y > 0)
        {
            if (y % 2 == 1)
            {
                ans = ans * x % m;
                y--;
            }
            y /= 2;
            x = x * x % m;
        }
        
        return ans;
    }

    // C(n, k) (mod m)
    // mは素数
    static long ModComb(int n, int k, long m)
    {
        if (n < k)
        {
            return 0;
        }
        return fact[n] * ModPow(fact[k], m - 2, m) % m * ModPow(fact[n - k], m - 2, m) % m;
    }

    static void Main()
    {
        // 入力
        var n = int.Parse(Console.ReadLine());
        var a = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();

        // ダブってる数字の外側の個数
        int count;
        {
            int first = 0, second = 0;
            var f = new int[n + 1];

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

            for (int i = 0; i < n + 1; i++)
            {
                if (f[a[i]] >= 0)
                {
                    first = f[a[i]];
                    second = i;
                    break;
                }
                f[a[i]] = i;
            }
            count = n - second + first;
        }

        // 階乗テーブルの生成
        fact = new long[n + 2];
        fact[0] = 1;
        for (int i = 1; i <= n + 1; i++)
        {
            fact[i] = fact[i - 1] * i % MOD;
        }

        for (int i = 1; i <= n + 1; i++)
        {
            double ans = (ModComb(n + 1, i, MOD) - ModComb(count, i - 1, MOD) + MOD) % MOD;
            Console.WriteLine(ans);
        }

        return;
    }
}

Measured memory_bytes: 25436
#include <iostream>

#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))

using namespace std;

int main() {
    int n,m,x,y;
    cin >> n >> m >> x >> y;

    int x_points[n + 1];
    for (int i = 0; i < n; i++) {
        cin >> x_points[i];
    }
    x_points[n] = x;

    int y_points[m + 1];
    for (int i = 0; i < m; i++) {
        cin >> y_points[i];
    }
    y_points[m] = y;

    sort(x_points, x_points + SIZE_OF_ARRAY(x_points));
    sort(y_points, y_points + SIZE_OF_ARRAY(y_points));

    if (y_points[0] - x_points[n] >= 1) cout << "No War" << endl;
    else cout << "War" << endl;
}


Measured memory_bytes: 256
a = []
ans = 'No'
for i in range(3):
    array = list(map(int, input().split()))
    a.append(array)
n = int(input())

for i in range(n): 
    hoge = int(input())
    for j in range(3):
        for k in range(3):
            if a[j][k] == hoge:
                a[j][k] = 0
for i in range(3):
    if a[0][i] == a[1][i] == a[2][i]:
        ans = 'Yes'
    if a[i][0] == a[i][1] == a[i][2]:
        ans = 'Yes'
if a[0][0] == a[1][1] == a[2][2] or a[2][0] == a[1][1] == a[0][2]:
    ans = 'Yes'
print(ans)

Measured memory_bytes: 3064
import sys
N,M=map(int,input().split())
a=list(map(int,input().split()))
dic={0:1}
tmp=0
for i in range(N):
    tmp=(tmp+a[i])%M
    if tmp in dic: dic[tmp]+=1
    else:dic.setdefault(tmp,1)
ans=0
for i in dic: ans+=dic[i]*(dic[i]-1)//2
print(ans)

Measured memory_bytes: 14696
#include <bits/stdc++.h>
using namespace std;
const string YES = "YES";
const string NO = "NO";

int main()
{
  vector<string> words = {"dream", "dreamer", "erase", "eraser"};
  string S;
  cin >> S;

  while(!S.empty()) {
    bool flg = false;
    for (int i=0; i<4; i++) {
      int l = words[i].length();
      if ((int)S.length()>=l && S.substr(S.length()-l, l) == words[i]) {
        S = S.substr(0, S.length()-l);
        flg = true;
      }
    }
    if (!flg) {
      cout << NO << endl;
      return 0;
    }
  }
  cout << YES << endl;

  return 0;
}


Measured memory_bytes: 512
let m_1e9 = int_of_float 1e9 + 7
let ( +^ ) x y = (x + y) mod m_1e9
let ( -^ ) x y = x - y + if x < y then m_1e9 else 0
let ( *^ ) x y = ((x mod m_1e9) * (y mod m_1e9)) mod m_1e9

let split_string ?(pattern="") = Str.split @@ Str.regexp pattern

let (n, k) = Scanf.sscanf (read_line ()) "%d %d" @@ fun n k -> (n, k)
let a = read_line () |> split_string ~pattern:" " |> List.map int_of_string |> Array.of_list

let l = if k mod 2 = 0 then (k / 2) *^ (k - 1) else k *^ ((k - 1) / 2)

let b = Array.fold_left (+) 0 @@ Array.init n (fun i -> 
  let cnt = ref 0 in
  for j = i + 1 to n - 1 do
    if a.(i) > a.(j) then cnt := !cnt + 1
  done;
  !cnt
)

let c = Array.fold_left (+) 0 @@ Array.init n (fun i ->
  let cnt = ref 0 in
  for j = 0 to n - 1 do
    if a.(i) > a.(j) then cnt := !cnt + 1
  done;
  !cnt
)

let () = Printf.printf "%d\n" @@ b *^ k +^ c *^ l

Measured memory_bytes: 896
#include <stdio.h>
#include <math.h>
main(){
  int i;
  double a[4];
  for(i=0;i<4;i++)
    scanf("%lf",&a[i]);
  printf("%f\n",sqrt(pow(a[2]-a[0],2)+pow(a[3]-a[1],2)));
  return 0;
}

Measured memory_bytes: 652
import java.io.UnsupportedEncodingException;
import java.util.*;

public class Main{
    public static void main(String[] args) throws UnsupportedEncodingException{
        Scanner scan = new java.util.Scanner(System.in);
        byte n = scan.nextByte();
        String s = scan.next();
        byte[] a = new byte[s.length()];
        for(int i = 0; i < s.length(); i++){
            a[i] = (byte) (s.codePointAt(i) - 65);
            a[i] = (byte) ((a[i] + n) % 26 + 65);
        }
        System.out.println(new String(a, "UTF-8"));
    }
}

Measured memory_bytes: 24020
N = int(input())
es = [[] for idx in range(N)]
# es[idx]:=[隣接リスト]

for _ in range(N - 1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    es[a].append(b)
    es[b].append(a)

h = [len(es[i]) for i in range(N)]
# 次数

c = list(map(int, input().split()))
c.sort()
# スコアが小さい順にソート

v = [-1] * N
cur = 0
ans = 0
for _ in range(N - 1):
    for target in range(N):
        # print(target, h, v, ans)
        if h[target] == 1:
            h[target] = 0
            v[target] = c[cur]
            ans += c[cur]
            cur += 1
            for nv in es[target]:
                h[nv] -= 1
            break
for target in range(N):
    if v[target] == -1:
        v[target] = c[cur]
print(ans)
print(*v, sep='\n')


Measured memory_bytes: 51672
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int colorCount = 0;
        int otherCount = 0;
        int gray   = 0;
        int brown  = 0;
        int green  = 0;
        int water  = 0;
        int blue   = 0;
        int yellow = 0;
        int orange = 0;
        int red    = 0;
        for(int i = 0; i < n; i++) {
            int num = sc.nextInt();
            if(num < 400) {
                if (gray == 0) colorCount++;
                gray = 1;
            } else if (400 <= num && num < 800) {
                if (brown == 0) colorCount++;
                brown = 1;
            } else if (800 <= num && num < 1200) {
                if (green == 0) colorCount++;
                green = 1;
            } else if (1200 <= num && num < 1600) {
                if (water == 0) colorCount++;
                water = 1;
            } else if (1600 <= num && num < 2000) {
                if (blue == 0) colorCount++;
                blue = 1;
            } else if (2000 <= num && num < 2400) {
                if (yellow == 0) colorCount++;
                yellow = 1;
            } else if (2400 <= num && num < 2800) {
                if (orange == 0) colorCount++;
                orange = 1;
            } else if (2800 <= num && num < 3200) {
                if (red == 0) colorCount++;
                red = 1;
            } else {
                otherCount++;
            }
        }
        int max = colorCount + otherCount, min = colorCount;
        if (min == 0) min++;
        System.out.println(min + " " + max);
    }
}

Measured memory_bytes: 21972
#include <bits/stdc++.h>
#define ll long long
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;

//定数
//円周率
const double pi = 3.141592653589793238462643383279;
//天井
const int INF = 1000000000; // = 10^9
const ll LINF = 100000000000000000; // = 10^17
//ABC文字列
const string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZABC";
const string abc = "abcdefghijklmnopqrstuvwxyzabc";
//よくあるmodくん
const ll MOD = 1000000007; // = 10^9 + 7
//前処理テーブルの大きさ指定
const int MAX = 1200000; // = 10^6 + 2*(10^5)
//ちなみに、1024MBで持てる最大長の配列は10^8程度

//データ構造
//隣接リスト用構造体（有向グラフ向け）
struct edge {
  ll to; // E.toでその辺の終点へアクセスできる。
  ll cost; // e.costでその辺の重みにアクセスできる。
};
//Union_Find木
struct UnionFind {
  vector<int> UF; // UF.at(i) : iの親の番号
  vector<int> SIZE; // SIZE.at(root(i)) : iと連結されてる要素の数
  UnionFind(int N) : UF(N), SIZE(N, 1) { // 最初は全てが根であるとして初期化
    for(int i = 0; i < N; i++) {
      UF.at(i) = i;
    }
  }
  int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
    if (UF.at(x) == x) {
      return x;
    }
    return UF.at(x) = root(UF.at(x));
  }
  void unite(int x, int y) { // xとyの木を併合
    int rx = root(x); // xの根をrx
    int ry = root(y); // yの根をry
    if (rx == ry) {
      return; // xとyの根が同じ(=同じ木にある)時はそのまま
    }
    // xとyの根が同じでない(=同じ木にない)時：小さい方の根を大きい方の根につける。
    if (SIZE.at(rx) < SIZE.at(ry)) {
      UF.at(rx) = ry;
      SIZE.at(ry) += SIZE.at(rx);
      SIZE.at(rx) = 0;
    }
    else {
      UF.at(ry) = rx;
      SIZE.at(rx) += SIZE.at(ry);
      SIZE.at(ry) = 0;
    }
  }
  bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す。
    int rx = root(x);
    int ry = root(y);
    return rx == ry;
  }
  int size(int x) { // xと連結されてる要素の数を返す。
    return SIZE.at(root(x));
  }
};

//関数 (計算量)
//ctoi (O(1))
int ctoi(char c){
  if (c == '0') return 0;
  if (c == '1') return 1;
  if (c == '2') return 2;
  if (c == '3') return 3;
  if (c == '4') return 4;
  if (c == '5') return 5; 
  if (c == '6') return 6;
  if (c == '7') return 7;
  if (c == '8') return 8;
  if (c == '9') return 9;
  return -1;  
}
//to_char (O(1))
char to_char(int i){
  if (i == 0) return '0';
  if (i == 1) return '1';
  if (i == 2) return '2';
  if (i == 3) return '3';
  if (i == 4) return '4';
  if (i == 5) return '5';
  if (i == 6) return '6';
  if (i == 7) return '7';
  if (i == 8) return '8'; 
  if (i == 9) return '9';
  return ' ';  
}

// A^N mod M を計算する。modしたくなかったらM = LINFとかにすればよい。(O(√N))
ll modpow(ll A, ll N, ll M) {
  ll ans = 1;
  while (N > 0) {
    if (N & 1) ans = ans * A % M;
      A = A * A % M;
      N >>= 1;
   }
  return ans;
}

//メイン処理
int main() {
  cout << fixed << setprecision(16); //精度向上
  //ここまでテンプレ
  int ans;
  int N, K;
  cin >> N >> K;
  cin >> ans;
  int B = ans;
  for (int i = 1; i < N; i++) {
    int M;
    cin >> M;
    ans = gcd(ans, M);
    B = max(B, M);
  }
  int memo = gcd(ans, K);
  if (ans == memo && K <= B) {
    cout << "POSSIBLE" << endl;
  }
  else {
    cout << "IMPOSSIBLE" << endl;
  }
}

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

using namespace std;

int main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    long long n,m;
    cin>>n>>m;
    if(n%m==0)
    {
        cout<<0<<endl;
    }
    else
        cout<<min(abs((n%m)-m),n%m)<<endl;
    return 0;
}


Measured memory_bytes: 256
/****************************************
	Sahil Gangurde
	Learning through WA, TLE, SIGESV
****************************************/
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <fstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <utility>
#include <climits>
#include <numeric>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <cassert>
using namespace std;
typedef long long ll;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ll n;
	cin>>n;
	n%=10;
	if(n==2 || n==4 || n==5 || n==7 || n==9) {
		cout<<"hon\n";
	}
	else if(n==0 || n==1 || n==6 || n==8 ) {
		cout<<"pon\n";
	}
	else {
		cout<<"bon\n";
	}
	return 0;
}


Measured memory_bytes: 3588
#include <bits/stdc++.h>
#define INF INT_MAX/1000
using namespace std;

int w, h;
int g[50][50];
bool used[50][50][2];

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

bool infield(int x, int y){
    return 0 <= x && x < w && 0 <= y && y < h;
}

int dfs(int x, int y, int color){
    if(g[y][x] == color) return 0;
    if(g[y][x] != 0){
        return -INF;
    }
    used[y][x][color-1] = true;

    int res = 0;
    for(int d = 0; d < 4; d++){
        int nx = x + dx[d], ny = y + dy[d];
        if(!infield(nx, ny) || used[ny][nx][color-1]) continue;
        res += dfs(nx, ny, color);
    }

    return res+1;
}

int main(void){
    while(cin >> w >> h, w || h){
        bool pole_exist = false;
        for(int i = 0; i < h; i++){
            for(int j = 0; j < w; j++){
                char c; cin >> c;
                used[i][j][0] = used[i][j][1] = false;
                if(c == 'W' || c == 'B') pole_exist = true;
                if(c == 'W') g[i][j] = 1;
                else if(c == 'B') g[i][j] = 2;
                else g[i][j] = 0;
            }
        }

        if(pole_exist == false){
            cout << 0 << " " << 0 << endl;
            continue;
        }
        int white = 0, black = 0;
        for(int i = 0; i < h; i++){
            for(int j = 0; j < w; j++){
                if(used[i][j][0] == false)
                    white += max(dfs(j, i, 1), 0);
                if(used[i][j][1] == false)
                    black += max(dfs(j, i, 2), 0);
            }
        }

        cout << black << " " << white << endl;
    }

    return 0;
}

Measured memory_bytes: 1244
#include <bits/stdc++.h>
#define N 15
using namespace std;
typedef pair<int,int> P;
int n,G[N][N];
int Min(int &a,int b){return a=min(a,b);}

int mem[N][1<<N],used[N][1<<N];
int dfs(int pos,int bit,int start){
  if(bit == (1<<n)-1) return 0;
  if(bit!=0 && pos == start) return 1e9;
  if(used[pos][bit]++) return mem[pos][bit];
  int res = 1e9;
  for(int i=0;i<n;i++){
    if(bit>>i&1)continue;
    int nbit = bit | 1<<i;
    Min(res,G[pos][i]+dfs(i,nbit,start));
  }
  return mem[pos][bit] = res;
}

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

  for(int i=0;i<N;i++)
    for(int j=0;j<N;j++)G[i][j] = 1e9;
  
  for(int i=0,a,b,d;i<m;i++){
    cin>>a>>b>>d;
    Min(G[a][b],d);
  }

  int ans = 1e9;
  for(int i=0;i<n;i++){
    memset(used,0,sizeof(used));
    Min(ans,dfs(i,0,i));
  }
  if(ans == 1e9)cout<<-1<<endl;
  else cout<<ans<<endl;
  
  return 0;
}

Measured memory_bytes: 6672
#include<iostream>
#include<vector>
#include<queue>
#define f first
#define s second
using namespace std;

int h,w,p[8][8],rast,ans,map[8][8];
int x[4]={1,-1,0,0};
int y[4]={0,0,1,-1};
bool color[6];
vector<pair<int,pair<int,int> >  > V;

bool in(int i,int j)
{
  if(i<0 || j<0 || i>=h || j>=w)return false;
  return true;
}

void Erase(int n)
{
  for(int i=n;i<V.size();i++){
    map[V[i].s.f][V[i].s.s]=0;
    V.erase(V.begin()+i);
    i--;
  }
}

int count()
{
  int a=0;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(map[i][j]!=0)a++;
    }
  }
  return a;
}

void Connect(int n,int num)
{
  int s=V.size();
  queue<pair<int,int> > Q;
  for(int i=0;i<V.size();i++){
    Q.push(make_pair(V[i].s.f,V[i].s.s));
    while(!Q.empty()){
      pair<int,int> u=Q.front();Q.pop();
      for(int k=0;k<4;k++){
	int a=u.f+x[k],b=u.s+y[k];
	if(in(a,b)){
	  if(map[a][b]==0 && p[a][b]==n){
	    map[a][b]=1;
	    if(num==0)map[a][b]=2;
	    Q.push(make_pair(a,b));
	    V.push_back(make_pair(n,make_pair(a,b)));
	  }
	}
      }
    }
  }
  if(num==5 && n==rast){
    ans=max(ans,count());
    Erase(s);
    return;
  }
  if(num==5){
    Erase(s);
    return;
  }
  for(int i=0;i<6;i++)Connect(i,num+1);
  Erase(s);
}
int main()
{
  while(1){
    cin>>h>>w>>rast;
    if(h+w+rast==0)break;
    rast--;
    V.clear();
    for(int i=0;i<6;i++)color[i]=false;
    for(int i=0;i<8;i++){
      for(int j=0;j<8;j++)map[i][j]=0;
    }
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
	cin>>p[i][j];
	p[i][j]--;
      }
    }
    ans=0;
    map[0][0]=2;
    V.push_back(make_pair(p[0][0],make_pair(0,0)));
    Connect(p[0][0],0);
    cout<<ans<<endl;
  }
  return 0;
}

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

int main(){
  string s;
  cin >> s;
  
  string ans;
  for(int i = 0; i < s.size(); i++){
    if(i % 2 == 0){
      ans.push_back(s.at(i));
    }
  }
  cout << ans << endl;
} 


Measured memory_bytes: 512
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner input = new Scanner(System.in);
		int time = input.nextInt();
		int h = time / 3600;
		int m = (time - (h*3600)) / 60;
		int s = time -(h*3600) - m*60;
		System.out.println(h +":" + m + ":" +s);
		
		
	}
}

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

unsigned long debt(int n) {
	unsigned long tmp;
	if(n == 0) return 100000;
	
	tmp = debt(n - 1) * 1.05;
	if(tmp % 1000 != 0)
		tmp = (tmp / 1000 + 1) * 1000;
	return tmp;
}

int main(void)
{
	int n;
	cin >> n;
	cout << debt(n) << endl;
	return 0;
}

Measured memory_bytes: 1156
//
//  main.cpp
//
 
#include <algorithm>
#include <array>
#include <assert.h>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
 
using namespace std;
 
using ll = long long;
using ull = unsigned long long;
 
template<typename T>
vector<T> make_vec_nd(T init, size_t size) {
	return vector<T>(size, init);
}
template<typename T, typename... Args>
auto make_vec_nd(T init, size_t size, Args... rest) {
	auto inner = make_vec_nd(init, rest...);
	return vector<decltype(inner)>(size, inner);
}

#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,a,b) for(ll i=a-1;i>=b;i--)

int main() {
	ll M;
	cin >> M;
	ll sum = 0;
	ll digits = 0;
	rep(i,0,M) {
		ll d, c;
		cin >> d >> c;
		sum += d * c;
		digits += c;
	}
	cout << (digits - 1) + (sum / 9 - (sum % 9 == 0)) << endl;
}


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

using namespace std;
typedef long long ll;
typedef unsigned long long ull;

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

    ll N,K;
    cin >> N >> K;
    vector<int> x;

    /*ll x[1000000];
    for (ll i = 0; i < N; i++) {
        cin >> x[i];
    }*/
    int num;
    for(int i = 0;i < N;i++){
        cin >> num;
        x.push_back(num);
    }

    if (N == 1) {
        cout << x[0] << endl;
        exit(0);
    }

    ll ans = 9999999999999;
    for (ll i = 0; i < N-K+1; i++) {
        ll left = abs(x[i]) + abs(x[i+K-1] - x[i]);
        ll right = abs(x[i+K-1]) + abs(x[i] - x[i+K-1]);

        ans = min(ans, left);
        ans = min(ans, right);
    }
    cout << ans << endl;

}

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

int		main(void)
{
	int h, w;
	
	cin >> h >> w;
	vector<string> P(h);
	for (int i = 0; i < h; i++)
		cin >> P[i];
	for (int i = 0; i < h; i++)
		cout << P[i] << endl << P[i] << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pb push_back
#define ff first
#define ss second
#define mod 1000000007
 
int32_t main() 
{
    IO;
    int n;
    cin>>n;
    int k;
    cin>>k;
    int a[n];
    for(int i=0;i<n;i++)
    cin>>a[i];
    vector<int> dp(n,INT_MAX);
    dp[0] = 0;
    // dp[1] = abs(a[1] - a[0]);
    for(int i=1;i<n;i++)
    {
        for(int j=1;j<=k;j++)
        {
            if(i - j >= 0)
            {
                dp[i] = min(dp[i-j] + abs(a[i] - a[i-j]),dp[i]);
            }
        }
    }
    cout<<dp[n-1];
	return 0;
}


Measured memory_bytes: 1792