akhauriyash/Code-Regression huggingface dataset:
using System;

class Program
{
    static void Main(string[] args)
    {
        var input = Console.ReadLine().Split(' ');
        var N = int.Parse(input[0]);
        var A = int.Parse(input[1]);
        var B = int.Parse(input[2]);

        var n1 = 0;
        var n2 = 0;
        var n3 = 0;
        var n4 = 0;
        var total = 0;
        var sum = 0;

        for(int i=0; i<=N; ++i)
        {
            if(i<10)
            {
                n1 = i;
            }

            else if(i<100)
            {
                n2 = 0;
                n1 = 0;
                n2 = i/10;
                n1 = i-n2*10;
            }

            else if(i<1000)
            {
                n3 = 0;
                n2 = 0;
                n1 = 0;
                n3 = i/100;
                n2 = (i-(n3*100))/10 ;
                n1 = i-(n3*100)-(n2*10);

            }

            else if(i<10000)
            {
                n4 = 0;
                n3 = 0;
                n2 = 0;
                n1 = 0;
                n4 = i/1000;
                n3 = (i-(n4*1000))/100;
                n2 = ((i-(n4*1000)) -(n3*100))/10;
                n1 = ((i-(n4*1000)) -(n3*100)) -(n2*10);
            }

            else if(i == 10000)
            {
                n4 = 0;
                n3 = 0;
                n2 = 0;
                n1 = 1;
            }

            sum = n4+n3+n2+n1;

            if(1<=sum && sum<=36)
            {
                if(A<=sum && sum<=B)
                {
                total += i;
                }
            }

        }
        Console.WriteLine(total);
    }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
int main(){
  int i;
  int a[6];
  for(i=0;i<6;++i){
    cin>>a[i];
  }
  for(i=0;i<6;++i){
    a[i]=a[i]-1;
  }
  int c[4]={0,0,0,0};
  for(i=0;i<6;++i){
    if(a[i]==0){
      c[0]++;
    }
    else if(a[i]==1){
      c[1]++;
    }
    else if(a[i]==2){
      c[2]++;
    }
    else{
      c[3]++;
    }
  }
  int f=0,g=0;
  for(i=0;i<4;++i){
    if(c[i]==1){
      f++;
    }
    if(c[i]==2){
      g++;
    }
  }
  if(f==2&&g==2){
    cout<<"YES";
  }
  else{
    cout<<"NO";
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    map<char, int> m;
    map<char, int>::iterator itr;
    string given;
    cin >> given;
    for(int i = 0; i < given.size(); i++){
        m[given[i]]++;
    }
    for(itr = m.begin(); itr != m.end(); itr++){
        if(itr->second > 1 && itr->second != given.size()){
            cout << "Yes";
            return 0;
        }
    }
    cout << "No";
    return 0;
}

Measured memory_bytes: 256
import math
n,m = map(int,input().split())
diff = abs(n-m)
count1 = 1
count2 = 1
a = 1

if diff >= 2:
    print(0)
elif diff == 1:
    ans = math.factorial(max(n,m))
    print(ans*(ans//max(n,m))%(10**9+7))
else:
    ans = math.factorial(n)
    print(ans*ans*2%(10**9+7))


Measured memory_bytes: 50544
#include <bits/stdc++.h>
using namespace std;
const int M = 1046527;
string sq[M];

int getChar(char c)
{
	switch(c){
		case 'A' : return 1;
		case 'T' : return 2;
		case 'C' : return 3;
		case 'G' : return 4;
	}
	return 0;
}

int getKey(string s)
{
	int sum = 0;
	int p = 1;
	for(int i = 0; i < s.size(); i++){
		sum += p*getChar(s[i]);
		p *= 5;
	}
	return sum;
}

int h1(int k){
	return k % M;
}

int h2(int k){
	return 1 + ( k % (M-1));
}

int find(string s)
{
	int key = getKey(s);
	for(int i = 0; ; i++){
		int h = (h1(key) + i*h2(key))%M;
		if(sq[h] == s) return 1;
		else if(sq[h] == "") return 0;
	}
}

int insert(string s)
{
	int key = getKey(s);
	for(int i = 0;; i++){
		int h = (h1(key) + i*h2(key))%M;
		if(sq[h] == s) return 1;
		else if(sq[h] == ""){
			sq[h] = s;
			return 0;
		}
	}
}

int main()
{
	int n;
	cin >> n;
	while(n--){
		string s1, s2;
		cin >> s1 >> s2;
		if(s1[0] == 'f'){
			if(find(s2))
				cout << "yes" << endl;
			else
				cout << "no" << endl;
		}
		else{
			insert(s2);
		}
	}

	return 0;
}

Measured memory_bytes: 27388
#pragma GCC target("avx2")
#pragma GCC optimization("O3")
#pragma GCC optimization("unroll-loops")
#include <bits/stdc++.h>
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define mkp make_pair
#define in insert
#define er erase
#define fd find
#define fr first
#define sc second
typedef long long ll;
typedef long double ld;
const ll INF=0x3f3f3f3f3f3f3f3f;
const ll llinf=(1LL<<62);
const int inf=(1<<30);
const int nmax=1e5+50;
const int mod=1e9+7;
using namespace std;
int n,i;
char c;
string s1,s;
int main()
{
	//freopen("sol.in","r",stdin);
	//freopen("sol.out","w",stdout);
	//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
	cin>>n;
	if(n&1)rc("No");
	for(i=1;i<=n/2;i++)cin>>c,s+=c;
	for(;i<=n;i++)cin>>c,s1+=c;
	if(s1==s)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}


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

using namespace std;
inline void FAST_IO(){ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);}

int main(){
	FAST_IO();
	
	int n,k;
	string s;
	cin >> n >> s >> k;
	
	char at = s[k-1];
	
	for(char &c : s)
		if(c != at)
			c = '*';
	
	cout << s << endl;
	
	return 0;
}

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 - 1; i >= 0; i--)
#define FOR(i, m, n) for(ll i = m; i <= n; i++)
#define FORR(i, m, n) for(ll i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n)
#define MAX 100000
#define inf 1000000007
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

//mapの使い方。数え上げ。O(n)
int main() {
    //cin高速化
    cin.tie(0);
    ios::sync_with_stdio(false);
    map<string, ll> memo;
    ll n, maxv;
    maxv = 0;
    cin >> n;
    string tmp;

    REP(i, n){//各単語の登場回数を調べる。
        cin >> tmp;
        memo[tmp] ++;
    }
    
    for (const auto& x : memo) {//登場する最大回数を抑える。
        ll v = x.second;
        if (v > maxv) maxv = v;
    }

    for (auto it = memo.begin(); it != memo.end(); it++) {//最大回数を同じ登場回数のものを出力。
        if (it->second == maxv) {
            cout << it->first << endl;
        }
    }
	return 0;
}


Measured memory_bytes: 23808
#include <iostream>
#include <algorithm>
#include <cmath>
#include <iomanip>
using namespace std;

typedef long long ll;

ll mod=1e9+7;

ll gcd(ll n,ll m){
    if(m==0) return n;
    else return gcd(m,n%m);
}

ll lcm(ll n,ll m){
    return n/gcd(n,m)*m;
}

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

string by_x(ll n,ll x){
    string ans="";
    while(n>0){
        char c=n%x+'0';
        ans=c+ans;
        n/=x;
    }
    return ans;
}

ll order(ll n,ll p){
    ll ans=0;
    while(n%p==0){
        ans++;
        n/=p;
    }
    return ans;
}

//UnionFind
//配列の要素数とかは適宜変える

int parent[100010];
int t_rank[100010];

void init(int n){
    for(int i=0;i<n;i++){
        parent[i]=i;
        t_rank[i]=0;
    }
}

int find(int x){
    if(parent[x]==x) return x;
    else return parent[x]=find(parent[x]);
}

void unite(int x,int y){
    x=find(x);
    y=find(y);
    if(x==y) return;
    if(t_rank[x]<t_rank[y]) parent[x]=y;
    else{
        parent[y]=x;
        if(t_rank[x]==t_rank[y]) t_rank[x]++;
    }
}

//mod演算
//ここも配列の要素数とかは適宜変える

ll fac[1000010];

ll modinv(ll a){
    ll b=mod,u=1,v=0;
    while(b){
        ll t=a/b;
        a-=t*b; swap(a,b);
        u-=t*v; swap(u,v);
        }
        u%=mod;
        if(u<0) u+=mod;
    return u;
}

void modfac(){
    fac[0]=1;
    for(ll i=1;i<1000010;i++){
        fac[i]=(fac[i-1]*i)%mod;
    }
}

ll modperm(ll n,ll k){
    if(n<0||k<0||n<k) return 0;
    else return (fac[n]*modinv(fac[n-k]))%mod;
}

ll modcomb(ll n,ll k){
    if(n<0||k<0||n<k) return 0;
    else return ((fac[n]*modinv(fac[k]))%mod*modinv(fac[n-k]))%mod;
}

ll modpow(ll a,ll b){
  ll ans=1;
  a%=mod;
  while(b){
    if(b&1) ans=ans*a%mod;
    a=a*a%mod;
    b>>=1;
  }
  return ans;
}

int main(){
    int a,b,c;
    cin >> a >> b >> c;
    cout << c/a*b << endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);

        int x = sc.nextInt();

        while (true) {
            if (x > 2 && x % 2 == 0) {
                x++;
            }
            boolean isOK = true;
            for (int i = 3; i < Math.sqrt(x) ; i++) {
                if (gcd(i, x) > 1) {
                    x++;
                    isOK = false;
                    break;
                }
            }
            if (isOK) {
                break;
            }
        }

        System.out.println(x);
    }

    private static long gcd(long a, long b) {
        long temp;
        while ((temp = a % b) != 0) {
            a = b;
            b = temp;
        }
        return b;
    }
}

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

using namespace std;

int main(){
  int dp[100000];
  int n,d,x,X,mx;
  int p[10][10];
  cin>>n>>d>>x;
  X=x;
  for(int i=0;i<d;i++){
    for(int j=0;j<n;j++){
      cin>>p[i][j];
    }
  }
  for(int i=0;i<d-1;i++){
    mx=0;
    for(int j=0;j<100000;j++){
      dp[j]=0;
    }
    for(int j=0;j<n;j++){
      if(x<p[i+1][j]){
	dp[p[i][j]]=dp[p[i+1][j]];
      }
    }
    for(int j=0;j<=x;j++){
      for(int k=0;k<n;k++){
	if(j-p[i][k]>=0){
	  dp[j]=max(dp[j-p[i][k]]+p[i+1][k],dp[j]);
	}
      }
    }
    for(int j=0;j<=x;j++){
      mx=max(mx,dp[j]+x-j);
    }
    x=mx;
  }
  cout<<max(x,X)<<endl;
  return 0;
}



Measured memory_bytes: 3508
#include<stdio.h>
#include<string.h>
#include<stdlib.h>

main(){
	
	char str[100];
	int len,i;
	
	scanf("%s",&str);
	
	len=strlen(str);
	
	for(i=0;i<=len-9;i++){
		printf("%c",str[i]);
	}
	
	printf("\n");
	
	return 0;
}



Measured memory_bytes: 128
N,M=map(int,input().split())
E=[[] for i in range(N)]
for i in range(M):
  u,v=map(int,input().split())
  u,v=u-1,v-1
  E[u].append(v)
S,T=map(int,input().split())
S,T=S-1,T-1

from collections import deque
stack=deque()
seen=[[False for i in range(3)] for j in range(N)]
stack.append([S,0,1])
while stack:
  node=stack.popleft()
  v=node[0]
  step=node[1]
  turn=node[2]
  if step==3:
    if v==T:
      print(turn)
      break
    step=0
    turn+=1
  if seen[v][step]:
    continue
  seen[v][step]=True
  children=E[v]
  for child in children:
    stack.append([child,step+1,turn])
else:
  print(-1)


Measured memory_bytes: 30224
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

void dfs(vector<int> &ta, vector<int> &l, vector<int> &p, vector<int> &co, int lv, int &ans){
  int n = l.size();
  if(lv == n){
    int add = 0;
    rep(i, 3){
      if(p.at(i) == 0) return ;
      add += abs(ta.at(i) - p.at(i));
      add += 10 * (co.at(i)-1);
    }
    ans = min(ans, add);
    return ;
  }
  dfs(ta, l, p, co, lv+1, ans);
  rep(i, 3){
    p.at(i) += l.at(lv);
    co.at(i)++;
    dfs(ta, l, p, co, lv+1, ans);
    p.at(i) -= l.at(lv);
    co.at(i)--;
  }
}

int main(){
  int n;
  cin >> n;
  vector<int> ta(3);
  rep(i, 3) cin >> ta.at(i);
  vector<int> l(n);
  rep(i, n) cin >> l.at(i);
  vector<int> p(n, 0), co(n, 0);
  int ans = 1001001001;
  dfs(ta, l, p, co, 0, ans);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
const int maxn=2e5+7;
typedef long long ll;
ll dp[maxn][57];
struct dian{
	int a,b;
};
vector<dian> ld;
vector<dian> ly;
dian store[maxn];
bool comp(const dian &a,const dian &b){
	return 1ll*b.a*(a.b+1)<1ll*a.a*(b.b+1);
}
bool cmp1(const dian &a,const dian &b){
	return a.b<b.b;
}
ll ttime[maxn];
int main(){
	int n,t;
	cin>>n>>t;
	int a0=0,a1=0;
	for(int i=1;i<=n;i++) {
		scanf("%d%d",&store[i].a,&store[i].b);
		if(store[i].a==0){
			a0++;
			ld.push_back(store[i]);
		}
		else {
			a1++;
			ly.push_back(store[i]);
		} 
	}
	sort(ly.begin(),ly.end(),comp);
	for(int j=1;j<=50;++j)
		dp[0][j]=t+1;
	for(int i=1;i<=a1;i++){
		for(int j=1;j<=log(t)/log(2);j++){
			dp[i][j]=min(dp[i-1][j],dp[i-1][j-1]+1+1ll*ly[i-1].a*(dp[i-1][j-1]+1)+ly[i-1].b);
		}
	}
	int ans=0;
	sort(ld.begin(),ld.end(),cmp1);//按b升序排列 
	int k=0;
	for(int i=0;i<ld.size();i++){
		ttime[k+1]=ld[i].b+1+ttime[k];
		k++;
	}
	for(int j=0;j<=log(t)/log(2);j++){
		if(dp[a1][j]<=t){//很重要啊 
		int sheng=t-dp[a1][j];
		int tmp=upper_bound(ttime+1,ttime+1+ld.size(),sheng)-ttime-1;
		if(j+tmp>ans)  ans=j+tmp; }
	/*	int i;
		if(dp[a1][j]<=t){
			ll s=0;
			for( i=0;i<ld.size();i++){
				s+=ld[i].b+1;
				if(dp[a1][j]+s>t) break; 
			}
			ans=max(ans,j+i);
		}*/
	}
	cout<<ans;
	return 0;
}













Measured memory_bytes: 92528
#include<iostream>

using namespace std;

int n,s,ans;

void dfs(int now,int sum,int times){
	if(n < times)
		return;
	if(n == times && s == sum){
		ans++;
		return;
	}
	for(int i = now + 1;i <= 9;i++)
		dfs(i,sum + i,times + 1);
}

int main(){
	while(cin >> n >> s,n+s != 0){
		ans = 0;
		for(int i = 0;i <= 9;i++){
			dfs(i,i,1);
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3076
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



int main(){

	char buf[3][11];

	for(int i = 0; i < 3; i++){

		scanf("%s",buf[i]);
		printf("%c",buf[i][0]-32);
	}
	printf("\n");

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,tmp;
  cin >> N;
  // vecotr<int> a(N);
  int ans = 0;
  for(int i=0;i<N;i++){
    cin >> tmp;
    if(i%2==0 && tmp%2==1) ans ++;
  }

  cout << ans << endl;
}

Measured memory_bytes: 3588
class SegmentTree(object):

    def __init__(self, init_array, seg_func=min, seg_func_null=10 ** 9 + 7):

        self.seg_func = seg_func
        self.seg_func_null = seg_func_null
        self.n = 1
        while self.n < len(init_array):
            self.n *= 2
        self.dat = [0] * (2 * self.n - 1)
        for i in range(len(init_array)):
            self.dat[self.n - 1 + i] = init_array[i]
        for i in range(self.n - 2, -1, -1):
            self.dat[i] = self.seg_func(self.dat[2 * i + 1], self.dat[2 * i + 2])

    def update(self, k, a):
        k += self.n - 1
        self.dat[k] = a
        while k > 0:
            k = (k - 1) // 2
            self.dat[k] = self.seg_func(self.dat[k * 2 + 1], self.dat[k * 2 + 2])

    def query(self, p, q):
        # [p, q)
        if q <= p:
            return self.seg_func_null

        p += self.n - 1
        q += self.n - 2
        res = self.seg_func_null

        while q - p > 1:
            if p & 1 == 0:
                res = self.seg_func(res, self.dat[p])
            if q & 1 == 1:
                res = self.seg_func(res, self.dat[q])
                q -= 1
            p = p // 2
            q = (q-1) // 2
        if p == q:
            res = self.seg_func(res, self.dat[p])
        else:
            res = self.seg_func(self.seg_func(res, self.dat[p]), self.dat[q])

        return res


def solve_b(n, k, p_list):

    min_tree = SegmentTree(p_list)
    max_tree = SegmentTree(p_list, max, -1)

    min_list = [0] * n
    max_list = [0] * n

    for i in range(n - k + 1):
        if p_list[i] == min_tree.query(i, i + k):
            min_list[i] = 1

    for i in range(n - k + 1):
        if p_list[i + k - 1] == max_tree.query(i, i + k):
            max_list[i + k - 1] = 1

    res = 1
    # print(min_list, max_list)

    for i in range(n - k):
        if min_list[i] == 0 or max_list[i + k] == 0:
            res += 1

    # count invariant
    straight = 1
    count_k = 0
    for i in range(n - 1):
        if p_list[i] < p_list[i + 1]:
            straight += 1
        else:
            straight = 1
        if straight == k:
            count_k += 1

    if count_k > 0:
        res -= count_k - 1

    return res


def solve_b_greedy(n, k, p_list):

    count_dict = dict()

    for i in range(n - k + 1):
        p_list_new = p_list[:i] + list(sorted(p_list[i:i + k])) + p_list[i + k:]
        p_list_new_hash = ".".join([str(p) for p in p_list_new])
        if p_list_new_hash in count_dict.keys():
            print(i, p_list_new_hash)
        count_dict[p_list_new_hash] = 1

    return len(count_dict)


def main_greed():
    n, k = map(int, input().split())
    p_list = list(map(int, input().split()))
    res = solve_b_greedy(n, k, p_list)
    print(res)


def main():
    n, k = map(int, input().split())
    p_list = list(map(int, input().split()))
    res = solve_b(n, k, p_list)
    print(res)


if __name__ == "__main__":
    main()


Measured memory_bytes: 100044
a, b, c = map(int, input().split())

if a != 1 and a == b == c:
  print(-1)
  exit()
  
result = 0

while True:
  if any([a & 1, b & 1, c & 1]):
    break
    
  a2 = a // 2
  b2 = b // 2
  c2 = c // 2
  a = b2 + c2
  b = a2 + c2
  c = a2 + b2
  result += 1

print(result)

Measured memory_bytes: 9116
#include <cstdio>
#include <vector>
#include <set>
#include <algorithm>
using namespace std;

const int INF = 1 << 30;

class Edge
{
public:
  int to, cap, rev, idx;
  bool isRev;
  Edge(int _to = 0, int _cap = 0, int _rev = 0, int _idx = 0, bool _isRev = false)
    :to(_to), cap(_cap), rev(_rev), idx(_idx), isRev(_isRev) {} 
};

void add_edge(vector<vector<Edge> >& g, int from, int to, int cap, int idx, bool isRev)
{
  g[from].push_back(Edge(to, cap, g[to].size(), idx, isRev));
  g[to].push_back(Edge(from, 0, g[from].size()-1, idx, isRev));
}

int ff(vector<vector<Edge> >& g, vector<int>& used, int s, int t, int f, set<int>& rev)
{
  if (s == t)
    return f;
  used[s] = 1;
  
  for (unsigned int i = 0; i < g[s].size(); ++i) {
    Edge& e = g[s][i];
    if (!used[e.to] && e.cap > 0) {
      int d = ff(g, used, e.to, t, min(f, e.cap), rev);
      if (d > 0) {
	if (e.isRev)
	  rev.insert(e.idx);
	e.cap -= d;
	g[e.to][e.rev].cap += d;
	return d;
      }
    }
  }
  return 0;
}

int solve(vector<vector<Edge> >& g, int s, int t, set<int>& rev)
{
  int flow = 0;
  for ( ; ; ) {
    vector<int> used(g.size(), 0);
    int f = ff(g, used, s, t, INF, rev);
    if (f == 0)
      return flow;
    flow += f;
  }
}

int main()
{
  int N, M;
  while (~scanf("%d %d", &N, &M)) {
    vector<vector<Edge> > g(N);
    for (int i = 0; i < M; ++i) {
      int X, Y;
      scanf("%d %d", &X, &Y);
      --X;
      --Y;
      add_edge(g, X, Y, 1, i+1, false);
      add_edge(g, Y, X, 1, i+1, true);
    }
    int S, T;
    scanf("%d %d", &S, &T);
    --S;
    --T;

    set<int> rev;
    printf("%d\n", solve(g, S, T, rev));
    printf("%d\n", rev.size());
    for (set<int>::iterator it = rev.begin(); it !=  rev.end(); ++it)
      printf("%d\n", *it);
  }
  return 0;
}

Measured memory_bytes: 0
//
//  header_useful.h
//  c++_acm
//
//  Created by 李弘辰 on 2019/7/23.
//  Copyright © 2019 李弘辰. All rights reserved.
//

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <vector>
#include <list>
#include <set>
#include <utility> // pair
#include <map>
#include <iostream>
#include <sstream>
#include <algorithm> // sort
#include <string>
#include <stack>
#include <queue>
#include <fstream>
#include <bitset>

using namespace std;

#define ll long long
#define uchar unsigned char
#define ushort unsigned short
#define uint unsigned int
#define ulong unsigned long
#define ull unsigned long long

#define INT_INF 0x7fffffff

#define pi acos(-1)

#define mx(a,b) (a) > (b) ? (a) : (b)
#define mn(a,b) (a) < (b) ? (a) : (b)
#define mem(a,b) memset(a,b,sizeof(a))
#define fre(a) freopen(a,"r",stdin)

#define cio ios::sync_with_stdio(false); // Do not use it with "scanf" and other c input!
#define pb push_back
#define REP(i,a,b) for (int i = a;i <= b;i ++)
#define pre(i,a,b) for (int i = a;i >= b;i --)
#define rep(i,a,b) for (int i = a;i < b;i ++)

#define itn int
#define nit int
#define inr int
#define mian main
#define ednl endl
#define fro for
#define fir for
#define reutrn return
#define retunr return
#define reutnr return


/* header_useful_h */


int main()
{
    double a,b,h,m;
    scanf("%lf%lf%lf%lf",&a,&b,&h,&m);
    double ha = m + h * 60;
    ha *= 0.5;
    double ma = 6 * m;
    double c = abs(ha - ma);
    c = min(360 - c,c);
    double ans = a * a + b * b - 2 * a * b * cos(c * pi / 180);
    printf("%.20f\n",sqrt(ans));
    return 0;
}


Measured memory_bytes: 4268
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
using namespace std;

#define pb push_back
#define mp make_pair
#define fs first
#define se second
#define pi 2*acos(0)
#define PI 3.14159265358979323846264338

typedef long long ll;
typedef unsigned long long ull;
typedef pair < int , int > pii;
typedef pair < ll , ll > pll;

const int N = 100010;
const int MX = 123456;
const int mod = (int)1e9 + 7;
const int base = 97;
const ull BS1 = 10000019ULL;
const int INF = (1 << 29);

template < class T > inline void fastScan(T &x){
    register char c = getchar();
    int neg = 0; x = 0;
    for(   ; (c < 48 || c > 57) && (c != '-'); c = getchar());
    if(c == '-') { neg = 1; c = getchar(); }
    for(   ; c > 47 && c < 58; c = getchar()){
        x = (x << 1) + (x << 3) + c - 48;
    }
    if(neg) x = -x;
}

// OrderedSet
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// template < typename T > using ordered_set = tree < T, null_type, greater < T >, rb_tree_tag, tree_order_statistics_node_update >;

//typedef uint64_t hash_t;
//mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
//const int HASH_COUNT = 2;
//const hash_t HASH_P = (uint32_t)-13337;
//uniform_int_distribution<hash_t> MULT_DIST(0.25 * HASH_P, 0.75 * HASH_P);
//const hash_t HASH_MULT[HASH_COUNT] = {MULT_DIST(rng), MULT_DIST(rng)};

int n;

int inp[N + N];
int arr[N + N];

int main(){
  fastScan(n);
  for(int i = 1; i <= n; i++){
    fastScan(inp[i]);
  }
  int hand = 0;
  for(int i = 1; i <= n; i++){
    hand ^= inp[i];
  }
  for(int i = 1; i <= n; i++){
    arr[i] = hand ^ inp[i];
  }
  for(int i = 1; i <= n; i++){
    printf("%d%c", arr[i], (i == n ? '\n' : ' '));
  }
}


Measured memory_bytes: 5204
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int inf = INT_MAX;
const ll INF = LLONG_MAX;
const ll MOD = 1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b, const ll mod=MOD) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b, const ll mod=MOD) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b, const ll mod=MOD) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b, const ll mod=MOD) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int A, B; cin >> A >> B;

    int res = -1;
    rep(x, 1, 100000){
        if((int)(x * 0.08) == A and (int)(x * 0.10) == B){
            res = x;
            break;
        }
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 256
// ABC173B - 

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

typedef unsigned long long int ull;
typedef long long int ll;

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

	map<string, int> ans;
	for (int i = 0; i < N; i++) {
		string t;
		cin >> t;
		ans[t]++;
	}

	cout << "AC x " << ans["AC"] << endl;
	cout << "WA x " << ans["WA"] << endl;
	cout << "TLE x " << ans["TLE"] << endl;
	cout << "RE x " << ans["RE"] << endl;

	return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
template <class T>
inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
const long long INF = 1LL << 60;
using pll = pair<long long, long long>;

int divSum(int n) {
  int divCount = 0;
  for (int i = 1; i <= n; i++) {
    if (n % i == 0) {
      ++divCount;
    }
  }
  return divCount;
}

int main() {
  // 標準入力が早くなる。Cスタイルの入出力とC++スタイルの入出力を混合させてはならない。
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);

  int N;
  cin >> N;

  int res = 0;
  for (int i = 1; i <= N; i = i + 2) {
    int tmp = divSum(i);

    if (tmp == 8) {
      ++res;
    }
  }

  cout << res << endl;

  return 0;
}


Measured memory_bytes: 384
import java.util.*;

public class Main {

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

		while(sc.hasNext()){
			String s = sc.next();
			int joi = 0;
			int ioi = 0;
			for(int i=0;i<s.length()-2;i++){
				String t = s.substring(i,i+3);
				if(t.compareTo("JOI")==0)joi++;
				if(t.compareTo("IOI")==0)ioi++;
			}
			System.out.println(joi);
			System.out.println(ioi);
		}
	}
}

Measured memory_bytes: 22804
#define y1 askjdkasldjlkasd
#include <bits/stdc++.h>
#undef y1

using namespace std;

#define pb push_back
#define mp make_pair
#define fi(a, b) for(int i=a; i<=b; i++)
#define fj(a, b) for(int j=a; j<=b; j++)
#define fo(a, b) for(int o=a; o<=b; o++)
#define fdi(a, b) for(int i=a; i>=b; i--)
#define fdj(a, b) for(int j=a; j>=b; j--)
#define fdo(a, b) for(int o=a; o>=b; o--)
#define clr(x) memset(x, 0, sizeof(x))
#define cpy(x,y) memcpy(x, y, sizeof(y))
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
typedef vector<ll> vl;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;

#ifdef _DEBUG
#define LOCAL
#endif

#ifdef LOCAL
#define err(...) fprintf(stderr, __VA_ARGS__)
#else
#define err(...) while (0)
#endif

double START_TIME;

void exit() {
#ifdef LOCAL	
	cerr << "TIME: " << setprecision(5) << fixed << (clock() - START_TIME) / CLOCKS_PER_SEC << endl;
#endif	
	exit(0);
}

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

template<typename T>
ostream& operator<<(ostream& os, vector<T> v) {
	fi(0, sz(v) - 1) {
		os << v[i] << " ";
	}
	return os;
}

template<typename T>
ostream& operator<<(ostream& os, set<T> t) {
	for (auto z : t) {
		os << z << " ";
	}
	return os;
}

template<typename T1, typename T2>
ostream& operator<<(ostream& os, map<T1, T2> t) {
	cerr << endl;
	for (auto z : t) {
		os << "\t" << z.first << " -> " << z.second << endl;
	}
	return os;
}

#ifdef LOCAL
#define dbg(x) {cerr << __LINE__ << "\t" << #x << ": " << x << endl;}
#define dbg0(x, n) {cerr << __LINE__ << "\t" << #x << ": "; for (int ABC = 0; ABC < n; ABC++) cerr << x[ABC] << ' '; cerr << endl;}
#define dbg1(x, n) {cerr << __LINE__ << "\t" << #x << ": "; for (int ABC = 1; ABC <= n; ABC++) cerr << x[ABC] << ' '; cerr << endl;}
#else
#define dbg(x) while(0){}
#define dbg0(x, n) while(0){}
#define dbg1(x, n) while(0){}
#endif

#ifdef LOCAL
#define ass(x) if (!(x)) { cerr << __LINE__ << "\tassertion failed: " << #x << endl, abort(); }
#else
#define ass(x) assert(x)
#endif

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

int a, b, k;
ll ans;

void solve() {
	if (b <= a + 2 || a - 1 > k) {
		printf("%d\n", 1 + k);
		return;
	}
	ans = a;
	k -= (a - 1);
	ll q = k / 2;
	ans += (b - a) * q;
	k %= 2;
	ans += k;
	printf("%lld\n", ans);
}

int main() {
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	START_TIME = (double)clock();
#endif
	
	scanf("%d %d %d", &k, &a, &b);
	solve();

	exit();
	return 0;
}





Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
ret = 0
flg = False
while flg == False:
    for i in range(len(a)):
        if(a[i] == 0 or a[i]%2 != 0):
            flg = True
        else:
            a[i] = a[i]/2
    
    if not flg:
        ret += 1
    

print(ret)


Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
#include <cassert>
#include <functional>
#include <numeric>
#include <limits>
#include <iomanip>
#include <queue>
#include <cmath>
#include <math.h>
#include <string>
#include <cmath>
#include <bitset>
#include <set>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const long long INF = 1LL << 60;
using pll = pair<long long, long long>;
typedef long long ll;
#define min(a, b) ((a) < (b) ? (a) : (b))
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)

int main() {
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	// cout << std::fixed << std::setprecision(15);
	string S; cin >> S;
	int aida = S.length() - 1;
	long long res = 0;
	for (int bit = 0; bit < (1 << aida); bit++) {
		long long tmp = S[0] - '0';
		for (int i = 0; i < aida; i++) {
			if (bit & (1 << i)) {
				res += tmp;
				tmp = 0;
			}
			tmp = tmp * 10 + S[i + 1] - '0';
		}
		res += tmp;
	}

	cout << res << endl;
}


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

using namespace std;

const int MAX_N = 1e5 + 10, MOD = 1e9 + 7;

inline int add (int a, int b) { return (a + b) % MOD; }
inline int mul (int a, int b) { return (1LL * a * b) % MOD; }

vector <int> G[MAX_N];
int dp[2][MAX_N];

int dfs (int u, int p, int flag) {
  int& ret = dp[flag][u];
  if (~ret) return ret;
  ret = 1;
  for (int v: G[u]) {
    if (v == p) continue;
    if (flag == 0) ret = mul(ret, dfs(v, u, 1));
    else ret = mul(ret, add(dfs(v, u, 0), dfs(v, u, 1)));
  }
  return ret;
}

int main () {
  int n;
  cin >> n;
  for (int i = 1; i < n; i++) {
    int u, v;
    cin >> u >> v;
    G[u].push_back(v);
    G[v].push_back(u);
  }
  memset(dp, -1, sizeof dp);
  dfs(1, -1, 0);
  dfs(1, -1, 1);
  cout << add(dp[0][1], dp[1][1]) << endl;
  return (0);
}


Measured memory_bytes: 14848
#include<iostream>

using namespace std;

int num_1[100010], num_2[100010], number[100010];

main()
{
	int n, max_1=0, max_2=0;
	cin >> n;
	for(int i = 0; i < n; i ++)
	{
		cin >> number[i];
		if(i%2)
		{
			num_1[number[i]] ++;
		}
		else
		{
			num_2[number[i]] ++;
		}
	}
	int v_1, v_2;
	for(int i = 0; i < n; i ++)
	{
		if(i%2)
		{
			if(max_1 < num_1[number[i]])
			{
				max_1 = num_1[number[i]];
				v_1 = number[i];
			}
		}
		else
		{
			if(max_2 < num_2[number[i]])
			{
				max_2 = num_2[number[i]];
				v_2 = number[i];
			}
		}
	}
	int max_1_=0, max_2_=0, v_1_=-1, v_2_=-1;
	if(v_1 == v_2)
	{
		for(int i = 0; i < n; i ++)
		{
			if(i%2 and number[i] != v_1)
			{
				if(max_1_ < num_1[number[i]])
				{
					max_1_ = num_1[number[i]];
					v_1_ = number[i];
				}
			}
			else if(!(i%2) and number[i] != v_2)
			{
				if(max_2_ < num_2[number[i]])
				{
					max_2_ = num_2[number[i]];
					v_2_ = number[i];
				}
			}
		}
		
		cout << n-max(max_1+max_2_, max_2+max_1_);
	}
	else
	{
		cout << n-max_1-max_2;
	}
}

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

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

const int mod = 1000000007;
//const int mod = 998244353;

struct mint {
    ll x; // typedef long long ll;
    mint(ll 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 { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= 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 { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}


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

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

// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
    vector<mint> fact, ifact;
    combination(int n):fact(n+1),ifact(n+1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n]*ifact[k]*ifact[n-k];
    }
};
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);

    string S; cin >> S;
    if (S[2] == S[3] && S[4] == S[5]) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fin(x) freopen(x,"r",stdin)
#define fout(x) freopen(x,"w",stdout)
#define mem(a,b) memset(a,b,sizeof(a))
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pii;
const ll INF=0x3f3f3f3f3f3f3f3f;
const ll inf=0xc0c0c0c0c0c0c0c0;
const double pi=acos(-1);
int main()
{
	ll A,B,C,X,Y;
	cin>>A>>B>>C>>X>>Y;
	ll ans=INF;
	ll f=max(X,Y);
	for(ll i=0;i<=f;i++)
	{
		ll temp=C*i*2;
		ll nX=max(X-i,0ll)*A;
		ll nY=max(Y-i,0ll)*B;
		ans=min(ans,temp+nX+nY);
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; 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; cin >> n;
    ll current_value = 0;
    ll max_length = 0;
    ll current_length = 0;
    REP(i, n) {
        ll value; cin >> value;
        if (i == 0) {
            current_value = value;
            continue;
        }
        if (current_value >= value) current_length++;
        else current_length = 0;

        if (current_length > max_length) max_length = current_length;

        current_value = value;
    }
    cout << max_length << endl;
    return 0;
}

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

int solve(string& s, int turn) {
  int answer = 0;
  for ( int i = 0; i < s.size(); ++i ) {
    answer += (s[i] == ('0' + turn));
    turn ^= 1;
  }
  return answer;
}

int main() {
  string s;
  while ( cin >> s ) {
    cout << min(solve(s, 0), solve(s, 1)) << endl;
  }
  return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,a[100],b[100],c[100],s=0;
    cin>>n;
    for(int i=1;i<=n;i++)cin>>a[i];
    for(int i=1;i<=n;i++){cin>>b[i];s+=b[i];}
    for(int i=1;i<n;i++)cin>>c[i];
    for(int i=1;i<n;i++)
    {
        if(a[i]+1==a[i+1])s+=c[a[i]];
    }
    cout<<s<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#define rep(i,n) for(int i=0;i<(n);i++)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define psortfirst(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.first<b.first;});
#define All(x) (x).begin(),(x).end()
using namespace std;
using pii  = pair<int,int>;
long long gcd(long long a, long long b){return (b == 0 ? a : gcd(b, a%b));}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
typedef long long ll;
#define MOD 1000000007
#define EPS 10e-8

int main() {
    ll A[6];
    rep(i,3){
        cin >> A[i];
    }
    //sort(A,A+3);
    cout << (A[2]-A[1]==A[1]-A[0] ? "YES" : "NO") << endl;
}

Measured memory_bytes: 256
sa = input()
sb = input()
sc = input()

ju = True

turn = sa[0:]
if turn:
    x = turn[0]
    sa = sa[1:]
else:
    print("A")
    ju = False
    
    
while ju:
    if x == "a":
        turn = sa[0:]
        if turn:
            x = turn[0]
            sa = sa[1:]
        else:
            print("A")
            break
            
    if x == "b":
        turn = sb[0:]
        if turn:
            x = turn[0]
            sb = sb[1:]
        else:
            print("B")
            break
            
    if x == "c":
        turn = sc[0:]
        if turn:
            x = turn[0]
            sc = sc[1:]
        else:
            print("C")
            break

Measured memory_bytes: 3064
package main

import (
    "fmt"
)

var n, m int 
var l [][]int
var r []int

func main() {
    fmt.Scan(&n)
    fmt.Scan(&m)
    l = make([][]int, n)
    r = make([]int, n)
    for i := 0; i < m; i++ {
        var x, y int 
        fmt.Scan(&x, &y) 
        l[x-1] = append(l[x-1], y-1)
    }   
    for i := range l { 
        r[i] = -1
    }   

    //fmt.Println(l)

    var max int 
    for i := 0; i < n; i++ {
        res := calc(i)
        if res > max {
            max = res 
        }   
    }   

    fmt.Println(max)
}

func calc(k int) int {
    if r[k] != -1 {
        return r[k]
    }   
    if len(l[k]) == 0 { 
        return 0
    }   
    var max int 
    for _, i := range l[k] {
        res := calc(i)
        if res > max {
            max = res 
        }   
    }   
    r[k] = max + 1 
    return r[k]
}


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

int main() {
	int a, c;
	char b;
	while (true) {
		cin >> a >> b >> c;
		if (b == '?') {
			return 0;
		} else if (b == '+') {
			cout << a + c << endl;
		} else if (b == '-') {
			cout << a - c << endl;
		} else if (b == '*') {
			cout << a * c << endl;
		} else if (b == '/') {
			cout << a / c << endl;
		}
	}
}

Measured memory_bytes: 3064
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int y = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int[] aArr = new int[a];
        for (int i = 0; i < a; i++) {
            aArr[i] = - sc.nextInt();
        }
        Arrays.sort(aArr);
        int[] bArr = new int[b];
        for (int i = 0; i < b; i++) {
            bArr[i] = - sc.nextInt();
        }
        Arrays.sort(bArr);
        int[] cArr = new int[x + y + c];
        for (int i = 0; i < x; i++) {
            cArr[i] = aArr[i];
        }
        for (int i = 0; i < y; i++) {
            cArr[x + i] = bArr[i];
        }
        for (int i = 0; i < c; i++) {
            cArr[x + y + i] = - sc.nextInt();
        }
        Arrays.sort(cArr);
        long total = 0;
        for (int i = 0; i < x + y; i++) {
            total -= cArr[i];
        }
        System.out.println(total);
    }
}


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

int main() {
    int n;
    while(cin >> n) {
        int res = 0;
        for(int a=0; a<10; ++a) {
            for(int b=0; b<10; ++b) {
                for(int c=0; c<10; ++c) {
                    for(int d=0; d<10; ++d) {
                        res += a+b+c+d == n;
                    }
                }
            }
        }
        cout << res << endl;
    }
}


Measured memory_bytes: 3068
import sys
 
stdin = sys.stdin
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()
nas = lambda: stdin.readline().split()

n, k, s = na()

for i in range(n):
    if i:
        print(' ', end='')
    if i < k:
        print(s, end='')
    else:
        print(s + 1 if s != pow(10, 9) else 1, end='')

print()

Measured memory_bytes: 4644
#include <stdio.h>
#include <stdlib.h>
int main()
{
	int A,B,C;
    scanf("%d%d%d",&A,&B,&C);
    if ((A==5&B==5&C==7)||(A==5&B==7&C==5)||(A==7&B==5&C==5))
    {
		printf("YES\n");
    }
    else
    {
		printf("NO\n");
    }
    
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")

#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()

using ll = long long;
using ull = unsigned long long;
using namespace std;

int gcd(int a, int b) {
  if (a < b) {
    a ^= b;
    b ^= a;
    a ^= b;
  }
  return b ? gcd(b, a % b) : a;
}

int main() {
  int K;
  cin >> K;
  ll result = 0;
  REP(i1, K) {
    REP(i2, K) {
      REP(i3, K) {
        result += gcd(i1+1, gcd(i2+1, i3+1));
      }
    }
  }
  cout << result << endl;
  return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define whlie while
#define pb push_back
#define eb emplace
#define fi first
#define se second
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repr(i,N) for(int i = (N) - 1; i >= 0; i--)
#define rep1(i,N) for(int i = 1; i <= (N) ; i++)
#define repr1(i,N) for(int i = (N) ; i > 0 ; i--)
#define each(x,v) for(auto& x : v)
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) ll __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
using namespace std; void solve();
using ll = long long; using vl = vector<ll>;
using vi = vector<int>; using vvi = vector< vector<int> >;
constexpr int inf = 1001001001;
constexpr ll infLL = (1LL << 61) - 1;
struct IoSetupNya {IoSetupNya() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); cerr << fixed << setprecision(10);} } iosetupnya;
template<typename T, typename U> inline bool amin(T &x, U y) { return (y < x) ? (x = y, true) : false; }
template<typename T, typename U> inline bool amax(T &x, U y) { return (x < y) ? (x = y, true) : false; }
template<typename T, typename U> ostream& operator <<(ostream& os, const pair<T, U> &p) { os << p.first << " " << p.second; return os; }
template<typename T, typename U> istream& operator >>(istream& is, pair<T, U> &p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator <<(ostream& os, const vector<T> &v) { int s = (int)v.size(); rep(i,s) os << (i ? " " : "") << v[i]; return os; }
template<typename T> istream& operator >>(istream& is, vector<T> &v) { for(auto &x : v) is >> x; return is; }
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
template<typename T>void die(T x){out(x); exit(0);}
#ifdef NyaanDebug
  #include "NyaanDebug.h"
  #define trc(...) do { cerr << #__VA_ARGS__ << " = "; dbg_out(__VA_ARGS__);} while(0)
  #define trca(v,N) do { cerr << #v << " = "; array_out(v , N);cout << endl;} while(0)
#else
  #define trc(...)
  #define trca(...)
  int main(){solve();}
#endif
using P = pair<int,int>; using vp = vector<P>;
constexpr int MOD = /** 1000000007; //*/ 998244353;
////////////////



void solve(){

  ini(N); inl(K);
  vl a(N); in(a);

  vector<int> s(1 << N , 0);

  rep(b , 1 << N){
    ll cur = 0;
    rep(k , N){
      if((b >> k) & 1) cur += a[k];
    }
    if(cur == K) s[b] = 1;
  }
  //rep(b , 1 << N) trc(s[b]);

rep(i,N) rep(j,1<<N) if (j&(1<<i)) s[j] |= s[j^(1<<i)];
  ll ans = N;
  rep(i , 1 << N){
    //trc(i , s[i]);
    if(s[i] == 0) amin(ans , N - __builtin_popcount(i));
  }
  out(ans);

}


Measured memory_bytes: 7068
#include<iostream>
#include<cmath>
#include<cstdio>
#include<cstring>
using namespace std;
int n,m,f[1100000],w[1100000];
int main ()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>w[i];
	}
	f[2]=abs(w[2]-w[1]);
	for(int i=3;i<=n;i++)
	{
		f[i]=min(f[i-1]+abs(w[i]-w[i-1]),f[i-2]+abs(w[i]-w[i-2]));
	}	
	cout<<f[n];
}

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

using namespace std;
typedef long long ll;

bool primeNumber(int n){
    if(n < 2) return false;
    else{
        for(int i = 2; i * i <= n; i++){
            if(n % i == 0) return false;
        }
        return true;
    }
}

int main(){
    int n;
    cin>>n;
    while(primeNumber(n) == false)n++;
    cout<<n;
}

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

using namespace std;

#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 FOR(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define INF (1 << 30)
#define LLINF (1LL << 62)
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

typedef long long ll;
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;


int main(){
  int n;
  cin>>n;
  int h[n];
  REP(i,n){
    cin>>h[i];
  }
  h[0]--;
  for(int i=1;i<n;i++){
    if(h[i-1]<h[i]){
      h[i]--;
    }
    if(h[i-1]>h[i]){
      cout<<"No"<<endl;
      return 0;
    }
  }
  cout<<"Yes"<<endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <iomanip>
#include <math.h>
#define rep(i,x) for(ll i = 0;i<x;i++)
#define all(a) (a).begin(),(a).end()
using ll = long long;
using ld = long double;
using namespace std;
using dou = double;
const ll INF = 1LL << 60;
const ll mod = 1000000007;
typedef pair<ll,ll> P;
using graph = vector<vector<ll>>;
template<class T> inline bool chmax(T& a, T b){if(a < b){a = b; return true;}return false;}
template<class T> inline bool chmin(T& a, T b){if(a > b){a = b; return true;}return false;}
ll gcd(ll a,ll b){
    if(a < b)swap(a,b);
    if(a % b == 0)return b;
    else return gcd(b,a%b);
}
bool isp(ll n){
    bool res = true;
    if(n == 1)return false;
    else{
        for(ll i = 2;i * i <= n;i++){
            if(n % i == 0){
                res = false;
                break;
            }
        }
        return res;
    }
}
//printf("%.10f\n", N);
/*
ll fibo(ll n){
    if(memo[n] != 0)return memo[n];
    if(n <= 1)return n;
    else return memo[n] = fibo(n - 1)+ fibo(n - 2);
}*/
/*  vector<ll> vec = {1,2,5,6,8,9,10};
    cout << binary_search(all(vec),5) << endl; -> true*/
/*
    vector<ll> vec = {1,2,5,6,8,9,10};
    auto n = upper_bound(all(vec),4);
    cout << *n << endl; -> 5*/
/*
    cout << fixed << setprecision(15);
    */
int main(){
    string S;
    cin >> S;
    ll ans = 0;
    if(S[0] == '1')ans++;
    if(S[1] == '1')ans++;
    if(S[2] == '1')ans++;
    cout << ans << endl;
}

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

typedef unsigned long ul;
typedef long long ll;
typedef pair<ul, ul> P; //ペア　タイプでふ
int main()
{
    string s;
    int a = 700;
    cin >> s;
    for (char n : s)
    {
        if (n == 'o')
            a += 100;
    }
    cout << a;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
int l,a,b,c,d,jpn,mth;
scanf("%d\n%d\n%d\n%d\n%d\n",&l,&a,&b,&c,&d);
jpn = a/c;
mth = b/d;
if(a%c > 0) jpn++;
if(b%d > 0) mth++;
if(jpn>=mth)l=l-jpn;else l=l-mth;
printf("%d\n",l);
return 0;
}

Measured memory_bytes: 600