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

/*
*****************code written By**********************
..................Marajul islam.......................
...................BSMRSTU,CSE........................
*/

int sc1() {int x; scanf("%d", &x); return x;}

long long sc2() {long long x; scanf("%lld", &x); return x;}



#define  gcd(a,b)         __gcd(a,b)
#define  lcm(a,b)         (a*b)/gcd(a,b)
#define  Int              sc1()
#define  LL               sc2()
#define  For(n)           for(int i=0;i<n;i++)
#define  Forj(n)          for(int j=0;j<n;j++)
#define  Fork(n)          for(int k=0;k<n;k++)
#define  For1(n)          for(int i=1;i<=n;i++)
#define  ll               long long
#define  vi               std::vector<int>
#define  vll              std::vector<ll>
#define  qui              qu
#define  pb               push_back
#define  mpsi             std::map<string, int>


const int mod           = 1e9 + 7;
const int inf           = (int)2e9 + 5;
const ll  Inf           = (ll)1e18 + 5;
const int N             = 5e6 + 5;

inline int add(int a, int b) {a += b; return a >= mod ? a - mod : a;}
inline int sub(int a, int b) {a -= b; return a < 0 ? a + mod : a;}
inline int mul(int a, int b) {return (ll)a * b % mod;}

int n;
std::vector<int> adj[100005];
map< pair<int, int>, int>mp;
bool vis[100005];

int bfs(int s)
{
	vis[s] = 1;
	queue< pair<int, int> >qu;
	qu.push({s, 0});
	while (!qu.empty()) {
		int toe = qu.front().first;
		int col = qu.front().second;
		qu.pop();
		int ss = 1;
		for (int i = 0; i < (int)adj[toe].size(); i++) {
			if (!vis[adj[toe][i]]) {
				// cout<<toe<<" "<<adj[toe][i]<<endl;
				if (ss == col) ss++;
				int aa = min(toe, adj[toe][i]);
				int bb = max(toe, adj[toe][i]);
				mp[ {aa, bb}] = ss;
				// cout<<aa<<' '<<bb<<' '<<ss<<endl;
				vis[adj[toe][i]] = 1;
				qu.push({adj[toe][i], ss});
				ss++;
			}
		}
	}

	return 0;
}
int solve() {

	n = Int;
	std::vector< pair<int,int> > ed;
	for (int i = 1; i < n; i++) {
		int u, v;
		cin >> u >> v;
		ed.pb({min(u,v),max(u,v)});
		adj[u].pb(v);
		adj[v].pb(u);
	}
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		ans = max(ans, (int)adj[i].size());
	}
	int xxx=bfs(1);
	cout<<ans<<endl;
	for(int i=0;i<n-1;i++){
		cout<<mp[{ed[i].first,ed[i].second}]<<endl;
	}


	return 0;
}




int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);

	int test = 1, tc = 0;
	//scanf("%d", &test);
	//cin >> test;
	while (test--) {
		//printf("Case %d: ", ++tc);
		solve();
	}

	return 0;




}




Measured memory_bytes: 13172
#include<iostream>
using namespace std;
int main(){
	int a, b, x = 0;
	char op;

	// for(;1;) {
	while(1) {
		cin >> a >> op >> b;

		if (op == '?') break;

		if (op == '+'){
			x = a + b;
		}
		else if (op == '-'){
			x = a - b;
		}
		else if (op == '*'){
			x = a * b;
		}
		else if (op == '/'){
			x = a / b;
		}

		cout << x << endl;
	}

	return 0;
}

Measured memory_bytes: 3080
#include<iostream>
int main(){
  short A,B, res;
  std::cin>>A>>B;
  if(A>B){
    res = A;
    A--;
  }
  else{
    res = B;
    B--;
  }
  res+= (A>B?A:B);
  std::cout<<res;
  return 0;
}


Measured memory_bytes: 256
def main():
    x = int(input())
    kouhodic = dict()
    for i in range(200):
        kouhodic[i ** 5] = i
        kouhodic[-i ** 5] = -i
    
    kouhodic = sorted(kouhodic.items())
    kazu = len(kouhodic)
    #print(kouhodic)

    for i in range(kazu):
        for j in range(i+1, kazu):
            if kouhodic[j][0] - kouhodic[i][0] == x:
                print(kouhodic[j][1], kouhodic[i][1])
                exit()
    
    
    




if __name__ == "__main__":
    main()

Measured memory_bytes: 63668
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
using namespace std;
typedef pair<int,int> P;
typedef long long int ll;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}

const int MAX_N = 1 << 19;
const int MAX_M = 2;

// セグメント木を持つグローバル配列
int nn;
ll  dat[2 * MAX_N - 1][2];

// 初期化
void init(int n_){
    // n_が小さいときの変な挙動を防ぐ
    if(n_ < 10)n_ = 10;
    // 簡単のため要素数を2のべき乗に
    nn = 1;
    while(nn < n_)nn *= 2;

    // 全ての値をINT_MAXに
    for(int i = 0; i < 2 * nn - 1; i++)for(int j = 0; j < MAX_M; j++)dat[i][j] = 123456789123456789;
}

// k番目の値(0-indexed)をaに変更
void update(int k, ll a, int m){
    // 葉の接点
    k += nn - 1;
    dat[k][m] = a;
    // 登りながら更新
    while(k > 0){
        k = (k - 1) / 2;
        dat[k][m] = min(dat[k * 2 + 1][m], dat[k * 2 + 2][m]);
    }
}

// [a,b)の最小値を求める
// 後ろのほうの引数は、計算の簡単のための引数。
// kは節点の番号、l, rはその節点が[l, r)に対応づいていることを表す。
// したがって、外からはquery(a, b, 0, 0, nn)として呼ぶ。
ll query(int a, int b, int k, int l, int r, int m){
    // [a, b)と[l, r)が交差しなければ、INT_MAX
    if (r <= a || b <= l)return (ll)123456789123456789;

    // [a, b)が[l, r)を完全に含んでいれば、この節点の値
    if (a <= l && r <= b)return dat[k][m];
    else {
        // そうでなければ、2つの子の最小値
        ll vl = query(a, b, k * 2 + 1, l, (l + r) / 2, m);
        ll vr = query(a, b, k * 2 + 2, (l + r) / 2, r, m);
        return min(vl, vr);
    }
}


int main(){
    ll n, E, T;
    cin >> n >> E >> T;
    n++;
    init(n);

    ll x[n] = {};
    srep(i,1,n) cin >> x[i];

    if(n == 2){
        cout << E + T << endl;
        return 0;
    }

    ll INF = 1001001001001001001;
    ll dp[n] = {};
    srep(i,1,n) dp[i] = INF;

    update(0,dp[0]-x[0]-2*x[1],0);
    update(0,dp[0]-x[0],1);

    srep(i,1,n){
        int l = 0, r = i - 1;
        if((x[i]-x[1])*2 < T){
            r = 0;
        }
        while(l+1<r){
            int m = (l+r)/2;
            if((x[i]-x[m+1])*2 < T){
                r = m;
            }else{
                l = m;
            }
        }

        


        ll tmp1 = INF, tmp2 = INF;
        tmp1 = query(r,i,0,0,nn,1) + T + x[i];
        if(r>0) tmp2 = query(0,r,0,0,nn,0) + 3 * x[i];
        dp[i] = min(tmp1, tmp2);

        // cout << i << ' ' << l << ' ' << r << ' ' << tmp1 << ' ' << tmp2 << endl;

        if(i == n - 1) break;

        update(i,dp[i]-x[i]-2*x[i+1],0);
        update(i,dp[i]-x[i],1);
    }

    cout << dp[n-1] + E - x[n-1] << endl;
    return 0;
}



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

int n,s;

int dfs(int num,int total,int de)
{
	int count = 0;

	if(de == n && total == s)
	{
		return 1;
	}
	if(de == n && total != s)
	{
		return 0;
	}

	for(int i=num; i<=9; i++)
	{
		count += dfs(i+1,total+i,de+1);
	}
	return count;
}

int main()
{

	while(cin >> n >> s, n || s)
	{
			dfs(0,0,0);
		cout << dfs(0,0,0) << endl;
	}

	return 0;
}

Measured memory_bytes: 1160
S=list(input())

# 最終形は、以下のいずれかでは？
# どちらか、近い方との差分を取る
# 1010101010...
# 0101010101...

N=len(S)

ans1=[]
ans2=[]

color=["0","1","0"]

for n in range(N):
	ans1.append(color[n%2])
	ans2.append(color[n%2+1])

# print(ans1)
# print(ans2)

diff1=0
diff2=0

for n in range(N):
	if S[n] != ans1[n]:
		diff1+=1
	if S[n] != ans2[n]:
		diff2+=1

print(min(diff1,diff2))



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

int main(){
	int H,W;
  cin>>H>>W;
  vector<char> vec(W);
  
  for(int i=0;i<H;i++){
  	for(int j=0;j<W;j++){
      cin>>vec.at(j);
      cout<<vec.at(j);
    }
    cout<<endl;
    for(int j=0;j<W;j++)
      cout<<vec.at(j);
  
  cout<<endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <set>
using namespace std;
typedef long long ll;
#define rep(i,s,n)for(int i = s;i<n;i++)
#define repe(i,s,n)for(int i = s;i<=n;i++)

int main() {
	ll N; cin >> N;
	ll M = N;
	ll sum = 0;
	while (M != 0) {
		sum += M % 10;
		M /= 10;
	}
	cout << ((N % sum == 0) ? "Yes" : "No") << endl;

	return 0;
}

Measured memory_bytes: 256
{-# LANGUAGE OverloadedStrings #-}
import qualified Data.ByteString.Char8 as B
import qualified Data.IntMap.Strict    as M
import           Data.List             (elemIndex, foldr)
import           Data.Maybe            (catMaybes, fromJust)


data Result = AC | WA
  deriving (Eq, Show)

parseLine :: B.ByteString -> (Int, Result)
parseLine s = (fst . fromJust $ B.readInt x1, readResult x2)
  where [x1, x2] = B.words s

readResult :: B.ByteString -> Result
readResult "AC" = AC
readResult "WA" = WA

main :: IO ()
main = do
  [n, m] <- map read . words <$> getLine
  pss <- map parseLine . B.lines <$> B.getContents
  let (a, b) = solve n m pss
  putStrLn . unwords $ map show [a, b]

solve :: Int -> Int -> [(Int, Result)] -> (Int, Int)
solve _ _ pss = (a, b) where
  xs = M.elems $ foldr f M.empty pss :: [[Result]]
  ys = catMaybes $ map (elemIndex AC) xs :: [Int]
  a = length ys
  b = sum ys

f :: (Int, Result) -> M.IntMap [Result] -> M.IntMap [Result]
f (p, s) xs = M.alter g p xs where
  g Nothing   = Just [s]
  g (Just ss) = Just (s:ss)


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

int main(int argc, char const *argv[])
{
  int r, g, b;
  	cin >> r >> g >> b;
  	if ((100 * r + 10 * g + b) % 4 == 0) {
  		cout << "YES";
  	}
  	else {
  		cout << "NO";
  	}
  	return 0;
}

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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> a(n), b(n), c(n - 1);
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < n; i++) cin >> b[i];
  for (int i = 0; i < n - 1; i++) cin >> c[i];
  ll ans = 0;
  int bef = -1;
  for (int i = 0; i < n; i++) {
    if (bef + 2 == a[i]) {
      ans += c[a[i] - 2];
    }
    ans += b[a[i] - 1];
    bef = a[i] - 1;
  }
  cout << ans << endl;
  return 0;
}


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

typedef long long ll;
typedef pair<int,int> ii;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int a,b,c; cin>>a>>b>>c; cout << (b-a==c-b ? "YES" : "NO") << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <atcoder/all>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = (n-1); i >= 0; i--)
using namespace std;
using namespace atcoder;
typedef long long ll;
const int MOD = 1000000007;
//const int MOD =  998244353;
 
const ll INF = 1LL<<60;
const int IINF = 1000000000;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){

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

    int N, M; cin >> N >> M;

    dsu ds(N);
    int ans = 0;
    rep(i,M){
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        ds.merge(a,b);
    }
    set<int> counter;
    rep(i,N){
        counter.insert(ds.leader(i));
    }

    cout << counter.size()-1 << endl;
}

Measured memory_bytes: 7600
import sys

n = int(input())
work = [list(map(int, input().split())) for i in range(n)]
work = sorted(work, key=lambda x:x[1])

sum = 0

for i in range(n):
  sum += work[i][0]
  if sum > work[i][1]:
      print('No')
      sys.exit()

print('Yes')

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

using namespace std;
int main()
{
    int a , b ;
    cin >> a >> b ;

    if( a > b )
        cout << a-1 ;
    else
        if ( a < b )
        cout << a;
    else
        if ( a == b )
        cout << a;

    return 0;
}


Measured memory_bytes: 3540
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <ctime>
#include <iomanip>
#include <numeric>
using namespace std;
const int MAX = 2e5 + 4;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n, r;
	cin >> n >> r;
	if (n >= 10) cout << r;
	else cout << r + (100 * (10 - n));
	return 0;
}

Measured memory_bytes: 256
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from functools import reduce
from bisect import bisect_left, insort_left
from heapq import heapify, heappush, heappop

INPUT = lambda: sys.stdin.readline().rstrip()
INT = lambda: int(INPUT())
MAP = lambda: map(int, INPUT().split())
S_MAP = lambda: map(str, INPUT().split())
LIST = lambda: list(map(int, INPUT().split()))
S_LIST = lambda: list(map(str, INPUT().split()))

sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7


def main():
    H, W = MAP()
    N = INT()
    A = LIST()

    idx = 0
    cnt = 0
    C = [[0] * W for _ in range(H)]
    for i in range(H):
        for j in range(W):
            C[i][j] = idx + 1
            cnt += 1
            if A[idx] == cnt:
                idx += 1
                cnt = 0

    for i in range(H):
        line = list(reversed(C[i])) if i % 2 else C[i]
        print(*line)


if __name__ == '__main__':
    main()


Measured memory_bytes: 10440
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,m;
  cin >> n >> m;
  vector<vector<int>>  map(n,vector<int>(m,0));
  for(int i=0;i<n;i++){
    int x;
    cin >> x;
    for(int j=0;j<x;j++){
      int y;
      cin >> y;
      map.at(i).at(y-1)=1;
    }
  }
  int count=0;
  for(int i=0;i<m;i++){
    bool ans=true;
    for(int j=0;j<n;j++){
      if(!map.at(j).at(i)){
        ans=false;
        break;
      }
    }
    if(ans)
      count++;
  }
  cout << count << endl;
}

Measured memory_bytes: 256
# https://atcoder.jp/contests/abc090/tasks/arc091_a



N, M = gets.split.map(&:to_i)

ans = if N == 1 && M == 1
        1
      elsif N == 1 || M == 1
        [N, M].max - 2
      else
        [N - 2, 0].max * [M - 2, 0].max
      end
puts ans


Measured memory_bytes: 1788
//#pragma GCC target("avx2")
//#pragma GCC optimize("O3")
 
//#include <x86intrin.h>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <string>
#include <bitset> 
#include <vector>
#include <cmath>
#include <deque>
#include <queue>
#include <iomanip>
#include <stack>
#include <map>
#include <set>
//#include <ordered_set>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
 
//using namespace __gnu_pbds;
using namespace std;
 
//template<typename T> using ordered_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
     
#define F first
#define S second           
#define lb lower_bound               
#define ub upper_bound
#define pb push_back
#define pf push_front    
#define ppb pop_back
#define mp make_pair                                     
#define bpp __builtin_popcountll                                                                                        
#define sqr(x) ((x) * (x)) 
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define in insert
#define ppf pop_front
#define endl '\n'
//#define int long long
 
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
 
const int mod = (int)1e9 + 7;
const int N = (int)3e5 + 123;
const ll inf = (ll)1e18 + 1;
 
const double pi = acos (-1.0);
const double eps = 1e-9;                  
const int dx[] = {0, 0, 1, 0, -1};
const int dy[] = {0, 1, 0, -1, 0};

string s;

inline void boost () {
   ios_base :: sync_with_stdio (0);
   cin.tie (0), cout.tie (0);
}
 
inline void Solve () {
   cin >> s;
   if ((sz (s) & 1) == (s[0] == s.back ()))
      cout << "Second";
   else
      cout << "First";
}               
 
signed main () {                                       
   #ifdef QWERTY
      freopen("input", "r", stdin);
   #endif
// freopen (".in", "r", stdin);    
// freopen (".out", "w", stdout);              
   boost ();
   int tt = 1;
   //cin >> tt;   
   while (tt --) {
      Solve ();
   }                                               
   return 0;      
}                   

Measured memory_bytes: 3788
#include <iostream>
#include <algorithm>
#include <string>

int main()
{
    int H, W;
    std::string a[110];
    std::cin >> H >> W;

    bool okH[110];
    bool okW[110];
    std::fill((bool *)okH, (bool *)(okH + 110), true);
    std::fill((bool *)okW, (bool *)(okW + 110), true);

    for (int i = 0; i < H; ++i)
        std::cin >> a[i];

    for (int i = 0; i < H; ++i)
    {
        for (size_t j = 0; j < a[i].size(); ++j)
            if (okW[i] && okH[j])
            {
                bool check = true;
                for (int k = 0; k < W; ++k)
                    if (a[i][k] == '#')
                    {
                        check = false;
                        break;
                    }
                if (check)
                {
                    okW[i] = false;
                    continue;
                }

                check = true;
                for (int k = 0; k < H; ++k)
                    if (a[k][j] == '#')
                    {
                        check = false;
                        break;
                    }
                if (check)
                {
                    okH[j] = false;
                    continue;
                }
                std::cout << a[i][j];
            }
        if (okW[i])
            std::cout << '\n';
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdio.h>
#include <math.h>
using namespace std;
using vi = vector<int>;
using vll = vector<long long int>;
using vb = vector<bool>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<long long int>>;
using ll = long long int;


int main(){
    ll N; cin >> N;
    bool m = true;
    for(ll i=1; i<3501; i++){
        if(m){
        for(ll j=1; j<3501; j++){
            if(m){
            if(4*i*j>=(i+j)*N){
            if(4*i*j-N*i-N*j != 0){
            if((N*i*j)%(4*i*j-N*i-N*j)==0){
                cout << i << " " << j << " " << (N*i*j)/(4*i*j-N*i-N*j);
                m = false;
            }
            }
            }
            }
        }
        }
    }
}

Measured memory_bytes: 256
# 参考: https://beta.atcoder.jp/contests/abc063/submissions/1329352
N, A, B = gets.split.map(&:to_i)
HS = readlines.map(&:to_i)

ans = (1..HS.max).bsearch do |t|
  count = 0
  HS.each do |h|
    count += ([h - B * t, 0].max.fdiv(A - B)).ceil
    break if count > t
  end
  count <= t
end
p ans

Measured memory_bytes: 10876
import java.util.Map;
import java.util.Scanner;
import java.util.TreeMap;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long k = sc.nextLong();
        Map<Integer, Long> m = new TreeMap<Integer, Long>();
        for (int i = 0; i < n; i++) {
            int a = sc.nextInt();
            long b = sc.nextLong();
            if (m.containsKey(a)) {
                m.put(a, m.get(a) + b);
            } else {
                m.put(a, b);
            }
        }
        long t = 0;
        for (Integer ans : m.keySet()) {
            t += m.get(ans);
            if (t >= k) {
                System.out.println(ans);
                return;
            }
        }
    }

}

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

int main() {
  long long int n;
  cin >> n;
  if(n % 2 == 1) cout << 0 << endl;
  else {
    long long int total = 0;

    for(int i=1;pow(5, i) * 2 <=n;i++) {
      total += n / (long long int)(pow(5, i) * 2);
    }

    cout << total << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
    using namespace std;
    #define INF 2000000000
    typedef long long int ll;
    typedef pair<ll,ll> ii;
    typedef pair<ii,ll> iii;
    typedef vector<ll> vi;
    typedef vector<ii> vii;
    #define getbit(n,i) (((n)&(1<<(i)))!=0)
    #define setbit0(n,i) ((n)&(~(1<<(i))))
    #define setbit1(n,i) ((n)|(1<<(i)))
    #define togglebit(n,i) ((n)^(1<<(i)))
    #define lastone(n) ((n)&(-(n)))
    #define read freopen("debug\\in.txt","r",stdin)
    #define write freopen("debug\\out.txt","w",stdout)
    #define fi first
    #define se second
    #define getI(a) scanf("%d",&a)
    #define getII(a,b) scanf("%d%d",&a,&b)
    #define PI (acos(-1))
    #define fastread ios_base::sync_with_stdio(false);cin.tie(NULL)
    #define mod (1000000007)
    #define asz 500005
    #define pb push_back
    #define ppf pop_front
    #define ppb pop_back
    #define pf push_front
    ll n;
    ll W;
    ll used[200005];
    ll a[200005];
    vector<ll>kola1,kola2;
    vector<vector<ll> >v;
    map<vector<ll>,ll>mp;
    ll co=0;
    void permute(ll at){
    	if(at>n){
    		vector<ll>temp;
            for(ll i=1;i<=n;i++)
            temp.pb(a[i]);
            v.pb(temp);
            //a.clear();
    		return ;
		}
		else{
			for(ll i=1;i<=n;i++){
				if(used[i]==0){
					//a.pb(i);
					a[at]=i;
					used[i]=1;
					permute(at+1);
					used[i]=0;
				}
			}
		}
	}
    int main()
    {
        fastread;
        ll i,j,k,l,m;
        cin>>n;
        for(i=1;i<=n;i++){
        	cin>>k;
        	kola1.pb(k);
		}
		 for(i=1;i<=n;i++){
        	cin>>k;
        	kola2.pb(k);
		}
        permute(1);
        ll sz=v.size();
        for(i=0;i<sz;i++)
        mp[v[i]]=i+1;
        /*for(i=0;i<6;i++){
        	for(j=0;j<3;j++)
        	cout<<v[i][j]<<" ";
        	cout<<endl;
		}*/
        //cout<<mp[kola1]<<endl;
        //cout<<mp[kola2]<<endl;
        cout<<abs(mp[kola1]-mp[kola2]);
    	return 0;
    }

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

int main()
{
    char s[100001];
    int a[26] = {};
    int i;
    scanf("%s", s);
    for (i=0; s[i]!='\0'; i++)
    {
        a[s[i] - 97] = 1;
    }
    for (i=0; i<26; i++)
    {
        if (a[i] == 0) {
            printf("%c\n", i + 97);
            return 0;
        }
    }
    printf("None\n");
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <utility>
#include <map>
#include<string>
using namespace std;
typedef long long ll;


int main()
{
  ll A,B,K;
  cin >> A >> B >> K;

  if(K < A){
    A = A - K;
    cout << A << ' '<< B << endl;
  }

  else if(A <= K && A + B > K){
    K = K - A;
    A = 0;
    B = B - K;
    cout << A << ' '<< B << endl;
  }

  else if(A + B <= K){
    A = 0;
    B = 0;
    cout << A << ' '<< B << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#!usr/bin/env python3
from collections import defaultdict
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007

#A
"""
h,w = LI()
a,b = LI()
y = h//a
x = w//b
ans = h*w-a*y*b*x
print(ans)
"""

#B
def m(x,y):
    if x == y:
        return "T"
    if x == "F":
        return "T"
    return "F"
n = I()
p = input().split()
ans = p[0]
for i in range(1,n):
    ans = m(ans,p[i])
print(ans)

#C
"""
s = [[1]*8 for i in range(4)]
for i in range(4):
    s.insert(2*i,[1,0,1,0,1,0,1,0])
for j in range(8):
    for i in range(1,8):
        s[j][i] += s[j][i-1]
for j in range(8):
    for i in range(1,8):
        s[i][j] += s[i-1][j]
s.insert(0,[0,0,0,0,0,0,0,0,0])
for i in range(1,9):
    s[i].insert(0,0)
q = I()
for _ in range(q):
    a,b,c,d = LI()
    print(s[c][d]-s[c][b-1]-s[a-1][d]+s[a-1][b-1])
"""

#D
"""
n = I()
a = LI()
dp = [float("inf") for i in range(n)]
b = [[] for i in range(n)]
ind = [0 for i in range(100001)]
for i in range(n):
    k = bisect.bisect_left(dp,a[i])
    dp[k] = a[i]
    b[k].append(a[i])
    ind[a[i]] = max(i,ind[a[i]])
for i in range(n):
    if dp[i] == float("inf"):break
    b[i].sort()
    b[i] = b[i][::-1]
i -= 1
ans = b[i][0]
now_ind = ind[b[i][0]]
now_v = b[i][0]
while i >= 0:
    for j in b[i]:
        if ind[j] < now_ind and j < now_v:
            ans += j
            now_ind = ind[j]
            now_v = j
    i -= 1
print(ans)
"""
#E

#F

#G

#H

#I

#J

#K

#L

#M

#N

#O

#P

#Q

#R

#S

#T



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

int main()
{
	string S;
	int ans = 0;
	cin >> S;

	int ss = S.size() -1;
	for (int s = 0; s < ss; s++) {
		if (S[s] == 'A' && S[s+1] == 'C')
			ans = 1;
	}

	if (ans)cout << "Yes";
	else cout << "No";

	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
const int MAXN=200010;

inline long long max(long long x,long long y){
	return x>y?x:y;
}
long long tr[MAXN<<2];int bit=1;
inline void build(int n){
	for(bit=1;bit<=n+1;bit<<=1);
}
inline void update(int x,long long y){
	for(tr[x+=bit]=y,x>>=1;x;x>>=1)
		tr[x]=max(tr[x<<1],tr[x<<1|1]);
}
long long query(int s,int t){
	if(s>t)
		return 0;
	if(s==t)
		return tr[s+bit];
	long long ans=0;
	for(s+=bit-1,t+=bit+1;s^t^1;s>>=1,t>>=1){
		if(~s&1)
			ans=max(ans,tr[s^1]);
		if(t&1)
			ans=max(ans,tr[t^1]);
	}
	return ans;
}

int n,a[MAXN],h[MAXN],p[MAXN];
bool cmp(const int &x,const int &y){
	return h[x]<h[y];
}

int main(){
	scanf("%d",&n);build(n);
	for(int i=1;i<=n;i++){
		scanf("%d",&h[i]);
		p[i]=i;
	}
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	std::sort(p+1,p+n+1,cmp);
	for(int i=1;i<=n;i++)
		update(p[i],query(1,p[i]-1)+a[p[i]]);
	printf("%lld\n",query(1,n));
	return 0;
}

Measured memory_bytes: 6272
#include<iostream>
#include<cstdio>
#include<cmath>

using namespace std;

int main() {
    while (1) {
        int d, e;
        cin >> d >> e;
        if (d == 0) break;

        double mindelta = abs(e - d);
        for (int x = 0; x <= d / 2; ++x) {
            int y = d - x;
            double delta = abs(e - sqrt(x * x + y * y));
            if (mindelta > delta) mindelta = delta;
        }
        printf("%.10f\n", mindelta);
    }
}

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

using namespace std;

using ll = long long;

int main(){
  ll l, r;
  cin >> l >> r;
  cin.ignore();

  ll min = 2018;
  ll tmp;

  // 2019は3と673の合成数→あとで考える！
  for(ll k = 0; k < 2019; ++k){
    for (ll i = l + k + 1; i < (l + k + 2019) && i <= r; i++){
      tmp = (l + k) * i % 2019;
      if(tmp < min){
        min = tmp;
        //cout << min << endl;
      }
    }
  }
  cout << min << endl;
  return 0;
}

  


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

const double pi = 3.14159265358979323846;
const ll mod = 1000000007;


int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
	int n; cin >> n;
	int tmp = n / 111 + 1;
	if(n % 111 == 0) cout << n << endl;
	else cout << tmp * 111 << endl;
} 

Measured memory_bytes: 256
import std.stdio, std.string, std.conv;

void main() {
    auto input = getStdin!(string[]);
    foreach (line; input) {
    	auto num = line.split(" ").to!(int[]);
    	int width = num[1];
    	int height = num[0];
    	if (width == 0 && height == 0) break;

    	for (int i_h = 0; i_h < height; i_h++) {
    		for (int j_w = 0; j_w < width; j_w++) {
    			if (i_h % 2 == 0 && j_w % 2 == 0 || i_h % 2 == 1 && j_w % 2 == 1) {
    				"#".write;
    			}
    			else {
    				".".write;
    			}
    			
    			if (j_w == width - 1)
    				"".writeln;
    		}
    	}
    	
    	"".writeln;
    }
}

T getStdin(T)() {
    string[] cmd;
    string line;
    while ((line = chomp(stdin.readln())) != "") cmd ~= line;
    return to!(T)(cmd);
}

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

#include<cstdio>
#define r(i,n) for(int i=0;i<n;i++)


int main(void){
  int n,sum=0;
  cin>>n;
  vector<int> l(n);
  vector<int> c(n);
  r(i,n)cin>>l.at(i)>>c.at(i);
  r(i,n){
    sum+=c.at(i)-l.at(i)+1;
  }
  cout<<sum<<endl;

return 0;}


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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'

// n回繰り返し
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) // 1-indexed昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  // 0-indexed降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   // 1-indexed降順
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii;  // 2次元配列
typedef vector<ll> vll;
typedef vector<double> vd;
typedef pair<int, int> PII;

template<typename T>
using vec = vector<T>;
template<class T>
using maxheap = std::priority_queue<T>;
template<class T>
using minheap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

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

const ld Pi = std::acos(-1.0L);
const ll infll = (1LL<<62)-1;
const int inf = (1<<30)-1;
const int mod = 1000000007;
// const int mod = 998244353;


/*FUNCs=================================================*/


/*MAIN==================================================*/
signed main(){
    int _StartTime_ = clock();
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
    // cout << fixed << setprecision(15);

    int n; cin >> n;
    vi s(n); rep(i,n) cin >> s[i];

    int q; cin >> q;
    int cnt = 0;
    rep(i,q) {
        int t;
        cin >> t;
        if(t == *lower_bound(all(s), t)) ++cnt;
    }

    cout << cnt << '\n';

    // printf("ExcutionTime: %d /ms\n",1000*(int)((clock()-_StartTime_)/CLOCKS_PER_SEC));
}


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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}

int main2() {
  int N = nextInt();
  int H = nextInt();
  vector<int> bs;
  int max_a = 0;
  REP(i, N) {
    int a = nextInt();
    int b = nextInt();
    bs.push_back(b);
    max_a = max(max_a, a);
  }
  sort(ALL(bs));
  reverse(ALL(bs));
  int p = 0;
  int ans = 0;
  while (H > 0) {
    if (p < N && bs[p] > max_a) {
      H -= bs[p++];
      ans++;
    } else {
      ans += (H + max_a - 1) / max_a;
      H = 0;
    }
  }
  cout << ans << endl;
  return 0;
}

int main() {
  for (;!cin.eof();cin>>ws)
    main2();
  return 0;
}


Measured memory_bytes: 892
N = int(input())
if N==1:
  import sys
  print(1)
  sys.exit()
  
ans = [0]*(N+1)
ans[0] = 2
ans[1] = 1
for i in range(2,N+1):
  ans[i]=ans[i-1]+ans[i-2]
print(ans[N])

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

using namespace std;

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

    long answer = 0;
    for (long k = 1; k < sqrt(n); ++k) {
        if ((n - k) % k == 0 && n * k % (n - k) != 0) {
            answer += (n - k) / k;
        }
    }
    if (n <= 2) answer = 0;
    cout << answer << endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int S, h, m, s;
    cin >> S;
    h = S / 3600;
    m = S % 3600 / 60;
    s = ( S % 3600 % 60 ); 
    cout << h << ":" << m << ":" << s << endl;
}


Measured memory_bytes: 3112
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>
#include<map>
#include<stack>

using namespace std;
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
#define ll long long
using lint=long long;
typedef pair<int,int> P;
const int inf=1000000007;
const int MOD=1000000007;
signed main(){  
  int n;cin>>n;
  vector<int> x(n);
  rep(i,n)cin>>x[i];
  stack<int> st;
  lint res=1;
  rep(i,n){
      st.push(x[i]);
      if(x[i]<st.size()*2-1){
          res*=st.size();
          st.pop();
      }
      res%=MOD;
  }
  int num=st.size();
  rep1(i,num){
      res*=i;res%=MOD;
  }
  cout<<res<<"\n";
  return 0;
}

Measured memory_bytes: 4008
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
x = sum(b)
for i in range(n) :
    if a[i] >= b[i] :
        a[i] -= b[i]
        b[i] = 0
    else :
        b[i] -= a[i]
        a[i] = 0
        if a[i+1] >= b[i] :
            a[i+1] -= b[i]
            b[i] = 0
        else :
            b[i] -= a[i+1]
            a[i+1] = 0
y = sum(b)
print(x-y)

Measured memory_bytes: 18624
import sys
N = int(input())
D,X = [int(n) for n in input().split()]
A = [int(input()) for _ in range(N)]
# S = str(input())
# L = len(S)
# T = str(input())
ans = N
for d in range(2,D+1):
    for a in A:
        if(d % a==1 or a == 1):
            ans+=1
print(ans+X)


Measured memory_bytes: 3060
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<climits>
#include<bitset>
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define int long long
using namespace std;
inline int read(){
    int f=1,ans=0;char c=getchar();
    while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
    while(c>='0'&&c<='9'){ans=ans*10+c-'0';c=getchar();}
    return f*ans;
}
double s(int x){
    int y=x,res=0;while(x){res+=(x%10);x/=10;}
    return (double)y/(double)res;
}
int N,bas=1;
signed main(){
    N=read();int now=0;
    while(N--){
        while(1){
            if(s(now+bas)>s(now+bas*10)) bas*=10;
            else break;
        }now+=bas;
        printf("%lld\n",now);
    }return 0;
}



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


#define long long long int

using namespace std;


typedef vector<int> vi;
typedef pair<int, int> pi;

void print(const vector<long> &a) {
    for (auto item : a) {
        cout << item << " ";
        flush(cout);
    }
}


int main() {

    int n;
    cin >> n;
    for (double i = 1; i <= 9; ++i) {
        double res = n / i;
        if (res == (int) res and res < 10) {
            cout << "Yes";
            return 0;
        }
    }
    cout << "No";


    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,m,a[10],w[10]={0,2,5,5,4,5,6,3,7,6};
string dp[10005];
int main()
{
	cin>>n>>m;
	for(int i=1;i<=m;i++)
		cin>>a[i];
	sort(a+1,a+m+1);
	for(int i=1;i<=10000;i++)
		dp[i]="0";
	for(int i=0;i<=n;i++)
	{
		if(dp[i]=="0") continue;
		for(int j=1;j<=m;j++)
		{
			if(i+w[a[j]]>n) continue;
			string t=dp[i];
			t+='0'+a[j];
			if(dp[i+w[a[j]]].size()<t.size())
				dp[i+w[a[j]]]=t;
			else
				dp[i+w[a[j]]]=max(dp[i+w[a[j]]],t);
		}
	}
	cout<<dp[n]<<endl;
	return 0;
}


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

int main() {
  ll n,m;
  cin >> n >> m;
  set<ll> pl;//正解した問題番号
  ll wa=0;
  map<int,int> wn;//問題番号、間違えた数
  for(ll i=0;i<m;i++){
    ll p;
    string s;
    cin >> p >> s;
    if(!pl.count(p)){
      if(s=="AC"){
        pl.insert(p);
        wa=wa+wn[p];
      }
      else
        wn[p]++;
    }
  }
  
  cout << pl.size() << " " << wa << endl;
}
  




Measured memory_bytes: 9600
CON_TYPE = 26
# 問題文の入力
D = gets.to_i
C = gets.split.map(&:to_i)
S = []
D.times do |d|
    S.push(Array.new(gets.split.map(&:to_i)))
end

# 回答の入力
T = []
D.times do |d|
    T.push (gets.to_i - 1)
end

# 得点計算
sat = 0
lasts = Array.new(CON_TYPE, -1)
D.times do |d|
    CON_TYPE.times do |type|
        if(T[d] == type)
            sat += S[d][type]
            lasts[type] = d
            # puts "#{type.to_s} held. sat+=#{S[d][type]}"
        else
            sat -= C[type] * (d - lasts[type])
            # puts "sat-=#{C[type] * (d - lasts[type])}"
        end
    end
    puts sat
end

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

#define NIL -1
#define MAX 100001
struct Node {int parent, left, right;};
struct Node tree[MAX];
int Depth[MAX];

void DepthCheck(int c, int d){
  Depth[c] = d; // 深さの更新
  if (tree[c].right != NIL) DepthCheck(tree[c].right, d);
  if (tree[c].left != NIL) DepthCheck(tree[c].left, d + 1);  //ノードが続いているときのみ深さの更新
}

void nodePrint(int u){
  cout << "node " << u << ": ";
  cout << "parent = " << tree[u].parent << ", ";
  cout << "depth = " << Depth[u] << ", ";

  if (tree[u].parent == NIL) cout << "root, ";
  else if (tree[u].left == NIL) cout << "leaf, ";
  else cout << "internal node, ";

  cout << "[";
  for (int i = 0, c = tree[u].left; c != NIL; i++, c = tree[c].right)
  {
      if (i > 0) cout << ", ";
      cout << c;
  }
  cout << "]" << endl;
}

int main(){
  int i, j, n, id, k, c, ri, r;
  cin >> n;
  for (i = 0; i < n; i++) {
    tree[i].parent = tree[i].left = tree[i].right = NIL; //初期値
  }
  for (i = 0; i < n; i++){
    cin >> id >> k;
    for (j = 0; j < k; j++){
      cin >> c;
      if (j == 0) tree[id].left = c;
      else tree[ri].right = c;
      ri = c;
      tree[c].parent = id;
    }
  }
  for (i = 0; i < n; i++){
    if (tree[i].parent == NIL) r = i;
  }
  for (i = 0; i < n; i++){
    if (tree[i].parent == NIL) ri = i;
  }
  // cout << "rの値" << r;
  DepthCheck(r, 0);
  for (i = 0; i < n; i++) nodePrint(i);

  return 0;
}



Measured memory_bytes: 7776
#include<iostream>
#include<string>
using namespace std;
int main(){

	int a=0;
	int b=0;
	int i=0;

        cin>>a>>b;

	if(a%3==0 || b%3==0 || (a+b)%3==0){
		cout<<"Possible";
	}else{
		cout<<"Impossible";
	}
}

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

typedef long long ll;
typedef vector<ll> vll;
typedef vector<int> vi;
const ll MOD = 1e9 + 7;
const int maxn = 1e6 + 10;

int dfs(string s, int n) {
    int res = 0;

    if (s != "") {
        if (stol(s) > n) {
            return 0;
        }
        if (s.find('3') != s.npos && s.find('5') != s.npos && s.find('7') != s.npos) {
            res = 1;
        }
    }

    for (char c : string("357")) {
        res += dfs(s + c, n);
    }
    return res;
}

int main() {
    int n;
    cin >> n;
    if (n < 357) {
        cout << 0 << endl;
    } else {
        cout << dfs("", n) << endl;
    }
    return 0;
}

static int speedUp = []() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    return 0;
}();


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()		//sort(all(vi S)) sort(all(string S))

typedef long long ll;
typedef vector<int> vi;
typedef set<int> seti;
typedef vector<string> vs;

const int MOD = 1e9+7;
const int INF = 1e9;

int N;
vector<int> b(110);
vector<int> ans;
int main() {
	cin>>N;
	rep(i,N){
		cin>>b[i];
		b[i]--;
	}
	int cnt = 0;
	for (int i = 0; i < N; ++i){//N回逆から操作を行う
		for (int j = N-1-i; j >= 0; j--){//0~N-1-iのうち、取れるもので最大のものを取ってくる
			if(b[j] == j){
				ans.push_back(b[j]+1);
				b.erase(b.begin() + j);
				cnt++;
				break;
			}
		}
	}
	if(cnt < N){
		cout<<-1<<endl;
		return 0;
	}
	for (int i = N-1; i >= 0; i--){
		cout<<ans[i]<<endl;
	}
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
class _0044
{
    public static void Main()
    {
        bool[] primJdg = new bool[50050];
        List<int> primNum = new List<int>();
        string str; int n, k;
        for (int i = 2; i < primJdg.Length; i++) primJdg[i] = true;
        for (int i = 2; i < primJdg.Length; i++) if (primJdg[i]) for (int j = 2; i * j < primJdg.Length; j++) primJdg[i * j] = false;
        for (int i = 2; i < primJdg.Length; i++) if (primJdg[i]) primNum.Add(i);
        while ((str = Console.ReadLine()) != null)
        {
            n = int.Parse(str); k = 0;
            while (primNum[k] < n) k++;
            if (primNum[k] == n) Console.WriteLine(primNum[k - 1] + " " + primNum[k + 1]);
            else Console.WriteLine(primNum[k - 1] + " " + primNum[k]);
        }
    }
}

Measured memory_bytes: 5760
sealed class State {
    object Lose: State()
    object Back: State()
    object Empty: State()
}
fun search(current: Int, turn: Int, state: Array<State>, memo: Array<DoubleArray>): Double {
    return when{
        current == memo.size && turn >= -1 -> 1.0
        turn < 0 -> 0.0
        current > memo.size -> search(memo.size - (current - memo.size), turn, state, memo)
        memo[current][turn] >= 0.0 -> memo[current][turn]
        else -> when(state[current]) {
            State.Lose -> ((1 .. 6).map{t -> search(current + t, turn - 2, state, memo)}.sum() / 6.0).also{memo[current][turn] = it}
            State.Back -> search(0, turn, state, memo)
            State.Empty ->  ((1 .. 6).map{t -> search(current + t, turn - 1, state, memo)}.sum() / 6.0).also{memo[current][turn] = it}
        }
    }
}
fun main(args: Array<String>?): Unit {
    while(true) {
        val (n, t, l, b) = readLine()!!.trim().split(' ').map(String::toInt)
        if (n == 0) return
        val memo = Array(n){DoubleArray(t){-1.0} }
        val state = Array(n){State.Empty as State}
        repeat(l){
            state[readLine()!!.toInt()] = State.Lose
        }
        repeat(b){
            state[readLine()!!.toInt()] = State.Back
        }
        println(
                String.format("%.10f", search(0, t - 1, state, memo))
        )
    }
}


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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()

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

    cout << 800 * n - n / 15 * 200 << endl;
    return 0;
}


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

typedef long long LL;
typedef vector<int> vi;
typedef vector<LL> vl;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;
typedef vector<pii> vpi;
typedef vector<pll> vpl;

#define fast ios_base::sync_with_stdio(0),cin.tie(0)
#define temp template<typename T>
#define debug(x) cerr<<"Line "<<__LINE__<<": "<<#x<<" = "<<x<<'\n'
#define itr(it,x) for(__typeof(x.begin()) it=x.begin();it!=x.end();it++)
#define rep(i,a,b) for(int i=a;i<=(int)b;i++)
#define repr(i,a,b) for(int i=a;i>=(int)b;i--)
#define cas(n) printf("Case %d:",(int)n)
#define mem(x,v) memset(x,v,sizeof(x))
#define read(x) freopen(x,"r",stdin)
#define write(x) freopen(x,"w",stdout)
#define all(x) x.begin(),x.end()
#define aut(x,v) for(auto &x:v)
#define ini(n) scanf("%d",&n)
#define inl(n) scanf("%lld",&n)
#define ind(n) scanf("%lf",&n)
#define ins(n) scanf("%s",n)
#define insn(n) scanf(" %[^\n]",n)
#define outi(n) printf("%d",(int)n)
#define outl(n) printf("%lld",(LL)n)
#define outd(n,p) printf("%.*lf",p,(double)n)
#define outs(n) printf("%s",n)
#define sz(x) (int)x.size()
#define nl printf("\n")
#define sp printf(" ")
#define pb push_back
#define mp make_pair
#define xx first
#define yy second

const int inf=0x3f3f3f3f;
const int mod=1000000007;
const int mx=5000000;
const LL  infL=0xf3f3f3f3f3f3f3f;
const double eps=1e-9;
const double pi=acos(-1.0);

int main()
{
    //read("in.txt"),write("out.txt");
    int a,b,c;
    ini(a),ini(b),ini(c);
    outi(b+min(a+b+1,c)),nl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define float double
#define endl "\n"
#define debug cout<<"Good uptill here"<<endl<<flush;
#define deb(x) cout<<#x<<":"<<x<<endl<<flush;

using namespace std;

const int inf = 1e17 + 7;
const int MOD = 1e7 + 9;

int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	//CODE FOR SPECIFIED INPUT AND OUTPUT
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int k,n;
	cin>>k>>n;
	int a[n+1];
	for(int i=0;i<n;i++) cin>>a[i];
	a[n] = a[0] + k;
	int maxi = 0;
	for(int i=1;i<n+1;i++){
		maxi = max(maxi,a[i]-a[i-1]);
	}
	cout<<(k-maxi)<<endl;
	return 0;
}



Measured memory_bytes: 1792
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm> // sort
#include <utility> // pair
#include <cfloat> // DBL_MAX

typedef long long ll;
using namespace std;

string oxs;
string ans;

bool cond(int idx, char sw, char ox){
  return ans[idx] == sw && ans[idx] == ox;
}

char inv(char c){
  if(c=='o') return 'x';
  return 'o';
}
char ox2sw(char c){
  if(c=='o') return 'S';
  return 'W';
}

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

  string oxs;
  cin >> oxs; cin.ignore();

  vector<string> inits(4);
  inits[0] = "oo"; inits[1] = "ox"; inits[2] = "xo"; inits[3] = "xx";

  string ans;
  bool flg=false;
  for(auto itr=inits.begin(); itr!=inits.end(); itr++){
    ans = *itr;
    for(int i=2; i<N; i++){ // fill
      if(ans[i-1] == oxs[i-1]){ // s-o or w-x
        ans.push_back(    ans[i-2]);
      } else {
        ans.push_back(inv(ans[i-2]));
      }
    }
    // cerr << ans << endl;

    // cntr?
    // oks:
    // 1ssss-oo, 2sssw-ox, 4ssws-xx, 3ssww-xo
    // 4swss-xx, 3swsw-xo, 1swws-oo, 2swww-ox
    // 3wsss-xo, 4wssw-xx, 2wsws-ox, 1wsww-oo
    // 2wwss-ox, 1wwsw-oo, 3wwws-xo, 4wwww-xx
    if((ans[N-1]=='o') ^ (ans[N-2]==ans[0])){ // if true, oxs[N-1] should be 'x'
      if(oxs[N-1] != 'x'){ continue; }
    } else {
      if(oxs[N-1] != 'o'){ continue; }
    }

    if((ans[  0]=='o') ^ (ans[N-1]==ans[1])){ // if true, oxs[  0] should 'x'
      if(oxs[0] != 'x'){ continue; }
    } else {
      if(oxs[0] != 'o'){ continue; }
    }

    flg = true;
    break;
  }

  // out
  if(flg){
    for(int i=0; i<ans.length(); i++){ ans[i] = ox2sw(ans[i]); }
    cout << ans << endl;
  } else {
    cout << -1 << endl;
  }
  return 0;
}


Measured memory_bytes: 776
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef long double ld;
const ll inf=1e9+7;
const ll mod=1e9+7;
//Range Minimum Query

ll linf=(1LL<<31)-1LL;
ll n;
vector<ll>RMQ(1<<21);
void init(ll n_){
    n=1;
    while(n<n_){
        n*=2;
    }
    rep(i,n*2-1){
        RMQ[i]=0;
    }
}
void update(ll k,ll a){
    k+=n-1;
    RMQ[k]=a;
    while(k>0){
        k--;
        k/=2;
        RMQ[k]=RMQ[2*k+1]|RMQ[2*k+2];
    }
}
//半開区間
ll query(ll a,ll b,ll k,ll l,ll r){
    if(r<=a||l>=b)return 0;
    if(l>=a&&r<=b)return RMQ[k];
    else{
        return query(a,b,k*2+1,l,(l+r)/2)|query(a,b,k*2+2,(l+r)/2,r);
    }
}
int main(){
    ll n_;cin>>n_;string s;
    cin>>s;
    ll q;cin>>q;
    init(n_);
    rep(i,n_){
        ll c=s[i]-'a';
        update(i,1<<c);
    }
    rep(i,q){
        ll a;cin>>a;
        if(a==1){
            ll k;char c;cin>>k>>c;
            k--;
            ll cc=c-'a';
            update(k,1<<cc);
        }else{
            ll l,r;cin>>l>>r;
            l--;r--;
            ll t=query(l,r+1,0,0,n);
            ll cnt=0;
            rep(i,26){
                if(t&(1<<i))cnt++;
            }
            cout<<cnt<<endl;
        }
    }
}

Measured memory_bytes: 17284