akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int n, m, x;
int c[2000], a[2000][2000], vis[2000], ans=INT_MAX;
int temp[2000]={0};
void dfs(int temp_ans, int pos)
{
      if (temp_ans>=ans) return ;
      int flag=1;
      for (int i=1; i<=m; i++)
      {
            if (temp[i]<x)
            {
                  flag=0;
                  break;
            }
      }
      if (flag)
      {
            ans=min(ans, temp_ans);
                  return;
      }
      for (int i=pos+1; i<=n; i++)
      {
            if (vis[i]==0)
            {
                  for (int j=1; j<=m; j++)
                  {
                        temp[j]+=a[i][j];
                  }
                  vis[i]=1;
                  dfs(c[i]+temp_ans, i);
                  vis[i]=0;
                  for (int j=1; j<=m; j++)
                  {
                        temp[j]-=a[i][j];
                  }
            }
      }
}
int main()
{
      ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
      cin >> n >> m >> x;
      for (int i=1; i<=n; i++)
      {
            cin >> c[i];
            for (int j=1; j<=m; j++)cin>>a[i][j];
      }
      dfs(0, 0);
      if (ans==INT_MAX) cout << -1 << endl;
      else cout << ans << endl;
      return 0;
}


Measured memory_bytes: 3676
#include <cstdio>
#include <algorithm>
using namespace std;
int main() {
	int N;
	scanf("%d",&N);
	for(int i=0;i<N;i++) {
		int x,y,b,p,sum,ans;
		scanf("%d %d %d %d",&x,&y,&b,&p);
		ans=sum=x*b+y*p;
		if(b<5) sum+=x*(5-b);
		if(p<2) sum+=y*(2-p);
		printf("%d\n",min(ans,(int)(sum*0.8)));
	}
}

Measured memory_bytes: 1028
#include <cstdio>
using namespace std;

int main() {
	int H,W;
	while(1) {
		scanf("%d%d",&H,&W);
		if(H==0 && W==0) break;
		for(int j=0;j<H;++j) {
			for(int i=0;i<W;++i){
				if((i+j)%2==0) {
					printf("#");
				} else {
					printf(".");
				}
			}
			printf("\n");
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 2512
#include<bits/stdc++.h>
using namespace std;
using LL = long long;
constexpr int maxn = 120;
char s[maxn][maxn];
int d[maxn][maxn];
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int H, W;
    cin >> H >> W;
    for(int i = 1; i <= H; i += 1) cin >> (s[i] + 1);
    for(int i = 0; i <= H + 1; i += 1)
        for(int j = 0; j <= W + 1; j += 1)
            d[i][j] = 1000000000;
    for(int i = 1; i <= H; i += 1)
        for(int j = 1; j <= W; j += 1)
            if(i == 1 and j == 1)
                d[i][j] = s[i][j] == '#';
            else if(s[i][j] == '#')
                d[i][j] = min(d[i - 1][j] + (s[i - 1][j] == '.'), d[i][j - 1] + (s[i][j - 1] == '.'));
            else 
                d[i][j] = min(d[i - 1][j], d[i][j - 1]);
    cout << d[H][W];
    return 0;
}


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

int main(){
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    
    string s;
    cin >> s;
    int odd = 0, even = 0;
    int total_odd = 0, total_even = 0;
    //白の枚数を数える
    for(int i = 0; i < s.length(); i++){
        if(i % 2 == 0){
            if(s[i] == '1'){
                even++;
            }
            total_even++;
        }else{
            if(s[i] == '1'){
                odd++;
            }
            total_odd++;
        }
    }
    int ans = min(total_even - even + odd, even + total_odd - odd);
    cout << ans << endl;
}

Measured memory_bytes: 512
o = str(input())
e = str(input())
l = []
for i in range(min(len(o),len(e))):
    l.append(o[i]+e[i])
    
if len(o) > len(e):
    l.append(o[-1])
elif len(o) < len(e):
    l.append(e[-1])

print("".join(l))

Measured memory_bytes: 3060
a1 = list(map(int, input().split()))
a2 = list(map(int, input().split()))
a3 = list(map(int, input().split()))
bingo_sheet = [a1, a2, a3]
n = int(input())

memo = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]

for i in range(n):
    b = int(input())

    for j, ai in enumerate(bingo_sheet):
        for k, a in enumerate(ai):
            if a == b:
                memo[j][k] = 1

ans = False

for i in range(3):
    if memo[i][0] and memo[i][1] and memo[i][2]:
        ans = True
        break

    elif memo[0][i] and memo[1][i] and memo[2][i]:
        ans = True
        break

if memo[0][0] and memo[1][1] and memo[2][2]:
    ans = True

if memo[0][2] and memo[1][1] and memo[2][0]:
    ans = True

if ans:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <functional>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
using namespace std;

signed main() {
	string s;
	cin >> s;
	if (s[0] == 'Y' && s[1] == 'A' && s[2] == 'K' && s[3] == 'I') {	cout << "Yes" << endl; }
	else { cout << "No" << endl; }
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
	int room[4][3][10];
	int b,f,r,v;
	int N;
	for(b=0;b<4;b++)
		for(f=0;f<3;f++)
			for(r=0;r<10;r++)
				room[b][f][r]=0;
	scanf("%d",&N);
	for(;N>0;N--){
		scanf("%d %d %d %d",&b,&f,&r,&v);
		room[b-1][f-1][r-1]+=v;
	}
	for(b=0;b<4;b++){
		for(f=0;f<3;f++){
			for(r=0;r<10;r++)
				printf(" %d",room[b][f][r]);
			printf("\n");
		}
		if(b<3)
			printf("#####""#####""#####""#####""\n");
	}
	return 0;
}

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

int main() {
    int N, ans = 0;
    cin >> N;
    vector<int> A(N), C(N - 1);
    for(int i = 0; i < N;++i){
        cin >> A[i];
        --A[i];
    }
    for(int i = 0; i < N; ++i) {
        int B;
        cin >> B;
        ans += B;
    }
    for(int i = 0; i < N - 1;++i){
        cin >> C[i];
    }
    for(int i = 0; i < N - 1; ++i) {
        if(A[i] + 1 == A[i + 1])
            ans += C[A[i]];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x)          (x).begin(), (x).end()
#define rep(i, s, n)    for (i64 i = (s), i##_limit = (n); i < i##_limit; ++i)
#define repr(i, s, t)   for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#define VAR(type, ...)  type __VA_ARGS__; read(__VA_ARGS__);
#ifndef DBG
#define dump(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U> inline bool chmax(T &a, const U &b) { return b > a && (a = b, true); }
template <class T, class U> inline bool chmin(T &a, const U &b) { return b < a && (a = b, true); }
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template <class T>
inline vector<T> makeV(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto makeV(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(makeV<T>(initValue, args...))>(sz, makeV<T>(initValue, args...));
}

template <class T>
inline istream& operator>> (istream &is, vector<T> &vec) {
    for (auto &e : vec) is >> e;
    return is;
}

inline void read() {}

template <class Head, class... Tail>
inline void read(Head &head, Tail&... tail) { cin >> head; read(tail...); }

inline void print() { cout << "\n"; }

template <class Head, class... Tail>
inline void print(Head &&head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream& operator<< (ostream &os, const vector<T> &vec) {
    static constexpr const char *delim[] = { " ", "" };
    for (const auto &e : vec) os << e << delim[&e == &vec.back()];
    return os;
}
// }}} End Header

struct UnionFind { // {{{
    vector<int> u;
    explicit UnionFind(int n): u(n+5, -1) {}
    int  size(int x)        { return -u[root(x)]; }
    int  root(int x)        { return (u[x] < 0)? x : (u[x] = root(u[x])); }
    bool same(int x, int y) { return (root(x) == root(y)); }
    bool unite(int x, int y){ return (x=root(x)) == (y=root(y))? false : (u[x]+=u[y], u[y]=x, true); }
}; // }}}

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(nullptr);

    VAR(int, N, M, K);
    UnionFind uf(N);

    vector<int> friendCnt(N);
    rep(i, 0, M) {
        VAR(int, a, b);
        --a, --b;
        uf.unite(a, b);
        friendCnt[a] += 1;
        friendCnt[b] += 1;
    }

    vector<int> blockCnt(N);
    rep(i, 0, K) {
        VAR(int, c, d);
        --c, --d;
        if (uf.same(c, d)) {
            blockCnt[c] += 1;
            blockCnt[d] += 1;
        }
    }

    vector<int> ans(N);
    rep(i, 0, N) {
        ans[i] = uf.size(i) - 1 - friendCnt[i] - blockCnt[i];
    }
    print(ans);

    return 0;
}


Measured memory_bytes: 2816
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;

//using Graph = vector<vector<edge>>;
using dou =long double;
string yes="yes";
string Yes="Yes";
string YES="YES";
string no="no";
string No="No";
string NO="NO";

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define rep(i, n)         for(int i = 0; i < (int)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(int i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(ll i = m; i < (ll)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define query int qq;std::cin >> qq;rep(qqq,qq)
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define itn int
#define mp make_pair
#define sum(a) accumulate(all(a),0ll)
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
#define case std::cout <<"Case #" <<qqq+1<<": "
#define RES(a,i,j) a.resize(i);rep(ii,i)a[ii].resize(j); 
#define as assign
#define ffor for(;;)
#define ppri(a,b) std::cout << a<<" "<<b << std::endl
#define pppri(a,b,c) std::cout<<a<<" "<<b<<" "<<c<<std::endl
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define ssum(a) accumulate(a,0ll) 
#define gre(n) greater<n>()

typedef long long ll;
//
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
//typedef long long T;
const int INF = 1000000000;
const double dINF = 1000000000;
const ll INF64 = 922337203685477580ll;
const ll MOD = 1000000007ll;
//const ll MOD = 67280421310721ll;
const dou pi=3.141592653589793;
//メモ
//二次元配列のresizeのしかた
//vv.resize(n);
//for(size_t i=0; i<n; i++){
// vv[i].resize(n);
//}

//メモ
//負の辺を持つ最短経路問題では到達不可経路でも初期化値より小さくなりうるので注意しよう！
int main(){
    int k,n;
    std::cin >> k>>n;
    VEC(int,a,n);
    a.pb(a[0]+k);
    int ans=INF;
    rep(i,n){
        chmin(ans,k-(a[i+1]-a[i]));
    }
    std::cout << ans << std::endl;
    
}

Measured memory_bytes: 1792
// Last Change: 02/24/2019 21:13:18.
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

namespace NS {
void LoopUntilZeroInpput() {
  int hogegegege = 0;
  while (cin >> hogegegege && hogegegege != 0) {
  }
}
} // namespace NS

int main() {
  const ll YPB = 380000; // Yen per BTC

  int N;
  double ans, x;
  string u;
  cin >> N;
  ans = 0;
  for (int i = 0; i < N; ++i) {
    cin >> x >> u;
    if (u == "JPY") {
      ans += x;
    } else {
      x *= YPB;
      ans += x;
    }
  }
  cout << ans << endl;

  //NS::LoopUntilZeroInpput();
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll inf = 1e18;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define per(i, a, b) for (int i = b - 1; i >= a; i--)
#define int ll
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

signed main() {
    int n;
    cin >> n;
    int l[n];
    rep(i, 0, n) cin >> l[i];
    int ans = 0;
    sort(l, l + n);
    rep(i, 0, n) {
        rep(j, i + 1, n) {
            rep(k, j + 1, n) {
                if (l[i] == l[j] || l[j] == l[k]) continue;
                if (l[i] + l[j] > l[k]) ans++;
            }
        }
    }
    cout << ans << "\n";
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } }
#define INF 2e9
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef pair<int, int> p;
typedef priority_queue<p> pq;
typedef priority_queue<p, vector<p>, greater<p>> gpq;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    string s;
    cin >> s;

    bool flag = true;

    REP(i, s.length())
    {
        if (i % 2 == 0)
        {
            if(s[i] != 'h'){
                flag = false;
                break;
            }
        }
        if(i % 2 == 1)
        {
            if(s[i] != 'i'){
                flag = false;
                break;
            }
        }
    }


    if(flag == true && s.length() % 2 == 0)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;


}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline


def read():
    H, W = map(int, input().strip().split())
    S = [['x' for j in range(W+2)] for i in range(H+2)]
    for i in range(H):
        s = input().strip()
        for j in range(W):
            S[i+1][j+1] = s[j]
    return H, W, S


def put_number(y, x, S):
    if S[y][x] == '#':
        return
    count = 0
    for dy, dx in [(1, 0), (1, 1), (0, 1), (-1, 1), (-1, 0), (-1, -1), (0, -1), (1, -1)]:
        ny, nx = dy + y, dx + x
        if S[ny][nx] == '#':
            count += 1
    S[y][x] = str(count)


def solve(H, W, S):
    for i in range(1, H+1):
        for j in range(1, W+1):
            put_number(i, j, S)
    for i in range(1, H+1):
        print(''.join(S[i][1:W+1]))


if __name__ == '__main__':
    inputs = read()
    outputs = solve(*inputs)
    if outputs is not None:
        print("%s" % str(outputs))


Measured memory_bytes: 3188
#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<climits>
#include<ctime>
#include<cstring>
#include<numeric>

#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;

using namespace std;

int main(){
  int N, k;
  while(cin >> N && N > 0){
    int ans = -1;
    rep(i, 101){
      rep(j, 1001){
        k = N - j*j - i*i*i;
        if (k < 0) break;
        if(ans == -1) {
          ans = i + j + k;
        } else{
          if (ans > i + j + k) ans = i + j + k;
        }

      }
    }
    cout << ans << endl;
  }

  return 0;
}



Measured memory_bytes: 3008
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define FORR(i,a,b) for (int i=(a);i>=(b);i--)
#define pb push_back
#define pcnt __builtin_popcount
#define show(x) cout<<#x<<" = "<<x<<endl;
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define fi first
#define se second
#define rng(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define sz(x) (int)(x).size()
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef set<int> si;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll;
typedef set<ll> sl;
typedef __int128_t lll;
typedef pair<lll,lll> plll;
typedef vector<lll> vlll;
template<typename T>string join(vector<T>&v)
{stringstream s;FOR(i,0,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename A, size_t N, typename T>void Fill(A (&array)[N], const T&v)
{fill((T*)array,(T*)(array+N),v);}
ll gcd(ll a,ll b){if(a>b)swap(a,b);for(;a>0;b%=a,swap(a,b));return b;}
int modpow(ll a,ll n,int m){if(a==0)return a;ll p=1;for(;n>0;n/=2,a=a*a%m)if(n&1)p=p*a%m;return(int)p;}
void dout(double d){printf("%.12f\n",d);}

const int iinf = 1e9;
const ll linf = 1e18;
const int mod = 1e9+7;
const double pi = acos(-1);
const double eps = 1e-10;
int k;
ll a[100000];
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> k;
  FOR(i, 0, k) cin >> a[i];
  ll l = 0, r = linf, mid;
  while(r-l > 1){
    mid = (l+r)/2;
    ll b = mid;
    FOR(i, 0, k) b -= b%a[i];
    if(b >= 2){
      r = mid;
    }else{
      l = mid;
    }
  }
  ll lef = r;
  l = 0, r = linf;
  while(r-l > 1){
    mid = (l+r)/2;
    ll b = mid;
    FOR(i, 0, k) b -= b%a[i];
    if(b <= 2){
      l = mid;
    }else{
      r = mid;
    }
  }
  ll rig = l;
  if(lef <= rig){
    cout << lef << " " << rig << endl;
  }else{
    cout << -1 << endl;
  }
  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;
ll MOD=1000000007;

int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  bool t=true;
  vector<int> a(n);
  int c=0;
  rep(i,n){
      if (s[i]=='2') t=false;
      if (s[i]=='1' || s[i]=='3') a[i]=0;
      else a[i]=1;
  }
  if (t){
      rep(i,n){
      if (s[i]=='3') a[i]=1;
      else a[i]=0;
      }
  }
  int y=n-1,m=0;
  vector<int> e(25,-1),p(25);
  rep(i,25){
      p[i]=pow(2,i);
      int u=y%2;
      if (u==1) {
          e[i]=m;
          m+=p[i];
      }
      y/=2;
  }
  int w=0;
  rep(i,n){
      bool r=true;
      rep(j,25){
          if (e[j]!=-1){
              if (i%p[j]>e[j]) r=false;
          }
      }
      if (r) w+=a[i];
  }
  if (w%2==0) cout << 0 << endl;
  else {
      if (t) cout << 2 << endl;
      else cout << 1 << endl;
  }
}


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

int main() {
    long l[87];
    l[0] = 2;
    l[1] = 1;

    int n;
    cin >> n;

    for (int i = 2; i <= n; i++) {
        l[i] = l[i - 1] + l[i - 2];
    }

    cout << l[n] << endl;

    return 0;
}


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

using namespace std;

int main(void) {

	int N, half;
	cin >> N;

	vector<int> d(N);

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

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

	cout << d[N / 2] - d[(N / 2) - 1] << endl;

	return 0;
}

Measured memory_bytes: 640
fun main(args: Array<String>) {
    val N = readLine()!!.toInt()
    val A = readLine()!!.split(' ').map { it.toLong() }.sorted()
    val sum = mutableListOf<Long>()
    var sumTmp = 0L
    A.forEach { sumTmp += it; sum.add(sumTmp) }

    var ans = 1
    for (i in N - 1 downTo 1) {
        if (i == 0 || A[i] <= sum[i - 1] * 2) {
            ans++
        } else {
            break
        }
    }
    println(ans)
}

Measured memory_bytes: 59608
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define rfor(i, a, b) for(int i = a; i < (int)b; i++)
#define all(ary) (ary).begin(), (ary).end()
#define debug(x) cerr << #x << ": " << x << '\n'
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
using namespace std;
using v = vector<int>;
using ll = long long;
template <class T = int> T in(){ T x; cin >> x; return (x);}

int main(int argc, char *argv[]){
    string s, e; cin >> s >> e;
    string res = "";
    rep(i, s.size()){
        // if(i % 2 == 0) res += s[i];
        // else res += e[i];
        if(s.size() - 1 >= i) res += s[i];
        if(e.size() - 1 >= i) res += e[i];
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define REP(i,n) for(int i=0;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<29
#define LINF LLONG_MAX/3
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(v) (v).begin(),(v).end()
#define all(v) ALL(v)
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
#define CININIT cin.tie(0),ios::sync_with_stdio(false)
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }

constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

int main(){
    CININIT;
    string s;
    cin>>s;
    string ss;
    int n=s.size();
    ss.push_back(s[0]);
    for(int i=1;i<n;i++){
        if(s[i-1]!=s[i]) ss.push_back(s[i]);
    }

    if(ss.size()==1){
        cout << 0 << endl;
        return 0;
    }

    cout << ss.size()-1 << endl;
}


Measured memory_bytes: 1100
#include<iostream>
#include<string.h>
#include<ctype.h>
#include<string>
#include<math.h>
#define pi 3.141592653589
#include<iomanip>
using namespace std;
#include<algorithm>


int main(){
     
    string s[100];
    int n,l;
    
    cin>>n>>l;
    for(int i=0;i<n;i++){
        cin>>s[i];
    }
    sort(s,s+n);
    for(int i=0;i<n;i++){
        cout<<s[i];
    }
    cout<<endl;
     
    return 0;
}
 

Measured memory_bytes: 256
#include <ios>
#include <iomanip>
#include <iostream>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>
 
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e9)

#define PI (acos(-1))
#define print(x) cout << x << endl
 
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; }
typedef pair <ll,ll> P;

int main()
{
    ll N;
    cin >> N;
    vector<ll> A(3*N);
    rep(i, 3*N) cin >> A[i];
    ll ans = 0;
    sort(all(A));
    rep(i, N) {
        ans += A[(3*N-1) - i * 2 - 1];
    }
    print(ans);
    return 0;
}

Measured memory_bytes: 2560
#include<stdio.h>
int main(){
	char s1[11],s2[11],s3[11];
	scanf("%s %s %s",s1,s2,s3);
	char a,b,c;
	a = s1[0] - 32;
	b = s2[0] - 32;
	c = s3[0] - 32;
	printf("%c%c%c\n",a,b,c);
		return 0;
	}

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

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

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

struct Vertex
{
    vector<ll> node;
    ll par;
};
Vertex T[200005];
Vertex V[200005];
bool U[200005];
ll P[200005];
ll A[200005];

int main()
{
    ll N, Q;
    cin >> N >> Q;
    REP(i, N - 1)
    {
        ll a, b;
        cin >> a >> b;
        a--;
        b--;
        T[a].node.push_back(b);
        T[b].node.push_back(a);
    }

    {
        memset(U, 0, sizeof(U));
        queue<ll> q;
        q.push(0);
        while (!q.empty())
        {
            ll t = q.front();
            q.pop();
            U[t] = true;
            REP(i, T[t].node.size())
            {
                ll n = T[t].node[i];
                if (U[n])
                    continue;
                V[n].par = t;
                V[t].node.push_back(n);
                q.push(n);
            }
        }
    }

    REP(i, Q)
    {
        ll p, x;
        cin >> p >> x;
        P[--p] += x;
    }

    {
        queue<pll> q;
        q.push(pll(0, 0));
        while (!q.empty())
        {
            pll t = q.front();
            q.pop();
            ll s = t.second + P[t.first];
            A[t.first] = s;
            REP(i, V[t.first].node.size())
            {
                ll n = V[t.first].node[i];
                q.push(pll(n, s));
            }
        }
    }
    REP(i, N)
    {
        cout << A[i] << " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 30592
N = gets.to_i
ABs = readlines.map{|l| l.split.map(&:to_i)}

g = Array.new(N + 1){[]}
ABs.each_with_index{|(a, b), i| g[a] << [b, i]; g[b] << [a, i]}
c = 1
q, ans = [], []
g[1].each do |b, i|
  q << [1, b, c]
  ans[i] = c
  c += 1
end
while !q.empty?
  x, y, c = q.shift
  cc = 1
  g[y].each do |z, i|
    next if z == x
    cc += 1 if cc == c
    q << [y, z, cc]
    ans[i] = cc
    cc += 1
  end
end
puts ans.max
puts ans

Measured memory_bytes: 38892
#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 h,n;
  cin >>h>>n;
  int a[10001],b[10001];
  vector<int> dp(h+1,100010001);
  rep(i,n){
    cin>>a[i]>>b[i];
  }
  dp[0]=0;
  rep(i,n){
    rep(j,h+1){
      dp[min(j+a[i],h)]=min(dp[min(j+a[i],h)],dp[j]+b[i]);
    }
  }
  cout << dp[h]<<endl;
}

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

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define INF 1000000007LL
#define all(x) x.begin(),x.end()
#define rep(i,a,b) for(i=a;i<=b;i++)

#define cil(a,b) ( ((a)%(b) == 0)?((a)/(b)):((a)/(b)+1) )

typedef long long ll;
typedef double db;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
typedef vector<pii> vii;

ll mypow(ll a, ll b) { if(b == 0) return 1; ll temp=mypow(a,b/2); temp=(temp*temp)%INF; if(b%2 == 1) temp=(a*temp)%INF; return temp; }
int mygcd(int a, int b) { if(b==0) return a; return mygcd(b,a%b); }
int cntBits(ll a) { int ret=0; while(a>0) { ret++; a/=2; } return ret; }

int main()
{
	ios::sync_with_stdio(0);
	int tt=1,tcase; 
	//cin >> tt;
	rep(tcase,1,tt)
	{
		string s,t; cin >> s >> t;
		int ans[s.size()+2][t.size()+2], prev[s.size()+2][t.size()+2];
		for(int i=0;i<s.size()+2;i++) for(int j=0;j<t.size()+2;j++) ans[i][j]=prev[i][j]=0;
		for(int i=1;i<=s.size();i++)
		{
			for(int j=1;j<=t.size();j++)
			{
				if(s[i-1]==t[j-1])
				{
					ans[i][j]=1+ans[i-1][j-1];
					prev[i][j]=3;
				}
				else 
				{
					ans[i][j]=max(ans[i-1][j],ans[i][j-1]);
					if(ans[i-1][j]>=ans[i][j-1]) prev[i][j]=1;
					else prev[i][j]=2;
				}
			}
		}
		int x=s.size(), y=t.size();
		vector<char> v;
		while(x!=0 && y!=0)
		{
			if(prev[x][y]==3) v.pb(s[x-1]);
			if(prev[x][y]==1) x--;
			else if(prev[x][y]==2) y--;
			else x--,y--;
		}
		for(int i=v.size()-1;i>=0;i--) cout << v[i];
		cout << "\n";
	}
	return 0;
}


Measured memory_bytes: 70656
#include<iostream>
#include<algorithm>
using namespace std;
int a[1000000];
int b[1000000];
int c[1000000];
int d[1000000];
signed main(){
  int n;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a[i]>>b[i];
    cin>>c[i]>>d[i];
  }
  for(int i=0;i<n;i++){
    if(c[i]>=5 && d[i]>=2){
      cout<<0.8*(a[i]*c[i]+b[i]*d[i])<<"\n";
    }
    else{
      if(c[i]>=5){
	if(0.8*(a[i]*c[i]+b[i]*2)<a[i]*c[i]+b[i]*d[i]){
	  cout<<0.8*(a[i]*c[i]+b[i]*2)<<"\n";
	}
	else{
	  cout<<a[i]*c[i]+b[i]*d[i]<<"\n";
	}
      }
      else{
	if(d[i]>=2){
	  if(0.8*(a[i]*5+b[i]*d[i])<a[i]*c[i]+b[i]*d[i]){
	    cout<<0.8*(a[i]*5+b[i]*d[i])<<"\n";
	  }
	  else{
	    cout<<a[i]*c[i]+b[i]*d[i]<<"\n";
	  }
	}
	else{
	  if(0.8*(a[i]*5+b[i]*2)<a[i]*c[i]+b[i]*d[i]){
	    cout<<0.8*(a[i]*5+b[i]*2)<<"\n";
	  }
	  else{
	    cout<<a[i]*c[i]+b[i]*d[i]<<"\n";
	  }
	}
      }
    }
  }  
  return(0);
}


Measured memory_bytes: 3308
#include <algorithm>
#include <cmath>
#include <iostream>
#include <numeric>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;
using ll = long long;

constexpr static ll MOD = 1000000007ll;
constexpr static int INF = 1 << 28; // for x <= 10^9
constexpr static ll INFL = 1ll << 60; // for x <= 10^19

struct Point {
    int x;
    int y;
};

int main() {
    int n, y;
    cin >> n >> y;
    for (int i = 0; i <= n; i++) {
        for (int j = 0; j <= n; j++) {
            int k = n - i - j;
            if (0 <= k && i * 10000 + j * 5000 + k * 1000 == y) {
                printf("%d %d %d\n", i, j, k);
                return 0;
            }
        }
    }

    printf("-1 -1 -1\n");
}


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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef double ld;
#define int ll
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<vvc> vvvc;
typedef pair<int, int> pii;
typedef pair<pii, pii> piii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector< vi > vvi;
typedef vector< vvi > vvvi;
typedef vector<short> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<ld> vld;
typedef vector<vld> vvld;
typedef vector<vvld> vvvld;
typedef vector<string> vst;
typedef vector<vst> vvst;
typedef pair<ld, ld> pld;

#define inmin(a, b) a = min(a, (b))
#define inmax(a, b) a = max(a, (b))
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define sqr(x) ((x) * (x))
#define fori(i, n) for(int i = 0; i < int(n); ++i)
#define SZ(a) ((int)((a).size()))
#define triple(T) tuple<T, T, T>
#define quad(T) tuple<T, T, T, T>
#define watch(x) cerr << (#x) << " = " << (x) << endl;

#ifdef RUS_HOME
#define cerr cout
#else
#define cerr if (false) cerr
#endif

const double PI = 2 * acos(0.0);
#define rand shittttty_shit
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 rng_64(chrono::steady_clock::now().time_since_epoch().count());

const string DIGITS = "0123456789";
const string ALPH = "abcdefghijklmnopqrstuvwxyz";


template <class T0, class T1>
inline ostream & operator << (ostream &out, pair<T0, T1> &a) {
    return out << "{" << a.first << ", " << a.second << "}";
}

template <class T0, class T1>
inline istream & operator >> (istream &in, pair<T0, T1> &a) {
    return in >> a.first >> a.second;
}

template <class T0, class T1, class T2>
inline ostream & operator << (ostream &out, tuple<T0, T1, T2> &a) {
    return out << "{" << get<0>(a) << ", " << get<1>(a) << ", " << get<2>(a) << "}";
}

template <class T0, class T1, class T2, class T3>
inline ostream & operator << (ostream &out, tuple<T0, T1, T2, T3> &a) {
    return out << "{" << get<0>(a) << ", " << get<1>(a) << ", " << get<2>(a) << ", " <<  get<3>(a) << "}";
}

template<class T>
inline ostream & operator << (ostream &out, vector<T> &a) {
    out << "[";
    fori (i, a.size())
        out << a[i] << vector<string>{", ", "]  "}[i + 1 == a.size()];
    return out;
}


void smain();



signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
#ifdef RUS_HOME
    freopen("input", "r", stdin);
    clock_t start = clock();
#endif
    cout << setprecision(12) << fixed;
    smain();
#ifdef RUS_HOME
    cout << "\n\n\n\nTOTAL EXECUTION TIME: " << float( clock () - start ) /  CLOCKS_PER_SEC << endl;
#endif
    return 0;
}




void smain() {

    int n,k;
    cin>>k>>n;
    vi a(n);
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    int ans=k;
    for(int i=1;i<n;i++){
        inmin(ans,k-(a[i]-a[i-1]));
    }
    inmin(ans,k-(k-a[n-1]+a[0]));

    cout<<ans;




}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define ll long long int
#define db double
#define pb push_back
#define mpr make_pair
#define mms0(x) memset(x,0,sizeof(x))
#define mms1(x) memset(x,-1,sizeof(x))
#define fr(i,n) for(long long int i=0;i<n;i++)
#define trace(it,x) for(auto it = (x).begin(); it != (x).end(); it++)
#define mod 1000000000
#define fastio ios::sync_with_stdio (false); cin.tie (0); cout.tie (0);
#define time cerr<< '\n' << "Time elapsed :" << clock() * 1000.0 / CLOCKS_PER_SEC << " ms\n" ;
using namespace std;

ll dp[100001];
ll vis[100001];
vector<ll>v[100001];

// covert number to string to_string(x);

void dfs(ll i)
{
    vis[i]=1;

    for(ll it=0;it<v[i].size();it++)
    {
        if(!vis[v[i][it]])
        {
            dfs(v[i][it]);
        }

        dp[i]=max(dp[i],1+dp[v[i][it]]);
    }
}   
    
int main()
{
    fastio

    ll n,m,a,b;
    cin >> n >> m;

    while(m--)
    {
        cin >> a >> b;

        v[a].pb(b);
    }

    mms0(dp);
    mms0(vis);

    ll ans=0;

    for(int i=1;i<=n;i++)
    {
        if(!vis[i])
            dfs(i);
    }

    for(int i=1;i<=n;i++)
        ans=max(ans,dp[i]);

    cout << ans;

    time
}

Measured memory_bytes: 9344
#include<bits/stdc++.h>
using namespace std;
main () {
    string s; cin >> s;
    if (s[0] == '0' || s.back() == '1') {
        cout << -1 << endl; exit(0);
    }
    for (int i = 1; i < s.size() - 1; i++) {
        if (s[i] != s[s.size() - i - 2]) {
            cout << -1 << endl; exit(0);
        }
    }
    s = s.substr(0, s.size() - 1);
    int tmp = 1, nxt = 2;
    for (auto&& chr : s) {
        if (chr == '1') {
            cout << tmp << " " << nxt << endl;
            tmp = nxt;
        } else {
            cout << tmp << " " << nxt << endl;
        }
        ++nxt;
    }
}


Measured memory_bytes: 1660
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n,m,a=1;
    cin>>n>>m;
    for(int i=1;i*i<=m&&i<=m/n;i++){
        if(m%i==0){
            a=max(a,i);
            if(m/i<=m/n){
                a=max(a,m/i);
            }
        }
    }
    cout<<a;
}


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

typedef long long ll;

const int M = (int)1e4;
const int N = (int)1e4;
const int inf = 0x3f3f3f3f;
const ll mod = (ll)1e9 + 7;

int main()
{
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
    string s; cin >> s;
    if(s[1] == 'B') s[1] = 'R';
    else            s[1] = 'B';
    cout << s << endl;
    return 0;
}


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

const int N = 200005;
const int INF = 1e9 + 1e8;
typedef pair<int, int> ii;

int n, q;
int best[N];
int par[N];

int anc(int p) { return p == par[p] ? p : par[p] = anc(par[p]); }
void join(int p, int q) { par[anc(p)] = anc(q); }

struct edge {
	int w; int u; int v;
	bool operator < (const edge &rhs) {
		return w < rhs.w;
	}
};
vector<edge> ed;

long long res;

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	
	cin >> n >> q;
	for (int i = 0; i < n; ++i) best[i] = INF, par[i] = i;

	while(q--) {
		int u, v, w; cin >> u >> v >> w;
		ed.push_back({w, u, v});
		best[u] = min(best[u], w + 1);
		best[v] = min(best[v], w + 2);
	}

	priority_queue < ii, vector<ii>, greater<ii> > pq;
	for (int i = 0; i < n; ++i) if (best[i] != INF) {
		pq.push(make_pair(best[i], i));
	}

	while(!pq.empty()) {
		ii top = pq.top(); pq.pop();
		int u = top.second, best_u = top.first;
		if (best[u] != best_u) continue;

		if (best[(u + 1) % n] > best[u] + 2) {
			pq.push(ii(best[(u + 1) % n] = best[u] + 2, (u + 1) % n));
		}
	}

	for (int i = 0; i < n; ++i) {
		ed.push_back({best[i], i, (i + 1) % n});
	}

	sort(ed.begin(), ed.end());
	for (auto &e : ed) {
		if (anc(e.u) != anc(e.v)) {
			join(e.u, e.v);
			res += e.w;
		}
	}

	cout << res << endl;
}

Measured memory_bytes: 13804
#include <bits/stdc++.h>
typedef long long LL;
#define SORT(c) sort((c).begin(),(c).end())

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

using namespace std;
int main(void)
{
  int n,w,h;
  cin >> n >> w >> h;
  vector<int> x(n),y(n),a(n);
  REP(i,n) cin >> x[i] >> y[i] >> a[i];
  vector<int> xseg(w+1,0),yseg(h+1,0);
  REP(i,n){
    xseg[max(0,x[i]-a[i])]++;
    xseg[min(w,x[i]+a[i])]--;
    yseg[max(0,y[i]-a[i])]++;
    yseg[min(h,y[i]+a[i])]--;
  }
  REP(i,w) xseg[i+1]+=xseg[i];
  REP(i,h) yseg[i+1]+=yseg[i];
  bool flag=true;
  REP(i,w) if(!xseg[i]) flag=false;
  if(flag){
    cout << "Yes" << endl;
    return 0;
  }
  flag=true;
  REP(i,h) if(!yseg[i]) flag=false;
  if(flag){
    cout << "Yes" << endl;
    return 0;
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 4696
#include<bits/stdc++.h>
using namespace std;
string s;
int n,h,ans;
int main(){
    cin>>n>>s;
    for(int i=0;i<n;i++){
        (s[i]=='I')? h++:h--;
        ans=max(ans,h);
    }
    cout<<ans<<endl;
    return 0;
}

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

typedef long long int ll;

int main()
{
  vector<ll> a(3);
  ll ans = 0;
  for(ll i = 0;i < 3;i++){
    cin >> a[i];
  }
  
  sort(a.begin(),a.end());
  
  for(ll i = 1;i < 3;i++){
    ans += a[i] - a[i - 1];
  }
  
  cout << ans;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<string.h>
#include<cmath>
#include<vector>
#include<queue>

using namespace std;

#define INF 2<<29

int main(){
  int n,q,cnt[100005]={};
  char s[100005];

  scanf("%d %d",&n,&q);
  scanf("%s",s);
  for(int i=1;i<n;i++){
    cnt[i+1]=cnt[i];
    if(s[i-1]=='A'&&s[i]=='C') cnt[i+1]++;
  }

  for(int i=0;i<q;i++){
    int l,r;
    scanf("%d %d",&l,&r);
    printf("%d\n",cnt[r]-cnt[l]);
  }
  
  return 0;
}


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

int check(int a, int b, int c)
{
	return a * 10000 + b * 5000 + c * 1000;
}

int main()
{
	int n, y;
	cin >> n >> y;
	
	for (int i = 0; i <= n; i++)
	{
		for (int j = 0; j <= n; j++)
		{
			if (y == check(i, j, n - i - j) && i + j <= n)
			{
				cout << i << " " << j << " " << n - i - j << endl;
				return 0;
			}
		}
	}
	
	cout << "-1 -1 -1" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
       
using namespace std;
typedef long long ll;
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; }

int main() {
  string s;
  cin >> s;

  string rpre = "", suf = "";
  int Q;
  cin >> Q;
  bool reversed = false;
  for (int i = 0; i < (int)(Q); ++i) {
    int T;
    cin >> T;
    if (T == 1) {
      reversed = !reversed;
    } else {
      int F;
      char C;
      cin >> F >> C;
      if ((F == 1 && reversed) || (F == 2 && !reversed)) {
        suf += C;
      } else {
        rpre += C;
      }
    }
  }

  if (reversed) {
    reverse((s).begin(), (s).end());
    reverse((suf).begin(), (suf).end());
    cout << suf << s << rpre << endl;
  } else {
    reverse((rpre).begin(), (rpre).end());
    cout << rpre << s << suf << endl;
  }

  return 0;
}


Measured memory_bytes: 1088
/*
文字列の配列の初期化、整数の型がlongになっているか
関数（splitとかcontainsとか）内では"+"とかは正規表現となされるので"\\+"とする
 */
import java.util.*;
import java.awt.*;
import java.awt.geom.*;
import static java.lang.System.*;
import static java.lang.Math.*;
public class Main {
    public static void main(String[] $) {
        Scanner sc = new Scanner(in);
        int[] cnt=new int[5];
        for (int i = 0; i < 3; i++) {
            int a=sc.nextInt(),b=sc.nextInt();
            cnt[a]++;
            cnt[b]++;
        }
        int d=0;
        for (int i = 1; i <= 4; i++) {
            if(cnt[i]==2)d++;
        }
        if(d==2)out.println("YES");
        else out.println("NO");
    }
}

Measured memory_bytes: 21844
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


public class Main {

	/**
	 * @param args
	 * @throws IOException 
	 * @throws NumberFormatException 
	 */
	public static void main(String[] args) throws NumberFormatException, IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		while(true){
			int n = Integer.parseInt(br.readLine());
			
			if(n == 0){
				break;
			}
			
			Square[] sq = new Square[n];
			sq[0] = new Square(0, 0);
			
			int[] dx = {-1,0,1,0};
			int[] dy = {0,-1,0,1};
			
			for(int i = 1; i < n; i++){
				String[] tmpArray = br.readLine().split(" ");
				int dist = Integer.parseInt(tmpArray[1]);
				int id = Integer.parseInt(tmpArray[0]);

				sq[i] = new Square(sq[id].x + dx[dist], sq[id].y + dy[dist]);
			}
			
			int left = 0;
			int right = 0;
			int top = 0;
			int bottom = 0;
			for(int i = 0; i < n; i++){
				int x = sq[i].x;
				int y = sq[i].y;
				
				left = Math.min(x, left);
				right = Math.max(x, right);
				top = Math.max(y, top);
				bottom = Math.min(y, bottom);
			}
			
			System.out.println((right - left + 1)+" "+(top - bottom + 1));
		}
	}

}

class Square {
	int x;
	int y;
	
	public Square(int x, int y){
		this.x = x;
		this.y = y;
	}
}

Measured memory_bytes: 29048
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String t = sc.next();
        int a = sc.nextInt();
        int b = sc.nextInt();
        String u = sc.next();
        
        if (s.equals(u)) --a;
        else if (t.equals(u)) --b;
        System.out.println(a + " " + b);
    }
}

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

#define SORT(v) sort(v.begin(),v.end())
#define si(n) scanf("%d",&n)
#define sii(n,m) scanf("%d %d",&n,&m)
#define sl(n) scanf("%lld",&n)
#define sll(n,m) scanf("%lld %lld",&n,&m)
#define ss(cad) scanf("%s",cad)
#define PB push_back
#define fst first
#define scn second
#define DBG(x) cerr << #x << " = " << (x) << endl; 
#define M 1000000007
#define N_MAX 100010

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<ll> vl;
typedef pair<int,int> pi;
typedef vector<pi> vp;

int main()
{
	char cad[10];
	ss(cad);
	if(cad[0] == cad[1] && cad[1] == cad[2])
		printf("No\n");
	else
		printf("Yes\n");
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>
using namespace std; using ll = long long; using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vpll = vector<pll>;
//**デバッグ準備**//
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
void debug_out() { cerr << endl; }
template<typename Head, typename... Tail>
void debug_out(Head h, Tail... t) {
	cerr << " " << h;
	if (sizeof...(t) > 0) cerr << " :";
	debug_out(t...);
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> vec) {
	for (size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	return os;
}
ll ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.first > secondElof.first;
}
//**Snippetリスト**//
//rep, vin, all, iteLoop//
//bitSearch, bitList, gcdlcm, isPrime, primeFactorize, Npow, divisor, modinv, dfs, bfs, eratos//
//dijkstra, WarshallFloyd, BellmanFord, UnionFind, COM, digitDP ,RMQ//
ll i, j, k, l; ll N, M, K, H, W, L, X, Y, Z;
ll MOD = 1000000007; ll INF = 1LL << 60; ll ans = 0; ll z = 0, o = 1;
vl flag, color, D, enter; vll path;
void bfs(ll now) {
	queue<ll> Q;
	Q.push(now);
	D[now] = 0;
	flag[now] = 1;
	ll u;
	while (!Q.empty()) {
		u = Q.front();
		Q.pop();
		for (ll v = 0; v < path[u].size(); v++) {
			ll next = path[u][v];
			if (enter[next]==1) {
				D[next] = D[u] + 1;
				flag[next] = 1;
				Q.push(next);
				enter[next]--;
			}
			else {
				enter[next]--;
			}
		}
	}
}
int main() {
	cin >> N;
	ll M = N * (N - 1);
	flag.resize(M);
	D.resize(M);
	path.resize(M);
	enter.resize(M);
	//aとb(a<b)の試合をa*(n-1)+bと定義
	for (i = 0; i < N; i++) {
		//根は便宜上0
		ll preA = 0, preB = 0;
		for (j = 0; j < N-1; j++) {
			ll a = i;
			ll b;
			cin >> b; b--;
			if (a > b) swap(a, b);
			path[preA * (N - 1) + preB].push_back(a * (N - 1) + b);
			enter[a * (N - 1) + b]++;
			preA = a; preB = b;
		}
	}
	bfs(0);
	for (i = 0; i < N-1; i++) {
		for (j = i+1; j < N; j++) {
			ll key = i * (N - 1) + j;
			if (!flag[key]) {
				cout << -1;
				exit(0);
			}
			else {
				ans = max(ans, D[key]);
			}
		}
	}
	cout << ans;
}

Measured memory_bytes: 62720
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll=long long;
using vec=vector<ll>;
using Graph = vector<vector<ll>>;
#define loop(i,n) for(ll i=0;i<n;i++)
#define Loop(i, m, n) for(ll i = m;i < n;i++)
#define pool(i,n) for(ll i=n;i>=0;i--)
#define Pool(i, m, n) for(ll i=n;i>=m;i--)
#define MAX 99999999999ll
#define MIN -99999999999ll
#define setbit bitset<8>
#define flagcount __builtin_popcount
#define flag(x) (1<<x)
#define flagadd(bit,x) bit|=flag(x)
#define flagpop(bit,x) bit&=~flag(x) 
#define flagon(bit,i) bit&flag(i)
#define flagoff(bit,i) !(bit & (1<<i))
#define all(v) v.begin(),v.end()
#define low2way(v,x) lower_bound(all(v),x)
#define high2way(v,x) upper_bound(all(v),x)
#define count2way(v,x) high2way(v,x)-low2way(v,x)
#define lower(v,x) low2way(v,x)-v.begin() //1番左が0、もし見つから無いならｎを出力
#define higher(v,x) high2way(v,x)-v.begin()-1 //1番左が0、もし見つからないならn-1を出力（注意）
#define putout(a) cout<<a<<endl
#define putout2(a,b) putout(a);putout(b)
#define putout3(a,b,c) putout(a);putout(b);putout(c)
#define putout4(a,b,c,d) putout(a);putout(b);putout(c);putout(d)
#define putout5(a,b,c,d,e) putout(a);putout(b);putout(c);putout(d);putout(e)
#define Gput(a,b) G[a].push_back(b)
#define cin1(a) cin>>a
#define cin2(a,b) cin>>a>>b
#define cin3(a,b,c) cin>>a>>b>>c
#define cin4(a,b,c,d) cin>>a>>b>>c>>d
#define cin5(a,b,c,d,e) cin>>a>>b>>c>>d>>e
#define sum(v) accumulate(all(v), 0ll)
#define gcd(x,y) __gcd(x,y)
ll ctoi(char c){
	if(c>='0'&&c<='9'){
		return c-'0';
	}
	return 0;
}
ll lcm(ll x,ll y){
  ll z=gcd(x,y);
  return x*y/z;
}
ll primejudge(ll n){
  if(n<2)return 0;
  else if(n==2)return 1;
  else if(n%2==0)return 0;
  double sqrtn=sqrt(n);
  Loop(i,3,sqrtn+1){
     if(n%i==0){
        return 0;
     }
     i++;
  }
  return 1;
}
int main() {
  cout << fixed << setprecision(30);
  ll n;
  cin>>n;
  vector<string> s(n);
  vec t(n);
  string x;
  loop(i,n)cin>>s[i]>>t[i];
  cin>>x;
  ll max=sum(t);
  ll count=0;
  bool check=false;
  loop(i,n){
    if(check)count+=t[i];
    if(s[i]==x)check=true;
  }
  putout(count);
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(){
  string data1,data2;
  cin>>data1;
  cin>>data2;
  int flag=0;
  for(int i=0;i<data1.size();i++){
    if(data1[i]!=data2[i]){
      flag=1;
    }
  }
  if(flag==1)cout<<"No"<<endl;
  else cout<<"Yes"<<endl;
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int a,b,c;
  cin>>a>>b>>c;
  int d=c-(a-b);
  if(d<0)
  {
      cout<<0;
  }
  else
  {
      cout<<d;
  }
  return 0;
}

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

using namespace std;

#define int long long

void solve()

{	
	int n;
	cin >> n;
	
	if(n % 2 == 1)
	{
		cout << 0;
		return ;
	}
	

	
	int res = 0;
	
	for(int i = 5; i <= n; i *= 5)
		res += (n / i) / 2;
	
	cout << res;
}

main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	
	int t = 1;
//	cin >> t;

	while(t--)
	{
		solve();
	}
}

Measured memory_bytes: 256