akhauriyash/Code-Regression huggingface dataset:
import bisect
import collections
import sys

sys.setrecursionlimit(100000)
input = sys.stdin.readline
ACMOD = 1000000007
INF = 1 << 62


def lmi():
    return list(map(int, input().split()))


def llmi(n):
    return [lmi() for _ in range(n)]


N, A, B, C = lmi()
S = [input().strip() for _ in range(N)]

a = A
b = B
total = A + B + C
ans = []
if total != 2:
    for s in S:
        c = total - a - b
        if s == "AB":
            if a == 0 and b == 0:
                print("No")
                exit()
            if a > b:
                a -= 1
                b += 1
                ans.append('B')
            else:
                a += 1
                b -= 1
                ans.append('A')
        if s == "AC":
            if a == 0 and c == 0:
                print("No")
                exit()
            if a > c:
                a -= 1
                ans.append('C')
            else:
                a += 1
                ans.append('A')
        if s == "BC":
            if b == 0 and c == 0:
                print("No")
                exit()
            if b > c:
                b -= 1
                ans.append('C')
            else:
                b += 1
                ans.append('B')
        # print(a,b,c)

    # print(ans, a, b, c)
    print('\n'.join(['Yes'] + ans))
    exit()

case = {(A, B, C): []}  # 1,1 1,0 0,1 0,0 2,0 0,2
ans = []

for i, s in enumerate(S):
    # while True:
    #     s = input().strip()
    new_case = {}
    for (a, b, c), v in case.items():
        if s == "AB":
            if a == 0 and b == 0:
                continue
            elif a == 1 and b == 1:
                new_case[(0, 2, 0)] = list(v) + ['B']
                v.append('A')
                new_case[(2, 0, 0)] = v
                # two case
                pass
            else:
                v.append('A' if b else 'B')
                new_case[(abs(a - 1), abs(b - 1), c)] = v
        if s == "AC":
            if a == 0 and c == 0:
                continue
            if a == c:
                new_case[(2, 0, 0)] = list(v) + ['A']
                v.append('C')
                new_case[(0, 0, 2)] = v

                # two case
                pass
            else:
                v.append('C' if a else 'A')
                new_case[(abs(a - 1), b, abs(c - 1))] = v

        if s == "BC":
            if b == 0 and c == 0:
                continue
            elif b == c:
                new_case[(0, 2, 0)] = list(v) + ['B']
                v.append('C')
                new_case[(0, 0, 2)] = v
            else:
                v.append('B' if c else 'C')
                new_case[(a, abs(b - 1), abs(c - 1))] = v

    if not new_case:
        print("No")
        exit()
    case = new_case
    if len(case) == 1:
        key = list(case.keys())[0]
        ans += case[key]
        case[key] = []

print('\n'.join(['Yes'] + ans + list(case.values())[0]))


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

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int vx = c - a, vy = d - b;
    printf("%d %d %d %d\n", c - vy, d + vx, a - vy, b + vx);
}

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

bool C(int m, int d) {
    if(d < 10) return false;
    else {
        int d1 = d % 10;
        int d2 = d / 10;
        if(d1 >= 2 && d2 >= 2 && m == d1 * d2) return true;
        else return false;
    }
}

int main() {
    int M, D;
    cin >> M >> D;
    int res = 0;
    for(int i=1; i<=M; ++i) {
        for(int j=1; j<=D; ++j) {
            if(C(i, j)) ++res;
        }
    }
    cout << res << endl;
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)    FOR (i,0,n)
#define ALL(f,x,...) ([&](decltype((x)) ALL) {                          \
            return (f)(begin(ALL), end(ALL), ## __VA_ARGS__); })(x)

using namespace std;

const string Yes = "Yes";
const string No = "No";

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

    if (x == 1 || x == 2 * N - 1) cout << No << endl;
    else
    {
        cout << Yes << endl;

        map<int, int> mp;
        mp[N - 2] = x + 1;
        mp[N - 1] = x;
        mp[N] = x - 1;
        mp[N + 1] = x + 2;

        int now = 1;

        REP(i, 2 * (N - 1) + 1)
        {
            if (mp.count(i) == 0)
            {
                if (now == x - 1) now = x + 3;
                cout << now << endl;
                now++;
            }
            else
            {
                if (2 * N - 1 < mp[i])
                {
                    cout << now << endl;
                    now++;
                }
                else
                {
                    cout << mp[i] << endl;
                }
            }
        }
    }

    return 0;
}


Measured memory_bytes: 1536
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    int n,A[100000];
    cin>>n;
    int ans,i=0;
    if(n==0) cout<<0;
    while(n!=0){
        if(n>0) {
            ans=(n%2);
            n=-n/2;
        }
        else {
            ans=(-n%2);
            n=(1-n)/2;
        }
        A[i]=ans;
        i++;
    }
    reverse (A,A+i);
    for(int j=0;j<i;j++) cout<<A[j];
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int a, b, W;
    cin >> W >> a >> b;
    if(a<b) {
        if(a+W>=b) {
            cout << 0 << endl;
        } else {
            cout << b-a-W << endl;
        }
    } else if(b<a) {
        if(b+W>=a) {
            cout << 0 << endl;
        } else {
            cout << a-b-W << endl;
        }
    } else {
        cout << 0 << endl;
    }



    return 0;
    
}

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

using i64 = long long;

#define REP(i, stop) for (int i = 0, i##_len = stop; i < i##_len; ++i)

i64 D[13];
i64 E[13];
char s[100001];
const i64 M = 1000000007;
signed main() {
	D[0] = 1;
	scanf("%s", s);
	i64 i = 0;
	while(true) {
		char c = s[i];
		if (c == 0) {
			break;
		} else if (c == '?') {
			/*
			REP(r, 13) {
				i64 s = 0;
				REP(j, 10) {
					s += D[(j - r + 13) * 9 % 13];
				}
				E[r] = s % M;
			}
			*/
			E[0] = (D[0] + D[9] + D[5] + D[1] + D[10] + D[6] + D[2] + D[11] + D[7] + D[3]) % M;
			E[1] = (D[4] + D[0] + D[9] + D[5] + D[1] + D[10] + D[6] + D[2] + D[11] + D[7]) % M;
			E[2] = (D[8] + D[4] + D[0] + D[9] + D[5] + D[1] + D[10] + D[6] + D[2] + D[11]) % M;
			E[3] = (D[12] + D[8] + D[4] + D[0] + D[9] + D[5] + D[1] + D[10] + D[6] + D[2]) % M;
			E[4] = (D[3] + D[12] + D[8] + D[4] + D[0] + D[9] + D[5] + D[1] + D[10] + D[6]) % M;
			E[5] = (D[7] + D[3] + D[12] + D[8] + D[4] + D[0] + D[9] + D[5] + D[1] + D[10]) % M;
			E[6] = (D[11] + D[7] + D[3] + D[12] + D[8] + D[4] + D[0] + D[9] + D[5] + D[1]) % M;
			E[7] = (D[2] + D[11] + D[7] + D[3] + D[12] + D[8] + D[4] + D[0] + D[9] + D[5]) % M;
			E[8] = (D[6] + D[2] + D[11] + D[7] + D[3] + D[12] + D[8] + D[4] + D[0] + D[9]) % M;
			E[9] = (D[10] + D[6] + D[2] + D[11] + D[7] + D[3] + D[12] + D[8] + D[4] + D[0]) % M;
			E[10] = (D[1] + D[10] + D[6] + D[2] + D[11] + D[7] + D[3] + D[12] + D[8] + D[4]) % M;
			E[11] = (D[5] + D[1] + D[10] + D[6] + D[2] + D[11] + D[7] + D[3] + D[12] + D[8]) % M;
			E[12] = (D[9] + D[5] + D[1] + D[10] + D[6] + D[2] + D[11] + D[7] + D[3] + D[12]) % M;
		} else {
			i64 d = c - '0';
			/*
			REP(r, 13) {
				E[r] = D[(d - r + 13) * 9 % 13];
			}
			*/
			E[d] = D[0];
			E[(d + 10) % 13] = D[1];
			E[(d + 7) % 13] = D[2];
			E[(d + 4) % 13] = D[3];
			E[(d + 1) % 13] = D[4];
			E[(d + 11) % 13] = D[5];
			E[(d + 8) % 13] = D[6];
			E[(d + 5) % 13] = D[7];
			E[(d + 2) % 13] = D[8];
			E[(d + 12) % 13] = D[9];
			E[(d + 9) % 13] = D[10];
			E[(d + 6) % 13] = D[11];
			E[(d + 3) % 13] = D[12];
		}
		swap(D, E);
		++i;
	}
	printf("%d", D[5]);
}


Measured memory_bytes: 256
INF = 10 ** 9 + 7

n, m, x = gets.chomp.split.map(&:to_i)
ca = Array.new(n) { gets.chomp.split.map(&:to_i) }

res = INF
(1 << n).times do |b|
  cs = 0
  u = Array.new(m, 0)
  n.times do |i|
    if b & (1 << i) > 0
      cs += ca[i][0]
      u = (1..m).to_a.map {|j| u[j - 1] + ca[i][j] }
    end
  end
  if u.all? {|j| j >= x } && cs < res
    res = cs
  end
end
puts (res == INF)? "-1" : res

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

#define si(a) scanf("%d",&a)
#define sl(a) scanf("%lld",&a)
#define sd(a) scanf("%lf",&a)
#define sc(a) scahf("%c",&a);
#define ss(a) scanf("%s",a)
#define pi(a) printf("%d\n",a)
#define pl(a) printf("%lld\n",a)
#define pc(a) putchar(a)
#define ms(a) memset(a,0,sizeof(a))
#define repi(i, a, b) for(register int i=a;i<=b;++i)
#define repd(i, a, b) for(register int i=a;i>=b;--i)
#define reps(s) for(register int i=head[s];i;i=Next[i])
#define ll long long
#define ull unsigned long long
#define vi vector<int>
#define vc vector<char>
#define vs vector<string>
#define pii pair<int,int>
#define pll pair<long,long>
#define pil pair<int,long>
#define pli pair<long,int>
#define mii unordered_map<int,int>
#define msi unordered_map<string,int>
#define lowbit(x) ((x)&(-(x)))
#define ce(i, r) i==r?'\n':' '
#define pb push_back
#define fi first
#define se second
#define INF 0x3f3f3f3f
#define pr(x) cout<<#x<<": "<<x<<endl
using namespace std;

inline int qr() {
    int f = 0, fu = 1;
    char c = getchar();
    while (c < '0' || c > '9') {
        if (c == '-')fu = -1;
        c = getchar();
    }
    while (c >= '0' && c <= '9') {
        f = (f << 3) + (f << 1) + c - 48;
        c = getchar();
    }
    return f * fu;
}

int main(){
    double R;
    cin>>R;
    cout<<2*acos(-1)*R<<endl;
    return 0;
}

Measured memory_bytes: 3788
#include<iostream>
#include<queue>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
using namespace std;
/****************************/
#define ll long long
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int,int>
#define vpii vector<pair<int,int> >
#define qi queue<int>
#define mii map<int,int>
#define msi map<string,int>
#define vs vector<string>
#define vc vector<char>
/****************************/
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep2(i,n) for(ll i=(n)-1;i>=0;i--)
#define rep3(i,a,n) for(ll i=(a);i<(n);i++)
#define rep4(i,a,n) for(ll i=(a)-1;i>=n;i--)
#define mp make_pair
#define pb push_back
#define st first
#define nd second
#define pi 3.1415926535897932384626433832795
#define zero(n) memset(n,0,sizeof(n));
#define SZ(n) n.size()
#define sn st.nd 
int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};
/****************************/
int n;
int main()
{
	cin>>n;
	if(n>=400&&n<=599) cout<<'8';
	if(n>=600&&n<=799) cout<<'7';
	if(n>=800&&n<=999) cout<<'6';
	if(n>=1000&&n<=1199) cout<<'5';
	if(n>=1200&&n<=1399) cout<<'4';
	if(n>=1400&&n<=1599) cout<<'3';
	if(n>=1600&&n<=1799) cout<<'2';
	if(n>=1800&&n<=1999) cout<<'1';
	return 0;
}

Measured memory_bytes: 3616
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func main() {
	sc := NewScanner()
	N := sc.NextInt()
	s := make([]int, N)
	total := 0
	for i := 0; i < N; i++ {
		s[i] = sc.NextInt()
		total += s[i]
	}
	sort.Ints(s)

	if total%10 != 0 {
		fmt.Println(total)
		return
	}

	for i := 0; i < N; i++ {
		if s[i]%10 == 0 {
			continue
		}
		total -= s[i]
		if total%10 != 0 {
			fmt.Println(total)
			return
		}
	}
	fmt.Println(0)

}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 640
fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readIntList() = readLine()!!.split(" ").map(String::toInt)
fun readLongList() = readLine()!!.split(" ").map(String::toLong)

fun main(args: Array<String>) {
	val (a, b) = readIntList()
  	val res = if((a * b) % 2 == 0) { "Even" } else { "Odd" }
    println(res)
}

Measured memory_bytes: 36152
N, A = map(int, input().split())  # N枚数のカード, 平均をAにしたい
X = tuple(map(int, input().split()))  # N枚のカードの中身

dp = [[[0]*(50*N+2) for _ in range(N+2)] for _ in range(N+2)]

dp[0][0][0] = 1  # 0枚の中から0枚選んで合計が0になる選び方が1通りある

for i in range(N):
    for j in range(N+1):
        for k in range(50*N+1):
            # if dp[i][j][k]:  # ここの分岐が分からん
            if k+X[i] < 50*N+2:
                dp[i+1][j][k] += dp[i][j][k]
                dp[i+1][j+1][k+X[i]] += dp[i][j][k]
ans = 0
for i in range(1, N+1):
    ans += dp[N][i][i*A]
print(ans)


Measured memory_bytes: 94812
// Hail god Yato
 
#include <bits/stdc++.h> 
using namespace std;
 
#define hs ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
const ll mod = 1000000007;
const ll INF = 1e18;
const ll MAX = 100001;
//
//
                void solve(){
                    int x, y;
                    cin>>x>>y;
                    if(y%2 == 0 && y/2-x >=0 && 2*x-y/2 >= 0)
                        cout<<"Yes";
                    else
                        cout<<"No";
                }
                int main(){ 
                        hs;
                        ll t;
                        t=1;
                        // cin>>t;
                        for (int i=1; i<=t; i++){
                                //cout<<"Case #"<<i<<": ";
                                solve();
                         }
        return 0; 
}         
 
 

Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>
#include <utility>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <math.h>
#include <string.h>
#include <iomanip>
#include <numeric>
#include <cstdlib>
#include <cstdint>
#include <cmath>
#include <functional>
#include <limits>

using namespace std;

using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vll = vector<vl>;
using vpll = vector<pll>;

void debug_out() { cout << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << " " << to_string(H);
  debug_out(T...);
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define Rep(i, n) for (long long i = 0; i< (long long)(n); i++)
#define RRep(i,n) for (long long i = ((long long)(n)-1); i>=0; i--)
#define all(v) (v).begin(),(v).end()

struct Edge{
    int to;
    int weight;
    Edge(int t, int w) : to(t), weight(w){ }
};

struct edge{
    int from;
    int to;
    int weight;
    edge(int f,int t,int w) : from(f), to(t), weight(w){ }
};

using Graph = vector<vector<Edge>>;
using graph = vector<vector<int>>;
using edges = vector<edge>;

template <class T>
inline bool chmin(T &a, T b){
    if (a > b){
        a = b;
        return true;
    }
    return false;
}

template <class T>
inline bool chmax(T &a, T b){
    if (a < b){
        a = b;
        return true;
    }
    return false;
}

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

template <class T>
T lcm(T a, T b){
    return (a*b)/gcd(a,b);
}

bool isPalindrome(string s){
    string t = s;
    reverse(all(t));
    return s==t;
}

constexpr int INF = 1e9+7;

vector<int> dx = {-1,0,1,0};
vector<int> dy = {0,-1,0,1};

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n,x;
    cin >> n >> x;
    vector<int> m(n);
    rep(i,n){
        cin >> m[i];
        x -= m[i];
    }
    sort(all(m));
    int ans = n;
    while(x>=m[0]){
        x -= m[0];
        ans++;
    }
    cout << ans << endl;
}

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

using namespace std;

using ll = long long;
using ui = unsigned int;
const ll MOD = 1000000007;
const ll INF = 9223372036854775807;

//ABC99-C
int main() {
	ll N;
	scanf("%lld", &N);

	vector<ll> dp(N + 1, INF);
	dp[N] = 0;

	for (ll i = N; i > 0; i--) {
		if (dp[i] == INF) {
			continue;
		}

		dp[i - 1] = min(dp[i - 1], dp[i] + 1);

		ll draw = 6;
		while (true) {
			if (i >= draw) {
				dp[i - draw] = min(dp[i - draw], dp[i] + 1);
			}
			else {
				break;
			}

			draw *= 6;
		}

		draw = 9;
		while (true) {
			if (i >= draw) {
				dp[i - draw] = min(dp[i - draw], dp[i] + 1);
			}
			else {
				break;
			}

			draw *= 9;
		}
	}

	printf("%lld\n", dp[0]);
}

//ARC100-C
//L1�����̑��a���ŏ�������ɂ͒����l
/*
int main() {
	ll N;
	scanf("%lld", &N);
	vector<ll> A(N, 0);
	for (ll i = 0; i < N; i++) {
		scanf("%lld", &A[i]);
	}

	vector<ll> B(N, 0);
	ll sum = 0;
	for (ll i = 0; i < N; i++) {
		B[i] = A[i] - (i + 1);
	}

	std::sort(B.begin(), B.end());

	ll b = B[N / 2];


	ll result = 0;

	for (ll i = 0; i < N; i++) {
		result += std::abs(A[i] - (b + i + 1));
	}

	printf("%lld\n", result);
}
*/

Measured memory_bytes: 1024
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <cassert>
#include <string.h>
//#include <unordered_set>
//#include <unordered_map>
//#include <bits/stdc++.h>

#define MP(A,B) make_pair(A,B)
#define PB(A) push_back(A)
#define SIZE(A) ((int)A.size())
#define LEN(A) ((int)A.length())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define fi first
#define se second

using namespace std;

template<typename T>inline bool upmin(T &x,T y) { return y<x?x=y,1:0; }
template<typename T>inline bool upmax(T &x,T y) { return x<y?x=y,1:0; }

typedef long long ll;
typedef unsigned long long ull;
typedef long double lod;
typedef pair<int,int> PR;
typedef vector<int> VI;

const lod eps=1e-11;
const lod pi=acos(-1);
const int oo=1<<30;
const ll loo=1ll<<62;
const int MAXN=3005;
const int INF=0x3f3f3f3f;//1061109567
/*--------------------------------------------------------------------*/
inline int read()
{
	int f=1,x=0; char c=getchar();
	while (c<'0'||c>'9') { if (c=='-') f=-1; c=getchar(); }
	while (c>='0'&&c<='9') { x=(x<<3)+(x<<1)+(c^48); c=getchar(); }
	return x*f;
}
int fac[MAXN],inv[MAXN],S[MAXN][MAXN],n,mods;
int C(int x,int y) { return 1ll*fac[x]*inv[y]%mods*inv[x-y]%mods; }
inline int quick_pow(int x,int y,int mods)
{
	int ret=1;
	for (;y;y>>=1)
	{
		if (y&1) ret=1ll*ret*x%mods;
		x=1ll*x*x%mods;
	}
	return ret;
}
inline int upd(int x,int y) { return x+y>=mods?x+y-mods:x+y; }
void Init(int n)
{
	fac[0]=1;
	for (int i=1;i<=n;i++) fac[i]=1ll*fac[i-1]*i%mods;
	inv[n]=quick_pow(fac[n],mods-2,mods);
	for (int i=n-1;i>=0;i--) inv[i]=1ll*inv[i+1]*(i+1)%mods;
	
	S[0][0]=1;
	for (int i=1;i<=n;i++)
		for (int j=1;j<=i;j++) S[i][j]=upd(S[i-1][j-1],1ll*S[i-1][j]*j%mods);
}
int main()
{
	n=read(),mods=read(); 
	Init(n+1);
	int ans=0;
	for (int i=0;i<=n;i++)
	{
		int t=0;
		for (int j=0;j<=i;j++) t=upd(t,1ll*S[i+1][j+1]*quick_pow(2,(n-i)*j,mods)%mods);
		t=1ll*t*C(n,i)%mods*quick_pow(2,quick_pow(2,n-i,mods-1),mods)%mods;
		ans=(i&1)?upd(ans,mods-t):upd(ans,t);
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 34176
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <math.h>
#include <sstream>
#include <numeric>
#include <string>
#include <cassert>

using namespace std;
typedef long long ll;

int main() {
  ll A, B;
  cin >> A >> B;
  ll diff = abs(A - B);
  if (diff % 2 == 0) {
    cout << (A + B) / 2 << endl;
  } else {
    cout << "IMPOSSIBLE" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i <= (n); ++i)
#define Sort(Array) sort(Array.begin(), Array.end())
#define Reverse(a) reverse(a.begin(), a.end())
#define out(ans) cout << ans << endl;

vector<int> g[200001];
vector<int> ans;

void dfs(int i, int p){
  for(int j: g[i]){
    if(j==p) continue;
    ans[j] += ans[i];
    dfs(j, i);
  }
}

int main(){
  int n, q;
  cin>>n>>q;
  ans.resize(n);
  rep(i, n-1){
    int a, b;
    cin>>a>>b;
    a--; b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }

  rep(i, q){
    int p, x;
    cin>>p>>x;
    p--;
    ans[p] += x;
  }
  dfs(0, -1);
  rep(i, n-1) cout<<ans[i]<<" ";
  out(ans[n-1]);
}


Measured memory_bytes: 23552
#include<iostream>
#include<cstdio>
#include<cstring>
#include<queue>
using namespace std;
const int N=2*(1e5)+10;
struct xxx{
	int y,nxt;
}a[N*2];
char s[N];
queue<int> q;
int h[N],cnt[N][2],in[N];
int n,m,tot,node;
void add(int x,int y){a[++tot].y=y; a[tot].nxt=h[x]; h[x]=tot;}
void prework(){
	int u;
	for (int i=1;i<=n;++i){
		for (int j=h[i];j!=-1;j=a[j].nxt){
			u=a[j].y;
			++cnt[i][s[u]-'A'];
		}
	}
}
bool solve(){
	int u,v;
	while (!q.empty()) q.pop();
	for (int i=1;i<=n;++i)
		if (!cnt[i][0]||!cnt[i][1]) q.push(i),in[i]=1;
	node=0;
	while (!q.empty()){
		v=q.front(); q.pop(); ++node;
		for (int i=h[v];i!=-1;i=a[i].nxt){
			u=a[i].y;
			--cnt[u][s[v]-'A'];
			if (!in[u]&&cnt[u][s[v]-'A']==0) q.push(u),in[u]=1;
		}
	}
	if (node!=n) return true;
	return false;
}

int main(){
#ifndef ONLINE_JUDGE
	//freopen("a.in","r",stdin);
#endif
	int x,y;
	scanf("%d%d",&n,&m);
	scanf("%s",s+1);
	memset(h,-1,sizeof(h));
	tot=0;
	for (int i=1;i<=m;++i){
		scanf("%d%d",&x,&y);
		add(x,y); add(y,x);
	}
	prework();
	if (solve()) printf("Yes\n");
	else printf("No\n");
}


Measured memory_bytes: 6912
#include<stdio.h>
int main()
{
    long long int x, y;

    while(scanf("%lld %lld", &x, &y)==2)
    {
        int count = 0;
        while(x<=y)
        {
            count++;
            x=x*2;
        }

        printf("%d\n", count);
    }

    return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <valarray>
#include <vector>

#define EPS 1e-9
#define INF 1070000000LL
#define MOD 1000000007LL
#define fir first
#define foreach(it,X) for(__typeof((X).begin()) it=(X).begin();it!=(X).end();it++)
#define ite iterator
#define mp make_pair
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define pb push_back
#define sec second
#define sz(x) ((int)x.size())

using namespace std;

struct timer{
	time_t start;
	timer(){start=clock();}
	~timer(){cerr<<1.*(clock()-start)/CLOCKS_PER_SEC<<" secs"<<endl;}
};

typedef istringstream iss;
typedef long long ll;
typedef pair<int,int> pi;
typedef stringstream sst;
typedef vector<int> vi;

ll dist,n,m;
ll S[6],D[6];
int decide[6];
ll ans;
ll start[6];

void f(int cur){
	//cout<<cur<<": ";
	//rep(i,n)cout<<start[i]<<" ";cout<<endl;
	if(cur==n){
		//rep(i,n)cout<<start[i]<<" ";
		ll res=0;
		rep(i,n){
			res=max(res,start[i] + dist*S[i]);
		}
		//cout<<":"<<res<<endl;
		ans=min(ans,res);
		return;
	}
	int target=decide[cur];
	rep(i,cur+1)rep(j,i<cur ? m : 1){
		if(i==cur){
			if(start[target-1]==-1)continue;
			start[target]=start[target-1]+1;
		}
		else{
			int car=decide[i];
			if(S[target] == S[car])continue;
			start[target] = start[car] + D[j] * (S[car]-S[target]);
		}
		//cout<<cur<<" start: "<<start[target]<<endl;
		
		if(start[target]<0){
			start[target]=-1;
			continue;
		}
		int ok=1;
		int used[6]={};
		rep(k,cur){
			int car=decide[k];
			if(car < target && start[target] <= start[car]
			|| car > target && start[target] >= start[car]){
				ok=0;break;
			}
			ll difstart = start[car]-start[target];
			ll difS = S[target]-S[car];
			//cout<<k<<" "<<difstart<<" "<<difS<<endl;
			if(difS == 0){
				continue;
			}
			if(difstart > 0 && difS < 0 || difstart < 0 && difS > 0){
				continue;
			}
			if(difstart < 0 && difS < 0){
				difstart*=-1;
				difS*=-1;
			}
			if(difstart >= difS * dist)continue;
			if(difstart % difS){
				ok=0;break;
			}
			ll point = difstart/difS;
			//cout<<point<<endl;
			int found=0;
			rep(l,m)if(D[l]==point){
				found=1;
				if(used[l]){
					ok=0;break;
				}
				used[l]=1;
				break;
			}
			if(!found){
				ok=0;break;
			}
		}
		if(ok){
			f(cur+1);
		}
		start[target]=-1;
	}
}

int main(){
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	
	cin>>dist>>n;
	rep(i,n)cin>>S[i];
	cin>>m;
	rep(i,m)cin>>D[i];
	D[m++]=dist;
	sort(D,D+m);
	//rep(i,m)cout<<D[i]<<" ";cout<<endl;
	
	rep(i,n)decide[i]=i;
	memset(start,-1,sizeof(start));
	start[0]=0;
	ans=INF*INF;
	do{
		//rep(i,n)cout<<decide[i]<<" ";cout<<endl;
		f(1);
		//cout<<endl;
	}while(next_permutation(decide+1,decide+n));
	cout<<ans<<endl;
}

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

//const int INF = 1001001001;
//const ll INF18 = 1000000000000000000;
const ll INF15 = 1000000000000000;

int main() {
	ll X, K, D;
    cin >> X >> K >> D;
    X = abs(X);

    ll straight = min(K, X / D);
    K -= straight;
    X -= straight * D;

    if (K % 2 == 0) {
        cout << X << endl;
    } else {
        cout << D - X << endl;
    }

    return 0;
}


Measured memory_bytes: 3596
import std.stdio, std.string, std.range, std.conv, std.array, std.algorithm, std.math, std.typecons;

void main() {
    const N = readln.chomp.to!int;
    const ls = readln.split.to!(int[]);
    const lsum = ls.sum;
    writeln(ls.all!(l => l * 2 < lsum) ? "Yes" : "No");
}



Measured memory_bytes: 256
import java.util.Scanner;
class Main{
  public static void main(String[] args){
    Scanner stdIn = new Scanner(System.in);
    
    int a = stdIn.nextInt();
    int b = stdIn.nextInt();
    int c = stdIn.nextInt();
    
    if (a == b) {
      if (b == c) {
        System.out.println("No");
      } else {
        System.out.println("Yes");
      }
    } else if (b == c) {
      if (a == b) {
        System.out.println("No");
      } else {
        System.out.println("Yes");
      }
    } else if (a == c) {
      if (a == b) {
        System.out.println("No");
      } else {
        System.out.println("Yes");
      }
    } else {
      System.out.println("No");
    }
  }
}

Measured memory_bytes: 23764
#include "bits/stdc++.h"

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define ALL(v) v.begin(),v.end()
#define DUMP(i, v)for(ll i=0;i<v.size();i++)cout<<v[i]<<" "

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<ll, ll> P;
struct Edge{ll from, to, cost;};
struct node{ll cost, to;
  bool friend operator>(node a, node b){
    return a.cost>b.cost;
  }
};

ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

ll modpow(ll a, ll n, ll mod){
  ll res=1;
  while(n>0){
    if(n&1) res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll modinv(ll a, ll mod){
  return modpow(a, mod-2, mod);
}

ll gcd(ll a, ll b){
  ll r = a%b;
  if(r==0) return b;
  else return gcd(b, a%b);
}

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}

ll up(ll a){
  return ((a+10-1)/10)*10;
}
/**************************************
** A main function starts from here  **
***************************************/
int main(){
  ll a[5],A[5];
  rep(i, 5)cin >> a[i];
  ll k = 0;
  ll ans = 0;
  rep(i, 5){
    ans += up(a[i]);
    k = max(up(a[i])-a[i], k);
  }

  ans = ans - k;
  cout << ans;
  /*
  ll A=up(a);
  ll A=up(b);
  ll A=up(c);
  ll A=up(d);
  ll A=up(e);*/
  return 0;
}


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

int main(){
    int N;
    char s;
    bool pink=false,green=false,white=false,yellow=false;
    cin >> N;
    rep(i,N){
        cin >> s;
        if(s=='P') pink=true;
        if(s=='G') green=true;
        if(s=='W') white=true;
        if(s=='Y') yellow=true;
    }
    if(white&&green&&white&&yellow) cout << "Four" << endl;
    else cout << "Three" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<algorithm>
#include<stdint.h>
#include<vector>
#include<string>
#include<time.h>
#include<random>
using namespace std;

struct node {
    vector<int> link;
    bool route;
    int dist;
};
//h, w
#define index(i, j) (((i) * w) + (j))
int main() {
   
    int w, h;

    cin >> h >> w;

    vector<string> s(h);
    vector<node> nodes(w*h);

    for (int i = 0; i < h; ++i) cin >> s[i];

    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            char xx = s[i][j];
            nodes[index(i,j)].route = (xx != '#');
        }
    }
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            if (!nodes[index(i, j)].route) continue;

            if (i > 0 && nodes[index(i - 1, j)].route) {
                nodes[index(i, j)].link.push_back(index(i - 1, j));
            }
            if (i < h - 1 && nodes[index(i + 1, j)].route) {
                nodes[index(i, j)].link.push_back(index(i + 1, j));
            }
            if (j > 0 && nodes[index(i, j - 1)].route) {
                nodes[index(i, j)].link.push_back(index(i, j - 1));
            }
            if (j < w - 1 && nodes[index(i, j + 1)].route) {
                nodes[index(i, j)].link.push_back(index(i, j + 1));
            }
        }
    }
    
    int ret = 0;
    vector<int> s_stack;

    for (int start = 0; start < nodes.size(); ++start) {
        if (!nodes[start].route) continue;

        for (int end = 0; end < nodes.size(); ++end) {
            if (start == end) continue;
            if (!nodes[end].route) continue;

            for (auto i = nodes.begin(); i != nodes.end(); ++i) {
                (*i).dist = -1;
            }

            s_stack.clear();

            nodes[start].dist = 0;
            s_stack.push_back(start);
            bool bre = false;

            for (int i = 0; i < s_stack.size() && !bre; ++i) {
                
                for (auto child : nodes[s_stack[i]].link) {
                    
                    if (nodes[child].dist == -1) {
                        nodes[child].dist = nodes[s_stack[i]].dist + 1;
                        s_stack.push_back(child);
                    }

                    if (child == end) {
                        bre = true;
                        break;
                    }
                }
            }

            ret = max(ret, nodes[end].dist);
        }
    }

    cout << ret << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

char st[100010];
int ans[100010];
int main()
{
    scanf("%s",st);

    int len=0;
    while (st[len]) len++;

    int tmp=0,cnt=0;
    while (tmp<len)
    {
        if (st[tmp]=='L'){
            ans[tmp]+= cnt/2;
            ans[tmp-1]+= (cnt-cnt/2);
            tmp++;cnt=0;
            continue;
        }
        while (st[tmp]=='R'){
            cnt++;tmp++;
        }
    }
    //printf("yes");
    tmp=len-1;cnt=0;
    while (tmp>=0)
    {
        if (st[tmp]=='R'){
            ans[tmp]+= cnt/2;
            ans[tmp+1]+=(cnt-cnt/2);
            tmp--;cnt=0;
            continue;
        }
        while (st[tmp]=='L'){
            cnt++;tmp--;
        }
    }

    for (int i=0;i<len;i++)
        printf("%d ",ans[i]);

}


Measured memory_bytes: 896
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 4000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

ll gcd(ll a, ll b) {
	if (b == 0) { return a; }
	if (a < b) { return gcd(b, a); }
	return gcd(b, a % b);
}

ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};

class mint {
    long long x;
public:
    mint(long long x = 0) : x((x% MOD + MOD) % MOD) {}
    mint operator-() const {
        return mint(-x);
    }
    mint& operator+=(const mint& a) {
        if ((x += a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator-=(const mint& a) {
        if ((x += MOD - a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator*=(const  mint& a) {
        (x *= a.x) %= MOD;
        return *this;
    }
    mint operator+(const mint& a) const {
        mint res(*this);
        return res += a;
    }
    mint operator-(const mint& a) const {
        mint res(*this);
        return res -= a;
    }
    mint operator*(const mint& a) const {
        mint res(*this);
        return res *= a;
    }

    mint operator^(const ll& t)const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }
    // for prime MOD
    mint inv() const {
        return pow(MOD - 2);
    }
    mint& operator/=(const mint& a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint& a) const {
        mint res(*this);
        return res /= a;
    }

    friend ostream& operator<<(ostream& os, const mint& m) {
        os << m.x;
        return os;
    }
};

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

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

    ll ans = 0;

    repn(i, N) {
        if (i % 3 != 0 && i % 5 != 0) { ans += i; }
    }

    cout << ans;
    
    system("PAUSE");
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long n;
  cin>>n;
  long long ans=1e18;
  for(long long i=1;i*i<=n;i++){
    if(n%i==0){
      long long j=n/i;
      ans=min(ans,i+j-2);
    }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())

X = [0]*n
C = [1]*n
X[0] = 1

for i in range(m):
    x, y = map(int, input().split())
    x, y = x-1, y-1
    if X[x] == 1:
        X[y] = 1
        if C[x] == 1:
            X[x] = 0
        C[x] -= 1
        C[y] += 1
    else:
        C[x] -= 1
        C[y] += 1

ans = sum(X)
print(ans)


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

//定数
const long long MOD1=1000000007;
const long long MOD2=998244353;
const long double PI=3.1415926535897932;
const long long MAXLL=9223372036854775807;
const long long INF=2305843009213693951;
const long long dx[]={0,1,0,-1,1,-1,1,-1};
const long long dy[]={1,0,-1,0,1,1,-1,-1};

//省略
#define ll long long
#define ull unsigned long long
#define ld long double
#define uld unsigned long double
#define pll pair<long long,long long>
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define vvvl vector<vector<vector<long long>>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vs vector<string>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vp vector<pair<long long,long long>>
#define umap unordered_map
#define uset unordered_set
#define Lqueue priority_queue<long long>
#define Squeue priority_queue<long long,vector<long long>,greater<long long>>
#define fi first
#define se second
#define mp make_pair
#define eb emplace_back

//マクロ
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define rbf(a,x) for(auto& a:x)
#define rep(i,n) for(long long i=0;i<(long long)(n);i++)
#define rep2(i,s,n) for(long long i=(s);i<(long long)(n);i++)
#define bitrep(i,s,n) for(long long i=(s);i<(1LL<<(n));i++)
#define bitcheck(bit,i) (bit)&(1LL<<(i))
#define Maxe(x) *max_element((x).begin(),(x).end())
#define Mine(x) *min_element((x).begin(),(x).end())
#define Size(x) ((long long)(x).size())
#define Lin(s) getline(cin,(s))

//Yes,No
void Yes(bool a){cout<<(a?"Yes":"No")<<endl;}
void YES(bool a){cout<<(a?"YES":"NO")<<endl;}

//MAX,MIN
template<class T,class U> auto max(T a,U b){return a>b?a:b;}
template<class T,class U> auto min(T a,U b){return a<b?a:b;}

//最大公約数,最小公倍数
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a,long long b){return a/gcd(a,b)*b;}

//切り上げ除算
long long cutup(long long a,long long b){return (a+b-1)/b;}

//累乗
template<typename t>
constexpr t my_pow(t a,long long b){
    if(b==0)return 1;
    if(a==0)return 0;
    t x=1;
    while(b>0){
        if(b&1LL)x*=a;
        a*=a;
        b>>=1LL;
    }
    return x;
}
#define pow my_pow

//chmin,chmax
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}

//組み合わせ O(r)
template<typename t>
constexpr t nCr(t n,long long r){
    if(r==0)return 1;
    if(n==0)return 0;
    if(n<r)return 0;
    t x=1;
    for(long long i=1;i<=r;i++){
        x*=n-i+1;
        x/=i;
    }
    return x;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    string s;
    ll k;
    cin>>s>>k;
    if(k<=Size(s)){
        rep(i,k){
            if(s[i]!='1')break;
            if(i==k-1){
                cout<<1<<endl;
                return 0;
            }
        }
    }
    rep(i,Size(s)){
        if(s[i]!='1'){
            cout<<s[i]<<endl;
            return 0;
        }
    }
}

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


int main(){
	int a;
	cin >> a;
	int b = (a / 100)%10;
	int c = (a / 1) % 10;
	if (b == c) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

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

using namespace std;

int main() {
    int a, n;
    cin >> n;
    vector<int> vec(n);
    for (int i = 0; i < n; ++i) {
        cin >> a;
        vec.at(i) = a;
    }

    int amount = 0;
    for (int j = 0; j < n; ++j) {
        for (int i = j + 1; i < n; ++i) {
            amount += vec.at(j) * vec.at(i);
        }
    }
    cout << amount << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define rep(x,y) for(lli i=x;i<y;i++)
#define pb push_back
#define mp make_pair
#define bg() begin()
#define en() end()
#define ft first
#define sc second
#define vect_lli_it vector<lli>::iterator
#define set_lli_it set<lli>::iterator
#define inf 1e18
int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    lli x,y,a,b,c;
    cin>>x>>y>>a>>b>>c;
    lli red[a],green[b],less[c];
    rep(0,a)
    cin>>red[i];
    rep(0,b)
    cin>>green[i];
    rep(0,c)
    cin>>less[i];
    sort(red,red+a,greater<lli>());
    sort(green,green+b,greater<lli>());
    sort(less,less+c,greater<lli>());
    vector <lli> ans;
    rep(0,x){
    	ans.pb(red[i]);
	}
	rep(0,y){
		ans.pb(green[i]);
	}
	sort(ans.bg(),ans.en());
	lli k=0;
	rep(0,c){
		if(less[i]>ans[k]){
		ans[k]=less[i];
		k++;
		}
	}
	lli total=0;
	rep(0,ans.size())
	total+=ans[i];
	cout<<total;
	return 0;
}


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

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int unsigned ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<pii> vp;

int gcd(int a, int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int lcm(int a, int b){
    return a/gcd(a,b)*b;
}

signed main(void) {
    int n;
    cin >> n;
    vi prime(n+5,1);
    prime[0] = prime[1] = 0;
    rep(i,n+5)if(prime[i]){
        for(int j = 2; i*j < n+5; j++)prime[i*j] = 0;
    }
    int ans = 0;
    rep(i,n+1){
        //cout << i << " " << prime[i] << endl;
        if(prime[i] && prime[i+2])ans++;
    }
    cout << ans*2 << endl;
}



Measured memory_bytes: 80892
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<list>
#include<map>
#include<numeric>
#include<iomanip>
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define ll long long
const double PI = 3.141592653589793;

using namespace std;

//最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) {
		return a;
	}
	return gcd(b, a % b);
}

//最小公倍数
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}

//階乗
ll fact(ll a) {
	int ans = 1;
	for (int i = 1; i <= a; i++) {
		ans *= i;
	}
	return ans;
}

//コンビネーション
ll combi(ll a, ll b) {
	return fact(a) / (fact(b) * fact(a - b));
}

int main() {
	double r;
	cin >> r;
	cout << PI * 2*r << endl;
	return 0;
}


Measured memory_bytes: 3800
#include<bits//stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long int ll;
ll n,k;
const int MAX = 510000;
const int MOD = 1000000007;
ll fac[MAX], finv[MAX], inv[MAX];
void COMint() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
ll COM(int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main() {
    COMint();
    cin >> n >> k;
    rep(i, k) {
        cout << COM(n - k + 1, i+1) * COM(k - 1, i) % MOD << endl;
    }
}

Measured memory_bytes: 12160
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

typedef pair<int, int> P;

bool cmp(P a, P b){
    if(a.first == b.first) return a.second < b.second;
    return a.first < b.first;
}

int main(int argc, char const *argv[])
{
    int n;
    cin >> n;
    vector<P> red, blue;
    for(int i=0; i<n; i++){
        int a, b;
        cin >> a >> b;
        red.push_back(make_pair(a, b));
    }
    for(int i=0; i<n; i++){
        int a, b;
        cin >> a >> b;
        blue.push_back(make_pair(a, b));
    }
    sort(red.begin(), red.end(), cmp);
    sort(blue.begin(), blue.end(), cmp);

    int cnt = 0;
    for(P b : blue){
        auto ub = upper_bound(red.begin(), red.end(), b, cmp);
        auto max_i = red.end();
        int max_y = -1;
        for(auto itr = red.begin(); itr != ub; itr++){
            if(itr->second < b.second && itr->second >= max_y){
                max_y = itr->second;
                max_i = itr;
            }
        }
        if(max_i != red.end()){
            cnt++;
            red.erase(max_i);
        }
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
n = gets.to_i
w = gets.split.map(&:to_i)
sum = w.inject(:+)
ans =100000
for i in 0..(n-2)
  x = 0
  for j in 0..i
    x += w[j]
  end
  x = (sum-(2*x)).abs
  ans = x if x < ans
end
puts ans

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

using i64 = int64_t;

#define rep(i, x, y) for (i64 i = i64(x), i##_max_for_repmacro = i64(y); i < i##_max_for_repmacro; ++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif

const int inf = 1.01e9;
const i64 inf64 = 4.01e18;
const double eps = 1e-9;

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

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
    os << "[";
    for (const auto &v : vec) {
        os << v << ",";
    }
    os << "]";
    return os;
}

template <typename T>
bool chmin(T &a, const T &b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template <typename T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

template<typename T, size_t size> void fill(T (&ary)[size], const T& val){
    fill_n((T*)ary, size, val);
}

void solve() {
    //const i64 mod = 1'000'000'007;
    i64 r,D,x;
    cin >> r >> D >> x;
    
    rep(i,0,10){
        x=r*x-D;
        cout << x << endl;
    }
}

int main() {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main {
    
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        ArrayList<Integer> p_list = new ArrayList<>();
        boolean[] isntP = new boolean[55556];
        for(int i = 2; i < isntP.length; i++) {
            if(!isntP[i]) {
                p_list.add(i);
                for(int j = i + i; j < isntP.length; j += i) {
                    isntP[j] = true;
                }
            }
        }

        ArrayList<Integer> ans = new ArrayList<>();
        
        for(int i = 0; i < p_list.size(); i++) {
            if(p_list.get(i) % 5 == 1) {
                ans.add(p_list.get(i));
            }
        }

        System.out.print(ans.get(0));
        for(int i = 1; i < n; i++) {
            System.out.print(" " + ans.get(i));
        }
        System.out.println();
    
    }
}

Measured memory_bytes: 21196
#include<iostream>
#include<vector>

using namespace std;

int main(){
  int h,w;
  cin>>h>>w;

  vector<vector<char>>c(h,vector<char>(w));
  int i,j;
  for(i=0;i<h;i++){
     for(j=0;j<w;j++){
        cin>>c[i][j];
     }
  }
  for(i=0;i<h;i++){
      for(j=0;j<w;j++) {
         cout<<c[i][j];
    }
    cout<<endl;
    for(j=0;j<w;j++) {
         cout<<c[i][j];
    }
  cout<<endl;
  }
  return 0;
}

Measured memory_bytes: 256