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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;++A)
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////
ll K;
ll mk[222];
ll i, j, k,ans;
ll gcd(ll a,ll b){
    if(b==0)
        return a;
    return gcd(b, a % b);
}
int main(){
    scanf("%lld", &K);
    fornum(i,1,K+1){
        fornum(j,1,K+1){
            ++mk[gcd(i, j)];
        }
    }
    fornum(i,1,K+1){
        fornum(j,1,K+1){
            ans += mk[j] * gcd(i, j);
        }
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 3836
#include<bits/stdc++.h>
using namespace std;
template <typename T> using vec = vector<T>;

int main()
{
    int n;
    cin >> n;
    vec<pair<long,long>> ab;
    long a,b;
    while(cin >> a >> b)
    {
        ab.push_back(make_pair(a,b));
    }

    sort(ab.begin(),ab.end(),[](pair<long,long> &a, pair<long,long> &b)
    {
        return a.second < b.second;
    });
    long now=0;
    long deadline = 0;
    bool flag =1;
    for (auto &&p : ab)
    {
        deadline = p.second;
        now += p.first;
        if(now>deadline)
        {
            flag = false;
        }
    }

    if(flag)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 6384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  ll n, m, a, b;
  in2(n, m);
  vector<ll> h(n);
  rep(i, n)
    in(h[i]);
  vector<vector<ll>> c(n, vector<ll> (0));
  rep(i, m){
    in2(a, b);
    c[a - 1].pb(b - 1);
    c[b - 1].pb(a - 1);
  }
  a = 0;
  rep(i, n){
    bool g = true;
    rep(j, c[i].size()){
      if(h[i] <= h[c[i][j]]){
        g = false;
        break;
      }
    }
    if(g)
      a++;
  }
  out(a);
  memi;
}

Measured memory_bytes: 9860
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const ll maxn=2e5+1;
void solve()
{
	ll M;
	cin>>M;
	vector<pair<ll,ll>> num;
	for(ll i=0;i<M;i++)
	{
		ll x,y;
		cin>>x>>y;
		num.push_back({x,y});
	}
	ll sumdigit=0,countdigit=0;
	for(ll i=0;i<M;i++)
	{
		sumdigit+=(num[i].second*num[i].first);
		countdigit+=(num[i].second);
	}
	//cout<<sumdigit<<" "<<countdigit<<"\n";
	ll ans=countdigit-1+((sumdigit-1)/9);
	cout<<ans<<"\n";
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll T=1,p=0;
	//cin>>T;
	do
	{
		solve();
		p++;
	}while(p<T);
	return 0;
}



Measured memory_bytes: 6000
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  ll a, b, s;
  s = -1;
  in2(a, b);
  rep(i, 10000){
    if(i * 8 / 100 == a && i / 10 == b){
      s = i;
      break;
    }
  }
  out(s);
  memi;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using P = pair<int, int>;

const long INF = 1L << 60;

int w[110], v[110];
long dp[110][110000];

int main(){
    int n, W;
    cin >> n >> W;
    for(int i = 1; i <= n; i++) cin >> w[i] >> v[i];
    for(int i = 0; i < 110000; i++) dp[0][i] = INF;
    dp[0][0] = 0;
    for(int i = 1; i <= n; i++){
        for(int j = 0; j <= 100000; j++){
            dp[i][j] = dp[i-1][j];
            if(j - v[i] >= 0)
                dp[i][j] = min(dp[i][j], dp[i-1][j-v[i]] + w[i]);
        }
    }
    int ans = 0;
    for(int i = 0; i <= 100000; i++)
        if(dp[n][i] <= W) ans = i;
    cout << ans << endl;
}

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

int main() {
  int N;
  cin >> N;
  
  vector<int> ans(10010, 0);
  
  for (int x = 1; x <= 100; x++) {
    for (int y = 1; y <= 100; y++) {
      for (int z = 1; z <= 100; z++) {
        int v = x*x + y*y + z*z + x*y + y*z + z*x;
        if (v <= 10000) ans[v]++;
      }
    }
  }
   
  for (int i = 1; i <= N; i++) {
    cout << ans[i] << endl;
  }
  
}

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

int main()
{
    int a, b, c;
    std::cin >> a >> b >> c;

    int count;
    for (int i = a; i <= b; i++) {
        if (c % i == 0) {
            count++;
        }
    }

    std::cout << count << std::endl;
    // std::vector<int> v;
    // v.reserve(b - a + 1);
    // std::iota(v.begin(), v.end(), a);

    // std::cout << std::count_if
    return 0;
}


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

#define pb         push_back

typedef long long ll;
const ll INF = 1000000000000000000ll;
const ll MOD = 1000000007ll;
const double EPS = 1e-8;

int from[200001];
int to[200001];
int main(void) {
	//ios_base::sync_with_stdio(false);
	//cin.tie(0);
	
	int n, m;
	cin >> n >> m;

	for(int i=0; i<m; i++){
		int ta, tb;
		cin >> ta >> tb;
		if(ta == 1){
			from[tb] = 1;
		}else if(tb == n){
			to[ta] = 1;
		}
	}

	for(int i=0; i<n; i++){
		if(from[i] == 1 && to[i] == 1){
			puts("POSSIBLE");
			return 0;
		}
	}
	puts("IMPOSSIBLE");
	
	return 0;
}


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

using namespace std;

int main() {
    int N, M, C;
    cin >> N >> M >> C;
    vector<int> B(M);
    for (int i=0; i<M; i++) cin >> B[i];

    int cnt = 0;
    for (int i=0; i<N; i++) {
        int A, sum = 0;
        for (int j=0; j<M; j++) {
            cin >> A;
            sum += A*B[j];
        }
        sum += C;
        if (sum > 0) cnt++;
    }

    cout << cnt << endl;

    return 0;
}


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

const int mod = 1e9 + 7;

int n, tmp, a[101], dp[51][101][101];

int main() {
	scanf("%d", &n);
	for (int i = 1; i <= 2 * n - 1; ++i) {
		scanf("%d", a + i);
	}
	std::sort(a + 1, a + 2 * n);
	#ifdef DEBUG
	for (int i = 1; i <= 2 * n - 1; ++i) {
		printf("%d ", a[i]);
	}
	puts("");
	#endif
	dp[n][1][1] = 1;
	for (int i = n; i > 1; --i) {
		bool fl = a[i - 1] != a[i], fr = a[2 * n - i + 1] != a[2 * n - i];
		#ifdef DEBUG
		printf("%d %d\n", fl, fr);
		#endif
		for (int j = 1; j <= (n - i + 1) * 2 - 1; ++j) {
			for (int k = j; k <= (n - i + 1) * 2 - 1; ++k) {
				if(tmp = dp[i][j][k]) {
					#ifdef DEBUG
					printf("dp[%d][%d][%d] = %d\n", i, j, k, tmp);
					#endif
					for (int nxt = 1 - fl; nxt < j; ++nxt) {
						(dp[i - 1][nxt + fl][k + fl + fr - (j - nxt - 1)] += tmp) %= mod;
					}
					(dp[i - 1][j + fl][k + fl + fr] += tmp) %= mod;
					for (int nxt = j + 1; nxt <= k + fr; ++nxt) {
						(dp[i - 1][j + 1 + fl][k + fl + fr - (nxt - j - 1)] += tmp) %= mod;
					}
				}
			}
		}
	}
	tmp = 0;
	for (int j = 1; j <= 2 * n - 1; ++j) {
		for (int k = j; k <= 2 * n - 1; ++k) {
			(tmp += dp[1][j][k]) %= mod;
		}
	}
	printf("%d\n", tmp);
	return 0;
}

Measured memory_bytes: 1408
str = gets.chomp
alpha = Array.new(26,false)
str.size.times do |i|
  alpha[str[i].ord - "a".ord] =true
end

alpha.size.times do |i|
  if !alpha[i]
    puts ("a".ord + i).chr
    exit(0)
  end
end

puts "None"

Measured memory_bytes: 1916
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ACC ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define mod 1000000007
#define MAXN 10000001
//string alpha="abcdefghijklmnopqrstuvwxyz";
//int dx[]={1,-1,0,0};
//int dy[]={0,0,1,-1};
//int dx8[]={1,-1,0,0,1,1,-1,-1};
//int dy8[]={0,0,1,-1,1,-1,1,-1};
/*int spf[MAXN];
void sieve()
{
	int i,j;
	for(i=0;i<MAXN;i++)
	spf[i]=i;
	for(i=4;i<MAXN;i+=2)
	spf[i]=2;
	for(i=3;i*i<MAXN;i++)
	{
		if(spf[i]==i)
		{
			for(j=i*i;j<MAXN;j+=i)
			{
				if(spf[j]==j)spf[j]=i;
			}
		}
	}
}*/
/*bool isvowel(char c)
{
    switch(c)
    {
        case 'a':
        case 'e':
        case 'i':
        case 'o':
        case 'u':return true;
        default : return false;
    }
}*/
/*bool isValid(int x,int y,int n,int m)
{
    if(x<0||x>n-1||y<0||y>m-1)return false;
    return true;
}*/
/*
bool comp(pair<int,int> x,pair<int,int> y)
{
    if(x.first==y.first)
        return x.second<y.second;
    return x.first>y.first;
}*/

int32_t main()
{
    ACC
    int T;
    T=1;
    //cin>>T;
    //sieve();
    while(T--)
    {
        int n,i;
        cin>>n;
        int a[n],b[n];
        for(i=0;i<n;i++)
        {
            cin>>a[i];
            b[i]=a[i];
        }
        for(i=n-2;i>=0;i--)
        {
            b[i]+=b[i+1];
        }
        int ans=0;
        for(i=0;i<n-1;i++)
        {
            ans+=((a[i]%mod)*(b[i+1]%mod))%mod;
        }
        cout<<ans%mod<<"\n";
    }
    return 0;
}


Measured memory_bytes: 6780
N = int(input())
X = []
X = input().split()
X = [int(i) for i in X]

P = float(sum(X) / N)
P = round(P, 0)

T = 0

for i in range(N):
  T = T + (X[i] - P)**2


print(int(T))

#print('N=', N)
#print('X=', X)


Measured memory_bytes: 3060
import java.io.*;
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Reader sc = new Reader();
        PrintWriter pw = new PrintWriter(System.out);
        
        try {
            char[] c = sc.next().toCharArray();
            long sum = 0;
            for(char x: c) {
                int y = x-'0';
                sum += y;
            }
            if(sum%9 == 0) pw.println("Yes");
            else pw.println("No");
        }
        finally {
            pw.flush();
            pw.close();
        }
    }
    
    static class Reader {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer("");

        String next() {
            while(!st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                }
                catch(IOException io) {
                    io.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }
    }
}


Measured memory_bytes: 37444
function main(input) {
    const args = input.split(' ');
    const N = parseInt(args[0], 10),
          Y = parseInt(args[1], 10);

    var result = '-1 -1 -1';

    for (var a = 0; a <= N; a++) {
        for (var b = 0; b <= N; b++) {
            if ((a + b) > N) {
                continue;
            }

            var sum = (a * 10000) + (b * 5000) + ((N - a - b) * 1000);
            if (sum === Y) {
                result = `${a} ${b} ${N - a - b}`;
                break;
            }
        }        
    }

    console.log(result);

}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 9420
#include<iostream>
#include<math.h>
#include<vector>
#include<array>
#include<algorithm>
#include<numeric>
#include<map>
#include<queue>
#include<deque>
#include<set>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
typedef long long ll;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

int main(){
    int N;cin>>N;
    string S;cin>>S;
    int ans=1;
    for(int i=1;i<N;i++){
        if(S[i]!=S[i-1])
            ans++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 512
import java.io.*;
import java.util.*;
class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
    static final int MAX = 2_147_483_646; // intMax 
    static final int INF = 1_000_000_000; // 10^9  
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		String[] n = saori.nextHayami().split("");
		if((Integer.parseInt(n[0]) == Integer.parseInt(n[1]) && Integer.parseInt(n[0]) < Integer.parseInt(n[2])) || Integer.parseInt(n[0]) < Integer.parseInt(n[1])){
			int num = Integer.parseInt(n[0]);
			num++;
			System.out.println(num + "" + num+num);
		} else {
			System.out.println(n[0]+n[0] + n[0]);
		}
		

		saori.close();
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

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

using namespace std;

#ifdef DEBUG_MODE
	#define DBG(n) n;
#else
	#define DBG(n) ;
#endif
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(ll (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(ll (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int WWW = 0;WWW < (n);WWW++)cerr << v[WWW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

typedef long long ll;
typedef pair<ll,ll> P;

ll n;
ll num;

bool f(ll mid){
	ll cou = 0;
	ll san = 0;
	ll go = 0;
	ll juugo = 0;
	ll keta = 9;
	ll prev = 0;
	ll kazu = 1;
	ll tmpsan;
	ll tmpgo;
	ll tmpjuugo;
	while(mid > keta){
		tmpsan = keta / 3 - san;
		tmpgo = keta / 5 - go;
		tmpjuugo = keta / 15 - juugo;
		cou += (tmpsan + tmpgo) * 4;
		cou += (keta - prev - tmpsan - tmpgo + tmpjuugo) * kazu;
		
		san += tmpsan;
		go += tmpgo;
		juugo += tmpjuugo;
		kazu++;
		prev = keta;
		keta *= 10;keta += 9;
	}

	tmpsan = mid / 3 - san;
	tmpgo = mid / 5 - go;
	tmpjuugo = mid / 15 - juugo;
	cou += (tmpsan + tmpgo) * 4;
	cou += (mid - prev - tmpsan - tmpgo + tmpjuugo) * kazu;
	
	num = cou;
	return n > cou;
}

void m_prinf(ll kazu){
	string str = "";
	
	for(ll i = kazu;i < kazu + 20;i++){
		if(i % 3 == 0){
			str += "Fizz";
		}
		if(i % 5 == 0){
			str += "Buzz";
		}
		if(i % 3 != 0 && i % 5 != 0){
			string tmpstr = "";
			ll tmp = i;
			while(tmp){
				tmpstr += (char)((tmp % 10) + '0');
				tmp /= 10;
			}
			for(int j = tmpstr.size() -1 ;j >= 0;j--){
				str += tmpstr[j];
			}
		}
	}
	
	REP(i,str.size()){
		num++;
		if(num >= n && num < n+20){
			cout << str[i];
		}
	}
	cout << endl;
	
}

int main(){
	cin >> n;
	
	ll tb = LLINF;
	ll ub = 0;
	
	while(abs(tb - ub) > 1){
		ll mid = (tb + ub) / 2;
		if(f(mid))ub = mid;
		else tb = mid;
	}
	f(ub);
	m_prinf(ub+1);
	
	return 0;
}



Measured memory_bytes: 3196
#pragma GCC target ("avx")
#pragma GCC optimize ("unroll-loops")

#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = (ll)(1e9+7);
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(int)(n); (i)++)

int H, W, K;
string S[10];

signed main(){
	cin >> H >> W >> K;
	rep(i, H) cin >> S[i];

	int ans = INT_MAX;
	rep(i, 1<<H-1){
		int tmp = 0;
		rep(j, 10) tmp += (i>>j)&1;

		int cnt[10] ={};
		int flg = 0;
		rep(j, W){
			int idx = 0;
			rep(k, H){
				if(S[k][j] == '1') cnt[idx]++;
				idx += (i>>k)&1;
			}
			rep(k, H){
				if(cnt[k] > K){
					if(flg == 1){
						flg = 2;
						break;
					}
					memset(cnt, 0, sizeof(cnt));
					tmp++;
					j--;
					flg = 1;
					break;
				}
				if(k == H-1) flg = 0;
			}
			if(flg == 2){
				tmp = INT_MAX;
				break;
			}
		}

		ans = min(ans, tmp);
	}
	cout << ans << endl;
}

/*
2 2 1
11
11
*/

Measured memory_bytes: 256
#![allow(unused_imports)]

use text_io::*;
use proconio::*;
use std::collections::*;
use itertools::Itertools;
use std::process::exit;
use std::cmp::*;
use num::*;
use num::integer::Roots;

fn main() {
    input! {
    a:usize,
    mut b:[usize;a],
    }
    let mut c=0;
    for i in 1..a{
        if b[i-1]==b[i]{
            b[i]=0;
            c+=1;
        }
    }
    println!("{}",c)
}

Measured memory_bytes: 2140
#include <bits/stdc++.h>
#define LOCAL
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << ": " << arg1 << " |";
__f(comma + 1, args...);
}
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
//#########################################
int a[110000][3],dp[110000][3];
int dfs(int x,int today){
	//0nichime-xnichime kyou today wo shita
	// trace(x,today,a[x][today]);
	if(x == 0)return 0;
	if(dp[x][today] != -1)return dp[x][today];
	int ret = 0;
	//0
	if(today != 0)ret = max(ret,dfs(x-1,0) + a[x-1][today]);
	//1
	if(today != 1)ret = max(ret,dfs(x-1,1) + a[x-1][today]);
	//2
	if(today != 2)ret = max(ret,dfs(x-1,2) + a[x-1][today]);
	return dp[x][today] = ret;

}
signed main(){
	int n;cin >> n;
	rep(i,n)cin >> a[i][0] >> a[i][1] >> a[i][2];
	rep(i,110000)rep(j,3)dp[i][j] = -1;
	cout << max({dfs(n,0),dfs(n,1),dfs(n,2)}) << endl;
	return 0;
}

Measured memory_bytes: 14716
#include <cstdio>
#include <queue>
#include <algorithm>
#define maxn 200005
using namespace std;

int a[maxn], n;

struct Position
{
	int lf, rf, comfort;
	inline Position(int l, int r)
	{
		lf = l, rf = r;
		comfort = min(l, r);
	}
	inline bool operator<(const Position& p) const
	{
		return comfort < p.comfort;
	}
};

priority_queue<Position> q;

inline bool cmp(int x, int y) {return x > y;}

int main(int argc, char** argv)
{
	scanf("%d", &n);
	for(int i=0; i<n; i++)
		scanf("%d", a + i);
	sort(a, a + n, cmp);
	q.push(Position(a[0], a[1]));
	long long res = a[0];
	for(int i=2; i<n; i++)
	{
		Position p = q.top();
		if(q.size() > 1) q.pop();
		res += p.comfort;
		q.push(Position(a[i], p.lf));
		q.push(Position(a[i], p.rf));
	}
	printf("%lld\n", res);
	return 0;
}

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

using namespace std;

typedef long long LL;
typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

const int INF = 1e9 + 7;
int N;

int main(){
	cin >> N;
	LL s = 0 , m = INF;
	repp(i,0,N){
		LL A,B; cin >> A >> B;
		s += A;
		if(A > B) m = min(m,B);
	}
	cout << (m==INF?0:s-m) << endl;
	return 0;
}


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

long long minbei(long long a, long long b)
{
	if (b == 0)
	{
		return a;
	}
	else
	{
		return minbei(b, a%b);
	}
}

int main()
{
	long double n, x;
	long long  result = 1;
	while (cin >> n)
	{
		result = 1;
		for (int i = 0; i < n; i++)
		{
			cin >> x;
			result = result*(long long)(x / minbei(x, result));
		}
		cout << result << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;
import java.util.NoSuchElementException;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		int x1 = sc.nextInt();
		int y1 = sc.nextInt();
		int x2 = sc.nextInt();
		int y2 = sc.nextInt();
		List<Integer> resList = new ArrayList<>();
		if(y1>y2){
			resList.add(x2-(y2-y1));
			resList.add(y2+(x2-x1));
			resList.add(x1-(y2-y1));
			resList.add(y1+(x2-x1));
		}else{
			resList.add(x2-(y2-y1));
			resList.add(y2+(x2-x1));
			resList.add(x1-(y2-y1));
			resList.add(y1+(x2-x1));
		}
		for(int i=0;i<4;i++){
			out.print(resList.get(i));
			if(i!=3){
				out.print(" ");
			}else{
				out.println();
			}
		}
		out.flush();
	}
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}

Measured memory_bytes: 22996
#include<cstdio>
#include<algorithm>
using namespace std;
int a,b,c,d;
int main()
{
	scanf("%d%d%d%d",&a,&b,&c,&d);
	printf("%s\n",(abs(a-c)<=d||abs(a-b)<=d&&abs(b-c)<=d)?"Yes":"No");
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<iomanip>
#include<list>
#include<deque>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
typedef std::pair<int,int> P;
struct edge{int to,cost;};
const int INF=100000000000000000;
const int INF2=9223372036854775807;
const int MOD=1000000007;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
#define MAX(X,Y) (*max_element(X,Y))
#define MIN(X,Y) (*min_element(X,Y))
#define NP(X,Y) next_permutation(X,Y)
#define setp(X,Y) cout<<fixed<<setprecision(Y)<<X;
int ceil2(int a,int b){if(a%b==0){return a/b;}else{return a/b+1;}}
int pow2(int a,int b){int r=1;for(int i=1;i<=b;i++){r*=a;}return r;}
int Log2(int a){int t=0;while(1){if(a==0||a==1){break;}a/=2;t++;}return t;}

int N;
int A[110];

signed main(){
	cin>>N;
	REP(i,N){
		cin>>A[i];
	}
	double d;
	REP(i,N){
		d+=1.000000000/(double)A[i];
	}
	setp(1.00000000000000/d,10)
	cout<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define INF 1e16
typedef pair<int,int> P;
typedef long long ll;

int main(void){
    int r;
    cin>>r;
    cout<<3*r*r<<endl;
    return 0;
}

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

typedef std::pair <int, int> pii;

const int N = 100010;

pii x[N], y[N];
int fa[N];
std::vector <std::pair <int, pii>> e;

int find(int u){
	return fa[u] == u ? u : (fa[u] = find(fa[u]));
}

void unite(int u, int v){
	int _u = find(u), _v = find(v);
	fa[_u] = _v;
}

int main(){
	int n;
	scanf("%d", &n);
	for (int i = 0, u, v; i < n; ++ i){
		scanf("%d%d", &u, &v);
		x[i] = {u, i};
		y[i] = {v, i};
	}
	std::sort(x, x + n);
	std::sort(y, y + n);
	for (int i = 0; i < n - 1; ++ i){
		e.push_back({x[i + 1].first - x[i].first, {x[i].second, x[i + 1].second}});
		e.push_back({y[i + 1].first - y[i].first, {y[i].second, y[i + 1].second}});
	}
	std::sort(e.begin(), e.end());
	for (int i = 0; i < N; ++ i){
		fa[i] = i;
	}
	long long ans = 0;
	for (auto u : e){
		int v = u.second.first, w = u.second.second;
		if (find(v) != find(w)){
			unite(v, w);
			ans += u.first;
		}
	}
	return printf("%lld\n", ans), 0;
}

Measured memory_bytes: 6516
//#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1e9;
const ll LINF = ll(1e18);
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
//cout<<fixed<<setprecision(15);有効数字15桁
//-std=c++14
//-std=gnu++17
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m;
    char c;
    cin>>n>>c>>m;
    if(c=='+')cout<<n+m<<"\n";
    else cout<<n-m<<"\n";
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main {

    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int i = 1;
        
        while (x != 0) {
            System.out.println("Case " + i + ": " + x);
            i++;
            x = sc.nextInt();
        }

    }
}



Measured memory_bytes: 42492
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N;
    cin>>N;
    vector<int> X(N);
    int L = 2000;
    int R = 2000;
    for (int i=0; i<N; i++) cin>>X[i];
    for (int i=0; i<N; i++) {
        L = min(L,X[i]);
        R = max(R,X[i]);
    }
    long ans = 1000000000;
    for (int i = L; i<= R; i++) {

        long s = 0;
        for (int j= 0; j<N; j++) {
            s+= (X[j] - i) * (X[j] - i);
        }
        ans = min(ans,s);
    }
    cout<<ans<<endl;
    return 0;
}

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

typedef long long ll; typedef unsigned long long ull; typedef unsigned int uint; typedef long double ld;

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

int n;
cin >> n;
ll t;
ld ans = 1;
for (int i = 0; i < n; i++)
{
    cin >> t;
    if (ans != -1)
       ans *= t;
    if (ans > 1000000000000000000 || ans < 0)
       ans = -1;
    if (t == 0)
       ans = 0;
}
cout << (ll)ans;
return 0;
}

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

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


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

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cout<<*i<<" "; cout<<endl; }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
ll f(int n){
	if(n <= 1) return 1;
	else return (ll)n * f(n-1);
}
int main(){
	string s;
	cin>>s;
	map<char, int> c;
	REP(i,s.size())c[s[i]]++;
	int n = s.size();
	int sum = 0;
	FORIT(it,c)sum += it->second % 2;
	bool canmake = n % 2 == sum;
	if(canmake){
		n -= n % 2;
		FORIT(it,c)it->second -= it->second % 2;
		ll ans = 1;
		ans *= f(n/2);
		FORIT(it,c)ans /= f(it->second/2);
		cout<<ans<<endl;
	}else{
		cout<<0<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,d;
	cin>>n>>d;
	long long int x,y,c=0;
	for(int i=0;i<n;i++)
	{
		cin>>x>>y;
		long double d1=sqrt(x*x+y*y);
		if(d1<=(d))c++;
	}
	cout<<c;
	return 0;
}


Measured memory_bytes: 3664
from heapq import heappush, heappop
import sys

input = sys.stdin.buffer.readline


n, q = map(int, input().split())
STX = [list(map(int, input().split())) for _ in range(n)]
task = []
for s, t, x in STX:
    task.append((t - x, 0, x))
    task.append((s - x, 1, x))
for i in range(q):
    d = int(input())
    task.append((d, 2, i))

task.sort()
kouho = set()
kouho_hp = []
ans = [-1] * q
for a, b, c in task:
    if b == 0:
        kouho.remove(c)
    if b == 1:
        kouho.add(c)
        heappush(kouho_hp, c)
    if b == 2:
        while kouho_hp and kouho_hp[0] not in kouho:
            heappop(kouho_hp)
        if not kouho_hp:
            continue
        else:
            ans[c] = kouho_hp[0]
        # heapは0-indexが最小値になっているからheapified_list[0]でもよい
print(*ans, sep="\n")


Measured memory_bytes: 146352
N = int(input())
Node = [[] for _ in range(N+1)]
P = []
for _ in range(N-1):
    a, b = map(int, input().split())
    Node[a].append(b)
    Node[b].append(a)
    P.append((a, b))
C = sorted(list(map(int, input().split())))
check = [0]*(N+1)
value = [0]*(N+1)
Q = [1]
cnt = 0
while Q:
    u = Q.pop()
    check[u] = 1
    value[u] = C[N-1-cnt]
    cnt += 1
    for v in Node[u]:
        if check[v]:
            continue
        else:
            Q.append(v)

ans = 0
for a, b in P:
    ans += min(value[a], value[b])

print(ans)
print(*value[1:])
 


Measured memory_bytes: 51544
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
    ll n,d;
    cin>>n>>d;
    ll cnt=0;
    for(ll i=0;i<n;++i){
        ll x,y;
        cin>>x>>y;
       //(y<0) y*=-1;
        long double dist = sqrt((x*x)+(y*y));
        //cout<<x<<" "<<y<<" "<<dist<<endl;
        if(dist<=d) {
            cnt++;
        }
    }
    cout<<cnt;
    return 0;
}

Measured memory_bytes: 3572
#include <bits/stdc++.h>
/// TONI BO$$ was here
/// #MLC

using namespace std;

int main()
{
    double x,y,a,b;
    scanf("%lf%lf%lf%lf",&a,&b,&x,&y);
    int rez=0;
    if(x==a/2.0 && y==b/2.0)
        rez=1;
    printf("%lf %d",a*b/2.0,rez);

    return 0;
}


Measured memory_bytes: 384
#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
ld EPS = 1e-12;
int INF = numeric_limits<int>::max() / 2;
int MOD = 1e9 + 7;

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

    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    int disx = x2 - x1;
    int disy = y2 - y1;
    int x3 = x2 - disy;
    int y3 = y2 + disx;
    int x4 = x3 - disx;
    int y4 = y3 - disy;
    cout << x3 << " " << y3 << " " << x4 << " " << y4 << '\n';
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
class Program{
	const int mod=1000000007;
	static void Main(){
		int n=int.Parse(Console.ReadLine());
		int[][] h=new int[n][];
		for(int i=0;i<n;i++){h[i]=Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}
		int m=1<<n;
		int b=1;
		long[] all=new long[m];
		long[] dp=new long[m];
		for(int i=3;i<m;i++){
			if(i==(1<<(b+1))){b+=1;continue;}
			for(int j=b;j>0;j--){
				if((i&(1<<j))==0){continue;}
				for(int k=j-1;k>=0;k--){
					if((i&(1<<k))!=0){all[i]+=h[j][k];}
				}
			}
			dp[i]=all[i];
			for (int j=((1<<(b+1))-1)&i;j>0;j=(j-1)&i){dp[i]=Math.Max(dp[i],dp[j]+dp[(~j)&i]);}
		}
		Console.WriteLine(dp[m-1]);
	}
}

Measured memory_bytes: 13372
#include <bits/stdc++.h>
#define ll long long int
#include <cstdio>
#include <iostream>
#include <iomanip>

using namespace std;

int main(){
  long double a,b,x; cin >> a >> b>>x;
  long double ans; long double pi = 3.141592653589793238;
  long double c = a*a*b/2;
  long double x1,y1;
  if(c<=x && x<2*c){
    x1 = 2*(a*a*b-x);
    y1 = a*a*a;
    long double answer = 90-atan2(y1,x1)*180/pi;
  cout<<fixed<<setprecision(12)<< answer<<endl;
  }
  else if(x == a*a*b){
    cout << "0" <<endl;
  }
  else{
     x1 = a*b*b;
     y1= 2*x;
    long double answer = 90-atan2(y1,x1)*180/pi;
  cout<<fixed<<setprecision(12)<< answer<<endl;
  }
  
  
}

Measured memory_bytes: 256
A, B, C = map(int, input().split())

if A % 2 == B % 2 == C % 2 == 0:
    if A == B == C:
        print(-1)
    else:
        ans = 0
        while A % 2 == B % 2 == C % 2 == 0:
            S = A + B + C
            A, B, C = (S - A) // 2, (S - B) // 2, (S - C) // 2
            ans += 1
        print(ans)
else:
    print(0)

Measured memory_bytes: 3064
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func main() {
	sc := NewScanner()
	D := sc.nextIntSlice(5)
	ans := 0
	maxDiff := 0
	for i := 0; i < 5; i++ {
		if D[i]%10 == 0 {
			ans += D[i]
		} else {
			diff := 10 - D[i]%10
			if maxDiff < diff {
				maxDiff = diff
			}
			ans += D[i] + diff
		}
	}
	fmt.Println(ans - maxDiff)
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  string s;
  cin >> s;
  map<char, int> mp;
  int n = s.size();
  rep(i, 0, n) mp[s[i]]++;

  if (mp.size() == 4)
    cout << "Yes" << endl;
  else if (mp.size() == 2) {
    char x[2];
    int i = 0;
    for (auto m : mp) {
      x[i] = m.first;
      i++;
    }
    if ((x[0] == 'N' && x[1] == 'S') || (x[0] == 'E' && x[1] == 'W'))
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
  } else
    cout << "No" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <deque>
#include <list>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>

using namespace std;


#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int (i)=(n); (i)>=(0); (i)--)
#define SIZE(x) ((int)(x).size())
#define GCD(a, b) int gcd(int a,int b){return b?gcd(b,a%b):a;}
#define QP(a, b) int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define all(v) (v).begin(),(v).end()


template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
template<typename A, size_t N, typename T>
void FILL(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

typedef vector<int, int> vint;
typedef pair<int,int> pint;
typedef vector<pint>vpint;
typedef long long ll;

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1LL << 60;
const ll MOD = 1000000007LL;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string O, E, ans; cin >> O >> E; ans = "";
    int i = 0;
    while(true){
        if(i == O.size()) break;
        ans.pb(O[i]);
        if(i == E.size()) break;
        ans.pb(E[i]);
        i++;
    }
    cout << ans;
    cout << endl;
    return 0;
}




Measured memory_bytes: 256
n, q = map(int, input().split())
listS = list(input())
index=0
listA=[]
listM=[0]*n
index2=1
countM=0
while index2 < len(listS):
    if listS[index2-1]=="A" and listS[index2]=="C":
        countM+=1
    listM[index2] = countM               
    index2+=1

while index < q:
    l, r = map(int, input().split())
    listA.append(listM[r-1]-listM[l-1])
    index+=1
for ans in listA:
    print(ans)

Measured memory_bytes: 10956
def valid?(a, b, c)
  a <= b + c && b <= c + a + 1 && c <= a + b + 1
end
 
def calc(rear, front, west, east, north, south, buffer, best)
  buffer.size.times do |i|
    a = rear + front
    b = west + east
    c = north + south
 
    if east > 0 && valid?(b - 1, c, a)
      rear, front, west, east = east - 1, west, rear, front
      y = 69
    elsif north > 0 && valid?(c - 1, a, b)
      rear, front, north, south = north - 1, south, front, rear
      y = 78
    elsif south > 0 && valid?(c - 1, a, b)
      rear, front, north, south = south - 1, north, rear, front
      y = 83
    #elsif west > 0 && valid?(b - 1, c, a)
    else
      rear, front, west, east = west - 1, east, front, rear
      y = 87
    end
     
    if best
      x = best[i]
      return best if x < y
      best = nil if x > y
    end
    buffer[i] = y  
  end
  buffer.dup
end
 
def find(target, limit)
  buffer = [0] * limit
  best = nil
  target.permutation(6).to_a.uniq.each do |rear, front, west, east, north, south|
    a = rear + front
    b = west + east
    c = north + south
    if valid?(a, b, c)
      best = calc(rear, front, west, east, north, south, buffer, best)
    end
  end
  best
end
 
loop do
  target = gets.split.map!(&:to_i)
  break if target.all?(&:zero?)
  p, q = gets.split.map!(&:to_i)
  result = find(target, q)
  puts result ? result[p-1...q].pack('C*') : 'impossible'
end

Measured memory_bytes: 30160
#include<iostream>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
#include<cstring>
using namespace std;

int main(void) {
	int a[3];
	cin >> a[0] >> a[1] >> a[2];
	sort(a, a + 3);
	int k,i;
	cin >> k;
	for (i = 0; i < k; i++) {
		a[2] *= 2;
	}
	cout << a[0] + a[1] + a[2] << endl;

	return 0;
}








Measured memory_bytes: 256
using System;
using System.Text;

class Program
{
    static void Main(string[] args)
    {
        var p = new Program();
        var N = int.Parse(Console.ReadLine());
        var s = Console.ReadLine();
        StringBuilder sb = new StringBuilder();
        //var N = int.Parse(Console.ReadLine());
        //var input = p.ConvertIntArray(p.ReadInput());
        //var A = input[0];
        //var B = input[1];
        //var ans = 0;

        for(var i = 0; i<s.Length; i++)
        {
            char c = Convert.ToChar(s[i]);
            var temp = Convert.ToInt32(c);
            temp = (int)s[i] + N;
            if (temp > 90)
            {
                temp -= 26;
                sb.Append(Convert.ToChar(temp));
            }
            else
            {
                sb.Append(Convert.ToChar(temp));
            }

        }

        Console.WriteLine(sb);

    }


    public string[] ReadInput()
    {
        return Console.ReadLine().Split(' ');
    }

    public int[] ConvertIntArray(string[] x)
    {
        var convertedArray = new int[x.Length];
        for (var i = 0; i < x.Length; i++)
        {
            convertedArray[i] = int.Parse(x[i]);
        }

        return convertedArray;
    }

}


Measured memory_bytes: 11224
n, q = map(int, input().split())
l = [list(input().split()) for i in range(n)]
from collections import deque
que = deque([[l[i][0], int(l[i][1])] for i in range(n)])
a = []
time = 0
while que != deque([]):
    a = que.popleft()
    if a[1] <= q:
        time += a[1]
        print("{} {}".format(a[0], str(time)))
    else:
        time += q
        a[0], a[1] = a[0], a[1] - q
        que.append(a)

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

int main(){

    int n,y;
    cin>>n>>y;

    for(int i=0;i<=n;i++){
        for(int j=0;j<=n-i;j++){
            int k=n-i-j;
            if(k>=0&&10000*i+5000*j+1000*k==y){
                cout<<i<<" "<<j<<" "<<k<<endl;
                return 0;
            }

        }
    }  

    cout<<-1<<" "<<-1<<" "<<-1<<endl;






    return 0;
}

Measured memory_bytes: 256
# 1以上100以下
N = gets.to_i
# X,Yは0以上100以下
# hは0以上1000000000以下
X = N.times.map { gets.split.map(&:to_i) }

xt = 0
yt = 0
ht = 0
N.times do |n|
  if X[n][2] > 0
    xt = X[n][0]
    yt = X[n][1]
    ht = X[n][2]
    break
  end
end

(0..100).each do |cx|
  (0..100).each do |cy|
    # 高さHを推定する
    # CxとCyは0..100なので総当たり
    # ht = h - (xt - cx).abs - (yt - cy).abs を右辺左辺入れ替え
    h = [ht + (xt - cx).abs + (yt - cy).abs, 0].max

    found = true
    (0...N).each do |i|
      # 推定した高さH,Cx,Cyが観測値100個全てと一致すればOK
      if X[i][2] != [h - (X[i][0] - cx).abs - (X[i][1] - cy).abs, 0].max
        found = false
        break
      end
    end
    if found
      puts [cx,cy,h].join(' ')
      exit
    end
  end
end

Measured memory_bytes: 1788