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

using namespace std;

typedef long long ll;

const int INF = 1000000000;

int main()
{
  int N; scanf("%d", &N);
  vector<int> A(N);
  for (int i = 0; i < N; ++i) {
    int a; scanf("%d", &a);
    A[i] = ++a;
  }
  vector<int> freqs(1e5 + 5, 0);
  for (int i = 0; i < N; ++i) {
    ++freqs[A[i]];
    ++freqs[A[i] - 1];
    ++freqs[A[i] + 1];
  }
  int ans = *max_element(freqs.begin(), freqs.end());
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 1024
import java.util.ArrayDeque
import java.util.Queue

fun solve(num: Int): Long {
    val lunlun_queue: Queue<Long> = ArrayDeque()

    for(i in 1L..9L) {
        lunlun_queue.add(i)
    }
    var count = 0
    var result = 0L
    while(lunlun_queue.size > 0) {
        result = lunlun_queue.poll()
        count += 1
        val m = result % 10L
        if(m > 0L) {
            lunlun_queue.add(10L * result + (m - 1))
        }
        lunlun_queue.add(10L * result + m)
        if(m < 9) {
            lunlun_queue.add(10L * result + (m + 1))
        }
        if(count == num) {
            break
        }
    }
    return result
}

fun main(args: Array<String>) {
    val K = readLine()!!.toInt()
    val lunluns = solve(K)

    println(lunluns)
}

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

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

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

#define MOD 1000000007
#define INF 1000000000000000LL

using namespace std;

int main(){
  int n, x;cin>>n>>x;
  int c = 2*n-1;
  if(x==1 || x==c){ cout<<"No"<<endl; return 0; }

  cout<<"Yes"<<endl;

  vector<int> r;
  rep1(i, c)r.push_back(i);
  swap(r[n-1], r[x-1]);
//  for(int p: r)cout<<p<<' ';cout<<endl;
  swap(r[n-2], r[0]);
//  for(int p: r)cout<<p<<' ';cout<<endl;
  swap(r[n], r[c-1]);
  for(int p: r)cout<<p<<' ';

  return 0;
}


Measured memory_bytes: 2420
s = input().strip()
t = input().strip()

st = {}
tset = set()
out = 'Yes'
for _s, _t in zip(s, t):
  if _s in st:
    if st[_s] != _t:
      out = 'No'
      break
  elif _t in tset:
    out = 'No'
    break
  else:
    st[_s] = _t
    tset.add(_t)
print(out)

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

static vector<tuple<int, int, int>> happyDays;
static vector<long> retA;
static vector<long> retB;
static vector<long> retC;

int main() {
  // 入力受け取り
  int N;
  cin >> N;
  happyDays.resize(N);
  retA.resize(N);
  retB.resize(N);
  retC.resize(N);
  int a,b,c;
  for (int i=0; i<N; i++) {
    cin >> a >> b >> c;
    happyDays.at(i) = make_tuple(a, b, c);
  }
  
  // dp
  retA[0]=get<0>(happyDays[0]);
  retB[0]=get<1>(happyDays[0]);
  retC[0]=get<2>(happyDays[0]);
  for(int i=1; i <N; i++) {
    retA[i]=get<0>(happyDays[i]) + max(retB[i-1],retC[i-1]);
    retB[i]=get<1>(happyDays[i]) + max(retA[i-1],retC[i-1]);
    retC[i]=get<2>(happyDays[i]) + max(retA[i-1],retB[i-1]);
  }

  cout << max(max(retA[N-1],retB[N-1]),retC[N-1]) << endl;
}


Measured memory_bytes: 3712
using System;
using System.Linq;

namespace ABC148
{
    class D
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();

            long res = 0;
            long current = 0;
            for (int i = 0; i < N; i++)
            {
                if (current + 1 == a[i]) { current = a[i]; }
                else res++;
            }

            if (res == N) Console.WriteLine(-1);
            else Console.WriteLine(res);

        }
    }
}


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

const int maxS = 3e3 + 7;
long double probs[maxS];
long double dp[maxS][maxS];
long double ONE = 1.000000000;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int N;
    cin >> N;
    for(int i = 1;i <= N;i ++) {
        cin >> probs[i];
    }
    for(int i = 0;i <= N;i ++) {
        for(int j = 0;j <= N;j ++) {
            dp[i][j] = 0.000000000;
        }
    }
    for(int i = 1;i <= N;i ++) {
        for(int j = 0;j <= i;j ++) {
            if(i == 1 && j == 0) {
                dp[i][j] = ONE - probs[i];
                continue;
            }
            if(i == 1 && j == 1) {
                dp[i][j] = probs[i];
                continue;
            }
            if(j == 0) {
                dp[i][j] = dp[i-1][j] * (ONE - probs[i]);
                continue;
            }
            dp[i][j] = dp[i-1][j] * (ONE - probs[i]) + (dp[i-1][j-1] * probs[i]);
            
            // cout << dp[i][j] << " ";
        }
        // cout << "\n";
    }
    long double probOfMoreHeadsThanTails = 0.000000000;
    for(int i = N/2 + 1;i <= N;i ++) {
        probOfMoreHeadsThanTails += dp[N][i];
        // cout << i << " " << dp[N][i] << "\n";
    }
    cout << setprecision(9) << fixed;
    cout << probOfMoreHeadsThanTails << "\n";
}

Measured memory_bytes: 141568
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main(){
	int N;
	cin>>N;
	N%=10;
	if(N==3)cout<<"bon";
	else if(N==0||N==1||N==6||N==8)cout<<"pon";
	else cout<<"hon";
	return 0;
}

Measured memory_bytes: 3592
import java.util.Scanner;
 
class Main {
   public static void main(String[] args) {
      Scanner scanner = new Scanner(System.in);
      int n = scanner.nextInt();
      if (n <= 100) {
        int[] array = new int[n];
         for (int i = 0; i < n; i++) {
            array[i] = scanner.nextInt();
         }
         for (int i = n - 1; i >= 1; i--) {
            System.out.print(array[i] + " ");
         }
         System.out.println(array[0]);
      }
   }
}

Measured memory_bytes: 26400
import sys
def input(): return sys.stdin.readline().rstrip()
import heapq
def main():
    n,m=map(int,input().split())
    A=[int(_) for _ in input().split()]
    A=list(map(lambda x:-x,A))
    heapq.heapify(A)
    for _ in range(m):
        x=heapq.heappop(A)
        heapq.heappush(A,-(-x//2))
    print(-sum(A))

if __name__=='__main__':
    main()

Measured memory_bytes: 69288
n,L = map(int,input().split())
a = list(map(int,input().split()))

r = [0]
for i in range(n):
    r.append(r[i] + a[i])

ansl = []
p,q = 0,n-1
suma = sum(a)
while p < q:
    if r[q+1] - r[p]  < L:
        print("Impossible")
        exit()
    if a[p] + a[p + 1] <= a[q-1] + a[q]:
        ansl.append(p + 1)
        p+=1
    else:
        ansl.append(q)
        q-=1


print("Possible")
for ans in ansl:
    print(ans)


Measured memory_bytes: 16992
#include<bits/stdc++.h>
using namespace std;
const long long int INF = 1e18 + 5;
long long int min(long long int a,long long int b){
	return (a<b?a:b);
}
int main(){
	int n,w,val_sum=0;
	cin>>n>>w;
	vector<long long int> val(n);vector<long long int>wt(n);
	for(int i=0;i<n;i++){
		cin>>wt[i]>>val[i];
		val_sum+=val[i];
	}
	vector<long long int>dp(val_sum+1,INF);
	dp[0]=0;
	for(int k=0;k<n;k++){
		for(int i=val_sum-val[k];i>=0;i--){
			dp[i+val[k]]=min(dp[i+val[k]],dp[i]+wt[k]);
		}
	}
	for(int i=val_sum;i>=0;i--)if(dp[i]<=w){cout<<i;break;}
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdint.h> // uint64_t

#define max(a,b) ((a) > (b) ? (a) : (b))
#define min(a,b) ((a) > (b) ? (b) : (a))
#define DIGITS_MAX 200000
#define BUF_SIZE (DIGITS_MAX+50)

// size: specify sizeof(str)
int get_str(char *str, int size) {
    if(!fgets(str, size, stdin)) return -1;
    return 0;
}

#define DIVISOR 2019

int main(void) {
    static char nstr[BUF_SIZE];
    get_str(nstr, BUF_SIZE);
    int len = strlen(nstr) - 1;
    static int map[DIGITS_MAX+2]; // 1-indexed

    static int power10[DIGITS_MAX+1];
    power10[0] = 1;
    int i;
    for(i = 1; i <= len; i++) {
        power10[i] = (power10[i-1] * 10)%DIVISOR;
    }

    for(i = len; i >= 1; i--) {
        int cur = len-i+1;
        int cur_digit = nstr[i-1] - '0';
        map[i] = (map[i+1] + power10[cur-1]*cur_digit)%DIVISOR;
    }

    static int cnt_map[DIVISOR];
    cnt_map[0]++;
    uint64_t res = 0;
    for(i = len; i >= 1; i--) {
        int mod = map[i];
#ifdef DEBUG
        printf("digit #%d: %d\n", len-i+1, mod);
#endif
        res += cnt_map[mod];
        cnt_map[mod]++;
    }
    printf("%llu\n", res);
    return 0;
}

Measured memory_bytes: 3360
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(a); (i)<(b); ++(i))
#define rFor(i, a, b) for(int (i)=(a)-1; (i)>=(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef pair<int, int> pii;
typedef pair<pii, lint> ppl;
typedef pair<lint, lint> pll;
typedef complex<double> xy_t;
typedef vector<lint> poly;

const lint mod = 1e9 + 7;

template<class T> struct ConvexHullTrick{
    struct CHTline{
        T a, b;
        CHTline(T a_, T b_): a(a_), b(b_){}

        T getval(T x){
            return a * x + b;
        }
    };

    deque<CHTline> dq;

    void addline(T a, T b){
        CHTline L3(a, b);
        while(dq.size() >= 2){
            CHTline L1 = dq[dq.size()-2], L2 = dq[dq.size()-1];
            if(L1.a*L3.b-L3.a*L1.b <= (L3.b-L1.b)*L2.a + (L1.a-L3.a)*L2.b){
                dq.pop_back();
            }
            else break;
        }
        dq.push_back(L3);
    }

    T getmin(T x){
        while(dq.size() >= 2 && dq[0].getval(x) >= dq[1].getval(x)){
            dq.pop_front();
        }
        return dq[0].getval(x);
    }
};

int main(){
    int n;
    lint c;
    scanf("%d%lld", &n, &c);
    lint h[n];
    rep(i, n) scanf("%lld", &h[i]);

    lint dp[n];
    dp[0] = 0;
    ConvexHullTrick<lint> cht;
    cht.addline(-2*h[0], h[0]*h[0] + c);

    For(i, 1, n){
        dp[i] = cht.getmin(h[i]) + h[i]*h[i];
        cht.addline(-2*h[i], h[i]*h[i] + c + dp[i]);
    }

    printf("%lld\n", dp[n-1]);
}

Measured memory_bytes: 5504
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
    [w,h,n] <- getIntList
    axys <- replicateM n $ do
        [x,y,a] <- getIntList
        return (a,x,y)
    print $ solve axys (0,w,0,h)

solve [] (s1,s2,s3,s4) = (max 0 (s2-s1)) * (max 0 (s4-s3))
solve ((a,x,y):axys) (s1,s2,s3,s4)
    | a == 1 = let s1' = max s1 x in solve axys (s1',s2,s3,s4)
    | a == 2 = let s2' = min s2 x in solve axys (s1,s2',s3,s4)
    | a == 3 = let s3' = max s3 y in solve axys (s1,s2,s3',s4)
    | a == 4 = let s4' = min s4 y in solve axys (s1,s2,s3,s4')

Measured memory_bytes: 508
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
int64_t N, K;
vector<int64_t> AP;
vector<int64_t> AM;

int64_t getSeqM(int64_t X) {
  int64_t ret = 0;
  int64_t plus = AP.size() - 1;
  for (int64_t minus = AM.size() - 1; minus >= 0; --minus) {
    while (0L <= plus && AP[plus] * AM[minus] <= X) plus--;
    ret += AP.size() - 1 - plus;
  }
  return ret;
}

int64_t getSeqP(int64_t X) {
  int64_t ret = 0;
  int64_t left = 0;
  int64_t right = AM.size() - 1;
  for (left = 0; left < (int)AM.size() - 1; ++left) {
    while (0 <= right && (AM[left] * AM[right]) <= X) right--;
    ret += min(AM.size() - 1 - right, AM.size() - 1 - left);
  }

  left = 0;
  for (right = AP.size() - 1; right > 0; --right) {
    while (left < (int)AP.size() && (AP[left] * AP[right]) <= X) left++;
    ret += min(left, right);
  }
  return ret;
}

int main(void) {
  ios::sync_with_stdio(false);
  cin >> N >> K;
  int64_t plus = 0;
  int64_t minus = 0;
  int64_t zero = 0;
  rep(i, N) {
    int64_t a;
    cin >> a;
    if (a < 0) {
      AM.emplace_back(a);
      minus++;
    } else if (a > 0) {
      AP.emplace_back(a);
      plus++;
    } else
      zero++;
  }
  sort(AM.begin(), AM.end());
  sort(AP.begin(), AP.end());

  int64_t m_pair = plus * minus;
  int64_t z_pair = (plus + minus) * zero + zero * (zero - 1) / 2;
  // int p_pair = plus * (plus - 1) / 2 + minus * (minus - 1) / 2;
  // cout << "plus="<< plus << " minus=" << minus << " zero=" << zero << endl;
  // cout << "mp=" << m_pair << " pp=" << p_pair << " zp=" << z_pair << endl;
  if (K <= m_pair) {
    int64_t left = -1e18 - 1L;
    int64_t right = 0;
    while (left + 1 < right) {
      int64_t mid = left + (right - left) / 2L;
      int64_t L = getSeqM(mid);
      if (L < K)
        left = mid;
      else
        right = mid;
    }
    cout << right << endl;
  } else if (K <= (m_pair + z_pair)) {
    cout << 0 << endl;
  } else {
    K -= (m_pair + z_pair);
    int64_t left = 0;
    int64_t right = 1e18 + 1L;
    while (left + 1 < right) {
      int64_t mid = left + (right - left) / 2L;
      int64_t L = getSeqP(mid);
      if (L < K)
        left = mid;
      else
        right = mid;
    }
    cout << right << endl;
  }
  return 0;
}


Measured memory_bytes: 5224
#include <cstdio>
using namespace std;
int main() {
    //a:入力 last_i:最後に注文する料理番号 sum:合計時間 
	int a[5],last_i,tmp,sum;
    for (int i=0; i<5; i++) {
        scanf("%d",&a[i]);
    }
    tmp = __INT32_MAX__;
    for (int i=0; i<5; i++){
        int tmp2 = a[i]%10;
        if (tmp2 == 0){
            tmp2 = 10;
        }
        if (tmp2<tmp){
            tmp = tmp2;
            last_i = i;
        }
    }
    sum = 0;
    for (int i=0;i<5;i++){
        if ( i!=last_i && a[i]%10>0 ){
            sum += a[i]+(10-a[i]%10);
        } else {
            sum += a[i];
        }
    }
    printf("%d\n",sum);
}

Measured memory_bytes: 128
#include<iostream>
#include <algorithm>
using namespace std;
int main(){
 int n,m,i,j,k,l=0,v=0;
 cin>>n>>m;
 int a[n];
 for(i=0;i<n;i++){
 	cin>>a[i];
 	l+=a[i];
 }
k=(4*m);
k=l/k;
j=0;
sort(a,a+n);
 for(i=n-1;i>=0;i--){
 	
 	if(4*a[i]*m>=l)
 		j++;
 
 }
 if(j>=m)
 	cout<<"Yes";
 else
 	cout<<"No";
 
 
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

long L;
int N;
long x[200001];
long sum[200001];

long calc(int l){
    long tmp = 0;
    if(l == N-l){
        tmp += 2*(sum[l]-sum[0]);
        tmp += (2*L*(N-l) - 2*(sum[N]-sum[l]));
        tmp -= min(x[l], L-x[l+1]);
    }else if(l < N-l){
        tmp += 2*(sum[l]-sum[0]);
        tmp += (2*L*l - 2*(sum[2*l]-sum[l]));        
        tmp -= min(x[l], L-x[l+1]);
        long tmp2 = 0;
        tmp2 += 2*(sum[l]-sum[0]);
        tmp2 += (2*L*(l+1) - 2*(sum[2*l+1]-sum[l]));     
        tmp2 -= (L-x[l+1]);
        tmp = max(tmp, tmp2);
    }else{
        tmp += 2*(sum[l]-sum[2*l-N]);
        tmp += (2*L*(N-l) - 2*(sum[N]-sum[l])); 
        tmp -= min(x[l], L-x[l+1]);
        long tmp2 = 0;
        tmp2 += 2*(sum[l]-sum[2*l-N-1]);
        tmp2 += (2*L*(N-l) - 2*(sum[N]-sum[l])); 
        tmp2 -= x[l];
        tmp = max(tmp, tmp2);
    }
    return tmp;
}

int main(){
    
    cin >> L >> N;
    //if(N > 2000) return 0;
    sum[0] = 0;
    for(int i = 1; i <= N; i++){
        cin >> x[i];
        sum[i] = sum[i-1]+x[i];
    }
    long ans = 0;
    if(N == 1){
        ans = max(x[1], L-x[1]);
        cout << ans << endl;
        return 0;
    }
    ans = max(max(x[1], L-x[1]), max(x[N], L-x[N]));
    
    for(int l = 1; l < N; l++){
        ans = max(ans, calc(l));
        //cout << ans << endl;
    }

    cout << ans << endl;
}

Measured memory_bytes: 3328
#include<cstdio>
#include<cstring>
using namespace std;
const int MAX = 100 + 10;

char a1[MAX], a2[MAX];

int main(){
  int n, ans;
  scanf("%d" ,&n);
  scanf("%s", a1);
  scanf("%s", a2);
  ans = 2 * n;
  for(int i = 0 ; i < n ; i++){
    bool get = true;
    for(int j = 0 ; j < n-i ; j++){
      if(a1[i+j] != a2[j]) {
        get = false;
        break;
      }
    }
    if(get){
      ans = n + i;
      break;
    }
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, a) for(int i = 0; i < a; i++)
#define all(v) v.begin(), v.end()
#define dcout cout << fixed << setprecision(15)
#define arep(i, a) for(auto i : a)
#define F first
#define S second
#define VE vector<int>
#define pb(x) push_back(x)
#define MOD 1000000007
#define INF 10000000000
#define int long long
#define KETA(n) floor(log10(n) + 1)
using namespace std;
signed main() {
    int a, b;
    cin >> a >> b;
    if(abs(a - b) % 2 != 0)
        cout << "IMPOSSIBLE";
    else
        cout << min(a, b) + abs(a - b) / 2;
    return 0;
}

Measured memory_bytes: 256
import math
N, H = map(int, input().split())
A = []
B = []
for i in range(N):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)

amax = max(A)
# 最強の振り刀より強い攻撃力を持つものを抽出
B = list(filter(lambda x: x > amax, B))
B.sort()

ans = 0
while H > 0:
    # まだ投げれる
    if B:
        H -= B.pop()
    # もう投げれない
    else:
        ans += math.ceil(H/amax)
        break
    ans += 1

print(ans)


Measured memory_bytes: 11764
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            String s = in.next();
            out.println(s.substring(s.indexOf('A'), s.lastIndexOf('Z')).length() + 1);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

    }
}



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

int main() {
  int N;
  ll Y;
  cin >> N >> Y;
  for (int i = 0; i<=N; i++) {
    for (int j = 0; j<=N-i; j++) {
      if (10000*i+5000*j+1000*(N-i-j) == Y) {
        cout << i <<" "<< j <<" "<< N-i-j << endl;
        return 0;
      }
    }
  }
  cout << "-1 -1 -1" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
#define pb push_back
#define pii pair < int , int >
#define F first
#define S second
#define endl '\n'
#define int long long
#define sync ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#define kill(x) return cout<<x<<'\n', 0;
using namespace std;
const int N=3e3+100;
vector <int> g[N];
ll a[N];
ll dp[N];
void dfs(ll v,ll p){
    for (auto u : g[v]){
        if (u==p) continue;
        dfs(u,v);
        if (a[u]<a[v] && dp[u]==0){
            dp[v]=1;
            break;
        }
    }
    return ;
}
int32_t main(){
    ll n;
    cin >> n;
    for (int i=1;i<=n;i++){
        cin >> a[i];
    }
    for (int i=0;i<n-1;i++){
        ll u,v;
        cin >> u >> v;
        g[u].pb(v);
        g[v].pb(u);
    }
    for (int i=1;i<=n;i++){
        dfs(i,i);
        if (dp[i]) cout << i << " ";
    }
}


Measured memory_bytes: 4080
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
 
using namespace std;
 
int main()
{
  int x,n,diff=0,min=INT_MAX,elem;
  cin>>x>>n;
  
  if(n==0) cout<<x<<endl;
  else
  {
    vector<int> v(101,0);
    vector<int> v1(n);
    for(int i=0;i<n;i++) cin>>v1[i],v[v1[i]]=1;
    
    sort(v1.begin(),v1.end());
    
    for(int i=0;i<=101;++i)
    { 
      if(v[i]==0){
      diff = abs(x-i);
      if(diff<min) min=diff, elem=i;}
    }
    
    cout<<elem<<endl;
  }
}

Measured memory_bytes: 3644
#include <iostream>
#include <algorithm>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <queue>
#include <cmath>
#include <cstdio>

using namespace std;

int main(){
    int n, h; cin >> n >> h;
    int max_a=0;
    vector<int> bs(n);
    for(int i=0; i<n; ++i){
        int a, b; cin >> a >> b;
        max_a=max(max_a, a);
        bs[i]=b;
    }
    sort(bs.rbegin(), bs.rend());
    int ans=0;
    for(int i=0; i<n; ++i){
        if(bs[i]<max_a) break;
        h-=bs[i];
        ++ans;
        if(h<=0){
            break;
        }
    }
    if(h>0) ans+=(h+max_a-1)/max_a;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 640
#include <stdio.h>
#define MAX 10000
#define NIL -1

struct Node { int p , l , r;};

struct Node T[MAX];

int n;

//先行
void preParse(int u)
{
	if( u == NIL) return;
	printf(" %d",u);
	preParse(T[u].l);
	preParse(T[u].r);
}

//中間
void inParse(int u)
{
	if( u == NIL) return;
	inParse(T[u].l);
	printf(" %d",u);
	inParse(T[u].r);
}

//後行
void postParse(int u)
{
	if(u == NIL) return;
	postParse(T[u].l);
	postParse(T[u].r);
	printf(" %d",u);
}

int main()
{
	int i , v , l , r , root;
	scanf("%d",&n);
	
	for( i = 0; i < n; i++)
	{
		T[i].p = NIL;
	}
	
	for( i = 0; i < n; i++)
	{
		scanf("%d %d %d",&v,&l,&r);
		T[v].l = l;
		T[v].r = r;
		if( l != NIL) T[l].p = v;
		if( r != NIL) T[r].p = v;
	}
	
	for( i = 0; i < n; i++) if(T[i].p == NIL) root = i;
	
	printf("Preorder\n");
	preParse(root);
	printf("\n");
	printf("Inorder\n");
	inParse(root);
	printf("\n");
	printf("Postorder\n");
	postParse(root);
	printf("\n");
	
	return 0;
}


Measured memory_bytes: 2104
#include<bits/stdc++.h>
using namespace std;
#define pi 3.14159265359
#define int long long
#define pii pair<int,int>
const int mod=1e9+7;

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

bool check(string &s)
{
  for(int i=0;i<s.size()/2;i++)
  {
    if(s[i]!=s[s.size()-1-i])return 0;
  }
  return 1;
}

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

 
  string s;
  cin>>s;

  string x=s.substr(0,(s.size()-1)/2);
  string y=s.substr((s.size()+3)/2-1);
  if(check(s)&&check(y)&&check(x))
  {
    cout<<"Yes\n";
  }

  else cout<<"No\n";



}




Measured memory_bytes: 256
s = [0] * 13
h = [0] * 13
c = [0] * 13
d = [0] * 13
N = int(input())
i = 0
while i < N:
    m, n = map(str, input().split(' '))
    n = int(n) - 1
    if m == 'S':
        s[n] = 1
    elif m == 'H':
        h[n] = 1
    elif m == 'C':
        c[n] = 1
    elif m == 'D':
        d[n] = 1
    i += 1
ans = ''
j = 0
while j < 13:
    if s[j] == 0:
        ans += 'S ' + str(j + 1) + '\n'
    j += 1
j = 0
while j < 13:
    if h[j] == 0:
        ans += 'H ' + str(j + 1) + '\n'
    j += 1
j = 0
while j < 13:
    if c[j] == 0:
        ans += 'C ' + str(j + 1) + '\n'
    j += 1
j = 0
while j < 13:
    if d[j] == 0:
        ans += 'D ' + str(j + 1) + '\n'
    j += 1
if ans != '':
    print(ans[:-1])


Measured memory_bytes: 5612
/* Bismillahirrahmanirrahim */
/* Author : Jehian Norman Saviero (@Reiva5) */
#include <bits/stdc++.h>

/* MACROS SAMPAH */
#define Jehian using
#define Norman namespace
#define Saviero std
#define cepet {ios_base::sync_with_stdio(0);cin.tie(0);}

Jehian Norman Saviero;

/* MACROS FOR TYPE */
typedef long l;
typedef long double ld;
typedef long long ll;
typedef unsigned long ul;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<l> vl;
typedef vector<ll> vll;
typedef pair<int, int> pi;
typedef pair<l,l> pl;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pld;

/* MACROS FOR PRINT */
#define nl printf("\n")
#define sp printf(" ")

/* MACROS FOR FUNCTION AND METHOD */
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define mp make_pair
#define eb emplace_back
#define RESET(x) memset((x), 0, sizeof(x))
#define SET(x,y) for(int _je = sizeof(x)/sizeof(x[0]); _je--;) x[_je] = y
#define SQR(x) (x)*(x)
#define CUBE(x) SQR(x)*(x)
#define ALL(x) (x).begin(), (x).end()
#define ALLSIZE(x,n) (x), (x)+(n)

/* MACROS FOR ATTRIBUTE */
#define fi first
#define se second

/* MACROS FOR SCAN */
#define scc(x) scanf("%c", &x)
#define scd(x) scanf("%Lf", &x)
#define scf(x) scanf("%f", &x)
#define sci(x) scanf("%d", &x)
#define scl(x) scanf("%ld", &x)
#define scll(x) scanf("%lld", &x)
#define scld(x) scanf("%Lf", &x)
#define scui(x) sci(x)
#define scul(x) scl(x)
#define scull(x) scll(x)

bool cmp(pll a, pll b){
	return a.fi > b.fi || (a.fi == b.fi && a.se < b.se);
}

bool cmp2(pll a, pll b){
	return a.se > b.se;
}

int main(){
	ll N, H;
	scll(N);
	scll(H);
	pll data[N];
	for (ll i = 0; i < N; ++i){
		cin >> data[i].fi >> data[i].se;
	}
	sort(data,data+N,cmp);
	sort(data+1,data+N,cmp2);
	ll cnt = 0;
	for (ll i = 1; i < N && H > 0; ++i){
		if (data[i].se > data[0].fi){
			++cnt;
			H -= data[i].se;
		} else {
			++cnt;
			H -= data[0].se;
			if (H > 0){
				cnt += (H/data[0].fi);
				H %= data[0].fi;
				if (H){
					++cnt;
					H = 0;
				}
			}
		}
	}
	if (H > 0){
		++cnt;
		H -= data[0].se;
		if (H > 0){
			cnt += (H/data[0].fi);
			H %= data[0].fi;
			if (H){
				++cnt;
				H = 0;
			}
		}
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 1920
d_list = list( input("") )
i = 0
while(i < len(d_list) ):
  if i % 2 == 0:
    if d_list[i] == "L":
        break
  if i % 2 == 1:
    if d_list[i] == "R":
        break
  i += 1

if i == len(d_list):
  print("Yes")
else:
  print("No")

      

Measured memory_bytes: 2940
import java.util.*;

public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    int N = Integer.parseInt(sc.next());
    int n = N%2==0 ? N/2 : N/2+1;
    
    int min = 100000000;
    for(int i = 1; i <= n; i++){
      int a = i;
      int b = N-i;
      int sum = 0;
      while(a > 0 || b > 0){
        sum += a%10;
        sum += b%10;
        a /= 10;
        b /= 10;
      }
      
      min = min > sum ? sum : min;
    }
    System.out.println(min);
  }
}

Measured memory_bytes: 21844
/**
 *  @author: pr4shan7 (प्रशांत)
 */
#include <bits/stdc++.h>
using namespace std;

// #define _DEBUG

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

#ifdef _DEBUG
  ifstream cin("input.txt");
  ofstream cout("output.txt");
#endif

  string s;
  cin >> s;
  long long k;
  cin >> k;

  int d1 = 1, d2 = 0, d3 = 1, d4 = 0;
  bool b = false;
  int i = 0;
  for (; i < s.length() - 1; i++) {
    if (s[i] == s[i + 1])
      d1++;
    else {
      i++;
      break;
    }
  }
  // i++;
  int j = s.length() - 1;
  for (; j > 0; j--) {
    if (s[j] == s[j - 1])
      d3++;
    else {
      j--;
      break;
    }
  }
  if (j == 0) b = true;

  long long res = 0;
  int temp = 0;
  for (; i < j; i++) {
    if (s[i] == s[i + 1])
      temp++;
    else if (temp) {
      d2 += (temp + 1) / 2;
      temp = 0;
    }
  }
  if (temp) {
    d2 += (temp + 1) / 2;
  }

  if (s[0] == s[s.length() - 1]) d4 = d1 + d3;

  if (!b and d4)
    res = k * d2 + (k - 1) * (d4 / 2) + d1 / 2 + d3 / 2;
  else if (d4 == 0) {
    res = k * d2 + k * (d1 / 2 + d3 / 2);
  }
  // cout << d1 << ' ' << d2 << ' ' << d3 << ' ' << d4 << ' ' << res << '\n';

  if (b and (s.length() & 1)) {
    if (k & 1)
      cout << (k / 2 + 1) * (s.length() / 2) + (k / 2) * (s.length() / 2 + 1) << '\n';
    else
      cout << (k / 2) * (s.length() / 2) + (k / 2) * (s.length() / 2 + 1) << '\n';
  } else if (b)
    cout << k * s.length() / 2 << '\n';
  else
    cout << res << '\n';
  return 0;
}


Measured memory_bytes: 256
N = int(input())
c = 0
S = list()
for i in input():
    if(i == 'o'): S.append(0)
    else: S.append(1)

for i in [0, 1]:
    if(c == 1): break
    for j in [0, 1]:
        t = list()
        t.append(i)
        t.append(j)

        for k in range(1, N-1):
            t.append(S[k] ^ t[k] ^ t[k-1])

        if(((S[0] ^ t[0] ^ t[-1]) == t[1]) & ((S[-1] ^ t[-1] ^ t[-2]) == t[0])):
            c = 1
            break

if(c == 1):
    ans = ""
    for i in t:
        if(i == 0): ans = ans + 'S'
        else: ans = ans + 'W'
    print(ans)
else:
    print('-1')

Measured memory_bytes: 4876
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define fs first
#define sc second

int main(void){
  int x,a;
  cin >> x >> a;
  cout << (int)(x>=a)*10 << endl;
}

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


int main(){
    
    int n,m;
    while(cin>>n>>m&&n&&m){
        vi p(n);
        rep(i,n)cin>>p[i];
        sort(all(p));
        
        set<ll> val;
        val.insert(0);
        rep(i,n){
            if(p[i]>m)break;
            val.insert(p[i]);
        }
        rep(i,n)for(ll j=i;j<n;j++){
            if(p[i]+p[j]>m)break;
            val.insert(p[i]+p[j]);
        }
        
        vector<ll> left,right;
        
        for(auto &v : val) left.pb(v);
        
        
        sort(all(left));
        right = left;
        
        ll maxi=0;
        rep(i,left.size()){
            ll num = left[i];
            if(num>m)break;
            
            ll l=0, r=right.size()+1, mid=(l+r)/2LL;
            while(l+1<r){
                if(right[mid]<=m-num) l = mid;
                else    r= mid;
                mid = (l+r)/2LL;
            }
            
            maxi = max<ll>(maxi,num+right[mid]);
        }
        cout<<maxi<<endl;
    }
}

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

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int N; cin >> N;
	vector<pair<pair<string, int>, int>> V(N);
	for (int i = 0; i < N; i++) {
		cin >> V[i].first.first;
		cin >> V[i].first.second;
		V[i].first.second *= -1;
		V[i].second = i+1;
	}
	sort(V.begin(), V.end());
	for (const auto& it : V) cout << it.second << '\n';

	return 0;
}


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

using namespace std;

long long inf=1000000007;

long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

int main(){
	int x,y;
	cin>>x>>y;
	if((x+y)%3!=0){
		cout<<0<<endl;
		return 0;
	}

	int a=(2*y-x)/3;
	int b=(x-a)/2;

	if(a<0 || b<0){
		cout<<0<<endl;
		return 0;
	}

	int n=a+b;
	int r=min(a,b);

	long long ans=1;

	for(int i=0;i<r;i++){
		ans*=n;
		ans%=inf;
		n--;
	}

	for(int i=1;i<=r;i++){
		ans*=modinv(i,inf);
		ans%=inf;
	}

	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
using namespace std;
 
int main() {
    const double Pi=3.14159265358979;
    double r;
    cin >> r;
 
    double s=Pi*r*r;
    double l=2*Pi*r;
 
    cout << fixed << setprecision(6) << s << " " << l << endl;
    return 0;
}

Measured memory_bytes: 1292
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>

int N;
std::vector<int> d;

int main(int argc, char const* argv[])
{
    std::cin >> N;
    int tmp;
    while (std::cin >> tmp) {
        d.push_back(tmp);
    }
    std::sort(d.begin(), d.end());
    std::cout << d[N/2]-d[N/2-1] << std::endl;
    return 0;
}


Measured memory_bytes: 892
#include <stdio.h>
#include <vector>

using namespace std;

vector<int> sei[100000];

bool s1[100000];
bool s2[100000];

int main(){
while(1){
int n,m;
scanf("%d%d",&n,&m);
if(n == 0){
return 0;
}
for(int i = 0; i < n; i++){
sei[i].resize(0);
}
for(int i = 0; i < m; i++){
int a,b;
scanf("%d%d",&a,&b);
a--;
b--;
sei[a].push_back(b);
sei[b].push_back(a);
}
for(int i = 0; i < n; i++){
s1[i] = false;
s2[i] = false;
}
for(auto i : sei[0]){
s1[i] = true;
}
for(int i = 0; i < n; i++){
if(s1[i]){
for(auto j : sei[i]){
s2[j] = true;
}
}
}
int all = 0;
for(int i = 0; i < n; i++){
if(s1[i] || s2[i]){
all++;
}
}
printf("%d\n",all - 1);
}
}

Measured memory_bytes: 5060
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
#ifdef DEBUG
#define line() cerr << "[" << __LINE__ << "] ";
#define dump(i) cerr << #i ": " << i << " ";
#define dumpl(i) cerr << #i ": " << i << endl;
#else
#define line(i)
#define dump(i)
#define dumpl(i)
#endif
using namespace std;
#include <bits/stdc++.h>
using namespace std;

int main()
{
    int n, m;
    cin >> n >> m;
    map<int, int> key;
    ll cost[m];
    rep(i, m)
    {
        int b;
        cin >> cost[i] >> b;
        key[i] = 0;
        rep(j, b)
        {
            int t;
            cin >> t;
            t--;
            key[i] |= (1 << t);
        }
    }
    ll dp[1 << n];
    ll INF = 1ll << 60;
    rep(i, 1 << n) dp[i] = INF;
    dp[0] = 0;
    rep(i, m)
    {
        rep(j, 1 << n)
        {
            dp[j | key[i]] = min(dp[j | key[i]], dp[j] + cost[i]);
        }
    }
    if (dp[(1 << n) - 1] != INF)
        cout << dp[(1 << n) - 1] << endl;
    else
        cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 384
n = int(input())
s = input()
e_l, e_sum = [], 0
w_l, w_sum = [], 0
for i in range(n):
    if s[i] == 'E':
        e_sum += 1
    else:
        w_sum += 1
    e_l.append(e_sum)
    w_l.append(w_sum)
for i in range(n):
    if i == 0:
        ans = e_l[n-1] - e_l[0]
    elif i == n:
        ans = max(ans, w_l[n-2])
    else:
        ans = min(ans, e_l[n-1] - e_l[i] + w_l[i-1])
print(ans)

Measured memory_bytes: 17832
n = int(input())
s = [input() for cnt in range(n)]

cnt_ac = 0
cnt_wa = 0
cnt_tle = 0
cnt_re = 0

for cnt in range(n):
    if s[cnt] == "AC":
        cnt_ac += 1
    elif s[cnt] == "WA":
        cnt_wa += 1
    elif s[cnt] == "TLE":
        cnt_tle += 1
    else:
        cnt_re += 1

print("AC x ", cnt_ac)
print("WA x ", cnt_wa)
print("TLE x ", cnt_tle)
print("RE x ", cnt_re)


Measured memory_bytes: 16320
import java.util.Scanner;

class Main {
    static long factri[] = new long[1_000_000];
    static final long mod = 1000000007;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        sc.close();
        if (Math.abs(n - m) >= 2) {
            System.out.println(0);
            return;
        }
        factri[0] = 0;
        factri[1] = 1;
        factri[2] = 2;
        for (int i = 3; i < n + 20; i++) {
            factri[i] = i * factri[i - 1];
            factri[i] %= mod;
        }
        long ans = factri[n] * factri[m] % mod;
        if (n == m) {
            ans *= 2;
            ans %= mod;
        }
        System.out.println(ans);

    }
}


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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 62)

typedef long long i64;
typedef pair<i64,i64> P;

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

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



int n, m, a[10];
int dp[101010], ma[101010];
void solve(){
	cin >> n >> m;
	bool b[10] = {0};
	for(int i = 0; i < m; i++){
		cin >> a[i];
		b[a[i]] = 1;
	}
	int y[10] = {10,2,5,5,4,5,6,3,7,6};
	fill(dp,dp+101010,-INF);
	dp[0] = 0;
	for(int i = 0; i < n; i++){
		for(int j = 1; j <= 9; j++){
			if(!b[j]) continue;
			if(dp[i+y[j]] == dp[i]+1){
				chmax(ma[i+y[j]], j);
			}
			if(chmax(dp[i+y[j]], dp[i]+1)){
				ma[i+y[j]] = j;
			}
		}
	}
	
	int now = n;
	while(now > 0){
		cout << ma[now]; 
		now -= y[ma[now]];
	}
	cout << endl;
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}

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

int main()
{
    string x;
    cin >> x;
    int ans = 0;
    for(int i=0; i<4; i++)
    {
        if(x[i]=='-')
            ans--;
        else
            ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	long long n;
	cin >> n; 

	string ans="";
	while(n>0){
		--n;
		ans += 'a'+ n%26;
		n /= 26;
	}

	reverse(ans.begin(),ans.end());
	cout << ans << endl;
}

Measured memory_bytes: 3628
// Marcin Knapik
#include<bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")

using namespace std;

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

// const ll MAX_LL = 0xFFFFFFFFFFFFFFFF;
// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define losuj(a, b) uniform_int_distribution<ull>(a, b)(rng)

typedef long double             ld;
typedef long long               ll;
typedef pair<ll, ll>          ii;
typedef vector<int>             vi;
typedef vector<ll>              vll;
typedef vector<vll>             vvll;
typedef vector<ii>              vii;
typedef vector<vi>              vvi;
typedef vector<vii>             vvii;
#define pll pair<long long, long long>

#define sz(a)                   (int)(a).size()
#define pb                      push_back
#define all(c)                  (c).begin(), (c).end()
#define rall(c)                 (c).rbegin(), (c).rend()
#define FOR(i, a)               for (int i = 0; i < (a); i++)
#define f                       first
#define s                       second

template <class T> inline bool setmin(T &a, T b){if (a > b)return a = b, 1;return 0;}
template <class T> inline bool setmax(T &a, T b){if (a < b)return a = b, 1;return 0;}

template<class T> inline T fast(T a,T b,T mod) {ll res = 1; while(b){if(b&1) res = (res*a)%mod;a = (a*a)%mod;b >>= 1;}return res;}
template<class T> istream &operator>>(istream &os, vector<T> &container){for (auto &u : container)os >> u;return os;}
template<class T> ostream &operator<<(ostream &os, const vector<T> &container){for (auto &u : container)os << u << " ";return os;}
template<class T> inline T gcd(T a, T b) { while (b)swap(a %= b, b); return a; }

const ll INF = 1e9 + 7;
const ll mod = 998244353;
const ll BIG_INF = 1e18;
const ll N = 1e6+7;
const ll T = 1<<20;
const ld inf = 1e18;

ll n, m, q;

int snak[N];
int odw[N];
vvi G(N);

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

    cin >> n >> m;

    FOR(i, m){
    	int a, b;
    	cin >> a >> b;
    	G[a].pb(b);
    	G[b].pb(a);
    }

    queue<int> kol;
    kol.push(1);
    odw[1] = true;

    while(sz(kol)){
    	auto akt = kol.front();
    	kol.pop();

    	for(auto & u : G[akt]){
    		if(!odw[u]){
    			odw[u] = 1;
    			kol.push(u);
    			snak[u] = akt;
    		}
    	}
    }

    for(int i = 2; i <= n; i++){
    	if(snak[i] == 0){
    		cout << "No";
    		exit(0);
    	}
    }
    cout << "Yes\n";
    for(int i = 2; i <= n; i++)
    	cout << snak[i] << '\n';

}   	

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

int main() {
  int N,K;
  cin >> N >> K;
  int A = 1;
  int B = K;
  for (int i = 0; i < 40; i++) {
    if (A <= N && N < B) {
      cout << i + 1 << endl;
      break;
    }
    A *= K;
    B *= K;
  } 
      
}


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

#define SIZE 200001

using namespace std;

int main() {
    long long int B,i,j,k,M,K,Q;
    long long int X,N,Y,Z;
  //  long long int A[100][100];

    char C;
    cin >> C;
    if ((C >= 'A') && (C <= 'Z'))
      cout << 'A' << endl;
    else
    cout << 'a' << endl;

  return 0;

}


Measured memory_bytes: 3628
//
//  main.cpp
//  AC
//
//  Created by makinofuya on 2019/07/08.
//  Copyright © 2019 makinofuya. All rights reserved.
//
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stack>
#include <math.h>

typedef long long ll;
using namespace std;
#define mod 1000000007
#define rep(i,n) for(ll i=0;i<n;i++)
#define out(s) cout << s << endl


int main(){
    int n;cin >> n;
    int t=n,c=0;
    while(t>0){
        c+=t%10;
        t/=10;
    }
    if(n%c==0)out("Yes");
    else out("No");
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    int k,count_odd=0,count_even=0;
    cin>>k;
    for(int i=1;i<=k;i++)
    {
        if(i%2==0)
        {
            count_even++;
        }
        else if(i%2!=0)
        {
            count_odd++;
        }
    }
    cout << count_even*count_odd << endl;
    return 0;
}


Measured memory_bytes: 256
program String_Formation
    implicit none
    character S*400005,C*1,query*100
    character ans(-400005:400005)
    integer Q,l,r,i,T,rev,F
    integer sf(100)

    read *,S,Q
    l = 0
    r = len_trim(S)+1
    rev = 0
    ans(1:) = transfer(S,ans,size=len(S))

    do i = 1, Q
        read (*,'(a)')query
        if(query(1:1) == '1') then
             rev = rev+1
        else
            read (query,*)T,F,C 
            if(F == 1) then
                if(mod(rev,2) == 1) then
                    ans(r:r) = C
                    r = r+1
                else
                    ans(l:l) = C
                    l = l-1
                endif
            else
                if(mod(rev,2) == 0) then
                    ans(r:r) = C
                    r = r+1
                else
                    ans(l:l) = C
                    l = l-1
                endif
            endif
        endif
    enddo

    if(mod(rev,2) == 0) then
        print *,ans(l+1:r-1)
    else
        print *,ans(r-1:l+1:-1)
    endif


end program String_Formation

Measured memory_bytes: 1820
#include<iostream>
 #include<stdio.h>
 #include<string>
 #include<math.h>
 #include<iomanip>
 #include<algorithm>
 #include<string.h>
 #include<cctype>
 #include<map>
 #include<set>
 #include<vector>
 #include<sstream>
 #include<stack>
 #include<queue>
 
 using namespace std;
 
 int hash[53]={0};
 
 int main()
 {
   int N;
   cin>>N;
   while(N--)
   {
     char type;
     int num;
     cin>>type>>num;
     if(type=='S') hash[num]++;
     else if(type=='H') hash[num+13]++;
     else if(type=='C') hash[num+26]++;
     else hash[num+39]++;          
   }
   for(int i=1;i<=52;i++)
   {
     if(!hash[i])
     {
       int a=(i-1)/13;
       char kk;
       int b=i%13;
       if(b==0) b=13;
       if(a==0) kk='S';
       else if(a==1) kk='H';
       else if(a==2) kk='C';
       else kk='D';
       cout<<kk<<" "<<b<<endl;           
     }        
   }
   //while(1);
   return 0;
 }
 

Measured memory_bytes: 3080
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define REP2(i,x,n) for (int i = x; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
static const double PI = acos(-1);
static const int INF = 1e9+7;



int main(){
  string s;
  cin >> s;

  int cnt = 0;

  REP(i,s.size() - 1){
    if(s[i] != s[i+1]) ++cnt;
  }

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


Measured memory_bytes: 3768
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define sez(a) a.size()
const int maxn=2e5+1;
const int INF=1e9+7;

int main(){
    #ifdef kolya
        freopen("input.txt","r",stdin);
    #else
     //   freopen("tree.in","r",stdin);
     //    freopen("tree.out","w",stdout);
    #endif // kolya
  //  ios_base::sync_with_stdio(0);u
  //  cin.tie(0);
  //  cout.tie(0);
    ll q,h,s,d;
    cin>>q>>h>>s>>d;
    ll two_liter=min(min(q*8,s*2),min(h*4,d));
    ll n;
    cin>>n;
    ll twos=n/2;
    ll ans=0;
    ans+=1ll*twos*two_liter;
    if (n&1)
        ans+=min(min(q*4,s),h*2);
    cout<<ans;
}


Measured memory_bytes: 256
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1111111111;
constexpr lint LINF = 1LL << 60;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (const auto &e : vec) os << e << (&e == &vec.back() ? "" : " ");
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

int main() {

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

	int N;
	cin >> N;

	vector<int> w(N);
	for (int i = 0; i < N; i++) cin >> w[i];
	reverse(w.begin(), w.end());

	vector<int> ans(N, INF);
	for (int i = 0; i < N; i++) *upper_bound(ans.begin(), ans.end(), w[i]) = w[i];

	cout << lower_bound(ans.begin(), ans.end(), INF) - ans.begin() << "\n";

	return 0;
}

Measured memory_bytes: 1024
import java.util.*;
public class Main{
  public static void main(String[] args)
  {
    Scanner input = new Scanner(System.in);
    
    int n = input.nextInt();
    int m = input.nextInt();
    
    if(n>9||m>9)
      System.out.println(-1);
    else
      System.out.println(n*m);
  }
}


Measured memory_bytes: 23636
#include <iostream>
#include <vector>
#include <utility>
#include <queue>

#define INF 100000000

using namespace std;

int dijk(vector<vector<pair<int,int> > > &graph, int start, int goal){
        int total;
        priority_queue<pair<int, int>, vector<pair<int, int> >, greater<pair<int, int> > > que;
        que.push( make_pair(0,start) );
        vector<int> cost(graph.size(), INF);
        while( !que.empty() ){
                pair<int,int> tmp = que.top(); 
                que.pop();
                if( cost[ tmp.second ] < INF ) continue;

        //      cout << tmp.second << "  " << tmp.first << "  " << endl;
                cost[tmp.second] = tmp.first;

                if( tmp.second == goal ) break;
                for(int i=0; i < graph[tmp.second].size(); i++){
                        if( cost[ graph[tmp.second][i].first ] == INF )
                                que.push( make_pair( tmp.first + graph[tmp.second][i].second, graph[tmp.second][i].first ) );
                }
        }
        return cost[goal];
}


int main(){
        int n, m, a, b, cost, time;

        while( cin >> n >> m , n && m ){
                vector<vector<pair<int, int> > > graph(m);
                vector<vector<pair<int, int> > > gtime(m);

                for(int i=0; i<n; i++){
                        cin >> a >> b >> cost >> time;
                        --a; --b;
                        graph[a].push_back( make_pair(b, cost) );
                        graph[b].push_back( make_pair(a, cost) );
                        gtime[a].push_back( make_pair(b, time) );
                        gtime[b].push_back( make_pair(a, time) );
                }

                int k;

                cin >> k;
                for(int i=0; i<k; i++){
                        int p, q, r;
                        cin >> p >> q >> r;
                        p--; q--;
                        if( r ){
                                cout << dijk( gtime, p, q ) << endl;
                        }else{
                                cout << dijk( graph, p, q ) << endl;
                        }
                }
        }

        return 0;
}

Measured memory_bytes: 1372