akhauriyash/Code-Regression huggingface dataset:
fun main(args: Array<String>) {
    val sc = java.util.Scanner(System.`in`)
    val s = sc.next()

    val y: Set<String> = (100..199).map { it.toString().substring(1) }.toSet()
    val m: Set<String> = (101..112).map { it.toString().substring(1) }.toSet()

    val left = s.substring(0..1)
    val right = s.substring(2..3)

    val mmyy = m.contains(left) && y.contains(right)
    val yymm = m.contains(right) && y.contains(left)

    val r = if (yymm && mmyy) {
        "AMBIGUOUS"
    } else if (mmyy) {
        "MMYY"
    } else if (yymm) {
        "YYMM"
    } else {
        "NA"
    }

    println(r)

}

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define each(i,c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define all(v) v.begin(), v.end()
#define mset(a, n) memset(a, n, sizeof(a))

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;

const int INF = 1000000000;
const int MOD = 1000000007;
const double eps = 1e-9;

int main(int argc, char *argv[]) {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    int N, T, pre = 0;
    cin >> N >> T;
    ll ans = T;
    rep(i, N) {
        int t; cin >> t;
        if (t - pre >= T) ans += T;
        else ans += t - pre;
        pre = t;
    }
    cout << ans << endl;
    return 0;
}

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

template <typename InputIterator>
typename InputIterator::value_type summation(InputIterator first,
                                             InputIterator last) {
  return std::accumulate(first, last, typename InputIterator::value_type());
}
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v);
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p);
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v) {
  for (auto &i : v) {
    stream >> i;
  }
  return stream;
}
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p) {
  stream >> p.first >> p.second;
  return stream;
}

int main() {
  std::string s;
  std::cin >> s;
  s[5] = ' ';
  s[13] = ' ';
  std::cout << s << std::endl;
  return 0;
}


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

namespace Practice
{
    class Program
    {
        static void Main(string[] args)
        {
            SolveA();
            //SolveB();
            //SolveC();
            //SolveD();
        }
        private const long MOD = 1000000007;
       
        static void SolveA()
        {
            string s = Console.ReadLine();
            string t = Console.ReadLine();
            var listS = new List<char>(s);
            var listT = new List<char>(t);

            listS.Sort();
            listT.Sort();

            bool b = IsValid0(listS, listT) || IsValid1(listS, listT);
            string ans = b ? "Yes" : "No";
            Console.WriteLine(ans);
        }
        private static bool IsValid0(List<char> s, List<char> t)
        {
            if( s.Count >= t.Count) { return false; }
            for(int i=0;i<s.Count;++i)
            {
                if(s[i] != t[i]) { return false; }
            }
            return true;
        }
        private static bool IsValid1(List<char> s, List<char> t)
        {
            for(int i=0;i<s.Count;++i)
            {
                char c = s[i];
                for(int j=i;j<t.Count;++j)
                {
                    if( t[j] > c)
                    {
                        return true;
                    }
                }
                // 同一はあるか？
                if( i >= t.Count) { return false; }
                if( c != t[i]) { return false; }
            }
            return false;
        }

        #region よく使う便利関数
        private static bool isPrime(long x)
        {
            if( x == 2) { return true; }
            if( x < 2 || x % 2 == 0) { return false; }
            long i = 3;
            while( i * i <= x)
            {
                if( x % i == 0) { return false; }
                i = i + 2;
            }
            return true;
        }
        private static long lcm(long x, long y)
        {
            return x / gcd(x, y) * y;
        }
        private static long gcd(long x, long y)
        {
            return y > 0 ? gcd(y, x % y) : x;
        }

        private static int ReadAndParseInt()
        {
            return int.Parse(Console.ReadLine());
        }
        private static int[] ReadAndParseIntArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
        }
        private static long ReadAndParseLong()
        {
            return long.Parse(Console.ReadLine());
        }
        private static long[] ReadAndParseLongArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
        }
        #endregion
    }
}

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

int main(){
	int n;
	cin>>n;
	vector<long long int> a(n);
	for(int i=0;i<n;i++) cin>>a[i];
	vector<int> seq;
	priority_queue<long long int> mount;
	int pre=0;
	for(int i=0;i<n;i++){
		if(i==0){
			seq.push_back(0);
			pre=a[i];
		}
		else if(pre<a[i]){
			seq.push_back(i);
			pre=a[i];
		}
		mount.push(a[i]);
	}
	vector<long long int> res(n,0LL);
	int flatted=0;
	for(int i=seq.size()-1;i>0;i--){
		if(flatted!=0){
			res[seq[i]]+=(a[seq[i]]-a[seq[i-1]])*flatted;
		}
		while(true){
			long long int val=mount.top();
			if(val<=a[seq[i-1]]){
				break;
			}
			mount.pop();
			res[seq[i]]+=(val-a[seq[i-1]]);
			flatted++;
		}
		if(i==1) break;
		while(true){
			int val=mount.top();
			if(val==a[seq[i-1]]){
				flatted++;
				mount.pop();
			}
			else{
				break;
			}
		}
	}
	res[0]=accumulate(a.begin(),a.end(),0LL)-accumulate(res.begin(),res.end(),0LL);
	for(int i=0;i<n;i++)cout<<res[i]<<endl;
	return 0;

}


Measured memory_bytes: 4468
#include "stdio.h"
 
int main()
{
	int A = 0;
	int B = 0;
	int C = 0;
	int X = 0;
 
	scanf("%d", &A);
	scanf("%d", &B);
	scanf("%d", &C);
	scanf("%d", &X);
 
	if (A < 0 || B < 0 || C < 0){
		return -1;
	}
 
	if (A > 50 || B > 50 || C > 50){
		return -1;
	}
 
	if (X < 50 || X > 20000){
		return -1;
	}
 
	int count = 0;
	int result = 0;
	for (int loop = 0; loop <= A; ++loop) {
		for (int loop2 = 0; loop2 <= B; ++loop2) {
			for (int loop3 = 0; loop3 <= C; ++loop3) {
				result = loop * 500 + loop2 * 100 + loop3 * 50;
				if (result == X) {
					++count;
				}
			}
		}
	}
 
	printf("%d", count);
 
	return 0;
}


Measured memory_bytes: 128
def main():
    s = input()
    k = int(input())

    def f(s):
        prev = "A"
        cnt = 0
        for e in s:
            if e == prev:
                cnt += 1
                prev = "A"
            else:
                prev = e

        return cnt

    li = [f(s*i) for i in range(6)]

    if k < 6:
        ans = li[k]

    else:
        idx = 5 - (k + 1) % 2
        d = li[idx] - li[idx-2]
        ans = li[idx] + d * (k - idx) // 2
        #d = li[5] - li[4]
        #ans = li[5] + d * (k - 5)

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
#include<iostream>
#include<vector>
std::vector<std::vector<int>> list(200000);
std::vector<bool> check(200000);

int ans;
int N,M;

int search(int i){
	int tmpans = 1;
	check[i] = true;
	for(auto j:list[i]){
		if(check[j]==true){
			continue;
		}
		tmpans+=search(j);
	}
	return tmpans;
}


int main(){

	std::cin >> N>>M;

	int tmpa, tmpb;
	for (int i = 0; i < M;i++){
		std::cin >> tmpa >> tmpb;
		list[tmpa-1].push_back(tmpb-1);
		list[tmpb-1].push_back(tmpa-1);
	}

	for (int i = 0; i < N;i++){
		if(check[i]==true){
			continue;
		}
		ans = std::max(ans, search(i));
	}

	std::cout << ans << std::endl;
}

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

bool isprime(int a){
	int b=sqrt(a);
	if(a==2)
	return true;
	if(a==1||a!=2&&a%2==0)
	return false;
	for(int i=3;i<=b;i++){
	if(a%i==0){
	return false;
		break;
	}
	if(i==b)
	return true;
}
}
main(){
	int n,ans;
  ans=0;
	scanf("%d",&n);
	int a[n];
  for(int u=0;u<n;u++)
  scanf("%d",&a[u]);
	for(int i=0;i<n;i++){
		if(isprime(a[i]))
		ans++;
	}
	printf("%d\n",ans);
	return 0;
}




Measured memory_bytes: 3220
#include<stdio.h>
#include<stdlib.h>
#include<math.h>

typedef long long int int64;

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

typedef struct rangeMinimumQueryDataStructure{
  int *a;
  int *b;
  int n;
  int sq;
} rmq;

rmq* newRMQ(int n,int ini){
  rmq *res=(rmq *)malloc(sizeof(int)*n);
  int sq=sqrt(n);
  res->n=n;
  res->sq=sq;
  res->a=(int *)malloc(sizeof(int)*n);
  res->b=(int *)malloc(sizeof(int)*((n+sq-1)/sq));
  int i;
  for(i=0;i<n;i++) res->a[i]=ini;
  for(i=0;i<(n+sq-1)/sq;i++) res->b[i]=ini;
  return res;
}

void update(rmq *a,int i,int x){
  int n=a->n;
  int sq=a->sq;
  a->a[i]=x;
  int min=x;
  int j;
  for(j=i/sq*sq;j<n && j<(i/sq+1)*sq;j++){
    min=MIN(min,a->a[j]);
  }
  a->b[i/sq]=min;
  return;
}

int find(rmq *a,int s,int t){
  int sq=a->sq;
  if(t-s<=2*sq){
    int min=a->a[s];
    int i;
    for(i=s+1;i<t;i++){
      min=MIN(min,a->a[i]);
    }
    return min;
  }
  int min=a->a[s];
  int i;
  for(i=s+1;i<(s/sq+1)*sq;i++) min=MIN(min,a->a[i]);
  for(;i+sq<t;i+=sq) min=MIN(min,a->b[i/sq]);
  for(;i<t;i++) min=MIN(min,a->a[i]);
  return min;
}

void run(void){
  int n,q;
  scanf("%d%d",&n,&q);
  rmq *a=newRMQ(n,2147483647);
  while(q--){
    int c,x,y;
    scanf("%d%d%d",&c,&x,&y);
    if(c==0){
      update(a,x,y);
    } else {
      printf("%d\n",find(a,x,y+1));
    }
  }
  return;
}

int main(void){
  run();
  return 0;
}



Measured memory_bytes: 2220
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h, w;
    cin >> h >> w;
    vector<string> s(h + 2);
    s[0] = string(w + 2, '.');
    FOR(i, 1, h) {
        string temp_s;
        cin >> temp_s;
        s[i] = '.' + temp_s + '.';
    }
    s[h + 1] = string(w + 2, '.');

    FOR(i, 1, h)FOR(j, 1, w)if(s[i][j] == '#') {
        if( s[i + 1][j] == '.' and 
            s[i - 1][j] == '.' and 
            s[i][j + 1] == '.' and 
            s[i][j - 1] == '.') {
                cout << "No" << endl;
                return 0;
            }        
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace	std;
int main(){

  long long k,sho,ama,ka;
  cin>>k;
  sho=k/50+50;
  ka=k%50;
  ama=sho-(ka+1);
  cout<<"50"<<endl;
  for(int i=0;i<50;i++){
    if(i)cout<<" ";
    cout<<(i<ka?sho:ama);
  }
  cout<<endl;
  return 0;

}




Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var a, b int
	fmt.Scan(&a, &b)

	var ans int
	for i := a; i <= b; i++ {
		if i/10000 == i%10 && i/1000%10 == i/10%10 {
			ans++
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        int c = Integer.parseInt(sc.next());
        int d = Integer.parseInt(sc.next());
        int e = Integer.parseInt(sc.next());
        int k = Integer.parseInt(sc.next());


        if ((e - a) <= k) {
            if ((d - a) <= k) {
                if ((c - a) <= k) {
                    if ((b - a) <= k) {
                        System.out.println("Yay!\n");
                    }
                }
            }
        }
        else
            System.out.println(":(\n");
    }
}


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

#ifdef DEBUG
#define PRINT(x)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#x<<" = "<<(x)<<endl;
#define PRINTA(a,first,last)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#a<<"["<<(first)<<", "<<(last)<<")"<<endl;\
    for (int i=(first);i<(last);++i){cout<<#a<<"["<<i<<"] = "<<(a)[i]<<endl;}
#else
#define PRINT(x)
#define PRINTA(a,first,last)
#endif

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

template <class T, class U> void amax(T& x, U y) {if (x < y) x = y;}
template <class T, class U> void amin(T& x, U y) {if (x > y) x = y;}

int main(void)
{
    constexpr int N_MAX = 100;
    constexpr int K_MAX = 100000;
    int N, K;
    int a[N_MAX];
    cin >> N >> K;
    REP(i, N) cin >> a[i];

    bool win[K_MAX + 1];
    REP(i, K + 1) {
        win[i] = false;
        REP(j, N) {
            if (i - a[j] >= 0) {
                if (win[i - a[j]] == false) {
                    win[i] = true;
                    break;
                }
            } else {
                break;
            }
        }
    }
    if (win[K]) {
        cout << "First" << endl;
    } else {
        cout << "Second" << endl;
    }
    return 0;
}



Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define debug(x) cerr << #x << ": " << x << "\n"
typedef long long ll;

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

  cout << a + a * a + a * a * a << endl;
}

Measured memory_bytes: 3600
from collections import deque

k = int(input())

def lunlun(n):
  d = deque(range(1, 10))
  
  for i in range(n):
    x = d.popleft()
    if x%10 != 0:
      d.append(x*10 + x%10 - 1)
    d.append(x*10 + x%10)
    if x%10 != 9:
      d.append(x*10 + x%10 + 1)
  
  return x

print(lunlun(k))

Measured memory_bytes: 11908
#include<bits/stdc++.h>
using namespace std;
#define int 	long long int

int32_t main(){
	
	string str;
	cin>>str;

	int ans=0;
	for(int i=0;str[i];i++){
		if(str[i]=='-'){
			ans--;
		}
		else
			ans++;
	}
	cout<<ans<<endl;

	return 0;
}




Measured memory_bytes: 3632
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

using ll = long long int ;

const int MAXN=52,MAXM=22;
vector<int> graph[MAXN];

int N,M;
ll dp[1<<MAXM][MAXN];
int depth[MAXN],p[MAXN],mark[MAXN];

void DFS(int cur,int parent,int d=0){
    // printf("%d %d\n",cur,d);
    p[cur]=parent;
    depth[cur]=d;
    for(auto adj:graph[cur]){
        if (adj==parent) continue;
        // puts("OK");
        DFS(adj,cur,d+1);
    }
}

void LCA(int a,int b,int m){
    if (depth[b]>depth[a]) swap(a,b);

    while(depth[a]>depth[b]) {
        mark[a]|=m;
        a=p[a];
    }

    while(a!=b) {
        // printf("%d %d\n",a,b);
        mark[a]|=m;
        mark[b]|=m;
        a=p[a];
        b=p[b];
    }

}

int main(){
    scanf("%d",&N);
    for(int i=0;i<N-1;i++){
        int u,v;
        scanf("%d%d",&u,&v);

        graph[u].push_back(v);
        graph[v].push_back(u);
    }

    DFS(1,1);   

    scanf("%d",&M);
    for(int i=0;i<M;i++){
        int u,v;
        scanf("%d%d",&u,&v);
        LCA(u,v,1<<i);
    }

    dp[0][1]=1;
    for(int e=2;e<=N;e++){
        for(int i=0;i<(1<<M);i++){
            dp[i|mark[e]][e]+=dp[i][e-1];
            dp[i][e]+=dp[i][e-1];
        }
    }

    // for(int i=2;i<=N;i++) printf("%x\n",mark[i]);

    printf("%lld\n",dp[(1<<M)-1][N]);

    return 0;
}

Measured memory_bytes: 429232
def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod
mod = 10**9+7
N = 10**5
g1 = [1, 1]
g2 = [1, 1]
inverse = [0, 1]
for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

N,K=map(int,input().split())
L=list(map(int,input().split()))
L=sorted(L)
s=0
for i in range(N-K+1):
  s+=(cmb(N-i-1,K-1,mod)*(L[N-1-i]-L[i]))%mod
print(s%mod)

Measured memory_bytes: 95052
#include <iostream>
#include <cstdlib>
#include <fstream>
#include <set>
#include <unordered_set>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <map>
#include <unordered_map>
#include <iomanip>
#include <numeric>

using namespace std;

typedef long long ll;

#define forn(i, n) for(int i = 0; i < (int)(n);++i)
#define fore(i, a, b) for(int i = (int)(a); i <= (int)(b); ++i)
#define fi first
#define se second
#define pb push_back
#define pll pair<ll,ll>
#define vi vector<int>
#define vb vector<bool>
#define vvi vector<vi>
#define vpll vector<pll>
#define vll vector<ll>
#define vvll vector<vll>
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()


void fastik() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
}

//ifstream &cin
void solve(){

}


int main() {
    fastik();
    string s;cin>>s;
    ll ans = 0;
    ll n = sz(s);
    fore(i,1,n-1){
        if(s[i-1] == s[i]){
            if(s[i-1] == '0'){
                s[i] = '1';
            }else{
                s[i] = '0';
            }
            ans++;
        }
    }
    cout << ans;
}

Measured memory_bytes: 512
#include<stdio.h>
int main(){
int a[4],b[4],s,t;
scanf("%d %d %d %d \n %d %d %d %d",&a[0],&a[1],&a[2],&a[3],&b[0],&b[1],&b[2],&b[3]);
s = a[0]+a[1]+a[2]+a[3];
t = b[0]+b[1]+b[2]+b[3];
if(s>t)printf("%d\n",s);else if(t>s)printf("%d\n",t);else if(t==s)printf("%d\n",s);
return 0;
}

Measured memory_bytes: 592
#include <iostream>

using namespace std;

int main() {
	int L, R, d;
	cin >> L >> R >> d;
	int res = 0;

	for (int i = 0; i <= 100; ++i) {
		if (d*i < L)
			continue;
		else if (d*i <= R)
			res++;
		else
			break;
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
 
//long long
using ll = long long;
 
// pair<int, int>
using PII = pair<int, int>;
 
//最大値、mod
const int MOD = 1000000007;
const int INF = 1000000000;
const long long LINF = 1e18;
const int MAX = 510000;
 
//出力系
#define print(x) cout << x << endl
#define prints(x) cout << fixed << setprecision(10) << x << endl
#define printc(x) cout << setw(2) << setfill('0') << x << endl;
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
 
// begin() end()
#define all(x) (x).begin(),(x).end()
 
//for
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
 
//最大公約数 
unsigned gcd(unsigned a, unsigned b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
 
// 最小公倍数
unsigned lcm(unsigned a, unsigned b){
    return a / gcd(a, b) * b; 
}
 
// a = max(a, b), a = min(a, b)
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; }
 
// 階乗(MODをとる)
ll pow_mod(ll num, ll pow, ll mod) {
    ll prod = 1;
    num %= mod;
    while (pow > 0) {
        if (pow & 1) prod = prod * num % mod;
        num = num * num % mod;
        pow >>= 1;
    }
    return prod;
}
 
 
 
// 二項係数(MODとる、1 ≦ k ≦ n ≦ 10^7 程度)
// COMinit()
// COM(x, y)
// とコンビで使う
 
// テーブルを作る前処理
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

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



struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

vector<ll>a;
void solve(int k, ll d){
  a.push_back(d);
  if(k >= 12) return;
  int e = d % 10;
  if(e > 0) solve(k + 1, d * 10 + (e - 1));
  solve(k + 1, d * 10 + e);
  if(e < 9) solve(k + 1, d * 10 + e + 1);
}




int main(){
  int k; cin >> k;
  REP(i, 9)solve(0, i + 1);
  sort(all(a));
  cout << a[k - 1] << endl;
  return 0;
}


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

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

  vector<int> v(N);
  for (int i = 0; i < N; i++) {
    cin >> v.at(i);
  }

  int sum = 0;
  for (int i = 0; i < N; i++) {
    int c;
    cin >> c;
    v.at(i) -= c;
    if (0 < v.at(i)) sum += v.at(i);
  }

  cout << sum << endl;
}
/*
  3 =N
  10 2 5 =Vi
  6 3 4 =Ci
 */

 


Measured memory_bytes: 256
a,b,c=map(int,input().split())
x=sorted([a,b,c])
count=0
if sum(x)%2==x[2]%2:
    while True:
        if x[1]==x[2] and x[0]==x[2]:
            break
        elif x[1]==x[2] and x[0]!=x[2]:
            x[0]+=2
        else:
            x[1]+=1
            x[0]+=1
        count+=1

else:
    x[2]+=1
    x[0]+=1
    count+=1
    while True:
        if x[1]==x[2] and x[0]==x[2]:
                break
        elif x[1]==x[2] and x[0]!=x[2]:
            x[0]+=2
        else:
            x[1]+=1
            x[0]+=1
        count+=1
print(count)

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

int main() {
  int total, price[10];
  while (1) {
    cin >> total;
    if (total == 0) break;

    int sum = 0;
    for (int i = 0; i < 9; i++) {
      cin >> price[i];
      sum += price[i];
    }

    cout << total - sum << endl;
  }

  return 0;
}


Measured memory_bytes: 3008
#include <bits/stdc++.h>
#define ll long long
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
// rep(i, 1, 5) --> {1,2,3,4}
// rep(i, 5, 1) --> {4,3,2,1}
// rep(it, end(v), begin(v)) --> *it

using namespace std;

int main()
{
    int a,b,c;
    cin >> a >> b >> c;
    if (a==b && a!=c)
        cout << c;
    else if (a==c && a!=b)
        cout << b;
    else 
        cout << a;
    return 0;
}

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

using namespace std;

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

const static int MOD = 1000000000 + 7;
const static int INT_INF = 999999999;
const static llong INF = 1LL << 60;
const static double eps = 1e-6;
const static int dx[] = {1, 0, -1, 0};
const static int dy[] = {0, 1, 0, -1};

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

    int n, m, c;
    cin >> n >> m >> c;
    vector<int> B(m);
    rep(i, m) cin >> B[i];
    int ans = 0;
    rep(i, n) {
        int tmp = 0;
        rep(j, m) {
            int a;
            cin >> a;
            tmp += a * B[j];
        }
        if (tmp + c>0) ++ans;
    }

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

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

int n;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
 	
 	cin >> n;
 	long long t, a, taka = 1, ao = 1;

 	while (n--) {
 		cin >> t >> a;
 		long long m = max(taka / t + (taka % t != 0), ao / a + (ao % a != 0));
 		taka = t * m;
 		ao = a * m;
 	}
 	cout << taka + ao << '\n';
 	
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<string.h>
#include<math.h>
#include<map>

#define MOD 1e9+7;
#define INF 1e17+9;
#define PI acos(-1);

using namespace std;

int main(){
	int W,H,N;
	cin >> W >> H >> N;
	
	int x_low=0,x_hi=W;
	int y_low=0,y_hi=H;
	
	for(int i=0;i<N;i++){
		int xi,yi,ai;
		cin >> xi >> yi >> ai;
		if(ai==1)x_low=max(x_low,xi);
		if(ai==2)x_hi=min(x_hi,xi);
		if(ai==3)y_low=max(y_low,yi);
		if(ai==4)y_hi=min(y_hi,yi);
	}
	
	W=x_hi-x_low;
	if(W<=0)W=0;
	H=y_hi-y_low;
	if(H<=0)H=0;
	
	cout << W*H << endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>

using namespace std;

int main()
{
	int N, M;
	cin >> N >> M;
	int i,j;
	
	int minR, maxL;
	cin >> maxL >> minR;


	for (i = 1; i < M; i++)
	{
		int L, R;
		cin >> L >> R;

		if (L > maxL)
		{
			maxL = L;
		}
		if (R < minR)
		{
			minR = R;
		}
	}
	int kekka = minR - maxL + 1;
	if (kekka < 0)
	{
		kekka = 0;
	}
	cout << kekka << endl;



	return 0;
}



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

long long int n, x, cvp;
pair<long long int, long long int> paralel;

int main(){
	cin>>n>>x;
	cvp=n;
	paralel=make_pair(max(n-x, x) , min(n-x, x));
	while(paralel.second!=paralel.first&&paralel.second!=0){
		cvp+= 2*(paralel.first/paralel.second)*paralel.second;
		if(paralel.first%paralel.second==0)cvp-= paralel.second;
		paralel=make_pair(max(paralel.second, paralel.first - paralel.second*(paralel.first/paralel.second)) , min(paralel.second, paralel.first - paralel.second*(paralel.first/paralel.second)));
		if(paralel.second==1){
			cvp+= paralel.first *2 -2 ;
			paralel.second=1;
			break;
		}
	}
	cvp+=paralel.second;
	cout<<cvp;
	return 0;
}


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

#define ll long long
#define ii pair<ll, ll>
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define ff first
#define ss second
#define pi acos(-1.0)
#define oo 1000000007
#define loo 0x7fffffffffffffff


#define prime 1000000007
ll mod = prime;
ll powmod(ll a,ll b) {ll res=1;a%=mod;assert(b>=0);for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}

#define W(x) cerr << "\033[31m" << #x << " = " << x << "\033[0m" << "\n";
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    int n; cin >> n;
    if(n == 1){
        cout << "0\n";
        return 0;
    }

    ll ans = 0;
    for (int i = 1; i < n; ++i){
        if(i <= n/i) {
            ans+=2*i-1 - (i*i==n);
        }
        else{ 
            ans+=2*(n/i) - 2*(i*(n/i) == n);
        }
    }
    cout << ans << "\n";

    return 0;
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
#define pb push_back
using namespace std;

const int mn=1<<19;
vector<int> a,b;
multiset<int> s;

int main()
{
	int n,x;
	scanf("%d",&n);
	for(int i=1;i<=(1<<n);++i) {scanf("%d",&x);s.insert(x);}
	a.pb(*--s.end());s.erase(--s.end());
	while(n--) {
		for(int i=0;i<a.size();++i) {
			multiset<int>::iterator it=s.lower_bound(a[i]);
			if(it==s.begin()) {
				puts("No");
				return 0;
			}
			it--;b.pb(*it);s.erase(it);
		}
		for(int i=0;i<b.size();++i) a.pb(b[i]);
		b.clear();
	}
	puts("Yes");
}

Measured memory_bytes: 13816
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;
char s[maxn];
void slove()
{
    scanf("%s" , s + 1);
    int n = strlen(s + 1);
    if (s[1] != '1' or s[n] == '1')
    {
        puts("-1");
        return ;
    }
    for (int i = 1; i <= n - i; ++ i)
    {
        if (s[i] != s[n - i])
        {
            puts("-1");
            return ;
        }
    }
    int now = 2, rt = 1;
    printf("%d %d\n" ,rt ,now);
    int ct = 1;
    while (now <= n - now)
    {
        printf("%d %d\n" ,rt ,++ now);
        if (s[now - 1] == '1')
            rt = now;
        ++ ct;
    }
    for (int i = ct + 1; i < n; ++ i)
        printf("%d %d\n" ,rt ,++ now);
    return ;
}
signed main()
{
	slove();
	return 0;
}


Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
int main(){
	vector<int>a(5);
  	for(auto& i:a)
     cin>>i;
  	for(int i=0;i<5;i++)
      if(a[i]==0){
      	cout<<i+1<<endl;
        break;
      }

}

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

#ifdef LOCAL

template<class T, class U>
ostream& operator<<(ostream& os, pair<T, U> p) {
	os << "(" << p.first << ", " << p.second << ")";
	return os;
}

template<template<class, class...> class C, class... A>
typename enable_if<!is_same<C<A...>, string>::value, ostream&>::type
operator<<(ostream& os, class C<A...> c) {
	auto i = c.begin();
	while (i != c.end()) {
		os << " {"[i == c.begin()] << *i;
		os << ",}"[++i == c.end()];
	}
	return os;
}

#define debug(x) cerr << #x << " = " << x << endl;
#else
#define debug(...) {}
#endif

const int N = 30 * 1000;
long long infLL = 1e18;
int inf = 1e9;

vector<int> liczby;

int main() {
	ios_base::sync_with_stdio(false);
	int ile = 0;
	vector<int> super;
	for (int i = 1; i <= N; i ++) {
		if (i % 2 == 0 || i % 3 == 0) {
			liczby.push_back(i);
			if (i % 6 != 0) super.push_back(i);
		}
	}
	debug(super.size());
	long long suma = 0;
	int n;
	cin >> n;
	if (n >= super.size()) {
		for (int i = 0; i < super.size(); i ++) {
			cout << super[i] << " ";
		}
		for (int i = 1; i <= (n - (int)super.size()); i ++) {
			cout << i * 6 << " ";
		}
		return 0;
	}
	if (n == 3) {
		cout << "2 5 63";
		return 0;
	}
	vector<int> roz;
	for (int i = 0; i < n - 1; i ++) {
		suma += liczby[i];
		roz.push_back(liczby[i]);
	}
	debug(suma);
	for (int i =  n - 1; i < liczby.size(); i ++) {
		if ((suma + liczby[i]) % 6 == 0) {
			roz.push_back(liczby[i]);
			for (int x : roz) cout << x << " ";
			return 0;
		}
	}
	for (int i = 0; i < roz.size(); i ++) {
		if (roz[i] != 2 && roz[i] != 3 && (suma - roz[i]) % 6 == 0 || (suma - roz[i]) % 6 == 3 || (suma - roz[i]) % 6 == 4) {
			suma -= roz[i];
			swap(roz[i], roz.back());
			roz.pop_back();
			break;
		}
	}
	debug(suma);
	for (int i =  n - 1; i < liczby.size(); i ++) {
		if ((suma + liczby[i]) % 6 == 0 || (suma + liczby[i]) % 6 == 3 || (suma + liczby[i]) % 6 == 4)  {
			roz.push_back(liczby[i]);
			suma += liczby[i];
			for (int j = i + 1; j < liczby.size(); j ++) {
				if ((suma + liczby[j]) % 6 == 0) {
					roz.push_back(liczby[j]);
					for (int x : roz) cout << x << " ";
					return 0;
				}
			}
			return 0;
		}
	}
	assert(false);
}


Measured memory_bytes: 640
#include<iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int Max = 1000000;
int main(){
	int a, b, c;
  	cin >> a >> b >> c;

  	if(a+b+c>=22){
  		cout << "bust" <<endl;
  	}else{
  		cout << "win" <<endl;
  	}
    
  	return 0;
}


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

namespace MINPRO2019B
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] ai = new int[3];
            int[] bi = new int[3];
            for(int i = 0; i < 3; i++)
            {
                var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
                ai[i] = input[0];
                bi[i] = input[1];
            }

            int[] sum = new int[4];
            for(int i = 0; i < 3; i++)
            {
                sum[ai[i]-1]++;
                sum[bi[i]-1]++;
            }

            var count = sum.Contains(3);

            if (count)
                Console.WriteLine("NO");
            else Console.WriteLine("YES");

            Console.ReadKey();
        }
    }
}


Measured memory_bytes: 13396
#include<bits/stdc++.h>
using namespace std;
#define SORT(c) sort((c).begin(),(c).end());
#define pb push_back
#define MP make_pair
#define pii pair<int,int>
#define pcc pair<char,char>
#define pic pair<int,char>
#define pci pair<char,int>
#define VS vector<string>
#define VI vector<int>
#define pi 3.141592653589793
#define ll long long
#define ull unsigned long long
#define w(x) int x;cin>>x;while(x--)
#define fast ios_base::sync_with_stdio(0)
#define sz size()
typedef unsigned long long UL;
template<typename T>inline T  S(T a)
{
    return a*a;
}
template<class T>inline string tostring(T a)
{
    ostringstream os("");
    os << a;
    return os.str();
}
template<typename T>inline ll tolong(T a)
{
    ll res;
    istringstream os(a);
    os>>res;
    return res;
}
template<typename T>inline T gcd(T a, T b)
{
    if (b == 0)return a;
    else return gcd(b, a % b);
}
template<typename T>inline T bigmod(T a, T b, T m)
{
    if (b == 0)return 1;
    else if (b % 2 == 0)return S(bigmod(a, b / 2, m)) % m;
    else return (a % m*bigmod(a, b - 1, m)) % m;
}
const int inf = (int)1e9 + 5;
const ll linf = (ll)1e16 + 5;
const ll modd = (ll)1e9 + 7;
const int mod = 10000007;
/*#define N 20000009
bool prime[N];
vector<ll> prm;
void seive ()
{

    memset(prime, true, sizeof(prime));

    for( ll i=2; i*i<=N; i++)
    {
        if (prime[i] == true)
        {
            prm.pb(i);
            for (ll j=i*i; j<=N; j += i)
                prime[j] = false;
        }
    }
}*/
void pr (int f)
{
    if(f==1)
        cout<<"YES\n";
    else
        cout<<"NO\n";
}
map<string,string>ma;
set<int > s;
multiset<string> :: iterator it;

deque <char> q ;
ll ar [55100];
int main()
{
    fast;
     int n,k,x,y;
     cin>>n>>k>>x;
   cout << ((n+k)*x)/2<<endl;
     

}




Measured memory_bytes: 3652
#include<stdio.h>
int div2(int n){
  if(n%2) return 0;
  else return div2(n/2)+1;
}
int main(){
  int n,i,sum=0,a;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&a);
    sum+=div2(a);
  }
  printf("%d",sum);
}

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

int N, Y;

void solve() {
  for(int i = 0; i <= N; ++i) {
    for(int j = 0; j <= N-i; ++j) {
      int k = N - i - j;
      if(10000*i + 5000*j + 1000*k == Y) {
        cout << i << " " << j << " " << k << endl;
        return;
      }
    }
  }
  cout << -1 << " " << -1 << " " << -1 << endl;
  return;
}

int main() {

  cin >> N >> Y;
  solve();
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

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

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define IN cin >> 
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (m-1); i >= (int)(n); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v,c) sort(v.begin(), v.end(), greater<c>()) 
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - a) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

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

int n,m;
bool a[100005] = {};
int ans[100005] = {};


int main(){
    
   
    cin >> n >> m;
    rep(i,0,m){
	int b;
	cin >> b;
	a[b] = 1;
    }

    ans[0] = 1;
    rep(i,0,n){
	if(a[i] == 0){
	    ans[i+1] += ans[i];
	    ans[i+1] = mod(ans[i+1]);
	    ans[i+2] += ans[i];
	    ans[i+2] = mod(ans[i+2]);
	}
    }
  
    P(ans[n]);
    return  0;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
using namespace std;

const ll MOD = 1e9 + 7;

int main(int argc, char const *argv[])
{
    int n;
    ll m;
    cin >> n >> m;
    vector<ll> w(n), v(n);
    rep(i, n)
    {
        cin >> w[i] >> v[i];
    }
    vector<vector<ll>> dp(n + 1, vector<ll>(301, 0));
    rep(i, n)
    {
        auto next = dp;

        rep(j, i + 1)
        {

            cerr << i << " " << j << endl;
            rep(k, 301)
            {

                if (k - (w[i] - w[0]) >= 0)
                    next[j + 1][k] = max(next[j + 1][k], dp[j][k - (w[i] - w[0])] + v[i]);
            }
        }
        dp = next;
    }
    ll ans = -1;
    rep(i, n + 1)
    {

        rep(j, 301)
        {

            ll curw = w[0] * i + j;
            if (curw <= m)
            {

                cerr << i << " " << j << " " << dp[i][j] << endl;
                ans = max(ans, dp[i][j]);
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 784
#include<bits/stdc++.h>
#include<math.h>
#include<string>
using namespace std;
int main(void){
	int s,result=0;
	cin >> s;
	if(s/100 <=12&&s/100>=1){
		result +=10;
	}
	if(s%100<=12&&s%100>=1){
		result += 1;
	}
	if(result == 0){
		cout << "NA" << endl;
	}else if(result == 1){
		cout << "YYMM" << endl;
	}else if(result==10){
		cout << "MMYY" << endl;
	}else if(result == 11){
		cout << "AMBIGUOUS" << endl;

	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int a[3];string s;
int main(){
cin.tie(0);
ios::sync_with_stdio(false);
cin>>s;
for(int i=0;i<s.size();i++)a[s[i]-'a']++;
cout<<((max({a[0],a[1],a[2]})-min({a[0],a[1],a[2]}))<2?"YES":"NO")<<endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define ii pair<int,int>
#define F first
#define S second
#define pb push_back
#define pf push_front
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define fore(i,a,b) for(int i = a;i < b; i+= 1)
#define forr(i,a) for(int i = a; i >= 0; i--)
#define fori(i,m) for(auto i = m.begin(); i != m.end(); i++) 
#define sz(s) int(s.size())
#define cls(a,car) memset(a,car,sizeof (a))
using namespace std;
typedef long long ll;
typedef vector<int> vi;
const int N = 1 * 1e5 + 5;
const ll mod = 1e9 + 7;
const int INF = INT_MAX;
const ll INFCAD  = ll(INT_MAX) * 2 + 1;
const double E = 1e-9;
int main(){
    //freopen("in","r",stdin);
    //freopen("out","w",stdout);
    int n,m;
    cin >> n >> m;
    char v[n + 3][m + 3];
    cls(v,'#');
    fore(i, 1, n + 1)
        fore(j, 1, m + 1)
            cin >> v[i][j];

    fore(i, 0, n + 2){
        fore(j, 0, m + 2)
            cout << v[i][j];
        cout << endl;
    }
            
    
    return 0;
}   

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) debug(x) debug(y);
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sq(x) ((x) * (x))

template<class T> T gcd(T a, T b){ return ((b == 0) ? a : gcd(b, a % b)); }

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	ll n, k;
	cin >> n >> k;
	vector<ll> a(n);
	rep(i, n) cin >> a[i];
	ll cnt = 0;
	sort(all(a));
	reverse(all(a));
	rep(i, n) if(i >= k){
		cnt += a[i];
	}
	cout << cnt << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


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

using namespace std;
#define local
#ifdef local

template<class T>
void _E(T x) { cerr << x; }

void _E(double x) { cerr << fixed << setprecision(6) << x; }

void _E(string s) { cerr << "\"" << s << "\""; }

template<class A, class B>
void _E(pair<A, B> x) {
    cerr << '(';
    _E(x.first);
    cerr << ", ";
    _E(x.second);
    cerr << ")";
}

template<class T>
void _E(vector<T> x) {
    cerr << "[";
    for (auto it = x.begin(); it != x.end(); ++it) {
        if (it != x.begin()) cerr << ", ";
        _E(*it);
    }
    cerr << "]";
}

void ERR() {}

template<class A, class... B>
void ERR(A x, B... y) {
    _E(x);
    cerr << (sizeof...(y) ? ", " : " ");
    ERR(y...);
}

#define debug(x...) do { cerr << "{ "#x" } -> { "; ERR(x); cerr << "}" << endl; } while(false)
#else
#define debug(...) 114514.1919810
#endif
#define _rep(n, a, b) for (ll n = (a); n <= (b); ++n)
#define _rev(n, a, b) for (ll n = (a); n >= (b); --n)
#define _for(n, a, b) for (ll n = (a); n < (b); ++n)
#define _rof(n, a, b) for (ll n = (a); n > (b); --n)
#define oo 0x3f3f3f3f3f3f3f3f
#define ll  long long
#define db long double
#define eps 1e-3
#define bin(x) cerr << bitset<10>(x) << endl
#define what_is(x) cerr << #x << " is " << x << endl
#define met(a, b) memset(a, b, sizeof(a))
#define all(x) x.begin(), x.end()
#define pii pair<ll, ll>
#define pdd pair<db, db>
#define endl "\n"
const ll mod = 1e9 + 7;
const ll maxn = 2e5 + 10;
const db pi = acos(-1.0);

ll qpow(ll a, ll b) {
    ll ret = 1;
    for (; b; a = a * a % mod, b >>= 1) {
        if (b & 1) {
            ret = ret * a % mod;
        }
    }
    return ret;
}

vector<ll> f(maxn), invf(maxn);

ll inv(ll a) {
    return qpow(a, mod - 2);
}

void prework() {
    f[0] = 1;
    _rep(i, 1, maxn - 1) {
        f[i] = f[i - 1] * i % mod;
    }
    invf[maxn - 1] = qpow(f[maxn - 1], mod - 2);
    for (ll i = maxn - 2; i >= 0; i--) {
        invf[i] = invf[i + 1] * (i + 1) % mod;
    }
}

ll C(ll n, ll m) {
    if (n > m || m < 0)return 0;
    if (n == 0 || m == n) return 1;
    ll res = (f[m] * invf[m - n] % mod * invf[n]) % mod;
    return res;
}

signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll a, b, c,d;
    cin >> a >> b >> c >> d;
    ll res = max(a*c, max(a*d, max(b*c,b*d)));
    cout << res << endl;
}

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

using namespace std;

int main(int argc, char *argv[]){
	int n;
	cin >> n;
	string s_hanako, s_taro;
	int p_hanako = 0;
	int p_taro = 0;
	for(int i = 0; i < n; i++){
		cin >> s_taro >> s_hanako;
		if (s_taro == s_hanako){
			p_hanako += 1;
			p_taro += 1;
		} else if (s_taro < s_hanako) {
			p_hanako += 3;
		} else if (s_taro > s_hanako) {
			p_taro += 3;
		}
	}
	cout << p_taro << " " << p_hanako << endl;
	return 0;
}

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

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

	int n, k;
	cin >> n >> k;
	int h[n], dp[n];
	for(int i=0; i<n; ++i) {
		cin >> h[i];
	}
	dp[0]=0;
	for(int i=1; i<n; ++i) {
		dp[i]=INT_MAX;
		for(int j=1; j<=k&&i-j>=0; ++j)
			dp[i]=min(dp[i-j]+abs(h[i]-h[i-j]), dp[i]);
	}
	cout << dp[n-1];
}


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

typedef long long int ll;
typedef pair<int, int> pii;
bool R(){return true;}
template<typename T, typename ... Args>
bool R(T & x, Args & ... args){return cin >> x && R(args...);}
void init_io(){ios::sync_with_stdio(false);cin.tie(0);}

#define PB push_back
#define FOR(prom, a, b) for(int prom = (a); prom < (b); prom++)
#define FORDE(prom, a, b) for(int prom = (a); prom >= (b); prom--)
#define ALL(vec) (vec).begin(), (vec).end()
#define MM(co, cim) memset((co), (cim), sizeof((co)))
#define DEB(x) cerr << ">>> " << #x << " : " << x << endl;
#define INF   1000000007
#define INFLL 4000000000000000007LL

ll n;
vector<char> res;
vector<ll> starts;

void solve ()
{
  R(n);
  starts.PB(1);
  ll cur = 26;
  while (1)
  {
    ll nxt = starts[starts.size() - 1];
    nxt += cur;
    starts.PB(nxt);
    cur *= 26;
    if (nxt > 1000000000000001LL) break;
  }
  FOR(i, 0, starts.size())
  {
    if (n < starts[i])
    {
      FOR(j, 0, i) res.PB('a');
      ll cur = n - starts[i - 1];
      int j = 0;
      while (cur)
      {
        res[j++] = 'a' + (cur % 26);
        cur /= 26;
      }
      break;
    }
  }
  reverse(ALL(res));
  for (auto c : res) printf("%c", c);
  printf("\n");
}

int main ()
{
  init_io();
  int T = 1;
  //R(T);
  while (T--) solve();
  return 0;
}


Measured memory_bytes: 3620
#include <stdio.h>
int main()
{
  int a[4],b[4],h,d,i,j;
  while((scanf("%d%d%d%d",&a[0],&a[1],&a[2],&a[3])) != EOF){
    scanf("%d%d%d%d",&b[0],&b[1],&b[2],&b[3]);
    h=d=0;
    for(i=0;i<4;i++){
      for(j=0;j<4;j++){
	if(a[i] == b[j]) {
	  if (i==j) h++;
	  else d++;
	}
      }
    }
    printf("%d %d\n",h,d);
  }
  return 0;
}

Measured memory_bytes: 0
#include<stdio.h>
int main(){
  int n,i,j,k,v,x,c=0,m=0;
  int A[1000000], G[1000000];
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  G[0]=1;
  for(i=1;G[i-1]<=n;i++){
    m++;
    G[i]=G[i-1]*3+1;
    if(m>100){
      break;
    }
  }
  for(i=0;i<m/2;i++){
    x=G[i];
    G[i]=G[m-i-1];
    G[m-i-1]=x;
  }
  for(i=0;i<m;i++){
    for(j=G[i];j<n;j++){
      v=A[j];
      k=j-G[i];
      while(k>=0&&A[k]>v){
	A[k+G[i]]=A[k];
        k=k-G[i];
	c++;
      }
      A[k+G[i]]=v;
    }
  }
  printf("\n%d\n",m);
  for(i=0;i<m;i++){
    printf("%d ",G[i]);
  }
  printf("\n%d\n",c);
  for(i=0;i<n;i++){
    printf("%d\n",A[i]);
  }
  return 0;
}
   

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



int main()
{
    int a,b,c,t,h;
    cin>>t;
    while(t--)
    {
        cin>>a>>b>>c;
        if(a*a==b*b+c*c || b*b==c*c+a*a || c*c==a*a+b*b) cout << "YES\n";
        else cout << "NO\n";
    }
    return 0;
}

Measured memory_bytes: 1120
import Control.Monad
import Control.Applicative
import Data.List
import Data.Array
strToInt s = (read :: String -> Int) s

main = do

   [x , y , z] <- (map strToInt . words) <$> getLine
   print (solve x y z)



solve :: Int -> Int -> Int -> Int

solve x y z = if (x-y-z) >= z
              then 1 + solve (x-y-z) y z
              else 0


Measured memory_bytes: 892
n = gets.chomp.to_i
a = []
n.times do
  x, l = gets.chomp.split.map(&:to_i)
  a.push([x - l, x + l])
end
a.sort_by!{|l, r| r}

ans = 0
rr = -1 * (10 ** 10)
a.each do |l, r|
  if rr <= l
    ans += 1
    rr = r
  end
end
p ans


Measured memory_bytes: 12664