akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<cstring>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
#include<time.h>
#include<cassert>

using namespace std;
typedef long long ll;
typedef long double ld;
#define all(a) (a).begin(),(a).end()
#define EPS (1e-5)
#define bit(n,k) ((n>>k)&1)
const ll Mod = 1000000007;
const ll mod = 998244353;
struct H {
	ll x, y;
	bool operator<(const H& b) const {
		if (x != b.x) return x < b.x;
		return y < b.y;
	}
	bool operator>(const H& b) const {
		if (x != b.x) return x > b.x;
		return y > b.y;
	}
	bool operator==(const H& b) const { return x == b.x && y == b.y; }
	bool operator!=(const H& b) const { return (*this) != b; }
};
struct P {
	ll pos, cost;
	bool operator<(const P& b) const { return cost < b.cost; }
	bool operator>(const P& b) const { return cost > b.cost; }
};
struct B {
	ll to, cost;
};
struct E {
	ll from, to, cost;
	bool operator<(const E& b) const { return cost < b.cost; }
	bool operator>(const E& b) const { return cost > b.cost; }
};
template<typename T, typename U>
void chmin(T& a, U b) {
	if (a > b) a = b;
}
template<typename T, typename U>
void chmax(T& a, U b) {
	if (a < b) a = b;
}
template<typename T>
T max_0(T a) {
	if (a < 0) return 0;
	return a;
}
template<typename T>
T min_0(T a) {
	if (a > 0) return 0;
	return a;
}
ll read() {
	ll u;
	ll k = scanf("%lld", &u);
	return u;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j % i, i);
}
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}//x^n%p
ll bitcount(ll x) {
	int sum = 0;
	for (int i = 0; i < 20; i++)
		if ((1ll << i) & x) sum++;
	return sum;
}
ll fact_[200000];
ll comb(ll x, ll y, ll mod = Mod) {
	if (!fact_[0]) {
		fact_[0] = 1;
		for (int i = 1; i < 200000; i++) {
			fact_[i] = fact_[i - 1] * i % mod;
		}
	}
	if (x < y) return 0;
	return mod_pow(fact_[x], mod, mod) *
		mod_pow(fact_[x - y], mod - 2, mod) % mod *
		mod_pow(fact_[y], mod - 2, mod) % mod;
}//xCy
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------
int n, k;
int a[300000];
signed main() {
	cin >> n >> k;
	n++;
	for (int i = 1; i < n; i++) {
		cin >> a[i];
		(a[i] += a[i - 1]) %= k;
	}
	map<int, int>m;
	m[0]++;
	int ans = 0;
	for (int i = 1; i < n; i++) {
		if (i >= k) {
			m[((a[i - k] - (i - k)) % k + k) % k]--;
		}
		ans += m[((a[i] - i) % k + k) % k];
		m[((a[i] - i) % k + k) % k]++;
	}
	cout << ans << endl;
}

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

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){
  while(x->left != NIL)
    x = x->left;
  return x;
}

Node treeMaximum(Node x){
  while(x->right != NIL)
    x = x->right;
  return x;
}

Node treeSearch(Node u, int k){
  if(u == NIL)return NIL;
  else if(k == u->key)return u;
  else if(k < u->key)return treeSearch(u->left,k);
  else return treeSearch(u->right,k);

}

Node treeSuccessor(Node x){
  if(x->right!=NIL)
    return treeMinimum(x->right);
  else{
    while(x == x->parent->right){
      if(x->parent == NIL)return NIL;
      else x = x->parent;
    }
    return  x->parent;
  }
}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y

  if(z->left == NIL || z->right ==NIL)
    y = z;
  else
    y = treeSuccessor(z);

  if(y->left != NIL)
    x = y->left;
  else
    x = y->right;

  if(x != NIL)
    x->parent = y->parent;

  if(y->parent == NIL)
    root = x;
  else if(y == y->parent->left)
    y->parent->left = x;
  else
    y->parent->right = x;

  if(y != z)
    z->key = y->key;
    

}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x!=NIL){
    y = x;
    if(z->key < x->key)
      x = x->left;
    else
      x = x->right;
  }

  z->parent = y;

  if(y == NIL)
    root = z;
  else if(z->key < y->key)
    y->left = z;
  else
    y->right = z;

}

void inorder(Node u){
  if(u->left != NIL)
    inorder(u->left);
  printf(" %d",u->key);
  if(u->right != NIL)
    inorder(u->right);  

}
void preorder(Node u){
  printf(" %d",u->key);
  if(u->left != NIL)
    preorder(u->left);
  if(u->right != NIL)
    preorder(u->right);

}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}



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

using namespace std;

#define IoFast ios_base::sync_with_stdio(0);cin.tie(0);
#define ll long long int
#define float long double
#define foor(i, a, b) for ( int (i) = (a); (i)<(b); (i)++ )
#define foor2(i, a, b) for( int (i) = (a); (i)>(b); (i)-- )
#define foorl(i, a, b) for ( ll (i) = (a); (i)<(b); (i)++ )
#define foorl2(i, a, b) for( ll (i) = (a); (i)>(b); (i)-- )
#define mp make_pair
#define f1 first
#define f2 second
#define pb push_back
#define pii pair<int,int>
#define vpii vector <pii>
#define vi vector<int>
#define sz(a) (int) a.size( )
#define fillArr(n, a) foor(i, 0, n) cin >> a[i];
#define print(a) cout << #a << endl;
#define umax(a,b) a = max ( a, b )
#define umin(a,b) a = min ( a, b )
#define all(k) k.begin ( ), k.end( )
#define rall(k) k.rbegin ( ), k.rend( )
#define clean(k) memset( k, 0, sizeof(k) )
#define endl '\n'
#define intt ll

const intt maxn = 1e10;

int main() {
    intt n;
    cin >> n;
    intt b = n;
    intt a = 0;
    while (b != 0) {
        b = b / 10;
        a++;
    }
    b = 0;
    foor (i,0,a) {
        intt c = 1;
        foor (j,0,i) {
            c *= 10;
        }
        b += 9 * c;
    }
    foor(i,0,10) {
        if(b <= n) {
            cout << 9 * a - i << endl;
            break;
        }
        b -= pow(10, a - 1);
    }
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using pint = pair<int,  int>;
using edge = int;
using graph = vector<vector<edge>>;
const ll INF = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;


int main() {
	ll  n,x, m,k;cin >>n>> x>> m>> k;
	ll M=max(n, max(x,m));
	ll ans=n+x+m+pow(2,k)* M-M;
    cout << ans << endl;
}


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

ll solve() {
    ll A, B;
    cin >> A >> B;
    ll ans = A+B;
    ans = max(ans, A-B);
    ans = max(ans, A*B);
    return ans;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
from collections import deque
import sys
sys.setrecursionlimit(10**9)

n,q=map(int,input().split())

link=[[] for _ in range(n)]
for _ in range(n-1):
    a,b=map(int,input().split())
    link[a-1].append(b-1)
    link[b-1].append(a-1)

v_counter=[0 for _ in range(n)]
for _ in range(q):
    p,x=map(int,input().split())
    v_counter[p-1]+=x

point=[0 for _ in range(n)]
que=deque()
que.append(0)
used=set()
used.add(0)
point[0] += v_counter[0]

while(len(que)>0):
    ind=que.popleft()
    relate=link[ind]
    for i in relate:
        if(i in used):
            continue
        else:
            point[i] += point[ind] + v_counter[i]
            que.append(i)
            used.add(i)

print(*point)


Measured memory_bytes: 70232
#include <stdio.h>
#include <iostream>
// #include <math.h>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <map>

//#include <bits/stdc++.h>
using namespace std;
#define print(x) cout<<(x)<<endl
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define ll long long int
#define pb push_back

int main() {
  int a [] = {0 , 1 , 3 , 1 , 2 , 1 , 2 , 1 , 1 , 2 , 1 , 2 , 1};
  int x, y;
  cin >> x >> y;
  if(a[x] == a[y]) print("Yes");
  else print("No");
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define mp make_pair
#define PI pair<int,int>
#define poly vector<int>
#define For(i,l,r) for(int i=(int)(l);i<=(int)(r);i++)
#define Rep(i,r,l) for(int i=(int)(r);i>=(int)(l);i--)
#define pb push_back
#define fi first
#define se second
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline ll read(){
	ll x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(ll a){
    if(a<0){
    	a=-a; putchar('-');
	}
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(ll a){write(a); puts("");}
inline void wri(ll a){write(a); putchar(' ');}
const int N=305,mod=1e9+7;
int x[N],y[N],s[N<<1];
ll g[N<<1],dp[N<<1][N<<1];
bool in(int x,int l,int r){
	return l<=x&&x<=r;
}
int main(){
	int n=read()*2,k=read();
	For(i,1,k){
		x[i]=read(); y[i]=read();
		s[x[i]]=1; s[y[i]]=1;
	}
	For(i,1,n)s[i]=1-s[i]+s[i-1];
	g[0]=1; for(int i=2;i<=n;i+=2)g[i]=g[i-2]*(i-1)%mod;
	Rep(i,n,1)for(int j=i+1;j<=n;j+=2){
		int f=1;
		For(o,1,k)if(in(x[o],i,j)!=in(y[o],i,j))f=0;
		if(f){
			dp[i][j]=g[s[j]-s[i-1]];
			for(int o=i+1;o<j;o+=2)dp[i][j]=(dp[i][j]-dp[i][o]*g[s[j]-s[o]])%mod;
		}
	}
	ll ans=0;
	For(i,1,n)for(int j=i+1;j<=n;j+=2)if(dp[i][j])ans=(ans+dp[i][j]*g[s[i-1]+s[n]-s[j]])%mod;
	cout<<(ans+mod)%mod<<endl;
}

Measured memory_bytes: 3072
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
using namespace std;

#define abs(N) ((N>0)?N:-1*N)
#define min(A,B) ((A>B)?B:A)
#define max(A,B) ((A<B)?B:A)
#define print(S) (cout << S)
#define println(S) (cout << S << endl)

int main(){
	char input[1202];
	cin.getline(input,sizeof(input));
	string str = string(input);


	int sz = str.size();
	for (int i = 0; i < sz; ++i) {
		if('A' <= str[i] && str[i] <= 'Z'){
			str[i] += 32;
		}else if('a' <= str[i] && str[i] <= 'z'){
			str[i] -= 32;
		}
	}

	cout << str << endl;;

	return 0;
}



Measured memory_bytes: 3144
n = int(input())
a = list(map(int, input().split()))
count = 0
while True:
    flag = 0
    for i in range(len(a)):
        if (a[i]%2==0):
            a[i]//=2
        else:
            flag += 1
    if (flag>0):
        break
    else:
        count += 1
print(count)

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

using namespace std;

int main(){
    int n;
    cin>>n;
    int ans=0;
    for(int i=0;i<n;i++){
        int hoge;
        cin>>hoge;
        ans+=hoge-1;
    }
    
    cout<<ans<<endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <cmath>
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<queue>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll inf = 1000000007;
ll a[100005];
ll x[505];
int main() {
	ll n, q;
	cin >> n >> q;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < q; i++) {
		cin >> x[i];
	}
	ll index = 0;
	while (index != q) {
		ll count = 0;
		int right = 0;
		ll sum = 0;
		for (int left = 0; left < n; left++) {
			
			while (right < n && sum + a[right] <= x[index]) {
				sum += a[right];
				right++;
			}

			count += right - left;
			if (left == right) {
				right++;
			}
			else {
				sum -= a[left];
			}
			
		}
		cout << count << endl;
		index++;
	}
	return 0;
}


Measured memory_bytes: 3876
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        n: i64,
        k: i64
    }
    println!("{}", n-k+1);
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define FORR(I,A,B) for(int I = ((B)-1); I >= (A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define REV(x) (reverse(x.begin(),x.end())) //reverse
int gcd(int a,int b){if(a<b)swap(a,b);if(a%b==0)return b;return gcd(b,a%b);}
int lcm(int a,int b){int c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=1e18+7;
const ll MOD=1e9+7;
#define pri(a) cout << (a) << endl

P m[51];
ll ans;
void dfs(ll n,ll k){
	if(k<=0)return;
	if(n==1){
		if(k==5)ans +=3ll; 
		else ans += k-1ll;
		return;
	}
	ll leveln = m[n].first + m[n].second;
	if(k==leveln){
		ans += m[n].second;
	}else if(k==(leveln/2ll+1ll)){
		ans += m[n-1].second+1ll;
		return;
	}else if(k < (leveln/2ll+1ll)){
		dfs(n-1,k-1);
	}else{
		ans += m[n-1].second+1ll;
		dfs(n-1,k-1ll-leveln/2ll);
	}
	return;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	ans = 0;
	ll n,x;
	cin >> n >> x;
	m[0] = {0ll,1ll};
	FOR(i,1,51)m[i]={m[i-1].first*2ll+2ll,m[i-1].second*2ll+1ll};//{b,p}
	dfs(n,x);
	cout << ans << endl;
}

Measured memory_bytes: 256
using System.Linq;
using static System.Console;
namespace Partition
{
    internal class Program
    {
        public static void Main(string[] args)
        {
            var n = int.Parse(ReadLine());
            var array = ReadLine().Split(' ').Select(int.Parse).ToArray();

            var part = Partition(array, 0, n - 1);
            for (var i = 0; i < part; i++) Write(array[i] + " ");
            Write("[" + array[part] + "]");
            for(var i = part+1;i<array.Length;i++) Write(" " + array[i]);
            WriteLine();
        }

        private static int Partition(int[] array, int begin, int end)
        {
            var x = array[end];
            var i = begin - 1;
            for (var j = begin; j < end; j++)
            {
                if (array[j] <= x)
                {
                    i++;
                    var tmp = array[i];
                    array[i] = array[j];
                    array[j] = tmp;
                }
            }

            var tmp2 = array[i + 1];
            array[i + 1] = array[end];
            array[end] = tmp2;
            return i + 1;
        }
    }
}


Measured memory_bytes: 28568
N, K = list(map(int, input().split()))
A = list(map(lambda x: int(x) - 1, input().split()))

v = [A[:]]
now = 0
for i in range(60):
    tmp = v[-1]
    v.append([tmp[x] for x in tmp])
    if K>>i & 1:
        now = v[i][now]
print(now + 1)

Measured memory_bytes: 115464
// Created by Nandu Vinodan
#include <bits/stdc++.h>

#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define rep(i,a,n) for(int i=a;i<=(n);++i)
#define repD(i,a,n) for(int i=a;i>=(n);--i)
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)
#define vi vector<int>
#define pi pair<int, int>
#define INF INT_MAX
#define _INF INT_MIN
#define TC 0 

using namespace std;
using ll = long long;

void testcase() {
    string s, t;
    cin >> s >> t;

    int n = s.size();
    int res = 0;
    rep (i, 0, n-1) {
        if (s[i] != t[i]) {
            res++;
        }
    }
    cout << res;
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    if (TC)
        cin>>t;
    while(t--) {
        testcase();
    }
    return 0;
}

Measured memory_bytes: 3828
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define len(s) (int)s.size()
#define pb push_back

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;
}
constexpr int mod = 1e9+7;
constexpr int inf = 3e18;

signed main(){
	int N;scanf("%lld",&N);
	int ans=0;
	REP(i,N+1){
		int j=N/i;
		ans+=i*j*(j+1)>>1;
	}
	printf("%lld\n",ans);
}


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

#define rep(i,N) for(int i=0;i<N;i++)
#define rep2(i,N) for(int i=1;i<=N;i++)
using namespace std;
long long  INF=1e18;
long long mod=1e9+7;


int main(){

    set<long long>mp;

    int N;
    cin>>N;
    rep(i,N){
        long long a;
        cin>>a;
        if(mp.find(a)==mp.end())mp.emplace(a);

        else{
            cout<<"NO"<<endl;
            return 0;
        }
    }
    cout<<"YES"<<endl;

    return 0;

}
/*


*/


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

using namespace std;

string poor(int A, int B, int C) {
	unordered_set<int> set = {A, B, C};
	return (set.size() == 2) ? "Yes" : "No";
}

int main() {
	int A, B, C;
	cin >> A >> B >> C;
	cout << poor(A, B, C);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
//C++11
#if __cplusplus == 201103L
#include <tuple>
#endif
 
using namespace std;
 
#define FOR(i,k,n) for(int i=(k); i<(int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
 
template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cout<<*i<<" "; cout<<endl; }
 
typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
vector<int> adj[50];
int power[50];
bool used[50];
int ans, rest, sum;
int N;
vector<int> per;
void dfs(int k_){
  if(k_ == N){
    ans = max(ans,  sum);
    return ;
  }
  int k = per[k_];
  //printf("%d:%d %d %d\n", k,sum , rest, ans);
  if(sum + rest <= ans){
    return;
  }
  bool usedtmp[50];
  memcpy(usedtmp, used, sizeof(used));
  int sumtmp = sum;
  int resttmp = rest;
  if(!used[k]){
    used[k] = true;
    sum += power[k];
    rest -= power[k];
    FORIT(it, adj[k])if(!used[*it]){
      rest -= power[*it];
      used[*it] = true;
    }
    dfs(k_ + 1);
    memcpy(used, usedtmp, sizeof(used));
    sum = sumtmp;
    rest = resttmp;
  }
  if(k != 0){
    if(!used[k])rest -= power[k];
    used[k] = true;
    dfs(k_ + 1);
  }
}
 
typedef pair<int, int> P;
int main(){
  while(cin>>N && N){
    ans = 0, rest = 0, sum = 0;
    REP(i, 50) adj[i].clear();
    memset(used, 0, sizeof(used));
    map<string, int> id;
    vector<string> adjstr[50];
    REP(i, N){
      string s; cin>>s; id[s] = i;
      cin>>power[i];
      rest += power[i];
      int k; cin>>k;
      while(k--){
        string str; cin>>str;
        adjstr[i].push_back(str);
      }
    }
    REP(i, N){
      REP(j, adjstr[i].size()){
        adj[i].push_back(id[adjstr[i][j]]);
      }
    }
    vector<P> ps(N-1);
    REP(i, N-1)ps[i] = P(-power[i+1], i+1);
    sort(ps.begin(), ps.end());
    per = vector<int>(N, 0);
    REP(i, N-1) per[i+1] = ps[i].second;
    dfs(0);
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 1384
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      char[] s = sc.next().toCharArray();
      char[] t = sc.next().toCharArray();
      int count = 0;
      for(int i = 0;i < 3;i++){
      	if(s[i]==t[i])count++;
      }
      System.out.println(count);
    }
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define tc int t; cin>>t; while(t--)
#define speed ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define mod 1000000007
#define pb push_back
#define vi vector<int>
#define vc vector<char>
#define eb emplace_back
#define pii pair<int,int>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define fo(i,x,n) for(int i=x;i<n;i++)
#define csb(x) __builtin_popcount(x)
#define tz(x) __builtin_ctz(x)
#define lsbp(x) __builtin_ffs(x)
#define msbp(x) __lg(x)
#define btoi(str,i) stoi(str,0,i)
#define ff first
#define ss second
const int inf=0x3f3f3f3f3f3f3f3f;

void zz(){
ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
}

int32_t main(){
zz();
int n;cin>>n;
int s=0;
for(int i=1;i<=n;i++){
	if(i%3!=0 && i%5!=0)s+=i;
}
cout<<s<<endl;return 0;

}

Measured memory_bytes: 3652
# 整数の入力
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())

l = [a,b,c,d,e]

max = max(l)
min = min(l)

if k >= max-min :
    print("Yay!")
else:
    print(":(")


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    ll n;
    cin >> n;
    vector <ll> a(n);
    vector <ll> b(n);
    for(int i=0;i<n;++i) cin >> a[i];
    for(int i=0;i<n;++i) {
        b[i]=a[i];
    }
    sort(b.begin(),b.end());
    for(int i=0;i<n;++i) {
        if(a[i]!=b[n-1]) cout << b[n-1] << endl;
        else cout << b[n-2] << endl;
    }
}

Measured memory_bytes: 4736
#include<stdio.h>
int main()
{
    long long int N=0,n=0,i=0,x=0;
    scanf("%lld", &N);
    
    for(i=1;i*(i+1)<N;i++){ //N=mq+r q=rより N=(m+1)q 
               
        if(N%i == 0){
            x = N/i;  //N=x*i
             
            if(N/(x-1) == N%(x-1))            
            n = n+(x-1);
        }
    }
    
    printf("%lld\n",n);
    return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod=1000000007;

int prime[100002]={};
int Er_N=100001;
void Er(){//Eratosthenes  1:PRIME  0:NOT PRIME
	for(int i = 2; i < Er_N; i++){
		prime[i] = 1;
	}
	int limit_Er_roop=sqrt(Er_N);
	for(int i = 2; i < limit_Er_roop; i++){
		if(prime[i]){
			for(int j = 0; i * (j + 2) < Er_N; j++){
				prime[i *(j + 2)] = 0;
			}
		}
	}
}


int main(){
	int n;
	cin>>n;
	Er();
	FOR(i,1,2){
		int c=0;
		FOR(j,0,11110){
			if(prime[j*5+i]&&n>0){
				cout<<j*5+i<<" ";
				n--;
			}
		}
		//cout<<c<<endl;
	}

    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string A,B,C;
	cin>>A>>B>>C;
	char c=A[0];
	A.erase(0,1);
	while(1)
	{
		if(c=='a')
		{
			if(A.size()==0){cout<<'A'<<endl;
			return 0;}
			c=A[0]; A.erase(0,1);
		}
		else if(c=='b')
		{
			if(B.size()==0){cout<<'B'<<endl;return 0;}
			c=B[0];B.erase(0,1);
		}
		else
		{
			if(C.size()==0){cout<<'C'<<endl;return 0;}
			c=C[0];C.erase(0,1);
		}
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); ++i)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define fi first
#define se second
#define INF 1000000009
#define LLINF 1000000000000000009LL
using ll = long long;

int main(){
  int n;
  cin>>n;
  set<string>st;
  rep(i,n){
    string s;
    cin>>s;
    st.insert(s);
  }
  cout<<st.size()<<endl;
  return(0);
}


Measured memory_bytes: 19248
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define mp make_pair
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define lli long long int
#define pii pair<int,int>
#define vii vector<pii>
#define pb push_back
#define eb emplace_back
#define em emplace
#define all(v)  v.begin(),v.end()
#define mod 1000000007
#define vi vector<int>
#define vl vector<lli>
#define vll vector<pair<lli,lli>>
#define pll pair<lli,lli>
#define vvi vector<vector<int>>
#define vvl vector<vector<lli>>
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#define tk(args...) take(args);
#define posLSB(X) __builtin_ctz(X)
#define num1bit(X) __builtin_popcount(X)
#define numlead0(X) __builtin_clz(X)
#define umreserve(X) X.reserve(32768); X.max_load_factor(0.25);
void err(istream_iterator<string> it) {} template<typename T, typename... Args> void err(istream_iterator<string> it, T a, Args... args) { cout << *it << " = " << a << "\n"; err(++it, args...);}
void take() {} template<typename T, typename... Args> void take( T & a, Args & ... args ) { cin>>a; take(args...); }
template<class T>
void printvec(vector<T> &a){
	for(T &x:a){
		cout<<x<<" ";
	}
	cout<<endl;
}
template<class T>
void printarr(T a[],lli n){
	for(lli i=0;i<n;i++){
		cout<<a[i]<<" ";
	}
	cout<<endl;
}
struct HASH{
  size_t operator()(const pair<int,int>&x)const{
    return (size_t) x.first * 37U + (size_t) x.second;
  }
};

#define endl "\n"

lli add(lli a, lli b) {
	a += b;
	if (a >= mod) a -= mod;
	return a;
}

lli mul(lli a, lli b) {
	return a * 1ll * b % mod;
}

inline bool setmin(lli &x, lli y) { return (y < x) ? x = y, 1 : 0; }
inline bool setmax(lli &x, lli y) { return (y > x) ? x = y, 1 : 0; }

lli power_mod(lli a,lli x){if(x==0) return 1;lli y=power_mod(a,x/2);lli ans=(y*y)%mod; if(x%2) ans=(ans*a)%mod;return ans;}
lli inv(lli a){return power_mod(a,mod-2);}
lli power(lli a, lli x){ if(x==0) return 1; lli y= power(a,x/2); lli ans=(y*y); if(x%2) ans*=a; return ans;}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin>>n;
	int k;
	cin>>k;
	vector<int> h(n);
	for(int i=0;i<n;i++)cin>>h[i];
	vector<int> dp(n,0);
	dp[0]=0;
	for(int i=1;i<n;i++){
		int ans=INT_MAX;
		for(int j=i-1;j>=max(0,i-k);j--){
			ans=min(ans,dp[j]+abs(h[i]-h[j]));
		}
		dp[i]=ans;
	}
	cout<<dp[n-1]<<endl;
}


Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
int main(){
    int N, K, min = 0, t=0;
    bool answer = true;
    cin >> N >> K;
    vector<char> D(K);
    for(int i = 0; i < K; i++){
        cin >> D[i];
    }
    for(int i = N;; i++){
        answer = true;
        for(int j = 0; j < to_string(i).size(); j++){
            for(int l = 0; l < K;l++){
                if(to_string(i).at(j) == D[l]){answer = false;}
            }
        }
        if(answer == true){
                min = i;
                break;
        }
    }
    cout << min << endl;
}

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

int main() {
	int n;
	while (cin >> n) {
		if (!(n % 39))puts("3C39");
		else printf("3C%02d\n", n % 39);
	}
}

Measured memory_bytes: 3128
def main():
    N = int(input().strip())

    n_color = [0 for i in range(8)]
    n_free = 0
    rates = list(map(int, input().strip().split()))
    for r in rates:
        if r >= 3200:
            n_free += 1
        else:
            n_color[r // 400] += 1

    n_less_3200 = sum(1 for _ in n_color
                      if _ > 0)

    n_min = max(1, n_less_3200)
    n_max = n_less_3200 + n_free

    print(n_min, n_max)

if __name__ == '__main__':
    main()


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

typedef long long int lli;
typedef unsigned long long int ulli;
typedef pair<int,int> pii;

#define ones(x) __builtin_popcount(x)
#define onesl(x) __builtin_popcountl(x)
#define onesll(x) __builtin_popcountll(x)

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define scn(n) scanf("%d",&n)
#define scnll(n) scanf("%lld",&n)
#define scn2(n,m) scanf("%d%d",&n,&m)
#define scn3(n,m,w) scanf("%d%d%d",&n,&m,&w)
#define scn2ll(n,m) scanf("%lld%lld",&n,&m)
#define atoz(v) v.begin(),v.end()
#define ratoz(v) v.rbegin(),v.rend()
#define Fill(a,v) memset(a,v,sizeof(a))
#define sz(v) v.size()
#define fi first
#define se second
#define inf 1e9
#define pi acos(-1.0)
#define sqr(x) x*x
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define ten(n) (int)1e##n
#define tenll(n) (lli)1e##n
#define mod 1000000007
#define FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

int Set(int N,int pos)
{
    return N=N | (1<<pos);
}
int reset(int N,int pos)
{
    return N = N & ~(1<<pos);
}
bool check(int N,int pos)
{
    return (bool)(N & (1<<pos));
}


inline int addmod(int x ,int y){return (x%mod + y%mod)%mod;}
inline int submod(int x ,int y){return (x%mod - y%mod + mod)%mod;}
inline int mulmod(int x ,int y){return (x%mod *1LL* y%mod)%mod;}
inline int nextSubMask(int i , int mask) {return (i-1)&mask;} /// returns next smallest submask

void we_r_done(){cout<<"NO"; exit(0);}

void debug(bool ok , string mssg)
{
    if(ok)return;
    cout<<mssg;
    exit(0);
}

using minHeap = priority_queue< int, vector< int >, greater< int > >;

int main()
{
    ///freopen("output.txt","w",stdout);
    ///freopen("input.txt","r",stdin);

    ///FastIO;

    string s;
    cin>>s;
    int n = s.size();

    stack<char>ase;

    for(int i=0; i<n; i++){
        if(ase.size()==0)ase.push(s[i]);
        else if(ase.top() != s[i])ase.pop();
        else ase.push(s[i]);
    }
    cout<<(n-ase.size());
    return 0;

}

///sin and cos expect input in radians not degrees. so use , sin(degrees * pi / 180)
///using bs = bitset<MX>; // how many distinct number can be form?


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define EPS (1e-10)
#define equals(a, b) (fabs((a)-(b)) < EPS)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<double> vd;
typedef pair<double,double> PD;
typedef pair<int,P> ed;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  int A,B,C,D;
  cin >> A >> B >> C >> D;
  rep(i,1000) {
    if(i%2==0) {
      C -= B;
      if(C<=0) {
        cout << "Yes" << endl;
        return 0;
      }
    } else {
      A -= D;
      if(A<=0) {
        cout << "No" << endl;
        return 0;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 3592
#include<iostream>
#include<cmath>
#include<string>
#include<map>
#include<stdio.h>
using namespace std;
int s[100005],a[100005],b[100005];
int main(){
	int n;
	cin >> n;
	int in[n+1][3];
	for(int i=1;i<=n;i++){
		cin >> in[i][1] >> in[i][2];
	}
	
	for(int i=2;i<=100000;i++){
		s[i]=1;
	}
	for(int i=2;i<(int)(sqrt(100000));i++){
		if(s[i]==1){
			for(int j=2*i;j<=100000;j+=i){
				s[j]=0;
//				cout << ' ';
			}
		}
	}
	for(int i=1;i<=100000;i++){
		if(s[i]&&s[(i+1)/2]){
			a[i]=1;
		}
	}
	for(int i=1;i<=100000;i++){
		b[i]=a[i]+b[i-1];
	}
//	for(int i=1;i<=20;i++){
//		cout << i << ':' << s[i] << ' ' << a[i] << ' ' << b[i] << endl;
//	}
	
	for(int i=1;i<=n;i++){
		int x=b[in[i][2]]-b[in[i][1]-1];
		cout << x << endl;
	}
	return 0;
}

Measured memory_bytes: 2944
def main():
    X, Y, A, B, C = tuple(map(int, input().split()))
    P = tuple(map(int, input().split()))
    Q = tuple(map(int, input().split()))
    R = tuple(map(int, input().split()))

    P = sorted(P, reverse=True)
    Q = sorted(Q, reverse=True)
    R = sorted(R, reverse=True)

    x = P[:X]
    y = Q[:Y]

    saikyo = sorted(x + y + R, reverse=True)
    print(sum(saikyo[:(X + Y)]))


if __name__ == '__main__':
    main()


Measured memory_bytes: 24512
#include <bits/stdc++.h>
using namespace std;
 
 
#define rp(i, k, n) for (int i = k; i < n; i++)
typedef long long ll;
typedef double ld;
 
ll mod = 1e9 + 7ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll inf = 1ll << 60;

int main(){
    int n, k;
    
    cin >> n >> k;

    if(k > (n-1) * (n-2) / 2){
        cout << -1 << endl;
        return 0;
    } else {
        int count = (n-1) * (n-2) / 2 - k;
        printf("%d\n", n-1 + count);
        rp(i, 2, n+1) printf("%d %d\n", 1, i);
        vector<vector<int>> check(110, vector<int>(110));
        rp(i, 2, n+1){
            rp(j, 3, n+1){
                if(count > 0 and check.at(i).at(j) == 0 and i != j){
                    printf("%d %d\n", i, j);
                    check.at(i).at(j) = 1;
                    check.at(j).at(i) = 1;
                    count --;
                }
            }
        }
        return 0;
    }
    
}


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

#define endl '\n'
#define int long long

int32_t main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

	int n; cin >> n;
	int last = 0;
	bool yes = false;
	for(int i = 0; i < n; i ++) {
		int x, y; cin >> x >> y;
		if(x == y) last ++;
		else last = 0;
		if(last == 3) yes = true;
	}
	if(yes) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 3468
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <list>
#include <utility>
#include <ctime>
#define INF 1000000000
#define LINF 9000000000000000000
#define mod 1000000007
 
#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=(n);i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define vector_rsort(x) sort(all(x));reverse(all(x))
#define array_rsort(x,n) sort(x,x+n);reverse(x,x+n);
#define pb push_back
#define mp make_pair
#define MOD(x) (x%(mod))

#define Yes cout<<"Yes"<<endl
#define YES cout<<"YES"<<endl
#define No cout<<"No"<<endl
#define NO cout<<"NO"<<endl
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;
 
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool debug=false;
/*---------------------------------------------------*/

int main(){
  string s,ss="FESTIVAL";
  cin>>s;
  rep(i,s.size()-ss.size())cout<<s[i];
  cout<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}

int main() {
  ll k; cin >> k;
  int n = 50;
  
  vector<ll> a(n);
  rep(i,n) a[i] = i;
  ll s = k / n;
  int r = k % n;
  rep(i,n) a[i] += s;
  rep(i,r)rep(j,n){
    if(i==j) a[j] += n;
    else a[j]--;
  }
  cout << n << endl;
  rep(i,n) cout << a[i] << " ";
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
N = int(input())

alph = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h',  'i', 'j']

def dfs(st, n, k):
    if n == N:
        print(st)
    else:
        for i in range(k+1):
            if i < k:
                dfs(st + alph[i], n+1, k)
            else:
                dfs(st + alph[i], n+1, k+1)

dfs("", 0, 0)

Measured memory_bytes: 4412
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<deque>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#include<regex>
#include<bitset>
#include<complex>
#include<chrono>
#include<random>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

ll gcd(ll n, ll m) {
	ll tmp;
	while (m!=0) {
		tmp = n % m;
		n = m;
		m = tmp;
	}
	return n;
}

ll lcm(ll n, ll m) {
	return abs(n * m) / gcd(n, m);//gl=xy
}
 
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;
}
 
using namespace std;
//ここから

void solve(){
  string s;
  ll k;
  cin>>s>>k;
  if(k<=s.size()){
    bool ng=false;
    char c;
    rep(i,k){
      if(s[i]!='1'){
        ng=true,c=s[i];
        break;
      }

    }
    if(!ng)cout<<1;
    else cout<<c;
  }
  else {
    rep(i,s.size()){
      if(s[i]!='1'){
        cout<<s[i];
        return;
      }
    }
  }
}

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


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

int main() {
  int m = 0, f = 0, r = 0, sum = 0;
  while (true) {
    cin >> m >> f >> r;
    sum = m + f;

    if (m == -1 && f == -1 && r == -1) {
      break;
    }
    
    if (m == -1 || f == -1) {
      cout << "F" << endl;
    } else if (sum >= 80) {
      cout << "A" << endl;
    } else if (sum >= 65) {
      cout << "B" << endl;
    } else if (sum >= 50) {
      cout << "C" << endl;
    } else if (sum < 30) {
      cout << "F" << endl;
    } else if (r >= 50) {
      cout << "C" << endl;
    } else {
      cout << "D" << endl;
    }

  }
  return 0;
}



Measured memory_bytes: 3120
#include <bits/stdc++.h>
#define ll long long
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define M 1000000007
using namespace std;
 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    string s;
    cin>>s;
    ll n = s.length() + 1;
    ll a[n] = {0},i;
    for(i=1;i<n;i++)
        if(s[i-1] == '<')
            a[i] = a[i-1]+1;

    for(i=n-2;i>=0;i--)
        if(s[i] == '>')
            a[i] = max(a[i], a[i+1]+1);
    ll sum = 0;
    for(i=0;i<n;i++)
        sum += a[i];
    cout<<sum;
    return 0;
}

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


int main() {
  int H,W;

  cin >> H >> W;

  string s[60];

  s[0] = ".";
  for(int i=0;i<W+1;i++){
    s[0]+=".";
  }  
  s[H+1] = ".";
  for(int i=0;i<W+1;i++){
    s[H+1]+=".";
  }

  for(int i=1;i<H+1;i++){
    cin >> s[i];
    s[i] = "." + s[i] + ".";
  }


  for(int i=1;i<H;i++){
    for(int j=1;j<W;j++){
      if(s[i][j]=='#'){
        if(!(s[i-1][j]=='#' || s[i][j-1]=='#' || s[i][j+1]=='#' || s[i+1][j]=='#')){
          cout << "No" << endl; return 0;
        }
      }
    }
  }

  cout << "Yes" << endl;

  

  
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(LL i=0;i<N;++i)
typedef long long int LL;

int main()
{
	LL a, b;
	in >> a >> b;
	out << std::abs(a - b) << std::endl;
}



Measured memory_bytes: 3108
s=gets.chomp.split("").map(&:to_i).sort
n=s.size
count0=0
s.each do |si|
  if si==0
    count0+=1
  else
    break
  end
end
count1=n-count0
if count0==count1
  puts n
else
  puts [count0,count1].min*2
end


Measured memory_bytes: 9328
#include<cstdio>

int main(){
	char a,b;
	scanf("%c %c", &a,&b);
	if(a=='H'&&b=='H') printf("H");
	if(a=='H'&&b=='D') printf("D");
	if(a=='D'&&b=='H') printf("D");
	if(a=='D'&&b=='D') printf("H");
	return 0;
}

Measured memory_bytes: 128
def s0():return input()
def s1():return input().split()
def s2(n):return [input() for x in range(n)]
def s3(n):return [input().split() for _ in range(n)]
def s4(n):return [[x for x in s] for s in s2(n)]
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]
def t3(n):return [tuple(int(x) for x in input().split()) for _ in range(n)]
def p0(b,yes="Yes",no="No"): print(yes if b else no)
# from sys import setrecursionlimit
# setrecursionlimit(1000000)
# from collections import Counter,deque,defaultdict
# import itertools
# import math
# import networkx as nx
# from bisect import bisect_left,bisect_right
# from heapq import heapify,heappush,heappop

x,y,a,b,c=n1()
P=n1()
Q=n1()
R=n1()

P.sort()
Q.sort()

A=P[-x:]+Q[-y:]+R

A.sort()
print(sum(A[-x-y:]))

Measured memory_bytes: 23088
#include <bits/stdc++.h>
 
#define all(x) (x).begin(), (x).end()
#define li long long
#define itn int
 
using namespace std;
 
inline int nxt(){
	int n;
	scanf("%d", &n);
	return n;
}

int main(){

	int w = nxt(), h = nxt();
	vector<int> p(w), q(h);
	for (int i = 0; i < w; i++) {
		p[i] = nxt();
	}
	for (int i = 0; i < h; i++) {
		q[i] = nxt();
	}

	sort(all(p));
	sort(all(q));

	long long ans = 0;
	int l = 0, r = 0;
	while (l < w && r < h) {
		if (p[l] < q[r]) {
			ans += 1ll * p[l] * (h + 1 - r);
			l++;
		} else {
			ans += 1ll * q[r] * (w + 1 - l);
			r++;
		}
	}
	while (l < w) {
		ans += p[l++];
	}
	while (r < h) {
		ans += q[r++];
	}

	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 1024
public class Main{
  public void run(java.io.InputStream in, java.io.PrintStream out){
    java.util.Scanner sc = new java.util.Scanner(in);
    int i, j;
    char[][] f;
    String s;

    f = new char[8][8];
    for(i = 0;i < 8;i++){
      s = sc.next();
      for(j = 0;j < 8;j++)f[i][j] = s.charAt(j);
    }

    roll(f);
    out.println("90");
    for(i = 0;i < 8;i++){
      for(j = 0;j < 8;j++)out.print(f[i][j]);
      out.println();
    }
    roll(f);
    out.println("180");
    for(i = 0;i < 8;i++){
      for(j = 0;j < 8;j++)out.print(f[i][j]);
      out.println();
    }
    roll(f);
    out.println("270");
    for(i = 0;i < 8;i++){
      for(j = 0;j < 8;j++)out.print(f[i][j]);
      out.println();
    }

    sc.close();
  }
  public static void main(String[] args){
    (new Main()).run(System.in, System.out);
  }
  private static void roll(char[][] f){
    int i, j;
    char tmp;

    for(i = 0;i < 4;i++)for(j = 0;j < 4;j++){
      tmp = f[i][j]; f[i][j] = f[7 - j][i]; f[7 - j][i] = f[7 - i][7 - j];
      f[7 - i][7 - j] = f[j][7 - i]; f[j][7 - i] = tmp;
    }
    return;
  }
}

Measured memory_bytes: 17144
import sys
input = sys.stdin.buffer.readline
import numpy as np

D = int(input())
c = np.array(input().split(), dtype=np.int32)
s = np.array([input().split() for _ in range(D)], dtype=np.int32)
last = np.zeros(26, dtype=np.int32)
# print(s)
# print(s.shape)

ans = []
point = 0
for i in range(D):
    down = (i+1-last)*c
    loss = down * 5 + s[i,:]
    idx = np.argmax(loss)
    ans.append(idx+1)
    point += s[i, idx] - down.sum()
    last[idx] = i+1
    # print(loss)

for i in range(D):
    print(ans[i])

Measured memory_bytes: 27460
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String input = br.readLine();
        StringBuilder output = new StringBuilder();

        for (int i = 0; i < input.length(); i++) {
            String word = input.substring(i,i+1);
            if(word.equals(word.toLowerCase())){
            word = word.toUpperCase();
            }else if(word.equals(word.toUpperCase())){
                word = word.toLowerCase();
            }
            output.append(word);
        }
        System.out.println(output);
            }

}

Measured memory_bytes: 24592
#include <stdio.h>
#include <vector>
#include <algorithm>
using namespace std;

int n,m;
int a[10];
int nums[10]={0,2,5,5,4,5,6,3,7,6};

int main()
{
    scanf("%d %d",&n,&m);
    for(int i=0;i<m;i++) scanf("%d",&a[i]);

    int dp[10050]={};
    for(int i=0;i<=n;i++) dp[i]=-1;
    dp[0]=0;
    for(int i=0;i<=n;i++)
    {
        if(dp[i]==-1) continue;
        for(int j=0;j<m;j++)
        {
            if(dp[i]+1>dp[i+nums[a[j]]]) dp[i+nums[a[j]]]=dp[i]+1;
        }    
    }
    // printf("%d\n",dp[n]);
    for(int i=0;i<m;i++) a[i]=-a[i];
    sort(a,a+m);
    for(int i=0;i<m;i++) a[i]=-a[i];

    for(int i=n;i>0;)
    {
        for(int j=0;j<m;j++)
        {
            if(i-nums[a[j]]<0)continue; 
            if(dp[i]==dp[i-nums[a[j]]]+1)
            {
                printf("%d",a[j]);
                i-=nums[a[j]];
                // fflush(stdout);
                break;
            }
        }
    }
    printf("\n");
}

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

char c[120000];
int f[120000];
int i,l;

int main()
{
	scanf("%s",c+1);
	l=strlen(c+1);
	f[0]=1;
	for (i=1;i<=l;i++)
		if (((f[i-5]) && (c[i-4]=='d') && (c[i-3]=='r') && (c[i-2]=='e') && (c[i-1]=='a') && (c[i]=='m')) ||
			((f[i-7]) && (c[i-6]=='d') && (c[i-5]=='r') && (c[i-4]=='e') && (c[i-3]=='a') && (c[i-2]=='m') && (c[i-1]=='e') && (c[i]=='r')) ||
			((f[i-5]) && (c[i-4]=='e') && (c[i-3]=='r') && (c[i-2]=='a') && (c[i-1]=='s') && (c[i]=='e')) ||
			((f[i-6]) && (c[i-5]=='e') && (c[i-4]=='r') && (c[i-3]=='a') && (c[i-2]=='s') && (c[i-1]=='e') && (c[i]=='r')))
			f[i]=1;
	if (f[l])
		puts("YES");
	else
		puts("NO");
	return 0;
}

Measured memory_bytes: 640