akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
string s;
int main()
{
	int n,m;
	getline(cin,s);
	for(int i=0;i<s.size();i++){
		if(s[i]==',')cout<<' ';
		else cout<<s[i];
	}
	return 0;
}

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

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

int main() {
	int n;
	cin >> n;
	double p;
	p = ((n + 1) / 2 + 0.0) / (n + 0.0);
	cout << setprecision(10) << p << endl;
	return 0;
}

Measured memory_bytes: 256
n, k = list(map(int, input().split()))
A = list(map(int, input().split()))
mod = (10 ** 9) + 7
C = 0
t = 0
for i in range(n):
    for j in range(n):
        if A[i] > A[j] and i < j:
            t += 1
        if A[i] > A[j]:
            C += 1
print((t * k + (C * k * (k - 1) // 2)) % mod)

Measured memory_bytes: 3188
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <stdlib.h>
#include <string>
#include <utility>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define loop(i, x, n) for (int i = (x); i < (n); i++)
#define all(v) (v).begin(), (v).end()
#define int long long
using namespace std;

signed main() {
  string s;
  cin >> s;
  rep(i, s.size()) {
    if (s[i] == 'A')
      cout << "T";
    else if (s[i] == 'T')
      cout << "A";
    else if (s[i] == 'C')
      cout << "G";
    else
      cout << "C";
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
while 1:
    try:s=input()
    except:break
    t=input()
    if len(s)<len(t):s,t=t,s
    a=sum(min(s.count(i),t.count(i)) for i in set(s)&set(t))
    b=0
    for x in range(len(t)):
        if len(t)-x<=b:break
        for y in range(b+1,min(a+1,len(t)-x+1)):
            if t[x:x+y] in s:b=y
            else:break
    print(b)

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

#define M 1000000
#define L 14

char H[M][L]; /* Hash Table */

int getChar(char ch){
  if ( ch == 'A') return 1;
  else if ( ch == 'C') return 2;
  else if ( ch == 'G') return 3;
  else if ( ch == 'T') return 4;
}

/* convert a string into an integer value */
long long getKey(char str[]){
  long long sum = 0, p = 1, i;
  for ( i = 0; i < strlen(str); i++ ){
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}

int h1(int key){ return key%M; }
int h2(int key){ return 1+(key%(M-1)); }

int find(char str[]){
  long long i,key,h;
  key=getKey(str);
  for(i=0;i<M;i++){
    h=(h1(key) + i*h2(key))%M;
    if(strcmp(H[h],str)==0) return 1;
    else if(strlen(H[h])==0) return 0;
  }
}

int insert(char str[]){
  long long key,i,h;
  key=getKey(str);
  for(i=0;i<M;i++){
    h=(h1(key) + i*h2(key))%M;
    if(strcmp(H[h],str)==0) return 1;
    else if(strlen(H[h])==0){
      strcpy(H[h],str);
      return 0;
    }
  }
}

int main(){
    int i, n, h;
    char str[L], com[9];
    for ( i = 0; i < M; i++ ) H[i][0] = '\0';
    
    scanf("%d", &n);
    
    for ( i = 0; i < n; i++ ){
	scanf("%s %s", com, str);
	
	if ( com[0] == 'i' ){
	    insert(str);
	} else {
	    if (find(str)){
		printf("yes\n");
	    } else {
		printf("no\n");
	    }
	}
    }

    return 0;
}



Measured memory_bytes: 15460
def main():
    N = int(input())
    xs = input().split()
    prod = 1
    for i in range(N):
        prod *= int(xs[i])
    sum = 0
    for i in range(N):
        sum += prod / int(xs[i])
    print(prod / sum)
    return


if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <cstring>
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <numeric>
#include <float.h>
#include <math.h>
using namespace std;
// repマクロの定義
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
// allマクロの定義
#define all(v) v.begin(), v.end()

typedef unsigned long long ll;


int main(){ 
int N; cin >> N;
vector<int> X(N);
vector<int> Y(N);
rep(i,N) cin >> X[i]; 
Y = X;
sort(Y.begin(),Y.end());
int a,b;
a = Y[N/2-1];
b = Y[N/2];
rep(i,N){
    if(X[i] < b){
        cout << b;
    }
    else{
        cout << a;
    }
    cout << endl;
}

}



Measured memory_bytes: 3712
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = (ll)(1e+8) + 9;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
int main() {
	int x, y; cin >> x >> y; cout << x + y/ 2 << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long int x;
	cin>>x;
	int arr[x];
	
	for(int i=0;i<x;i++)
    	cin>>arr[i];
    	
    int dp[x];
    dp[0]=0;
	dp[1]=abs(arr[1]-arr[0]);
    
    for(int i=2;i<x;i++)
    	dp[i]=min(dp[i-2]+abs(arr[i-2]-arr[i]),dp[i-1]+abs(arr[i-1]-arr[i]));
    	
    
	cout<<endl<<dp[x-1];
}


Measured memory_bytes: 1024
w,h,n=map(int,input().split())
l=[[0 for i in range(w)] for j in range(h)]
for i in range(n):
  x,y,a=map(int,input().split())
  if a==1:
    for j in range(x):
      for k in range(h):
        l[k][j]=1
  elif a==2:
    for j in range(x,w):
      for k in range(h):
        l[k][j]=1
  elif a==3:
    for j in range(y):
      for k in range(w):
        l[j][k]=1
  else:
    for j in range(y,h):
      for k in range(w):
        l[j][k]=1
count=0
for i in range(w):
  for j in range(h):
    if l[j][i]==0:
      count+=1
print(count)

Measured memory_bytes: 3064
import java.util.*;
import java.io.*;

class Main{
    public static void main(String[] args){
        FastScanner fsc=new FastScanner();
        int n=fsc.nextInt();
        int[] count=new int[100002];
        for(int i=0;i<n;i++){
            int a=fsc.nextInt();
            count[a]++;
            count[a+1]++;
            count[a+2]++;
        }
        fsc.close();
        int max=-1;
        for(int i=0;i<100002;i++){
            if(count[i]>max) max=count[i];
        }
        System.out.println(max);
    }
    static class FastScanner {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;
        private boolean hasNextByte(){
            if(ptr<buflen) return true;
            else{
                ptr = 0;
                try{
                    buflen = in.read(buffer);
                }
                catch(IOException e){
                    e.printStackTrace();
                }
                if(buflen<=0) return false;
            }
        return true;
        }
        private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
        private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
        public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while(isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }
        public long nextLong() {
            if (!hasNext()) throw new NoSuchElementException();
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || '9' < b) throw new NumberFormatException();
            while(true){
                if ('0' <= b && b <= '9') {
                    n *= 10;
                    n += b - '0';
                }
                else if(b == -1 || !isPrintableChar(b)) return minus ? -n : n;
                else throw new NumberFormatException();
                b = readByte();
            }
        }
        public int nextInt() {
            long nl = nextLong();
            if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
            return (int) nl;
        }
        public double nextDouble() { return Double.parseDouble(next());}
        public void close(){
            try{in.close();}
            catch(IOException e){e.printStackTrace();}
        }
    }
}


Measured memory_bytes: 22416
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define vi vector<int>
#define vl vaector<long>
#define vll vector<long long int>
#define vC  vector<char>
#define FastIO ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define db(...) ZZ(#__VA_ARGS__, __VA_ARGS__)
ll pow(ll x, ll y,ll m) { ll res = 1;x=x%m; while (y > 0) { if (y & 1) res = ((res%m) * (x%m))%m; y = y >> 1; x = ((x%m) * (x%m))%m; } return res%m; }
template <typename Arg1> void ZZ(const char* name, Arg1&& arg1){std::cerr << name << " = " << arg1 << endl;}
template <typename Arg1, typename... Args>void ZZ(const char* names, Arg1&& arg1, Args&&... args)
{
	const char* comma = strchr(names + 1, ',');
	std::cerr.write(names, comma - names) << " = " << arg1;
	ZZ(comma, args...);
}
const ll INF = 0xFFFFFFFFFFFFFFFL;
clock_t time_p=clock();
void abhigyan10()
{time_p=clock()-time_p;cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";}
ll seed;
mt19937 rng(seed=chrono::steady_clock::now().time_since_epoch().count());
inline ll rnd(ll l=0,ll r=INF){return uniform_int_distribution<ll>(l,r)(rng);}
#define clrbuf cin.ignore(numeric_limits<streamsize>::max(),'\n');
#define preciset(x) cout<<setprecision(x)<<fixed;
const ll mod =1000000007;
int main()
{
    
	
    	
        FastIO

        ll n,h,i,x=0LL;
        cin>>n>>h;
        vll a(n);
        for(i=0;i<n;i++)
        	cin>>a[i];
        sort(a.begin(),a.end());

        for(i=0;i<n-h;i++)
        	x+=a[i];
        cout<<x;
        return 0;
    }

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

int main(){
    int a, b, c, d;
    cin >> a >> b >> c >> d;

    while(a > 0 && c > 0) {
        c -= b;
        if (c <= 0){
            cout << "Yes" << endl;
            break;
        } 
        a -= d;
        if (a <= 0) cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 3632
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using static System.Console;

class Program
{
    static void Main(string[] args)
    {
        var (N, K) = ReadLine().Split(' ').Select(int.Parse).ToArray();

        var ans = N % K == 0 ? 0 : 1;

        WriteLine(ans);
    }
}

static class ArrayDeconstructExtensions
{
    public static void Deconstruct<T>(this T[] a, out T i1, out T i2) => (i1, i2) = (a[0], a[1]);
    public static void Deconstruct<T>(this T[] a, out T i1, out T i2, out T i3) => (i1, i2, i3) = (a[0], a[1], a[2]);
    public static void Deconstruct<T>(this T[] a, out T i1, out T i2, out T i3, out T i4) => (i1, i2, i3, i4) = (a[0], a[1], a[2], a[3]);
    public static void Deconstruct<T>(this T[] a, out T i1, out T i2, out T i3, out T i4, out T i5) => (i1, i2, i3, i4, i5) = (a[0], a[1], a[2], a[3], a[4]);
}


Measured memory_bytes: 28076
#include<bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define sl set<ll>
#define vs vector<string>
#define vl vector<ll>
#define vi vector<int>
#define vpl vector<pair<ll,ll>>
#define pb push_back
#define PI 3.14159265358979323846
#define ll long long
#define ld long double
#define endl "\n"
#define rep(i,a,b) for (ll i = (a); i < (b); i++)
#define repp(i,a,b) for (ll i = (a); i >= (b); i--)
#define rop(i,a,b)  for(ll i=(a); i>(b); i--)
#define min3(a, b, c) min(c, min(a, b))
#define min4(a, b, c, d) min(d, min(c, min(a, b)))
#define tt long long t; cin>>t; while(t--)
#define IOS ios::sync_with_stdio(0);cin.tie(0);
const int maxn=1e5+100;

int main()
{
    IOS;
    ll n;
    cin>>n;
    ll a[n],b[n];
   
    for(ll i=0;i<n;i++)
    {
        cin>>a[i]>>b[i];
    }
    ll flag=0;
    for(ll i=0;i<=n-3;i++)
    {
        if(a[i]==b[i] && a[i+1]==b[i+1] && a[i+2]==b[i+2]){cout<<"Yes";flag=1;break;}
    }
    if(flag==0)cout<<"No";
    
}

Measured memory_bytes: 3656
#include <iostream>
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
#include <vector>

using namespace std;

int main() {
    int n,sum = 0; cin >> n;
    for (int i = 0; i < n; ++i) {
        int a,b; cin >> a >> b;
        sum += (b - a + 1);
    }
    cout << sum << endl;
}

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

int main() {
  int a,b,c,d,e,f;
  cin>>a>>b>>c>>d;
  e=max(a,max(b,c));
  f=e;
  for(int i=0;i<d;i++){
    f=f*2;
  }
  cout<<a+b+c+f-e<<endl;
}

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

const int maxn=800+5;

char A[maxn][maxn];
int F[maxn][maxn],N;

int main(){
	scanf("%d",&N);
	for(int i=1;i<=N;i++)scanf("%s",A[i]+1);
	for(int i=1;i<=N;i++)for(int j=1;j<=N;j++)A[i][j+N]=A[i+N][j]=A[i+N][j+N]=A[i][j];
	int ans=0;
	for(int i=1;i<N*2;i++){
		for(int j=1;j<N*2;j++){
			int t=F[i-1][j-1];bool ok=true;
			for(int k=1;k<=t;k++){
				if(A[i-k][j]!=A[i][j-k]){ok=false;break;}
			}
			F[i][j]=ok?t+1:1;ans+=F[i][j]>=N;
		}
	}
	cout<<ans<<'\n';
	return 0;
}


Measured memory_bytes: 2560
class MineMap(val height: Int, val width: Int) {

  type Mine = (Int, Int)

  private val internalCounts = Array.fill(height)(Array.fill(width)(0))
  private var mines = Seq.empty[Mine]

  private def isInside(coordinate: Mine): Boolean =
    0 <= coordinate._1 && coordinate._1 < height && 0 <= coordinate._2 && coordinate._2 < width

  def setMines(mines: Mine*): Unit = mines.foreach { mine =>
    this.mines = this.mines :+ mine
    for {
      h <- mine._1 - 1 to mine._1 + 1
      w <- mine._2 - 1 to mine._2 + 1
    } yield {
      if (isInside((h, w))) internalCounts(h)(w) += 1
    }
  }

  def opened(mineChar: String = "#"): Array[Array[String]] = {
    val stringMap = internalCounts.map { line =>
      line.map(_.toString)
    }
    this.mines.foreach { mine =>
      stringMap(mine._1)(mine._2) = mineChar
    }
    stringMap
  }
}

import java.util.Scanner

trait Reader {
  val scanner = new Scanner(System.in)
}

object Main extends App with Reader {

  final val H = scanner.nextInt()
  final val W = scanner.nextInt()
  val mineMap = new MineMap(H, W)

  val mines = (0 until H).foldLeft(Seq.empty[(Int, Int)]) { (acc, h) =>
    acc ++  scanner.next().zipWithIndex.collect {
      case ('#', w) => (h, w)
    }
  }
  mineMap.setMines(mines:_*)
  val answer = mineMap.opened().map { line =>
    line.map(_.toString).mkString
  }.mkString("\n")
  println(answer)
}



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

namespace AtCoder.Abc171
{
    class D
    {
        static readonly int MaxN = 100000;

        public static void Main()
        {
            int n = int.Parse(Console.ReadLine());
            var a = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();

            var count = new long[MaxN + 1];

            foreach (var item in a)
                count[item]++;

            int q = int.Parse(Console.ReadLine());

            long sum = 0;
            for (int i = 1; i <= MaxN; i++)
                sum += i * count[i];

            for (int i = 0; i < q; i++)
            {
                var bc = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();

                long minus = bc[0] * count[bc[0]];
                long plus = bc[1] * count[bc[0]];
                count[bc[1]] += count[bc[0]];
                count[bc[0]] = 0;
                sum += plus - minus;
                Console.WriteLine(sum);
            }
        }
    }
}


Measured memory_bytes: 50824
# 左側と右側の長さそれぞれk-1（末端から伸ばすぶんで-1）で削っていく感じ
# とおもったけどこれじゃ不十分で, 2 1 3でK=3のとき一発でいけるんでダメ
# 頭からk個、そこからk-1個ずつ伸ばしていく感じ。idxはもはや関係ない
# たぶんO(1)あるんだろうけど思いつかない、せいぜいN<=100000なのでシミュレーションまわしてもいいのでは

n, k = gets.chomp.split.map(&:to_i)
arr = gets.chomp.split.map(&:to_i)

length = 0
count = 0
while length<n do
  if length.zero?
    length = k
  else
    length += k-1
  end
  count+=1
end

puts count

Measured memory_bytes: 8708
def combmod(n, r, p):
    if r < 0 or n < r:
        return 0
    return fact[n] * finv[r] * finv[n-r] % p


p = 10**9+7
N = 10**6
fact = [1, 1]
finv = [1, 1]
inv = [0, 1]

for i in range(2, N+1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    finv.append((finv[-1] * inv[-1]) % p)

h, w, a, b = (int(x) for x in input().split())
ans = 0
for j in range(b, w):
    ans += combmod(h-a-1 + j, j, p) * combmod(a+w-2 - j, w-1 - j, p)
print(ans % p)


Measured memory_bytes: 124176
using System.Numerics;
using static System.Math;
using System;

public class Hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        BigInteger x = Abs(long.Parse(line[0]));
        BigInteger k = long.Parse(line[1]);
        BigInteger d = long.Parse(line[2]);
        getAns(x, k, d);
    }
    static void getAns(BigInteger x, BigInteger k, BigInteger d)
    {
        if (x - k * d >= 0) { Console.WriteLine(BigInteger.Abs(x - k * d)); return; }
        var t = x / d;
        if ((k - t) % 2 == 0) Console.WriteLine(BigInteger.Abs(x - t * d));
        else Console.WriteLine(BigInteger.Abs(x - d * (t + 1)));
    }
}


Measured memory_bytes: 27784
#include<algorithm>
#include<iostream>
#include<cstdio>
#include<cmath>

using namespace std;

const long long inf=1e13;

long long f[2][600001],a[200010],n,lazy[2][600001],A,B,Q;

void update(int t,int s)
{
	f[t][s]+=lazy[t][s];
	if((s*2)<=600000) lazy[t][s*2]+=lazy[t][s];
	if((s*2+1)<=600000)lazy[t][s*2+1]+=lazy[t][s];
	lazy[t][s]=0;
}

long long get(int o,int p,int q,int r,int s,int t)
{
	if(q>r) return inf;
    update(t,s);
	if((o==q)&&(p==r)) return f[t][s];
	int mid=(o+p)/2;
	if(r<=mid) return get(o,mid,q,r,s*2,t);else
	if(q>mid) return get(mid+1,p,q,r,s*2+1,t);else
	return min(get(o,mid,q,mid,s*2,t),get(mid+1,p,mid+1,r,s*2+1,t));
}

void put(int o,int p,int q,int r,int s,long long t)
{
    update(s,r);
    f[s][r]=min(f[s][r],t);
    if((o==q)&&(p==q)) return;
    int mid=(o+p)/2;
    if(q<=mid) put(o,mid,q,r*2,s,t);else put(mid+1,p,q,r*2+1,s,t);
}

int main()
{
	scanf("%lld%lld%lld%lld",&n,&Q,&A,&B);
	for(int i=0;i<=600000;i++)
	{
		f[0][i]=f[1][i]=inf;
		lazy[0][i]=lazy[1][i]=0;
	}
	a[0]=B;
	put(1,n,A,1,1,A);
	put(1,n,A,1,0,-A);
	for(int i=1;i<=Q;i++)
	{
		scanf("%lld",&a[i]);
		long long yu=min(get(1,n,1,a[i],1,0)+a[i],get(1,n,a[i]+1,n,1,1)-a[i]);
		lazy[0][1]=lazy[1][1]=abs(a[i]-a[i-1]);
		put(1,n,a[i-1],1,0,yu-a[i-1]);
		put(1,n,a[i-1],1,1,yu+a[i-1]);		
	}
	long long ans=inf;
	for(int i=1;i<=n;i++)
	    ans=min(ans,(get(1,n,i,i,1,0)+i));
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 20608
#include<cstring>
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;

int main()
{
	int w,a,b;
	scanf("%d %d %d",&w,&a,&b);
	if (a<=b && a+w>=b) printf("0");
	else
	if (b<=a && b+w>=a) printf("0");
	else
	if (a<b) printf("%d",b-a-w);
	else printf("%d",a-b-w);
	return 0;
 }  

Measured memory_bytes: 128
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
typedef complex<double> P;
typedef long long int Int;
const int NORMA = 1000000;

int main() {
  int N;
  while(cin >>N && N){
    map<Int, Int> m;
    set<Int> s;
    vector<Int> v;
    REP(i, N){
      Int a, b, c; cin >>a >>b >>c;
      m[a] += b * c;
      if(s.find(a) == s.end()) v.push_back(a);
      s.insert(a);
    }
    vector<Int> ans;
    REP(i, v.size()) if(m[v[i]] >= NORMA) ans.push_back(v[i]);
    if(ans.size() == 0) cout <<"NA" <<endl;
    else REP(i, ans.size()) cout <<ans[i] <<endl;
  }
  return 0;
}

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

int main() {
  int n;
  scanf("%d", &n);
  vector<int> a(n);
  for (int i = 0; i < n; ++i)
    scanf("%d", &a[i]);
  if (a[0] != 0)
    return 0 * puts("-1");
  for (int i = 0; i < n - 1; ++i)
    if (a[i + 1] - a[i] > 1)
      return 0 * puts("-1");
  vector<pair<int, int>> v;
  for (int i = 0; i < n; ) {
    int j = i + 1;
    while (j < n && a[j] == a[i])
      ++j;
    v.emplace_back(a[i], j - i);
    i = j;
  }
  long long ans = 0;
  for (int i = 0; i < int(v.size()); ) {
    int j = i + 1;
    while (j < int(v.size()) && v[j].first == v[j - 1].first + 1)
      ++j;
    int nx = j;
    --j;
    ans += 1LL * v[j].second * v[j].first;
    --j;
    while (j >= i) {
      --v[j].second;
      ans += 1LL * v[j].second * v[j].first;
      --j;
    }
    i = nx;
  }
  printf("%lld\n", ans);
  return 0;
}

Measured memory_bytes: 3188
import java.io.*;
import java.util.*;

class Main {
	public static void main(String[] $) {
		new Main().run();
	}
	
	void run() {
		Scanner sc=new Scanner(System.in);
		String s=sc.next();
		int n=s.length();
		if (s.charAt(n-1)=='s') s+="es";
		else s+="s";
		System.out.println(s);
	}
	
	void tr(Object...objects) {System.out.println(Arrays.deepToString(objects));}
}


Measured memory_bytes: 38448
#include <iostream>
using namespace std;
int n;
long long a[410];
long long dp[410][410];
int main () {
	cin >> n;
	for (int i=0; i<n; i++) {
		cin >> a[i];
	}
	for (int sz=1; sz<n; sz++) {
		for (int i=0; i<n-sz; i++) {
			dp[i][i+sz] = 1e16;
			for (int j=i; j<i+sz; j++) {
				dp[i][i+sz] = min(dp[i][i+sz], dp[i][j]+dp[j+1][i+sz]);
			}
			for (int j=i; j<=i+sz; j++) {
				dp[i][i+sz] += a[j];
			}
		}
	}
	cout << dp[0][n-1] << endl;
}

Measured memory_bytes: 4876
k = gets.to_i
a = gets.split.map(&:to_i)

max = 10**14
min = 0
while max-min > 1
    mid = min+(max-min)/2
    b = mid*1
    for i in 0..k-1
        b -= b%a[i]
    end
    if b > 2
        max = mid
    else
        min = mid
    end
end
ans_max = min

max = 10**14
min = 0
while max-min > 1
    mid = min+(max-min)/2
    b = mid*1
    for i in 0..k-1
        b -= b%a[i]
    end
    if b >= 2
        max = mid
    else
        min = mid
    end
end
ans_min = max

puts (ans_max < ans_min ? "-1" : "#{ans_min} #{ans_max}")

Measured memory_bytes: 10532
#include<bits/stdc++.h>
using namespace std;
#define  ll  long long
const int N=1e5+3;
ll a[N];
int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll i,n,m,s=0,l=0,r=0;
    cin>>n;
    for(i=0; i<n; i++)
    {
        cin>>a[i];
    }
    for(i=0; i<n; i++)
    {
        s+=a[i];
        if(i%2==0)
        {
            if(s<=0)
            {
                l+=abs(s)+1;
                s=1;
            }
        }
        else
        {
            if(s>=0)
            {
                l+=s+1;
                s=-1;
            }
        }
    }
    s=0;
    for(i=0; i<n; i++)
    {
        s+=a[i];
        if(i%2==1)
        {
            if(s<=0)
            {
                r+=abs(s)+1;
                s=1;
            }
        }
        else
        {
            if(s>=0)
            {
                r+=s+1;
                s=-1;
            }
        }
    }
    cout<<min(l,r)<<"\n";
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int n,a,v,cnt[21],maxcnt;

int main(){
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a>>v;
    cnt[a-1]+=v;
    maxcnt=max(maxcnt,cnt[a-1]);
  }
  for(int i=0;i<n;i++){
    if(maxcnt==cnt[i]){
      cout<<i+1<<' '<<maxcnt<<endl;
      break;
    }
  }
  return 0;
}

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

#define forn(l, r) for(int i = l; i < (r); ++i)
#define forj(l, r) for(int j = l; j < (r); ++j)
#define TAM 1000100
#define SYNC ios::sync_with_stdio(0);
#define $ << ' ' <<
#define F first
#define S second
#define endl '\n'


using namespace std;

using ll = long long int;
using ii = pair<int, int>;
using vii = vector<ii>;
using vi = vector<int>;
using graph = vector<vi>;
const int INF = 0x3f3f3f3f;
const int MAXN = 112345;
const ll mod = 1000000007;


int main() {
    //SYNC
    string s;
    int n, k;
    cin >> n >> k >> s;;
    s[k-1] += 32;
    cout << s << endl;
    return 0;
}

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

int main (){
    int A, B, C, X;
    cin >> A >> B >> C >> X ;
    int count = 0;
    for (int i = 0;i <= A;i++){
        for (int j = 0;j <= B;j++){
            for (int k = 0;k <= C;k++){
                if (500*i + 100*j +50*k == X)
                count++;
            }
        }
    }
    cout << count << endl;
}

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

#define FOR(i,a,b) for(int i=(a);i<(int)(b);++i)
#define REP(i,n) FOR(i,0,n)

using namespace std;


int main(){
  int n,d;
  cin>>n>>d;
  vector<vector<int>> x(n,vector<int>(d));
  REP(i,n){
    REP(j,d)cin>>x[i][j];
  }

  int ans=0;
  REP(i,n){
    REP(j,i){//j<i
      int sq=0;
      REP(k,d){
        int s=x[i][k]-x[j][k];
        sq+=s*s;
      }
      int s=sqrt(sq)+0.5;//int キャストは切り捨てなので0.5たしとく
      if(s*s==sq)ans++;
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
import math

a,b,x = map(int, input().split())
m = a*a*b
z = math.degrees(math.atan(b / a))

if x >= m / 2:  
  z = ((x*2) / (a*a)) - b
  r = math.degrees(math.atan((b - z) / a))
  print(r)
else:  
  z = (x*2) / (a*b)
  r = 90 - math.degrees(math.atan(z / b))
  print(r)

Measured memory_bytes: 3060
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
ll mod =1e9+7;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,a,b) for(int i=(a);i<(b);++i)

template<class T> T maxt(T x,T y) {if (x>y) return x;else return y;}
template<class T> T mint(T x,T y) {if (x>y) return y;else return x;}
//sort(v.begin(), v.end(), [](auto& x, auto& y){return x[1] < y[1];});


//小数出力
double print_double(double d){printf("%.11f", d);}

//約数列挙
vector<ll> divisor(ll n) {
  vector<ll> ret;
  for(ll i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}



// ll combination_mod(int n, int k) {
//   k = mint(k,n-k);
//   ll ans = 1;
//   if (n==0 || k ==0) return ans;
//   rep(i,k) {
//     ans = ans*(n-i)%mod;
//     ans = ans*modinv(i+1)%mod;
//   }
//   return ans;
// }

struct edge {
  int from; //出発点
  int to;   //到達点
  ll cost; //移動コスト
};

//ベルマンフォード法
vector<ll> bellman_ford (vector<edge> edges, int V, int E, int r, ll INF = 100000000000) {  
  vector<ll> cost_to(V,INF);
  cost_to[r] = 0;
  rep(i,V) {
    rep(j,E) {
      edge e = edges[j];
      if (cost_to[e.from]==INF) continue;
      if (cost_to[e.to] > cost_to[e.from] + e.cost) {
        cost_to[e.to] = cost_to[e.from] + e.cost;
        if (i==V-1) {
          printf("NEGATIVE CYCLE\n");
          return {};
        }
      }

    }
  }
  return cost_to;
}

// combination
const int MAX = 510000;
const int MOD = 1000000007;
 
long long fac[MAX], finv[MAX], inv[MAX];
 
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


template<class T> inline void chmin(T& a, T b) {if (a > b) a = b;}
template<class T> inline void chmax(T& a, T b) {if (a < b) a = b;}


// 木上の探索
vector<int> cnt;
void dfs(const vector<vector<int>> &G, int v, int p) {
    for (auto nv : G[v]) {
        if (nv == p) continue; // nv が親 p だったらダメ
        dfs(G, nv, v);
    }

    // 帰りがけ時に、部分木サイズを求める
    cnt[v] = 1; // 自分自身
    for (auto c : G[v]) {
        if (c == p) continue;
        cnt[v] += cnt[c]; // 子のサイズを加える
    }
}

int main() {
  int N,M,a;
  cin >> N >> M;
  rep(i,M) {
    cin >> a;
    N-=a;
  }
  cout << maxt(N,-1) << endl;
}

Measured memory_bytes: 3632
// ABC044_B
#include <iostream>
#include <string>
#include <vector>
#include <iterator>  // std::prev(iter, n) n 個分デクリメントしたイテレータ
#include <tuple>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <stack>
#include <queue>
#include <algorithm>
#include <functional>  // std::greater<T>()
#include <utility>  // std::swap()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <bitset>  // static_cast<std::bitset<8>>
#include <sstream>  // std::stringstream
#include <cmath>
#include <climits>  // INT_MIN
#include <cctype>  // std::isdigit()
#include <iomanip>  // std::setprecision()
using namespace std;
using ll = long long;

#define REP(i, n) for (ll i=0; i < n; i++)  // 0 ~ n-1
#define MIN(vec) min_element(vec.begin(), vec.end())  // イテレータのため、値を取り出すときは * を先頭につける
#define MAX(vec) max_element(vec.begin(), vec.end())
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define SUM(vec) accumulate(vec.begin(), vec.end(), 0LL)  // 0 は初期値
#define pll pair<ll, ll>
#define F first
#define S second
const ll INF = 1LL<<60;  // 10^18（const int inf   = 1<<29;）

int main() {
    // input(sunippets: inpv, inpn, inps)
    string S;
    cin >> S;
    
    // calculation
    map<char, ll> mp;
    REP(i, S.length()) {
        mp[S[i]]++;
    }
    
    auto begin = mp.begin(), end = mp.end();
    for (auto itr = begin; itr != end; itr++) {
        if (itr->second % 2 != 0) {
            cout << "No" << "\n";
            return 0;
        }
    }
    
    cout << "Yes" << "\n";
    
    return 0;
}

Measured memory_bytes: 256
/*

    author : s@if

*/

#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define 		NIL 			-1
#define		 	fi	 		    first
#define 		sec 			second
#define 		MAX 			INT_MAX
#define			INF 			1e9
#define 		ll 			    long long
#define 		PI 			    acos(-1.0)
#define			MOD 			1000000007
#define 		PLL 			pair<ll,ll>
#define 		PII			    pair<int,int>
#define 		ull 			unsigned long long
#define 		For(i,a,b) 		for(int i=a;i<=(int)b;i++)
typedef tree<int, null_type, less<int>, rb_tree_tag,
            tree_order_statistics_node_update> new_data_set;

//*find_by_order(k)  gives the kth element;
//order_of_key(item)   gives the index(number of element strictly less than item) of item;


inline int in() {int x; scanf("%d", &x); return x; }
bool Check(int N , int pos)	{	return (bool) (N & (1<<pos));}
int Set(int N, int pos) {	return N = N | (1<<pos);}

int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};    // King's move
int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};
int hx[]={-2,-2,-1,+1,+2,+2,-1,+1};    // Knight's move
int hy[]={+1,-1,+2,+2,-1,+1,-2,-2};
int dx[]={+1,-1,+0,+0};
int dy[]={+0,+0,+1,-1};

const int MAXN = (int)2e5+9;

vector<int>adj[MAXN];
int dp[MAXN];

void dfs(int curr, int prev = -1)
{
    dp[curr] = 0;

    for(int i=0; i<adj[curr].size(); i++)
    {
        int v = adj[curr][i];
        if(v!=prev){
            dfs(v, curr);
            dp[curr]^=1+dp[v];
        }
    }
}

int main()
{
/*	freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout); */

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

    int i,j,k,l,m,n,p,q,x,y,u,v,r,tc,t;

    cin>>n;
    for(i=1; i<n; i++)
    {
        cin>>u>>v;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }

    dfs(1);

    if(dp[1]>0){
        cout<<"Alice\n";
    }else{
        cout<<"Bob\n";
    }

    return 0;
}

// read the question correctly (is y a vowel? what are the exact constraints?)
// look out for SPECIAL CASES (n=1?) and overflow (ll vs int?)


Measured memory_bytes: 19612
n=int(input())
a=list(map(int,input().split()))
for i in range(n):
    a[i]-=1
ans=0
for i in range(n-1):
    if a[i]==i and a[i+1]==i+1:
        ans+=1
        a[i],a[i+1]=i+1,i
    if a[i]==i:
        ans+=1
if a[-1]==n-1:
    ans+=1
print(ans)

Measured memory_bytes: 14004
#!/usr/bin/env python3

#from collections import defaultdict
#from heapq import heappush, heappop
import sys

sys.setrecursionlimit(10**6)
input = sys.stdin.buffer.readline
INF = 10 ** 9 + 1  # sys.maxsize # float("inf")
MOD = 10 ** 9 + 7


def debug(*x):
    print(*x, file=sys.stderr)


def solve(K, D):
    K = [x - ord("0") for x in K]
    N = len(K)
    less = [[0] * D for i in range(N + 1)]
    border = 0
    debug(": K, N", K, N)
    debug(": less", less)
    for i in range(N):
        for j in range(10):
            for d in range(D):
                less[i][(d + j) % D] += less[i - 1][d]
                less[i][(d + j) % D] %= MOD
            if j < K[i]:
                less[i][(border + j) % D] += 1
        border += K[i]
        border %= D

    debug(": less", less)
    ret = less[N - 1][0] - 1
    ret += (border == 0)
    return ret % MOD


def main():
    # parse input
    K = input().strip()
    D = int(input())
    print(solve(K, D))


# tests
T1 = """
30
4
"""


def test_T1():
    """
    >>> as_input(T1)
    >>> main()
    6
    """


T2 = """
1000000009
1
"""


def test_T2():
    """
    >>> as_input(T2)
    >>> main()
    2
    """


T3 = """
98765432109876543210
58
"""


def test_T3():
    """
    >>> as_input(T3)
    >>> main()
    635270834
    """


T4 = """
555
1
"""


def test_T4():
    """
    >>> as_input(T4)
    >>> main()
    555
    """


T6 = """
5
1
"""


def test_T6():
    """
    >>> as_input(T6)
    >>> main()
    5
    """

# add tests above


def _test():
    import doctest
    doctest.testmod()


def as_input(s):
    "use in test, use given string as input file"
    import io
    global read, input
    f = io.StringIO(s.strip())

    def input():
        return bytes(f.readline(), "ascii")

    def read():
        return bytes(f.read(), "ascii")


USE_NUMBA = False
if (USE_NUMBA and sys.argv[-1] == 'ONLINE_JUDGE') or sys.argv[-1] == '-c':
    print("compiling")
    from numba.pycc import CC
    cc = CC('my_module')
    cc.export('solve', solve.__doc__.strip().split()[0])(solve)
    cc.compile()
    exit()
else:
    input = sys.stdin.buffer.readline
    read = sys.stdin.buffer.read

    if (USE_NUMBA and sys.argv[-1] != '-p') or sys.argv[-1] == "--numba":
        # -p: pure python mode
        # if not -p, import compiled module
        from my_module import solve  # pylint: disable=all
    elif sys.argv[-1] == "-t":
        print("testing")
        _test()
        sys.exit()
    elif sys.argv[-1] != '-p' and len(sys.argv) == 2:
        # input given as file
        input_as_file = open(sys.argv[1])
        input = input_as_file.buffer.readline
        read = input_as_file.buffer.read

    main()


Measured memory_bytes: 153160
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
#include<numeric>
using namespace std;

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
constexpr ll mod = 998244353;
const ll INF = mod * mod;
typedef pair<int, int>P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);

void chmin(int &a, int b) {
	a = min(a, b);
}
void chmax(int &a, int b) {
	a = max(a, b);
}
ll mod_pow(ll a, ll n, ll m = mod) {
	a %= m;
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }
const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}

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

modint dp[3001][3001];
void solve() {
	int n, s; cin >> n >> s;
	dp[0][0] = 1;
	vector<int> a(n);
	rep(i, n)cin >> a[i];
	rep(i, n) {
		rep(j, s + 1) {
			dp[i + 1][j] += (modint)2 * dp[i][j];
			if (j + a[i] <= s) {
				dp[i + 1][j + a[i]] += dp[i][j];
			}
		}
	}
	cout << dp[n][s] << "\n";
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(7);
	//init_f();
	//init();
	solve();
	stop
		return 0;
}


Measured memory_bytes: 78080
x,k,d = gets.split.map(&:to_i)
x = x.abs
a = [(x - k*d).abs]
a.push(x % d) if k - (x / d) >= 0 && (k - (x / d)).even?
a.push((x % d - d).abs) if k - (x / d) + 1 >= 0 && (k - (x / d) + 1).even?
puts a.min

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

int main()
{
    long long a, b, c, d ;
    long long val, maxnum;
    cin >> a >> b >> c >> d;
    if(a >= 0){
        if(c >= 0){
            maxnum = b * d;
        }else if(c < 0 && d >= 0){
            maxnum = b * d;
        }else if(d < 0){
            maxnum = a * d;
        }
    }else if(a < 0 && b >= 0){
        if(c >= 0){
            maxnum = b * d;
        }else if(c < 0 && d >= 0){
            maxnum = max(a * c, b * d);
        }else if(d < 0){
            maxnum = a * c;
        }
    }else if(b < 0){
        if(c >= 0){
            maxnum = b * c;
        }else if(c < 0 && d >= 0){
            maxnum = a * c;
        }else if(d < 0){
            maxnum = a * c;
        }
    }
    cout << maxnum << endl;
}

Measured memory_bytes: 3568
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

// #define int ll
#define REP(i,n) for (int i = 0; i < (n); ++i)
#define FORE(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define debug(x) cerr << #x << ": " << x << '\n'
#define hyphen() cerr << "--\n"

#define ALL(vec) (vec).begin(), (vec).end()
#define REVALL(vec) (vec).rbegin(), (vec).rend()

#define fst first
#define pb push_back

const int MOD = (int)1e9 + 7;

signed main() {
    int N;

    cin >> N;

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


}


Measured memory_bytes: 3600
#if 0
date +%Y.%m.%d

题解先咕着。
#endif
#include <cstdio>
#define debug(...) fprintf(stderr, __VA_ARGS__)

typedef long long ll;

struct {
	inline operator int () { int x; return scanf("%d", &x), x; }
	inline operator ll () { ll x; return scanf("%lld", &x), x; }
	template<class T> inline void operator () (T &x) { x = *this; }
	template<class T, class ...A> inline void operator () (T &x, A &...a)
	{ x = *this; this -> operator ()(a...); }
} read;

const int maxn = 404, maxm = 100005;
int a[maxm], b[maxm];
bool need[maxn];

int main() {
	int n = read, m = read;

	for(int i = 1; i <= m; i ++)
		read(a[i], b[i]);

	int ans = 0;
	for(int i = 1; i < n; i ++)
		for(int j = i + 1; j <= n; j ++) {
			int now = m;
			for(int k = 1; k <= n; k ++)
				need[k] = k == i or k == j;

			while(now) {
				if(need[a[now]] and need[b[now]])
					break;
				if(need[a[now]] or need[b[now]])
					need[a[now]] = need[b[now]] = 1;
				-- now;
			}

			if(!now)
				++ ans;
		}

	printf("%d\n", ans);
}


Measured memory_bytes: 896
object Main extends App {
  val Array(a, b) = io.StdIn.readLine.split(" ").map(_.toInt)

  def nega_zero_posi(n: Long): String = n match {
    case v if v < 0  => "Negative"
    case v if v == 0 => "Zero"
    case v if 0 < v  => "Positive"
  }

  // a, a+1, ..., b の数列が
  val result = (nega_zero_posi(a),nega_zero_posi(b)) match {
    case ("Positive", "Positive")  => "Positive" // 正の整数のみ含むとき
    case ("Zero", _) | (_, "Zero") => "Zero"     // 0を含むとき
    case ("Negative", "Positive")  => "Zero"     // 0を含むとき
    case ("Negative", "Negative")  => { // 負の整数のみ含み、かつ
      if ((b-a+1)%2 == 0) "Positive"      // - 負の整数が偶数個あるとき
      else "Negative"                   // - 負の整数が奇数個あるとき
    }
  }

  println(result)
}

Measured memory_bytes: 54784
#include <bits/stdc++.h>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i,a,b) for (ll i=(a);i<(ll)b; i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define INF 1000000000000000
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; }
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll,ll> p;
constexpr int MOD = 1000000007;

void print(const std::vector<int>& v)
{
  std::for_each(v.begin(), v.end(), [](int x) {
    std::cout << x << " ";
  });
  std::cout << std::endl;
}

int main ()
{
    int N,M;cin>>N>>M;
    map<int, int>m;
    vector<int> A(N),S(N+1,0);
    //S[i+1] iまでの区間での和
    REP(i,N){
        cin>>A[i];A[i] %= M;
        S[i+1] += A[i] + S[i];
        S[i+1] %= M;
    }
    ll cnt =0;
    //print(S);
    for(int i  = 0 ;i<N+1;i++){
        cnt += m[S[i]];
        m[S[i]]++;
    }
    cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 3968
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
string ALP = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string alp = "abcdefghijklmnopqrstuvwxyz";
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}
void neg() {cout << - 1 << endl;}
void unhap() {cout << ":(" << endl;}

int main() {
  ll d, n;
  cin >> d >> n;
  ll sub = pow(100, d);
  if (n == 100) cout << sub * 101 << endl;
  else cout << sub * n << endl;
}

Measured memory_bytes: 384
N = int(input())
lst = list(map(int, input().split()))
smallest = [0 for i in range(N)]
smallest[0] = lst[0]
cnt = 0
for i in range(1,N):
    smallest[i] = min(lst[i],smallest[i-1])
for i in range(N):
    if lst[i] <= smallest[i]:
        cnt += 1
print(cnt)

Measured memory_bytes: 85456
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define repr(e,x) for(auto& e:x)
using namespace std;
typedef long long ll;
typedef long double ld;

int N;
int a[100001], b[100001], c[100001];
int dp[100001][3];

int main(){
    cin>>N;
    repn(i,N) cin>>a[i]>>b[i]>>c[i];

    repn(i,N){
        dp[i][0]=max(dp[i-1][1],dp[i-1][2])+a[i];
        dp[i][1]=max(dp[i-1][2],dp[i-1][0])+b[i];
        dp[i][2]=max(dp[i-1][0],dp[i-1][1])+c[i];
    }

    int ans=max(max(dp[N][0],dp[N][1]),dp[N][2]);
    cout<<ans<<endl;
}

Measured memory_bytes: 5924
# @author 

import sys

class BJudgeStatusSummary:
    def solve(self, tc=0):
        n = int(input())
        a = ['AC', 'WA', 'TLE', 'RE']
        d = {x: 0 for x in a}
        for i in range(n):
            line = input().strip()
            d[line] += 1
        
        for x in a:
            print("{} x {}".format(x, d[x]))
            




solver = BJudgeStatusSummary()
input = sys.stdin.readline

solver.solve()


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

using namespace std;

#define forn(i, n) for (ll i = 0; i < (ll) (n); ++i)
#define sz(a) static_cast<int>((a).size())
#define pb emplace_back
#define mp make_pair
#define endl '\n'
#define f first
#define s second

#ifdef SEREZHKA
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define dbg(...)
#endif

template<typename T>
void _dbg(const char* _s, T _h) { cerr << _s << " = " << _h << "\n"; }

template<typename T, typename... Ts>
void _dbg(const char*_s, T _h, Ts... _t) {
    int _b = 0;
    
    while (((_b += *_s == '(') -= *_s == ')') != 0 || *_s != ',')
        cerr << *_s++;
    
    cerr << " = " << _h << ",";
    _dbg(_s + 1, _t...);
}

using ll = long long;

const ll INF = static_cast<ll>(1e9) + 7ll;
const ll LINF = INF * INF;
const int MAXN = static_cast<int>(4e2) + 17;

int n, c;
int A[MAXN], B[MAXN];
ll pw[MAXN][MAXN], f[MAXN][MAXN], dp[MAXN][MAXN];

bool read() {
    if (!(cin >> n >> c))
        return false;

    forn (i, n)
        cin >> A[i + 1];

    forn (i, n)
        cin >> B[i + 1];

    return true;
}

void add(ll& a, ll b) {
    a += b;

    if (a >= INF)
        a -= INF;
}

void solve() {
    for (int x = 1; x < MAXN; ++x) {
        pw[x][0] = 1;

        for (int p = 1; p < MAXN; ++p)
            pw[x][p] = pw[x][p - 1] * x % INF;
    }

    for (int i = 1; i <= n; ++i)
        for (int p = 0; p <= c; ++p)
            for (int x = A[i]; x <= B[i]; ++x)
                add(f[i][p], pw[x][p]);

    dp[0][0] = 1;

    for (int i = 0; i < n; ++i)
        for (int s = 0; s <= c; ++s)
            for (int p = 0; p + s <= c; ++p)
                add(dp[i + 1][s + p], dp[i][s] * f[i + 1][p] % INF);

    cout << dp[n][c] << endl;
}

int main() {
    cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    
    while (read())
        solve();
    
    return 0;
}



Measured memory_bytes: 4224