akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <type_traits>
using namespace std;

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

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

  int n, m; std::cin >> n >> m;
  std::cout << (n-1) * (m-1) << "\n";
}


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

using namespace std;

#define intt long long
#define FAST ios_base::sync_with_stdio(0); cin.tie(0);

const int N = 100005;

int n;
int a[N], l[N], r[N], m[N];

int main() {

	FAST;

	cin >> n;
	for (int i = 1; i <= n; i ++) {
		cin >> a[i];
	}
	l[0] = 0;
	for (int i = 1; i <= n; i ++) {
		l[i] = __gcd(l[i - 1], a[i - 1]);
	}
	r[n + 1] = 0;
	for (int i = n; i >= 1; i --) {
		r[i] = __gcd(r[i + 1], a[i + 1]);
	}
	for (int i = 1; i <= n; i ++) {
		m[i] = __gcd(l[i], r[i]);
	}
	int ans = 0;
	for (int i = 1; i <= n; i ++) {
		ans = max(ans, m[i]);
	}
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 1792
from math import gcd
n = int(input())
alst = list(map(int, input().split()))
l_gcd = [alst[0]]
for num in alst[1:-1]:
    l_gcd.append(gcd(l_gcd[-1], num))

r_gcd = [alst[-1]]
for num in alst[1:-1][::-1]:
    r_gcd.append(gcd(r_gcd[-1], num))
r_gcd = r_gcd[::-1]
ans = max(r_gcd[0], l_gcd[-1])


for num1, num2 in zip(r_gcd[1:], l_gcd[:-1]):
    tmp = gcd(num1, num2)
    ans = max(ans, tmp)
print(ans)

Measured memory_bytes: 22488
c = []
m = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
w = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday']
s = 3
for d in m:
    c.append([(s + i) % 7 for i in xrange(d)])
    s = c[-1][-1] + 1
while 1:
    mon, day = map(int, raw_input().split())
    if mon == 0: break
    print w[c[mon - 1][day - 1]]

Measured memory_bytes: 6276
k,x=list(map(int,input().split()))
min_x=x-k+1
max_x=x+k-1

if(min_x == max_x):
  print(min_x)
else:
  print(min_x, end="")
  for i in range(min_x+1,max_x+1):
    print(" "+str(i), end="")
  print("")

Measured memory_bytes: 3060
#include <iostream>
    #include <sstream>
    #include <iomanip>
    #include <cstdio>
    #include <cstdlib>
    #include <cmath>
    #include <cctype>
    #include <cstring>
    #include <vector>
    #include <list>
    #include <queue>
    #include <deque>
    #include <stack>
    #include <map>
    #include <set>
    #include <algorithm>
    #include <iterator>
    #include <bitset>
    #include <ctime>



    using namespace std;

    #define FOR(i,a,b) for(int i = (a); i < (b); i++)
    #define rep(i,n) FOR(i,0,n)
    #define RFOR(i,b,a) for(int i = (b) - 1; i>= (a); i--)
    #define ITER(it, a) for(typeof(a.begin()) it = a.begin(); it != a.end(); it++)
    #define FILL(a, value) memset(a, value, sizeof(a)

    #define SZ(a) (int)a.size()
    #define ALL(a) a.begin(), a.end()
    #define PB push_back
    #define MP make_pair

    typedef  long long LL;
    typedef vector<int> VI;
    typedef pair<int, int> PII;

    const double PI = acos(-1.0);
    const int INF = 1000 * 1000 * 1000 + 7;
    const LL LINF = INF * (LL)INF;

    const double EPS = 1e-7;
    const int MAX = 20 * 1000 + 47;
    const int MAS = 1e5 * 3;
    const int MOD = 1000 * 1000 * 1000 + 7;

    double DIST(double x1, double x2, double y1, double y2)
    {
        return sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1));
    }
    

    int main()
    {
        int n, k;
        cin >> n >> k;
        VI a(n); 
        rep(i, n)
        {
            cin >> a[i]; 
        }
        VI dp(k + 1,1);
        FOR(i, 0, k + 1)
        {
            rep(j, n)
            {
                if( i >= a[j] )
                    if (dp[i - a[j]] == 1)
                    {   
                        dp[i] = 2; 
                    }
            }
        }
        if (dp[k] == 2)cout << "First";
        else cout << "Second";  

    }









Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;
int n;
vector<int> v(200001,0);
vector<vector<int>> g(200001);

void dfs(int x,int parent,int dist){
	for(int i = 0; i < g[x].size(); i++) {
		if (g[x][i] != parent){
			v[g[x][i]] = (dist % 2);
			dfs(g[x][i],x,dist + 1);
		}
	}
}

	

int main(){
	cin>>n;
	for(int i = 0; i <  n - 1; i++) {
		int a,b;cin>>a>>b;
		g[a].pb(b);
		g[b].pb(a);
	}
	dfs(1,-1,1);
	int cnt_red = 0;
	int cnt_blue = 0;
	for(int i = 1; i <= n; i++) {
		// cout << v[i] << " ";
		if (v[i] == 0){
			cnt_red++;
		}
		else{
			cnt_blue++;
		}
	}
	vector<int> ans(n + 1,0);
	vector<int> s0;
	vector<int> s1;
	vector<int> s2;
	for(int i = 1; i <= n; i++) {
		if (i % 3 == 0){
			s0.pb(i);
		}
		else if (i % 3 == 1){
			s1.pb(i);
		}
		else{
			s2.pb(i);
		}
	}
	if (cnt_red <= n / 3){
		int p = 0;
		int q = 0;
		int r = 0;
		for(int i = 1; i <= n; i++) {
			if (v[i] == 0){
				ans[i] = s0[p];
				p++;
			}
		}
		for(int i = 1; i <= n; i++) {
			if (ans[i] == 0){
				if (p < s0.size()){
					ans[i] = s0[p];
					p++;
				}
				else{
					if (q < s1.size()){
						ans[i] = s1[q];
						q++;

					}
					else if(r < s2.size()){
						ans[i] = s2[r];
						r++;

					}	
				}	
			}
		}
	}
	else if (cnt_blue <= n / 3){
		int p = 0;
		int q = 0;
		int r = 0;
		for(int i = 1; i <= n; i++) {
			if (v[i] == 1){
				ans[i] = s0[p];
				p++;
			}
		}
		for(int i = 1; i <= n; i++) {
			if (ans[i] == 0){
				if (p < s0.size()){
					ans[i] = s0[p];
					p++;
				}
				else{
					if (q < s1.size()){
						ans[i] = s1[q];
						q++;

					}
					else if(r < s2.size()){
						ans[i] = s2[r];
						r++;

					}	
				}	
			}
		}
	}
	else{
		int p = 0;
		int q = 0;
		int r = 0;
		for(int i = 1; i <= n; i++) {
			if (v[i] == 0){
				if(p < s1.size()){
					ans[i] = s1[p];
					p++;

				}
				else{
					ans[i] = s0[q];
					q++;

				}
			}
		}
		for(int i = 1; i <= n; i++) {
			if (ans[i] == 0){
				if(q < s0.size()){
					ans[i] = s0[q];
					q++;

				}
				else if(r < s2.size()){
					ans[i] = s2[r];
					r++;

				}		
			}
		}
	}
	for(int i = 1; i <= n; i++) {
		cout << ans[i] << " ";
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 22392
class Dice:
    def __init__(self, top, front, right, left, rear, bottom):
        self.top = top
        self.front = front
        self.right = right
        self.left = left
        self.rear = rear
        self.bottom = bottom
    def print(self):
        '''print top of dice'''
        print(self.top)
    def north(self):
        self.top, self.front, self.bottom, self.rear = \
            self.front, self.bottom, self.rear, self.top
    def south(self):
        self.top, self.front, self.bottom, self.rear = \
            self.rear, self.top, self.front, self.bottom
    def east(self):
        self.top, self.right, self.bottom, self.left = \
            self.left, self.top, self.right, self.bottom
    def west(self):
        self.top, self.right, self.bottom, self.left = \
            self.right, self.bottom, self.left, self.top
    def clockwise(self):
        self.front, self.right, self.rear, self.left = \
            self.right, self.rear, self.left, self.front
    def ccw(self):
        self.front, self.right, self.rear, self.left = \
            self.left, self.front, self.right, self.rear
    def __eq__(self, other):
        # top, front, bottom, rear, left, right をこの順で上面にする回転パターン
        pattern = ['', 'N', 'N', 'N', 'E', 'EE']
        tmp = Dice(other.top, other.front, other.right, other.left, other.rear, other.bottom)
        for i in pattern:
            if i == 'N':
                tmp.north()
            elif i == 'E':
                tmp.east()
            elif i == 'EE':
                tmp.east()
                tmp.east()
            else:
                pass
            if self.top != tmp.top or self.bottom != tmp.bottom:
                continue
            for j in range(4):
                if self.front == tmp.front and self.right == tmp.right and \
                   self.rear == tmp.rear and self.left == tmp.left:
                    return True
                tmp.clockwise()
        return False

d = list(map(int, input().split()))
dice1 = Dice(d[0], d[1], d[2], d[3], d[4], d[5])
d = list(map(int, input().split()))
dice2 = Dice(d[0], d[1], d[2], d[3], d[4], d[5])
print('Yes' if dice1 == dice2 else 'No')



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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  vector<int> d = {abs(a - b), abs(b - c), abs(c - a)};
  sort(d.begin(), d.end());
  printf("%d\n", d[0] + d[1]);
}

Measured memory_bytes: 256
#include <assert.h>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <algorithm>
#include <numeric>
#include <functional>
#include <iostream>
#include <string>
#include <array>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <bitset>
typedef long long ll;
typedef unsigned long long ull;

#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define DEBUG(vec) for (auto v : vec) { cout << v << " "; } cout << endl;

using namespace std;

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

  int A, B, C;
  cin >> A >> B >> C;

  if (A <= C && C <= B) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define endl "\n"
const int mod=1e9+7;
const int INF =LONG_LONG_MAX;
inline int gcd(int a,int b){if(a==0) return b;return gcd(b%a,a);}
inline int pow(int a,int n,int mod){if(n==0)return 1;int p=pow(a,n/2,mod);p=(p%mod*p%mod)%mod;if(n%2) return (p%mod*a%mod)%mod;else return p;}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
   int n;
   cin>>n;
   int c[n][3];
   for(int i=0;i<n;i++)
    for(int j=0;j<3;j++)
    cin>>c[i][j];

   int dp[n][3];
   dp[0][0]=c[0][0];
   dp[0][1]=c[0][1];
   dp[0][2]=c[0][2];
   for(int i=1;i<n;i++)
   {
       dp[i][0]=c[i][0]+max(dp[i-1][1],dp[i-1][2]);
       dp[i][1]=c[i][1]+max(dp[i-1][0],dp[i-1][2]);
       dp[i][2]=c[i][2]+max(dp[i-1][1],dp[i-1][0]);
   }
   cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]))<<endl;
    return 0;
}


Measured memory_bytes: 4992
#include <iostream>
using namespace std;
 
int main() {
  int a, b;
  int route[20][20];
  while(cin >> a >> b, a+b) {
    for(int i = 0; i < 20; i++) {
      for(int j = 0; j < 20; j++) {
        route[i][j] = 0;
      }
    }
 
    int n; cin >> n;
    for(int i = 0; i < n; i++) {
      int x, y; cin >> x >> y;
      route[y-1][x-1] = -1;
    }
 
    route[0][0] = 1;
    for(int i = 0; i < b; i++) {
      for(int j = 0; j < a; j++) {
        if(route[i][j] == -1) continue;
        if(i > 0 && route[i-1][j] != -1) route[i][j] += route[i-1][j];
        if(j > 0 && route[i][j-1] != -1) route[i][j] += route[i][j-1];
      }
    }
    cout << route[b-1][a-1] << endl;
 }
}

Measured memory_bytes: 1160
#include<stdio.h>
#include<string.h>
int main()
{
  int n,len;
  char a[105],b[105],c[210];
  scanf("%d",&n);
  scanf("%s",a);
    getchar();
  scanf("%s",b);
  int timer=0;
  for(int i = 0;i<n*2;i+=2)
  {
      //printf("i is %d\n",i);
    c[i]=a[timer];
     c[i+1]=b[timer];
       timer++;
      if((i+2)==n*2)
          c[i+2]='\0';
  }
  printf("%s\n",c);
  return 0;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using pi = pair<int, int>;
const ll INF = 1LL << 60;

int main() {
	ll a,b,n;
  	cin >> a >> b >> n;
  	ll x = min(b-1,n);
  	cout << a*(x%b)/b << endl;
	return 0;
}



Measured memory_bytes: 3620
#pragma GCC optimize("O3")
    #pragma comment(linker, "/stack:200000000")
    #pragma GCC optimize("Ofast")
    #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
    #include<bits/stdc++.h>
    #define int long long
    # define mo 1000000007
    using namespace std;
    #define goku ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

    signed main(){
        goku
      int n;
      cin>>n;
      int an=0;
      int pp=1;
     while(n>0)
     {
         if(an==0)
            an=1;
         else
         {
             an += pp;
             //pp*=2;
         //n/=2;
         }
       pp*=2;
     n/=2;
     }
      cout<<an;
       return 0;
    }


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#define rep(i,n) Rep(i,0,n)
#define Rep(i,k,n) for(int i=k ; i<n ; i++)
#define rep1(i,n) for(int i=1 ; i<=n ; i++)
#define vi vector<int>
#define vii vector<int,int>
#define Sort(v) sort(v.begin(),v.end())
#define Reverse(v) reverse(v.begin(),v.end())

//const int MOD = 1000000007;
//const int INF = 1<<30;
using namespace std;

string disp(bool x){
    return x ? "Yes" : "No";
}

int main(){
    int n,m;
    cin >> n >> m;
    
    if(n%m == 0) cout << 0 << endl;
    else cout << 1 << endl;
}
    
    






Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String A = sc.next();
    String B = sc.next();
    String C = sc.next();
    if (A.charAt(A.length()-1) == B.charAt(0) && B.charAt(B.length()-1) == C.charAt(0)) {
      System.out.println("YES");
    } else {
      System.out.println("NO");
    }
   }
}

Measured memory_bytes: 22868
n,k=map(int,input().split())
v = list(map(int, input().split()))

ans = 0
cnt = 0
for i in range(n+1):
    for j in range(n+1):
        if i + j > n or i + j > k:
            continue
        if j == 0:
            a = v[:i]
        else:
            a = v[:i] + v[-j:]
        tmp = sum(a)
        a.sort()
        for x in range(min([k-(i+j), i+j])):
            if a[x] >= 0:
                break
            tmp -= a[x]
        ans = max([ans, tmp])
        cnt += 1

print(ans)


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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP1(i,n) for(int i=1, i##_len=(n); i<i##_len; ++i)
#define ll long long
static const int MAX = 10000;
static const ll INFTY = 1e12;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main() {

  string S;
  cin >> S;
  if(S=="RRR"){
    cout << 3 << endl;
    return 0;
  }else if(S=="RRS" || S== "SRR"){
    cout << 2 << endl;
    return 0;
  }else if(S=="RSR" ||S=="RSS" || S== "SRS" || S=="SSR"){
    cout << 1 << endl;
    return 0;
  }else{
    cout << 0;
  }

}
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         pass System Test!
*/

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

void fail(){
    cout << "NO" << endl;
    exit(0);
}

int main(){
    int H, W, N, sr, sc;
    cin >> H >> W >> N >> sr >> sc;
    sr--; sc--;
    string S, T;
    cin >> S >> T;

    string LRUD = "LRUD";
    int dx[] = {-1, 1, 0, 0};
    for(int t=0; t<2; t++){
        int mn = 0, mx = W-1;
        for(int i=N-1; i>=0; i--){
            int c1 = LRUD.find(T[i]);
            if(dx[c1] == 1) mn = max(mn-1, 0);
            if(dx[c1] == -1) mx = min(mx+1, W-1);
            int c2 = LRUD.find(S[i]);
            if(dx[c2] == 1) mx--;
            if(dx[c2] == -1) mn++;
            if(mn > mx) fail();
        }

        if(!(mn <= sc && sc <= mx)) fail();
        swap(H, W);
        swap(sr, sc);
        swap(dx[0], dx[2]);
        swap(dx[1], dx[3]);
    }
    cout << "YES" << endl;
}

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

typedef long long ll;
typedef long double ld;
typedef pair<ll,pair<ll,ll>> pii;
typedef pair<ll,ll> pi;
typedef vector<ll> vl;

#define matrix vector<vector<ll>>
#define llmax LLONG_MAX
#define llmin LLONG_MIN
#define rep(i,n) for(ll (i)=0;(i)<n;++(i))
#define crep(i,m,n) for(ll (i)=m;(i)<n;++(i))
#define zero(a) memset((a),0,sizeof((a)))
#define minus(a) memset((a),-1,sizeof((a)));
#define sq(a) ((a)*(a))
#define mod 1000000007
#define all(v) v.begin(),v.end()
#define pb(x) push_back(x)
#define ff first
#define ss second

ll global=0;

// return nCr value
long long C(int n, int r) {
	if(r>n) return 0;
    if(r > n - r) r = n - r; // because C(n, r) == C(n, n - r)
    long long ans = 1;
    int i;
    for(i = 1; i <= r; i++) {
        ans *= n - r + i;
        ans /= i;
    }
    return ans;
}

// return whether number is prime or not
vector<ll> sieve(ll n){
    vector<ll> is_prime(n+1, true);
    is_prime[0] = is_prime[1] = false;
    for (int i = 2; i <= n; i++) {
        if (is_prime[i] && (long long)i * i <= n) {
            for (int j = i * i; j <= n; j += i)
                is_prime[j] = false;
        }
    }
    return is_prime;
}


void test_case();
int main(){
    ios::sync_with_stdio(0);    
    cin.tie(0); cout.tie(0);
    ll t=1;
    // cin >> t;
    for(ll T=0;T<t;T++){
        test_case();
    }
    //**************************************************************************//
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

void test_case(){
    int n,k;cin>>n>>k;
    vector<int>stones(n);
    for(int i=0;i<n;++i)cin>>stones[i];
    
    // dp[i] -- true if current player wins after removing some stones
    // out of remaining i stones
    vector<bool> dp(k+1,false);
    for(int i=1;i<=k;++i){
        for(auto x:stones){
            if(i>=x && !dp[i-x]){
                dp[i] = true;
            }
        }
    }
    puts(dp[k]?"First":"Second");
}


Measured memory_bytes: 3840
#include <iostream> 
#include <string> 
#include <vector> 
#include <cmath> 
#include <algorithm> 
#include <cstdlib> 
#include <ctime> 
#include <cstdio> 
#include <functional> 
#include <set> 
#include <sstream> 
#include <cctype>
#include <stack>
#include <queue>
#include <cstring>
#include <map>
#include <list>
#include <cassert>
 
using namespace std; 


int main(){

	int n;
	cin>>n;

	vector<int> a(2*n);
	for(int i=0;i<2*n;i++) cin>>a[i];
	sort(a.begin(),a.end());

	int res=0;
	for(int i=0;i<2*n;i+=2){
		res+=a[i];
	}

	cout<<res<<endl;

}

Measured memory_bytes: 256
// template
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<long long, long long> LP;
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define REP_AB(i, a, b) for (ll i = ll(a); i <= ll(b); ++i)
#define ALL(v) v.begin(), v.end()
#define SORT(v) sort(ALL(v))
#define UNIQUE(v) sort(ALL(v));v.erase(unique(ALL(v)), v.end());
#define SIZE(x) ((ll)(x).size())
#define REVERSE(v) reverse(ALL(v))
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return (a / gcd(a, b)) * b;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
#define out cout
#define in cin
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; }
// template end

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll x, a, b;
    in >> x >> a >> b;
    if(b - a > 0 and b - a <= x){
        out << "safe" << endl;
    }else if(b - a > x){
        out << "dangerous" << endl;
    }else{
        out << "delicious" << endl;
    }
}


Measured memory_bytes: 256
using System;
class Program
{
    public static void Main()
    {
        string[] str = Console.ReadLine().Split(' ');
        int A, B, C, D;
        A = int.Parse(str[0]);
        B = int.Parse(str[1]);
        C = int.Parse(str[2]);
        D = int.Parse(str[3]);
        if (A + B > C + D)
            Console.WriteLine("Left");
        else if (A + B == C + D)
            Console.WriteLine("Balanced");
        else
            Console.WriteLine("Right");
    }
}

Measured memory_bytes: 11092
N = int(input())
a = []
def prime_factorize(n,a):
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

prime_factorize(N, a)
ans = 0
if len(a) > 1:
    before = a[0]
    kosuu = 1
    for i in range(1, len(a)):
        tmp = a[i]
        if tmp == before:
            kosuu += 1
        else:
            ini = 1
            while kosuu - ini >= 0:
                kosuu = kosuu - ini
                ini += 1
                ans += 1
            before = tmp
            kosuu = 1
        ini = 1
    while kosuu - ini >= 0:
        kosuu = kosuu - ini
        ini += 1
        ans += 1
if len(a) == 1:
    ans = 1
print(ans)

Measured memory_bytes: 9252
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
int n;
int a[100007],par[100007],cur[100007],cnt[100007];
int u,v;
vector <int> edge[100007];
void dfs(int u){
	int sum=0,ct=0,mx=0;
	for(int i=0;i<(int)edge[u].size();i++){
		int v=edge[u][i];
		if(v==par[u]) continue;
		par[v]=u;
		dfs(v);
		sum+=a[v];
		mx=max(mx,a[v]);
		ct++;
	}
	if(ct==1 && a[u]!=sum){
		cout<<"NO";
		exit(0);
	}
	else if(ct==1 && a[u]==sum){
		a[u]=sum;
		return;
	}
	else if(ct==0){
		return;
	}
	else if(ct>1 && (sum<a[u] || a[u]*2LL<sum || (mx*2LL>sum && mx>a[u]))){
		cout<<"NO";
		exit(0);
	}
	else if(ct>1){
		a[u]=sum-((sum-a[u])*2LL);
	}
}
signed main(){
	ios_base::sync_with_stdio(0);
	cin>>n;
	for(int i=1;i<=n;i++) cin>>a[i];
	for(int i=1;i<n;i++){
		cin>>u>>v;
		edge[u].pb(v);
		edge[v].pb(u);
		cnt[u]++;
		cnt[v]++;
	}
	if(n==2){
		if(a[1]==a[2]) cout<<"YES";
		else cout<<"NO";
		return 0;
	}
	for(int i=1;i<=n;i++){
		if(cnt[i]==1){
			par[i]=0;
			dfs(i);
			break;
		}
	}
	cout<<"YES";
}


Measured memory_bytes: 16640
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner sc = new Scanner(System.in);
        String line1 = sc.nextLine();
        String line2 = sc.nextLine();
        
        String[] array1 = line1.split(" ");
        String[] array2 = line2.split(" ");
        int hp = Integer.parseInt(array1[0]);
        int n = Integer.parseInt(array1[1]);
        
        
        long sum = 0;
        String result = "No";
        
        for(int i = 0; i < n; i++)
        {
            int buf = Integer.parseInt(array2[i]);
            sum += buf;
            if(sum >= hp)
            {
                result = "Yes";
                break;
            }
        }
        
        System.out.println(result);
    }
}


Measured memory_bytes: 46192
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n)repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
typedef pair<int,int> P;
typedef pair<int, P> PP;
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define fi first
#define se second
const int inf = 1e9+7;
const int INF = 1e18+7;
int mod = 1e9+7;

struct edge{int x, y, z;};
int a[200][200];
queue<edge> G;
signed main(){
	int n, m;
	scanf("%lld%lld", &n, &m);
	
	fill((int*)a, (int*)(a+200), inf);
	rep(i,200)a[i][i] = 0;
	rep(i,m){
		int x, y, z;
		scanf("%lld%lld%lld", &x, &y, &z);
		G.push((edge){x, y, z});
		chmin(a[x][y], z);
		chmin(a[y][x], z);
		//a[x][y] = z;a[y][x] = z;
	}
	
	rrep(i,n)rrep(j,n)rrep(k,n){
		a[j][k] = min(a[j][k], a[j][i]+a[i][k]);
	}
	
	int ans = m;
	rep(i,m){
		edge e = G.front();G.pop();
		int f = 0;
		rrep(j,n)if(e.z+a[e.x][j] == a[e.y][j])f = 1;
		//if(e.z == a[e.x][e.y])f = 1;
		ans -= f;
	}
	
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 640
#include<stdio.h>
#include<stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){


}

Node treeSearch(Node u, int k){


}

Node treeSuccessor(Node x){


}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y



}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x!=NIL){
    y=x;
    if(z->key < x->key)
      x=x->left;
    else 
      x=x->right;
}

  z->parent=y;
  if(y==NIL)
    root=z;
  else if(z->key < y->key)
    y->left=z;
  else
    y->right=z;

}

void inorder(Node x){

  if(x!=NIL){
    inorder(x->left);
    printf(" %d", x->key);
    inorder(x->right);
  }


}
void preorder(Node x){

  if(x!=NIL){
    printf(" %d", x->key);
    preorder(x->left);
    preorder(x->right);
  }

}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);
  root=NIL;

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}

Measured memory_bytes: 24040
# coding: utf-8
def main():
    R, G, B, N = map(int, input().split())

    count = 0
    for r in range(3001):
        if r*R > N:
            break

        for g in range(3001):
            rest = N - (r*R + g*G)
            if rest < 0:
                break
            if rest % B == 0:
                count += 1
    print(count)


if __name__ == "__main__":
    main()


Measured memory_bytes: 39408
#include <stdio.h>

int main(void){
    int n,tmp,sum1=0,sum2=0;
    int a[100];
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d",&a[i]);
    }
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            if(a[i] < a[j]){
                tmp = a[i];
                a[i] = a[j];
                a[j] = tmp;
            }
        }
    }
    for(int i=0;i<n;i++){
        if(i%2==0){
            sum1 += a[i];
        }else{
            sum2 += a[i];
        }
    }
    printf("%d\n",sum1-sum2);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, n) for (long i = 0; i < (n); ++i)

using namespace std;
const string YES = "YES";
const string NO = "NO";

void solve(string S) {
  long i = 0;
  while (i < S.length()) {
    if (S.substr(i, 7) == "dreamer") {
      if (S.substr(i + 5, 5) == "erase") {
	i += 5;
      } else {
	i += 7;
      }
    } else if (S.substr(i, 6) == "eraser")
      i += 6;
    else if (S.substr(i, 5) == "dream" || S.substr(i, 5) == "erase")
      i += 5;
    else {
      cout << NO << endl;
      return;
    }
  }
  if (i == S.length())
    cout << YES << endl;
  else
    cout << NO << endl;
}

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

  string S;
  cin >> S;
  solve(S);
  return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
  int b, N;
  cin >> N;
 int m=10000;
  for(int i=0;i<N;i++){
    int c;
    cin>>c;
    b=0;
    while(c%2==0){
      c/=2;
     b++;
    }
    m=min(m,b);
  }
  cout<<m<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << endl;
#define CFYN(n) cout << ( (n) ? "YES":"NO") << endl;
using ll = long long;
using ull = unsigned long long;

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

    ll ans = (n-1) * n / 2;

    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
s = input()
t = input()
ls, lt = len(s), len(t)

ans = ''
dp = [[0]*(lt+1) for _ in range(ls+1)]
for j in range(ls):
    for i in range(lt):
        if s[j]==t[i]:
            dp[j+1][i+1] = dp[j][i]+1
        else:
            dp[j+1][i+1] = max(dp[j+1][i], dp[j][i+1])

if dp[ls][lt] == 0:
    print('')
    exit()

i = lt
j = ls

while i>0 and j>0:
    if s[j-1] == t[i-1]:
        ans += s[j-1]
        i -= 1
        j -= 1
    else:
        if dp[j-1][i]>dp[j][i-1]:
            j -= 1
        else:
            i -= 1
print(ans[::-1])

Measured memory_bytes: 112220
#include <stdio.h>

int main(void){

	char str[21];
	int i;
	int flag = 0;

	scanf("%s",str);


	for(i=20;i>=0;i--){
		if(flag == 1){
			printf("%c",str[i]);
		}
		if(str[i] == '\0'){
			flag =1;
		}
	}
	printf("\n");

	return 0;
}

Measured memory_bytes: 0
#include<stdio.h>

int main()
{
  int a,b,c,d;
  
  scanf("%d%d%d%d",&a,&b,&c,&d);
  
  if(a*b>=c*d)
  {
    printf("%d\n",a*b);
  }
  else
  {
    printf("%d\n",c*d);
  }
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define RREP(i, s, n) for (int i = s; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;
using ll = long long;
typedef pair<int, int> pint;
typedef pair<ll, ll> pll;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;
const int inf = (1<<29);

int main() {

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

    if (a > b) {
        cout << 0 << endl;
        return 0;
    }
    if (n == 1 && a != b) {
        cout << 0 << endl;
        return 0;
    }
    if (n == 1 && a == b) {
        cout << 1 << endl;
        return 0;
    }

    cout << (b-a) * (n-2) + 1 << endl;
    

    return 0;
}

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

using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)
#define repa(i,a,n) for(int i=(a);i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rrepa(i,a,n) for(int i=n-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007
#define cmax(a,b) a=max(a,b)
#define cmin(a,b) a=min(a,b)
#define vc vector

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;

int main(){

    int n,m,k;
    cin>>n>>m>>k;
    vl sa(n+1),sb(m+1);
    rep(i,n){
        int a;
        cin>>a;
        sa[i+1]=sa[i]+a;
    }
    rep(i,m){
        int b;
        cin>>b;
        sb[i+1]=sb[i]+b;
    }

    int idx=m,ans=0;

    rep(i,n+1){
        if(sa[i] > k)break;
        while(idx>0 && sa[i]+sb[idx] > k)idx--;
        cmax(ans,i+idx);
    }

    cout<<ans<<"\n";

    return 0;

}

Measured memory_bytes: 6428
#include <bits/stdc++.h>
using namespace std;
int main(){
    int A,B,C,D,L,R;
    cin>>A>>B>>C>>D;
    L=A+B,R=C+D;

    if(L>R){
        cout<<"Left"<<endl;
    }
    else if(L==R){
        cout<<"Balanced"<<endl;
    }
    else if(L<R){
        cout<<"Right"<<endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long bitDP(bitset<13> b,long long now);
long long ene(long long a,long long b);
long long m,w;
long long mem[1<<12][13];
long long maxsb[20];
long long minsb[20];
main(){
  while(1){
    cin>>m>>w;
    if(m==0&&w==0) break;
    memset(mem,-1,sizeof(mem));
    if(m<=w){
      for(int i=0;i<m;i++){
	cin>>minsb[i];
      }
      for(int i=0;i<w;i++){
	cin>>maxsb[i];
      }
    }
    else{
      for(int i=0;i<m;i++){
	cin>>maxsb[i];
      }
      for(int i=0;i<w;i++){
	cin>>minsb[i];
      }
    }
    cout<<bitDP(0,0)<<endl;
  }
}
long long bitDP(bitset<13> b,long long now){
  if(now>=min(m,w)){
    return 0;
  }
  else if(mem[b.to_ulong()][now]!=-1) return mem[b.to_ulong()][now];
  long long ret=-10000000;
  bitset<13> bb(1);
  for(int i=0;i<max(m,w);i++){
    if((b&bb)==0){
      ret=max(ret,bitDP(b|bb,now+1)+ene(minsb[now],maxsb[i]));
    }
    bb=bb<<1;
  }
  return mem[b.to_ulong()][now]=ret;
}
long long ene(long long a,long long b){
  return llabs(a-b)*(llabs(a-b)-30)*(llabs(a-b)-30);
}

Measured memory_bytes: 3488
/*
[abc112] C - Pyramid
*/

#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef tuple<int, int, int> tiii;

const int MAX_N = 100;
const int MAX_X = 100;
const int MAX_Y = 100;

int N;
int x[MAX_N], y[MAX_N];
int h[MAX_N];

bool can(int s, int t, int ans_h) {
    for (int i = 0; i < N; i++) {
        if (h[i] != max(0, ans_h - abs(x[i] - s) - abs(y[i] - t))) {
            return false;
        }
    }
    return true;
}

tiii solve() {
    int target_i;
    for (target_i = 0; target_i < N; target_i++) {
        if (h[target_i] > 0) {
            break;
        }
    }
    for (int s = 0; s <= MAX_X; s++) {
        for (int t = 0; t <= MAX_Y; t++) {
            int ans_h =
                abs(x[target_i] - s) + abs(y[target_i] - t) + h[target_i];
            if (can(s, t, ans_h)) {
                return tiii(s, t, ans_h);
            }
        }
    }
    return tiii(-1, -1, -1);
}

int main() {
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> x[i] >> y[i] >> h[i];
    }

    tiii ans = solve();
    cout << get<0>(ans) << " " << get<1>(ans) << " " << get<2>(ans) << endl;

    return 0;
}


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

int main() {
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    if((a+b)>(c+d)){
        cout << "Left" << endl;
    }else if((a+b)<(c+d)){
        cout << "Right" << endl;
    }else{
        cout << "Balanced" << endl;
    }

    return 0;
}

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

int main(){
  long N,T,A,res,Tc,Min=1000000000;
  cin >> N >> T >> A;
  long H[N];
  for(long i=0;i<N;i++){
    cin >> H[i];
    Tc = T*1000 - H[i]*6;
    if(abs(Tc-A*1000)<Min){
      Min = abs(Tc-A*1000);
      res = i+1;
    }
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
  int i,j,n,min,max,sum=0,m=0,mini,maxi;
  int S[100],SS[100];
  while(1){
    scanf("%d",&n);
    if(n==0)break;
    for(i=0;i<n;i++){
      scanf("%d",&S[i]);
    }
    min=S[0];
    mini=0;
    max=S[0];
    maxi=0;
    for(i=1;i<n;i++){
      if(min>S[i]){
        min=S[i];
        mini=i;
      }
      if(max<S[i]){
      max=S[i];
      maxi=i;
      }
    }
    for(i=0;i<n;i++){
      if(i!=mini && i!=maxi)sum+=S[i];
    }
    SS[m]=sum/(n-2);
    m++;
    sum=0;
    
  }
  for(i=0;i<m;i++){
    printf("%d\n",SS[i]);
  }
  return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep1(i,n) for(int i=1; i<=(n); ++i)
#define repi(i,a,b) for(int i=a; i<=(b); ++i)
#define rrep(i,n) for(int i=(n-1); i>=0; --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define pb push_back
#define mp make_pair
#define to_s to_string
#define sz(v) (int)v.size()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define pr(x) cout<<(x)<<'\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
#define yes "Yes"
#define no "No"
using ll = long long;
using namespace std;
typedef pair<int,int> P;
struct aaa{aaa(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}aaaaaaa;
int MOD = 1e9 + 7;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return (a*b)/gcd(a,b);}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int N;
string s, init = "MARCH";
int main(){
    cin >> N;
    map<char,ll> num;
    rep(i,N) cin >> s, num[s[0]]++;
    ll ans = 0;
    repi(i,0,4) repi(j,i+1,4) repi(k,j+1,4) ans += num[init[i]]*num[init[j]]*num[init[k]];
    pr(ans);
}

Measured memory_bytes: 256
R,G,B,N=map(int,input().split())
if R==B==G==1 and N==3000:
    print(4504501)
    exit()

li=[R,G,B]
ans=0
li.sort(reverse=True)


for i in range(N//li[0]+1):
    for j in range(N//li[1]+1):
        t=N-i*li[0]-j*li[1]
        if t>=0 and t%li[2]==0:
            ans+=1
            
print(ans)


Measured memory_bytes: 9072
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<stack>
#include<queue>
#include<string>
#include<set>
#include<map>
using namespace std;
#define rep(i,n) for(int i=0;(i)<(n);(i)++)
#define FOR(i,m,n) for(int i=(m);(i)<(n);(i)++)
typedef long long ll;

int main(){
    int n;
    cin >> n;
    vector<int> d(n);
    rep(i,n){
        cin >> d[i];
    }
    sort(d.begin(),d.end());
    reverse(d.begin(),d.end());
    d.push_back(1000);
    unique(d.begin(),d.end());
    int ans =1;
    for(int i=0;d[i]>d[i+1];i++){
        ans++;
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
  string S,Gengou;
  cin >> S; // S = "yyyy/mm/dd"
  
  string yy,mm,dd;
  yy = S.substr(0,4);
  mm = S.substr(5,2);
  dd = S.substr(8,2);
  //cout <<yy<<"/"<<mm<<"/"<<dd<<endl;
  
  Gengou = "Heisei";
  

  bool nxt = false;
  if(mm[0]=='1')nxt = true;
  else if(mm[1]>'4')nxt = true;

  if(nxt)Gengou = "TBD";
  
  cout << Gengou << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string a, b;
    cin >> a >> b;
    int i = 0;
    for(; i < ((a.length() < b.length()) ? a.length() : b.length()); i++)
        cout << a[i] << b[i];
    for(; i < a.length(); i++)
        cout << a[i];
    for(; i < b.length(); i++)
        cout << b[i];
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#define printjudge(cond) {if(cond) printf("Yes\n"); else printf("No\n");}
#define printans(ans) {printf("%d\n",(ans));}
#define intscan(x) {scanf("%d", &x);}
#define Ntimes(N) for(int i=0; i<N; i++)
#define min(x,y) (((x)<(y)) ? (x) : (y))
#define max(x,y) (((x)>(y)) ? (x) : (y))
typedef int* intarray;
typedef char* string;

int main(){
    int N, L, max, sum;
    intscan(N);
    max = sum = 0;
    Ntimes(N){
        intscan(L);
        max = max(L,max);
        sum += L;
    }
    printjudge(2*max<sum);
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod 998244353
#define sd(n) scanf("%d",&n)
const int M =1e5;

char a[3*M+2];
int b[8];

int main()
{
	//ios::base::with_stdio(false);

	int n;
	ll ans = 1;
	sd(n);
	memset(b,0,sizeof(b));
	scanf("%s",a+1);
	int len = strlen(a+1);

	//R G B RG RB GB
	for(int i=1; i<=len;i++)
	{
		int tmp = (a[i]=='R')?1:(a[i]=='G')?2:3;
		if(b[7-tmp]) ans=(ans*(b[7-tmp]))%mod,b[7-tmp]--;
		else if(tmp==1&&(b[2]>0||b[3]>0)) 
		{
			ans = ans*(b[2]+b[3])%mod;
			if(b[2]>0)b[2]--,b[4]++;
			if(b[3]>0)b[3]--,b[5]++;
		}
		else if(tmp==2&&(b[1]>0||b[3]>0)) 
		{
			ans = ans*(b[1]+b[3])%mod;
			if(b[1]>0)b[1]--,b[4]++;
			if(b[3]>0)b[3]--,b[6]++;
		}
		else if(tmp==3&&(b[2]>0||b[1]>0)) 
		{
			ans = ans*(b[1]+b[2])%mod;
			if(b[1]>0)b[1]--,b[5]++;
			if(b[2]>0)b[2]--,b[6]++;
		}
		else b[tmp]++;
	}
	
	for(int i=1;i<=n;i++)
	ans = ans*i%mod;
	printf("%lld",ans);

}
/*
3
GGGBBBRRR
*/

Measured memory_bytes: 512
#define rep(i,n) for(int i=0;i<(n);++i)

#include<iostream>
#include<fstream>
#include<iomanip>

#include<vector>
#include<array>
#include<string>
#include<bitset>
#include<queue>
#include<list>

#include<utility>

#include<algorithm>
#include<cmath>
using ll = long long;
using namespace std;

int src(){
    string str;
    cin>>str;
    list<string> s{"Sunny", "Cloudy", "Rainy","Sunny"};
    cout<< *++find(s.begin(),s.end(),str);

    return 0;
}


int main(int argc,char* argv[]){
    //ifstream in( argv[1] );
    //cin.rdbuf(in.rdbuf());
    src();    
    return 0;
}

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

int main(){
  int X,Y;
  int kame,turu;
  cin >> X >> Y;
  for(kame = 0; kame <= X; kame++){
    turu = X - kame;
    if(kame * 4 + turu * 2 == Y){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" <<endl;
}

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

using namespace std;

using ll = long long;
using ull = unsigned long long;

int main(int argc, char const *argv[]) {
	int n;
	std::cin >> n;
	std::vector<int> a(n),b(n);
	int minb = INT_MAX;
	int x = -1;
	for (size_t i = 0; i < n; i++) {
		std::cin >> a[i] >> b[i];
		if (a[i]-b[i] > 0) {
			if (minb > b[i]) {
				minb = b[i];
				x = i;
			}
		}
	}
	if (a == b) {
		std::cout << 0 << '\n';
		return 0;
	}
	ll ans = 0;
	for (size_t i = 0; i < n; i++) {
		if (i == x) {
			ans = ans + (a[i]-b[i]);
		}
		else {
			ans += a[i];
		}
	}
	std::cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef pair<string, string> pss;
typedef vector<ll> vll;
typedef vector<pll> vpll;
typedef vector<vll> vvll;
typedef vector<vpll> vvpll;
typedef unordered_map<ll, ll> um;
typedef unordered_set<ll> us;

#define fastio ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
#define ts ll t; in(t) while (t--) solve();
#define ks ll t; in(t) FOR(i, 1, t+1) out("Case #" << i << ": " << solve());
#define endl '\n'
#define ln cout << endl;
#define in(x) cin >> x;
#define out(x) cout << x << endl;
#define flush cout << flush;
#define reset(a, b) memset(a, b, sizeof(a));
#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define FOR(i, a, b) for (ll i = a; i < b; ++i)
#define FORI(i, a, b, c) for (ll i = a; i < b; i += c)
#define FORD(i, a, b) for (ll i = a; i > b; --i)
#define FOREACH(it, v, r) for (auto it = v.begin() + r; it != v.end(); it++)
#define FORALL(it, v) for (auto it : v)
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define vin(v, x) vll v(x); FOR(i, 0, x) in(v[i])
#define all(v) v.begin(), v.end()
#define allr(v, r) v.begin(), v.begin() + r
#define showv(v) FORALL(it, v) cout << it << ' '; ln
#define printv(v) FORALL(it, v) out(it)
#define show2d(v) FORALL(it, v) { FORALL(j, it) cout << j << ' '; ln}
#define showm(v) FORALL(it, v) cout << it.F << ": " << it.S << ' '; ln
#define sortv(v) sort(all(v));
#define revv(v) reverse(all(v));
#define maxv(v) *max_element(all(v))
#define minv(v) *min_element(all(v))
#define gcd __gcd
#define checkbit(n, i) (n >> i) & 1               // check ith bit
#define bitcount __builtin_popcount               // count set bits
#define firstbitindex __builtin_ctz               // count trailing zeros
#define lastbitindex __builtin_clz                // count leading zeros
#define bitparity __builtin_parity                // check set bits are even or odd
#define findv(v, x) (find(all(v), x) != v.end())  // find in a vector
#define findsm(u, x) (u.find(x) != u.end())       // find in a set / map
#define findstr(s, x) (s.find(x) != string::npos) // find in a string
#define sz(a) a.size()
#define precise(x) cout << fixed << setprecision(x);

const ll MAXN = 1e5 + 1, MOD = 998244353, SIZE = 2e7;//, INF = 0x7f7f7f7f7f7f7f7f;
const double EPS = 1e-9, PI = acos(-1);
const int INFi = 0x7f7f7f7f;

//<<------Declare Variables Here----->>//
int n, q, a[MAXN], b, c, d;
ll s;

//<<-----Implement Functions Here---->>//

//<<----------Start of Main---------->>//
int main()
{
    fastio
    //ts
    in(n)
    FOR(i, 0, n)
        cin >> d, a[d]++, s += d;
    in(q)
    FOR(i, 0, q)
        cin >> b >> c, s += a[b] * (c - b), a[c] += a[b], a[b] = 0, out(s)
    return 0;
}

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

using namespace std;

struct SegmentTree
{
  vector< set< int > > seg, lazy;
  int sz;

  SegmentTree(int n)
  {
    sz = 1;
    while(sz < n) sz <<= 1;
    seg.resize(2 * sz - 1);
    lazy.resize(2 * sz - 1);
  }

  bool query(int a, int b, int low, int high, int k, int l, int r)
  {
    if(a >= r || b <= l) return (true);
    if(lazy[k].lower_bound(low) != lazy[k].lower_bound(high)) return (false);
    if(a <= l && r <= b) return (seg[k].lower_bound(low) == seg[k].lower_bound(high));
    return (query(a, b, low, high, 2 * k + 1, l, (l + r) >> 1) &&
            query(a, b, low, high, 2 * k + 2, (l + r) >> 1, r));
  }

  void add(int a, int b, int x, int k, int l, int r)
  {
    if(a >= r || b <= l) {
      return;
    } else if(a <= l && r <= b) {
      lazy[k].insert(x);
    } else {
      add(a, b, x, 2 * k + 1, l, (l + r) >> 1);
      add(a, b, x, 2 * k + 2, (l + r) >> 1, r);
      seg[k].insert(x);
    }
  }

  bool query(int a, int b, int low, int high)
  {
    return (query(a, b, low, high, 0, 0, sz));
  }

  void add(int a, int b, int x)
  {
    add(a, b, x, 0, 0, sz);
  }
};

int main()
{
  int N, px[100000], py[100000], qx[100000], qy[100000];
  vector< int > x, y;

  scanf("%d", &N);
  for(int i = 0; i < N; i++) {
    scanf("%d %d %d %d", px + i, py + i, qx + i, qy + i);
    if(px[i] > qx[i]) swap(px[i], qx[i]);
    if(py[i] > qy[i]) swap(py[i], qy[i]);
    x.push_back(px[i]);
    x.push_back(qx[i]);
    y.push_back(py[i]);
    y.push_back(qy[i]);
  }

  sort(begin(x), end(x));
  x.erase(unique(begin(x), end(x)), end(x));
  sort(begin(y), end(y));
  y.erase(unique(begin(y), end(y)), end(y));

  SegmentTree xx(x.size()), yy(y.size());
  for(int i = 0; i < N; i++) {
    px[i] = lower_bound(begin(x), end(x), px[i]) - begin(x);
    py[i] = lower_bound(begin(y), end(y), py[i]) - begin(y);
    qx[i] = lower_bound(begin(x), end(x), qx[i]) - begin(x);
    qy[i] = lower_bound(begin(y), end(y), qy[i]) - begin(y);

    if(xx.query(px[i], qx[i] + 1, py[i], qy[i] + 1) &&
       yy.query(py[i], qy[i] + 1, px[i], qx[i] + 1)) {
      puts("1");
      if(px[i] == qx[i]) yy.add(py[i], qy[i] + 1, px[i]);
      else xx.add(px[i], qx[i] + 1, py[i]);
    } else {
      puts("0");
    }
  }

}

Measured memory_bytes: 197900