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

using namespace std;

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


const ll LongINF=1e13+7;
const int INF=1e9+7;
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template <class T, class Y>T GCD(T a, Y b){if(a<b){int c=a;a=b;b=c;}if (a % b == 0){return b;}return GCD(b, a % b);}
template<class T,class Y> T FLOOR(T a,Y b){return (a+b-1)/b;}
void clear(queue<pair<int, int>> &q){queue<pair<int, int>> empty;swap(q, empty);} //queueの中身の型は適時変更を忘れない
#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define rv reverse
#define ALL(a) (a).begin(),(a).end()


int main(){
    ll N,ans=0;
    cin>>N;
    if(ll(N)%2==1){
        cout<<0<<endl;
        return 0;
    }else{
        for(ll i=10;i<=N;i*=5){
            ll a=N/i;
            ans+=a;
        }
        cout<<ans<<endl;
        return 0;
    }


    return 0;
}

//a=97,z=122

Measured memory_bytes: 256
N=int(input())

A=list(map(int, input().split()))
p=10**9+7
if A[0]!=0:
    print(0)
    exit()

dp=[0]*N
dp[0]=3
counts=[0]*N #前が何人か(自分が＊人目)
counts[0]=1
for i in range(1,N):
    a=A[i]
    if a==0:
        dp[i]=(dp[i-1]*(3 - counts[a]))%p
    else:
        dp[i]=(dp[i-1]*(counts[a-1] - counts[a]))%p
    

    counts[a]+=1

print(dp[-1])    
    


Measured memory_bytes: 85324
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;

enum inf3 = 1_001_001_001;
enum inf6 = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;




void main() {
    int n;
    scan(n);
    auto a = iota(n).map!(i => readln.chomp.to!int).array;

    int top, sec;

    foreach (i ; 0 .. n) {
        if (a[i] > top) {
            sec = top;
            top = a[i];
        }
        else if (a[i] > sec) {
            sec = a[i];
        }
    }

    foreach (i ; 0 .. n) {
        if (a[i] < top) {
            writeln(top);
        }
        else {
            writeln(sec);
        }
    }
}




















int[][] readGraph(int n, int m, bool isUndirected = true, bool is1indexed = true) {
    auto adj = new int[][](n, 0);

    foreach (i; 0 .. m) {
        int u, v;
        scan(u, v);
        if (is1indexed) {
            u--, v--;
        }
        adj[u] ~= v;
        if (isUndirected) {
            adj[v] ~= u;
        }
    }

    return adj;
}

alias Edge = Tuple!(int, "to", int, "cost");

Edge[][] readWeightedGraph(int n, int m, bool isUndirected = true, bool is1indexed = true) {
    auto adj = new Edge[][](n, 0);

    foreach (i; 0 .. m) {
        int u, v, c;
        scan(u, v, c);
        if (is1indexed) {
            u--, v--;
        }
        adj[u] ~= Edge(v, c);
        if (isUndirected) {
            adj[v] ~= Edge(u, c);
        }
    }

    return adj;
}

void yes(bool b) {
    writeln(b ? "Yes" : "No");
}

void YES(bool b) {
    writeln(b ? "YES" : "NO");
}

T[] readArr(T)() {
    return readln.split.to!(T[]);
}

T[] readArrByLines(T)(int n) {
    return iota(n).map!(i => readln.chomp.to!T).array;
}

void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x > arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x < arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}


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

int main(){
  int A,B,K;
  cin >> A >> B >> K;
  for(int i = A;i <= B;i++){
    if(i <= (A + K - 1))cout << i << endl;
    else if(i >= (B - K + 1))cout << i << endl;
  }
}

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

using namespace std;

#define DEBUG(...) fprintf(stderr, __VA_ARGS__)
#define mp make_pair
#define fst first
#define snd second
#define SZ(u) ((int) (u).size())
#define ALL(u) (u).begin(), (u).end()

inline void proc_status()
{
    ifstream t("/proc/self/status");
    cerr << string(istreambuf_iterator<char>(t), istreambuf_iterator<char>()) << endl;
}

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }
template<typename T> inline T read()
{
	register T sum(0), fg(1);
	register char ch(getchar());
	for(; !isdigit(ch); ch = getchar()) if(ch == '-') fg = -1;
	for(;  isdigit(ch); ch = getchar()) sum = (sum << 3) + (sum << 1) - '0' + ch;
	return sum * fg;
}

typedef long long LL;
typedef long double LD;
typedef pair<int, int> pii;

LL k;

inline void input()
{
	k = read<LL>();
}

LL p10[20];

inline int safe_log(LL val)
{
	int cnt = 0;
	while(val) val /= 10, ++cnt;
	return cnt;
}

inline LL F(LL x)
{
	int D = safe_log(x), sum = 0;
	for(int i = 0; i <= D; ++i) sum += x / p10[i] % 10;

	double mn = (double) x / sum;
	LL x0 = x;
	for(int i = 0; i <= D; ++i)
	{
		int p = x / p10[i] % 10;
		x -= p * p10[i], sum -= p;
		x += 9 * p10[i], sum += 9;
		if(chkmin(mn, (double) x / sum)) x0 = x;
	}
	return x0;
}

inline void solve()
{
	p10[0] = 1;
	for(int i = 1; i <= 18; ++i) p10[i] = p10[i - 1] * 10;
	for(LL x = 1; k--; x = F(x + 1)) printf("%lld\n", x);
}

int main()
{
//	freopen("D.in", "r", stdin);
//	freopen("D.out", "w", stdout);

	input();
	solve();

	return 0;
}



Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<cstring>
#include<string>
#include<cmath>
#include<ctime>
#include<set>
#include<vector>
#include<map>
#include<queue>
 
#define N 3000005
#define M 8000005
 
#define ls (t<<1)
#define rs ((t<<1)|1)
#define mid ((l+r)>>1)
 
#define mk make_pair
#define pb push_back
#define fi first
#define se second
 
#define Mo 998244353
#define g 3
 
using namespace std;

int i,j,m,n,p,k,A,B,C;

int main()
{
		scanf("%d%d%d",&A,&B,&C);
		printf("%d\n",B+min(A+B+1,C)); 
}


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

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

int N,M;
vector<pair<int,int>> V;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>M;
	FOR(i,N) {
		cin>>x>>y;
		V.push_back({x,y});
	}
	sort(ALL(V));
	ll ret=0;
	FORR(v,V) {
		x=min(M,v.second);
		ret+=1LL*x*v.first;
		M-=x;
	}
	cout<<ret<<endl;
	
}


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


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

#define rep(i,a,b)      for(int i=a;i<=b;i++)
#define revp(i,a,b)     for(int i=b;i>=a;i--)

int n,d,ans;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    

    cin>>n>>d;
    d=2*d+1;
    if(n%d==0)
        ans=n/d;
    else
        ans=n/d+1;
    cout<<ans;
}


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

const int MAX = 8;

int N;
int A, B, C;
vector<int> l(MAX);

int solve(int n, int a, int b, int c)
{
    if (n == N) {
        if (a > 0 && b > 0 && c > 0) {
            return (abs(a - A) - 10) + (abs(b - B) - 10) + (abs(c - C) - 10);
        } else {
            return 1000000;
        }
    }
    int mp[4] = {0};
    mp[0] = solve(n + 1, a, b, c);
    mp[1] = solve(n + 1, a + l[n], b, c) + 10;
    mp[2] = solve(n + 1, a, b + l[n], c) + 10;
    mp[3] = solve(n + 1, a, b, c + l[n]) + 10;
    return *min_element(mp, mp + 4);
}

int main(int argc, const char * argv[]) {
    cin >> N;
    cin >> A >> B >> C;
    
    for (int i = 0; i < N; i++) {
        cin >> l[i];
    }
    
    cout << solve(0, 0, 0, 0) << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
typedef long long int lli;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    map<int, int> m;
    rep(i,n){
        ll mi;
        cin >> mi;
        m[mi]++;
    }
    if (m.count(0) && m[0] == n){
        cout << "Yes" << endl;
        return 0;
    }

    if (n % 3 != 0){
        cout << "No" << endl;
        return 0;
    }

    if (m.size() == 2 && m.count(0) && m[0] == n/3){
        cout << "Yes" << endl;
        return 0;
    }
    else if (m.size() == 3){
        ll ans = 0;
        for(auto mi = m.begin(); mi != m.end(); mi++){
            if (mi->second != n/3){
                cout << "No" << endl;
                return 0;            
            }
            ans ^= mi->first;
        }
        if (ans == 0){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
 
}

Measured memory_bytes: 4224
#include <bits/stdc++.h>
#define FOR(i,a,b) for(ut i=(a);i<(ut)(b);i++)
#define REP(i,b) FOR(i,0,b)
#define ALL(c) c.begin(),c.end()
#define PB push_back
#define cat //cout << __LINE__ << endl;
using namespace std;
typedef long long LL;
typedef double ld;
typedef LL ut;
typedef vector<ut> VI;
typedef pair<ut,ut> pr;
typedef vector<pr> Vpr;
typedef pair<ut,ut> prs;
inline void IN(ut &x){cin >> x;}
inline void INA(ut n,ut x[]){REP(i,n) cin >> x[i];}
inline void INE(ut m,VI edges[]){
	ut a,b;
	REP(i,m){
		cin >> a >> b;
		edges[a].PB(b);
		edges[b].PB(a);
	}
}
inline void INEC(ut m,Vpr edges[]){
	ut a,b,c;
	REP(i,m){
		cin >> a >> b >> c;
		edges[a].PB(pr(c,b));
		edges[b].PB(pr(c,a));
	}
}
const int SIZE=5+2*1e5;
const int INF=10+1e9;
const LL p=7+1e9;
VI nums;
int main(){
	int N,M;
	string s;
	LL ans=0,x;
	cin >> N;
	REP(i,N*3){
		cin >> x;
		nums.PB(x);
	}
	sort(ALL(nums),greater<LL>());
	REP(i,N){
		ans+=nums[i*2+1];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 6512
import fractions as fr
from functools import reduce

n=int(input())
t=[input() for i in range(n)]
t=[int(i) for i in t]

def lcm_base(x, y):
    return (x * y) // fr.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

print(lcm(*t))

Measured memory_bytes: 5076
#include <iostream>
#include <fstream>
#include <string> 
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <functional>
#include <cctype>
#include <list>
//#include <boost/multiprecision/cpp_int.hpp>

#define BIT(a) (1 << (a))

using namespace std;
//using namespace boost::multiprecision;

long long MOD = 1000000007;


long long mod_pow(long long x, long long n){
    long long res = 1;
    for(int i = 0;i < 60; i++){
        if(n >> i & 1) res = res * x % MOD;
        x = x * x % MOD;
    }
    return res;
}

char field[10][10];
int H, W;

int dfs(int x, int y){
    int nx = x+1;
    int ny = y+1;
    field[x][y] = '.';
    int flag = 0;
    if (nx < W && field[nx][y] == '#'){
        flag = 1;
        dfs(nx, y);
    }
    if (ny < H && field[x][ny] == '#'){
        if (flag) return 0;
        dfs(x, ny);
    }
    return 0;
}

int main(void){
    cin >> H >> W;
    for (int i = 0; i < H; i++){
        for (int j = 0; j < W; j++){
            scanf(" %c", &field[j][i]);
        }
    }
    dfs(0, 0);
    for (int i = 0; i < H; i++){
        for (int j = 0; j < W; j++){
            if (field[j][i] == '#'){
                cout << "Impossible" << endl;
                return 0;
            }
        }
    }
    cout << "Possible" << endl;
    return 0;
}



Measured memory_bytes: 256
N,Q = map(int,input().split())
S = (input())
cnt = [0] * (N + 1)
for i in range(N):
 if S[i:i+2] == "AC":
  cnt[i+1] = cnt[i] + 1
 else:
  cnt[i+1] = cnt[i]

for i in range(0,Q):
 l,r = map(int,input().split())
 print(cnt[r-1] - cnt[l-1])


Measured memory_bytes: 52824
A = input("")
L = A.split(" ")
a_s = ""
a = int(L[0])
b = int(L[1])

if (a < b):
    for i in range(b):
        a_s += str(a)
else:
    for i in range(a):
        a_s += str(b)

print(a_s)

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

int main() {
	std::string s;
  	long i = 0;
	std::cin >> s;
  	for (int j = 0;j < 4;++j)
		if (s[j] == '+')
          ++i;
      	else
          --i;
	std::cout << i << std::endl;
}

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

using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

int main() {

	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif

	int n; string s; cin >> n >> s;
	int a = 0;
	int f = -1;
	// cout << n << ' ' << s << endl;
	for (int i = 0; i < n; i++) {
		if (s[i] == ')') {
			if (f == -1) f = i;	// The index of the first ')' character
			a--;
			if (a < 0) {
				s.insert(f, "(");
				a++; n++; i++;
			}
		}  else {
			a++;
		}

		// cout << a << ' ' << s << endl;
	}
	string s2 = "";
	for (int i = 0; i < a; i++) s2 += ")";
	s.insert(n, s2);
	cout << s;
	
	return 0;
}

Measured memory_bytes: 3576
/*
    Author:zeke
    
    pass System Test!
    GET AC!!
*/
#include <iostream>
#include <queue>
#include <vector>
#include <iostream>
#include <vector>
#include <string>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <map>
#include <iomanip>
#include <utility>
#include <stack>
#include <bitset>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rep3(var, min, max) for (ll(var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ll(var) = (max)-1; (var) + 1 > (min); --(var))
#define Mp(a, b) make_pair((a), (b))
#define F first
#define S second
#define Icin(s) \
    ll(s);      \
    cin >> (s);
#define Scin(s) \
    ll(s);      \
    cin >> (s);
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;
}
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef vector<V> VV;
typedef vector<P> VP;
ll mod = 1e9 + 7;
ll MOD = 1e9 + 7;
ll INF = 1e18;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    string s;
    cin>>s;
    ll cnt1=0;
    ll temp1=0;
    ll temp2=0;
    rep(i,n){
        if(s[i]==')'){
            if(temp1<temp2){
                temp1++;
                continue;
            }
            temp1++;temp2++;cnt1++;
        }else{
            temp2++;
        }
        //cout<<temp1<<" "<<temp2<<endl;
    }
    ll cnt2=0;
    temp1=0;
    temp2=0;
    for(int i=n-1;i>=0;i--){
        if(s[i]=='('){
            if(temp1<temp2){
                temp1++;
                continue;
            }
            temp1++;temp2++;cnt2++;
        }else{
            temp2++;
        }
    }
    rep(i,cnt1)cout<<'(';
    cout<<s;
    rep(i,cnt2)cout<<')';
    cout<<endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
int a[200000], dp[200000];
int main()
{
	int n, k;
	scanf("%d%d", &n, &k);
	dp[0] = 0;
	for(int i = 1; i < 200000; dp[i++] = 1 << 30){}
	for(int i = 0; i < n; scanf("%d", &a[i++])){}
	for(int i = 0; i < n - 1; ++i)
	{
		for(int j = 1; j <= k; ++j)
		{
			dp[i + j] = min(dp[i + j], dp[i] + abs(a[i + j] - a[i]));
		}
	}
	printf("%d\n", dp[n - 1]);
}

Measured memory_bytes: 1408
import sys
range = xrange
input = raw_input

n = int(input())

A = [int(x) for x in input().split()]

B = [a for a in A if a&1 == 0]

if B == [b for b in B if b%3 == 0 or b%5 == 0]:
    print 'APPROVED'
else:
    print 'DENIED'


Measured memory_bytes: 28012
package main

import "fmt"

var t [100001]int
var a [100]int
var n int

func solve(k int) int {
	if t[k] != 0 {
		return t[k]
	}

	for i := 0; i < n; i++ {
		if k < a[i] {
			break
		}
		s := solve(k - a[i])
		if s < 0 {
			t[k] = 1
			return 1
		}
	}

	t[k] = -1
	return -1
}

func main() {
	var k int
	fmt.Scan(&n, &k)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i])
	}

	if solve(k) < 0 {
		fmt.Println("Second")
	} else {
		fmt.Println("First")
	}
}


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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
using ll = long long;

int main() {
    ll A, B, C, K;
    cin >> A >> B >> C >> K;

    ll ans = 0;
    ans += min(A, K);
    K -= A + B;
    if (K > 0) ans -= K;

    cout << ans << endl;
}


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

using namespace std;

#define REP(var, n)  for (decltype(n) var = 0; var < (n); var++)
#define RREP(var, n)  for (auto var = n - 1; var != static_cast<decltype(var)>(-1); var--)
#define FOR(var, a, b)  for (auto var = (a); var < (b); var++)
#define RFOR(var, a, b)  for (auto var = b - 1; var != a; var--)

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;

#define all(c) begin(c),end(c)

#define D(x) do { std::cerr << x << " "; } while (0)
#define D2(x) do { std::cerr << #x << ": " << x << std::endl; } while (0)


template<typename T>
std::ostream &operator<<(std::ostream &out, const std::vector<T> &v) {
    if (!v.empty()) {
        out << '[';
        std::copy(v.begin(), v.end(), std::ostream_iterator<T>(out, ", "));
        out << "\b\b]";
    }
    return out;
}


template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
    return os << '(' << p.first << ',' << p.second << ')';
}


template<class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}


auto solve() {
    int N;
    cin >> N;

    vll a(N);
    for (auto &&e: a) cin >> e;

    vector<vll> dp(N + 1, vll(N + 1, 0));

    FOR(size, 1, N + 1) {
        REP(i, N) {
            int j = i + size;
            if (j > N) continue;

            if ((N - size) % 2 == 0) {
                dp[i][j] = max(
                        a[i] + dp[i + 1][j],
                        dp[i][j - 1] + a[j - 1]
                );
            } else {
                dp[i][j] = min(
                        -a[i] + dp[i + 1][j],
                        dp[i][j - 1] - a[j - 1]
                );
            }
        }
    }

    return dp[0][N];
}


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

//    cout << (solve() ? "First" : "Second") << endl;
//    cout << (solve() ? "YES" : "NO") << endl;
    cout << solve() << endl;
//    solve();

    return 0;
}


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

using lli = long long int;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

int main() {
  string o,e;
  cin >> o>>e;
  rep(i, o.size()+e.size())
    cout<<(i%2==0?o.at(i/2):e.at(i/2));
  cout<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string a, b;
  cin >> a >> b;
  int kaunto = 0;
  for (int i = 0; i < a.size(); i++) {
    if (a.at(i) != b.at(i)) {
      kaunto += 1;
    }
  }
  cout << kaunto << endl;
}

Measured memory_bytes: 3916
import java.util.Scanner;

/**
 * http://abc071.contest.atcoder.jp/tasks/arc081_b
 */
public class Main {

	final static int MOD = 1000000007;

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		final int N = sc.nextInt();
		String s1 = sc.next();
		String s2 = sc.next();
		sc.close();
		
		long ans = 1;
		for(int i=0; i<N;){
			if(s1.charAt(i)==s2.charAt(i)){
				if(i==0){
					ans *= 3;
				}else if(s1.charAt(i-1) == s2.charAt(i-1)){
					ans *= 2;
				}
				i+=1;
			}else{
				if(i==0){
					ans *= 6;
				}else if(s1.charAt(i-1) == s2.charAt(i-1)){
					ans *= 2;
				}else{
					ans *= 3;
				}
				i+=2;
			}
			ans %= MOD;
		}
		
		System.out.println(ans);

	}

}

Measured memory_bytes: 22996
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
constexpr int MOD = 1'000'000'007;
//inline void modAdd(LL &l, LL &r) {l = (l + r) % MOD;}

template<class T> inline T sqr(T x) {return x*x;}

void solve() {
    string s;
    cin >> s;
    int n = s.size();
    VVLL dp(n,VLL(13));
    if (s[0] == '?') REP(i,0,10) dp[0][i]++;
    else dp[0][s[0]-'0']++;
    REP(i,1,n) {
        if (s[i] == '?') {
            REP(j,0,13) {
                REP(add,0,10) {
                    dp[i][(j*10+add)%13] += dp[i-1][j];
                    if (dp[i][(j*10+add)%13] >= MOD) dp[i][(j*10+add)%13] -= MOD;
                }
            }
        } else {
            int add = s[i] - '0';
            REP(j,0,13) {
                dp[i][(j*10+add)%13] += dp[i-1][j];
                if (dp[i][(j*10+add)%13] >= MOD) dp[i][(j*10+add)%13] -= MOD;
            }
        }
    }
    cout << dp[n-1][5] << endl;
    /* 
    REP(i,0,n) {
        REP(j,0,13) cout << dp[i][j] << " ";
        cout << endl;
    }
    */
}

int main() {
    solve();
    
    return 0;
}

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

int main() {
 int a,b,c,x,y;
  cin >>a>>b>>c >>x>>y;
int d = a*x + b *y;
  int e = c*2 * max(x,y);
  int f;
  if(x>y) f =  c *2* y + a * (x-y);
  else f = c*2*x+b*(y-x);
  int ans =min(min(d,e),f);
  printf("%ld\n",ans);
}

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

namespace _20190309_04 {
    class Program {
        static void Main(string[] args) {
            var line0 = Console.ReadLine().Split(' ').Select(x => ulong.Parse(x)).ToArray();
            var a = line0[0];
            var b = line0[1];
            var remainder = b - a + 1;
            ulong ans = 0;
            switch (a % 4) {
                case 0:
                    ans = 0;
                    break;
                case 1:
                    ans = a - 1;
                    break;
                case 2:
                    ans = 1;
                    break;
                case 3:
                    ans = a;
                    break;
                default:
                    break;
            }
            switch (b % 4) {
                case 0:
                    ans = ans ^ b;
                    break;
                case 1:
                    ans = ans ^ 1;
                    break;
                case 2:
                    ans = ans ^ (b + 1);
                    break;
                case 3:
                default:
                    break;
            }
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 13396
a = gets.to_i
b = gets.to_i
c = gets.to_i
x = gets.to_i

count =0

for i in 0..a
  if x < (i*500)
    break
  end
  for j in 0..b
    for k in 0..c
      if x == i*500+j*100+k*50
        count += 1
      end
    end
  end
end

puts "#{count}"


Measured memory_bytes: 1788
// luogu-judger-enable-o2
// SeptEtavioxy
#include<cstdio>
#include<cctype>
#include<cstring>
#include<algorithm>
#include<cmath>
#define re register
#define ll long long
#define il inline
#define rep(i,s,t) for(re int i=(s);i<=(t);i++)
#define rev_rep(i,s,t) for(re int i=(s);i>=(t);i--)
#define each(i,u) for(int i=head[u];i;i=bow[i].nxt)
#define pt(ch) putchar(ch)
#define pti(x) printf("%d",x)
#define ptll(x) printf("%lld",x)
#define file(s) freopen(s".in","r",stdin),freopen(s".out","w",stdout)
using namespace std;
// c_ints
il int ci(){
	re char ch;int f=1;
	while(!isdigit(ch=getchar()))f= ch=='-'?-1:1 ;
	re int x= ch^'0';
	while(isdigit(ch=getchar()))x=(x*10)+(ch^'0');
	return f*x;
}
enum{N=100024};
int fa[N],dis[N],size[N];
void fd(int x){
	if( fa[x]==x ) return ;
	fd(fa[x]);
	dis[x]+= dis[fa[x]];
	fa[x]= fa[fa[x]];
}
int main(){
	int n=ci(), m=ci();
	rep(i,1,n) fa[i]=i, size[i]=1;
	while( m-- ){
		int l=ci(), r=ci(), d=ci();
		fd(l), fd(r);
		if( fa[l]==fa[r] ){
			if( dis[r]-dis[l]!=d ){
				puts("No");
				return 0;
			}
		}
		else{
			if( size[l]<size[r] ) swap(l,r), d=-d;
			int fl=fa[l], fr=fa[r];
			int x= dis[l]+d-dis[r];
			dis[fr]= x;
			fa[fr]= fl;
			size[fl]+= size[fr];
		}
	}
	puts("Yes");
	return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define repone(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define Rep(j,n) for(int j=0;j<(int)(n);++j)
#define Repo(j,o,n) for(int j=o;j<(int)(n);++j)
#define Repone(j,n) for(int j=1;j<(int)(n);++j)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define int long long
#define pb(a) push_back(a)
#define eraser(v,i) (v).erase(v.begin()+(i))
#define pbpair(a,b) push_back(make_pair(a,b))
#define MOD 1000000007
#define MODB 998244353
#define INF 9223372036854775807

signed main()
{
  int x=0,y=1,z=0,w=0,n=0,m=0;
std::cin >> x>>y>>z;
x-=z;
std::cout << x/(y+z) << '\n';
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastScanner in = new FastScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ProblemC solver = new ProblemC();
        solver.solve(1, in, out);
        out.close();
    }

    static class ProblemC {
        public void solve(int testNumber, FastScanner in, PrintWriter out) {
            int n = in.nextInt();
            long[] a = new long[n];
            for (int i = 0; i < n; i++) {
                a[i] = in.nextLong() - i - 1;
            }
            Arrays.sort(a);
            long ans = 0;
            for (int i = 0; i < n; i++) {
                ans += Math.abs(a[i] - a[n / 2]);
            }
            out.println(ans);
        }

    }

    static class FastScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public FastScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(in.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

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

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

    }
}



Measured memory_bytes: 49456
import java.util.Scanner;
public class Main
{
	public static void main(String arg[])
	{
		Scanner in=new Scanner(System.in);
		int t1[]=new int[1001];
		int t2[]=new int[1001];
		for(;;)
		{
			String s[]=in.nextLine().split(",");
			if(s[0].compareTo("")==0)
				break;
			t1[Integer.valueOf(s[0])]++;
		}
		while(in.hasNext())
		{
			String s[]=in.nextLine().split(",");
			t2[Integer.valueOf(s[0])]++;
		}
		for(int i=0;i<=1000;i++)
		{
			if(t1[i]>0&&t2[i]>0)
				System.out.println(i+" "+(t1[i]+t2[i]));
		}
	}
}

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


#define mod 1000000007
#define ull unsigned long long int
#define FastIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
 
/* TYPE DEFINITIONS */
typedef     long long int        ll;
typedef     vector<ll>     vi;
typedef     pair<ll,ll>   pi;
 
 
 
/* MATH */
bool isPrime(ull n) 
{ 
    if (n <= 1)  return true; 
    if (n <= 3)  return true; 
    if (n%2 == 0 || n%3 == 0) return false; 
  
    for (ull i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
  
    return true; 
} 
 
ll pow(ll a,ll b,ll m)
{
    ll res=1;
    while(b>0)
    {
        if(b&1)res=(res*a)%m;
        a=(a*a)%m;
        b>>=1;
    }
    return res;
}

ll ncr(int n, int k)  
{  
    if(k>n)return 0;
    ll res = 1;  
    if ( k > n - k )  
        k = n - k;  
    for (int i = 0; i < k; ++i)  
    {  
        res *= (n - i);  
        res /= (i + 1);  
    }  
  
    return res;  
} 
  
//
/* MACROS */
 
#define  all(A)         (A).begin() , (A).end()
#define  arrall(A,n)    (A),((A)+(n))
#define  rall(A)        (A).rbegin() , (A).rend()
#define  sz(A)          (int)(A).size()
#define  pb             push_back
#define  ppb            pop_back
#define  mp             make_pair
#define  ln(X)          (int)(X).length()
#define  square(X)      ((X)*(X))
#define  cube(X)        ((X)*(X)*(X))
#define  forn(i, n)  for (int i = 0; i < int(n); i++)
#define  forr(i, n)  for (int i = int(n - 1); i >= 0; i--)
#define  fora(i, a, b)  for (int i = int(a); i <= int(b); i++)
#define  forb(i, a, b)  for (int i = int(a); i >= int(b); i--)
#define  fore(it, a)    for(__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++) 
#define  deb(x)       cout << '>' << #x << ':' << x << endl;

void  solve()
{
    
    int n;
    cin>>n;
    int ans=0;
    string s;
    cin>>s;
    forn(i,n-2)
    {
        if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C')ans++;
    }
    cout<<ans<<endl;

    

}

int main()
{
 
    FastIO;
    ll t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
}

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 P = pair<int,int>;
int main() {
    int n; cin >> n;
    vector<int> L(n);
    rep(i, n) {
        cin >> L[i];
    }
    int ans = 0;
    for(int i=0;i<n;i++) for(int j=i+1;j<n;j++) for(int k=j+1;k<n;k++) {
        if (L[i]!=L[j]&&L[j]!=L[k]&&L[i]!=L[k]) {
            if (L[i]+L[j]>L[k] && L[j]+L[k]>L[i] && L[i]+L[k]>L[j]) {
                ans++;
            }
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 3628
#include <iostream>

#include <algorithm>
#include <utility>

using std::cin;
using std::cout;
using std::endl;

using std::sort;
using std::pair;

using int_pair = pair<int, int>;

static int
solve(int N, int M, int_pair ab[])
{
  sort(&ab[0], &ab[M]);
  int_pair ba[100000];
  int i = 0;
  for (int m = 0; m < M;)
  {
    int a = ab[m].first;
    ba[i].second = a;
    ba[i].first = ab[m].second;
    ++i;
    while (++m < M && ab[m].first == a)
    {
    }
  }
  sort(&ba[0], &ba[i]);
  int count = 0;
  for (int ii = 0; ii < i; ii++)
  {
    count++;
    int b = ba[ii].first;
    while (ii + 1 < i && ba[ii + 1].second < b)
    {
      ++ii;
    }
  }
  return count;
}

int
main()
{
  int N, M;
  cin >> N >> M;
  int_pair ab[100000];
  for (int m = 0; m < M; m++)
  {
    cin >> ab[m].first >> ab[m].second;
  }
  cout << solve(N, M, ab) << endl;
  return 0;
}


Measured memory_bytes: 5168
#include<stdio.h>
#include<math.h>
#include<string.h>
int main()
{
	long long int a,b;
	int c,i,j;
	scanf("%lld%lld%d",&a,&b,&c);
	if(2*c>=b-a+1)
		for(i=a;i<=b;i++)
			printf("%d\n",i);
	else
	{
		for(i=0,j=a;i<c;i++,j++)
			printf("%d\n",j);
		for(i=0,j=b-c+1;i<c;i++,j++)
			printf("%d\n",j);
	}
	return 0;
}

Measured memory_bytes: 128
h, w = map(int, input().split())
s = [list(input()) for _ in range(h)]
for i in range(h):
    s[i].insert(0,'9')
    s[i].append('9')
wall = ['9' for _ in range(w+2)]
s.insert(0, wall)
s.append(wall)
ans = [[0 for i in range(w)] for j in range(h)]
for i in range(1,h+1):
    for j in range(1, w+1):
        if s[i][j] == '.':
            cnt = 0
            for k in range(i-1,i+2):
                for l in range(j-1,j+2):
                    if s[k][l] == '#':
                        cnt += 1
            s[i][j] = cnt
        ans[i-1][j-1] = s[i][j]
for i in ans:
    print(*i, sep='')

Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
using P = pair<int,int>;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

int main(){
    int h, w;
    cin >> h >> w;
    vector<string> s(h);
    rep(i,h) cin >> s[i];
    for(int i = 0; i <= h+1; i++){
        if (i == 0 || i == h+1){
            for(int j = 0; j <= w+1; j++){
                cout << "#";
            }
        }else{
            for(int j = 0; j <= w+1; j++){
                if (j == 0 || j == w+1) cout << "#";
                else cout << s[i-1][j-1];
            }
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 3676
// C.

#include <iostream>
#include <algorithm>

using namespace std;

int main(int argc, char *argv[])
{
	int n;
	cin >> n;
	int ans = 1 << 30;
	for (int i = 0; i <= n; ++i) {
		auto count = [](int f, int r) {
			int c = 0;
			for (int j = f; r > 0; j *= f) {
				int k = r % j;
				c += k / (j / f);
				r -= k;
			}
			return c;
		};
		ans = min(ans, count(6, i) + count(9, n - i));
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
import sys
from collections import deque

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    H, W = map(int, input().split())
    grid = list(list(input()) for _ in range(H))

    res = [[0] * W for _ in range(H)]
    visited = [[False] * W for _ in range(H)]
    for y in range(H):
        for x in range(W):
            if grid[y][x] == "#":
                visited[y][x] = True
                que = deque([[y, x]])
                cnt = 1
                tmp = []
                while que:
                    h, w = que.popleft()
                    for dh, dw in ((1, 0), (-1, 0), (0, 1), (0, -1)):
                        next_h, next_w = h + dh, w + dw
                        if next_h < 0 or next_h >= H or next_w < 0 or next_w >= W:
                            continue
                        if grid[h][w] == "#" and grid[next_h][next_w] == ".":
                            if not visited[next_h][next_w]:
                                que.append([next_h, next_w])
                                tmp.append([next_h, next_w])
                                visited[next_h][next_w] = True
                        elif grid[h][w] == "." and grid[next_h][next_w] == "#":
                            if not visited[next_h][next_w]:
                                cnt += 1
                                que.append([next_h, next_w])
                                visited[next_h][next_w] = True
                for h, w in tmp:
                    res[h][w] = cnt
    ans = 0
    for h in range(H):
        ans += sum(res[h])
    print(ans)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 93176
N, x = map(int, input().split())
a = list(map(int, input().split()))

a = sorted(a)
ans = 0
for i in range(N):
    if i == N - 1:
        if x == a[i]:
            ans += 1
        break
    if x >= a[i]:
        x -= a[i]
        ans +=1

print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define FORR(I,A,B) for(ll I = (B-1); I >= (A); --I)
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;else return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
const ll INF=1e18+7;
const ll MOD=1e9+7;

// ax+by=gcd(a,b)
ll ext_gcd(ll a,ll b,ll &x ,ll &y){
	if(b==0){
		x = 1;y =0;return a;
	}
	ll q = a/b;
	ll g = ext_gcd(b,a-q*b,x,y);
	ll z = x - q*y;
	x = y;y = z;
	return g;
}


int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll a,b;
	ll x=9,y;
	cin >> a >> b;
	ext_gcd(a,b,x,y);
	cout << x << " " << y << endl;
}



Measured memory_bytes: 3236
#include <bits/stdc++.h>
#define N 50001
#define M 100011
#define f first
#define s second
#define INF (1e9)
using namespace std;
typedef pair<int,int> P;
typedef pair<P,P> PP;
int n,m,T;
vector<PP> G[M]; // to,cost,y,x
vector<int> g[M],used[M];
vector<P> D[M];

priority_queue<PP,vector<PP>,greater<PP> >Q;  
P dijkstra(int a,int b){

  while(!Q.empty()){
    PP t=Q.top();Q.pop();
    int cost=t.f.f,cnt=t.f.s;
    int y=t.s.f, x=t.s.s;
    int pos=g[y][x];
    if(D[y][x]<t.f||used[y][x])continue;
    if(pos==b) return t.f;
    
    for(int i=0;i<G[pos].size();i++){
      PP e=G[pos][i];
      int ncost=cost+e.f.s,ncnt=cnt;
      int ny=e.s.f,nx=e.s.s;
      if(pos!=a&&(ny!=y||abs(x-nx)!=1)) ncost+=T,ncnt++;
      if(!used[ny][nx]&&D[ny][nx]>P(ncost,ncnt)){
	D[ny][nx]=P(ncost,ncnt);
	Q.push(PP(D[ny][nx],P(ny,nx)));
      }
    }
  }
  return P(-1,-1);
}

int main(){
  string s,t;
  cin>>m>>T>>s>>t;
  map<string,int> mp;
  mp[s]=n++;
  mp[t]=n++;

  for(int i=0,a;i<m;i++){
    cin>>a;
    D[i].resize(a,P(INF,INF));
    used[i].resize(a,0);
    for(int j=0;j<a;j++){
      string str;
      cin>>str;
      if(!mp.count(str))mp[str]=n++;
      if(str==s)D[i][j]=P(0,0);
      if(str==s&&Q.empty())Q.push(PP(P(0,0),P(i,j)));
      g[i].push_back(mp[str]);
    }

    for(int j=0,pre=g[i][0],cost;j<a-1;j++){
      cin>>cost;
      int pos=g[i][j+1];
      G[pre].push_back(PP(P(pos,cost),P(i,j+1)));
      G[pos].push_back(PP(P(pre,cost),P(i,j)));
      pre=pos;
    }
  }

  P ans=dijkstra(0,1);
  if(ans==P(-1,-1)) cout<<-1<<endl;
  else cout<<ans.f<<" "<<ans.s<<endl;
  return 0;
}

Measured memory_bytes: 26164
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main() {
    int A, B, C;
    cin >> A >> B >> C;
    int k;
    cin >> k;

    vector<int>vec = {A,B,C};
    sort(all(vec));

    for (int i=0; i<k; i++)vec[2] *= 2;

    cout << vec[0] + vec[1] + vec[2] << endl;

}

Measured memory_bytes: 256
import numpy
mod=10**9+7
def primesfrom2to(n):
    """, Returns a array of primes, 2 <= p < n """
    if n==1:return numpy.array([])
    if n==2:return numpy.array([])
    if n==3:return numpy.array([2])
    if n==4:return numpy.array([2,3])
    if n==5:return numpy.array([2,3])
    sieve = numpy.ones(n//3 + (n%6==2), dtype=numpy.bool)
    for i in range(1,int(n**0.5)//3+1):
        if sieve[i]:
            k=3*i+1|1
            sieve[       k*k//3     ::2*k] = False
            sieve[k*(k-2*(i&1)+4)//3::2*k] = False
    return numpy.r_[2,3,((3*numpy.nonzero(sieve)[0][1:]+1)|1)]
n=int(input())
table=[]
for i in primesfrom2to(n+1):
    i=int(i)
    cnt=0
    originalp=i
    p=originalp
    while True:
        tmp=n//p
        if tmp==0:
            break
        else:
            p*=originalp
            cnt+=tmp
    table.append(cnt)
ans=1
#print(table)
for i in table:
    ans=(ans*(i+1))%mod
print(ans)

Measured memory_bytes: 20992
n=int(input())

a=list(map(int,input().split()))

z=[0]*((10**5)+1)

for i in range(n):
  z[a[i]]+=1

q=int(input())

y=[]

sam=sum(a)

for i in range(q):
  b,c=map(int,input().split())
  z[c]+=z[b]
  sam-=z[b]*b
  sam+=z[b]*c
  z[b]=0
  #print(z)
  
  y.append(sam)

for i in range(len(y)):
  print(y[i])

Measured memory_bytes: 84192
#include<iostream>
using namespace std;
int main(){
	int a,b;
	char c;
	while(cin>>a>>c>>b){
		if(c=='?')
			break;
		if(c=='+'){
			cout<<a+b<<endl; 
		}else if(c=='-'){
			cout<<a-b<<endl;
		}else if(c=='*'){
			cout<<a*b<<endl;
		}else if(c=='/'){
			cout<<a/b<<endl;
		}
	}
	return 0;
}


Measured memory_bytes: 3092
#include <bits/stdc++.h>
#define pb push_back
using namespace std;
const int INF=0x3f3f3f3f;
const int maxn=100005;

struct edge{int to,cost;};

int n,ro;
int temp,ans;
vector<edge>G[maxn];

void dfs(int u,int p,int w) {
	for (edge e:G[u])
		if (e.to!=p) dfs(e.to,u,w+e.cost);
	if (w>temp) {
		temp=w;
		ro=u;
	}
}

void dfs2(int u,int p,int w) {
	for (edge e:G[u])
		if (e.to!=p) dfs2(e.to,u,w+e.cost);
	ans=max(ans,w);
}

int main() {
	cin>>n;
	for (int i=0;i<n-1;i++) {
		int u,v,w; cin>>u>>v>>w;
		G[u].pb(edge{v,w});
		G[v].pb(edge{u,w});
	}
	dfs(0,-1,0);
	dfs2(ro,-1,0);
	cout<<ans<<'\n';
}


Measured memory_bytes: 13188
#!/usr/bin/env python
# coding: utf-8

def ri():
    return int(input())

def rl():
    return list(input().split())

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

def main():
    n = ri()
    la = rli()
    lb = rli()
    ans = 0
    for i in range(len(lb)):
        b = lb[i]
        a0 = la[i]
        a1 = la[i+1]
        d0 = min(b, a0)
        b -= d0
        d1 = min(b, a1)
        la[i+1] = a1-d1
        ans += d0 + d1
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 18476
n=int(input())
s=[input() for _ in range(n)]
m=int(input())
t=[input() for _ in range(m)]

s1=set(s)
a=b=0
for ss in s1:
  a=s.count(ss)-t.count(ss)
  if a>b:
    b=a
print(b)

Measured memory_bytes: 9100
#include "bits/stdc++.h"
#include <cmath>
#include <iomanip>
using namespace std;
 
#define f first
#define s second
 
#define pb push_back
#define pp pop_back
#define mp make_pair
 
#define sz(x) (int)x.size()
#define sqr(x) ((x) * 1ll * (x))
#define all(x) x.begin(), x.end()
#define clr(a,v) memset(a, v, sizeof(a))
 
#define rep(i, l, r) for (int i = (l); i <= (r); i++)
#define per(i, l, r) for (int i = (l); i >= (r); i--)
#define reflex ios_base::sync_with_stdio(false)
 
#define nl '\n'
#define ioi exit(0);
 

#define PI 3.14159265

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
 
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int N= (int)5e5 + 7;
const int inf = (int)1e9 + 7;
//const int mod = (int)1e9 + 7;
//const int mod = 1000000007;
const ll linf = (ll)1e18 + 7;
 
const int dx[] = {-1, 0, 1, 0, 1, -1, -1, 1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
const int kx[] = {-1,1,2,2,1,-1,-2,-2};
const int ky[] = {2,2,1,-1,-2,-2,-1,1};

const int mod = 998244353;

struct dsu{
	int parent[N];
	int cont;
	void make_set(int n){
		for(int i = 1; i <= n; i++)
			parent[i] = i;
		cont = n;
	}
	
	int find_set(int v){
		if(v == parent[v])
			return v;
		return find_set(parent[v]);
	}
	
	void union_sets(int a, int b){
		a = find_set(a);
		b = find_set(b);
		if(a != b){
			parent[b] = a;
			cont--;
		}
	}
};


string v[7] = {"SUN", "MON", "TUE","WED","THU","FRI","SAT"};
int main(){
	string s; cin>> s;
	for(int i = 0; i < 7; i++){
		if(v[i].compare(s) == 0){
			cout<< 7 - (i+1) + 1;
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <set>
#include <sstream>
#include <bitset>
#include <stack>
#include <cstdlib>
#include <utility> //pair

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

typedef long long ll;

using namespace std;

int main() {

    ll n;
    cin >> n;

    vector<ll> a(n);

    FOR(i, 0, n){
        cin >> a[i];
        a[i] = a[i] -(i+1);
    }

    sort(a.begin(),a.end());

    ll b,b1,b2;
    ll ans=0;
    ll ans1=0,ans2=0;
    if(n%2!=0){
        b = a[n/2]; //中央値
        FOR(i, 0, n){
            ans += abs(a[i]-b);
        }
    }else{
        b1 = a[n/2];
        b2 = a[n/2-1];
        FOR(i, 0, n){
            ans1 += abs(a[i]-b1);
            ans2 += abs(a[i]-b2);
        }
        ans = min(ans1,ans2);
    }

    cout <<  ans <<  endl;

    return 0;
}

Measured memory_bytes: 1792
def rest_col(s1,s2):
  if(s1=="R"):
    if(s2=="R"):
      return -1
    elif(s2=="G"):
       return 2
    else:
       return 1
  if(s1=="G"):
    if(s2=="G"):
      return -1
    elif(s2=="R"):
       return 2
    else:
       return 0
  if(s1=="B"):
    if(s2=="B"):
      return -1
    elif(s2=="R"):
       return 1
    else:
       return 0

str_c=["R","G","B"]
n=int(input())
s=input()
count=[[0,0,0] for i in range(n)] #count[i][c]はi番目以上で色cの個数
if(s[n-1]=="R"):
  count[n-1][0]=1
if(s[n-1]=="G"):
  count[n-1][1]=1
if(s[n-1]=="B"):
  count[n-1][2]=1
for i in range(1,n):
  count[n-1-i][0]=count[n-i][0]
  count[n-1-i][1]=count[n-i][1]
  count[n-1-i][2]=count[n-i][2]
  if(s[n-1-i]=="R"):
    count[n-1-i][0]+=1
  if(s[n-1-i]=="G"):
    count[n-1-i][1]+=1
  if(s[n-1-i]=="B"):
    count[n-1-i][2]+=1
ans=0
for a in range(n-1):
  for b in range(a,n-1):
    r=rest_col(s[a],s[b])
    if(r!=-1):
      ans+=count[b+1][r]
      if(2*b-a<len(s)):
        if(s[2*b-a]==str_c[r]):
          ans-=1
print(ans)


Measured memory_bytes: 70908