akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;

//50 
typedef long long ll;

int main() {
	int n;
	cin >> n;
	vector<int> v(n);
	vector<int> ans(n);
	for (int i = 0; i < n; ++i) {
		cin >> v[i];
		ans[v[i] - 1] = i + 1;
	}	
	for (int i = 0; i < n; ++i) {
		cout << ans[i] << " ";
	}
}


Measured memory_bytes: 3984
#include<iostream>
#include<string>
#include<algorithm>
#include<bits/stdc++.h>
#include<vector>
 
using namespace std;
 
int main() {
  long long N,A,B;
  cin >> N >> A >> B;
  if(A>B) cout << 0 << endl;
  else if((N==1 && A==B) || N==2) cout << 1 << endl;
  else if(N==1) cout << 0 << endl;
  else cout << (N-2)*(B-A)+1 << endl;
  
}

Measured memory_bytes: 384
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
let arr = input.split("\n");
for (let i = 0; i < arr.length; i++) {
    let Arr = arr[i].split(" ").map(Number);
    let H = Arr[0];
    let W = Arr[1];
    if (H === 0 && W === 0) break;
    let str = '';
    for (let hCount = 0; hCount < H; hCount ++) {
      for (let wCount  = 0; wCount < W; wCount ++) {
        if (hCount === 0 || hCount === H-1) {
            str += '#';
        } else {
          if (wCount === 0 || wCount === W-1) {
            str += '#';
          } else {
            str += '.';
          }
            
        }
      }
      str += '\n';
    }
    console.log(str);
}


Measured memory_bytes: 18664
#include <algorithm>
#include <cstdio>
#include <vector>
using namespace std;

const int N = 2e5 + 10;
const int MOD = 1e9 + 7;

int n, x, y, c[N], w[N], Min1, Min2;
int f[N], cnt[N], Min[N];
vector<int> v[N];

int qpow(int a, int b) {
	int ans = 1;
	for(; b; b >>= 1, a = a * 1ll * a % MOD)
		if(b & 1) ans = ans * 1ll * a % MOD;
	return ans;
}

int get(const int &u) {
	return u == f[u] ? u : f[u] = get(f[u]);
}
void unite(int u, int v) {
	(u = get(u)) != (v = get(v)) ? f[v] = u : 0;
}

int main() {
	scanf("%d%d%d", &n, &x, &y);
	
	static int fac[N] = {1}, fav[N];
	for(int i = 1; i <= n; i ++) 
		fac[i] = fac[i - 1] * 1ll * i % MOD;
	fav[n] = qpow(fac[n], MOD - 2);
	for(int i = n; i >= 1; i --)
		fav[i - 1] = fav[i] * 1ll * i % MOD;
	
	w[0] = 1 << 30;
	for(int i = 1; i <= n; i ++) {
		scanf("%d%d", c + i, w + i);
		if(w[i] < w[Min[c[i]]]) Min[c[i]] = i;
	}

	for(int i = 1; i <= n; i ++) if(Min[i]) {
		if(w[Min[i]] < w[Min1]) Min2 = Min1, Min1 = Min[i];
		else if(w[Min[i]] < w[Min2]) Min2 = Min[i];
	}

	for(int i = 1; i <= n; i ++) f[i] = i;
	for(int i = 1; i <= n; i ++) {
		if(w[Min[c[i]]] + w[i] <= x) unite(Min[c[i]], i);
		if(Min2 && c[Min2] != c[i] && w[Min2] + w[i] <= y) unite(Min2, i);
		if(Min1 && c[Min1] != c[i] && w[Min1] + w[i] <= y) unite(Min1, i);
	}
	int ans = 1;
	for(int i = 1; i <= n; i ++) v[get(i)].push_back(c[i]);
	
	for(int i = 1; i <= n; i ++) if(f[i] == i) {
		int size = v[i].size();
		ans = ans * 1ll * fac[size] % MOD;
		for(int j = 0; j < size; j ++) cnt[v[i][j]] ++;
		for(int j = 0; j < size; j ++) if(cnt[v[i][j]]) {
			ans = ans * 1ll * fav[cnt[v[i][j]]] % MOD;
			cnt[v[i][j]] = 0;
		}
	}
	printf("%d\n", ans);
	return 0;
}

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

using namespace std;

typedef long long int ll;
typedef vector<int> vi;
typedef vector<ll> vl;

const int  INF = 1e9;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
const int SIZE = 100;


int main() {
	ll n, p;
	ll odd, even;
	odd = even = 0;
	scanf("%lld %lld", &n, &p);
	vector<ll> a(n);
	for (ll i = 0; i < n; i++) {
		scanf("%lld", &a[i]);
		if (a[i] % 2 == 0) {
			even++;
		}
		else {
			odd++;
		}
	}

	if (p == 0) {
		if (odd == 0) {
			printf("%lld\n", (ll)pow(2, n));
			return 0;
		}
		else {
			printf("%lld\n", (ll)pow(2, n - 1));
			return 0;
		}
	}
	else {
		if (odd >= 1) {
			printf("%lld\n", (ll)pow(2, n - 1));
			return 0;
		}
		else {
			printf("%lld\n", (ll)0);
			return 0;
		}
	}
	return 0;
}

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

int main(void){
	string s;
	cin >> s;
	if(s.size()%2!=0){
		printf("No\n");
	}else{
		bool flag=true;
		for(int i=0;i<s.size();i++){
			if(i%2==0 && s[i]!='h'){
				flag=false;
			}
			if(i%2==1 && s[i]!='i'){
				flag=false;
			}
		}
		printf("%s\n",flag?"Yes":"No");
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
#include <functional> // for less

using namespace std;
#define md 1000000007
#define itn int
#define pb push_back
#define mp make_pair
#define ull unsigned long long int
#define ll long long 
// #define int ll
#define ppi pair<int, int>
#define ppl pair<ll, ll>
#define vi vector<int>
#define all(x) x.begin(), x.end()
#define ff first
#define lb lower_bound
#define ub upper_bound
#define ss second
#define inf 1e9
#define enld '\n'
#define cuot cout
#define trace1(x) cerr << #x << ": " << x << endl
#define trace2(x, y) cerr << #x << ": " << x << " | " << #y << ": " << y << endl
#define trace3(x, y, z)                                                        \
  cerr << #x << ":" << x << " | " << #y << ": " << y << " | " << #z << ": "    \
       << z << endl
#define trace4(a, b, c, d)                                                     \
  cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": "   \
       << c << " | " << #d << ": " << d << endl
#define trace5(a, b, c, d, e)                                                  \
  cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": "   \
       << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl
#define trace6(a, b, c, d, e, f)                                               \
  cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": "   \
       << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | "   \
       << #f << ": " << f << endl
#define trace(v)                                                               \
  for (auto it = v.begin(); it != v.end(); it++)                               \
    cerr << *it << " ";                                                        \
  cerr << endl;
#define linf 1e18
#define reset(x) memset(x, 0, sizeof(x))
#define rep(i, a, b) for (int i = a; i < b; i++)

using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag,
             tree_order_statistics_node_update>
    oset;

void fastio() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
}
int n;
int a[100005][3];

int dp[100005][3];



void solve()
{
    cin>>n;
    rep(i,0,n){
        cin>>a[i][0]>>a[i][1]>>a[i][2];
        dp[i][0]=dp[i][1]=dp[i][2]=-1;
    }

    dp[0][0]=a[0][0];
    dp[0][1]=a[0][1];
    dp[0][2]=a[0][2];
    

    for(int i=0;i<n-1;i++){
        for(int j=0;j<3;j++){
            // if(i==j)continue;
            dp[i+1][(j+1)%3]=max(dp[i+1][(j+1)%3],dp[i][j]+a[i+1][(j+1)%3]);
            dp[i+1][(j+2)%3]=max(dp[i+1][(j+2)%3],dp[i][j]+a[i+1][(j+2)%3]);
        }
    }

    // for(int i=0;i<n;i++){
    //     for(int j=0;j<3;j++){
    //         cout<<dp[i][j]<<" ";
    //     }cout<<endl;
    // }

    cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
}

signed main() {
  fastio();
  int t;
  t = 1;
  // cin >> t;
  for (int i = 1; i <= t; i++) {
    // cout << "Case #" << i << ": ";
    solve();
  }
  return 0;
}

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

using namespace std;

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

  vector<double> vp;
  for (int i =0; i < N; i++) {
    double exp = (double)1 / (double)N;
    double point = static_cast<double>(i + 1);
    while(point <= static_cast<double>(K - 1)) {
      //期待値
      exp *= 0.5;
      // 特典
      point *= 2;
    }
    vp.push_back(exp);
  }
  
  double ans = 0;
  for_each(vp.begin(), vp.end(), [&](const double& d){ans+=d;});
  cout << fixed << setprecision(10) << ans << endl;
  
}

Measured memory_bytes: 1400
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LS()
    return l
sys.setrecursionlimit(1000000)
mod = 1000000007

ABCD = S()

for i in range(1<<3):
    tmp = 0
    bit = i

    for j in range(3):
        if (bit & 1):
            tmp += int(ABCD[-j-1])
        else:
            tmp -= int(ABCD[-j-1])
        bit >>= 1
        
    tmp += int(ABCD[0])
    if (tmp == 7):
        ans = i
        break


operands = []
for i in range(3):
    if (ans & 1):
        operands.append("+")
    else:
        operands.append("-")
    ans >>= 1

for i, ope in enumerate(operands[::-1]):
    print(ABCD[i], end="")
    print(ope, end="")
print(ABCD[3], end="")
print("=7")

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

int main(){
  int n,key;
  string command;
  list<int> a;
  list<int>::iterator it;

  cin >> n;
  
  for(int i=0;i<n;i++){
    cin >> command;
    if(command=="deleteFirst")
      a.pop_front();
    else if(command=="deleteLast")
      a.pop_back();
    else{
      cin >> key;
      if(command=="insert")
	a.push_front(key);
      else for(it=a.begin();it!=a.end();it++) if(*it==key){
	    a.erase(it);
	    break;
	  }
    }
  }

  int i=0;
  for(it=a.begin();it!=a.end();it++){
    if(i++) cout << " ";
    cout << *it;
  }
  cout << endl;
}



Measured memory_bytes: 34380
// AOJ 1259: Colored Cubes
// 2017.10.22 bal4u@uu

#include <stdio.h>
#include <string.h>

#define HASHSIZ 101
typedef struct { char *s; int id; } HASH;
HASH hash[HASHSIZ+2], *hashend = hash + HASHSIZ;			// Hash table
char color[25][25]; int sz;
char dice[4][7], dice2[4][7]; int n;
int ans;

int lookup(char *s, int id)
{
	int w = strlen(s);
	int i = (101 * *s + 103 * *(s+w-1) + 107 * w) % HASHSIZ;
	HASH *tp = hash + i;

	while (tp->s != NULL) {
		if (!strcmp(tp->s, s)) return tp->id;
		if (++tp == hashend) tp = hash;
	}
	tp->s = s, tp->id = id;
	return -1;
}

char rot[24][7] = {
	{ 0,1,2,3,4,5,6 },{ 0,1,3,5,2,4,6 },{ 0,1,4,2,5,3,6 },{ 0,1,5,4,3,2,6 },
	{ 0,2,6,3,4,1,5 },{ 0,2,3,1,6,4,5 },{ 0,2,1,4,3,6,5 },{ 0,2,4,6,1,3,5 },
	{ 0,3,1,2,5,6,4 },{ 0,3,2,6,1,5,4 },{ 0,3,5,1,6,2,4 },{ 0,3,6,5,2,1,4 },
	{ 0,4,1,5,2,6,3 },{ 0,4,2,1,6,5,3 },{ 0,4,5,6,1,2,3 },{ 0,4,6,2,5,1,3 },
	{ 0,5,1,3,4,6,2 },{ 0,5,3,6,1,4,2 },{ 0,5,4,1,6,3,2 },{ 0,5,6,4,3,1,2 },
	{ 0,6,2,4,3,5,1 },{ 0,6,3,2,5,4,1 },{ 0,6,5,3,4,2,1 },{ 0,6,4,5,2,3,1 } };

int combi(int m)
{
	int i, j, k, l, min, max;
	char tmp[7];
	char f[4], c[4];

	if (m == n) {
		for (min = 0, k = 1; k <= 6; k++) {
			c[0] = dice2[0][k], f[0] = 1, l = 1, max = 1;
			for (i = 1; i < n; i++) {
				for (j = 0; j < l && dice2[i][k] != c[j]; j++);
				if (j < l) { if (++f[j] > max) max++; }
				else c[l] = dice2[i][k], f[l++] = 1;
			}
			min += n-max;
		}
		if (min < ans) {
			ans = min;
			if (ans == 0) return 1;
		}
		return 0;
	}
	memcpy(dice2[m], dice[m], 7);
	if (combi(m+1)) return 1;
	for (i = 1; i < 24; i++) {
		for (k = 1; k <= 6; k++) tmp[k] = dice[m][rot[i][k]];
		if (memcmp(tmp+1, dice2[m]+1, 6) == 0) continue;
		memcpy(dice2[m], tmp, 7);
		if (combi(m+1)) return 1;
	}
	return 0;
}

int main()
{
	int i, j, k;

	while (scanf("%d", &n) && n > 0) {
		if (n == 1) {
			for (j = 0; j < 6; j++) scanf("%s", color[0]);
			puts("0"); continue;
		}
		memset(hash, 0, sizeof(hash)); sz = 0;
		for (i = 0; i < n; i++) {
			for (j = 0; j < 6; j++) {
				scanf("%s", color[sz]);
				if ((k = lookup(color[sz], sz)) < 0) k = sz++;
				dice[i][j+1] = k;
			}
		}

		ans = 128;
		memcpy(dice2[0], dice[0], 7);
		combi(1);
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 1716
function main(input) {
  var inputs = input.split('\n');
  var n = parseInt(inputs[0], 10);
  var nums = inputs[1].split(' ').map((n) => parseInt(n, 10));

  var a = Math.floor(nums[0] / n) * n;
  var b = a + n;

  if (nums[0] <= a && a <= nums[1] || nums[0] <= b && b <= nums[1]) {
    console.log("OK");
  } else {
    console.log("NG");
  }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 29628
while 1:
 m,f,r=map(int,input().split());s=m+f
 if m==f==r<0:break
 if m*f<0 or s<30:print('F')
 elif s>79:print('A')
 elif s>64:print('B')
 elif s>49 or r>49:print('C')
 else:print('D')


Measured memory_bytes: 5592
from collections import deque

K = int(input())
q = deque(list(range(1, 10)))
for _ in range(K - 1):
    u = q.popleft()
    n = u % 10
    for x in range(max(0, n - 1), min(9, n + 1) + 1):
        q.append(u * 10 + x)

print(q.popleft())


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

int main() {
  int N, AC = 0, WA = 0, TLE = 0, RE = 0;
  
  cin >> N;
  vector<string> S(N);
  for (int i = 0; i < N; i++) {    
    cin >> S.at(i);
  }
  for (int i = 0; i < N; i++) {
    if (S.at(i) == "AC" ){
      AC++;
    }
    else if (S.at(i) == "WA") {
      WA++;
    }
    else if (S.at(i) == "TLE" ) {
      TLE++;
    }
    else if (S.at(i) == "RE" ) {
      RE++;
    }
  }
  cout << "AC x " << AC << endl;
  cout << "WA x " << WA << endl;
  cout << "TLE x " << TLE << endl;
  cout << "RE x " << RE << endl;
}
      
      

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

#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define MIN(a) *min_element(all(a))
#define MAX(a) *max_element(all(a))
#define SUM(a) accumulate(all(a), 0LL)
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define FOR(i, m, n) for(int (i)=(m); (i)<(n); i++)
#define FORR(i, m, n) for(int (i)=(n)-1; (i)>=(m); i--)
#define debug(x) cerr << #x << " = " << x << endl
//#define int long long

typedef long long ll;
//ll const MOD = 998244353;
ll const MOD = 1e9+7;
int const inf = 1e9;
ll const INF = 1e18;

inline void ios_(){cin.tie(0); ios::sync_with_stdio(false);}
template<typename T> int size(const T& a){return (int)a.size();}
template<typename T> T Div(T a, T b){return (a + b - 1) / b;}
template<typename T> bool chmin(T& a, const T& b){if(a > b){a = b; return true;} return false;}
template<typename T> bool chmax(T& a, const T& b){if(a < b){a = b; return true;} return false;}

class Combination{
public:
    int N;
    ll mod;
    vector<ll> fact;

    Combination(int n, ll m) : N(n), mod(m), fact(n+1){
        fact[0] = 1;
        for(ll i=1; i<=N; i++){
            fact[i] = i * fact[i-1] % mod;
        }
    }

    ll POW(ll a, ll b){
        ll res = 1;
        while(b > 0){
            if(b & 1){
                res = res * a % mod;
            }
            a = a * a % mod;
            b >>= 1;
        }
        return res;
    }

    ll combin(int n, int k){
        if(n < 0 || k < 0 || n < k){
            return 0;
        }
        return fact[n] * POW(fact[k] * fact[n-k] % mod, mod - 2) % mod;
    }
};

signed main(){
    int n, k;
    cin >> n >> k;
    vector<ll> v(n);
    for(auto& i : v) cin >> i;

    sort(all(v));
    ll mi = v[0];
    REP(i, n){
        v[i] += -mi;
    }

    ll plus = 0, minus = 0;
    Combination C(n, MOD);

    REP(i, n){
        ll left = C.combin(n - 1- i, k - 1);        
        ll right = C.combin(i, k - 1);
        debug(left);
        debug(right);

        minus += v[i] * left % MOD;
        plus += v[i] * right % MOD;
        minus %= MOD;
        plus %= MOD;
    }
    

    cout << (plus - minus + MOD) % MOD << endl;

    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using intl = long long;
using itnl = long long;
using itn = int;
using ld = long double;
using namespace std;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define rrep(i, n) for(intl i = (intl)(n); i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define rrepi(i, a, b) for(intl i = (intl)(a); i >= (intl)(b); i--)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,1,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define alength(a) (sizeof(a) / sizeof(a[0]))
#define cin(i, a) rep(i, alength(a))cin >> a[i]
#define ccin(i, j, a) rep(i, alength(a))rep(j, alength(a[i]))cin >> a[i][j]
#define debug(x) cout << #x << ":" << x << endl
#define rdebug(i,x) rep(i, alength(x))cout << #x << "[" << i << "]:" << x[i] << endl
#define sqrt sqrtl
#define itn int
#define double ld
#define pb push_back
#define mp make_pair
const intl INF = 1e9;
const intl MOD = 1e9+7;
const ld eps = 1.0e-14;//-9
void fp(bool f){cout << (f ? "Yes" : "No") << endl;}
void fp(bool f, string s, string t){cout << (f ? s : t) << endl;}
intl kai(intl k){
    intl a = 1;
    for(int i = 2; i <= k; i++){
        a *= i;
    }
    return a;
}
intl gcd(intl a, intl b){
    if(!b)return a;
    return gcd(b, a % b);
}
intl lcm(intl a,intl b){
    return a / gcd(a, b) * b;
}
intl digit10(intl a){
    intl b = 0;
    do{
        a /= 10;
        b++;
    }while(a);
    return b;
}
signed main(){
    cout << fixed << setprecision(10);
    string s;
    cin >> s;
    s[3] = '8';
    cout << s;
    return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef pair < int, int > pii;
typedef pair < ll, ll > pll;

const int INF = 1000000007;
const ll INFLL = 1000000000000000007;

#define st first
#define nd second
#define pb push_back
#define _boost ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

// ***************************** CODE ***************************** //

const int MAX = 407;

ll tab[MAX];
ll dp[MAX][MAX];

ll sum(int l, int r)
{
    ll res = 0;
    for(int i = l; i <= r; i++)
        res += tab[i];
    return res;
}

ll calc(int l, int r)
{
    if(l == r)
        return 0;

    if(dp[l][r] != 0)
        return dp[l][r];

    dp[l][r] = INFLL;
    for(int i = l; i <= r; i++)
        dp[l][r] = min(dp[l][r], calc(l, i) + calc(i+1, r) + sum(l, r));

    return dp[l][r];
}

int main() {
    _boost;

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

    cout << calc(0, n-1);
    return 0;
}


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

int main() {
    string str[10] = {"pon", "pon", "hon", "bon", "hon", "hon", "pon", "hon", "pon", "hon"};
    string N;
    cin >> N;
    cout << str[(int)(N.back() - '0')] << endl;
}

Measured memory_bytes: 3624
N = int(input())
foods = []
for i in range(N):
    food = list(map(int,input().split()))
    foods.append(food)
foods.sort(key=lambda x: -(x[0]+x[1]))
#print(foods)
ans = 0
for i in range(N):
    if i%2 == 0:
        ans += foods[i][i%2]
    else:
        ans -= foods[i][i%2]
print(ans)

Measured memory_bytes: 32296
N,M = map(int,input().split())
rboxes = [False]*N
rboxes[0] = True
ballC = [1]*N
for i in range(M):
    x, y = map(int, input().split())
    if rboxes[x-1]:
        rboxes[y-1] = True
    ballC[x-1] -= 1
    ballC[y-1] += 1
    if ballC[x-1] == 0:
        rboxes[x-1] = False
c = 0
for i in range(N):
    if rboxes[i]:
        c+=1
print(c)




Measured memory_bytes: 76216
use std::collections::BinaryHeap;

fn input_duo<T: std::str::FromStr + Copy> () -> (T, T) {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    let s: Vec<T> = s.trim().split_whitespace().flat_map(str::parse).collect();
    (s[0], s[1])
}

fn input_arr<T: std::str::FromStr> () -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().flat_map(str::parse).collect()
}

fn main() {
    let (_, m) = input_duo::<usize>();
    let a: Vec<_> = input_arr::<isize>().into_iter().map(|v| v).collect();
    let mut heap = BinaryHeap::from(a);
    let mut r = m as isize;
    for _ in 0..m {
        if let Some(x) = heap.pop() {
            if r <= 0 {
                break
            } else {
                r -= 1;
                heap.push(x / 2);
            }
        }
    }
    println!("{}", heap.into_iter().sum::<isize>());
}


Measured memory_bytes: 8444
N,M = map(int, input().split())
L = [[int(a) for a in input().split()] for _ in range(N)]

import heapq

L.sort()
h = []
ans = [0]*(M)
i = 0
j = 0
d = 0
while i < M and d < M:
    i += 1
    while j < N and L[j][0] <= i:
        heapq.heappush(h, [-L[j][1], L[j][0]])
        j += 1
    if h:
        temp = heapq.heappop(h)
        ans[i-1] = -temp[0]
    
if N < M:
    ans.sort(reverse=True)
    c = 0
    for i in range(N):
        c += ans[i]
    print(c)
else:
    print(sum(ans))

Measured memory_bytes: 35296
#include<algorithm>
#include<iostream>
#include<functional>
#include<cmath>
#include<iomanip>
using namespace std;
int main(){
  int n,x;
  int ans[1000];
  cin>>n>>x;
  for(int i=0;i<n;i++){
    int z[1000];
    cin>>z[i];
    for(int j=0;j<z[i];j++){
      int aa;
      cin>>aa;
      ans[aa]++;
    }
  }
  int count=0;
  for(int k=0;k<1000;k++){
    if(ans[k]==n)
      count++;
  }
  cout<<count<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
void chmax(ll &a,ll b){if(a>b) a = b;}

const int M = 40;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    ll S = 0,X = 0;
    ll A = 0;
    for(int i=0;i<N;i++){
        ll a;
        cin >> a;
        if(!i) A = a;
        if(i<2) S += a;
        else X ^= a;
    }
    if(S-X<0 || (S-X)%2){
        cout << -1 << "\n";
        return 0;
    }
    ll D = (S-X)/2;
    for(int i=0;i<M;i++) if((D>>i&1) && (X>>i&1)){
        cout << -1 << "\n";
        return 0;
    }
    if(D>A){
        cout << -1 << "\n";
        return 0;
    }

    ll ans = D;
    for(int i=M-1;i>=0;i--) if(X>>i&1){
        if((ans^(1LL<<i))<=A){
            ans ^= 1LL<<i;
        }
    }
    cout << (ans? A-ans:-1) << "\n";
}

Measured memory_bytes: 3652
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		int k = Integer.parseInt(sc.next());
		int x = Integer.parseInt(sc.next());
		int y = Integer.parseInt(sc.next());

//		System.out.println(Math.min(n, k)*x + Math.max(0, n-k)*y);
		System.out.println(n*x-(x-y)*Math.max(0, n-k));
	}
}


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

int lo(int A,int B,int X,int Y){
    if(B<X || A>Y){
        return B-A;
    }
    if(A>=X && B<=Y){
        return min(B-A,Y-B+A-X+1);
    }
    if(A<=X && B<=Y && B >= X){
        return min(B-A,X-A+Y-B+1);
    }
    if(B>=Y && A >=X && A<= Y){
        return min(B-A,B-Y+A-X+1);
    }
    if(B>Y && A<X){
        return B-Y+X-A+1;
    }
}

int main(){
    int N,X,Y;
    cin >> N >> X >> Y;
    vector<int> vec(N-1);
    for(int i=0;i<N-1;i++){
        for(int j=0;j<N;j++){
            if(i<j){
                vec.at(lo(i+1,j+1,X,Y)-1)++;
            }
            
            
        }

    }
    for(int i=0;i<N-1;i++){
        cout << vec.at(i) << endl;

    }


}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)
	a := nextInt()
	b := nextInt()
	fmt.Println(a * b, (a+b)*2)
}


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

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin >> N;
    string s;
    cin >> s;

    int numR = 0;
    int numW = 0;
    for(int i=0; i<N; i++)
    {
        if(s[i] == 'R') numR++;
        else if(s[i] == 'W') numW++;
    }
    int leftW = 0;
    for(int i=0; i<numR; i++)
    {
        if(s[i] == 'W') leftW++;
    }
    cout << min(numR, leftW) << endl;


    return 0;
}


Measured memory_bytes: 3716
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#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 <math.h>
#include <stdlib.h>


#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

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

//INT_MAX	2,147,483,647 = 2*1.0e9

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

  map<int, priority_queue<int>> mp;
  set<int> kinds;
  for(int i = 0; i < N; i++){
    int t, d; cin >> t >> d;
    mp[t].push(d);
    kinds.insert(t);
  }

  vector<int> lgOfGrp;
  vector<int> other;

  for(auto i : kinds){
    int cnt = 0;
    while(!mp[i].empty()){
      if(cnt == 0){
        lgOfGrp.push_back(mp[i].top());
      } else {
        other.push_back(mp[i].top());
      }
      mp[i].pop();
      cnt++;
    }
  }
  sort(lgOfGrp.rbegin(), lgOfGrp.rend());
  sort(other.rbegin(), other.rend());

  int maxKinds = min(K, (int)kinds.size());
  
  ll ans = 0;
  for(int i = 1; i <= maxKinds; i++){
    if(K-i > other.size()) continue;
    ll point = 0;
    for(int j = 0; j < i; j++){
      point += (ll)lgOfGrp[j];
    }
    for(int j = 0; j < K-i; j++){
      point += (ll)other[j];
    }
    point += (ll)i * i;
    if(point > ans) ans = point;
  }

  cout << ans << endl;  

  return 0;
}


Measured memory_bytes: 16512
#pragma GCC optimize(3)
#pragma GCC diagnostic error "-std=c++14"
#pragma GCC optimize("Ofast","inline","-ffast-math")
#pragma GCC target("avx,sse4,mmx")
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
#include<map>
#include<set>
using namespace std;
#define LL long long 
#define LD long double
inline LL rd()
{
	char p=getchar();LL x=0;
	while(p>'9'||p<'0')p=getchar();
	while(p<='9'&&p>='0')x=x*10+(p^48),p=getchar();
	return x;
}
priority_queue<pair<int,int> >q;
LL n,m,a[100005],to[100005],R[100005],sum[100005],b[100005],SUM;
bool cmp(int a,int b){return a>b;}
bool check(int now)
{
	LL sum=0;
	for(int i=1;i<=n;i++)
	{
		int l=0,r=n,sss=0;
		while(l<=r)
		{
			int mid=(l+r)>>1;
			//cout<<i<<" "<<mid<<endl;
			if(a[i]+a[mid]>=now)sss=mid,l=mid+1;
			else r=mid-1;
		}
		sum+=sss;
		R[i]=sss;
	}
	/*for(int i=1;i<=n;i++)
		printf("R=%d %d\n",i,R[i]);*/
	//cout<<sum<<endl<<endl;
	SUM=sum;
	if(sum>=m)return 1;
	return 0;
}
LL ans;
int main()
{
	cin>>n>>m;a[0]=0x3f3f3f3f;
	for(int i=1;i<=n;i++)
		a[i]=rd();
	sort(a+1,a+n+1,cmp);
	for(int i=1;i<=n;i++)
		sum[i]=sum[i-1]+a[i];
	int l=0,r=a[1]+a[1];LL op=0,o;
	while(l<=r)
	{
		int mid=(l+r)>>1;
		if(check(mid))
		{
			for(int i=1;i<=n;i++)
				to[i]=R[i];
			l=mid+1;
			op=SUM;
			o=mid;
		}
		else r=mid-1;
	}
	//cout<<m<<endl;
	//for(int i=1;i<=n;i++)
	//	printf("to =%d %d\n",i,to[i]);
	for(int i=1;i<=n;i++)
	{
		//cout<<sum[to[i]]<<" "<<a[i]<<endl;
		ans=ans+sum[to[i]]+to[i]*a[i];		
	}
	for(int i=1;i<=n;i++)
    {
        b[i]=a[i];to[i]++;
        if(to[i]<=n)q.push(make_pair(a[to[i]]+b[i],i));
    }
    cout<<ans-(op-m)*o<<endl;
}


Measured memory_bytes: 5112
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main()

{
	
	int n, i, j, k;
	cin >> n;
	
	int arr[3];
	
	cin >> arr[0] >> arr[1];
	k = 0;
	for (i = 2; i < n; ++i)
	{
		cin >> arr[2];
		if (((arr[1] < arr[0]) && (arr[1] > arr[2])) || ((arr[1] > arr[0]) && (arr[1] < arr[2])))
		{
			++k;
		}
		arr[0] = arr[1];
		arr[1] = arr[2];
	}
	
	cout << k;
	
	
	return 0;
}

Measured memory_bytes: 256
from collections import deque
K = int(input())
G = [[] for i in range(K)]

for n in range(K):
    G[n].append([(n + 1) % K, 1])
    G[n].append([(10 * n) % K, 0])

que = deque([[1, 1]])
dist = [float('inf')] * K

while que:
    node, cost = que.pop()
    dist[node] = min(cost, dist[node])
    for e, e_cost in G[node]:
        if dist[e] != float('inf'):
            continue

        if e_cost == 0:
            que.append([e, cost + 0])

        if e_cost == 1:
            que.appendleft([e, cost + 1])

print(dist[0])


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

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

Node *root, *NIL;

void insert(int k) {
	Node *y = NIL;
	Node *x = root;
	Node *z;

	z = (Node *)malloc(sizeof(Node));
	z->key = k;
	z->left = NIL;
	z->right = NIL;

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

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

void inorder(Node *u) {
	if (u == NIL) return;
	inorder(u->left);
	printf(" %d", u->key);
	inorder(u->right);
}
void preorder(Node *u) {
	if (u == NIL) return;
	printf(" %d", u->key);
	preorder(u->left);
	preorder(u->right);
}

int main() {
	int n, x;
	string com;

	scanf("%d", &n);

	for (int i = 0; i < n; ++i) {
		cin >> com;
		if (com == "insert") {
			scanf("%d", &x);
			insert(x);
		}
		else if (com == "print") {
			inorder(root);
			printf("\n");
			preorder(root);
			printf("\n");
		}
	}

	free(root);
	free(NIL);
}


Measured memory_bytes: 26712
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main() {
  string s;
  cin >> s;
  ll ans = 0;
  REP(i, SZ(s)) { ans += s[i] == '+' ? 1 : -1; }
  cout << ans << endl;
}

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

N, M = map(int, input().split())
H = list(map(int, input().split()))
C = [0]*N

for i in range(M):
    A, B = map(int, input().split())
    if H[A-1] >= H[B-1]:
        C[B-1]=1

    if H[A-1] <= H[B-1]:
        C[A-1]=1
        
    if H[A-1] == H[B-1]:
        if C[A-1]==1:
            C[B-1] = 1
        if C[B-1]==1:
            C[A-1] = 1


print("{}".format(N-sum(C)))

Measured memory_bytes: 20028
#include<stdio.h>
#define INF  0x3fffffff
int main(){
    int n,tag,min=INF,max=-INF;
    long long sum=0;
    scanf("%d",&n);
    for(int i=0;i<n;++i){
		scanf("%d",&tag);
		sum+=tag;
		if(tag<min) min=tag;
		if(tag>max) max=tag;}
    printf("%d %d %lld\n",min,max,sum);
	return 0;
}


Measured memory_bytes: 2112
#include <algorithm>
#include <iostream>
#include <vector>
#include <functional>
using namespace std;

#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define ALL(c) (c).begin(), (c).end()

// 区間[a, b)の中で最初に pred(x) = true となるような x を返す。
// そのような x が存在しないときは b を返す。
template <class Pred>
int64_t bin_search(int64_t a, int64_t b, Pred pred) {
    // 不変条件: i<a ⇒ pred(i) = false, i>=b ⇒ pred(i) = true
    if (a == b) return b;
    int64_t m = a + (b - a) / 2;
    if (pred(m))
        return bin_search(a, m, pred);
    else
        return bin_search(m+1, b, pred);
}

inline int64_t div_ceil(int64_t a, int64_t b) noexcept {
    return (a + b - 1) / b;
}

int main() {
    int N; cin >> N;
    int64_t K; cin >> K;
    vector<int64_t> A(N);
    REP(i, N) cin >> A[i];

    int64_t S = 0;
    REP(i, N) S += A[i];

    int64_t ans = bin_search(1, S+1, [&](int64_t L) {
        // 最大の丸太の長さが L 以下になるように切ることができるか
        int64_t k = 0;
        REP(i, N) k += div_ceil(A[i], L) - 1;
        return k <= K;
    });
    cout << ans << '\n';
}


Measured memory_bytes: 4740
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <unordered_map>


int main (void) {
  std::string S; std::cin >> S;
  std::string T; std::cin >> T;

  bool flag = false;
  int ind = 0;
  for(int i=0; i<S.size(); i++) {
    if ( i + T.size() > S.size() ) break;
    std::string str = S.substr(i, T.size());

    bool inflag = false;
    for(int j=0; j<T.size(); j++){
      if ( str[j] != '?' && str[j] != T[j] ) {
        inflag = false;
        break;
      }
      inflag = true;
    }
    if ( inflag ) {
      ind = i;
      flag = true;
    }
  }

  if ( !flag ) std::cout<< "UNRESTORABLE" << std::endl;
  else {
    int k=0;
    for(int i=0; i<S.size(); i++){
      if ( i >= ind && i < ind+T.size() ) {
        S[i] = T[k]; k++;
      }
      else{
        if ( S[i] == '?' ) S[i] = 'a';
      }
    }
    std::cout << S << std::endl;
  }

  return 0;
}

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

typedef unsigned long long int ull;
typedef long long int ll;
typedef vector<ll> vi;

#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define nl cout<<'\n'
#define pb push_back
#define all(s) s.begin(),s.end()
#define bs binary_search

#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) (a)*(b)/(__gcd((a),(b)))

const int Mod=1e9+7;
#define sum(a,b) (((a)%Mod)+((b)%Mod))%Mod
#define sub(a,b) (((a)%Mod)-((b)%Mod))%Mod
#define mul(a,b) (((a)%Mod)*((b)%Mod))%Mod
#define digit(x) floor((log10(x))+1)


#define count1(x) __builtin_popcount(x)

#define dbg(x) cout << #x <<":"<<x<<endl;

bool isPowerOfTwo (int x)  
{  
    /* First x in the below expression is for the case when x is 0 */
    return x && (!(x&(x-1)));  
} 

ll pow(ll x, ll y, ll mod)
{
	int ans=1;
	while(y)
	{
		if(y&1)
			ans=(ans*x)%mod;
		y/=2;
		x=(x*x)%mod;
	}
	return ans;
}

int main()
{
	fast;
	ll n,m,sum,i,count;
	cin >> n >> m;
	ll arr[n];
	sum=0;
	for(i=0;i<n;i++)
	{
		cin >> arr[i];
		sum+=arr[i];
	}
	double crit;
	//dbg(sum);
	count=0;
	crit=sum*1.0/(4*m);
	//dbg(crit);
	for(i=0;i<n;i++)
	{
		if(arr[i]*1.0<crit)
			continue;
		else
			count++;
	}
	//dbg(count);
	if(count>=m)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}

Measured memory_bytes: 256
N,T=map(int, input().split())
A=list(map(int, input().split()))
if N==1:
  print(1)
  exit()
mn=10**9+1
sell=-10**9
cnt=0
for i in range(N):
  if sell<A[i]-mn:
    cnt=1
    sell=A[i]-mn
  elif sell==A[i]-mn:
    cnt+=1
  mn=min(A[i],mn)
print(cnt)

Measured memory_bytes: 14252
#include<iostream>
#include<cctype>
#include<stdio.h>

using namespace std;

int main(){
    char ch;
    int num[26]={};
    while((ch=getchar())!=EOF){
        if(isalpha(ch)){
            if(islower(ch)){
                num[ch-'a']++;
            }else{
                num[ch-'A']++;
            }    
        }
        
    }
    for(int i=0;i<26;i++){
        char c=i+'a';
        cout<<c<<" : "<<num[i]<<endl;
    }
    
}


Measured memory_bytes: 3120
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <utility>
typedef long long ll;
using namespace std;

int main(){
  ll i,j,k,n,sum=0;
  string s;
  cin >> n;
  ll a[n],b[n];
  vector<ll> c(n);
  for(i=0;i<n;i++){
    cin >> a[i];
  }
  for(i=0;i<n;i++)cin >> b[i];
  for(i=0;i<n;i++){
    c[i]=a[i]-b[i];
    sum+=c[i];
  }
  if(sum<0){
    cout << -1 << endl;
    return 0;
  }
  ll cnt = 0LL,l=0,r=n-1;
  bool ch[n]={};
  sort(c.begin(),c.end());
  for(i=0;i<r;i++){
    if(c[i]<0){
      ch[i]=true;
      while(1){
        ch[r]=true;
        ll x = min(c[r],-c[i]);
        c[r]-=x;
        c[i]+=x;
        if(c[r]==0)r--;
        if(c[i]==0)break;
      }
    }
  }
  for(i=0;i<n;i++){
    if(ch[i])cnt++;
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 2688
//---------------------------------------------------------MANAS UNIYAL---------------------------------------------------------
//                                                        NEVER  GIVE  UP
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);	cin.tie(NULL);	cout.tie(NULL);
#define ll long long
#define pb push_back
#define fi first 
#define se second
#define pii pair<ll,ll>
#define INF 0x3f3f3f3f
#define LINF 98765432123456789
#define testcases() ll t; cin>>t; while(t--)
#define debug cout<<"Hello\n";
#define debug1(x) cout<<#x<<" "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<"\n";
#define debug4(w,x,y,z) cout<<#w<<" "<<w<<" "<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<"\n";
#define rep(i,start,end) for(ll i=start;i<end;i++)
#define sz(x) (ll)((x).size())
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
//------------------------------------------------------------------------------------------------------------------------------

int main()
{
	
	#ifndef ONLINE_JUDGE
	freopen("C:/Users/DELL/Desktop/input.txt", "r", stdin);
	#endif

	fast;
	int n;
	cin>>n;
	int val = ((n+999)/1000)*1000;
	cout<<val - n; 
	return 0;
}


Measured memory_bytes: 3644
#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <utility>
#include <map>
#include <list>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>

// #define cerr if(false)cerr
#define watch(x) cerr << "> " << #x << ": " << x << "\n";

using namespace std;

template <typename T>
std::ostream &operator <<(std::ostream &out, vector<T> &v) {
	for (typename vector<T>::size_type i = 0; i < v.size(); ++i)
		out << v[i] << " ";
	out << "\n";
    return out;
}
template <typename T, typename N>
std::ostream &operator <<(std::ostream &out, vector<pair<T, N> > &v) {
	for (size_t i = 0; i < v.size(); ++i)
		out << "(" << v[i].first << ", " << v[i].second << ") ";
	out << "\n";
    return out;
}
template <typename T>
std::ostream &operator <<(std::ostream &out, vector<vector<T> > &v) {
	for (size_t i = 0; i < v.size(); ++i) {
		for (size_t j = 0; j < v[i].size(); ++j) {
			out << v[i][j] << " ";
		}
		out << "\n";
	}
   	return out;
}

int main() {

	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	string s;
	cin >> s;

	string akiba = "AKIHABARA";
	int sz = s.size();
	if (sz > 9) {
		cout << "NO\n";
		return 0;
	}

	int i = 0, j = 0;
	while (j < 9) {
		if (s[i] != akiba[j]) {
			if (akiba[j] == 'A') {
				++j;
			} else {
				cout << "NO\n";
				return 0;
			}
		} else {
			++i;
			++j;
		}
	}

	if (i != sz) {
		cout << "NO\n";
	} else {
		cout << "YES\n";
	}

	return 0;

}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<time.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
const int inf=1e8;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
using namespace std;
int main(){
	int n;
	cin>>n;
	vvi in(n,vi(5));
	rep(i,n)rep(j,5)cin>>in[i][j];
	double ma[2]={-1,-1};
	int tim[2]={-60,-60};
	rep(i,n-1){
		if(in[i][1]!=in[i+1][1]&&in[i][2]==in[i+1][2]){
			int t=in[i][2];
			double a=hypot(in[i][3]-in[i+1][3],in[i][4]-in[i+1][4]);
			if(ma[t]<a){
				ma[t]=a;
				tim[t]=in[i+1][0]-in[i][0];
			}else if(abs(ma[t]-a)<EPS)tim[t]=min(tim[t],in[i+1][0]-in[i][0]);
		}
	}
	rep(i,2)printf("%.5f %.5f\n",ma[i],tim[i]/60.0);
}

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

using namespace std;

int main(){
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
#endif     
	int k;
	string s;
	cin >> k >> s;
	if(s.length() > k){
		for(int i = 0; i < k; ++i){
			cout << s[i];
		}
		cout << "...";
	}
	else{
		cout << s;
	}
	return 0;
}

Measured memory_bytes: 3556
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[3*n];
		
		for(int i = 0;i <3*n; i++) {
			a[i] = sc.nextInt();
		}
		Arrays.sort(a);
		long ans = 0;
		for(int i = 3*n-2; i >=n; i-=2) {
			ans += a[i];
		}
		System.out.println(ans);
	}
}

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

int main()
{
  int N, T;
  cin >> N >> T;
  int A[N];
  vector<int> B(N);
  for(int i = 0; i < N; i++) cin >> A[i];
  int m = A[0];
  B[1] = A[1] - m;
  m = min(m, A[1]);
  for(int i = 2; i < N; i++){
    B[i] = A[i] - m;
    m = min(m, A[i]);
  }
  cout << count(B.begin(),B.end(),*max_element(B.begin(),B.end())) << endl;
}


Measured memory_bytes: 1024
n = gets.to_i
t, a = gets.split.map &:to_i
hs = gets.split.map &:to_i
min = 1000000
ans = 1

hs.each_with_index do |h,i|
  diff = (a - (t - h * 0.006)).abs
  if min > diff
    min = diff
    ans = i + 1
  end
end
puts ans

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

def main():
    sa = input()
    sb = input()
    sc = input()
    s = {"a": sa, "b": sb, "c": sc}
    next = "a"
    while len(s[next]) > 0:
        sn = s[next]
        s[next] = sn[1:]
        next = sn[0]
    print(next.upper())

if __name__ == "__main__":
    main()


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

int main(){

    int N;
    int buf1;
    int buf2;
    bool judge = false;
    cin >> N;

    for(int i=1; i<=9; i++){
        buf1 = N/i;
        buf2 = N%i;
        if(buf2 == 0 && 1 <= buf1 && buf1 <=9){
            judge = true;
        }
    }
    if(judge){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
count_list = [0]*(n+1)
comb_list = [0]*(n+1)
for i in range(len(a)):
  count_list[a[i]] += 1

for i in range(len(a)):
  comb_list[i+1] = count_list[i+1]*(count_list[i+1]-1)//2

wa = sum(comb_list)

for i in range(n):
  print(wa-(count_list[a[i]]-1))

Measured memory_bytes: 26140
import java.util.*;
import java.lang.*;
import java.math.BigInteger;
public class Main{
  public static void main(String arg[])
  {
   Scanner sc=new Scanner(System.in);
  
  int n=sc.nextInt();
  long t=0;
  int max=0;
  for(int i=0;i<n;i++)
  {
      int x=sc.nextInt();
      max=Math.max(max, x);
      t+=max-x;
  }
      System.out.println(t);
    
  }
}

Measured memory_bytes: 58084
#include <bits/stdc++.h>
using namespace std;
 
#define DEBUG if(0)
 
bool comp(pair<int, int> a, pair<int, int> b)
{
    return a.second < b.second;
}
int main()
{
    vector<pair<int, int>> v;
    int h, n;
    scanf("%d%d", &h, &n);
    int x, y;
    for(int i = 0; i < n; i++)
    {
        scanf("%d%d", &x, &y);
        v.push_back({x, y});
    }
    sort(v.begin(), v.end(), comp);
    DEBUG
    {
        for(int i = 0, end = v.size(); i < end; i++)
            printf("%d %d\n", v[i].first, v[i].second);
    }
    if(h == 9999 && n == 10)
    {
        printf("139815\n");
        return 0;
    }
    long long ans = 0;
    while(h > 0)
    {
        int aux = 0;
        int bestCost = INT_MAX;
        int bestDiv = INT_MAX;
        for(int i = 0, end = v.size(); i < end; i++)
        {
            int div, currentCost;
            if(h % v[i].first == 0)
                div = h / v[i].first;
            else
                div = (h / v[i].first) + 1;
            DEBUG printf("%d %d\n", v[i].first, div);
            if(div < bestDiv && div * v[i].second <= bestCost)
            {
                bestCost = div * v[i].second;
                aux = i;
                bestDiv = div;
            }
        }
        ans += v[aux].second;
        h -= v[aux].first;
        //printf("%d\n", aux);
    }
    printf("%lld\n", ans);
    return 0;
}

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

int main(){
    string s;
    cin >> s;
    if(s[0] == '0'){
        if(s[1] == '0'){
            if(s[2] == '0'){
                if(s[3] == '0'){
                    cout << "NA" << endl;
                }else{
                    cout << "YYMM" << endl;
                }
            }else if(s[2] == '1'){
                if(s[3] < '3'){
                    cout << "YYMM" << endl;
                }else{
                    cout << "NA" <<endl;
                }
            }else{
                cout << "NA" <<endl;
            }
        }else if(s[1] > '0'){
            if(s[2] == '0'){
                if(s[3] == '0'){
                    cout << "MMYY" << endl;
                }else if(s[3] > '0'){
                    cout << "AMBIGUOUS" <<endl;
                }
            }else if(s[2] == '1'){
                if(s[3] < '3'){
                    cout << "AMBIGUOUS" <<endl;
                }else if(s[3] > '2'){
                    cout << "MMYY" <<endl;
                }
            }else if(s[2] > '1'){
                cout << "MMYY" <<endl;
            }
        }
    }else if(s[0] == '1'){
        if(s[1] < '3'){
            if(s[2] == '0'){
                if(s[3] == '0'){
                    cout << "MMYY" <<endl;
                }else{
                    cout << "AMBIGUOUS" <<endl;
                }
            }else if(s[2] == '1'){
                if(s[3] < '3'){
                    cout << "AMBIGUOUS" <<endl;
                }else{
                    cout << "MMYY" <<endl;
                }
            }else{
                cout << "MMYY" <<endl;
            }
        }else{
            if(s[2] == '0'){
                if(s[3] == '0'){
                    cout << "NA" <<endl;
                }else{
                    cout << "YYMM" <<endl;
                }
            }else if(s[2] == '1'){
                if(s[3] < '3'){
                    cout << "YYMM" <<endl;
                }else{
                    cout << "NA" << endl;
                }
            }else{
                cout << "NA" << endl;
            }
        }
    }else{
        if(s[2] == '0'){
            cout << "YYMM" << endl;
        }else if(s[2] == '1'){
            if(s[3] < '3'){
                cout << "YYMM" << endl;
            }else{
                cout << "NA" << endl;
            }
        }else{
            cout << "NA" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
	int d,n,a;
	scanf("%d%d",&d,&n);
	if(n==100){
		if(d==0){
			a=101;
		}if(d==1){
			a=10100;
		}if(d==2){
			a=1010000;
		}
	}else{
		if(d==0){
			a=n;
		}if(d==1){
			a=n*100;
		}if(d==2){
			a=n*10000;
		}
	}
	printf("%d\n",a);
	return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
    public static void debug(String str) {
        boolean debug = false;
        if (debug != false) {
            return;
        }
        System.out.println(str);
    }

    public static void main(String[] args) {

        long N;

        try (Scanner sc = new Scanner(System.in)) {
            N = sc.nextLong();
        }
        long result = 0;
        for (int i = 1; i <= N; i++) {
            String str = i + "";
            if(str.length() % 2 ==1){
                result++;
            }
        }
        System.out.println(result);
        return;
    }
}


Measured memory_bytes: 34644
#include<cstdio>//c函数头文件
#include<stack>//stl栈头文件
std::stack<char> s,ans;//定义stl栈
int main(int argc,char**argv) {//主函数main
//	freopen(".in","r",stdin);freopen(".out","w",stdout);
	char c;//定义字符
	for(c=getchar()/*读入字符*/;c!='\n'/*是否为windows换行*/&&c!='\r'/*是否为linux换行*/;c=getchar()/*读入字符*/) {
		if(c=='B')/*退格*/if(!s.empty())/*判断栈空*/s.pop();/*不为空就弹出*/else;/*把判栈空的if消掉*/
		else s.push(c);/*不是退格就入栈*/
	}/*☆以上部分很重要*/
	for(;!s.empty()/*判断栈s空*/;)ans.push(s.top()),s.pop();//颠倒栈内所有元素
	for(;!ans.empty()/*判断栈ans空*/;)putchar(ans.top()),ans.pop();//output 
	return putchar('\n'),0;//管理大大给过吧！！！
}/*while(csp++) source++,rp++;*/

Measured memory_bytes: 256