akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

const int N = 100000;
vector<int> G[N];

int ee = 0;
vector<int> et;
int L[N],R[N];
void dfs(int v){
    L[v] = ee++;
    et.pb(v);
    for(int c:G[v]){
        dfs(c);
    }
    R[v] = ee++;
    et.pb(v);
}

const int B = 448;

bool flip[B]={};
int sum[B]={};
int a[B][B];

void push(int bidx){
    if(!flip[bidx]) return;

    sum[bidx] = 0;
    rep(i,B){
        a[bidx][i] = !a[bidx][i];
        sum[bidx] += a[bidx][i];
    }

    flip[bidx] = false;
}

void FLIP(int l, int r){
    int lidx = l/B, ridx = r/B;
    push(lidx);
    push(ridx);
    if(lidx == ridx){
        for(int i=l; i<=r; ++i){
            if(a[lidx][i%B] == 1) --sum[lidx];
            else ++sum[lidx];
            a[lidx][i%B] = !a[lidx][i%B];
        }
    }
    else{
        for(int i=l%B; i<B; ++i){
            if(a[lidx][i%B] == 1) --sum[lidx];
            else ++sum[lidx];
            a[lidx][i%B] = !a[lidx][i%B];
        }
        for(int bidx=lidx+1; bidx<ridx; ++bidx){
            flip[bidx] = !flip[bidx];
            sum[bidx] = B-sum[bidx];
        }
        for(int i=0; i<=r%B; ++i){
            if(a[ridx][i%B] == 1) --sum[ridx];
            else ++sum[ridx];
            a[ridx][i%B] = !a[ridx][i%B];
        }
    }
}

int SUM(int l, int r){
    int lidx = l/B, ridx = r/B;
    push(lidx);
    push(ridx);
    int ret = 0;
    if(lidx == ridx){
        for(int i=l; i<=r; ++i) ret += a[lidx][i%B];
    }
    else{
        for(int i=l%B; i<B; ++i) ret += a[lidx][i%B];
        for(int bidx=lidx+1; bidx<ridx; ++bidx) ret += sum[bidx];
        for(int i=0; i<=r%B; ++i) ret += a[ridx][i%B];
    }
    return ret;
}

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

    for(int i=1; i<n; ++i){
        int p;
        cin >>p;
        --p;
        G[p].pb(i);
    }

    dfs(0);

    vector<char> c(n);
    rep(i,n) cin >>c[i];

    rep(i,ee){
        if(c[et[i]] == 'G'){
            a[i/B][i%B] = 1;
            ++sum[i/B];
        }
    }

    rep(i,q){
        int v;
        scanf(" %d", &v);
        --v;
        FLIP(L[v],R[v]);
        int s = SUM(0,ee-1);

        if(s/2 > n/2) printf("broccoli\n");
        else printf("cauliflower\n");
    }
    return 0;
}



Measured memory_bytes: 15700
#include <cmath>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <iomanip>
#include <map>
#include <stack>
#include <queue>

using namespace std;

typedef long long ll;

int n;
ll y;

int main() {
    cin >> n >> y;
    
    int a = 0, b = 0;
    ll ans;
    bool flag = 0;
    while (a <= n) {
        b = 0;
        while (b <= n - a) {
            ans = 10000 * a + 5000 * b + 1000 * (n - a - b);
            if (ans == y) {
                flag = 1;
                break;
            }
            b++;
        }
        if (flag) break;
        a++;
    }
    
    if (flag) cout << a << ' ' << b << ' ' << n - a - b << endl;
    else cout << "-1 -1 -1" << endl;
}


Measured memory_bytes: 256
import copy
from collections import deque


def bfs(s, f):
    f[s[0]][s[1]] = 0
    moves = [[1, 0], [-1, 0], [0, 1], [0, -1]]

    q = deque([s])
    while q:
        c = q.popleft()
        for m in moves:
            my, mx = c[0] + m[0], c[1] + m[1]

            if f[my][mx] == ".":
                f[my][mx] = f[c[0]][c[1]] + 1
                q.append([my, mx])
            else:
                continue

    f = sum(f, [])
    return max([x for x in f if type(x) == int])


def main():
    H, W = map(int, input().split())
    field_s = []

    for h in range(H + 2):
        field_s.append(["#"] * (W + 2))
        if 1 <= h <= (H):
            field_s[h][1:-1] = list(map(str, input().rstrip()))

    start = []
    for y in range(1, H + 1):
        for x in range(1, W + 1):
            if field_s[y][x] == ".":
                start.append([y, x])

    ans = 0
    for s in start:
        field = copy.deepcopy(field_s)
        ans = max(ans, bfs(s, field))

    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 3572
#include<iostream>
    using namespace std;
    int main()
    {
      int a;
      int b;
      std::cin >> a;
      std::cin >> b;

      int n = 1;
      int i = 0;

      while (n < b) {
        n = 1 + (a-1)*(i+1);
        i++;
      }

      std::cout << i << '\n';
    }


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

using namespace std;

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

int main(){
    int a, b;
    cin >> a >> b;
    if((a + b)%3 && a%3 && b%3){
        cout << "Impossible" << endl;
    }else{
        cout << "Possible" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
from collections import Counter
n,k,l=map(int,input().split())
city1=[i for i in range(n)]
city2=[i for i in range(n)]
def root(c,x):
  if x==c[x]:
    return x
  else:
    return root(c,c[x])
def union(c,x,y):
  rx=root(c,x)
  ry=root(c,y)
  if rx>ry:
    c[rx]=ry
  else:
    c[ry]=rx
for i in range(k):
  a,b=map(int,input().split())
  union(city1,a-1,b-1)
for i in range(l):
  a,b=map(int,input().split())
  union(city2,a-1,b-1)
r=[]
for i in range(n):
  r.append((root(city1,i),root(city2,i)))
c=Counter(r)
for i in range(n):
  ans=c[r[i]]
  if i==n-1:
    print(ans)
  else:
    print(ans,end=' ')

Measured memory_bytes: 56060
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  ll N, A, B;
  cin>>N>>A>>B;
  ll h[N];
  for(int i=0;i<N;++i) cin>>h[i];
  ll l=1, r=inf, m;
  ll tmp;
  while(l<r) {
    m = (l+r)/2;
    tmp = 0;
    for(int i=0;i<N;++i) {
      if(h[i]-B*m<=0) continue;
      if((h[i]-B*m)%(A-B)==0) tmp += (h[i]-B*m)/(A-B);
      else tmp += (h[i]-B*m)/(A-B)+1;
    }
    if(tmp<=m) r = m;
    else l = m+1;
  }
  cout<<l<<endl;
}



Measured memory_bytes: 4396
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(I,A,B) for(int I = int(A); I < int(B); ++I)
#define FORR(I,A,B) for(int I = int((B)-1); I >= int(A); --I)
#define REV(x) (reverse(x.begin(),x.end()))

int encode(int a){
	if(a<=399&&a>=1){
		return 1;
	}else if(a<=799){
		return 2;
	}else if(a<=1199){
		return 3;
	}else if(a<=1599){
		return 4;
	}else if(a<=1999){
		return 5;
	}else if(a<=2399){
		return 6;
	}else if(a<=2799){
		return 7;
	}else if(a<=3199){
		return 8;
	}
}


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

	int n,f=0;
	set<int> se;
	cin >> n;
	FOR(i,0,n){
		int a;
		cin >> a;
		if(a>=3200){
			f++;
		}else{
			se.insert(encode(a));
		}
	}
	cout << max((int)se.size(),1) << " " << f+(int)se.size() << endl;
}

// _______  _____  _______  _____  _______ _______ _____ _______ _____ _    _ _______ 
// |       |     | |  |  | |_____] |______    |      |      |      |    \  /  |______ 
// |_____  |_____| |  |  | |       |______    |    __|__    |    __|__   \/   |______ 
//
//  _____   ______  _____   ______  ______ _______ _______ _______ _____ __   _  ______   /
// |_____] |_____/ |     | |  ____ |_____/ |_____| |  |  | |  |  |   |   | \  | |  ____  / 
// |       |    \_ |_____| |_____| |    \_ |     | |  |  | |  |  | __|__ |  \_| |_____| .  
//


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(void){
int a,b;   
int yes=0;
scanf("%d %d",&a,&b);
for(int i=a;i<=b;i++){
    if(i/10000==i%10&&i/10%10==i/1000%10){yes++;}
}
printf("%d\n",yes);
}


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

int main(){
    int a, b, c, t;
    cin >> a  >> b >> c;
    
    if ( a > b ) { t = a; a = b; b = t; }
    if ( b > c ) { t = b; b = c; c = t; }
    if ( a > b ) { t = a; a = b; b = t; }
    
    cout << a << " " << b << " " << c << endl;
    
    return 0;
}


Measured memory_bytes: 3096
#include <algorithm> //STLͨ���㷨
#include <cmath> //������ѧ����
#include <cstdio> //��������/�������
#include <iostream> //����������/���
#include <cstring> //�ַ�������
#include <string> //�ַ�����
#include <ctime> //�������ʱ��ĺ���
#define itn int
#define fro for
#define ll long long
#define reg register
#define inf 1234567890
#define rep(i,a,b,c) for (int i=a;i<=b;i+=c)
/*#include <bitset> //STLλ������
#include <cstype> //�ַ�����
#include <cerrno> //���������
#include <complex> //������
#include <clocale> //���屾�ػ�����
#include <cstdlib> //������������ڴ���亯��
#include <deque> //STL˫�˶�������
#include <exception> //�쳣������
#include <fstream> //�ļ�����/���
#include <functional> //STL�������㺯��(���������)
#include <limits> //�����������������ֵ����
#include <list> //STL�����б�����
#include <map> //STLӳ������
#include <iomanip> //����������/���
#include <ios> //��������/���֧��
#include <iosfwd> //����/���ϵͳʹ�õ�ǰ������
#include <istream> //����������
#include <ostream> //���������
#include <queue> //STL��������
#include <set> //STL��������
#include <sstream> //�����ַ�������
#include <stack> //STL��ջ����
#include <stdexcept> //��׼�쳣��
#include <streambuf> //�ײ�����/���֧��
#include <utility> //STLͨ��ģ����
#include <vector> //STL��̬��������
#include <cwchar.h>//���ַ�����������/���
#include <cwctype.h> //���ַ�����*/

using namespace std;

int ans;

int max(int x,int y){return x>y?x:y;}

int min(int x,int y){return x<y?x:y;}

int abs(int x){return x>0?x:-x;}

int gcd(int x,int y){return (!y)?x:gcd(y,x%y);}

void exgcd(int a,int b,int &d,int &x,int &y){if (!b){d=a,x=1,y=0;}else{exgcd(b,a%b,d,y,x);y-=x*(a/b);}}

int quick_power(ll a,int b){ll r=1;for (;b;b>>=1,a=a*a)if (b&1) r=r*a;return r;}

inline char read() {
	static const int IN_LEN = 1000000;
	static char buf[IN_LEN], *s, *t;
	return (s == t ? t = (s = buf) + fread(buf, 1, IN_LEN, stdin), (s == t ? -1 : *s++) : *s++);
}
template<class T>
inline void read(T &x) {
	static bool iosig;
	static char c;
	for (iosig = false, c = read(); !isdigit(c); c = read()) {
		if (c == '-') iosig = true;
		if (c == -1) return;
	}
	for (x = 0; isdigit(c); c = read()) x = x * 10 + (c ^ '0');
	if (iosig) x = -x;
}

char sr[10000000],z[20];int C=-1,Z=0;
void Ot(){fwrite(sr,1,C+1,stdout),C=-1;}
void print(int x){
	if (x<0) sr[++C]='-',x=-x;
    while(z[++Z]=x%10+48,x/=10);
    while(sr[++C]=z[Z],--Z);sr[++C]='\n';
}
//int find(int x){return fa[x]=fa[x]==x?x:find(fa[x]);}

//void add(int x,int y,int z){to[++cnt]=y;v[cnt]=z;Next[cnt]=head[x];head[x]=cnt;}
string s;

int main()
{
	cin>>s;
	int len=s.length();
	s=' '+s;
	if (s[len]=='1'||s[1]=='0'||s[len-1]=='0') return puts("-1"),0;

	int now=2;

	while (now<=len-now)
	{
		if (s[now]!=s[len-now]) return puts("-1"),0;
		now++;
	}

	int root=2,num=1;
	now=2;
	printf("2 1\n");
	while (now<=len-now)
	{
		if (s[now]=='1')
		{
			printf("%d %d\n",++now,root);
			root=now;
		}
		else printf("%d %d\n",++now,root);
		num++;
	}
	for (int i=num+1;i<len;i++) printf("%d %d\n",root,++now);
	return 0;
}









Measured memory_bytes: 1660
#include<cstdio>
#include<algorithm>
#define rep(i,l,r) for (int i=(l); i<=(r); i++)
using namespace std;

const int N=2010,mod=1e9+7;
int n,m,K,fac[N*N],inv[N*N],f[N][N];

int ksm(int a,int b){
	int res=1;
	for (; b; a=1ll*a*a%mod,b>>=1)
		if (b & 1) res=1ll*res*a%mod;
	return res;
}

int C(int n,int m){ return n<m ? 0 : 1ll*fac[n]*inv[m]%mod*inv[n-m]%mod; }

int main(){
	scanf("%d%d",&n,&K); m=n*K;
	if (K==1){ puts("1"); return 0; }
	fac[0]=1; rep(i,1,m) fac[i]=1ll*fac[i-1]*i%mod;
	inv[m]=ksm(fac[m],mod-2);
	for (int i=m; i; i--) inv[i-1]=1ll*inv[i]*i%mod;
	f[0][0]=1;
	rep(i,1,n) rep(j,0,i)
		f[i][j]=(f[i][j]+f[i-1][j]+(!j?0:1ll*f[i][j-1]*(n-j+1)%mod*C((n-i)+(n-j+1)*(K-1)-1,K-2)%mod))%mod;
	printf("%d\n",f[n][n]);
	return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> vec(n);
  for(int i = 0;i < n; i++){
    cin >> vec.at(i);
  }
  sort(vec.begin(), vec.end());
  int sum = 100000000;
  
  for(int i = 0;i < vec.at(n-1) - vec.at(0) + 1;i++){
    int ans = 0;
    for(int j = 0;j < n; j++){
    ans += (max(vec.at(j), i+vec.at(0)) - min(vec.at(j), i+vec.at(0))) * (max(vec.at(j), i+vec.at(0)) - min(vec.at(j), i+vec.at(0)));
  }
    sum = min(sum, ans);
  }
  cout << sum;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
  #include <string>
  #include <vector>
  #include <algorithm>
  #include <utility>
  using namespace std;
  typedef long long ll;
  #define rep(i,n) for (int i=0;i < (int)(n);i++)

  int main(){
   int x;
   int ans=0;
   cin >> x;
   ans+=(x/500)*1000;
   x%=500;
   ans+=(x/5)*5;
   cout << ans << endl;
    return 0;
  }

Measured memory_bytes: 256
import sys
import math 
ni = lambda: int(ns())
na = lambda: list(map(int, input().split()))
ns = lambda: input()

N=ni()
G=[dict() for i in range(N)]
for i in range(N-1):
    u,v,w=na()
    G[u-1][v-1]=w
    G[v-1][u-1]=w

dist=[-1 for i in range(N)]
color=[0 for i in range(N)]
dist[0]=0
q=[0]
while(len(q)>0):
    r=q.pop()
    for p in G[r]:
        if(dist[p]!=-1):
            continue
        else:
            dist[p]=dist[r]+G[r][p]
            q.append(p)
for i in range(N):
    if(dist[i]%2==0):
        color[i]=1

for ans in color:
    print(ans)

Measured memory_bytes: 49912
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cerr << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cerr<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 500010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 30;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
mt19937 rng; //use it by rng() % mod, shuffle(all(vec), rng)
///////////////////////////////////////////////////////////////////////////////////////////////////

int N;
int A[MAX_N];

void solve() {
	cin >> N;
	rep(i, 0, N) cin >> A[i];
	A[0]--;
	rep(i, 1, N) {
		if(A[i - 1] < A[i]) A[i]--;
		else if(A[i - 1] > A[i]) {
			cout << "No\n"; return;
		}
	}
	cout << "Yes\n";
}

uint32_t rd() {
	uint32_t res;
#ifdef __MINGW32__
	asm volatile("rdrand %0" :"=a"(res) ::"cc");
#else
	res = std::random_device()();
#endif
	return res;
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
    cerr << fixed;
	cerr.precision(6);
	rng.seed(rd());
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
	if(!freopen("in.txt", "rt", stdin)) return 1;
#endif	
	solve();
    cerr << "Time: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}



Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<set>
#include<math.h>
#include <bits/stdc++.h>
#include<fstream>
using namespace std;

int main(){
   int n;
   int d[100][2];
   cin>>n;
   for(int i=0;i<n;i++){
      int d1,d2;
      cin>>d1>>d2;
      d[i][0]=d1;
      d[i][1]=d2;
   }
   int cnt=0;
   int f=0;
   for(int i=0;i<n;i++){
      if(d[i][0]==d[i][1]){
         cnt++;
      }else{
         cnt=0;
      }
      if(cnt==3){
         cout<<"Yes"<<endl;
         f=1;
         break;
      }

   }
   if(f==0) cout<<"No"<<endl;
   return 0;
}

Measured memory_bytes: 3524
#include <stdio.h>

int main(void) {

  long a,b,c,d;
  scanf("%ld %ld %ld %ld", &a, &b, &c, &d);
  long ans = a*c;
  if (a*d > ans) {
    ans = a*d;
  }
  if (b*c > ans) {
    ans = b*c;
  }
  if (b*d > ans) {
    ans = b*d;
  }
  printf("%ld\n", ans);

  return 0;
}

Measured memory_bytes: 1704
#include <iostream>
#include<map>

using namespace std;
#define fin(ans) cout << (ans) << '\n'
int main()
{
    int A[3];
    cin >> A[0] >> A[1] >> A[2];
    sort(A,A+3);
    fin(A[0]+A[1]);
    return 0;
}

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

using namespace std;

typedef long long ll;

const int INF = 1000000000;

char getop(int i)
{
  return (i == 0) ? '+' : '-';
}

int main()
{
  char buf[64] = { '\0' };
  scanf("%s", buf);
  int A = buf[0] - '0', B = buf[1] - '0', C = buf[2] - '0', D = buf[3] - '0';
  for (int i = 0; i < 2; ++i) {
    int val1 = (i == 0) ? A + B : A - B;
    for (int j = 0; j < 2; ++j) {
      int val2 = (j == 0) ? val1 + C : val1 - C;
      for (int k = 0; k < 2; ++k) {
        int val3 = (k == 0) ? val2 + D : val2 - D;
        if (val3 == 7) {
          printf("%d%c%d%c%d%c%d=7\n",
                 A, getop(i), B, getop(j), C, getop(k), D);
          return 0;
        }
      }
    }
  }
  printf("ouch!\n");
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define sci(n)               scanf("%d",&n)
#define scl(n)               scanf("%lld",&n)
#define scd(n)               scanf("%lf",&n)
#define FOR(i,n)             for(ll i=1;i<=n;i++)
#define LOOP(i,n)            for(ll i=0;i<n;i++)
#define loop(a,b)            for(ll i=a;i<=b;i++)
#define ll long long
#define pb push_back
#define mp make_pair
struct edge
{
    int u,v,w;
};
bool operator<(edge A,edge B)
{
    return A.w<B.w;
}
vector<edge>E;
int p[10005];
int find(int x)
{
    if(p[x]==x)
        return x;
    return p[x]=find(p[x]);
}
void mst()
{
    sort(E.begin(),E.end());
    int sz=E.size();
    int ans=0;
    LOOP(i,sz)
    {
        if(find(E[i].u)!=find(E[i].v))
        {
            p[p[E[i].u]]=p[E[i].v];
            ans+=E[i].w;
            //cout << ans << endl;
        }
    }
    printf("%d\n",ans);
}
int main()
{
    int n,m;
    sci(n);
    sci(m);
    LOOP(i,m)
    {
        int u,v,w;
        sci(u);
        sci(v);
        sci(w);
        p[u]=u;
        p[v]=v;
        edge get;
        get.u=u;
        get.v=v;
        get.w=w;
        E.pb(get);
    }
    mst();
}




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

void swap(int A[], int a, int b){
	int num = A[a];
	A[a] = A[b];
	A[b] = num;
}

void write(int A[], int a, int b){
	A[a] = A[b];
}

int main(){
	map<int, int> A;
	int N, M, a, d;
	cin >> N >> a >> d >> M;
	for(int i = 0; i < M; i++){
		int x, y, z;
		cin >> x >> y >> z;
		if(x == 0)
		{
			int yy = y, zz = z;
			if(A.find(y) != A.end())
				yy = A[y];
			if(A.find(zz) != A.end())
				zz = A[z];
			A[y] = zz;
			A[z] = yy;
 		}
		else
		{
			int zz = z;
			if(A.find(zz) != A.end())
				zz = A[z];
			A[y] = zz;
		}
	}
	long long k;
	cin >> k;
	if(A.find(k) != A.end())
		k = A[k];
	cout << a + d * (k - 1) << endl;
}

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

const int MAX = 2100000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
  int k;
  cin >> k;
  string s;
  cin >> s;
  size_t size = s.length();
  ll a=1;
  ll res=0;
  COMinit();
  rep(i,k+1){
    res+=a*COM(k+size,i);
    res%=MOD;
    a*=25;
    a%=MOD;
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 53520
#include <iostream>
#include <vector>
#include <deque>
#include <algorithm>
#include <numeric>
#include <string>
#include <cstring>
#include <list>
#include <unordered_set>
#include <tuple>
#include <cmath>
#include <limits>
#include <type_traits>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <set>
#include <bitset>
#include <regex>
#include <random>
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
#define rep(i,n)for(ll i=0;i<n;++i)
#define exout(x) printf("%.10f\n", x)
const double pi = acos(-1.0);
const ll MOD = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 1010;

//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

ll lcm(ll x, ll y) {
	if (x == 0 || y == 0)return 0;
	return (x / gcd(x, y) * y);
}

//組み合わせの余りを求める
ll fac[MAX_N], finv[MAX_N], inv[MAX_N];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX_N; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll dx[4] = { 0,0,-1,1 };
ll dy[4] = { -1,1,0,0 };
ll dp[101010];

//long longしか使わない
//素数は1より大きい
int main() {
	ll n;
	cin >> n;
	vector<ll>a(n);
	rep(i, n) {
		cin >> a[i];
	}
	ll res = a[0];
	for (ll i = 1;i < n;++i) {
		res ^= a[i];
	}
	if (n % 2 == 0) {
		rep(i, n) {
			ll res2 = res;
			res2 ^= a[i];
			cout << res2 << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 4760
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  Int n;
  cin>>n;
  vector<Int> as(n);
  for(Int i=0;i<n;i++) cin>>as[i];
  Int sum=0;
  for(Int i=0;i<n;i++){
    if(~i&1) sum+=as[i];
    else sum-=as[i];
  }
  assert(~sum&1);
  vector<Int> bs(n);
  bs[0]=sum;
  for(Int i=1;i<n;i++) bs[i]=(as[i-1]-bs[i-1]/2)*2;
  for(Int i=0;i<n;i++){
    if(i) cout<<" ";
    cout<<bs[i];
  }
  cout<<endl;
  return 0;
}


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

template <typename InputIterator>
typename InputIterator::value_type
summation(InputIterator first, InputIterator last) {
  using T = typename InputIterator::value_type;
  T *p = new T();
  const auto sum = std::accumulate(first, last, *p);
  delete p;
  return sum;
}
template <typename T>
std::istream& operator>> (std::istream &stream, std::vector<T> &v);
template <typename T1, typename T2>
std::istream& operator>> (std::istream &stream, std::pair<T1, T2> &p);
template <typename T>
std::istream& operator>> (std::istream &stream, std::vector<T> &v) {
  for (auto &i : v) {
    stream >> i;
  }
  return stream;
}
template <typename T1, typename T2>
std::istream& operator>> (std::istream &stream, std::pair<T1, T2> &p) {
  stream >> p.first >> p.second;
  return stream;
}

int main() {
  int a, b, c, d;
  std::cin >> a >> b >> c >> d;
  std::cout << std::max(a * b, c * d) << std::endl;
  return 0;
}


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

using namespace std;

int main(){
    int N;
    cin>>N;
    int a[N];
    for(int i=0;i<N;++i)cin>>a[i];

    sort(a,a+N,greater<int>());
    int Alice=0,Bob=0;

        for(int i=0;i<N;++i){
            if(i%2==0){
                Alice+=a[i];
            }else{
                Bob+=a[i];
            }
        }
    cout<<Alice-Bob;




}

Measured memory_bytes: 3164
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>
#include <stack>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;

template<class T>
constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;



int main() {
    int n, m;
    cin >> n >> m;
    vector<int> p(n, 0);
    vector<vector<int>> G(n);
    for (int i = 0; i < m; ++i) {
        int x, y;
        scanf("%d %d", &x, &y);
        G[x-1].emplace_back(y-1);
        p[y-1]++;
    }
    stack<int> st;
    for (int i = 0; i < n; ++i) {
        if(p[i] == 0) st.emplace(i);
    }
    queue<int> Q;
    while(!st.empty()){
        int i = st.top(); st.pop();
        Q.emplace(i);
        for (auto &&j : G[i]) {
            p[j]--;
            if(p[j] == 0) st.push(j);
        }
    }
    vector<int> dp(n, 0);
    int ans = 0;
    while(!Q.empty()){
        for (auto &&i : G[Q.front()]) {
            dp[i] = max(dp[i], dp[Q.front()]+1);
        }
        Q.pop();
    }
    cout << (*max_element(dp.begin(), dp.end())) << "\n";
    return 0;
}


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

int main()
{
    ll n;
    cin >> n;
    ll power = 1;
    for(ll i = 1;i <= n;i++){
        power *= i;
        power %= 1000000007;
    }
    cout << power << endl;
}


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

int main() {
    int n;
    cin >> n;
    vector<int> x(n), y(n);
    for (int i = 0; i < n; i++) cin >> x[i] >> y[i];

    double sum = 0;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            if (i != j) {
                int xx = x[i] - x[j];
                int yy = y[i] - y[j];
                double d = sqrt(xx*xx + yy*yy);
                sum += d;
            }
        }
    }
    double ans = sum / (double)n;
    printf ("%.7lf", ans);
}

Measured memory_bytes: 3816
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>
#define IP pair<int,P>
#define PI pair<P,int>
#define PP pair<P,P>
#define Yes(f){cout<<(f?"Yes":"No")<<endl;}
#define YES(f){cout<<(f?"YES":"NO")<<endl;}
int Madd(int x,int y) {return (x+y)%M;}
int Msub(int x,int y) {return (x-y+M)%M;}
int Mmul(int x,int y) {return (x*y)%M;}


signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);

  int n,w;
  cin>>n>>w;
  vi dp(n*100+1,inf);
  dp[0]=0;
  rep(_,n){
    int a,b;
    cin>>a>>b;
    rrep(i,n*100-a){
      if(dp[i]==inf) continue;
      dp[i+a]=min(dp[i+a],dp[i]+b);
    }
    
  }

  rrep(i,n*100){
    if(dp[i]<=w){
      cout<<i<<endl;
      break;
    }
  }


}


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


int gcd(int a, int b)
{
    if( a < b )
      swap(a, b);
     
    while(b!=0){
        int mod = a % b;
        a = b;
        b = mod;
    }
    return a;
}

int main(void)
{
  int n;
  cin >> n;
  
  vector<int> a, n_gcd;
  array<int, 100001> n_gcd_fwd, n_gcd_bwd;
  for(int i=0; i<n; i++){
      int tmp;
      cin >> tmp;
      a.push_back(tmp);      
  }
  
  n_gcd_fwd[0] = a[0];
  for(int i=1; i<n-1; i++){
    n_gcd_fwd[i] = gcd(n_gcd_fwd[i-1], a[i]);
  }
  n_gcd_bwd[n-1-1] = a[n-1];
  for(int i=1; i<n-1; i++){
      n_gcd_bwd[n-1-1-i] = gcd(n_gcd_bwd[n-1-1-i+1], a[n-1-i]);
  }

  n_gcd.push_back(n_gcd_bwd[0]);
  for(int i=1; i<n-1; i++){
      n_gcd.push_back(gcd(n_gcd_fwd[i-1], n_gcd_bwd[i]));  
  }
  n_gcd.push_back(n_gcd_fwd[n-2]);

  sort(n_gcd.begin(), n_gcd.end());
  
  cout << n_gcd[n-1] << endl;
  
  return 0;
}


Measured memory_bytes: 2168
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <numeric>
#include <ctime>
#include <complex>
#include <bitset>
#include <random>

using namespace std;

typedef long long ll;
typedef long double ld;

#define int ll
#define double ld
#define loop(i, n) for(int i = 0; i < (int)n; ++i)
#define loop1(i, n) for(int i = 1; i <= (int)n; ++i)
#define F first
#define S second
#define pb push_back
#define pi pair <int, int>
#define all(x) begin(x), end(x)
#define ti tuple <int, int, int>
#define Point Vect
#define no {cout << -1; return;}
#define mkp make_pair
#define cerr if (0) cerr

const int N = 2e5 + 7;

int mn[N], mx[N];

void solve() {
    int n; cin >> n;
    loop(i, n)
        cin >> mn[i] >> mx[i];
    sort(mn, mn + n);
    sort(mx, mx + n);
    if (n % 2 == 1)
        cout << mx[n / 2] - mn[n / 2] + 1;
    else
        cout << (mx[(n - 1) / 2] + mx[n / 2]) - (mn[(n - 1) / 2] + mn[n / 2]) + 1;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //int t; cin >> t; loop(i, t)
    solve();
    return 0;
}


Measured memory_bytes: 6736
#include <cstdio>
#include <cstring>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>


using namespace std;

int main()
{
	int n, a, b, d1[100000], d2[100000], f=0, s=0;
	scanf("%d", &n);
	vector<int> vs[100000];
	for(int i=0; i<n-1; i++){
		scanf("%d %d", &a, &b);
		a--;
		b--;
		vs[a].push_back(b);
		vs[b].push_back(a);
	}
	for(int i=0; i<n; i++){
		if(i==0){
			d1[i]=0;
			d2[i]=-1;
		}else if(i==n-1){
			d1[i]=-1;
			d2[i]=0;
		}else{
			d1[i]=-1;
			d2[i]=-1;
		}
	}

	vector<int> v1, v2;
	v1.push_back(0);
	while(!v1.empty()){
		int v=v1.back();
		v1.pop_back();
		for(auto itr=vs[v].begin();itr!=vs[v].end(); itr++){
			int w=*itr;
			if(d1[w]==-1){
				d1[w]=d1[v]+1;
				v1.push_back(w);
			}
		}
	}
  	v2.push_back(n-1);
	while(!v2.empty()){
		int v=v2.back();
		v2.pop_back();
		for(auto itr=vs[v].begin();itr!=vs[v].end(); itr++){
			int w=*itr;
			if(d2[w]==-1){
				d2[w]=d2[v]+1;
				v2.push_back(w);
			}
		}
	}
	for(int i=0; i<n; i++){
		if(d1[i]<=d2[i]){
			f++;
		}else{
			s++;
		}
	}

	if(f<=s){
		printf("%s\n", "Snuke");
	}else{
		printf("%s\n", "Fennec");
	}
	return 0;
}

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

//template
#define rep(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll;
const int inf = 0x3fffffff; const ll INF = 0x1fffffffffffffff; const double eps=1e-12;
template<typename T>inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T>inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
//end



int main(){
   int n,x,t; cin>>n>>x>>t;
   cout<<t*((n+x-1)/x)<<endl;
   return 0;
}

Measured memory_bytes: 3620
n,h=map(int,input().split())
a,b=[],[]

for i in range(n):
  inp=list(map(int,input().split()))
  a.append(inp[0])
  b.append(inp[1])

am=max(a)
b.sort()
b.reverse()
c=0
for i in b:
  if i<am:
    break
  c+=1
  h-=i
  if h<=0:
    break
c+=max((h-1)//am+1,0)
print(c)

Measured memory_bytes: 85656
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<cmath>
#include<deque>
using namespace std;

using ll = long long;
const int INF = 1001001001;
const ll LLINF = 1001001001001001001;

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

ll coun = 0;

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

  if (n % 2) {
    cout << 0 << endl;
    return 0;
  }

  ll x = 10;
  ll res = 0;
  while (n / x > 0) {
    res += n / x;
    x *= 5;
  }
  cout << res << endl;
}


Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define uniq(x) (x).erase(unique(ALL(x)),(x).end())
#define SORT(x) sort(ALL(x))
#define REV(x) reverse(ALL(x))
#define foreach(it,x) for(__typeof((x).begin()) it=(x).begin();it!=(x).end();it++)
#define debug(x) cerr<<#x<<"="<<(x)<<endl
#define gett() cerr<<"Time:"<<clock()<<"ms."<<endl
#define ri(x) scanf("%d",&x)
#define rl(x) scanf("%lld",&x)
#define rlcfpoj(x) scanf("%I64d",&x)
#define pi(x) printf("%d",x)
#define pl(x) printf("%lld",x)
#define plcfpoj(x) printf("%I64d",x)
#define lfd() printf("\n")
#define sp() printf(" ")
#define inrep(x) int x;scanf("%d",&x);while(x--)
#define testbit(mask,i) (((mask)>>(i))&1)
#define setbit(mask,i) ((mask)|(1<<i))
#define delbit(mask,i) ((mask)^(1<<i))
string str[100100];
map<string,int> mp;
int n;
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>str[i];
		sort(str[i].begin(),str[i].end());
		mp[str[i]]++;
	}
	long long res=0LL;
	for(int i=1;i<=n;i++){
		res+=(long long)(mp[str[i]]-1);
	}
	cout<<res/2LL<<endl;
	return 0;
}


Measured memory_bytes: 16640
#include<bits/stdc++.h>
using namespace std;
inline void E(){puts("-1");exit(0);}
typedef long long ull;
const int N=1e5+5;
int n,i,a[N];ull l[N],r[N],ans,v[N];
int main(){
	scanf("%d",&n);
	for(i=0;i<=n;++i)scanf("%d",a+i);
	l[0]=r[0]=1;
	for(i=0;i<n;++i){
		if(r[i]<=a[i])E();
		if(l[i]<=a[i])l[i+1]=1;else l[i+1]=l[i]-a[i];
		r[i+1]=r[i]-a[i]<<1;r[i+1]=min(r[i+1],1ll<<50);
	}
	if(l[n]>a[n] || r[n]<a[n])E();
	v[n]=a[n];
	for(i=n-1;i>=0;--i){
		v[i]=min(r[i],v[i+1]+a[i]);
	}
	for(i=0;i<=n;++i)ans+=v[i];
	cout<<ans<<endl;
}

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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

int main()
{
    string s, t;
    cin >> s >> t;
    sort(ALL(s));
    sort(ALL(t), greater<int>());

    if (s < t)
        OP("Yes");
    else
        OP("No");

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int a, b, cnt, i, n, A = 0, B = 0;
	while (scanf("%d %d", &a, &b) != EOF) {
		a = a + b;
		if (10 > a) {
			printf("1\n");
		}
		else {
			while (1) {
				a = a / 10;
				B++;
				if (a < 10) {
					printf("%d\n", B+1);
					break;
				}
			}
		}
		B = 0;
	}
}

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

int main()
{
	int n; cin >> n;
	string s; cin >> s;
	
	bool equal = true;
	string ans;

	if (n % 2 != 0)	{
		ans = "No";
	}
	else {
		for (int i = 0; i <= n / 2 - 1; i++) {
			if (s.at(i) != s.at(n / 2 + i)) equal = false;
		}
		if (equal) {
			ans = "Yes";
		}
		else {
			ans = "No";
		}
	}

	cout << ans << endl;	

	return 0;
}

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

int main()
{
    int t=1;
    //cin>>t;
    while(t--)
    {
      ll n,m,k; cin>>n>>m>>k;
      ll arr1[n],arr2[m];
      for(int i=0;i<n;i++) cin>>arr1[i];
      for(int i=0;i<m;i++) cin>>arr2[i];
      ll dp[n+1]; dp[0]=arr1[0];
      ll max_=0,run=0,i=0;
      for(i=0;i<n && run+arr1[i]<=k;i++)
      {
        run+=arr1[i];
      }
      max_=i; run=0;
      for(int i=1;i<n;i++) dp[i]=dp[i-1]+arr1[i];
      for(int i=0;i<m &&run<=k;i++)
      {
        //i books from second pile
        // costed run 
        run+=arr2[i];
        if(run>k) break;
        ll idx=upper_bound(dp,dp+n,k-run)-dp;
        //cout<<" for run ="<<run<<" "<<i+1<<" + "<<idx<<endl;
        max_=max(max_,i+1+idx);
      }
      cout<<max_;
    }
}

Measured memory_bytes: 8304
#include<iostream>
#include<queue>
using namespace std;
#define ll long long

int main(){
    int n,m;cin>>n>>m;
    int a;
    priority_queue<int> que;
    for(int i=0;i<n;i++){
        cin>>a;
        que.push(a);
    }
    for(int i=0;i<m;i++){
        int b=que.top();
        que.pop();
        b/=2;
        que.push(b);
    }
    ll sum=0;
    while(!que.empty()){
        int c=que.top();
        que.pop();
        sum+=c;
    }
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
 
#define MOD (1000000007)
#define f first
#define s second
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) x.begin(), x.end()
#define print(vec,l,r) for(int i = l; i <= r; i++) cout << vec[i] <<" "; cout << endl;
#define forf(i,a,b) for(int i = (a); i < (b); i++)
#define forr(i,a,b) for(int i = (a); i > (b); i--)
#define input(vec,N) for(int i = 0; i < (N); i++) cin >> vec[i];
typedef long long int ll;
#define ld long double
const int N = 3003;
//https://codeforces.com/problemset/page/2?tags=1700-1700
ld ans=0;
ld dp[N][N];
 
void solve(){
   int n;
   cin>>n;
   ld prob[n+3];
   for(int i=1;i<=n;i++){
     cin>>prob[i];
   }
   //ld dp[n+3][n+3];
   dp[0][0]=1;
   for(int i=1;i<=n;i++){
     for(int j=0;j<=i-1;j++){
       dp[i][j+1] += dp[i-1][j]*prob[i];
       dp[i][j] += dp[i-1][j]*(1-prob[i]);
     }
   }
   ld ans=0;
   for(int i=n/2+1;i<=n;i++){
     ans+=dp[n][i];
   }
   cout<<fixed<<setprecision(12)<<ans<<'\n';
}
 
 
int main(){
 	ios_base::sync_with_stdio(false);
  cin.tie(NULL);
	int T;
  //cin >> T;
  //cout<<prs.size()<<'\n';
	 T = 1;
  //visited[1]=1;
	while(T--){
		solve();
	}
}

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

int main() {
  
  string O, E, ans; cin >> O >> E;
  
  for (int i = 0; i < E.size(); i++) ans = ans + O.at(i) + E.at(i);
  
  if (O.size() != E.size()) ans += O.back();
  
  cout << ans << endl;
  
}

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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

int x, k, r[100002], q, t[100000], a[100000];
int s[100002], mi[100002], ma[100002];

void setII(int & v, int l, int r) {
	setmax(v, l);
	setmin(v, r);
}

int main() {
	cin >> x >> k;
	r[0] = 0;
	inc1(i, k) { cin >> r[i]; }
	k++;
	r[k] = 1e9 + 1;
	cin >> q;
	inc(i, q) { cin >> t[i] >> a[i]; }
	
	s[0] = 0;
	mi[0] = 0;
	ma[0] = x;
	inc1(i, k) {
		int v = (i % 2 != 0 ? -1 : 1) * (r[i] - r[i - 1]);
		s[i] = s[i - 1] + v;
		mi[i] = mi[i - 1] + v;
		ma[i] = ma[i - 1] + v;
		setII(mi[i], 0, x);
		setII(ma[i], 0, x);
	}
	
	
	int p = 0;
	inc(qq, q) {
		while(r[p + 1] <= t[qq]) { p++; }
		
		int w = s[p] + a[qq];
		setII(w, mi[p], ma[p]);
		int v = (p % 2 != 0 ? 1 : -1) * (t[qq] - r[p]);
		w += v;
		setII(w, 0, x);
		cout << w << "\n";
	}
	
	return 0;
}


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

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
fn main() {
    input! {
    n: usize,
    }
    let mut dp = vec![0; n + 1];
    dp[0] = 1;
    dp[1] = 1;
    for i in 1..n {
        dp[i + 1] = dp[i] + dp[i - 1];
    }
    println!("{}", dp[n]);
}



Measured memory_bytes: 5036
#include <stdio.h>
 
int main(void){
  int i,j,n,taro_p=0,hana_p=0;
  char taro[101], hana[101];
 
  scanf("%d", &n);
 
  for(i=0;i<n;i++){
    scanf("%s %s", taro, hana);
 
    for(j=0;;j++){
      if(taro[j] > hana[j]){
        taro_p += 3;
        break;
      }else if(taro[j] < hana[j]){
        hana_p += 3;
        break;
      }else if(taro[j] + hana[j] == 0){
        hana_p++;
        taro_p++;
        break;
      }
    }
  }
 
  printf("%d %d\n", taro_p , hana_p);
  return 0;
}
   


Measured memory_bytes: 2148
#include <iostream>
#include <set>

int main(){
    std::set<unsigned long long> s;
    unsigned long long n,a,top1=0,top2=0;
    std::cin>>n;
    while(n--){
        std::cin>>a;
        if(s.count(a)){
            s.erase(a);
            if(top1<a){

                top2 = top1;
                top1 = a;
            }
            else if(top2<a){
                top2 = a;
            }
        }
        else{
            s.insert(a);
        }
    }
    std::cout<<top1*top2;
}


Measured memory_bytes: 4992
def generate_divisor_count_sieve(N):
    tau = [0]*(N+1)
    for d in range(1,N+1):
        for n in range(d,N+1,d):
            tau[n] += 1
    return tau
N = int(input())
tau = generate_divisor_count_sieve(N)
print(sum([n*tau[n] for n in range(1,N+1)]))

Measured memory_bytes: 365976
from collections import Counter
import sys
sys.setrecursionlimit(10000)

s_n = input()
n = int(s_n)
ans = 0
add_list = ["3", "5", "7"]


def rec(now, i):
    # print(now, i)
    global ans
    coun = len(Counter(now))
    if coun > 2:
        # print("coun", coun)
        if int(now) <= n:
            # print("hoge")
            ans += 1
        else:
            return 0
    if i > -1:
        for j in range(3):
            rec(now + add_list[j], i-1)
    else:
        return 0


rec("", len(s_n)-1)
print(ans)


Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
int main()
{
  set<int>s;
  for(int i=1;i<=9;i++)
  {
    for(int j=1;j<=9;j++)
    {
      s.insert(i*j);
    }
  }
  int n;
  cin>>n;
  if (binary_search(s.begin(), s.end(), n))cout<<"Yes";
  else cout<<"No";
  
}

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

int main() {
  int N; cin >> N;
  vector<int> A(N + 2, 0);
  for (int i = 1; i < N + 1; ++i) cin >> A[i];
  vector<int> s(N + 2, 0);
  for (int i = 1; i < N + 2; ++i) s[i] = s[i - 1] + abs(A[i] - A[i - 1]);
  for (int i = 1; i < N + 1; ++i) {
    int ans = s[N + 1];
    int before = A[i] - A[i - 1];
    int after = A[i + 1] - A[i];
    if (before * after < 0) ans -= 2 * min((s[i] - s[i - 1]), s[i + 1] - s[i]);
    cout << ans << endl;
  }
  return 0;
}


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

#define     fast()              ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); 
#define     ll                  long long int
#define     test()              ll t; cin>>t; while(t--) 
#define     lp0(i,begin,end)    for(ll i=begin;i<end;i++)
#define     lp1(i,begin,end)    for(ll i=begin;i<=end;i++)
#define     rlp(i,begin,end)    for(ll i=end;i>=begin;i--)
#define     prec(n)             fixed<<setprecision(n)
#define     initial(a,i)        memset(a,i,sizeof(a))
#define     pb                  push_back
#define     PI                  3.1415926535897932384626433832795
#define     MOD                 1000000007
#define     F                   first
#define     S                   second
#define     all(a)              (a).begin(),(a).end()
#define     BPC(x)              __builtin_popcountll(x)
#define     gcd(a,b)            __gcd(a,b)

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

ll power(ll x,ll n)
{
    ll result = 1;
    while (n)
    {
        if (n & 1)
            result = result * x;
        n = n / 2;
        x = x * x;
    }
    return result;
}


// Solution Function
void solution(ll compte)
{
    // cout<<compte<<"\n";
    ll n;
    cin>>n;
    ll arr[n];
    ll mx = 1e18;
    for(ll i=0;i<n;i++)
        cin>>arr[i];
    sort(arr,arr+n);    
    if(arr[0]==0)
    {
		cout<<0<<endl;
		return ;
	}
 
	ll ans=1;
	for(ll i=0;i<n;i++)
    {
		if(arr[i] > mx/ans)
        {
			cout<<-1<<endl;
			return ;
		}
		ans *= arr[i];
	}
	cout<<ans<<endl;
}
    // Driver Function
int main()
{
    ll compte = 1;
    //test()
    //{
        solution(compte);
        compte++;
    //}
    return 0;
}


Measured memory_bytes: 4380
N,M = map(int,input().split())
s,c,d = [],[],[0 for i in range(M)]
for i in range(N):
    s += [[int(x) for x in input().split()]]
for i in range(M):
    c += [[int(x) for x in input().split()]]

for i in range(N):
    for j in range(M):
        d[j] = abs(s[i][0] - c[j][0]) + abs(s[i][1] - c[j][1])
    print(d.index(min(d))+1)


Measured memory_bytes: 3064
N, M = list(map(int, input().split(' ')))
S = input()

# print("%d,%d" % (N, M))
# print(S)
if S[0] == 1 or S[-1] == 1:
    print(-1) # no route
    exit(0)

pos = len(S) - 1
move = []
while pos >= 0:
    if pos - M <= 0:
        move.append(pos)
        break
    
    found = False
    for idx in range(pos - M, pos):
        if S[idx] == '0':
            found = True
            break
    
    if not found:
        move = None
        break # no route
    
    move.append(pos - idx)
    pos = idx

if move is None:
    print(-1)
else:
    move.reverse()
    print(' '.join(list(map(str, move))))


Measured memory_bytes: 10492
#include <stdio.h>

int main(void)
{
    int n, a, b, max, min;
    scanf("%d %d %d", &n, &a, &b);

    if(a > b)
        max = b;
    else
        max = a;

    min = a + b - n;
    if (min < 0)
        min = 0;

    printf("%d %d", max, min);

    return 0;
}


Measured memory_bytes: 128