akhauriyash/Code-Regression huggingface dataset:
#![allow(unused_imports)]
#![allow(dead_code)]
use std::io::{stdin, stdout, stderr, Write, BufWriter, BufReader, BufRead};

macro_rules! read_from_line {
    ($inbuf:ident => $($name:ident : $ty:ty),* ) => {
        let mut buf = String::new();
        $inbuf.read_line(&mut buf).unwrap();
        buf.pop();
        let mut words = buf.split_whitespace();
        $(
            let $name:$ty = words.next().unwrap().parse().unwrap();
        )*
    };
}

fn main() {
    let cout = stdout();
    let mut cout = BufWriter::new(cout.lock());
    let cin = stdin();
    let mut cin = BufReader::new(cin.lock());

    //read_from_line!(cin => a:i32, b:String);
    //let xs: Vec<i32> = strio::read_many_from_line(&mut cin);
    
    read_from_line!(cin => n:i32);
    if n % 2 == 0 {
        writeln!(cout, "{}", n).unwrap();
    } else {
        writeln!(cout, "{}", n * 2).unwrap();
    }

}

mod strio {
    use std::str::FromStr;
    use std;

    pub fn read_from_line<T, R> (r: &mut R) -> T where
        T: FromStr,
        <T as std::str::FromStr>::Err : std::fmt::Debug,
        R: std::io::BufRead,
    {
        let mut buf = String::new();
        r.read_line(&mut buf).unwrap();
        buf.pop();
        buf.parse().unwrap()
    }

    pub fn read_many_from_line<T, R> (r: &mut R) -> Vec<T> where
        T: FromStr,
        <T as std::str::FromStr>::Err : std::fmt::Debug,
        R: std::io::BufRead,
    {
        let mut buf = String::new();
        r.read_line(&mut buf).unwrap();
        buf.pop();
        buf.split_whitespace().map(|x| x.parse().unwrap()).collect()
    }
}


Measured memory_bytes: 4352
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

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

typedef long long ll;
#define tr(container, it) \
        for (auto it = container.begin(); it != container.end(); it++)
#define scontains(c, x) ((c).find(x) != (c).end())   //O(log n)
#define contains(c, x) (find((c).begin(),(c).end(),x) != (c).end()) //O(n)
#define pll pair<ll,ll>
#define pii pair<int,int>
#define mll map<ll,ll>
#define intv(x, a, b)((x)>=a && (x)<=b)
#define  rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define  _for(i, end) for (__typeof(end) i = 0; i < (end); i += 1)
#define all(x) (x).begin(),(x).end()
//#define len(array)  (sizeof(array)/sizeof((array)[0]))
#define what_is(x) cerr << #x << " is " << x << endl;
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#define mod(x, m) ((((x) % (m)) + (m)) % (m))
const double PI = 2 * acos(.0);
const int INF = 0x3f3f3f3f;
const ll LLINF = 1000000000000000005LL;;
const ll MOD = (ll) (1e9) + 7;
void _mod(ll &x){x = mod(x, MOD);}
//const ll MOD = (ll) 998244353 ;
const double EPS = 1e-10;

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    std::fill((T *) array, (T *) (array + N), val);
}


//#define int ll

class BBoxes {
public:
        ll N;
        ll A[101010];
void solve(std::istream& cin, std::ostream& cout) {
    cin >> N;
    ll sum = 0;
    _for(i,N)cin >> A[i];
    _for(i,N)sum += A[i];
    if(sum % ((N+1)*N/2)){
        cout << "NO\n";
        return;
    }
    ll n = sum / (N*(N+1)/2);
    int cnt = 0;
    _for(i,N){
        if((n-(A[(i+1)%N]-A[i])) % N || !intv((n-(A[(i+1)%N]-A[i])) / N,0,n)){
            cout << "NO\n";
            return;
        }
        cnt += (n - (A[(i+1)%N] - A[i]))/N;
    }
    if(cnt == n)cout << "YES\n";
    else cout << "NO\n";


}
};


#undef int
int main() {
	BBoxes solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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

const ll mod = 1e9+7;

int main() {
    int N,M;
    cin >> N >> M;
    vector<ll> dp(N+1, -1);
    dp[0]=1;
    dp[1]=1;
    int a;
    for(int i=0;i<M;++i) {
        cin >> a;
        dp[a] = 0;
    }
    for(int i=2;i<=N;++i) {
        if(dp[i]==0) continue;
        dp[i] = (dp[i-2]+dp[i-1])%mod;
    }
    cout << dp[N] << endl;
    
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define INF 1000000

//セグ木ここから
//*
//↓ここを変える
typedef struct atai{int o,oi,e,ei;}atai;
atai xx(atai x,atai y){
	atai r;
	if(x.o<y.o){
		r.o=x.o;
		r.oi=x.oi;
	}else{
		r.o=y.o;
		r.oi=y.oi;
	}
	if(x.e<y.e){
		r.e=x.e;
		r.ei=x.ei;
	}else{
		r.e=y.e;
		r.ei=y.ei;
	}
	return r;
}
//↑ここを変える

int segNUM;
atai segN[1<<19],*seg;
void seguse(int n){segNUM=n;seg=segN+segNUM;}

//seg[]に値を与えてから初期化
void seginit(){for(int node=segNUM-1;node;node--)segN[node]=xx(segN[node*2],segN[node*2+1]);}
void segupdate(int node,atai x){
	//seg[node]をxに更新
	node+=segNUM;
	segN[node]=x;
	while(node/=2)segN[node]=xx(segN[node*2],segN[node*2+1]);
}

atai segcalcsub(int l,int r,int k,int cl,int cr){
	//完全に含むとき
	if(l<=cl&&cr<=r)return segN[k];

	int cm=(cl+cr)/2;
	//左側だけ
	if(r<=cm)return segcalcsub(l,r,2*k  ,cl,cm);
	//右側だけ
	if(cm<=l)return segcalcsub(l,r,2*k+1,cm,cr);
	//両方
	return xx(segcalcsub(l,r,2*k,cl,cm),segcalcsub(l,r,2*k+1,cm,cr));
}
atai segcalc(int l,int r){return segcalcsub(l,r,1,0,segNUM);}
//セグ木ここまで
//*/




//*
//プラキュー（二分ヒープ）（最低限バージョン）
ll heap[1<<18];
int cnt;
int al[1<<18],ar[1<<18],ax[1<<18];
//int PQhikaku(int i,int j);//jの方が優先度が高いならtrueを返す
int PQhikaku(ll*heap,int i,int j){return ax[heap[i]]>ax[heap[j]];}
void heap_utod(ll*heap,int n){
	if(2*n>heap[0])return;
	int rflag=(2*n+1<=heap[0])&&(PQhikaku(heap,2*n,2*n+1));
	if(PQhikaku(heap,n,2*n+rflag)){
		ll temp=heap[2*n+rflag];
		heap[2*n+rflag]=heap[n];
		heap[n]=temp;
		heap_utod(heap,2*n+rflag);
	}
}
void heap_dtou(ll*heap,int n){
	if(n==1||PQhikaku(heap,n,n/2))return;
	ll temp=heap[n];
	heap[n]=heap[n/2];
	heap[n/2]=temp;
	heap_dtou(heap,n/2);
}
ll PQpop(ll*heap){
	ll rr=heap[1];
	heap[1]=heap[heap[0]--];
	heap_utod(heap,1);
	return rr;
}
void PQpush(ll*heap,ll l,ll r){
	al[cnt]=l;
	ar[cnt]=r;
	atai x=segcalc(l,r);
	if(l%2==0)ax[cnt]=x.e;
	else ax[cnt]=x.o;
	heap[++heap[0]]=cnt;
	cnt++;
	heap_dtou(heap,heap[0]);
}
//*/



int main(){
	ll n;
	scanf("%lld",&n);
	seguse(1<<18);
	rep(i,0,n){
		ll t;
		scanf("%lld",&t);
		if(i%2==0){
			seg[i].o=INF;
			seg[i].e=t;
		}else{
			seg[i].o=t;
			seg[i].e=INF;
		}
		seg[i].ei=seg[i].oi=i;
	}
	rep(i,n,1<<18)seg[i].o=seg[i].e=INF;
	seginit();
	
	PQpush(heap,0,n);
	rep(i,0,n/2){
		int t=PQpop(heap);
		int l=al[t],r=ar[t];
		atai x=segcalc(l,r);
		if(l%2==0){
			printf("%d ",x.e);
			atai y=segcalc(x.ei+1,r);
			printf("%d ",y.o);
			if(l!=x.ei)PQpush(heap,l,x.ei);
			if(x.ei+1!=y.oi)PQpush(heap,x.ei+1,y.oi);
			if(y.oi+1!=r)PQpush(heap,y.oi+1,r);
		}else{
			printf("%d ",x.o);
			atai y=segcalc(x.oi+1,r);
			printf("%d ",y.e);
			if(l!=x.oi)PQpush(heap,l,x.oi);
			if(x.oi+1!=y.ei)PQpush(heap,x.oi+1,y.ei);
			if(y.ei+1!=r)PQpush(heap,y.ei+1,r);
		}
	}
}


Measured memory_bytes: 13440
#include <cstdio>
#include <cmath>

int main(){
    int n, d = 0;
    scanf("%d",&n);
    for (int i = 0; i < n; ++i)
    {
        int a;
        scanf("%d",&a);
        
        int l = sqrt(a);
        int b = 0;
        if(a%2!=0){
            for (int j=2; j<=l; j++) {
                if(a%j==0){
                    b=1;
                }
            }
            if (b==0) {
                d++;
            }
        }
           
        
        
        if(a==2){
            d++;
        }
    }
    printf("%d\n",d);
}


Measured memory_bytes: 2688
#include <iostream>
#include <iomanip>
#include <map>
#include <string>
#include <algorithm>
using namespace std;

void Main() {
    // input
    u_int32_t N;
    cin >> N;

    map<string, u_int32_t> count_map;
    u_int32_t max_count = 0;
    for (u_int i = 0; i < N; i++) {
        string S;
        cin >> S;
        if ((count_map.find(S)) == count_map.end()) {
            count_map[S] = 0;
        }
        count_map[S]++;
        max_count = max(max_count, count_map[S]);
    }

    // translate


    // output
    for (auto itr = count_map.begin(); itr != count_map.end(); itr++) {
        if (itr->second == max_count) {
            cout << itr->first << endl;
        }
    }

}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 19272
import java.io.InputStream;
import java.io.PrintStream;
import java.util.*;
import java.util.stream.Collectors;

public class Main {

  public static void main(String[] args) {
    solve(System.in, System.out);
  }

  private static class Student {

    int id;
    int order;
  }

  static void solve(InputStream is, PrintStream os) {
    Scanner sc = new Scanner(is);

    /* read */
    int n = sc.nextInt();

    List<Student> students = new ArrayList<>(n);

    for (int i = 1; i <= n; i++) {
      Student s = new Student();
      s.id = i;
      s.order = sc.nextInt();
      students.add(s);
    }

    students.sort(Comparator.comparingInt(s -> s.order));

    List<String> ids = students.stream().map(student -> String.valueOf(student.id))
        .collect(Collectors.toList());

    os.println(String.join(" ", ids));
  }

}

Measured memory_bytes: 63564
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <sstream>
#include <string>
#include <vector>
using namespace std;
int main(void){
    string s;
    cin >> s;
    int y = stoi(s.substr(0, 4));
    int m = stoi(s.substr(5, 2));
    string ans;
    if (y < 2019){
        ans = "Heisei";
    } else if(y == 2019){
        if(m > 4){
            ans = "TBD";
        } else{
            ans = "Heisei";
        }
    } else {
        ans = "TBD";
    }
    cout << ans;
}

Measured memory_bytes: 256
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  

#pragma warning(disable:4996)  
#pragma comment(linker, "/STACK:336777216")  
using namespace std;

#define mp make_pair  
#define Fi first  
#define Se second  
#define pb(x) push_back(x)  
#define szz(x) ((int)(x).size())  
#define rep(i, n) for(int i=0;i<n;i++)  
#define all(x) (x).begin(), (x).end()  
#define ldb ldouble  

typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 19;
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;

int in[3][3];
int main() {
	int i, j, k;
	for (i = 0; i < 3; i++) for (j = 0; j < 3; j++) scanf("%d", &in[i][j]);
	
	for (i = 1; i < 3; i++) {
		for (j = 1; j < 3; j++) {
			if (in[i][j] + in[0][0] != in[0][j] + in[i][0]) return !printf("No\n");
		}
	}
	return !printf("Yes\n");
}

Measured memory_bytes: 256
l = raw_input().split()
M = [0]*3
M[0] = int(l[0])
M[1] = int(l[1])
M[2] = int(l[2])
N = int(l[3])
M.sort()

#print(M, N)

count = 0

for i in range(N / M[2] + 1):
    remain1 = N - i * M[2]
 #   print('i', i, remain)
    for j in range(remain1 / M[1] + 1):
        remain2 = remain1 - j * M[1]
#        print('j', j, remain)
        if remain2 % M[0] == 0:
#            print('ans', remain2 / M[0], j, i)
            count += 1

print(count)



Measured memory_bytes: 2820
N = int(input())
h = [int(i) for i in input().split()]
h.append(0)

cnt = 0
for H in range(max(h)):
    #print(h)
    for i in range(N):
        if h[i] >0:
            h[i] -= 1
            if h[i+1] == 0:
                cnt +=1

print(cnt)

Measured memory_bytes: 38896
from collections import Counter,defaultdict,deque
import sys
import bisect
import math
import itertools
import string
import queue
import copy
from itertools import permutations, combinations
from heapq import heappop, heappush
# input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
 
def inp(): # n=1
    return int(input())
def inpm(): # x=1,y=2
    return map(int,input().split())
def inpl(): # a=[1,2,3,4,5,...,n]
    return list(map(int, input().split()))
def inpls(): # a=['1','2','3',...,'n']
    return list(input().split())
def inplm(n): # x=[] 複数行
    return list(int(input()) for _ in range(n))
def inpll(n): # [[1,1,1,1],[2,2,2,2],[3,3,3,3]]
    return [list(map(int, input().split())) for _ in range(n)]

def div(x): #素因数配列
    div=[1]
    check=2
    while(x!=1 and check <= int(x**0.5)+2):
        if(x%check==0):
            div.append(check)
            while(x%check==0):
                x=x//check
        check+=1
    if x != 1:
      div.append(x)
    return div

def main():
    x = inp()
    for i in range(x,100004):
        if div(i)==[1,i]:
            print(i)
            return

if __name__ == "__main__":
    main()

Measured memory_bytes: 41068
// Problem : E - Red and Green Apples
// Contest : AtCoder Beginner Contest 160
// URL : https://atcoder.jp/contests/abc160/tasks/abc160_e
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/coder3101/cp-editor)

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

#ifdef LOCAL
#define DEBUG(...) cerr << #__VA_ARGS__ << ": ", debug(__VA_ARGS__);
#else
#define DEBUG(...)
#endif

template<typename T, typename S> ostream& operator << (ostream &os, const pair<T, S> &p) {return os << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator << (ostream &os, const vector<T> &v) {os << "["; for (int i=0; i<(int)v.size(); i++) {if (i) os << ", "; os << v[i];} return os << "]";}
void debug() {cerr << "\n";} template<typename T, typename... Args> void debug(T x, Args... args) {cerr << x << "; "; debug(args...);}

int p[100000], q[100000], r[100000];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    
    int x, y, a, b, c;
    cin >> x >> y >> a >> b >> c;
    for (int i=0; i<a; i++)
        cin >> p[i];
    for (int i=0; i<b; i++)
        cin >> q[i];
    for (int i=0; i<c; i++)
        cin >> r[i];
    
    sort(p, p + a, greater<int>());
    sort(q, q + b, greater<int>());
    sort(r, r + c, greater<int>());
    
    int i = 0, j = 0, k = 0;
    long long ret = 0;
    while (x > 0 || y > 0) {
        int mx = max({x == 0 ? 0 : p[i], y == 0 ? 0 : q[j], k == c ? 0 : r[k]});
        if (x > 0 && p[i] == mx) {
            ret += p[i++];
            x--;
        } else if (y > 0 && q[j] == mx) {
            ret += q[j++];
            y--;
        } else {
            ret += r[k++];
            if (y == 0 || p[i+x-1] < q[j+y-1])
                x--;
            else
                y--;
        }
    }
    
    cout << ret << "\n";

    return 0;
}


Measured memory_bytes: 1536
#include <iostream>
using namespace std;
#define REP(i, n)   for(int i = 0; i < (int)(n); i++)
#define MAX_N   20

int n;
int p[MAX_N];

void solve(){
    int ans = 0;
    REP(i, n - 2){
        if((p[i] < p[i + 1] && p[i + 1] < p[i + 2]) || (p[i] > p[i + 1] && p[i + 1] > p[i + 2]))
            ans++;
    }
    cout << ans << endl;
}

int main (){
    cin >> n;
    REP(i, n)
        cin >> p[i];
    solve();
    return 0;
}

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

using namespace std;

const int mod = 1e9 + 7;

int n, c[200010], lst[200010], f[200010];

int main () {
	scanf ("%d", &n);
	for (int i = 1; i <= n; ++i) scanf ("%d", &c[i]);
	
	f[0] = 1;
	for (int i = 1; i <= n; ++i) {
		f[i] = f[i - 1];
		if (lst[c[i]] && lst[c[i]] != i - 1) (f[i] += f[lst[c[i]]]) %= mod;
		lst[c[i]] = i;
	}
	
	printf ("%d\n", f[n]);
	
	return 0;
}

Measured memory_bytes: 2560
//%std
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
inline int read()
{
	int out = 0, fh = 1;
	char jp = getchar();
	while ((jp > '9' || jp < '0') && jp != '-')
		jp = getchar();
	if (jp == '-')
		fh = -1, jp = getchar();
	while (jp >= '0' && jp <= '9')
		out = out * 10 + jp - '0', jp = getchar();
	return out * fh;
}
const int N = (1 << 10) + 10;
int a[11][N][N];
void construct(int n)
{
	if (n == 0)
		return;
	construct(n - 1);
	int len = 1 << (n - 1);
	for (int i = 1; i < len; ++i)
		for (int j = 1; j < len; ++j)
		{
			int t = a[n - 1][i][j];
			a[n][i][j] = t;
			a[n][i + len][j] = t;
			a[n][i][j + len] = t;
			a[n][i + len][j + len] = t;
		}		
	a[n][len][len] = 1;
}
int n, m, f = 0;
int main()
{
	n = read(), m = read();
	if (n < m)
		swap(n, m), f = 1;
	construct(n);
	if (!f)
	{
		for (int i = 1; i <= (1 << n) - 1; ++i, puts(""))
			for (int j = 1; j <= (1 << m) - 1; ++j)
				printf("%d", a[n][i][j]);
	}
	else
	{
		for (int j = 1; j <= (1 << m) - 1; ++j, puts(""))
			for (int i = 1; i <= (1 << n) - 1; ++i)
				printf("%d", a[n][i][j]);
	}
	return 0;
}


Measured memory_bytes: 26752
#include <iostream>
#include <vector>
using namespace std;
int main(void){
    int n, m;
    string s;
    vector<int> ans;
    cin >> n >> m;
    cin >> s;

    int b = n;
    for(;b > 0;){
        for(int i=m;i>0;i--){
            if(b-i >= 0 && s[b-i] == '0'){
                ans.push_back(i);
                b -= i;
                break;
            }else if(i == 1){
                cout << -1 << endl;
                return 0;
            }
        }
    }

    int as = ans.size();
    for(int i=as-1;i>=0;i--){
        cout << ans[i] << " ";
    }
    cout << endl;
}


Measured memory_bytes: 1144
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define is(a, b) a == b
#define len(v) ll(v.size())

const ll INF = 1LL << 58;

//xより以下の要素へのindex
template <class T> int former(const vector<T> &v, T x) {
  return upper_bound(v.begin(), v.end(), x) - v.begin() - 1;
}
//x以上の要素へのindex
template <class T> int latter(const vector<T> &v, T x) {
  return lower_bound(v.begin(), v.end(), x) - v.begin();
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b,q;
    ll res;
    cin>>a>>b>>q;
    vector<ll> s(a),t(b),ans(q);
    rep(i,a){
        cin>>s[i];
    }
    rep(i,b){
        cin>>t[i];
    }
    s.push_back(INF);
    s.push_back(-INF);
    t.push_back(INF);
    t.push_back(-INF);
    sort(s.begin(),s.end());
    sort(t.begin(),t.end());
    rep(i,q){
        ll x;
        cin>>x;
        res=INF;
        rep(i,2){
            ll first=(i?t[former(t,x)]:t[latter(t,x)]);
            rep(j,2){
                ll second=(j?s[former(s,first)]:s[latter(s,first)]);
                res=min(res,abs(x-first)+abs(first-second));
            }
        }
        rep(i,2){
            ll first=(i?s[former(s,x)]:s[latter(s,x)]);
            rep(j,2){
                ll second=(j?t[former(t,first)]:t[latter(t,first)]);
                res=min(res,abs(x-first)+abs(first-second));
            }
        }
        cout<<res<<'\n';
    }
}

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

int main() {
  int a , d , b;
  cin >> a >> b;

  if ( a * b %2 == 0 ) {
    cout << "Even" << endl;
  }
  else if (  a * b %2 == 1 ) {
    cout << "Odd" << endl;
}
}

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

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};


class UnionFind {
  std::vector<int> p;
  int g;

public:
  UnionFind(int n) : p(n, -1) {g=n;}

  int root(int x) { return p[x] < 0 ? x : p[x] = root(p[x]); }

  bool same(int x, int y) { return root(x) == root(y); }

  bool unite(int x, int y) {
    x = root(x);
    y = root(y);
    if (x == y) return false;
    if (p[y] < p[x]) std::swap(x, y);
    if (p[x] == p[y]) --p[x];
    p[y] = x;
    g--;
    return true;
  }
  int groups(){
      return g;
  }
};

int main(){
    int n;
    cin>>n;
    int ans=n;
    vector<ll> x(n),y(n);
    for (int i = 0; i < n; i++)
    {
        cin>>x[i]>>y[i];
    }
    for (int a = 0; a < n; a++)
    {
        for (int b = 0; b < a; b++)
        {
            UnionFind uf = UnionFind(n);
            ll diffx = x[a]-x[b];
            ll diffy = y[a]-y[b];

            for (int p = 0; p < n; p++)
            {
                for (int q = 0; q < p; q++)
                {
                    if((x[p]-x[q]==diffx && y[p]-y[q]==diffy) || 
                    (x[p]-x[q]==-diffx && y[p]-y[q]==-diffy) )
                    {
                        uf.unite(p,q);
                    }
                }
                
            }
            ans=min(ans,uf.groups());
        }
        
    }
    
    
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

#define MOD 1000000007
#define MOD2 998244353
#define int long long
#define double long double
#define EPS 1e-9
//#define PI 3.14159265358979

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

using namespace std;

template < typename T >
ostream &operator<<(ostream &os, const vector< T > &A) {
	for (int i = 0; i < A.size(); i++)
		os << A[i] << " ";
	os << endl;
	return os;
}
template <>
ostream &operator<<(ostream &os, const vector< vector< int > > &A) {
	int N = A.size();
	int M;
	if (N > 0)
		M = A[0].size();
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++)
			os << A[i][j] << " ";
		os << endl;
	}
	return os;
}

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

struct edge {
	int from, to, d, c;
	edge(int _from = 0, int _to = 0, int _d = 0, int _c = 0) {
		from = _from;
		to = _to;
		d = _d;
		c = _c;
	}
	bool operator<(const edge &rhs) const {
		return (d == rhs.d) ? (c < rhs.c) : (d < rhs.d);
	}
};
struct aabb {
	int x1, y1, x2, y2;
	aabb(int x1, int y1, int x2, int y2) : x1(x1), y1(y1), x2(x2), y2(y2) {}
};

typedef vector< edge > edges;
typedef vector< edges > graph;
struct flow {
	int to, cap, rev, cost;
	flow(int to = 0, int cap = 0, int rev = 0, int cost = 0) : to(to), cap(cap), rev(rev), cost(cost) {}
};
typedef vector< vector< flow > > flows;

const int di[4] = {0, -1, 0, 1};
const int dj[4] = {-1, 0, 1, 0};
const int ci[5] = {0, 0, -1, 0, 1};
const int cj[5] = {0, -1, 0, 1, 0};
const ll LINF = LLONG_MAX / 2;
const int INF = INT_MAX / 2;
const double PI = acos(-1);

int pow2(int n) { return 1LL << n; }
template < typename T, typename U >
bool chmin(T &x, const U &y) {
	if (x > y) {
		x = y;
		return true;
	}
	return false;
}
template < typename T, typename U >
bool chmax(T &x, const U &y) {
	if (x < y) {
		x = y;
		return true;
	}
	return false;
}

struct initializer {
	initializer() {
		cout << fixed << setprecision(20);
	}
};
initializer _____;

int N, M, K, T, Q, H, W;
signed main() {
	string S;
	cin >> S;
	N = S.size();
	reverse(S.begin(), S.end());
	vector< int > acc(N + 1, 0);
	int ten = 1;
	rep(i, N) {
		acc[i + 1] = (acc[i] + (S[i] - '0') * ten) % 2019;
		(ten *= 10) %= 2019;
	}
	vector< int > C(2019, 0);
	C[0] = 1;
	int ans = 0;
	rep(i, N) {
		ans += C[acc[i + 1]];
		C[acc[i + 1]]++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 5244
//order_of_key(k): Number of items strictly smaller than k .
//find_by_order(k): K-th element in a set (counting from zero).
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define full(x,n) x,x+n+1
#define full(x) x.begin(),x.end()
#define finish return 0

#define putb push_back
#define f first
#define s second

//logx(a^n)=loga(a^n)/logx(a)
//logx(a*b)=logx(a)+logx(b)
//logx(y)=log(y)/log(x)

#define ordered_set tree<ll,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
#define putf push_front
#define gainb pop_back

#define gainf pop_front
#define len(x) (ll)x.size()

// 1/b%mod=b^(m-2)%mod
// (a>>x)&1==0

typedef double db;
typedef long long ll;

const ll ary=1e5+5;
const ll mod=1e9+7;
const ll inf=1e18;

using namespace std;
using namespace __gnu_pbds;
ll x,y,ans;
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	cin>>x>>y;
	ans=300000-(x-1)*100000;
	ans=max(ans,0ll);
	ans+=max(0ll,300000-(y-1)*100000);
	ans+=400000*(x==1&&y==1);
	cout<<ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n; i >= 0; i--)
#define inf LLONG_MAX
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;


int main()
{
    ll N, K; cin >> N >> K;
    vll A(N); rep(i, N) cin >> A[i];

    vll DS(60, 0);
    rep(k, 60) {
        rep(i, N) {
            DS[k] += ((A[i] >> k) & 1);
        }
    }
    // for (auto elem : DS) cout << elem << " "; cout << endl;
    
    ll k = 0, ans = 0;
    for (ll bit = 59; bit >= 0; bit--) {
        if (DS[bit] * 2 < N && k + (1ll<<bit) <= K) {
            k += (1ll<<bit);
            ans += (N - DS[bit]) * (1ll<<bit);
        } else {
            ans += DS[bit] * (1ll<<bit);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
/*  
*  Sachin Mittal
*/
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define M 998244353
#define mod 1000000007
#define all(v) v.begin(),v.end()
#define rep(i,j,n) for(int i=j;i<n;i++)
#define F first
#define S second
#define lb lower_bound
#define mem0(dp) memset(dp,0,sizeof(dp))
#define mem1(dp) memset(dp,-1,sizeof(dp))
#define pb push_back
#define sz(s) (int)(s.size())
#define debug(x) cout << #x << " = " << x << '\n';

map<int, int> black;

void rec2(vector<string> s, int k){
  if(k == s[0].size()){
    int cnt = 0;
    rep(i, 0, sz(s)){
      rep(j, 0, sz(s[0])){
        if(s[i][j] == '#'){
          cnt++;
        }
      }
    }
    black[cnt]++;
    return;
  }
  rec2(s, k + 1);
  rep(i, 0, sz(s)){
    s[i][k] = '.';
  }
  rec2(s, k + 1);
}

void rec1(vector<string> s, int k){
  if(k == s.size()){
    rec2(s, 0);
    return;
  }
  rec1(s, k + 1);
  rep(i, 0, sz(s[0])){
    s[k][i] = '.';
  }
  rec1(s, k + 1);
}


void solve()
{
  int n, m, k;
  cin >> n >> m >> k;
  vector<string> s(n);
  rep(i, 0, n){
    cin >> s[i];
  }
  rec1(s, 0);
  cout << black[k];
}

int32_t main(){
ios_base::sync_with_stdio(false); 
cin.tie(0); cout.tie(0);
int tst = 1;
//cin >> tst;
while(tst--)
{
  solve();
}
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void solve() {
    ll N, T;
    cin >> N >> T;
    vector<P> items(N);
    rep(i, N) cin >> items[i].first >> items[i].second;
    vector<vector<ll>> dp(N + 1, vector<ll>(T + 3005, 0));
    sort(items.begin(), items.end());
    rep(i, N) {
        P p = items[i];
        rep(j, T + 3004) {
            dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
            if (j < T) {
                dp[i + 1][j + p.first] = max(dp[i + 1][j + p.first], dp[i][j] + p.second);
            }
        }
    }
    ll ans = 0;
    rep2(i, T, T + 3004) {
        ans = max(ans, dp[N][i]);
    }
    cout << ans << '\n';
}

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


Measured memory_bytes: 141184
#include<bits/stdc++.h>
using namespace std;
signed main(){
  int n,ax=0;
  cin>>n;
  vector<int> a(n);
  for(int i=0;i<n;++i){
    cin>>a[i];
    ax ^= a[i];
  }
  for(int i=0;i<n;++i)cout<<(ax^a[i])<<endl;
}

Measured memory_bytes: 4028
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define FORR(i, a, b) for (int i = b - 1; i >= a; --i)
#define SORT(v) sort(v.begin(), v.end())
#define SORTR(v) sort(v.rbegin(), v.rend())
#define REV(v) reverse(v.begin(), v.end())
#define ITER(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define LB(v, x) (lower_bound(v.begin(), v.end(), x) - v.begin())
#define UB(v, x) (upper_bound(v.begin(), v.end(), x) - v.begin())
#define SZ(v) (int)v.size()
using namespace std;
using ll = long long;
using P = pair<int, int>;

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

    int N;
    cin >> N;
    string s;
    cin >> s;
    int r = 0;
    REP(i, N) {
        if (s[i] == 'R') ++r;
    }
    int w = 0;
    REP(i, r) {
        if (s[i] == 'W') ++w;
    }
    cout << w << endl;

    return 0;
}


Measured memory_bytes: 3768
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define vcout(v) rep(i,v.size()) cout << v[i] << " "; cout << endl
#define mcout(m) rep(j,m.size()){vcout(m[j]);}

void mainsolve(){

	ll n;
	cin >> n;
	string s;
	cin >> s;

	ll cnt = 0;
	rep(i,s.size()-2){
		if(s[i]=='A' && s[i+1]=='B' && s[i+2]=='C') cnt++;
	}
	cout << cnt << endl;
	return;
}

int main(){
	
	//ll TC;cin>>TC;rep(I,TC){cout<<"case:"<<I+1<<"---"<<endl; // comment out!
		mainsolve();
	//} // comment out!
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);i++)
using namespace std;
const int N=105;
char mp[N][N];
int n,m,ex,ey,ans,dp[N][N][N];
int sr[N][N],sc[N][N];
void mx(int &x,int y){x<y?x=y:0;}
int main(){
	scanf("%d%d",&n,&m);
	memset(dp,233,sizeof(dp));
	For(i,1,n) scanf("%s",mp[i]+1);
	For(i,1,n) For(j,1,m){
		if (mp[i][j]=='o') sr[i][j]=sc[i][j]=1;
		else if (mp[i][j]=='E') ex=i,ey=j;
		sr[i][j]+=sr[i][j-1],sc[i][j]+=sc[i-1][j];
	}
	int L=ey-1,R=m-ey,U=ex-1,D=n-ex; dp[0][0][0]=0;
	For(l,0,L) For(r,0,R) For(u,0,U) For(d,0,D){
		int v=dp[r][u][d]; ans=max(ans,v);
		int up=max(ex-u,d+1),dn=min(ex+d,n-u),le=max(ey-l,r+1),ri=min(ey+r,m-l);
		if (up>dn||le>ri) continue;
		if (u<U-d) mx(dp[r][u+1][d],v+sr[ex-u-1][ri]-sr[ex-u-1][le-1]);
		if (d<D-u) mx(dp[r][u][d+1],v+sr[ex+d+1][ri]-sr[ex+d+1][le-1]);
		if (r<R-l) mx(dp[r+1][u][d],v+sc[dn][ey+r+1]-sc[up-1][ey+r+1]);
		if (l<L-r) mx(dp[r][u][d],v+sc[dn][ey-l-1]-sc[up-1][ey-l-1]);
	}
	printf("%d",ans);
}

Measured memory_bytes: 4864
K, N = (int(x) for x in input().split())
i = list(map(int, input().split()))
max = i[0] + (K-i[N-1])
for j in range(N-1):
    if (i[j+1]-i[j]) > max:
        max = i[j+1]-i[j]
ans = K - max
print(ans)


Measured memory_bytes: 26060
#include <bits/stdc++.h>
using namespace std;
//#pragma GCC optimize("Ofast")
#define rep(i,n) for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
#define PQ(T) priority_queue<T>
#define SPQ(T) priority_queue<T,vector<T>,greater<T>>
using ll=long long;
using P=pair<ll,ll>;
using PP=tuple<ll,ll,ll>;
using S=multiset<ll>;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
const double eps=1e-10;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())cout<<'('<<v[i].fi<<','<<v[i].se<<')';cout<<'\n';}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}
template<class T> bool isin(T x,T l,T r){return (l)<=(x)&&(x)<=(r);}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
void decimal(int x){cout<<fixed<<setprecision(x);}
//ll GCD(ll a,ll b){if(b==0) return a; return GCD(b,a%b);}
//ll LCM(ll a,ll b){return(a/GCD(a,b))*(b/GCD(a,b))*GCD(a,b);}
ll POW(ll a,ll b){a%=mod;if(b==0)return 1;if(b&1)return a*POW(a,b-1)%mod;ll k=POW(a,b/2);return k*k%mod;}
vi calc(ll x){vi res;while(x>0){res.eb(x%10);x/=10;}reverse(all(res));return res;}

void solve(){
  string t;
  cin>>t;
  rep(i,t.size()) if(t[i]=='?') t[i]='D';
  out(t);
}

signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  solve();
}


Measured memory_bytes: 3716
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

def main():
    n = int(input())
    s = list(input())
    cnt = 0
    cache1 = set()
    for i in range(n):
        if int(s[i]) in cache1: continue
        cache1.add(int(s[i]))
        cache2 = set()
        for j in range(i+1, n):
            if int(s[j]) in cache2: continue
            cache2.add(int(s[j]))
            cache3 = set()
            for k in range(j+1, n):
                if int(s[k]) in cache3: continue
                cache3.add(int(s[k]))
                cnt += 1

    print(cnt)

if __name__ == "__main__":
    main()


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

using namespace std;

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

	bool flag = false;
	flag |= (S[0] == S[1] && S[2] == S[3]);
	flag |= (S[0] == S[2] && S[1] == S[3]);
	flag |= (S[0] == S[3] && S[1] == S[2]);

	if (S[0] == S[1] && S[1] == S[2] && S[2] == S[3]){
		flag = false;
	}

	cout << (flag ? "Yes" : "No") << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std; 
#define flash ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define debug(x) cerr << " - " << #x << ": " << x << endl;
#define debugs(x, y) cerr << " - " << #x << ": " << x << " " << #y << ": " << y << endl;
#define all(x) (x).begin(),(x).end()
#define sz(x) (ll)x.size()
#define ll long long
#define INF 1000000000
#define pb push_back
struct greateri
{
    template<class T>
    bool operator()(T const &a, T const &b) const { return a > b; }
};
vector<pair<ll,ll>>gg;
ll k;
ll dp[101][100001];
ll solve(ll x,ll weight)
{
  if(weight>k)return -INF;
  if(weight==k)return 0;
  if(x >= gg.size())return 0;
  if(dp[x][weight]!= -1)return dp[x][weight];
  ll ans = -INF;
  ans = max(ans,gg[x].second+solve(x+1,weight+gg[x].first));
  ans = max(ans,solve(x+1,weight));
  return dp[x][weight]=ans;
}
int main()
{
  // flash;
  ll x;
  cin>>x;
  cin>>k;
  for (int i = 0; i < x; ++i)
  {
    ll yo;ll no;
    cin>>yo>>no;
    gg.pb(make_pair(yo,no));
  }
  memset(dp,-1,sizeof dp);
  cout<<solve(0,0);
  return 0;
}

Measured memory_bytes: 79104
#include <iostream>

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

    char c;
    int R = 0;
    for (int i=0; i<N; i++) {
        std::cin >> c;
        if (c == 'R') R++;
    }

    if (R > N/2)
        std::cout << "Yes" << std::endl;
    else
        std::cout << "No" << std::endl;
}


Measured memory_bytes: 256
import java.util.*;
public class Main
{
	static int n,ans;
	static int a[];
	public static void main(String[] args) 
	{
		Scanner in=new Scanner(System.in);
		for(;;)
		{
			n=in.nextInt(); //n<=20
			if(n==0)
				return;
			a=new int[n];
			for(int i=0;i<n;i++)
				a[i]=in.nextInt();
			ans=1000000;
			dfs(0,0,0);
			System.out.println(ans);
		}
	}

	static void dfs(int i,int A,int B)
	{
		if(i==n)
			ans=Math.min(ans,Math.abs(A-B));
		else
		{
			dfs(i+1,A+a[i],B);
			dfs(i+1,A,B+a[i]);
		}
	}
}

Measured memory_bytes: 20936
#!/usr/bin/env python3
import sys
import itertools
import collections
import functools
import math
from queue import Queue
# import numpy as np
INF = float("inf")


def solve(A: int, B: int, C: int, D: int, E: int):
    ryouri = [A, B, C, D, E]
    a = [x % 10 for x in ryouri if x % 10 != 0]
    if len(a) == 0:
        print(sum([10*(math.ceil(x/10.0)) for x in ryouri]))
    else:
        print(sum([10*(math.ceil(x/10.0)) for x in ryouri]) - (10-min(a)))

    # print(A, B, C, D, E)
    # print(A+B+C+D+E)
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    D = int(next(tokens))  # type: int
    E = int(next(tokens))  # type: int
    solve(A, B, C, D, E)


if __name__ == '__main__':
    main()


Measured memory_bytes: 4456
/**
 *    author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *    created : 2020-03-28 22:12:36
**/

#include <iostream>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
#include <bitset>
#include <cassert>
#include <cctype>
#include <iomanip>
#include <random>
#include <utility>
#include <chrono>

using namespace std;

using int64 = long long;

template<class T> using binary_heap = std::priority_queue<T, std::vector<T>, std::greater<T>>;
template<class T> std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) { os << '{'; size_t n = vec.size(); for (size_t i = 0; i < n; ++i) { os << vec[i]; if (i != n - 1) os << ','; } os << '}'; return os; }
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) { return os << '{' << p.first << " " << p.second << '}'; }
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) { os << '{'; for (auto it = mp.begin(); it != mp.end(); ++it) { os << '{' << it->first << ':' << it->second << '}'; if (it != --mp.end()) os << ','; } os << '}'; return os; }
template<class T> std::ostream& operator<<(std::ostream& os, const std::set<T>& st) { os << '{'; for (auto it = st.begin(); it != st.end(); ++it) { os << *it; if (it != --st.end()) os << ','; } os << '}'; return os; }
template<class T> std::istream& operator>>(std::istream& is, std::vector<T>& vec) { size_t n = vec.size(); for (size_t i = 0; i < n; ++i) is >> vec[i]; return is; }

#define all(_) begin(_), end(_)
#define rall(_) rbegin(_), rend(_)

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...) 1728
#endif

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}

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

  int x, y, a, b, c; cin >> x >> y >> a >> b >> c;
  vector<int64> p(a), q(b), r(c); cin >> p >> q >> r;

  sort(rall(p));
  sort(rall(q));

  p.resize(x); q.resize(y);

  vector<int64> t;
  for (int64 e : p) t.emplace_back(e);
  for (int64 e : q) t.emplace_back(e);
  for (int64 e : r) t.emplace_back(e);

  sort(rall(t));

  cout << accumulate(t.begin(), t.begin() + x + y, int64()) << endl;

  return 0;
}

Measured memory_bytes: 8944
#include<bits/stdc++.h>
using namespace std;
//Optimisations
#pragma GCC target ("avx2")
#pragma GCC optimization ("unroll-loops")
#pragma GCC optimize("O2")
//shortcuts for functions
#define pb push_back
#define mp make_pair
#define ff first 
#define ss second
#define all(v) v.begin(),v.end()
#define prec(n) fixed<<setprecision(n)
#define n_l '\n'
// make it python 
#define gcd __gcd
#define append push_back
#define str to_string
// utility functions shortcuts
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define sswap(a,b) {a=a^b;b=a^b;a=a^b;}
#define swap(a,b) {auto temp=a; a=b; b=temp;}
#define init(dp) memset(dp,-1,sizeof(dp));
#define set0(dp) memset(dp,0,sizeof(dp));
#define bits(x) __builtin_popcount(x)
#define SORT(v) sort(all(v))
#define endl "\n"
#define forr(i,n) for(ll i=0;i<n;i++)
// declaration shortcuts
typedef long long int ll;
#define int ll
// Constants
constexpr int dx[] = {-1, 0, 1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, 1, -1};
constexpr ll INF = 1999999999999999997; 
constexpr int inf= INT_MAX;
constexpr int MAXSIZE = int(1e6)+5;
constexpr auto PI  = 3.14159265358979323846L;
constexpr auto oo  = numeric_limits<int>::max() / 2 - 2;
constexpr auto eps = 1e-6;
constexpr auto mod = 1000000007;
constexpr auto MOD = 1000000007;
constexpr auto MOD9 = 1000000009;
constexpr auto maxn = 100006;
//void IOfile(){
//freopen(file_name, reade_mode, stdin);
//freopen(file_name, write_mode, stdout);
//}
void fastio(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
}
int32_t main(){
	fastio();
	int n,x,t;
	cin >> n >> x >> t;
	cout << ((n + x - 1) / x * t);	
}

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

int cut(int* card,int p,int c){
	int buf[60],i;
	if(p==1){
		return 0;
	}
	for(i=0;i<c;i++){//tukamu
		buf[i]=card[p-1+i];
	}
	for(i=0;i<p-1;i++){//ずらす
		card[p-2-i+c]=card[p-2-i];
	}
	for(i=0;i<c;i++){//乗っける
		card[i]=buf[i];
	}
	return 0;
}

int main(){
	int n,r;
	int i,j;
	int* card;
	while(1){
		scanf("%d %d",&n,&r);
		if(n==0&&r==0)
			break;
		card=(int*)malloc(sizeof(int)*n);
		for(i=0;i<n;i++){
			card[i]=n-i;
		}
		for(i=0;i<r;i++){
			int p,c;
			scanf("%d %d",&p,&c);
			cut(card,p,c);
		//	for(j=0;j<n;j++){
		//		printf("%d|",card[j]);
		//	}
		//	puts("");
		}
		printf("%d\n",card[0]);
		free(card);
	}
	
	return 0;
}

Measured memory_bytes: 0
// eddy1021
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef double D;
typedef long double LD;
typedef long long LL;
typedef pair<int,int> PII;
typedef pair<LL,LL> PLL;
#define mod9 1000000009LL
#define mod7 1000000007LL
#define INF  1023456789LL
#define INF16 10000000000000000LL
#define eps 1e-9
#define SZ(x) (int)(x).size()
#define ALL(x) (x).begin(), (x).end()
#ifndef ONLINE_JUDGE
#define debug(...) printf(__VA_ARGS__)
#else 
#define debug(...)
#endif
inline LL getint(){
  LL _x=0,_tmp=1; char _tc=getchar();    
  while( (_tc<'0'||_tc>'9')&&_tc!='-' ) _tc=getchar();
  if( _tc == '-' ) _tc=getchar() , _tmp = -1;
  while(_tc>='0'&&_tc<='9') _x*=10,_x+=(_tc-'0'),_tc=getchar();
  return _x*_tmp;
}
inline LL add( LL _x , LL _y , LL _mod = mod7 ){
  _x += _y;
  return _x >= _mod ? _x - _mod : _x;
}
inline LL sub( LL _x , LL _y , LL _mod = mod7 ){
  _x -= _y;
  return _x < 0 ? _x + _mod : _x;
}
inline LL mul( LL _x , LL _y , LL _mod = mod7 ){
  _x *= _y;
  return _x >= _mod ? _x % _mod : _x;
}
LL mypow( LL _a , LL _x , LL _mod ){
  if( _x == 0 ) return 1LL;
  LL _ret = mypow( mul( _a , _a , _mod ) , _x >> 1 , _mod );
  if( _x & 1 ) _ret = mul( _ret , _a , _mod );
  return _ret;
}
LL mymul( LL _a , LL _x , LL _mod ){
  if( _x == 0 ) return 0LL;
  LL _ret = mymul( add( _a , _a , _mod ) , _x >> 1 , _mod );
  if( _x & 1 ) _ret = add( _ret , _a , _mod );
  return _ret;
}
inline bool equal( D _x ,  D _y ){
  return _x > _y - eps && _x < _y + eps;
}
#define Bye exit(0)
int __ = 1 , _cs;
/*********default*********/
#define N 101010
void build(){

}
char a[ N ] , b[ N ];
int pa[ N ] , pb[ N ];
void init(){
  scanf( "%s%s" , a + 1 , b + 1 );
  int la = strlen( a + 1 );
  int lb = strlen( b + 1 );
  for( int i = 1 ; i <= la ; i ++ )
    pa[ i ] = pa[ i - 1 ] + a[ i ] - 'A' + 1;
  for( int i = 1 ; i <= lb ; i ++ )
    pb[ i ] = pb[ i - 1 ] + b[ i ] - 'A' + 1;
}
void solve(){
  int q = getint(); while( q -- ){
    int la = getint();
    int ra = getint();
    int lb = getint();
    int rb = getint();
    int ca = pa[ ra ] - pa[ la - 1 ];
    int cb = pb[ rb ] - pb[ lb - 1 ];
    puts( ca % 3 == cb % 3 ? "YES" : "NO" );
  }
}
int main(){
  build();
  //__ = getint();
  while( __ -- ){
    init();
    solve();
  }
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n;
  	double d, ret = 0;
  	string s;
  	cin >> n;
  	while(n--) {
     	cin >> d >> s;
      	if (s == "JPY") ret += d;
      	else {
         	ret += 380000.0 * d;
        }
      	//cout << d << " " << s << endl;
    }
  	cout << setprecision(10) << ret << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define len(x) (int)(x.size())
#define all(vs) vs.begin(), vs.end()
using ii = pair<int, int>;
using ll = long long;

int32_t main(){
	ios::sync_with_stdio(0);	
	ll n, k;
	cin >> n >> k;
	ll res = log(n)/log(k)+1;
	cout << res << endl;
}


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

using namespace std;

int main(){
	string str;
	cin>>str;
	string rpta="";
	for (int i=0 ; i<str.size() ; i++){
		if(str[i]=='1' || str[i]=='0'){
			rpta+=str[i];
		}else{
			if(rpta.size()>0){
				rpta.erase(rpta.size()-1);	
			}
			
		}
	}
	cout<<rpta;
return 0;
}

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

using namespace std;
int main() {
    int n;
    long long k;
    long long cnt = 0LL;
    vector <pair<int, int> > pairs;

    cin >> n >> k;

    for (int i = 0; i < n; i++) {
        int a, b;
        cin >> a >> b;
        pairs.push_back(make_pair(a, b));
    }

    sort(pairs.begin(), pairs.end());
    for (int i = 0; i < n; i++) {
        pair<int, int> x = pairs[i];
        cnt += x.second;

        if (cnt >= k) {
            cout << x.first << endl;
            break;
        }
    }

    return 0;
}


Measured memory_bytes: 1400
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <tuple>
#include <cmath>
#include <cstring>

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

using namespace std;
typedef long long ll;

int N;
int A[200001];

int main() {
    cin >> N;
    rep(i, N) cin >> A[i];
    sort(A, A + N);
    int prev = A[0];
    for (int i = 1; i < N; i ++) {
        if (prev == A[i]) {
            cout << "NO" << endl;
            return 0;
        }
        prev = A[i];
    }
    cout << "YES" << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include"bits/stdc++.h"
#include<math.h>
#include<string.h>
using namespace std;
#define ll long long
#define FOR(i, j, k, in) for (ll i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for (int i=j ; i>=k ; i-=in)
#define rep(i, j) FOR(i, 0, j, 1)
#define rrep(i, j) RFOR(i, j, 0, 1)
#define MP make_pair
#define PB push_back
#define INF (int)1e9
#define endl "\n"
#define MOD 1000000007
void fastio()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
void solve()
{
	int n,flag=0;
	cin>>n;
	while(n>0)
	{
		int x=n%10;
		if(x==7)
			{
				flag=-1;
			}
		n=n/10;
	}
	if(flag==-1)
		cout<<"Yes";
	else
		cout<<"No";
}
void solve1()
{
	ll n,sum=0;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		if(i%3==0)
			continue;
		if(i%5==0)
			continue;
		sum+=i;
	}
	cout<<sum;
}
void solve2()
{
	int k;
}
int main()
{
	fastio();
	
	solve();
	//solve1();
	return 0;
}

Measured memory_bytes: 3656