akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <time.h>

#define _CRT_SECURE_NO_WARNINGS
#define TLong long long 

// fact(n)
int fact(int n){
	if(n == 1)	return 1;
	else return (n * fact(n - 1));
}

// combination(n,r)
int combination(int n, int r){
	if(r == 0 || r == n)	return 1;
	else if(r == 1)	return n;
	return (combination(n - 1, r - 1) + combination(n - 1, r));
}

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

// lcm(a.b)
int lcm(int a,int b){
	return (a * b) / gcd(a,b);
}

// qsort(array, size, sizeof(int),comp);
int comp(const int *a,const int *b){
	return (*a - *b);
}

// append(array,*size,addNum)
void append(int *array,int *size,int num){
	realloc(array, sizeof(int) * (*size + 1));
	array[(*size)] = num;
	++(*size);
}

// pop(array,*size) & nongetpop(array,*size)
int pop(int *array,int *size){
	int temp = array[(*size - 1)];
	realloc(array,sizeof(int) * (*size - 1));
	--(*size);
	return temp;
}

void nongetpop(int *array,int *size){
	realloc(array,sizeof(int) * (*size - 1));
	--(*size);
}

int main(int argc, char const *argv[]){
	int player = 0,turn[3] = {0,-1,-1};
	char card[3][120];
	scanf("%s %s %s",card[0],card[1],card[2]);
	for (int i = 0; i < strlen(card[0]) + strlen(card[1]) + strlen(card[2]); ++i){
		switch(card[player][turn[player]]){
			case 'a':
				player = 0;
				break;
			case 'b':
				player = 1;
				break;
			case 'c':
				player = 2;
				break;
		}
		if(++turn[player] > strlen(card[player])){
			printf("%c\n", (player + 'A'));
			return 0;
		}
	}
	printf("%c\n", (player + 'A'));
	return 0;
}


Measured memory_bytes: 128
#include <stdio.h>

int main(void){
    char line[1001];
    int i,sum;
    for(;sum=0,i=0,scanf("%s",line),line[0] != '0';){
        while(line[i])
            sum+=line[i++]-'0';
        printf("%d\n",sum);
    }
    return 0;
}

Measured memory_bytes: 536
N=int(input())

dic={'M':0,'A':0,'R':0,'C':0,'H':0}
k = dic.keys()

for i in range(N):
    s=input()
    if s[0] in k:
        dic[s[0]]+=1

from itertools import combinations

ans=0
for p,q,r in combinations(k,3):
    ans+=dic[p]*dic[q]*dic[r]

print(ans)


Measured memory_bytes: 44888
#include<iostream>
#include<unordered_map>
#include<bitset>
#include<math.h>
#include<vector>
#include<set>
#include<algorithm>
#include<ctype.h>
#include<unordered_set>
#include<string>
#include<iomanip>
#include<queue>
#include<limits>
#include<map>
#include<stack>
#include<iterator>
#include<cstring>
#include<deque>
#include<chrono>
using namespace std;
#define pi 3.141592653589793238


#define MOD 1000000007
#define INF 999999999999999999 
#define pb push_back
#define ff first
#define ss second
#define mt make_tuple
#define ll long long
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define f0 get<0>
#define f1 get<1>
#define f2 get<2>
typedef vector<ll> vi;
typedef vector<vi> vvi;


////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    fast;
    ll T = 1, i, j;
    
    
    //cin >> T;
    
    while (T--) {
        ll n;
        cin >> n;
        ll k;
        ll lo = 0, hi = 10;
        ll len = 0;
        ll sum = 0;
        ll p = 26;
        while(sum + p <= n){
            sum += p;
            p *= 26;
            //cout << sum << endl;
            len++;
        }
        ll left = n - sum;
        if(left == 0){
            for(i = 0; i < len; i++){
                cout << "z";
            }
            return 0;
        }
        p = pow(26, len);
        len++;
        left--;
        //cout << len << endl;
        for(i = 0; i < len; i++){
            ll cnt = 0;
            ll x = 1;
            for(j = 0; j < len - i - 1; j++){
                x *= 26;
            }
            while(left - x >= 0){
                cnt++;
                left -= x;
                
            }
            cout << char('a' + cnt);
            p /= 26;
        }
    }

    return 0;
}


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

int main() {
    /* Input */
    string s;
    cin >> s;

    /* Output */
    if (s == "ABC") cout << "ARC" << endl;
    else cout << "ABC" << endl;

    return 0;
}

Measured memory_bytes: 3580
#include<stdio.h>
int main(void) {
	char str[8][9];
	int i, j;

	for (i = 0; i < 8; i++) 
		scanf("%s",str[i]);

	printf("90\n");
	for (i = 0; i< 8; i++) {
		for (j = 7; j >= 0; j--) 
			printf("%c",str[j][i]);
		printf("\n");
	}

	printf("180\n");
	for (i = 7; i >= 0; i--) {
		for (j = 7; j >= 0; j--)
			printf("%c", str[i][j]);
		printf("\n");
	}
	
	printf("270\n");
	for (i = 7; i >= 0; i--) {
		for (j = 0; j < 8; j++)
			printf("%c", str[j][i]);
		printf("\n");
	}
	return 0;
}

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

int main()
{
   string s;
   cin >> s;
   ll l=0,r=s.size()-1;//文字列の最初を参照する変数l、文字列の最後を参照する変数rを用意
   ll ans=0;
   while (1) {
     if (l>=r) break;
     if (s[l]==s[r]){
            l++;r--;
     }
     else if (s[l]=='x'){
        ans++;
        l++;
     }
     else if (s[r]=='x'){
        ans++;
        r--;
     }
     else {
        ans=-1;
        break;
     }
   }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 512
n,k,q = map(int, input().split())
d = [0]*(n+1)
for i in range(q):
    a = int(input())
    d[a]+=1

for i in range(1,n+1):
    if k - q + d[i] >0:
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 4680
import bisect

N, K = map(int,input().split())
X = list(map(int,input().split()))

s = bisect.bisect_left(X,0)
if 0 in X:
    K -= 1
else:
    bisect.insort_left(X,0)
    N += 1

MIN = 2 * 10**9
for i in range(K+1):
    if s - K + i >= 0 and s + i <N:
        f = X[s -K+i]
        l = X[s+i]
        if abs(f) < abs(l):
            ans = abs(f) * 2 + abs(l)
        else:
            ans = abs(l) * 2 + abs(f)
        MIN =min(MIN,ans)

print(MIN)

Measured memory_bytes: 14660
s = list(input())
t = list(input())
s = sorted(s)
t = sorted(t,reverse=True)
counter = 0
for i in range(min(len(s),len(t))) :
    if s[i] != t[i] :
        L = []
        L.append(s[i])
        L.append(t[i])
        K = sorted(L)
        if L[0] == K[0] :
            print("Yes")
            break
        else :
            print("No")
            break
    else :
        counter += 1
        continue
if counter == min(len(s),len(t)) :
    if len(s) < len(t) :
        print("Yes")
    else :
        print("No")
        
        

Measured memory_bytes: 3064
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
from collections import Counter
def main():
    s = input()
    n = len(s)

    amari = [0] * n
    ketaamari = 1
    t = 0
    for i1 in range(n):
        t = (t + ketaamari * int(s[-i1 -1])) % 2019
        amari[-i1-1] = t
        ketaamari = (ketaamari * 10) % 2019
    amari.append(0)
    ac = Counter(amari)
    r = 0
    for v in ac.values():
        r += v * (v - 1) // 2
    print(r)

if __name__ == '__main__':
    main()

Measured memory_bytes: 16716
import java.util.*;

public class Main {
    private static Integer res= 0;
    public static void main(String args[]) {
        Scanner scanner = new Scanner(System.in);
        int m1 = scanner.nextInt();
        int d1 = scanner.nextInt();
        int m2 = scanner.nextInt();
        int d2 = scanner.nextInt();
        if (m1 != m2) {
            System.out.println(1);
        }else{
            System.out.println(0);
        }
    }
}

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

# define INF 0x3f3f3f3f

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

using namespace std;

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

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

  int total = 0;
  int m = max(max(A, B), C);
  total += (m - A) / 2;
  total += (m - B) / 2;
  total += (m - C) / 2;

  int rem = 0;
  if ((m - A) % 2 == 1) rem++;
  if ((m - B) % 2 == 1) rem++;
  if ((m - C) % 2 == 1) rem++;

  if (rem == 1) {
    total += 2;
  } else if (rem == 2) {
    total += 1;
  }

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


Measured memory_bytes: 256
#include<stdio.h>

int main() {
	long long int a, b, c, d, n, m=0, result = 100000;
	
	scanf("%lld", &n);
	for (int i = 0; i <= n;i++) {
		a = i;
		m = 0;
		while (a > 0) {
			m += a % 6;
			a /= 6;
		}
		a = n - i;
		while (a > 0) {
			m += a % 9;
			a /= 9;
		}
		if (m < result) { result = m; }
	}
	
	printf("%lld", result);
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>


using namespace std;

int main(){
    
    string S;
    
    cin >> S;
    
    
    
    
    if (S[0] == S[1]) {
        if (S[2] == S[3] && S[0] != S[2]) {
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }else if(S[0] == S[2]){
        if (S[1] == S[3] && S[0] != S[1]) {
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
        
    }else if(S[0] == S[3]){
        if (S[1] == S[2] && S[0] != S[2]) {
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
        
    }else{
        
        cout << "No" << endl;
    }
        
        
    
    
    return 0;
    
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define F(i,s,e) for(int i=s;i<e;++i)

int main()
{
    int a,b;
    cin >> a >> b;
    
    int ans=1;
    while(ans<=10000){
        if(int(ans*0.08) == a && int(ans*0.1) == b){
            cout << ans << endl;
            return 0;
        }
        ++ans;
    }
    cout << -1 << endl;
    return 0;
}

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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;

li res[200200];
li n;
li a[200200];

int main() {
    cin >> n;
    rin{
        cin >> a[i];
    }
    for (li i = n - 1; i >= 0; i--) {
        li sum = 0;
        for (li j = (i + 1) * 2; j <= n; j += (i + 1)) {
            sum += res[j - 1];
        }
        res[i] = (sum % 2) ^ a[i];
    }
    li cnt = 0;
    rin{
        if (res[i] > 0) {
            cnt++;
        }
    }
    cout << cnt << endl;
    rin{
        if (res[i] > 0) {
            cout << i + 1 << " ";
        }
    }
    cout << endl;


    return 0;
}

Measured memory_bytes: 3968
import sys

s=list(input())
a=s[0]
b=s[1]
c=s[2]
e=s[3]

for i in range(8):
    d=0
    x=[a,b,c,e]
    for j in range(3):
        if (i >> j)&1:
            x.insert(-j-1-d,'+')
            d+=1
        else:
            x.insert(-1-j-d,'-')
            d+=1
    q="".join(x)
    f=int(a)
    g=int(b)
    h=int(c)
    k=int(e)
    if q[1]=="-":
        g=-g
    if q[3]=="-":
        h=-h
    if q[5]=="-":
        k=-k
    if f+g+h+k==7:
        ans=q+"=7"
        print(ans)
        sys.exit()
    
            


Measured memory_bytes: 3064
# -*- coding: utf-8 -*-

n = int(input())
a = list(map(int,input().split()))

def array_count(arr):
    arr_target = [[]]
    cnt = 1
    for i in range(1,len(arr)):
        if arr[i] == arr[i-1]:
            cnt += 1
        else:
            arr_target.append([arr[i-1],cnt])
            cnt = 1
    arr_target.append([arr[len(arr)-1],cnt])
    del arr_target[0]
    return arr_target


a.sort()
a = array_count(a)

b= []

for i in range(len(a)):
    if a[i][1] >= 2:
        b.append(a[i][0])
    if a[i][1] >= 4:
        b.append(a[i][0])

b.sort()
b.reverse()

if len(b) <= 1:
    print(0)
else:
    print(b[0]*b[1])


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

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

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

    for(int k=1; k<N; k++){
        ll cost = k*x;
        for(int i=0; i<N; i++){
            c[i] = min(c[i], a[(i-k+N)%N]);
            cost += c[i];
        }
        ans = min(ans, cost);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
import sys
N = int(sys.stdin.readline())  # N個の候補
T, A = map(int, sys.stdin.readline().strip().split())  # T-x*0.006度, A度に近い地点
H = list(map(int, sys.stdin.readline().strip().split()))

ans = 0

# A度に近い地点を探す
gosa = 1e+9

for i in range(len(H)):
    if gosa > abs(A-(T-H[i]*0.006)):
        gosa = abs(A-(T-H[i]*0.006))
        ans = i

print(ans+1)


Measured memory_bytes: 3060
#include <stdio.h>

int main()
{
  int n;
  unsigned long hi, mid, lo;
  int i;

  scanf("%d", &n);
  hi=0; mid=0; lo=1;
  for(i=1; i<=n; i++){
    lo*=(unsigned long)i;
    mid*=(unsigned long)i;
    hi*=(unsigned long)i;
    if(lo>99999999){
      mid+=lo/100000000;
      lo%=100000000;
    }
    if(mid>99999999){
      hi+=mid/100000000;
      mid%=100000000;
    }
  }
  if(mid==0) printf("%lu\n", lo);
  else if(hi==0) printf("%lu%08lu\n", mid, lo);
  else printf("%lu%08lu%08lu\n", hi, mid, lo);

  return 0;
}

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

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

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

#define INF 99999999
#define MOD (int)1e9 + 7
#define rep(i,n) for(int i = 0;i<n;i++)
#define all(x) x.begin(),x.end()

int main() {

	ll n;
	cin >> n;

	for (int i = 1; i < 3501; i++) {
		for (int j = 1; j < 3501; j++) {
			ll a = 4 * i*j - n*(i + j);
			ll b = n*i*j;
			if (a > 0 && b % a == 0) {
				printf("%d %d %ld\n", i, j, b / a);
					return 0;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;

/*
<url:http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1565>
問題文============================================================

 近年、イカたちの間では縄張り争いが頻繁に起きている。
 複数のイカたちがチームを組み、自らのイカスミを武器に戦うのが近年のイカの戦闘スタイルである。
 
 現在も縄張り争いが起こっており、その戦場は R×C のグリッドで表される。
 縄張り争いに参加しているイカのゲソ太はこのグリッド上のある場所にいる。
 この争いでは、重要な場所を敵よりも早く占拠することで戦況を有利にすることができる。
 そのため、ゲソ太は重要そうな場所を1つ決め、そこになるべく早く移動したいと考えている。
 
 ゲソ太は隣接する上下左右のマスに移動することができる。
 グリッドの各マスには味方、または敵のイカスミが塗られている場合がある。
 なにも塗られていないマスに移動する場合、2秒かかるが、
 味方のイカスミが塗られているマスに移動する場合、その半分の時間(1秒)で済む。
 敵のイカスミが塗られているマスには移動することができない。壁があるマスや戦場の外へは当然移動することができない。
 
 また、ゲソ太は上下左右のいずれかの方向を向き、イカスミを吐くことができる。
 すると、前方の3マスが味方のイカスミで上書きされる。
 ただし途中に壁がある場合はその手前までしかイカスミは届かない。この動作には2秒かかる。
 
 戦場の情報とゲソ太の位置と目的の位置が与えられるので、最短で何秒で移動できるか求めてほしい。
 
=================================================================

解説=============================================================
ダイクストラ法
 
 遷移の方法としては、純粋に四方４マスで移動できるようであればその遷移をみる。
 さらに、四方について３マス分色ぬりを行ったとして、遷移を取っていけば良い
================================================================
*/

int dx[4] = {1,0,-1,0};
int dy[4] = {0,1,0,-1};
int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
    ll R,C; cin >> R >> C;
    pii s,g;
    vector<vector<char>> masu(R+2,vector<char>(C+2,'#'));
    for(int i = 1; i <= R;i++){
        for(int j = 1; j <= C;j++){
            cin >> masu[i][j];
            if(masu[i][j] == 'S'){
                masu[i][j] = '.';
                s = pii(i,j);
            }
            if(masu[i][j] == 'G'){
                masu[i][j] = '.';
                g = pii(i,j);
            }
        }
    }
    
    vector<vector<int>> dist(R+2,vector<int>(C+2,INF));
    dist[s.first][s.second] = 0;
    queue<pii> q;
    q.push(s);
    while(!q.empty()){
        auto n = q.front(); q.pop();
        int x = n.first, y = n.second;
        for(int i = 0; i  < 4;i++){
            int nx = x + dx[i], ny = y + dy[i];
            if(masu[nx][ny] == '#') continue;
            if(masu[nx][ny] == '.'){
                if(dist[nx][ny] > dist[x][y] + 2){
                    dist[nx][ny] = dist[x][y] + 2;
                    q.push(pii(nx,ny));
                }
            }
            if(masu[nx][ny] == 'o'){
                if(dist[nx][ny] > dist[x][y] + 1){
                    dist[nx][ny] = dist[x][y] + 1;
                    q.push(pii(nx,ny));
                }
            }
        }
        for(int i = 0; i < 4;i++){
            for(int j = 1; j <= 3;j++){
                int nx = x + j*dx[i], ny = y + j*dy[i];
                if(masu[nx][ny] == '#') break;
                if(dist[nx][ny] > dist[x][y] + 2 + j){
                    dist[nx][ny] = dist[x][y] + 2 + j;
                    q.push(pii(nx,ny));
                }
            }
        }
    }
    cout << dist[g.first][g.second] << endl;
	return 0;
}



Measured memory_bytes: 3172
N = int(input())
S = list(input().strip())

ans = len([1 for d in S[1:] if d == 'E'])
cnt = ans
for i in range(1, N):
    if S[i] == 'E': cnt -= 1
    if S[i-1] == 'W': cnt += 1
    if ans > cnt: ans = cnt
print(ans)

Measured memory_bytes: 10484
#include<iostream>

int main(){
  int n,r,ans;
  std::cin >> n;
  std::cin >> r;

  if(n >= 10){
    ans = r;
  }
  else{
    ans = r + 100*(10 - n);
  }
  std::cout << ans << std::endl;

  return 0;
}
    


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int main () {
	char ch[105];
	scanf("%[^\n]", ch);
	
	for(int i = 0; i < 19; i++){
		if (ch[i] == ',') {
			printf(" ");
		}
		else {
			printf("%c", ch[i]);
		}
	}
	
	return 0;
}

Measured memory_bytes: 1596
#include <bits/stdc++.h>
#define mk make_pair
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;
int b[100010];
vector<int> a[100010];
int main(){
    int n, m;
    while(cin>>n>>m){
        ll ans=0;
        int x, y;
        for(int i=1; i<=n; ++i)
        	scanf("%d",b+i);
        for(int i=0; i<m; ++i){
            scanf("%d%d",&x, &y);
            a[x].push_back(y);
            a[y].push_back(x);
        }
        for(int i=1; i<=n; ++i){
        	bool l=1;
        	for(int j=0; j<a[i].size(); ++j){
        		if(b[a[i][j]]>=b[i]){
        			l=0;
        			break;
        		}
        	}
        	ans+=l;
        }
        cout<<ans<<endl;
    }
  return 0;
}




Measured memory_bytes: 9272
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define range(a) (a).begin(),(a).end()
#define print(A,x,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i]x;}cout<<endl;
#define pprint(A,y,m,n) rep(j,0,m){print(A[j],y,n);}
const long mod=1e9+7;
const int size=1e5;
const int inf=1e9;
int main(){
	int N;cin>>N;
	long dp[N+1][4][4][4] = {};
	rep(j,0,4)rep(k,0,4)rep(l,0,4){
        if(j == 0 && k == 2 && l == 1) continue;
        if(j == 2 && k == 0 && l == 1) continue;
        if(j == 0 && k == 1 && l == 2) continue;
        dp[3][j][k][l] = 1;
    }
	rep(n,3,N+1){
		rep(i,0,4)rep(j,0,4)rep(k,0,4)rep(l,0,4){
			if(j == 0 && k == 2 && l == 1) continue;
			if(j == 2 && k == 0 && l == 1) continue;
			if(j == 0 && k == 1 && l == 2) continue;
            if(i == 0 && k == 2 && l == 1) continue;
            if(i == 0 && j == 2 && l == 1) continue;
			(dp[n][j][k][l] += dp[n-1][i][j][k]) %= mod;
		}
	}
	long sum = 0;
	rep(i,0,4)rep(j,0,4)rep(k,0,4) (sum += dp[N][i][j][k]) %= mod;
	cout<<sum<<endl;
}

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

using namespace std;
int main(){
  string str;
  cin>>str;
  int ret=str.size()+1;
  for(int i=0;true;i++){
    if(str[i]=='A')break;
    ret--;
  }
  for(int i=str.size();true;i--){
    if(str[i]=='Z')break;
    ret--;
  }
  cout<<ret;
  return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>

using namespace std;
using ll = long long;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
int gcd(int a, int b){ return (b == 0) ? a : gcd(b, a % b); }

#define Sq(x) (x)*(x)
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Unique(a) a.erase(unique(Range(a)), a.end())
#define Vec2(T, n, m, xs, x0) vector<vector<T>> xs(n, vector<T>(m, x0))
#define Sum(a) accumulate(Range(a), 0)
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs, 0); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) for(const auto &e : xs) cout << e << " "; cout << "\n"
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")

// constexpr int MOD = 1e9+7;
#include <deque>

int main(void){
    Cin(int, h, w);
    Cinss(char, h, w, c);
    deque<pair<int, int>> q;
    For(i, h) For(j, w){
        if(c[i][j] == '#') q.emplace_back(i, j);
    }
    int ans = 0;
    while(!q.empty()){
        ans ++;
        deque<pair<int, int>> q2;
        
        while(!q.empty()){
            int i = q.front().first, j = q.front().second;
            if(i+1 <  h && c[i+1][j] == '.') c[i+1][j] = '#', q2.emplace_back(i+1, j);
            if(i-1 >= 0 && c[i-1][j] == '.') c[i-1][j] = '#', q2.emplace_back(i-1, j);
            if(j+1 <  w && c[i][j+1] == '.') c[i][j+1] = '#', q2.emplace_back(i, j+1);
            if(j-1 >= 0 && c[i][j-1] == '.') c[i][j-1] = '#', q2.emplace_back(i, j-1);
            q.pop_front();
        }
        q = q2;
    }
    Cout(ans-1);
}

Measured memory_bytes: 9600
using System;
using System.Collections.Generic;
using System.Linq;

namespace CSharpSample01
{
    class UnionFind
    {
        int[] p;
        int[] len;

        
        public UnionFind(int N)
        {
            p = new int[N];
            len = new int[N];
            for(int i = 0; i < N; i++)
            {
                p[i] = i;
                len[i] = 0;
            }
        }

        public int Root(int x)
        {
            if (p[x] == x) return x;
            return Root(p[x]);
        }

        public void Unit(int x, int y)
        {
            int root_x = Root(x);
            int root_y = Root(y);
            if (root_x == root_y) return;

            int smool;
            int big;

            if(len[root_x] < len[root_y])
            {
                smool = root_x;
                big = root_y;
            }
            else
            {
                smool = root_y;
                big = root_x;
            }

            if (len[root_x] == len[root_y]) len[big]++;

            p[smool] = big;
            
        }

        public bool IsSame(int x, int y)
        {
            if (Root(x) == Root(y)) return true;
            else return false;
        }
        
    }

    class Program
    {

        
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int N = int.Parse(input[0]);
            int M = int.Parse(input[1]);

            int[] p = Console.ReadLine().Split(' ').Select(x => int.Parse(x) - 1).ToArray();

            UnionFind uf = new UnionFind(N);
            
            for(int i = 0; i < M; i++)
            {
                input = Console.ReadLine().Split(' ');
                int x = int.Parse(input[0]) - 1;
                int y = int.Parse(input[1]) - 1;
                uf.Unit(x, y);
            }

            int cnt = 0;

            for(int i = 0; i < N; i++)
            {
                if (uf.IsSame(i, p[i]))
                {
                    cnt++;
                }
            }               

            Console.WriteLine(cnt);

        }
    }
}

Measured memory_bytes: 24032
#include <bits/stdc++.h>
using namespace std;
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
static const ll maxLL = (ll)1 << 62;
const ll MOD=1000000007,INF=1e18;
int dy[]={-1,0,1,0};
int dx[]={0,1,0,-1};

#define int ll

int n,cnt=0;


signed main(){
    cin>>n;
    vector<ll> a(n),sum(n+1);
    rep(i,0,n+1)sum[i]=0;
    rep(i,0,n){
        cin>>a[i];
    }
    sort(a.begin(),a.end());
    rep(i,0,n){
        sum[i+1]=sum[i]+a[i];
    }
    for(int i=n-2;i>=0;i--){
        if(sum[i+1]*2>=a[i+1])cnt++;
        else break;
    }
    cout<<cnt+1<<endl;
    return 0;
}

Measured memory_bytes: 1792
h, w = map(int,input().split())
a = [list(map(int,input().split())) for i in range(h)]
b = [list(map(int,input().split())) for i in range(h)]

ab = [[0]*w for i in range(h)]
for ch in range(h):
    for cw in range(w):
        ab[ch][cw] = abs(a[ch][cw] - b[ch][cw])

ab0 = ab[0][0]
size = 80*(h+w)
dp = [[0]*w for hh in range(h)]
dp[0][0] |= 2**(size + ab0)
dp[0][0] |= 2**(size - ab0)
for ch in range(h):
    for cw in range(w):
        if ch < h-1:
            dp[ch+1][cw] |= dp[ch][cw] << ab[ch+1][cw]
            dp[ch+1][cw] |= dp[ch][cw] >> ab[ch+1][cw]
        if cw < w-1:
            dp[ch][cw+1] |= dp[ch][cw] << ab[ch][cw+1]
            dp[ch][cw+1] |= dp[ch][cw] >> ab[ch][cw+1]

a = dp[h-1][w-1]>>size
m = a&(-a)
print(m.bit_length()-1)

Measured memory_bytes: 89588
arr = list(map(str, input().split()))
stack = []

for i in range(len(arr)):
	current = arr[i]
	if current == '+' or current == '-' or current == '*':
		n1 = stack.pop()
		n2 = stack.pop()
		if current == '+':
			n1 = n1 + n2
		elif current == '-':
			n1 = n2 - n1
		else:
			n1 = n1 * n2
		stack.append(n1)
	else:
		stack.append(int(current))
print(stack.pop())



Measured memory_bytes: 5600
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

A, B = MAP()
print(A - 2*B if A > 2*B else 0)

Measured memory_bytes: 5148
#include<bits/stdc++.h>
#define pb push_back
#define all(x) x.begin(), x.end()
using namespace std;
using ll = long long;
using vi = vector<ll>;
const int maxn = 1<<20, mod = 924844033;
int n, q;
ll ans[maxn], c[maxn];
vi a;
void solve(ll l, ll C) {
	int i = lower_bound(all(a), l)-a.begin();
	if(i == 0) {
		ans[l] += C;
		return;
	}
	c[i-1] += (l/a[i-1])*C;
	solve(l%a[i-1], C);
}
int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin >> n >> q;
	a.push_back(n);
	for(ll t, i = 0; i < q; i++) {
		cin >> t;
		while(!a.empty() && a.back() >= t) a.pop_back();
		a.push_back(t);
	}
	c[a.size() - 1] = 1;
	for(int i = a.size(); i--;) solve(a[i], c[i]);
	for(int i = n; i; i--) ans[i] += ans[i+1];
	for(int i = 1; i <= n; i++) cout << ans[i] << "\n";
}


Measured memory_bytes: 5492
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pint = pair<int, int>;
using vecvec = vector<vector<int>>;

int dx4[4]{1, 0, -1, 0};
int dy4[4]{0, 1, 0, -1};

ll INF = 1ll << 60;

int main(int argc, char **argv)
{
	int H, W;
	cin >> H >> W;

	queue<pint> que;
	vecvec dist(H, vector<int>(W, -1));
	for (int h = 0; h < H; ++h)
	{
		for (int w = 0; w < W; ++w)
		{
			char c; cin >> c;
			if (c == '#')
			{
				que.push(pint(h, w));
				dist[h][w] = 0;
			}
		}
	}
	
	while (!que.empty())
	{
		auto coodinate = que.front(); que.pop();
		int h = coodinate.first;
		int w = coodinate.second;

		for (int i = 0; i < 4; ++i)
		{
			int hh = h + dy4[i];
			int ww = w + dx4[i];
			if (hh < 0 || hh >= H || ww < 0 || ww >= W) continue;
			if (dist[hh][ww] != -1) continue;

			dist[hh][ww] = dist[h][w] + 1;
			que.push(pint(hh, ww));
		}
	}

	int res{0};
	for (int h = 0; h < H; ++h)
		for (int w = 0; w < W; ++w)
			res = max(res, dist[h][w]);
	std::cout << res << std::endl;
}


Measured memory_bytes: 12432
(let* ((n (read-line)))
  (cond ((string= n  "SAT") (princ 1))
        ((string= n  "FRI") (princ 2))
        ((string= n  "THU") (princ 3))
        ((string= n  "WED") (princ 4))
        ((string= n  "TUE") (princ 5))
        ((string= n  "MON") (princ 6))
        ((string= n  "SUN") (princ 7))))

Measured memory_bytes: 9448
#include <stdio.h>
#include <stdlib.h>
#define int long long

int power(int a, int N){
	if(N == 0){
		return 1;
	}
	else{
		return a * power(a, N - 1);
	}
}

signed main(){
	int N, P, i, j, ans = 1;
	scanf("%lld%lld", &N, &P);
	if(N == 1){
		printf("%lld\n", P);
		return 0;
	}
	for(i = 2; i * i <= P; i++){
//		printf("i = %lld\n", i);
		for(j = 0; P % i == 0; j++){
			P /= i;
		}
//		printf("j = %lld\n", j);
		ans *= power(i, (j / N));
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 128
import sys

occurrences = [0] * 26

for c in sys.stdin.read():
    al = c.lower()
    if 'a' <= al <= 'z':
        occurrences[ord(al) - ord('a')] += 1

for i, oc in enumerate(occurrences):
    print(f"{chr(ord('a') + i)} : {oc}")



Measured memory_bytes: 5576
#include <bits/stdc++.h>
using namespace std;
#define scd(t) scanf("%d",&t)
#define scld(t) scanf("%ld",&t)
#define sclld(t) scanf("%lld",&t)
#define scc(t) scanf("%c",&t)
#define scs(t) scanf("%s",t)
#define scf(t) scanf("%f",&t)
#define sclf(t) scanf("%lf",&t)
#define MEM(a, b) memset(a, (b), sizeof(a))
#define ffor(i, j, k, in) for (int i=j ; i<k ; i+=in)
#define rfor(i, j, k, in) for (int i=j ; i>=k ; i-=in)
#define rep(i, j) ffor(i, 0, j, 1)
#define rrep(i, j) rfor(i, j, 0, 1)
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define IN(A, B, C) assert( B <= A && A <= C)
#define mp make_pair
#define pb push_back
//#define f first
//#define s second
#define inf (int)1e9
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define read(type) readInt<type>()
#define trace1(x)                     cout <<#x<<": "<<x<< endl;
#define trace2(x, y)                 cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<< endl;
#define trace3(x, y, z)              cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl;
#define trace4(a, b, c, d)           cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl;
#define trace5(a, b, c, d, e)        cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<<": "<<e<<endl;
const double pi=acos(-1.0);
typedef pair<long long int,long long int> pii;
typedef long long ll;
typedef vector<long long int> vi;
typedef vector<string> vs;
typedef vector<pii> vpii;
typedef vector<vi> vvi;
typedef map<long long int,long long int> mpii;
typedef set<long long int> sei;
typedef multiset<long long int> msei;
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int  uint64;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(NULL);
    ll i,j,n,m;
    cin>>n;
    long double a[n+1];
    for(i=1;i<=n;i++)
    {
        cin>>a[i];
    }
    long double dp[n+1][n+1];
    for(i=0;i<=n;i++)
    {
        for(j=0;j<=n;j++)
        dp[i][j]=0.0;
    }
    dp[0][0]=1;
    for(i=1;i<=n;i++)
    {
        for(j=i;j>=1;j--)
        {
            dp[i][j]=dp[i-1][j-1]*a[i]+dp[i-1][j]*((long double)1-a[i]);
        }
        dp[i][0]=dp[i-1][0]*((long double)1-a[i]);
    }
    long double cnt=0;
    for(i=n/2+1;i<=n;i++)
    cnt+=dp[n][i];
    cout<<setprecision (15)<<cnt;
    return 0;
}

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

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int t; cin >> t;
	while(t--)
	{
		int n, d; cin >> n >> d;
		int sum = d;
		priority_queue<int, vi, greater<int> > pq;
		pq.push(d);
		for(int i = 0; i < n - 1; i++)
		{
			int x = pq.top(); pq.pop();
			int best = 0; int cur = 0;
			for(int j = 0; j < 128; j++)
			{
				if(j+(j^x) >= best)
				{
					best = j+(j^x);
					cur = j;
				}
			}
			sum += best; sum -= x;
			pq.push(cur); pq.push((cur^x));
		}
		cout << sum << '\n';
	}
}


Measured memory_bytes: 384
num = int(input())
hantei = 0
for i in range(1,num+1):
  p = num/i
  if p.is_integer() == True:
    if len(str(i)) == 1 and len(str(int(p))) == 1:
      hantei+=1
      break
      
      
if hantei == 0:
  print("No")
else:
  print("Yes")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using vec2div = vector<vector<long long>>;
using vec = vector<long long>;

int main(){
	long long n;
	cin >> n;
	vec a(n);
	long long i;
	for(i=0;i<n;i++){
		cin >> a.at(i);
      	if(a.at(i) == 0){
          int zero = 0;
          cout << zero << endl;
          return 0;
        }
	}
	long long sum = a.at(0);
  	long long tmp;

	for(i=1;i<n;i++){
		tmp = sum * a.at(i);
		if(sum< LLONG_MAX/a.at(i)){
          sum *= a.at(i);
        }else{
          sum = 0-1;
          break;
        }
      	if(sum > 1000000000000000000){
          sum = 0-1;
          break;
        }

	}

	cout << sum << endl;
}

Measured memory_bytes: 4052
#include <bits/stdc++.h>
#include <chrono>
//#pragma GCC optimize("Ofast")
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,Q,K,A,B;
string S;
typedef pair<ll, ll> P;
const ll INF = (1LL<<58);

template<class T> bool chmin(T &a, const T &b){
    if(a > b) {a = b; return true;}
    else return false;
}
template<class T> bool chmax(T &a, const T &b){
    if(a < b) {a = b; return true;}
    else return false;
}

int main() {
    cin>>H>>W;
    vec s(2), t(2);
    cin>>s[0]>>s[1]>>t[0]>>t[1];
    rep(i,2){--s[i]; --t[i];}
    vector<string> G(H);
    rep(i,H) cin>>G[i];
    mat dist(H, vec(W, INF));
    dist[s[0]][s[1]] = 0;
    deque<P> que;
    que.emplace_back(0, s[0] * W + s[1]);
    const vector<int> dh = {-1, 0, 1, 0}, dw = {0, -1, 0, 1};
    while(!que.empty()){
        P p = que.front();
        que.pop_front();
        int h = p.se/W, w = p.se%W;
        //if(dist[h][w] < p.fi) continue;
        rep(i, 4){
            int nh = h + dh[i], nw = w + dw[i];
            if(nh >= 0 && nh < H && nw >= 0 && nw < W && G[nh][nw] != '#'){
                if(chmin(dist[nh][nw], p.fi)){
                    que.emplace_front(p.fi, nh * W + nw);
                }
            }
        }
        for(int i = -2; i <= 2; ++i){
            for(int j = -2; j <= 2; ++j){
                int nh = h + i, nw = w + j;
                if(nh >= 0 && nh < H && nw >= 0 && nw < W && G[nh][nw] != '#'){
                    if(chmin(dist[nh][nw], p.fi + 1)){
                        que.emplace_back(p.fi + 1, nh * W + nw);
                    }
                }
            }
        }
    }
    cout<<(dist[t[0]][t[1]] == INF ? -1 : dist[t[0]][t[1]])<<endl;
}


Measured memory_bytes: 13592
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <array>
#include <bitset> 
#include <unordered_map>
#include <random>

using namespace std;
typedef long long LL;
typedef pair<int,int> P;

int main() {
	int ret=0;
	int N;
	cin >> N;
	int pre=-1;
	for(int i=0;i<N;i++){
		int a;
		cin >> a;
		if(a==pre){
			ret++;
			a=-1;
		}
		pre=a;
	}
	cout << ret << endl;

	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <stack>
#include <algorithm>
using namespace std;
int main(){
  int i,n,a=0,b=0;
  string s;
  stack<char> sta;
  cin >> n;
  cin >> s;
  for(i=0;i<n;i++){
    if(!sta.empty() && s[i]==')' && sta.top()=='('){
      sta.pop();
      b--;
    }else{
      sta.push(s[i]);
      if(s[i]==')') a++;
      else b++;
    }
  }
  for(i=0;i<a;i++) cout << "(";
  cout << s;
  for(i=0;i<b;i++) cout << ")";
  cout << "\n";
  return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
long long n,a,b,h[100005];
bool check(long long x)
{
    long long center=0;
    for(long long i=1;i<=n;i++)
        center+=max((h[i]-x*b+a-b-1)/(a-b),0LL);
    return center<=x;
}
int main()
{
	cin>>n>>a>>b;
	for(long long i=1;i<=n;i++)
		cin>>h[i];
	long long l=1,r=1000000005,ans;
	while(l<=r)
	{
		long long m=(l+r)/2;
		if(check(m))
		{
			ans=m;
			r=m-1;
		}
		else
			l=m+1;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 1024
N = int(input())
aN = list(map(int, input().split()))

# 最適な戦略：Aliceは大きな数字から取っていく
Alice = []
Bob = []
for i in range((N + 1) // 2):
  # Aliceがカードを取る
  max_val = max(aN)
  Alice.append(max_val)
  aN.remove(max_val)
  if len(aN) > 0:
    # Aliceがカードを取った後Bobがカードを取る
    max_val = max(aN)
    Bob.append(max_val)
    aN.remove(max_val)

print(sum(Alice) - sum(Bob))


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

using namespace std;

int main(){
	char s[4];
	scanf("%s",s);
	int count = 0;
	if(s[0] == 'R' && s[1] == 'R' && s[2] == 'R'){
		count = 3;
	}else if((s[0] == 'R' && s[1] == 'R') ||  (s[1] == 'R' && s[2] == 'R')){
		count = 2;
	}else if(s[0] == 'R' || s[1] == 'R' || s[2] == 'R'){
		count = 1;
	}
	printf("%d\n",count);
}

Measured memory_bytes: 3812
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <functional>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <limits>
#include <sstream>
#include <typeinfo>

using namespace std;

int to_digits(int N)
{
	int bits = 0;
	while (N > 0) {
		int m = N % 10;
		bits |= (1 << m);
		N /= 10;
	}
	return bits;
}

int main() {
	int N, K;
	cin >> N >> K;
	int Dbits = 0;
	for (int i = 0; i < K; i++) {
		int D;
		cin >> D;
		Dbits |= (1 << D);
	}
	int ans = N;
	for (; ans < 100000; ans++) {
		auto bits = to_digits(ans);
		if (!(Dbits & bits))
			break;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
import bisect
N, K = map(int, input().split())
D = [0]*N
for i in range(K):
    d = int(input())
    for x in input().split():
        x = int(x)
        x -= 1
        D[x] += 1

D.sort()
print(bisect.bisect_left(D, 1))


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

using namespace std;
typedef long long ll;

int main() {
    int k;
    string s;
    cin >> k >> s;
    if (s.size() <= k)cout << s << endl;
    else cout << s.substr(0, k) << "..." << endl;
    return 0;
}

Measured memory_bytes: 3584
#include <iostream>
#include <string>
using namespace std;
int main(){
  int a,z;
  string h;
  cin>>h;
  
  for(int i=0;i<h.size();i++){
    if(h[i]=='A') {
      a=i+1;
      break;
    }
  }
  for(int i=h.size()-1;i>0;i--){
    if(h[i]=='Z') {
      z=i+1;
    break;
    }
  }
  cout<<z-a+1<<endl;
}

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

const int mn=2e5+6;
int a[mn],n,b[mn],c[mn],d[mn];
vector<int> app[mn];
long long ans;

int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;++i) {
		scanf("%d",a+i);
		b[i]=a[i]+i,c[i]=i-a[i];
		d[i]=c[i];
	}
	sort(d+1,d+n+1);
	for(int i=1;i<=n;++i) {
		int t=lower_bound(d+1,d+n+1,b[i])-d;
		if(d[t]==b[i]) app[t].push_back(i);
	}
	for(int i=1;i<=n;++i) {
		int t=lower_bound(d+1,d+n+1,c[i])-d;
		ans+=upper_bound(app[t].begin(),app[t].end(),i)-app[t].begin();
	}
	printf("%lld",ans);
//	i-j=a[i]+a[j] i-a[i]=j+a[j]
}

Measured memory_bytes: 14128
#include <stdio.h>
#define N 1000000
int main(){
  int a,i,j,flag=0;
  int x[N];
  scanf("%d",&a);
  x[0]=a;
  for(i=1;i<N;i++){
    if(x[i-1]%2==0)x[i]=x[i-1]/2;
    else x[i]=3*x[i-1]+1;
    
    //printf("%d\n",x[i]);
  }
  for(i=0;i<N;i++){
     for(j=i+1;j<N;j++){
        if(x[i]==x[j]){
          flag=1;
          break;
        }
       
     }
    if(flag==1)break;
  }
  printf("%d\n",j+1);
  return 0;
}

Measured memory_bytes: 4096
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef double db;
#define fi first
#define se second
#define pb push_back
#define vi vector<int>
#define SZ(x) (int)(x.size())
#define sci(x) scanf("%d",&(x))
#define all(v) (v).begin(),(v).end()
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define per(i,a,b) for(int i=(a);i>=(b);--i)
#define syn ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
ll modpow(ll x,ll n,ll mod){ll res=1;for(;n;n>>=1,x=x*x%mod)if(n&1)res=res*x%mod;return res;}
const db eps=1e-8,PI=acos(-1.0);
const int N=4e3+10,M=1e6+10,INF=0x3f3f3f3f,mod=1e9+7;//998244353
bool ok;
char s[5];
int main(){
	scanf("%s",s+1);
	int n=strlen(s+1);
	rep(i,1,n)if(s[i]=='7')ok=1;
	puts(ok?"Yes":"No");
    return 0;
}

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


typedef struct node{
	int key;
	int priority;
	struct node *left, *right;
}NODE;


NODE *ROOT;


NODE *Find(int key)
{
	NODE *p = ROOT;

	while(p != NULL){
		if(key == p->key)
			return p;

		if(key < p->key)
			p = p->left;
		else
			p = p->right;
	}

	return NULL;
}


NODE *RightRotate(NODE *t)
{
	NODE *s = t->left;
	t->left = s->right;
	s->right = t;

	return s;	// ROOT of the subtree
}


NODE *LeftRotate(NODE *t)
{
	NODE *s = t->right;
	t->right = s->left;
	s->left = t;

return s;	// ROOT of the subtree
}


NODE *Make_node(int key, int priority)
{
	NODE *p;

	if( (p = (NODE *)malloc(sizeof(NODE))) == NULL)
		return NULL;
	p->key = key;
	p->priority = priority;
	p->left = NULL;
	p->right = NULL;

	return p;
}


NODE *Insert(NODE *t, int key, int priority)	// 再帰的に探索
{
	// 葉に到達したら新しい節点を生成して返す
	if(t == NULL)
		return Make_node(key, priority);

	// 重複したkeyは無視
	if(key == t->key)
		return t;

	// 左の子へ移動
	if(key < t->key){
		t->left = Insert(t->left, key, priority);	// 左の子へのポインタを更新
		if(t->priority < t->left->priority)	// 左の子の方が優先度が高い場合右回転
			t = RightRotate(t);
	}else{
	// 右の子へ移動
		t->right = Insert(t->right, key, priority);	// 右の子へのポインタを更新
		if(t->priority < t->right->priority)	// 右の子の方が優先度が高い場合左回転
			t = LeftRotate(t);
	}

	return t;
}


NODE *_Delete(NODE*, int);

NODE *Delete(NODE *t, int key)
{
	if(t == NULL)
		return NULL;
	if(key < t->key)                                // 削除対象を検索
		t->left = Delete(t->left, key);
	else if(t->key < key)
		t->right = Delete(t->right, key);
	else
		return _Delete(t, key);

	return t;
}

NODE *_Delete(NODE *t, int key) // 削除対象の節点の場合
{
	if(t->left == NULL && t->right == NULL){
	// 葉の場合
		free(t);
		return NULL;
	}else if(t->left == NULL)	// 右の子のみを持つ場合左回転
		t = LeftRotate(t);
	else if(t->right == NULL)	// 左の子のみを持つ場合右回転
		t = RightRotate(t);
	else{
	// 左の子と右の子を両方持つ場合
		if(t->left->priority > t->right->priority)	// 優先度が高い方を持ち上げる
			t = RightRotate(t);
		else
			t = LeftRotate(t);
	}

	return Delete(t, key);
}


void Walk_tree(NODE *p, int kind)
{
	if(p == NULL)
		return;

	if(kind == 0)
		printf(" %d", p->key);

	Walk_tree(p->left, kind);

	if(kind == 1)
		printf(" %d", p->key);

	Walk_tree(p->right, kind);
}


int main()
{
	int n;
	char command[10];
	int key, priority;
	int i;

	ROOT = NULL;

	scanf("%d", &n);

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

		if(!strcmp(command, "find")){
			scanf("%d", &key);
			if(Find(key))
				printf("yes\n");
			else
				printf("no\n");
		}else if(!strcmp(command, "print")){
			Walk_tree(ROOT, 1);
			printf("\n");
			Walk_tree(ROOT, 0);
			printf("\n");
		}else if(!strcmp(command, "insert")){
			scanf("%d %d", &key, &priority);
			ROOT = Insert(ROOT, key, priority);
		}else if(!strcmp(command, "delete")){
			scanf("%d", &key);
			ROOT = Delete(ROOT, key);
		}
	}


	return 0;
}


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

int main() {

  while (1) {

    string s;
    cin >> s;

    if (s == "0") {
      return 0;
    }

    int answer = 0;

    for (int i = 0; i < s.size(); i++) {
      answer  += (s[i] - '0');
    }

    cout << answer << endl;

  }

  return 0;

}


Measured memory_bytes: 3164