akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <vector>

using namespace std;

#define whole(xs) (xs).begin(),(xs).end()

vector< vector<int> > G1, G2;
int V;
vector<bool> used;
void init() {
    G1.clear(); G1.resize(V);
    G2.clear(); G2.resize(V);
    used.clear(); used.resize(V);
}
void addEdge(int from, int to) {
    G1[from].push_back(to);
    G2[to].push_back(from);
}
vector<int> vs;
void dfs1(int v) {
    used[v] = true;
    for (int i = 0; i < G1[v].size(); i++) {
        if (!used[ G1[v][i] ]) dfs1(G1[v][i]);
    }
    vs.push_back(v);
}
void dfs2(int v, int k, vector<int>& order) {
    used[v] = true;
    order[v] = k;
    for (int i = 0; i < G2[v].size(); i++) {
        if (!used[ G2[v][i] ]) dfs2(G2[v][i], k, order);
    }
}
int solve(vector<int>& ord) {
    fill(whole(used), false);
    vs.clear();
    for (int v = 0; v < V; v++) {
        if (!used[v]) dfs1(v);
    }
    fill(whole(used), false);
    int k = 0;
    ord.clear(); ord.resize(V, -1);
    for (int i = vs.size() - 1; i >= 0; i--) {
        if (!used[vs[i]]) dfs2(vs[i], k++, ord);
    }
    return k;
}

int main() {
    int E;
    scanf("%d %d\n", &V, &E);
    init();
    for (int i = 0; i < E; i++) {
        int s, t; scanf("%d %d\n", &s, &t);
        addEdge(s, t);
    }
    vector<int> ord;
    int k = solve(ord);
    printf("%d\n", k != V);
    return 0;
}

Measured memory_bytes: 1088
#include <stdio.h>
int main() {
	int H,W,i,j;

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


Measured memory_bytes: 2612
import math
n,m = [int(x) for x in input().split()]

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

if n > 1 and m > 1:
    print(combinations_count(n, 2) + combinations_count(m, 2))
elif n > 1:
    print(combinations_count(n, 2))
elif m > 1:
    print(combinations_count(m, 2))
else:
    print(0)

Measured memory_bytes: 3060
fun main(args: Array<String>){
    val (s,t) = readLine()!!.split(" ")
    var (a,b) = readLine()!!.split(" ").map(String::toInt)
    val u = readLine()!!

    if (s == u){
        a -= 1
    }
    else{
        b -= 1
    }
    println("$a $b")
}

Measured memory_bytes: 36304
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b, c, d, e, k;
  cin >> a >> b >> c >> d >> e >> k;
  
  if(e - a <= k){
    cout << "Yay!" << endl;
  }
  else{
    cout << ":(" << endl;
  }
}

Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

#define mod 1000000007

int main () {
    string s = "";
    cin >> s;
    long long k = 0;
    cin >> k;
    for (int i=0; i<s.size(); i++) {
        if (i+1 == k) {
            cout << s.at(i) << endl;
            break;
        }
        if (s.at(i) == '1') continue;
        else {
            cout << s.at(i) << endl;
            break;
        }
    }
    return 0;
}


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

string S;
queue<pair<string, int>>Q;
vector<string>X;
char T[27] = "abcdefghijklmnopqrstuvwxyz";

int main() {
	while (true) {
		X.clear();
		cin >> S;
		if (S == "#") { break; }
		Q.push(make_pair(S, 25));
		while (!Q.empty())
		{
			pair<string, int>pa = Q.front();
			string U = pa.first; int b = pa.second;
			if (b == 0) {
				break;
			}
			Q.pop();
			char target = T[b - 1], t2 = T[b];

			for (int i = 0; i < U.size(); i++) {
				if (U[i] == t2) {
					goto E;
				}
				if (U[i] == target) {
					string W = U.substr(0, i);
					W += t2;
					W += U.substr(i + 1, U.size() - (i + 1));
					Q.push(make_pair(W, b - 1));
				}
			}
			Q.push(make_pair(U, b - 1));
		E:;
		}
		int cnt = 0;
		while (!Q.empty()) {
			pair<string, int>pa2 = Q.front(); Q.pop();
			X.push_back(pa2.first);
			cnt++;
		}
		sort(X.begin(), X.end());
		cout << cnt << endl;
		if (cnt <= 10) {
			for (int i = 0; i < X.size(); i++) {
				cout << X[i] << endl;
			}
		}
		else {
			for (int i = 0; i < 5; i++) {
				cout << X[i] << endl;
			}
			for(int i = cnt - 5; i < cnt; i++) {
				cout << X[i] << endl;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 4708
#include <iostream>
#include <algorithm>
#include <string>
#include <functional>
#include <math.h>
using namespace std;

int main() {
	string s, t;
	cin >> s >> t;
	sort(s.begin(), s.end());
	sort(t.begin(), t.end());
	reverse(t.begin(), t.end());
	if (s < t) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
(let* ((n (read))
       (m (read))
       (c (make-array `(,(1+ n)) :initial-element 1))
       (ans (make-array `(,(1+ n)) :initial-element nil)))
  (setf (aref ans 1) t)
  (loop :for i :from 1 :to m
        ;:do (format t "~A~%" ans)
        ;:do (format t "~A~%" c)
        :do (let ((x (read))
                  (y (read)))
              (decf (aref c x))
              (incf (aref c y))
              (when (aref ans x)
                (setf (aref ans y) t)
                (when (= (aref c x) 0)
                  (setf (aref ans x) nil)))))
  ;(format t "~A~%" ans)
  ;(format t "~A~%" c)
  (format t "~A~%" (loop :for i :from 1 :to n
                         :sum (if (aref ans i) 1 0))))


Measured memory_bytes: 78704
#include<bits/stdc++.h>
using namespace std;
#define max(a,b) (a<b?b:a)
#define abs(x) (x<0?(-x):x)
#define F(i,L,R) for (int i = L; i < R; i++)
#define FE(i,L,R) for (int i = L; i <= R; i++)
#define RF(i,L,R) for (int i = L; i > R; i--)
#define RFE(i,L,R) for (int i = L; i >= R; i--)
#define getI(a) scanf("%d", &a)
#define getII(a,b) scanf("%d%d", &a, &b)
#define getIII(a,b,c) scanf("%d%d%d", &a, &b, &c)
#define VgetI(n) int (n); scanf("%d",&(n))
#define VgetII(n,m) int (n),(m); scanf("%d %d",&(n),&(m))
#define VgetIII(n,m,k) int (n),(m),(k); scanf("%d %d %d",&(n),&(m),&(k))
#define ll long long
#define INF 1000000000000000005
#define nINF -2000000000
#define MOD 1e9+7
#define PI 3.1415926535897932384626
int main(){
	char in[200005];
	while(~scanf("%s",in)){
		int l=strlen(in);
                ll ans=0;
		ll dp[l+5];
		if(in[0]=='B') dp[0]=1;
		else dp[0]=0;
		F(i,1,l){
			if(in[i]=='B') dp[i]=dp[i-1]+1;
			else{
				dp[i]=dp[i-1];
				ans+=dp[i];
			}
		}
		printf("%lld\n",ans);
	}
}

Measured memory_bytes: 2048
#include <bits/stdc++.h>
#include <numeric>
using namespace std;
using ll = long long;

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

    string S;
    cin >> S;
    if (S[0] == S[1]) {
        cout << "Bad" << endl;
    }
    else if (S[1] == S[2]) {
        cout << "Bad" << endl;
    }
    else if (S[2] == S[3]) {
        cout << "Bad" << endl;
    }
    else {
        cout << "Good" << endl;
    }
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	char szInput[1200] = { 0 };		// 入力文字列
	int aiCountLetter[26] = { 0 };	// 各文字数のカウンタ
	char* pchInputLetter = szInput;	// 入力されたある1文字へのポインタ
	int iCount;						// ループカウンタ

	// 各文字の出現回数をカウントする
	while (1)
	{
		// 1行分の入力を受け取る
		pchInputLetter = fgets(szInput, sizeof(szInput), stdin);
		if (pchInputLetter == NULL) break;

		while (*pchInputLetter != '\n')
		{
			// 文字を小文字に置き換える
			if ('A' <= *pchInputLetter && *pchInputLetter <= 'Z')
			{
				*pchInputLetter = 'a' + (*pchInputLetter - 'A');
			}

			// アルファベットならばカウントする
			if ('a' <= *pchInputLetter && *pchInputLetter <= 'z')
			{
				aiCountLetter[*pchInputLetter - 'a']++;
			}

			// ポインタを次の文字につけかえる
			pchInputLetter++;
		}
	}

	// 各文字の出現回数を出力する
	for (iCount = 0; iCount < 26; iCount++)
	{
		printf("%c : %d\n", 'a' + iCount, aiCountLetter[iCount]);
	}
	
	return 0;
}


Measured memory_bytes: 2032
#include<cstdlib>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
#include<cstring>
#include<cmath>
using namespace std;
const int MAXN = (int) 5e5 + 10;
const int INF = (int) 0x3f3f3f3f;
typedef long long LL;

int N;
string s;
set<string> st;

void work(){
    scanf("%d",&N);
    while(N--){
        cin>>s;
        st.clear();
        int len=s.size();
        for(int i=0;i<=len;i++){
            string pre1,pre2;
            string suf1,suf2;
            for(int j=0;j<i;j++) pre1+=s[j],pre2+=s[i-j-1];
            for(int j=0;i+j<len;j++) suf1+=s[i+j],suf2+=s[len-j-1];
//            cout<<"-"+pre1+"-"<<" "<<"-"+pre2+"-"<<" "<<"-"+suf1+"-"<<" "<<"-"+suf2+"-"<<endl;
            st.insert(pre1+suf1);
            st.insert(pre1+suf2);
            st.insert(pre2+suf1);
            st.insert(pre2+suf2);
            st.insert(suf1+pre1);
            st.insert(suf1+pre2);
            st.insert(suf2+pre1);
            st.insert(suf2+pre2);
        }
        printf("%d\n",st.size());
    }
}

int main(){
#ifdef NNever
//    freopen("data.in","r",stdin);
//    freopen("out.txt","w",stdout);
#endif // NNever
    work();
    return 0;
}




Measured memory_bytes: 3404
typedef long long ll;
#include <bits/stdc++.h>
using namespace std;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main() {
    ll n,m;
    ll a[100010];
    ll sum[100010];
    // ll count[1000000010];
    sum[0] = 0; 
    // count[sum[0]]++;
    unordered_map<ll,ll> count;
    count[sum[0]]++;
    std::cin >> n >> m;
    for (int i = 0; i < n; i++) {
        std::cin >> a[i];
        a[i] %= m;
        sum[i+1] = a[i] + sum[i];
        sum[i+1] %= m;
        count[sum[i+1]]++;
    }
    ll result = 0;
    for(auto itr = count.begin(); itr != count.end(); ++itr) {
        ll key = itr->first;
        ll value = itr->second;
        if(value>1){
            result += value * (value-1) /2;
        }
    }
    
    std::cout << result << std::endl;
}


Measured memory_bytes: 4772
n,k = list(map(int,input().split()))
p = list(map(int,input().split()))

d = []
d.append(sum(p[0:k]))

for i in range(1,n + 1 - k) :
    d.append(d[i-1] + p[i + k -1] - p[i-1])

md = d.index(max(d))

print(sum([ (1/2 *( i * (i + 1)))/ i for i in p[md:md + k]]))

Measured memory_bytes: 25060
using System;
using System.Collections.Generic;
class Program
    {
    	static void Main(string[] args)
    	{
    		int n = int.Parse(Console.ReadLine());
            long[] x = new long[n], y = new long[n];
            for (int i=0; i<n; i++)
            {
                string[] pos = Console.ReadLine().Split(' ');
                x[i] = int.Parse(pos[0]);
                y[i] = int.Parse(pos[1]);
            }
            for (int i=0; i<n; i++)
            {
                long[] v1 = new long[] {x[i] - x[(i+1)%n], y[i] - y[(i+1)%n]};
                double max = 0, min = 0;
                for (int j=2; j<n; j++)
                {
                    long[] v2 = new long[] {x[i] - x[(i+j)%n], y[i] - y[(i+j)%n]};
                    double theta = Math.Acos((v1[0] * v2[0] + v1[1] * v2[1]) 
                    / (Math.Sqrt(v1[0] * v1[0] + v1[1] * v1[1]) * Math.Sqrt(v2[0] * v2[0] + v2[1] * v2[1])));
                    if (v1[0] * v2[1] - v1[1] * v2[0] < 0) theta *= -1;
                    //Console.Error.WriteLine(v1[0] + " " + v1[1] + " " + v2[0] + " " + v2[1] + " " + theta);
                    if (theta > max) max = theta;
                    if (theta < min) min = theta;
                }
                if (max - min > Math.PI * 0.99999) Console.WriteLine(0);
                else Console.WriteLine((Math.PI - max + min) / (2 * Math.PI));
            }
        }
    }
    //mcs Main.cs
    //mono Main.exe


Measured memory_bytes: 13140
n,k=map(int,input().split())
a=list(map(int,input().split()))
ok=10**10
ng=1
for i in range(40):
    chk=(ok+ng)//2
    cnt=0
    for j in range(n):
        cnt+=(a[j]+chk-1)//chk-1
    if cnt > k:
        ng = chk
    else:
        ok = chk
print(ok)


Measured memory_bytes: 30812
#include <bits/stdc++.h>
#define ll long long int
#define MOD1		1000000007
#define MOD2		998244353
#define BOOST		ios_base::sync_with_stdio(false); cin.tie(NULL)

using namespace std;


int main()
{
    ll n, m;
    cin >> n >> m;
    vector<ll> v(n);
    ll cum = 0;
    for(auto &i : v) {
        cin >> i;
        cum += i;
    }
    ll ans = 0;
    for(auto &i: v)
    {
        if(i >= 0.25*cum/m)
            ans++;
    }
    if(ans >= m)
        cout << "Yes\n";
    else
        cout << "No\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;

//const int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
//const int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main()
{
	int n, k;
	cin >> n >> k;
	ll ans = k;

	REP(i, n - 1){
		ans *= (k-1);
	}

	cout << ans << endl;
}


Measured memory_bytes: 256
//khodaya khodet komak kon
#include <bits/stdc++.h>

#define F first
#define S second
#define pb push_back
#define all(x) x.begin(), x.end()
#pragma GCC optimise ("ofast")
#pragma GCC optimise("unroll-loops")

using namespace std;

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

const int N = 200000 + 10;
const ll MOD = 1000000000 + 7;
const ll INF = 1000000010;
const ll LOG = 25;

int n, L[N], R[N], mx[N];
string A, B;
int mark[N];
vector<int> buc[N];

bool cmp(int x, int y){
	return L[x] < L[y];
}

int main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> A >> B;
	n = (int)A.size();
	int cnt = 0, cnt1 = 0;
	for (auto u:A) cnt += (u == '1');
	for (auto u:B) cnt1 += (u == '1');
	if (cnt1 == 0 && cnt > 0) return cout << -1, 0;
	if (cnt1 == 0 && cnt == 0) return cout << 0, 0;
	for (int i = 0; i < n; i++){
		bool f = 0;
		int pnt = i;
		int cnt = 0;
		while (!f){
			if (B[pnt] == '1') R[i] = cnt, f = 1;
			else pnt++, pnt %= n, cnt++;	
		}
		pnt = i;
		f = 0;
		cnt = 0;
		while (!f){
			if (B[pnt] == '1') L[i] = cnt, f = 1, buc[cnt].pb(i);
			else pnt--, pnt %= n, pnt += n, pnt %= n, cnt++;
		}	
		//cout << L[i] << ' ' << R[i] << '\n';
	}
	int ans = INF;
  	//cout << n << '\n';
	for (int i = -n; i <= n; i++){
		vector<int> khar;
		memset(mark, 0, sizeof mark);
	//	cout << i << ":\n";
      	for (int j = 0; j < n; j++){
			int ki = j + i;
			ki %= n, ki += n, ki %= n;
          	//cout << j << ' ' << ki << '\n';
			if (B[ki] != A[j]) mark[j] = 1;			
		}
		for (int j = 0; j <= n; j++){
			for (auto u:buc[j]){
				if (mark[u]) khar.pb(u);
			}
		}
 		 //for (auto u:khar) cout << u << '\n';
	//	sort(all(khar), cmp);
		mx[khar.size()] = 0;
		for (int j = khar.size() - 1; j >= 0; j--){
			mx[j] = max(mx[j + 1], R[khar[j]]);
          	//cout << khar[j] << ' ' << mx[j] << '\n';
		}
		int pnt = 0;
		int res = INF;
		for (int j = 0; j <= n; j++){
			while (pnt != khar.size() && L[khar[pnt]] <= j) pnt++;
			int Mx = mx[pnt];
		//	cout << Mx << '\n';
			res = min(res, min(j + Mx + j + abs(Mx - i), Mx + Mx + j + abs(i + j))); 
 		}
 		res += khar.size();
 		ans = min(ans, res);
	}
	cout << ans;











	return 0;
}


Measured memory_bytes: 6528
package main

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

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, initialBufSize), maxBufSize)
	defer wt.Flush()

	h, w := nextInt(), nextInt()
	a := make([]string, h)
	for i := 0; i < h; i++ {
		a[i] = next()
	}

	ok := true
	for i := 1; i < h; i++ {
		for j := 1; j < w; j++ {
			if a[i][j-1] == '#' && a[i-1][j] == '#' {
				ok = false
			}
		}
	}

	if ok {
		puts("Possible")
	} else {
		puts("Impossible")
	}
}

const (
	initialBufSize = 100000
	maxBufSize     = 10000000
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wt = bufio.NewWriter(os.Stdout)
)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}


Measured memory_bytes: 640
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String s = sc.nextLine();
		char c;
		for(int i = 0;i < s.length();++i){
			c = s.charAt(i);
			if(c <= 67){
				c+=23;
			}else{
				c-=3;
			}
			System.out.print(Character.toString(c));
		}
                System.out.println("");

	}
}

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

#define int long long

int N;
vector<int> A, B;

int calc(int b) {
  int ret = 0;
  for (int i = 1; i <= N; i++) {
    ret += abs(A[i-1] - (b + i));
  }
  return ret;
}

signed main() {
  cin >> N;
  A.resize(N);
  B.resize(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    B[i] = A[i] - (i + 1);
  }

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

  cout << calc(B[N/2]) << endl;

  return 0;
}

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

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

using ll = long long;

const ll MOD = 1000000007;

/*
expr   ::= term | expr sp ">>" sp term
term   ::= number | "S" sp "<" sp expr sp ">"
sp     ::= "" | sp " "
number ::= digit | number digit
digit  ::= "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9"
*/

string s;
int it;

int dfs_expr();
int dfs_term();
int dfs_sp();

int dfs_expr(){
	// printf("expr(%d)\n",it);
	int t = dfs_term();
	dfs_sp();
	if(it>=1 && s[it]=='>' && s[it-1]=='>'){
		it-=2;
		dfs_sp();
		int e = dfs_expr();
		// printf("expr ret %d = %d>>%d\n",t>>e,t,e);
		if(t>=30)return 0;
		return e>>t;
	}else{
		// printf("expr ret %d\n",t);
		return t;
	}
}
int dfs_term(){
	// printf("term(%d)\n",it);
	if(s[it]=='>'){
		it--;	// >
		dfs_sp();
		int e = dfs_expr();
		dfs_sp();
		it--;	// <
		dfs_sp();
		it--;	// S
		// printf("term ret %d = %d*%d\n",(int)(1ll*e*e%MOD),e,e);
		return 1ll*e*e%MOD;
	}else{
		int ret = 0;
		int b = 1;
		while(it>=0 && isdigit(s[it])){
			ret += (s[it]-'0') * b;
			it--;
			b *= 10;
		}
		// printf("term ret %d\n",ret);
		return ret;
	}
}
int dfs_sp(){
	while(it>=0 && s[it]==' ')it--;
	return 0;
}

int main(){
	while(true){
		getline(cin,s);
		if(s=="#")break;
		it = s.size() - 1;
		int ans = dfs_expr();
		printf("%d\n",ans);
	}
	return 0;
}



Measured memory_bytes: 5432
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)

	n, k := nextInt(), nextInt()
	sum := 0

	for b := 1; b <= n; b++ {
		sum += max(0, b-k)*(n/b) + max(0, n%b+1-k)
	}
	if k == 0 {
		sum = n * n
	}

	fmt.Println(sum)
}

func max(a, b int) int {
	if a < b {
		return b
	}
	return a
}


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

public class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader reader =
                new BufferedReader(new InputStreamReader(System.in));
        while (true) {
            String input = reader.readLine();
            if (input == null || input.equals("0")) {
                break;
            }
            long value = Long.parseLong(input);
            int count = 0;
            for (long i = 5; i <= value; i *= 5) {
                count += value / i;
            }
            System.out.println(count);
        }
    }
}

Measured memory_bytes: 9372
function main(input) {
  const inputs = input.split('\n')
  const [N, M] = inputs[0].split(' ').map(Number)
  const Ai = inputs[1].split(' ').map(Number)
  const sum = Ai.reduce((h, e) => { return h + e }, 0)
  console.log(N - sum < 0 ? -1 : N - sum)
  
}
main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

// ----------- define --------------
#define int long long
#define vi vector<int>
#define vc vector<char>
#define ii pair<int,int>
#define fi first
#define sc second
#define stoi stoll
#define all(x) (x).begin(),(x).end()
#define get_bit(x, k) ((x >> k) & 1)
// ---------------------------------

void MAIN() {
  int n, c;
  cin >> n >> c;
  const int V = 100000;
  vector<int> v(V + 2);
  for (int i = 1; i <= n; i++) {
    int x, y, t;
    cin >> x >> y >> t;
    v[x]++;
    v[y + 1]--;
  }
  int ans = 0;
  for (int i = 1; i <= V; i++) {
    v[i] += v[i - 1];
    ans = max(ans, v[i]);
  }
  ans = min(ans, c);
  cout << ans << '\n';
}

signed main() {
  ios::sync_with_stdio(0); cin.tie(0);
  int T = 1;
  // cin >> T;
  while (T--) MAIN();
}


Measured memory_bytes: 3956
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false), cin.tie(0)
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define ALL(x) (x).begin(), (x).end()
#define dump(x) cout << (x) << endl
#define LMAX 9223372036854775807LL
#define LMIN -9223372036854775807LL
using ll = long long;
template<typename T>
using vec = vector<T>;
using P = pair<ll, ll>;
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
	fill((T *)array, (T *)(array + N), val);
}

const ll INF = 1e16;
const ll MOD = 1e9 + 7;
//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//ll pas[51][52];

ll mod(double a, double b){
	return a - floor(a / b) * b;
}

int main(){
	IOS;
	ll n, m;
	cin >> n >> m;
	vec<ll> x(n), y(m);
	REP(i, n)cin >> x[i];
	REP(i, m)cin >> y[i];
	ll sumx = 0;
	ll sumy = 0;
	REP(i, n){
		sumx -= (n - i - 1) * x[i];
		sumx = mod(sumx,MOD);
		sumx += i * x[i];
		sumx = mod(sumx,MOD);
	}
	REP(i, m){
		sumy -= (m - i - 1) * y[i];
		sumy = mod(sumy,MOD);
		sumy += i * y[i];
		sumy = mod(sumy,MOD);
	}
	dump((sumx * sumy) % MOD);
}

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

// 2 で割り切れる回数を返す
int f(int x) {
 int res = 0;
 while (x % 2 == 0) {
   x /= 2;
   res++;
 }
 return res;
}

// 最大公約数を返す
long long gcd(long long a, long long b) {
 if (b == 0) {
   return a;
 }
 return gcd(b, a % b);
}

// 最小公倍数を返す
long long lcm(long long a, long long b) {
 return a / gcd(a, b) * b;
}

int main() {

 int N, M;
 cin >> N >> M;

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

 // 入力を 2 で割る
 for (int i = 0; i < N; i++) {
   if (a[i] % 2 == 1) {
     cout << 0 << endl;
     return 0;
   }
   a[i] /= 2;
 }

 // 2 で割り切れる回数が a[0] から a[N - 1] まで、全部同じじゃないとダメ
 // 同じ場合は、2^t で割る
 int t = f(a[0]);
 for (int i = 0; i < N; i++) {
   if (f(a[i]) != t) {
     cout << 0 << endl;
     return 0;
   }
   // a[i] /= 2^t
   a[i] >>= t;
 }

 // M /= 2^t
 M >>= t;

 // 2^t で割った a[0] から a[N - 1] までの lcm を求める。
 // lcm が M を超えるとダメ
 long long lcm_ = 1;
 for (int i = 0; i < N; i++) {
   lcm_ = lcm(lcm_, a[i]);
   if (M < lcm_) {
     cout << 0 << endl;
     return 0;
   }
 }

 // 2^t で割った M = lcm * answer を満たす必要があり、
 // answer は奇数じゃないとダメなので、奇数の個数が答えになる
 M /= lcm_;
 int answer = (M + 1) / 2;
 
 cout << answer << endl;
 
 return 0;

}


Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;

namespace atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var nm = Console.ReadLine().Split(' ').Select(num => int.Parse(num)).ToArray();
            var n = nm[0];
            var m = nm[1];

            var array = new(int P, int C) [m];
            var dic = new Dictionary < (int P, int C),
                string > ();

            for (var i = 0; i < m; i++)
            {
                var py = Console.ReadLine().Split(' ').Select(num => int.Parse(num)).ToArray();
                var tpl = (py[0], py[1]);
                array[i] = tpl;
            }
            var tmpArray = array.OrderBy(tpl => tpl.P).ThenBy(tpl => tpl.C).ToArray();

            var pCnt = 0;
            var pCode = "";
            var cCodeMemo = new Dictionary<int, string>();
            for (var i = 0; i < m; i++)
            {
                var tpl = tmpArray[i];
                if (i == 0 || tmpArray[i - 1].P != tpl.P)
                {
                    pCnt = 1;
                    pCode = GetCode(tpl.P);
                }
                else { pCnt++; }

                if (cCodeMemo.TryGetValue(pCnt, out var code))
                {
                    dic.Add(tpl, pCode + code);
                }
                else
                {
                    var cCode = GetCode(pCnt);
                    dic.Add(tpl, pCode + cCode);
                }
            }

            foreach (var tpl in array)
            {
                Console.WriteLine(dic[tpl]);
            }

            string GetCode(int num)
            {
                var d = (int) Math.Log10(num) + 1;
                return new string('0', 6 - d) + num.ToString();
            }
        }
    }
}

Measured memory_bytes: 58124
a,b,c,k=map(int,input().split())
s=0
if k-a>=0:
    s=a
    k=k-a
    if k-b>=0:
        k=k-b
        if k-c==0:
            s=s-c
        elif k-c<0:
            s=s-k
    elif k-b<0:
        pass
elif k-a<0:
    s=k
print(s)

Measured memory_bytes: 9080
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;

int main(){
	string s,t;
	cin>>s>>t;
	sort(s.begin(),s.end());
	sort(t.begin(),t.end(),greater<char>());
	if(s<t) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long   // <-----!!!!!!!!!!!!!!!!!!!

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()

typedef long long ll;
typedef pair<int, int> Pii;
typedef tuple<int, int, int> TUPLE;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
typedef vector<vector<int>> Graph;
const int inf = 1e9;
const int mod = 1e9 + 7;

// N, E, S, W
const int dx[4] = {-1, 0,  1,  0};
const int dy[4] = { 0, 1,  0, -1};

map<char, int> mpdir = {
    {'N', 0},
    {'E', 1},
    {'S', 2},
    {'W', 3}
};

const string dir = "NESW";

enum { X, Y, DIR };
typedef vector<int> State;

int H, W, L;
vector<string> s;
vector<State> v;
set<State> st;

inline bool inside(int x, int y) {
    return 0 <= x && x < H && 0 <= y && y < W;
}

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

    while (cin >> H >> W >> L, H) {
        s.clear();
        s.resize(H);
        v.clear();
        st.clear();

        State state(3);
        rep(i, H) {
            cin >> s[i];
            rep(j, W) {
                if (isalpha(s[i][j])) {
                    state[X] = i;
                    state[Y] = j;
                    state[DIR] = mpdir[s[i][j]];
                }
            }
        }

        rep(t, 50000) {
            if (st.count(state) != 0) {
                int offset;
                for(offset = 0; v[offset] != state; offset++) {
                    assert(offset < v.size());
                }

                int last_id = L;
                if (last_id >= offset) {
                    int T = t - offset;
                    last_id = (L - offset) % T + offset;
                }

                cout << v[last_id][X] + 1 << " " << v[last_id][Y] + 1 << " " << dir[v[last_id][DIR]] << endl;
                break;
            }

            v.emplace_back(state);
            st.insert(state);

            while (!inside(state[X] + dx[state[DIR]], state[Y] + dy[state[DIR]]) || s[state[X] + dx[state[DIR]]][state[Y] + dy[state[DIR]]] == '#') {
                state[DIR] = (state[DIR] + 1) % 4;
            }

            state[X] += dx[state[DIR]];
            state[Y] += dy[state[DIR]];
        }
    }

}

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

#define rep(i,n) for(ll i = 0; i < (n); i++)
#define rrep(i,n) for(int i = (n)-1; i >= 0; i--)
#define rep1(i,n) for(int i = 1; i <= (n); i++)
#define rrep1(i,n) for(int i = (n); i > 0; i--)

#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>

#define MOD 1000000007
#define INF 1000000000000000LL

using namespace std;

int main(){
  ll x;cin>>x;
  rep(a, 10000)rep(b, 10000){
    ll diff=5000;
    ll a5 = (a-diff)*(a-diff)*(a-diff)*(a-diff)*(a-diff);
    ll b5 = (b-diff)*(b-diff)*(b-diff)*(b-diff)*(b-diff);
    if(a5-b5==x) {cout<<(a-diff)<<' '<<(b-diff); return 0;}
  }

  return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)
#define all(x) x.begin(),x.end()

int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  rep(i,0,N - 1){
    cin >> A[i];
  }
  int ans = 0;
  for(int i = 1;i < N;i++){
    if(A[i - 1] == A[i] && (i + 1 < N && A[i] == A[i + 1])){
      i++;
      ans++;
    }
    else if(A[i - 1] == A[i]){
      i++;
      ans++;
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
    int k,a,b,flg=0;
    cin >> k >> a >> b;
    for(int i=a;i<b+1;i++){
        if(i%k==0){
            flg = 1;
        }
    }
    if(flg==1){
        cout << "OK" << endl;
    }else{
        cout << "NG" << endl;
    }
    return 0;
}

Measured memory_bytes: 3592
#include <iostream>
#include <iomanip>
#include <fstream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>

#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using namespace std;
using vi = vector<int64_t>;
using vvi = vector<vi>;

int main(int argc, const char * argv[]) {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    char x;
    cin >> x;
    char j = x+1;
    cout << j << endl;
}


Measured memory_bytes: 256
from heapq import heappop, heappush
import sys
input=sys.stdin.readline


def solve():
    H, W = map(int, input().split())
    Ch, Cw = map(int, input().split())
    Dh, Dw = map(int, input().split())

    l = []
    for _ in range(H):
        s = input()
        l.append([1 if i=="#" else 0 for i in s])

    Ch -= 1
    Cw -= 1
    Dh -= 1
    Dw -= 1

    q = [(0, (Ch, Cw))]
    INF = 10**12
    costs = [[INF]*W for _ in range(H)]
    costs[Ch][Cw] = 0

    while q:
        cost, pos = heappop(q)
        h, w = pos
        for dh in range(-2, 3):
            for dw in range(-2, 3):
                hh = h+dh
                ww = w+dw
                if not (0<=hh<H and 0<=ww<W):
                    continue
                if l[hh][ww]:
                    continue
                
                if (abs(dh)==1 and abs(dw)==0) or (abs(dh)==0 and abs(dw)==1):
                    if costs[hh][ww] > costs[h][w]:
                        costs[hh][ww] = costs[h][w]
                        heappush(q, (cost, (hh, ww)))
                elif costs[hh][ww] > costs[h][w]+1:
                    costs[hh][ww] = costs[h][w]+1
                    heappush(q, (cost+1, (hh, ww)))

    print(costs[Dh][Dw] if costs[Dh][Dw]!=INF else -1)


solve()


Measured memory_bytes: 126184
#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("fast-math")
#pragma GCC optimize("section-anchors")
#pragma GCC optimize("profile-values,profile-reorder-functions,tracer")
#pragma GCC optimize("vpt")
#pragma GCC optimize("rename-registers")
#pragma GCC optimize("move-loop-invariants")
#pragma GCC optimize("unswitch-loops")
#pragma GCC optimize("function-sections")
#pragma GCC optimize("data-sections")
#pragma GCC optimize("branch-target-load-optimize")
#pragma GCC optimize("branch-target-load-optimize2")
#pragma GCC optimize("btr-bb-exclusive")
#include <iostream>
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <tuple>
#include <math.h>
#include <set>
#include <stack>
#include <bitset>
#include <map>
#include <queue>
#include <random>
#include <unordered_set>
#include <unordered_map>
#define DEBUG
#define fi first
#define se second
#define pqueue priority_queue
#define pb(x) push_back(x)
// #define endl '\n'
#define all(x) x.begin(), x.end()
#define int long long
#define mk(a, b) make_pair(a, b)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ull> vull;
typedef vector<ll> vll;
// typedef tuple<int, int, int> tiii;
typedef pair<int, int> pii;
typedef vector<pair<int, int> > vpii;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector< vector<int> > vvi;
typedef vector<char> vc;

const int INF = 1e9;
const ll INFLL = 1e18;
const int MOD = 1000000007;
const int MAXN = 3e5;
//const ld eps = 1e-6;
const ld eps2 = 1e-9;
const int MOD2 = 998244353;
const int dosz = 5e5;
const int SZ = (1<<18);
const ld PI = atan2l(0, -1);


void fast_io(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#ifdef DEBUG
        // freopen("a.in", "r",stdin);
#else
       // freopen("mxnl.in", "r", stdin);
       // freopen("mxnl.out", "w", stdout);
#endif
}

int gcd(int a, int b){
    return (b?gcd(b, a%b):a);
}

void solve(){ 
    int n, k;
    cin >> n >> k;
    cout << min(n%k, abs((n%k)-k)) << endl;
}

signed main() {
    fast_io();
    int q = 1;
    // cout << fixed << setprecision(6);
    // cin >> q;
    // cout << 1 << endl;
    while(q--){
        solve();
    }
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(long long x){
  char f[20];
  int m=0, s=0;
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
template<class S, class T> inline S max_L(S a,T b){
  return a>=b?a:b;
}
int N;
int A[100000];
int main(){
  int i, j;
  long long dp0, dp1, nx0, nx1;
  rd(N);
  {
    int Lj4PdHRW;
    for(Lj4PdHRW=0;Lj4PdHRW<N;Lj4PdHRW++){
      rd(A[Lj4PdHRW]);
    }
  }
  dp0 = 0;
  dp1 = -4611686016279904256LL;
  for(i=0;i<N;i++){
    nx0 =max_L(dp0 + A[i], dp1 - A[i]);
    nx1 =max_L(dp0 - A[i], dp1 + A[i]);
    dp0 = nx0;
    dp1 = nx1;
  }
  wt_L(dp0);
  wt_L('\n');
  return 0;
}
// cLay varsion 20190601-1

// --- original code ---
// int N, A[1d5];
// {
//   int i, j;
//   ll dp0, dp1, nx0, nx1;
//   
//   rd(N,A(N));
//   dp0 = 0;
//   dp1 = -ll_inf;
//   rep(i,N){
//     nx0 = max(dp0 + A[i], dp1 - A[i]);
//     nx1 = max(dp0 - A[i], dp1 + A[i]);
//     dp0 = nx0;
//     dp1 = nx1;
//   }
//   wt(dp0);
// }


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
int main()
{
	int W[10],S[10];
	for(int i=0; i<10; i++)std::cin>>W[i];
	for(int i=0; i<10; i++)std::cin>>S[i];
	std::sort(W,W+10);
	std::sort(S,S+10);
	printf("%d %d\n",W[9]+W[8]+W[7],S[9]+S[8]+S[7]);
	return 0;
}

Measured memory_bytes: 0
while True:
 n,x=map(int,raw_input().split())
 if n==0 and x==0:break
 count=0
 for i in range(1,n+1):
  for j in range(i+1,n+1):
   for k in range(j+1,n+1):
    
    if i+j+k==x:
	 count+=1	 
 print count

Measured memory_bytes: 4208
#include <iostream>
#include <string>
#include <vector>
#include <cstdio>
#include <cstring>
#include <climits>
#include <sstream>
#include <algorithm>
#define fastio() ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
#define ll long long 
#define MOD 1000000007
#define inf 9223372036854775807ll
using namespace std;

int main(){
	int n, k; cin >> n >> k;
	int height[100002];
	for(int i = 0; i < n; i++){
		cin >> height[i];
	}

	int dp[100001];
	memset(dp, 0, sizeof(dp));
	for(int i = 2; i <= n; i++){
		dp[i] = INT_MAX;
		for(int j = i - 1; j >= max(i - k, 1); j--){
			dp[i] = min(dp[i], dp[j] + abs(height[i - 1] - height[j - 1]));
		}
	}
	cout << dp[n];
	return 0;
}

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

#define rep(i, N) for (int i = 0; i < N; i++)
#define pb push_back
typedef long long ll;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<ll, ll> ll_ll;
const int MOD = 1e9 + 7;
const int INF = INT_MAX / 2;
struct edge { int i, v, w; };

void dfs(int N, int K, vector<int>& a, vector<vector<int> >& as) {
	as.pb(a);
	if (a.size() == N) return; 
	for (int k = 1; k <= K; k++) {
		a.pb(k);
		dfs(N, K, a, as);
		a.pop_back();
	}
}

vector<int> naive(int N, int K) {
	vector<vector<int> > as;
	vector<int> a;
	dfs(N, K, a, as);
	sort(as.begin(), as.end());
	int M = as.size();
	return as[M / 2];
}

vector<int> solve(int N, int K) {
	if (K == 1) return vector<int>((N + 1) / 2, 1);
	if (K % 2 == 0) {
		vector<int> a(N, K);
		a[0] = K / 2;
		return a;
	}
	vector<int> a(N, K / 2 + 1);
	rep(t, N / 2) {
		int i;
		for (i = N - 1; !a[i]; i--);
		a[i]--;
		if (a[i]) for (int j = i + 1; j < N; j++) a[j] = K;
	}
	for (; a.back() == 0; a.pop_back());
	return a;
}

int main() {
	int N, K; cin >> K >> N;
	vector<int> b = solve(N, K);
	for (int x : b) printf("%d ", x);
	cout << endl;
	/*
	for (;;) {
		int N, K; cin >> K >> N;
		vector<int> a = naive(N, K);
		for (int x: a) cout << x << ' ';
		cout << endl;
		vector<int> b = solve(N, K);
		for (int x : b) cout << x << ' ';
		cout << endl;
	}
	*/
}


Measured memory_bytes: 3456
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(int)(n); i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;

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

Measured memory_bytes: 19120
I=lambda:map(int,input().split())
N,A,B,C,D=I()
S=input()
if C<D: #not cross
    f=True
    for i in range(A-1,C-1):
        if S[i]==S[i+1]=='#':f=False
    for i in range(B-1,D-1):
        if S[i]==S[i+1]=='#':f=False
    print('Yes' if f else 'No')
else:
    f=True
    akichi=False
    for i in range(B-1,D):
        if S[i-1]==S[i]==S[i+1]=='.':akichi=True
    f=True
    for i in range(A-1,C-1):
        if S[i]==S[i+1]=='#':f=False
    for i in range(B-1,D-1):
        if S[i]==S[i+1]=='#':f=False
    print('Yes' if f and akichi else 'No')

Measured memory_bytes: 3572
#include <iostream>
#include <utility>
#include <queue>
#include <algorithm>
using namespace std;
#define MP make_pair

short dp[5010][5010]={};
int main(){
	int N,M,a,b,x,res,cnt;
	cin>>N>>M;
	for(int i=0;i<M;i++){
		cin>>a>>b>>x;
		for(int j=0;j<=x;j++){
			dp[a+j][b]=max(dp[a+j][b],(short)(j+1));
		}
	}

	res=0;
	for(int i=1;i<=N;i++){
		cnt=0;
		for(int j=1;j<=i;j++){
			if(j!=1&&dp[i][j-1]==0){
				cnt++;
			}
			dp[i][j]=max((short)(dp[i][j-1]-1),dp[i][j]);
		}
		if(dp[i][i]==0) cnt++;
		res+=cnt;
	}
	cout<<N*(N+1)/2-res<<endl;
	return 0;
}

Measured memory_bytes: 48924
#ifndef LOCAL
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#else
#include <iostream>
#include <iomanip> 
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <memory>
#include <cctype>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; }; sim > rge<c> range(c i, c j) { return rge<c>{i, j}; } sim > auto dud(c* x) -> decltype(cerr << *x, 0); sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; } eni(!=) cerr << boolalpha << i; ris; } eni(==) ris << range(begin(i), end(i)); } sim, class b dor(pair < b, c > d) { ris << "(" << d.first << ", " << d.second << ")"; } sim dor(rge<c> d) { *this << "["; for (auto it = d.b; it != d.e; ++it) *this << ", " + 2 * (it == d.b) << *it; ris << "]"; }
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds; 
// #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 

template<typename T> void setmax(T& x, T y) {x = max(x, y);}
template<typename T> void setmin(T& x, T y) {x = min(x, y);}
#define fix(a) fixed << setprecision(a)
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define rep(i, a, b) for (int i = int(a); i < int(b); i++)
#define all(V) V.begin(), V.end()
#define rall(V) V.rbegin(), V.rend()
#define len(V) (int)V.size()
#define ll long long
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define endl '\n'

void solve(){
  string s, t;
  cin >> s >> t;
  forn(i, len(s)){
    cout << s[i];
    if (i < len(t)) cout << t[i];
  }
}

int main() {
  ios::sync_with_stdio(false);
  // cin.tie(0); cout.tie(0);
  int t = 1;
  // cin >> t;
  forn(i, t){
    solve();
  }
}

/* 

aattccooddeerrbreeggiunlnaerrccoonntteesstt
aattccooddeerrbreeggiunlnaerrccoonntteesstt
*/

Measured memory_bytes: 3512
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>		//UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>		//do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)
#define ALL(u) (u).begin(),(u).end()

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;

const int MR = 1e5 + 10;
const int MOD = 1e9 + 7;

char S[MR];

int ile[200];

int main()
{
    int N;
    scanf("%d%s", &N, S);

    REP(i, N)
        ile[S[i]]++;

    // wybieraj dla kazdej litery 1 pozycje lub nie bierz jej wcale
    int res = 1;
    FORQ(i, 'a', 'z')
        res = (res * (LL)(ile[i] + 1)) % MOD;

    // wyrzuc pusty ciag
    res = (res - 1 + MOD) % MOD;

    printf("%d\n", res);

    return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int main(void){
	int n;
	int a[101]={0};

	while(cin>>n){
        a[n]++;

	}
	int b=0;
    for(int i=0;i<100;i++){
        b=max(a[i],b);

    }
    for(int i=0;i<100;i++){
        if(a[i]==b)cout<<i<<endl;

    }

	return 0;
}

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

int main() {
  int N; cin >> N;
  string S; cin >> S;
  string Scopy = S;
  bool exist = true;
  while (exist) {
    exist = false;
    if (Scopy.size() <= 1) break;
    for (int i = 0; i < Scopy.size()-1; i++) {
      if (Scopy.at(i) == '(' && Scopy.at(i+1) == ')') {
        Scopy.erase(i, 2);
        exist = true;
        break;
      }
    }
  }
  int insertl = 0;
  int insertr = 0;
  for (int i = 0; i < Scopy.size(); i++) {
    if (Scopy.at(i) == ')') insertl++;
    else insertr++;
  }
  string l = "";
  string r = "";
  for (int i = 1; i <= insertl; i++) l.push_back('(');
  for (int i = 1; i <= insertr; i++) r.push_back(')');
  cout << l << S << r << endl;
}

Measured memory_bytes: 256
#include <limits.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <math.h>

#define P 1000000007

int comp(const void *a, const void *b){return *(int*)a-*(int*)b;}

int main(void){
	int n, i;
	int d[100000];
	scanf("%d", &n);
	for(i=0; i<n; i++){
		scanf("%d", d+i);
	}
	qsort(d, n, sizeof(int), comp);
	printf("%d\n", d[n/2]-d[n/2-1]);
}


Measured memory_bytes: 892
n = int(input())
x = []
for i in range(n):
    ai = int(input())
    xi = []
    for j in range(ai):
        xi.append(list(map(int, input().split())))
    x.append(xi)

m = 0
for h in range(2**n - 1, -1, -1):
    is_break = False
    h = bin(h)[2:].zfill(n)
    for i, xi in enumerate(x):
        if h[i] == '0':
            continue
        for xij, yij in xi:
            if (int(h[xij - 1]) != yij):
                is_break = True
                break
        if is_break:
            break
    else:
        m = max(sum(map(int, list(h))), m)

print(m)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include<algorithm>
#include <string>
#include <set>
#include <limits.h>
#include <map>
#include <queue>
#include <stack>

using namespace std;

#define rip(i,n,s) for (int i=(s);i<(int)(n);i++)
#define all(a) (a).begin(),(a).end()
typedef long long ll;

int main(){
    int n;
    cin >> n;
    vector<ll> da(n*3);
    rip(i,n*3,0){
        cin >> da[i];
    }
    vector<ll> fo(n+1,0),ba(n+1,0);
    priority_queue<ll,vector<ll>,greater<ll>> small;
    priority_queue<ll> big; 
    rip(i,n,0){
        small.push(da[i]);
        fo[0]+=da[i];
    }
    rip(i,n,0){
        small.push(da[n+i]);
        fo[i+1]=fo[i]+da[n+i]-small.top();
        small.pop();
    }
    rip(i,3*n,2*n){
        big.push(da[i]);
        ba[n]+=da[i];
    }
    for(int i=n*2-1;i>=n;i--){
        big.push(da[i]);
        ba[i-n]=ba[i-n+1]+da[i]-big.top();
        big.pop();
    }
    ll ans=-LLONG_MAX;
    rip(i,n+1,0){
        ans=max(ans,fo[i]-ba[i]);
        //printf("%lld %lld\n",fo[i],ba[i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 6516
#include <bits/stdc++.h>
using namespace std;
bool prime[100010];

void SieveOfEratosthenes()
{
	// Create a boolean array "prime[0..n]" and initialize
	// all entries it as true. A value in prime[i] will
	// finally be false if i is Not a prime, else true.
	int n=100009;
	//bool prime[n+1];
	memset(prime, true, sizeof(prime));
	prime[0]=false;
	prime[1]=false;

	for (int p=2; p*p<=n; p++)
	{
		// If prime[p] is not changed, then it is a prime
		if (prime[p] == true)
		{
			// Update all multiples of p
			for (int i=p*2; i<=n; i += p)
				prime[i] = false;
		}
	}
}

// Driver Program to test above function
int main()
{
    SieveOfEratosthenes();
    int q;
    cin>>q;
    int arr[100010];
    int ans=0;
    for(int i=1;i<=100009;i++)
    {
        if(prime[i]  && prime[(i+1)/2])
                ans++;
         arr[i]=ans;

    }

    while(q--)
    {
        int l,r,ans=0;
        cin>>l>>r;


        cout<<arr[r]-arr[l-1]<<endl;


    }

	return 0;
}


Measured memory_bytes: 1152
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>

using namespace std;

int main(){
	int n, c, ans = 0;
	cin >> n >> c;
	vector<vector<pair<int, int>>> t(c + 1);
	for(int i = 0; i < n; i++){
		int x, y, z;
		cin >> x >> y >> z;
		t[z].push_back({x, y});
	}
	for(int i = 1; i <= c; i++){
		sort(t[i].begin(), t[i].end());
		t[i].push_back({-1, -1});
	}
	vector<int> a(200001);
	for(int i = 1; i <= c; i++){
		if(t[i].size() == 0) continue;
		int l = t[i][0].first, r = t[i][0].second;
		for(int j = 1; j < t[i].size(); j++){
			if(r == t[i][j].first){
				r = t[i][j].second;
			}else{
				a[2 * l - 1]++;
				a[2 * r]--;
				l = t[i][j].first; r = t[i][j].second;
			}
		}
	}
	for(int i = 1; i < a.size(); i++){
		a[i] += a[i - 1];
		ans = max(ans, a[i]);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2304