akhauriyash/Code-Regression huggingface dataset:
#define rep(i, n) for(ll i = 0; i < n; i++)
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using P = pair<int, int>;

string narabi(string str) {
	int len = str.length();
	for (int i=0;i<len;i++) {
		for(int j=i;j<len;j++) {
			if (str[i] > str[j]) {
				char a = str[i];
				str[i] = str[j];
				str[j] = a;
			}
		}
	}
	return str;
}

int main() {
	ll n;
	cin >> n;
	vector<string> str_list;
	rep(i,n) {
		string str;
		cin >> str;
		str_list.push_back(narabi(str));
	}
	sort(str_list.begin(), str_list.end());
	str_list.push_back("----------");
	//rep(i,n+1) cout << str_list[i] << endl;

	ll ans = 0;
	string now_str = str_list[0];
	ll cnt = 1;
	for(int i=1;i<n+1;i++) {
		if (str_list[i] == now_str) cnt++;
		else {
			now_str = str_list[i];
			ans += cnt*(cnt-1)/2;
			cnt = 1;
		}
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 5748
#include <iostream>
#include <algorithm>
#include <cstring>
#include<cstdio>
using namespace std;

int ans = -1000000000;
int a[10];
int n, f[100][10], p[100][11];
int max(int ans, int score)
{
	if (ans > score)
		return ans;
	else
		return score;
}
void func(void){
	int score = 0, cnt;
	for (int i = 0; i < n; i++){
		cnt = 0;
		for (int j = 0; j < 10; j++){
			if (a[j] == 1 && f[i][j] == 1)
				cnt++;
		}
			score += p[i][cnt];
	}
	ans = max(ans, score);
}
void dfs(int pos)
{
	int  flag = 0;
	if (pos == 10){
		//int flag = 0;
		for (int i = 0; i < 10; i++){
			if (a[i] == 1)
				flag = 1;
		}
		if (flag)
		func();
		return;
	}
		a[pos] = 0; dfs(pos + 1);
		a[pos] = 1; dfs(pos + 1);

}

int main()
{
	cin >> n;

	for (int i = 0; i < n; i++){
		for (int j = 0; j < 10; j++)
			scanf("%d", &f[i][j]);
	}

	for (int i = 0; i < n; i++)
		for (int j = 0; j < 11;j++)
		scanf("%d", &p[i][j]);

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

Measured memory_bytes: 256
N = int(input())

ans = ''

def divide(n):
	if n % (-2) != 0:
		p = (n//(-2))+1
		q = n - p * (-2)
	else:
		p = n//(-2)
		q = n - p * (-2)
	return p,q

while True:
	p,q = divide(N)
	if p == 0:
		ans = str(p) + ans
		break
	N = p
	ans = str(q) + ans
	if p == 1:
		ans = str(p) + ans
		break
print(ans)

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

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
mod2 = 998244353
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
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 pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


def main():
    h,w = LI()
    aa = [[0 if c == '.' else 1 for c in S()] for _ in range(h)]

    dp = [[[inf]*2 for _ in range(w)] for __ in range(h)]
    dp[0][0][aa[0][0]] = aa[0][0]
    for i in range(h):
        for j in range(w):
            k = aa[i][j]
            if i > 0:
                dp[i][j][k] = min(dp[i][j][k], dp[i-1][j][k])
                dp[i][j][k] = min(dp[i][j][k], dp[i-1][j][1-k]+1)
            if j > 0:
                dp[i][j][k] = min(dp[i][j][k], dp[i][j-1][k])
                dp[i][j][k] = min(dp[i][j][k], dp[i][j-1][1-k]+1)

    return min(dp[-1][-1][0] + 1, dp[-1][-1][1] + 2) // 2


print(main())





Measured memory_bytes: 6556
#include<iostream>
#include<string>
using namespace std;
int main(){
	int n,h,w,x[1000],y[1000],s,t;
	while(true){
		cin>>n;
		if(n==0)
			break;
		cin>>w>>h;
		for(int i=0;i<n;i++)
			cin>>x[i]>>y[i];
		cin>>s>>t;
		int best=0;
		for(int i=0;i<=h-t;i++){
			for(int j=0;j<=w-s;j++){
				int count=0;
				for(int k=0;k<n;k++){
					if(j+1<=x[k]&&j+s>=x[k]&&i+1<=y[k]&&i+t>=y[k])
						count++;
				}
				if(count>best)
					best=count;
			}
		}
		cout<<best<<endl;
	}
	return 0;
}

Measured memory_bytes: 1164
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> as(n);
    unordered_map<int, int> mp;
    for (int i = 0; i < n; ++i) {
        cin >> as[i];
        ++mp[as[i]];
    }
    long long mx = 0;
    for (auto p : mp) {
        mx += (long long)p.second * (long long)(p.second - 1) / 2;
    }
    for (int i = 0; i < n; ++i) {
        int a = as[i];
        long long c = mp[a];
        cout << mx - c * (c - 1) / 2 + (c - 1) * (c - 2) / 2 << endl;
    }
    return 0;
}


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

int main(){
  int n, k, q;
  cin >> n >> k >> q;
  vector<int> data(n, k - q);
  for(int i = 0; i < q; i++){
    int x;
    cin >> x;
    data.at(x - 1) += 1;
  }
  for(auto x : data){
    if(x <= 0){
      cout << "No" << endl;
    }
    else{
      cout << "Yes" << endl;
    }
  }
}


Measured memory_bytes: 1024
#include <iostream>
#include <stdio.h>

using namespace std;

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

  int h[n], sum = 0;
  for(int i = 0; i < n; i++){
    cin >> h[i];

    if(h[i] < k)  continue;
    sum++;
  }

  cout << sum << endl;

  return 0;
}

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

int main(void) {
  int n, k, i, j, ichk, cnt = 0;
  scanf( "%d %d", &n, &k );
  int d[k], a[n]; 
  for(i = 0;i < n;i++) { a[i] = 0; }
  for(i = 0;i < k;i++) {
    scanf( "%d", &d[i] );  
    for(j = 0;j < d[i];j++) {
      scanf( "%d", &ichk );
      a[ichk - 1] = 1;
    }    
  }  

  for(i = 0;i < n;i++) { if( a[i] == 0 ) { cnt++; } }
  printf( "%d\n", cnt );
  
  return 0; 
}  

Measured memory_bytes: 1728
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>

#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 1000000000
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
typedef long long int ll;

#define ARRAY_MAX 101
#define MOD 1000000007

ll frac(ll n){

    ll tmp = 1;
    for(ll i = n;i > 0;i--){
        tmp = (tmp*i)%MOD;
    }
    return tmp;
}

int main(){

    ll n,m;
    ll ans = 0;
    cin >> n >> m;
    if(abs(n-m)>1){
        ans = 0;
    }else{

        ll dog = frac(n);
        ll monkey = frac(m);
        ans = (dog*monkey)%MOD;
        if(n == m){
            ans = (ans*2)%MOD;
        }
    }
    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define max(a,b) ((a)>(b)?(a):(b))

int main()
{
    int i;
    int a = 0;
    char temp[5];
    scanf("%s", temp);
    for(i=0;i<4;i++){
        if(temp[i]=='+') a++;
        else if(temp[i]=='-') a--;
    }
    
    printf("%d", a);

    return 0;
}

Measured memory_bytes: 128
import java.util.*;
public class Main {
    public static Scanner sc = new Scanner(System.in);
    public static void main(String[] agrs){
        int a, b;
        int ans;
        while(sc.hasNext()){
            ans = 0;
            a = sc.nextInt();
            b = sc.nextInt();
            ans = a + (b)/2;
            System.out.println(ans);
        }
    }
}


Measured memory_bytes: 21844
package main
import(
  "fmt"
  "bufio"
  "os"
  "strconv"
)
var sc=bufio.NewScanner(os.Stdin)
var wtr=bufio.NewWriter(os.Stdout)
func nextInt() int{
  sc.Scan()
  i, e :=strconv.Atoi(sc.Text())
  if e!=nil{
    panic(e)
  }
  return i
}
func main(){
  var i, n, q, temp, b, c int
  var ans int64
  sc.Split(bufio.ScanWords)
  n=nextInt()
  a:=make([]int, 100001)
  for i=0;i<n;i++{
    temp=nextInt()
    a[temp]++
    ans+=int64(temp)
  }
  q=nextInt()
  for i=0;i<q;i++{
    b=nextInt()
    c=nextInt()
  	ans+=int64(a[b]*(c-b))
    a[c]+=a[b]
    a[b]=0
    fmt.Fprintln(wtr,ans)
    _ = wtr.Flush()
  }
}


Measured memory_bytes: 5692
using System;
using System.Collections.Generic;
using System.Linq;

namespace C_ABC129
{
    class MainClass
    {

        static int[] s;
        static long[] dp;
        static long MOD;

        public static void Main(string[] args)
        {
            s = Array.ConvertAll(Console.ReadLine().Split().ToArray(), int.Parse);
            dp = new long[s[0] + 1];
            for (int i = 0; i <= s[0]; i++)
            {
                dp[i] = -1;
            }
            var alst = new List<int>();
            for (int i = 0; i < s[1]; i++)
            {
                int a = int.Parse(Console.ReadLine());
                alst.Add(a);
                dp[a] = 0;
            }

            MOD = 1000000007;

            dp[0] = 1;
            if (dp[1] != 0)
            {
                dp[1] = 1;
            }

            Console.WriteLine(Dp(s[0]));

        }

        public static long Dp(int n)
        {

            if (dp[n] != -1)
            {
                // Console.Write("DP: {0} ", n);
                //   Console.WriteLine("ans: {0} ", dp[n]);
                return dp[n];
            }
            else
            {
                long ans = Dp(n - 1) + Dp(n - 2);
                dp[n] = ans % MOD;
                //           Console.Write("DP: {0} ", n);
                // Console.WriteLine("ans: {0} ", dp[n]);
                return dp[n];
            }
        }
    }
}


Measured memory_bytes: 16992
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <limits>
using namespace std;

double inf = numeric_limits<double>::infinity();

int main() {
    int x;
    cin >> x;
    
    int s = 0;
    int i = 0;
    while (s < x) {
        s += ++i;
    }
    cout << i << endl;
}

Measured memory_bytes: 256
<?php
$input = explode(' ', fgets(STDIN));
$a = trim($input[0]);
$b = trim($input[1]);
$c = trim($input[2]);

if($a > $b)
{
	$t = $a;
	$a = $b;
	$b = $t;
}
if($b > $c)
{
	$t = $b;
	$b = $c;
	$c = $t;
}
if($a > $b)
{
	$t = $a;
	$a = $b;
	$b = $t;
}
print($a.' '.$b.' '.$c."\n");	

Measured memory_bytes: 6552
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef double ld;
typedef pair<ll,ll> pp;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> super_set;

#define x1 dfds
#define y1 dsfdsfe
#define pb push_back
#define forn(i,n) for(ll i = 1;i<=n;++i)
#define fi first
#define sc second
#define endl '\n'
#define po(x) (1ll<<x)
const ll DIM = 2*10E3+7;
const ll INF = 10E17;

int main()
{

    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    ll a,b;
    cin>>a>>b;
    if (a<=b)cout<<"unsafe\n";
    else cout<<"safe\n";
    return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e6;
int a[MAXN];
int main() {
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d", &a[i]);
	}
	int ans = 0;
	int i = 0;
	while (i < n) {
		while (i + 1 < n && a[i] == a[i + 1]) {
			i++;
		}
		if (i + 1 < n) {
			if (a[i] > a[i + 1]) {
				while (i + 1 < n && a[i] >= a[i+ 1]) {
					i++;
				}
			} else {
				while (i + 1 < n && a[i] <= a[i + 1]) {
					i++;
				}
			}
		}
		ans++;
		i++;

	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 640
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	A
# CreatedDate:  2020-09-27 00:18:14 +0900
# LastModified: 2020-09-27 00:27:44 +0900
#


import os
import sys
# import numpy as np
# import pandas as pd


def main():
    A, B, C = map(int, input().split())
    abc = {
            "AB": [A*B, C],
            "AC": [A*C, B],
            "BC": [B*C, A]
          }
    max_value = 1e18
    for key, value in abc.items():
        if value[0] < max_value:
            important_key = key
            max_value = value[0]
    if abc[important_key][1] % 2 == 0:
        print(0)
    else:
        print(abc[important_key][0])


if __name__ == "__main__":
    main()


Measured memory_bytes: 9136
import java.util.Scanner;

/**
 * https://beta.atcoder.jp/contests/abc073/tasks/abc073_b
 */
public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		final int N = sc.nextInt();
		int ans = 0;
		for(int i=0; i<N; i++){
			ans += -(sc.nextInt()-sc.nextInt())+1;
		}
		sc.close();
		
		System.out.println(ans);

	}

}

Measured memory_bytes: 27880
#include <stdio.h>
int main (void){
    int n,debt=100000,i;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        debt*=1.05;
        if(debt%1000!=0){
            debt=((debt/1000)+1)*1000;
        }
    }
    printf("%d\n",debt);
    return 0;
}

Measured memory_bytes: 592
#include<bits/stdc++.h>
#define loop(i, a, b) for(int i = a; i < b; i++) 
#define rep(i, a) loop(i, 0, a)
using namespace std;
const int MOD = 1000000007;
const int inf = 1e8;
using vi = vector <int>;
using vvi = vector <vi>;
using vc = vector <char>;
using vvc = vector <vc>;
using vs = vector <string>;
using vvs = vector <vs>;
//g++ -std==c++14
//setprecision(10)
long long n, k;
vector <long long> a, b;
vector <pair <long long, long long> > c; 

int main(){
    cin >> n >> k;
    a = b = vector <long long> (n);
    rep(i, n){
        cin >> a[i] >> b[i];
    }
    rep(i, n){
        c.push_back(make_pair(a[i], b[i]));
    }
    sort(c.begin(), c.end());
    long long va = c[0].second;
    if(k <= va){
        cout << c[0].first << endl;
        return 0;
    }
    loop(i, 1, n){
        if(va < k && k <= va + c[i].second){
            cout << c[i].first << endl;
            return 0;
        }
        va += c[i].second;
    }
}

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

int main(void) {
	string N;
	cin >> N;

	if ((N[0] == N[1] && N[1] == N[2])
			|| (N[1] == N[2] && N[2] == N[3]))
		cout << "Yes\n";
	else
		cout << "No\n";

	return 0;
}


Measured memory_bytes: 256
s = input()
k = int(input())
p = s[0]
loop = 0
tmp = 1
first_tmp = 0
for c in s[1:]:
    if c == p:
        tmp += 1
    else:
        loop += tmp // 2
        if first_tmp == 0:
            first_tmp = tmp
        tmp = 1
    p = c
loop += tmp // 2
ans = loop * k
if first_tmp == 0 and tmp % 2 == 1:
    ans += k // 2
elif s[0] == s[-1] and first_tmp % 2 == 1 and tmp % 2 == 1:
    ans += k - 1
print(ans)


Measured memory_bytes: 3064
#define IO ios::sync_with_stdio(false);cin.tie();cout.tie(0)
#pragma GCC optimize(2)
#include<set>
#include<map>
#include<cmath>
#include<queue>
#include<string>
#include<vector>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
const int N=100010;
int main()
{
    IO;
    int T=1;
    //cin>>T;
    while(T--)
    {
        int n;
        cin>>n;
        ll res=0;
        for(int i=1;i<=n;i++)
        {
            ll now=n/i;
            if(n%i==0) now--;
            res+=now;
        }
        cout<<res<<'\n';
        
    }
    return 0;
}

Measured memory_bytes: 3608
#include<iostream>
#include<array>
#include<algorithm>
using namespace std;
int main(){
    int a[3];
    cin >> a[0] >> a[1] >> a[2];
    sort(a, a+3);
    for (int i=0; i<3; i++){
        if (i != 0) cout << " ";
        cout << a[i];
    }
    cout << endl;
    return 0;
}


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

def main():
    N=int(input())  #数値入力 「N」だけの入力のとき
    H=list(map(int, input().split()))  #リスト入力 「a1 a2 a3 ...」みたいな配列のような入力のとき
    D=list()
    ans = 0
    cnt = 0
    for ind, i in enumerate(H[:-1]): #初めから最後から2番目の要素まで
        if i>=H[ind+1]:
            cnt += 1
            if ind == N-2:
                D.append(cnt)
        else:
            D.append(cnt)
            cnt = 0
        ans = max(ans, cnt)
    #print("D")
    #print(D)

    print(ans)

if __name__ == '__main__':
    main()

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

#define rep(i, n) for(int i=0; i < n; i++)
#define REP(i, n, m) for(int i=n; i < m; i++)
#define reps(i, n) for(int i=1; i <= n; i++)
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)

using namespace std;
using ll=long long;

const ll INF = 1LL << 60;

ll mod=1000000007;

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}


int main() {
  int a;cin>>a;
  cout<<a+a*a+a*a*a;
}

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


using LL = long long int;
using uLL = unsigned long long int;
using uint = unsigned int;
using ld = long double;

const int N = 107;
const int K = 100007;

bool dp[K];
int A[N];

int main(){
    cin.tie(NULL);
    ios_base::sync_with_stdio(0);
    int n, k;
    cin >> n >> k;
    for(int i = 0; i < n; i++){
        cin >> A[i];
    }
    for(int i = 1; i <= k; i++){
        for(int j = 0; j < n; j++){
            if(A[j] <= i){
                dp[i] = max(bool(dp[i]), bool(dp[i-A[j]]^1));
            }
        }
    }
    if(dp[k] == true){
        cout << "First\n";
    }
    else{
        cout << "Second\n";
    }
    
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
using namespace std;
vector<size_t> creatVec(size_t size);
int main() {
    size_t size{}, ans{};
    cin >> size;
    vector<size_t> nums {creatVec(size)};
    for (size_t i{}; i < size; i+=2) if (nums[i] % 2 != 0) ans++;
    cout << ans;
    return 0;
}
vector<size_t> creatVec(size_t size) {
    vector<size_t> vec {};
    for (size_t i{}; i < size; i++) {
        size_t in{};
        cin >> in;
        vec.push_back(in);
    }
    return vec;
}

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

int main() {
  int n,m,c;cin>>n>>m>>c;
  int ans =0;
  int sum =0;
  int a;
  vector<int>b(m);
  for(int i=0;i<m;++i) cin>>b[i];
  for(int i=0;i<n;++i){
    sum = c;
    for(int j=0;j<m;++j){
      cin>>a;
      sum +=a*b[j];
    }
    if(sum>0) ++ans;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            //Out.Flush();
            Read();
        }

        static void Solve()
        {
            var S = ReadLine();
            var N = S.Length;
            var dp = new long[N + 1].Select(_ => new long[4]).ToArray();
            dp[0][0] = 1;
            for(var i=0;i<N;++i)
            {
                if (S[i] == 'A' || S[i] == '?')
                {
                    dp[i + 1][0] += dp[i][0];
                    dp[i + 1][1] += dp[i][1] + dp[i][0];
                    dp[i + 1][2] += dp[i][2];
                    dp[i + 1][3] += dp[i][3];
                }
                if (S[i] == 'B' || S[i] == '?')
                {
                    dp[i + 1][0] += dp[i][0];
                    dp[i + 1][1] += dp[i][1];
                    dp[i + 1][2] += dp[i][2] + dp[i][1];
                    dp[i + 1][3] += dp[i][3];
                }
                if(S[i]=='C' || S[i] == '?')
                {
                    dp[i + 1][0] += dp[i][0];
                    dp[i + 1][1] += dp[i][1];
                    dp[i + 1][2] += dp[i][2];
                    dp[i + 1][3] += dp[i][3] + dp[i][2];
                }
                for (var j = 0; j < 4; ++j)
                    dp[i + 1][j] = dp[i + 1][j] % Mod;
            }
            WriteLine(dp[N][3]);
        }

        static long Mod = (long)1e9 + 7;
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static public (T1 a, T2 b) Slice<T1, T2>()
        {
            var t = ReadLine().Split();
            return (
            (T1)Convert.ChangeType(t[0], typeof(T1)),
            (T2)Convert.ChangeType(t[1], typeof(T2)));
        }
        static public (T a, T b) Slice2<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)));
        }
        static public (T a, T b, T c) Slice3<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)));
        }
    }
}

Measured memory_bytes: 33464
// BEGIN CUT HERE
#ifdef _MSC_VER
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <numeric>
#include <cctype>
#include <tuple>
#include <array>
#include <climits>
#include <bitset>
#include <cassert>
#include <unordered_map>
#include <agents.h>
#else
// END CUT HERE
#include <bits/stdc++.h>
// BEGIN CUT HERE
#endif
// END CUT HERE

#define FOR(i, a, b) for(int i = (a); i < (int)(b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define REV(v) v.rbegin(), v.rend()
#define MEMSET(v, s) memset(v, s, sizeof(v))
#define UNIQUE(v) (v).erase(unique(ALL(v)), (v).end())
#define MP make_pair
#define MT make_tuple

using namespace std;

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

const int N = 55;
ll dp[2][55][55][55];

map<string, vector<int>> dpm;
map<string, vector<string>> mp;

vector<int> func(string s){
	int x = 0;
	for (auto c : s){
		rep(i, 4) if (c == "ATGC"[i]) x |= 1 << i;
	}
	return vector<int>(1, x);
}

vector<int> operator+(const vector<int> &lhs, const vector<int> &rhs) {
	vector<int> res = lhs;
	for (auto e : rhs) res.push_back(e);
	return res;
}

vector<int> parse(string s){
	if (s[0] == '[') return func(s);
	auto &res = dpm[s];
	if (!res.empty()) return res;

	auto &vs = mp[s];
	for (auto &s : vs){
		res = res + parse(s);
		if (res.size() > 200) return res;
	}
	return res;
}

int main(){
	int A, T, G, C;
	cin >> A >> T >> G >> C;
	int m;
	cin >> m;
	cin.ignore();

	string str;
	rep(i, m){
		string s;
		getline(cin, s);
		stringstream ss(s);
		string t;
		ss >> t;
		t = t.substr(0, t.size() - 1);
		if (str.empty()) str = t;
		while (ss >> s){
			mp[t].push_back(s);
		}
	}

	auto x = parse(str);

	int n = A + T + G + C;
	if (x.size() != n){
		cout << 0 << endl;
		return 0;
	}
	
	const ll mod = 1e9 + 7;
	dp[0][0][0][0] = 1;

	auto upd = [&](ll &a, ll &b){
		a = (a + b) % mod;
	};

	rep(i, n){
		int cur = i & 1, nxt = !cur;
		rep(j, A + 1) rep(k, T + 1) rep(l, G + 1) dp[nxt][j][k][l] = 0;
		rep(j, A + 1) rep(k, T + 1) rep(l, G + 1){
			if (x[i] & 1) upd(dp[nxt][j + 1][k][l], dp[cur][j][k][l]);
			if (x[i] & 2) upd(dp[nxt][j][k + 1][l], dp[cur][j][k][l]);
			if (x[i] & 4) upd(dp[nxt][j][k][l + 1], dp[cur][j][k][l]);
			if (x[i] & 8) upd(dp[nxt][j][k][l], dp[cur][j][k][l]);
		}
	}
	cout << dp[n & 1][A][T][G] << endl;

}

Measured memory_bytes: 3752
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
const ld eps = 1e-9;


int main() {

	int N;cin>>N;
	N++;
	int ans=0;
	while (N) {
		ans++;
		N/=2;
	}
	cout<<ans-1<<endl;
	/*{

	}
	string S,T;cin>>S>>T;

	int num=0;

	for (auto ch : S) {
		if (ch == T[num%T.size()]) {
			num++;
		}
	}
	int ans=num/T.size();
*/


	return 0;
}


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

// def
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
#define repeat(i, a, b) for (int i = (a); i < (b); i++)
#define revrepeat(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define revrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define CYES cout << "Yes" << endl
#define CNO cout << "No" << endl
#define SPC(x) cout << fixed << setprecision(x)
#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a, 0xff, sizeof(a))

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<ll> vl;
typedef vector<vector<ll>> vll;
typedef pair<int, int> P;
typedef complex<ld> Point;
const int MOD = 1e9 + 7;
const int INF = 1e9;
const int MAX_V = 1e5 + 5;
const int MAX_N = 1e5 + 5;
const double PI = acos(-1);

int main() {
    int n;
    cin >> n;
    vector<pair<ll, ll>> v(n);
    rep(i, n) {
        ll a, b;
        cin >> a >> b;
        v[i] = make_pair(a, b);
    }
    auto comPair = [](const P &firstElof, const P &secondElof) {
        if (firstElof.second != secondElof.second)
            return firstElof.second < secondElof.second;
        else
            return firstElof.first < secondElof.first;
    };
    sort(all(v), comPair);
    // debug(v[0].second);

    ll t = 0;
    bool ok = true;
    rep(i, n) {
        t += v[i].first;
        if (t > v[i].second)
            ok = false;
    }

    if (ok)
        CYES;
    else
        CNO;
    return 0;
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
#define ll             long long int
#define lb             lower_bound
#define ub             upper_bound
#define fi             first
#define mp             make_pair
#define vll            vector<ll>
#define se             second
#define sz             size()
#define mod            1000000007
#define endl           "\n"
#define fast           ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb             push_back
#define all(v)         v.begin(),v.end()
#define allr(v)        v.rbegin(),v.rend()
#define inp(V,n)      for(int i=0;i<n;i++){cin >> V[i];}
#define oup(V,n)     {for(int i=0;i<n;i++){cout <<  V[i] << " "  ;} cout << endl;}
using namespace std;
ll factorial(ll n)
{
    return (n == 1 || n == 0) ? 1 : n * factorial(n - 1);
}
ll gcd(ll a, ll b)
{
    if (a == 0)
      return b;
    return gcd(b % a, a);
}
ll lcm(ll a, ll b)
{
   return (a*b)/gcd(a, b);
}
bool sortByVal(const pair<double,double> &a,
               const pair<double,double> &b)
{
    if(a.fi==b.fi)
    {
    return (a.second >b.second);
    }
    else
        return (a.fi<b.fi);
}

int main()
{
fast;
int q=1;
//cin>>q;
while(q--)
{
ll n,k,sum=0,ans=0,a,b,c,d=0,e,i,y,x;
cin>>x>>n;
set<ll>s;
for(i=0;i<n;i++)
{   cin>>y;
    s.insert(y);
}
 if(!s.count(x))
    cout<<x<<endl;
 else
    for(i=0;i<=101;i++)
 {
      y=x-i;
      if(!s.count(y))
      {
          cout<<y<<endl;
          break;
      }
      c=x+i;
      if(!s.count(c)){
        cout<<c<<endl;
        break;
      }
      {

      }
 }
}
return 0;
}



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

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> divisors;
    for (int i = 1; i < ceil(sqrt(M)) + 1; i++) {
        if (M % i == 0) {
            divisors.push_back(i);
            divisors.push_back(M / i);
        }
    }
    int threshold = M / N;
    int max_possible_divisors = 1;
    for (auto it = begin(divisors); it != end(divisors); ++it) {
        if (*it <= threshold && *it > max_possible_divisors) {
            max_possible_divisors = *it;
        }
    }
    cout << max_possible_divisors << endl;
}


Measured memory_bytes: 256
package main
import (
	"fmt"
	"math"
)

func main() {
	var n int
	fmt.Scanf("%d", &n)
	m := int(math.Ceil(math.Sqrt(float64(n))))
	for j := m; ; j-- {
		if n % j == 0 {
			i := n / j
			d := (i-1) + (j-1)
			fmt.Println(d)
			return
		}
	}
}



Measured memory_bytes: 512
import java.io.BufferedReader
import java.io.PrintWriter

class MainKt

val out: PrintWriter = PrintWriter(System.out)

fun main(args: Array<String>) {
    val n = MyScanner.readAsString().ofCountMap()['o']
    val score = if (n == null) 700 else 700 + 100 * n
    println(score)
}


class MyScanner {
    companion object {
        private var reader : BufferedReader = System.`in`.bufferedReader()

        init {
            reader.mark(0)
        }

        fun reset(){
            reader.reset()
        }

        fun readAsInt(): Int {
            return Integer.parseInt(reader.readLine())
        }

        // Int
        fun readAsIntArray(delimiters: String = " "): IntArray {
            return reader
                .readLine()
                .split(delimiters)
                .map { s -> Integer.parseInt(s) }
                .toIntArray()
        }

        fun readNTimesAsInt(n: Int): IntArray {
            return (1..n).map { readAsInt() }.toIntArray()
        }

        fun readNTimesAsIntArray(n: Int): Array<IntArray> {
            return (1..n).map { readAsIntArray() }.toTypedArray()
        }

        // long
        // TODO 別の方法を考える
        fun readAsLong(): Long {
            return reader.readLine().toLong()
        }

        fun readAsLongArray(delimiters: String = " "): LongArray {
            return reader.readLine()
                .split(delimiters)
                .map { s -> s.toLong() }
                .toLongArray()
        }

        fun readNTimesAsLong(n: Int): LongArray {
            return (1..n).map { readAsLong() }.toLongArray()
        }

        fun readAsString(): String {
            return reader.readLine()
        }

        fun readAsStringArray(delimiters: String = " "): Array<String> {
            return readAsString().split(delimiters).toTypedArray()
        }

    }
}

/**
 * 要素とその個数を出力
 */
fun <T> Array<T>.ofCountMap(): Map<T, Int> {
    return this.groupBy { it }.mapValues { it.value.count() }
}

/**
 * 文字とその個数を出力
 */
fun String.ofCountMap(): Map<Char, Int> {
    return this.toCharArray().ofCountMap()
}

/**
 * 文字とその個数を出力
 */
fun CharArray.ofCountMap(): Map<Char, Int> {
    return this.groupBy { it }.mapValues { it.value.count() }
}

Measured memory_bytes: 31396
/*
  ∧,,∧
( 'ω' )つ ＜WA,またお前か！！　
（m9 ＼ 　　
　 ＼　 ＼
　 　 ) ) ＼
　 ／／ ＼ ＼
　 (＿） 　 (＿)
*/

#include <bits/stdc++.h>
using namespace std;

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

typedef long long LL;
typedef long double LD;

bool compare_by_a(pair<int, int> a, pair<int, int> b) {
    if (a.first != b.first) {
        return a.first < b.first;
    } else {
        return a.second < a.second;
    }
}

bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if (a.second != b.second) {
        return a.second < b.second;
    } else {
        return a.first < b.first;
    }
}

int main()
{
    int X;
    cin >> X;
    string ans;
    ans = (X == 3 || X == 5 || X == 7) ? "YES" : "NO";
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>

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

int w,h;
int f[20][20];
int ans;
int dx[4] = {1,0,-1,0};
int dy[4] = {0,-1,0,1};

void rec(int n,int x, int y){

	if(n >= ans)return;

	rep(i,4){
		int mx = x + dx[i];
		int my = y + dy[i];

		if(f[my][mx] == 1)continue;
		if(0>mx || mx>=w)continue;
		if(0>my || my>=h)continue;

		while(1){
			if(f[my][mx] == 3){
				if(ans > n)ans = n;
				return;
			}

			mx += dx[i], my += dy[i];
			if(0>mx || mx>=w)break;
			if(0>my || my>=h)break;

			if(f[my][mx] == 1){
				f[my][mx]=0;
				rec(n+1,mx-dx[i],my-dy[i]);
				f[my][mx]=1;
				break;
			}
		}
	}
}

int main(){

	int sx,sy;

	while(std::cin >> w >> h, (w||h)){

		rep(i,h){
			rep(j,w){
				std::cin >> f[i][j];
				if(f[i][j] == 2){
					sx = j, sy = i;
				}
			}
		}
		ans = 11;
		rec(1,sx,sy);
		if(ans > 10)ans = -1;
		std::cout << ans << std::endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<P,int> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int n,k;
vl a;

int main(){
	cin>>n>>k;
	a=vl(n);
	for(int i=0;i<n;i++) cin>>a[i];
	ll res=INF;
	for(int i=0;i<=n-k;i++){
		ll L=a[i],R=a[i+k-1],t;
		if(L<=0&&0<=R) t=abs(L)+R+min(abs(L),R);
		else t=max(abs(L),abs(R));
		res=min(res,t);
	}
	cout<<res<<endl;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define Vp vector<pair<ll, ll>>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
using namespace std;
const double pi = acos(-1.0);
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
using Graph = vector<vector<int>>;

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

  ll a, b, c, d; cin >> a >> b >> c >> d;
  ll cnt1 = 0, cnt2 = 0;
  while(c > 0){
    c -= b;
    cnt1++;
  }
  while(a > 0){
    a -= d;
    cnt2++;
  }
  if(cnt1 <= cnt2) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}


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

using namespace std;

int main(){
  long long X;
  cin >> X;
  
  for(long long A = -1000; A <= 1000; A++){
    if(X == 0) break;
    for(long long B = -1000; B <= 1000; B++){
      if(A * A * A * A * A - B * B * B * B * B == X){
        cout << A << ' ' << B << endl;
        X = 0;
        break;
      }
    }
  }
  
  return 0;
}

Measured memory_bytes: 3584
#include <stdio.h>
#define N 25

typedef struct Node{
    int key;
    int light;
    int left;
    int parent;
}node;

node tree[N];

int FindRoot(int num){
    int i;
    for(i=0; i<num; i++){
        if(tree[i].parent == -1) return i;
    }
}

int CalcDegree(int i){
    int deg = 0;
    if(tree[i].left != -1) deg++;
    if(tree[i].light != -1) deg++;
    return deg;
}

int CalcDepth(int i, int root){
    int dep = 0;
    while(i != root){
        dep++;
        i = tree[i].parent;
    }
    return dep;
}

int CalcHeight(int i,int h){
    int rh=0,lh=0;
    if(tree[i].light == -1 && tree[i].left == -1){
        return h; 
    }else{
        if(tree[i].left != -1){
            lh = CalcHeight(tree[i].left,h+1);
        }
        if(tree[i].light != -1){
            rh = CalcHeight(tree[i].light,h+1);
        }
        if(lh<rh) return rh;
        else return lh;
    }
}

int Sibling(int i){
    if(tree[i].parent == -1){
        return -1;
    }else if(tree[i].key == tree[tree[i].parent].left){
        return tree[tree[i].parent].light;
    }else{
        return tree[tree[i].parent].left;
    }
}

int main(){
    int i,num,buf,root;

    for(i=0; i<N; i++){
        tree[i].parent = -1;
    }
    scanf("%d",&num);
    for(i=0; i<num; i++){
        scanf("%d",&buf);
        scanf("%d %d",&tree[buf].left, &tree[buf].light);
        tree[buf].key = buf;
        if(tree[buf].left != -1)tree[tree[buf].left].parent = tree[buf].key;
        if(tree[buf].light != -1)tree[tree[buf].light].parent = tree[buf].key;
    }

    root = FindRoot(num);
    for(i=0; i<num; i++){
        printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, ",
        i,tree[i].parent,Sibling(i),CalcDegree(i),CalcDepth(i,root),CalcHeight(i,0));

        if(tree[i].parent == -1) printf("root\n");
        else if(tree[i].left == -1 && tree[i].light == -1) printf("leaf\n");
        else printf("internal node\n");
    }
    return 0;
}


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

namespace ABC133B
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] ND = CIN.IntArray();
            int[][] X = new int[ND[0]][];
            for (int i = 0; i < ND[0]; i++)
            {
                X[i] = CIN.IntArray();
            }

            int ans = 0;
            for (int i = 0; i < ND[0]; i++)
            {
                for (int j = 0; j < i; j++)
                {
                    float d2 = 0;
                    for (int k = 0; k < ND[1]; k++)
                    {
                        d2 += (X[i][k] - X[j][k]) * (X[i][k] - X[j][k]);
                    }

                    if (Math.Sqrt(d2) % 1 <= 0)
                    {
                        ans++;
                    }
                }
            }
            Console.WriteLine(ans);
        }
    }

    internal static class CIN
    {
        public static string String()
        {
            return Console.ReadLine();
        }

        public static int Int()
        {
            return int.Parse(Console.ReadLine());
        }

        public static int[] IntArray()
        {
            return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        }

        public static long Long()
        {
            return long.Parse(Console.ReadLine());
        }

        public static long[] LongArray()
        {
            return Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
        }

        public static double[] DoubleArray()
        {
            return Console.ReadLine().Split(' ').Select(double.Parse).ToArray();
        }
    }
}

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

static const int MAX = 100;
static const long long INF = (1LL<<32);

int V,E;
long long d[MAX][MAX];

void floyd(){
  for(int k=0;k<V;k++){
    for(int i=0;i<V;i++){
      if(d[i][k] == INF) continue;
      for(int j=0;j<V;j++){
	if(d[k][j] == INF) continue;
	d[i][j] = min(d[i][j],d[i][k] + d[k][j]);
      }
    }
  }
}

int main(){
  cin >> V >> E;
  for(int i=0;i<V;i++){
    for(int j=0;j<V;j++){
      if(i == j) d[i][j] = 0;
      else d[i][j] = INF;
    }
  }
  for(int i=0;i<E;i++){
    int a,b,c;
    cin >> a >> b >> c;
    d[a][b] = c;
  }
  floyd();

  bool minus = false;
  for(int i=0;i<V;i++){
    if(d[i][i] < 0) minus = true;
  }
  if(minus) {
    cout << "NEGATIVE CYCLE" << endl;
  } else {
    for(int i=0;i<V;i++){
      for(int j=0;j<V;j++){
	if(j) cout << " ";
	if(d[i][j] == INF) cout << "INF";
	else cout << d[i][j];
      }
      cout << endl;
    }
  }
}

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

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,int> plli;
typedef pair<int,pii> pipii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<pii> vpii;

#define int long long
#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n);i>=0;i--)
#define rrep2(i,a,b) for (int i=(a);i>b;i--)
#define pb push_back
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()

const ll mod = 1e9 + 7;
const ll INF = 1<<30;
const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};
const int dx8[8] = {1, 1, 1, 0, 0, -1, -1, -1};
const int dy8[8] = {0, 1, -1, 1, -1, 0, 1, -1};
const double pi = 3.141592653589793;

int n, m;
int p[100000 + 5];
int s[100000 + 5][25];
int cnt[25];
int dp[1<<21];

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n >> m;
    rep(i, n) cin >> p[i];
    rep(i, n) cnt[p[i] - 1] += 1;
    rep(i, n) s[i + 1][p[i] - 1] += 1;
    rep(i, n)rep(j, m) s[i + 1][j] += s[i][j];
    fill(dp, dp + (1<<m) + 1, 1e9);
    dp[0] = 0;
    rep(i, 1<<m) {
        rep(j, m) {
            if (i>>j & 1) {
                int l = 0;
                int r = 0;
                rep(k, m) {
                    if (k == j) r = cnt[k];
                    else if (i>>k & 1) l += cnt[k];
                }
                int change = r - (s[r + l][j] - s[l][j]);
                dp[i] = min(dp[i], dp[i ^ (1<<j)] + change);
            }
        }
    }
    cout << dp[(1<<m) - 1] << endl;
}

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

int main()
{
  	int n;
  
 	cin >> n;
  
    vector<int> a(n);
  
  	for(int i = 0;i < n;i++){
      cin >> a.at(i);
    }
  
  	for(int i = n - 1;i > 0;i--){
      cout << a.at(i) << " ";
    }
    cout << a.at(0) << endl;
}


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

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

    //1の桁の数
    int count = N % 10;

    if (count == 3) {
        cout << "bon";
    } else if (count == 0 or count == 1 or count == 6 or count == 8) {
        cout << "pon";
    } else {
        cout << "hon";
    }

    return 0;
}

Measured memory_bytes: 3584
import java.util.Scanner;

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

      int ans = 0;
      for(int i = 0;i < S.length();i++){
          if(S.charAt(i) != T.charAt(i)){
              ans++;
          }
      }
      System.out.println(ans);
    }
}

Measured memory_bytes: 41128
#include <iostream>
#include <vector>

using namespace std;

int main()
{
  int n;
  vector<int> h;
  int move_max, move_cnt;

  cin >> n;
  for (int i = 0; i < n; i++) {
    int h1;
    cin >> h1;
    h.push_back(h1);
  }

  move_max = 0;
  move_cnt = 0;
  for (int i = n-2; 0 <= i; i--) {
    if (h[i] >= h[i+1]) {
      move_cnt++;
    } else {
      if (move_max < move_cnt) {
        move_max = move_cnt;
      }
      move_cnt = 0;
    }
  }
  if (move_max < move_cnt) {
    move_max = move_cnt;
  }
  cout << move_max << endl;
  return 0;
}


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

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

using namespace std;
using ll = long long;

int selection_sort(int *a, int n) {
  int cnt = 0;

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

    for (int j = i; j < n; j++) {
      if (a[j] < a[minj]) {
        minj = j;
      }
    }

    if (minj != i) {
      int v = a[i];
      a[i] = a[minj];
      a[minj] = v;
      cnt++;
    }
  }

  return cnt;
}

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

  int a[n];
  rep(i, n) cin >> a[i];

  int cnt;
  cnt = selection_sort(a, n);

  rep(i, n) {
    cout << a[i];
    if (i < n - 1)
      cout << " ";
    else
      cout << endl;
  }

  cout << cnt << endl;

  return 0;
}



Measured memory_bytes: 3092
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;


int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(12);


    int n, K;
    cin >> n >> K;

    vector<int> P(n);
    for (int i = 0; i < n; ++i) {
        cin >> P[i];
        --P[i];
    }
    vector<long long> C(n);
    for (int i = 0; i < n; ++i) {
        cin >> C[i];
    }

    long long res = -(1LL << 62);

    vector<bool> visited(n, false);

    vector<int> que(n + 123);
    vector<long long> sums(n * 2 + 123, 0);
    for (int i = 0; i < n; ++i) {
        if (visited[i]) {
            continue;
        }
        int sz = 0;
        int x = i;
        while (!visited[x]) {
            visited[x] = true;
            que[sz++] = x;
            x = P[x];
        }

        // for (int j = 0; j < sz; ++j) {
        //     cout << que[j] << '\n';
        // }
        // cout << endl;
        for (int j = 0; j < 2 * sz; ++j) {
            sums[j] = C[que[j % sz]];
        }
        for (int j = 1; j < 2 * sz; ++j) {
            sums[j] += sums[j - 1];
        }
        long long total = sums[sz - 1];
        for (int j = 0; j < sz; ++j) {
            long long ans = 0;
            long long m = K / sz;
            ans += m * total;
            long long r = K % sz;
            if (r > 0) {
                ans += sums[j + r - 1] - (j - 1 >= 0 ? sums[j - 1] : 0);
            }
            res = max(res, ans); 
        
            for (int k = 0; k < sz && k < K; ++k) {
                long long ans = sums[j + k] - (j - 1 >= 0 ? sums[j - 1] : 0);
                ans += max(0LL, (K - k - 1) / sz * total);

                res = max(res, ans);
            }
        }
    }

    cout << res << '\n';

    return 0;
}

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

#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

//#define bug( x ,y) cerr << #x << '=' << x<<','<<#y<<'='<< y << '\n' ;


int n;


int main(){

	IOS

	cin >> n;

	int a[n] ,s=0 ;

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

		s += a[i] ;
	}

	s = round(1.0*s/n);

	int res=0;

	for (int i = 0; i < n; ++i)
	{
	   	res +=((a[i]-s) * (a[i]-s));
	}

	cout << res << '\n';
	




	
 
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define gcd(x,y) __gcd(x,y)
#define fi first
#define se second
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
template <class A> inline ll abs(A &a) { return (a < 0 ? -a : a); }
using namespace std;
const ll inf=(1LL<<62);
const ll MOD=(1e9)+7;
const ll mod=998244353;
signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  ll n, a[1000000];
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }

  ll ans = 0;
  for (int i = 0; i < n - 1; i++) {
    if (a[i] > a[i + 1]) {
      ans += a[i] - a[i + 1];
      a[i + 1] = a[i];
    }
  }

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

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


int main(){
    int n, ans=0;
    cin >> n;
    vector<vector<int>> data(10, vector<int>(10));
    for (int i=1; i<=n; i++){
        int h, t;
        string x = to_string(i);
        h = x[0] - '0';
        t = x[x.size()-1] - '0';
        data.at(h).at(t) += 1;
    }
    for (int i=1; i<=9; i++){
        for (int j=1; j<=9; j++){
            ans += data.at(i).at(j) * data.at(j).at(i);
        }
    }

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

Measured memory_bytes: 256
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		
		final String NK = Integer.toString(N, K);
		int ans = NK.length();
		
		System.out.println(ans);
	}
}


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

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    int sum = a + b + c;
    if (sum % 2 != 0) cout << "No" << endl;
    else {
        if (a == sum / 2 || b == sum / 2 || c == sum / 2) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <limits.h>
int main(void){
    int dp[100][100][3];
    int n,i,j,k,m;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d %d",&dp[i][i][1],&dp[i][i][2]);
        dp[i][i][0]=0;
    }
    for(i=1;i<n;i++){
        for(j=0;j<n-i;j++){
            dp[j][j+i][0]=1000000;
            dp[j][j+i][1]=dp[j][j][1];
            dp[j][j+i][2]=dp[j+i][j+i][2];
            for(k=0;k<i;k++){
                m = dp[j][j+k][0]+dp[j+k+1][j+i][0]+dp[j][j+k][1]*dp[j][j+k][2]*dp[j+k+1][j+i][2];
                if(m<dp[j][j+i][0]){dp[j][j+i][0]=m;}
            }
        }
    }
    printf("%d\n",dp[0][n-1][0]);
}


Measured memory_bytes: 2092