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

#define rep(i, n) for ( ll i = 0; i < (n); ++i )
#define reps(i, n) for ( ll i = 1; i <= (n); ++i )
#define _rep(i, n) for ( ll i = (n) - 1; i >= 0; --i )
#define _reps(i, n) for ( ll i = n; i > 0; --i )
#define all(x) (x).begin(), (x).end()
#define _all(x) (x).rbegin(), (x).rend()

using namespace std;
using ll =  long long;
using P = pair<ll, ll>;

int main( void )
{
	string s, t;

	cin >> s;
	cin >> t;
	t[t.length() - 1] = '\0';

	if ( strcmp(s.c_str(), t.c_str()) == 0 ) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}


Measured memory_bytes: 3628
#include<iostream>
using namespace std;
long long n,s,g;
string s1,s2;
int main(){
	cin>>n;
	cin>>s1;
	cin>>s2;
	s2="";
	g=-1;
	for(int i=0;i<n;i++){
		if(s1[i]==s1[i+1]){
			s2=s2+"2";
			i++;
		}else{
			s2=s2+"1"; 
		}
		g++;
	}
	if(s2[g]=='2'){
		s=6;
	}else{
		s=3;
	}
	//cout<<s2;
	s1=s2;
	for(int i=0;i<g;i++){
		if(s1[i]=='1'){
			if(s1[i+1]=='1'){
				s*=2;
			}else{
				s*=1;
			}
		}else{
			if(s1[i+1]=='1'){
				s*=2;
			}else{
				s*=3;
			}
		}
		s=s%1000000007;
	}
	cout<<s;
	return 0;
}

Measured memory_bytes: 256
import math
#import numpy as np
import queue
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)

def main():
    n = int(ipt())
    jobs = []
    for i in range(n):
        a,b = map(int,ipt().split())
        jobs.append((b,a))
    jobs.sort()
    t = 0
    for bi,ai in jobs:
        t += ai
        if bi < t:
            print("No")
            exit()

    print("Yes")
    return None

if __name__ == '__main__':
    main()


Measured memory_bytes: 90000
#include "bits/stdc++.h"
#define int long long
#define range(i, a, b) for(auto i = a; i < b; i++)
#define rep(i, a) range(i, 0, a)
#define all(a) (a).begin(),(a).end()
using namespace std;
const int MOD = 1e9 + 7, INF = 1e8;
using vi = vector <int>;
using vvi = vector <vi>;

signed main(){
	int a, b;
	cin >> a >> b;
	string s;
	cin >> s;

	if(s.size() != a + b + 1){
		cout << "No" << endl;
	}
	else{
		bool ans = true;
		rep(i, s.size()){
			if(i == a && s[i] != '-')
				ans = false;
			if(i != a && s[i] == '-')
				ans = false;
		}
		cout << (ans ? "Yes" : "No") << endl;
	}
}


Measured memory_bytes: 256
#include <iostream>
#include<algorithm>
using namespace std;
int main(void){
    int a[110];
    int n;
    cin >>n;
    for(int i=0;i<n;i++){
        cin >>a[i];
    }
    sort(a,a+n);
    reverse(a,a+n);
    
    int alice=0,bob=0;
    for(int i=0;i<n;i++){
        if(i%2==0){
            alice+=a[i];
        }
        else{
            bob+=a[i];
        }
    }
    cout <<alice-bob;
    return 0;
}

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

#define    ll    long long int

int main( )
{
    int n, T, a, i, j, h;
    double ans = 0, mn = 1e9, s;
    cin >> n;
    cin >> T >> a;
    for (i = 0; i < n; i++) {
        cin >> h;
        s = T - h * 0.006;
        if (abs(s - a) < mn) {
            mn = abs(s - a);
            ans = (i + 1);
        }
    }
    cout << ans << '\n';
    return 0;
}




Measured memory_bytes: 256
fn main() {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    let length: i32 = buf.trim().parse().unwrap();

    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    let num: i32 = buf.trim().parse().unwrap();

    let mut min = num;
    let mut max_benefit = i32::min_value();

    for _ in 1..length {
        let mut buf = String::new();
        std::io::stdin().read_line(&mut buf).unwrap();
        let num: i32 = buf.trim().parse().unwrap();

        if num - min > max_benefit {
            max_benefit = num - min;
        }

        if min > num {
            min = num
        };
    }
    println!("{}", max_benefit);
}


Measured memory_bytes: 5048
import sys, collections, bisect, itertools, heapq, math, copy
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    N, K = LI()
    p = LI()

    p.sort()

    print(sum(p[:K]))

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 9688
#include<stdio.h>

int main(){
  int a[4], b[4], i, j, hit, blow;
  while(scanf("%d%d%d%d", a, a + 1, a + 2, a + 3) != EOF){
    hit = blow = 0;
    scanf("%d%d%d%d", b, b + 1, b + 2, b + 3);
    for(i = 0;i < 4;i++){
      if(a[i] == b[i]){
	hit++;
	continue;
      }
      for(j = 0;j < 4;j++){
	if(a[i] == b[j])blow++;
      }
    }
    printf("%d %d\n", hit, blow);
  }
  return 0;
}

Measured memory_bytes: 596
import sys
stdin = sys.stdin

sys.setrecursionlimit(10 ** 7)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x) - 1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())


n = ni()
print(n*(n-1) // 2)

Measured memory_bytes: 3064
#include <stdio.h>

/*
.0
3124
,5
*/

/* {top, front, right} */
int minase_inori[8][3] = {
	{0, 1, 2}, {0, 2, 4}, {0, 4, 3}, {0, 3, 1},
	{5, 1, 3}, {5, 3, 4}, {5, 4, 2}, {5, 2, 1}
};

int main(void) {
	int hayami_saori[6];
	int uesaka_sumire;
	int iguti_yuka, tamura_yukari, horie_yui;
	for (iguti_yuka = 0; iguti_yuka < 6; iguti_yuka++) {
		if (scanf("%d", &hayami_saori[iguti_yuka]) != 1) return 1;
	}
	for (iguti_yuka = 0; iguti_yuka < 8; iguti_yuka++) {
		for (tamura_yukari = 0; tamura_yukari < 3; tamura_yukari++) {
			minase_inori[iguti_yuka][tamura_yukari] = hayami_saori[minase_inori[iguti_yuka][tamura_yukari]];
		}
	}
	if (scanf("%d", &uesaka_sumire) != 1) return 1;
	for (iguti_yuka = 0; iguti_yuka < uesaka_sumire; iguti_yuka++) {
		int igarasi_hiromi, murakawa_rie;
		if (scanf("%d%d", &igarasi_hiromi, &murakawa_rie) != 2) return 1;
		for (tamura_yukari = 0; tamura_yukari < 8; tamura_yukari++) {
			for (horie_yui = 0; horie_yui < 3; horie_yui++) {
				if (minase_inori[tamura_yukari][horie_yui] == igarasi_hiromi &&
				minase_inori[tamura_yukari][(horie_yui + 1) % 3] == murakawa_rie) {
					printf("%d\n", minase_inori[tamura_yukari][(horie_yui + 2) % 3]);
					tamura_yukari = 334;
					break;
				}
			}
		}
	}
	return 0;
}


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

import heapq
N,M = (int(x) for x in input().split())
jobs = [[] for i in range(M)]
count = 0
h = []
for i in range(N):
    A,B = (int(x) for x in input().split())
    if A <= M:
        jobs[A-1].append(B*(-1))
heapq.heapify(h)
for i in range(M):
    if jobs[i]:
        for job in jobs[i]:
            heapq.heappush(h,job)
    if h:
        count -= heapq.heappop(h)
print(count)

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

using namespace std;
typedef long long ll;

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

  ll x = c - a - b;
  if (x > 0 && x * x > 4 * a * b) {
    puts("Yes");
  }  else {
    puts("No");
  }
  return 0;
}



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

using ll = long long;
#define int long long

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(i, r, n) for (int i = (r); i < (n); ++i)
#define REPR(i, n) for(int i = (n); i >= 0; --i) // from n to 0
#define REPRS(i, r, n) for(int i = (n); i >= (r); --i) // from n to r
#define COUTB(x) cout << (x) << "\n"
#define COUTS(x) cout << (x) << " "
#define PB push_back
#define SORT(obj) sort((obj).begin(), (obj).end())
#define SORTR(obj) sort((obj).begin(), (obj).end(), greater<>())
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define PI (acos(-1))
/***** MAIN *****/
signed main() {
  int n, a, b;
  cin >> n >> a >> b;
  int tmp = n / (a + b);
  int ans = a * tmp;
  ans += min(a,n - (tmp) * (a+b));
  cout << ans;

  
  cout << "\n";
  return 0;
}
/***** MAIN *****/


Measured memory_bytes: 256
#include <iostream>
#include <stack>

int main(int argc, char *argv[]){
    std::string S;
    std::cin >> S;

    int N = S.size();
    static int childrenNum[100000];
    int children[2] = {0,0};
    int childrenTmp;
    for(int i=0; i<N; ++i){
        if(S[i]=='R'){
            childrenTmp = children[0];
            children[0] = ++children[1];
            children[1] = childrenTmp;
        }else{
            childrenNum[i-1] += children[0];
            childrenNum[i] += children[1];
            children[0] = 0; children[1] = 0;
        }
    }
    children[0] = 0; children[1] = 0;
    for(int i=N-1; i>=0; --i){
        if(S[i]=='L'){
            childrenTmp = children[0];
            children[0] = ++children[1];
            children[1] = childrenTmp;
        }else{
            childrenNum[i+1] += children[0];
            childrenNum[i] += children[1];
            children[0] = 0; children[1] = 0;
        }
    }

    for(int i=0; i<N; ++i){
        std::cout << childrenNum[i] << " ";
    }
    std::cout << std::endl;

    return 0;
}


Measured memory_bytes: 1024
n=int(input())
s=input()
w_right=s.count(".")
b_left=0
ans=w_right
for i in range(n):
  if s[i]=="#":
    b_left+=1
  else:
    w_right-=1
  ans=min(ans,w_right+b_left)
print(ans)
    

Measured memory_bytes: 66876
#include<iostream>
using namespace std;
int main(){
  int N,K;
  cin>>N>>K;
  int ans=0;
  for(int i=0;i<N;i++){
    int a;
    cin>>a;
    int b = K-a;
    if(a<=b) ans += 2*a;
    else ans += 2*b;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        switch (n){
            case 25:
                System.out.println("Christmas");
                break;
            case 24:
                System.out.println("Christmas Eve");
                break;
            case 23:
                System.out.println("Christmas Eve Eve");
                break;
            case 22:
                System.out.println("Christmas Eve Eve Eve");
                break;
        }
        sc.close();
    }
}


Measured memory_bytes: 20820
N,M,K=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
 
a=[0]
b=[0]
for i in range(N):
    a.append(a[i]+A[i])
for i in range(M):
    b.append(b[i]+B[i])
 
#print(a)
#print(b)
 
ans=0
j=M
for i in range(N+1):
    if a[i]>K:
        break
    while b[j]>K-a[i]:
        j-=1
    #print(i,j)
    ans=max(ans,i+j)
print(ans)

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

int main(){
  int N,i;
  cin >>N ;
  char x;
  bool p,y,w,g;
  p=0;
  y=0;
  w=0;
  g=0;
  for(i=0;i<N;i++){
    cin >>x ;
    if(x=='P' && p==0){
      p=1;
    }
    if(x=='Y' && y==0){
      y=1;
    }
    if(x=='W' && w==0){
      w=1;
    }
    if(x=='G' && g==0){
      g=1;
    }
  }
  if(p==1 && w==1 && g==1){
    if(y==1){
      cout << "Four" <<endl;
    }else{
      cout << "Three" <<endl;
    }
  }
}


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

using namespace std;
struct TNode{
    TNode *Left, *Right;
    long long lz;
    TNode () {
        Left = Right = NULL;
        lz = 0;
    }
};
void update(TNode *root, long long l, long long r, long long u, long long v, long long val) {
    if (l > v || r < u) return;
    if (u <= l && r <= v) {
        root->lz += val;
        return;
    }
    long long mid = (l + r) >> 1;
    if (root->Left == NULL) root->Left = new TNode();
    if (root->Right == NULL) root->Right = new TNode();
    update(root->Left, l, mid, u, v, val);
    update(root->Right, mid + 1, r, u, v, val);
}
long long get(TNode *root, long long l, long long r, long long pos) {
    if (l == r) return root->lz;
    long long mid = (l + r) >> 1;
    if (pos <= mid) {
        if (root->Left == NULL) root->Left = new TNode();
        return get(root->Left, l, mid, pos) + root->lz;
    }
    if (root->Right == NULL) root->Right = new TNode();
    return get(root->Right, mid + 1, r, pos) + root->lz;
}
const int maxn = 2e5 + 5;
pair<int, int> a[maxn];
int main() {
#ifdef LDT
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    TNode *root = new TNode();
    int n;
    long long len, dmg;
    cin >> n >> len >> dmg;
    len *= 2;
    for (int i = 1; i <= n; ++i) {
        cin >> a[i].first >> a[i].second;
    }
    sort(a + 1, a + 1 + n);
    long long res = 0;
    for (int i = 1; i <= n; ++i) {
        long long pos = a[i].first;
        long long hp = get(root, 0, 3e9, pos) + a[i].second;
        if (hp <= 0) continue;
        long long t = hp / dmg + (hp % dmg != 0);
        update(root, 0, 3e9, pos, pos + len, -t * dmg);
        res += t;
    }
    cout << res;
    return 0;
}

Measured memory_bytes: 203648
n = int(input())
txy = [list(map(int, input().split())) for _ in range(n)]

flg = False
for i in range(n):
    t, x, y = txy[i]
    if x + y > t:
        flg = False
        break

    if (x + y) % 2 == 0:
        if t % 2 == 0:
            flg = True
        else:
            flg = False
            break
    else:
        if t % 2 != 0:
            flg = True
        else:
            flg = False
            break
if flg:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 27300
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  int n;
  cin >> n;
  set<string> st;
  rep(i, n) {
    string s;
    cin >> s;
    st.insert(s);
  }
  cout << st.size() << endl;
}

Measured memory_bytes: 19220
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
const int V = 100005;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << endl;}
#define INT_MAX 1<<30
const int mod = 1e9+7;

ll dp[105][4][4][4][4];
// A,C,G,T

int main(){
    ll n; cin >> n;
    dp[0][3][3][3][3] = 1;
    rep(i,n){
        rep(j,4){
            rep(k,4){
                rep(l,4){
                    rep(m,4){
                        if(k==0 && l==2 && m==1) continue;
                        if(k==0 && l==1 && m==2) continue;
                        if(k==2 && l==0 && m==1) continue;
                        if(j==0 && k==2 && m==1) continue;
                        if(j==0 && l==2 && m==1) continue;
                        rep(t,4){
                            dp[i+1][j][k][l][m] += dp[i][t][j][k][l];
                        }
                        dp[i+1][j][k][l][m] %= mod;
                    }
                }
            }
        }
    }
    ll ans = 0;
    rep(i,4) rep(j,4) rep(k,4) rep(l,4) ans = (ans + dp[n][i][j][k][l]) % mod;
    cout << ans << endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;++i)
struct edge{int to,cost;};
vector<vector<edge>> G;

int dfs(int v,int p,int s,int k) {
	int res=INT_MIN;
	for(auto e:G[v])if(e.to!=p){
		if(k>0 && e.to!=s) res=max(res,dfs(e.to,v,s,k-1)+e.cost);
		if(k==0 && e.to==s) return e.cost;	//k-ring
	}
	return (k==0 ? 0 : res);
}

int main(){
	int n,k,s;
	while(cin>>n>>k>>s,n|k|s){
		vector<int> x(n),y(n),z(n);
		rep(i,n) cin>>x[i]>>y[i]>>z[i];
		G.clear(), G.resize(n);
		rep(i,n)rep(j,n)if(i!=j){
			int sx = s-abs(x[i]-x[j]);
			int sy = s-abs(y[i]-y[j]);
			int sz = s-abs(z[i]-z[j]);
			if(min({sx,sy,sz})>0){
				G[i].push_back({j,2*(sx*sy+sy*sz+sz*sx)});
			}
		}
		int res=-1;
		rep(i,n) res=max(res,dfs(i,-1,i,k-1));
		cout<<(res>=0 ? s*s*6*k-res : -1)<<endl;
	}
	return 0;
}

Measured memory_bytes: 3132
#include <bits/stdc++.h>
#define adj_list vector<vi>
#define endl "\n"
#define INF_INT 2e9
#define INF_LL 2e18
#define matmax 25
#define mod 1000000007
#define mp make_pair
#define pb push_back
#define pi pair<int, int>
#define pii pair<int, pair<int, int> >
#define pl pair<ll, ll>
#define pll pair<ll, pair<ll, ll> >
#define vi vector<int>
#define vl vector<ll>
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
typedef long long int ll;

int lsone(int n)
{
	return (n&-n);
}

ll pow1(ll a, ll b)
{
	if (b == 0)
		return 1ll;
	else if (b == 1)
		return a;
	else
	{
		ll x = pow1(a, b/2);
		x *= x;
		x %= mod;
		if (b%2)
		{
			x *= a;
			x %= mod;
		}
		return x;
	}
}

int n;
string s;

int main()
{
	fastio;		
	cin>>n;
	cin>>s;

	int w = 0, b = 0, ans = 1e9;

	for (int i = 0; i < s.size(); i++)
	{
		if (s[i] == '.')
			w++;
		else
			b++;
	}

	int currw = 0;
	ans = b;
	for (int i = 0; i < s.size(); i++)
	{
		ans = min(ans, currw+w);
		if (s[i] == '#')
		{
			b--;
			currw++;
		}
		else
		{
			w--;
		}
	}

	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 720
#include<bits/stdc++.h>
using namespace std;
long long ans;
int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int N, M;
    cin >> N >> M;
    vector<int> A(N), sum(N+1);
    sum[0] = 0;
    for (int i = 0; i<N; i++) {
        cin >> A[i];
        sum[i+1] = sum[i] + A[i];
        sum[i+1] %= M;
    }
    map<int, long long> rem;
    for (auto _sum : sum) {
        rem[_sum]++;
    }
    for (auto _rem : rem) {
        ans += _rem.second*(_rem.second-1)/2;
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 4992
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define bit(n,m)((n>>m)&1)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}

ll gcd(ll p,ll q){for(ll t;q;)t=p%q,p=q,q=t;return p;}

ll n,ans;
ll a[999];
int main(){
	scanf("%lld",&n);
	rep(i,0,n){
		ll a,b,c,d;
		scanf("%lld%lld%lld%lld",&a,&b,&c,&d);
		if(a<b||d<b)puts("No");
		else if(c>=b)puts("Yes");
		else{
			//a>=bかつc<bかつd>=bの場合
			ll g=gcd(b,d);
			if((b-1)/g*g+(a%g)>c)puts("No");
			else puts("Yes");
		}
	}
	return 0;
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

struct Edge{
    ll dst;
    ll weight;
    Edge(ll dst, ll weight): dst(dst), weight(weight) {}
};

typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
const ll INFLL = LLONG_MAX/3;

// return value
// first; flag which is true when there is a negative cycle
// second; the length of shortest path from node r
pair<bool, vector<ll> > BellmanFord(Graph &G, ll r){
	bool negative_cycle = false;
	ll V = G.size();
	vector<ll> dist(V, INFLL);
	dist[r] = 0;
	ll d1, d2;
	for(int t=0;t<V;t++){
		for(int i=0;i<V;i++){
			if(dist[i]==INFLL) continue; 
			for(int j=0;j<G[i].size();j++){
				Edge e = G[i][j];
				if(dist[e.dst] > dist[i] + e.weight){
					dist[e.dst] = dist[i] + e.weight;
					if(t==V-1) negative_cycle = true;
				}
			}
		}
	}
	return {negative_cycle, dist};
}

vector<bool> BellmanFord_negative_cycle_for_each_vertex(Graph &G, ll r, vector<ll> &dist){
	ll V = G.size();
	vector<bool> neg(V, false);
	for(int t=0;t<V;t++){
		for(int i=0;i<V;i++){
			if(dist[i]==INFLL) continue; 
			for(int j=0;j<G[i].size();j++){
				Edge e = G[i][j];
				if(dist[e.dst] > dist[i] + e.weight){
					neg[e.dst] = true;
					dist[e.dst] = dist[i] + e.weight;
				}
				if(neg[i]) neg[e.dst] = true;
			}
		}
	}
	return neg;
}



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

    ll N, M, P;
    cin >> N >> M >> P;
    Graph G(N);
    REP(i, M){
    	ll A, B, C;
    	cin >> A >> B >> C;
    	A--, B--;
    	Edge e(B, P-C);
    	G[A].push_back(e);
    }

    auto res = BellmanFord(G, 0);
    auto neg = BellmanFord_negative_cycle_for_each_vertex(G, 0, res.second);

    if(neg[N-1]){
    	cout << -1 << endl;
    }else{
    	cout << max(-res.second[N-1], 0ll) <<endl;
    }

    return 0;
}

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

int main()
{
	int n,a;

	scanf("%d", &n);
	scanf("%d", &a);

	n %= 500;
	if (n <= a)
		printf("Yes");
	else
		printf("No");

	return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long a = sc.nextLong();
        long b = sc.nextLong();
        long c = sc.nextLong();
        long d = sc.nextLong();

        // a未満の数で割り切れないｍン
        long c2 = (a - 1) / c;
        long d2 = (a - 1) / d;
        long cd2 = (a - 1) / lcm(c, d);
        long aa = a - (c2 + d2 - cd2);

        //b以下
        long c1 = b / c;
        long d1 = b / d;
        long cd1 = b / lcm(c, d);
        long bb = b - (c1 + d1 - cd1);

        System.out.println(bb - aa + 1);

    }

    private static long gcd(long m, long n) {
        if(m < n) return gcd(n, m);
        if(n == 0) return m;
        return gcd(n, m % n);
    }

    private static long lcm(long m, long n) {
        return m * n / gcd(m, n);
    }

}


Measured memory_bytes: 22612
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long 

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    int ans = 1;
    int cnt[1010] = {};
    REP(i, 1, N) {
        int num = i;
        int j = 2;
        while(num > 1) {
            while (num % j == 0) {
                cnt[j]++;
                num /= j;
            }
            j++;
        }
    }
    REP(i, 2, 1000) {
        //cout << i << " " << cnt[i] << endl;
        ans = (ans * (cnt[i] + 1)) % mod;
    }
    cout << ans << endl;
    

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define lli long long int
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define test lli t;cin>>t;while(t--)
#define arrin lli n;cin>>n;lli a[n];for(lli i=0;i<n;i++)cin>>a[i]
#define floop for(lli i=0;i<n;i++)
#define mod 1000000007
#define defvec vector<lli>v
#define ub upper_bound
#define pb push_back
#define bs binary_search
using namespace std;
lli him(lli a[],lli n)
{
    lli i,j,count=0;
    for(i=0;i<n;i++)
    {
        for( j=0;j<i;j++)
        {
            if(a[i]==a[j])
            break;
        }
        if(i==j)
        count++;
    }
    return count;
}
int main()
{  
    lli a,b,c,d;
    cin>>a>>b>>c>>d;
    if(d<=a)
    cout<<d<<endl;
    else if(d<=(a+b))
    {
        cout<<a<<endl;
    }
    else
    {   if(c<=(d-a-b))
        cout<<a+(c)*(-1)<<endl;
        else
        cout<<a+((d-a-b))*(-1)<<endl;
    }
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define INT(a) scanf("%d",&a)
#define STR(a) scanf("%s",a)
#define DBL(a) scanf("%lf",&a)
#define LNG(a) scanf("%lld",&a)
#define PI acos(-1)
#define ff first
#define ss second
int b[100005], c[100005];
int main(){
	int n, m;
	cin>>n>>m;
	vector< int > num;
	for(int i=1;i<=n;i++){
		int a;
		cin>>a;
		num.push_back(a);
	}

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

	vector< pair< int, int > > query;
	for(int i=1;i<=m;i++){
		cin>>b[i]>>c[i];
		query.push_back({c[i], b[i]});
	}

	sort(query.rbegin(), query.rend());


	long long sum=0, j=0;
	for(int i=0;i<query.size();i++){
		long long val = query[i].ff;

		int pos = lower_bound(num.begin(), num.end(), val)-num.begin();

		if(pos>=j){
			int tmp =pos-j;
			tmp = min(tmp, query[i].ss);
			sum+=tmp*val;
			j+=tmp;
		}
	}

	sum=accumulate(num.begin()+j, num.end(), sum);

	cout<<sum<<endl;
	return 0;
}


Measured memory_bytes: 2296
while True:
    m, f, r = [int(i) for i in input().split()]
 
    if m == f == r == -1:
        break
 
    total = m + f
    if m == -1 or f == -1 or total < 30:
        print('F')
 
    elif total < 50 and r < 50:
        print('D')
 
    elif total < 65:
        print('C')
         
    elif total < 80:
        print('B')
 
    else:
        print('A')
        

Measured memory_bytes: 7712
import java.util.*;

public class Main {
    public static void main(final String[] args) {
        final Scanner sc = new Scanner(System.in);
        // 整数の入力
        // final int a = sc.nextInt();
        // 文字列の入力
        // final String s1 = sc.next();
        final String s = sc.next();
        final String t = sc.next();
        sc.close();
        String result = "No";

        if (t.length() == s.length() + 1 && t.substring(0, s.length()).equals(s)) {
            result = "Yes";
        }

        System.out.println(result);
    }
}


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

#define mem( arr, i ) fill( arr, arr + sizeof (arr), i )
#define MEM( arr, i ) memset( arr, i, sizeof (arr) )
#define Push push_back
#define Pair make_pair
typedef unsigned long long ull;
typedef long long lli;
typedef pair<int,int> pii;
typedef pair<lli,lli> pll;
typedef vector<int> vcI;
typedef vector<lli> vcL;
typedef vector<pii> vPI;
typedef vector<pll> vPL;
//typedef priority_queue<T> prior_S<T>;
//typedef priority_queue< T, vector<T>, greater<T> > prior_B<T>;
const double PI = 3.141592653589793;
const lli I_MAX = 1LL << 60;
const lli mod = 1000000007;

lli cnt = 0;

void Msort(vcL &A, lli x, lli y, vcL &T) {
	
	if ( y-x > 1 ) {
		lli m = (x+y)/2;
		lli p = x, q = m, i = x;
		
		Msort( A, x, m, T );
		Msort( A, m, y, T );
		
		while ( p < m or q < y ) {
			
			if ( q >= y or ( p < m and A[p] <= A[q] ) ) {
				T[ i++ ] = A[ p++ ];
			}
			else {
				T[ i++ ] = A[ q++ ];
				cnt += m-p;
			}
		}
		
		for (int i = x; i < y; ++i) A[i] = T[i];
	}
}

int main() {
	string s;
	while ( cin >> s ) {
		cnt = 0;
		
		lli sz = s.size();
		vcL num, tmp(200000);
		
		for (int i = 0; i < sz; ++i) {
			if ( s[i] == 'A' ) num.Push(2);
			else if ( i+1 < sz and s[i] == 'B' and s[ i+1 ] == 'C' ) ++i, num.Push(1);
			else {
//				for (auto x : num) cout << x; cout << '\n';
				Msort( num, 0, num.size(), tmp );
				num.clear();
				tmp.clear();
			}
			
			if ( !num.empty() and i == sz-1 ) {
				Msort( num, 0, num.size(), tmp );
				num.clear();
				tmp.clear();
			}
		}
		
		cout << cnt << '\n';
	}
	return 0;
}


Measured memory_bytes: 4216
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <utility>
#include <cstdio>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <cmath>
#include <set>
#include <map>
using ll = long long;
using itn = int;
using namespace std;
int main(){
    int d,g;
    cin >> d >> g;
    ll p[d],c[d];
    for(int i=0; i<d; i++){
        cin >> p[i] >> c[i];
    }
    int ans=1e9;
    for(int mask=0; mask<(1<<d); mask++){
        int res=0;
        int cnt=0;
        int rm=-1;
        for(int i=0; i<d; i++){
            if(1&(mask>>i)){
                res+=100*(i+1)*p[i]+c[i];
                cnt+=p[i];
                }else{
                    rm=i;
                }
            }
            if(res<g){
                int r=100*(rm+1);
                int nes=(g-res+r-1)/r;
                if(nes>=p[rm]){
                    continue;
                }
                cnt += nes;
            }
        ans=min(ans,cnt);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define F first
#define S second
const int A = 2e3;
const int mod = 1e9 + 7;

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int n;
    cin >> n;
    int a[n], b[n];
    bool done = 0;
    for (int i = 0; i < n; i++) {
        cin >> a[i] >> b[i];
        if (i > 1) {
            if (a[i] == b[i] && a[i - 1] == b[i - 1] && a[i - 2] == b[i - 2])
                done = 1;
        }
    }
    cout << (done ? "Yes" : "No");
    return 0;
}

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

#define INF 1e9
using namespace std;
typedef long long ll;

int main() {

    int a, b, c; cin >> a >> b >> c;

    for (int i = 1; i <= 10000; ++i) {
        if ((a * i) % b == c) {
            puts("YES");
            return 0;
        }
    }

    puts("NO");
}

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

if A==B==C:
    print('No')
else:
    if A==B:
        if B!=C:
            print('Yes')
    elif A==C:
        if C!=B:
            print('Yes')
    elif B==C:
        if C!=A:
            print('Yes')
    else:
        print('No')

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		// 天気予報の取得
		String yohou = sc.next();
		//天気の結果取得
		String result = sc.next();
		int count = 0;
		int j = 0;
		String a,b;
		//カウントする。
		for(int i = 0; i < 3; i++) {
			j= i;
			a = yohou.substring(i, i+1);
			b = result.substring(j, j+1);
			//System.out.println("YOHOU"+ i +"文字目：" + a);
			//System.out.println("RESULT"+ i +"文字目：" +b);

			if(a.equals(b)) {
				count++;
			}
		}
		// 出力
		System.out.println(count);
	}

}


Measured memory_bytes: 23124
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define mod 1000000007
using namespace std;
typedef long long ll;
template<class T> using V=vector<T>;
using Graph = vector<vector<int>>;
using P=pair<ll,ll>;
typedef unsigned long long ull;
typedef long double ldouble;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//V,P(大文字)使用不可
//乗算の際にオーバーフローに注意せよ！！（適切にmodをとれ）

const ll INF=1e18;

int a[5][5];

signed main(){
    rep(i,3){
        rep(j,3) cin>>a[i][j];
    }
    int n;
    cin>>n;
    V<int> b(n);
    cinf(n,b);
    int ans=0;
    bool ok=1;
    set<int> st;
    rep(i,n) st.insert(b[i]);
    rep(i,3){
        if(!st.count(a[i][1])) ok=0;
    }
    if(ok) ans++;
    ok=1;
    rep(i,3){
        if(!st.count(a[1][i])) ok=0;
    }
    if(ok) ans++;
    ok=1;
    rep(i,3){
        if(!st.count(a[i][0])) ok=0;
    }
    if(ok) ans++;
    ok=1;
    rep(i,3){
        if(!st.count(a[0][i])) ok=0;
    }
    if(ok) ans++;
    ok=1;
    rep(i,3){
        if(!st.count(a[i][2])) ok=0;
    }
    if(ok) ans++;
    ok=1;
    rep(i,3){
        if(!st.count(a[2][i])) ok=0;
    }
    if(ok) ans++;
    ok=1;
    if(st.count(a[0][0])&&st.count(a[1][1])&&st.count(a[2][2]))ok=1;
    else ok=0;
    if(ok) ans++;
    ok=1;
    if(st.count(a[0][2])&&st.count(a[1][1])&&st.count(a[2][0]))ok=1;
    else ok=0;
    if(ok) ans++;
    ok=1;
    if(ans>0) cout<<"Yes";
    else cout<<"No";
}

Measured memory_bytes: 256
def solve():
    w, h = [int(x) for x in input().split()]
    if w == h == 0:
        return False
    field = [[int(x) for x in input().split()] for _ in range(h)]

    ans = 0
    for x in range(w):
        for y in range(h):
            if field[y][x] > 0:
                stack = []
                mark(field, w, h, x, y, stack)
                while stack:
                    p, q = stack.pop()
                    mark(field, w, h, p, q, stack)
                    
                ans += 1
    print(ans)
    return True



def mark(field, w, h, x, y, stack):
    if x < 0 or x >= w or y < 0 or y >= h:
        return

    if field[y][x] != 1:
        return

    field[y][x] = -1

    stack.append((x+1, y+1))
    stack.append((x+1, y))
    stack.append((x+1, y-1))
    stack.append((x, y+1))
    stack.append((x, y))
    stack.append((x, y-1))
    stack.append((x-1, y+1))
    stack.append((x-1, y))
    stack.append((x-1, y-1))
    

while solve():
    pass

Measured memory_bytes: 8424
#include<bits/stdc++.h>
using namespace std;
#define f first
#define s second
#define ll long long
#define fl float
#define db double
#define ii pair<ll,ll>
#define pii pair<ii,ii>
#define ford(i,a,b) for(int i=a;i<=b;i++)
#define foru(i,a,b) for(int i=a;i>=b;i--)
#define forv(i,a,b) for(int i=a;i<b;i++)
#define oo 10000000000001
#define ooo -1000000000001
#define bost  ios_base::sync_with_stdio(false); cin.tie(0);
int n,p[35];
int res=0;
int main()
{
    bost
    cin>>n;
    ford(i,1,n) cin>>p[i];
    ford(i,2,n-1){
        if(p[i]>p[i-1] && p[i]<p[i+1]) res++;
        if(p[i]<p[i-1] && p[i]>p[i+1]) res++;
    }
    cout<<res;
    return 0;
}


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

int main(){
    int n; cin >> n;
    ll a, b; cin >> a >> b;
    ll c = a - b;
    vector<ll> h(n); rep(i,n) cin >> h[i];

    ll left = -1;
    ll right = 1002003004;
    while(abs(right-left) > 1){
        ll mid = (left+right)/2;
        ll cnt = 0;
        rep(i,n){
            cnt += max(0ll, ((h[i] - b*mid)+c-1)/c);
        }

        if(cnt > mid){
            left = mid;
        }
        else{
            right = mid;
        }
    }

    cout << right << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <set>
using namespace std;

int main() {
    set<int>one,last;
    int n,m;
    cin>>n>>m;
    for(int i=0; i<m; i++) {
        int a,b;
        cin>>a>>b;
        if(a==1)
            one.insert(b);
        if(b==n)
            last.insert(a);
    }
    for(int i:one) {
        if(last.find(i)!=last.end()) {
            cout<<"POSSIBLE"<<endl;
            return 0;
        }
    }
    cout<<"IMPOSSIBLE"<<endl;
    return 0;
}


Measured memory_bytes: 9600
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
	ll t,n;
  	cin >> t >> n;
  	vector<ll> v(n);
  	for(int i= 0; i < n; i++){cin >> v[i];}
  	long sum = accumulate(v.begin(),v.end(),0);
  	if(sum<=t) {cout<<t-sum;}
  else {cout<<-1;}
 return 0;
}


Measured memory_bytes: 3664
#include <iostream>
using namespace std;
int main(){
	int H,W;
	while(1){
	cin>>H>>W;
	if(H==0&&W==0){
			break;
	}
	for(int i=0;i<H;i++){
		for(int j=0;j<W;j++){
			if((i%2==0)&&(j%2==0)){
				cout<<"#";
			}
			else if(i%2!=0&&j%2!=0){
				cout<<"#";
			}
			else{
				cout<<".";
			}

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

Measured memory_bytes: 1156
import java.util.Scanner;

public class Main 
{
	static Scanner scan = new Scanner(System.in);
	
	static int decrypt(String s)
	{
		int val = 0;
		
		int pos = s.indexOf('m');
		if(pos == 0)
		{
			val += 1000;
			s = s.substring(pos+1);
		}
		else if(pos > 0)
		{
			val += Integer.parseInt(s.substring(0, pos))*1000;
			s = s.substring(pos+1);
		}
		
		pos = s.indexOf('c');
		if(pos == 0)
		{
			val += 100;
			s = s.substring(pos+1);
		}
		else if(pos > 0)
		{
			val += Integer.parseInt(s.substring(0, pos))*100;
			s = s.substring(pos+1);
		}
		
		pos = s.indexOf('x');
		if(pos == 0)
		{
			val += 10;
			s = s.substring(pos+1);
		}
		else if(pos > 0)
		{
			val += Integer.parseInt(s.substring(0, pos))*10;
			s = s.substring(pos+1);
		}
		
		pos = s.indexOf('i');
		if(pos == 0)
		{
			val += 1;
			s = s.substring(pos+1);
		}
		else if(pos > 0)
		{
			val += Integer.parseInt(s.substring(0, pos))*1;
			s = s.substring(pos+1);
		}
		
		return val;
	}
	
	public static void main(String[] args) 
	{
		int n = scan.nextInt();
		
		for(int i = 0; i < n; i++)
		{

			
			String s1 = scan.next();
			
			String s2 = scan.next();
			
			int val = decrypt(s1)+decrypt(s2);
			
			String ans = "";
			
			if(val >= 1000)
			{
				int div = val/1000;
				if(div > 1)
				{
					ans += div;
				}
				ans += "m";
				
				val = val%1000;
			}
			
			if(val >= 100)
			{
				int div = val/100;
				if(div > 1)
				{
					ans += div;
				}
				ans += "c";
				
				val = val%100;
			}
			
			if(val >= 10)
			{
				int div = val/10;
				if(div > 1)
				{
					ans += div;
				}
				ans += "x";
				
				val = val%10;
			}
			
			if(val >= 1)
			{
				int div = val/1;
				if(div > 1)
				{
					ans += div;
				}
				ans += "i";
				
				val = val%1;
			}
			
			System.out.println(ans);
		}
	}

}



Measured memory_bytes: 39716
#include<bits/stdc++.h>
using namespace std;
const int N = 510;
int n,m;
char g[N],r[N][N],b[N][N];
int main()
{
	scanf("%d%d", &n, &m);
	for(int i = 1; i <= n; ++i)
		for(int j = 1; j <= m; ++j)
			r[i][j] = b[i][j] = '.';
	for(int i = 1; i <= n; i += 2)
		for(int j = 2; j < m; ++j)
			r[i][j] = '#';
	for(int i = 2; i <= n; i += 2)
		for(int j = 2; j < m; ++j)
			b[i][j] = '#';
	for(int i = 1; i <= n; ++i)
	{
		scanf("%s", g + 1);
		for(int j = 1; j <= m; ++j)
			if(g[j] == '#')
				r[i][j] = b[i][j] = '#';
	}
	for(int i = 1; i <= n; ++i)
	{
		r[i][1] = '#';
		b[i][m] = '#';
	}
	for(int i = 1; i <= n; ++i)
	{
		for(int j = 1; j <= m; ++j)
			printf("%c", r[i][j]);
		puts("");
	}
	puts("");
	for(int i = 1; i <= n; ++i)
	{
		for(int j = 1; j <= m; ++j)
			printf("%c", b[i][j]);
		puts("");
	}
	return 0;
}


Measured memory_bytes: 1280
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
#define int long
#define ll long long
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define SZ(x) x.size()
#define fi first
#define se second
const int INF = 1e9;
using namespace std;

template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;

using pi=pair<int,int>;
using vi=vc<int>;

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(20);

    int N; cin >> N;
    string S,T; cin >> S >> T;
    rep(i,N){
        cout << S[i] << T[i];
    }
    cout << endl;
}

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

using namespace std;
typedef long long ll;


#define SIZE 101
#define INF 1000000000
#define LLINF 1000000000000000000LL

ll n2[32] = {1};

int calc(int s,int d){
  int ans = 0;
  
  if(s <= 0 && 0 <= d){
    ans = __builtin_popcount(abs(s)) + __builtin_popcount(abs(d));
  }else{
    int base = 0;
    
    for(int i=0;i<32;i++){
      if(d-s < n2[i]){
	
	if(d <= 0){
	  while(base > d) base-=n2[i-1];
	}else{
	  while(base < s) base+=n2[i-1];
	}

	break;
      }
    }
    
    d -= base;
    s -= base;

    ans = __builtin_popcount(abs(s)) + __builtin_popcount(abs(d));
  }

  return ans;
}

int main(){
  int s,d;
  int n;
  
  for(int i=0;i<31;i++) n2[i+1] = n2[i]*2;

  scanf("%d",&n);
  
  for(int i=0;i<n;i++){
    scanf("%d%d",&s,&d);

    printf("%d\n",calc(s,d));
  }
  
  return 0;
}

Measured memory_bytes: 1176
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
    return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
    return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
  ns = []
  while len(ns) < rantime:
    n = random.randint(ran1, ran2)
    if not n in ns:
      ns.append(n)
  return sorted(ns)

def rand_query(ran1, ran2, rantime):
  r_query = []
  while len(r_query) < rantime:
    n_q = rand_ints_nodup(ran1, ran2, 2)
    if not n_q in r_query:
      r_query.append(n_q)
  return sorted(r_query)

from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
import heapq
import math
from fractions import gcd
import random
import string
import copy
from itertools import combinations, permutations, product
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 998244353


#############
# Main Code #
#############

K = getN()
N = 50
ans = [49 + K // N] * N

for i in range(K % N):
    ans[i] += 1

# あまりの分を引いてる最中にも残りの分は増えていくので
for j in range(K % N, N):
    ans[j] -= K%N

print(N)
print(*ans)

Measured memory_bytes: 83316
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <string>
#include <cmath>
#include <limits>
#include <algorithm>
#include <memory>
#include <climits>
#include <iomanip>

constexpr long long MOD = 1000000007;

int main()
{
  int N, K;
  std::cin >> N >> K;
  double ans = 0;
  for (int i = 1; i <= std::min(K - 1, N); ++i)
  {
    int n = i;
    int cnt = 0;
    while (n < K)
    {
      n *= 2;
      ++cnt;
    }
    ans += (1.0 / (std::pow(2.0, (double)cnt) * (double)N));
  }
  ans += (K <= N ? (double)(N - K + 1) / (double)N : 0);
  std::cout << std::setprecision(12) << ans << std::endl;
  return 0;
}



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


int main() {
	double A, B, C, D, E, F;
	cin >> A >> B >> C >> D >> E >> F;

	vector<double> x, y;
	for (int i = 0; i <= F; i++) {
		for (int j = 0; j <= F; j++) {
			double tx = 100 * A*i + 100 * B*j;
			double ty = C*i + D*j;
			if (tx <= F) {
				x.push_back(tx);
			}
			if (ty <= F) {
				y.push_back(ty);
			}
		}
	}

	double Ma=-1e5; int ans1=0, ans2=0;
	for (int i = 0; i < x.size(); i++) {
		for (int j = 0; j < y.size(); j++) {
			if (((double)E / 100 >= (double)y[j] / x[i]) && (x[i]+y[j])<=F) {
				double nodo = 100.0*y[j] / (x[i]+y[j]);
				if (Ma < nodo) {
					Ma = nodo;
					ans1 = x[i]+y[j];
					ans2 = y[j];
				}
			}
		}
	}

	cout << ans1 <<" "<< ans2 << endl;
}

Measured memory_bytes: 2420
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define ll long long
#define ld long double
using namespace std;
const int N = 1e5 + 5;
ll n, k, x;
vector<ll>pos, neg;
int main()
{
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin >> n >> k;
    for(int i = 0; i < n; i++){
        cin >> x;
        if(x > -1)
            pos.push_back(x);
        else
            neg.push_back(x);
    }
    reverse(neg.begin(), neg.end());
    ll ans = 2e18;
    for(int i = 0; i <= k; i++){
        ll l = i, r = k - i, cnt = 0;
        if(neg.size() < l || pos.size() < r)
            continue;
        if(!l) ans = min(ans, pos[r - 1]);
        else if(!r) ans = min(ans, abs(neg[l - 1]));
        else{
            int mn = min(-neg[l - 1], pos[r - 1]), mx = max(-neg[l - 1], pos[r - 1]);
            ans = min(ans, 2ll * mn + mx);
        }
    }
    for(int i = 0; i <= k; i++){
        ll l = k - i, r = i, cnt = 0;
        if(neg.size() < l || pos.size() < r)
            continue;
        if(!l) ans = min(ans, pos[r - 1]);
        else if(!r) ans = min(ans, abs(neg[l - 1]));
        else{
            int mn = min(-neg[l - 1], pos[r - 1]), mx = max(-neg[l - 1], pos[r - 1]);
            ans = min(ans, 2ll * mn + mx);
        }
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 1656
#include <iostream>
using namespace std;
int main()
{
  int n, a;
  cin >> n >> a;
  int ans = 0;
  ans = n % 500;

  if (ans <= a)
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <cctype>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <string>
#include <functional>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <bitset>
#define pb push_back 
#define YES cout<<"YES"<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define No cout<<"No"<<endl
#define INF (1<<30)
#define MOD 1000000007
using ll = long long;
using namespace std;

int main() {
    int w;
    string s;
    cin >> s >> w;
    for (int i = 0; i < s.length(); i++) {
        if (i%w == 0)cout << s[i];
    }
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
#include <fstream>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;cin>>N;
  ll ans=1e18;
  ll sum=0;
  FOR(i,0,N){
    ll A,B;
    cin>>A>>B;
    if(A>B)ans=min(ans,B);
    sum+=A;
  }
  cout<<(ans==1e18?0:sum-ans)<<endl;
  return 0;
}

Measured memory_bytes: 256