akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main
{

    public static void main(String[] args)
    {
        Scanner scan = new Scanner(System.in);

        int a = 0;

        for (int i = 0; i < 10; i++) {
            int s = scan.nextInt();
            a += s;
        }
        System.out.println(a);

    }
}



Measured memory_bytes: 26352
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
using namespace std;
typedef pair<int,string> P;
string str;
int n,m;
vector<P> p;
map <string,int> q;
int main(){
  cin>>n;
  p.resize(n);
  for(int i=0;i<n;i++){
    cin>>p[i].second>>m;
    p[i].first=p[i].second.size();
    q[p[i].second]+=m;
  }
  sort(p.begin(),p.end());
  for(int i=0;i<n;i++){
    if(i&&p[i]==p[i-1])continue;
    cout<<p[i].second<<' '<<q[p[i].second]<<endl;
  }
  return 0;
}

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

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")


#define boost ios::sync_with_stdio(0); cin.tie(0);
#define int long long
const int N = 5 + 1000;


int32_t main(){
  boost;
    int a , b ,h;

    cin >> a >> b >> h;

    cout << ((a+b)*h)/2;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using vb = vector<bool>;
using mll = map<ll, ll>;
using sll = stack<ll>;
#define REP(i,n) for(ll i(0);(i)<(n);(i)++)
#define rep(i,n) for(ll i(0);(i)<(n);(i)++)
#define ALL(a) a.begin(), a.end()
#define enld endl //* missspell check
const ll INF = 1LL << 60;

void solve(long long N){
    vector<vll> c(10, vll(10, 0));
    for(ll k=1; k<= N; k++){
        ll i = to_string(k)[0]-'0';
        ll j = k % 10;
        c[i][j]++;
    }
    ll ans = 0;
    REP(i, 10){
        REP(j, 10){
            ans += c[i][j]*c[j][i];
        }
    }
    cout<< ans<<endl;

}

int main(){
    long long N;
    scanf("%lld",&N);
    solve(N);
    //cout<< getMid(N)<<endl;
    return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#pragma region include
#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <ctime>
////
//#include <random>//
#pragma endregion //#include
/////////

#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
#pragma endregion //typedef
////定数
const int INF = (int)1e9;
const LL MOD = (LL)1e9+7;
const LL LINF = (LL)4e18+20;
const LD PI = acos(-1.0);
const double EPS = 1e-9;
/////////
using namespace::std;

void solve(){
	int A,B;
	cin>>A>>B;
	if(A<=8 && B<=8 ){
		cout <<"Yay!" << endl;
	}else{
		cout <<":(" << endl;
	}
}

#pragma region main
signed main(void){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}
#pragma endregion //main()


Measured memory_bytes: 256
s = input()
n = len(s)
dp = [0] * n
dp[0] = 1

for i in range(1, n):
    if s[i] != s[i - 1]:
        dp[i] = dp[i - 1] + 1
    else:
        dp[i] = dp[i - 1]
        if i >= 2:
            dp[i] = max(dp[i], dp[i - 2] + 1)
        if i >= 3:
            dp[i] = max(dp[i], dp[i - 3] + 2)
print(dp[-1])

Measured memory_bytes: 10976
#include <iostream>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <cstdio>
#include <cmath>
using namespace std;

string check(char c) {
	char check[5] = { 'a','i','u','e','o' };
	for (int i = 0; i < 5; i++) {
		if (c == check[i])return "vowel";
	}
	return "consonant";
}

int main() {
	char c;
	cin >> c;
	cout << check(c) << endl;
	return 0;
}

Measured memory_bytes: 256
from collections import deque
import sys;input=sys.stdin.readline

h,w=map(int,input().split())
grid=[["#"]*(w+2)]+[list("#"+input()+"#")for x in range(h)]+[["#"]*(w+2)]

stack=deque()
for y in range(1,h+1):
    for x in range(1,w+1):
        if grid[y][x]=="#":
            grid[y][x]=0
            stack.append((y,x))

for i in range(h*w):
    tmp=deque()
    while stack:
        my,mx=stack.pop()
        for y,x in ([0,1],[1,0],[-1,0],[0,-1]):
            if grid[my+y][mx+x]==".":
                grid[my+y][mx+x]=i+1
                tmp.append([my+y,mx+x])
    stack=tmp
    if not tmp:
        print(i)
        break


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

const int NMAX = 2e5 + 5;
int n, a[NMAX], b[NMAX], nr;

int main() {
    cin >> n;
    for(int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    b[n] = a[n] % 2;
    nr = b[n];
    for(int i = n - 1; i >= 1; i--) {
        int sum = 0;
        for(int j = i; j <= n; j += i) {
            sum += b[j];
        }
        if(sum % 2 != a[i] % 2) {
            b[i] = 1;
        }
        nr += b[i];
    }
    cout << nr << '\n';
    for(int i = 1; i <= n; i++) {
        if(b[i] == 1) {
            cout << i << ' ';
        }
    }
    return 0;
}

Measured memory_bytes: 5032
#include <bits/stdc++.h>
using namespace std;
using 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 bg begin()
#define ed end()
#define all(x) x.bg, x.ed
#define vi vector<int>
template <class t, class u>
bool chmax(t &a, u b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class t, class u>
bool chmin(t &a, u b)
{
    if (b < a)
    {
        a = b;
        return true;
    }
    return false;
}

ll mod = 1000000007;



signed main()
{
    int n;
    cin>>n;
    vi b(n);
    rep(i,n){
        cin >> b[i];
    }
    vi ans;
    while (b.size() > 0)
    {
        bool f = true;
        per(i, b.size())
        {
            if(b[i]==i+1){
                b.erase(b.begin() + i);
                ans.push_back(i + 1);
                f = false;
                break;
            }
        }
        if(f){
            cout << -1 << endl;
            return 0;
        }
    }
    per(i,n){
        cout << ans[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 3632
//Together.cpp (C)
#include <iostream>
#include <algorithm>
using namespace std;

int main(){
  int N;
  int a[110000];
  int num[110000] = {0};
  cin >> N;
  for(int i = 0; i < N; i++){
    cin >> a[i];
    ++num[a[i]];
    ++num[a[i]+1];
    ++num[a[i]-1];
  }
  sort(num,num+100001,greater<int>());
  printf("%d\n",num[0]);

}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define rep(i, n) for(int i =0 ; i < n; ++i)
#define Rep(i,a,b) for(int i=a;i<=b;i++)
#define pii pair < int, int >
typedef vector<int> vi;
typedef  long long ll;
const int mod =1e9+7;
const int N = (int)2e5 + 5;
int used[N];

void solve(){
	int n,m;
	cin>>n>>m;
	int h[n];
	rep(i,n)cin>>h[i];
	int a[m],b[m];
	rep(i,n){
		used[i]=1;
	}
	rep(i,m){
		cin>>a[i]>>b[i];
		--a[i],--b[i];
		if(h[a[i]]<=h[b[i]])used[a[i]]=0;
		if(h[b[i]]<=h[a[i]])used[b[i]]=0;		
	}		
	int cnt=0;
	rep(i,n){
		if(used[i])cnt++;
	}
	cout<<cnt;
	
    
}

int main(){
	Red;
	int t=1;
	//cin>>t;
	while(t--)
	solve();
	return 0;
}

Measured memory_bytes: 5212
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <list>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <bitset>
#include <functional>

using namespace std;

#define FOR(i,n) 		for(int(i)=0;(i)<(int)(n);(i)++)
#define FORN(i,a,b,c) 	for(int(i)=a;i<(int)(b);i+=(c))
#define RES(x,nilai)	memset(x,nilai,sizeof(x));
#define pb              push_back
#define mp              make_pair
#define INF				1000000000

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

inline string IS(int a){
    char x[100];
    sprintf(x,"%d",a); string s = x;
    return s;
}

inline int SI(string a){
    char x[100]; int res;
    strcpy(x,a.c_str()); sscanf(x,"%d",&res);
    return res;
}

//==============================================

bool cmp(int x,int y) {return x>y;}

int arr[5],n;

int main() {
	//freopen("in.txt","r",stdin);
	//freopen("13.txt","w",stdout);
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	
	cin >> n;
	for(int i =0 ;i < n;i++) {
		cin >> arr[0] >> arr[1] >> arr[2];
		sort (arr,arr+3);
		if (sqrt((arr[0]*arr[0]) + (arr[1]*arr[1]) ) == arr[2]) cout << "YES" << endl;
		else cout << "NO" << endl;
	}
		
    return 0;
}

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

#define int long long

main(){
	int n;
	int a[100002];
	int f[100002]={0};

	int total=0;

	cin>>n;
	for(int i=0;i<n;i++){ cin>>a[i];total+=a[i]; }
	sort(a,a+n);
	
	int ans=1;
	for(int i=n-2;i>=0;i--){
		total-=a[i+1];
		if(total*2>=a[i+1])ans++;
		else break;
	}

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

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

int main(){ 
  int N; cin >> N;
  vector<vector<int>> to(N);
  vector<pair<int,int>> Edges;
  for(int i = 1; i < N; i++){
    int a,b; cin >> a >> b; a--; b--;
    to[a].push_back(b); to[b].push_back(a);
    Edges.push_back({a,b}); 
  }
  
  map<pair<int,int>,int> ans; //どの辺にどの色を塗るのか指定する
  vector<bool> visited(N,false);
  queue<int> Q; Q.push(0); //根付き木として、どの親まで辿ったかを保存
  int S = 0; //最大サイズ
  vector<int> color(N,0); visited[0] = true;
  
  while(!Q.empty()){
    int p = Q.front(); Q.pop(); //今parent_Pに着目している
    S = max(S,(int)to[p].size()); 
    
    int paint = 1; //pの子との間の辺を順次色分けしていく
    
    for(auto ne : to[p]){ 
      if(visited[ne]){ continue;}
      
      if( paint == color[p]){ paint++;}
      
      visited[ne] = true;
      
      color[ne] = ans[{p,ne}] = ans[{ne,p}] = paint++;
      
      Q.push(ne);
      
    }
  }
  
  cout << S << endl;
  
  for(auto ne : Edges){ cout << ans[ne] << endl;}
  
  return 0;
}
      
  
  

Measured memory_bytes: 19700
#include <bits/stdc++.h>
// #define int long long
#define Matrix vector<vector<int> >
// #define Matrix vector<vector<int> >
#define double long double
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define td(v) v.begin(),v.end()
#define tdr(v) v.rbegin(),v.rend()
#define endl "\n"
#define Matrix vector<vector<int> >
using namespace std;
const int MOD = 1e9+7;
const long long INF = 5e18;
const double pi = acos(-1.0);
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
int gcd(int a, int b){return (b == 0 ? a : gcd(b, a%b));}
int lcm(int a,int b){return (a*b)/gcd(a,b);}
 
inline long long mod(long long n, long long m){
    long long ret = n%m;
    if(ret < 0) ret += m;
    return ret;
}
 
double rad(double x){
    return x*pi/180.0;
}
 
bool isleft(pair<int,int> a, pair<int,int> b, pair<int,int> c){
    int det = (b.first-a.first)*(c.second-a.second) - (c.first-a.first)*(b.second-a.second);
    if(det>=0) return true;
    if(det<0) return false;
    return false;
}
 
int exp(int a, int b){
    int result = 1;
    while (b > 0){
        if (b & 1)
            result = mod(result*a,MOD);
 
        b >>= 1;
        a = mod(a*a,MOD);
    }
    return result;
}

double memo[321][321][321];
int vet[321];
int n;
double dp(int t, int d, int u){
	if(t+d+u==0) return 0;
	double &x = memo[t][d][u];
	if(x!=-1) return x;
	x = 0;
	if(t>0)
		x+=t*dp(t-1,d+1,u);
	if(d>0)
		x+=d*dp(t,d-1,u+1);
	if(u>0){
		x+=u*dp(t,d,u-1);
	}
	x/=(t+d+u)*1.0;
	x+=n*1.0/(t+d+u);
	return x;
}
void solve(){
	cin>>n;
	int q[4] = {0,0,0};
	for(int i=0;i<n;i++){
		cin>>vet[i];
		q[vet[i]]++;
	}
	for(int i=0;i<321;i++)
		for(int j=0;j<321;j++)
			for(int k=0;k<321;k++)
				memo[i][j][k]=-1;
	cout<<fixed<<setprecision(13);
	cout<<dp(q[3],q[2],q[1])<<endl;
}

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

Measured memory_bytes: 520704
#include<stdio.h>

int main(void)
{
	int len;
	char wls[101];

	scanf("%d", &len);
	scanf("%s", wls);

	int i, max = 0, point = 0;
	for (i = 0; i < len; i++) {
	
		if (wls[i] == 'I')point++;
		if (wls[i] == 'D')point--;
		if (point>max)max=point;
	}
	printf("%d", max);

	return 0;
}

Measured memory_bytes: 128
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <string>
#define BIG 1000000000
#define BIGNUM 100000
#define S_SIZE 100000
using namespace std;

int binarySearch(int *A,int n,int key) {
	int left = 0;
	int right = n;
	int mid;
	while (left < right) {
		mid = (left + right) / 2;
		if (A[mid] == key) {
			return 1;
		}
		else if (A[mid] > key) {
			right = mid;
		}
		else {
			left = mid + 1;
		}
	}
	return 0;
}

int main() {
	int n;
	int q;
	int S[S_SIZE];
	int key;
	int cnt = 0;

	scanf("%d", &n);
	for (int i = 0; i < n; i++) scanf("%d", &S[i]);

	scanf("%d", &q);
	for (int i = 0; i < q; i++) {
		scanf("%d", &key);
		if (binarySearch(S, n, key))
			cnt++;
	}
	
	printf("%d\n", cnt);
}

Measured memory_bytes: 3520
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <utility>

using namespace std;

#define fi first
#define se second
typedef pair<int,int> ii;

ii pos[400*400];
long long dp[400*400];

int main()
{
    // ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	//freopen("input.in", "r", stdin);
	int n, m, d; scanf("%d %d %d", &n, &m, &d);
	for(int i = 1; i <= n; i++)
	{
		for(int j = 1; j <= m; j++)
		{
			int x; scanf("%d", &x);
			pos[x] = {i,j};
		}
	}
	for(int i = n*m; i >= 1; i--)
	{
		if(i + d > n*m)
			continue;
		else
			dp[i] = dp[i+d] + 1LL*abs(pos[i].fi-pos[i+d].fi) + 1LL*abs(pos[i].se-pos[i+d].se);
			
	}
	int q; scanf("%d", &q);
	while(q--)
	{
		int l, r;
		scanf("%d %d", &l, &r);
		printf("%lld\n", dp[l]-dp[r]);
	}
}






Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long int
#define MP make_pair
#define ull unsigned long long int
#define F first
#define S second
#define put insert
#define pb push_back
#define rsort(arr) sort(arr.begin(),arr.end(),greater<int>())
#define srt(arr) sort(arr.begin(),arr.end())
#define arrInput(arr,n) for(int i=0;i<n;i++) cin>>arr[i];
#define rev(arr) reverse(arr.begin(), arr.end())
ll MOD = 1e9+7;
int main() {
    fastio
    // int t;
    // cin>>t;
    // while(t--) {
    int n;
    cin>>n;
    vector<int> arr(n);
    arrInput(arr,n);
    srt(arr);
    int ans = 0;
    if(n <= 2) {
        cout<<ans;
        return 0;
    }
    for(int i=0;i<n-2;i++) {
        for(int j=i+1;j<n-1;j++) {
            for(int k=j+1;k<n;k++) {
                if(arr[i] != arr[j] && arr[i] != arr[k] && arr[j] != arr[k]) {
                    if(arr[i]+arr[j] > arr[k])
                        ans++;
                }
            }
        }
    }
    cout<<ans;
    // }
    return 0;
}


Measured memory_bytes: 3656
/*
* @Author: Nazrul Islam
* @Date:   2020-09-20 20:15:13
* @Last Modified by:   Nazrul Islam
* @Last Modified time: 2020-09-20 21:06:57
*/

#include<bits/stdc++.h>
using namespace std;
#define IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
typedef long long ll; 
typedef double dd;
typedef vector<int> vi;
typedef vector<char> vc;
typedef list<int> li;
typedef set<int> si;
typedef map<int,int> mp;
#define pb push_back
#define pf push_front
#define mk make_pair
#define sc scanf
#define pr printf
#define pi acos(-1.0)
#define endl '\n'
// char s[200009];
// char st[200009];
// int a[600][600];
// int b[29][10];
// int a[200009];
// int c[200009];
ll m = 1e9+7;
ll func(ll n, ll k) {
	// cn++;
	if(k == 0) return 1;
	ll p = func(n, k/2);
	if(k % 2 == 0) return ((p * p) % m);
	else return (((p*p)%m*n) %m);
}
void solve()
{
	ll n;
	cin >> n;
	// if(n == 0) cout << ""
	ll o = func(10, n) - 2*func(9, n) + func(8, n);
	o = o%m;
	o = (o+m)%m;
	cout << o << endl; 
}
int main()
{
	IO;
	int t; 
	t = 1;
	// cin >> t;
	while(t--)
		solve();
	return 0;
}

Measured memory_bytes: 3644
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

public static partial class Program
{
    public static void Main()
    {
        var s = CRL();
        var t = CRL();

        const string unres = "UNRESTORABLE";

        if (s.Length < t.Length)
        {
            CWL(unres);
            return;
        }

        for (int sIdx = s.Length - t.Length; sIdx >= 0; sIdx--)
        {
            var sb = new StringBuilder(s);
            var conf = false;
            for (int tIdx = 0; tIdx < t.Length; tIdx++)
            {
                if (s[sIdx + tIdx] == '?')
                {
                    sb[sIdx + tIdx] = t[tIdx];
                    continue;
                }

                if (s[sIdx + tIdx] != t[tIdx])
                {
                    conf = true;
                    break;
                }
            }

            if (conf)
            {
                continue;
            }

            CWL(sb.ToString().Replace("?", "a"));
            return;
        }

        CWL(unres);
    }
}

public static partial class Program
{
    //テンプレここから
    private static long ToInt(this string str) => long.Parse(str);
    private static long[] ToInt(this IEnumerable<string> strs) => strs.Select(x => x.ToInt()).ToArray();
    public static long[] ArrayLongs(this string str, char opr = ' ') => str.Split(opr).ToInt();
    public static string CRL() => Console.ReadLine();
    public static void CWL(object obj) => Console.WriteLine(obj);
    public static long Diff(long a, long b) => Math.Abs(Math.Max(a, b) - Math.Min(a, b));
    public static long Sign(this long i) => Math.Sign(i);
    public static bool IsEven(this long i) => i % 2 == 0;
    public static bool IsEven(this int i) => i % 2 == 0;
    public static long[] dx = new long[] { 0, -1, 0, 1 };
    public static long[] dy = new long[] { -1, 0, 1, 0 };
    public static long mod = 1000000007;
    public static string alphabet = "abcdefghijklmnopqrstuvwxyz";
    public static long ToLong(this char c) => c.ToString().ToInt();
    //テンプレここまで
}


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

#define mem( arr, i ) fill( arr, arr + sizeof (arr), i )
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;
const lli I_MAX = 1LL << 60;
const lli mod = 1000000007;


void solve() {
	lli n, m, q, k;
	cin >> n;
	
	if ( n == 1 ) cout << "Hello World\n";
	else {
		cin >> q >> k;
		cout << q+k << '\n';
	}
}

int main() {
	int t = 1;
//	cin >> t;
	for (int i = 1; i <= t; ++i) {
//		printf("Case #%d: ", i );
		solve();
	}
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int m[10],dum;
	for (int i = 0; i < 10; i++){
		cin >> m[i];
	}
	for (int j = 0; j < 3; j++){
		for (int i = j+1; i < 10; i++){
			if (m[j] < m[i]){
				dum = m[j];
				m[j] = m[i];
				m[i] = dum;
			}
		}
	}
	for (int i = 0; i < 3; i++){
		cout << m[i] << endl;
	}
	return 0;
}


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

int main(){
  string s; cin >>s;
  string str = "";
  int n = s.size();
  rep(i,n){
    if(s[i]=='0') str += '0';
    else if(s[i]=='1') str += '1';
    else if(s[i]=='B' && str!="") {
      int x = str.size();
      str.erase(x-1, 1);
    }
  }
  cout << str << endl;
  return 0; 
}

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

int main(){
    using namespace std;
    unsigned long N, M;
    cin >> N >> M;
    vector<pair<pair<unsigned long, unsigned long>, unsigned long>> q(M);
    for(auto& i : q){
        cin >> i.first.second >> i.first.first >> i.second;
        --i.first.second;
        --i.first.first;
    }
    sort(q.begin(), q.end());
    vector<unsigned long> segtree(2 * N, numeric_limits<unsigned long>::max() / 3);
    segtree[N] = 0;
    const auto& chmin = [](auto& i, auto j){i = min(i, j);};
    const auto& range_add = [&segtree, &N, &chmin](unsigned long r, unsigned long l, unsigned long a){
        r += N;
        l += N + 1;
        while(r < l){
            if(r & 1){
                chmin(segtree[r], a);
                ++r;
            }
            if(l & 1){
                --l;
                chmin(segtree[l], a);
            }
            r >>= 1;
            l >>= 1;
        }
    };
    const auto& point_fold = [&segtree, &N, &chmin](unsigned long r) -> unsigned long {
        unsigned long ret{numeric_limits<unsigned long>::max()};
        r += N;
        while(r){
            chmin(ret, segtree[r]);
            r >>= 1;
        }
        return ret;
    };
    const auto& range_fold = [&segtree, &N, &chmin, &point_fold](unsigned long r, unsigned long l) -> unsigned long {
        unsigned long ret{min(point_fold(r), point_fold(l))};
        r += N;
        l += N + 1;
        while(r < l){
            if(r & 1){
                chmin(ret, segtree[r]);
                ++r;
            }
            if(l & 1){
                --l;
                chmin(ret, segtree[l]);
            }
            r >>= 1;
            l >>= 1;
        }
        return ret;
    };
    constexpr unsigned long lim = numeric_limits<unsigned long>::max() / 7;
    for(const auto& i : q){
        auto k = range_fold(i.first.second, i.first.first);
        range_add(i.first.second, i.first.first, (k > lim ? k : k + i.second));
    }
    const auto ans = point_fold(N - 1);
    cout << static_cast<long>(ans > lim ? -1 : ans) << endl;
    return 0;
}

Measured memory_bytes: 4096
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  int sum = 0;
  cin >> N;

  for (int i = 0; i < N; i++) {
  	int l, r;
  	cin >> l >> r;
 	sum += r - l + 1 ;
 }
 cout << sum << 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();
        int[] A = new int[N];
        for (int i = 0; i < N; i++) {
            A[i] = sc.nextInt();
        }
        System.out.println( solve(N, A) );
    }

    private static long solve(int N, int[] A) {
        long ans = 0;
        int l = 0;
        int r = 0;
        int cur = A[0];
        while(l < N) {
            while(r < N-1) {
                int next = A[r+1];
                int xor = cur ^ next;
                int sum = cur + next;

                if( xor == sum ) {
                    r++;
                    cur = sum;
                } else {
                    break;
                }
            }

            ans += r - l + 1;
            cur = cur ^ A[l];
            l++;
        }
        return ans;
    }
}

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

template <class T> ostream &operator<<(ostream &os, vector<T> &v) {
  for (auto i = v.begin(); i != v.end(); i++) {
    os << *i << " ";
  }
  return os;
}

const long long MOD = 1000000007;

int main(){
  int x, y;
  cin>>x>>y;
  std::cout << max(0,x-2*y) << std::endl;
  return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
n = int(input())
s = [input() for _ in range(n)]

print('AC', 'x', s.count('AC'))
print('WA', 'x', s.count('WA'))
print('TLE', 'x', s.count('TLE'))
print('RE', 'x', s.count('RE'))


Measured memory_bytes: 16140
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001001001001
#define mod 1000000007
#define mod2 998244353
#define pi acos(-1)
#define all(v) v.begin(),v.end()

int main(){
    int x;cin>>x;
    if(x==7|| x==5||x==3){
        cout<<"YES"<<endl;
    }else{
        cout<<"NO"<<endl;
    }
}

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

int main(void){
    int n,h;
    cin>>n>>h;
    vector<ll> b(n);
    ll amax=0,cnt=0;
    rep(i,n){
        ll a;
        cin>>a>>b[i];
        amax = max(amax,a);
    }
    sort(b.begin(),b.end(),greater<ll>());
    rep(i,n){
        if(b[i] < amax)break;
        h -= b[i];
        cnt++;
        if(h<=0)break;
    }
    if(h>0) cnt += h/amax + (h%amax>0);
    cout<<cnt<<endl;
}


Measured memory_bytes: 1024
use std::io;

fn get_line() -> String {
  let mut line = String::new();
  io::stdin()
    .read_line(&mut line)
    .ok();
  line
}

fn line_to_vec_i64(line: &str) -> Vec<i64> {
  line
    .trim()
    .split_whitespace()
    .map(|s| { s.parse::<i64>().unwrap_or(0) })
    .collect()
}

fn main() {
  let line = get_line();
  let v = line_to_vec_i64(&line);
  let (a, b) = (v[0], v[1]);
  let (d, r, f): (i64, i64, f64);
  d = a / b;
  r = a % b;
  f = a as f64 / b as f64;
  println!("{} {} {:.5}", d, r, f);
}



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

typedef long long ll;

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

ll f(int x)
{
    ll s = 1; for(int i = 1; i <= 5; ++i) s *= x;
    return s;
}

void work(ll x)
{
    int o = (int)3e3;
    for(int i = -o; i <= o; ++i)
    {
        for(int j = -o; j <= o; ++j)
        {
            if(f(i) - f(j) == x)
            {
                printf("%d %d\n", i, j);
                return;
            }
        }
    }
}

int main()
{
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
    ll x; scanf("%lld", &x);
    work(x);
    return 0;
}


Measured memory_bytes: 3828
import java.util.Scanner;
public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int h = sc.nextInt();
		int w = sc.nextInt();
		int k = sc.nextInt();
		int ans = 0;
		String[] s = new String[h];
		for(int i = 0;i < h; i++) {
			s[i] = sc.next();
		}
		for(int is = 0; is < (1<<h); is++) {
			for(int js = 0; js < (1<<w); js++) {
				int count = 0;
				for(int i = 0; i < h; i++) {
					for(int j = 0; j < w; j++) {
						if(((is>>i) & 1)==1) {
							continue;
						}
						if(((js>>j)&1)==1){
							continue;
						}
						if(s[i].charAt(j)=='#') {
							count++;
						}
					}
				}
				if(count == k ) {
					ans++;
				}
			}
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 36128
#include <iostream>

int main() {
  int time;
  std::cin >> time;

  int h, m, s;
  h = time / 3600;
  time = time % 3600;
  m = time / 60;
  time = time % 60;
  s = time;

  std::cout << h << ":" << m << ":" << s << std::endl;
}


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

using namespace std;

int main(){
    int n;
    char e;
    string ss;
    set<string> s;

    cin >> n;
    cin >> ss;
    e = ss[ss.length()-1];
    s.insert(ss);

    bool flag = true;
    for(int i = 0;i < n-1;i++){
        string temp;
        cin >> temp;
        if(temp[0] != e){
            flag = false;
            break;
        }
        e = temp[temp.length()-1];
        s.insert(temp);
    }
    if(flag && s.size() == n){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>
#include<algorithm>
#include<functional>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll, int> plli;
typedef pair<int, pii> pipii;
typedef vector<vector<int> > mati;
typedef vector<vector<double> > matd;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)

template <typename T>
void vec_print(vector<T> VEC){
  REP(i, VEC.size()){
    cout << VEC[i] << " ";
  }
  cout << "\n";
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  REP(i, MAT.size()){
    REP(j, MAT[i].size()){
      cout << MAT[i][j] << " ";
    }
    cout << "\n";
  }
};

template <typename CLASS1, typename CLASS2>
class HOGE{
  public:
    CLASS1 key;
    CLASS2 value;
    HOGE(void){
      return;
    };
    HOGE(CLASS1 key, CLASS2 value){
      this->key = key;
      this->value = value;
    };
    ~HOGE(void){
      return;
    };

    void print(void){
      cout << "key : " << key << ", value : " << value << "\n";
      return;
    };
    
    bool operator==(const HOGE &obj){
      return (this->value == obj.value);
    };
    bool operator<(const HOGE &obj){
      return (this->value < obj.value);
    };
    bool operator>(const HOGE &obj){
      return (this->value > obj.value);
    };
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  ll N, K;
  cin >> N >> K;

  cout << N-K+1 << "\n";

  return 0;
}

Measured memory_bytes: 256
#N回跳ねるボール　1≤X≤10000　Xは領域
N, X = map(int, input().split())
#Lははねた距離
length = list(map(int, input().split()))

#バウントしたかず
count_total = 1
#最初の位置
now = 0
  
for count in range(N):
  #もし領域よりも小さければもう一回跳ねる
  now = now + length[count]
  if now <= X:
    count_total = count_total + 1

print(count_total)
  

Measured memory_bytes: 2940
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String n = sc.next();

		if (n.charAt(n.length() - 1) == '2' ||
				n.charAt(n.length() - 1) == '4' ||
				n.charAt(n.length() - 1) == '5' ||
				n.charAt(n.length() - 1) == '7' ||
				n.charAt(n.length() - 1) == '9') {
			System.out.println("hon");
		} else if (n.charAt(n.length() - 1) == '0' ||
				n.charAt(n.length() - 1) == '1' ||
				n.charAt(n.length() - 1) == '6' ||
				n.charAt(n.length() - 1) == '8') {
			System.out.println("pon");
		} else if (n.charAt(n.length() - 1) == '3'){
			System.out.println("bon");
		}
		sc.close();
	}
}

Measured memory_bytes: 27004
#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 FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VLL;
typedef vector<vector<int> > VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
const LL MOD=1000000007ll;
const LL INF=2000000000ll;

long power(long a,long b){return b?power(a*a%MOD,b/2)*(b%2?a:1)%MOD:1;}
long comb(int N,int K)
{
	long x=1,y=1;
	for(int i=1;i<=K;i++)
	{
		x=x*(N-i+1)%MOD;
		y=y*i%MOD;
	}
	return x*power(y,MOD-2)%MOD;
}

long hcomb(int N, int K){
    return comb(N+K-1, N-1);
}

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

    int k;
    cin >> k;
    VPII p(k);
    REP(i,k) cin >> p[i].first >> p[i].second;

    VI order(8);
    REP(i, 8) order[i] = i;
    VVI c(8,VI(8));
    int ok = 1;
    do {
        int chk = 1;
        REP(i,k){
            if (order[p[i].first] != p[i].second) chk = 0;
        }
        if (chk){
            REP(i,8) REP(j,8) c[i][j] = 0;
            REP(i,8) c[i][order[i]] = 1; 
            ok = 1;
            REP(i,8){
                int j = 1;
                while (i-j >= 0 && order[i]-j >= 0){
                    if (c[i-j][order[i]-j]) ok = 0;
                    j++;
                }
                j = 1;
                while (i-j >= 0 && order[i]+j < 8){
                    if (c[i-j][order[i]+j]) ok = 0;
                    j++;
                }
                j = 1;
                while (i+j < 8 && order[i]-j >= 0){
                    if (c[i+j][order[i]-j]) ok = 0;
                    j++;
                }
                j = 1;
                while (i+j < 8 && order[i]+j < 8){
                    if (c[i+j][order[i]+j]) ok = 0;
                    j++;
                }
            }
            if (ok) break;
        }
      	else ok = 0;
    } while(next_permutation(ALL(order)) && (ok^1));

    REP(i,8) {
        REP(j,8){
            if (c[i][j]) cout << 'Q';
            else cout << '.';
        }
        cout << endl;
    }

}


Measured memory_bytes: 3220
#include "bits/stdc++.h"
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(s) s.begin(), s.end()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<string> vs;
const int MX = 100005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;
const int DIV = 2e9+7;

int main() {
    int h, w;
    cin >> h >> w;
    vs grid(h);
    rep(i, h) cin >> grid[i];
    vi skip_row, skip_column;
    bool is_skip;
    rep(row, h) {
        is_skip = true;
        rep(column, w) {
            if (grid[row][column] == '#') {
                is_skip = false; break;
            }
        }
        if (is_skip) skip_row.pb(row);
    }
    rep(column, w) {
        is_skip = true;
        rep(row, h) {
            if (grid[row][column] == '#') {
                is_skip = false; break;
            }
        }
        if (is_skip) skip_column.pb(column);
    }
    rep(row, h) {
        auto it = find(all(skip_row), row);
        if (it != skip_row.end()) continue;
        rep(column, w) {
            auto it = find(all(skip_column), column);
            if (it != skip_column.end()) continue;
            cout << grid[row][column];
        }
        cout << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define pie 3.141592653589793238462643383279
#define int long long
#define mod 1000000007
#define INF 1145141919364364
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>
#define S second
#define F first
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}

int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1)*x%mod;
}

int mod_pow(int x, int y, int mood) {
	int res = 1;
	while (y > 0) {
		if (y & 1)res = res * x%mood;
		x = x * x%mood;
		y >>= 1;
	}
	return res;
}

int comb(int x, int y) {
	return kai(x)* mod_pow(kai(x - y), mod - 2, mod) % mod * mod_pow(kai(y), mod - 2, mod) % mod;
}

string s;
int ans;

signed main() {
	cin >> s;
	ans = (int)s.size();
	for (int i = 1; i < (int)s.size(); i++) {
		if (s[i - 1] == s[i]) {
			ans--;
			i += 2;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 640
from collections import deque

class Graph(): #directed
    def __init__(self, n, edge, indexed=1):
        self.n = n
        self.graph = [[] for _ in range(n)]
        for e in edge:
            self.graph[e[0] - indexed].append(e[1] - indexed)

INF = 10**18

N, M = map(int, input().split())
edge = [tuple(map(int, input().split())) for _ in range(M)]

g = Graph(N, edge)

loopsize = INF

for i in range(N):
    root = i
    queue = deque([root])
    dist = [INF for _ in range(N)]
    dist[root] = 0
    prev = [None for _ in range(N)]
    while queue:
        node = queue.popleft()
        for adj in g.graph[node]:
            if adj == root: #閉路を検出する
                dist[root] = dist[node] + 1
                prev[root] = node
                break
            if dist[adj] != INF:
                continue
            dist[adj] = dist[node] + 1
            prev[adj] = node
            queue.append(adj)
        else:
            continue
        break
    else:
        continue
    #最小の閉路なら条件を満たす
    if loopsize > dist[root]:
        loopsize = dist[root]
        path = [root]
        node = root
        while prev[node] != root:
            node = prev[node]
            path.append(node)

if loopsize != INF:
    print(loopsize)
    for node in path:
        print(node + 1)
else:
    print(-1)

Measured memory_bytes: 9604
a = list(input())
b = list(input())
c = list(input())

s = a[0]

del a[0]

while True:
    if s is 'a':
        if len(a) == 0:
            print('A')
            break

        s = a[0]
        del a[0]
        
    elif s is 'b':
        if len(b) == 0:
            print('B')
            break
        
        s = b[0]
        del b[0]
        
    else:
        if len(c) == 0:
            print('C')
            break
        
        s = c[0]
        del c[0]

Measured memory_bytes: 9020
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define substr(s,f,t) (s.substr(f-1,t-f+1))
#define ALL(a) (a).begin(),(a).end()
#define Yes(hoge) cout<<((hoge)?"Yes":"No")<<endl;
#define YES(hoge) cout<<((hoge)?"YES":"NO")<<endl;
using namespace std;
struct Grid{ll x,y,t;};
struct Edge{ll to,cost;};
struct Graph{vector<vector<Edge>>E;int V;
  const ll Inf = llINF;const int MAX_V=201010;vector<ll>d;
  Graph(int n):E(n){d.resize(MAX_V);E.resize(n);V=n;}
  void init(){for(int i=0;i<MAX_V;i++)d[i]=Inf;}
  void add_edge(ll from,ll to,ll cost){E[from].pb({to,cost});}
};
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll k;
  cin>>k;
  if(k<=(ll)2*(1e16)){
    cout<<2<<endl;
    if(k%2){
      cout<<k/2+2<<" "<<k/2<<endl;
    }else{
      cout<<k/2+1<<" "<<k/2<<endl;
    }
  }else{
    ll num=k/((ll)(1e16));
    if(k%((ll)(1e16))){
      num++;
    }
    vvi list(100);
    ll now=0;
    for(int i=0;i<num;i++){
      for(int j=0;j<num;j++){
	list[i].pb(now);
	now=(now+1)%(num+1);
      }
    }
    cout<<num<<endl;
    for(int i=0;i<num;i++){
      cout<<list[k%num][i]+(k/num)<<" ";
    }
    cout<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"unicode"
)

func main() {
	var wtr = bufio.NewWriter(os.Stdout)
	var alpha string
	fmt.Scan(&alpha)
	r := rune(alpha[0])
	var ans string
	if unicode.IsUpper(r) {
		ans = "A"
	} else {
		ans = "a"
	}
	fmt.Fprintln(wtr, ans)
	_ = wtr.Flush()
}


Measured memory_bytes: 1840
a=input()
if a[-1]=='2'or a[-1]=='4' or a[-1]=='5'or a[-1]=='7'or a[-1]=='9':
    print('hon')
elif a[-1]=='0'or a[-1]=='1'or a[-1]=='6'or a[-1]=='8':
    print('pon')
else:
    print("bon")

Measured memory_bytes: 9052
posi_list=[]
posi_list.append(int(input()))
posi_list.append(int(input()))
posi_list.append(int(input()))
posi_list.append(int(input()))
posi_list.append(int(input()))

k=int(input())
dis_list=0
for posi in posi_list:
    for other_posi in posi_list:
        if abs(other_posi-posi)>k:
            dis_list=1
            break
if dis_list==1:
    print(":(")
else:
    print("Yay!")

Measured memory_bytes: 3064
def run(N, L):
    L = sorted(L)
    ret = 'No'
    if 2*L[-1] < sum(L):
        ret = 'Yes'
    return ret


def main():
    N = int(input())
    L = list(map(int, input().split()))
    print(run(N, L))


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
import java.util.Scanner;
import java.awt.geom.Point2D.Double;
import java.io.InputStreamReader;
public class Main {
private static int merge (int A[], int l, int mid, int right) {
        int cnout = 0;
        int n = mid - l;
        int n2 = right - mid;
        int Lef[] = new int[n+1];
        int R[] = new int[n2+1];
        for (int i = 0; i < n; i++)
            Lef[i] = A[l + i];
        Lef[n] = Integer.MAX_VALUE;
        for (int i = 0; i < n2; i++)
            R[i] = A[mid + i];
        R[n2] = Integer.MAX_VALUE;
        int i = 0,j = 0;
        
        for (int f = l; f < right; f++) {
            cnout++;
            if (Lef[i] <= R[j]) {
                A[f] = Lef[i];
                i++;
            }
            else {
                A[f] = R[j];
                ++j;
            }
        }
        return cnout;
      } 





public static void main(String args[]) {
        Scanner scner = new Scanner(System.in);
        int n;
        int F =0;
        int AB = 100098;
        int A[];
        int counting;
        n = scner.nextInt();
        A = new int[n];
        for (int i = 0; i < n; i++)
            A[i] = scner.nextInt();
        counting = mergeSort(0,A.length,A);
        for (int i = 0; i < A.length; ++i) {
            System.out.print(A[i]);
            if (i != n - 1) System.out.print(" ");
        }
        System.out.println();
        System.out.println(counting);
    }

  private static int mergeSort(int left, int r,int F[]) {
        int cuont = 0;
        if(left + 1 < r) {
            int mid = (left + r) / 2;
            cuont += mergeSort(left, mid, F);
            cuont += mergeSort(mid, r, F);
            cuont += merge(F,left, mid, r);
        }
        return cuont;
    }
    }


Measured memory_bytes: 167140
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <cctype>
#include <cstring>
#include <iostream>
#define fi first
#define se second
#define N 1000005

using namespace std;
typedef long long ll;

template <class T> inline void read(T &x) {
	char ch; bool flag = false;
	while (!isdigit(ch = getchar())) flag |= ch == '-';
	for (x = ch ^ 48; isdigit(ch = getchar()); x = x * 10 + (ch ^ 48));
	if (flag) x = -x;
}

inline int input() {
	int x; char ch; bool flag = false;
	while (!isdigit(ch = getchar())) flag |= ch == '-';
	for (x = ch ^ 48; isdigit(ch = getchar()); x = x * 10 + (ch ^ 48));
	return flag ? -x : x;
}

int mod;
inline int add(int x, int y) { x += y; return x >= mod ? x - mod : x; }
inline void inc(int &x, int y) { x += y; x -= x >= mod ? mod : 0; }

inline int Power(int x, int y) {
	int res = 1;
	while (y) {
		if (y & 1) res = (ll) res * x % mod;
		x = (ll) x * x % mod, y >>= 1;
	} return res;
}

template <class T> void chkmax(T &x, T y) { x = x > y ? x : y; }
template <class T> void chkmin(T &x, T y) { x = x < y ? x : y; }
template <class T> T gcd(T x, T y) { return !y ? x : gcd(y, x % y); }

int n, m, q;
int u[N], v[N], c[N];
bool pd[2][N];
int fa[N];
int g, z;

int Id(int x, int y, int z) { return (x - 1) * 6 + y * 3 + z; }

int find(int x) { return fa[x] == x ? x : fa[x] = find(fa[x]); }
void merge(int x, int y) { fa[find(x)] = find(y); }

int main() {
	ios::sync_with_stdio(false);
	cin >> n >> m >> q >> mod;
	for (int i = 1; i <= m; ++i) {
		cin >> u[i] >> v[i] >> c[i];
		g = gcd(g, abs(c[i] - c[1]));
	}
	if (!g) g = mod;
	mod = gcd(mod, g * 3);
	z = c[1] % g;
	
	for (int i = 1; i <= n * 6; ++i) fa[i] = i;
	for (int i = 1; i <= m; ++i) {
		int w = (c[i] - z) / g;
		for (int p = 0; p <= 1; ++p)
			for (int q = 0; q <= 2; ++q) {
				merge(Id(u[i],p,q),Id(v[i],1-p,(2*q+w)%3));
				merge(Id(v[i],p,q),Id(u[i],1-p,(2*q+w)%3));
			}
	}
	
	for (int i = 0, Pow = z; i < mod << 1; ++i, (Pow <<= 1) %= mod)
		pd[i & 1][Pow] = true;
	
	while (q--) {
		int s, t, r;
		cin >> s >> t >> r;
		bool flag = false;
		for (int p : {0, 1}) for (int q : {0, 1, 2})
			if (find(Id(t, 0, 0)) == find(Id(s, p, q)))
				flag |= pd[p][(r + z + (3 - q) * g) % mod];
		puts(flag ? "YES" : "NO");
	} return 0;
}

Measured memory_bytes: 9856
#include<iostream>
#include<cctype>
#include<cstdio>
using namespace std;

int main()
{
        char ch;

        while( (ch=getchar()) != EOF ){
                        if( islower(ch) ){ ch = toupper(ch); }
                        else{ ch = tolower(ch); }
                        cout << ch;
        }

        return 0;
}

Measured memory_bytes: 1088
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> l_l;
typedef pair<int,int> i_i;
const ll mod=1e9+7;
const int inf=1<<30;

struct unionfind{
  vector<int> par;
  vector<int> rank;
  unionfind(int n=1){
    init(n);
  }
  void init(int n=1){
      par.resize(n); rank.resize(n);
      for(int i=0;i<n;++i) par[i]=i,rank[i]=0;
  }
  int root(int x){
    if(par[x]==x){
      return x;
    }
    else{
      int r=root(par[x]);
      return par[x]=r;
    }
  }
  bool issame(int x,int y){
    return root(x)==root(y);
  }
  bool merge(int x,int y){
    x=root(x); y=root(y);
    if(x==y) return false;
    if(rank[x]<rank[y]) swap(x,y);
    if(rank[x]==rank[y]) ++rank[x];
    par[y]=x;
    return true;
  }
};

int main(){
  int n,m,k;
  cin >> n >> m >> k;
  unionfind uf(n);
  vector<int> fri(n);
  vector<int> blo(n);
  rep(i,m){
    int a,b;
    cin >> a >> b;
    a--; b--;
    if(a>b) swap(a,b);
    uf.merge(a,b);
    fri[a]++; fri[b]++;
  }
  rep(i,k){
    int a,b;
    cin >> a >> b;
    a--; b--;
    if(uf.root(a)!=uf.root(b)) continue;
    blo[a]++; blo[b]++;
  }
  vector<int> ans(n);
  map<int,int> mp;
  rep(i,n){
    mp[uf.root(i)]++;
  }
  rep(i,n){
    ans[i]=mp[uf.root(i)]-fri[i]-blo[i]-1;
  }
  rep(i,n){
    cout << ans[i] << " ";
  }cout << endl;
  /*rep(i,n){
    cout << i<<":"<<uf.root(i) << endl;
  }*/
}

Measured memory_bytes: 7040
#include <cctype>
#include <cassert>
#include <iostream>
using namespace std;
string S;
size_t cur; //?§£???????§???????
int digit() {
  assert(isdigit(S[cur])); //S[cur]?????°?????§???????????¨????¢????
  int n = S[cur] - '0'; // '0'???0?????????
  cur = cur + 1; //??????????????????
  return n;
}
int number() {
  int n = digit();
  while(cur < S.size() && isdigit(S[cur])) { //?¬??????°??????1???????????????
    n = n*10 + digit();
  }
  return n;
}
int expression(); //????????£?¨?
int factor() {
  if(S[cur] != '(') {
    return number();
  }
  cur += 1;
  int n = expression ();
  assert(S[cur] == ')');
  cur +=1;
  return n;
}
int term() {
  int a = factor();
  while(cur < S.size() && (S[cur] == '*' || S[cur] == '/')) {
    char op = S[cur++];
    int b = factor();
    if(op == '*') {
      a *= b;
    }
    else {
      a /= b;
    }
  }
  return a;
}
int expression() {
  int a = term();
  while(cur < S.size() && (S[cur] == '+' || S[cur] =='-')) { //?¶???????????????????????¶???????
    char op = S[cur++];
    int b = term();
    assert(op == '+' || op == '-');
    if(op == '+') {
      a += b;
    }
    else {
      a -= b;
    }
  }
  return a;
}
int main() {
  int N;
  cin >> N;
  for(int i=0; i<N; ++i) {
    cur = 0;
    cin >> S;
    S.resize(S.size() - 1); //?????????=?????????
    cout << expression() << endl;
  }
}

Measured memory_bytes: 1208