akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <stack>
#include <map>
#include <set>
#include <ios>
#include <cctype>
#include <cstdio>
#include <functional>
#include <cassert>
#include <fstream>
#include <ctime>

using namespace std;
using ll = long long;

#define REP(i,a) for(int i = 0;i < (a);++i)
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define FORR(i,a,b) for(int i = (a) - 1;i >=(b);--i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SIZE(obj) (int)(obj).sizeT()
#define YESNO(cond,yes,no){cout <<((cond)?(yes):(no))<<endl; }
#define SORT(list) sort(ALL((list)));
#define RSORT(list) sort((list).rbegin(),(list).rend())
#define ASSERT(cond,mes) assert(cond && mes)

constexpr int MOD = 1'000'000'007;
constexpr int INF = 1'050'000'000;

template<typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

template <typename T1, typename T2>
istream& operator>>(istream& is, pair<T1, T2>& p) {
    is >> p.first >> p.second;
    return is;
}

template <typename T1, typename T2>
ostream& operator<<(ostream& os, pair<T1, T2>& p) {
    os << p.first << p.second;
    return os;
}

template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
    REP(i, (int)v.size())is >> v[i];
    return is;
}

template <typename T>
T clamp(T& n, T a, T b) {
    if (n < a)n = a;
    if (n > b)n = b;
    return n;
}

template <typename T>
static T GCD(T u, T v) {
    T r;
    while (v != 0) {
        r = u % v;
        u = v;
        v = r;
    }
    return u;
}

template <typename T>
static T LCM(T u, T v) {
    return u / GCD(u, v) * v;
}

std::vector<int> enum_div(int n) {
    std::vector<int> ret;
    for (int i = 1; i*i <= n; ++i) {
        if (n%i == 0) {
            ret.push_back(i);
            if (i != 1 && i*i != n) {
                ret.push_back(n / i);
            }
        }
    }
    return ret;
}

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;
}

struct ToUpper {
    char operator()(char c) { return toupper(c); }
};

struct ToLower {
    char operator()(char c) { return tolower(c); }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    int N;
    string S;
    cin >> N >> S;

    REP(i, S.length()) {
        S[i] = (char)S[i] + N;
        if (S[i] > 'Z')S[i] -= 'Z' - 'A' + 1;
    }

    cout << S << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<set>
#include<algorithm>
#include<iomanip>

using namespace std;
using ll=long long;

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

int main(){
  std::cin.tie(nullptr);                  // 標準入出力高速化
  std::ios_base::sync_with_stdio(false);  // SとS++の入出力出力を非同期
  int n,d;
  cin>>n;
  set<int> st;
  rep(i,0,n){
      cin>>d;
      if(!st.count(d)) st.insert(d); 
  }
  cout<<st.size()<<endl;
}


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

ll solve() {
    ll N;
    cin >> N;
    vector<ll> A(N+1), B(N);
    for ( int i = 0; i < N+1; i++ ) {
        cin >> A[i];
    }
    for ( int i = 0; i < N; i++ ) {
        cin >> B[i];
    }
    ll num = 0, c;
    for ( int i = 0; i < N; i++ ) {
        c = min(A[i], B[i]);
        num += c;
        A[i] -= c;
        B[i] -= c;
        c = min(A[i+1], B[i]);
        num += c;
        A[i+1] -= c;
        B[i] -= c;
    }
    return num;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
ld EPS = 1e-12;
int INF = numeric_limits<int>::max() / 2;
ll LINF = numeric_limits<ll>::max() / 2;
int MOD = 1e9 + 7;
#define rep(i,n) for(int i = 0; i < n; i++)
#define all(obj) (obj).begin(), (obj).end()
#define debug(x) cerr << #x << ": " << x << '\n'

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

    int n;
    map<int, int> mp;

    cin >> n;
    rep(i,n){
        int a;
        cin >> a;
        a--;
        mp[a]++;
    }
    
    int ans = 0;

    for(auto itr = mp.begin(); itr != mp.end(); itr++){
        if(itr->second % 2 == 1) ans++;
    }
    
    cout << ans << endl;
    return 0;
    
}

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

int large = 1000000007;
unsigned long long temp;
unsigned long long power(unsigned long long	 m,unsigned long long	 n){
    if(n > 1) {
        temp = power(m,n/2);
        if(n%2 == 0){
            return temp * temp % large;
        }else{
            return ((temp * temp) % large * m) % large;
        }
    }else return m;
}

int main(){
    unsigned long long	 m,n;
    cin >> m >> n;
    cout << power(m,n)%large << endl;
    return 0;
}


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

#define ll long long

int main() {
    int N, M;
    cin >> N >> M;
    bool survey[N][M + 1];
    bool like[M + 1];
    fill(like, like + M + 1, true);
    for(int n = 0;n < N;n++) {
        fill(survey[n], survey[n] + M + 1, false);
    }
    for(int n = 0;n < N;n++) {
        int K;
        cin >> K;
        for(int k = 0;k < K;k++) {
            int x;
            cin >> x;
            survey[n][x] = true;
        }
    }
    for(int m = 1;m <= M;m++) {
        for(int n = 0;n < N;n++) {
            like[m] = like[m] && survey[n][m];
        }
    }
    int count = 0;
    for(int m = 1;m <= M;m++) {
        if(like[m])count++;
    }
    cout << count << endl;
    return 0;
}

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

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  char a;
  cin >> a;
  if (isupper(a)){
    cout << 'A';
  } else {
    cout << 'a';
  }
  return 0;
}

Measured memory_bytes: 3612
from math import ceil,floor,factorial,gcd,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf
from itertools import accumulate,groupby,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heapify,heappop,heappush
from queue import Queue,LifoQueue,PriorityQueue
from copy import deepcopy
from time import time
from functools import reduce, lru_cache
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def MAP1()  : return map(lambda x:int(x)-1,input().split())
def LIST()  : return list(MAP())
def LIST1() : return list(MAP1())

n = INT()
a = LIST()

c = [0]*(10**6+1)
for x in a:
    c[x] += 1

k = max(sum(c[i::i]) for i in range(2, 10**6+1))

if k <= 1:
    print("pairwise coprime")
elif k < n:
    print("setwise coprime")
else:
    print("not coprime")

Measured memory_bytes: 134724
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> P;
typedef priority_queue<P,vector<P>,greater<P>> P_queue;
 
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define ALL(a) a.begin(),a.end()
#define SORT(a) sort(ALL(a))
#define U_ERASE(V) V.erase(unique(ALL(V)), V.end());

int main(){
  long long N, K; cin>>N>>K;
  long long ans=K*pow((K-1), N-1);
  cout<<ans<<endl;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  for(int i = 0; i < N; i++)
    cin >> a.at(i);
  sort(a.begin(), a.end());
  reverse(a.begin(), a.end());
  int A = 0, B = 0;
  for(int i = 0; i < N; i += 2)
    A += a.at(i);
  for(int i = 1; i < N; i += 2)
    B += a.at(i);
  cout << A - B << endl;
}


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

int bubbleSort(int A[],int N){
	int sw=0;
	bool flag=1;
	for(int i=0; flag; i++){
		flag=0;
		for(int j=N-1;j>=i+1;j--){
			if(A[j]<A[j-1]){
				swap(A[j],A[j-1]);
				flag=1;
				sw++;
			}
		}
	}
	return sw;
}

int main(){
	int A[100],N,sw;
	cin>>N;
	for(int i=0;i<N;i++)cin>>A[i];
	
	sw=bubbleSort(A,N);
	
	for(int i=0;i<N;i++){
		if(i)cout<<" ";
		cout<<A[i];
	}
	cout << endl;
	cout << sw << endl;
	
	return 0;
}
    

Measured memory_bytes: 3096
def main() -> None:
    N = int(input())
    a = [[0]*N for _ in range(N)]
    for i in range(N):
        *a[i], = map(int, input().split())

    sums = [0]*(1<<N)
    for s in range(1, 1<<N):
        for i in range(1, N):
            for j in range(i):
                if (s>>i & 1) & (s>>j & 1):
                    sums[s] += a[i][j]

    dp = [0]*(1<<N)
    for s in range(1, 1<<N):
        t = s
        while t > 0:
            dp[s] = max(dp[s], dp[s & ~t] + sums[t])
            t = s & (t-1)

    print(dp[-1])
 
if __name__ == '__main__':
    main()

Measured memory_bytes: 75064
import java.util.Scanner;

public class Main{
    public static void main(String[]argc){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        for(int i=1;i<=n;i++){
            if(i%3==0){
                System.out.printf(" %d",i);
            }else{
                int j = i;
                while(j>0){
                    if(j%10==3){
                        System.out.printf(" %d",i);
                        break;
                    }
                    j/=10;
                }
            }
        }
        System.out.printf("\n");
    }
}


Measured memory_bytes: 37828
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  string s;
  cin>>s;
  char c=s[0];
  int counter=1;
  for(int i=1;i<n;i++)
  {
    if(s[i]!=c)
    {
      counter++;
      c=s[i];
    }
  }
  cout<<counter<<endl;
}

Measured memory_bytes: 512
#include <iostream>

using namespace std;
int n, y;
int main() {
	cin >> n >> y;
  	int k;
  	for (int i = 0; i <= n; i++) {
    	for (int j = 0; j <= n; j++) {
        	k = n-i-j;
          	if (k < 0) continue;
          	if (10000*i + 5000*j + 1000*k == y) {
            	cout << i << " " << j << " " << k << endl;
              	return 0;
            }
        }
    }
  	cout << "-1 -1 -1" << endl;
 	return 0;
}


Measured memory_bytes: 3160
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception{
		
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		double[] x = new double[n];
		double sum = 0;
		long ave;
		
		for(int i=0; i<n; i++){
			x[i] = sc.nextDouble();
			sum += x[i];
		}
		
		ave = Math.round(sum / n);
		
		int ans = 0;
		for(int i=0; i<n; i++){
			ans += Math.pow(x[i]-ave, 2);
		}
		
		System.out.println(ans);
		

		sc.close();
	}
}


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

int main(){
    int n;
    string s1,s2;
    int a=0,b=0;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>s1>>s2;
        if(s1>s2)a+=3;
        else if(s1<s2)b+=3;
        else{
            a++;b++;
        }
    }
    cout<<a<<" "<<b<<endl;
    return 0;
}


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

if N==3:
    print('3 5 22')
else:
    c = 0
    a=2
    S=0
    while(c <= N-3):
        if a%2==0 or a%3==0 or a%5==0:
            print(str(a)+' ',end='')
            c+=1
            S+=a
        a+=1
     

    if S%2==0:
        if a%2!=0:
            a+=1
        print(str(a)+' ',end='')
        S+=a
        a+=1
        while((S+a)%30!=0):
            a+=1
        print(str(a))
    else:
        a=a-(a%6)+9
        print(str(a)+' ',end='')
        S+=a
        a+=1
        while((S+a)%30!=0):
            a+=1
        print(str(a))








        


Measured memory_bytes: 3416
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<algorithm>
#include<queue>
#include<vector>
#include<set>
#include<map>
#include<ctime>
#include<iostream>
#include<stack>
typedef long long LL;
using namespace std;
const int Maxn = 1e6;
const int Inf = 1e9 + 7;
int main()
{
	char a[110] , b[110];
	while( ~scanf(" %s %s",a,b) ){
		int len = strlen(a);
		int flag = 1 , d = -1 , check = 0;
		for( int i = 0 ; i < len ; i++ ){
			if( a[0] == b[i] ){
				flag = 1 , d = -1;
				for( int j = i ; j < len ; j++ ){
					if( a[++d] != b[j] ){
						flag = 0;
					}
					if( flag == 0 ) break;
				}
				if( flag == 0 ) continue;
				d = -1;
				for( int j = len - i ; j < len - 1 ; j++ ){
					if( a[j] != b[++d] ){
						flag = 0;
					}
					if( flag == 0 )	break;
				}
				if( flag == 0 ) continue;
				if( flag == 1 ){
					check = 1;
				}
			}
			if( check == 1 )	break;
		}
		if( check == 1 )	printf("Yes\n");
		else	printf("No\n");
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define RREP(i, s, n) for (int i = s; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;
using ll = long long;
typedef pair<int, int> pint;
typedef pair<ll, ll> pll;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;
const int inf = (1<<29);

int main() {

    ll n;
    cin >> n;
    
    ll sum = 0;
    RREP(i, 1, n+1) {
        if (!(i % 3 == 0) && !(i % 5 == 0))
            sum += i;
    }

    cout << sum << endl;
    

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

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

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

typedef long long ll;
const ll MOD = 1e9 + 7;

int main() {
  ll N;
  std::cin >> N;

  if(N % 2 == 1) {
    std::cout << 0 << '\n';
    return 0;
  }

  ll two = N / 2;
  ll five = 0;
  ll x = 5;

  while(N / 2 / x > 0) {
    five += N / 2 / x;
    x *= 5;
  }

  std::cout << std::min(two, five) << '\n';

}


Measured memory_bytes: 764
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
const int N = 2e5 + 1;
int a[N] , avail[N] , b[N] , c[N];
int n , q;
vector <int> V;
void compress(){
    V.push_back(-1);
    for (int i = 1; i <= n; i++) V.push_back(a[i]);
    for (int i = 1; i <= q; i++){
        V.push_back(b[i]);
        V.push_back(c[i]);
    }
    sort(V.begin(),V.end());
    V.resize(unique(V.begin(),V.end()) - V.begin());
    for (int i = 1; i <= n; i++) a[i] = lower_bound(V.begin(),V.end(),a[i]) - V.begin();
    for (int i = 1; i <= q; i++){
        b[i] = lower_bound(V.begin(),V.end(),b[i]) - V.begin();
        c[i] = lower_bound(V.begin(),V.end(),c[i]) - V.begin();
    }
}   
int main(){
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> a[i];
    cin >> q;
    for (int i = 1; i <= q; i++) cin >> b[i] >> c[i];
    compress();
    long long sum = 0;
    for (int i = 1; i <= n; i++){
        sum = sum + V[a[i]];
        avail[a[i]]++;
    }
    for (int i = 1; i <= q; i++){
        sum = sum - 1LL * V[b[i]] * avail[b[i]];
        sum = sum + 1LL * V[c[i]] * avail[b[i]];
        avail[c[i]] += avail[b[i]];
        avail[b[i]] = 0;
        cout << sum << "\n";
    }
    return 0;
}

Measured memory_bytes: 6444
import java.util.Scanner;
import java.util.Arrays;
class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int N = scan.nextInt();
    if (N % 10 == 3) {
      System.out.println("bon");
    }
    else if (N % 10 == 0 || N % 10 == 1 || N % 10 == 6 || N % 10 == 8) {
      System.out.println("pon");
    }
    else{
      System.out.println("hon");
    }
    
  }
}



Measured memory_bytes: 35768
#pragma once
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
using namespace std;
typedef long long ll;
void GridColoring() {

	int h, w, n;
	cin >> h >> w >> n;
	int t[10010];
	for (size_t i = 0; i < n; i++)
	{
		cin >> t[i];
	}
	t[n] = -1;
	int tx[4] = { 1,0,-1,0 };
	int ty[4] = { 0,1,0,-1 };
	int table[101][101];
	for (size_t i = 0; i < 101; i++)
	{
		for (size_t j = 0; j < 101; j++)
		{
			table[i][j] = -1;
		}
	}

	int nx = 0;
	int ny = 0;
	int ti = 0;
	table[0][0] = 1;
	t[0]--;

	while (t[ti] != -1)
	{
		for (int i = 0; i < 4; i++)
		{
			while (t[ti] > 0)
			{
				int x = nx + tx[i];
				int y = ny + ty[i];
				if (x < 0 || x >= w || y < 0 || y >= h) {
					break;
				}
				if (table[y][x] != -1) break;
				nx = x;
				ny = y;
				table[y][x] = ti + 1;

				t[ti]--;
			}

			if (t[ti] == 0) {
				ti++;
				i--;
				continue;
			}
		}
	}


	for (size_t i = 0; i < h; i++)
	{
		for (size_t j = 0; j < w; j++)
		{
			cout << table[i][j] << " ";
		}
		cout << endl;
	}
}

int main() {
	GridColoring();
	return 0;
}



Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define I_L_Z_D ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); 

std:: vector<int> v[300008];

int32_t main(){
 I_L_Z_D ;

int n = 5;
int t;
int a[n],cnt=0;

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

  for(int i = 0 ; i < n ;i++){
	  int tot=0;
    for(int j = i+1; j < n ; j++){
        if( a[j]-a[i] <=t) 
			 tot++;               
    }
    
    if(tot==n-i-1)
       cnt++;
   
  }
  
  //cout<<cnt<<endl;
        
        if(cnt!=n)
          cout<<":(";
          
        else
		 cout << "Yay!";       
  return 0;

}


Measured memory_bytes: 7804
N = int(input())
A = [int(i) for i in input().split()]

B = [0] * N
for i in reversed(range(N)):
    B[i] = (A[i] - sum(B[i::i + 1])) % 2

ans = [i + 1 for i, b in enumerate(B) if b == 1]
print(len(ans))
print(*ans)

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

void solve(long long X)
{
    long long value = 100;
    long long cnt = 0;
    while (value < X)
    {
        cnt++;
        value = static_cast<long long>(floor(static_cast<double>(value) * 1.01));
    }
    cout << cnt << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main()
{
    long long X;
    scanf("%lld", &X);
    solve(X);
    return 0;
}


Measured memory_bytes: 3804
from collections import deque
def S(n):
  ans=0
  while n>0:
    ans=ans+n%10
    n=n//10
  return ans
ans=[]
A=[i for i in range(1,10**5)]
for i in range(1,11):
  for j in range(10**4,10**5):
    A.append(j*10**i+10**i-1)
A=A[::-1]
a=10**20
for i in range(len(A)):
  b=A[i]/S(A[i])
  if a>=b:
    ans.append(A[i])
    a=b
ans=ans[::-1]
for i in range(int(input())):
  print(ans[i])

Measured memory_bytes: 111488
#include <iostream>
#include <vector>
#include <cstdlib>
#include <algorithm>

using namespace std;

const int numOfMountain = 10;

int main(){
    int mountainBuf;
    vector<int> mountains;

    for(int i = 0; i < numOfMountain; i++) {
        cin >> mountainBuf;
        mountains.push_back(mountainBuf);
    }

    sort(mountains.begin(), mountains.end());

    vector<int>::iterator out = mountains.end();
    for(int i = 0; i < 3; i++) {
        out--;
        cout << *out << endl;
    }

    return 0;
}


Measured memory_bytes: 3136
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>
using namespace std;
namespace adaptor = boost::adaptors;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
typedef long long ll;

void Main()
{
  int N;
  cin >> N;
  vector<int> A(N+1);
  rep(i,N+1) cin >> A[i];
  vector<int> B(N);
  rep(i,N) cin >> B[i];
  
  ll ans = 0;
  rep(i,N+1){
    if(i!=0){
      	if(B[i-1]>=A[i]){
        	ans += A[i];
        	B[i-1] -= A[i];
        	A[i] = 0;
      	}
      	else{
        	ans += B[i-1];
        	A[i] -= B[i-1];
        	B[i-1] = 0;
      	}
    }
    if(i!=N){
    	if(B[i]>=A[i]){
      		ans += A[i];
      		B[i] -= A[i];
      		A[i] = 0;
    	}
    	else{
      		ans += B[i];
      		A[i] -= B[i];
      		B[i] = 0;
    	}
    }
  }
  cout << ans << endl;
  return; 
}

int main()
{
 cin.tie(nullptr);
 ios_base::sync_with_stdio(false);
 cout << fixed << setprecision(15);
 Main();
 return 0;
}


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        var sc = new Scanner(System.in);
        var n = sc.nextInt();
        var s = sc.next().toCharArray();

        long[] counts = new long[3];
        for (int i = 0; i < n; i++) {
            if (s[i] == 'R') counts[0]++;
            if (s[i] == 'G') counts[1]++;
            if (s[i] == 'B') counts[2]++;
        }

        long ans = counts[0] * counts[1] * counts[2];
        for (int j = 1; j < n - 1; j++) {
            for (int i = 0; i < j; i++) {
                var k = j + (j - i);
                if (k >= n) continue;
                if (s[i] == s[j]) continue;
                if (s[j] == s[k]) continue;
                if (s[k] == s[i]) continue;
                ans--;
            }
        }

        System.out.println(ans);
        sc.close();
    }
}


Measured memory_bytes: 36412
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define ll          long long
#define pb          push_back
#define eb 			emplace_back
#define mp 			make_pair
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define vii         vector<pii>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define all(a)      (a).begin(),(a).end()
#define fi          first
#define si          second
#define sz(x)       (ll)x.size()
#define endl        '\n'
#define checkbit(n, b) ((n >> b) & 1)
#define mod        1000000007
#define puts(n)		cout<<n;
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define setbits(x) __builtin_popcount(x)
#define mset(m,v) memset(m,v,sizeof(m))
using namespace std;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	
	char s[3001],t[3001];
	cin>>s>>t;
	ll n,m;
	n=strlen(s);
	m=strlen(t);
	ll dp[n+1][m+1]={};
	for(ll i=1;i<=n;i++){
		for(ll j=1;j<=m;j++){
			if(s[i-1]==t[j-1]) dp[i][j] = dp[i-1][j-1]+1;
			else dp[i][j] = max(dp[i][j],max(dp[i-1][j] , dp[i][j-1]));
		}
	}
	
	ll i=n,j=m,index=0;
    char ans[3001];
	while(i!=0 && j!=0){
		if(dp[i][j] == dp[i-1][j-1]+1 && s[i-1]==t[j-1] ){
			ans[index] = s[i-1];
			index++;
			i--;
			j--;
		}
		else if(dp[i][j]== dp[i-1][j]){
			i--;
		}
		else{
			j--;
		}
	}
    for(ll i=index-1;i>=0;i--){
    	cout<<ans[i];
	}
	return 0;
}


Measured memory_bytes: 70656
#include <cstdlib>
#include<iostream>
#include<string>
#include <algorithm>
#include<array>
using namespace std;

int main() {

	string s,str;
	cin >> s;
	int n = s.size(),i;
	for (i = 0; i < n; i++) {
		if (i % 2 == 0) {
			str += s.substr(i, 1);
		}
	}
	cout << str << "\n"; 
}

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

int main()
{
	vector<int> v;

	for (int i = 0; i < 3; i++) {
		int x; cin >> x;
		v.push_back(x);
	}

	sort(v.begin(), v.end());

	if (v[0] + v[1] == v[2]) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
using Int = int64_t;
int main() {
    Int N, ans = 0, t = 10;
    cin >> N;
    while (N >= t) {
        ans += N / t;
        t *= 5;
    }
    cout << (N & 1 ? 0 : ans) << endl;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    var s = readLine()!!
    when (s) {
        "SUN" -> println(7)
        "MON" -> println(6)
        "TUE" -> println(5)
        "WED" -> println(4)
        "THU" -> println(3)
        "FRI" -> println(2)
        else -> println(1)
    }
}

Measured memory_bytes: 31800
<?php
$n = trim(fgets(STDIN));
$last = false;
$ok = true;
for($i = 0; $i < $n; $i++){
    $str = trim(fgets(STDIN));
    if($last !== false){
        if($str[0] != $last)$ok = false;
    }
    $last = substr($str, -1);
    if(isset($map[$str]))$ok = false;
    $map[$str] = true;
    
}
echo $ok ? "Yes" : "No";


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

const int MAX = 200;
int main() {
	int N, L[MAX];
	cin >> N;
	N <<= 1;
	for (int i = 0;i < N;++ i) cin >> L[i];
	sort(L, L+N);
	int ans = 0;
	for (int i = N - 2;i >= 0;i -= 2) ans += L[i];
	cout << ans;
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり
また、コンテスト後に https://31536000.hatenablog.com/ で解説していると思うので、良かったら読んでねー

串をソートする
ここで、A_1≦A_2≦A_3≦A_4に対し、A_1とA_3、A_2とA_4とやるよりA_1とA_2、A_3とA_4とやった方が具材数は増える
よって、基本的に小さい順に取る
ただ、奇数本の時はどう考えても一番小さい串が不要なので、むしろ大きい順に取っていくと良い
*/

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
 const ll INF = 1e18;
//const ll MOD = 1e9+7;
//const double pi = 3.14159265358979;
using vl = vector<ll>;
# define rep(i, n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(ll i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(ll i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(ll i=((int)(n)); i>0; --i)
# define all(x) (x).begin(), (x).end()

ll N, M, X;
ll minSum = INF;
ll A[13][13] = {0};
ll C[13] = {0};
struct Points {
    ll val[13];
};

void dfs(ll money, ll i, ll depth, Points points) {
    if (i == N) {
        return;
    }
    if (depth == N) {
        return;
    }
    
    money += C[i];
    rep(j, M) {
        points.val[j] += A[i][j];
    }
    bool flag = true;
    rep(j, M) {
        if (points.val[j] < X) {
            flag = false;
            break;
        }
    }
    
    if(flag) {
        minSum = min(minSum, money);
    }
    
    for(ll k=i+1; k<N; k++) {
        dfs(money, k, depth+1, points);
    }
}

int Main() {
    cin >> N >> M >> X;

    rep(i,N) {
        cin >> C[i];
        rep(j,M) {
            cin >> A[i][j];
        }
    }
    
    rep(i, N) {
        auto points = new Points;
        dfs(0, i, 0, *points);
    }
    
    if (minSum == INF) {
        cout << "-1" << endl;
    } else {
        cout << minSum << endl;
    }
    
    return 0;
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 3664
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <string.h>
#include <vector>
#include <functional>
#include <queue>

using namespace std;
typedef long long ll;

int Calc(char alphabet, int FirstN, char s[]){
		while(true){
		int N = strlen(s);
		
		// ループ抜け判定
		bool AllSame = true;
		for(int i = 0; i < N-1; i++){
			if(s[i] != s[i+1]){
				AllSame = false;
			}
		}
		
		if(AllSame){
			return FirstN - N;
			break;
		}
		
		// 文字列変形処理
		char newS[101];
		bool skiped = false;
		for(int i = 0; i < N; i++){
			if(skiped){
				if(s[i] == alphabet || s[i-1] == alphabet){
					newS[i-1] = alphabet;
				}else{
					newS[i-1] = s[i];
				}
			}
			else{
				if(s[i] == alphabet || (i < N-1 && s[i+1] == alphabet)){
					newS[i] = alphabet;
				}else{
					skiped = true;
				}
			}
		}
		newS[N-1] = '\0';
		
		strcpy(s, newS);
	}
}

int main()
{
	char s[101];
	cin >> s;
	
	int N = strlen(s);
	
	int ans = 999;
	for(int i = 0; i < 26; i++){
		char S[101];
		strcpy(S, s);
		int count = Calc(char(i+97), N, S);
		if(count < ans){
			ans = count;
		}
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
if isfile("mystdin.txt");mystdin=open("mystdin.txt","r");redirect_stdin(mystdin);end
pI(x)=parse(Int,x)
pM(x::Array{SubString{String},1})=map(pI,x)
function main()
  n,k=pM(split(readline()))
  h=[pI(readline()) for i=1:n]
  sort!(h)
  println(minimum([h[i+k-1]-h[i] for i=1:n-k+1]))
end
main()
if isdefined(Base, :mystdin);close(mystdin);end

Measured memory_bytes: 135132
# -*- coding: utf-8 -*-
'''
所要時間は、分位であった。
'''


# ライブラリのインポート
#import re
import sys
input = sys.stdin.readline
#import heapq
#import bisect
from collections import deque
#import math

def main():
    n = int(input())
    for _ in range(n): 
        IN = input().strip()
        exp1 = calcmold(IN)
        exp2 = calc1(exp1)
        exp3 = calcmult(exp2)
        print(calcplus(exp3))

def calcmold(exp):
    # seikei
    tmp = ""
    EXP = deque()
    oplist = ["+","-","*","/","(",")","="]
    for i in range(len(exp)):
        if exp[i] not in oplist:
            tmp += exp[i]
        else:
            if tmp == "":
                EXP.append(exp[i])
                continue
            EXP.append(int(tmp))
            EXP.append(exp[i])
            tmp = ""
    return EXP


def calc1(IN):
    #calculate()
    EXP = deque()
    while(IN):
        check = IN.popleft()
        if check == ")":
            TMP = deque()
            while(1):
                look = EXP.pop()
                if look == "(": break
                TMP.appendleft(look)
            TMP.append("=")
            EXP.append(calcplus(calcmult(TMP)))
        else: EXP.append(check)
    return EXP
        


def calcmult(exp):
    # no()
    EXP = deque()
    while(exp):
        check = exp.popleft()
        if check == "*":
            arg1 = EXP.pop()
            arg2 = exp.popleft()
            EXP.append(arg1*arg2)
        elif check == "/":
            arg1 = EXP.pop()
            arg2 = exp.popleft()
            EXP.append(int(arg1/arg2))
        else: EXP.append(check)
    return EXP


def calcplus(exp):
    # no()
    EXP = deque()
    while(exp):
        check = exp.popleft()
        if check == "+":
            arg1 = EXP.pop()
            arg2 = exp.popleft()
            EXP.append(arg1+arg2)
        elif check == "-":
            arg1 = EXP.pop()
            arg2 = exp.popleft()
            EXP.append(arg1-arg2)
        elif check == "=":
            return EXP.pop()
        else: EXP.append(check)
    return EXP
if __name__ == '__main__':
    main()



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

#define REP(i, n) for (int i = 0; i < (n); i++)
#define FOR(i, init, n) for (int i = init; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define fi first
#define se second

using namespace std;
using ll = long long int;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using edge = struct
{
    int to, cost;
};

const int MOD = 1e9 + 7;
const int iINF = 1e9;
const long long int llINF = 1e18;
const double PI = acos(-1.0);

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

int main()
{
    int coins[6] = {1, 5, 10, 50, 100, 500};

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

    int value;
    reverse(coins, coins + 6);

    while (cin >> value, value)
    {
        value = 1000 - value;

        int ans = 0;

        REP(i, 6)
        {
            ans += value / coins[i];

            value %= coins[i];
        }

        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 3084
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(k,i,n) for(ll i=k;i<n;++i)
#define mod 1000000007
int main(void){
    ll h,w;
    cin>>h>>w;
    bool st[h][w];
    rep(0,i,h){
        string s0;
        cin>>s0;
        rep(0,j,w){
            string s00=s0.substr(j,1);
            if(s00=="#")st[i][j]=false;
            else st[i][j]=true;
        }
    }
    ll l[h][w],r[h][w],u[h][w],d[h][w];
    rep(0,i,h){
        rep(0,j,w){
            if(j==0){
                if(st[i][j])l[i][j]=1;
                else l[i][j]=0;
            }else{
                if(st[i][j])l[i][j]=l[i][j-1]+1;
                else l[i][j]=0;
            }
        }
    }
    rep(0,i,h){
        rep(0,j,w){
            ll x=w-1-j;
            if(!st[i][x])r[i][x]=0;
            else{
                if(j==0)r[i][x]=1;
                else r[i][x]=r[i][x+1]+1;
            }
        }
    }
    rep(0,i,w){
        rep(0,j,h){
            if(!st[j][i])u[j][i]=0;
            else{
                if(j==0)u[j][i]=1;
                else u[j][i]=1+u[j-1][i];
            }
        }
    }
    rep(0,i,w){
        rep(0,j,h){
            ll x=h-1-j;
            if(!st[x][i])d[x][i]=0;
            else{
                if(j==0)d[x][i]=1;
                else d[x][i]=1+d[x+1][i];
            }
        }
    }
    ll ans=0;
    rep(0,i,h){
        rep(0,j,w){
            ans=max(ans,u[i][j]+d[i][j]+l[i][j]+r[i][j]-3);
            //cout<<u[i][j]<<" "<<d[i][j]<<" "<<l[i][j]<<" "<<r[i][j]<<endl;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 129152
import sys

# 入力を整数に変換して受け取る
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def MI1(): return map(int1, sys.stdin.readline().split())
# 入力全てを整数に変換したものの配列を受け取る
def LI(): return list(map(int, sys.stdin.readline().split()))
# 入力全てを整数に変換して1引いたものの配列を受け取る
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SR(): return sys.stdin.readline().rstrip()

ascii_lowercase = 'abcdefghijklmnopqrstuvwxyz'
ascii_uppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
ascii_uppercase2 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ'

# リストを改行区切りで出力する
p2D = lambda x: print(*x, sep="\n")
p2E = lambda x: print(''.join(x))


n,k=MI()
h=LI()

ans = 0
for H in h:
    if H >= k:
        ans+=1
print(ans)



Measured memory_bytes: 11892
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1000000007;
const ld PI = acos(-1);  
const ld EPS = 0.0000000001;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define rep(i, n) for(ll i=0; i<(ll)(n); i++)
#define repd(i, n) for(ll i=n-1; 0<=i; i--)
#define FOR(i, a, b) for(ll i=a; i<(ll)(b); i++)
#define FORD(i, a, b) for(ll i=b-1; (ll)(a)<=i; i--)
#define ALL(x) x.begin(), x.end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};


int main(){
    ll n;   cin >> n;
    vector<vector<ll>> g(n);
    rep(i, n-1){
        ll a, b;    cin >> a >> b;
        a--;    b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    vector<ll> cost(n, 0), c(n);
    rep(i, n)   cin >> c[i];
    sort(ALL(c), greater<ll>());
    queue<ll> que;
    que.push(0);
    ll i=0, res=0;
    cost[0] = c[i++];
    while(!que.empty()){
        ll v = que.front();  que.pop();
        for(auto nv: g[v]){
            if(0<cost[nv]) continue;
            cost[nv] = c[i++];
            que.push(nv);
            res += min(cost[nv], cost[v]);
        }
    }
    cout << res << endl;
    rep(i, n) cout << cost[i] << ' ';
}


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

int main() {
  int N, A;
  int count;
  int ans;
  
  cin >> N;
  
  for (int i = 0; i < N; i++) {
    cin >> A;
    count = 0;
    
    while (A % 2 == 0) {
      A /= 2;
      count++;
    }
    
    if (i == 0) {
      ans = count;
    }
    else if (ans > count) {
      ans = count;
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 3516
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define P pair<ll, ll>
#define Graph vector<vector<ll>>
#define fi first
#define se second
constexpr ll mod = 1000000007;
constexpr ll INF = (1ll << 60);
constexpr double pi = 3.14159265358979323846;
template <typename T>
inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}

int main() {
    ll x;
    cin >> x;
    if (x <= 3) {
        cout << 1 << "\n";
        return 0;
    }

    ll ans = 0;
    rep(i, x + 1) {
        if (i == 0) continue;
        ll ins = i, cnt = 0;
        rep(j, x + 1) {
            if (j == 0 || j == 1) continue;

            while (ins % j == 0) {
                cnt++;
                ins /= j;
            }

            if (ins != 1) {
                ins = i;
                cnt = 0;
                continue;
            }
            if (cnt < 2) {
                ins = i;
                cnt = 0;
                continue;
            }

            ans = i;
            ins = i;
            cnt = 0;
            break;
        }
    }

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

Measured memory_bytes: 3604
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
typedef long long ll;


int main()
{
    char s[1500];
    scanf("%s",s);

    int a=strlen(s);
    if(s[a-1]=='s')
    {
        printf("%ses\n",s);
    }
    else
    {
        printf("%ss\n",s);
    }
    

    return 0;
}

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

#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define repd(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define forr(i,a,b) for(ll i=(a);i<=(b);i++)
#define ford(i,a,b) for(ll i=(a);i>=(b);i--)
#define all(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define size(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 10000007 //10^9+7
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define MAXR 100000 //10^5:最大のrange(素数列挙などで使用)



int main(void) {
    long int a,ans=0,b,i;
    cin >> a;
    cin >> b;
    if(a*b % 2 == 0){
        cout << "Even" << "\n";
    }
    else{
        cout << "Odd" << "\n";
    }


    

  return 0;
}

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

using namespace std;

int main()
{

    int a,b,c,d;

    scanf("%d%d",&a,&b);

    if(a>=0 && b<=100){
        c = a*3;
        d = (b+c)/2;
        printf("%d\n",d);
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define rep(X,N) for(int X = 0; X < N; X++)
#define PI (acos(-1.0))

using namespace std;

int main(){

    int x[3];

    cin >> x[0] >> x[1] >> x[2];

    int mods[3] = {x[0] % 2, x[1] % 2, x[2] % 2};

    int ans = 0;

    if(mods[0] + mods[1] + mods[2] == 2 | mods[0] + mods[1] + mods[2] == 1){

        rep(i,2){
            for(int j = i + 1; j <= 2; j++){
                if(mods[i] == mods[j]){
                    x[i]++;
                    x[j]++;
                }
            }
        }

        ans++;
    
    }

    int most = max(x[0], max(x[1], x[2]));
    ans = ans + (most - x[0]) / 2 + (most - x[1]) / 2 + (most - x[2]) / 2;

    cout << ans << endl;

    return 0;
}

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


int main (){
    int A, B, C;

    cin>>A>>B>>C;
    vector<int> Vec(3);
    Vec={A, B, C};
    sort(Vec.begin(), Vec.end());
    cout<<Vec.at(0)* Vec.at(1)/2<<endl;
}

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

int solve(int i, int m, int n, int A[])
{
	int d[21][2001];
	
	if(m==0) return 1;
	if(i>=n) return 0;
	if(d[i][m]!=0) return d[i][m];
	if(solve(i+1,m,n,A)==1 || solve(i+1,m-A[i],n,A)==1) return d[i][m]=1;
	else return d[i][m]=0;
}

int main()
{
	int i,n,A[20],q,m;
	
	scanf("%d",&n);
	for(i=0;i<=n-1;i++) scanf("%d",&A[i]);
	scanf("%d",&q);
	for(i=0;i<=q-1;i++)
	{
		scanf("%d",&m);
		if(solve(0,m,n,A)==1) printf("yes\n");
		else printf("no\n");
	}
	return 0;
}

Measured memory_bytes: 3232
# -*- coding: utf-8 -*-
"""
B - Ordinary Number
https://atcoder.jp/contests/abc132/tasks/abc132_b

"""
import sys


def solve(numbers):
    ans = 0
    for a, b, c in zip(numbers, numbers[1:], numbers[2:]):
        t = sorted([a, b, c])
        ans += t[1] == b
    return ans


def main(args):
    _ = input()
    numbers = [int(x) for x in input().split()]
    ans = solve(numbers)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])


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

namespace c
{
    class Program
    {
        static void Main(string[] args)
        {
            var _ = Console.ReadLine().Split();
            var n = int.Parse(_[0]);
            var m = int.Parse(_[1]);

            var t = new Tuple<int,int,int>[m];
            for(var i = 0; i < m; i++){
                var __ = Console.ReadLine().Split();
                var p = int.Parse(__[0]);
                var y = int.Parse(__[1]);
                t[i] = Tuple.Create(i, p, y);
            }

            var id = new string[m];
            var count = new int[n];
            foreach(var x in t.OrderBy(i => i.Item2).ThenBy(i => i.Item3)){
                id[x.Item1] = string.Format("{0:D6}{1:D6}",x.Item2,count[x.Item2-1]+1);
                count[x.Item2-1]++;
            }

            foreach(var x in id){
                Console.WriteLine(x);
            }
        }
    }
}


Measured memory_bytes: 32660
#include<bits/stdc++.h>
using namespace std;
int  main()
{
  int N;
   cin >> N;
  int swim[N];
  int bug[N];
  int home[N];

  cin >> swim[0] >> bug[0] >> home[0];
  for(int i=1;i<N;i++)
  {
   cin >> swim[i] >> bug[i] >> home[i];
    swim[i]+=max(bug[i-1],home[i-1]);
    bug[i]+=max(swim[i-1],home[i-1]);
    home[i]+=max(bug[i-1],swim[i-1]);
  }
  
  cout << max(max(swim[N-1],home[N-1]),bug[N-1]);
  
  
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int cnt=0;
    string s,rev;
    cin>>s;
    rev=s;
    reverse(rev.begin(),rev.end());
    for(int i=0;i<s.size();i++)
    {
        if(s[i]!=rev[i])
            cnt++;
    }
    if(cnt%2==0)
        cout<<cnt/2<<endl;
    else cout<<cnt<<endl;

    return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;	cin >> n;
  priority_queue<double, vector<double>, greater<double>>	v;
  for(int i=0;i<n;i++){
    double x;	cin >> x;
    v.push(x);
  }
  
  for(int i=0;i<n-1;i++){
    double x=v.top();	v.pop();
    double y=v.top();	v.pop();
    v.push((x+y)/2);
  }
  printf("%.10f",v.top());
}

Measured memory_bytes: 3776
s = input()
head = int(s[:2])
tail = int(s[2:])

is_mmyy = False
is_yymm = False

if 1 <= head <= 12:
    is_mmyy = True

if 1 <= tail <= 12:
    is_yymm = True

if is_yymm and is_mmyy:
    print('AMBIGUOUS')
elif is_yymm:
    print('YYMM')
elif is_mmyy:
    print('MMYY')
else:
    print('NA')


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

int main() {
  ll a, b, c, k;
  cin >> a >> b >> c >> k;
  int sum = 0;
  if (a < k) {
    sum += a;
    k -= a;
  } else {
    sum += k;
    cout << sum << endl;
    return 0;
  }
  
  if (b < k) {
    k -= b;
    sum -= k;
    cout << sum << endl;
    return 0;
  } else {
    cout << sum << endl;
    return 0;
  }
  

  return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end() 
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define INF 1000000000
using namespace std;
typedef long long ll;

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

    ll ans = K;
    FOR(i, 1, N-1){
        ans = ans*ll(K-1);
    }

    cout << ans << endl;
}


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

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))

#define INF 2e9
#define INF_LL 1LL<<60
#define ll long long

typedef pair<ll, ll> P;

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

int main(){
    int n, ans = 0; cin >> n;
    vector<int> h(n);
    REP(i, n) cin >> h[i];

    int idx = 0;

    while(1){
        bool new_0 = true;

        REP(i, n) {
            if(h[i] > 0 && new_0) {
                ans++, h[i]--;
                new_0 = false;
            } else if (h[i] > 0 && !new_0) {
                h[i]--;
            } else if(i != 0 && i != n-1){
                new_0 = true;
            }
        }
        /*
        REP(i, n){
            cout << h[i] << " ";
        }

        cout << endl;
        */


        bool isALL = true;
        REP(i, n) if(h[i] != 0) isALL = false;
        
        if(isALL) break;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp3
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int a = int.Parse(input[0]);
            int b = int.Parse(input[1]);

            if ((a * b) % 2 != 0) { Console.WriteLine("Odd"); } else { Console.WriteLine("Even"); }
        }
    }
}


Measured memory_bytes: 11092
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();

		int minus = 0;
		boolean zero = false;
		for (int i = a; i <= b; i++) {
			if (i < 0) minus++;
			if (i == 0) zero = true;
		}

		if (zero) {
			System.out.println("Zero");
		} else if (minus % 2 == 0) {
			System.out.println("Positive");
		} else {
			System.out.println("Negative");
		}

		sc.close();
	}

}


Measured memory_bytes: 35864
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cstring>
#include <set>
#include <map>
#include <list>
 
using namespace std;
 
int main() {
	int n;
	cin >> n;
    string result = "";
	for(int i=0; i<n; i++){
	    int d1,d2;
	    cin >> d1 >> d2;
	    if(d1 == d2){
	        result+="A";
	    }else{
	        result+="B";
	    }
	}
	if(result.find("AAA") != std::string::npos){
	    cout << "Yes" << endl;
	}else{
	    cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 3624
#include<iostream>
using namespace std;
int main()
{
    int N,maxm=0, x=0;
    cin>>N;
 char S[N];


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

if(S[i]=='I')
   {
      x++;}
    else
    if(S[i]=='D')
    { x--;}
if( x>=maxm)
      {

        maxm= x;}
}


cout<<maxm;
return 0;
}


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

using namespace std;


int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++) {
        cin >> a[i];
    }
    long long ans = 0;
    int cur = a[0];
    for(int i = 0; i < n; i++) {
        if(cur > a[i]) {
            ans += (cur - a[i]);
        } else {
            cur = a[i];
        }
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 4012
#include<iostream>
#include<string>

using namespace std;

int main(int argc, char* argv[])
{
  int number;
  int taro_point=0;
  int hanako_point=0;
  string taro,hanako;
  cin >> number;
  for(int i=0;i<number;i++)
  {
    cin >> taro >> hanako;
    if(taro>hanako) taro_point+=3;
    else if(hanako>taro) hanako_point+=3;
    else
    {
      taro_point+=1;
      hanako_point+=1;
    }
  }
  cout << taro_point << " " << hanako_point << endl;
}

Measured memory_bytes: 3192