akhauriyash/Code-Regression huggingface dataset:
n, m = map(int, input().split())
ipy_pairs = [tuple(map(int, (("%d " % i) + input()).split())) for i in range(m)]
ipy_pairs.sort(key=(lambda ipy: ipy[1]))

ret = []
current_p_idx = 0
current_p = ipy_pairs[current_p_idx][1]
for idx in range(m):
    p = ipy_pairs[idx][1]
    if p != current_p:
        current_ipy_pairs = ipy_pairs[current_p_idx:idx]
        current_ipy_pairs.sort(key=lambda ipy: ipy[2])
        for _idx_, ipy in enumerate(current_ipy_pairs):
            ret.append((ipy[0], "%06d" % current_p + "%06d" % (_idx_+1)))
        current_p_idx = idx
        current_p = ipy_pairs[current_p_idx][1]
else:
    current_ipy_pairs = ipy_pairs[current_p_idx:]
    current_ipy_pairs.sort(key=lambda ipy: ipy[2])
    for _idx_, ipy in enumerate(current_ipy_pairs):
        ret.append((ipy[0], ("%06d" % current_p + "%06d" % (_idx_+1))))

ret.sort(key=lambda x: x[0])
for r in ret:
    print(r[1])


Measured memory_bytes: 36680
#include<bits/stdc++.h>
#define int long long
#define inf 100000000000
using namespace std;
int n,m,l,a,b,c,q,s,t;
int mapp[305][305];
int mappp[305][305];
inline int read()
{
	int x=0,f=1;
	char c=getchar();
	while(c>'9'||c<'0'){if(c=='-')f=-1;c=getchar();}
	while(c<='9'&&c>='0'){x=(x<<1)+(x<<3)+c-'0';c=getchar();}
	return x*f;
}
signed main()
{
	n=read(),m=read(),l=read();
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=n;j++)
		{
			if(i!=j)
			mapp[i][j]=inf;
		}
	}
	for(int i=1;i<=m;i++)
	{
		a=read(),b=read(),c=read();
		mapp[a][b]=mapp[b][a]=c;
	}
	for(int k=1;k<=n;k++)
	{
		for(int i=1;i<=n;i++)
		{
			for(int j=1;j<=n;j++)
			{
				mapp[i][j]=min(mapp[i][j],mapp[i][k]+mapp[k][j]);
			}
		}
	} 
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=n;j++)
		{
			if(mapp[i][j]<=l)
			{
				mappp[i][j]=1;
			}
			else
			{
				mappp[i][j]=inf;
			}
		}
	}
	for(int k=1;k<=n;k++)
	{
		for(int i=1;i<=n;i++)
		{
			for(int j=1;j<=n;j++)
			{
				mappp[i][j]=min(mappp[i][j],mappp[i][k]+mappp[k][j]);
			}
		}
	}
	q=read();
	while(q--)
	{
		s=read(),t=read();
		if(mappp[s][t]==inf)cout<<-1<<endl;
		else cout<<mappp[s][t]-1<<endl;
	}
}

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

//type
#define ll long long
typedef pair<int, int> P;
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007    //10^9+7:合同式の法
#define MAXR 100000       //10^5:配列の最大のrange
//略記
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first      //pairの一つ目の要素
#define S second     //pairの二つ目の要素
#define Z class
// OTHER
// xの二乗を返す (関数テンプレート版)
template <typename T>
T square(T x) { return x * x; }
template <class T>
T GCD(T a, T b)
{
    T r;
    while (a)
        r = b, b = a, a = r % a;
    return b;
}
template <class T>
T LCM(T a, T b) { return a / GCD(a, b) * b; }

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))
// loop
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repe(i, n) for (ll i = 0; i <= (n); i++)
#define repd(i, n) for (ll i = n; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= (b); i++)
#define FORD(i, a, b) for (ll i = a; i >= (b); i--)
#define FORA(i, I) for (const auto &i : I)

// vector
#define ALL(x) x.begin(), x.end()
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef vector<ll> vl;
#define ERASE(x) x.erase(unique(ALL(x)), x.end()); // erase same elements
#define VEC(type, c, n)     \
    std::vector<type> c(n); \
    for (auto &i : c)       \
        std::cin >> i;

// input
#define INIT                          \
    std::ios::sync_with_stdio(false); \
    std::cin.tie(0);
#define VAR(type, ...) \
    type __VA_ARGS__;  \
    MACRO_VAR_Scan(__VA_ARGS__);
template <typename T>
void MACRO_VAR_Scan(T &t)
{
    std::cin >> t;
}
template <typename First, typename... Rest>
void MACRO_VAR_Scan(First &first, Rest &... rest)
{
    std::cin >> first;
    MACRO_VAR_Scan(rest...);
}

// output
template <typename T>
void MACRO_OUT(const T t) { std::cout << t; }

#define OUT(...) MACRO_OUT(__VA_ARGS__);
#define SP std::cout << " ";
#define TAB std::cout << "\t";
#define BR std::cout << "\n";
#define ENDL std::cout << std::endl;

#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n", (x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define yes() printf("yes\n")
#define no() printf("no\n")
#define ln cout << '\n'
template <Z A>
void pr(A a)
{
    cout << a;
    ln;
}
template <Z A, Z B>
void pr(A a, B b)
{
    cout << a << ' ';
}

double ans = 0;
bool check = 0;
bool boo = 0;
string s, t;
int N = 3;
vector<int> v(N);
double a, b, c, d, n, m, k = 0;
int x = 0, y = 0;
int sum;
char ch;

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
// cout << (conditon ? (result:  == 1 ): (==0)) << endl; <- output result of if
// long long 型が表せる値の上限はおよそ 9 × 10＾18 です．
int main()
{
    INIT;

    cin >> n;
    rep(i, n)
    {
        cin >> a;
        sum += a;
        m = max(a, m);
    }
    if (sum - m > m)
        Yes();
    else
        No();
    return 0;
}


Measured memory_bytes: 3732
import sys
sys.setrecursionlimit(10**7)

class Node:
    def __init__(self,parent,left,right):
        self.parent = parent
        self.left = left
        self.right = right

def insert(T:dict,z:int):
    global root
    y = -1
    x = root
    while x != -1:
        y = x
        if z < x:
            x = T[x].left
        else:
            x = T[x].right
    T[z] = Node(y,-1,-1)
    
    if y == -1:
        root= z
    elif z < y:
        T[y].left = z
    else:
        T[y].right = z

def inorder(u:int):
    if u == -1:
        return 
    inorder(T[u].left)
    print(" "+str(u),end="")
    inorder(T[u].right)

def preorder(u:int):
    if u == -1:
        return 
    print(" "+str(u),end="")
    preorder(T[u].left)
    preorder(T[u].right)

n = int(input())
root = -1
T = {}
for _ in range(n):
    scan = input().split()
    if len(scan) == 1:
        inorder(root)
        print()
        preorder(root)
        print()
    else:
        insert(T,int(scan[-1]))


Measured memory_bytes: 125612
def isPrime(num)
  root = Math.sqrt(num).floor
  (2..root).each do |n|
    if num%n == 0
      return false
    end
  end
  true
end


x = gets.to_i
num = x
loop do
  #puts num
  if isPrime(num)
    puts num
    break
  else
    num += 1
  end
end



Measured memory_bytes: 1788
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>
#include <iomanip>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
#define all(v) (v).begin(), (v).end()
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
    int N;
    cin >> N;
    double p[N];
    rep(i, 0, N) cin >> p[i];

    double dp[N + 1][N + 1];
    dp[0][0] = 1.0;
    dp[1][0] = 1.0 - p[0];
    dp[1][1] = p[0];
    rep(i, 1, N) rep(j, 0, N + 1) {
        if(j - 1 >= 0) {
            dp[i + 1][j] = dp[i][j - 1] * p[i] + dp[i][j] * (1.0 - p[i]);
        } else {
            dp[i + 1][j] = dp[i][j] * (1.0 - p[i]);
        }
    }

    double rsl = 0.0;
    rep(j, N / 2 + 1, N + 1) {
        rsl += dp[N][j];
    }
    cout << setprecision(20) << rsl << endl;


}


Measured memory_bytes: 70528
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
using namespace std;
using ll = int64_t;
using vi = vector<int>;
using vvi = vector<vi>;

int main() {
    int h, w;
    cin >> h >> w;
    vector<string> s(h);
    rep(i, h) {
        cin >> s[i];
    }

    queue<pair<int, int> > Q;
    Q.push(make_pair(0, 0));
    vvi dp(h, vi(w, -1));
    dp[0][0] = 0;

    int dot=0;
    rep(i, h) {
        rep(j, w) {
            if(s[i][j] == '.') {
                dot++;
            }
        }
    }

    while(!Q.empty()) {
        int i = Q.front().first;
        int j = Q.front().second;
        Q.pop();

        if(i>0 && s[i-1][j]=='.' && dp[i-1][j] == -1) {
            dp[i-1][j] = dp[i][j] + 1;
            Q.push(make_pair(i-1, j));
        }
        if(j>0 && s[i][j-1]=='.' && dp[i][j-1] == -1) {
            dp[i][j-1] = dp[i][j] + 1;
            Q.push(make_pair(i, j-1));
        }
        if(i<h-1 && s[i+1][j]=='.' && dp[i+1][j] == -1) {
            dp[i+1][j] = dp[i][j] + 1;
            Q.push(make_pair(i+1, j));
        }
        if(j<w-1 && s[i][j+1]=='.' && dp[i][j+1] == -1) {
            dp[i][j+1] = dp[i][j] + 1;
            Q.push(make_pair(i, j+1));
        }
    }

    if(dp[h-1][w-1] == -1) {
        cout << -1 << endl;
        return 0;
    }

    cout << dot-dp[h-1][w-1]-1 << endl;
}

Measured memory_bytes: 256
#include <iostream>

#include <bits/stdc++.h>

using namespace std;

int main()

{
	int ar[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
	int k;
	cin>>k;
	cout<<ar[k-1]<<endl;
	
	return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include<bitset>
#include<iostream>
#include<cmath>
#include<sstream>
#include<string>
#include<vector>
using namespace std;

int main(){
    int N;
    int i;
    int result=0;
    cin>>N;
    if(N%2==0){
        cout<<N/2-1<<endl;
    }else{
        cout<<N/2<<endl;
    }
}

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

using ll = long long;
#define int long long

// [a -> b-1]
#define reps(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
// [0 -> a-1]
#define rep(i, a) reps(i, 0, (a))
// [a-1 -> b]
#define rreps(i, a, b) for (int i = (int)((a)-1); i >= (int)(b); i--)
// [a-1 -> 0]
#define rrep(i, a) rreps(i, a, 0)
#define all(v) (v).begin(), (v).end()
// next_permutation(all(v))
#define PERM(v) next_permutation(all(v))
/*sort(all(v));
 * (v).erase(unique(all(v)), v.end())*/
#define UNIQUE(v)\
	sort(all(v));\
	(v).erase(unique(all(v)), v.end())
#define MINV(v) min_element(all(v))
#define MAXV(v) max_element(all(v))
#define MIN3(a, b, c) min(min(a, b), c)
#define MIN4(a, b, c, d) min(MIN3(a, b, c), d)
#define MIN5(a, b, c, d, e) min(MIN4(a, b, c, d), e)
#define MIN6(a, b, c, d, e, f) min(MIN5(a, b, c, d, e), f)
#define MAX3(a, b, c) max(max(a, b), c)
#define MAX4(a, b, c, d) max(MAX3(a, b, c), d)
#define MAX5(a, b, c, d, e) max(MAX4(a, b, c, d), e)
#define MAX6(a, b, c, d, e, f) max(MAX5(a, b, c, d, e), f)
// b is [a, c)
#define RANGE(a, b, c) ((a) <= (b) && (b) < (c))
// c is [a, e) && d is [b, f)
#define RANGE2D(a, b, c, d, e, f) (RANGE((a), (c), (e)) && RANGE((b), (d), (f)))
#define chmin(a, b) a = min(a, (b))
#define chmin3(a, b, c) a = MIN3(a, (b), (c))
#define chmin4(a, b, c, d) a = MIN4(a, (b), (c), (d))
#define chmin5(a, b, c, d, e) a = MIN5(a, (b), (c), (d), (e))
#define chmin6(a, b, c, d, e, f) a = MIN6(a, (b), (c), (d), (e), (f))
#define chmax(a, b) a = max(a, (b))
#define chmax3(a, b, c) a = MAX3(a, (b), (c))
#define chmax4(a, b, c, d) a = MAX4(a, (b), (c), (d))
#define chmax5(a, b, c, d, e) a = MAX5(a, (b), (c), (d), (e))
#define chmax6(a, b, c, d, e, f) a = MAX6(a, (b), (c), (d), (e), (f))
#define fcout cout << fixed << setprecision(15)
#define YES(f) cout << ((f) ? YES_STR : NO_STR) << endl;

using namespace std;

int solve(int n) {
	int res = 0;
	int l = 1, r = 1;
	int sum = 0;
	while (l <= n) {
		while (sum < n) sum += r++;
		while (sum > n) sum -= l++;
		res += sum == n;
		sum -= l++;
	}
	return res;
}

signed main() {
	int n;
	while (cin >> n, n) cout << solve(n) - 1 << endl;
}




Measured memory_bytes: 3080
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef vector<ll> VI;
typedef vector<VI> VVI;
const ll MOD = 998244353;
const ll INF = 4611686018427387903;
#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

clock_t start=clock();
const double tl = 1.9;
const double T0=1e3;
const double T1=6e2;
double T=T0;

const int w=10;
const int k=300;
const int n=26;

int d;
VI c(n);
VVI s(365,VI(n));

struct st{
	VI a;
	ll score;
	bool operator<(const st &another) const {return score < another.score;};
};

ll f(VI a){
	ll ret=0;
	VI last(n,-1);
	REP(i,d){
		last[a[i]]=i;
		ret+=s[i][a[i]];
		REP(j,26)
			ret-=c[j]*(i-last[j]);
	}
	return ret;
}

vector<st> f2(st p){
	VI a=p.a; ll score=p.score;
	int now=a.size()+1;
	VI last(n,0);
	REP(i,a.size())
		last[a[i]]=i+1;
	VI down(n); ll downsum=0;
	REP(i,n){
		down[i]=c[i]*(now-last[i]);
		downsum+=down[i];
	}
	a.push_back(-1);
	vector<st> tmp;
	REP(i,n){
		a[now-1]=i;
		tmp.push_back({a,score-downsum+down[i]+s[now-1][i]});
	}
	sort(ALL(tmp));
	vector<st> ret;
	REP(i,w)
		ret.push_back(tmp[n-1-i]);
	return ret;
}

int main(){
	cin >> d;
	REP(i,n) cin >> c[i];
	REP(i,d)REP(j,n) cin >> s[i][j];
	priority_queue<st> q;
	VI a(0);
	q.push({a,0});
	REP(i,d){
		priority_queue<st> next;
		REP(j,k){
			if(q.empty())
				break;
			for(auto nx:f2(q.top()))
				next.push(nx);
			q.pop();
		}
		q=next;
	}
	VI ans(d,10); ans=q.top().a;
	int cnt=0;
	while(1){
		cnt++;
		if(cnt%100==0){
			double t=(double)(clock()-start)/CLOCKS_PER_SEC/tl;
			if(t>=1.0)
				break;
			T=pow(T0,1.0-t)*pow(T1,t);
		}
		ll oldscore=f(ans);
		if(rand()%2){
			int cd=rand()%d;
			int old=ans[cd];
			ans[cd]=rand()%26;
			ll newscore=f(ans);
			if(rand()%1000000<=exp((newscore-oldscore)/T)*1e6)
				continue;
			ans[cd]=old;
		}
		else{
			int cd1=rand()%(d-1);
			int cd2=cd1+1+(rand()%(d-cd1-1));
			swap(ans[cd1],ans[cd2]);
			ll newscore=f(ans);
			if(rand()%1000000<=exp((newscore-oldscore)/T)*1e6)
				continue;
			swap(ans[cd1],ans[cd2]);
		}
	}
	REP(i,d)
		cout << ans[i]+1 << endl;
	//cout << f(ans) << endl;
	return 0;
}

Measured memory_bytes: 25268
#include "bits/stdc++.h"
using namespace std;
int main() {
  int N,K,X,Y;
  cin >>N>>K>>X>>Y;
  int A;
if (N<=K){  
 A= N*X;
}else{
 A= K*X+(N-K)*Y;
}
  
cout << A;
    return 0;
}    

Measured memory_bytes: 256
#include <cassert>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
static int nines[1000];

unsigned long long solve(const int *const n, const int width, const int k) {
    assert(width >= 1);
    assert(k >= 0);
    assert(0 <= *n && *n <= 9);
    if (k > width)
        return 0;
    if (k == 0)
        return 1;
    if (width == 1)
        return *n;
    if (*n == 0)
        return solve(n + 1, width - 1, k);

    auto counter = 0ULL;

    counter += solve(n + 1, width - 1, k - 1);
    counter += (*n - 1) * solve(nines, width - 1, k - 1);
    counter += solve(nines, width - 1, k);

    return counter;
}

int main() {
    string n;
    int k;
    cin >> n >> k;
    auto x = vector<int>(n.length());
    auto index = 0;
    for (auto c : n)
        x[index++] = c - '0';

    for (auto &nine : nines)
        nine = 9;
    cout << solve(x.data(), x.size(), k);
    return 0;
}


Measured memory_bytes: 256
program main
      implicit none
      integer x, y, z
      integer a, b, c
      integer a2, b2, c2

      read *, x, y, z
      a = x
      b = y
      c = z

      a2 = b
      b2 = a
      a = a2
      b = b2

      a2 = c
      c2 = a
      a = a2
      c = c2

      print *, a, b, c

end program main

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

using namespace std;

int main() {
	string s;
	cin >> s;
	int a = -1;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == 'C'&&a == -1) {
			a = i;
		}
		if (s[i] == 'F'&&a != -1) {
			cout << "Yes" << endl;
			return 0;
		}

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

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


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

int main() {
	char b;
	cin >> b;

	switch (b)
	{
	case 'A': cout << "T"; break;
	case 'C': cout << "G"; break;
	case 'G': cout << "C"; break;
	case 'T': cout << "A"; break;

	}



	
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

typedef long long ll;
typedef int keytype;

int gcd(int a, int b){ return (a % b) ? gcd(b, a % b) : b;}
int lcm(int a, int b){ return (a / gcd(a, b)) * b;}

void quicksort(keytype a[], int first, int last)
{
    int i, j;
    keytype x, t;

    x = a[(first + last) / 2];
    i = first;  j = last;
    for ( ; ; ) {
        while (a[i] < x) i++;
        while (x < a[j]) j--;
        if (i >= j) break;
        t = a[i];  a[i] = a[j];  a[j] = t;
        i++;  j--;
    }
    if (first  < i - 1) quicksort(a, first , i - 1);
    if (j + 1 < last) quicksort(a, j + 1, last);
}

int is_prime(int x){
    if(x <= 1) return 0;
    for(int i = 2; i * i <= x; i++){
        if(x % i == 0) return 0;
    }
    return 1;
}

int is_substr(char s[], char t[], int i){
    int flag = 1;

    if(s[i] == '\0') flag = 0;

    for(int j = 0; j < strlen(t); ++j, ++i){
        if(s[i] != t[j]){
            flag = 0;
            break;
        }
    }
    return flag;
}

// factor list, number of factors, natural number
void factorize(int ftr[], int *num, int n){
    int a = 2, cnt = 0;

    while(n >= a){
        if(n % a == 0){
            n = n / a;
            ftr[cnt++] = a;
        }else{
            a++;
        }
    }
    *num = cnt;
}

void comb(int size1, int size2, int v[size1][size2]){
  for(int i = 0; i < size1; i++){
    v[i][0] = 1;
    v[i][i] = 1;
  }
  for(int k = 1; k < size1; k++){
    for(int j = 1; j < k; j++){
      v[k][j] = (v[k-1][j-1] + v[k-1][j]);
    }
  }
}

int abs_val(int a, int b){
    if(a > b) return a - b;
    else return b - a;
}

int main(){
    int k;
    scanf("%d", &k);

    int cnt = 0;
    for(int i = 1; i <= k - 1; ++i){
        for(int j = i + 1; j <= k; ++j){
            if(((i + j) % 2 == 1)) cnt++;
        }
    }

    printf("%d\n", cnt);

    return 0;
}


Measured memory_bytes: 1724
#include<bits/stdc++.h>
#define rep(a,b,c) for(int a=b;a<=c;a++)
#define per(a,b,c) for(int a=b;a>=c;a--)
#define ios; ios::sync_with_stdio(false); cin.tie(0);
#define pb push_back
#define mk make_pair
#define fi first
#define se second
#define mem(a,b) memset(a,b,sizeof(a))
#define inf 0x3f3f3f3f
#define INF 0x3f3f3f3f3f3f3f3f
#define ls(x) (x<<1)
#define rs(x) (ls(x)|1)
#define eps 1e-11
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<int> VI;
typedef double db;
mt19937 rnd(random_device{}());
const int mod = 1e9 + 7;
const int N = 2e5 + 5;
const int M = 1e3 + 5;
const db pi = acos(-1.0);
inline ll gcd(ll a,ll b){ return b?gcd(b,a%b):a; }
inline ll lcm(ll a,ll b){ return a*b/gcd(a,b); }
inline ll ksm(ll x,ll y){ ll res=1; while(y){if(y&1) res=res*x%mod;
x=x*x%mod; y>>=1;} return res; }
int n, m, k;
int a[N], b[N];

int main(){
    ios;
    cin>>n>>k;
    rep(i,1,n){
        cin>>a[i];
    }
    rep(i,1,k){
        rep(j,1,n) b[max(1,j-a[j])]++, b[min(n,j+a[j])+1]--;
        int mn = n+1;
        rep(j,1,n){
            b[j]+=b[j-1];
            b[j-1]=0;
            a[j]=b[j];
            mn = min(mn,a[j]);
        }
        b[n]=0;
        if(mn==n) break;
    }
    rep(i,1,n) cout<<a[i]<<" ";
    return 0;
}

Measured memory_bytes: 5196
#include <iostream>
#include <cstdio>
#include <vector>
#include <set>
#include <unordered_set>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>

using namespace std;
using lli = long long int;
// #define DEBUG
#ifdef DEBUG
#define debug(var) cout << (#var) << ": " << (var) << endl;
template<class T> void dump_array_impl(const T& a) {
  bool first = true;
  for (auto&& x : a) {
    if (!first) { cout << ", "; first = false; }
    cout << x;
  }
}
#define debug_array(a) cout<<(#a)<<": ";dump_array_impl(a);cout<<endl
#else
#define debug(var) {}
#define debug_array(a) {}
#endif
template<class T> void read_n(vector<T>& v, size_t n) {
  v = vector<T>(n);
  for (lli i=0; i<n; ++i) cin >> v[i];
}
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

lli n;
vector<lli> v;
int main() {
  cin >> n;
  read_n(v, n);
  lli p=v[0], q=v[1], r=v[2], s=accumulate(begin(v)+3, end(v), 0ll);
  lli x=1, y=2, z=3;
  lli ans=1e17;
  while (y <= v.size()-2) {
    while (x+1<y && abs(q-p) > abs(q-v[x] - (p+v[x]))) {
      p+=v[x]; q-=v[x]; ++x; 
    }
    while (z+1<n && abs(s-r) > abs(s-v[z] - (r+v[z]))) {
      r+=v[z]; s-=v[z]; ++z; 
    }

    // printf("x:%lld, y:%lld, z:%lld %lld %lld %lld %lld\n", x, y, z,p,q,r,s);

    lli cur = max(max(p,q), max(r,s)) - min(min(p,q), min(r,s));
    ans = min(ans, cur);

    q+=v[y]; r-=v[y]; ++y;
    if (y == z) {
      r+=v[z]; s-=v[z]; ++z; 
    }
  }
  cout << ans << endl;
  return 0;
}


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

int main () {
	int x,y,n,m;
	
	cin>>x>>y>>n>>m;
	
	int has = x-y;
	
	if(has <=0 ) {
		cout<<n*x<<endl;
	} else {
		cout<<y*n + has*m<<endl;
	}
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  int n=s.size();
  if(s[0]==s[s.size()-1]){
    n-=3;
  }
  else{
    n-=2;
  }

  if(n%2==0){
    cout<<"Second"<<endl;
  }
  else{
    cout<<"First"<<endl;
  }

  return(0);
}


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

string str = "mcxi";

int chint(string s)
{
     int num = 0, t = 1000, i = 0, j = 0, k = 1;
     while (j < str.size()) {
	  if (str[j] == s[i]) {
	       num += (k * t);
	       t /= 10;
	       k = 1;
	       j++;
	       i++;
	  }else if ('1' < s[i] && s[i] <= '9') {
	       k = s[i] - '0';
	       i++;
	  }else {
	       j++;
	       t /= 10;
	  }
     }

     return num;
}

string chstr(int num)
{
     string s;
     int i = 1000, t, j = 0;
     while (num) {
	  t = num / i;
	  num %= i;
	  if (t > 1) {
	  	char c;
	  	c = t + '0';
	  	s = s + c + str[j];
	  }else if (t > 0)  s += str[j];
	  i /= 10;
	  j++;
     }
     
     return s;
}

int main(void)
{
     string str1, str2;
     int n;
     cin >> n;
     while (n) {
	  cin >> str1 >> str2;
	  int ans;
	  ans = chint(str1) + chint(str2);
	  str1 = chstr(ans);
	  cout << str1 << endl;
	  n--;
     }

     return 0;
}

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

using namespace std;

typedef long long ll;

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    vector<int> a(n);
    int ans = 1, bd = 1;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
        ans *= 3;
        if (a[i] % 2 == 0) bd *= 2;
    }
    cout << ans - bd;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		try(Scanner sc = new Scanner(System.in)) {

			String s = sc.next();
			
			if ( s.equals("ABC")) {
				System.out.println("ARC");
			}
			else {
				System.out.println("ABC");
			}

		}
	}

}

Measured memory_bytes: 35604
#include <cstdio>

using namespace std;

int main(){
	int a, b;
	scanf("%d %d", &a, &b);
	int d = a / b;
	int r = a % b;
	double f = 1.0 * a / b;
	printf("%d %d %.5lf\n", d, r, f);
	return 0;
}

Measured memory_bytes: 1068
n = int(input())
P = [int(i) for i in input().split()]
cnt = 0
for i in range(n):
  if i == n-1 and P[i]==i+1:
    cnt += 1
    break
  if i+1==P[i]:
    a = P[i]
    P[i] = P[i+1]
    P[i+1] = a
    cnt += 1
print(cnt)

Measured memory_bytes: 13880
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long N;cin>>N;
  vector<long> A(N);
  bool zero=false;
  double lwa=0;
  long seki=1;
  for(int i=0;i<N;i++){
    cin>>A[i];
    lwa+=log10(A[i]);
    if(lwa<=18)seki*=A[i];
    if(A[i]==0)zero=true;
  }
  if(zero)seki=0;
  cout<<(lwa<=18&&seki<=1000000000000000000?seki:-1)<<endl;
}

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

int n, d1, d2, yes = 0;
vector <pair <int, int> > d;

int main() {
    for(cin >> n; n; n--) {
        cin >> d1 >> d2;
        d.push_back(make_pair(d1, d2));
    }
    for(size_t i = 0; i < d.size() - 2; i++) {
        if(d[i].first == d[i].second && d[i + 1].first == d[i + 1].second && d[i + 2].first == d[i + 2].second) {
            yes = 1;
            break;
        }
    }
    if(yes == 1)
        cout << "Yes";
    else
        cout << "No";
    return 0;
}


Measured memory_bytes: 3596
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <string>
#include <cmath>
#include <complex>
#include <numeric>
#include <cassert>

#include <vector>
#include <array>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <utility>

#define int64 long long
#define uint64 unsigned long long
using namespace std;

int main()
{
	int64 nn, ans = 1;
	cin >> nn;
	vector<int64> memo(nn + 1, 0);
	for(int64 ii = 2;ii <= nn;ii++)
	{
		int64 tmp = ii;
		for(int64 jj = 2;jj <= ii;jj++)
		{
			while(tmp % jj == 0)
			{
				tmp /= jj;
				memo[jj]++;
			}
		}
	}
	for(int64 ii = 2;ii <= nn;ii++)
	{
		ans *= memo[ii] + 1;
		ans %= 1000000007;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3624
h1,m1,h2,m2,k=map(int,input().split())
all=0
if m2>=m1:
    all += (h2-h1)*60 + (m2-m1)
    all -= k
else:
    all += (h2-1-h1)*60 + (m2+60-m1)
    all -= k
print(all)

Measured memory_bytes: 9188
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
int gcd(int A,int B){
  if(A<B)
    swap(A,B);
  while(1){
    if(A%B==0)
      return B;
    int C=A%B;
    A=B;
    B=C;
  }
}
signed main(){
  int A,B,C;
  cin>>A>>B>>C;
  string ans="NO";
  int X=gcd(A,B);
  if(C%X==0)
    ans="YES";
  cout<<ans<<endl;
  }



Measured memory_bytes: 256
#include <iostream>
using namespace std;
int  main(){
  char s[]={'0','1','2','3','5','7','8','9'};
  long long int n;
  for(;cin>>n,n;)
    {
      string a="";
      for(;n>0;n/=8)
	a=s[n%8]+a;
      cout<<a<<endl;
    }
}

Measured memory_bytes: 1204
#include<bits/stdc++.h>
using namespace std;
int main(){
  cin.tie(NULL);
  ios::sync_with_stdio(false);
  int a,b,c;
  cin>>a>>b>>c;
  int sum=a*100+b*10+c;
  if(sum%4==0) cout<<"YES"<<'\n';
  else cout<<"NO"<<'\n';
  return 0;
}


Measured memory_bytes: 256
n, lw = gets.split.map(&:to_i)
h = Hash.new { |bh, k| bh[k] = [] }

n.times do
  w, v = gets.split.map(&:to_i)
  h[w] << v
end

w = h.keys
(4 - w.size).times { w << 0 }

cum = Array.new(4) { [0] }
h.each_value.with_index do |v, idx|
  v.sort.reverse_each { |e| cum[idx] << cum[idx][-1] + e }
end

ans = 0

cum[0].size.times do |i|
  cum[1].size.times do |j|
    cum[2].size.times do |k|
      cum[3].size.times do |l|
        next if w[0] * i + w[1] * j + w[2] * k + w[3] * l > lw

        ans = [ans, cum[0][i] + cum[1][j] + cum[2][k] + cum[3][l]].max
      end
    end
  end
end

puts ans


Measured memory_bytes: 14264
import java.util.Scanner;

public class Main {
    public static void debug(String str) {
        System.out.println(str);
    }

    public static void main(String[] args) {

        int X;
        int Y;
        int E = 1000000007;

        try (Scanner sc = new Scanner(System.in)) {
            X = sc.nextInt();
            Y = sc.nextInt();
        }

        int x = 2 * Y - X;
        if (x % 3 != 0) {
            System.out.println(0);
            return;
        }
        x = x / 3;
        Combination com = new Combination();
        com.COMinit();
        System.out.println(com.COM(x + ((X-x)/2),x));

    }

    public static class Combination {


        static int MAX = 1000_000;
        static int MOD = 1000_000_007;
        static long fac[] = new long[MAX];
        static long finv[] = new long[MAX];
        static long inv[] = new long[MAX];

        public static void COMinit() {
            fac[0] = fac[1] = 1;
            finv[0] = finv[1] = 1;
            inv[1] = 1;
            for (int i = 2; i < MAX; i++) {
                fac[i] = fac[i - 1] * i % MOD;
                inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
                finv[i] = finv[i - 1] * inv[i] % MOD;
            }
        }

        // 二項係数計算
        public static int COM(int n, int k) {
            if (n < k)
                return 0;
            if (n < 0 || k < 0)
                return 0;
            return (int) (fac[n] * (finv[k] * finv[n - k] % MOD) % MOD);
        }
    }

}


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

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

    int q,t,f;
    cin >> q;

    char c;
    bool tflag=false;
    int tcount=0;
    for(int i=0;i<q;++i){
        cin >> t;
        if(t==1){
            if(tflag){
                tflag=false;
            }else{
                tflag=true;
            }
            tcount++;
        }else{
            cin >> f >> c;
            if(!tflag){
                if(f==1){
                    s.insert(s.begin(),c);
                }else{
                    s.push_back(c);
                }
            }else{
                if(f==1){
                    s.push_back(c);
                }else{
                    s.insert(s.begin(),c);
                }
            }
        }
    }
    if(tcount%2==1){
        reverse(s.begin(),s.end());
    }
    cout << s <<endl;
    
    return 0;
}

Measured memory_bytes: 900
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<ctime>
#include<cctype>
#include<climits>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<memory>
#include<functional>

#define rep(i, n) REP(i, 0, n)
#define REP(i, a, n) for(int i = a ; i < (int)n ; i++)
#define N 8

using namespace std;

bool isLocated[N][N];
int row[N];     
int col[N];     
int dl[2*N-1]; 
int dr[2*N-1];

void print(){
  rep(i, N){
    rep(j, N){
      if(isLocated[i][j] && row[i] != j) return;
    }
  }

  rep(i, N){
    rep(j, N){
      cout << (row[i] == j?"Q":".");
    }
    cout << "\n";
  }
}

void solve(int i){

  if(i == N){
    print();
    return;
  }

  rep(j, N){
       if(col[j] == 1 || dl[j + i] == 1 || dr[i - j + N - 1] == 1){
      continue;
    }
    
    row[i] = j;
    col[j] = dl[j+i] = dr[i-j+N-1] = 1;
    solve(i+1);
    col[j] = dl[j+i] = dr[i-j+N-1] = -1;
  }
  
}

void init(){
  rep(i, N){
    row[i] = col[i] = -1;    
  }

  rep(i, 2*N-1){
    dl[i] = dr[i] = -1;
  }

  rep(i, N){
    rep(j, N){
      isLocated[i][j] = false;
    }
  }
}

signed main(){
  int n;
  int r, c;

  init();
  cin >> n;
  rep(i, n){
    cin >> r >> c;
    isLocated[r][c] = true;
  }
  solve(0);  
}



Measured memory_bytes: 3100
// 2015/04/20 Tazoe

#include <iostream>
#include <algorithm>
using namespace std;

int C;

void bubbleSort(int A[], int N)
{
	bool flag = true;

	while(flag){
		flag = false;

		for(int j=N-1; j>=1; j--){
			if(A[j]<A[j-1]){
				swap(A[j], A[j-1]);
				C++;
				flag = true;
			}
		}
	}
}

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

	int A[100];
	for(int i=0; i<N; i++){
		cin >> A[i];
	}

	C = 0;

	bubbleSort(A, N);

	for(int i=0; i<N; i++){
		cout << A[i];

		if(i<N-1){
			cout << ' ';
		}
		else{
			cout << endl;
		}
	}
	cout << C << endl;

	return 0;
}

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

int main(void){
	int n,q,x,y;
	cin>>n>>q;
	vector<int> v[n];
	while(q--){
		cin>>x;
		if(x==0){
			//pb
			cin>>x>>y;
			v[x].push_back(y);
		}else if(x==1){
			cin>>x;
			for(int i=0;i<v[x].size();i++){
				if(i!=0)cout<<" ";
				cout<<v[x][i];
			}
			cout<<endl;
		}else{
			cin>>x;
			v[x].clear();
		}
	}
	return 0;
}



Measured memory_bytes: 5904
S = input()
C = ["0","1"] 
count1=count2=0

for i in range(len(S)):
  # case 1
  if S[i] == C[i%2]:
    count1+=1
  # case 2
  if S[i] == C[(i+1)%2]:
    count2+=1

print(min([count1, count2]))

Measured memory_bytes: 3188
#!usr/bin/env python3
import sys
import math
import string
import collections
import fractions
import random
from operator import itemgetter
import itertools
from collections import deque
import copy
import heapq
from bisect import bisect, bisect_left, bisect_right

MOD = 10 ** 9 + 7
INF = 10 ** 18
input = lambda: sys.stdin.readline().strip()

sys.setrecursionlimit(10 ** 8)

M = int(input())
d = [0] * M
c = [0] * M
for i in range(M):
    d[i], c[i] = map(int, input().split())  # dがc回続く
SUM = 0
for i in range(M):
    SUM += d[i] * c[i]
times = math.ceil(SUM / 9) - 1
print(sum(c) + times - 1)

Measured memory_bytes: 14896
function Main(input) {
    const lines = input.split("\n");
    const [N, K] = lines[0].split(' ');
    const descHs = lines[1].split(' ').map(v => +v).sort((a, b) => b - a);
    
    console.log(descHs.slice(K).reduce((acc, val) => acc + val, 0));
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 38736
#include <iostream>
#include <cstdlib>
#include <vector>

using namespace std;

int N;

int main()
{
   cin >> N;
   vector<vector<int>> candy(2, vector<int>(N)); 
   for(int j = 0; j < 2; j++) {
    for(int i = 0; i < N; i++) {
        int c;
        cin >> c; 
        if (i == 0) {
            candy[j][0] = c;
            continue;
        }
        candy[j][i] = candy[j][i - 1] + c;
    }
   }
    
    int ans = candy[0][0] + candy[1][N - 1];
    for(int i = 1; i < N; i++) {
       ans = max(ans, candy[0][i] + candy[1][N - 1] - candy[1][i - 1]);
    }
     cout << ans << endl;
}   

Measured memory_bytes: 384
n=int(input())
mlst = []
ilst = []
for i in range(n):
    tmp = []
    a,b = input().split()
    c = int(b)
    tmp.append(a)
    tmp.append(c)
    mlst.append(tmp)
    ilst.append(a)
#print(mlst)
#print(ilst)
name = input()
idx = ilst.index(name)

total = 0
for j in range(idx+1, n):
    total += mlst[j][1]
print(total)


Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>

using namespace std;

int pow(int a)
{
	return a*a;
}

int main(void)
{
	int n,sum;
	while (scanf("%d",&n)!=EOF) {
		sum=0;
		for(int i=1;i<(600/n);i++){
			sum+=pow(n*i)*n;
		}
		
		cout<<sum<<endl;
	}
	
	return (0);
}

Measured memory_bytes: 0
import std.stdio, std.conv, std.string, std.array, std.range, std.algorithm, std.container;
import std.math, std.random, std.bigint, std.datetime, std.format;
void main(string[] args){ if(args.length > 1) if(args[1] == "-debug") DEBUG = 1; solve(); }
void log()(){ writeln(""); } void log(T, A ...)(T t, lazy A a){ if(DEBUG) write(t, " "), log(a); } bool DEBUG = 0; 
string rstring(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
T rtype(T)(){ return rstring.to!T; } alias rint = rtype!int, rlong = rtype!long, rreal = rtype!real;
T[] rtypes(T)(int n){ return n.iota.map!(i => rtype!T()).array; } alias rint = rtypes!int, rlong = rtypes!long, rreal = rtypes!real;
T[][] rtypess(T)(int n, int m){ return n.iota.map!(i => rtypes!T(m)).array; } alias rint = rtypess!int, rlong = rtypess!long, rreal = rtypess!real;

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

void solve(){
	int n = rint;

	Node[] nodes;
	foreach(i; 0 .. n) nodes ~= new Node(i);

	X[] edges;
	foreach(i; 0 .. n - 1){
		int a = rint - 1, b = rint - 1;
		edges ~= X(a, b);
		nodes[a].nodes ~= nodes[b];
		nodes[b].nodes ~= nodes[a];
		nodes[a].deg += 1;
		nodes[b].deg += 1;
	}

	int maxd;
	foreach(nd; nodes) maxd = max(maxd, nd.deg);

	nodes[0].treefy(null);
	nodes[0].paint(-1);

	int[] ans;
	foreach(ed; edges){
		Node nda = nodes[ed.a], ndb = nodes[ed.b];
		if(nda.parent && nda.parent.id == ndb.id){
			ans ~= nda.value;
		}
		else ans ~= ndb.value;
	}

	maxd.writeln;
	foreach(an; ans) an.writeln;

}
struct X{
	int a, b;
}
class Node{
	int id;
	int deg;
	int value; // 親からの色
	Node[] nodes;
	Node[] sons;
	Node parent;
	this(int id){
		this.id = id;
	}
	void treefy(Node par){
		if(par) this.parent = par;
		foreach(nd; nodes){
			if(par && par.id == nd.id) continue;
			else{
				sons ~= nd;
				nd.treefy(this);
			}
		}
	}
	void paint(int col){
		this.value = col;
		int i = 1;
		foreach(nd; sons){
			if(parent && parent.id == nd.id) continue;
			if(i == col) i += 1;
			nd.paint(i);
			i += 1;
		}
	}
}

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

#define MOD (1000000000+7)
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) x.begin(), x.end()
#define print(vec,l,r) for(int i = l; i <= r; i++) cout << vec[i] <<" "; cout << endl;
#define forf(i,a,b) for(int i = (a); i < (b); i++)
#define forr(i,a,b) for(int i = (a); i > (b); i--)
#define input(vec,N) for(int i = 0; i < (N); i++) cin >> vec[i];

// template starts
typedef long long int ll;

void solve(){
	// code starts from here
	string s1,s2;
	cin >> s1 >> s2;
	if(!(s1.size() <= 10 && s1.size() >= 1)){
		cout << "No" << endl;
		return;
	}
	s2.pop_back();
	if(s1 == s2){
		cout << "Yes" << endl;
	}
	else cout << "No" << endl;
}

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

	int T;
	T = 1;
	while(T--){
		solve();
	}

	return 0;
}


Measured memory_bytes: 3616
/* ＵＴＦ－８ */
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <array>
#include <queue>
#include <stack>
#include <algorithm>
#include <tuple>
#include <numeric>
#include <type_traits>
#include <limits>

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

#define USE_COLORED 1

#ifdef USE_COLORED
static const char stdout_pre[]  = "\033[1m"; // bold black
static const char stderr_pre[]  = "\033[31;1m"; // bold red
static const char stdxxx_post[] = "\033[m";

// 当然ながら GCC(g++)/libstdc++ 依存
#include <ext/stdio_filebuf.h>
using stdio_filebuf = __gnu_cxx::stdio_filebuf<char>;
class colored_stdio_filebuf : public stdio_filebuf {
private:
	const char* const pre_;
	const char* const post_;

public:
	colored_stdio_filebuf(FILE* fp, const char* pre, const char* post) : stdio_filebuf(fp, std::ios_base::out), pre_(pre), post_(post)
	{
	}

protected:
	std::streamsize xsputn(const char* s, std::streamsize count) override
	{
		stdio_filebuf::xsputn(pre_, strlen(pre_));
		auto ret = stdio_filebuf::xsputn(s, count);
		stdio_filebuf::xsputn(post_, strlen(post_));
		return ret;
	}
};
#endif

int main()
{
#ifdef USE_COLORED
	if (getenv("DEBUG")) {
		std::cout.rdbuf(new colored_stdio_filebuf(stdout, stdout_pre, stdxxx_post));
		std::cerr.rdbuf(new colored_stdio_filebuf(stderr, stderr_pre, stdxxx_post));
	} else
#endif
	{
		int fd = open("/dev/null", O_WRONLY);
		dup2(fd, 2);
		close(fd);
	}
	
	long N, K;
	std::vector<long> H;
	std::cin >> N >> K;
	H.resize(N);
	for (auto& h : H)
		std::cin >> h;

	if (N <= K) {
		std::cout << "0\n";
		return 0;
	}

	std::sort(H.begin(), H.end());
	long result = 0;
	for (int i = 0; i < H.size() - K; ++i)
		result += H[i];
	std::cout << result << "\n";
}


Measured memory_bytes: 1792
W = 0
H = 1
x = 2
y = 3
r = 4

l1 = input().split()
l2 = []

for i in l1:
    l2.append(int(i))

if l2[W] <= l2[x]:
    print("No")
else:
    if l2[H] <= l2[y]:
        print("No")
    else:
        if(l2[x] - l2[r]) < 0:
            print("No")
        else:
            if(l2[y] - l2[r]) < 0:
                print("No")
            else:
                print("Yes")


Measured memory_bytes: 5600
#include<stdio.h>
int main(void) {
int water, bill;

scanf("%d",&water);
while(water!=-1) {
bill=1150;
if(water-10>0)
bill+=(water-10)*125;
if(water-20>0)
bill+=(water-20)*15;
if(water-30>0)
bill+=(water-30)*20;
printf("%d\n",4280-bill);
scanf("%d",&water);
}
return(0);
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
int main(){
    int n,h[200001],dp[200001]={0};
    cin>>n;
    rep(i,n) cin>>h[i];
    dp[1]=abs(h[0]-h[1]);
    rep(i,n-2) dp[i+2]=min(dp[i]+abs(h[i]-h[i+2]),dp[i+1]+abs(h[i+1]-h[i+2]));
    cout<<dp[n-1];
}

Measured memory_bytes: 1408
// J'aime
// Chemise Blanche

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

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr << __LINE__ << " > " << #x << " = " << (x) << endl

void MAIN() {
  int h1, m1, h2, m2, k;
  cin >> h1 >> m1 >> h2 >> m2 >> k;
  int t = (h2 - (h1 + 1)) * 60 + (60 - m1) + m2;
  cout << t - k << '\n';
}

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
  // freopen("out", "w", stdout);
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int T = 1;
  // cin >> T;
  while (T--) MAIN();
}


Measured memory_bytes: 3648
#include<iostream>
#include <string> 
#include <vector>  
#include<math.h>

#define INF 1000000000
#define LM 55555
using namespace::std;


long Lmax(long x, long y) {
	if (x > y)return x;
	return y;
}

int max(int x, int y) {
	if (x > y)return x;
	return y;
}

long Lmin(long x, long y) {
	if (x < y)return x;
	return y;
}


int min(int x, int y) {
	if (x < y)return x;
	return y;
}

int abs(int a) {
	if (a < 0) {
		return -a;
	}
	return a;
}

long long A,B,C,H,W,X,Y,N, M,num,x,ans,a[10000];
string s[1000], t;

int main() {
	cin >>H>>W;
	if (W == 100) {
		W = 101;
	}
	if (H == 0) {
		cout << W << endl;
		return 0;
	}
	
	int i = 1;
	if (H == 1) {
		cout << 100 * W << endl;
	}

	if (H == 2) {
		cout << 10000 * W << endl;
	}
	return 0;

}




Measured memory_bytes: 256
#include <cassert>
#include <algorithm>
#include <array>
#include <bitset>
#include <cctype>
#include <cstdint>
#include <cmath>
#include <complex>
#include <chrono>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
#include <random>
#include <memory>
#include <utility>
#include <limits>
#include "limits.h"
 
#define rep(i, a, b) for (long long (i) = (a); (i) < (b); (i)++)
#define all(i) i.begin(), i.end()
#define debug(...) std::cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

void debug_out(){std::cerr<<std::endl;}

template<typename Head,typename... Tail>
void debug_out(Head h,Tail... t){
  std::cerr<<" "<<h;
  debug_out(t...);
}
 
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (int i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}
 
template<typename T1,typename T2>
inline bool chmax(T1& a,T2 b){return a<b && (a=b,true);}
 
template<typename T1,typename T2>
inline bool chmin(T1& a,T2 b){return a>b && (a=b,true);}
 
long long pow_mod(long long a, long long b, long long mod=-1) {
  if(b==0)return 1;
  if ((a == 0)||(mod!=-1&&(a+mod)%mod==0)) {
    return 0;
  }
  long long x = 1;
  while (b > 0) {
    if (b & 1) {
      x = (mod!=-1)?(x * a) % mod:x*a;
    }
    a = (mod!=-1)?(a * a) % mod:a*a;
    b >>= 1;
  }
  return x;
}

// const long long MOD = 998244353;
const long long MOD = 1e9 + 7;

using ll = long long;
using P=std::pair<long long,long long>;

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

  ll a,b;
  std::cin>>a>>b;

  std::string s,t;
  
  rep(i,0,b)s+=(char)('0'+a);
  rep(i,0,a)t+=(char)('0'+b);

  std::cout<<std::min(s,t)<<"\n";

  return 0;
}


Measured memory_bytes: 256
module Main where

import Control.Applicative
import Text.Printf

getInt :: IO Int
getInt = head <$> getInts

getInts :: IO [Int]
getInts = map read . words <$> getLine 

main :: IO ()
main = do
  { ss <- getInt
  ; let (q, s) = divMod ss 60
  ; let (h, m) = divMod q 60
  ; putStrLn (show h ++ ":" ++ show m ++ ":" ++ show s)
  }



Measured memory_bytes: 3608
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

using Pair = System.Collections.Generic.KeyValuePair<int, int>;

class Program
{
	public Program() { }

	static void Main(string[] args)
	{
		new Program().prog();
	}
	Scanner cin;
	const int MOD = 1000000007;
	const int INF = int.MaxValue;
	const double EPS = 1e-7;
	const double PI = 3.1415926536;

	void prog()
	{
		cin = new Scanner();
		int[,] dir8 = new int[8, 2] { { -1, -1 }, { -1, 0 }, { -1, 1 }, { 0, -1 }, { 0, 1 }, { 1, -1 }, { 1, 0 }, { 1, 1 } };
		int[,] dir4 = new int[4, 2] { { -1, 0 }, { 0, -1 }, { 0, 1 }, { 1, 0 } };

		int N = cin.nextInt();
		int[] a = new int[N];
		for (int i = 0; i < N; i++)
		{
			a[i] = -1;
		}
		int ans = 0;
		for (int i = 0; i < N; i++)
		{
			a[i] = cin.nextInt() - 1;
			if(a[a[i]] == i)
			{
				ans++;
			}
		}
		Console.WriteLine(ans);
	}
}

class Scanner
{
	string[] s;
	int i;

	char[] cs = new char[] { ' ' };

	public Scanner()
	{
		s = new string[0];
		i = 0;
	}

	public string next()
	{
		if (i < s.Length) return s[i++];
		string st = Console.ReadLine();
		while (st == "") st = Console.ReadLine();
		s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
		i = 0;
		return next();
	}

	public int nextInt()
	{
		return int.Parse(next());
	}

	public long nextLong()
	{
		return long.Parse(next());
	}

	public double nextDouble()
	{
		return double.Parse(next());
	}
}

Measured memory_bytes: 9688
from sys import stdin,stdout
size = int(stdin.readline())
li = list(map(int,stdin.readline().split()))
"""ans = [0]*size
for i in li:
    if i not in ans:
        ans[i-1] = 1
    else:
        ans[i-1] += 1
for i in ans:
    print(i)
"""
from collections import Counter
c1 = Counter(li)
ans2 = [0] * size
for i,j in c1.items():
    ans2[i-1] = j
for i in ans2:
    stdout.write(str(i)+"\n")


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

int main() {

    char sa[101];
    char sb[101];
    char sc[101];

    int a = 0;
    int b = 0;
    int c = 0;

    scanf("%s %s %s", sa, sb, sc);
    char chr = sa[a];
    a++;

    while (1) {

        //printf("%c",chr);
        if (a == strlen(sa)+1 ) {
            printf("A");
            break;
        }
        if (b == strlen(sb)+1) {
            printf("B");
            break;
        }
        if (c == strlen(sc)+1) {
            printf("C");
            break;
        }
        
        if(chr=='a') {
            chr = sa[a];
            a++;

        }else if(chr=='b') {
            chr = sb[b];
            b++;
            
        }else if(chr=='c') {
            chr = sc[c];
            c++;
        }

    }


    return 0;
} 

Measured memory_bytes: 128