akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;

int main(){
    int T[101][101],r,c;
    
    cin >> r >> c;
    for (int i=0; i<r; i++)
        for (int j=0; j<c; j++) cin >> T[i][j];
        
    for (int i=0; i<=r; i++) T[i][c]=0;
    for (int j=0; j<=c; j++) T[r][j]=0;
    
    for (int i=0; i<r; i++){
        for (int j=0; j<c; j++){
            T[i][c] += T[i][j];
            T[r][j] += T[i][j];
            T[r][c] += T[i][j];
        }
    }
    for (int i=0; i<=r; i++){
        for (int j=0; j<=c; j++){
            if (j) cout <<" ";
            cout << T[i][j];
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3144
# -*- coding: utf-8 -*-
import math

# 整数の入力
k = int(input())
sum = 0.0

for a in range(1, k+1):
    for b in range(1, k+1):
        gcd_ab = math.gcd(a, b)
        for c in range(1, k+1):
            sum = sum + math.gcd(gcd_ab, c)

print(int(sum))

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

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i,N){
        cin >> A[i];
    }
    int count = 0;
    rep(i,N){
        if(A[i]%2 == 1) count++;
    }

    if(count%2 == 1) cout << "NO" <<endl;
    else cout << "YES" <<endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define DEBUG(x) cerr<<#x<<":"<<x<<endl;
#define ALL(c) (c).begin(),(c).end()
 
template<class T> void pv(T a, T b) {
	for(T it = a; it != b; ++it)
		cerr << *it << " ";
	cerr << endl;
}
 
int index(char c) {
	return (c == 'o') ? 1 : 0;
}
 
int main() {
	string line;
	getline(cin, line);
	// 0: black, 1: white
	int ans[2] = {0, 0};
	ans[index(line[0])]++;
	for(int i = 1; i < (int)line.length(); i++) {
		if(line[i - 1] != line[i]) {
			ans[index(line[i])]++;
		}
	}
	// pv(ans, ans + 2);
	if(ans[0] <= ans[1]) cout << 'o' << endl;
	else cout << 'x' << endl;
}

Measured memory_bytes: 1164
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define ALL(v) (v).begin(),(v).end()
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;

int main() {
	int N, K;
	cin >> N >> K;
	if (K == 1) {
		cout << 0 << endl;
	}
	else {
		cout << N - K << endl;
	}
}

Measured memory_bytes: 256
N = int(input())
a = list(map(int, input().split()))

min_cost = 10 ** 10

for i in range(-100,101):
    cost = 0
    for j in range(len(a)):
        cost += (a[j] - i) ** 2
    min_cost = min(cost, min_cost)

print(min_cost)


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

int main(){
    int n,m; cin>>n>>m;

    vector<int> sum(n+1,0);

    for(int i=1; i<=m; i++){
        int a,b; cin>>a>>b;

        sum[a]++; sum[b]++;
    }

    for(int i=1; i<=n; i++) cout<<sum[i]<<endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    while(true) {
      int a = sc.nextInt();
      String op = sc.next();
      int b = sc.nextInt();
      if(op.equals("?")) {
        break;
      } else if(op.equals("+")) {
        System.out.println(a + b);
      } else if(op.equals("-")) {
        System.out.println(a - b);
      } else if(op.equals("*")) {
        System.out.println(a * b);
      } else {
        System.out.println(a / b);
      }
    }
  }
}



Measured memory_bytes: 26348
#include<iostream>
using namespace std;
 
int main(){
  int D;
  cin>>D;
  
  
  switch(D){
    case 22:
    
    	cout<<"Christmas Eve Eve Eve"<<endl;
    	break;
    case 23:
    	cout<<"Christmas Eve Eve"<<endl;
    	break;
    case 24:
    	cout<<"Christmas Eve"<<endl;
    	break;
    case 25:
 		cout<<"Christmas"<<endl;
    	break;
  }
 return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define Tp template<typename Ty>
#define Ts template<typename Ty,typename... Ar>
#define Reg register
#define RI Reg int
#define Con const
#define CI Con int&
#define I inline
#define W while
#define N 200000
using namespace std;
int n,A,B,C,D;char s[N+5];
int main()
{
	RI i;scanf("%d%d%d%d%d%s",&n,&A,&B,&C,&D,s+1);
	for(i=A;i^C;++i) if(s[i]=='#'&&s[i+1]=='#') return puts("No"),0;
	for(i=B;i^D;++i) if(s[i]=='#'&&s[i+1]=='#') return puts("No"),0;
	if(C>D)
	{
		RI f=0;for(i=B;i<=D&&!f;++i) s[i-1]=='.'&&s[i]=='.'&&s[i+1]=='.'&&(f=1);
		if(!f) return puts("No"),0;
	}return puts("Yes"),0;
}

Measured memory_bytes: 3836
import numpy as np
n,k = map(int,input().split())
mod = 10**9 + 7
ans = 0
if k==n+1:
    print(1)
    exit()
for i in range(k, n+2):
    low = (i-1)*i//2
    high = (2*n-i+1)*i//2
    ans += high - low + 1
    ans %= mod
print(ans%mod)

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

#define L(i) (i<<1)+1
#define R(i) (i+1)<<1

using namespace std;

vector<int> A;

vector<int> tree;

int gcd (int a, int b) {
	while (b) {
		a %= b;
        	swap(a, b);
   	}
    	return a;
}

void create(int i,int a,int b){
	if(a==b){
		tree[i]=A[a];
		return;
	}
	int m=(a+b)/2;
	create(L(i),a,m);
	create(R(i),m+1,b);
	tree[i]=gcd(tree[L(i)],tree[R(i)]);
}

int rmq(int i,int a,int b,int qa,int qb){
	if(qb < a || b < qa)return 0;
	if(qa <= a && b<=qb){
		return tree[i];
	}
	int m=(a+b)/2;
	int gL = rmq(L(i),a,m,qa,qb);
	int gR = rmq(R(i),m+1,b,qa,qb);
	return gcd(gL,gR);
}

void update(int i,int a,int b,int p,int v){
	if(p<a || b<p)return;

	if(p==a && b==p){
		tree[i]=v;
		return;
	}
	int m=(a+b)/2;
	update(L(i),a,m,p,v);
	update(R(i),m+1,b,p,v);
	tree[i]=gcd(tree[L(i)],tree[R(i)]);
}

int main(){
	int n;
	cin >> n;
	A.resize(n);
	for(int i=0;i<n;i++){
		cin >> A[i];
	}
	
	tree.assign(4*n,0);
	create(0,0,n-1);

	int ans=0;

	for(int i=0;i<n;i++){
		update(0,0,n-1,i,0);
		ans=max(ans,rmq(0,0,n-1,0,n-1));
		//cerr << rmq(0,0,n-1,0,n-1) << endl;
		update(0,0,n-1,i,A[i]);
	}
	cout << ans << endl;
	return 0;
}


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

vector<int> v;


int main() {
	ll n, x, y;
	cin >> n >> x;
	for(int i = 0; i < n; ++i) {
		cin >>y;
		v.push_back(y);
	}

	ll p = 0;
	int b = 1;
	for(int i = 0; i < n; ++i) {
		p = p+v[i];
		if(p <= x) {
			++b;
			//cout << p << endl;
		}
		//cout << p << endl;
	}
	cout << b << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[] args){
  	Scanner sc=new Scanner(System.in);
    
  	int A=sc.nextInt();
    int B=sc.nextInt();
    int C=sc.nextInt();
    
    if(A==5&&B==5&&C==7||A==5&&B==7&&C==5||A==7&&B==5&&C==5) System.out.println("YES");
    else System.out.println("NO");
  }
}

Measured memory_bytes: 21716
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;
typedef string::const_iterator State;
#define Ma_PI 3.141592653589793
#define eps 1e-5
#define LONG_INF 2000000000000000000LL
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL
#define MOD 998244353LL
#define seg_size 262144
#define REP(a,b) for(long long a = 0;a < b;++a)
map<long long,long long> go_back;
long long find_next(long long now) {
	if (go_back[now] == now||go_back[now] == -1) return go_back[now];
	return go_back[now] = find_next(go_back[now]);
}
int main() {
#define int long long
	long long n, k;
	cin >> n >> k;
	go_back[k - 1] = -1;
	for (int i = k; i < k + 2 * n; ++i) {
		go_back[i] = i;
	}
	vector<tuple<long long, long long, long long>> ans;
	for (int i = 1; i <= n; ++i) {
		long long c = k + 3 * n - i;
		long long b;
		if (i % 2 == 0) {
			b = find_next(k + 2 * n - 1);
		}
		else {
			b = find_next(k + n - 1);
		}
		if (b == -1) {
			cout << -1 << endl;
			return 0;
		}
		go_back[b] = b - 1;
		if (go_back.find(c - b) == go_back.end()) {
			cout << -1 << endl;
			return 0;
		}
		long long a = find_next(c - b);
		if (a == -1) {
			cout << -1 << endl;
			return 0;
		}
		go_back[a] = a - 1;
		ans.push_back(make_tuple(a, b, c));
	}
	REP(i, n) {
		cout << get<0>(ans[i]) << " " << get<1>(ans[i]) << " " << get<2>(ans[i]) << endl;
	}
	return 0;
}

Measured memory_bytes: 19184
package main

import (
	"fmt"
)

func main() {
	var d, g int
	fmt.Scanf("%d%d", &d, &g)

	p := make([]int, d)
	c := make([]int, d)
	for i, _ := range p {
		fmt.Scanf("%d%d", &p[i], &c[i])
	}

	ans := 1000000000
	for mask := 0; mask < (1 << uint(d)); mask++ {
		score := 0
		count := 0
		mid := 0

		for i := 0; i < d; i++ {
			if mask&(1<<uint(i)) > 0 {
				score += (i+1)*100*p[i] + c[i]
				count += p[i]
			} else {
				mid = i
			}
		}

		if g > score+(mid+1)*100*(p[mid]-1) {
			continue
		}

		for g > score {
			score += (mid + 1) * 100
			count++
		}

		if ans > count {
			ans = count
		}
	}

	fmt.Println(ans)
}


Measured memory_bytes: 512
#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; }



string s, t;
void solve(){
	cin >> s >> t;
	int n = s.size();
	
	int used[26] = {0};
	for(int i = 0; i < n; i++){
		int a = s[i]-'a', b = t[i]-'a';
		if(used[a] && used[a] != b){
			cout << "No" << endl;
			return;
		}
		used[a] = b;
	}
	fill(used,used+26,0);
	for(int i = 0; i < n; i++){
		int a = t[i]-'a', b = s[i]-'a';
		if(used[a] && used[a] != b){
			cout << "No" << endl;
			return;
		}
		used[a] = b;
	}
	cout << "Yes" << 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: 916
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int a[] = new int[N];
		for(int i = 0;i < N;i++) {
			a[i] = sc.nextInt();
		}
		int max = a[0],min = a[0];
		for(int i = 0;i < N;i++) {
			if(max < a[i]) {
				max = a[i];
			}
			if(min > a[i]) {
				min = a[i];
			}
		}
		System.out.println(max - min);
		sc.close();
	}
}

Measured memory_bytes: 23124
S = list(input())
s = len(S)

p = [S[i] for i in range(0,s) if i%2 == 0]
q = [S[i] for i in range(1,s) if i%2 == 1]

p_1 = p.count('1')
p_0 = len(p)-p_1

q_1 = q.count('1')
q_0 = len(q)-q_1

if p_1 > p_0:
    if q_0 > q_1:
        ans = p_0 + q_1

    else:
        if p_1-p_0 > q_1-q_0:
            ans = p_0+q_1
        else:
            ans = p_1+q_0

else:
    if q_1 > q_0:
        ans = p_1 + q_0

    else:
        if p_0-p_1 > q_0-q_1:
            ans = p_1+q_0
        else:
            ans = p_0+q_1

print(ans)


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

#define rep(...) repN((__VA_ARGS__,rep3,rep2,loop,~))(__VA_ARGS__)
#define loop(n) rep2(_loop_,n)
#define rep2(i,n) rep3(i,0,n)
#define rep3(i,begin,end) for(int i = (int)(begin), i##_end = (int)(end); i < i##_end; ++i)
#define repN(a) repX a
#define repX(a0,a1,a2,x,...) x

int main(void){
	string s;
	cin >> s;
	int len = s.size();
	rep(i, len){
		printf("%c", s[i]);
		i++;
	}
	printf("\n");
	return 0;
}


Measured memory_bytes: 512
//解説あり
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <string>

#define rep(i, a, b) for ( int i = (a); i < (b); i++ )
#define per(i, a, b) for ( int i = (b)-1; i >= (a); i--)
#define pb push_back
#define mp make_pair
#define bg begin()
#define en end()
#define all(v) (v).begin(), (v).end()


using namespace std;

typedef long long ll;

static const long long MOD = 1000000007;

int ans = 500;

int main(void) {
  string s;
  cin >> s;
  int n = (int)s.size();
  
  for (char c = 'a'; c<='z'; c++) {
    string t = s;
    int _n = n;
    while (_n>=1) {
      bool ok = true;
      for (int i=0; i<_n-1;i++){
        if (t[i]!=t[i+1]) ok = false;
      }
      if(ok) break;
      
      for (int i=0; i<_n-1;i++){
        if (t[i+1]==c) t[i] = t[i+1];
      }
      _n--;
 
    }
    ans = min(ans, n-_n);
  
  }
  cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long N = Long.parseLong(sc.next());
        long A = Long.parseLong(sc.next());
        long B = Long.parseLong(sc.next());
        long C = A + B;
        // Nを指定した場合のあまり
        long L = N % C;
        // 計算用
        long target = A * (N / C) + Math.min(L, A);
        // 出力
        System.out.println(target);
    }
}

Measured memory_bytes: 20948
#include <stdio.h>

int ctoi(const char c)
{
    switch (c)
    {
    case '0':
        return 0;
    case '1':
        return 1;
    case '2':
        return 2;
    case '3':
        return 3;
    case '4':
        return 4;
    case '5':
        return 5;
    case '6':
        return 6;
    case '7':
        return 7;
    case '8':
        return 8;
    case '9':
        return 9;
    default:
        return -1;
    }
}

int main()
{
    char S[5];

    scanf("%s", S);
    // printf("%c", S[0]);

    int mae, usi = 0;
    // 先頭の二文字
    mae = ctoi(S[0]) * 10 + ctoi(S[1]);
    // 後ろの二文字
    usi = ctoi(S[2]) * 10 + ctoi(S[3]);

    // printf("%d%d", mae, usi);

    // どこかが0だった場合
    if (mae == 0 || usi == 0) {
        if (mae == 0 && usi == 0) {
            printf("NA");
            return 0;
        }

        if (mae == 0 && usi <= 12) {
            printf("YYMM");
            return 0;
        }

        if (mae <= 12 && usi == 0) {
            printf("MMYY");
            return 0;
        }
    }

    // NA どれもない
    if ((mae == 0 && 12 < usi)||(12 < mae && usi == 0) || (12 < mae && 12 < usi))  {
        printf("NA");
        return 0;
    }
    // AMBIGUOUS(どちらもあり得る)
    else if(0 < mae && mae <= 12 && 0 < usi && usi <= 12) {
        printf("AMBIGUOUS");
        return 0;
    }
    // YYMM
    else if(12 <= mae) {
        printf("YYMM");
        return 0;
    } else {
        printf("MMYY");
        return 0;
    }
    return 0;
}

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

using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define REPO(i, n) for(int i = 1;i <= n;i++)
#define ll long long
#define INF 1999999999
#define MINF -1999999999
#define INF64 5999999999999999999
#define ALL(n) n.begin(),n.end()
#define ABS(a,b) max(a,b) - min(a,b)

vector<int> s;
int main() {
	int n;
	ll ans = 0;
	cin >> n;
	REP(i, 3 * n) {
		int a;
		cin >> a;
		s.push_back(a);
	}
	sort(ALL(s), greater<int>());
	REP(i, n) {
		ans += s[i * 2 + 1];
	}
	cout << ans << endl;
}

Measured memory_bytes: 2420
#include <stdio.h>
int main()
{
  int a, b,n=0;
  char op;
  while(n = 1){
    scanf("%d %c %d", &a, &op, &b);
    if(op == '+')
      printf("%d\n",a+b);
    if (op == '-')
      printf("%d\n",a-b);
    if (op == '*')
      printf("%d\n",a*b);
    if (op == '/')
      printf("%d\n",a/b);
    if (op == '?')
      break;
  }
  return 0;
}

Measured memory_bytes: 600
solist=[2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997]
sosu=[0 for i in range (len(solist))]
N=int(input())
for n in range(1,N+1):#n以下の数の約数の個数
    num=n
    for p in range(len(solist)):
        while num%solist[p]==0:
            sosu[p]+=1
            num=num//solist[p]
ans=1
for j in sosu:
    ans*=j+1
    ans=ans%(10**9+7)
print(ans)


Measured memory_bytes: 3188
import sys
sys.setrecursionlimit(700000)

def s_in():
    return input()

def n_in():
    return int(input())

def l_in():
    return list(map(int, input().split()))

n=n_in()

base=[]

for _ in range(n):
    s = s_in()

    c = s[0]
    cnt = 1
    ar = []
    for t in range(1,len(s)):
        if s[t-1] == s[t]:
            cnt += 1
        else:
            ar.append((c,cnt))
            c = s[t]
            cnt = 1
    ar.append((c,cnt))

    start = 0
    if ar[0][0] == ")":
        start = 1

    r = 0 # ( の数
    sgn = 1
    for c,cnt in ar[start:]:
        r += sgn*cnt
        sgn *= -1


    res = ()
    if ar[0][0] == ")":
        if r >= 0:
            res = (ar[0][1], r)
        else:
            res = (ar[0][1]-r,0)
    else:
        if r >= 0:
            res = (0, r)
        else:
            res = (-r, 0)

    base.append(res)

i_cnt = 0
j_cnt = 0

base2 = []

for i,j in base:
    i_cnt += i
    j_cnt += j

    if j > 0:
        base2.append((i,-(j-i),j))

if i_cnt != j_cnt:
    print("No")
    exit()

base2.sort()

current = 0


for i,p,j in sorted(filter(lambda x: x[1] <= 0 ,base2)):
    if current < i:
        print("No")
        exit()
    current -= i
    current += j

base3 = []
for i,p,j in filter(lambda x: x[1] > 0 ,base2):
    base3.append((p,i,j))

base3.sort()

for p,i,j in base3:
    if current < i:
        print("No")
        exit()
    current -= i
    current += j
    
print("Yes")
        


Measured memory_bytes: 244824
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
ll a,b;
string s;
int main(void){
    cin>>a>>s;
    b=(s[0]-'0')*100+(s[2]-'0')*10+(s[3]-'0');
    cout<<a*b/100<<endl;

}



Measured memory_bytes: 3576
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update

using namespace std;
using namespace __gnu_pbds;

//find_by_order gives kth-largest element
//order_of_key gives the number of items in the set that are strictly smaller!!

// OT.find_by_order(k-1)
// 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define db4(x, y, z, w) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << "," << #w << "=" << w << endl
#define ll long long
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define mp make_pair
#define X first
#define Y second
#define sz(x) (int)((x).size())
#define pii pair<int,int>
#define MOD (ll)(1e9 + 7)
#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
typedef vector<int> vi;
#define inf (ll)(1e18)
#define double long double
#define int long long

//////////////////////

int32_t main() {

    ios::sync_with_stdio(false);
    cin.tie(0); 
    cout.tie(0);
    cout.precision(12);
    cout << fixed;

    int n;
    cin >> n;

    vector<int> v(n);

    double tp = 0;
    rep(i,n) {
        cin >> v[i];
        // tp *= v[i];
        tp += 1.0 / v[i];
    }

    cout << 1.0 / tp << '\n';
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n;
int a[200010];
map<int,bool> mp;
set<int> s;
map<int,int> inv;
int main(){
	cin>>n;
	int mx=0;
	for(int i=0;i<n;i++){
		cin>>a[i];
		s.insert(a[i]);
		mx=max(mx,a[i]);
		inv[a[i]]++;
	}
	int k;
	for(set<int>::iterator it=s.begin();it!=s.end();it++){
		k=*it;
		if(inv[k]>1)mp[k]=1;
		for(int i=k+k;i<=mx;i+=k){
			mp[i]=1;
		}
	}
	int cnt=0;
	for(int i=0;i<n;i++){
		if(!mp[a[i]]){
			cnt++;
		}
	}
	cout<<cnt<<endl;
	return 0; 
}

Measured memory_bytes: 65276
#include <stdio.h>
#define SIZE 100010

int main(void) {
  int i;
  char str[SIZE];
  scanf("%s", str);
  for (i = 0; str[i] != '\0'; i++) {
    if (i % 2 == 0) {
      printf("%c", str[i]);
    }
  }

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
	int n,i;
	long long ab[100000][2],ans=0;
	scanf("%d",&n);
	for(i=0;i<n;i++)scanf("%lld%lld",&ab[i][0],&ab[i][1]);
	for(i=n-1;i>=0;i--)ans+=(ab[i][1]-(ab[i][0]+ans)%ab[i][1])%ab[i][1];
	printf("%lld\n",ans);
	return 0;
}

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

#define rep(i,n) for(int i = 0; i < n; i++)
#define REP(i,n) for(int i = 1; i < n; i++)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl "\n"
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using vs = vector<string>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll a, const ll b){return ((a)+(b)-1)/b;}


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

  int n, m;
  cin >> n >> m;
  vi l(m), r(m);
  rep(i,m) cin >> l[i] >> r[i];
  int L = -1, R = inf;
  rep(i,m) {
    L = max(L, l[i]);
    R = min(R, r[i]);
  }
  if(L > R) {
    cout << 0 << endl;
    return 0;
  }
  int ans = R-L + 1;
  cout << ans << endl;
}

Measured memory_bytes: 1024
n, m = map(int, input().split())
A = [[int(i) for i in input().split()] for i in range(n)]
B = []

def pm(x):
    if x % 2 == 0:
        return 1
    else:
        return -1
    
for i in range(8):
    temp = sorted([pm(i // 4) * x + pm(i // 2) * y + pm(i) * z for x, y, z in A], reverse=True)
    B.append(sum(temp[:m]))

print(max(B))

Measured memory_bytes: 3316
#include<stdio.h>
#define N 36

typedef struct{
  char form;
  int num;
}inf;

int main(){
  inf x[N],y[N],z[N],tmp;
  int i,j,n,flag=1,minj,a,b,f=1;
  char c;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf(" %c%d",&x[i].form,&x[i].num);
    z[i]=y[i]=x[i];

  }



  while(flag==1){
    flag=0;

    for(i=n-1;i>0;i--){
      if(x[i].num<x[i-1].num){
        tmp=x[i];
        x[i]=x[i-1];
        x[i-1]=tmp;
        flag=1;
      }
    }
  }

 for(i=0;i<n-1;i++) printf("%c%d ",x[i].form,x[i].num);
  printf("%c%d\n",x[i].form,x[i].num);

  for(i=0;i<n-1;i++){
    if(f==0) break;
    for(j=i+1;j<n-1;j++){
      if(f==0) break;
      for(a=0;a<n-1;a++){
        if(f==0) break;
        for(b=a+1;b<n-1;b++){
          if(z[i].num==z[j].num&&z[i].form==x[b].form&&z[j].form==x[a].form&&z[i].num==x[b].num&&z[j].num==x[a].num){
            printf("Not stable\n");
            f=0;
            break;
          }
        }
      }
    }
  }
  if(f==1) printf("Stable\n");

   for(i=0;i<n-1;i++){
    minj=i;
    for(j=i;j<n;j++){
      if(y[j].num<y[minj].num) minj=j;
      }
        tmp=y[i];
        y[i]=y[minj];
        y[minj]=tmp;
    }

 for(i=0;i<n-1;i++) printf("%c%d ",y[i].form,y[i].num);
  printf("%c%d\n",y[i].form,y[i].num);

  f=1;

  for(i=0;i<n-1;i++){
    if(f==0) break;
    for(j=i+1;j<n-1;j++){
      if(f==0) break;
      for(a=0;a<n-1;a++){
        if(f==0) break;
        for(b=a+1;b<n-1;b++){
          if(z[i].num==z[j].num&&z[i].form==y[b].form&&z[j].form==y[a].form&&z[i].num==y[b].num&&z[j].num==y[a].num){
            printf("Not stable\n"); 
                        f=0;
            break;
          }
        }
      }
    }
  }
  if(f==1) printf("Stable\n");

  return 0;
}


Measured memory_bytes: 2104
import sys
def S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())

import itertools
import math

n = I()
p = [LI() for i in range(n)]

nums = range(n)
result = 0
count = 0
for lis in itertools.permutations(nums,n):
    x = 0
    for i in range(n-1):
        x += math.sqrt((p[lis[i+1]][1]-p[lis[i]][1])**2 + (p[lis[i+1]][0]-p[lis[i]][0])**2)
    
    result += x
    count += 1

print(result / count)

Measured memory_bytes: 3064
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include<bits/stdc++.h>
using namespace std;
int main()
{
       char c;
        cin>>c;
        if(c>96&&c<123)
                cout<<"a"<<endl;
        else
                cout<<"A"<<endl;
        
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false), cin.tie(0)
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define ALL(x) (x).begin(), (x).end()
#define dump(x) cout << (x) << endl
#define LMAX 9223372036854775807LL
#define LMIN -9223372036854775807LL

using ll = long long;
using vll = vector<ll>;
using P = pair<ll, ll>;

template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val)
{
	fill((T *)array, (T *)(array + N), val);
}

const ll INF = 1e18;
const ll mod = 1e9 + 7;


int main(){
	IOS;
	ll a,b,k;
	ll na,nb;
	cin >> a >> b >> k;
	REP(i,k){
		if(i % 2 == 0){
			if(a % 2 == 0){
				a /= 2;
				b += a;
			}
			else {
				a--;
				a /= 2;
				b += a;
			}
		}
		else {
			if(b % 2 == 0){
				b /= 2;
				a += b;
			}
			else {
				b--;
				b /= 2;
				a += b;
			}
		}
	}
	cout << a << " " << b << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[] num = new int[6];
		Dice dice = new Dice(num);
		for (int i = 0; i < 6; i++) {
			num[i] = sc.nextInt();
		}
		dice.setFace(num);
		String str = sc.next();
		dice.order(str);
		System.out.println(dice.getFace());
		sc.close();
	}
}

class Dice {
	private int face[] = new int[6];

	Dice(int[] num) {
		for (int i = 0; i < 6; i++) {
			this.face[i] = num[i];
		}
	}

	public void order(String str) {
		char[] order = str.toCharArray();
		for (int i = 0; i < order.length; i++) {
			switch (order[i]) {
			case 'N':
				rollToNorth();
				break;
			case 'S':
				rollToSouth();
				break;
			case 'E':
				rollToEast();
				break;
			case 'W':
				rollToWest();
				break;
			}
		}
	}

	public void rollToNorth() {
		int tmp;
		tmp = face[0];
		face[0] = face[1];
		face[1] = face[5];
		face[5] = face[4];
		face[4] = tmp;
	}

	public void rollToSouth() {
		int tmp;
		tmp = face[0];
		face[0] = face[4];
		face[4] = face[5];
		face[5] = face[1];
		face[1] = tmp;
	}

	public void rollToEast() {
		int tmp;
		tmp = face[0];
		face[0] = face[3];
		face[3] = face[5];
		face[5] = face[2];
		face[2] = tmp;
	}

	public void rollToWest() {
		int tmp;
		tmp = face[0];
		face[0] = face[2];
		face[2] = face[5];
		face[5] = face[3];
		face[3] = tmp;
	}

	public int getFace() {
		return face[0];
	}

	public void setFace(int[] face) {
		this.face = face;
	}
}


Measured memory_bytes: 26220
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;

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

int N;
int A[100010];
int B[100010];
int C[100010];

int main() {
    cin >> N;
    rep(i, N) scanf("%d", &A[i]);
    rep(i, N) scanf("%d", &B[i]);
    rep(i, N) scanf("%d", &C[i]);

    sort(A, A+N);
    sort(C, C+N);

    long long cnt = 0;
    rep(j, N) {
        cnt += (lower_bound(A, A+N, B[j]) - A) * (N + C - upper_bound(C, C+N, B[j]));
    }

    cout << cnt << endl;
}



Measured memory_bytes: 1408
#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
#include<stdio.h>
#include<vector>
using namespace std;
#define rep(s,i,n) for(int i=s;i<n;i++)
#define c(n) cout<<n<<endl;
#define ic(n) int n;cin>>n;
#define sc(s) string s;cin>>s;
#define mod 1000000007
#define F first
#define s second
#define int long long		
int a[214514];
int b[214514];
signed main(){
	ic(n)
	rep(0,i,n)cin>>a[i];
	rep(1,i,n){
		if(a[i-1]-a[i]<=1){
			a[i-1]-=1;
			if(a[i-2]>a[i-1]){
				a[i-1]+=1;
			}	
		}	
		else{
			c("No")
			return 0;
		}
	}
	rep(1,i,n){
		if(a[i-1]>a[i]){
			c("No")
			return 0;
		}	
	}		
	c("Yes")
}		
			


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

#define loop(n, i) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define HERE cout << "HERE: " << __LINE__ << endl;
#define INSP(v) cout << v << " at " << __LINE__ << endl;

using namespace std;
typedef long long ll;


int main()
{
    int max = 1299710;
    vector<int> mat(max, 1);
    vector<int> primes;
    for (int i=2; i<sqrt(max); i++) {
        if (mat[i]) {
            for (int j=i*2; j < max; j+=i) mat[j] = 0;
        }
    }
    for (int i=2; i<max; i++) {
        if (mat[i]) primes.push_back(i);
    }

    int k;
    while (cin >> k, k) {
        loop(primes.size(),i) {
            if (k == primes[i]) {
                cout << 0 << endl;
                break;
            } else if (k < primes[i]) {
                cout << primes[i]-primes[i-1] << endl;
                break;
            }
        }
    }
}

Measured memory_bytes: 8380
#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--)
using namespace std;
using Graph = vector<vector<int>>;
#define MOD 1000000007
#define MOD2 998244353
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;

int num[4];

int main(){
    string s;
    cin >> s;
    rep(i, s.size()){
        if (s[i] == 'N') num[0] = 1;
        else if (s[i] == 'W') num[1] = 1;
        else if (s[i] == 'S') num[2] = 1;
        else if (s[i] == 'E') num[3] = 1;
    }

    if ((num[0] ^ num[2]) || (num[1] ^ num[3])) cout << "No" << endl;
    else cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <unordered_map>
#include <algorithm>
#include <iostream>
#include <string.h>
#include <cstdlib>
#include <vector>
#include <string>
#include <bitset>
#include <math.h>
#include <queue>
#include <stack>
#include <set>
#include <map>
 
typedef long long ll;
typedef long double ld;
 
const ll MOD = 1e9 + 7, INF = 1e18 + 1;
 
using namespace std;
int n, k;

vector <int> d[1000000];

vector <int> f (vector <int> a, vector <int> b)
{
	vector<int> v (n);

	for (int i = 0; i < n; i++)
		v[i] = a[b[i] - 1];

	return v;
}

vector <int> inv (vector <int> a)
{
	vector <int> s (n);

	for (int i = 0; i < n; i++)
		s[a[i] - 1] = i + 1;

	return s;
}

vector <int> qpow (vector <int> a, int b)
{
	vector <int> s;

	for (int i = 0; i < n; i++)
		s.push_back (i + 1);

	while (b)
	{
		if (b & 1) s = f (s, a);
		a = f (a, a);
		b /= 2;
	}

	return s;
}

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

	vector <int> p (n), q (n);

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

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

	auto A = qpow (f (q, f (inv (p), f (inv (q), p))), (k - 1) / 6);

	if(k % 6 == 4) A = f (A, q);
	if(k % 6 == 5 || k % 6 == 0) A = f (A, f (q, inv (p)));

	vector <int> B[7];

	B[1] = p;
	B[2] = q;
	B[3] = f (q, inv (p));
	B[4] = inv (p);
	B[5] = inv (q);
	B[6] = f (inv (q), p);

	auto ans = f (A, f (B[(k - 1) % 6 + 1], inv (A)));

	for (int i = 0; i < n; i++)
		printf("%d ",ans[i]);
}


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

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		new Main().run();
	}
	void tr(Object... os) {
		System.err.println(deepToString(os));
	}

	Scanner sc = new Scanner(System.in);
	public void run() {
		makePrimes();
		for (;sc.hasNext();) {
			int n = sc.nextInt();
			if (n == 0) break;
			for (int i = n; i > 2; i--) {
				if (isPrime[i] && isPrime[i-2]) {
					System.out.println((i-2) + " " + i);
					break;
				}
			}
		}
	}
	static final int MAX_N = 1024 * 1024;
	boolean[] isPrime = new boolean[MAX_N];
	int[] primes;
	void makePrimes(){
		if (primes != null) return;
		for (int i = 0; i < isPrime.length; i++) isPrime[i] = true;
		isPrime[0] = isPrime[1] = false;
		for (int i = 2; i * i < isPrime.length; i++)
			if (isPrime[i])
				for(int j = i * i; j < isPrime.length; j += i)
					isPrime[j] = false;
		int p = 0;
		for (int i = 2; i < isPrime.length; i++) p += isPrime[i] ? 1 : 0;
		primes = new int[p];
		p = 0;
		for (int i = 2; i < isPrime.length; i++) if (isPrime[i]) primes[p++] = i;
	}
}

Measured memory_bytes: 35492
#include <cstdio>
#include <cstring>
#include <algorithm>
#define ll long long

int n, m;
struct Data{
	int a, b;
	bool operator<(const Data &c)const{
		return a < c.a;
	}
}d[111111];

int main(){
	scanf("%d %d", &n, &m);
	for(int i = 1; i <= n; i++) scanf("%d %d", &d[i].a, &d[i].b);
	std::sort(d + 1, d + n + 1);
	ll ans = 0;
	for(int i = 1; i <= n; i++){
		if(!m) break;
		if(d[i].b > m) ans += 1ll * m * d[i].a, m = 0;
		else ans += 1ll * d[i].b * d[i].a, m -= d[i].b;
	}
	return !printf("%lld\n", ans);
}

Measured memory_bytes: 896
n = int(input())
leafNums = list(map(int, input().split()))

ans = 0

# d=0
ans += 1
currentRootNodeNum = 1
if (leafNums[0] >= 1 and n >=1) or (leafNums[0] > 1 and n == 0):
    print(-1)
    exit()

# cond2maxの計算でTLEっぽいので、事前に累積和を求めておく
leafAccumlateFromEnd = [0] * (n+1)
leafAccumlateFromEnd[n] = leafNums[n]
for i in range(n-1,-1,-1):
    leafAccumlateFromEnd[i] = leafAccumlateFromEnd[i+1] + leafNums[i]

# d=1~n
for i in range(1, n+1):
    # cond2max = sum(leafNums[i:])
    cond2max = leafAccumlateFromEnd[i]
    cond1max = currentRootNodeNum*2
    currentMax = min(cond1max, cond2max)
    ans += currentMax
    currentRootNodeNum = currentMax - leafNums[i]
    if currentRootNodeNum < 0:
        print(-1)
        exit()

print(ans)

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

typedef long long ll;
typedef long double ld;


char rev(char x) {
    if(x == 'S') return 'W';
    else return 'S';
}

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

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

    A--;
    B--;

    if(A == 0) A += 13;
    if(B == 0) B += 13;

    if(A < B) {
        cout << "Bob" << endl;
    } else if(A > B) {
        cout << "Alice" << endl;
    } else {
        cout << "Draw" << endl;
    }
}

Measured memory_bytes: 256
<?php

list($h, $n) = explode(' ', trim(fgets(STDIN)));
$a = explode(' ', trim(fgets(STDIN)));

rsort($a, SORT_NUMERIC);

$current = $h;

foreach ($a as $value) {
    $current -= (int) $value;
    if ($current <= 0) {
        echo 'Yes' . PHP_EOL;
        exit;
    }
}
echo 'No' . PHP_EOL;
exit;


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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 (a>b) { a=b; return 1; } return 0; }

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    char c; cin>>c;
    if ('a'<=c && c<='z'){
        cout<<"a\n";
    }else{
        cout<<"A\n";
    }
    return 0;
}


Measured memory_bytes: 3632
#!/usr/bin/env python3
import sys
import math

def solve(X: int):
    N = 100
    i = 0
    while N < X:
        N = math.floor(N*1.01)
        i += 1
    print(i)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    X = int(next(tokens))  # type: int
    solve(X)

if __name__ == '__main__':
    main()

Measured memory_bytes: 63340
import java.io.*;
import java.math.*;
import java.util.*;
public class Main { 
 
	public static void main(String[] args) { 
		FastScanner I = new FastScanner(); //Input
		OutPut O = new OutPut(); //Output
		int AC = 0;
		int WA = 0;
		int TLE = 0;
		int RE = 0;
		int N = I.nextInt();
		for (int i = 0; i < N; i++) {
			String S = I.next();
			if (S.equals("AC")) AC++;
			else if (S.equals("WA")) WA++;
			else if (S.equals("TLE")) TLE++;
			else if (S.equals("RE")) RE++;
		}
		O.pln("AC x "+AC);
		O.pln("WA x "+WA);
		O.pln("TLE x "+TLE);
		O.pln("RE x "+RE);
	}
	public static long ceil(long num, long den) {long ans = num/den; if (num%den!=0) 
	ans++; return ans;}
	public static long GCD(long a, long b) {
		if (a==0||b==0) return Math.max(a,b);
		return GCD(Math.min(a, b),Math.max(a, b)%Math.min(a, b));
	}
	public static long FastExp(long base, long exp, long mod) {
		long ans=1;
		while (exp>0) {
			if (exp%2==1) ans*=base;
			exp/=2;
			base*=base;
			base%=mod;
			ans%=mod;
		}
		return ans;
	}
	public static long ModInv(long num,long mod) {return FastExp(num,mod-2,mod);}
	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		int nextInt() {return Integer.parseInt(next());}
		long nextLong() {return Long.parseLong(next());};
	}
	static class OutPut{
		PrintWriter w = new PrintWriter(System.out);
		void pln(int x) {w.println(x);w.flush();}
		void pln(long x) {w.println(x);w.flush();}
		void pln(String x) {w.println(x);w.flush();}
		void pln(char x) {w.println(x);w.flush();}
		void pln(StringBuilder x) {w.println(x);w.flush();}
		void p(int x) {w.print(x);w.flush();}
		void p(long x) {w.print(x);w.flush();}
		void p(String x) {w.print(x);w.flush();}
		void p(char x) {w.print(x);w.flush();}
		void p(StringBuilder x) {w.print(x);w.flush();}
	}
}

Measured memory_bytes: 38940
using System;

namespace abca148
{
    class Program
    {
        static void Main(string[] args)
        {
       
            int a = int.Parse(Console.ReadLine());
            int b = int.Parse(Console.ReadLine());
            if (a == 1 && b == 2)
                Console.WriteLine("3");
            if (a == 1 && b == 3)
                Console.WriteLine("2");
            if (a == 2 && b == 1)
                Console.WriteLine("3");
            if (a == 2 && b == 3)
                Console.WriteLine("1");
            if (a == 3 && b == 1)
                Console.WriteLine("2");
            if (a == 3 && b == 2)
                Console.WriteLine("1");
           


            Console.ReadKey();
 


        }
    }
}


Measured memory_bytes: 13140
#include<stdio.h>
#include<stdlib.h>

void swap(int array[],int lo,int hi){
  int temp=array[lo];
  array[lo]=array[hi];
  array[hi]=temp;
}

void shuffle(int array[],int size){
  for(int i=0;i<size;i++){
    int j=rand()%size;
    swap(array,i,j);
  }
}

int partition(int array[],int low,int hig){
  int i=low;
  int j=hig+1;
  while(1){
    while(array[++i]<array[low]){
      if(i == hig) break;}
    while(array[low]<array[--j]){
      if(j==low) break;}
    if(i>=j) break;
    swap(array,i,j);
  }
  swap(array,low,j);
  return j;
}

void sort(int array[],int lo,int hi){
  if(hi<=lo) return;
  int j=partition(array,lo,hi);
  sort(array,lo,j-1);
  sort(array,j+1,hi);
}

void quicksort(int array[],int size){
  shuffle(array,size);
  sort(array,0,size-1);
}

int main(){
  int n,k;
  scanf("%d%d",&n,&k);
  int h[n];
  long int sum=0;
  for(int i=0;i<n;i++){
    scanf("%d",&h[i]);}
  quicksort(h,n);
  for(int i=0;i<n-k;i++){
    sum+=h[i];}
  
  printf("%ld\n",sum);


  return 0;
}


Measured memory_bytes: 896
N = int(input())
H = list(map(int, input().split()))

res = True
if N >= 2:
    for i in range(N - 1):
        if H[i] - H[i + 1] >= 2:
            res = False

y_card = 0
if N >= 3 and res == True:
    for i in range(N - 1):
        if H[i] - H[i + 1] == 1:
            y_card += 1
            if y_card == 2:
                res = False
                break
        elif H[i] == H[i + 1]:
            pass
        elif H[i + 1] - H[i] >= 1:
            y_card -= H[i + 1] - H[i]
            if y_card < 0:
                y_card = 0


if res == True:
    print('Yes')
else:
    print('No')



Measured memory_bytes: 14704
S = int(input())
if 1 <= S / 100 and S / 100 <= 12:
	if 1 <= S % 100 and S % 100 <= 12: print("AMBIGUOUS")
	else: print("MMYY")
else:
	if 1 <= S % 100 and S % 100 <= 12: print("YYMM")
	else: print("NA")

Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repI(i, d, n) for (int i = (d); i < (n); ++i)
#define reps1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

using ll = long long;
using P = pair<int, int>;
using Pl = pair<ll, ll>;
using M = map<int, int>;
using Ml = map<ll, ll>;
ll const INF = 1ll<<61;
double pi = 3.141592653589793238;

int main() {
  ll a, b;
  cin >> a >> b;

  cout << max(a+b, max(a-b, a*b)) << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (lli i = 0; i < (n); i++)
#define rrep(i, n) for (lli i = (n)-1; i >= 0; i--)
using namespace std;
using lli = long long int;
int main() {
    int x, a;cin >> x >> a;
    if(x < a)cout << 0 << endl;
    else cout << 10 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef vector<int> vec1;
typedef vector<string> vec2;
typedef vector<double> vec3;

int main() {
  
  int a, b, c;
  cin >> a >> b >> c;
  int x, y;
  cin >> x >> y;
  ll ans = 0;
  int n = x + y;
  for(int i = 0; i < n; i++) {
    if(x == 0 && y == 0) break;
    if(x > 0 && y > 0) {
      int d = min(a+b,c*2);
      ans = ans + d;
      x--;
      y--;
      continue;
    } 
    if(x == 0 && y > 0) {
      int d = min(b,c*2);
      ans = ans + d;
      y--;
    } else {
      int d = min(a,c*2);
      ans = ans + d;
      x--;
    }
  }
  cout << ans << endl;
}


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

int main(){
  int N,L;
  cin >> N >> L;
  vector<string> S(N);
  for(int i = 0;i < N;i++){
	cin >> S.at(i);
  }

  for(int i = 0;i < N;i++){
    for(int j = i + 1;j < N;j++){
      if((S.at(j) + S.at(i)) < (S.at(i) + S.at(j))){
        string tmp = S.at(i);
        S.at(i) = S.at(j);
        S.at(j) = tmp;
      }
    }
  }
  
  for(int i = 0;i < N;i++){
    cout << S.at(i);
    if(i == N - 1){
      cout << endl;
      return 0;
    }
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fr first
#define se second
#define r_0 return 0
#define ll long long
#define pb push_back
using namespace std;

const long long INF = 1e7;
const long long N = 1e5+ 7;
const long long mod = 1e9 + 7;
const long double eps = 1E-7;

long double a, n, b, c = 1, d , cnt , m , ans;
string s , s1 , s2;
set<char>st;
ll used[N];
vector<int>v;
int main()
{
   /// freopen("symposium.in" ,"r" ,stdin);
///freopen("symposium.out" , "w" ,  stdout);
    ios_base::sync_with_stdio(0);
cin >> s;
for( int i = 0;i < s.size();i ++ )
    cout << 'x' ;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline

n,m = map(int, input().split())
t = sorted([tuple(map(int, input().split())) for i in range(m)])
d=[0,0]+[1e18]*n
for l,r,c in t:
  for i in range(r,l,-1):
    if d[l]+c<d[i]:
      d[i]=d[l]+c
    else:
      break
print(d[-2]%10**18or-1)

Measured memory_bytes: 87900
MOD = 10 ** 9 + 7
s = input()

def ad(x, y):
	return int((x + y) % MOD)


a = s[:2].count("A")
b = s[:2].count("B")
c = s[:2].count("C")
q = s[:2].count("?")


qq = 0
aq = 0
qb = 0
ab = 0

if s[:2] == "??":
	qq += 1
elif s[:2] == "A?":
	aq += 1
elif s[:2] == "?B":
	qb += 1
elif s[:2] == "AB":
	ab += 1

if s[2] == "A":
	a += 1
elif s[2] == "B":
	qb += q
	ab += a
	b += 1
elif s[2] == "C":
	c += 1
elif s[2] == "?":
	qq += q
	aq += a
	q += 1

three = 0
two = 0
one = 0
zero = 0

if s[:3] == "???":
	three += 1
elif s[:3] == "A??" or s[:3] == "?B?" or s[:3] == "??C":
	two += 1
elif s[:3] == "AB?" or s[:3] == "A?C" or s[:3] == "?BC":
	one += 1
elif s[:3] == "ABC":
	zero += 1

#print(zero)


for i in range(3, len(s)):
	if s[i] == "A":
		a += 1
	elif s[i] == "B":
		qb = ad(qb, q)
		ab = ad(ab, a)
		b += 1
	elif s[i] == "C":
		two = ad(two, qq)
		one = ad(one, qb)
		one = ad(one, aq)
		zero = ad(zero, ab)
		c += 1
	elif s[i] == "?":
		three = ad(three, qq)
		two = ad(two, aq)
		two = ad(two, qb)
		one = ad(one, ab)
		qq = ad(qq, q)
		aq = ad(aq, a)
		q += 1

ans = 0
ans = ad(ans, (3 ** (q - 3)) * three)
ans = ad(ans, (3 ** (q - 2)) * two)
ans = ad(ans, (3 ** (q - 1)) * one)
ans = ad(ans, (3 ** q) * zero)

print(ans)



Measured memory_bytes: 3444
n = int(input())
H = list(map(int,input().split()))

ans = "Yes"
c=0
for i in range(n-1):
    if H[i]-1>H[i+1] :
        ans = "No"
        break
    elif H[i]>H[i+1] :
        c+=1
        if c>=2 :
            ans = "No"
            break
    elif H[i]<H[i+1] :
        c=0
print(ans)

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

using namespace std;
using ll = long long;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define INF 9223372036854775807
#define all(x) (x).begin(), (x).end()

ll ts = 1000000007;

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

  ll r, g;
  cin >> r >> g;

  cout << 2 * g - r << "\n";
}

Measured memory_bytes: 256
use std::io;
use std::str::FromStr;
use std::collections::HashSet;

fn input_set() -> HashSet<i64> {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    line.split_whitespace().map(|s| s.parse().unwrap()).collect()
}

fn input_tuple() -> (i64, i64) {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    let vec: Vec<i64> = line.split_whitespace().map(|s| s.parse().unwrap()).collect();
    (vec[0], vec[1])
}

fn main() {
    let (x, n) = input_tuple();
    let p_set = input_set();
    for i in 0..1000 {
        if !p_set.contains(&(x-i)) {
            println!("{}", (x-i));
            return;
        } 
        if !p_set.contains(&(x+i)) {
            println!("{}", (x+i));
            return;
        }
    }
}


Measured memory_bytes: 2156