akhauriyash/Code-Regression huggingface dataset:
// created on : Tue Jun 23 2020
 
import java.io.*;
import java.util.*;

public class Main {

    public static void main(String[] args) throws IOException {
        int a = in.nextInt();
        int b = in.nextInt();
        int h = in.nextInt();
        int m = in.nextInt();

        double angle = 30*h - 5.5*m;       // degrees

        // a^2 = b^2 + c^2 + 2bc cos(angle between b and c)
        double ans = a * a + b * b - 2 * a * b * (Math.cos(Math.toRadians(angle)));
        println(Math.sqrt(ans));

        in.close();
        out.close();
    }

    static int MIN = Integer.MIN_VALUE;
    static int MAX = Integer.MAX_VALUE;
    static Reader in = new Reader();
    static PrintWriter out = new PrintWriter(System.out);

    static int[] readInt(int N) throws IOException { 
    	int arr[] = new int[N];
    	for(int i = 0; i < N; i++){ 
    		arr[i] = in.nextInt(); 
    	} 
    	return arr;
    }
    
    static long[] readLong(int N) throws IOException { 
    	long arr[] = new long[N];
    	for(int i = 0; i < N; i++){ 
    		arr[i] = in.nextLong(); 
    	} 
    	return arr;
    }
    
    static void print(Object O) {  
    	out.print(O); 
    }
    
    static void println(Object O) { 
    	out.println(O); 
    }
    
    static void println(int arr[]) { 
    	for(int i = 0; i < arr.length; i++){ 
    		print(arr[i] + " "); 
    	} 
    	println(""); 
    }
    
    static void displayRuntime(long startTime){
        long stopTime = System.currentTimeMillis();
        long elapsedTime = stopTime - startTime;
        System.out.println("Runtime: " + elapsedTime / 1000D);
    }
}

class Reader {
    BufferedReader reader;
    StringTokenizer tokenizer;

    Reader() {
        reader = new BufferedReader(new InputStreamReader(System.in));
        tokenizer = new StringTokenizer("");
    }

    String next() throws IOException {
        while (!tokenizer.hasMoreTokens() ) { 
            tokenizer = new StringTokenizer(reader.readLine()); 
        }
        return tokenizer.nextToken();
    }

    int nextInt() throws IOException { 
        return Integer.parseInt(next()); 
    }
    
    double nextDouble() throws IOException { 
        return Double.parseDouble(next());
    }
    
    long nextLong() throws IOException { 
        return Long.parseLong(next()); 
    }
    
    String nextLine() throws IOException { 
        return reader.readLine(); 
    }
    
    void close() throws IOException { 
        reader.close(); 
    }
}


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

int main(){
  int n, mid1, mid2;
  cin >> n;
  int a[n], b[n];
  for (int i = 0; i < n; i++){
    cin >> a[i];
    b[i] = a[i];
  }
  sort(b, b+n);
  mid1 = b[n/2-1];
  mid2 = b[n/2];
  for (int i = 0; i < n; i++){
    if(a[i] <= mid1) cout << mid2 << endl;
    else cout << mid1 << endl;
  }
  
}


Measured memory_bytes: 3712
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define FORN(i,n) for(int i=1;i<=n;i++)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define forn(i,a,b) for(int i=a;i<=b;i++)
#define foreach(i,c) for(__typeof(c.begin())i=c.begin();i!=(c).end();i++)
#define ll long long
#define sz(s) s.size()
#define all(s) s.begin(),s.end()
#define pii pair<int,int>
#define vpii vector<pair<int,int> >
using namespace std;
string s;
int check(int x,int y){
	string last="";
	string nw="";
	for(int i=0;i<x;i++)last+=(char)(s[i]);
	for(int i=x;i<x+y;i++)nw+=(char)(s[i]);
	int num=2;
	for(int i=x+y-1;i<s.size();i++){
		if(i==s.size()-1){
			if(last==nw)num--;
			break;
		}
		if(last==nw){
			nw+=(char)(s[i+1]);
		}
		else if(last!=nw){
			last=nw;
			nw=(char)(s[i+1]);
			num++; 
		}
	}
	return num;
}
int main(){
	cin>>s;
	if(s.size()==1){
		cout<<1<<endl;
		return 0;
	}
	if(s.size()==2){
		if(s[0]==s[1]){
			cout<<1<<endl;
			return 0;
		}
		else{
			cout<<2<<endl;
			return 0;
		}
	}
	int mx=0;
	mx=max(mx,check(1,2));
	mx=max(mx,check(2,1));
	mx=max(mx,check(1,1));
	mx=max(mx,check(2,2));
	cout<<mx<<endl;
	return 0;
}

Measured memory_bytes: 640
#include <iostream>

int main(int argc, char **argv) {
	int a, b, c;
	std::cin >> a >> b >> c;
	
	if(a < b && b < c) {
		std::cout << "Yes" << std::endl;
	} else {
		std::cout << "No" << std::endl;
	}
}


Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
#define all(V) V.begin(),V.end()
#define ll long long
#define MOD 998244353

map<ll, ll> ZX, ZY;
vector<int> S1(524288, 0), S2 = S1, S3 = S1, S4 = S1, S5 = S1, S6 = S1, S7 = S1, S8 = S1;
ll mem[200010], d2[200010];

int rsq(vector<int>& V, int s, int t, int k = 1, int l = 0, int r = 262143) {
	if (t < l || r < s)return 0;
	if (s <= l && r <= t)return V[k];
	int lv = rsq(V, s, t, k * 2, l, (l + r) / 2);
	int rv = rsq(V, s, t, k * 2 + 1, (l + r) / 2 + 1, r);
	return lv + rv;
}

void upd(vector<int>& V, int x) {
	x += 262144;
	V[x]++;
	while (x) {
		x /= 2;
		V[x] = V[x * 2] + V[x * 2 + 1];
	}
}

void mod(ll& x) {
	x %= MOD;
	x += MOD;
	x %= MOD;
}

int main() {
	d2[0] = 1;
	for (int i = 1;i < 200010;i++)
		d2[i] = d2[i - 1] * 2 % MOD;

	int N, x, y;
	cin >> N;
	vector<pair<ll, ll>> P1(N), P2(N);
	for (int i = 0;i < N;i++) {
		cin >> x >> y;
		ZX.insert({ x,0 });
		ZY.insert({ y,0 });
		P1[i] = { x,y };
		P2[i] = { y,-x };
		mem[i] = d2[N] - 1;
	}
	sort(all(P1));
	sort(all(P2));
	x = 1;
	for (auto& i : ZX) {
		i.second = x;
		x++;
	}
	y = 1;
	for (auto& i : ZY) {
		i.second = y;
		y++;
	}

	for (int i = 0;i < N;i++) {
		tie(x, y) = P1[i];
		x = ZX[x];
		y = ZY[y];
		mem[i] -= d2[rsq(S5, 0, x - 1)];
		mem[i] += d2[rsq(S1, y + 1, N)];
		mod(mem[i]);
		upd(S5, x);
		upd(S1, y);
	}

	for (int i = N - 1;i >= 0;i--) {
		tie(x, y) = P1[i];
		x = ZX[x];
		y = ZY[y];
		mem[i] -= d2[rsq(S6, x + 1, N)];
		mem[i] += d2[rsq(S2, 0, y - 1)];
		mod(mem[i]);
		upd(S6, x);
		upd(S2, y);
	}
	
	for (int i = 0;i < N;i++) {
		tie(y, x) = P2[i];
		x = ZX[-x];
		y = ZY[y];
		mem[i] -= d2[rsq(S7, 0, y - 1)];
		mem[i] += d2[rsq(S3, 0, x - 1)];
		mod(mem[i]);
		upd(S7, y);
		upd(S3, x);
	}

	for (int i = N - 1;i >= 0;i--) {
		tie(y, x) = P2[i];
		x = ZX[-x];
		y = ZY[y];
		mem[i] -= d2[rsq(S8, y + 1, N)];
		mem[i] += d2[rsq(S4, x + 1, N)];
		mod(mem[i]);
		upd(S8, y);
		upd(S4, x);
	}

	ll ans = 0;
	for (int i = 0;i < N;i++) {
		ans += mem[i];
		//cout << mem[i] << endl;
		mod(ans);
	}
	cout << ans << endl;
}

Measured memory_bytes: 51072
#include <bits/stdc++.h>
    using namespace std;
    typedef long long ll;
    typedef long double ld;
    ll MOD= 1000000007;
    #define fori(it, x) for (__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
    int dp[1002][1002];
    int main()
    {
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        ll a,b;
        cin>>a>>b;
        ll n=b-a;
        ll x=n*(n+1)/2;
        ll y=n*(n-1)/2;
        cout<<x-b;
    }

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

int main() {
    int N;
    cin >> N;
    if(N % 2) {
        cout << 2 * N << endl;
    } else {
        cout << N << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std; 
#define mod 1000000007
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define endl "\n" 
#define pb push_back
#define mp make_pair
typedef long long int ll;
 
int main()
{
    fast;
    ll n;
    cin >> n;
    long long arr[n + 1];
    map<ll, ll> umap;
    for(ll i = 0; i < n - 1; i++){
        cin >> arr[i];
        umap[arr[i] - 1]++;
    }
 
    for(ll i = 0; i < n; i++){
        if(umap.find(i) != umap.end()){
            cout << umap[i] << " ";
        }
        else{
            cout << 0 << " ";
        }
    }
    cout << endl;
 
}

Measured memory_bytes: 17680
// AOJ_C++.cpp : アプリケーションのエントリ ポイントを定義します。
//
#include <iostream>

void Output(int i, int* arr);

int main()
{
	
	int arr[10000];
	for (int i = 0; true; ++i) {
		int a;
		std::cin >> a;
		if (a == 0) {
			Output(i, arr);
			break;
		}
		arr[i] = a;
	}
    return 0;
}

void Output(int i, int* arr) {
	for (int j = 0; j < i; ++j) {
		std::cout << "Case " << j+1 << ": " << arr[j] << std::endl;
	}
}


Measured memory_bytes: 3040
#include <bits/stdc++.h>
using std::cout;
using std::endl;
using std::cin;

int dp[100010];

int main(){
	for(int i = 0; i < 100010; i++) dp[i] = 1e9; dp[0] = 0;
	int n; cin >> n;
	
	for(int i = 0; i < n; i++) {
		dp[i + 1] = std::min(dp[i + 1], dp[i] + 1);
		
		for(int j = 6; i + j <= n; j *= 6) 
			dp[i + j] = std::min(dp[i + j], dp[i] + 1);
			
		for(int j = 9; i + j <= n; j *= 9) 
			dp[i + j] = std::min(dp[i + j], dp[i] + 1);
	}
	
	cout << dp[n] << endl;
	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <fstream>
#include <string>

//std::ifstream f("input.in");
//std::ofstream g("output.out");

int n;
std::string s,t;

int main(){
    
    std::cin >> n >> s >> t;
    
    for(int i = 0;i < n;++i)
        std::cout << s[i] << t[i];
    
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=998244353;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-13;
const double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
double ABS(double a){return max(a,-a);}

int main(){
	int a,b;scanf("%d%d",&a,&b);
	if(a>b)swap(a,b);
	if(b==1){
		printf("1\n");return 0;
	}
	if(a==1){
		printf("%d\n",b-2);return 0;
	}
	long long ret=(long long)(a-2)*(b-2);

	printf("%lld\n",ret);
}


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

int main() {
  string s;
  cin >> s;
  int n = s.size();
  int cr = (n-1)/2;
  int cl = n-cr-1;
  char d = s[cr];
  char r = s[cr];
  char l = s[cl];
  int ans = cl;
  while (r == d && l == d) { 
    ++ans;
    --cr;
    ++cl;
    if (cr < 0 || cl >= n) break;
    r = s[cr];
    l = s[cl];
  }
  cout << ans << endl;
}



Measured memory_bytes: 512
#!python3.8
# -*- coding: utf-8 -*-
# abc175/abc175_b
import sys
from itertools import combinations

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [i2s() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def main():
    N = i2n()
    L = i2nn()
    ans = 0
    for cmb in combinations(L, 3):
        a, b, c = sorted(cmb)
        if a != b and b != c and a + b > c:
            ans += 1
    print(ans)
    return

main()


Measured memory_bytes: 9220
n=int(input())
h=[int(i) for i in input().split()]

a=[0]*n
a[1]=abs(h[0]-h[1])
for i in range(2,n):
    c1=a[i-1] + abs(h[i]-h[i-1])
    c2=a[i-2] + abs(h[i]-h[i-2])
    a[i] = min(c1,c2)
print(a[-1])

Measured memory_bytes: 52208
n = int(input())
d = list(map(int,input().split()))
m = int(input())
t = list(map(int,input().split()))

dd = {}
for i in range(n):
    if d[i] in dd:
        dd[d[i]] += 1
    else:
        dd[d[i]] = 1


ans = "YES"
for i in t:
    try:
        if dd[i] >= 1:
            dd[i] -= 1
        else:
            ans = "NO"
    except:
        ans="NO"
print(ans)


Measured memory_bytes: 127572
// A.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <queue>
#include <functional>
#include <map>
#include <string>
#include <cstdlib>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <numeric>


using lolo=long long;
using namespace std;
using vec=vector<lolo>;
using pari=pair<lolo, lolo>;
using vvec=vector<vec>;
using vecb=vector<bool>;
#define FOR(i,n) for (lolo i=0; i<n; ++i)
#define FORIT(it,v) for (auto it=v.begin(); it!=v.end(); ++it)
#define FORANGE(it, v) for (auto it : v)
#define FORN(i,a,b) for (lolo i=a; i<b; ++i)
#define REV(i,a,b) for (lolo i=a; i>b; --i)
#define ALL(x) x.begin(), x.end()

int main()
{
	lolo N, M;
	cin >> N >> M;
	vec K(M); 
	vvec S(M);

	lolo ans = 0;

	FOR(i, M) {
		cin >> K[i];

		FOR(j, K[i]) {
			lolo tmp;
			cin >> tmp;
			S[i].push_back(tmp);
		}
	}

	vec P(M);
	FOR(i, M) cin >> P[i];


	FOR(i, 1 << N) {
		bool ok = true;
		FOR(j, M) { // すべての電球について
			
			lolo cnt = 0;
			for (auto v : S[j]) {
				if (i & (1 << (v - 1))) {
					cnt += 1;
				}
			}
			if (cnt % 2 != P[j]) {
				ok = false;
				break;
			}
		}
		if (ok) ans += 1;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <stdio.h>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional> //operator[]
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;

signed main(){
    int x,y,z; cin >> x >> y >> z;
    swap(x,y); swap(x,z);
    cout << x <<" "<< y <<" " << z<< endl;
}




Measured memory_bytes: 256
<?php
  list($s) = explode(" ", trim(fgets(STDIN)));

  $ans = [];
  $n = strlen($s);
  $j = 0;
  for ($i=0; $i<$n; $i++) {
    if($s[$i] == '0' || $s[$i] == '1'){
      $ans[$j] = $s[$i];
      $j++;
    }else{
      if($j != 0){
        $j--;
      }
    }
  }
    
  for ($i=0; $i<$j; $i++) {
    echo $ans[$i];
  }


Measured memory_bytes: 16204
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 int a,b,c,d,e,k;
 cin >> a >> b >> c >> d >> e >> k;
 if(e-a<=k){
     cout << "Yay!" << endl;
 }
 else{
     cout << ":(" << endl;
 }
}
    

Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, char const *argv[]) {

    int a,b,i,j;

    while(1){
        scanf("%d%d",&a,&b);
        if(a == 0 && b == 0){
            break;
        }

        for(i = 0; i < a; i++){

            if(i == 0 || i == a-1){

                for(j = 0; j < b; j++){
                    printf("#");
                }

            }else{
                for(j = 0; j < b; j++){
                    if(j == 0 ||j == b-1){
                        printf("#");
                    }
                    else{
                        printf(".");
                    }

                }
            }
            printf("\n");
        }
        printf("\n");

    }
    return 0;
}


Measured memory_bytes: 2036
sx,sy,tx,ty = list(map(int,input().split()))
dir_x = tx > sx
dir_y = ty > sy
space_x = abs(sx - tx)
space_y = abs(sy - ty)
if dir_x:
    if dir_y:
        dirset = 'RULDDRULULDR'
    else:
        dirset = 'RDLUURDLDLUR'
else:
    if dir_y:
        dirset = 'LURDDLURURDL'
    else:
        dirset = 'LDRUULDRDRUL'

for p in range(space_x):
    print(dirset[0],end='')    
for p in range(space_y):
    print(dirset[1],end='')
for p in range(space_x):
    print(dirset[2],end='')
for p in range(space_y):
    print(dirset[3],end='')
print(dirset[4],end='')
for p in range(space_x+1):
    print(dirset[5],end='')
for p in range(space_y+1):
    print(dirset[6],end='')
print(dirset[7],end='')
print(dirset[8],end='')
for p in range(space_x+1):
    print(dirset[9],end='')
for p in range(space_y+1):
    print(dirset[10],end='')
print(dirset[11],end='')

Measured memory_bytes: 4468
open System

[<EntryPoint>]
let main argv = 
    let char123 = stdin.ReadLine().ToCharArray()

    let is7 c = c = '7'

    let check1 = is7 char123.[0]
    let check2 = is7 char123.[1]
    let check3 = is7 char123.[2]
    let check x = 
        if check1 then true
        elif check2 then true
        elif check3 then true
        else false
    let answer = 
        if check char123 then "Yes"
        else "No"

    printfn "%s" answer

    0

Measured memory_bytes: 29400
#include<iostream>
using namespace std;
int n,k,A[251];
int main(){
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>A[i];
    }
    for(int i=1;i<=n;i++){
        cout<<"node "<<i<<": "<<"key = "<<A[i]<<", ";
        if(i!=1) cout<<"parent key = "<<A[i/2]<<", ";
        if(i*2<=n) cout<<"left key = "<<A[i*2]<<", ";
        if(i*2+1<=n) cout<<"right key = "<<A[i*2+1]<<", ";
        cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 3132
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <math.h>
#include <string>
#include <string.h>
#include <stack>
#include <queue>
#include <vector>
#include <utility>
#include <set>
#include <map>
#include <stdlib.h>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 10000000000LL
#define rep(i,n) for(i=0;i<n;i++)

typedef pair<int,int> pii;
int i,j;

int main(void) {
  int n;
  char alph[55]={"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"};
  while(1){
    cin>>n;
    if(n==0)break;
    int k[105];
    rep(i,n)
      cin>>k[i];
    char str[105]={};
    cin>>str;
    int a=strlen(str);
    rep(i,a){
      int c;
      if('A'<=str[i] && str[i]<='Z')
        c=(int)(str[i]-'A')+26;
      else
        c=(int)(str[i]-'a');
      cout<<alph[(52+c-k[i%n])%52];
    }
    cout<<endl;
  }
  return 0;
}

Measured memory_bytes: 3100
#include <iostream>

using namespace std;

int main (void){

	int a,b,i=0;

	while(cin>>a>>b){


		a+=b;
		b=0;
		while(a>0){
			a=a/10;
			i++;
		}

		cout<<i<<endl;
		i=0;
	}
}

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

string judge (string s) {
  if (s[0] == '0' && s[1] != '0') {
    return "ym";
  } else if(s[0] == '1' && (s[1] == '0' or s[1] == '1' or s[1] == '2')){
    return "ym";
  }
  return "y";
}

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

  string ans;

  string s1, s2;

  s1 = s.substr(0, 2);
  s2 = s.substr(2, 2);

  string res1, res2;

  res1 = judge(s1);
  res2 = judge(s2);

  if (res1 == "ym" && res2 == "ym") {
    ans = "AMBIGUOUS";
  } else if (res1 == "y" && res2 == "ym") {
    ans = "YYMM";
  } else if (res1 == "ym" && res2 == "y") {
    ans = "MMYY";
  } else {
    ans = "NA";
  }
/*
  if (s[0] != '0' && s[0] != '1') {
    if (s[2] != '0' && s[2] != '1') {
      ans = "NA";
    } else {
      ans = "YYMM";
    }
  } else {
    if (s[2] != '0' && s[2] != '1') {
      ans = "MMYY";
    } else {
      ans ="AMBIGUOUS";
    }
  }*/
/*
  if (s[0] == '0' or s[0] == '1') {
    if (s[2] == '0' or s[2] == '1') {
      ans = "AMBIGUOUS";
    } else {
      ans = "MMYY";
    }
  } else {
    if (s[2] == '0' or s[2] == '1') {
      ans = "YYMM";
    } else {
      ans = "NA";
    }
  }

  if (s[0] == '0') {
    if (s[1] == '0') {
      if (s[2] == '0') {
        if (s[3] == '0') {
          ans = "NA";
        } else {
          ans = "YYMM";
        }
      } else if(s[2] == '1') {
        if (s[3] == '0' or s[3] == '1' or s[3] == '2') {
          ans = "YYMM";
        } else {
          ans = "NA";
        }
      } else {
        ans = "NA";
      }
    } else {

    }
  }
*/

  if (s[0] == '0' && s[1] == '0' && s[2] == '0' && s[3] == '0') {
    ans = "NA";
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <map>
// #include <cmath>
// #include <algorithm>
// #include <numeric>
// #include <string>
// #include <queue>
// #include <iomanip>
// #include <list>
// #include <cassert>

// #define MOD 1000000007
// #define INF 1000000001

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


template <class T>
ostream &operator<<(ostream &o, const vector<T>&obj) {
    o << "["; for (int i = 0; i < (int)obj.size(); ++i) o << (i > 0 ? ", " : "") << obj[i]; o << "]"; return o;
}
template <class T, class U>
ostream &operator<<(ostream &o, const pair<T, U>&obj) {
    o << "(" << obj.first << ", " << obj.second << ")"; return o;
}
template <class T, class U>
ostream &operator<<(ostream &o, const map<T, U>&obj) {
    o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;
}
template <class T>
ostream &operator<<(ostream &o, const set<T>&obj) {
    o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;
}

void print() {
    cout << "\n";
}
template<class Head, class... Body>
void print(Head head, Body... body) {
    cout << head << " ";
    print(body...);
}

int main(int argc, char const *argv[]) {
    int N;
    cin >> N;
    cout << "ABC" << N / 100 << (N/10) % 10 << N % 10 << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		TreeSet<Integer> set = new TreeSet<>();
		int n = sc.nextInt();
		for (int i = 0; i < n; i++) {
		    set.add(sc.nextInt());
		}
		int m = sc.nextInt();
		for (int i = 0; i < m; i++) {
		    set.add(sc.nextInt());
		}
		StringBuilder sb = new StringBuilder();
		for (int x : set) {
		    sb.append(x).append("\n");
		}
		System.out.print(sb);
	}
}



Measured memory_bytes: 195056
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
		ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
		int a;
		string p;
		cin>>a>>p;
		if(a>=3200)cout<<p;
		else cout<<"red";
		return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	string s;
	cin >> s;

    bool flg=1;
    for(int i=0; i<s.size(); ++i){
        if((i+1)%2==1 && s[i]=='L'){
            flg=0;
            break;
        }
        if((i+1)%2==0 && s[i]=='R'){
            flg=0;
            break;
        }
    }

    cout << (flg ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
#define N 100005
using namespace std;
 
int n, k;
int main() {
	scanf("%d %d", &n, &k);
	int mx = 0, gcd = 0;
	for (int i = 1; i <= n; i++) {
		int x; scanf("%d", &x);
		mx = max(mx, x);
		gcd = __gcd(gcd, x);
	}
	puts(k % gcd == 0 && k <= mx ? "POSSIBLE" : "IMPOSSIBLE");
}

Measured memory_bytes: 256
def main():
    N, K = [int(v) for v in input().split()]
    H = [int(v) for v in input().split()]

    dp = [0] * N

    for i in range(1, N):
        dp[i] = min(dp[j] + abs(H[i] - H[j]) for j in range(max(0, i - K), i))

    print(dp[N - 1])


main()


Measured memory_bytes: 13980
#include<bits/stdc++.h>
using namespace std;
int n,m,a,b;
int main()
{
    cin>>n>>m;
    a=(m-2*n)/2;
    b=n-a;
    if(a>=0&&b>=0&&a+b==n&&a*4+b*2==m)
    {
        cout<<"Yes"<<endl;
    }
    else cout<<"No"<<endl;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#include<string.h>
 
typedef long long int ll;
#define all(x) (x).begin(), (x).end()
 
using namespace std;

int nxt() {
    int x;
    cin >> x;
    return x;
}

ll nxtl(){
    ll x;
    cin>>x;
    return x;
}
 
void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 
 
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    return b;
}
 
ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
} 

ll modPow(ll a, ll x, ll p) {
    //calculates a^x mod p in logarithmic time.
    ll res = 1;
    while(x > 0) {
        if( x % 2 != 0) {
            res = (res * a) % p;
        }
        a = (a * a) % p;
        x /= 2;
    }
    return res;
}

ll modInverse(ll a, ll p) {
    //calculates the modular multiplicative of a mod m.
    //(assuming p is prime).
    return modPow(a, p-2, p);
}
ll modBinomial(ll n, ll k, ll p) {
// calculates C(n,k) mod p (assuming p is prime).

    ll numerator = 1; // n * (n-1) * ... * (n-k+1)
    for (int i=0; i<k; i++) {
        numerator = (numerator * (n-i) ) % p;
    }

    ll denominator = 1; // k!
    for (int i=1; i<=k; i++) {
        denominator = (denominator * i) % p;
    }

    // numerator / denominator mod p.
    return ( numerator* modInverse(denominator,p) ) % p;
}

ll f[200001];
 
ll pow(ll a, ll b, ll MOD)
{
 ll x=1,y=a; 
 while(b > 0)
    {
        if(b%2 == 1)
    {
        x=(x*y);
        if(x>MOD) x%=MOD;
    }
    y = (y*y);
    if(y>MOD) y%=MOD; 
    b /= 2;
    }
 return x;
}
 
/* Modular Multiplicative Inverse
 Using Euler's Theorem
 a^(phi(m)) = 1 (mod m)
 a^(-1) = a^(m-2) (mod m) */
ll InverseEuler(ll n, ll MOD)
{
 return pow(n,MOD-2,MOD);
}
 
ll C(ll n, ll r, ll MOD)
{
 
 return (f[n]*((InverseEuler(f[r], MOD) * InverseEuler(f[n-r], MOD)) % MOD)) % MOD;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int a=nxt(),b=nxt(),c=nxt();
    int k=nxt();
    while(k)
    {
        if(b<=a)
        {
            k--;
            b*=2;
        }
        else
        {
            k--;
            c*=2;
        }
    }
    if(b>a&&c>b)
        cout<<"Yes\n";
    else
        cout<<"No\n";
    
    
    return 0;   
}


 
 


Measured memory_bytes: 3616
#include<iostream>

using namespace std;

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

    if (n % 2 != 0) {
        cout << "No" << endl;
        return 0;
    }
    string b = s.substr(0, n / 2);
    string a = s.substr(n / 2, n);
    if (b.compare(a) == 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
n = int(input())
ss = []
for i in range(n):
    s = input()
    ss.append(''.join(sorted(s)))

ss = sorted(ss)

res = 0
while True:
    if len(ss) <= 1:
        break
    if ss[0] != ss[1]:
        ss.pop(0)
        continue
    i = 1
    while True:
        if i == len(ss):
            res += i * (i-1) / 2
            for num in range(i):
                ss.pop(0)
            break
        if ss[0] == ss[i]:
            i += 1
        else:
            res += i * (i-1) / 2
            for num in range(i):
                ss.pop(0)
            break

print(int(res))

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

int main(int argc, char** argv){
  int A, B, Q;
  cin >> A >> B >> Q;
  long long s[A+2];
  long long t[B+2];
  long long x;
  s[0]=-1e11;
  for(int cnt0=1; cnt0<=A; cnt0++){
    cin >> s[cnt0];
  }
  s[A+1]=1e11;
  t[0]=-1e11;
  for(int cnt0=1; cnt0<=B; cnt0++){
    cin >> t[cnt0];
  }
  t[B+1]=1e11;

  while(cin >> x){
    long long d;
    long long *ws, *es;
    long long *wt, *et;
/*
	for(int cnt0=1; cnt0<A+2; cnt0++){
      if(s[cnt0] >= x) {
        ws=s[cnt0-1];
        es=s[cnt0];
        break;
      }
    }
*/
    es = upper_bound(s, s+A, x);
    ws = es-1;
/*
    printf("%lld, %lld\n", *es, *ws);
    return 0;
*/
    /*
    for(int cnt0=1; cnt0<B+2; cnt0++){
      if(t[cnt0] >= x) {
        wt=t[cnt0-1];
        et=t[cnt0];
        break;
      }
    }
*/
    et = upper_bound(t, t+B, x);
    wt = et-1;
/*
    cout << "ws: " << ws << ", es: " << es << endl;
    cout << "wt: " << wt << ", et: " << et << endl;
    continue;
*/
	d = abs(*ws-x)+abs(*wt-*ws);
    d = min(d, abs(*ws-x)+abs(*et-*ws));
    d = min(d, abs(*es-x)+abs(*wt-*es));
    d = min(d, abs(*es-x)+abs(*et-*es));    
    d = min(d, abs(*wt-x)+abs(*ws-*wt));
    d = min(d, abs(*wt-x)+abs(*es-*wt));
    d = min(d, abs(*et-x)+abs(*ws-*et));
    d = min(d, abs(*et-x)+abs(*es-*et));
    printf("%lld\n", d);
  }
/*
  for(int cnt0=0; cnt0<Q; cnt0++){
    cin >> t[cnt0];
  }
*/

  return 0;
}


Measured memory_bytes: 2816
n, h = map(int, input().split())
bi_str = []
a_big = 0
ans = 0
a = [0] * n
b = [0] * n
for i in range(n):
    a[i], b[i] = map(int, input().split())
    if a[i] > a_big:
        a_big = a[i]

for i in range(n):
    if b[i] > a_big:
        bi_str.append(b[i])
bi_str.sort(reverse=True)
#print(bi_str)
#print(a_big)
if h <= sum(bi_str):
    for i in bi_str:
        if h > 0:
            h -= i
            ans += 1
        else:
            break
else:
    h -= sum(bi_str)
    ans += len(bi_str)
    ans += -(-h//a_big)
    '''
    if round(h/a_big) == h//a_big:
        ans += h//a_big
    else:
        ans += h//a_big+1
        '''

print(ans)



Measured memory_bytes: 17860
/*"Success isn't permanent, failure isn't fatal,
                                      it's the courage to continue that counts"*/
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
using namespace std;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
#define ll long long 
#define scn(n) scanf("%d",&n)
#define lscn(n) scanf("%lld",&n)
#define lpri(n) printf("%lld",n)
#define pri(n) printf("%d",n)
#define pln() printf("\n")
#define priln(n) printf("%d\n",n)
#define lpriln(n) printf("%lld\n",n)
#define rep(i,init,n) for(int i=init;i<n;i++)
#define pb push_back     
#define mp make_pair
#define F first
#define S second
#define gcd __gcd
#define inf INT_MAX
#define ninf INT_MIN
const int mod=1e9+7;         
const int N=2e5+4;

int main()
{
	int n,k,c;

	scn(n); scn(k); scn(c);

	string s;

	cin>>s;

	//I mean day if I write time anywhere...

	//earliest[i] tells the earliest time we can start the ith day's work
	//latest[i] tells the latest time we can start the ith day's work
	int earliest[k+1],latest[k+1];

	int cnt=1;

	//times can be greedily be alloted. Consider the case of earliest, If I can
	//work at this instant, then why not, if I skip today's work then we can
	//see that the earliest time of all later works including today's work
	//will only get delayed.

	for(int i=0;i<n;i++)
	{
		if(s[i]=='o')
		{
			earliest[cnt++]=i+1;

			i+=c;

			if(cnt>k)
			break;
		}
	}

	cnt=k;

	for(int i=n-1;i>=0;i--)
	{
		if(s[i]=='o')
		{
			latest[cnt--]=i+1;

			i-=c;

			if(cnt<=0)
			break;
		}
	}

	//rep(i,1,k+1)
	//cout<<earliest[i]<<" "<<latest[i]<<endl;

	vector<int> ans;

	rep(i,1,k+1)
	if(latest[i]==earliest[i])
	ans.pb(latest[i]);

	for(int it:ans)
	priln(it);

    return 0;
}

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

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

#define int long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define dbg(x) cerr << #x << ": " << x << endl;
#define dbg2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define dbg3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define dbgB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }

template<typename T>
void print1(T begin, T end) {
	while (begin != end) {
		cerr << (*begin) << " ";
		*begin++;
	}
	cerr << endl;
}

template<typename T>
void print2(T Array, int height, int width) {
	for (int i = 0; i < height; i++) {
		for (int j = 0; j < width; j++) {
			cerr << " " << Array[i][j];
		}
		cerr << endl;
	}
}

void print() { std::cerr << endl; }
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
	std::cerr << head << " ";
	print(std::forward<Tail>(tail)...);
}

template<class T>
void Add(T &a, const T &b, const T &mod=1000000007) {
	int val = ((a % mod) + (b % mod)) % mod;
	if (val < 0) { val += mod; }
	a = val;
}

template <typename X, typename T> auto vectors(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto vectors(X x, Y y, Z z, Zs... zs) { auto cont = vectors(y, z, zs...); return vector<decltype(cont)>(x, cont); }

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

const long long mod = 1e9 + 7;

long long POW(long long a, long long b) {
	long long ret = 1;
		while (b > 0) {
			if (b&1) {
				ret = ((ret % mod) * (a % mod)) % mod;
			}
			a = ((a % mod) * (a % mod)) % mod;
			b /= 2;
		}
	return ret;
}

long long nCk(long long n, long long k) {
	long long ue = 1; // 分子
	long long shita = 1; // 分母
	for (int i = 0; i < k; i++) {
		ue *= n - i;
		shita *= k - i;
		ue %= mod;
		shita %= mod;
	}
	shita = POW(shita, mod - 2) % mod; // 逆元にする

	// dbg3(ue, shita, (ue / shita) % mod)
	// return (ue / shita) % mod;

	return (ue * shita) % mod;
}

signed main() {
	int n, a, b;
	cin >> n >> a >> b;

	long long ans = POW(2, n) % mod - (nCk(n, a) + nCk(n, b) + 1) % mod;
	if (ans < 0) {
		ans += mod;
		ans %= mod;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/ruby -Ku

require 'pp'

time1 = [35.5, 37.5, 40.0, 43.0, 50.0,  55.0,  70.0, 2<<30 ]
time2 = [71.0, 77.0, 83.0, 89.0, 105.0, 116.0, 148.0, 2<<30]

rank = ["AAA", "AA", "A", "B", "C", "D", "E", "NA"]

loop do
  line = gets
  break if line == nil
  
  t1, t2 = line.split(nil).map(&:to_f)
  i = 0
  time1.length.times{|i|
    if t1 < time1[i] && t2 < time2[i] then
      puts rank[i]
      break
    end
  }
end

Measured memory_bytes: 6276
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define FOR(i,a,b) for(int i=(a); i<=(b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define chmin(a,b) if((a)>(b)) (a)=(b);
#define chmax(a,b) if((a)<(b)) (a)=(b);
#define vi vector<int>
#define pii pair<int,int>
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define pb push_back
#define pf push_front
int gcd(int a,int b){/*a>=0,b>=0,￢(a=b=0)*/
  while(min(a,b)>0){if(a<b)swap(a,b);a%=b;}return max(a,b);
}
int dx[]={1,0,-1,0,1,-1,-1,1};
int dy[]={0,1,0,-1,1,1,-1,-1};
const int MOD = 1e9+7;
const long long INF = 1e18+10;

/*--------------------------------------------------------------------*/
signed main(){
	string s;
	cin>>s;

	int n=s.size();
	int ans=0;
	rep(i,(n+1)/2){
		if(s[i]!=s[n-i-1]){
			ans++;
		}
	}
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 3600
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
	int n;cin>>n;
	vector<int> A(n);
	for(int i = 0; n > i; i++){
		cin>>A[i];
	}
	int mx = 0;
	for(int i = 0; n > i; i++){
		if(mx < i){
			cout << "no" << endl;
			return 0;
		}
		mx = max(mx,i+A[i]/10);
	}
	reverse(A.begin(),A.end());
	mx = 0;
	for(int i = 0; n > i; i++){
		if(mx < i){
			cout << "no" << endl;
			return 0;
		}
		mx = max(mx,i+A[i]/10);
	}
	cout << "yes" << endl;
}


Measured memory_bytes: 3888
import java.util.Scanner;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    for (int i = 1; ; i++){
      int x = sc.nextInt();
      if (x > 0) {
        System.out.printf("Case %d: %d\n", i, x);
      } else {
        break;
      }
    }
  }
}



Measured memory_bytes: 61880
from collections import Counter


def main():
    N, K = list(map(int, input().split(' ')))
    A = list(map(int, input().split(' ')))
    counter = Counter(A)
    n_kind = len(counter.keys())
    if n_kind <= K:
        print(0)
    else:
        counts = list(counter.values())
        counts.sort()
        print(sum(counts[:(n_kind - K)]))



if __name__ == '__main__':
    main()

Measured memory_bytes: 32564
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include<set>
#include<map>
using namespace std;

const double PI  = 3.141592653589793238463;

int main() {
    int a, b;
    string s;
    cin >> a >> b;
    for(int i = 0; i < a; i++){
        cin >> s;
        cout << s << endl << s << endl;
    }
}


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

int N, M;   //N個のスイッチとM個の電球
int k[11];  //k個のスイッチにつながってる
int s[11][11];  //k個のスイッチ=s1~sk
int p[11];  //s個のスイッチのうち、オンになっている数を2で割った余りがpの時、点灯

/* ビットの立っているフラグをついてる電球する。s個ずらす方法で比べて、つながってる電球のうちついているものがいくつかを調べる。その調べた個数を2で割ってpと比べる */
int judge(int bit)
{
    int cnt;
    for(int i=1; i<=M; i++) {
        cnt=0;
        for(int j=1; j<=k[i]; j++) {    //つながってるk個のスイッチに対して
            if(bit & (1<<(s[i][j]-1))) cnt++;   //bitの(s[i][j]-1)番目が1の時、(s[i][j])はスイッチオン
            // printf("%dの%d回目:%d\n", i, j, cnt);
        }
        if((cnt%2) != p[i]) return 0;
    }
    return 1;
}

int main()
{
    int total=0;
    scanf("%d %d", &N, &M);
    for(int i=1; i<=M; i++) {
        scanf("%d", &k[i]);
        for(int j=1; j<=k[i]; j++) {
            scanf("%d", &s[i][j]);
        }
    }
    for(int i=1; i<=M; i++) scanf("%d", &p[i]);

    for(int bit=0; bit<(1<<N); bit++) {
        if(judge(bit)) total++;
    }

    printf("%d", total);
}

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

using namespace std;
typedef long long ll;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);	
   
    int k, r, d=0;
    cin >> k >> r;
    if(k >= 10)
        cout << r;
    else
        cout << r+100*(10-k);
    return 0;
} 
 


Measured memory_bytes: 3616
#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++)
using ll = long long;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using P = pair<ll, ll>;

// chmin, chmax関数
template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) {
        xmax = x;
        return true;
    }
    return false;
}
template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) {
        xmin = x;
        return true;
    }
    return false;
}

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

int main(){
    ll x,y,a,b,c;
    cin >> x >> y >> a >> b >> c;
    VL p(a), q(b), r(c);
    rep(i,a) cin >> p[i];
    rep(i,b) cin >> q[i];
    rep(i,c) cin >> r[i];

    VL eat;
    sort(p.begin(), p.end(), greater<ll>());
    sort(q.begin(), q.end(), greater<ll>());
    sort(r.begin(), r.end(), greater<ll>());

    rep(i,x) eat.push_back(p[i]);
    rep(i,y) eat.push_back(q[i]);
    sort(eat.begin(), eat.end(), greater<ll>());

    ll ei = 0, ri = 0, ans = 0;
    rep(i,x+y){
        if(r[ri] > eat[ei]){
            ans += r[ri];
            ri++;
        }else{
            ans += eat[ei];
            ei++;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4724
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef long long LL;
#define PB push_back
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define IN_LL(v) LL v;cin>>v;
#define OUT(v) cout<<v<<endl


int main() {
  IN_LL(N);

  vector<LL> A;
  priority_queue<LL> Q;
  REP(i, N) {
    IN_LL(a);
    A.PB(a);
    Q.push(a);
  }
  LL max_val = Q.top(); Q.pop();
  LL second_val = Q.top(); Q.pop();
  REP(i, N) {
    if (max_val == second_val)
      OUT(max_val);
    else if (A[i] == max_val)
      OUT(second_val);
    else
      OUT(max_val);
  }

  return 0;
}


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

const long long MOD = 1000000007;
vector<vector<int>> T;
int N;
const ll MAXN = 100000;
ll dp[MAXN +1][2];

int dfs(int node,int color,int parent){
    cerr <<"target =" << node << endl;
    if(dp[node][color] >= 0){
        return dp[node][color];
    }
    ll retVal = 1;
    for(int child:T[node]){
        cerr << "child node = " << child << endl;
        if(child == parent){
            continue;
        }
        if(color == 0){   
            retVal *= ((dfs(child,1,node) + dfs(child,0,node)) % MOD);
            retVal %= MOD;
        }else{
            retVal *= dfs(child,0,node);
            retVal %= MOD;
        }
    }
    cerr << "target =" << node << "color = " << color << " Val = " << retVal << endl;
    dp[node][color] = retVal;
    return retVal;
}

int main(){
    cin >> N;
    T.resize(N);
    for(int i=0;i<N-1;i++){
        int a,b;
        cin >> a >> b;
        a--;b--;
        T[a].push_back(b);
        T[b].push_back(a);
    }
    for(int i=0;i<N;i++){
        for(int j=0;j<2;j++){
            dp[i][j] = -1;
        }
    }
    // cerr <<"white" << dfs(0,0,-1) << endl;
    // cerr <<"black" <<  dfs(0,1,-1) << endl;
    cout << (dfs(0,0,-1) + dfs(0,1,-1)) %MOD << endl;
    return 0;
}


Measured memory_bytes: 17024
import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from math import *
# import math
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
# sys.setrecursionlimit(int(pow(10, 2)))
# sys.stdin = open("input.txt", "r")
# sys.stdout = open("output.txt", "w")
mod = int(pow(10, 9) + 7)
mod2 = 998244353
def data(): return sys.stdin.readline().strip()
def out(*var, end="\n"): sys.stdout.write(' '.join(map(str, var))+end)
def l(): return list(sp())
def sl(): return list(ssp())
def sp(): return map(int, data().split())
def ssp(): return map(str, data().split())
def l1d(n, val=0): return [val for i in range(n)]
def l2d(n, m, val=0): return [l1d(n, val) for j in range(m)]





# @lru_cache(None)
sa=input()
sb=input()
sc=input()
i=j=k=0
d={"a":0,"b":1,"c":2}
curr=0
while(i<=len(sa) and j<=len(sb) and k<=len(sc)):
    # print(curr)
    if(curr==0):
        if(i==len(sa)):
            break
        curr=d[sa[i]]
        i+=1
    elif(curr==1):
        if(j==len(sb)):
            break
        curr=d[sb[j]]
        j+=1
    else:
        if(k==len(sc)):
            break
        curr=d[sc[k]]
        k+=1
if(curr==0):
    print("A")
elif(curr==1):
    print("B")
else:
    print("C")



Measured memory_bytes: 5252
import java.util.ArrayList;

import java.util.Scanner;

public class Main{
	
	public static void main(String[] args){

		//初期処理
		Scanner sc = null;
		ArrayList<Integer> array = new ArrayList<Integer>();
		int number = 0;
		
		//テキスト入力クラス
		sc = new Scanner(System.in);

		//do~while処理
		do{
			
			//現在の入力値
			number = sc.nextInt();
			//配列に追加
			array.add(number);

		//入力結果が0になるまで入力
		}while(number != 0);
		
		//最後の配列を出力しないので、ループは配列の数より１回少ない
		for(int i =1;i < array.size();i++){
			//配列に格納されている結果を出力
			System.out.println("Case "+i+": "+array.get(i-1));
		}
	}
}

Measured memory_bytes: 39936
n, q = list(map(int, input().split()))
s = input()
ls = []
for _ in range(q):
    l, r = list(map(int, input().split()))
    ls.append((l, r))

t = [0] * (n + 1)
for i in range(n):
    t[i + 1] = t[i] + (1 if s[i : i + 2] == "AC" else 0)

for (l, r) in ls:
    print(t[r - 1] - t[l - 1])

Measured memory_bytes: 21300
#include <bits/stdc++.h>
#define fi first
#define se second
using namespace std;

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    int n, m;
    cin >> n >> m;
    pair<int, int> s {-1, 200000};
    for(int i = 1; i <= m; ++i) {
        int l, r;
        cin >> l >> r;
        s.fi = max(s.fi, l);
        s.se = min(s.se, r);
    }
    cout << max(0, s.se - s.fi + 1) << endl;
}

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


int main()
{
	
	int n;
	cin>>n;
	map<int,int > m;
	for(int i=0;i<n-1;i++)
	{
		int a;
		cin>>a;
		m[a]++;
	}
	for(int i=1;i<=n;i++)
	{
		cout<<m[i]<<endl;
	}
		
		
}



Measured memory_bytes: 13008
#include <iostream>
#include <vector>
#include <deque>
#include <algorithm>
#include <numeric>
#include <string>
#include <cstring>
#include <list>
#include <unordered_set>
#include <tuple>
#include <cmath>
#include <limits>
#include <type_traits>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <set>
#include <bitset>
#include <regex>
#include <random>
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
#define rep(i,n)for(ll i=0;i<n;++i)
#define exout(x) printf("%.10f\n", x)
const double pi = acos(-1.0);
const ll MOD = 1000000007;
const ll INF = 1e18;
const ll MAX_N = 201010;

//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

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

ll dx[4] = { 0,0,-1,1 };
ll dy[4] = { -1,1,0,0 };
char c[30][30];
char atari[30];
ll dp[101];

//long longしか使わない
//素数は1より大きい
//lower_boundは指定したkey以上の要素の一番左のイテレータをかえす
//upper_boundは指定したkeyより大きい要素の一番左のイテレータをかえす
int main() {
	ll n;
	cin >> n;
	vector<ll>a(n);
	rep(i, n) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	ll ans1 = a[n - 1];
	ll target = a[n - 1] / 2;
	ll target2 = (a[n - 1] + 1) / 2;
	ll dist = INF;
	ll ans2;
	rep(i, n-1) {
		if (abs(a[i] - target) + abs(a[i] - target2) <= dist) {
			ans2 = a[i];
			dist = abs(a[i] - target) + abs(a[i] - target2);
		}
	}
	cout << ans1 << " " << ans2 << endl;
	return 0;
}


Measured memory_bytes: 4032
#ifdef LOCAL
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <map>
#else
#include <bits/stdc++.h>
#endif
using namespace std ;

typedef long long ll ;
#define rep(i , n ) for ( int i =0; i < n ; i++)
#define _sort(arg) sort(begin(arg), end(arg))
#define MOD 1000000007
#define pb push_back
#define DEBUG(x) cout << #x << ": " << x << endl;

/*
__attribute__((constructor))
void initial()
{
	cin.tie(NULL);
	ios::sync_with_stdio(false);
}
*/

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

	ll N, K;
	
	cin >> N >> K;

	ll sum = 0;
	//ll a[N], b[N];
	map<ll, ll> v;

	#if 0
	ll found_v = 0;

	rep(i, N)
	{
		ll a, b;
		cin >> a >> b;
		if ((sum < K) && (sum + b >= K))
		{
			found_v = a;
		}
		sum += b;
	}

	cout << found_v << endl;
	#endif

	rep(i, N)
	{
		ll a, b;
		cin >> a >> b;

		if (v[a] == 0)
		{
			v[a] = b;
		}
		else
		{
			v[a] += b;
		}
	}
	//ll sum = 0;

	for (std::map<ll, ll>::iterator i = v.begin(); i != v.end(); i++)
	{
		if ((sum < K) && (sum + i->second >= K))
		{
			cout << i->first << endl;
			break;
		}
		sum += i->second;
	}
	return 0;
}


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

int main(void){
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for(int i=0; i<n; ++i)
        cin >> a[i];

    int ans = 0;
    for(int i=0; i<n; ++i){
        ans += (2*a[i] <= 2*(k-a[i]))? 2*a[i] : 2*(k-a[i]);
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 3564