akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
  
using namespace std;
using namespace __gnu_pbds;
 
#define ll long long
#define uint unsigned int
#define ull  unsigned long long
#define pb push_back
#define mk make_pair
#define ins insert
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define X first
#define Y second
#define umap unordered_map
#define speed() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define setvalue(d,s,e,n) for(int qwe = s; qwe < e; ++qwe) d[qwe] = n
#define mset multiset
#define pqueue priority_queue
   
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
        
const int  N = 2e5 + 314;
const int INF = 1e9;
const double PI = acos(-1);
const int MOD = 1e9 + 7;
const double eps = 1e-9;
 
void solve(){
    int a, b, c;
    cin >> a >> b >> c;
    set <int> s;
    s.ins(a);
    s.ins(b);
    s.ins(c);
    if(s.size() == 2){
        cout << "Yes";
    }
    else {
        cout << "No";
    }
}
 
int main(){
    speed();
    int t = 1;
    // cin >> t;
    while(t--)solve();
}

Measured memory_bytes: 256
import math

def main():
    mod = 1000000007
    N = int(input())
    A = list(map(int, input().split()))

    A_max = sorted(A)[-1]
    if A_max == 0:
        print(0)
        exit()
    bit_max = int(math.ceil(math.log2(A_max)))

    i = 0
    bit = 1
    res = 0
    while i <= bit_max:
        c_zero = 0
        c_one = 0
        for j in range(N):
            if A[j] & bit == 0:
                c_zero += 1
            else:
                c_one += 1
        m_bit = bit % mod
        res += m_bit*c_zero*c_one
        res %= mod
        i += 1
        bit<<=1
    print(res)

if __name__ == "__main__":
    main()

Measured memory_bytes: 127100
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define ll long long
#define ull unsigned long long
#define si set <ll>
#define vi vector <ll>
#define popcount(x) __builtin_popcountll(x)
#define mii map <ll,ll>
#define vpi vector <pair <ll,ll> >
#define sz(c) (int)c.size()
#define fr first
#define ll long long
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define sc second
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define mem0(a) memset(a,0,sizeof(a))
#define rep(i,a,n) for( ll i=a ; i<n ; i++)
#define ld long double
#define rall(a) (a).rbegin(),(a).rend()

ll power(ll b,ll e,ll m)
{
  if(e==0) return 1;
  if(e&1) return b*power(b*b%m,e/2,m)%m;
  return power(b*b%m,e/2,m);
}
ll power( ll b, ll e)
{
  if(e==0) return 1;
  if(e&1) return b*power(b*b,e/2);
  return power(b*b,e/2);
}  
bool isPowerOfTwo(ll x)
{
    // x will check if x == 0 and !(x & (x - 1)) will check if x is a power of 2 or not
    return (x && !(x & (x - 1)));
} 

void solve()
{
  ll a,b,c,k;
  cin>>a>>b>>c>>k;
  int x=0,y=0;
  while(b<=a) 
  {
    b*=2;
    x++;
  }
  while(c<=b) 
  {
    c*=2;
    y++;
  }
  if(x+y<=k) cout<<"Yes"<<"\n";
  else cout<<"No"<<"\n";
}

int main()       
{
  fastio
  ll tt=1;
  while(tt--)
  {
    solve();
    cout<<"\n";
  }
  return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>																							   
																													   
using namespace std; 																								   
																													   
const int INF = 1000000001;																						   
const float PI = 3.14;																								   
typedef long long LL;																								   
																													   
typedef vector<int> vi;																								   
typedef list<int> li;																								   
typedef queue<int> qi; 																								   
typedef pair<int,int> ii; 																							   
typedef map<string,int> msi; //np msi['nazwa'] = 'liczba'															   
typedef vector<ii> vii; //vector par<int>, do tworzenia tablicy dla grafów wagowych #dijkstra #Bellman_Ford			   
typedef priority_queue< ii, vector<ii>, greater<ii> > pq; //kolejka priorytetowa vectorów par(top()=min) #dijkstra	   
																													   																					   
vector<ii>::iterator iter;																							   
																													   																				   
#define print_list(x) for(it = (x).begin(); it != (x).end(); it++) {cout << *it << " ";}							   
#define print_vector(x) for(it2 = (x).begin(); it2 != (x).end(); it2++) {cout << *it2 << " ";}						   
#define search_list(x) for(it = (x).begin(); it != (x).end(); it++)													   
#define search_vector(x) for(it2 = (x).begin(); it2 != (x).end(); it2++);											   
#define pb(x) push_back(x) 																							   
#define pf(x) push_front(x)																							   
#define mp(x, y) make_pair(x, y)                                                                                       
///////////////////////////////////////////////GLOBAL DEFINITIONS////////////////////////////////////////////////////////



///////////////////////////////////////////////////FUNCTIONS/////////////////////////////////////////////////////////////



/////////////////////////////////////////////////////MAIN////////////////////////////////////////////////////////////////
int main(int argc, char* argv[])																					 
{ios_base::sync_with_stdio(false); cin.tie(NULL);                  												       
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	
	string s;
	cin >> s;
	bool check = false;
	int n = s.size();
	for(int i = 0; i < n; i++){
		if(s[i] == '7'){
			check = true;
			break;
		}
	}
	
	if(check) cout << "Yes" << '\n';
	else cout << "No" << '\n';


	return 0;
}


Measured memory_bytes: 3612
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <cstdlib>

uint64_t operator<<(uint64_t& lhs, std::string& rhs){
	std::istringstream iss(rhs);
	iss >> lhs;
	return lhs;
}
uint64_t str2u64(std::string str){
	uint64_t res;
	std::istringstream iss(str);
	iss >> res;
	return res;
}

std::vector<std::string> split(std::string str, std::string delimiters){
	std::vector<std::string> result;
	while(str.length()){
		bool found_delim = false;
		for(auto& d : delimiters){
			auto pos = str.find_first_of(d);
			if(pos != std::string::npos){
				result.push_back(str.substr(0, pos));
				str = str.substr(pos + 1, str.length() - pos - 1);
				found_delim = true;
			}
		}
		if(!found_delim){
			result.push_back(str);
			return result;
		}
	}
}

int main(int argc,char *argv[]){
	std::string S;
	std::cin >> S;
	
	auto splitted = split(S, "/");
	uint64_t date = str2u64(splitted[0]) * 10000u + str2u64(splitted[1]) * 100u + str2u64(splitted[2]);
	if(date <= 20190430)
		std::cout << "Heisei";
	else
		std::cout << "TBD";
	
	return 0;
}



Measured memory_bytes: 256
import java.io.*;
class Main {
	public static void main(String...args)throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] zahyos = br.readLine().split(" ");
		double[] tri = new double[3];
		double a = Double.valueOf(zahyos[0]); 
		double b = Double.valueOf(zahyos[1]); 
		double c = Double.valueOf(zahyos[2]);
		double powC = Math.pow(a ,2) + Math.pow(b,2)  - 2 * a * b * Math.cos(Math.toRadians(c));
		double shahenn = Math.sqrt(powC);
		double S = a * b /2 * Math.sin(Math.toRadians(c));
		double L = a + b + shahenn;
		double h = S * 2 /a;
		System.out.println(S);
		System.out.println(L);
		System.out.println(h);
	}
}


Measured memory_bytes: 24464
#include<stdio.h>

int main(){

  int a,b,n,st;

  //load a,b 
  scanf("%d %d",&a,&b);
  //sort
  if(a<b){
    st=a;
    a=b;
    b=st;
  }

  //argorithm
  while(1){
    n=a%b;
    if(n==0){
      printf("%d\n",b);
      break;
    }
    else{
      st=b;
      b=n;
      a=st;
      continue;
    }


  }


  return 0;
}

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

int main(void){
  long long int a,b,c,x,y,ans,tmp_ans;
  long long int zero;
  zero=0;
  ans=1000000009;
  cin>>a>>b>>c>>x>>y;
  for(int i=0;i<2*max(x,y)+1;i+=2){
  	tmp_ans=c*i+a*max(x-i/2,zero)+b*max(y-i/2,zero);
  	ans=min(tmp_ans,ans);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define inf 1000000005
#define all(a) (a).begin(), (a).end()
#define ms(a,x) memset(a, x, sizeof(a))
#define mod 1000000007
#define sz(a) ((ll)(a).size())

template<class T> int getbit(T s, int i) { return (s >> i) & 1; }
template<class T> T onbit(T s, int i) { return s | (T(1) << i); }
template<class T> T offbit(T s, int i) { return s & (~(T(1) << i)); }
template<class T> int cntbit(T s) { return __builtin_popcount(s);}
#define Rep(i,n) for(int i = 0; i < (n); ++i)
#define Repd(i,n) for(int i = (n)-1; i >= 0; --i)
#define For(i,a,b) for(int i = (a); i <= (b); ++i)
#define Ford(i,a,b) for(int i = (a); i >= (b); --i)

typedef unsigned long long ull;
typedef long long ll;
typedef double ld;
#define eps 1e-12
typedef pair<int, int> II;
typedef pair<ll, ll> LL;
template<class T> T gcd(T a, T b){ T r; while (b != 0) { r = a % b; a = b; b = r; } return a;}
template<class T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
#define PI (2 * acos((ld)0))
#define linf (1ll << 60)
#define y1 y32432
#define y0 y435346

#define maxn 400005

int n, deg[maxn], que[maxn], size, flag[maxn];
vector<int> V[maxn];

int main()
{
//	freopen("in.txt", "r", stdin);
	ios::sync_with_stdio(0);
	cin.tie(0);

	cin >> n;
	For(i, 1, n - 1){
		int u, v;
		cin >> u >> v;
		V[u].pb(v);
		V[v].pb(u);
		deg[u]++;
		deg[v]++;
	}

	size = 0;
	For(i, 1, n) if(deg[i] == 1){
		que[size++] = i;
	}

	Rep(i, size){
		int u = que[i];
		if(flag[u]) continue;
		flag[u] = 1;
		if(deg[u] == 0){
			cout << "First" << endl;
			return 0;
		}
		Rep(j, sz(V[u])){
			int v = V[u][j];
			if(flag[v]) continue;
			flag[v] = 1;
			Rep(k, sz(V[v])){
				int t = V[v][k];
				deg[t]--;
				if(!flag[t] && deg[t] <= 1){
					que[size++] = t;
				}
			}
		}
	}

	cout << "Second" << endl;

  return 0;
}


Measured memory_bytes: 16156
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
count=0
C=0
for i in range(N):
    a=A[i]+A[i+1]
    if a>B[i]:
        count=count+B[i]
        C=max(B[i]-A[i],0)
        A[i+1]=A[i+1]-C
    elif a==B[i]:
        count=count+B[i]
        A[i+1]=0
    else:
        count=count+a
        A[i+1]=0
print(count)

Measured memory_bytes: 19004
// {{{
#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <complex>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <algorithm>
#include <numeric>
using namespace std;

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define FOR(i, a, b) for(ll i = static_cast<ll>(a); i < static_cast<ll>(b); i++)
#define FORR(i, a, b) for(ll i = static_cast<ll>(a); i >= static_cast<ll>(b); i--)
#define REP(i, n) for(ll i = 0ll; i < static_cast<ll>(n); i++)
#define REPR(i, n) for(ll i = static_cast<ll>(n); i >= 0ll; i--)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> IP;
typedef pair<ll, LP> LLP;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, 1, -1};

constexpr int INF = 100000000;
constexpr ll LINF = 10000000000000000ll;
constexpr int MOD = static_cast<int>(1e9 + 7);
constexpr double EPS = 1e-9;
// }}}

int N;
int divisor[101];

void init()
{
}

ll rec(int i, int n)
{
    //if(i == 100) return (n == 75 ? 1 : 0);
    if(n == 75) return 1;
    if(i == 100) return 0;
    ll ret = 0;
    REP(j, divisor[i]+1){
        if(!(j == 0 || j == 2 || j == 4 || j == 14 || j == 24 || j == 74)) continue;
        ret += rec(i+1, n*(j+1));
    }
    return ret;
}

void solve()
{
    int val = 2;
    while(val <= N){
        int val_ = val;
        int n = 2;
        while(val_ > 1){
            if(val_ % n == 0){
                divisor[n]++;
                val_ /= n;
            }else{
                n++;
            }
        }
        val++;
    }
    //FOR(i, 1, N+1){
    //    cout << divisor[i] << " ";
    //    if(i % 10 == 0 || i == N) cout << endl;
    //}
    cout << rec(1, 1) << endl;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    solve();
    return 0;
}

// vim:set foldmethod=marker:


Measured memory_bytes: 892
N = int(input())
A = [0]
A.extend(list(map(int, input().split())))

for i in range(1, N//2 + 1)[::-1]:
    wa = 0
    for j in range(2, N+1):
        if i * j > N:
            break
        wa += A[i*j]
    wa %= 2
    if A[i] == wa:
        A[i] = 0
    else:
        A[i] = 1


A = A[1:]
print(A.count(1))
for i, j in enumerate(A):
    if j == 1:
        print(i+1, end=' ')


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

using namespace std;

long long b[1000006], p[1000006];

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	long long n, m, br = 0;
	string s;
	cin >> s;
	n = s.size();
	for(long long i = 0; i < n; ++i) b[i] = s[i] - 48;
	p[n - 1] = 10 - b[n - 1];
	for(long long i = n - 2; i >= 0; --i) p[i] = p[i - 1] + 10 - b[i] - 1;
	m = p[0] + 1;
	for(long long i = n - 1; i > 0; --i){
		if(b[i] < 5) br += b[i];
		else{
			if(b[i] == 5 and b[i - 1] < 5){
				br += b[i];
		    }
		    else{
		    	br += 10 - b[i];
				++b[i - 1];
		    }
		}
	}
	if(b[0] <= 5) br += b[0];
	else br += 10 - b[0] + 1;
	cout << br;

	return 0;
}



Measured memory_bytes: 16924
#include <bits/stdc++.h>
long long int N,A,B;
long long int h[100000];

int is_enough(int T){
  long long int count = 0;
  for (long long int i = 0; i < N; i++) {
    long long int HP = (h[i]-T*B);
    if(HP>0){
      count+= HP%(A-B)==0 ? HP/(A-B) : HP/(A-B)+1;
    }
  }
  return count > T ? 0 : 1;
}

int main(int argc, char *argv[])
{
  scanf("%lld %lld %lld",&N,&A,&B);
  for (long long int i = 0; i < N; i++) {
    scanf("%lld",&h[i]);
  }
  long long int bottom =0;
  long long int top = 1000000000;
  long long int mid = (top+bottom)/2;

  while(top-bottom>1){
    if(is_enough(mid)==0){
      bottom=mid;
      mid = (top+bottom+1)/2;

    }else{
      top = mid;
      mid = (top+bottom+1)/2;
    }
  }
  printf("%lld\n",top);
  return 0;
}


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

using namespace std;

int sqr(int x){
  int t=0;
  while(t*t<x){
    t++;}
  return t;}


int main(){
int a,b;
  cin>>a>>b;
  int p;
  
  if(1<=b && b<=9)p=10*a+b;
  else if(10<=b && b<=99)p=100*a+b;
  else p=1000*a+b;
  
  if(sqr(p)*sqr(p)==p)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string s;
int n,q,p[100010],qzh[100010],l,r;
int main() {
	scanf("%d%d",&n,&q);
	cin>>s;
	for(int i=0;i<s.size();i++)
	if(s[i]=='A'&&s[i+1]=='C')
	p[i+1]=1;
	for(int i=1;i<=n;i++)
	qzh[i]=qzh[i-1]+p[i];
	while(q--)
	{
		scanf("%d%d",&l,&r);
		printf("%d\n",qzh[r-1]-qzh[l-1]);
	}
}

Measured memory_bytes: 1792
#include<stdio.h>
#include<algorithm>
#include<string.h>
using namespace std;
const int inf=2147483647;
struct dat{
	int x,i;
	dat(int a=0,int b=0){x=a;i=b;}
}d[20010];
bool operator<(dat a,dat b){return a.x==b.x?a.i<b.i:a.x<b.x;}
int x[10010],y[10010],n;
int h[120010],nex[4000010],to[4000010],M,mx;
void add(int a,int b){
	M++;
	to[M]=b;
	nex[M]=h[a];
	h[a]=M;
}
void build(int l,int r,int x){
	mx=max(mx,x+4*n);
	if(l==r)return add(x+4*n,d[l].i*2);
	int mid=(l+r)>>1;
	add(x+4*n,(x<<1)+4*n);
	add(x+4*n,(x<<1|1)+4*n);
	build(l,mid,x<<1);
	build(mid+1,r,x<<1|1);
}
void modify(int L,int R,int u,int l,int r,int x){
	if(L<=l&&r<=R)return add(u,x+4*n);
	int mid=(l+r)>>1;
	if(L<=mid)modify(L,R,u,l,mid,x<<1);
	if(mid<R)modify(L,R,u,mid+1,r,x<<1|1);
}
void gao(int x,int b,int L,int R){
	L=lower_bound(d+1,d+2*n+1,dat(L,0))-d;
	R=lower_bound(d+1,d+2*n+1,dat(R,inf))-d-1;
	if(L>R)return;
	if(L<b)modify(L,min(b-1,R),x*2-1,1,2*n,1);
	if(b<R)modify(max(b+1,L),R,x*2-1,1,2*n,1);
}
int dfn[120010],low[120010],bl[120010],st[120010],tp,C;
bool ins[120010];
void dfs(int x){
	int i;
	dfn[x]=low[x]=++M;
	st[++tp]=x;
	ins[x]=1;
	for(i=h[x];i;i=nex[i]){
		if(!dfn[to[i]]){
			dfs(to[i]);
			low[x]=min(low[x],low[to[i]]);
		}else if(ins[to[i]])
			low[x]=min(low[x],dfn[to[i]]);
	}
	if(dfn[x]==low[x]){
		C++;
		do{
			i=st[tp--];
			bl[i]=C;
			ins[i]=0;
		}while(i!=x);
	}
}
bool check(int len){
	int i;
	memset(h,0,sizeof(h));
	M=0;
	mx=0;
	build(1,2*n,1);
	for(i=1;i<=n;i++){
		add(4*i-3,4*i);
		add(4*i,4*i-3);
		add(4*i-1,4*i-2);
		add(4*i-2,4*i-1);
		gao(2*i-1,lower_bound(d+1,d+2*n+1,dat(x[i],i*2-1))-d,x[i]-len+1,x[i]+len-1);
		gao(2*i,lower_bound(d+1,d+2*n+1,dat(y[i],i*2))-d,y[i]-len+1,y[i]+len-1);
	}
	M=C=0;
	memset(dfn,0,sizeof(dfn));
	for(i=1;i<=mx;i++){
		if(!dfn[i])dfs(i);
	}
	for(i=1;i<=4*n;i+=2){
		if(bl[i]==bl[i+1])return 0;
	}
	return 1;
}
int main(){
	int i,l,r,mid,ans;
	scanf("%d",&n);
	for(i=1;i<=n;i++){
		scanf("%d%d",x+i,y+i);
		d[i*2-1]=dat(x[i],i*2-1);
		d[i*2]=dat(y[i],i*2);
	}
	sort(d+1,d+2*n+1);
	ans=0;
	l=1;
	r=d[2*n].x-d[1].x;
	while(l<=r){
		mid=(l+r)>>1;
		if(check(mid)){
			ans=mid;
			l=mid+1;
		}else
			r=mid-1;
	}
	printf("%d",ans);
}

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

#define sz(x) (int)x.size() 
#define pb push_back 
#define mp make_pair 
#define fi(a, b) for(int i=a; i<=b; i++) 
#define fj(a, b) for(int j=a; j<=b; j++) 
#define fo(a, b) for(int o=a; o<=b; o++) 
#define fdi(a, b) for(int i=a; i>=b; i--) 
#define fdj(a, b) for(int j=a; j>=b; j--) 
#define fdo(a, b) for(int o=a; o>=b; o--) 

#ifdef LOCAL
#define err(...) fprintf(stderr, __VA_ARGS__)
#else
#define err(...) while(false) {}
#endif

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

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

int const MAX = 3e3 + 41;

int n, MOD;
int C[MAX][MAX];

int add(int a, int b) {
	a += b;
	while (a < 0) a += MOD;
	while (a >= MOD) a -= MOD;
	return a;
}

int mult(int a, int b) {
	return (ll) a * b % MOD;
}

int bp(int x, ll d) {
	int res = 1;
	while (d) {
		if (d & 1) res = mult(res, x);
		x = mult(x, x);
		d >>= 1;
	}	
	return res;
}

int bp1(int x, ll d) {
	int res = 1;
	while (d) {
		if (d & 1) res = (ll) res * x % (MOD - 1);
		x = (ll) x * x % (MOD - 1);
		d >>= 1;
	}	
	return res;
}


int g[MAX][MAX];
int f[MAX];

void init() {
	fi(0, MAX - 1) {
		C[i][0] = 1;
		fj(1, i) {
			C[i][j] = add(C[i - 1][j - 1], C[i - 1][j]);
		}
	}
	g[0][0] = 1;
	fi(1, MAX - 1) {
		fj(0, MAX - 1) {
			g[i][j] = add(g[i][j], g[i - 1][j]);
			g[i][j] = add(g[i][j], mult(j, g[i - 1][j]));
			if (j) {
				g[i][j] = add(g[i][j], g[i - 1][j - 1]);				
			}
		}
	}
	fi(0, n) {
		int v1 = bp(2, bp1(2, n - i));
		fj(0, i) {
			int v2 = bp(2, (n - i) * j);
			int v3 = g[i][j];
			int v = mult(v1, mult(v2, v3));
			f[i] = add(f[i], v);
		}
	}
}

int ans;

void solve() {
	int s = 1;
	fi(0, n) {		
		ans = add(ans, mult(s, mult(C[n][i], f[i])));
		s = -s;	
	}
	printf("%d\n", ans);
	//
	fi(0, n) {
		err("i = %d f = %d\n", i, f[i]);
	}
	//
}

int main() {
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	scanf("%d %d", &n, &MOD);
	init();	  
	solve();		

	
#ifdef LOCAL
	err("ELAPSED TIME: %.3Lf\n", (ld) clock() / CLOCKS_PER_SEC);
#endif	
	
	return 0;
}

Measured memory_bytes: 72448
import java.util.*;
public class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    String s = sc.next();
    String t = sc.next();
    for(int i=0 ; i<n ; i++){
      System.out.print(s.charAt(i));
      System.out.print(t.charAt(i));
    }
    System.out.println();
  }
}


Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n, m;
    cin >> n >> m;
    int a[10100];
    int total = 0;
    for(int i = 0; i < m; i++){
        cin >> a[i];
        total += a[i];
    }
    if(total > n) cout << -1 << endl;
    else cout << n-total << endl;
} 

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

int main() {
    vector<int> V(5);
    vector<int> W(5);
    vector<int> X(5);
    int ans = 0;
    for (int i = 0; i < 5; i++) {
        cin >> V[i];
    }
    for (int j = 0; j < 5; j++) {
        W[j] = V[j]/10 + min(1,V[j]%10);
        ans += W[j]*10;
    }
    for (int k = 0; k < 5; k++) {
        X[k] = (V[k] - 1 )%10 + 1 - 10;
    }
    sort(X.begin(),X.end());
    cout << ans + X[0] << endl;
}

Measured memory_bytes: 3624
#include <stdio.h>
#include <vector>

void Output(const char& suit, const std::vector<int>& vec) {
	for (int i = 1; i <= 13; i++) {
		if (vec[i] == 0) {
			printf("%c %d\n", suit, i);
		}
	}
}

                   
int main(int argc, char const* argv[])
{

	int n, tmp;
	char suit[2];

	std::vector<int> S(14, 0);
	std::vector<int> H(14, 0);
	std::vector<int> C(14, 0);
	std::vector<int> D(14, 0);

	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%s %d", suit, &tmp);
		//printf("%s %d\n", suit, tmp);
		switch(suit[0]) {
			case 'S':
			   S[tmp] = 1;
			   break;
			case 'H':
			   H[tmp] = 1;
			   break;
			case 'C':
			   C[tmp] = 1;
			   break;
			case 'D':
			   D[tmp] = 1;
			   break;
		}
	}

	Output('S', S);
	Output('H', H);
	Output('C', C);
	Output('D', D);

	return 0;
}                              


Measured memory_bytes: 2716
#include <bits/stdc++.h>
#define rep(i,n1) for(int i=0;i<n1;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define yesno(flg) if(flg){cout<<'YES'<<endl;}else{cout<<'NO'<<endl;}
#define vi vector<int>
#define pb push_back
#define i197 1000000007
#define MAX_N 200002
#define PI 3.141592653589793
using namespace std;

typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<Pii,int> Piii;
typedef pair<int,ll> Pil;
typedef pair<ll,ll> Pll;
typedef pair<string,int> Psi;
typedef pair<Psi,int> Psii;

const ll inf=1000000007;
struct edge{
	int myc,to,c,cost;
};
struct pos{
	int to,cost,color;
};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

vector<Pii> v[100001];
ll dp[300000][60]={};
ll dp2[300000][60]={};
ll a[300000];
int main() {
	int a,b;
	int s[4]={};
	cin>>a>>b;
	s[a]=1;
	s[b]=1;
	if(s[1]==0)cout<<"1"<<endl;
	if(s[2]==0)cout<<"2"<<endl;
	if(s[3]==0)cout<<"3"<<endl;
	
	return 0;
}


Measured memory_bytes: 3584
import sys, math
from pprint import pprint
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mod = 10**9 + 7

S = rs()
#S = '1'*200000

mods = []
n = 0
e = 0
for i in reversed(range(len(S))):
	n += int(S[i]) * pow(10,e,2019)
	#e = (e*10) % 2019
	e += 1
	#n = n % 2019
	mods.append(n % 2019)
mods.append(0)
import collections
cnt = collections.Counter(mods)
ans = 0
for k, c in cnt.items():
	ans += c*(c-1)//2
print(ans)


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

using namespace std;

int main() {
  int h,w;
  int shiro=0;
  cin>>h>>w;
  vector<vector<char>> data(h+2, vector<char>(w+2));
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin>>data.at(i+1).at(j+1);
      if(data.at(i+1).at(j+1)!='#'){
        shiro++;
      }
    }
    
  }
  for(int i=0;i<w+2;i++){
    data.at(0).at(i)='#';
    data.at(h+1).at(i)='#';
  }
  for(int i=0;i<h;i++){
    data.at(i+1).at(0)='#';
    data.at(i+1).at(w+1)='#';
  }
  
  vector<int> dist((h+2)*(w+2), -1); // 全頂点を「未訪問」に初期化
    queue<int> que;
  

    // 初期条件 (頂点 0 を初期ノードとする)
    dist[w+3] = 0;
    que.push(w+3); // 0 を橙色頂点にする

    // BFS 開始 (キューが空になるまで探索を行う)
    while (!que.empty()) {
        int v = que.front(); // キューから先頭頂点を取り出す
        que.pop();
      vector<int> vec(4);
      vec.at(0)=v-w-2;
      vec.at(1)=v-1;
      vec.at(2)=v+1;
      vec.at(3)=v+w+2;

        // v から辿れる頂点をすべて調べる
        for (int nv : vec) {
          if(nv%(w+2)==0||nv%(w+2)==w+1){
            continue;
          }
          if(data.at(nv/(w+2)).at(nv%(w+2))=='#'){
            continue;
          }
         
            if (dist[nv] != -1) continue; // すでに発見済みの頂点は探索しない

            // 新たな白色頂点 nv について距離情報を更新してキューに追加する
            dist[nv] = dist[v] + 1;
            que.push(nv);
        }
    }
      if(dist[w*h+w+2*h]==-1){
        
        cout<<-1<<endl;
        return 0;
      }
      else {
        
        cout<<shiro-dist[w*h+w+2*h]-1<<endl;
      }

  
  
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;

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

    ll a, b;
    cin >> a >> b;

    if(a*b<0) {
        puts("Zero");
        return 0;
    }

    if(a>0 && b>0){
        puts("Positive");
        return 0;
    }

    if((b-a)%2) puts("Positive");
    else puts("Negative");

    return 0;
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
string S[101];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	FOR(i,N) {
		cin>>S[i];
		if(S[i]=="Y") return _P("Four\n");
	}
	_P("Three\n");
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


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

fn main() {
    let stdin = stdin();
    let mut stdinlock = stdin.lock();
    let mut str1 = String::new();
    stdinlock.read_line(&mut str1).unwrap();
    let mut it1 = str1.trim().split_whitespace().map(|x| u32::from_str(x).unwrap());
    let n = it1.next().unwrap();
    let mut na = n;
    let mut j = 0;
    for _ in 0..9 {
        j += na % 10u32;
        na = na / 10;
    }
    if n % j == 0 {
        println!("Yes");
    } else {
        println!("No");
    }
}


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

int main(){

  int a,b=0;
 
  cin>>a>>b;
  
  if(a>9 || b>9){cout<<-1<<endl;return 0;}
  
  cout<<a*b<<endl;

  
}


Measured memory_bytes: 256
def findgraphs(nodes):
    graphs = []
    while nodes:
        graph = set()
        queue = set([next(iter(nodes))])
        while queue:
            nextq = set()
            graph.update(queue)
            for q in queue:
                nextq.update(n for n in nodes[q] if n not in graph)
                del nodes[q]

            queue = nextq

        graphs.append(graph)

    return graphs




friends = dict()
N, M = map(int, input().split())
nodes = {x : set() for x in range(1, N+1)}
for _ in range(M):
    A, B = map(int, input().split())
    nodes[A].add(B)
    nodes[B].add(A)
graphs = findgraphs(nodes)

m = max(len(g) for g in graphs)
print(m)


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

const string YES = "Yes";
const string NO = "No";

void f(const string& S, const string& T)
{
    vector<int> pair_ch(26, 1e9);
    for (ll i = 0; i < S.size(); i++) {
        int s = S[i] - 'a';
        int t = T[i] - 'a';
        if (pair_ch[s] == 1e9) {
            pair_ch[s] = t;
        } else if (pair_ch[s] != t) {
            cout << NO << "\n";
            exit(0);
        }
    }
}

void solve(std::string S, std::string T)
{
    f(S, T);
    f(T, S);
    cout << YES << "\n";
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
// clang-format off
int main(){
    std::string S;
    std::cin >> S;
    std::string T;
    std::cin >> T;
    cin.tie(nullptr);
    cout.tie(nullptr);
	ios_base::sync_with_stdio(false);
    solve(S, T);
    return 0;
}


Measured memory_bytes: 776
#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 rep1(i,n) for(int i = 1; i <= (n); i++)
#define rrep1(i,n) for(int i = (n); i > 0; i--)

#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>

#define MOD 1000000007
#define INF 1000000000000000LL

using namespace std;

int main(){
  int n, k;cin>>n>>k;
  map<int, int> m;
  rep(i, k){
    int d;cin>>d;
    rep(j, d){
      int t;cin>>t;
      m[t]++;
    }
  }
  cout<<n-m.size()<<endl;

  return 0;
}

Measured memory_bytes: 3632
import java.util.Arrays;
import java.util.Scanner;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

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

        int N = sc.nextInt();
        int M = sc.nextInt();
        int X = sc.nextInt();
        int[] A = new int[M];
        for (int i = 0; i < A.length; ++i) {
            A[i] = sc.nextInt();
        }

        System.out.println(solve(N, A, X));

        sc.close();
    }

    static int solve(int N, int[] A, int X) {
        Set<Integer> gates = Arrays.stream(A).boxed().collect(Collectors.toSet());

        return Math.min((int) IntStream.range(1, X).filter(gates::contains).count(),
                (int) IntStream.range(X + 1, N).filter(gates::contains).count());
    }
}

Measured memory_bytes: 27092
/*
ID: learnin7
TASK: test
LANG: C++                 
*/
/* LANG can be C++11 or C++14 for those more recent releases */
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;

int main(){
        
    ios_base::sync_with_stdio(0);
    //ofstream fout ("test.out");
    //ifstream fin ("test.in");
    //fin >> a >> b;
    //fout << a+b << endl;
    int n;
    cin>>n;
    vector<int> x(n);
    for(int i=0;i<n;i++)    x[i]=i+1;
    vector<vector<int> > p_n;
    do{
        p_n.push_back(x);
    }while(next_permutation(x.begin(), x.end()));

    vector<int> a(n), b(n);
    
    for(int i=0;i<n;i++)    cin>>a[i];
    for(int i=0;i<n;i++)    cin>>b[i];
   /* 
    for(int i=0;i<p_n.size();i++){
        cout<<i+1<<" = ";
        for(int j=0;j<p_n[i].size();j++)
            cout<<p_n[i][j]<<" ";
        cout<<"\n";
    }*/
    auto it_a = find(p_n.begin(), p_n.end(), a);
    //cout<<it_a-p_n.begin()<<endl;
    auto it_b = find(p_n.begin(), p_n.end(), b);
    //cout<<it_b-p_n.begin()<<endl;
    cout<<abs(it_a-it_b)<<endl;
    return 0;
}



Measured memory_bytes: 3384
"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    const S = arg[0].split("");
    
    const set = new Set(S);
    
    console.log(set.size !== 1 ? "Yes" : "No");
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 21956
k = int(input())

lsd = k % 10
if lsd % 2 == 0 or lsd == 5:
    print(-1)
    exit()

dct = {0: 0}
for i in range(1, 10):
    dct[(lsd*i) % 10] = i

l = k
c = 0
while l > 0:
    t = l % 10
    n = dct[(7 - t) % 10]
    l += (k*n)

    l //= 10
    c += 1

print(c)

Measured memory_bytes: 9164
#pragma region header
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cctype>
#include <assert.h>
#include <time.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>
#include <cstring>
#include <array>
// ===============================================================
//using系
#pragma region header
using namespace std;
using lint = long long;
using ld = long double;
using ulint = unsigned long long;
const int dx[] = { 1,0,-1,0 };
const int dy[] = { 0,1,0,-1 };
constexpr lint mod = 1000000007;
constexpr long double pi = 3.141592653589793238462643383279;
#pragma endregion
// ========================================================================
//define
#define INF (lint)10000000000000000;
#define mod (int)1000000007
#pragma region header
template <class T, class U>
inline bool chmin(T& lhs, const U& rhs) {
	if (lhs > rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
template <class T, class U>
inline bool chmax(T& lhs, const U& rhs) {
	if (lhs < rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
#pragma endregion
#pragma endregion

class UnionFind {
public:
	vector<int> par;

	UnionFind(int n) : par(n, -1) { }

	int root(int x) {
		if (par[x] < 0) return x;
		else return par[x] = root(par[x]);
	}

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

	bool unite(int x, int y) {
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y); // merge technique
		par[x] += par[y];
		par[y] = x;
		return true;
	}

	int size(int x) {
		return -par[root(x)];
	}
};

int main(void) {
	ios::sync_with_stdio(false);
	cin.tie(0);
	lint n, m; cin >> n >> m;
	lint ans = n * (n - 1) / 2;
	vector<pair<int, int>> d(m);
	for (int i = 0; i < m; i++) 
		cin >> d[i].first >> d[i].second;
	UnionFind u(n);
	vector<lint> Finalans(m);
	for (int i = m - 1; i >= 0; --i) {
		Finalans[i] = ans;
		int a = d[i].first - 1;
		int b = d[i].second - 1;
		if (!u.same(a, b)) {
			ans -= u.size(a) * u.size(b);
			u.unite(a, b);
		}
	}
	for (int i = 0; i < m; i++) cout << Finalans[i] << endl;

	return 0;
}

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

const int MOD = 1e9+7;
const int MAX_N = 3006;
int n;
string s;
ll dp[MAX_N][MAX_N], pfx[MAX_N][MAX_N];

void solve()
{
	dp[1][1] = 1;
	for(int i=2;i<=n;i++){
	    for(int x=1;x<=i;x++) pfx[i-1][x]=(pfx[i-1][x-1]+dp[i-1][x])%MOD;
		if(s[i-2]=='<'){
			for(int j=1;j<=i;j++){
			    // 1..j-1
				dp[i][j] = pfx[i-1][j-1];
			}
		}
		else{
			for(int j=1;j<=i;j++){
			    // >= j..i-1
				dp[i][j] = (pfx[i-1][i-1]-pfx[i-1][j-1]+MOD)%MOD;
			}
		}
	}
	ll ans = 0;
	for(int x=1;x<=n;++x) (ans+=dp[n][x])%=MOD;
	cout << ans << '\n';
}

int main()
{
	cin >> n;
	cin >> s;
	solve();
	return 0;
}

Measured memory_bytes: 95936
#include <iostream>
#include <vector>
#include <numeric>

int main() {
    std::size_t n;
    std::cin >> n;

    std::vector<size_t> a(n, 0);
    for (auto&& ai : a) std::cin >> ai;

    const auto sum = std::accumulate(a.begin(), a.end(), size_t(0)) / 2;
    std::vector<size_t> x(n, 0);
    x[0] = sum;
    for (size_t i = 1; i < n; i = i + 2) x[0] -= a[i];
    for (size_t i = 1; i < n; ++i) x[i] = a[i - 1] - x[i - 1];

    for (auto&& xi : x) std::cout << 2*xi << ' ';
    std::cout << std::flush;
}

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

const int M=2e5+5;
const int MO=1e9+7;
int inv[M],fa[M],ifa[M];

inline int add(int x,int y)
{
	x+=y;
	if(x>=MO) x-=MO;
	return x;
}
inline int sub(int x,int y)
{
	x-=y;
	if(x<0) x+=MO;
	return x;
}
inline int mul(int x,int y)
{
	return 1LL*x*y%MO;
}

int qp(int x,int n)
{
	int ans=1;
	x=(x%MO+MO)%MO;
	while(n)
	{
		if(n&1) ans=mul(ans,x);
		x=mul(x,x);
		n>>=1;
	}
	return ans;
}

int getinv(int x)
{
	if(x<M) return inv[x];
	else return qp(x,MO-2);
}

void init()
{
	fa[0]=ifa[0]=1;
	inv[1]=fa[1]=ifa[1]=1;
    for(int i=2;i<M;i++)
    {
    	fa[i]=mul(fa[i-1],i);
    	inv[i]=mul(MO-MO/i,inv[MO%i]);
    	ifa[i]=mul(inv[i],ifa[i-1]);
    }
}

/*
dp[u] = fa[sz[u]-1] * \prod dp[v]/fa[sz[v]]
*/

vector<int> g[M];
int sz[M],dp[M];
void dfs(int u,int f)
{
	dp[u]=1;
	for(int v:g[u])
	{
		if(v==f) continue;
		dfs(v,u);
		sz[u]+=sz[v];
		dp[u]=mul(dp[u],mul(dp[v],ifa[sz[v]]));
	}
	dp[u]=mul(fa[sz[u]],dp[u]);
	sz[u]++;
	//cout<<u<<" "<<sz[u]<<" "<<dp[u]<<endl;
}

/*
dp[u] = fa[sz[u]-1] * \prod dp[v]/fa[sz[v]]
delete u from v
newdp[u]=(olddp[u]*ifa[oldsz[u]-1]/(olddp[v]*ifa[oldsz[v]]))*fa[newsz[u]-1]
newdp[v]=(olddp[v]*ifa[oldsz[v]-1]*(newdp[u]*ifa[newsz[u]]))*fa[newsz[v]-1]
*/
int ans[M];
void dfs2(int u,int f)
{
	ans[u]=dp[u];
	for(int v:g[u])
	{
		if(v==f) continue;
		int tmpu=dp[u],tmpv=dp[v];
		int szu=sz[u],szv=sz[v];
		sz[v]=szu; sz[u]-=szv; 
		dp[u]=mul(tmpu,ifa[szu-1]);
		dp[u]=mul(dp[u],getinv(mul(tmpv,ifa[szv])));
		dp[u]=mul(dp[u],fa[sz[u]-1]);
		//cout<<"u "<<u<<" "<<dp[u]<<endl;
		dp[v]=mul(tmpv,ifa[szv-1]);
		dp[v]=mul(dp[v],mul(dp[u],ifa[sz[u]]));
		dp[v]=mul(dp[v],fa[sz[v]-1]);
		//cout<<" v "<<v<<" "<<sz[v]<<" "<<dp[v]<<endl;
		dfs2(v,u);
		sz[u]=szu; sz[v]=szv;
		dp[u]=tmpu; dp[v]=tmpv;
	}
}

int main()
{
	//freopen("F.in","r",stdin);
	init();
	int n; 
	scanf("%d",&n);
	int u,v;
	for(int i=1;i<n;i++)
	{
		scanf("%d%d",&u,&v);
		g[u].push_back(v);
		g[v].push_back(u);
	}
	dfs(1,0);
	dfs2(1,0);
	for(int i=1;i<=n;i++)
		printf("%d\n",ans[i]);
	return 0;
}

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

using namespace std;

using ll = long long;
using ld = long double;
using ull = unsigned long long;

#define int long long
#define F first
#define S second
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

void shift()
{
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(0);
}
const int N = 2e3;
int dp[N][3 * N];

int cost[N];
int msk[N];

int inf = 1e9;



signed main() {
    int n, m;
    int a, b;
    cin >> n >> m;
    for(int i = 0; i < m; ++i) {
        int a, b;
        cin >> a >> b;
        cost[i] = a;
        for(int j = 0; j < b; ++j) {
            int x;
            cin >> x;
            --x;
            msk[i] |= (1 << x);
        }
    }
    // for(int i = 0; i < m; ++i)
    //    cout << msk[i] << ' ';
    // cout << endl;
    for (int i = 0; i <= m; ++i) {
        for (int j = 0; j < (1 << 12); ++j)
            dp[i][j] = inf;
    }
    dp[0][0] = 0;
    for (int i = 0; i < m; ++i) {
        for (int j = (1 << 12) - 1; j >= 0; --j) {
            if (dp[i][j] == inf)
                continue;
            dp[i + 1][j] = min(dp[i + 1][j], dp[i][j]);
            dp[i + 1][j | msk[i]] = min(dp[i][j] + cost[i], dp[i + 1][j | msk[i]]);
        }
    }
    int rs = (1 << n) - 1;
    if (dp[m][rs] == inf)
        cout << -1;
    else
        cout << dp[m][rs];
    return 0;
}


Measured memory_bytes: 46848
package main

import (
	"fmt"
	"strconv"
	"strings"
)

func main() {
	var ans int
	var s string
	fmt.Scan(&s)
	l := len(s) - 1
	var dfs func(string, int)
	dfs = func(s string, t int) {
		if t < l*2 {
			s1 := s[:t] + "x" + s[t:]
			s2 := s[:t] + "+" + s[t:]
			dfs(s1, t+2)
			dfs(s2, t+2)
		} else {
			s = strings.Replace(s, "x", "", -1)
			ss := strings.Split(s, "+")
			//fmt.Println(ss)
			for _, i := range ss {
				x, _ := strconv.Atoi(i)
				ans += x
			}
			return
		}
	}
	dfs(s, 1)
	fmt.Println(ans)
}


Measured memory_bytes: 640
import java.io.*;
import java.util.ArrayList;
public class Main{
	public static void main(String args[]){
    int a=0,b=0,c=0,i=0,n=0;
    BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    while(true){
      a = 0;
    try{
      String line = reader.readLine();
      if (line.equals("0")) break;
      for(String splitted: line.split("")){
        a += Integer.parseInt(splitted);
      }
      
		}catch(Exception e){
      System.out.println("error");
      break;
    }

    System.out.println(a);

  }
	}
}


Measured memory_bytes: 25432
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;


public class A
{
	public static void Main()
	{
		string[] args = Console.ReadLine().Split(' ');
		int A = Int32.Parse(args[0]);
		int B = Int32.Parse(args[1]);
		int C = Int32.Parse(args[2]);
		int D = Int32.Parse(args[3]);

		int AB = A + B;
		int CD = C + D;
		Console.WriteLine((AB > CD) ? "Left" :
			((AB == CD) ? "Balanced" : "Right"));
	}
}





Measured memory_bytes: 13140
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>
#include <regex>
#include <functional>
#include <complex>
#include <list>
#include <cassert>
/*多倍長整数/cpp_intで宣言
#include <boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;
*/

//#pragma GCC target ("avx2")
//#pragma GCC optimization ("O3")
//#pragma GCC optimization ("unroll-loops")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define rep2(i, n) for(int i = 2; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printin(a) printf(a ? "possible\n" : "imposible\n")
#define printdb(a) printf("%.50lf\n", a)//少数出力
#define printdbd(a) printf("%.16lf\n", a)//少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str())//string出力
#define all(x) (x).begin(), (x).end()
#define allsum(a, b, c) ((a + b) * c / 2)//等差数列の和、初項,末項,項数
#define pb push_back
#define priq priority_queue
#define rpriq priq<int, vector<int>, greater<int>>
#define deg_to_rad(deg) (((deg)/360.0)*2.0*PI)
#define rad_to_deg(rad) (((rad)/2.0/PI)*360.0)
#define Please return
#define AC 0
#define addf(T) [](T a, T b){return (a + b);}
#define minf(T) [](T a, T b){return min(a, b);}
#define maxf(T) [](T a, T b){return max(a, b);}


using ll = long long;

constexpr int INF = 1073741823;
constexpr int MINF = -1073741823;
constexpr ll LINF = ll(4661686018427387903);
constexpr ll MOD = 1000000007;
const long double PI = acos(-1.0L);

using namespace std;

void scans(string& str) {
	char c;
	str = "";
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);//最初の改行対策
	while (c != '\n' && c != -1) {
		str += c;
		scanf("%c", &c);
	}
}

void scanc(char& str) {
	char c;
	scanf("%c", &c);
	if (c == -1)return;
	while (c == '\n') {
		scanf("%c", &c);
	}
	str = c;
}

double acot(double x) {
	return PI / 2 - atan(x);
}

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

ll lcm(ll number1, ll number2) {//lcmを求める
	return number1 / gcd(number1, number2) * number2;
}

ll LSB(ll n) { return (n & (-n)); }

/*-----------------------------------------ここからコード-----------------------------------------*/



int main() {

	int n;
	scanf("%d", &n);
	vector<int> a(n);
	rep(i, n)scanf("%d", &a[i]);
	sort(all(a));
	printf("%d\n", accumulate(a.begin(), a.end() - 1, 0) + a.back() / 2);

	Please AC;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <string> 
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <functional>

using namespace std;
using ll = long long;

#define FOR(i, m, n) for(int i = (m);i < (n);i++)
#define REP(i,n) for(int i = 0; i < int(n); i++)
#define VI vector<int>
#define VVI vector<vector<int>>
#define VVVI vector<vector<vector<int>>>
#define VL vector<ll>
#define VVL vector<vector<ll>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define PAIR pair<int,int>
#define MP make_pair
#define VP vector<pair<int,int>>
#define VS vector<string>
#define QUE queue<int>
#define DEQ deque<int>
#define PQUE priority_queue<int> //5,5,4,3,3,2,...
#define REPQUE priority_queue<int, vector<int>, greater<int>> //1,1,2,3,4,4,5,...
#define SUM(obj) accumulate((obj).begin(), (obj).end(), 0)
#define SORT(obj) sort((obj).begin(), (obj).end()) // 1,2,3,4,5...
#define RESORT(obj) sort((obj).begin(), (obj).end(), greater<int>()) // 5,4,3,2,1...
#define UB(obj,n) upper_bound((obj).begin(), (obj).end(), n) //itr > n
#define LB(obj,n) lower_bound((obj).begin(), (obj).end(), n) //itr>= n

const ll MOD = (ll)1e9 + 7;

int main() {
	int K;
	cin >> K;
	VL A(K),L(K + 1),R(K + 1);
	REP(i,K) cin >> A[i];
	
	L[K] = R[K] = 2;
	REP(i, K) {
		
		ll y = (R[K - i] / A[K - (i + 1)])*A[K - (i + 1)];
		if (y < L[K - i]) {
			cout << -1 << endl;
			return 0;
		}
		
		
		ll x = (L[K - i] % A[K - (i + 1)] == 0) ? L[K - i] : (L[K - i] / A[K - (i + 1)] + 1)*A[K - (i + 1)];
		if (x > R[K - i]) {
			cout << -1 << endl;
			return 0;
 		}

		R[K - (i + 1)] = y + A[K - (i + 1)] - 1;
		L[K - (i + 1)] = x;


	}
	
	cout << L[0] << " " << R[0] << endl;
	return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main(){
    int H,W;
    cin >> H >> W;
   string board[50];
   for(int i = 0;i < H;i++) cin >> board[i];
   const int dx[8] = {-1,0,1,-1,1,-1,0,1};
   const int dy[8] = {-1,-1,-1,0,0,1,1,1};
   for(int i = 0;i < H;i++){
       for(int j = 0;j < W;j++){
           if(board[i][j] == '#') continue;
           int num = 0;
           for(int d = 0;d < 8;d++){
               const int ni = i + dx[d];
               const int nj = j + dy[d];
               if(ni < 0 || ni >= H) continue;
               if(nj < 0 || nj >= W) continue;
               if(board[ni][nj] == '#')num++;
           }
           board[i][j] = char(num + '0');
       }
   }
   for(int l = 0;l < H;l++) cout << board[l] << endl;
}

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(){
  ll n,m,k;
  cin>>n>>m>>k;
  vector<ll>a(n+1),b(m+1);
  rep(i,n){
    int na;
    cin>>na;
    a[i+1]=a[i]+na;
  }
  rep(i,m){
    int nb;
    cin>>nb;
    b[i+1]=b[i]+nb;
  }
  int ans=0;
  rep(i,n+1){
    if(k-a[i]<0)continue;
    int j=upper_bound(b.begin(),b.end(),k-a[i])-b.begin();
    if(j<=0)continue;
    chmax(ans,i+j-1);
  }
  cout<<ans<<endl;
  return(0);
}

Measured memory_bytes: 6372
#include <bits/stdc++.h>
using namespace std;
long long GCD(long long A,long long B){
    long long R = A % B;
    while(R != 0){
        A = B;
        B = R;
        R = A % B;
    }
    return B;
}
int main(void){
    int N;
    cin >> N;
    vector<long long> A(N);
    for(int i = 0; i < N; i++) cin >> A[i];
    sort(A.begin(),A.end());
    long long MaxG = 1000000000;
    for(int i = 0; i < N-1; i++) MaxG = min(MaxG,GCD(A[i+1],A[i]));
    cout << MaxG << endl;
}


Measured memory_bytes: 1024
from collections import deque
r, c, n = [int(item) for item in input().split()]
on_edge = [[] for _ in range(4)]
for i in range(n):
    x1, y1, x2, y2 = [int(item) for item in input().split()]
    v1_on_edge = x1 == 0 or x1 == r or y1 == 0 or y1 == c 
    v2_on_edge = x2 == 0 or x2 == r or y2 == 0 or y2 == c 
    if v1_on_edge and v2_on_edge:
        if x1 == 0:
            on_edge[0].append([y1, i])
        elif x1 == r:
            on_edge[2].append([y1, i])
        elif y1 == 0:
            on_edge[3].append([x1, i])
        elif y1 == c:
            on_edge[1].append([x1, i])
        if x2 == 0:
            on_edge[0].append([y2, i])
        elif x2 == r:
            on_edge[2].append([y2, i])
        elif y2 == 0:
            on_edge[3].append([x2, i])
        elif y2 == c:
            on_edge[1].append([x2, i])
for i in range(4):
    if i <= 1:
        on_edge[i].sort()
    else:
        on_edge[i].sort(reverse=True)
total = [item for line in on_edge for item in line]        
st = deque()
st.append(-1)
for val, item in total:
    if st[-1] == item:
        st.pop()
    else:
        st.append(item)
if st[-1] == -1:
    print("YES")
else:
    print("NO")



Measured memory_bytes: 35688
import bisect

N = int(input())
a = []
b = []
bb = []

for i in range(N):
	a.append(int(input()))

for i in range(N):
	b.append(int(input()))

a = sorted(a)
b = sorted(b)

for i in range(N):
	bb.append(bisect.bisect_left(a, b[i]))

ans = 1
for i in range(N):
	if bb[i] - i != 0:
		if bb[i] > i:
			ans = ans * (bb[i] - i)
		else:
			ans = ans * (i - bb[i] + 1)
		ans = ans % 1000000007

print(ans)

Measured memory_bytes: 14888