akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

#define FORE(i, a) for (auto i = a.begin(); i != a.end(); ++i)
#define REPU(i, a, b) for (int i = (a); i < (b); ++i)
#define REPD(i, a, b) for (int i = (a); i > (b); --i)
#define MEM(a, x) memset(a, x, sizeof(a))
#define ALL(a) a.begin(), a.end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())

vector<string> split(const string &s, char c) {
	vector<string> v; stringstream ss(s); string x;
	while (getline(ss, x, c)) v.push_back(x);
	return v;
}
#define DEBUG(args...) { vector<string> _v = split(#args, ','); err(_v.begin(), args); }
void err(vector<string>::iterator it) {}
template<typename T, typename... Args>
void err(vector<string>::iterator it, T a, Args... args) {
	cerr << "[DEBUG] " << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << '\n';
	err(++it, args...);
}

typedef long long ll;
const int MOD = 1000000007;

template<class T, class U> inline T tmin(T a, U b) { return (a < b) ? a : b; }
template<class T, class U> inline T tmax(T a, U b) { return (a > b) ? a : b; }
template<class T, class U> inline void amax(T &a, U b) { if (b > a) a = b; }
template<class T, class U> inline void amin(T &a, U b) { if (b < a) a = b; }
template<class T> T gcd(T a, T b) { while (b != 0) { T c = a; a = b; b = c % b; } return a; }

const int N = 200005;
ll dp[N];
int coef[N];
typedef unsigned long long ull;

inline ll f(int from, int to) {
	return dp[to] - dp[from - 1];
}

int main(int argc, char *argv[]) {
	ios_base::sync_with_stdio(false);

	int n, X; cin >> n >> X;
	vector<ll> xs(n + 1);
	dp[0] = 0;
	REPU(i, 1, n + 1) {
		cin >> xs[i];
		dp[i] = dp[i - 1] + xs[i];
	}
	coef[0] = 5;
	REPU(i, 1, N) coef[i] = 2*i + 3;
	ull ans = ULLONG_MAX;
	REPU(nk, 1, n + 1) {
		ull res = (nk + n)*1LL*X;
		int x = n/nk;
		int idx = n;
		REPU(i, 0, x) {
			res += coef[i]*f(idx - nk + 1, idx);
			idx -= nk;
		}
		res += coef[x]*1LL*dp[idx];
		amin(ans, res);
	}
	cout << ans << endl;


	return 0;
}


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

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define ALL(v) (v.begin(),v.end())
#define COUT(x) cout<<(x)<<endl

string divide[4] = {"dream", "dreamer", "erase", "eraser"};

int main(){
    string s;
    cin >> s;
    //sを逆順にする
    reverse(s.begin(),s.end());
    //sを逆順にしたのでdivideも逆順にする必要あり
    REP(i,4){reverse(divide[i].begin(),divide[i].end());}

    //切断
    bool flag = true;//出力のフラグ
    for(int i=0;i<s.size();){
        bool cut = false;
        for(int j=0;j<4;j++){
            string d = divide[j];
            if(s.substr(i,d.size())==d){
                cut = true;
                i += d.size();
            }
        }
        if(!cut){
            flag = false;
            break;
        }
    }
    if(flag)COUT("YES");
    else COUT("NO");
    return 0;
}    


Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,A,B;
string S;
string alpha = "abcdefghijklmnopqrstuvwxyz";
string ALPHA = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

ll dfs(vec used, ll num, ll nowk){
    //cout<<num<<' '<<nowk<<endl;
    if(nowk == 0){
        rep(i,3) if(used[i] == 0) return 0;
        return 1;
    }
    ll ans = 0;
    vec sgs = {7,5,3};
    rep(i,3){
        //cout<<num+nowk*sgs[i]<<' '<<n<<endl;
        if(num+nowk*sgs[i] <= N){
            vec temp(3,0);
            rep(j,3) temp[j] = used[j];
            temp[i] += 1;
            ans += dfs(temp,num+nowk*sgs[i],nowk/10);
        }
    }
    return ans;
}

int main(){
    cin>>N;
    vec used(3,0);
    ll keta = 0;
    M = N;
    while(M>0){
        ++keta;
        M /= 10;
    }
    ll ans = 0, tens = 10;
    reps(i,3,keta+1){
        tens *= 10;
        ans += dfs(used,0,tens);
    }
    cout<<ans<<endl;
}


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

int main() {
    int n, d, x;
    cin >> n >> d >> x;
    int a[n];
    for (int i = 0; i < n; i++) cin >> a[i];
    
    int ans = 0;
    for (int i = 0; i < n; i++) {
        ans++;
        int temp = a[i]+1;
        while (temp <= d) {
            ans++;
            temp += a[i];
        }
    }
    ans += x;
    cout << ans << endl;
}

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

using namespace std;

long gcd(long a, long b){
  
  while(a%b){
   long r=a%b;
   a=b;
   b=r; 
  }
  
 return b;
}


int main(){
  long n,m;
  cin >> n >> m;
  string s,t;
  cin >> s >> t;
  
  long g=gcd(n,m);
  long res=n/g*m;
  for(int k=0;k<g;k++) if(s[k*n/g]!=t[k*m/g]) res=-1;

  
  
  
  
  
  
 cout << res << endl;
  
}

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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define itn int
typedef long long ll;
typedef pair<int,int> p;


int main()
{
  while(true)
  {
    int n;
    cin >> n;
    if(n == 0) return 0;
    int nn = n;
    vector<string> v(n, "aaaa00");
    map<string, int> count;

    for (int i = 0; i < n; i++)
    {
      cin >> v[i];
    }

    // vector<string> vTmp = v;
    set<string> s(v.begin(), v.end());
    vector<string> tmp(s.begin(), s.end());

    for(string hoge : tmp)
    {
      count[hoge] = 0;
    }

    int maxv = 0;
    int secv = 0;
    string ans = "aa";

    // map<string, int> mp = count;
    // for (int i = 0; i < nn; i++){
    //   mp[v[i]]++;
    //   for(auto a : mp)
    //   {
    //     if(maxv < a.second)
    //     {
    //       maxv = a.second;
    //       ans = a.first;
    //     }
    //     if(a.first != ans && secv < a.second)
    //     {
    //       secv = a.second;
    //     }
    //   }
    // }
    // cout << maxv << endl;
    // cout << secv << endl;
    // if(maxv == secv)
    // {
    //   cout << "TIE" << endl;
    //   continue;
    // }

    maxv = 0;
    secv = 0;
    for (int i = 0; i < nn; i++){
      count[v[i]]++;
      // cout << count["B"] << endl;
      n--;
      for(auto a : count)
      {
        if(maxv < a.second)
        {
          maxv = a.second;
          ans = a.first;
        }
        if(a.first != ans && secv < a.second)
        {
          secv = a.second;
        }
      }
      // cout << maxv << endl;
      // cout << secv << endl;
      if (maxv > secv + n) {
        cout << ans << " " << nn - n << endl;
        break;
      }
    }
    if(maxv == secv)
    {
      cout << "TIE" << endl;
      continue;
    }

  }
  // for(auto i : count) cout << i.first << " : " << i.second << endl;
  // cout << "TIE" << endl;
}


Measured memory_bytes: 3188
import java.util.*;

public class Main {    
    public static void main(String[] args){        
        Scanner sc = new Scanner(System.in);                                
         
        StringBuilder sA = new StringBuilder(sc.nextLine());
        StringBuilder sB = new StringBuilder(sc.nextLine());
        StringBuilder sC = new StringBuilder(sc.nextLine());
        
        Map<Character,StringBuilder> map = new HashMap<>();
        
        map.put('a',sA);
        map.put('b',sB);
        map.put('c',sC);

        char ch = sA.charAt(0);
         
        while(true){                                  
           StringBuilder sb = map.get(ch);      
           if(sb.length() == 0){
                System.out.println(String.valueOf(ch).toUpperCase());   
                return;
           }           
           ch = sb.charAt(0);
           sb.deleteCharAt(0);                                                      
        }                        
        
    }            
}

Measured memory_bytes: 23124
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
   int a[105],n,ma,mi,i;ma=-1;mi=100000;
   cin>>n;
   for(i=1;i<=n;i++)
   {
       cin>>a[i];
       if(a[i]>ma)
        ma=a[i];
       if(a[i]<mi)
        mi=a[i];
   }
   cout<<ma-mi;


        return 0;
}


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

using namespace std;
int N;
vector<long long int> a;
int main(void){

	cin >> N;
	long long int tmp;
	for (int i = 0; i < N; i++) {
		cin >> tmp; a.push_back(tmp);
	}

	long long int count = 0;
	for (int i = 0; i < N; i++) {
		for (;;) {
			if (a[i] % 2 == 0) { a[i] /= 2; count++; }
			else { break; }
		}
	}
	cout << count << endl;
	//system("pause");
	return 0;
}

Measured memory_bytes: 512
/*         
               JAI SHREE RAM    */
 
 
 
#include<bits/stdc++.h>
using namespace std;
 
#define ff              first
#define ss              second
#define pb              push_back
#define int             long long
#define mp              make_pair
#define pr              pair<long long,long long>
#define vr              vector<long long>
#define mod            1000000007
#define mod2            998244353
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define ll              long long
#define ld	            long double
#define w(x)            int x; cin>>x; while(x--)
#define fill(a,b)       memset(a, b, sizeof(a))
#define ios ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
 

const int N = 1000001;
  vector <int> a;
int power(int x, unsigned int y) 
{ 
    int res = 1;     
   
    while (y > 0) 
    { 
        
        if (y & 1) 
            res = res*x; 
        y = y>>1; // y = y/2 
        x = x*x;  // Change x to x^2 
    } 
    return res; 
}
 
long long maxSubArray(long long a[], int sze)
{
   long long max_so_far = 0, max_ending = 0;
   for (int i = 0; i < sze; i++)
   {
       max_ending = max_ending + a[i];
       if (max_ending < 0)
           max_ending = 0;
       else if (max_so_far < max_ending)
           max_so_far = max_ending;
   }
   return max_so_far;
}
 
 
 
ll factorialNumInverse[N + 1]; 
ll naturalNumInverse[N + 1]; 
ll fact[N + 1]; 
  
 
void InverseofNumber(ll p) 
{ 
    naturalNumInverse[0] = naturalNumInverse[1] = 1; 
    for (int i = 2; i <= N; i++) 
        naturalNumInverse[i] = naturalNumInverse[p % i] * (p - p / i) % p; 
} 
void InverseofFactorial(ll p) 
{ 
    factorialNumInverse[0] = factorialNumInverse[1] = 1; 
  
    
    for (int i = 2; i <= N; i++) 
        factorialNumInverse[i] = (naturalNumInverse[i] * factorialNumInverse[i - 1]) % p; 
} 
void factorial(ll p) 
{ 
    fact[0] = 1; 
  
    // precompute factorials 
    for (int i = 1; i <= N; i++) { 
        fact[i] = (fact[i - 1] * i) % p; 
    } 
} 
  
ll Binomial(ll N, ll R, ll p) 
{ 
    // n C r = n!*inverse(r!)*inverse((n-r)!) 
    ll ans = ((fact[N] * factorialNumInverse[R]) 
              % p * factorialNumInverse[N - R]) 
             % p; 
    return ans; 
} 

 
void solve()
{
   int n;
   cin>>n;
   int ans=0;
   
    for(int i=1;i<n;i++)
    {
        for(int j=1;j*i<n;j++)
        {
            if(j*i<n)
            ans++;
        }
    }
    cout<<ans<<"\n";
}
 
int32_t main()
{ 
      
      ios;
      int test;
     
      
      test=1;
   //  cin>>test;
    
      while(test--)
      {
          solve();
      }
       
    
    return 0;
	}

Measured memory_bytes: 3672
#include<stdio.h>

int main(){
	int MA[4],MB;
	int A,B;
	int RH,RB;
	while(scanf("%d",MA)!=EOF){
		RH=RB=0;
		for(A=1;A<4;A++)
			scanf("%d",MA+A);
		for(A=0;A<4;A++){
			scanf("%d",&MB);
			for(B=0;B<4;B++)
				if(MA[B]==MB){
					if(A==B)
						RH++;
					else
						RB++;
				}
		}
		printf("%d %d\n",RH,RB);
	}
	return 0;
}

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

typedef long long int ll;
#define pb push_back

int main()
{
   ll a[3];

   ll i;
   for(i=0;i<3;i++)
    cin>>a[i];

    sort(a,a+3);

    cout<<a[0]+a[1];
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdlib>  
#include <algorithm>
#include <string>
using namespace std;
 
int main() {
   string a;
   cin >> a;
   if(a == "SUN") cout<<"7";
   else if(a == "MON") cout<<"6";
   else if(a == "TUE") cout << "5";
   else if (a == "WED") cout << "4";
  else if ( a == "THU") cout <<"3";
  else if ( a == "FRI") cout <<"2";
  else cout<<"1";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = int(A); I < int(B); ++I)
#define FORR(I,A,B) for(ll I = int((B)-1); I >= int(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 POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll 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 out(a) cout<<fixed<<setprecision((a))


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

	ll N,M;
	cin >> N >> M;
	vector<ll> X(N+5,0);
	FOR(i,0,M){
		ll a;
		cin >> a;
		X[a]=-1;
	}
	X[0] = 1;
	if(X[1]!=-1)X[1] = 1;
	FOR(i,2,N+1){
		if(X[i]==-1)continue;
		ll a = (X[i-1]!=-1)*X[i-1] + (X[i-2]!=-1)*X[i-2];
		if(X[i]!=-1)X[i] = a%MOD;
	}
	cout << X[N] << endl;
}


Measured memory_bytes: 1024
void solve(){
}
void main(){
	string s = instr();
	writeln(s[0].to!string ~ (s.length-2).to!string ~ s[$-1].to!string);
}
     
import std.stdio, std.conv, std.algorithm, std.numeric, std.string, std.math, std.range;
const long mod = 10^^9+7;
alias instr = () => readln().chomp();
T inelm(T= int)(){ return to!(T)( readln().chomp() ); }
T[] inary(T = int)(){ return readln().chomp().split().to!(T[])(); }



Measured memory_bytes: 2852
#include<iostream>
using namespace std;
int main(){
    int x, y, n;
    n = 1;
    
    while (n <= 3000) {
        cin >> x >> y;
        if (x == 0 && y == 0) break;
        else if (x <= y) cout << x << " " << y << endl;
        else cout << y << " " << x << endl;
        n += 1;
        x = 0;
        y = 0;
    }
    
    return 0;
    
}


Measured memory_bytes: 3056
n = int(input())
g = [[1] * n for _ in range(n)]
for i in range(n-1 if n % 2 else n):
    j = n-i-2 if n % 2 else n-i-1
    g[i][j], g[j][i] = 0, 0
print((n*(n-1)//2)-n//2)
for i in range(n):
    for j in range(i+1, n):
        if g[i][j]: print(i+1, j+1)


Measured memory_bytes: 3700
#include <iostream>
#include <vector>
#include <sstream>

using namespace std;

vector<string> split(const string &s, char delim) {
    vector<string> elems;
    stringstream ss(s);
    string item;
    while (getline(ss, item, delim)) {
        if (!item.empty()) {
            elems.push_back(item);
        }
    }
    return elems;
}

int main() {
    string str;
    getline(cin, str);
    vector<string> splited = split(str, ' ');

    int desk = stoi(splited[0].c_str());
    int chair = stoi(splited[1].c_str());
    cout << desk * chair << endl;
    return 0;
}

Measured memory_bytes: 3172
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<n;++i)
#define rep2(i,a,b) for (ll i=a;i<b;++i)
const ll MOD=1e9+7;
const ll INF=1e9;
const ll IINF=1e18;
const double EPS=1e-8;
const double pi=acos(-1);

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;
}

int main(){
    ll N;
    cin >> N;
    vector<ll> a(2),b(2),c(2);
    rep(i,2) cin >> a[i] >> b[i] >> c[i];
    ll ans=N;
    rep(i,2){
        int s=i%2,t=(s+1)%2;
        ll money=ans;
        if (a[s]<a[t]){
            for (ll j=0;a[s]*j<=ans;++j){
                if (b[s]<b[t]){
                    if (c[s]<c[t]){
                        for (ll k=0;b[s]*k<=ans-a[s]*j;++k){
                            ll l=(ans-a[s]*j-b[s]*k)/c[s];
                            chmax(money,ans-a[s]*j-b[s]*k-c[s]*l+a[t]*j+b[t]*k+c[t]*l);
                        }
                    }
                    else {
                        ll k=(ans-a[s]*j)/b[s],l=0;
                        chmax(money,ans-a[s]*j-b[s]*k-c[s]*l+a[t]*j+b[t]*k+c[t]*l);
                    }
                }
                else {
                    ll k=0;
                    if (c[s]<c[t]){
                        ll l=(ans-a[s]*j)/c[s];
                        chmax(money,ans-a[s]*j-b[s]*k-c[s]*l+a[t]*j+b[t]*k+c[t]*l);
                    }
                    else {
                        ll l=0;
                        chmax(money,ans-a[s]*j-b[s]*k-c[s]*l+a[t]*j+b[t]*k+c[t]*l);
                    }
                }
            }
        }
        else {
            ll j=0;
            if (b[s]<b[t]){
                if (c[s]<c[t]){
                    for (ll k=0;b[s]*k<=ans-a[s]*j;++k){
                        ll l=(ans-a[s]*j-b[s]*k)/c[s];
                        chmax(money,ans-a[s]*j-b[s]*k-c[s]*l+a[t]*j+b[t]*k+c[t]*l);
                    }
                }
                else {
                    ll k=(ans-a[s]*j)/b[s],l=0;
                    chmax(money,ans-a[s]*j-b[s]*k-c[s]*l+a[t]*j+b[t]*k+c[t]*l);
                }
            }
            else {
                ll k=0;
                if (c[s]<c[t]){
                    ll l=(ans-a[s]*j)/c[s];
                    chmax(money,ans-a[s]*j-b[s]*k-c[s]*l+a[t]*j+b[t]*k+c[t]*l);
                }
                else {
                    ll l=0;
                    chmax(money,ans-a[s]*j-b[s]*k-c[s]*l+a[t]*j+b[t]*k+c[t]*l);
                }
            }
        }
        chmax(ans,money);
    }   
    cout << ans << endl;
}

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

using namespace std;

int main(){
    int n;
    scanf("%d", &n);

    vector<int> fibo(n + 1);
    fibo[0] = 1;
    fibo[1] = 1;
    for(int i = 2; i <= n; i++){
        fibo[i] = fibo[i - 2] + fibo[i - 1];
    }
    cout << fibo[n] << endl;
    return 0;
}


Measured memory_bytes: 3228
#include <iostream>
#include <cstdint>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int, int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<ll>> vvll;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rrep(i, n) for (ll i = 1; i <= (n); ++i)
#define irep(it, stl) for (auto it = stl.begin(); it != stl.end(); it++)
#define drep(i, n) for (ll i = (n)-1; i >= 0; --i)
#define mes(a) cout << (a) << endl
#define dmes(a, b) cout << (a) << " " << (b) << endl
#define re0 return 0
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define rSort(a) sort(a.rbegin(), a.rend())
#define Rev(a) reverse(a.begin(), a.end())
#define MATHPI acos(-1)
#define itn int
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
struct io
{
    io()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
};
const int INF = INT_MAX;
const ll LLINF = 1LL << 60;
const ll MOD = 1000000007;
const double EPS = 1e-19;


signed main() {
    ll x, y, a, b, c;
    cin >> x >> y >> a >> b >> c;
    
    ll sum = 0;
    
    vll rap(a), gap(b), cap(c);
    rep(i, a) {
        cin >> rap[i];
    }
    rep(i, b) {
        cin >> gap[i];
    }
    rep(i, c) {
        cin >> cap[i];
    }
    
    rSort(rap);
    rSort(gap);
    rSort(cap);
    
    
    vll pap(x+y);
    
    rep(i, x) {
        pap[i] = rap[i];
    }
    rep(i, y) {
        pap[x+i] = gap[i];
    }
    Sort(pap);
    
    
    
    
    rep(i, x+y) {
        if (i < c && pap[i] < cap[i]) {
            pap[i] = cap[i];
        }
        
        sum += pap[i];
    }
    
    mes(sum);
    
        
    
    
    
    
    
    
    
    
}

Measured memory_bytes: 6868
from collections import deque
n, m = map(int, input().split())
connect = [[] for _ in range(n)]
for _ in range(m):
    a, b = map(lambda x: int(x)-1, input().split())
    connect[a].append(b)
    connect[b].append(a)
color = [-1]*n
color[0] = 0
next = deque([0])
Yes = True
while next:
    now = next.popleft()
    C = (color[now]+1)%2
    for a in connect[now]:
        if color[a] != -1:
            if color[a] != C:
                Yes = False
            continue
        color[a] = C
        next.append(a)
if Yes:
    s=sum(color)
    print(s*(n-s)-m)
else:
    print(n*(n-1)//2-m)

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

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

    ll ans = N==M ? 2 : 1;
    while(true){
        ans *= (N*M)%1000000007;
        ans %= 1000000007;
        N--;
        M--;
        if(min(N, M) == 0){
            if(max(N, M) > 1) ans = 0;
            break;
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 3608
#include <stdio.h>
#include <string.h>

char visited[1000001];

int str2num(const char* str,int len) {
	int result,i;
	result=0;
	for(i=0;i<len;i++)result=result*10+str[i]-'0';
	return result;
}

int getnextnum(int num) {
	char thenumber[100];
	int length;
	int max;
	int i;
	sprintf(thenumber,"%d",num);
	length=strlen(thenumber);
	max=0;
	for(i=1;i<length;i++) {
		int temp;
		temp=str2num(thenumber,i)*str2num(&thenumber[i],length-i);
		if(max<temp)max=temp;
	}
	return max;
}

int main(void) {
	int Q,i;
	int N;
	int count;
	scanf("%d",&Q);
	for(i=0;i<Q;i++) {
		scanf("%d",&N);
		memset(visited,0,sizeof(visited));
		for(count=0;N>=10;count++) {
			if(visited[N]){count=-1;break;}
			visited[N]=1;
			N=getnextnum(N);
		}
		printf("%d\n",count);
	}
	return 0;
}

Measured memory_bytes: 1592
#include <stdio.h>
#include <iostream>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <sstream>
#include <string>
#include <map>
using namespace std;

//ABC136 B
int main() {
	int n;
	cin >> n;
	int ans = 0;

	for (int i=1; i<=n; i++) {
		string str;
		str = to_string(i);
		if (str.length()%2==1) {
			ans += 1;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
import sys
n, m = map(int, input().split())
num = [-1 for i in range(n)]
for i in range(m):
    s, c = map(int, input().split())
    s -= 1
    if num[s] != -1 and c != num[s]:
        print(-1)
        sys.exit()
    num[s] = c
if num[0] == 0 and n == 1:
    print(0)
elif num[0] == 0:
    print(-1)
elif n == 1 and num[0] == -1:
    print(0)
else:
    num[0] = max(num[0], 1)
    for i in range(1, n):
        num[i] = max(num[i], 0)
    print(''.join([str(i) for i in num]))

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

// macro
#define rep(i,n) for(i=0;i<n;i++)
#define ll long long
#define all(v) v.begin(), v.end()

// code starts
int main()
{
  int d;
  cin >> d;
  vector<int> c(26);
  int i,j;
  rep(i,26) cin >> c[i];
  vector<vector<int>> s(d,vector<int>(26));
  rep(i,d)rep(j,26) cin >> s[i][j]; 
  vector<int> t(d);
  rep(i,d)
  {
    t[i] = rand()%26;
  }
  vector<int> las(26,0);
  vector<int> rowans(26,0);
  int sums = 0;
  int kans = 0;
  rep(i,d)
  {
    las[t[i]] = i+1;
    sums += s[i][t[i]];
    kans += s[i][t[i]];
    rep(j,26)
    {
      kans -= c[j]*(i+1-las[j]);
      rowans[j] += c[j]*(i+1-las[j]);
    }
  }
  //int m = 100000;
  double tmp = 100000000.0;
  double alpha = 0.9999;
  int inds = 0;
  while(tmp >= 0.01)
  {
    inds++;
    int tans = 0;
    int tod,q;
    tod = rand()%d;
    q = rand()%26;
    int bq = t[tod];
    sums -= s[tod][bq];
    sums += s[tod][q];
    int browq = rowans[bq];
    int rowq = rowans[q];
    t[tod] = q; //change
    rowans[q] = 0;
    rowans[bq] = 0;
    rep(j,26)
    {
      las[j] = 0;
    }
    rep(j,d)
    {
      las[t[j]] = j+1;
      rowans[bq] += c[bq]*(j+1-las[bq]);
      rowans[q] += c[q]*(j+1-las[q]);
    }
    tans = sums;
    rep(j,26) tans -= rowans[j];
    double prob = ((double)rand())/32767.0;
    int dis = kans-tans;
    if(tans >= kans)
    {
      kans = tans;
    }
    else if(prob <= exp(-(double)dis/(double)tmp))
    {
      kans = tans;
      //if(inds%1000 == 0)cout << kans << ' ' << tmp << endl;
    }
    else
    {
      rowans[bq] = browq;
      rowans[q] = rowq;
      t[tod] = bq;
    }
    tmp *= alpha;
    //cout << tmp << endl;
  }
  rep(i,d)
  {
    cout << t[i]+1 << "\n";
  }
}


Measured memory_bytes: 4384
#include<bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long int ll;

const ll logx=30;
const ll N=2e5+5;
const ll M=3e5+5;
const ll mod=1e9+7;
const ll INF=1e18+5;
const double PI = 3.14159265358979323846;

#define ints(n) scanf("%d",&n)
#define intp(n) printf("%d\n",n)
#define longs(n) scanf("%intd",&n)
#define longp(n) printf("%intd\n",n)

inline ll mul(ll a, ll b){ return (a * 1ll * b) % mod; }
inline ll sub(ll a, ll b){ ll c = a - b; if(c < 0) c += mod; return c; }
inline ll add(ll a, ll b){ ll c = a + b; if(c > mod) c -= mod; return c; }

#define f first
#define s second
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define mp(x,y) make_pair(x,y)
#define GCD(a,b) __gcd((a),(b))
#define all(v) v.begin(),v.end()
#define bits(x) __builtin_popcount(x)
#define LCM(a,b) ((a)*(b))/GCD((a),(b))
#define ms(dp,val) memset(dp,val,sizeof(dp))
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
template<typename T> T power(T x,T y,ll m){T ans=1;while(y>0){if(y&1LL) ans=(ans*x)%m;y>>=1ll;x=(x*x)%m;}return ans%m;}

#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl

int main()
{
  string s;
  cin>>s;
  ll n=s.length();
  for(ll i=0;i<n-1;i++)
  {
    if(s[i]==s[i+1]){cout<<"Bad"<<endl;exit(0);}
  }
  cout<<"Good"<<endl;
}


Measured memory_bytes: 256
# N
# S

n = gets.chomp.to_i
s = gets.chomp

l = []
r = []

l[0] = 0
r[n - 1] = 0

aux = 0

for i in (0...(n-1)) do
  if s[i] == "W"
    aux += 1
  end

  l[i + 1] = aux
end

aux = 0

for i in (1...n).reverse_each.to_a do
  if s[i] == "E"
    aux += 1
  end

  r[i - 1] = aux
end

sum = l.zip(r).map do |i, j|
  i + j
end

puts sum.min


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

using namespace std;  

int mp[205][205],r[205],n,m,R,ans=100000000;  

int main(){  
    cin>>n>>m>>R;  
    for( int i = 1; i <= R; i++ ) scanf("%d", &r[i]);  
    memset(mp,63,sizeof(mp));  
    for( int i = 1,u,v,w; i <= m; i++ ){  
        scanf("%d%d%d", &u, &v, &w);  
        mp[u][v] = mp[v][u] = w;  
    }  
    for( int i = 1; i <= n; i++ ) mp[i][i] = 0;  
    for( int k = 1; k <= n; k++ )  
        for( int i = 1; i <= n; i++ )  
            for( int j = 1; j <= n; j++ )  
                mp[i][j] = min( mp[i][j], mp[i][k]+mp[k][j] );  
    sort( r+1, r+R+1 );  
    do{  
        int res = 0;  
        for( int i = 2; i <= R; i++ ) res += mp[r[i-1]][r[i]];  
        ans = min( ans, res );  
    }while( next_permutation( r+1, r+R+1 ) );  
    printf("%d\n", ans);  
    return 0;  
}  


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, n) for (int i = 1; i <= (int)(n); i++)
using ll = long long;
using P = pair<ll,ll>;
#define pb push_back
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; }

/*
 string -> int : stoi(S);
 int -> string : to_string(N);
 Sのn文字以降をm文字取り出す : S.substr(n,m)
cout << fixed << setprecision(2) << 3.14 << endl; //3.1

 int: -2,147,483,648 ～ 2,147,483,647 (2×10^9)
 ll: -9,223,372,036,854,775,808 ~ 9,223,372,036,854,775,807 (9×10^18)

*/

int main() {

  ll n, m, count=0, ans=0;
  string s,t;
  char d;
 
  cin >> s;
  int len = s.length();
  d= s[len-1];
  if(d=='3') t="bon";
  else if(d=='0'||d=='1'||d=='6'||d=='8') t="pon";
  else t="hon";

  cout << t << endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rng(i, a, b) for (int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define gnr(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define per(i, b) gnr(i, 0, b)
#define bg begin()
#define ed end()
#define all(x) x.bg, x.ed
#define vi vector<int>
template <class t, class u>
bool chmax(t &a, u b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class t, class u>
bool chmin(t &a, u b)
{
    if (b < a)
    {
        a = b;
        return true;
    }
    return false;
}

int main()
{
    int n;
    cin >> n;
    vi v;
    rep(i, n)
    {
        int s;
        cin >> s;
        v.push_back(s);
    }
    sort(all(v));
    int sum = std::accumulate(all(v), ll(0));
    if (sum % 10 == 0)
    {
        for (size_t i = 0; i < n; i++)
        {
            if (v[i] % 10 != 0)
            {
                sum -= v[i];
                break;
            }
            /* code */
        }
        if (sum % 10 == 0)
        {
            cout << 0 << endl;
        }
        else
        {
            cout << sum << endl;
        }
    }
    else
    {
        cout << sum << endl;
    }
    return 0;
}

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

int main(){
    int n;
    cin >>n;
    if(n>=21){
        puts("Yes");
        return 0;
    }
    if(n==4||n==7||n==8||n==11||n==12||n==14||n==15||n==16||n==18||n==19||n==20){
        puts("Yes");
        return 0;
    }
    puts("No");
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;

class Program
{
    public void Proc()
    {
        Reader.IsDebug = false;
        int[] inpt = Reader.ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray();
        int w = inpt[0];
        int h = inpt[1];
        int cnt = inpt[2];

        Dictionary<int, Dictionary<int, bool>> isBlack = new Dictionary<int,Dictionary<int, bool>>();
        for (int i = 0; i <= h; i++)
        {
            isBlack.Add(i, new Dictionary<int,bool>());
            for (int j = 0; j <= w; j++)
            {
                isBlack[i].Add(j, false);
            }
        }
        for (int i = 0; i < cnt; i++)
        {
            inpt = Reader.ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray();
            int x = inpt[0];
            int y = inpt[1];
            int tp = inpt[2];
            if (tp == 1) {
                isBlack.ToList().ForEach(a => a.Value.Where(b => b.Key < x).ToList().ForEach(b => isBlack[a.Key][b.Key] = true));
            }
            else if (tp == 2)
            {
                isBlack.ToList().ForEach(a => a.Value.Where(b => b.Key >= x).ToList().ForEach(b => isBlack[a.Key][b.Key] = true));

            }
            else if (tp == 3)
            {
                isBlack.Where(a => a.Key < y).ToList().ForEach(a => a.Value.ToList().ForEach(b => isBlack[a.Key][b.Key] = true));
            }
            else
            {
                isBlack.Where(a => a.Key >= y).ToList().ForEach(a => a.Value.ToList().ForEach(b => isBlack[a.Key][b.Key] = true));
            }

        }

        Console.WriteLine(isBlack.Where(a => a.Key != h).Sum(a => a.Value.Count(b => b.Key != w && !b.Value)));

    
    }



    public class Reader
    {
        public static bool IsDebug = true;
        private static String PlainInput = @"

10 10 5
1 6 1
4 1 3
6 9 4
9 4 2
3 1 3


";
        private static System.IO.StringReader Sr = null;
        public static string ReadLine()
        {
            if (IsDebug)
            {
                if (Sr == null)
                {
                    Sr = new System.IO.StringReader(PlainInput.Trim());
                }
                return Sr.ReadLine();
            }
            else
            {
                return Console.ReadLine();
            }
        }
    }
    static void Main()
    {
        Program prg = new Program();
        prg.Proc();
    }
}

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

struct Edge{
  int to,id;
};
vector<vector<Edge>>g,id;
vector<int>ans;
void dfs(int v,int c=-1,int p=-1){
  int k=1;
  for(auto ng:g[v]){
    if(ng.to==p) continue;
    if(k==c) k++;
    ans[ng.id]=k;
    dfs(ng.to,k,v);
    k++;
  }
}
int main(){
  int n,a,b;
  cin>>n;
  g.resize(n);
  for(int i=0;i<n-1;i++){
    cin>>a>>b;
    a--;
    b--;
    g[a].push_back((Edge){b,i});
    g[b].push_back((Edge){a,i});
  }
  ans.resize(n-1);
  dfs(0,-1,-1);
  int mx = 0;
  for(int i = 0; i < n; i++){
        mx = max(mx, (int)g[i].size());
  }
  cout << mx << endl;
  for(int i = 0; i < n - 1; i++){
        cout << ans[i] << endl;
  } 
  return 0;
}

Measured memory_bytes: 11000
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define tmax(a,b,c) max(a,max(b,c))
#define tmin(a,b,c) min(a,min(b,c))
#define pb push_back
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
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;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    vector<int> d(n);
    rep(i,n) cin >> d[i];
    sort(all(d));
    int l = d[n/2-1];
    int r = d[n/2];
//    rep(i,n) cout << d[i] << endl;
    cout << max(r-l,0) << endl;
}


Measured memory_bytes: 640
#include <stdio.h>
#include <iostream>
using namespace std;

class Node {
private:
	int id;
	Node *parent;
	Node *child_l;
	Node *child_r;
public:
	Node(int id){ this->id = id; parent = NULL; child_l = NULL; child_r = NULL;}
	void setChildl(Node *nl);
	void setChildr(Node *nr);
	void setParent(Node *np){ parent = np; }
	Node *searchNode(int id);
	Node *searchRight();
	int getId(){ return id; }
	Node *getParent(){ return parent; }
	Node *getChildl(){ return child_l; }
	Node *getChildr(){ return child_r; }
};

void Node::setChildl(Node *nl)
{
	child_l = nl;
	if (child_l != NULL) child_l->setParent(this);
}

void Node::setChildr(Node *nr)
{
	child_r = nr;
	if (child_r != NULL) child_r->setParent(this);
}

Node *Node::searchNode(int id)
{
	if (this->id == id) return this;
	if (child_l != NULL) {
		Node *sl = child_l->searchNode(id);
		if (sl != NULL) return sl;
	}
	if (child_r != NULL) {
		Node *sr = child_r->searchNode(id);
		if (sr != NULL) return sr;
	}
	return NULL;
};

Node *Node::searchRight()
{
	if (child_r == NULL) return this;
	return child_r->searchRight();
}

class BinaryTree {
private:
	Node *preroot;
	Node *root;
	char flag;
public:
	BinaryTree(){ preroot = NULL; root = NULL; flag = 'l'; }
	void setNodePreorder(int id);
	void setNodeInorder(int id);
	void walkPostorder();
	void walkPostorder(Node *node);
};

void BinaryTree::setNodePreorder(int id)
{
	if (preroot == NULL) {
		preroot = new Node(id);
		root = new Node(id);
		return;
	}

	Node *node = preroot;
	Node *nr;
	while ((nr = node->getChildr()) != NULL) node = nr;
	node->setChildr(new Node(id));
	return;
}

void BinaryTree::setNodeInorder(int id)
{
	if (root == NULL) {
		cout << "!!!" << endl;
		return;
	}

	if (id == root->getId()) {
		flag = 'r';
		return;
	}

	if (flag == 'l' && root->getChildl() == NULL) {
		root->setChildl(new Node(id));
		return;
	}

	if (flag == 'r' && root->getChildr() == NULL) {
		root->setChildr(new Node(id));
		return;
	}

	Node *new_subroot;
	if (flag == 'l') new_subroot = root->getChildl();
	else new_subroot = root->getChildr();
	Node *pre_child = preroot->searchNode(id);
	Node *new_child = NULL;
	while (pre_child != NULL) {
		new_child = new_subroot->searchNode(pre_child->getId());
		if (new_child != NULL) break;
		pre_child = pre_child->getChildr();
	}
	Node *node = new Node(id);
	if (new_child == NULL) {
		(new_subroot->searchRight())->setChildr(node);
	}
	else {
		Node *new_parent = new_child->getParent();
		if (new_parent->getChildl() == new_child) new_parent->setChildl(node);
		else new_parent->setChildr(node);
		node->setChildl(new_child);
	}
}

void BinaryTree::walkPostorder()
{
	walkPostorder(root);
}

void BinaryTree::walkPostorder(Node *node)
{
	if (node == NULL) return;
	walkPostorder(node->getChildl());
	walkPostorder(node->getChildr());
	cout << node->getId();
	if (node != root) cout << " ";
	else cout << endl;
}

int main(void)
{
	BinaryTree bt;

	int n, id;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> id;
		bt.setNodePreorder(id);
	}
	for (int i = 0; i < n; i++) {
		cin >> id;
		bt.setNodeInorder(id);
	}
		
	bt.walkPostorder();
		
	return 0;
}

Measured memory_bytes: 3096
#include <iostream>
#include <cstdlib>
#include <utility>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <set>

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

using namespace std;

int main() {
    vector <int> a(5, 0); 
    rep(i, 5) cin >> a[i];
    int t = 0;
    rep(i, 5) t += a[i] / 10 * 10; 
    rep(i, 5) a[i] = a[i] % 10; 
    sort(a.begin(), a.end());
    int flag = 0;
    rep(i, 5) {
        if (a[i] == 0) continue;
        if (flag == 1) t += 10; 
        else {t += a[i]; flag = 1;} 
    }   
    cout << t << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;

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

  int N; cin >> N;
  ll C; cin >> C;
  vector<ll> x(N+2), cs(N+1);
  for (int i = 1; i <= N; i++) {
    ll v;
    cin >> x[i] >> v;
    cs[i] = cs[i-1] + v;
  }
  x[N+1] = C;

  ll leftMax1 = 0, leftMax2 = 0;
  ll ans1 = 0, ans2 = 0;
  for (int i = 0; i <= N; i++) {
    leftMax1 = max(leftMax1, cs[i] - x[i] * 2);
    ll right1 = max(0LL, cs[N] - cs[i] - C + x[i+1]);
    ans1 = max(ans1, leftMax1 + right1);
    leftMax2 = max(leftMax2, cs[i] - x[i]);
    ll right2 = max(0LL, right1 - C + x[i+1]);
    ans2 = max(ans2, leftMax2 + right2);
  }
  cout << max(ans1, ans2) << "\n";
}

Measured memory_bytes: 1792
//
// Created by sark2 on 19-12-2019.
//

#include "bits/stdc++.h"

using namespace std;
#define pb push_back
#define IOS cin.sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define CASES int t;cin>>t;while(t--)

using ll = long long;
using ld = long double;

const int mod = 1e9 + 7;

int main() {

    int n; cin>>n;

    vector<int>a(n);
    int x[n+5][n+5], y[n+5][n+5];


    for(int i = 0; i < n; i++){
        cin>>a[i];
        for (int j = 1; j <= a[i]; j++) {
            cin>>x[i+1][j]>>y[i+1][j];
        }
    }

    int ans = 0;

    for(int mask = 1; mask < (1<<n); mask++){
        bool ok = true;
        for(int i = 0; i < n; i++){
            if(!(mask & (1<<i))){
                continue;
            }
            for(int j = 1; j <= a[i]; j++){
                if(((mask >> (x[i+1][j]-1)) & 1)^y[i+1][j])ok = false;
            }
        }
        if(ok) ans = max(ans, __builtin_popcount(mask));
    }

    cout<<ans<<"\n";




}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define ADD(a, b) a = (a + b) % mod
#define SUB(a, b) a = (a+mod-b)%mod
#define MUL(a, b) a = (a * b) % mod
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define fi first
#define se second
typedef pair<int,int> P;
typedef pair<int, P> PP;
typedef pair<P, int> Pi;
typedef vector<int> vi;
typedef deque<int> dq;
const int inf = 1e9+7;
const int INF = 1e18+7;

string str;
int solve(){
	if(str[0] != 'A')return 0;
	int f = 0, n = str.size();
	repi(i,2,n-1)if(str[i] == 'C')f++;
	if(f != 1)return 0;
	rep(i,n){
		if(str[i] == 'A' or str[i] == 'C')continue;
		if('a' <= str[i] and str[i] <= 'z')continue;
		return 0;
	}
	return 1;
}

signed main(){
	cin >> str;
	int ans = solve();
	printf("%s\n", ans ? "AC" : "WA");
	return 0;
}







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

int main(){
	int S ,h ,m ,s;
	cin>>S;
	h=S/3600;
	m=(S-h*3600)/60;
	s=S-(h*3600+m*60);
	cout<<h<<":"<<m<<":"<<s<<endl;
}


Measured memory_bytes: 3120
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

int main(){

	int x_per,y_base,y_base_limit,y_delta,P;
	int x_sum = 0,y_sum = 0;

	scanf("%d\n%d\n%d\n%d\n%d",&x_per,&y_base,&y_base_limit,&y_delta,&P);

	x_sum = P*x_per;

	y_sum += y_base;

	if(P > y_base_limit){
		y_sum += y_delta*(P-y_base_limit);
	}

	printf("%d\n",min(x_sum,y_sum));

    return 0;
}

Measured memory_bytes: 2760
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args)
	{
		Scanner s=new Scanner(System.in);
		
		int n=s.nextInt();
		long d=2*s.nextInt();
		long a=s.nextInt();
		
		pair[] arr=new pair[n];
		
		for(int i=0;i<n;i++)
		{
			int pos=s.nextInt();
			int power=s.nextInt();
			
			pair p=new pair(pos,power);
			arr[i]=p;
		}
		
		Arrays.sort(arr,new comp());
		
		long[] diff=new long[n+1];
		diff[0]=arr[0].power;
		
		for(int i=1;i<n;i++)
		{
			diff[i]=arr[i].power-arr[i-1].power;
		}
		
		long ans=0;
		
		for(int i=0;i<n;i++)
		{
			if(diff[i]>0)
			{
				double left=diff[i];
				long moves=(long)Math.ceil(left/a);
				ans=ans+moves;
				diff[i]=diff[i]-moves*a;
				
				int index=bs(arr,arr[i].pos+d,n);
				diff[index]=diff[index]+moves*a;
			}
			
			diff[i+1]=diff[i+1]+diff[i];
			
		}
		
		System.out.println(ans);
		
	}
	
	public static int bs(pair[] arr,long range,int n)
	{
		int start=0;
		int end=n-1;
		
		int ans=-1;
		
		while(start<=end)
		{
			int mid=(start+end)/2;
			
			if(arr[mid].pos<=range)
			{
				ans=mid;
				start=mid+1;
			}
			else
			{
				end=mid-1;
			}
		}
		
		return ans+1;
	}
	
}

class pair
{
	int pos;
	long power;
	
	public pair(int pos,long power)
	{
		this.pos=pos;
		this.power=power;
	}
}

class comp implements Comparator<pair>
{
	public int compare(pair a,pair b)
	{
		return a.pos-b.pos;
	}
}

Measured memory_bytes: 115220
#include <bits/stdc++.h>
#include <fstream>
#include<string>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>


typedef  long long ll;
typedef long double ld;
using namespace std;
using namespace __gnu_pbds;
#define  point complex<ld>
#define Cp(a,b) ((conj(a)*b).imag())
#define Dp(a,b) ((conj(a)*b).real())
#define dist(a,b) (abs(line(a,b)))
#define angel(a) (atan2(a.Y,a.X)*360/pi)

#define X real()
#define Y imag()

#define line(a,b) (b-a)

#define endl "\n"

#define FIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ordered_set tree<pair<int,int>, null_type,less<pair<int,int>>, rb_tree_tag,tree_order_statistics_node_update>
const int N=3e5+5;
ll mod=998244353 ;
ll inf=1e18;
ld eps=1e-12;
ld pi=2*2*acos(0);
ll mul (ll a, ll b)
{
    a%=mod;
    b%=mod;
    return (a*b)%mod;
}
ll add (ll a, ll b)
{
    a%=mod;
    b%=mod;
    return (a+b+mod)%mod;
}
ll fastpow(ll b, ll p)
{
    if(p==0)
        return 1;
    ll ans=fastpow(b,p/2);
    ans=mul(ans,ans);
    if(p%2)ans=mul(ans,b);
    return ans;
}
vector<vector<int>>v;

void back_tarack(vector<int>vv)
{
    if(vv.size()==10)
    {
        v.push_back(vv);
        return;
    }
    vv.push_back(0);
    back_tarack(vv);
    vv.pop_back();

    vv.push_back(1);
    back_tarack(vv);
    vv.pop_back();

}
int n,f[N][10],p[N][11];

int main()
{
    FIO
    cin>>n;
    for(int i=0; i<n; i++)
    {
        for(int j=0; j<10; j++)
            cin>>f[i][j];

    }
    for(int i=0; i<n; i++)
    {
        for(int j=0; j<11; j++)
            cin>>p[i][j];

    }
    ll ans=-1e18;
    for(int mask=1; mask<(1<<10); mask++)
    {
        ll cost=0;
        for(int shop=0; shop<n; shop++)
        {
            int co=0;
            for(int j=0; j<10; j++)
            {
                if(f[shop][j]&&(mask>>j)&1!=0)
                    co++;
            }

            cost+=p[shop][co];
        }
        ans=max(ans,cost);


    }
    cout<<ans;

    return 0;
}


Measured memory_bytes: 3676
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define RFOR(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define rep(i,n) FOR(i,0,(n))
#define REPS(i,n) FOR(i,1,(n)+1)
#define RREP(i,n) RFOR(i,0,(n))
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define DEBUG(x)  cout << #x << " = " << (x) << endl;
#define SORT(x) sort(ALL(x));
#define RSORT(x) sort(RALL(x));
#define SUM(x) accumulate(ALL(x),0);
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const ll mod = 1e9+7;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//cout << fixed << setprecision(10);

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) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

const int AMAX = 100000;
ll cnt[AMAX+1];

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

  rep(i,N) {
    int A, B;
    cin >> A >> B;
    cnt[A] += B;
  }

  FOR(ans,1,AMAX+1) {
    if (K <= cnt[ans]) {
      cout << ans << endl;
      break;
    }
    K -= cnt[ans];
  }

  return 0;
}

Measured memory_bytes: 1024
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let a: i32 = read();
    let b: i32 = read();
    println!("{}", (a + b + 1) / 2);
}

Measured memory_bytes: 4352