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

typedef long long ll;
typedef pair<ll, ll> pll;

const ll INF = ll(9E18);

ll N, A, B, C, D;

void solve() {
	scanf("%lld%lld%lld%lld%lld", &N, &A, &B, &C, &D);
	set<ll>st;
	priority_queue<pll, vector<pll>, greater<pll> >que;
	que.push(make_pair(0, N)); ll ans = INF;
	while( !que.empty() ) {
		pll t = que.top(); que.pop();
		if( t.first > ans ) continue;
		if( t.second <= (ans - t.first) / D ) ans = t.second*D + t.first;
		if( st.count(t.second) ) continue;
		st.insert(t.second);
		
		ll d1, d2, r1, r2;
		
		r1 = t.second % 2, r2 = (2 - t.second % 2) % 2, d1 = r1*D + A, d2 = r2*D + A;
		if( d2 + D > d1 ) que.push(make_pair(t.first + d1, (t.second - r1) / 2));
		if( d1 + D > d2 ) que.push(make_pair(t.first + d2, (t.second + r2) / 2));
		
		r1 = t.second % 3, r2 = (3 - t.second % 3) % 3, d1 = r1*D + B, d2 = r2*D + B;
		if( d2 + D > d1 ) que.push(make_pair(t.first + d1, (t.second - r1) / 3));
		if( d1 + D > d2 ) que.push(make_pair(t.first + d2, (t.second + r2) / 3));
		
		r1 = t.second % 5, r2 = (5 - t.second % 5) % 5, d1 = r1*D + C, d2 = r2*D + C;
		if( d2 + D > d1 ) que.push(make_pair(t.first + d1, (t.second - r1) / 5));
		if( d1 + D > d2 ) que.push(make_pair(t.first + d2, (t.second + r2) / 5));
	}
	printf("%lld\n", ans);
}

int main() {
	int T; scanf("%d", &T);
	while( T-- ) solve();
}

Measured memory_bytes: 4264
#include<stdio.h>

//??????????????????????????????????????????
int top,S[1000];

void push(int x){
  S[++top] = x;
}

int pop(){
  top--;
  return S[top+1];
}

int main(){
  int a,b;
  top = 0;
  char s[100];

  while( scanf("%s",s) != EOF ){
    if(s[0]=='+'){
      a=pop();
      b=pop();
      push(a+b);
    } else if(s[0]=='-'){
      a=pop();
      b=pop();
      push(b-a);
    } else if(s[0]=='*'){
      a=pop();
      b=pop();
      push(a*b);
    } else {
      push(atoi(s));
    }
  }

  printf("%d\n",pop());
  
  return 0;
}

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

using namespace std;

typedef long long lli;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<vector<lli>> mat;

lli n;
string s;
string r;
string l;
lli t;

int main(){
  cin >> n >> s;
  for(lli i = s.size();i > 0;i--){
    if(s[i-1] == ')') t++;
    if(s[i-1] == '('){
      if(t > 0) t--;
      else r = r + ')';
    }
  }
  while(t>0){
    l = '('+l;
    t--;
  }
  cout << l+s+r << endl;
  return 0;
}


Measured memory_bytes: 384
#!/usr/bin/env python3

X = input()
N = len(X)
after_x = ""
next_i = 0
# 連続する箇所で部分文字列を作りたい
s_count, t_count = 0, 0
if X[0] == "T":
    # Tから始まる場合、最初の連続するTは確定で残るので切り捨てる
    for i, x in enumerate(X):
        if x == "T":
            after_x += x
        else:
            break
    next_i = i

if len(after_x) != N:
    # 「全ての文字列がT」ではない
    # 残りの文字列について操作する（最初のTは処理したので、必ずSから始まる）
    for i, char in enumerate(X[next_i:]):
        if i == 0:
            # 最初は確定でSから始まる
            s_count += 1
            continue

        if char == "S":
            # Sの場合
            if X[next_i + i - 1] == "T":
                # T->Sの切り替わりのとき
                if t_count >= s_count:
                    # Sを全て使い切り、余ったTは確定で残る
                    after_x += "T" * (t_count - s_count)
                    t_count = 0
                    s_count = 0
                else:
                    # Tを全部使い切り、余ったSは引き継がれる
                    s_count -= t_count
                    t_count = 0
            s_count += 1
        else:
            # Tの場合
            t_count += 1
    last_char = char

    if last_char == "T":
        # Tで終わる場合
        if t_count >= s_count:
            # Sを全て使い切り、余ったTは確定で残る
            after_x += "T" * (t_count - s_count)
            t_count -= s_count
            s_count = 0
        else:
            # Tを全部使い切り、余ったSは引き継がれる
            s_count -= t_count
            t_count = 0
            after_x += "S" * s_count
    else:
        # Sで終わる場合
        after_x += "S" * s_count
# print(after_x)
ans = len(after_x)
print(ans)


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

int main(){
	int n; cin >> n;
	vector<int> v(n);
	for(int i = 0; i < n; ++i){
		cin >> v[i];
	}
	sort(v.begin(), v.end(), greater<int>());
	int sum = accumulate(v.begin(), v.end(), 0);
	if(v[0] * 2 < sum) cout << "Yes" << endl;
	else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define ARRAY_LENGTH(array) sizeof(array)/sizeof(*array)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const int INF = 1000100100;

int main() {
    ll N, M;
    cin >> N >> M;

    vector<bool> is_loved(M, true);
    REP(i, N) {
        ll K;
        cin >> K;

        vector<bool> tmp(M, false);
        REP(j, K) {
            ll A;
            cin >> A;
            tmp[A - 1] = true;
        }

        REP(j, M) {
            if(is_loved[j] && !tmp[j]) {
                is_loved[j] = false;
            }
        }
    }

    ll ans = 0;
    REP(i, M) {
        if(is_loved[i]) {
            ++ans;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3572
from enum import Enum
import sys
import math

BIG_NUM = 2000000000
MOD = 1000000007
EPS = 0.000000001

#0:中央 1:南 2:東 3:西 4:北 5:裏側
class Dice():

    def __init__(self):
        self.number = [i for i in range(6)]
        self.work = [i for i in range(6)]


    def setNumber(self,n0,n1,n2,n3,n4,n5):
        self.number[0] = n0
        self.number[1] = n1
        self.number[2] = n2
        self.number[3] = n3
        self.number[4] = n4
        self.number[5] = n5


    def roll(self,loc):
        for i in range(6):
            self.work[i] = self.number[i]

        if loc == 'E':
            self.setNumber(self.work[3],self.work[1],self.work[0],self.work[5],self.work[4],self.work[2])
        elif loc == 'N':
            self.setNumber(self.work[1],self.work[5],self.work[2],self.work[3],self.work[0],self.work[4])
        elif loc == 'S':
            self.setNumber(self.work[4],self.work[0],self.work[2],self.work[3],self.work[5],self.work[1])
        elif loc == 'W':
            self.setNumber(self.work[2],self.work[1],self.work[5],self.work[0],self.work[4],self.work[3])


    def get_Top(self):
        return self.number[0]


dice = Dice()
table = list(map(int,input().split()))
dice.setNumber(table[0], table[1], table[2], table[3], table[4], table[5])

loc_array = str(input())
for tmp_loc in loc_array:
    dice.roll(tmp_loc)

print("%d"%(dice.get_Top()))


Measured memory_bytes: 6396
import java.util.Scanner
import java.io.PrintWriter

object Main {
  def main(args: Array[String]): Unit = {
    val sc = new Scanner(System.in)
    val pw = new PrintWriter(System.out)

    val a, b = sc.nextInt()
    pw.println(math.max(a - 2 * b, 0))

    pw.flush()
  }
}

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

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);

        int A = Integer.parseInt(sc.next());
        int B = Integer.parseInt(sc.next());
        sc.close();

        if (A <= 8 && B <= 8) {
            out.printf("Yay!\n");
        } else {
            out.printf(":(\n");
        }
        out.flush();
    }
}


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

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  
  for(int i=0; i<N; i++){
  cin >> A.at(i);
  }

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

  int ans1=0;
  int ans2=0;
  
  for(int i= 0; i<N-1; i++){
  ans1=A.at(i) - A.at(i+1);
  if(ans1==0){
  ans2++;
  }
  }

  if(ans2!=0){
  cout << "NO" << endl;
  }
  
  if(ans2==0){
  cout << "YES" << endl;
  }
  return 0;
}


Measured memory_bytes: 1024
//Solution By SlavicG
#include <bits/stdc++.h>
using namespace std;
 
#define ll                          long long
 
#define forn(i,n)                   for(int i=0;i<n;i++)
#define all(v)                      v.begin(), v.end()
#define rall(v)                     v.rbegin(),v.rend()
	
#define pb                          push_back
#define sz(a)                       (int)a.size()
#define mp                          make_pair
 
#define   endl                       "\n"
#define fastio                       ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

int  main()
{
	int a,b,c;
	cin >> a >> b >> c;
	int available = a - b;
	cout << max(0, c - available) << endl;
}

Measured memory_bytes: 3644
#include <iostream>
#include <vector>
using namespace std;
const int MAX = 55555;

bool P[MAX+1] = {false, false};
void sieve(int n) {
	fill(P+2, P+n+1, true);
	for (int i = 2; i*i <= n; ++i) {
		if (P[i]){
			for (int j = i*i; j <= n; j += i) {
				P[j] = false;
			}
		}
	}
}

int main() {
	int n;
	cin >> n;
	sieve(MAX);
	vector<int> ans;
	for (int i = 1; i <= MAX; i++) {
		if (P[i] && (i%5 == 1)) {
			ans.push_back(i);
		}
	}
	for (int i = 0; i < n; i++) {
		cout << ans[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 3140
from collections import deque

N, M = map(int, input().split())
edges = [list(map(int, input().split())) for _ in range(M)]
routings = [[] for _ in range(N+1)]
for a, b in edges:
  routings[a].append(b)
  routings[b].append(a)

answer = 0
for a, b in edges:
  route = deque([])
  cnt = 0
  checked = [False for i in range(N+1)]
  for r in routings[1]:
    if a == 1 and b == r:
      continue
    else:
      route.append(r)
      cnt += 1
      checked[r] = True
  while len(route) > 0:
    current = route.popleft()
    for next in routings[current]:
      if not checked[next] and (min(current, next) != a or max(current, next) != b):
        route.append(next)
        cnt += 1
        checked[next] = True
  if cnt < N:
    answer += 1
print(answer)


Measured memory_bytes: 74100
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define ret return
using namespace std;
int main() {
	//crane has two
	//turtle has four
	int x,y;
	cin>>x>>y;
	bool ok=0;
	for(int i=x;i>=0;i--) {
		int j=x-i;
		if(i*2+j*4==y)
			ok=1;
		
	}
	if(ok)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
	
	ret 0;
}




Measured memory_bytes: 3628
input()
xs = list(map(int, input().split()))

def solve(x, xs):
    res = []
    for y in xs:
        res.append(abs(x - y))
    if len(xs) > 2:
        res += solve(xs[0], xs[1:])
    return res

print(max(solve(xs[0], xs[1:])))


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

int main() {
    int N, M;
    cin >> N >> M;

    vector<ll> a(N), b(N), c(M), d(M);
    rep(i, N) {
        cin >> a.at(i) >> b.at(i);
    }
    rep(i, M) {
        cin >> c.at(i) >> d.at(i);
    }

    ll maxValue = pow(10, 10);  // 上限値

    vector<int> minChackPoints(N);

    // O(N * M)
    rep(i, N) {  // 人
        ll minDistance = maxValue;
        int minCheckPoint = 0;
        rep(j, M) {  // 地点
            ll distance = abs(a.at(i) - c.at(j)) + abs(b.at(i) - d.at(j));
            if (distance < minDistance) {
                minDistance = distance;
                minCheckPoint = j;
            }
        }
        minChackPoints.at(i) = minCheckPoint + 1;
    }

    rep(i, N) {
        cout << minChackPoints.at(i) << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(c) c.begin(),c.end()


int main(){
    int n; cin >> n;
    vector<string> s(n);
    for(int i = 0; i < n ; i++){
        cin >> s[i];
        sort(all(s[i]));
    }
    sort(all(s));

    ll cnt = 1;
    ll ans = 0;
    for(int i = 1; i < n ; i++){
        if(s[i-1] == s[i]){
            cnt++;
        }else{
            ans += ((cnt*(cnt-1))/2);
            cnt = 1;
        }
        if(n-1 == i){
             ans += ((cnt*(cnt-1))/2);
        }
       
    
    }
    cout << ans << endl;
   
    return 0;
}

Measured memory_bytes: 7296
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <math.h>


using namespace std;

int main() {
    int N, M;
    cin >> N >> M;

    int x[M];
    for(int i = 0; i < M; i++) {
        cin >> x[i];
    }
    sort(x, x + M);

    int absX[M - 1];
    for(int i = 0; i < M - 1; i++) {
        absX[i] = abs(x[i] - x[i + 1]);
    }

    sort(absX, absX + M - 1, greater<>());

    long long ans = 0;
    for(int i = N - 1; i < M - 1; i++) {
        ans += absX[i];
    }

    cout << ans << endl;

    return 0;
}


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

ans = 0
i = 0
while (N >= 10**i):
    if (i%2 == 1):
        ans += 10**i - 10**(i-1)
    i += 1
if (i%2 == 1):
    ans += N - 10**(i-1) + 1
print(ans)


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

int g[15][15];

int counter(int x){
	if(x==0) return 0;
	return counter(x>>1)+(x&1);
}

int main(){
	int n;
	cin>>n;
	for(int i=0;i<n;i++)for(int j=0;j<n;j++)g[i][j]=-1;
	for(int i=0;i<n;i++){
		int m;
		cin>>m;
		for(int j=0;j<m;j++){
			int a,x;
			cin>>a>>x;
			--a;
			g[i][a]=x;
		}
	}
	int ans=0;
	for(int i=0;i<(1<<n);i++){
		vector<int>d(n);
		for(int j=0;j<n;j++){
			if(i>>j&1)d[j]=1;
		}
		bool ok=true;
		for(int j=0;j<n;j++){
			if(d[j]){
				for(int k=0;k<n;k++){
					if(g[j][k]==-1)continue;
					if(g[j][k]!=d[k])ok=false;
				}
			}
		}
		if(ok)ans=max(ans,counter(i));
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <list>
using namespace std;
typedef long long ll;
int main()
{
    ll a,b,c;
    cin>>a>>b>>c;
    int flag=0;
    ll i,j;
    for(i=1;i<=1000;i++)
    {
        if(a*i>=b&&a*i<=c)
        {
            flag=1;
            break;
        }
    }
    if(flag)
    {
        cout<<"OK"<<endl;
    }
    else
    {
        cout<<"NG"<<endl;
    }
}


Measured memory_bytes: 3588
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.next()
    var flg = 0

    for (i in 0 until n.length) {
        if (i != 0 && n[i] != '9') {
            flg = 1
        }
    }
    println((n[0] + "").toInt() + 9 * (n.length - 1) - flg)
}


Measured memory_bytes: 31396
package main

import (
	"fmt"
)

func main() {
	var s, t string
	fmt.Scan(&s, &t)

	for i := 0; i < len(s); i++ {
		if s == t {
			fmt.Println("Yes")
			return
		}
		s = string(s[len(s)-1]) + s[0:len(s)-1]
	}
	fmt.Println("No")
}


Measured memory_bytes: 512
#include <iostream>
#include <queue>
#include <cctype>
#include <stdio.h>
#include <map>
#include <math.h>


using namespace std;

int main(int argc, char const* argv[])
{
    int e;
    while (cin >> e, e) 
    {
        int x,y,z;
        int m = 1000000;

        //for (int i = 0; i <= e; i++) 
        //{
        //    for (int j = 0; j*j <= e; j++) 
        //    {
        //        for (int k = 0; k*k*k <= e; k++) 
        //        {
        //            //cout << " x y z = " << i << j << k <<endl;
        //            if ( i + j*j + k*k*k == e) 
        //            {
        //                m = min( m, i + j + k);
        //            }
        //        }
        //    }
        //}
        for (int k = 0;  k*k*k <= e; k++) 
        {
            int j = sqrt(e - k*k*k);
            int i = e - k*k*k -j*j;
            m = min( m, i + j + k);
        }
        cout << m << endl;
    }
    return 0;
}

Measured memory_bytes: 1156
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <csignal>
#include <cstdio>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>

using Graph = std::vector<std::vector<int>>;
using WGraph = std::vector<std::vector<std::pair<int, long long>>>;
using ll = long long;
using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i=0; i<n; i++) {
        cin >> a.at(i);
    }
    int cur = 1;
    for (int i=0; i<n; i++) {
        if (a.at(i) == cur) {
            cur++;
        }
    }
    if (cur == 1) {
        cout << -1 << endl;
    } else {
        cout << n - cur + 1 << endl;
    }
    return 0;
}


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

int main()
{
    string a,b;
    cin>>a>>b;
    if(a.size()>b.size()) cout<<"GREATER"<<endl;
    else if(a.size()<b.size()) cout<<"LESS"<<endl;
    else{
        for(int i=0;i<a.size();i++){
            if(a[i]>b[i]){
                cout<<"GREATER"<<endl;
                return 0;
            }
            if(a[i]<b[i]){
                cout<<"LESS"<<endl;
                return 0;
            }
        }
        cout << "EQUAL" << endl;
    }
   
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int ll
#define ll long long
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
// #define MOD 998244353
#define MEM_SIZE 101010
#define DEBUG_OUT true
#define ALL(x) (x).begin(), (x).end()

template <typename T>
void DEBUG(T e)
{
  if (DEBUG_OUT == false)
    return;
  std::cout << e << " ";
}
template <typename T>
void DEBUG(const std::vector<T> &v)
{
  if (DEBUG_OUT == false)
    return;
  for (const auto &e : v)
  {
    std::cout << e << " ";
  }
  std::cout << std::endl;
}
template <typename T>
void DEBUG(const std::vector<std::vector<T>> &vv)
{
  if (DEBUG_OUT == false)
    return;
  for (const auto &v : vv)
  {
    DEBUG(v);
  }
}
template <class T, class... Ts>
void DEBUG(T d, Ts... e)
{
  if (DEBUG_OUT == false)
    return;
  DEBUG(d);
  DEBUG(e...);
}
template <class T>
void corner(bool flg, T hoge)
{
  if (flg)
  {
    cout << hoge << endl;
    abort();
  }
}
template <typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

//BELOW
//solve

//-----CODE------//
bool check(vector<pair<int, int>> &vp)
{
  int h = 0;
  for (auto &&p : vp)
  {
    int b = h + p.first;
    if (b < 0)
      return false;
    h += p.second;
  }
  return true;
}
void solve(void)
{
  //カッコ列の問題は折れ線にする。
  int n;
  cin >> n;
  vector<pair<int, int>> ls, rs;
  int total = 0;
  for (int i = 0; i < n; i++)
  {
    string s;
    cin >> s;
    int h = 0;
    int b = 0;
    for (auto &&c : s)
    {
      if (c == '(')
        h += 1;
      else
        h -= 1;
      chmin(b, h);
    }

    if (h > 0)
      ls.emplace_back(b, h);
    else
      rs.emplace_back(b - h, -h);

    total += h;
  }
  sort(ALL(ls));
  reverse(ALL(ls));
  sort(ALL(rs));
  reverse(ALL(rs));
  if (check(ls) and check(rs) && total == 0)
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }

  return;
}

int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(11);
  solve();

  return 0;
}


Measured memory_bytes: 19024
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <deque>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <complex>
#include <functional>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cctype>

using namespace std;

#define dump(n) cout<<"# "<<#n<<"="<<(n)<<endl
#define debug(n) cout<<__FILE__<<","<<__LINE__<<": # "<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,n) repi(i,0,n)
#define iter(c) __typeof((c).begin())
#define tr(c,i) for(iter(c) i=(c).begin();i!=(c).end();i++)
#define allof(c) (c).begin(),(c).end()
#define mp make_pair

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;

int main()
{
	for(double x;cin>>x;){
		vector<double> xs(1,x);
		rep(i,9){
			if(i&1)
				xs.push_back(xs[i]/3);
			else
				xs.push_back(xs[i]*2);
		}
		printf("%.8f\n",accumulate(allof(xs),0.0));
	}
	
	return 0;
}

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

typedef vector<string> vs;

int main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int N, L, i;
	cin >> N >> L;
	vs strs(N);
	for (i = 0; i < N; i++)
		cin >> strs[i];
	sort(strs.begin(), strs.end());
	for (i = 0; i < N; ++i)
		cout << strs[i];
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
n,k = list(map(int, input().split()))

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
N = 10**4
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

for i in range(1, k+1):
    a1 = cmb(n-k+1, i, mod)*cmb(k-1, i-1, mod)
    print(a1%mod)

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

#define int long long
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

using namespace std;

void solve(){
	int n,cp;
	cin >> n >> cp;
	int w[n], v[n];
	for(int i = 0;i < n;i++) cin >> w[i] >> v[i];
	int dp[n][cp+1]; //The maximum value for the first n items and capacity
	for(int i = 0;i <= cp;i++) dp[0][i] = (i < w[0] ? 0: v[0]);
	for(int i = 1;i < n;i++){
		for(int	j = 0;j <= cp;j++){
			if(j==0) dp[i][j] = 0;
			else{
				dp[i][j] = dp[i][j-1];
				dp[i][j] = max(dp[i-1][j],dp[i][j]);
				if(j >= w[i]) dp[i][j] = max(dp[i][j], dp[i-1][j-w[i]] + v[i]);
			}
		}
	}
	cout << dp[n-1][cp] << "\n";
}

signed main(){
	fastio
	int t = 1;
	//cin >> t;
	while(t--) solve();
}

Measured memory_bytes: 81672
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <string>
#include <algorithm>
#define inf 0x3f3f3f3f
#define LL long long

using namespace std;

int main()
{
    string str;
    while(cin>>str)
    {
        for(int i=0;i<str.size()-8;i++)
        {
            cout<<str[i];
        }
        cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int N,X;
	cin>>N>>X;
	int m,sum=0,minn=999999;
	for(int i=1;i<=N;i++){
		cin>>m;
		sum+=m;
		if(m<minn)minn=m;
	}
	if(X-sum==0){
		cout<<N;
	}else{
		int y=(X-sum)/minn;
		cout<<y+N;
	}
	return 0;	
} 

Measured memory_bytes: 256
#include<stdio.h>
using namespace std;

int main() {
    int x, y, tmp;
    int i = 0;
    while(1) {
        scanf("%d %d", &x, &y);
        if (x == 0 && y == 0) break;
        if (x > y) {
            tmp = x;
            x = y;
            y = tmp;
        }
        printf("%d %d\n", x, y);
    }
}


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

int main(){
	string w, t, last = "END_OF_TEXT";
	int num = 0;
	cin >> w;
	while(cin >> t && t.find(last) == string::npos){
		int N = 1000;
		char c[N];
		for(int i = 0; i < t.size(); i++){
			if(t[i] >= 'A' && t[i] <= 'Z'){
				c[i] = t[i]-'A'+'a';
			}
			else{
				c[i] = t[i];
			}
		}
		bool flag = true;
		if(w.size() != t.size()){
			flag = false;
		}
		else{
			for(int i = 0; i < w.size(); i++){
				if(c[i] != w[i]){
					flag = false;
					break;
				}
			}
		}
		if(flag){
			num++;
		}
	}
	cout << num << endl;
	return 0;
}


Measured memory_bytes: 3156
h,w = map(int, input().split())
n = int(input())
a = list(map(int, input().split()))
nn = h*w
pos = 0
cnt = 0
while True:
    tmp = []
    for j in range(w):
        if a[pos] == 0:
            pos += 1
        tmp.append(pos+1)
        a[pos] -= 1
    print(*tmp)
    cnt += w
    if cnt >= nn:
        break
    tmp = []
    for j in range(w):
        if a[pos] == 0:
            pos += 1
        tmp.append(pos+1)
        a[pos] -= 1
    print(*tmp[::-1])
    cnt += w
    if cnt >= nn:
        break



Measured memory_bytes: 3700
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;

//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define UNTIL(p) while(!(p))

//constant
const double EPS = 1e-5;
const double PI  = acos(-1.0);

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

#define PUTS(x) cout << (x) << endl;

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

    VI a(3);
    cin>>a[0]>>a[1]>>a[2];
    SORT(a);
    cout<< a[2] - a[0] << endl;
}

Measured memory_bytes: 256
A,B,C = list(map(int,input().split()))
K = int(input())
flag= 0
for i in range(K):
    if A>=B:
        B *=2
    elif C <= B:
        C *=2
    if C >B and B>A:
        flag = 1
        break
if flag == 0:
    print("No")
else:
    print("Yes")

Measured memory_bytes: 9104
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;


void main()
{
  auto n = readln.chomp.to!int;
  auto a = new int[](n+1);
  long res;
  foreach (i; 1..n+1) {
    a[i] = readln.chomp.to!int;
    if (a[i-1]) {
      auto num = min(a[i-1], a[i]);
      a[i-1] -= num;
      a[i] -= num;
      res += num;
    }
    auto num = a[i] / 2;
    res += num;
    a[i] = a[i] % 2;
  }
  res.writeln;
}


Measured memory_bytes: 3708
nm = list(map(int, input().split()))
lis = list(map(int, input().split()))

lis.sort()

sum = 0
diff = []

if nm[1] - nm[0] <= 0:
    print(0)
else:
    for i in range (nm[1] - 1):
        diff.append(lis[i + 1] - lis[i])

    diff.sort()

    if nm[0] != 1:
        for j in range (nm[0] - 2):
            diff.pop(-1)

    for k in range (nm[1] - nm [0]):
        sum = sum + diff[k]

    print(sum)


Measured memory_bytes: 13960
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define MOD1 1000000007
#define MOD2 998244353
#define LIMIT1 200002
#define LIMIT2 500002
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(i=0;i<n;i++)
#define max(a,b) ((a)>(b) ? (a) : (b))
#define min(a,b) ((a)<(b) ? (a) : (b))
#define zt(a,b) (max((a),(b))-min((a),(b)))
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll nPr(int n,int r){ll i,result=1;rep(i,r){result*=(ll)(n-i);}return result;}
ll nCr(int n,int r){ll i,result=1; rep(i,min(r,n-r)){result*=(ll)(n-i);result/=(ll)(i+1);}return result;}
#define fact(n) nPr((int)(n),(int)(n))
#define nHr(n,r) nCr((int)((n)+(r)+1),(int)(r))
#define sankaku(x) (((x)*((x)+1))/2)
int dx[8]={1,0,-1,0,1,-1,-1,1};
int dy[8]={0,1,0,-1,1,1,-1,-1};
int upint(const void *a, const void *b) { return *(int *)a < *(int *)b ? -1 : *(int *)a > *(int *)b ? 1 : 0; }
int downint(const void *a, const void *b) { return *(int *)a < *(int *)b ? 1 : *(int *)a > *(int *)b ? -1 : 0; }
int upchar(const void* left, const void* right) {return strcmp((char *)left,(char *)right);}
int downchar(const void* left, const void* right) {return strcmp((char *)right,(char *)left);}
ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}
void initialize(){
    
}
int main(void){
  initialize();
  ll n,m,i,j,result=0;
  int l[LIMIT2]={0},r[LIMIT1]={0};
  char s[LIMIT1];
  int lMax,rMin;

  scanf("%lld %lld",&n,&m);
  rep(i,m) scanf("%d %d",&l[i],&r[i]);
  lMax = l[m-1];
  rMin = r[m-1];
  rep(i,m-1){
    lMax = max(l[i],lMax);
    rMin = min(r[i],rMin);
  }
  printf("%d",max(rMin-lMax+1,0));

  return 0;
}



Measured memory_bytes: 2944
W,H,x,y,r=input().split()
W=int(W)
H=int(H)
x=int(x)
y=int(y)
r=int(r)
if x-r>=0 and x+r<=W:
    if y-r>=0 and y+r<=H:
        print("Yes")
    else:
        print("No")
else:
    print("No")


Measured memory_bytes: 5596
#include <iostream>

using namespace std;

void swap(int& a,int& b)
{
	int tmp = a;
	a = b;
	b = tmp;
}

int main()
{
	int w,n;
	int a,b;
	int perm[31];
	char dummy;
	
	cin >> w >> n;
	
	for (int i=1; i<=w; i++) perm[i] = i;
	
	for (int i=0; i<n; i++) {
		cin >> a >> dummy >> b;
		swap(perm[a], perm[b]);
	}
	
	for (int i=1; i<=w; i++) cout << perm[i] << endl;
	
	return 0;
}

Measured memory_bytes: 3020
# A - ABD
# コンテスト名が開催数によって変化する
# 1~999 回目 ABC001 ABC002 ... ABC999
# 1000 ~ 1998 回目 ABD001 ABD002 ... ABD999
# 最初の3文字を出力させる

# 開催数 N (整数） の入力
N = int(input())
# print(N)

# 条件分岐　N が 1 ~ 999 の時 ABC
if N <= 999:
    answer = 'ABC'
elif N <= 1998:
    answer = 'ABD'

# 結果の表示
print(answer)


Measured memory_bytes: 9140
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
using namespace std;

int main()
{
    int a, b, c, x;
    int ans = 0;

    cin >> a >> b >> c >> x;
    for (int i = a; i >= 0; i--)
    {
        for (int j = b; j >= 0; j--)
        {
            for (int k = c; k >= 0; k--)
            {
                if (500 * i + 100 * j + 50 * k == x)
                {
                    ans++;
                    break;
                }
            }
        }
    }

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

Measured memory_bytes: 256
import java.io.*;
class Main {
	static StreamTokenizer st = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
	static int nextInt() throws IOException {
		st.nextToken();
		return (int)st.nval;
	}
	public static void main(String[] args) throws IOException {
		PrintWriter pw = new PrintWriter(new OutputStreamWriter(System.out));
		int sx = nextInt(), sy = nextInt(), tx = nextInt(), ty = nextInt();
		for(int i=sy;i<ty;++i) pw.print("U");
		for(int i=sx;i<tx;++i) pw.print("R");
		for(int i=sy;i<ty;++i) pw.print("D");
		for(int i=sx;i<tx;++i) pw.print("L");
		pw.print("L");
		for(int i=sy;i<=ty;++i) pw.print("U");
		for(int i=sx;i<=tx;++i) pw.print("R");
		pw.print("DR");
		for(int i=sy;i<=ty;++i) pw.print("D");
		for(int i=sx;i<=tx;++i) pw.print("L");
		pw.print("U\n");
		pw.flush();
	}
}

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

 #define REP(i, a, n) for(int i=a; i<n; i++)

int main() {
	int a;
	cin >> a;
	if(a==1){
      cout << "Hello World" << endl;
    }else{
      int b, c;
      cin >> b >> c;
      cout << b+c << endl;
    }
}


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

int keta(int n) {
    int res;
    for(int i = 0; i < 100; i++) {
        n = n / 10;

        if(n == 0) {
            res = i + 1;
            break;
        }
    }
    return res;
}

int main() {
    ll n, d;
    cin >> n >> d;
    ll cnt = 0;
    rep(i, n) {
        ll p, q;
        cin >> p >> q;
        if(d * d >= p * p + q * q) cnt++;
    }
    cout << cnt << endl;
}


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

using namespace std;

#define mem(a,b) memset(a,b,sizeof(a))
#define FOR(i,j,k) for(int i=j;i<=k;i++)
#define read        freopen("in.txt", "r", stdin)
#define write       freopen("out.txt", "w", stdout)
#define pf          printf
#define sf(n)       scanf("%d", &n)
#define sff(a,b)    scanf("%d %d", &a, &b)
#define PB push_back
#define F first
#define S second
#define MP make_pair

typedef pair<int,int> pii;
typedef long long LL;

const int MAX = (2e5) + 5;
int n, k, ara[MAX], can[MAX];

void solve()
{
    int prin = 0;

    cin >> n >> k;
    FOR(i,0,n-1) cin >> ara[i];

    FOR(i,0,n-1) can[ ara[i] ]++;

    sort(can, can + n + 1);
    FOR(i,0,n-k) prin += can[i];

    cout << prin << endl;
}

int main()
{
    ios::sync_with_stdio(false);

    solve();
    return 0;
}



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

using namespace std;

long solve( vector< long > to, long n, long k )
{
    long step = 0, pos = 1;
    vector< long > dis( n + 1, -1 );
    dis[ pos ] = 0;

    long loop_start, loop_len;

    while( true )
    {
        if( step == k )
            return pos;
        long next = to[ pos ];
        if( dis[ next ] != -1 )
        {
            loop_start = next;
            loop_len = dis[ pos ] - dis[ next ] + 1;
            break;
        }
        step++;
        dis[ next ] = dis[ pos ] + 1;
        pos = next;
    }

    k = ( k - dis[ loop_start ] ) % loop_len;
    long ans = loop_start;

    while( k-- )
        ans = to[ ans ];
    
    return ans;
}

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

    vector< long > a( n + 1 );
    for( int i = 1; i <= n; i++ )
        cin >> a[ i ];
    
    cout << solve( a, n, k ) << endl;

    return 0;
}

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

int main(){
  int n,score1=0,score2=0;
  string s1,s2;
  
  cin >> n;

  
  for(int i=0 ; i<n ; ++i){
    cin >> s1 >> s2;

    if(s1 != s2){
      if( s1 > s2 ){
        score1 += 3;
      } else {
        score2 += 3;
      }
    }else {
      ++score1;
      ++score2;
    }
  }

  cout << score1 << " " << score2 << endl;
}



Measured memory_bytes: 3164
#include <iostream>
#include <string>
using namespace std;
int main()
{
	char c;
	cin >> c;
	if (c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o') {
		cout << "vowel" << endl;
	}
	else {
		cout << "consonant" << endl;
	}
}

Measured memory_bytes: 3520
// Created by martinezdiego on 21/5/19

#include <bits/stdc++.h>

using namespace std;

#define N 100005

vector<int> adj[N];
bool visited[N];

void dfs(int node) {
  if (visited[node]) return;
  visited[node] = true;
  for (auto u : adj[node]) dfs(u);
}

int main() {
  ios_base::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int x, y, z;
    cin >> x >> y >> z;
    adj[x].push_back(y);
    adj[y].push_back(x);
  }
  int count = 0;
  for (int i = 1; i <= n; i++) {
    if (visited[i]) continue;
    count++;
    dfs(i);
  }
  cout << count << '\n';
}

Measured memory_bytes: 8960
n,k=map(int,input().split())
P=[int(i) for i in input().split()]
ans=0
for i in range(k):
  ans+=(P[i]+1)/2
cur=ans
for i in range(k,n):
  cur+=(P[i]+1)/2
  cur-=(P[i-k]+1)/2
  if cur>ans:
    ans=cur
print(ans)

Measured memory_bytes: 25188
#include <iostream>
#include <set>
#include <cmath>
#include <tuple>
#include <vector>
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
#define D()
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 10000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

int main(){
	int h,w;
	std::cin >> h >> w;
	char board[51][51] = {'.'};
	for ( int i = 0 ; i < h ; i++ ) {
		for ( int ii = 0 ; ii < w ; ii++ ) {
			std::cin >> board[i][ii];
		}
	}
	for ( int i = 0 ; i < h ; i++ ) {
		for ( int ii = 0 ; ii < w ; ii++ ) {
			char moji = board[i][ii];
			if(moji=='.') continue;
			if(!(board[i-1][ii]=='#' || board[i+1][ii]=='#' || board[i][ii-1]=='#' || board[i][ii+1]=='#')) {
				std::cout << "No" << std::endl;
				return 0;
			}
		}
	}
	std::cout << "Yes" << std::endl;
	return 0;
}


Measured memory_bytes: 256
#![allow(unused_imports, non_snake_case, dead_code)]
use proconio::{
    input, fastout,
    marker::{Chars, Bytes, Usize1}
};

const MODULO: u64 = 1_000_000_007;

struct Combination {
    MOD: u64,
    size: usize,
    fact: Vec<u64>,
    inv_fact: Vec<u64>,
}
impl Combination {
    fn new(size: usize, MOD: u64) -> Self {
        let mut fact = vec![1; size + 1];
        let mut inv_fact = vec![1; size + 1];
        for i in 1..size + 1 {
            fact[i] = fact[i - 1] * i as u64 % MOD;
        }
        inv_fact[size] = Self::modpow(fact[size], MOD - 2, MOD);
        for i in (1..size + 1).rev() {
            inv_fact[i - 1] = inv_fact[i] * i as u64 % MOD;
        }
        Combination {
            MOD,
            size,
            fact,
            inv_fact,
        }
    }
    fn modpow(mut x: u64, mut y: u64, m: u64) -> u64 {
        let mut res: u64 = 1;
        while y > 0 {
            if y & 1 > 0 {
                res = res * x % m;
            }
            x = x * x % m;
            y >>= 1;
        }
        res
    }
    fn modinv(x: u64, m: u64) -> u64 {
        Self::modpow(x, m - 2, m)
    }
    fn nPr(&self, n: usize, r: usize) -> u64 {
        if n < r {
            return 0;
        };
        self.fact[n] * self.inv_fact[n - r] % self.MOD
    }
    fn nCr(&self, n: usize, r: usize) -> u64 {
        if n < r {
            return 0;
        };
        self.fact[n] * self.inv_fact[r] % self.MOD * self.inv_fact[n - r] % self.MOD
    }
}

#[fastout]
fn main() {
    input!{
        N: usize
    }
    let ncr = Combination::new(N * 2, MODULO);
    let mut ans = 0;
    for i in 1..N/3+1 {
        ans = (ans + ncr.nCr(N-i*3+i-1, i-1)) % MODULO;
    }
    println!("{}", ans);

}


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

#define llong long long 
#define len(x) ((int)x.size())
#define rep(i,n) for (int i = -1; ++ i < n; )
#define rep1(i,n) for (int i = 0; i ++ < n; )
#define rand __rand
mt19937 rng(chrono::system_clock::now().time_since_epoch().count());  // or mt19937_64
template<class T = int> T rand(T range = numeric_limits<T>::max()) { return (T)(rng() % range); }

#define CONCAT_(x, y) x##y/*{{{*/
#define CONCAT(x, y) CONCAT_(x, y)
#ifdef LOCAL_DEBUG   
int __db_level = 0;
bool __db_same_line = false;
#define clog cerr << string(!__db_same_line ? __db_level * 2 : 0, ' ')
struct debug_block {
    function<void()> fn;
    void print_name() { __db_same_line = true; fn(); clog << endl; __db_same_line = false;  }
    debug_block(function<void()> fn_): fn(fn_) { clog << "{ "; print_name(); ++__db_level; }
    ~debug_block() { --__db_level; clog << "} "; print_name(); }
};
#define DB(args...) debug_block CONCAT(dbbl, __LINE__)([=]{ clog << args; })
#define deb(...)  if (1) { (clog << "[" #__VA_ARGS__ "] = [" << __VA_ARGS__) << "]"; if (!__db_same_line) clog << endl; }
#else
#define clog if (0) cerr
#define DB(...)
#define deb(...)
#endif
template<class T>
ostream& operator,(ostream& out, const T& thing) { return out << ", " << thing; }
template<class U, class V>
ostream& operator<<(ostream& out, const pair<U, V>& p) { return (out << "(" << p.first, p.second) << ")"; }
template<class A, class B>
ostream& operator<<(ostream& out, const tuple<A, B>& t) { return (out << "(" << get<0>(t), get<1>(t)) << ")"; }
template<class A, class B, class C>
ostream& operator<<(ostream& out, const tuple<A, B, C>& t) { return (out << "(" << get<0>(t), get<1>(t), get<2>(t)) << ")"; }
template<class T> ostream& operator<<(ostream& out, const vector<T>& container) { 
    out << "{";
    if (len(container)) out << container[0];
    rep1(i, len(container) - 1) out, container[i];
    return out << "}";
}
template<class x> vector<typename x::value_type> $v(const x& a) { return vector<typename x::value_type>(a.begin(), a.end()); }
#define ptrtype(x) typename iterator_traits<x>::value_type
template<class u> vector<ptrtype(u)> $v(u a, u b) { return vector<ptrtype(u)>(a, b); }/*}}}*/
// ACTUAL SOLUTION BELOW ////////////////////////////////////////////////////////////

unordered_set<int> d;
bool check(int num) {
    if (num == 0) return true;
    return !d.count(num % 10) and check(num / 10);
}

int main(void) {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n; cin >> n;
    int k; cin >> k;
    while (k--) {
        int x; cin >> x;
        d.insert(x);
    }
    
    while (!check(n)) ++n;
    cout << n;

    return 0;
}

// Remember:
// - Multitest? REFRESHING the data!!!
// - Constrains for each set of data may differs. Should NOT USE the same max constant (maxn)
//   for all of them.
// vim: foldmethod=marker


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

using namespace std;
#define BUF (100005)
#define ll long long

int n,k;

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

	int p;
	for(int i=1;i<=n;i++){
		int tmp;
		cin >> tmp;
		if(tmp==1) p=i;
	}

	if(n==k){
		cout << 1 << endl;
		return 0;
	}

	int ans = (n-1)/(k-1);
	if((n-1)%(k-1)!=0) ans++;

	cout << ans << endl;

	return 0;
}


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

#define mod 1000000007

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

using namespace std;
typedef long long int ll;
const long long INF = 1LL << 60;
 
int main(void){
	
	ll N;
	ll ans = INF;
	
	cin >> N;
	
	for(ll i=1; i<=(long long int)sqrt(N); i++){
		if(N % i == 0){
			if(ans >= i + N / i - 2){
				ans = i + N / i - 2;
			}
		}
	}
	
	printf("%lld\n", ans);
	
	return 0;
}

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

using namespace std;

int main(){
  int n; cin >> n;
  vector<int> a(n),sa(n);
  vector<bool> f(n);
  int cnt=0;
  for(int i=0;i<n;++i) cin >> a[i];
  sa=a; sort(sa.begin(),sa.end());
  for(int i=0;i<n;++i)
    if(sa[i]==a[i]) f[i]=true,cnt++;
  if(n==cnt){
    cout << 0 << endl;
    return 0;
  }
  int q; cin >> q;
  int i;
  int x,y;
  for(i=0;i<q;++i){
    cin >> x >> y;
    x--; y--;
    swap(a[x],a[y]);
    if(sa[x]==a[x]){
      if(!f[x]) f[x]=true,cnt++;
    }else if(f[x]) f[x]=false,cnt--;
    if(sa[y]==a[y]){
      if(!f[y]) f[y]=true,cnt++;
    }else if(f[y]) f[y]=false,cnt--;
    if(n==cnt) break;
  }
  if(i!=q) cout << i+1 << endl;
  else cout << -1 << endl;

  return 0;
}


Measured memory_bytes: 5196
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const int inf = 1e9;
const ll INF = 1e18;
const double pi = 3.14159265358979323846;
#define rep(i,n) for(ll i=0;i<n;i++)

int main(){
	int n,s;cin>>n>>s;
	int x[n];
	rep(i,n) cin>>x[i];
	int ans=abs(x[0]-s);
	rep(i,n) ans=__gcd(ans,abs(x[i]-s));
	cout<<ans<<"\n";
}

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

using namespace std;
int main(){
	int n;
	int a,b,c;
	int aa=0,bb=0,cc=0;
	cin>>n;

	for(int i = 0;i<n;i++){
        cin>>a>>b>>c;

        a+=max(bb,cc);
        b+=max(aa,cc);
        c+=max(aa,bb);

        aa=a;bb=b;cc=c;
	}
    cout<<max(aa,max(bb,cc));
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n,k;
    cin>>n>>k;
    int sum=0;
    if(n>=10){
        cout<<k<<endl;
    }else{
//        int sum=0;
          sum = k+(100*(10-n));
        cout<<sum<<endl;
    
    }
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<cassert>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<deque>
#include<queue>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
typedef pair<int, int>P;
const int MOD = 1e9 + 7;
const int INF = 1e10;
const long double PI = (acos(-1));


signed main() {
	int N;
	cin >> N;
	vector<int>A(N);
	rep(i, N)cin >> A[i];
	vector<int>left(N), right(N);
	left[0] = A[0]; right[0] = A[N - 1];
	rep(i, N - 1)left[i + 1] = gcd(left[i], A[i + 1]);
	rep(i, N - 1)right[i + 1] = gcd(right[i], A[N - 2 - i]);
	int mx = 1;
	rep(i, N) {
		int g;
		if (!i)g = right[N - 2];
		else if (i == N - 1)g = left[N - 2];
		else g = gcd(left[i - 1], right[N - 2 - i]);
		mx = max(mx, g);
	}
	cout << mx << endl;
}

Measured memory_bytes: 2560
#include<string>
#include<string.h>
#include<map>
#include<set>
#include<vector>
#include<stdio.h>
#include<math.h>
#include<iostream>
#include<algorithm>
#include<queue>
#include<stdio.h>
#include <climits>
using namespace std;


int a[105];
bool cmp(int i,int j)
{
    return i>j;
} 
int main()
{
    int n,ans=0,cnt=0;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    sort(a,a+n,cmp);
    for(int i=0;i<n;i+=2)
    {
        ans+=a[i];
    }
    for(int i=1;i<n;i+=2)
    {
        cnt+=a[i];
    }
    cout<<ans-cnt;
    //system("pause");
    return 0;
} 

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <map>
using namespace std;
string z(int i){string s="";if(i>25){s+='a'+i/25;i%=25;}s+='a'+i;return s;}
int main(){
	string s;
	map<string,int>m;
	int i=0;
	cout<<"?shiritori"<<endl;
	for(;i<50;i++){
		cin>>s;
		if(s[0]!='i'||m[s]){cout<<"!OUT"<<endl;return 0;}
		m[s]=1;
		cout<<string("?")+s[s.size()-1]+z(i)+"i"<<endl;
	}
	return 1; //RE
}

Measured memory_bytes: 0
Sa,Sb,Sc=list(input()),list(input()),list(input())
target = "a"
while Sa or Sb or Sc != []:
    if target == "a":
        if Sa==[]:
            print("A")
            break
        target = Sa[0]
        del Sa[0]
    elif target == "b":
        if Sb==[]:
            print("B")
            break
        target = Sb[0]
        del Sb[0]
    else:
        if Sc==[]:
            print("C")
            break
        target = Sc[0]
        del Sc[0]


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

int main(){
  int n, sum, s;
  cin >> n;
  sum = 0;
  s = 1;
  for(int i = 0; i < 8; i++, s *= 10){
    sum += n / s % 10;
  }
  if(n % sum == 0){
    cout << "Yes" <<endl;
  }
  else{
    cout << "No" <<endl;
  }
}
    


Measured memory_bytes: 384
#include <iostream>
#include<bits/stdc++.h>
#define int long long int
#define e 1000000007
using namespace std;

 
int32_t main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
 int t=1;
    // cin>>t;
  while(t--){
    float n,x,k;
    cin>>n>>x>>k;
    int y = ceil(n/x);
    int v = y*k;
    cout<<v<<endl;
  }
}

Measured memory_bytes: 3696