akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repd(i,a,b) for (int i = (a); i < (b); i++)
#define INF LLONG_MAX
typedef long long ll;

double naiseki(double x1, double y1, double x2, double y2)
{
	return x1*x2 + y1*y2;
}

double gaiseki(double x1, double y1, double x2, double y2)
{
	return x1*y2 - x2*y1;
}

int main(void)
{
	int q;
	cin >> q;
	int xp0, yp0, xp1, yp1, xp2, yp2, xp3, yp3;
	int p0p1_x, p0p1_y, p2p3_x, p2p3_y, nai, gai;
	rep(i, q)
	{
		cin >> xp0 >> yp0 >> xp1 >> yp1 >> xp2 >> yp2 >> xp3 >> yp3;
		p0p1_x = xp1 - xp0;
		p0p1_y = yp1 - yp0;
		p2p3_x = xp3 - xp2;
		p2p3_y = yp3 - yp2;
		nai = naiseki(p0p1_x, p0p1_y, p2p3_x, p2p3_y);
		gai = gaiseki(p0p1_x, p0p1_y, p2p3_x, p2p3_y);
		if(gai == 0) cout << 2 << endl;
		else if(nai == 0) cout << 1 << endl;
		else cout << 0 << endl;
	}
}



Measured memory_bytes: 3100
s = input()
t = input()

count = 0
ans = 0

for i in range(0,len(s)-len(t)+1):
    S = s[i:i+len(t)]
    for j in range(len(t)):
        if t[j] == S[j]:
            count += 1
    ans = max(ans, count)
    count = 0

print(len(t) - ans)

Measured memory_bytes: 67608
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String s = sc.next();
		int max = 0;
		int sum = 0;
		for(int i = 0; i < n; i++){
			if(s.charAt(i)== 'I'){
				sum += 1;
			}else if(s.charAt(i)== 'D'){
				sum -= 1;
			}
		    max = Math.max(max, sum);
	    }
	    System.out.println(max);
	}
}

Measured memory_bytes: 21972
#インポート
import sys

#入力用
def ILI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def ISI(): return map(int, sys.stdin.readline().rstrip().split())
def II(): return int(sys.stdin.readline().rstrip())
def ISS(): return sys.stdin.readline().rstrip().split()
def IS(): return sys.stdin.readline().rstrip()

N = II()
S = IS()
max = 0
for i in range(1, N+1):
    cnt = 0
    a = set(S[:i])
    b = set(S[i:])
    for s in a:
        if s in b:
            cnt += 1
    if max < cnt:
        max = cnt
print(max)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define mod 1000000007
#define mod998 998244353
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define mkp make_pair
typedef long long ll;
using namespace std;


string S;
int cnt;

int main() {
	cin >> S;
	cnt = 15 - S.size();
	for (int i = 0; i < S.size(); ++i) {
		if (S[i] == 'o')++cnt;
	}
	puts((cnt >= 8) ? "YES" : "NO");
}

Measured memory_bytes: 256
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, std.bitmanip;

void main() {
    auto N = readln.chomp.to!int;
    auto A = readln.split.map!(to!int).array;
    long ans = 0;
    foreach (a; A) {
        while (a % 2 == 0) ans += 1, a /= 2;
    }
    ans.writeln;
}


Measured memory_bytes: 2684
#include <algorithm>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define DEBUGP(val) cerr << #val << "=" << val << "\n"

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;




int main(void) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int a, b, q;
  cin >> a >> b >> q;
  VL s(a + 2), t(b + 2), x(q);
  REP(i, 0, a) cin >> s[i + 1];
  REP(i, 0, b) cin >> t[i + 1];
  REP(i, 0, q) cin >> x[i];
  const ll inf = 1e16;
  s[0] = t[0] = -inf;
  s[a + 1] = t[b + 1] = inf;
  REP(i, 0, q) {
    ll k = x[i];
    int sa = lower_bound(s.begin(), s.end(), k) - s.begin() - 1;
    int sb = sa + 1;
    int ta = lower_bound(t.begin(), t.end(), k) - t.begin() - 1;
    int tb = ta + 1;
    ll mi = 1e18;
    mi = min(mi, max(k - s[sa], k - t[ta]));
    mi = min(mi, max(-k + s[sb], -k + t[tb]));
    mi = min(mi, (k - s[sa]) + (t[tb] - k) + min(k - s[sa], t[tb] - k));
    mi = min(mi, (k - t[ta]) + (s[sb] - k) + min(k - t[ta], s[sb] - k));
  cout << mi << endl;
  }
}


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

ll calc(ll l,ll r,ll n){
  l = ((l-1)/n+1)*n;
  if(l>r) return 0;
  return (r-l)/n+1;
}

ll calc(ll x){
  ll len=0,num = 1,cnt=1;
  while(num<=x){
    ll nx = min(x+1,num*10);
    ll d3 = calc(num,nx-1,3);
    ll d5 = calc(num,nx-1,5);
    ll d15= calc(num,nx-1,15);
    ll d  = d3+d5-d15;
    len+= ((nx-num) - d)*cnt;
    len+= (d3+d5)*4;
    num = nx;
    cnt++;
  }
  return len;
}

ll search(){
  ll L=0,M,R=1LL<<60;
  while(L<R){
    M = (L+R)/2;
    if(calc(M)>=n)R = M;
    else L = M+1;
  }
  return L-1;
}

string ItoS(ll a){
  if(a==0) return "0";
  string res;
  while(a)res=(char)(a%10+'0')+res,a/=10;
  return res;
}

int main(){
  cin>>n;
  ll num = search()+1;
  ll len = calc(num-1);
  string ans;
  while(ans.size()<100){
    if(num%3==0) ans+="Fizz";
    if(num%5==0) ans+="Buzz";
    if(num%3&&num%5) ans+=ItoS(num);
    num++;
  }
  cout<<ans.substr(n-len-1,20)<<endl;
  return 0;
}

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

int main() {
    int N;
    cin >> N;
    vector<int> C(N - 1), S(N - 1), F(N - 1);
    for (int i = 0; i < N - 1; i++)
        cin >> C[i] >> S[i] >> F[i];

    for (int i = 0; i < N; i++) {
        int time = 0;
        for (int j = i; j < N - 1; j++) {
            if (time < S[j]) {
                time = S[j];
            } else if (time % F[j] == 0) {
                ;
            } else {
                time = time + F[j] - time % F[j];
            }
            time += C[j];
        }
        cout << time << endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
typedef long long ll;
const int Max = 1e5 + 5;
int lst[Max], ls[Max];

int main()
{
	int k, s;
	cin >> k >> s;
	ll res = 0;
	for (int i = 0; i <= k; i++)
	{
		for (int j = 0; j <= k; j++)
		{
			if (i + j > s)break;
			if (i + j + k >= s)res++;
		}
	}
	cout << res << endl;
}

Measured memory_bytes: 3108
import java.util.Scanner;
 
class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int input = sc.nextInt();
		if (input % 2 == 1)
			System.out.println(input / 2 + 1);
		else
			System.out.println(input / 2);
		sc.close();
	}
}

Measured memory_bytes: 21972
#include <iostream>
#include <algorithm>
#include <math.h>
#include <string.h>

typedef long long ll;
using namespace std;

int main()
{
  ll n, a, b=0;

  cin >> n;
   a = n;
  while(a){
    b+=(a%10);
    a/=10;
  }
  if(n%b==0) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
from bisect import bisect_left
import sys
sys.setrecursionlimit(10**9)
input = lambda: sys.stdin.readline().rstrip()
inpl = lambda: list(map(int,input().split()))

N, Q = inpl()
S = input()

ACs = []
for i in range(N-1):
    if S[i:i+2] == 'AC':
        ACs.append(i)

for i in range(Q):
    l, r = inpl()
    Nl = bisect_left(ACs,l-1)
    Nr = bisect_left(ACs,r-1)
    print(Nr-Nl)

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

const int maxn = 110;
int n, x, a[maxn];

int main() {
    cin >> n >> x;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    sort(a + 1, a + n + 1);
    int cur = 0, ans = 0;
    for (int i = 1; i <= n; i++) {
        cur += a[i];
        if (cur <= x) ans++;
        else break;
    }
    if (cur < x) ans--;
    cout << ans << endl;
    return 0;
}

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

int main(){

    // 1. 入力情報取得.
    int N;
    scanf("%d", &N);
    
    // 2. 昇順sortできるかを判定.
    int ans = 0;
    for(int i = 1; i <= N; i++){
        int p;
        scanf("%d", &p);
        if(p != i) ans++;
    }
    
    // 3. 出力 ～ 後処理.
    if(ans == 0 || ans == 2) printf("%s\n", "YES");
    else                     printf("%s\n", "NO");
    
    return 0;

}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>

using namespace std;

unsigned mygcd(unsigned a, unsigned b) {
    while (1) {
        if (a < b) swap(a, b);
        if (!b) break;
        a %= b;
    }
    return a;
}

unsigned gcd3(unsigned a, unsigned b, unsigned c) {
    return mygcd(mygcd(a, b), c);
}

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

    long long int ans = 0;
    int tempg;

    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= n; j++) {
            tempg = mygcd(i, j);
            for (int k = 1; k <= n; k++) {
                ans += mygcd(tempg, k);
            }
        }
    }

    cout << ans;


    return 0;
}

Measured memory_bytes: 3636
import java.util.*

fun main(args: Array<String>) {
    val s = readLine()!!
    val stack1 = ArrayDeque<Int>()
    val stack2 = ArrayDeque<Pair<Int, Int>>()

    for (i in 0 until s.length) {
        when(s[i]) {
            '\\' -> {
                stack1.addFirst(i)
            }
            '/' -> {
                if (stack1.isNotEmpty()) {
                    stack2.addFirst(stack1.removeFirst() to i)
                }
            }
        }
    }

    var totalArea = 0
    val lakes = mutableListOf<Int>()
    var ll = s.length

    while (stack2.isNotEmpty()) {
        val (l, r) = stack2.removeFirst()

        if (l < ll) {
            ll = l
            lakes.add(0)
        }

        totalArea += r - l
        lakes[lakes.size - 1] += r- l
    }

    println(totalArea)

    if (lakes.isEmpty()) {
        println(0)
    } else {
        println("${lakes.size} ${lakes.reversed().joinToString(" ")}")
    }
}


Measured memory_bytes: 29676
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long n = sc.nextLong();
    long min = Integer.MAX_VALUE;
    for (int i = 1; i <= (long)Math.sqrt(n); i++) {
      if (n % i == 0) {
        long a = i;
        long b = n / a;
        min = Math.min(min, Math.max(String.valueOf(a).length(), String.valueOf(b).length()));
      }
    }
    System.out.println(min);
  }
}

Measured memory_bytes: 35564
<?php

ini_set('error_reporting', E_ALL & ~E_NOTICE & ~E_WARNING);
ini_set('display_errors', 'Off');

// define('DEBUG', true);
define('DEBUG', false);

fscanf(STDIN, "%d %d %d", $A, $B, $K);

if ($K > $B - $A + 1) {
    $K = $B - $A + 1;
}

$arr1 = array_fill($A, $K, 1);
$arr2 = array_fill($B - $K + 1, $K, 1);
$arr = $arr1 + $arr2;

echo implode("\n", array_keys($arr)) . "\n";


Measured memory_bytes: 4604
s = input()
n = 0
m = 0
for i in range(0, len(s)):
    if s[i] == 'C':
        n = 1
        break
for j in range (i, len(s)):
    if s[j] == 'F':
        m = 1
        break
if n == 1 and m == 1:
    print('Yes')
else:
    print('No')

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

using namespace std;

#define PI 3.14159265358979323846264338327950L

int main(void){
    long long K,N,right,left,ans,tmp;
    map<long long , long long> A;
    vector<long long> dist;

    cin>>K>>N;

    for(long long i=1;i<=N;i++){
        cin>>A[i];
    }
    for(long long i=2;i<=N;i++){
        dist.push_back(A[i] - A[i-1]);
    }

    tmp=K-A[N];
    dist.push_back( tmp+A[1] );
    sort(dist.begin(),dist.end(),greater<long long>());

    ans=K-dist[0];

    cout<<ans<<endl;


    


    return 0;
}



Measured memory_bytes: 14964
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    if len(x) == 0:
        return []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False

def pow_k(x, n):
    ans = 1
    while n:
        if n % 2:
            ans *= x
        x *= x
        n >>= 1
    return ans

"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1
"""

n = onem()

if n >= 30:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 65216
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int sz = 1e6+5;

int dp[66][66];

ll fnc() {
   string s;
   cin >> s;
   int dt = -1;
   for(int i=0; i<s.size(); i++) {
      if(s[i] == '.') {
         dt = i;
      }
   }
   if(dt < 0) {
      s += '.';
      dt = 9;
   }
   else dt = 10 - s.size() + dt;
   while(dt--) s += '0';

   ll x = 0;
   for(char c : s) {
      if(c == '.') continue;
      int y = c - '0';
      x = x * 10 + y;
   }
   return x;
}

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

   int n;
   cin >> n;
   vector <int> a, b;
   for(int i=0; i<n; i++) {
      ll x = fnc();
      int two = 0, five = 0;
      while(x % 2 == 0) two++, x /= 2;
      while(x % 5 == 0) five++, x /= 5;
      dp[two][five]++;
      a.push_back(two);
      b.push_back(five);
   }
   for(int i=60; i>=0; i--) {
      for(int j=60; j>=0; j--) {
         dp[i][j] += dp[i+1][j] + dp[i][j+1] - dp[i+1][j+1];
      }
   }

   ll ans = 0;
   for(int i=0; i<n; i++) {
      int x = 18 - a[i];
      int y = 18 - b[i];
      if(x <= a[i] && y <= b[i]) ans--;
      if(x < 0) x = 0;
      if(y < 0) y = 0;
      ans += dp[x][y];
   }

   cout << ans / 2  << endl;
}


Measured memory_bytes: 5068
from collections import defaultdict


# 試し割り法による素因数分解
# 桁でかくなると回らない
# N<=10**5くらいまで
def prime_factorize(n):
    dd = defaultdict(int)
    while n % 2 == 0:
        dd[2] += 1
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            dd[f] += 1
            n //= f
        else:
            f += 2
    if n != 1:
        dd[n] += 1
    return dd


n, p = map(int, input().split())
dic = prime_factorize(p)

ans = 1
for k, v in dic.items():
    ans *= k**(v // n)
print(ans)



Measured memory_bytes: 9352
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        final Scanner scanner = new Scanner(System.in);
        final int count = scanner.nextInt();

        int res = 0;
        for (int i = 1; i < count + 1; i++) {
            final int a = scanner.nextInt();
            if (a != i) {
                res++;
            }
        }

        if (res <= 2) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
    }
}


Measured memory_bytes: 22868
#include <iostream>
#include <cstdio>
#include <string>
#include <cmath>
#include <cctype>
#include <cstdlib>
#include <stack>
#include <queue>
#include <vector>
#include <algorithm>
#include <list>
#include <map>
#include <set>
#define INFTY 1000000001
using namespace std;

int L[500000] = {}, R[500000] = {},cnt;
void merge(int s[], int l,int mid, int r) {
	int n1 = mid - l, n2 = r - mid;
	for (int i = 0; i < n1;i++) {
		L[i] = s[l + i];
	}
	for (int i = 0; i < n2; i++) {
		R[i] = s[mid + i];
	}
	L[n1] = R[n2] = INFTY;
	int j = 0, k = 0;
	for (int i = l;i < r; i++) {
		cnt++;
		if (L[j] <= R[k]) {
			s[i] = L[j];
			j++;
		}
		else {
			s[i] = R[k];
			k++;
		}
	}
}
void mergeSort(int s[], int l, int r) {
	if (l + 1 < r) {
		int mid = (l + r) / 2;
		mergeSort(s, l, mid);
		mergeSort(s, mid, r);
		merge(s, l, mid, r);
	}
}
int main() {
	int n, s[500000] = {};
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> s[i];
	}
	int l = 0, r = n;
	cnt = 0;
	mergeSort(s, l, r);
	for (int i = 0; i < n; i++) {
		if (i) cout << " ";
		cout << s[i];
	}
	cout << endl;
	cout << cnt << endl;
}


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

using namespace std;

int main(int argc, char const *argv[]){
    double w, h, x, y;
    cin >> w >> h >> x >> y;
    double area = w*h/2;
    cout << area << ' ';
    cout << (((x/w)==0.5) &((y/h)==0.5)) << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		final int N = sc.nextInt();
		int a[] = new int[N + 2];
		a[0] = 0;
		a[N + 1] = 0;
		for(int i = 1; i <= N; i++) {
			a[i] = sc.nextInt();
		}
		
		int sum = 0;
		for(int i = 0; i < N + 1; i++) {
			sum += Math.abs(a[i + 1] - a[i]);
		}
		
		for(int i = 1; i < N + 1; i++) {
			int route1 = Math.abs(a[i] - a[i - 1]);
			int route2 = Math.abs(a[i + 1] - a[i]);
			int route3 = Math.abs(a[i + 1] - a[i - 1]);
			System.out.println(sum - route1 - route2 + route3);
		}
	}
}


Measured memory_bytes: 65320
#include<iostream>
using namespace std;
int main()
{
    int a,b,c;
    int m,n,o;
    cin>>a>>b>>c;
    m=a;
    n=b;
    o=c;

    b=m;
    a=o;
    c=n;

    cout<<a<<" "<<b<<" "<<c;
    return 0;
}


Measured memory_bytes: 3584
#include<bits/stdc++.h>
using namespace std;
string s;
int main(){
   // freopen("A.inp","r",stdin);
  //  freopen("A.out","w",stdout);
    cin>>s;
    if (int(s.size())&1){
        cout<<"No";
        exit(0);
    }
    string t="hi";
    for(int i=0; i<s.size(); i++){
        if (s[i]!=t[i&1]){
            cout<<"No";
            exit(0);
        }
    }
    cout<<"Yes";
}


Measured memory_bytes: 256
#!/usr/bin/env python
"""AtCoder Beginner Contest 167: A - 
https://atcoder.jp/contests/abc167/tasks/abc167_a
"""

__author__ = 'bugttle <bugttle@gmail.com>'


def main():
    S = input()
    T = input()

    if S == T[0:-1]:
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main()


Measured memory_bytes: 9068
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;
using Int = int64_t;
int main() {
    Int N;
    cin >> N;
    vector<Int> A(N);
    for (Int i = 0; i < N; i++) {
        cin >> A[i];
        A[i] -= i + 1;
    }
    sort(A.begin(), A.end());
    Int ans = 0;
    for (Int i : A) ans += abs(i - A[A.size() / 2]);
    cout << ans << endl;
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <cmath>
#include <climits>

constexpr int SINT_MAX = std::numeric_limits<int>::max();
constexpr int SINT_MIN = std::numeric_limits<int>::min();

using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;

template<class T>
T choose(bool b, T t, T f)
{
    if (b) return t;
    else return f;    
}

const char *YesNo(bool b)
{
    return choose(b, "Yes", "No");
}

const char *YESNO(bool b)
{
    return choose(b, "YES", "NO");
}

template<template<class...> class ContT, class ValueT, size_t Dim>
struct vec_type
{
    using type = ContT<typename vec_type<ContT, ValueT, Dim-1>::type>;
};

template<template<class...> class ContT, class ValueT>
struct vec_type<ContT, ValueT, 0>
{
    using type = ValueT;
};

template<class ValueT, size_t Dim = 1>
using vec_t = typename vec_type<std::vector, ValueT, Dim>::type;


template<class ValueT, size_t Dim, class = typename std::enable_if<Dim == 0>::type>
auto make_vec(ValueT value = ValueT()) -> ValueT
{
    return value;
}

template<class ValueT, size_t Dim, class... Rest>
auto make_vec(size_t size0, Rest... rest)
{
    auto vec = make_vec<ValueT, Dim-1>(rest...);
    return std::vector(size0, vec);
}

int diffabs(int l, int r)
{
    if (l < r) return r-l;
    else return l-r;    
}


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

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

    string ans;
    switch (N % 10)
    {
    case 2:
    case 4:
    case 5:
    case 7:
    case 9:
        ans = "hon";
        break;
    case 0:
    case 1:
    case 6:
    case 8:
        ans = "pon";
        break;
    default:
        ans = "bon";
        break;
    }

    cout << ans << endl;
}

Measured memory_bytes: 3600
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <time.h>
#include <random>
#include <string>
#include <cassert>
#include <vector>
#include <ostream>
#include <istream>
#include <stack>
#include <deque>
#include <queue>
#include <functional>
#include <chrono>
#include <stack>

using namespace std;

#define int long long
#define pb push_back
#define all(a) (a).begin(), (a).end()
#define pii pair<int, int>
#define ld long double

ostream& operator<< (ostream &a, const vector<int> &b) {
    for (auto k : b) cout << k << " ";
    return a;
}

istream& operator>> (istream& a, pii& b) {
    cin >> b.first >> b.second;
    return a;
}

ostream& operator<< (ostream& a, const pii& b) {
    cout << "{" << b.first << ", " << b.second << "}";
    return a;
}

template <typename T1, typename T2> inline void chkmin(T1 &x, const T2 &y) {if (x > y) x = y;}
template <typename T1, typename T2> inline void chkmax(T1 &x, const T2 &y) {if (x < y) x = y;}


#ifdef LOCAL
    #define dbg(x) cout << #x << " : " << (x) << "\n";
    const int INF = 100;
    // const int mod = 2600000069;
    // const int p = 10;
    // const ld PI = 3.1415926535;
#else
    #define dbg(x)
    const int INF = 1e15;
    // const int mod = 2600000069; 
    // const int p = 179;
    // const ld PI = 3.1415926535;
#endif

// #pragma GCC optimize("Ofast,no-stack-protector")
// #pragma GCC target("sse,sse2,sse3,sse3,sse4")
// #pragma GCC optimize("unroll-loops")
// #pragma GCC optimize("fast-math")
// #pragma GCC target("avx2")  
// #pragma GCC optimize("section-anchors")
// #pragma GCC optimize("profile-values,profile-reorder-functions,tracer")
// #pragma GCC optimize("vpt")
// #pragma GCC optimize("rename-registers")
// #pragma GCC optimize("move-loop-invariants")
// #pragma GCC optimize("unswitch-loops")
// #pragma GCC optimize("function-sections")
// #pragma GCC optimize("data-sections")

mt19937 gen(chrono::high_resolution_clock::now().time_since_epoch().count());

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    cout << n + n * n + n * n * n;
}
/*

*/


Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    string s,t,u;
    ll a,b;
    cin>>s>>t>>a>>b>>u;
    if(u==s)
    a--;
    else if(u==t)
    b--;
    cout<<a<<" "<<b;
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.DataInputStream;
import java.io.IOException;
import java.io.FileInputStream;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Reader in = new Reader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        AFrog1 solver = new AFrog1();
        solver.solve(1, in, out);
        out.close();
    }

    static class AFrog1 {
        public void solve(int testNumber, Reader in, PrintWriter out) {
            int n = in.nextInt();
            int[] a = new int[n];
            for (int i = 0; i < n; ++i) {
                a[i] = in.nextInt();
            }
            int c = 0;
            int d = Math.abs(a[1] - a[0]);
            for (int i = 2; i < n; ++i) {
                int x = Math.abs(a[i] - a[i - 1]) + d;
                int y = Math.abs(a[i] - a[i - 2]) + c;
                int z = Math.min(x, y);
                c = d;
                d = z;
            }
            out.println(d);
        }

    }

    static class Reader {
        final private int BUFFER_SIZE = 1 << 16;
        private DataInputStream din;
        private byte[] buffer;
        private int bufferPointer;
        private int bytesRead;

        public Reader(InputStream in) {
            din = new DataInputStream(in);
            buffer = new byte[BUFFER_SIZE];
            bufferPointer = bytesRead = 0;
        }

        public Reader(String file_name) {
            try {
                din = new DataInputStream(new FileInputStream(file_name));
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
            buffer = new byte[BUFFER_SIZE];
            bufferPointer = bytesRead = 0;
        }

        public int nextInt() {
            int ret = 0;
            byte c = read();
            while (c <= ' ') {
                c = read();
            }
            boolean neg = (c == '-');
            if (neg) {
                c = read();
            }
            do {
                ret = ret * 10 + c - '0';
            } while ((c = read()) >= '0' && c <= '9');

            if (neg) {
                return -ret;
            }
            return ret;
        }

        private void fillBuffer() {
            try {
                bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
                if (bytesRead == -1) {
                    buffer[0] = -1;
                }
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }

        private byte read() {
            if (bufferPointer == bytesRead) {
                fillBuffer();
            }
            return buffer[bufferPointer++];
        }

    }
}



Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Rep(i, m,n) for (int i = m; i < (int)(n); i++)
int main(){
string S;
  cin>>S;
  if(S.at(2)==S.at(3)&&S.at(4)==S.at(5)){cout<<"Yes"<<endl;}
  else{cout<<"No"<<endl;}
  
  
}

Measured memory_bytes: 256
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#include <ctype.h>
#include <stdint.h>
#include <string.h>
#include <wchar.h>
#include <math.h>

#define N_MAX (100)
#define P_MAX (100)
#define DP_ARRAY_SIZE (N_MAX * P_MAX / 32 + 1)

#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define ABS(a) ((a) < 0 ? -(a) : (a))
#define ABSS(a, b) ((a) > (b) ? (a) - (b) : (b) - (a))

int compare_sz_desc(const void* a, const void* b) {
    return *((size_t*)a) > * ((size_t*)b) ? -1 : 1;
}

int compare_f(const void* a, const void* b) {
    return *((int64_t*)a) < *((int64_t*)b) ? -1 : 1;
}

int compare_f2(const void* a, const void* b) {
    return *((uint64_t*)a) > * ((uint64_t*)b) ? -1 : 1;
}

static size_t comb(const size_t n, const size_t r) {
    size_t result = 1;

    for (size_t i = 0; i < r; i++) {
        result *= n - i;
        result /= i + 1;
    }

    return result;
}

static uint64_t combU64(const uint64_t n, const uint64_t r) {
    uint64_t result = 1;

    for (uint64_t i = 0; i < r; i++) {
        result *= n - i;
        result /= i + 1;
    }

    return result;
}

static uint64_t gcdU64(uint64_t m, uint64_t n)
{
    uint64_t temp;

    while (m % n != 0) {
        temp = n;
        n = m % n;
        m = temp;
    }

    return n;
}

static size_t gcdZu(size_t m, size_t n) {
    size_t temp;

    while (m % n != 0) {
        temp = n;
        n = m % n;
        m = temp;
    }

    return n;
}

int main(void) {
    size_t N;
    int32_t L;

    scanf("%zu %"PRId32, &N, &L);

    int32_t skipPos = 0;

    if (L <= -(int32_t)(N - 1)) {
        skipPos = N - 1;
    }
    else if (-(int32_t)(N - 1) < L && L <= 0) {
        skipPos = -(int32_t)L;
    }
    else {
        skipPos = 0;
    }

    int32_t sum = 0;

    for (size_t i = 0; i < N; i++) {
        if (i != skipPos) {
            sum += (int32_t)(i + 1) + L - 1;
        }
    }

    printf("%"PRId32, sum);

    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using Graph = vector<vector<int>>;
const int INF = 1e9 + 1;
const ll LLINF = 1e18;
const int MOD = 1e9 + 7;

int main() {
    int N;
    string S;
    cin >> N >> S;
    for(int i = 0; i < S.length(); ++i) {
        if(S[i] + N > 90)
            printf("%c", 64 + (S[i] + N) % 90);
        else
            printf("%c", S[i] + N);
    }
    return 0;
}


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

int main(){
    int n;
    cin >> n;
    vector<string> s(n);
    rep(i,n) cin >> s[i];
    vector<int> cnt(4);
    rep(i,n){
        if(s[i]=="AC"){
            cnt[0]++;
        }else if(s[i] == "WA"){
            cnt[1]++;
        }else if(s[i] == "TLE"){
            cnt[2]++;
        }else if(s[i] == "RE"){
            cnt[3]++;
        }
    }
    cout << "AC x " << cnt[0] << endl;
    cout << "WA x " << cnt[1] << endl;
    cout << "TLE x " << cnt[2] << endl;
    cout << "RE x " << cnt[3] << endl;

    return 0;
}

Measured memory_bytes: 6420
#include<iostream>
#include<cstdio>
#include<vector>
using namespace std;
#define int long long
signed main(){
	vector<int> primes(50050,1);
	for(int i=2;i<230;i++){
		if(primes[i]==0) continue;
		for(int j=i+1;j<50050;j++){
			if(j%i==0) primes[j] = 0;
		}
	}
	int a;
	int prev = -1;
	while( scanf("%lld", &a) != EOF ){
		for(int i=0;i<50050;i++){
			if(i<a && primes[i]==1) prev = i;
			if(a<i && primes[i]==1 ){ cout << prev << " " << i << endl; break;}
		}
	}
	return 0;
}

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

vector<ll> v(200005),w(200005);

int ft(ll l, ll r, ll &m, vector<ll> &vctr){
  ll x = w[m-1] - w[l-1];
  ll y = w[r-1] - w[m-1];

  ll d = abs(x-y);
  
  while(x < y){
    ++m;
    x += v[m-2];
    y -= v[m-2];
    
    if(d >= abs(x-y)){
      d = abs(x-y);
      continue;
    }else{
      x -= v[m-2];
      y += v[m-2];
      --m;
      break;
    }
  }
  
  vctr[0] = max(x,y);
  vctr[1] = min(x,y);
  return 0;
}


int main(){
  ll n;
  cin >> n;
  
  for(ll i=0; i<n; i++) cin >> v[i];
  w[0] = 0;
  w[1] = v[0];
  for(ll i=1; i<n; i++) w[i+1] = w[i] + v[i];
  
  vector<ll> tmp1(2);
  vector<ll> tmp2(2);
  
  ll left = 1;
  ll right = n;
  
  ll m_l = left + 1;
  ll sep = m_l + 1;
  ll m_r = sep + 1;
  
  ll tr = 100000000000;
  
  for(sep = 3; sep <= n-1; sep++){
    ft(left, sep, m_l, tmp1);
    ft(sep, right+1, m_r, tmp2);
    
    tr = min(tr,max(tmp1[0],tmp2[0]) - min(tmp1[1],tmp2[1]));
    
  }
  
  cout << tr << endl;
}


Measured memory_bytes: 3328
// https://atcoder.jp/contests/abc108/tasks/arc102_b

#include <bits/stdc++.h>

using namespace std;

#define REP(i,n)   for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); i++)
#define DUMP(a, n) REP(_i, n) printf("%d%c", a[_i], _i + 1 == n ? '\n' : ' ')
#define DUMP2D(a, n, m) REP(_i, n) REP(_j, m) printf("%d%c", a[_i][_j], _j + 1 == m ? '\n' : ' '); puts("")

const int L_MAX = 1e6;
const int N_MAX = 20;

int L;
int N;
int M;
int bs[N_MAX];

struct edge { int from, to, len; };
vector<edge> es;

void solve() {
  N = 0, M = 0;
  for (int l = L; l > 0; l >>= 1) {
    bs[N++] = l & 1;
  }

  int k = L;
  REP(i, N - 1) {
    es.push_back({i + 1, i + 2, 0});
    es.push_back({i + 1, i + 2, 1 << i});
    if (bs[i]) {
      k ^= 1 << i;
      es.push_back({i + 1, N, k});
    }
  }

  M = es.size();
  printf("%d %d\n", N, M);
  REP(i, M) printf("%d %d %d\n", es[i].from, es[i].to, es[i].len);
}

void input() {
  scanf("%d", &L);
}

int main() {
  input();
  solve();
  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll   long long
#define ld long double
#define endl '\n'
#define INF 10000000000000000
#define pll pair<ll,ll>
#define ff first
#define ss second

using namespace std;
const ll N = 200005;
const ll MOD = 998244353;
ll dp[3005][3005];
pll p[3005][3005];
int main()
{
 //freopen("input.txt","r",stdin);
 //  freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    string s,t;
    cin>>s>>t;
    ll n = s.size();
    ll m = t.size();
    for(ll i =0;i<n;i++) {
        for(ll j =0;j<m;j++) {
            if(s[i]==t[j]) {
                if(dp[i+1][j+1]<dp[i][j]+1) {
                    dp[i+1][j+1]=dp[i][j]+1;
                    p[i+1][j+1]={i,j};
                }
            }
             if(dp[i][j+1]<dp[i][j]) {
                    dp[i][j+1]=dp[i][j];
                    p[i][j+1]={i,j};
                }
            if(dp[i+1][j]<dp[i][j]) {
                    dp[i+1][j]=dp[i][j];
                    p[i+1][j]={i,j};
                }
        }
    }
    ll i1 = 0;
    ll j1 = 0;
    for(ll i =0;i<n+1;i++) {
        for(ll j =0;j<m+1;j++) {
            if(dp[i][j]>dp[i1][j1]) {i1=i;j1=j;}
        }
    }
    string an="";
    while(i1!=0 && j1!=0) {
        pll k = p[i1][j1];
        if(dp[i1][j1]>dp[k.ff][k.ss])
        an+=s[k.ff];
        i1=k.ff;
        j1=k.ss;
    }
   reverse(an.begin(),an.end());
   cout<<an;


}


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

long long int n,a,b,temp,ans=0;
int main()
{
    cin>>n>>a>>b;
    temp = a+b;
    ans = (n/temp)*a;
    n%=temp;
    if(n<a)
        ans+=n;
    else
    {
        ans+=a;
    }
    cout<<ans;
}


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

#define ALL(a) begin(a),end(a)
#define COUNTOF(a) (sizeof(a)/sizeof(a[0]))
#define SP << " " <<
#define FMT(a) #a<<":"<<a 
#define FMT2(a,b) #a<<":"<<a<<", "<<#b<<":"<<b 
#define FMT3(a,b,c) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c 
#define FMT4(a,b,c,d) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c<<", "<<#d<<":"<<d 
typedef long long ll;
template<class T> istream& operator >> (istream& s, vector<T>& v) {
  for (T& x: v) s >> x;
  return s;
}
inline void Yes(bool f=true){cout<<(f?"Yes":"No")<<endl;}
inline void YES(bool f=true){cout<<(f?"YES":"NO")<<endl;}

int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    //cout<<std::fixed<<std::setprecision(10);
    vector<int> a(5); cin >>a;
    int k; cin>>k;
    for(int i=0;i<=3;i++) {
        for(int j=i+1;j<=4;j++) {
            if (abs(a[i]-a[j]) > k) {
                cout << ":(" << endl;
                return 0;
            }
        }
    }
    
    cout << "Yay!" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define REP(i,n) for(int i=0;i<(int)(n);i++)

using namespace std;

int main(){ _;
  int n; cin>>n;
  int h = n/3600;
  n-=h*3600;
  int m = n/60;
  n-=m*60;
  int s = n;
  cout << h << ":" << m << ":" << s << endl;
}

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


/*  
    
*/

void test_case(){
    int x;
    cin >> x;
    cout<<(!x)<<endl;
}

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

    int t; t = 1;
    //~ cin >> t;
    while(t--)
        test_case();
    return 0;
}


Measured memory_bytes: 3644
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <set>
#include <stdio.h>
#include <math.h>
using namespace std;
typedef long long int lli;
const long long int MaxN=300005;
const lli mod=1e9+7;
#define fst first
#define snd second
#define mp make_pair
const float pi=3.1415926535897932384626433832795028;
	lli mcd(lli a,lli b){
		if(a==0)return b;
		return mcd(b%a,a);
	}
	float arr[MaxN];
	void solve(){
		lli N,i,j,p,q;
		float res=0;
		cin>>N;
		for(i=0;i<N;i++){
			cin>>arr[i];
		}
		sort(arr,arr+N);
		res=(arr[0]+arr[1])/2;
		for(i=2;i<N;i++){
			res+=arr[i];
			res=res/2;
		}		
		cout<<res;
	}
int main(){
	//cin.tie(0),ios_base::sync_with_stdio(0);
	lli i,t;
	t=1;
	for(i=1;i<=t;i++){
		solve();
	}
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
    int N,K,X,Y;
    cin >> N;
    cin >> K;
    cin >> X;
    cin >> Y;
    int ans = 0;
    for (int i=1; i<K+1 && i<N+1;i++){
        ans+=X;
    }
    if (N > K){
        for(int j=K+1;j<N+1;j++){
            ans+=Y;
        }
    }
    cout << ans << "\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <limits>
#include <math.h>
#define REP(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define RREP(i,n) for(ll i=(n)-1; i>=0; --i)
#define SREP(i,s,n) for(ll i=(s), i##_len=(n); i<i##_len; ++i)


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

template <typename T>
T gcd(T a, T b) {
    if(a < b) gcd(b, a);
    if (b == 1) return 1;
    T r;
    while ((r=a%b)) {
        a = b;
        b = r;
    }
    return b;
}

bool comp(pair<ll, ll> a, pair<ll, ll> b) {
    return (a.first*a.first + a.second*a.second) > (b.first*b.first + b.second*b.second);
}

struct UnionFind {
    vector<int> par;
    vector<int> rank;
    
    UnionFind(int n = 1) {
        init(n);
    }
    
    void init(int n = 1) {
        par.resize(n); rank.resize(n);
        for (int i = 0; i < n; ++i) {
            par[i] = i;
            rank[i] = 0;
        }
    }
    
    int root(int x) {
        if (par[x] == x) {
            return x;
        }
        else {
            int r = root(par[x]);
            return par[x] = r;
        }
    }
    
    bool issame(int x, int y) {
        return root(x) == root(y);
    }
    
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (rank[x] < rank[y]) swap(x, y);
        if (rank[x] == rank[y]) ++rank[x];
        par[y] = x;
        return true;
    }
};

#define MOD (1000000007)
bool tbl[101];
int main(int argc, const char * argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    REP(i, 10) {
        REP(j, 10) {
            tbl[i*j] = true;
        }
    }
    ll N;
    cin >> N;
    cout << ((tbl[N])?"Yes":"No") << endl;
}


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

typedef long long ll;
const int maxn=5e3+10,mod=1e9+7,inv2=mod+1>>1;
int n;
ll val[maxn];
vector<int> g[maxn];
vector<ll> dp[maxn];

inline ll fpow(ll a,ll n){
	ll res=1;
	for(;n;n>>=1,a=a*a%mod)
		if(n&1ll)
			res=res*a%mod;
	return res;
}
inline void init(){
	for(int i=2;i<maxn;i+=2){
		val[i]=fpow(inv2,i/2);
		for(int j=i/2+1;j<=i;++j)
			val[i]=val[i]*j%mod;
	}
}
vector<ll> mul(vector<ll> a,vector<ll> b){
	vector<ll> res(a.size()+b.size()-1);
	for(int i=0;i<a.size();++i)
		for(int j=0;j<b.size();++j)
			(res[i+j]+=a[i]*b[j])%=mod;
	return res;
}
void dfs(int pos,int fa){
	if(fa)
		g[pos].erase(find(g[pos].begin(),g[pos].end(),fa));
	dp[pos].push_back(0);
	dp[pos].push_back(1);
	for(int i=0;i<g[pos].size();++i){
		dfs(g[pos][i],pos);
		dp[pos]=mul(dp[pos],dp[g[pos][i]]);
	}
	for(int i=2;i<dp[pos].size();i+=2)
		(dp[pos][0]+=dp[pos][i]*(mod-val[i]))%=mod;
}

int main(){
	cin>>n;
	for(int i=1,u,v;i<n;++i){
		cin>>u>>v;
		g[u].push_back(v);
		g[v].push_back(u);
	}
	init();
	dfs(1,0);
	cout<<(mod-dp[1][0])%mod<<endl;
	return 0;
}

Measured memory_bytes: 71680
#include <iostream>
#include <algorithm>
using namespace std;
const int MOD = 1000000007;

long long mod(long long a) {
	a %= MOD;
	return a >= 0 ? a : a+MOD;
}
long long mod(long long a, long long m) {
	a %= m;
	return a >= 0 ? a : a+m;
}

int main() {
	string s;
	cin >> s;
	int n = s.size();
	reverse(s.begin(), s.end());

	long long dp[n+1][13];
	fill((long long *)dp, (long long *)dp + sizeof(dp)/sizeof(long long), 0);
	dp[0][0] = 1;
	long long z = 1;
	for (int i = 0; i < n; i++) {
		int D = s[i]=='?' ? -1 : s[i] - '0';
		for (int j = 0; j < 13; j++) {
			if (D == -1) {
				for (int x = 0; x < 10; x++) {
					int next_j = mod(j+z*x,13);
					dp[i+1][next_j] = mod(dp[i+1][next_j] + dp[i][j]);
				}
			} else {
				int next_j = mod(j+z*D,13);
				dp[i+1][next_j] = mod(dp[i][j] + dp[i+1][next_j]);
			}
		}
		z = mod(z*10, 13);
	}
	long long ans = dp[n][5];
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 10624
(n,*c),a,*q=$<.map{_1.split.map &:to_i}
b=(0..n).map{_1&-_1}
d=b.map{[]}
u=i=k=0
q.map{d[_2]<<[_1-1,k+=1]}
a.map{t=c[_1]
(b[t]-=1;t+=t&-t)until t ?t>n:u+=1
c[_1]=i+=1
d[i].map{|x,y|s=u
(s-=b[x];x&=x-1)while x>0
$*[y]=s}}
puts$*

Measured memory_bytes: 171972
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define ESP 1e-5

int main(void){
    ll a;
    cin >> a;
    double b;
    cin >> b;
    int B = b * 100 + ESP;
    ll ans = a * B / 100;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3676
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    ws=STR()
    alp='abcdefghijklmnopqrstuvwxyz'
    ans=[0]*26
    flg=1
    for w in ws:
        ct=alp.index(w)
        ans[ct]+=1
    for i in ans:
        if i%2==1:
            flg=0
    if flg==1:
        print('Yes')
    else:
        print('No')
if __name__ == '__main__':
    do()

Measured memory_bytes: 3064
#include<stdio.h>
int main(void){
    char n;
    for(int i=0;i<3;i++){
        scanf("%c",&n);
        if(n == '1'){
            printf("9");
        } else if(n == '9'){
            printf("1");
        } else {
            printf("%c", n);
        }
    }
    printf("\n");
    return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
int main()
{
    int a,b,c,n;
    scanf("%d%d%d",&a,&b,&c);
    if(a>=b){
        if(a>=c){n=b+c;}
        if(a<c){n=a+b;}}
    else {
        if(b>=c){n=a+c;}
    if(b<c){n=a+b;}}
    printf("%d",n);
    return 0;
}

Measured memory_bytes: 128
N = int(input())
A = list(map(int, input().split()))
dic = dict()

for a in A:
	if a in dic:
		dic[a] += 1
	else:
		dic[a] = 1

dic_sorted = list(sorted(list(dic.items()), key=lambda x:x[0], reverse = True))
# print(dic_sorted)
res = []

for i in range(len(dic_sorted)):
	if len(res) == 2: break
	remain = dic_sorted[i][1]
	while remain >= 2:
		res.append(dic_sorted[i][0])
		remain -= 2
		if len(res) == 2: break

if len(res) == 2:		
	print(res[0] * res[1])
else:
	print(0)

Measured memory_bytes: 72472
package main

import (
	"fmt"
)

func main() {
	var k int
	var s string

	fmt.Scan(&k)
	fmt.Scan(&s)

	i := len(s)

	if i <= k {
		fmt.Println(s)
	} else {
		fmt.Print(s[:k])
		fmt.Print("...")

	}

}


Measured memory_bytes: 1820
#include <iostream>

using namespace std;

int main()
{
    int H, W;
    
    while (1) {
        cin >> H >> W;
        if (H == 0 && W == 0)   break;

        for (int i = 1; i <= H; i++) {
            for (int j = 1; j <= W; j++) {
                if (j == 1 || j == W || i == 1 || i == H) {
                    cout << "#";
                } else {
                    cout << ".";
                }
            }
            cout << '\n';
        }
        cout << endl;
    }
    return 0;


}


Measured memory_bytes: 3068
from collections import Counter

N, K = map(int, input().split())
A = Counter(list(map(int, input().split())))

l = len(A)
if l <= K:
    print(0)
else:
    ans = 0
    A = sorted(A.items(), key=lambda A: A[1])
    for i in range(l-K):
        ans += A[i][1]
    print(ans)

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

using namespace std;

#define llong long long int
#define rep(i, n) for (int i = 0; i < n; ++i)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define stl_repr(itr, x) for (auto itr = x.rbegin(); itr != x.rend(); ++itr)
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()

const static int MOD = 1000000000 + 7;
const static int inf = INT_MAX / 2;
const static llong INF = 1LL << 31;
const static int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

int main (int argc, char *argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n;
    cin >> n;
    vector<pair<int, int> > work;
    rep(i, n) {
        int a, b;
        cin >> a >> b;
        work.push_back({b, a});
    }
    sort(all(work));

    llong cur = 0;
    rep(i, n) {
        cur += work[i].second;
        if (cur > work[i].first) {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
    
    return 0;
}

Measured memory_bytes: 2420
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define INF 1145141919
int dy[] = {0, 0, 1, -1};
int dx[] = {1, -1, 0, 0};
int ny, nx;
typedef long long int ll;
using namespace std;

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

ll lcm(ll m, ll n)
{
    if ((0 == m) || (0 == n))
        return 0;
    return ((m / gcd(m, n)) * n);
}

ll llpow(ll x, ll y)
{
    ll ans = 1;
    REP(i, y)
    ans *= x;
    return ans;
}

int ctoi(char c)
{
    if (c >= '0' && c <= '9')
    {
        return c - '0';
    }
    return 0; 
}
////////////////////////////////////////////////////////////////////
int main()
{
    int S; cin >> S;
    int F=int(S/100), L=S-F*100;

    //cout << F << " " << L << endl;
    
    if(1<=F and F<=12){
        if(1<=L and L<=12){cout << "AMBIGUOUS" << endl;}
        else cout << "MMYY" << endl;
    }else{
        if(1<=L and L<=12){cout << "YYMM" << endl;}
        else cout << "NA" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){

	int n;
	int a=0;
	int b=0;
	int c=0;
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> a >> b >> c;
		if((a + b > c) && a*a+b*b==c*c){
			cout << "YES" << endl;
		}
		else if(a + c > b && a*a+c*c==b*b){
			cout << "YES" << endl;
		}
		else if(b + c > a && b*b+c*c==a*a){
			cout << "YES" << endl;
		}
		else{
			cout << "NO" << endl;
		}
	}
	
	return 0;
}

Measured memory_bytes: 0
import sys
input = lambda: sys.stdin.readline().rstrip()

def main():
    n = int(input())
    h = list(map(int, input().split()))
    ans = h[0]
    for i in range(1, n):
        if h[i] - h[i-1] > 0:
            ans += h[i] - h[i-1]
    print(ans)
        
if __name__ == '__main__':
    main()

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

int main() {
  int n;
  cin >> n;
  vector<int> vec(1000000, 0);
  for (int x = 1; x < 101; x++) {
    for (int y = 1; y <= x; y++) {
      for (int z = 1; z <= y; z++) {
        int nn = (x+y+z) * (x+y+z) - x*y - y*z - z*x;
        int num;
        if (x != y && y != z) num = 6;
        else if ((x == y && y != z) || (x != y && y == z)) num = 3;
        else num = 1;
        vec[nn-1] += num;
      }
    }
  }
  for (int i = 0; i < n; i++) {
    cout << vec[i] << endl;
  }
}

Measured memory_bytes: 7152
//keyence2019_c.cpp
//Sun Jan 13 20:54:10 2019

#include <iostream>
#include <string>
#include <queue>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

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

	ll atotal = 0;
	ll a[n],b[n];
	for (int i=0;i<n;i++){
		cin >> a[i];
		atotal += a[i];
	}
	ll btotal = 0;
	for (int i=0;i<n;i++){
		cin >> b[i];
		btotal += b[i];
	}

	if (atotal<btotal){
		cout << -1 << endl;
		return 0;
	}

	ll alowernumtotal = 0;
	vector<ll> alower;
	vector<ll> ahigher;
	for (int i=0;i<n;i++){
		if (a[i]<b[i]){
			alower.push_back(b[i]-a[i]);
			alowernumtotal += b[i]-a[i];
		}else if (a[i]>b[i]){
			ahigher.push_back(a[i]-b[i]);
		}
	}

	if (alowernumtotal==0){
		cout << 0 << endl;
		return 0;
	}
	sort(ahigher.begin(),ahigher.end(),greater<ll>());

	int requiredahigher = 0;
	for (int i=0;i<ahigher.size();i++){
		alowernumtotal = alowernumtotal-ahigher[i];
		requiredahigher++;
		if (alowernumtotal<=0){
			break;
		}
	}


	cout << requiredahigher + alower.size() << endl;
}

Measured memory_bytes: 2812