akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <map>
#include <set>
#include <algorithm>
#include <vector>
#include <sstream>
#include <string>
#include <functional>
#include <queue>
#include <deque>
#include <stack>
#include <limits>
#include <unordered_map>
#include <unordered_set>
#include <math.h>
#include <fstream>
#include <iterator>
#include <random>
#include <chrono>
 
 
#define forr(i,start,count) for (int i = (start); i < (start)+(count); ++i)
#define set_map_includes(set, elt) (set.find((elt)) != set.end())
#define readint(i) int i; cin >> i
#define readll(i) ll i; cin >> i
#define readdouble(i) double i; cin >> i
#define readstring(s) string s; cin >> s

typedef long long ll;
 
using namespace std;

template<class T>
T fastpower(T a, long long n) {  // n must be >= 1
  if (n % 2 == 0) {  
      T halfpower = fastpower<T>(a, n/2);
      return halfpower*halfpower;
  } else {
      if (n == 1) {  return a; } else {  
          T halfpower = fastpower<T>(a, n/2);
          return (halfpower*halfpower)*a;
      }
  }
};


int main()   {
    cout.precision(17);
    ll modd = 1000 * 1000 * 1000 + 7;
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    uniform_int_distribution<int> rand_gen(0, modd);   // rand_gen(rng) gets the rand no
    ll infinit = 10000000000000000;

//    auto start = chrono::steady_clock::now();

//    readint(test_cases);
    int test_cases = 1;
    forr(t, 1, test_cases) {
        readll(n); readll(p);

        map<ll,int> decomp;
        ll pp = 2;
        while (pp*pp<=p) {
            if (p%pp==0) {
                decomp[pp]++;
                p/=pp;
            } else {
                pp++;
            }
        }
        if (p>1) {decomp[p]++;}

        ll ret = 1;
        for(auto pp : decomp) {
            int oo = pp.second/n;
            if (oo>0) {
                ret *= fastpower<ll>(pp.first, oo);
            }
        }
        cout << ret << endl;
    }

//    auto end = chrono::steady_clock::now();
//    cout << chrono::duration_cast<chrono::milliseconds>(end - start).count() << endl;

    return 0;
}

Measured memory_bytes: 3612
N,Q=gets.split.map(&:to_i)
A=[2]+[0]*(N-1)
c=0
f=->{
	if c-1>=0 && A[c-1]==0
		A[c-1]=1
	end
	if c+1<N && A[c+1]==0
		A[c+1]=1
	end
}
Q.times{
	a,b=gets.split.map(&:to_i)
	a-=1
	b-=1
	f.()
	A[a],A[b]=A[b],A[a]
	c = c==a ? b : c==b ? a : c
}
f.()
p A.count{|e|e>0}

Measured memory_bytes: 3324
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
#include<utility>
#include<map>
#include<set>
#include<string>

using namespace std;
#define ll long long

int main(){
    ll N;
    ll a, b, sum = 0;
    cin >> N;
    vector<pair<ll, ll> > C;
    for(int i = 0; i < N; i++){
        cin >> a >> b;
        C.push_back(make_pair(b, a));
    }
    sort(C.begin(), C.end());
    for(int i = 0; i < N; i++){
        sum += C[i].second;
        if(sum > C[i].first){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 6256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define REPR(i, n) for(int i = (n); i >= 0; i--)
#define FOR(i, m, n) for(int i = (m); i < (n); i++)
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << ": " << x << endl;

using namespace std;
typedef long long ll;

bool kaibun1(string str) {
  int l = str.length();
  REP(i, l / 2) {
    if(str[i] != str[l - i - 1]) {
      return false;
    }
  }
  return true;
}

bool kaibun2(string str) {
  int l = str.length();
  if(l == 3) return true;
  if(l == 5) return str[0] == str[1];
  if(l == 7) return str[0] == str[2];
  REP(i, (l - 1) / 4) {
    if(str[i] != str[(l - 1) / 2 - i - 1]) {
      return false;
    }
  }
  return true;
}

bool kaibun3(string str) {
  int l = str.length();
  if(l == 3) return true;
  if(l == 5) return str[3] == str[4];
  if(l == 7) return str[4] == str[6];
  REP(i, (l - 1) / 4) {
    int j = i + (l + 3) / 2 - 1;
    if(str[j] != str[l - i - 1]) {
      return false;
    }
  }
  return true;
}

signed main() {
  string s;
  cin >> s;
  if(kaibun1(s) && kaibun2(s) && kaibun3(s)) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


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

int main() {
	string S;
	cin >> S;
	int N = S.length();
	int tmp1 = 0, tmp2 = 0;

	for (int i = 0; i < N; i++) {
		if (i % 2 == 0) {
			if (S[i] == '1') {
				tmp1++;
			}
		}
		else {
			if (S[i] == '0') {
				tmp1++;
			}
		}
	}

	for (int i = 0; i < N; i++) {
		if (i % 2 == 0) {
			if (S[i] == '0') {
				tmp2++;
			}
		}
		else {
			if (S[i] == '1') {
				tmp2++;
			}
		}
	}

	int ans = min(tmp1, tmp2);
	cout << ans << endl;


	return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<stack>
using namespace std;
//TSTTSS
//T ST TST T TT STT SSTT
int main()
{
	stack<char> s;
	string a;
	cin>>a;
	//char c;
	int n=a.size();
	s.push(a[0]);
	for(int i=1;i<n;i++)
	{
		if(!s.empty()) 
		{
			char c=s.top();
			if(c=='S'&&a[i]=='T') 
				s.pop();
			else 
				s.push(a[i]); 
		}
		else s.push(a[i]);
			
	}
	cout<<s.size();
	return 0;
}

Measured memory_bytes: 644
from collections import defaultdict, Counter


def readln():
    return list(map(int, input().split()))


N = readln()[0]
S = input()
mod = 10**9+7

dic = Counter(S)

ans = 1
for count in dic.values():
    # print(count)
    ans *= (count + 1)
    ans %= mod

# print(ans)
print(ans-1)


Measured memory_bytes: 3444
N = int(input())
lst = list(map(int,input().split()))

def col(x):
  if x >= 1 and x <= 399:
    return 'glay'
  elif x >= 400 and x <= 799:
    return 'brown'
  elif x >= 800 and x <= 1199:
    return 'green'
  elif x >= 1200 and x <= 1599:
    return 'light-blue'
  elif x >= 1600 and x <= 1999:
    return 'blue'
  elif x >= 2000 and x <= 2399:
    return 'yellow'
  elif x >= 2400 and x <= 2799:
    return 'orange'
  elif x >= 2800 and x <= 3199:
    return 'red'
  else:
    return 'joker'

Col_Lst = []
count = 0
count_joker = 0
for num in range(N):
  color = col(lst[num])
  if color == 'joker':
    count_joker += 1
  else:
    if color in Col_Lst:
      pass
    else:
      count += 1
  Col_Lst.append(color)

mn = 0
mx = 0
if count == 0:
  mn = 1
  mx = count_joker
else:
  mn = count
  mx = count + count_joker
  
print('%d %d' %(mn, mx))

Measured memory_bytes: 38384
l = list(str(input()))
for i in range(len(l)):
    if l[i] == 'A' or l[i] == 'T' or l[i] == 'C' or l[i] == 'G':
        pass
    else:
        l[i] = ','
ll = "".join(l).split(',')
ans = max(len(ll[i]) for i in range(len(ll)))
print(ans)


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

using namespace std;

int main() {
  long long N, M, K; cin >> N >> M >> K;
  vector<long long> A(N+1);
  A[0] = 0;
  for (long long i = 1; i < N+1; i++) {
    long long tmp; cin >> tmp;
    A[i] = A[i-1] + tmp;
    //cout << A[i] << ' ';
  }
  //cout << endl;
  vector<long long> B(M+1);
  B[0] = 0;
  for (long long i = 1; i < M+1; i++) {
    long long tmp; cin >> tmp;
    B[i] = B[i-1] + tmp;
    //cout << B[i] << ' ';
  }
  //cout << endl;
  auto pos1 = upper_bound(B.begin(), B.end(), K);
  long long result = distance(B.begin(), pos1) - 1;
  //cout << result << endl;
  for (long long i = 1; i < N+1; i++) {
    if (A[i] > K) {
      break;
    }
    auto pos = upper_bound(B.begin(), B.end(), K - A[i]);
    long long idx = distance(B.begin(), pos) - 1;
    //cout << "pos" << idx << endl;
    result = i + idx > result ? i + idx : result;
  }
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 6416
import java.io.IOException;
import java.math.BigDecimal;
import java.math.BigInteger;

public class Main {
    private static final StringBuilder builder = new StringBuilder();
    public static void main(String[] args) {
        BigDecimal bd = readBigDecimal().multiply(readBigDecimal());
        System.out.print(bd.toBigInteger());
    }

    private static void read() {
        builder.setLength(0);
        while (true) {
            try {
                int b = System.in.read();
                if (b == ' ' || b == '\n' || b == -1) {
                    break;
                } else {
                    builder.appendCodePoint(b);
                }
            } catch (IOException e) {
                break;
            }
        }
    }

    private static int readInt() {
        read();
        return Integer.parseInt(builder.toString());
    }

    private static int readInt(int radix) {
        read();
        return Integer.parseInt(builder.toString(), radix);
    }

    private static long readLong() {
        read();
        return Long.parseLong(builder.toString());
    }

    private static long readLong(int radix) {
        read();
        return Long.parseLong(builder.toString(), radix);
    }

    private static double readDouble() {
        read();
        return Double.parseDouble(builder.toString());
    }

    private static BigInteger readBigInteger() {
        read();
        return new BigInteger(builder.toString());
    }

    private static BigInteger readBigInteger(int radix) {
        read();
        return new BigInteger(builder.toString(), radix);
    }

    private static BigDecimal readBigDecimal() {
        read();
        return new BigDecimal(builder.toString());
    }

    private static void skipLine() {
        while (true) {
            try {
                int b = System.in.read();
                if (b == '\n' || b == -1) {
                    break;
                }
            } catch (IOException e) {
                break;
            }
        }
    }

    private static void skip() {
        while (true) {
            try {
                int b = System.in.read();
                if (b == ' ' || b == '\n' || b == -1) break;
            } catch (IOException e) {
                break;
            }
        }
    }

}


Measured memory_bytes: 33116
#include<stdio.h>

char s[50][51];
int H, W, a[50][50] = {0}, i, j;

int main(){
  
  scanf("%d %d", &H, &W);
  
  for (i = 0; i < H; i++){
    scanf("%s", s[i]);
  }
  
  for (i = 0; i < H; i++){
    for(j = 0; j < W; j++){
      if(s[i][j] == '#'){
        if(i > 0 && j > 0)         a[i - 1][j - 1]++;
        if(j > 0)                  a[i][j - 1]++;
        if(i < H - 1 && j > 0)     a[i + 1][j - 1]++;
        if(i > 0)                  a[i - 1][j]++;
                                   a[i][j] = 9;
        if(i < H - 1)              a[i + 1][j]++;
        if(i > 0 && j < W - 1)     a[i - 1][j + 1]++;
        if(j < W - 1)              a[i][j + 1]++;
        if(i < H - 1 && j < W - 1) a[i + 1][j + 1]++;
      }
    }
  }
  
  for (i = 0; i < H; i++){
    for(j = 0; j < W; j++){
      if(a[i][j] < 9){
        printf("%d", a[i][j]);
      } else {
        printf("#");
      }
    }
    printf("\n");
  }
  
  return 0;
}

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

int main() {
    int N,Q;
    cin>>N>>Q;
    string s;
    cin>>s;
    
    vector<char> t(Q),d(Q);
    for(int i=0;i<Q;i++){
        cin>>t[i]>>d[i];
    }
    int left=-1,right=N;
    for(int i=Q-1;i>=0;i--){
        if(d[i]=='L'&&t[i]==s[left+1]) left++;
        if(d[i]=='R'&&t[i]==s[right-1]) right--;
        if(d[i]=='L'&&t[i]==s[right]) right++;
        if(d[i]=='R'&&t[i]==s[left]) left--;
        
    }
    cout<<max(0,right-left-1)<<endl;
}

Measured memory_bytes: 900
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  double i,j,sum=0,pco=0;
  cin >> i >> j;
  vector<int> vote(i);
  for(int count=0;count<i;count++){
    cin >> vote.at(count);
    sum = sum + vote.at(count);
  }
  for(int count=0;count<i;count++){
    if(vote.at(count)>=sum/(4*j)) pco++;
  }
  if(j<=pco) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using static System.Console;

class Program
{
    static void Main(string[] args)
    {
        var NM = ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
        var (N, M) = (NM[0], NM[1]);
        var PY = Enumerable.Range(0, M).Select(i => ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray()).Select(x => (P: x[0], Y: x[1])).ToArray();
        
        foreach(var s in PY.Select((py, i) => (py, i)).OrderBy(x => x.py.Y).GroupBy(x => x.py.P).SelectMany(g => g.Select((x, i) => (x.i, s: x.py.P.ToString("D6") + (i + 1).ToString("D6")))).OrderBy(x => x.i).Select(x => x.s))
            WriteLine(s);
    }
}


Measured memory_bytes: 70420
/*
これを入れて実行
g++ code.cpp
./a.out
 */

#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef long double ld;

int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};

const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;

bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}

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

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

ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}

ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}

//-----------------------ここから-----------

int main(void){
    int n, k;
    cin >> n >> k;
    vector<int> d(k);

    for(int i = 0; i < k; i++) cin >> d[i];

    vector<int> num;
    for(int i = n; i <= 10 * n; i++){
        string tmp = to_string(i);
        bool ok = true;
        for(int j = 0; j < tmp.size(); j++){
            int tmp2 = tmp[j] - '0';
            for(int k = 0; k < d.size(); k++){
                if(tmp2 == d[k]){
                    ok = false;
                    break;
                }
            }
            if(!ok) break;
        }
        if(!ok) continue;
        cout << i << endl;
        return 0;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>

using namespace std;

const int MAXN = 100 + 10;
const int MOD = 1000000007;

int n, a[MAXN];
int f[MAXN][MAXN][MAXN];

int add(int &x, int y)
{
	x = (x + y) % MOD;
}

int main()
{
	ios::sync_with_stdio(false);
	// freopen("1.in", "r", stdin);
	// freopen("1.out", "w", stdout);

	cin >> n;
	for(int i = 1; i <= 2 * n - 1; i++)
		cin >> a[i];
	sort(a + 1, a + 2 * n);
	f[n][1][1] = 1;
	for(int i = n; i >= 2; i--)
		for(int j = 1; j <= 2 * (n - i) + 1; j++)
			for(int k = 1; k <= 2 * (n - i) + 1; k++)
				if(f[i][j][k])
				{
					int jj = j + (a[i] != a[i - 1]) + (a[2 * n - i] != a[2 * n - i + 1]);
					int kk = k + (a[i] != a[i - 1]);
					add(f[i - 1][jj][kk], f[i][j][k]);
					for(int l = 1; l <= kk - 1; l++)
						add(f[i - 1][jj - (kk - l - 1)][l], f[i][j][k]);
					for(int l = kk + 1; l <= jj; l++)
						add(f[i - 1][jj - (l - kk - 1)][kk + 1], f[i][j][k]);
				}
	int ans = 0;
	for(int i = 1; i <= 2 * n - 1; i++)
		for(int j = 1; j <= 2 * n - 1; j++)
			if(f[1][i][j])
				add(ans, f[1][i][j]);
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3456
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>

using namespace std;

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

typedef long long ll;

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

ll lcm(ll a, ll b)
{
    ll n = gcd(a, b);
    return a / n * b;
}

void Main()
{
    int N; cin >> N;
    ll T[110];
    rep(i, N) cin >> T[i];

    ll res = 1;
    rep(i, N)
    {
        res = lcm(T[i], res);
    }
    cout << res << endl;
}

int main()
{
    cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	Main();
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cstring>
#include<numeric>
#include<vector>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<cmath>
using namespace std;
typedef long long ll;
typedef pair<int,int>PII;
typedef pair<ll,ll>PLL;
typedef long double ld;

//typedef acos(-1) PI;

#define PI acos(-1)

int main(){
	int n;
	cin>>n;
	ld ans=2*PI*n;
	printf("%.9Lf\n",ans);
	//cout<<ans<<endl;
	return 0;
}

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

typedef long long ll;
typedef pair<int,int> pii;
const int N = 200010; 
const int LOGN = 20;
const ll oo = 1e18;

string s;

int main(){
  cin >> s;
  ll ans = 0,wt = 0;
  for (int i = s.size()-1;i >= 0; --i){
    if(s[i]=='W')wt++;
    else ans += wt;
  }
  cout << ans << endl;
  return 0;
}

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


int main(void){
    string s;
    cin >> s;
    int n = s.size();
    ll ans;
    char op[n];
    for(int bit=0;bit<(1<<n-1);bit++){
        ans = s[0]-'0';
        for(int i=0;i<n-1;i++){
            if(bit & (1<<i)){
                ans += s[i+1]-'0';
                op[i] = '+';
            }
            else{
                ans -= s[i+1]-'0';
                op[i] = '-';
            }
        }
        if(ans == 7) break;
    }
  cout<<s[0]<<op[0]<<s[1]<<op[1]<<s[2]<<op[2]<<s[3]<<'='<<ans;
}


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

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

typedef long long ll;

const bool isT = false;

void sol();

int main() {
	std::ios::sync_with_stdio(0); std::cin.tie(0);
	if (isT) {
		int t; std::cin >> t;
		while (t--) {
			sol();
		}
		return 0;
	}
	sol();
	return 0;
}

void sol() {

	ll x; std::cin >> x;
	ll now = 100LL;
	ll ans = 0LL;
	while (true) {
		if (now >= x) {
			std::cout << ans << "\n";
			return;
		}
		ans++;
		now = (double)now * (1 + 0.01);
	}

}

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

void displayA(int A[], int N) {
	for (int i = 0; i < N - 1; i++)
		cout << A[i] << " ";
	cout << A[N-1] << endl;
}

void insertionSort(int A[], int N) {
	for (int i = 1; i < N; i++) {
		displayA(A, N);
		int v = A[i];
		int j = i - 1;
		while (0 <= j && v < A[j]) {
			A[j + 1] = A[j];
			j--;
		}
		A[j + 1] = v;
	}
	displayA(A, N);
}

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

	insertionSort(A, N);


	return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
int main(){
  ios::sync_with_stdio(0);  cin.tie(0); cout<<setprecision(3); cout<<fixed;
  #ifdef DEBUG
  freopen("ip.txt","r",stdin);
  clock_t tStart = clock();
  #endif


  int x,y,z; cin>>x>>y>>z;
  cout<<(x-z)/(y+z);


  #ifdef DEBUG
	cout<<"\nExecution time: "<<(((double)clock() - tStart)/CLOCKS_PER_SEC)<<"s.\n";
	#endif
  return 0;
}


Measured memory_bytes: 256
#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("%.12f\n", x)
const double pi = acos(-1.0);
const ll MOD = 1000000007;
const ll INF = 1e18;
const ll MAX_N = 1010101;

//組み合わせの余りを求める
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;
}

// mod.m での a の逆元 a^ { -1 } を計算する
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

//最大公約数
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 );
}

//union-find木について
ll par[101010];
ll rank2[101010];

void init(ll n) {
	rep(i, n) {
		par[i] = i;
		rank2[i] = 0;
	}
}

ll find(ll x) {
	if (par[x] == x) {
		return x;
	}
	else {
		return par[x] = find(par[x]);
	}
}

void unite(ll x, ll y) {
	x = find(x);
	y = find(y);
	if (x == y)return;
	if (rank2[x] < rank2[y]) {
		par[x] = y;
	}
	else {
		par[y] = x;
		if (rank2[x] == rank2[y]) {
			rank2[x]++;
		}
	}
}


ll dx[8] = { 1,-1,0,0,1,1,-1,-1 };
ll dy[8] = { 0,0,1,-1,1,-1,1,-1 };
char c[2010][2010];
ll dp[101010][20];

//long longしか使わない
//素数は1より大きい
//lower_boundは指定したkey以上の要素の一番左のイテレータをかえす
//upper_boundは指定したkeyより大きい要素の一番左のイテレータをかえす
int main() {
	ll n, m;
	cin >> n >> m;
	init(n);
	rep(i, m) {
		ll a, b;
		cin >> a >> b;
		a--, b--;
		unite(a, b);
	}
	map<ll, ll>mp;
	rep(i, n) {
		mp[find(i)]++;
	}
	ll ans = 0;
	for (auto res : mp) {
		ans++;
	}
	cout << ans - 1 << endl;
	return 0;
}


Measured memory_bytes: 10248
import java.util.*;
public class Main {
	static int N;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		N = sc.nextInt();
		int P[] = new int[N];
		for(int i=0;i<N;i++) P[i]=sc.nextInt()-1;
		sc.close();
		
		//順列の中の大きい数字から見ていきたいので、処理順に配列の添字を入れた配列を用意する
		int idx[] = new int[N]; //添字の数がP配列のどこにあるか
		for(int i=0;i<N;i++) idx[P[i]]=i; 
		
		TreeSet<Integer> ts = new TreeSet<>();
		
		long ans = 0;
		for(int i=N-1;i>=0;i--) {
			int now = idx[i]; //iの場所
			int hi1 = myHigher(ts, now);
			int hi2 = myHigher(ts, hi1);
			int low1 = myLower(ts, now);
			int low2 = myLower(ts, low1);
			
			long cnt =  (long)(hi2-hi1) * (now - low1) + (long)(hi1-now) * (low1 - low2) ;
			ans += cnt * (i+1);
			
			ts.add(now);			
		}
		System.out.println(ans);
	}
	static int myHigher(TreeSet<Integer> ts, int now) {
		if(ts.higher(now)!=null)return ts.higher(now);
		else return N;
	}
	static int myLower(TreeSet<Integer> ts, int now) {
		if(ts.lower(now)!=null)return ts.lower(now);
		else return -1;
	}
	
}

Measured memory_bytes: 65032
import java.util.*;
import static java.lang.Math.*;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int a[] = new int[n];
        int max = 0;
        for(int i=0; i<n; i++){
            a[i] = sc.nextInt();
            max = max(max, a[i]);
        }
        int sum = 0;
        boolean flag = true;
        for(int i=0; i<n; i++){
            if(a[i] == max && flag){
                flag = false;
                continue;
            }
            sum += a[i];
        }
        System.out.println(sum > max ? "Yes" : "No" );
    }
}


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

#define rep(i,k,n) for(int (i)=(k);(i)<(n);(i)++)
#define max(a,b) (a)>(b)?(a):(b)
#define min(a,b) (a)<(b)?(a):(b)
#define abs(a) (a)>0 ?(a):-(a)
#define llong long long

int main(){
	int N,M,X; scanf("%d %d %d",&N,&M,&X);
	int C[N],A[N][M],flag[N],study[M];
	int min=200000000;
	rep(i,0,N){
		scanf("%d",&C[i]);
		rep(j,0,M){
			scanf("%d",&A[i][j]);
		}
	}
	int N_2=1;
	rep(i,0,N) N_2 *= 2;
	rep(i,0,N_2){
		int cost=0;
		int ii=i;
		rep(j,0,N){
			flag[j] = ii&1;
			ii /= 2;
		}
		rep(j,0,M) study[j]=0;
		rep(j,0,N){
			if( flag[j] ){
				cost += C[j];
				rep(k,0,M){
					study[k] += A[j][k];
				}
			}
		}
		if( cost > min ) continue;
		rep(j,0,M){
			if( study[j] < X ) break;
			if( j==M-1 ) min = cost;
		}
	}
	if( min==200000000 ) printf("-1");
	else printf("%d",min);
	return 0;
}


Measured memory_bytes: 1736
#include <iostream>
#include <string>
#include <unordered_map>
using namespace std;


int main(){
  // unordered_map<string, string> lookup = {
  //   {"Sunny", "Cloudy"},
  //   {"Cloudy", "Rainy"},
  //   {"Rainy", "Sunny"}
  // };

  unordered_map<string, string> lookup;
  lookup["Sunny"] = "Cloudy";
  lookup["Cloudy"] = "Rainy";
  lookup["Rainy"] = "Sunny";

  string S;
  cin >> S;

  cout<<lookup[S]<< endl;

  return 0;
}

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

const int N=5000,INF=0x3f3f3f3f;
int dep[N],head[N],next[N],to[N],flow[N],idx;

void reset(void){
	memset(head,-1,sizeof(head)),idx=0;
}

void addEdge(const int x,const int y,const int c){
	next[idx]=head[x],to[idx]=y,flow[idx]=c,head[x]=idx++;
	next[idx]=head[y],to[idx]=x,flow[idx]=0,head[y]=idx++;
}

bool bfs(const int St,const int Ed){
	memset(dep,-1,sizeof(dep));
	queue<int> q;q.push(St);dep[St]=0;
	while(!q.empty()){
		int t=q.front();q.pop();
		for(int i=head[t];~i;i=next[i])
			if(dep[to[i]]<0&&flow[i])
				dep[to[i]]=dep[t]+1,q.push(to[i]);
	}
	return dep[Ed]>0;
}

int dfs(const int St,const int Ed,int fl){
	if(St==Ed||fl==0)	return fl;
	int ans=0,add;
	for(int i=head[St];~i;i=next[i])
		if(dep[to[i]]==dep[St]+1&&(add=dfs(to[i],Ed,min(flow[i],fl))))
			flow[i]-=add,flow[i^1]+=add,ans+=add,fl-=add;
	return ans;
}

int maxFlow(const int St,const int Ed){
	int ans=0,add;
	while(bfs(St,Ed))
		ans+=dfs(St,Ed,INF);
	return ans;
}

int main(void){
	int n,m;
	while(scanf("%d%d",&n,&m)!=EOF){
		reset();
		for(int i=0,x,y,c;i<m;i++)
			scanf("%d%d%d",&x,&y,&c),addEdge(x,y,c);
		printf("%d\n",maxFlow(0,n-1));
	}
	return 0;
}

Measured memory_bytes: 1276
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <string>
#define INT long long int
 
using namespace std;
string s;
 
INT dp(int x, INT v, INT z)
{
    if( x == s.size() ) return z+v;
    return dp(x+1, v*10+(s[x]-'0'), z) + dp(x+1, (s[x]-'0'), z+v);
}
 
int main()
{
    cin>>s;
    cout<<dp(1, s[0]-'0', 0);
}

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

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

int main(){
  int x; cin>>x;
  int ans = x;
  while(true){
    if (JudgePrime(ans)){
      cout << ans;
      return 0;
    }
    ans++;
  }
}

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

int main() {
    int N,K;
    cin >> N >> K;
    string S;
    cin >> S;
    int ans = 0;
    rep(i,N-1){
      if(S[i] == S[i+1]) ans++;
    }
    ans += 2*K;
    cout << min(ans,N-1) << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#pragma warning (disable:4996)
using namespace std;
#define ll long long 
#define ull unsigned long long

int a[55], b[55], c[55];

int main()
{
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++)
		cin >> a[i];
	for (int i = 1; i <= n; i++)
		cin >> b[i];
	for (int i = 1; i < n; i++)
		cin >> c[i];
	int ans = 0;
	int lasteat = -1;
	for (int i = 1; i <= n; i++)
	{
		ans += b[a[i]];
		if (a[i]-1==lasteat)
			ans += c[a[i] - 1];
		lasteat = a[i];
	}

	cout << ans;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#define swap(x, y) x += y, y = x - y, x = x - y;
using namespace std;

int partition(int A[], int p, int r){
    int x, i, j;
    x = A[r];
    i = p - 1;
    for (j = p; j < r; j++)
    {
        if (A[j] <= x)
        {
            i++;
            if(A[i] != A[j])
                swap(A[i], A[j]);
        }
    }
    if(A[i+1] != A[j])
        swap(A[i+1], A[j]);
    return i+1;
}

int main(){
    int n; cin >> n;
    int A[100005];
    for (int i = 0; i < n; i++)
    {
        cin >> A[i];
    }
    int x;
    x = partition(A, 0, n-1);
    for (int i = 0; i < n-1; i++)
    {
        if(i == x) cout << "[" << A[i] << "] ";
        else cout << A[i] << " ";
    }
    if(n-1 == x) cout << "[" << A[n-1] << "]" << endl;
    else cout << A[n-1] << endl;
}


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

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

    vector<int> vec(N);
    for (int i = 0; i < N; i++) {
        cin >> vec.at(i);
    }

    int ans = 0;
    for (int i = 0; i < N; i++) {
        ans += min(vec.at(i), K - vec.at(i)) * 2;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include<map>
#include<set>
#include<list>
#include<cmath>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<complex>
#include<cstdlib>
#include<cstring>
#include<numeric>
#include<sstream>
#include<iostream>
#include<algorithm>
#include<functional>
 
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
 
using namespace std;
 
#define int long long
//typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      P;
 
const int INF=1e+9;
const double EPS=1e-9;
const int MOD=1000000007;
 
const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

struct edge{ int to; int cost; };
typedef pair<int,int> P;

int n;
vector<edge> graph[200000];
int d[200000];

void dijkstra(int s){
	priority_queue<P,vector<P>,greater<P> > que;
	for(int i = 0;i < n;i++) d[i] = INF;
	d[s] = 0;
	que.push(make_pair(0,s));
	while(!que.empty()){
		P p = que.top();
		que.pop();
		int v = p.second;
		if(d[v] < p.first) continue;
		for(int i = 0;i < graph[v].size();i++){
			edge e = graph[v][i];
			if(d[e.to] > d[v] + e.cost){
				d[e.to] = d[v] + e.cost;
				que.push(make_pair(d[e.to],e.to));
			}
		}
	}
}

signed main(){
	int m;
	cin >> n >> m;
	for(int i = 0;i < m;i++){
		int a,b;
		cin >> a >> b; a--;b--;
		graph[a].push_back({b,1});
		graph[b].push_back({a,1});
	}
	dijkstra(0);
	if(d[n - 1] == 2) cout << "POSSIBLE" << endl;
	else cout << "IMPOSSIBLE" << endl;
	return 0;
}

Measured memory_bytes: 18912
n, a, b, c = map(int, input().split())
ss = []
for i in range(n):
    ss.append(input())

res_list = []
flag = 1

for i in range(n):
    if flag == 0:
        break
    if ss[i] == 'AB':
        if a == 0 and b == 0:
            flag = 0
        elif a == 0:
            a, b = 1, b-1
            res_list.append('A')
        elif b == 0:
            a, b = a-1, 1
            res_list.append('B')
        elif a == 1 and b == 1:
            if i == n-1:
                res_list.append('A')
            elif ss[i+1] == 'BC':
                res_list.append('B')
                a, b = 0, 2
            elif ss[i+1] == 'AC':
                res_list.append('A')
                a, b = 2, 0
            else:
                res_list.append('A')
                a, b = 2, 0
        elif a == 1:
            res_list.append('A')
            a, b = 2, b-1
        elif b == 1:
            res_list.append('B')
            a, b = a-1, 2
        else:
            res_list.append('A')
            a, b = a+1, b-1
    elif ss[i] == 'BC':
        if b == 0 and c == 0:
            flag = 0
        elif b == 0:
            b, c = 1, c-1
            res_list.append('B')
        elif c == 0:
            b, c = b-1, 1
            res_list.append('C')
        elif b == 1 and c == 1:
            if i == n-1:
                res_list.append('B')
            elif ss[i+1] == 'AB':
                res_list.append('B')
                b, c = 2, 0
            elif ss[i+1] == 'AC':
                res_list.append('C')
                b, c = 0, 2
            else:
                res_list.append('B')
                b, c = 2, 0
        elif b == 1:
            res_list.append('B')
            b, c = 2, c-1
        elif c == 1:
            res_list.append('C')
            b, c = b-1, 2
        else:
            res_list.append('B')
            b, c = b+1, c-1
    else:
        if a == 0 and c == 0:
            flag = 0
        elif a == 0:
            a, c = 1, c-1
            res_list.append('A')
        elif c == 0:
            a, c = a-1, 1
            res_list.append('C')
        elif a == 1 and c == 1:
            if i == n-1:
                res_list.append('A')
            elif ss[i+1] == 'AB':
                res_list.append('A')
                a, c = 2, 0
            elif ss[i+1] == 'BC':
                res_list.append('C')
                a, c = 0, 2
            else:
                res_list.append('A')
                a, c = 2, 0
        elif a == 1:
            res_list.append('A')
            a, c = 2, c-1
        elif c == 1:
            res_list.append('C')
            a, c = a-1, 2
        else:
            res_list.append('A')
            a, c = a+1, c-1

if flag == 0:
    print('No')
else:
    print('Yes')
    for res in res_list:
        print(res)


Measured memory_bytes: 17128
#define _USE_MATH_DEFINES
#include <iostream>
#include <complex>
#include <algorithm>
#include <vector>
#include <stack>
#include <string>
#include <queue>
#include <cmath>
#include <math.h>
#include <numeric>
#include <list>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <climits>
#include <set>
#include <memory.h>
#include <memory>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cassert>
#include <map>
#include <cassert>
#include <time.h>

using namespace std;

typedef complex<double> xy_t;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int , P> PP;
typedef pair<int, string> Ps;
typedef vector<int> vec;
typedef vector<vec> mat;
const int INF= 1 << 30;
const double EPS = 1e-9;
const double PI = 3.1415926535897932384626433832795;

int f[501][501];
bool go[501];
bool go2[501];

int main(){
	int n, m;
	while(cin >>n >> m && (n || m)){
		memset(f, false, sizeof(f));
		memset(go2, false, sizeof(go2));
		memset(go, false, sizeof(go));
		for(int i = 1; i <= n; i++) f[i][i] = true;
		for(int i = 0; i < m; i++){
			int a,b;
			cin >> a >> b;
			f[a][b] = f[b][a] = true;
		}
		go[1] = true;
		for(int i = 0; i < 2; i++){
			
			for(int j = 1; j <= n; j++){
				if(go[j])
				for(int k = 1; k <= n; k++){
					if(f[j][k]) go2[k] = true;
				}
			}
			memcpy(go, go2, sizeof(go));
		}
		int cnt = -1;
		for(int i = 0; i <= n; i++) if(go2[i]) cnt++;
		cout << cnt << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  int a, b;
  cin >> a >> b;
  for(int i = 10; i <= 10000; i++) {
    if ((i*8/100) == a && (i*10/100 == b)) {
      cout << i << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}

Measured memory_bytes: 3696
#define CPP17
#include <limits>
#include <initializer_list>
#include <utility>
#include <bitset>
#include <tuple>
#include <type_traits>
#include <functional>
#include <string>
#include <array>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iterator>
#include <algorithm>
#include <complex>
#include <random>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <regex>
#include <cassert>
#include <cstddef>
#ifdef CPP17
#include <variant>
#endif

// Yay!!
#define endl codeforces

// macros for iterator
#define ALL(v) std::begin(v), std::end(v)
#define ALLR(v) std::rbegin(v), std::rend(v)

// alias
using ll = std::int64_t;
using ull = std::uint64_t;
using pii = std::pair<int, int>;
using tii = std::tuple<int, int, int>;
using pll = std::pair<ll, ll>;
using tll = std::tuple<ll, ll, ll>;
template <typename T> using vec = std::vector<T>;
template <typename T> using vvec = vec<vec<T>>;

// variadic min/max
template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename T, typename... Tail> const T& var_min(const T &t, const Tail&... tail) { return std::min(t, var_min(tail...)); }
template <typename T, typename... Tail> const T& var_max(const T &t, const Tail&... tail) { return std::max(t, var_max(tail...)); }

// variadic chmin/chmax
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }

// multi demension array
template <typename T, std::size_t Head, std::size_t... Tail> struct multi_dim_array { using type = std::array<typename multi_dim_array<T, Tail...>::type, Head>; };
template <typename T, std::size_t Head> struct multi_dim_array<T, Head> { using type = std::array<T, Head>; };
template <typename T, std::size_t... Args> using mdarray = typename multi_dim_array<T, Args...>::type;

#ifdef CPP17
// fill container
template <typename T, typename F, typename... Args> 
void fill_seq(T &t, F f, Args... args) { if constexpr (std::is_invocable<F, Args...>::value) { t = f(args...); } else { for (ssize_t i = 0; i < t.size(); i++) fill_seq(t[i], f, args..., i); } }
#endif

// make multi dimension vector
template <typename T> vec<T> make_v(ssize_t sz) { return vec<T>(sz); }
template <typename T, typename... Tail> auto make_v(ssize_t hs, Tail&&... ts) { auto v = std::move(make_v<T>(std::forward<Tail>(ts)...)); return vec<decltype(v)>(hs, v); }

// init
namespace init__ { 
struct InitIO { InitIO() { std::cin.tie(nullptr); std::ios_base::sync_with_stdio(false); std::cout << std::fixed << std::setprecision(30); } } init_io; 
}


int main() {
    ll n, k;
    std::cin >> n >> k;
    vec<ll> av(n);
    for (ll &e : av) std::cin >> e;
    std::sort(ALL(av));
    while (k < av.size()) av.pop_back();
    std::cout << accumulate(ALL(av), 0ll) << "\n";
    return 0;
}


Measured memory_bytes: 3664
#include<iostream>
#include<climits>
#include<vector>
#include<list>
#include<functional>
#include<algorithm>
#include<string>
#include<cmath>
#include<complex>
#include<set>
#include<map>
#include<stack>
#include<queue>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

class question {
public:
	ll A[3];
	void ans() {
		ll res = 1;
		REP(i, 3) {
			cin >> A[i];
			if (A[i] % 2 == 0) res = 0;
		}
		if (res) {
			sort(A, A + 3);
			res = A[0] * A[1];
		}
		cout << res << "\n";
	}

};

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	question q;
	q.ans();
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <functional>
#include <math.h>
#include <stdlib.h>
#include <map>
#include <deque>
#include <sys/timeb.h>
#include <fstream>

using namespace std;

#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define repi(itr,ds) for(auto itr=ds.begin();itr!=ds.end();itr++)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define INF 1050000000
#define INFL 1100000000000000000LL
#define EPS (1e-10)
#define MOD 1000000007
#define PI 3.1415926536
#define RMAX 4294967295

typedef long long ll;
typedef pair<int, int> Pi;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<vector<int> > vvi;
typedef vector<vector<bool> > vvb;
typedef vector<vector<ll> > vvll;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<double> > vvd;
typedef vector<vector<Pi> > vvPi;
typedef priority_queue<int, vector<int>, greater<int> > pqli;
typedef priority_queue<ll, vector<ll>, greater<ll> > pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi> > pqlP;
struct Edge {
	int from, to, cost;
	bool operator<(Edge e) {
		return cost < e.cost;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
template <class T>
using vec = vector<T>;
template<class T>
using pql = priority_queue<T, vector<T>, greater<T>>;
string debug_show(Pi a) {
	return "(" + to_string(a.first) + "," + to_string(a.second) + ")";
}

template<class T>
struct augEdge {
	T from, to;
	int cost;
	bool operator<(augEdge e) { return cost < e.cost; }
	bool operator>(augEdge e) { return cost > e.cost; }
};
template<class T>
using augGraph = vector<augEdge<T>>;



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

	string s, t;
	cin >> s >> t;
	if (s.size() == t.size()) {
		rep(i, s.size()) {
			cout << s[i];
			cout << t[i];
		}
		cout << endl;
	}
	else {
		cout << s[0];
		rep(i, s.size() - 1){
			cout << t[i];
			cout << s[i + 1];
		}
		cout << endl;
	}

	return 0;
}


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

#define bb      begin()
#define ee      end()
#define ff      first
#define ss      second
#define pb      push_back
#define pf      push_front
#define popb    pop_back()
#define popf    pop_front()
#define mem(a , v)    memset(a , v , sizeof(a))

typedef long long ll;
typedef long double ld;

using namespace std;

const int BIG = 1e5+9;
const int INF = 1e9+9;
const ll BINF = 1e18+9;
const double SML = (1e-7);

int a,b,x,i;
bool go=false;

int main()
{
    //freopen("output.txt" , "w" , stdout);
    //freopen("input.txt" , "r" , stdin);
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>a>>b;
    for(x=1 ; x<=1120 ; x++)
    {
        if((x*8)/100==a && (x*10)/100==b)
        {
            go=true;
            break;
        }
    }
    if(go)
    {
        cout<<x;
    }
    else
    {
        cout<<-1;
    }
    return 0;
}


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

using namespace std;

const vector<int> dx = {1, -1, 0, 0}, dy = {0, 0, 1, -1};

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int H, W;
  cin >> H >> W;
  vector<string> S(H);
  for (int i = 0; i < H; i++) {
    cin >> S[i];
  }
  int res = 0;
  auto f = [S, H, W](int sy, int sx) {
    vector<vector<int>> G(H, vector<int>(W, -1));
    G[sy][sx] = 0;
    queue<pair<int, int>> que;
    que.push(make_pair(sy, sx));
    int res = 0;
    while (!que.empty()) {
      auto q = que.front();
      que.pop();
      int y = q.first, x = q.second;
      for (int i = 0; i < 4; i++) {
        int ny = y + dy[i], nx = x + dx[i];
        if (ny < 0 || ny >= H || nx < 0 || nx >= W) continue;
        if (G[ny][nx] != -1 || S[ny][nx] == '#') continue;
        G[ny][nx] = G[y][x] + 1;
        que.push(make_pair(ny, nx));
        res = max(res, G[ny][nx]);
      }
    }
    return res;
  };
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (S[i][j] == '#') continue;
      res = max(res, f(i, j));
    }
  }
  cout << res << '\n';
  return 0;
}


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

using namespace std;

int main() {
  
  int n,i,l,j,k,p;

   string s,t="";
   cin>>s;
   n=s.size();
   for(i=0;i<n;i++)
   {
       if(s[i]=='B')
       {if(!t.empty()) t.pop_back();}
       
       else t+=s[i];
   }

cout<<t;
}

Measured memory_bytes: 3628
K = list(range(1,int(input())+1))

import itertools

def gcd(a,b):
    if b>a:
        a,b = b,a
    while b:
        a,b = b,a%b
    return a

result = 0


if len(K)>=3:
    for i in list(itertools.combinations(K,3)):
        result += gcd(gcd(i[0],i[1]),i[2])*6

if len(K)>=2:
    for i in list(itertools.combinations(K,2)):
        result += gcd(i[0],i[1])*6

for i in list(itertools.combinations(K,1)):
    result += i[0]

print(result)

Measured memory_bytes: 102656
#include <iostream>
using namespace std;
int min(int a,int b){
    if(a>b) return b;
    else return a;
}

int main(){
    int a,b,c,x,y,t,res;
    cin >> a >> b >> c >> x >> y;
    if((a+b)<=2*c) res=x*a+y*b;
	else{
		if(x>y){
			t=2*c*y+a*(x-y);
			res=min(t,2*c*x);
		} 
		else{
			t=2*c*x+b*(y-x);
			res=min(t,2*c*y);
		} 
	}
	cout<< res;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<bits/stdc++.h>
#include<algorithm>
#define FasterIO     ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define PI acos(-1)
#define all(a) a.begin(),a.end()
#define f first
#define s second
#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define mp make_pair
#define f0(i,n) for(i=0;i<n;i++)
#define f1(i,n) for(i=1;i<n;i++)
#define f1n(i,n) for(i=1;i<=n;i++)
#define szf sizeof()
#define sz size()
#define ln length()
using namespace std;
using ll=long long;
int cnt,element;
long long int arr[100000001];
vector<ll>vec;
int main()
{
    int s,w;
    cin>>s>>w;
    if(w>=s)
        cout<<"unsafe"<<endl;
    else
        cout<<"safe"<<endl;
    return 0;
}


Measured memory_bytes: 3624
#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
int main()
{
    string s;
    cin>>s;
    int len = s.size();
    //nump <= numg
    int nump = 0, numg = 0;
    for(int i = 0 ; i < len; i++){
        if(s[i] == 'p')nump++;
        else if(s[i] == 'g')numg++;
    }
    cout<<(nump+numg)/2-nump;
    return 0;
}


Measured memory_bytes: 512
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
using namespace std;
///////////////////library zone!!!!!!!!!!!!!!!!!!!!!!!!!!!!
typedef long long ll;
typedef long double ld;
#define all(a) (a).begin(),(a).end()
#define EPS (1e-5)
#define bit(n,k) ((n>>k)&1)
const ll Mod = 1000000007;
const ll mod = 998244353;
struct H {
	ll x, y;
	bool operator<(const H &b) const {
		if (x != b.x) return x < b.x;
		return y < b.y;
	}
	bool operator>(const H &b) const {
		if (x != b.x) return x > b.x;
		return y > b.y;
	}
	bool operator==(const H &b) const { return x == b.x&&y == b.y; }
	bool operator!=(const H &b) const { return (*this) != b; }
};
struct P {
	ll pos, cost;
	bool operator<(const P &b) const { return cost < b.cost; }
	bool operator>(const P &b) const { return cost > b.cost; }
};
struct B {
	ll to, cost;
	bool operator<(const B& b) const { return cost < b.cost; }
	bool operator>(const B& b) const { return cost > b.cost; }
};
struct E {
	ll from, to, cost;
	bool operator<(const E &b) const { return cost < b.cost; }
	bool operator>(const E &b) const { return cost > b.cost; }
};
template<typename T, typename U>
void chmin(T &a, U b) {
	if (a > b) a = b;
}
template<typename T, typename U>
void chmax(T &a, U b) {
	if (a < b) a = b;
}
template<typename T>
T max_0(T a) {
	if (a < 0) return 0;
	return a;
}
template<typename T>
T min_0(T a) {
	if (a > 0) return 0;
	return a;
}
ll read() {
	ll u;
	ll k = scanf("%lld", &u);
	return u;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j%i, i);
}
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}//x^n%p
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------
int n;
H a[200000];
signed main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i].y >> a[i].x;
	}
	sort(a, a + n);
	int t = 0;
	for (int i = 0; i < n; i++) {
		if (t + a[i].y > a[i].x) {
			cout << "No\n";
			return 0;
		}
		t += a[i].y;
	}
	cout << "Yes\n";
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int64_t n,d,k;
  k=0;
  cin>>n>>d;
  vector<int64_t>x(n);
  vector<int64_t>y(n);
  for(int i=0;i<n;i++){
    cin>>x.at(i)>>y.at(i);
    if(x.at(i)*x.at(i)+y.at(i)*y.at(i)<=d*d){
      k++;
    }
  }
  cout<<k<<endl;
}

Measured memory_bytes: 6424