akhauriyash/Code-Regression huggingface dataset:
a = gets.to_i
b = gets.to_i
c = gets.to_i
d = gets.to_i

def hantei(i,j)
    case i <=> j
    when 1 then
        return j
    when 0 then
        return i
    when -1 then
        return i
    end
end

train = hantei(a,b)
bus = hantei(c,d)
puts train + bus

Measured memory_bytes: 1788
#include <iostream>
#include <math.h>
using namespace std;

int main()
{
	int N, M;
	int T[100+5];
	int aux[100 + 5];
	int sol[105];
	int P[100 + 5];
	int X[100 + 5];
	cin >> N;
	for (int i = 0; i < N; i++)
	{
		cin >> T[i];
	}
	cin >> M;
	for (int i = 0; i < M; i++)
	{
		cin >> P[i] >> X[i];
	}
	int sum = 0;
	for (int i = 0; i < M; i++)
	{
		for (int i = 0; i < N; i++)
		{
			aux[i] = T[i];
		}
		aux[P[i] - 1] = X[i];
		for (int i = 0; i < N; i++)
		{
			sum = sum + aux[i];
		}
		sol[i] = sum;
		sum = 0;
	}
	for (int i = 0; i < M; i++)
	{
		cout << sol[i] << endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int N = sc.nextInt();
		long a[] = new long[N] ;
		long absmin = Long.MAX_VALUE ;
		int minusCount = 0 ;
		for( int i = 0 ; i < N ; i ++) {
			a[i] = sc.nextInt();

			if(a[i] < 0) {
				minusCount ++ ;
			}
			long abs = a[i] ;
			if(abs < 0) {
				abs = (-1)*abs;
			}
			a[i] = abs ;
			if(abs < absmin) {
				absmin = abs ;
			}
		}


		long sum = 0 ;
		for( int i = 0 ; i < N ; i ++) {
			sum += a[i] ;
		}

		if(!(minusCount%2 == 0)) {
			sum = sum - (2*absmin) ;
		}
		// 出力
		System.out.println(sum);

	}

}


Measured memory_bytes: 62888
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define For(i, a, b) for (i = a; i <= b; i++)
#define Rof(i, a, b) for (i = a; i >= b; i--)

inline int read()
{
	int res = 0; bool bo = 0; char c;
	while (((c = getchar()) < '0' || c > '9') && c != '-');
	if (c == '-') bo = 1; else res = c - 48;
	while ((c = getchar()) >= '0' && c <= '9')
		res = (res << 3) + (res << 1) + (c - 48);
	return bo ? ~res + 1 : res;
}

template <class T>
inline void Swap(T &a, T &b) {a ^= b; b ^= a; a ^= b;}

typedef long long ll;

const int N = 1e5 + 5;

int n, x[N], m, a[N], tr[N], st[N], tmp[N];
ll k, ans;

int main()
{
	int i;
	n = read();
	For (i, 1, n) x[i] = read();
	Rof (i, n, 2) x[i] -= x[i - 1];
	m = read(); std::cin >> k;
	For (i, 1, m) a[i] = read();
	For (i, 1, n) tr[i] = st[i] = i;
	For (i, 1, m) Swap(tr[a[i]], tr[a[i] + 1]);
	while (k)
	{
		if (k & 1) For (i, 1, n) st[i] = tr[st[i]];
		For (i, 1, n) tmp[i] = tr[tr[i]];
		For (i, 1, n) tr[i] = tmp[i];
		k >>= 1;
	}
	For (i, 1, n)
	{
		ans += x[st[i]];
		printf("%lld.000000000\n", ans);
	}
	return 0;
}

Measured memory_bytes: 4224
import math


def inputIntList():
    return [int(s) for s in input().split()]


def inputInt():
    return int(input())


def main():
    ans = [1, 2, 3]
    ans.remove(inputInt())
    ans.remove(inputInt())

    return ans[0]


if __name__ == "__main__":
    print(main())


Measured memory_bytes: 2940
#include<bits/stdc++.h>                                                                        
using namespace std;
int main()
{
  int N;
  cin >> N;
  string S;
  cin >> S;
  int x=0;
  int max=-101;
  for(int i=0; i<N; i++){
    if(max<x)
      max=x;
    if(S.at(i)=='I')
      x++;
    else if(S.at(i)=='D')
      x--;
    if(max<x)
      max=x;
  }
  
  cout << max << endl;
}


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

int main()
{
  	char s[105],t[105],u[205];
	int n;
    scanf("%d",&n);
    scanf("%s%s",s,t);
  	for(int i=0;i<n;i++) u[2*i]=s[i];
   	for(int i=0;i<n;i++) u[2*i+1]=t[i];
  	u[2*n]='\0';
  	printf("%s\n",u);
  	return 0;
}



Measured memory_bytes: 128
MOD = 10**9+7


def main():
    N, M = map(int, input().split())
    if abs(N-M) >= 2:
        print(0)
        return
    F = [1] * (max(N, M) + 1)
    for i in range(2, max(N, M) + 1):
        F[i] = F[i-1] * i % MOD
    if N == M:
        print((F[N] * F[M] * 2) % MOD)
    else:
        print((F[N] * F[M]) % MOD)


if __name__ == "__main__":
    main()


Measured memory_bytes: 39280
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <vector>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <map>
#include <set>
#include <queue>
using namespace std;
#define lowbit(x) (x&(-x))
#define max(x,y) (x>y?x:y)
#define min(x,y) (x<y?x:y)
#define MAX 100000000000000000
#define MOD 1000000007
#define pi acos(-1.0)
#define ei exp(1)
#define PI 3.141592653589793238462
#define INF 0x3f3f3f3f3f
#define mem(a) (memset(a,0,sizeof(a)))
typedef long long ll;
ll gcd(ll a,ll b){
    return b?gcd(b,a%b):a;
}
bool cmp(int x,int y)
{
    return x>y;
}
const int N=55;
const int mod=1e9+7;

int main()
{
    int a,b,h;
    while(cin>>a>>b>>h){
        int s=(a+b)*h/2;
        cout<<s<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
import sys 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
mod = 10 ** 9 +7
N, K = map(int, readline().split())
s = [0] * (N+1)
g = [0] * (N+1)
g[0] = N % mod
for i in range(1,N+1):
    s[i] += (s[i-1] + i ) % mod
    g[i] += (g[i-1] + N - i) % mod
ans = (sum(g[K-1:]) % mod  - sum(s[K-1:]) % mod + N-K+2) % mod
print(ans)

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

const int maxN = 1e5 + 10;
vector<int>a(maxN, 0);


int main(){
    //ios_base::sync_with_stdio(false); cin.tie(NULL);
    int n;
    cin >> n;
    int k = n%1000;
    if(k > 0){
        cout << 1000 - k << endl;
    }
    else cout << k << endl;
    return 0;
}

Measured memory_bytes: 3724
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <stack>

using std::vector;
using std::printf;
using std::cout;
using std::endl;
using std::string;
using std::cin;
using std::pair;
using std::sort;

#define i64t long long int
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))

template<typename T>
void dump(vector<T> vec) {
    for (auto x : vec) {
        std::cout << x << " ";
    }
    std::cout << std::endl;
}

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

const i64t MOD = 1000000007;

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

    for (int i = 0; i < S.length(); ++i) {
        if ((i % 2 == 0) && (S[i] == 'L')) {
            printf("No");
            return 0;
        }
        if ((i % 2 == 1) && (S[i] == 'R')) {
            printf("No");
            return 0;
        }
    }
    printf("Yes");
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner

object Main {
  def resolve(N: Int, x: Int, a: Array[Int]): Long = {
    // 左から２個ずつペア(i, i + 1) i+1を先に減らしていく貪欲法でいける
    var res: Long = 0
    for {
      i <- 0 until N - 1
    } {
      val r1 = a(i + 0) + a(i + 1) - x
      val sub1 = if (r1 > 0) math.min(r1, a(i + 1)) else 0
      val r0 = r1 - sub1
      val sub0 = if (r0 > 0) math.min(r0, a(i + 0)) else 0

      a(i + 1) -= sub1
      a(i + 0) -= sub0

      res += sub1 + sub0
    }
    res
  }

  def main(args: Array[String]): Unit = {
    val sc = new Scanner(System.in)
    val N = sc.nextInt()
    val x = sc.nextInt()
    val a = Array.ofDim[Int](N)
    a.indices foreach (i => a(i) = sc.nextInt())
    println(resolve(N, x, a))
  }
}


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

using namespace std;

void Main() {
    int n;
    cin >> n;
    vector<vector<int>> chars(n, vector<int>(26, 0));
    for (int i = 0; i < n; ++i) {
        string s;
        cin >> s;
        for (int j = 0; j < s.size(); ++j) {
            chars[i][s[j] - 'a'] += 1;
        }
    }
    string ans = "";
    for (int j = 0; j < 26; ++j) {
        int minOfThis = 1000000000;
        for (int i = 0; i < n; ++i) {
            minOfThis = min(minOfThis, chars[i][j]);
        }
        for (int k = 0; k < minOfThis; ++k) {
            ans += ('a' + j);
        }
    }
    cout << ans << endl;
}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 3616
// #pragma GCC optimize(3, "Ofast", "inline")
#include <bits/stdc++.h>
#define String std::string
#define fi first
#define se second
#define mp std::make_pair
#define Pair std::pair<int, int>
#define Map std::map< int, int >
#define Vector std::vector<int>
 
using std::cin;
using std::cout;
using std::endl;
 
typedef long long ll;
typedef unsigned long long ull;
 
const int N = 100000 + 5;
const int M = 3000 + 5;
const int K = 1e7 + 5;
const int MOD = 1e9 + 7;
const int inv2 = 500000004;
const int dx[] = { 0, 1, -1, 0, 1, -1, 1, -1 };
const int dy[] = { 1, 0, 0, -1, 1, -1, -1, 1 };
const double PI = acos(-1);
 
template<class T>
inline T readT() {
    T res = 0, f = 1;
    char ch = getchar();
    for (; !isdigit(ch); ch = getchar()) if (ch == '-') f = -1;
    for (; isdigit(ch); ch = getchar()) res = (res << 1) + (res << 3) + ch - '0';
    return res * f;
}
#define read readT<int>

int n, m;
int row[1005], col[1005];
char map[1005][1005];

int main() {
    scanf("%d %d", &n, &m);
    for (int i = 1; i <= n; i++) {
        scanf("%s", map[i] + 1);
    }
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            if (map[i][j] == '.') {
                row[i]++;
                col[j]++;
            }
        }
    }

    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            if (row[i] == m || col[j] == n) {
                continue;
            }
            putchar(map[i][j]);
        }
        if (row[i] != m) puts("");
    }
    return 0;
}

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

int main() {
  int n;
  std::cin >> n;
  std::set<std::string> w;

  char c;
  std::string s;
  std::cin >> s;
  c = s.back();
  w.insert(std::move(s));
  for (int i = 1; i < n; i++) {
    std::string s;
    std::cin >> s;

    if (c != s.front()) {
      std::cout << "No" << std::endl;
      return 0;
    }
    c = s.back();

    if (w.find(s) != w.cend()) {
      std::cout << "No" << std::endl;
      return 0;
    }
    w.insert(std::move(s));
  }
  std::cout << "Yes" << std::endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int g = 0;
        for (int b = 1; b <= 33; b++) {
            for (int p = 2; p <= 10; p++) {
                if ((int)Math.pow(b,p) > x) {
                    break;
                } else if ((int)Math.pow(b,p) > g){
                    g = (int)Math.pow(b,p);
                }
            }
        }
        System.out.print(g);
        sc.close();
    }
}

Measured memory_bytes: 21716
#include<bits/stdc++.h>
                    
					using namespace std;
                    #define FAST ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
                    #define pb push_back
                    #define ff first
                    #define ss second
                    #define sz size()
                    #define mp make_pair
                    #define int long long int
                    #define double long double
                    #define bp __builtin_popcountll
                    #define FOR(i,a,b) for(int i=a;i<b;i++)
                    #define ROR(i,a,b) for(int i=a;i>=b;i--)
                    const int M=1e9+7;
                    const int N=1e6+5;
                    const int inf=1e18;
                    string s;
                    int n;
                    int dp[N][2];
                    int solve(int idx,int vaddi)
                    {
                    	if(idx==0)
                    	{
                    		if(vaddi==1)
                    		return 1;
                    		return 0;
                    	}
                    	int &ans=dp[idx][vaddi];
                    	if(ans!=-1)
                    	return ans;
                    	ans=0;
                    	char pp;
                    	if(vaddi==1)
                    	{
                    		pp=s[idx]+1;
                    		if(s[idx]+1>'9')
                    		ans=solve(idx-1,1);
                    		else
                    		ans=min((pp-'0')+solve(idx-1,0),(10 +'0'-pp)+solve(idx-1,1));
                    		
                    	}
						else
						ans=min((s[idx]-'0')+solve(idx-1,0),(10 +'0'-s[idx])+solve(idx-1,1));
                    	return ans;
                    }
                    int32_t main()
                    {
                		FAST
                		cin>>s;
                		s='0'+s;
                		n=s.size();
                		// cout<<s;
                		memset(dp,-1,sizeof(dp));
                		cout<<(solve(n,0)+48);
                    }

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

using namespace std;

#define F first
#define S second

using ll = long long;

const int N = 1e5 + 5;
pair<ll, ll> arr[N];
int main() {
    int a, b, k;
    cin >> a >> b >> k;
    for (int i = min(a, b); i >= 1; i--) {
        if (a % i == 0 && b % i == 0) {
            k--;
        }
        if (k == 0) {
            cout << i << '\n';
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
const double PI = acos(-1);
#define rep(i, n) for (int i = 0; i < (int)(n); i++ )
using namespace std;
int main(){
    long long k, s;
    cin >> k >> s;
    int ans = 0;
    rep(x,k+1){
        rep(y,k+1){
            int z = s - x - y;
            if( 0 <= z && z <= k ) ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int M, K; cin >> M >> K;
  if(M == 0){
    if(K == 0){
      cout << 0 << " " << 0 << endl;
      return 0;
    }else{
      cout << -1 << endl;
      return 0;
    }
  }else if(M == 1){
    if(K == 0){
      cout << 0 << " " << 0 << " " << 1 << " " << 1 << endl;
      return 0;
    }else{
      cout << -1 << endl;
      return 0;
    }    
  }else if(K >= pow(2, M)){
    cout << -1 << endl;
    return 0;
  }else{
    REP(i, pow(2, M)){
      if(i != K){
        cout << i << " ";
      }
    }
    cout << K << " ";
    for(int i = pow(2, M)-1; i >= 0; i--){
      if(i != K){
        cout << i << " ";
      }
    }
    cout << K << endl;
  }
}

Measured memory_bytes: 1792
n = int(input())

strs = {}

for i in range(n):
  tmp = sorted(input())
  tmp = ''.join(tmp)
  if tmp in strs:
    strs[tmp] += 1
  else:
    strs[tmp] = 1
    
count = 0
for v in strs.values():
  if v > 1 :
    count += v * (v-1) // 2

print(count)
  

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

using namespace std;

using ll = long long;
using ld = long double;

using pll = pair<ll, ll>;
using vll = vector<ll>;
using vpll = vector<pll>;
using gr = vector<vll>;
using wgr = vector<vpll>;

#define pb push_back
#define FOR(i, m, n) for (ll i(m); i < n; i++)
#define REP(i, n) FOR(i, 0, n)
#define F(n) REP(i, n)
#define FF(n) REP(j, n)
struct d_ {
    template<typename T> d_ & operator ,(const T & x) { cerr << ' ' <<  x; return *this;}
    template<typename T> d_ & operator ,(const vector<T> & x) { for(auto x: x) cerr << ' ' <<  x; return *this;}
} d_t;
#define dbg(args ...) { d_t,"|",__LINE__,"|",":",args,"\n"; }
#define EPS (1e-10)
#define INF (1LL<<61)
#define CL(A,I) (memset(A,I,sizeof(A)))
#define all(x) begin(x),end(x)
#define IN(n) ll n;cin >> n;
#define x first
#define y second

#define MX 2007

ll n,k,q; 
ll a[MX];

ll solve(ll x) {
    vll y;
    for(ll i=0; i<n;) {
        if(a[i]>=x) {
            vll v;
            while(i < n && a[i]>=x) {
                v.pb(a[i]);
                i++;
            }
            if(v.size() < k) continue;
            sort(all(v));
            FF(v.size()-k+1) y.pb(v[j]);
        } else i++;
    }
    sort(all(y));
    if(y.size()<q) return INF;
    return y[q-1]-x;
}

int main(void) {
    ios_base::sync_with_stdio(false);
    cin >> n >> k >> q;
    F(n) cin >> a[i];
    ll ret = INF;
    F(n) ret=min(ret,solve(a[i]));
    cout << ret << endl;
    return 0;
}


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

using namespace std;

int main(){

    string o;
    string e;
    cin>>o>>e;
    int i=0;
    for(i=0;i!=e.size();i++){
        cout<<o[i]<<e[i];
    }
    if(o.size()-e.size()!=0){
        cout<<o[i];
    }
    cout<<endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<complex>
using namespace std;
int main(){
	string s;cin>>s;
	char z='a';
	for(int i=0;i<26;i++){
		bool ok=false;
		for(int j=0;j<s.size();j++)if(s[j]==z){ok=true;}
		if(!ok)break;
		z++;
	}
	if(z-1=='z')cout<<"None"<<endl;
	else cout<<z<<endl;
	return 0;
}


Measured memory_bytes: 512
/**
  * @brief atcoder
  * @author yao
  */
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <utility>
#include <algorithm>
#include <functional>
#include <climits>
#define ft first
#define sd second
#ifdef DBG
#   define dbg_pri(x...) fprintf(stderr,x)
#else
#   define dbg_pri(x...) 0
#   define NDEBUG
#endif //DBG
#include <cassert>

typedef unsigned int uint;
typedef long long int lli;
typedef unsigned long long int ulli;

#define N 10000001

#define NUM_PRIME N
#define MAX_PRIME N
int prime[NUM_PRIME],nprime;
int min_factor[MAX_PRIME];
int pre[MAX_PRIME];
void euler_sieve()
{
    for(int i=2;i<MAX_PRIME;++i)
    {
        if(!min_factor[i]) prime[nprime++]=i, min_factor[i]=i, pre[i]=1;
        for(int j=0; i*prime[j] < MAX_PRIME; ++j)
        {
            min_factor[i*prime[j]] = prime[j];
            pre[i*prime[j]] = i;
            if(prime[j]==min_factor[i]) break;
        }
    }
    dbg_pri("poi euler_sieve: max=%d num=%d n=%d\n",MAX_PRIME,NUM_PRIME,nprime);
}

int cnt[N], base[N], val[N];

int main()
{
    euler_sieve();
    int n;
    scanf("%d", &n);
    base[1]=1, val[1]=1;
    for(int i=2;i<=n;++i)
    {
        int x = pre[i];
        if(min_factor[i] == min_factor[x]) cnt[i] = cnt[x] + 1, base[i] = base[x];
        else cnt[i] = 1, base[i] = val[x];
        val[i] = base[i] * (cnt[i]+1);
    }
    lli ans = 0;
    for(int i=1;i<=n;++i)
        ans += (lli)i * val[i];
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 199600
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	int n;cin>>n;
	vector<ll> s(n + 1,0);
	for(int i = 0; i < n; i++) {
		ll x;cin>>x;
		s[i + 1] = s[i] + x;
	}
	map<ll,ll> m;
	for(int i = 0; i < n + 1; i++) {
		m[s[i]]++;
	}
	ll ans = 0;
	for(auto& e:m){
		ans += e.sc * (e.sc - 1) /2;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 14336
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 998244353
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int n,m;
priority_queue<ll>que;
int main(){
    cin >> n >> m;
    rep(i,n){ll a;cin>>a; que.push(a);}
    rep(i,m){
        ll Q = que.top(); que.pop();
        que.push(Q/2);
    }
    ll ans = 0;
    while(!que.empty()){ans+=que.top();que.pop();}
    cout<<ans<<endl;
}

Measured memory_bytes: 1400
#include "bits/stdc++.h"
using namespace std;

//#define int long long


/*https://github.com/kurokoji/.cpp-Template/wiki#struct-fast*/
//理解できていないものはコメントアウト
struct Fast { Fast() { std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

/* debug */
#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';

/* short */
//#define pb push_back
//#define eb emplace_back
//#define mp make_pair
//#define Fi first
//#define Se second
#define ALL(v) begin(v), end(v) // sort(ALL(v));みたいに使う
//#define RALL(v) rbegin(v), rend(v)
#define X real()
#define Y imag()

/* REPmacro */
#define REPS(i, a, n) for (ll i = (a); i < (ll)(n); ++i)
#define REP(i, n) REPS(i, 0, n)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (ll i = (a); i >= (ll)(n); --i)
#define DEP(i, n) DEPS(i, n, 0)
//#define EACH(i, n) for (auto&& i : n)

/* alias */
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
//using pii = pair<int, int>;
using D = double;
//using P = complex<D>;
using vs = vector<string>;
//template <typename T> using PQ = priority_queue<T>;
//template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;
const D EPS = 1e-9;
//const int dx[] = { 0, 1, 0, -1, 1, -1, 1, -1 }, dy[] = { 1, 0, -1, 0, 1, -1, -1, 1 };

/* func */
inline bool inside(int y, int x, int H, int W) { return y >= 0 && x >= 0 && y < H && x < W; }
inline int in() { int x; cin >> x; return x; }
//inline vs split(const string& t, char c) { vs v; stringstream s(t); string b; while (getline(s, b, c)) v.eb(b); return v; }
//template <typename T> inline bool chmin(T& a, const T& b) { if (a > b) a = b; return a > b; }
//template <typename T> inline bool chmax(T& a, const T& b) { if (a < b) a = b; return a < b; }
//template <typename T, typename S> inline void print(const pair<T, S>& p) { cout << p.first << " " << p.second << endl; }
template <typename T> inline void print(const T& x) { cout << x << '\n'; }
//template <typename T, typename S> inline void print(const vector<pair<T, S>>& v) { for (auto&& p : v) print(p); }
//template <typename T> inline void print(const vector<T>& v, string s = " ") { REP(i, v.size()) cout << v[i] << (i != (ll)v.size() - 1 ? s : "\n"); }


int a=0, b=0, c=0;
vi l;

int dfs(int depth, int len_a, int len_b, int len_c) {
	if (depth == 0) {
		if (min({ len_a, len_b, len_c }) > 0)		return abs(len_a - a) + abs(len_b - b) + abs(len_c - c);
		return INF;
	}

	int ret0 = dfs(depth - 1, len_a, len_b, len_c);
	int reta = dfs(depth - 1, len_a + l[depth-1], len_b, len_c) + (len_a==0?0:10) ;
	int retb = dfs(depth - 1, len_a, len_b + l[depth - 1], len_c) + (len_b == 0 ? 0 : 10);
	int retc = dfs(depth - 1, len_a, len_b, len_c + l[depth - 1]) + (len_c == 0 ? 0 : 10);

	int ans = min({ ret0, reta, retb, retc });
	return ans; 
}

signed main() {
	int N = in();
	a = in();
	b = in();
	c = in();

	REP(i, N) {
		int x;
		cin >> x;
		l.push_back(x);
	}

	cout << dfs(N, 0,0,0) << endl;


	#ifdef _DEBUG
		system("pause");
	#endif
	return 0;
}



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

int main(){
    int k,s;
    int count = 0;
    cin >> k >> s;
    for(int i = 0;i <= k; i++){
        for(int j = 0; j <= k;j++){
            int z = s - i - j;
            if(0 <= z && z <= k){
                count += 1;
            }
            
                }
            }
        cout << count << endl;
        }

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

int main(){
    int N,M;
    cin >> N >> M;
    vector<int> toshi(N);
    for(int i = 0;i<N;i++){
        toshi.at(i) = 0;//都市から伸びてるやつを初期化
    }

    int a,b;
    for(int i = 0;i<M;i++){
        cin >> a >> b;
        toshi.at(a - 1) += 1;
        toshi.at(b - 1) += 1;//添え字的に-1しないとあかん
    }
    for(int i = 0;i < N;i++){
        cout << toshi.at(i) << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = (1<<30)-1;
const ll INF = (1LL<<60)-1;
const ld EPS = 1e-10;
template<typename T> bool chmax(T &x, const T &y) {return (x < y)? (x = y, true) : false;};
template<typename T> bool chmin(T &x, const T &y) {return (x > y)? (x = y, true) : false;};

//aとbの最大公約数を返し、ax+by=gcd(a,b)を満たすようにx,yを変更する
ll extgcd(ll a, ll b, ll &x, ll &y){
    ll d = a;
    if(b == 0) x = 1, y = 0;
    else{
        d = extgcd(b, a%b, y, x);
        y -= (a/b)*x;
    }
    return d;
}

ll mpow(ll x, ll n, ll m){
    ll now = x, ret = 1;
    while(n){
        if(n&1) ret *= now, ret %= m;
        now *= now, now %= m;
        n >>= 1;
    }
    return ret;
}

ll msum(ll x, ll n, ll m){
    ll now = abs(x), ret = 0;
    while(n){
        if(n&1) ret += now, ret %= m;
        now += now, now %= m;
        n >>= 1;
    }
    if(x < 0) ret = m-ret;
    return ret;
}

ll Euler_Totient(ll m){
    ll ret = m;
    for(ll i = 2; i*i <= m; i++){
        if(m%i == 0) ret *= i-1, ret /= i;
        while(m%i == 0) m /= i;
    }
    if(m > 1) ret *= m-1, ret /= m;
    return ret;
}

ll solve(ll a, ll m){
    if(m == 1) return 100;
    ll t = Euler_Totient(m), k = solve(a, t);
    ll u = mpow(a, k, t), v = mpow(a, k, m);
    ll x, y, g = extgcd(t, m, x, y);
    ll l = lcm(t, m);
    ll ret = msum(t*x, (v/g), l) + msum(m*y, (u/g), l) + mpow(a, k, g);
    if(ret < 100) ret += l*((100-ret)/l+1);
    return ret;
}

int main(){
    int Q; cin >> Q;
    rep(i, Q){
        ll a, m;
        cin >> a >> m;
        cout << solve(a, m) << endl;
    }
}

Measured memory_bytes: 3584
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>

namespace adaptor = boost::adaptors;

void solve()
{
    int64_t N;
	std::cin >> N;
	std::vector<int64_t> X(N);
	for (auto& v : X) std::cin >> v;

	std::vector<int64_t> vec = X;
	std::sort(vec.begin(), vec.end());

	for (int64_t i = 0; i < N; i++)
	{
		int64_t ans = X[i] < vec[N / 2] ? vec[N / 2] : vec[N / 2 - 1];
		std::cout << ans << std::endl;
	}

}

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	solve();
}


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

int main() {
  int N;
  string s;

  cin >> N;
  cin >> s;

  int R = 0, B = 0;

  for (int i = 0; i < N; i++) {
    if (s.at(i) == 'R') R++;
    else B++;
  }

  if (R > B) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>//printf("%.15f\n",*********);
#include<vector>//文字列.erase(n),vector
#include<algorithm>//next_permutation
#include<set>
#include<string>//char(小文字-32=大文字)
                //to_string,string,substr
#include<sstream>
#include<complex>
#include<time.h>
#include<random>
#include<cmath>//min,max
#include<math.h>
#include<queue>
#include<time.h>
#include<iomanip>
#include<locale>
#include<utility>//swap
#define rt "\n"
#define rep(i,n) for(int i=0;i<n;i++)
#define rop(i,n) for(int i=1;i<=n;i++)//start==1
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define drop(i,n) for(int i=n;0<i;i--)//end==1
#define yes(ans) if(ans)cout<<"yes"<<rt;else cout<<"no"<<rt;
#define Yes(ans) if(ans)cout<<"Yes"<<rt;else cout<<"No"<<rt;
#define YES(ans) if(ans)cout<<"YES"<<rt;else cout<<"NO"<<rt;
#define Yay(ans) if(ans)cout<<"Yay!"<<rt;else cout<<":("<<rt;
#define sec(a,b,ans) if(ans)cout<<a<<rt;else cout<<b<<rt;
#define vcin(s,n) rep(i,n)cin>>s[i];//vcin(配列名),(繰り返し回数)
#define sort(s) sort(s.begin(),s.end())//標準=昇順
#define reve(s) reverse(s.begin(),s.end())//反転
#define str string
#define please return
#define AC 0
#define rapid_pleaseAC_fast cin.tie(0);ios::sync_with_stdio(false)
#define pi 3.1415926535897932384626//pi
#define nine 1000000000//10^9

using namespace std;
typedef vector<int> vint;
typedef long double ldouble;
typedef vector<string> vstr;
typedef vector<char> vchar;
typedef vector<double> vdou;
typedef vector<double> vdouble;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair<llint, llint> pllint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<char>> vvchar;
typedef vector<vector<double>> vvdouble;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<string>> vvstr;
typedef vector<vector<bool>> vvbool;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;

long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

long long LCM(long long a, long long b) {
	return a * b / GCD(a, b);
}

unsigned GetDigit(unsigned num) {
	return std::to_string(num).length();
}

int tow(int n) {//2のn乗
	if (n == 0)return 1;
	int x = tow(n / 2);
	x *= x;
	if (n % 2 == 1)x *= 2;
	return x;//@domino
}

int KETA(int n) { //Sum of Each Digit
	int sum = 0;
	while (n > 0) {
		sum += n % 10; n /= 10;
	}
	return sum;
}

unsigned ND(unsigned num) {//Number of Digits
	return std::to_string(num).length();//outmax=10
}//stringのほうが効率よくないか？

bool KIBN(string s) {
	rep(i, s.size() / 2) {
		if (s[i] != s[s.size() - 1 - i])return false;
	}
	return true;
}

/*

 (char)toupper(a[n])=文字列のn文字目を大文字で出力

  pow(a,b)=aのb乗

  */


int main(void) {
	rapid_pleaseAC_fast;
	
	string s;
	cin >> s;
	int ans = 0;
	rep(i, 3) {
		if (s[i] == '1') {
			ans++;
		}
	}
	cout << ans << rt;

	please AC;
}
//参考：---

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

using namespace std;

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

    map<long,long> p;
    for(long i=0; i<m; i++) {
        long a, b;
        cin >> a >> b;
        p[a]++, p[b]++;
    }

    cout << (all_of(p.begin(), p.end(), [&](auto t){return ~t.second&1;}) ? "YES" : "NO") << endl;
}


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

using namespace std;

int A,B,WA;

int main() {
    cin>>A>>B;
    WA=-1;
    {if ((A<10) && (B<10) && (A>0) && (B>0))
    cout<<A*B<<endl;
    else
    cout<<WA<<endl;
    }
}

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

using namespace std;

int main(){
    string a, b;
    cin >> a >> b;
    string aa = "", bb = "";
    int anum = atoi(a.c_str()), bnum = atoi(b.c_str());
    for(int i = 0; i < bnum; i++){
        aa += a;
    }
    for(int i = 0; i < anum; i++){
        bb += b;
    }
    if(aa < bb){
        cout << aa << endl;
        return 0;
    }
    cout << bb << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <queue>
#include <stack>
#include <list>
#include <utility>
#include <vector>
#include <set>
#include <algorithm>
#include <cmath>
#include <climits>
#include <map>
#include <unordered_map>
#include <string.h>
#include<iomanip>
#include <iterator>

#define all(a) a.begin(),a.end()
#define VV(T) vector<vector< T > >
#define rep(i,N) for(int i = 0; i <N; i++)
#define fill(x,y) memset(x,y,sizeof(x))
#define name(x) #x
using namespace std;


const int INF = INT_MAX-100;
const int MOD = pow(10,9)+7;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

typedef long long ll,LL;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
typedef pair<int,int> pii;
typedef pair<LL, LL> pLL;


// vector入力
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x: vec) is >> x;
    return is;
}
// vector出力
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec){
    for(int i=0; i<vec.size(); i++){
        os << vec[i] << ( i+1 == vec.size() ? "" : " " );
    }
    return os;
}


int main() {
    int N,W;
    cin >> N >> W;
    VV(ll) vec(N+1,vector<ll>(2,0));
    
    for(auto i = 1; i<=N; i++){
        cin >> vec[i];
    }
    
    VV(ll) dp(N+1,vector<ll>(W+1,0));
    
    for(auto i =1; i<=N;i++){
        
        for(auto w = 0; w<=W; w++){
            
            if (w-vec[i][0] >= 0){
                dp[i][w] = max(dp[i-1][w],dp[i-1][w-vec[i][0]]+vec[i][1]);
            }else{
                dp[i][w] = dp[i-1][w];
            }
        }
        
    }
    
    cout << dp[N][W] << endl;
    
    return 0;
}




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

using namespace std;
int main(void){
    
   string s;
   cin >> s;
   
   int n = (int)s.size();
   
   int ans = 99999;
   
   for (char x = 'a'; x <= 'z'; x++){
       
       int count = 0;
       int temp = 0;
       
       s += x;
       
       for (int i = 0; i < n+1; i++){
           
           if (s[i] == x){
               temp = max(temp,count);
               count = 0;
           }
           else{
               count++;
           }
       }
       
       s = s.substr(0,n);
       ans = min(ans, temp);
   }
    
    cout << ans << endl;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
S = [0]*N
D = [0]*N

for i in range(N):
    if A[i]+i < N:
        S[A[i]+i] += 1
    if i - A[i] > 0:
        D[i - A[i]] += 1
ans = 0
for l in range(N):
    ans += S[l]*D[l]
    

print(ans)

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

N = int(input())

order = {}
count = 1
list = list((map(int, input().split())))
for i in list:
    order[i] = count
    count += 1

# 並び替える
order_sorted = sorted(order.items())
print(' '.join([str(item[1]) for item in order_sorted]))


Measured memory_bytes: 71448
N, M = map(int,input().split())


from collections import defaultdict
import queue
connection = defaultdict(lambda: defaultdict(int))

for i in range(M):
  A, B = map(int, input().split())
  connection[A-1][B-1] = 1
  connection[B-1][A-1] = 1

c = defaultdict(int)
q = queue.Queue()
d = defaultdict(int)
p = defaultdict(int)

c[0] = 1
d[0] = 0
q.put(0)

while not(q.empty()):
  u = q.get()
  for v in connection[u]:
    if c[v] == 0:
      c[v] = 1
      d[v] = d[u] + 1
      p[v] = u
      q.put(v)
  c[u] = 2
print("Yes")
for i in range(1,N):
  print(p[i] + 1)

Measured memory_bytes: 79896
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <x86intrin.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define V vector
template <typename T> bool chmin(T &a, const T &b) {if(a > b){a = b; return true;} return false;}
template <typename T> bool chmax(T &a, const T &b) {if(a < b){a = b; return true;} return false;}
V<int> dx = {-1, 1,  0, 0, -1, -1,  1, 1};
V<int> dy = { 0, 0, -1, 1, -1,  1, -1, 1};

int main () {
    string s; cin >> s;
    int n = s.size();
    int cnt = 0;
    rep(i, n) cnt += s[i] - '0';
    if (cnt % 9 == 0) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

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

int main() {
	int n;
	int ca = 0;
	while (cin >> n&&n!=0) {
		while (1) {
			if (n == 1) { break; }
			if (n % 2 == 1&&n!=1) {
				n=n * 3 + 1;
			}
			else if (n % 2 == 0) {
				n /= 2;
			}
			ca++;
			if (n == 1) { break; }
		}
		cout << ca << endl;
		ca = 0;
	}
	return 0;
}

Measured memory_bytes: 3096
a, b, k = map(int, input().split())
for i in range(k):
    if i % 2 == 0:
        a -= a % 2
        b += a // 2
        a //= 2
    else:
        b -= b % 2
        a += b // 2
        b //= 2
print(a, b)


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

int main(){

int n ;

cin >> n;

for (int i; i < 4 ; i++){
    n %= 10;
}

if (n == 3) cout << "bon"<<endl;
else if (n ==0 || n== 1 || n == 6 || n == 8 )
cout << "pon" << endl;
else cout << "hon" << endl;
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

int main() {
  ll n, a, b, ans = 0;
  cin >> n >> a >> b;

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

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

  cout << a + b + (n - 2) * b - (a + b + (n - 2) * a) + 1 << endl;
  return 0;
}


Measured memory_bytes: 256
def cut(cake,s):
    w=cake[0]
    h=cake[1]
    s=s%(w+h)
    if s<w:
        if s<(w-s):
            return [(s,h),(w-s,h)]
        else:
            return [(w-s,h),(s,h)]
    else:
        if (s-w)<(w+h-s):
            return [(w,s-w),(w,w+h-s)]
        else:
            return [(w,w+h-s),(w,s-w)]
        
n,w,d=map(int,input().split())
while n!=0 or w!=0 or d!=0:
    cakes=[(w,d)]
    for i in range(n):
        p,s=map(int,input().split())
        p=p-1
        cut_cakes=cut(cakes[p],s)
        cakes=cakes[:p]+cakes[p+1:]+cut_cakes
    ans=[0]*len(cakes)
    for i in range(len(cakes)):
        ans[i]=cakes[i][0]*cakes[i][1]
    ans.sort()
    print(ans[0],end="")
    for i in range(1,len(cakes)):
        print(" "+str(ans[i]),end="")
    print()
    n,w,d=map(int,input().split())



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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define copy(from, to) copy(from.begin(), from.end(), back_inserter(to));
#define sort(a) sort(a.begin(), a.end())

typedef long long ll;
using namespace std;

template<class T>
void load(vector<T> &v, int n) {
  for (int i = 0; i < n; ++i) {
    T t;
    cin >> t;
    v.push_back(t);
  }
}

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;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
ll ans[305][305];
string S[305];
ll H, W, K;
ll num = 0;

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> H >> W >> K;
    for(int h = 1; h <= H; h++) {
        cin >> S[h];
        S[h] = "!" + S[h];
        for(int w = 1; w <= W; w++) {
            if(S[h][w] == '#') {
                num++;
                ans[h][w] = num;
            }
        }
    }
    for(int h = 1; h <= H; h++) {
        for(int w = 1; w <= W; w++) {
            if(ans[h][w] == 0) {
                ans[h][w] = ans[h][w-1];
            }
        }
    }
    for(int h = 1; h <= H; h++) {
        for(int w = W; w >= 1; w--) {
            if(ans[h][w] == 0) {
                ans[h][w] = ans[h][w+1];
            }
        }
    }
    for(int w = 1; w <= W; w++) {
        for(int h = 1; h <= H; h++) {
            if(ans[h][w] == 0) {
                ans[h][w] = ans[h-1][w];
            }
        }
    }
    for(int w = 1; w <= W; w++) {
        for(int h = H; h >= 1; h--) {
            if(ans[h][w] == 0) {
                ans[h][w] = ans[h+1][w];
            }
        }
    }
    for(int h = 1; h <= H; h++) {
        for(int w = 1; w <= W; w++) {
            if(w != 1) cout << " ";
            cout << ans[h][w];
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 1664
function myout(text){console.log(text);}//standard output
function Main(input) {
	//input = parseInt(input);
	//input = input.trim().split(" ");
	input = input.trim().split("\n");
	//input = input.trim().split(" ").map((a)=>Number(a));
	//input = input.trim().split("\n").map((a)=>Number(a));
  var tmpInput = JSON.parse(JSON.stringify(input[1]));
  var left = 0;
  var right = 0;
  while(tmpInput.indexOf("()") != -1){
  	tmpInput = tmpInput.replace("()","");
	}
  //myout(tmpInput);
  for(var i = 0; i < tmpInput.length; i++){
    var tmp = tmpInput.slice(i, i + 1);
    if(tmp == "("){
       left++;
    }else if(tmp == ")"){
       right++;
    }
  }
  for(var i = 0; i < right; i++){
    input[1] = "(" + input[1];
  }
  for(var i = 0; i < left; i++){
    input[1] += ")";
  }
  myout(input[1]);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8").trim());


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

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

int main(void){
    int X, N;
    cin >> X >> N;
    int check = 0;
    vector<int> list(100);

    rep(i,N){
        cin >> check;
        list.at(check - 1) = 1;
        check = 0;
    }
    for(int j = 0; j < 500; j++){
        if(X - j - 1 >= 0){
            if(list.at(X - j - 1) != 1){
                cout << X - j;
                break;
            }
        } else {
          cout << X - j;
          break;
        }
      
        if(X + j - 1 <= 99){
            if(list.at(X + j - 1) != 1){
                cout << X + j;
                break;
            }
        } else {
          cout << X + j;
          break;
        }
    }
}

Measured memory_bytes: 3628
#include<stdio.h>

int main(){
	int n;
	scanf("%d", &n);
	long long int total=1, batas=1e18;
	int zero=0, flag=0;
	for(int i=1; i<=n; i++){
		long long int angka;
		scanf("%lld", &angka);
		if(angka==0){
			zero=1;
			break;
		}
		else{
			flag=(batas<angka) ? flag=1 :flag=0;
			total*=angka;
			batas/=angka;
		}
	}
	if(zero==1){
		printf("0\n");
	}
	else{
		if(flag==1){
			printf("-1\n");
		}
		else printf("%lld\n", total);
	}
	return 0;
}

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

#define all(x) (x).begin(),(x).end()
#define rep(i,l,r) for(int i=(int)(l);i<(int)(r);i++)

typedef long long ll;
const ll MOD = 1e9 + 7;
const ll inf = 1LL<<60;
const double eps = 1e-9;



int main()
{
    int N;
    cin >> N;
    vector <int> P(N), Q(N);
    for (int i = 0; i < N; i++) cin >> P[i];
    for (int i = 0; i < N; i++) cin >> Q[i];
    vector <int> v(N);
    iota(v.begin(),v.end(), 1);

    int a, b, i, j = 0;
    do {
        int c = 0;
        for (i = 0; i < N; i++) {
            //cout << v[i] << endl;
            if (v[i] == P[i]) c++;
        }
        if (c == N) a = j;
        c = 0;
        for (i = 0; i < N; i++) {
            if (v[i] == Q[i]) c++;
        }
        if (c == N) b = j;
        j++;
    } while (next_permutation(v.begin(), v.end()));
    //cout << a << " " << b << endl;
    cout << abs(a-b) << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner (System.in);
		int a = sc.nextInt(), b = sc.nextInt();
		int r = (a + b) % 2;
		int ans = ((a + b) / 2) + r;
		sc.close();
		System.out.println(ans);
	}

}


Measured memory_bytes: 22868
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		char c11 = scan.next().charAt(0);
		char c22 = scan.next().charAt(1);
		char c33 = scan.next().charAt(2);
		scan.close();
		System.out.println(c11+""+c22+""+c33);
	}
}


Measured memory_bytes: 21204
n = int(input())
d = []
c = 0
while n % 2 == 0:
    c += 1
    n //= 2
if c > 0:
    d.append(c)
p = 3
while p*p <= n:
    c = 0
    while n % p == 0:
        c += 1
        n //= p
    if c > 0:
        d.append(c)
    p += 2
if n > 1:
    d.append(1)
ans = 0
for x in d:
    c = 1
    while x >= c:
        ans += 1
        x -= c
        c += 1
print(ans)

Measured memory_bytes: 9216
if __name__ == '__main__':

    n = int(input())
    A = list(input())

    white = A.count("W")
    red   = A.count("R")

    #最終形を作る
    B = sorted(A)

    #現在の形と最終形との比較をする
    a = b = 0
    for w,r in zip(A,B):
        if w != r:
            if w == "W":
                a += 1
            else:
                b += 1

    #結果
    com = min(a,b)
    bg = max(a,b)
    dif = bg - com
    ans = com + dif
    print(ans)


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

#define int long long

signed main(){
  int n,m;
  cin >> n>> m;
  int a[n+1];
  
  vector<pair<int,int>> v;
  
  for(int i = 1;i<=n;i++)cin >> a[i];
  sort(a+1,a+n+1);
  
  for(int i = 1;i<=m;i++){
    int b,c;
    cin >> b >> c;
    v.push_back({c,b});
  }
  sort(v.rbegin(), v.rend());
  
  int ans = 0;
  
  int idx = 0;
  for(int i = 1;i<=n;i++){
    if(idx>=m)ans+=a[i];
    else{
      
      ans+=max(a[i], v[idx].first);
      v[idx].second--;
      if(v[idx].second==0)idx++;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3188
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<map>
#include<iostream>
#include<unordered_map>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b)-1);i>=((int)(a));i--)
typedef long long int lli;
//typedef pair<int, int> mp;
#define fir first
#define sec second
#define IINF INT_MAX
#define LINF LLONG_MAX
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define pque(type) priority_queue<type,vector<type>,greater<type> >
#define memst(a,b) memset(a,b,sizeof(a))

struct UF {
  int n;
  vector<int> d;
  UF(int n):n(n), d(n, -1) {}
  int root(int v) {
    if (d[v] < 0) return v;
    return d[v] = root(d[v]);
  }
  bool unite(int x, int y) {
    x = root(x); y = root(y);
    if (x == y) return false;
    if (size(x) < size(y)) swap(x,y);
    d[x] += d[y];
    d[y] = x;
    return true;
  }
  int size(int v) { return -d[root(v)];}
};

int main(void){
	int n, k, l;
	cin >> n >> k >> l;
	UF c(n), t(n);
	
	rep(i, k){
		int p, q; cin >> p >> q;
		p--; q--;
		c.unite(p, q);
	}
	rep(i, l){
		int p, q; cin >> p >> q;
		p--; q--;
		t.unite(p, q);
	}
	
	vector<int> a;
	unordered_map<lli, int> mp;
	lli ta[n];
	rep(i, n) ta[i] = lli(c.root(i))*lli(n) + lli(t.root(i));
	
	rep(i, n){
		if(mp.find(ta[i]) == mp.end()){
			mp[ta[i]] = a.size() + 1;
			a.push_back(0);
		}
		a[mp[ta[i]]-1]++;
	}
	rep(i, n-1) cout << a[mp[ta[i]]-1] << " ";
	cout << a[mp[ta[n-1]]-1] << endl;
}

Measured memory_bytes: 12092
#include <bits/stdc++.h>
using namespace std;
#define M 1000000007
#define U 998244353
#define N 1000005
#define int long long
#define sz(c) (int)c.size()
#define fr first
#define ll long long 
#define sc second
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define rep(i,a,n) for(int i=a ; i<n ; i++)
#define r0 return 0;
#define endl '\n'
#define INF (int)1e15
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	std::cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
int dp[101][2][4];
bool vis[101][2][4];
string n;
int k;
int dfs(int ind, int small, int cur){
	if(ind>sz(n)){
		if(cur==0) return 1;
		else return 0;
	}
	if(vis[ind][small][cur]) return dp[ind][small][cur];
	int ans = 0;
	if(small==0){
		if(n[ind-1]-'0'!=0) ans = (ans+dfs(ind+1,1,cur));
		else ans = dfs(ind+1,0,cur);
		// trace(ind,small,cur,ans);
		if(cur>0) if(n[ind-1]-'0'!=0) ans = (ans+(n[ind-1]-'0'-1)*dfs(ind+1,1,cur-1));
		// trace(ind,small,cur,ans);
		if(cur>0) if(n[ind-1]-'0'!=0) ans += dfs(ind+1,0,cur-1);
		// trace(ind,small,cur,ans);
	}
	else{
		// trace(ind,small,cur,ans);
		ans = (ans+dfs(ind+1,1,cur));
		// trace(ind,small,cur,ans);
		if(cur>0) ans += 9*dfs(ind+1,1,cur-1);
		// trace(ind,small,cur,ans);
	}
	// trace(ind,small,cur,ans);
	vis[ind][small][cur] = 1;
	dp[ind][small][cur] = ans;
	return ans;
}
signed main()
{
	ios_base::sync_with_stdio(0);
	int TESTS=1;
	// cin>>TESTS;
	while(TESTS--)
	{   
		cin >> n;
		cin >> k;
		dfs(1,0,k);
		int ans = dp[1][0][k];
		int cnt = 0;
		// rep(i,0,sz(n)) if(n[i]!='0') cnt++;
		// if(cnt==k) ans++;
		cout<<ans;
	}
}

Measured memory_bytes: 256