akhauriyash/Code-Regression huggingface dataset:
#include<algorithm>
#include<cstring>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
using namespace std;

const int maxn = 300010,inf = 1<<29;
int W,H,N,ans,tree[maxn*4],tag[maxn*4];

inline int gi()
{
	char ch; int ret = 0,f = 1;
	do ch = getchar(); while (!(ch >= '0'&&ch <= '9')&&ch != '-');
	if (ch == '-') f = -1,ch = getchar();
	do ret = ret*10+ch-'0',ch = getchar(); while (ch >= '0'&&ch <= '9');
	return ret*f;
}

struct node
{
	int x,y;
	inline node(int _x = 0,int _y = 0):x(_x),y(_y) {}
	inline void read() { x = gi(); y = gi(); }
	friend inline bool operator <(const node &a,const node &b) { return a.x < b.x; }
}P[maxn];

inline void build(int now,int l,int r)
{
	tree[now] = -inf; tag[now] = 0; if (l == r) return;
	int mid = (l+r) >> 1;
	build(now<<1,l,mid); build(now<<1|1,mid+1,r);
}

inline void pushdown(int now,int l,int r)
{
	if (l != r)
	{
		tree[now<<1] += tag[now]; tag[now<<1] += tag[now];
		tree[now<<1|1] += tag[now]; tag[now<<1|1] += tag[now];
	}
	tag[now] = 0;
}

inline void modify(int now,int l,int r,int ql,int qr,int key)
{
	if (tag[now]) pushdown(now,l,r);
	if (l == ql&&r == qr) { tree[now] += key; tag[now] = key; return; }
	int mid = (l+r) >> 1;
	if (qr <= mid) modify(now<<1,l,mid,ql,qr,key);
	else if (ql > mid) modify(now<<1|1,mid+1,r,ql,qr,key);
	else modify(now<<1,l,mid,ql,mid,key),modify(now<<1|1,mid+1,r,mid+1,qr,key);
	tree[now] = max(tree[now<<1],tree[now<<1|1]);
}

inline void change(int now,int l,int r,int pos,int key)
{
	if (tag[now]) pushdown(now,l,r);
	if (l == r) { tree[now] = key; return; }
	int mid = (l+r) >> 1;
	if (pos <= mid) change(now<<1,l,mid,pos,key);
	else change(now<<1|1,mid+1,r,pos,key);
	tree[now] = max(tree[now<<1],tree[now<<1|1]);
}

inline void work()
{
	sort(P+1,P+N+1); build(1,1,N+1);
	stack <node> S1,S2; int mid = H>>1;
	change(1,1,N+1,1,H); S1.push(node(mid,0)); S2.push(node(H-mid,0));
	for (int i = 1;i <= N;++i)
	{
		ans = max(ans,(P[i].x+tree[1])<<1); int h,last;
		if (P[i].y <= mid)
		{
			for (h = mid,last = i;!S1.empty()&&mid-P[i].y < (S1.top()).x;h = (S1.top()).x,last = (S1.top()).y,S1.pop())
				modify(1,1,N+1,(S1.top()).y+1,last,mid-P[i].y-h);
			if (S1.empty()) S1.push(node(mid-P[i].y,0));
			else modify(1,1,N+1,(S1.top()).y+1,last,mid-P[i].y-h);
			S1.push(node(mid-P[i].y,i));
		}
		else
		{
			for (h = H-mid,last = i;!S2.empty()&&P[i].y-mid < (S2.top()).x;h = (S2.top()).x,last = (S2.top()).y,S2.pop())
				modify(1,1,N+1,(S2.top()).y+1,last,P[i].y-mid-h);
			if (S2.empty()) S2.push(node(P[i].y-mid,0));
			else modify(1,1,N+1,(S2.top()).y+1,last,P[i].y-mid-h);
			S2.push(node(P[i].y-mid,i));
		}
		change(1,1,N+1,i+1,H-P[i].x);
	}
	ans = max(ans,(W+tree[1])<<1);
}

int main()
{
//	freopen("D.in","r",stdin);
//	freopen("D.out","w",stdout);
	W = gi(); H = gi(); N = gi();
	for (int i = 1;i <= N;++i) P[i].read();
	ans = max((H+1)<<1,(W+1)<<1);
	work();
	for (int i = 1;i <= N;++i) swap(P[i].x,P[i].y); swap(H,W);
	work();
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 12672
package main

import "fmt"
import "math"

func main() {
  var A, B int
  fmt.Scan(&A,&B)
  
  ansAmin := math.Ceil(float64(A)/0.08)
  ansBmin := math.Ceil(float64(B)/0.1)
  ansAmax := math.Ceil(float64(A+1)/0.08)
  ansBmax := math.Ceil(float64(B+1)/0.1)
  
  if ansBmin>=ansAmin && ansBmin<ansAmax{
    fmt.Println(ansBmin)
  } else if ansAmin>=ansBmin && ansAmin<ansBmax{
    fmt.Println(ansAmin)
  } else {
    fmt.Println(-1)
  }
}
  


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main()
{
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
string s,t;
cin>>s>>t;
int i=0,k=0;

while(s[i]!='\0')
{
	if(s[i]!=t[i])
		k++;
	i++;
}

cout<<k;



	return 0;
 }

Measured memory_bytes: 3924
#include <bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
using ll = long long;
const ll INF = (ll)1e18L;
const int NMAX = 3030;
template<class X, class Y> X& remin(X& x, Y y) { return x = (y < x ? y : x); }
template<class X, class Y> X& remax(X& x, Y y) { return x = (y > x ? y : x); }
std::string solve(std::string s, std::string t) {
    const int ns = (int)s.size(), nt = (int)t.size();
    s = "?" + s;
    t = "#" + t;
    static int16_t len[NMAX][NMAX], fromS[NMAX][NMAX], fromT[NMAX][NMAX];
    static char with[NMAX][NMAX];    
    for (int is = 1; is <= ns; is++) {
        for (int it = 1; it <= nt; it++) {
            if (s[is] == t[it]) {
                with[is][it] = s[is];
                len[is][it] = len[is-1][it-1] + 1;
                fromS[is][it] = is-1;
                fromT[is][it] = it-1;
            } else if (len[is-1][it] >= len[is][it-1]) {
                with[is][it] = ' ';
                len[is][it] = len[is-1][it];
                fromS[is][it] = is-1;
                fromT[is][it] = it;
            } else {
                with[is][it] = ' ';
                len[is][it] = len[is][it-1];
                fromS[is][it] = is;
                fromT[is][it] = it-1;
            }
        }
    }
    std::string answ;
    int is = ns, it = nt;
    while (is > 0 && it > 0) {
        if (with[is][it] != ' ') answ.push_back(with[is][it]);
        int ps = fromS[is][it];
        int pt = fromT[is][it];
        is = ps;
        it = pt;
    }
    std::reverse(all(answ));
    return answ;
}
int main() {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(0);
    std::string s, t;
    while (std::cin >> s >> t) {
        std::cout << solve(s,t) << std::endl;
    }
    return 0;
}

Measured memory_bytes: 62976
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n, maxi = 0, i = 10, k = 2;
	cin >> n;
	int cur = n / 100;
	int s = cur;
	n %= 100;
	bool flag = 1;
	while(k--){
		if(cur > n / i){
			flag = 1;
			break;
		}
		else if(cur < n / i){
			flag = 0;
			break;
		}
		n %= i;
		i /= 10;
	}
	if(flag)
		for(int j = 0; j < 3; j++)
			cout << s;
	else
		for(int j = 0; j < 3; j++)
			cout << s + 1;
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
#define LL long long
#define PB push_back
#define MP make_pair

int N, C, D[30][30];
int c[3][30] ={};
int main(){
	cin >> N >> C;
	for(int i=0; i<C; i++){
		for(int j=0; j<C; j++){
			cin >> D[i][j];
		}
	}
	for(int i=0; i<N; i++){
		for(int j=0; j<N; j++){
			int tmp;
			cin >> tmp;
			c[(i+j)%3][tmp-1]++;
		}
	}

	int ans = INT_MAX;
	for(int i=0; i<C; i++){
		for(int j=0; j<C; j++){
			for(int k=0; k<C; k++){
				if(i == j || i == k || j == k) continue;
				int t[3]={ i,j,k };
				int sum = 0;
				for(int l=0; l<3; l++){
					for(int n=0; n<C; n++){
						sum += D[n][t[l]] * c[l][n];
					}
				}
				ans = min(ans, sum);
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <cmath>
#include <stack>
#include <map>
#include <iomanip>
using namespace std;

int64_t min(int64_t a,int64_t b) {
    if (a > b)
    {
        return b ;
    }else
    {
        return a ;
    }
}

const int MAX = 510000;
const int MOD = 1000000007;

int64_t fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


int main(){
    int n ;
    cin >> n ;
    vector<int64_t> ans(n+1,0) ;
    for (int x = 1; x < sqrt(n)+1; x++)
    {
        for (int y = 1; y < sqrt(n)+1; y++)
        {
            for (int z = 1; z < sqrt(n)+1; z++)
            {
                int f = x*x + y*y + z*z + x*y + y*z +z*x ;
                if (f <= n)
                {
                    ans.at(f) ++ ;
                }
                
            }
            
        }
        
    }
    for (int i = 1; i < n+1; i++)
    {
        cout << ans.at(i) << endl ;
    }
    
}

Measured memory_bytes: 3508
import sys; sys.setrecursionlimit(2147483647); input = sys.stdin.readline
from math import floor, ceil, sqrt, factorial, log
from collections import Counter, defaultdict
from operator import itemgetter
INF = float('inf'); MOD = 10**9+7
def I(): return int(input())
def MI(): return map(int,input().split())
def LI(): return list(MI())
def LIR(n): return [LI() for i in range(n)]
def S(): return input().rstrip()

def main():
    A, B, C = MI()
    if A==B and A!=C: print('Yes')
    elif A==C and A!=B: print('Yes')
    elif B==C and A!=C: print('Yes')
    else: print('No')
if __name__ == '__main__':
    main()

Measured memory_bytes: 38384
import java.io.*;
import java.util.*;

public class Main {

	
	public static void main(String[] args) {
		FastScanner in=new FastScanner();
		PrintWriter out=new PrintWriter(System.out);
	//	int t=in.nextInt();
	//	while(t-->0)
		solve(in,out);
		out.close();
	}

    static void solve(FastScanner in,PrintWriter out){
    int n=in.nextInt();
    long ans=0;
    long a[]=new long[n];
    long sum[]=new long[n]; long s=0;
    int M=1_000_000_000+7;
    for(int i=0;i<n;i++) { a[i]=in.nextLong(); s+=a[i];  sum[i]=s; }
    for(int i=0;i<n;i++){
        ans=(ans+(((sum[n-1]-sum[i])%M)*a[i])%M)%M;
    }
    out.println(ans);
    }    
	


	static void sort(int[] a) {
		ArrayList<Integer> l=new ArrayList<>();
		for (int i:a) l.add(i);
		Collections.sort(l);
		for (int i=0; i<a.length; i++) a[i]=l.get(i);
	}
	
	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		
		int nextInt() {
			return Integer.parseInt(next());
		}
		int[] readArray(int n) {
			int[] a=new int[n];
			for (int i=0; i<n; i++) a[i]=nextInt();
			return a;
		}
		long nextLong() {
			return Long.parseLong(next());
		}
	}

	
}


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

int main() {
    string s;
    cin >> s;
    
    bool ac = false;
    for(int i=0; i<s.size()-1; ++i) {
         if(s[i] == 'A' && s[i+1] == 'C') {
             ac = true;
             break;
         }
    }
    if(ac) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
from collections import defaultdict
N = int(input())
A = list(map(int, input().split()))

X = [a - i for i, a in enumerate(A, start=1)]
Y = [-a - i for i, a in enumerate(A, start=1)]
memo = defaultdict(int)
ans = 0

for i in range(N - 1):
    memo[Y[i]] += 1
    ans += memo[X[i + 1]]
print(ans)

Measured memory_bytes: 65992
/******************************************
* AUTHOR : HRITIK AGGARWAL *
******************************************/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define N 100005
#define MOD 1000000007
#define dd double
#define vi vector<int>
#define vll vector<ll>
#define forr(i, n) for(int i = 0; i < n; i++)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep1(i,b) for(int i=1;i<=b;i++)
#define pb push_back
#define mp make_pair
#define clr(x) x.clear()
#define sz(x) ((int)(x).size())
#define ms(s, n) memset(s, n, sizeof(s))
#define F first
#define S second
#define int ll
ll po(ll a, ll x,ll m){ if(x==0){return 1;}ll ans=1;ll k=1;  while(k<=x) {if(x&k){ans=((ans*a)%m);} k<<=1; a*=a; a%=m; }return ans; }
int32_t main() {
   
 	int n;
 	cin>>n;
 	int a[n];
 	forr(i,n)
 		cin>>a[i];
 	int b[n];
 	forr(i,n){
 		int k = a[i];
 		k--;
 		b[k]=i+1;
 	}   
 	forr(i,n)
 		cout<<b[i]<<" ";
return 0;
}

Measured memory_bytes: 2432
#include <iostream>
    #include <vector>
    #include <algorithm>
    #include <cmath>
    #include <cstdio>
    #include <string>
    using namespace std;
    #define rep(i,n) for(int i=0;i<n;i++)
    #define INF 100000007
     
    int main() {
    	long long int x, y;
    	cin >> x >> y;
    	int i;
    	for (i = 0; x*(long long int)pow(2, i) <= y; i++);
    	cout << i;
    }

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int cnt_digits(ll N){
 int digits=0;

 while(N>0){
 N/=10;
 digits++;
 }

 return digits;
 }

 int main(void){
 ll N;
 cin >> N;

 int ans=cnt_digits(N); // 1*N=N max(cnt_digits(1),cnt_digits(N))=cnt_digits(N)

 for(ll A=1LL;A*A<=N;++A){
 if(N%A!=0) continue;
 const ll B=N/A;

 const int cur=max(cnt_digits(A),cnt_digits(B));

 if(ans>cur){
 ans=cur;
 }
 }

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

Measured memory_bytes: 3644
n = int(input())
 
ansl = []
if n == 0:
    print("0")
    exit()
while n:
    if n % -2 == 0:
        ansl.append("0")
    else:
        n -= 1
        ansl.append("1")
    n = n // -2
 
ansl.reverse()
print("".join(ansl))

Measured memory_bytes: 38384
#include <stdio.h>
int main(){
    int n,a[1000]={0},tmp,i,j,k;
    scanf("%d",&n);
    for(i = 0; i < n; i++){
        scanf("%d",&a[i]);
    }
    for(j = 0; j < n/2; j++){
        tmp = a[j];
        a[j] = a[n-j-1];
        a[n-j-1] = tmp;
    }
    for(k = 0; k<n-1; k++){
        printf("%d ",a[k]);

    }
    printf("%d\n",a[n-1]);
    return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <math.h>
#include <vector>
#include <queue>
#include <map>
#include <utility>
using namespace std;

void trace(int a[], int n)
{
    for (int i = 0; i < n - 1; i++)
        cout << a[i] << " ";
    cout << a[n - 1] << "\n";
}

void swap(int *x, int *y)
{
    int tmp = *x;
    *x = *y;
    *y = tmp;
}

void bubbleSort(int a[], int n)
{
    //trace(a, n);
    bool flag = true;
    int count = 0;
    while (flag)
    {
        flag = false;
        for (int i = n - 1; i >= 0; i--)
        {
            if (a[i] < a[i - 1])
            {
                flag = true;
                swap(&a[i], &a[i - 1]);
                count++;
            }
        }
    }
    trace(a, n);
    cout << count << "\n";
}

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

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

    bubbleSort(a, n);
    

    return 0;
}



Measured memory_bytes: 3104
#include <bits/stdc++.h>
#include<vector>
using namespace std;
 vector<bool> S(13);
  vector<bool> H(13);
   vector<bool> C(13);
    vector<bool> D(13);
int main() {
    int a,c;
    char b;
    cin>>a;
    for(int i=0;i<a;i++){
        cin>>b>>c;
        if(b=='S'){
            S.at(c-1)=true;
        }
                if(b=='H'){
            H.at(c-1)=true;
        }
                if(b=='C'){
            C.at(c-1)=true;
        }
                if(b=='D'){
            D.at(c-1)=true;
        }
    }
        for(int i=0;i<13;i++){
        if(S.at(i)==false){
            cout<<"S"<<" "<<i+1<<endl;;
        }
    }
            for(int i=0;i<13;i++){
        if(H.at(i)==false){
            cout<<"H"<<" "<<i+1<<endl;
        }
    }
            for(int i=0;i<13;i++){
        if(C.at(i)==false){
            cout<<"C"<<" "<<i+1<<endl;
        }
    }
            for(int i=0;i<13;i++){
        if(D.at(i)==false){
            cout<<"D"<<" "<<i+1<<endl;
        }
    }
}


Measured memory_bytes: 3084
#include "bits/stdc++.h"
using namespace std;
 
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);

    int n;
    cin >> n;
    
    int a[n];

    for(int& i : a)cin >> i;
    
    int mx=a[0];

    long long stool=0;

    for(int i=1;i<n;i++){
        if(a[i]<mx){
            stool+=mx-a[i];
        }
        else{
            mx=a[i];
        }
    }
    cout<<stool<<endl;
}



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

int main(){
	int N,Q;
	string S;
	cin >> N >> Q >> S;
	vector<int> A(N+1,0);
	for(int i=1;i<N;i++){
		if(S[i-1]=='A' && S[i]=='C')A[i]=A[i-1]+1;
		else A[i]=A[i-1];
	}
	A[N]=A[N-1];
	vector<int> ans(Q);
	for(int i=0;i<Q;i++){
		int l,r;
		scanf("%d%d",&l,&r);
		ans[i]=A[r]-A[l-1];
		if(r<N && S[r-1]=='A' && S[r]=='C')ans[i]--;
	}
	for(int i=0;i<Q;i++)printf("%d\n",ans[i]);
	return 0;
}

Measured memory_bytes: 1792
n = int(input())
a = []
for i in range(n):
    num = int(input())
    for j in range(num):
        hi, tf = map(int,input().split())
        a.append([i,hi-1,tf])

m = 0
for i in range(1,2**n):
    se = format(i,'b').zfill(n)
    fl = True
    for j in a:
        if se[j[0]] == "1":
            if int(se[j[1]])^j[2] == 1:
                fl = False
                break
    if fl:
        m = max([m,se.count("1")])

print(m)


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

int main(){
  int N,L;
  cin >> N >> L;
  vector<string> S(N);
  rep(i,N){
    cin >> S.at(i);
  }
  sort(S.begin(),S.end());
  rep(i,N){
    cout << S.at(i);
  }
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
  int n, m, i, j, k;
  int hoge[100][100] = {};
  int foo[100] = {};
  int res[100] = {};
  scanf("%d%d", &n, &m);
  for ( i = 0; i < n; i++) {
    for (j = 0; j < m; j++) {
      scanf("%d", &hoge[i][j]);
    }
  }
  for (i = 0; i < m; i++) {
    scanf("%d", &foo[i]);
  }
  for (i = 0; i < n; i++) {
    for (j = 0; j < m; j++) {
      res[i] += hoge[i][j]*foo[j];
    }
    printf("%d\n", res[i]);
  }
  return 0;
}

Measured memory_bytes: 648
import java.io.PrintWriter
import java.util.ArrayDeque

fun main(args: Array<String>) {
    PrintWriter(System.out).use { out ->
        solve(out)
        out.flush()
    }
}

/** edge info */
data class Edge<T>(val to: Int, var cost: T)


fun solve(out: PrintWriter) {
    val (n, x, y) = readIntegerList()

    /** incidenceList[fromNodeIndex]: edges to other node */
    val incidenceList = Array(n) { mutableListOf<Edge<Int>>() }
    for (i in 0 until n - 1) {
        incidenceList[i].add(Edge(i + 1, 1))
        incidenceList[i + 1].add(Edge(i, 1))
    }
    incidenceList[x - 1].add(Edge(y - 1, 1))
    incidenceList[y - 1].add(Edge(x - 1, 1))

    val ans = IntArray(n - 1)
    for (i in 0 until n) {
        val costArray = IntArray(n)
        val isChecked = BooleanArray(n)
        val queue = ArrayDeque<Int>()
        queue.addLast(i)
        isChecked[i] = true
        while (queue.isNotEmpty()) {
            val node = queue.removeFirst()

            for (edge in incidenceList[node]) {
                if (isChecked[edge.to] == false) {
                    costArray[edge.to] = costArray[node] + 1
                    isChecked[edge.to] = true
                    queue.addLast(edge.to)
                }
            }
        }

        for (j in (i + 1) until n) {
            ans[costArray[j] - 1]++
        }
    }

    println(ans.joinToString("\n"))
}

fun readInteger() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntegerList() = readStringList().map(String::toInt)
fun readLongList() = readStringList().map(String::toLong)
fun readDoubleList() = readStringList().map(String::toDouble)


Measured memory_bytes: 106608
import Control.Monad
import Data.List

main = do
 [a,b] <- map (read :: String -> Int).words<$>getLine
 s <- replicateM a (getLine)
 putStrLn.unlines $ solve s

solve s = transpose $ sieve $ transpose (sieve s)

sieve :: [[Char]] -> [[Char]]
sieve [] = []
sieve (a:as) | elem '#' a = [a] ++ sieve as
 | otherwise = sieve as

Measured memory_bytes: 1916
package main

import (
	"math/rand"
	"time"
	"os"
	"bufio"
	"fmt"
	"strconv"
)

var(
	inf = 10000000071000000
	stdin = bufio.NewReader(os.Stdin)
	mod = 1000000007
	mod9 = 1000000009
	//////////////////////////////////
	stack []byte
)

func init()  {
	rand.Seed(time.Now().UnixNano())
}

type zahyo struct {
	x int
	y int
}

func main() {
	s := gostring()
	count := 0
	l,r := 0,len(s)-1
	for {
		if l >= r{break}
		if s[l] == s[r]{
			l++;r--
		} else {
			if s[l] == 'x' {
				count ++
				l++
			} else if s[r] == 'x'{
				count ++
				r --
			} else {
				fmt.Println(-1)
				os.Exit(0)
			}
		}
	}
	fmt.Println(count)
}


//||||||||||||||||||||||||||入力|||||||||||||||||||||||||||||||||||||||

//次のスペースか改行まで読み込む
func gostring() string {
	byte_ls := make([]byte,0)
	for  {
		b, _ := stdin.ReadByte()
		if b == 32 || b == 10 || b == 0{
			return string(byte_ls)
		} else if b == 13 {
			continue
		} else {
			byte_ls = append(byte_ls,b)
		}
	}
}

//上の関数のintバージョン
func goint() int {
	n,_ := strconv.Atoi(gostring())
	return n
}

//数字一行
func intLine(n ,a int) []int {
	ls := make([]int,n)
	for i,_ := range ls{
		ls[i] = goint() + a
	}
	return ls
}

//|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||

func sum(a ...int) int {
	ans := 0
	for i:=0;i<len(a);i++{
		ans += a[i]
	}
	return ans
}

func min(a ...int) int {
	ans := a[0]
	for i:=1;i<len(a);i++{
		if ans > a[i]{
			ans = a[i]
		}
	}
	return ans
}

func abs(n int) int {
	if n >= 0{
		return n
	} else {
		return -n
	}
}

func max(a ...int) int {
	ans := a[0]
	for i:=1;i<len(a);i++{
		if ans < a[i]{
			ans = a[i]
		}
	}
	return ans
}

func intList(n,k int) []int {
	ls := make([]int,n)
	for i:=0;i<n;i++{
		ls[i] = k
	}
	return ls
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define endl '\n'

using namespace std;

const int MOD = (1e9) + 7;
const int N = 100007;

int state[N][15];
bool used[N][15];
string s;

int recurse(int pos, int rem) {
  if(pos>=(int)(s.size())) {
    return rem==5;
  }

  if(used[pos][rem]) return state[pos][rem];

  long long ans = 0;

  if(s[pos]=='?') {
    for(int i=0;i<10;i++) {
      ans += recurse(pos + 1, (rem * 10 + i) % 13);
    }

    ans %= MOD;
  } else {
    ans = recurse(pos + 1, (rem * 10 + s[pos] - 48) % 13);
  }

  used[pos][rem] = true;
  return state[pos][rem] = ans;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  cin>>s;
  cout<<recurse(0, 0)<<endl;

  return 0;
}


Measured memory_bytes: 15696
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>


using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD (ll)1000000007
#define P pair<ll, ll>



int main() {
	ll a, b;
	cin >> a >> b;
	cout << max(0ll, a - b * 2) << endl;
}


Measured memory_bytes: 256
use proconio::{input, fastout};
use proconio::marker::{Chars};
use proconio::marker::Usize1;
use std::cmp::*;

macro_rules! debug {
      ($($a:expr),*) => {
          eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

#[fastout]
fn main() {
    input!{
        n: Chars,
    }

    if (n[0]==n[1] && n[1]==n[2]) || (n[1]==n[2] && n[2]==n[3]) {
        println!("Yes");
    } else {
        println!("No");
    }

}


Measured memory_bytes: 2192
X, Y = map(str, input().split())
if X == 'A':
    x = 10
elif X == 'B':
    x = 11
elif X == 'C':
    x = 12
elif X == 'D':
    x = 13
elif X == 'E':
    x = 14
elif X == 'F':
    x = 15

if Y == 'A':
    y = 10
elif Y == 'B':
    y = 11
elif Y == 'C':
    y = 12
elif Y == 'D':
    y = 13
elif Y == 'E':
    y = 14
elif Y == 'F':
    y = 15

if x < y:
    print('<')
elif x == y:
    print('=')
else:
    print('>')


Measured memory_bytes: 38256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
using namespace std;
#define REP(i, n)  for (int i = 0; i < (int) (n); i++)
#define REP1(i, n) for (int i = 1; i <= (int) (n); i++)
#define all(x)     (x).begin(), (x).end()
#define SZ(x)      ((int) (x).size())
int main(){
    int N,M,sum;
    cin>>N>>M;
    cout<<(N*(N-1)+M*(M-1))/2<<endl;
}

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

int main(){

    // omajinai
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    // omajinai

    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0;i < n;i ++){
        cin >> a.at(i);
    }

    map<int,int> mp;
    for(int i = 0;i < n;i ++){
        mp[a.at(i)] ++;
    }

    int ans = 0;

    for(auto p: mp){
        if(p.first > p.second){
            ans += p.second;
        }else{
            ans += p.second - p.first;
        }
    }

    cout << ans << endl;
}

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

using namespace std;

// self-made function version
int my_gcd(int a, int b) {
    // ベースケース
    if (b == 0) {
        return a;
    }

    // 再帰ステップ
    return my_gcd(b, a % b);
}

int main() {
    int K;
    cin >> K;

    int sum = 0;
    for (int a = 1; a <= K; a++) {
        for (int b = 1; b <= K; b++) {
            for (int c = 1; c <= K; c++) {
                sum += my_gcd(my_gcd(a, b), c);
            }
        }
    }

    cout << sum << endl;

    return 0;
}


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

using namespace std;

int main(){
	long n;
	vector<long> a;
	long ans=0;
	long times=1;

	cin>>n;

	for(long i=0; i<n; i++){
		long tmp;
		cin>>tmp;
		a.push_back(tmp);
	}

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

	for(long i=0; i<a.size()-1; i++){
		if(a.at(i)==a.at(i+1)){
			times++;
			if(i==a.size()-2 && times%2==1){
				ans++;
			}

		}else{
			if(i==a.size()-2){
				ans++;

			}

			if(times%2==1){
				ans++;
			}
			times=1;
		}
	}

	if(n == 1)
		ans=1;

	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 1400
//#include "debug.h"
#include <string.h>
#include <limits.h>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
using namespace std;

#define MAXN 100000

int n;
int s[3], t[3];

int input() {
	for (int i=0; i<3; i++) {
		if (scanf("%d %d", &s[i], &t[i]) < 0) return 0;
		s[i]--, t[i]--;
	}
	return 1;
}

void init() {
}

int check(int *e, int m) {
	int mark[4]={0};
	for (int i=0; i<m-1; i++)
		if (t[e[i]] != s[e[i+1]])
			swap(t[e[i+1]], s[e[i+1]]);
	mark[s[e[0]]] = 1;
	for (int i=0; i<m; i++) {
		if (i<m-1 && t[e[i]] != s[e[i+1]]) return 0;
		mark[t[e[i]]] = 1;
	}
	for (int i=0; i<4; i++)
		if (!mark[i]) return 0;
	return 1;
}

long solve() {
	int e[3]={0,1,2};
	while (1) {
		if (check(e, 3)) return 1;
		swap(s[e[0]], t[e[0]]);
		if (check(e, 3)) return 1;
		if (!next_permutation(e,e+3)) break;
	}
	return 0;
}

void output(long ans) {
	printf("%s\n", ans? "YES":"NO");
}

void cleanup() {
}

int main() {
	while (input()) {
		init();
		output(solve());
		cleanup();
		//break;
	}
}





Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int n;
int a[110];
int main(){
	scanf("%d",&n);
	for (register int i=1; i<=n; ++i) scanf("%d",&a[i]);
	bool jay=true;
	for (register int i=1; i<=n; ++i) 
	if (a[i]%2==0 && a[i]%3!=0 && a[i]%5!=0) {jay=false; break;}
	if (!jay) puts("DENIED");
	else puts("APPROVED");
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
using namespace std;
int main() {
  
  string S;cin>>S;
  
  if(S[0]==S[1]&&S[2]==S[3]&&S[0]!=S[2]){
    cout<<"Yes"<<endl;
  }
  else if(S[0]==S[2]&&S[1]==S[3]&&S[0]!=S[1]){
    cout<<"Yes"<<endl;
  }
  else if(S[0]==S[3]&&S[1]==S[2]&&S[0]!=S[1]){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}

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

using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
const int N = 1e3 + 10;
const int mod = 998244353;
const double eps = 1e-8;

LL n;
int a[] = {2, 3, 5, 7};
int check(LL n) {
    for(int i = 0; i < 4; i++) {
        if(n % a[i] == 0) return 1;
    }
    return 0;
}

int main()
{
    cin>>n;
    cout<<"Christmas";
    for(int i=0;i<25-n;i++) cout<<" Eve";


    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		while (true) {
			int n = scn.nextInt();
			int x = scn.nextInt();
			int sum = 0;
			if (n == 0 && x == 0) {
				break;
			}
			for (int i = 1; i <= n; i++) {
				for (int j = i + 1; j <= n; j++) {
					for (int k = j + 1; k <= n; k++) {
						if (i + j + k == x) {
							sum++;
						}
					}
				}
			}
			System.out.println(sum);
		}
	}
}



Measured memory_bytes: 26948
import static java.util.Arrays.deepToString;

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		new Main().run();
	}
	Scanner sc = new Scanner(System.in);
	public void run() {
		int t = sc.nextInt();
		for (int tt = 0; tt < t; tt++) {
			solve();
		}
	}
	void solve() {
		int score = 0;
		int[] base = {0, 0, 0, 0};
		for (int out = 0; out < 3;) {
			String s = sc.next();
			if (s.equals("OUT")) {
				out++;
			} else if (s.equals("HIT")) {
				score += base[3];
				base[3] = base[2];
				base[2] = base[1];
				base[1] = 1;
			} else if (s.equals("HOMERUN")) {
				score += 1 + base[1] + base[2] + base[3];
				base[1] = base[2] = base[3] = 0; 
			}
		}
		System.out.println(score);
	}
}

Measured memory_bytes: 17196
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <tuple>

using lint = long long;
using ldouble = long double;

using namespace std;

template <class T>
using greater_priority_queue = priority_queue<T, vector<T>, greater<T>>;

struct Edge {
    int dst, cost;
    Edge(int dst, int cost) : dst(dst), cost(cost) {}
};

const int INF = 1 << 30;

int N;

inline int encode(int v, int m) {
    return v + m * N;
}

bool solve() {
    int M, L, K, A, H;
    cin >> N >> M >> L >> K >> A >> H;
    if (N == 0) return false;

    vector<vector<Edge>> graph(N * (M + 1));
    for (int i = 0; i < L; ++i) {
        int v;
        cin >> v;
        for (int m = 0; m < M; ++m) {
            graph[encode(v, m)].emplace_back(encode(v, m + 1), 1);
        }
    }

    for (int i = 0; i < K; ++i) {
        int u, v, d;
        cin >> u >> v >> d;
        for (int m = 0; m + d <= M; ++m) {
            graph[encode(u, m + d)].emplace_back(encode(v, m), d);
            graph[encode(v, m + d)].emplace_back(encode(u, m), d);
        }
    }

    vector<int> dist(N * (M + 1), INF);
    dist[encode(A, M)] = 0;
    greater_priority_queue<pair<int, int>> que;
    que.emplace(0, encode(A, M));

    while (!que.empty()) {
        int d, v;
        tie(d, v) = que.top();
        que.pop();

        if (dist[v] < d) continue;
        for (auto e : graph[v]) {
            if (dist[e.dst] <= d + e.cost) continue;
            dist[e.dst] = d + e.cost;
            que.emplace(dist[e.dst], e.dst);
        }
    }

    int ans = INF;
    for (int m = 0; m <= M; ++m) {
        ans = min(ans, dist[encode(H, m)]);
    }

    cout << (ans == INF ? "Help!" : to_string(ans)) << endl;
    return true;
}

int main() {
    while (solve()) {}
    return 0;
}



Measured memory_bytes: 4696
N,A,B = map(int,input().split())

mod = 10**9 + 7
def cmb(n,r,mod):
	a=1
	b=1
	r = min(r,n-r)
	for i in range(r):
		a = a*(n-i)%mod
		b = b*(i+1)%mod
	return a*pow(b,mod-2,mod)%mod

all = pow(2,N,mod) + mod
nCa = cmb(N,A,mod)
nCb = cmb(N,B,mod)

ans = all - nCa - nCb
print((ans-1)%mod)

Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<algorithm>
#include<stdio.h>
#include<math.h>
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define RFOR(i, a, b) for(int i=(a);i>(b);i--)
using namespace std;
 
int main(void) {
	int n;
	int* p;
	int count = 0;
	int point = 0;
	bool* check;
 
	cin >> n;
	p = new int[n + 1];
	check = new bool[n + 1];
	FOR(i, 1, n + 1) {
		cin >> p[i];
	}
	FOR(i, 1, n+1) {
		if (p[i] == i) {
			check[i] = 1;
		}
	}
	FOR(i, 1, n + 1) {
		if (check[i]==1) {
			point++;
		}
		else {
			if (point > 0) {
				if (point % 2 == 0) {
					point /= 2;
				}
				else {
					point = (point / 2) + 1;
				}
			}
			count = count + point;
			point = 0;
		}
		if ((point > 0) && (i == n)) {
			if (point % 2 == 0) {
				point /= 2;
			}
			else {
				point = (point / 2) + 1;
			}
			count = count + point;
		}
	}
	cout << count << endl;
	delete[] p;
	delete[] check;
	return 0;
}

Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
typedef long long       ll;
#define MOD ((int)1e9+7)
#define N ((int)2e5+123)
void reads(string& x){ char kk[N]; scanf("%s",kk); x = kk;}
ll n,m,k, ans, a[N],b[N], sa[N], soma;
void solve(){
    scanf("%lld %lld %lld", &n,&m,&k);
    //vector<int> sa(n+10);
    //printf("%d\n",k);
    for(int i=0;i<n;i++){
        scanf("%lld",a+i);
        if(i)sa[i] = sa[i-1]+a[i];
        else sa[0] = a[0];
    }
    ans = upper_bound(sa,sa+n,k) - sa;
    for(int i=0;i<m;i++){
        scanf("%lld",b+i);
        soma+=b[i];
        if(k-soma>=0) ans = max(ans, (ll)(i + 1 + (upper_bound(sa,sa+n,k-soma) - sa)));
        //printf("%lld %lld %d\n",soma, k-soma,((upper_bound(sa,sa+n,k-soma) - sa)));
    }
    printf("%lld\n", ans);
}

int main(){
    ios_base::sync_with_stdio(0);
    int t = 1; //scanf("%d",&t);
    for(int caso=1;caso<=t;caso++){
        solve();
    }
}

Measured memory_bytes: 8544
#include <iostream>
#include <string>

using namespace std;


int main()
{
	int N;
	string S;
	long long count = 0;
	long long sum = 0;
	long long r = 0, g = 0, b = 0;

	cin >> N;
	cin >> S;


	for (int i = 0; i < N; i++)
	{
		if (S[i] == 'R') r++;
		if (S[i] == 'G') g++;
		if (S[i] == 'B') b++;
	}

	sum = r * g * b;

	for (int i = 0; i < N; ++i)
	{
		for (int j = i + 1; j < N; ++j)
		{
			int k = j + j - i;
			if (k < N)
			{
				if (S[i] != S[j] && S[i] != S[k] && S[j] != S[k])
				{
					count++;
				}
			}


		}

	}


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

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

int main(){
    int k, n, maxl = 0,start, res = 0;
    cin >> k >> n;
    vector<int> a(n);
    pair<int,int> p;

    for(int i = 0; i < n; i++){
        cin >> a.at(i);
    }

    for(int i = 1; i < n; i++){
        if(a.at(i)-a.at(i-1) > maxl){
            maxl = a.at(i)-a.at(i-1);
            p = make_pair(a.at(i),a.at(i-1));
            start = a.at(i-1);
        }
    }
    if(k - a.at(n-1) + a.at(0) > maxl){
            maxl = k - a.at(n-1) + a.at(0);
            p = make_pair(a.at(0),a.at(n-1));
            start = a.at(n-1);
    }

    if(a.at(n-1) != start){
        res += k - a.at(n-1) + a.at(0);
    }
    for(int i = 0; i < n - 1; i++){
        if(a.at(i) != start){
            res += a.at(i+1) - a.at(i);
        }
    }
    cout << res << endl;
}

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

int main() {
    int s; cin>>s;
    int h = s/3600;
    s %= 3600;
    int m = s/60;
    s %= 60;
    int sec = s;
    cout<<h<<':'<<m<<':'<<sec<<endl;
}


Measured memory_bytes: 3104
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <cmath>
using namespace std;
#define MOD 1000000007
#define INF 1<<30
#define LINF (ll)1<<62
#define MAX 510000
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
#define uni(q) unique(all(q)),q.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;

int main(){
    ll x,a,b; cin >> x >> a >> b;
    cout << (x-a)%b << endl;
}


Measured memory_bytes: 256
//Jai Bhole Ki
#include <bits/stdc++.h>
using namespace std;
#define fast int fvariable = []() { std::ios::sync_with_stdio(false); cin.tie(NULL); return 0; }();
#define ll long long
#define LL unsigned ll
#define pb push_back
#define pi pair<ll,ll>
#define debug(x) cout<<x<<"\n";
#define debug cout<<"debugged\n";
#define minval -2e9
#define maxval 2e9
long double PI =3.14159265358979323846;
 
const ll M=1e9+7;
const ll inf=1e18;
const ll ms=2e5+5;
fast;
ll ans;
ll y,a,b,c,d;
void solve()
{
    cin>>a>>b>>c>>d;
    ll i=1;
    while(a>0&&c>0)
    {
        if(i%2)
            c-=b;
        else
            a-=d;
        i++;
    }
    if(a>0)
    {
        cout<<"Yes"<<endl;
    }
    else
        cout<<"No"<<endl;
}
int main()
{
 // freopen("input.txt","r",stdin);
//  freopen("output.txt","w",stdout);
    //int t;cin>>t;while(t--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3616
from collections import defaultdict

def prime_factorization(n):
    '''
    Trial division.
    Input: 
        n : a positive integer
    Output:
        a dictionary of #(each prime factors) of n,
    '''
    result = defaultdict(int)
    if n < 2:
        return result
    while n % 2 == 0:
        result[2] += 1
        n //= 2
    p = 3
    while p*p <= n:
        while n % p == 0:
            n //= p
            result[p] += 1
        p += 2
    if n > 1:
        result[n] += 1
    return result

N, P = map(int, input().split())
factors = prime_factorization(P)
ans = 1
for p, n in factors.items():
    ans *= p ** (n // N)
print(ans)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
static const int INF = 1<<30;
static const int SIZE = 100000+10;

int main(){
    int n;
    cin>>n;
    vector<int> dp(SIZE,INF);
    dp[0] = 0;

    for(int i=1; i<=n; i++){
        
        for(int six=1; six<=i; six *= 6){
            if(i-six < 0) continue;
            dp[i] = min(dp[i],dp[i-six]+1);
        }

        for(int nine=1; nine<=i; nine *= 9){
            if(i-nine < 0) continue;
            dp[i] = min(dp[i],dp[i-nine]+1);
        }
    }

    cout<<dp[n]<<endl;

    return 0;
}



Measured memory_bytes: 640
import numpy as np

N,D = map(int, input().split())

x = [list(map(int, input().split())) for _ in range(N)]
#print(x_list)
cnt=0
for i in range(N):
    for j in range(i+1,N):
        tmp=0
        for k in range(D):
            tmp += pow((x[i][k]-x[j][k]),2)
        tmp = np.sqrt(tmp)
        if tmp.is_integer()==True:
            cnt+=1
print(cnt)

Measured memory_bytes: 12428
#include<iostream>
#include<cstdio>
using namespace std;
const int MAX = 500000;
const int maxnum = 1000000010;

// ???????±???¨??°???
int L[MAX / 2 + 2], R[MAX / 2 + 2];
int A[MAX], n;
long long cnt ;

// ??????????????¶
void merge(int left, int mid, int right) {
	int n1 = mid - left;
	int n2 = right - mid;
	for (int i = 0; i < n1; i++) L[i] = A[left + i];
	for (int i = 0; i < n2; i++) R[i] = A[mid + i];

	// ???????±???¨??°?????????????????????????????§?????°
	L[n1] = R[n2] = maxnum;
	int i = 0, j = 0;
	// ?????¶
	for (int k = left; k < right; k++) {
		if (L[i] <= R[j])
			A[k] = L[i++];
		else {
			A[k] = R[j++];
			cnt += n1 - i;
		}
	}
}
// ??????
void mergeSort(int left, int right) {
	if (left + 1 < right) {
		int mid = (left + right) / 2;
		mergeSort(left, mid);
		mergeSort(mid, right);
		merge(left, mid, right);
	}
}
int main() {

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

	mergeSort(0, n);
	printf("%lld\n", cnt);
	return 0;
}

Measured memory_bytes: 4772
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cstddef>
#include<queue>
#include<math.h>
#include<iomanip>
using namespace std;

int main()
{
    int n, q, ans = 0;
    cin >> n >> q;
    string s;
    cin >> s;
    vector<int> l(q), r(q), a(n);
    for(int i = 0; i < q; ++i) cin >> l.at(i) >> r.at(i);
    for(int i = 0; i < n - 1; ++i){
        if(i != 0) a.at(i + 1) = a.at(i);
        if(s.at(i) == 'A' && s.at(i + 1) == 'C') a.at(i + 1)++;
    }
    for(int i = 0; i < q; ++i){
        ans = a.at(r.at(i) - 1) - a.at(l.at(i) - 1);
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 4508
n, m = map(int, input().split())
a = [0]*m
for i in range(m):
  a[i] = int(input())

up = [0]*(m+1)
if m == 0:
  up[0] = n
else:
  up[0] = a[0]-1
  up[m] = n - a[m-1]-1
  for i in range(m-1):
    up[i+1] = a[i+1]-a[i]-2

ans = 1
if -1 in up:
  ans = 0
else:
  f = [0]*(max(up)+1)
  f[0] = 1
  if max(up) > 0:
    f[1] = 1
    for i in range(2, max(up)+1):
      f[i] = f[i-1] + f[i-2]
  for i in range(m+1):
    ans *= f[up[i]]

print(ans % 1000000007)

Measured memory_bytes: 460020
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<stack>
#include<queue>
#include<vector>
#include<set>
#include<map>
#include<string>
#define ls k<<1,l,mid
#define rs k<<1|1,mid+1,r
#define mp(x,y) make_pair(x,y)
#define r(x) read(x)
#define rr(x,y) read(x);read(y)
#define rrr(x,y,z) read(x);read(y);read(z)
#define FOR(i,l,r) for(int i=l;i<=r;i++)
#define pb(x) push_back(x)
#define sss(str) scanf("%s",str+1)
#define ssf(x) scanf("%lf",&x)
#define aLL(x) x.begin(),x.end()
#define fi first
#define se second
using namespace std;
typedef long long LL;
typedef double dd;
typedef pair<LL,LL> pt;
const int N=2e5+5;
const int M=2e2+5;
const int INF=0x7fffffff;
const int mod=1e9+7;
const int sz=18;
const double eps=1e-10;
const double pi=acos(-1);
//***********************
int n,m;
int dad[N];
int num[N];
vector<int> v[N];
//***********************
template<class T>
inline void read(T &x)
{
    char c;
    x=1;
    while((c=getchar())<'0'||c>'9') if(c=='-') x=-1;
    T res=c-'0';
    while((c=getchar())>='0'&&c<='9') res=res*10+c-'0';
    x*=res;
}
int seek(int k)
{
    return dad[k]==k?k:dad[k]=seek(dad[k]);
}
int main()
{
    int k;
    rrr(n,m,k);
    FOR(i,1,n)
    {
        dad[i]=i;
        num[i]=1;
    }

    FOR(i,1,m)
    {
        int a,b;
        rr(a,b);
        v[a].pb(b);
        v[b].pb(a);
        int fa=seek(a);
        int fb=seek(b);
        if(fa!=fb)
        {
            dad[fa]=fb;
            num[fb]+=num[fa];
        }
    }

    FOR(i,1,k)
    {
        int a,b;
        rr(a,b);
        v[a].pb(b);
        v[b].pb(a);
    }
    for(int i=1;i<=n;i++)
    {
        //cout<<dad[i]<<" ";
    }
    //cout<<endl;
    for(int i=1;i<=n;i++){
        //cout<<num[i]<<" ";
    }
    //cout<<endl;
    FOR(i,1,n)
    {
        int x=seek(i);
        int ans=num[x];
        for(int j:v[i])
        {
            int y=seek(j);
            if(x==y) ans--;
        }
        cout<<ans-1<<' ';
    }
    cout<<endl;
}



Measured memory_bytes: 11640
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
   int a,b,c,x,y;
   cin>>a>>b>>c;
   if(a>=b&&a>=c&&b>=c)
   {
       x=a-b;
       y=b-c;
       cout<<x+y;
   }
   else if(a>=b&&a>=c&&c>=b)
   {
       x=a-c;
       y=c-b;
       cout<<x+y;
   }
   else if(a>=b&&a<=c)
   {
       x=c-a;
       y=a-b;
       cout<<x+y;
   }
   else if(a<=b&&a>=c)
   {
       x=b-a;
       y=a-c;
       cout<<x+y;
   }
   else if(a<=b&&a<=c&&b<=c)
   {
       x=c-b;
       y=b-a;
       cout<<x+y;
   }
   else if(a<=b&&a<=c&&c<=b)
   {
       x=b-c;
       y=c-a;
       cout<<x+y;
   }



    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<map>
using namespace std;
int main(){
  map<int,char> m;
  m['a'] = 0;
  m['z'] = 1;
  m['y'] = 2;
  m['x'] = 3;
  m['w'] = 4;
  m['v'] = 5;
  m['u'] = 6;
  m['t'] = 7;
  m['s'] = 8;
  m['r'] = 9;
  m['q'] = 10;
  m['p'] = 11;
  m['o'] = 12;
  m['n'] = 13;
  m['m'] = 14;
  m['l'] = 15;
  m['k'] = 16;
  m['j'] = 17;
  m['i'] = 18;
  m['h'] = 19;
  m['g'] = 20;
  m['f'] = 21;
  m['e'] = 22;
  m['d'] = 23;
  m['c'] = 24;
  m['b'] = 25;
  string s;
  int n;
  cin >> s >> n;
  for(int i=0;i<s.size();i++){
    if(m[s[i]]<=n){
      n -= m[s[i]];
      s[i] = 'a';
    }
    if(n==0) break;
  }
  n %= 26;
  if(n>0){
    for(int i=0;i<n;i++){
      // cout << s[s.size()-1] << endl;
      if(s[s.size()-1]=='z') s[s.size()-1] = 'a';
      else if(s[s.size()-1]=='a') s[s.size()-1] = 'b';
      else if(s[s.size()-1]=='b') s[s.size()-1] = 'c';
      else if(s[s.size()-1]=='c') s[s.size()-1] = 'd';
      else if(s[s.size()-1]=='d') s[s.size()-1] = 'e';
      else if(s[s.size()-1]=='e') s[s.size()-1] = 'f';
      else if(s[s.size()-1]=='f') s[s.size()-1] = 'g';
      else if(s[s.size()-1]=='g') s[s.size()-1] = 'h';
      else if(s[s.size()-1]=='h') s[s.size()-1] = 'i';
      else if(s[s.size()-1]=='i') s[s.size()-1] = 'j';
      else if(s[s.size()-1]=='j') s[s.size()-1] = 'k';
      else if(s[s.size()-1]=='k') s[s.size()-1] = 'l';
      else if(s[s.size()-1]=='l') s[s.size()-1] = 'm';
      else if(s[s.size()-1]=='m') s[s.size()-1] = 'n';
      else if(s[s.size()-1]=='n') s[s.size()-1] = 'o';
      else if(s[s.size()-1]=='o') s[s.size()-1] = 'p';
      else if(s[s.size()-1]=='p') s[s.size()-1] = 'q';
      else if(s[s.size()-1]=='q') s[s.size()-1] = 'r';
      else if(s[s.size()-1]=='r') s[s.size()-1] = 's';
      else if(s[s.size()-1]=='s') s[s.size()-1] = 't';
      else if(s[s.size()-1]=='t') s[s.size()-1] = 'u';
      else if(s[s.size()-1]=='u') s[s.size()-1] = 'v';
      else if(s[s.size()-1]=='v') s[s.size()-1] = 'w';
      else if(s[s.size()-1]=='w') s[s.size()-1] = 'x';
      else if(s[s.size()-1]=='x') s[s.size()-1] = 'y';
      else if(s[s.size()-1]=='y') s[s.size()-1] = 'z';
    }
  }
  cout << s << endl;
  return 0;
}

Measured memory_bytes: 640
// C++ code to find number of distinct numbers
// in a subarray
#include<bits/stdc++.h>
using namespace std;

const int MAX = 1000001;

// structure to store queries
struct Query
{
    int l, r, idx;
};

// cmp function to sort queries according to r
bool cmp(Query x, Query y)
{
    return x.r < y.r;
}

// updating the bit array
void update(int idx, int val, int bit[], int n)
{
    for (; idx <= n; idx += idx&-idx)
        bit[idx] += val;
}

// querying the bit array
int query(int idx, int bit[], int n)
{
    int sum = 0;
    for (; idx>0; idx-=idx&-idx)
        sum += bit[idx];
    return sum;
}

void answeringQueries(int arr[], int n, Query queries[], int q)
{
    // initialising bit array
    int bit[n+1];
    memset(bit, 0, sizeof(bit));

    // holds the rightmost index of any number
    // as numbers of a[i] are less than or equal to 10^6
    int last_visit[MAX];
    memset(last_visit, -1, sizeof(last_visit));

    // answer for each query
    int ans[q];
    int query_counter = 0;
    for (int i=0; i<n; i++)
    {
        // If last visit is not -1 update -1 at the
        // idx equal to last_visit[arr[i]]
        if (last_visit[arr[i]] !=-1)
            update (last_visit[arr[i]] + 1, -1, bit, n);

        // Setting last_visit[arr[i]] as i and updating
        // the bit array accordingly
        last_visit[arr[i]] = i;
        update(i + 1, 1, bit, n);

        // If i is equal to r of any query  store answer
        // for that query in ans[]
        while (query_counter < q && queries[query_counter].r == i)
        {
            ans[queries[query_counter].idx] =
                     query(queries[query_counter].r + 1, bit, n)-
                     query(queries[query_counter].l, bit, n);
            query_counter++;
        }
    }

    // print answer for each query
    for (int i=0; i<q; i++)
        cout << ans[i] << endl;
}

// driver code
int main()
{
    int n,c;
    cin>>n>>c;
    int a[n];
    for (int i = 0; i < n; i++)
    {
        cin>>a[i];
    }

    // int n = sizeof(a)/sizeof(a[0]);
    Query queries[c];
    for (int i = 0; i < c; i++)
    {
        int x,y;
        cin>>x>>y;
        queries[i].l=x-1;
        queries[i].r=y-1;
        queries[i].idx=i;
    }

    // queries[0].l = 0;
    // queries[0].r = 4;
    // queries[0].idx = 0;
    // queries[1].l = 1;
    // queries[1].r = 3;
    // queries[1].idx = 1;
    // queries[2].l = 2;
    // queries[2].r = 4;
    // queries[2].idx = 2;
    int q = sizeof(queries)/sizeof(queries[0]);
    sort(queries, queries+q, cmp);
    answeringQueries(a, n, queries, q);
    return 0;
}

Measured memory_bytes: 19416