akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll inf = 1e9;
#define sz              3000005
#define Fast            ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

string s,p;

int solve(int n){

    queue < int > white;
    priority_queue< int >  red;

    for(int i=0; i<n; i++){
        if(s[i]=='R')red.push(i);
        else white.push(i);
    }
    int cnt=0;
    while(!red.empty() && !white.empty()){

        if(white.front()<red.top()){
            cnt++;
            red.pop();
            white.pop();
        }
        else{
            break;
        }
    }
    return cnt;
}

int main(){
    Fast;
    int a,b,c, i,j,k, n,m,t, cs=1;

    cin>>n>>s;
    cout<<solve(n)<<endl;

    return 0;
}


Measured memory_bytes: 4516
#include "bits/stdc++.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
//----------------------------------------------------------------

// int MOD = 998244353;
int MOD = 1000000007;
int dp[3010][3010][2] = {0};

//----------------------------------------------------------------
signed main(){
   
    int x,y;
	cin >> x >> y;
	int ans = 0;

	if(x == 1)ans += 300000;
	if(y == 1)ans += 300000;
	if(x == 2)ans += 200000;
	if(y == 2)ans += 200000;
	if(x == 3)ans += 100000;
	if(y == 3)ans += 100000;

	if(x == 1 && y == 1)ans += 400000;

	cout << ans << endl;
	


	
	return 0;
}

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

// g++ -std=c++14 code1.cpp
// sudo pip3 install --upgrade online-judge-tools
// rm -r -f test;oj dl https://code-festival-2018-quala.contest.atcoder.jp/tasks/code_festival_2018_quala_c
// rm -r -f test;oj dl https://ddcc2020-qual.contest.atcoder.jp/tasks/ddcc2020_qual_b
// rm -r -f test;oj dl https://abc145.contest.atcoder.jp/tasks/abc145_b

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

using namespace std; 
int main()
{
	long long int n,sum=0;
	cin>>n;
	vector<long long int>city(n+1);
	vector<long long int>hero(n);
	for(int i=0;i<n+1;i++)
	{
		cin>>city[i];
	}
	for(int i=0;i<n;i++)
	{
		cin>>hero[i];
	}
	
	for(int i=0;i<n;i++)
	{
	//	cout<<"Heroe "<<i+1<<endl;
		
		if(hero[i]>=city[i])
		{
			if(city[i]>0)
			{
			
				sum += city[i];
				hero[i]-=city[i];
				city[i]=0;
			}
			if(city[i+1]>0&&hero[i]>=city[i+1])
			{
				sum+= city[i+1];
				hero[i]-=city[i+1];
				city[i+1]=0;
			}
			else if(city[i+1]>0&&hero[i]<city[i+1]&&hero[i]>0)
			{
				sum+=hero[i];
				
				city[i+1]-=hero[i];
				hero[i]=0;
			}
		}
		
		else if(hero[i]<city[i]&&city[i]>0&&hero[i]>0)
		{
			sum+=hero[i];
			city[i]-=hero[i];
			hero[i]=0;			
		}
	//	cout<<"Heroe t; "<<hero[i]<<endl;
			
	}
	cout<<sum<<endl;
	
	return 0;		
}




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

#define LL long long
#define RG register

using namespace std;
template<class T> inline void read(T &x) {
	x = 0; RG char c = getchar(); bool f = 0;
	while (c != '-' && (c < '0' || c > '9')) c = getchar(); if (c == '-') c = getchar(), f = 1;
	while (c >= '0' && c <= '9') x = x*10+c-48, c = getchar();
	x = f ? -x : x;
	return ;
}
template<class T> inline void write(T x) {
	if (!x) {putchar(48);return ;}
	if (x < 0) x = -x, putchar('-');
	int len = -1, z[20]; while (x > 0) z[++len] = x%10, x /= 10;
	for (RG int i = len; i >= 0; i--) putchar(z[i]+48);return ;
}
const int N = 3e5 + 10;
int a[N], n, m, s[N], b[N];
bool check(int x, int k) {
	int p = lower_bound(a + 1, a + 1 + m, x) - a;
	return s[p - 1] / x + m - p + 1 >= k;
}
int main() {
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);
	read(n);
	for (int i = 1; i <= n; i++) read(b[i]);
	sort(b + 1, b + 1 + n);
	for (int i = 1; i <= n; i++)
		if (b[i] != b[i - 1]) a[++m] = 1;
		else a[m]++;
	sort(a + 1, a + 1 + m);
	for (int i = 1; i <= m; i++) s[i] = s[i - 1] + a[i];
	for (int k = 1; k <= n; k++) {
		int l = 1, r = s[m] / k;
		while (l <= r) {
			int mid = (l + r) >> 1;
			if (check(mid, k)) l = mid + 1;
			else r = mid - 1;
		}
		printf("%d\n", l - 1);
	}
	return 0;
}


Measured memory_bytes: 4224
import Control.Applicative ((<$>), (<*>))
import Control.Monad
import Data.List
import Data.Array.Unboxed
import Test.HUnit

main :: IO ()
-- main = runTestTT (TestList tests) >> return ()
main = do
  [h,w] <- getl $ split toInt
  when (h /= 0 || w /= 0) $ do
    xs <- replicateM h getLine
    print $ solve h w xs
    main
    
solve :: Int -> Int -> [String] -> Int
solve h w xs = fst $ foldl f (0,iarr) [(i,j) | i <- [1..h], j <- [1..w]]
  where
    iarr = listArray ((1,1),(h,w)) $ concat xs :: UArray (Int,Int) Char
    f (cnt, arr) p
      | arr ! p == ' ' = (cnt, arr)
      | otherwise = (cnt + 1, clrChar arr h w (arr ! p) p)

clrChar :: UArray (Int,Int) Char -> Int -> Int -> Char -> (Int, Int) -> UArray (Int,Int) Char
clrChar arr h w c (i,j)
  | arr ! (i,j) /= c = arr
  | otherwise = foldl f (arr // [((i,j),' ')]) lst
  where
    lst = [(u,v) | (u,v) <- [(i+1,j),(i-1,j),(i,j+1),(i,j-1)], u >= 1, u <= h, v >= 1, v <= w]
    f a p = clrChar a h w c p

toInt :: String -> Int
toInt s = read s

split :: (String -> a) -> String -> [a]
split f = map f . words

getl :: (String -> a) -> IO a
getl f = f <$> getLine

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

using namespace std;

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

    int a = N.length() - 1;

    if (N[a] == '2' || N[a] == '4' || N[a] == '5' || N[a] == '7' || N[a] == '9')
    {
        cout << "hon";
    }

    if (N[a] == '0' || N[a] == '1' || N[a] == '6' || N[a] == '8')
    {
        cout << "pon";
    }

    if (N[a] == '3')
    {
        cout << "bon";
    }
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define f first
#define s second
#define pb push_back
#define eb emplace_back
#define mk make_pair
#define mt make_tuple
#define MOD 1000000007
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
#define all(x) x.begin(), x.end()
#define vi vector<int>
#define vl vector <long long int>
#define pii pair <int,int>
#define pll pair <long long int, long long int>
#define vpii vector< pair<int,int> >
#define vpll vector < pair <long long int,long long int> >
#define boost ios::sync_with_stdio(false); cin.tie(0)
using namespace std;
const int inf = 1e9 + 5;
const ll inf64 = 1e18 + 5;
int main()
{
	boost;
	int n, k, i;
	cin >> n >> k;
	bool ok[n];
	memset(ok, 0, sizeof ok);
	
	fo(i, 0, k) {
		int d;
		cin >> d;
		while(d--) {
			int x;
			cin >> x;
			ok[x - 1] = 1;
		}
	}
	int ans = 0;
	fo(i, 0, n)
	ans += (!ok[i]);
	cout << ans;
}


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

int main() {
  int N, K, X, Y, ans;
  cin  >> N >> K >> X >> Y;
  ans = 0;
  if(N > K){
    ans = K * X + (N - K) * Y;
  }
  else if(N <= K){
    ans = N * X;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
    int H = 1, W = 1, i, j;
    
    while(1){
        scanf("%d %d\n", &H, &W);
        if(H == 0 && W == 0){
            break;
        }
        
        for(i = 1; i <= H; i++){
            for(j = 1; j <= W; j++){
                
                if(i % 2 == 1){
                    if(j % 2 == 1){
                        printf("#");
                    }else{
                        printf(".");
                    }
                }
                
                if(i % 2 == 0){
                    if(j % 2 == 1){
                        printf(".");
                    }else{
                        printf("#");
                    }
                }
            }
            printf("\n");
        }
        
        printf("\n");
    }
    
    return 0;
}


Measured memory_bytes: 2032
#include <bits/stdc++.h> 
#define FOR(i,a,b) for(int i=(a);i<=(b);++i) 
#define RFOR(i,a,b) for(int i=(a);i>=(b);--i) 
#define REP(i,n) for(int i=0;i<(n);++i)
#define RREP(i,n) for(int i=(n);i>0;--i)
#define CI cin>> 
#define CO cout<<
#define EN <<endl 
#define all(x) (x).begin(),(x).end() 
#define asn ans
using namespace std;
template <typename T> istream& operator >> (istream& is, vector<T>& vec) { for (T& x : vec) is >> x; 	return is; }
using ll = long long;

int main() {
	string a, b, c; CI a >> b >> c;
	CO a[0] << b[1] << c[2] EN;
	return 0;
}

Measured memory_bytes: 256
# WIP (WA: 1_01.txt, 1_06.txt, 1_07.txt)
import sys
input_s = sys.stdin.readline

N, K = map(int, input_s().split())
xxx = list(map(int, input_s().split()))

min_elapsed_time = 10**10
for left, right in zip(xxx, xxx[K - 1:]):
    elapsed_time = right - left + min(abs(left), abs(right))
    """
    right - left : a section distance
    min(abs(left), abs(right)) : a start point to move the section
    """
    min_elapsed_time = \
        elapsed_time if elapsed_time < min_elapsed_time else min_elapsed_time

print(min_elapsed_time)


Measured memory_bytes: 14168
h, w, m = map(int, input().split())
a = [list(map(lambda x: int(x) - 1, input().split())) for _ in range(m)]
mh = [0 for i in range(h)]
mw = [0 for j in range(w)]

for i, j in a:
    mh[i] += 1
    mw[j] += 1 

hmax = max(mh)
wmax = max(mw)
ans = hmax + wmax

flag = mh.count(hmax) * mw.count(wmax)
for i,j in a:
    if mh[i] == hmax and mw[j] == wmax:
        flag -= 1

if flag == 0:
    print(ans - 1)
else:
    print(ans)

Measured memory_bytes: 68512
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
const int N=2005;
int Head[N],Next[N<<1],Adj[N<<1],tot=0,dis[N];
int u[N],v[N];
inline void addedge(int u,int v){
	Next[++tot]=Head[u];
	Head[u]=tot;
	Adj[tot]=v;
	Next[++tot]=Head[v];
	Head[v]=tot;
	Adj[tot]=u;
}
inline void dfs(int x,int f){
	for (int e=Head[x];e;e=Next[e])
		if (Adj[e]!=f) dis[Adj[e]]=dis[x]+1,dfs(Adj[e],x);
}
int main (){
	int n,k;
	scanf ("%d%d",&n,&k);
	for (int i=1;i<n;i++){
		scanf ("%d%d",&u[i],&v[i]);
		addedge(u[i],v[i]);
	}
	int ans=n;
	if (k&1){
		for (int i=1;i<n;i++){
			dis[u[i]]=dis[v[i]]=0;dfs(u[i],v[i]),dfs(v[i],u[i]);
			int cnt=0;
			for (int j=1;j<=n;j++) if (dis[j]>(k/2)) cnt++;
			ans=min(ans,cnt);
		}
	}else{
		for (int i=1;i<=n;i++){
			dis[i]=0;int cnt=0;dfs(i,0);
			for (int j=1;j<=n;j++) if (dis[j]>(k/2)) cnt++;
			ans=min(ans,cnt);
		}
	}
	printf ("%d",ans);
	return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define ll long long int 
#define mod 1000000007
#define se second
#define fi first
#define endl "\n"
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	ll n,k,c;
	cin>>n>>k>>c;
	string s;
	cin>>s;
	vector<ll> vl,vr;
	ll x,y,z;
	x=0;
	y=0;
	while(x!=k)
	{
		if(s[y]=='o')
		{
			x++;
			vl.push_back(y+1);
			y+=c+1;
		}
		else 
		y++;
	}
	x=0;
	y=n-1;
	while(x!=k)
	{
		if(s[y]=='o')
		{
			x++;
			vr.push_back(y+1);
			y-=c;
			y--;
		}
		else 
		y--;
	}
	reverse(vr.begin(),vr.end());
	for(int a=0;a<k;a++)
	{
		if(vl[a]==vr[a])
		{
			cout<<vl[a]<<endl;
		}
	}
	return 0;
}


Measured memory_bytes: 5128
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define PI 				acos(-1)
#define mp				make_pair
#define pb				push_back
#define all(a)			(a).begin(), (a).end()
#define sz(a)			a.size()
#define srt(a)			sort(all(a))
#define mem(a, h)		memset(a, (h), sizeof(a))
#define f 				first
#define s 				second
#define MOD1			998244353
#define fore(i, b, e)	for(int i = b; i < e; i++)
#define forg(i, b, e, m)	for(int i = b; i < e; i+=m)
int in(){int r=0,c;for(c=getchar();c<=32;c=getchar());if(c=='-') return -in();for(;c>32;r=(r<<1)+(r<<3)+c-'0',c=getchar());return r;}

using namespace std;
using namespace __gnu_pbds;

typedef long long 		ll;
typedef unsigned long long 		ull;
typedef pair<int, int>  ii;
typedef vector<int>     vi;
typedef vector<ii>      vii;
typedef vector<ll>      vll;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
const int tam = 100010;
const int MOD = 1e9+7;
const double EPS = 1e-9;

int main()
{
	ios::sync_with_stdio(0); cin.tie(0);
	//freopen("qwe.txt", "r", stdin);
	//freopen("asd.txt", "w", stdout);
	int n, k;
	ll res = 0;
	cin>>n>>k;
	fore(i, 1, n + 1)
	{
		res += (n / i) * max(0, i - k) + max(0, n % i + 1 - k);
	}
	cout<<res - (k == 0? n:0)<<'\n';
	return 0;
}

// read the question correctly (is y a vowel? what are the exact constraints?)
// look out for SPECIAL CASES (n=1?) and overflow (ll vs int?) ARRAY OUT OF BOUNDSS2

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

int main() {
    string S; cin >> S;
    int C;
    if (S == "SUN") C = 7;
    if (S == "MON") C = 6;
    if (S == "TUE") C = 5;
    if (S == "WED") C = 4;
    if (S == "THU") C = 3;
    if (S == "FRI") C = 2;
    if (S == "SAT") C = 1;
    cout << C << endl;

}


Measured memory_bytes: 256
import java.util.Scanner;
class Main
{
    public static void main(String args[])
    {
	Scanner scan=new Scanner(System.in);
	while(true)
	    {
		int t,n,count=0;
		t=scan.nextInt();
		if(t==0)break;
		n=scan.nextInt();
		for(int i=0;i<n;i++)
		    {
			int s,f;
			s=scan.nextInt();
			f=scan.nextInt();
			for(int j=s;j<f;j++)
			    {
				count++;
			    }
		    }
		if(count>=t)System.out.println("OK");
		else System.out.println(t-count);
	    }
    }
}

Measured memory_bytes: 23584
const fs = require('fs');
const [h, w, k, ...m] = fs.readFileSync('/dev/stdin', 'utf8').split(/\s/);

function solve(m, x=0, y=0, f) {
  if (m.length === 0 || m[0].length === 0) {
    return 0;
  }
  const n = m.join('').replace(/\./g, '').length;
  let a = 0;
  if (n == k) {
    a++;
  }
  if (n < k) {
	  return a;
  }
  if (!f) {
    for (let i = y; i < m.length; i++) {
      a += solve([...m.slice(0, i), ...m.slice(i + 1)], x, i < y ? y : i);
    }
  }
  for (let i = x; i < m[0].length; i++) {
    a += solve(m.map(l => l.slice(0, i) + l.slice(i + 1)), i < x ? x : i, y, true);
  }
  return a;
}

console.log(solve(m.slice(0, h).map(l => l.slice(0, w))));

Measured memory_bytes: 33700
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N, K, cnt = 0;
    cin >> N >> K;
    vector<int> vec(N);
    for(int i = 0; i < vec.size(); i++){
        cin >> vec[i];
        if(vec[i] >= K){
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 640
//#define _GLIBCXX_DEBUG
#include "bits/stdc++.h"

using namespace std;

//------------------------------- Libraries --------------------------------//

//------------------------------- Type Names -------------------------------//

using i64 = int_fast64_t;

using seika = string;
//akari : 1D, yukari : 2D, maki : 3D vector
template <class kizuna>
using akari = vector<kizuna>;
template <class yuzuki>
using yukari = akari<akari<yuzuki>>;
template <class tsurumaki>
using maki = akari<yukari<tsurumaki>>;
//akane : ascending order, aoi : decending order
template <class kotonoha>
using akane = priority_queue<kotonoha, akari<kotonoha>, greater<kotonoha>>;
template <class kotonoha>
using aoi = priority_queue<kotonoha>;

//------------------------------- Dubug Functions ---------------------------//
inline void print()
{
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest)
{
    cout << first << ' ';
    print(rest...);
}
//------------------------------- Solver ------------------------------------//

void solve()
{
    int n, m;
    cin >> n >> m;
    yukari<pair<int, int>> g(n);
    for (int i = 0; i < m; i++)
    {
        int s, t;
        cin >> s >> t;
        s--, t--;
        g[s].push_back(make_pair(t, 1));
    }
    akari<double> dp(n, n + 1);
    akari<int> heavy(n), vst(n);
    auto calc = [&](auto &&calc, akari<double> &dp, int s = 0) -> double {
        if (vst[s])
        {
            return dp[s];
        }
        double res = 0, maxi = 0;
        int cnt = 0;
        vst[s] = 1;
        for (auto np : g[s])
        {
            if (!np.second)
            {
                continue;
            }
            cnt++;
            double w = calc(calc, dp, np.first) + 1;
            if (maxi < w)
            {
                maxi = w;
                heavy[s] = np.first;
            }
            res += w;
        }
        if (cnt)
        {
            res /= cnt;
        }
        else if (s != n - 1)
        {
            res = n + 1;
        }
        return dp[s] = res;
    };
    double ans = calc(calc, dp);
    for (int s = 0; s < n - 1; s++)
    {
        akari<double> dp2(n, n + 1);
        fill(vst.begin(), vst.end(), 0);
        for (auto &p : g[s])
        {
            if (p.first == heavy[s])
            {
                p.second = 0;
                ans = min(ans, calc(calc, dp2));
                p.second = 1;
                break;
            }
        }
    }
    cout << setprecision(15) << ans << endl;
}

int main()
{
    solve();
    return 0;
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using edge = pair<ll, P>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
using Graph = vector<vector<ll>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    int N, M;
    cin >> N >> M;
    Graph graph(N);
    vector<int> in_cnt(N, 0);
    rep(i, N + M - 1) {
        int a, b;
        cin >> a >> b;
        a --;
        b --;
        graph[a].push_back(b);
        in_cnt[b] ++;
    }

    queue<int> que;
    rep(i, N) {
        if (in_cnt[i] == 0) {
            que.push(i);
        }
    }
    vector<int> sorted(N, -1);
    sorted[que.front()] = 0;
    while (!que.empty()) {
        int q = que.front(); que.pop();
        for (ll v : graph[q]) {
            in_cnt[v] --;
            if (in_cnt[v] == 0) {
                sorted[v] =  q + 1;
                que.push(v);
            }
        }
    }
    rep(i, N) {
        cout << sorted[i] << endl;
    }


}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}


Measured memory_bytes: 7040
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
  int n,a[1005];
  cin>>n;
  for(int i=0;i<n;i++)
  {
    cin>>a[i];
  }
  int q;
  cin>>q;
  while(q--)
  {
    int b,m,e;
    cin>>b>>m>>e;
    swap_ranges(a+b,a+m,a+e);
  }
  for(int i=0;i<n-1;i++)
  {
    cout<<a[i]<<" ";
  }
  cout<<a[n-1]<<endl;
}



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

using namespace std;

using int64 = long long;
const int mod = 1e9 + 7;
const int inf = (1 << 30) - 1;
const int64 infll = (1LL << 61) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;

template< typename T >
ostream &operator<<(ostream &os, const vector< T > &v) {
  for(int i = 0; i < (int) v.size(); i++) {
    os << v[i] << (i + 1 != v.size() ? " " : "");
  }
  return os;
}

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}

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); }

template< typename T = int64 >
vector< T > make_v(size_t a) {
  return vector< T >(a);
}

template< typename T, typename... Ts >
auto make_v(size_t a, Ts... ts) {
  return vector< decltype(make_v< T >(ts...)) >(a, make_v< T >(ts...));
}

template< typename T, typename V >
typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) {
  t = v;
}

template< typename T, typename V >
typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) {
  for(auto &e : t) fill_v(e, v);
}

using pi = pair< int, int >;

int main() {
  int N;
  cin >> N;
  vector< int > B(N);
  cin >> B;
  for(auto &p : B) --p;

  vector< int > ans;
  for(int i = N - 1; i >= 0; i--) {
    int match = -1;
    for(int j = B.size() - 1; j >= 0; j--) {
      if(B[j] == j) {
        match = j;
        break;
      }
    }
    if(match == -1 || B[match] > i) {
      cout << -1 << endl;
      return 0;
    }
    ans.emplace_back(match);
    vector< int > t;
    for(int j = 0; j < B.size(); j++) {
      if(j == match) continue;
      t.emplace_back(B[j]);
    }
    B = t;
  }


  reverse(begin(ans), end(ans));
  for(auto &p : ans) cout << p + 1 << endl;
}





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

typedef long long ll;

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

const ll INF = (1ll << 60);
const ll MOD = (ll)1e9 + 7;

signed main()
{
  int n, k;
  cin >> n >> k;
  vector<int> p;
  for (int i = 0; i < n; i++)
  {
    int tmp;
    cin >> tmp;
    p.push_back(tmp);
  }
  map<int, double> m;
  for (int i = 1; i <= 1000; i++)
    m[i] = (i + 1) / 2.0;
  double mx = 0;
  for (int j = 0; j < k; j++)
  {
    mx += m[p[j]];
  }
  double prev = mx;
  for (int j = 1; j + k - 1 < n; j++)
  {
    double now = prev - m[p[j - 1]] + m[p[j + k - 1]];
    mx = max(now, mx);
    prev = now;
  }
  printf("%.10f\n", mx);
}

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

int main() {
  char l;
  cin >> l;
  
  if (l=='a' || l=='e' || l=='i' || l=='o' || l=='u') {
    cout << "vowel" << endl;
  }
  
  else {
    cout << "consonant" << endl;
  }
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int ans = 1;
        if(n < 2) ans = 1;
        else if(n < 4) ans = 2;
        else if(n < 8) ans = 4;
        else if(n < 16) ans = 8;
        else if(n < 32) ans = 16;
        else if(n < 64) ans = 32;
        else ans = 64;
        System.out.println(ans);
    }
}


Measured memory_bytes: 35796
#include <bits/stdc++.h>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
#define pi 3.14159265358979323846264338327950L
using namespace std;

int main() {
  string N;
  cin >> N;
  int64_t n=N.size(), k=0;
  for (int64_t i=0; i<n; i++) {
    if (N[i]=='1') {
      k=k+1;
    }
    else if (N[i]=='2') {
      k=k+2;
    }
    else if (N[i]=='3') {
      k=k+3;
    }
    else if (N[i]=='4') {
      k=k+4;
    }
    else if (N[i]=='5') {
      k=k+5;
    }
    else if (N[i]=='6') {
      k=k+6;
    }
    else if (N[i]=='7') {
      k=k+7;
    }
    else if (N[i]=='8') {
      k=k+8;
    }
    else {
      k=k+9;
    }
    k=k%9;
  }
  if (k==0) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3720
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define sz(x) ((long long)(x).size())
#define all(x)  x.begin(),x.end()
#define rall(x) (x).rbegin(), (x).rend()
#define endl "\n"
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define leastsigbit(x)     __builtin_ffs(x)
#define mod             1000000007
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define pii pair<ll,ll>
#define vpii vector<pii>
#define tt ll tt;cin >> tt;while(tt--)
#define  fio ios::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define D1(x) { cerr << " [" << #x << ": " << x << "]\n"; }
#define D2(x) { cerr << " [" << #x << ": "; for(auto it:x) cerr << it << " "; cerr << "]\n";}
const double PI = acos(-1);
ll power(ll a,ll b,ll m=mod){ ll ans=1; a=a%m;  while(b>0) {  if(b&1)  ans=(1ll*a*ans)%m; b>>=1;a=(1ll*a*a)%m;}return ans;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll lcm( ll x, ll y) { return (x*y)/gcd(x,y);}
bool isprime(ll n){if(n < 2) return 0; ll i = 2; while(i*i <= n){if(n%i == 0) return 0; i++;} return 1;}
bool isPowerOfTwo(int x)
{
    /* First x in the below expression is for the case when x is 0 */
    return x && (!(x&(x-1)));
}
void offset(vector<int>&a,int x) {
    for(int i = 0; i < sz(a);i++) {
        a[i] = x;
    }
}
struct cmp {
    bool operator() (const pair<int,int>& lhs, const pair<int,int>& rhs) const {
        return lhs.ff * rhs.ss < lhs.ss * rhs.ff;
    }
//for map<pii,int>
};


// auto cmp = [](pair<int,int>a,pair<int,int>b) {if(a.first==b.first)return a.second>b.second;
//      else return a.first > b.first;
//  };
//  multiset<pair<int,int>,decltype(cmp)>fc(cmp);
double distform(int x, int y, int z, int w) {//(x1,y1,x2,y2)
    return sqrt(1. * pow(x-z,2) + 1. * pow(y-w,2));
}
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
    //unordered_map<long long, int, custom_hash> safe_map;
};

const int MAXN = 2e5+ 10;

#define int long long
bool cmps(pair<int,int>p1,pair<int,int>p2) {
    return p1.ss > p2.ss;
}
int32_t main() {
    fio
    string s;
    cin >> s;
    int ans = 0;
    int cnt = 0;
    for (int i = 0; i < sz(s); ++i) {
        if(s[i] == 'R') {
            cnt++;
            ans=max(ans,cnt);
        }
        else {
            cnt = 0;
        }
    }
    cout << ans << endl;

    cerr <<endl <<"[ Time : " << (float)clock() / CLOCKS_PER_SEC << " secs ]" << endl;


}






Measured memory_bytes: 3824
n = gets.to_i
s = (1..n).map{gets.split.map(&:to_i)}
ans = []
101.times{|x|101.times{|y|
    sd = s.sort{|a, b|
        aa = (a[0] - x).abs + (a[1] - y).abs
        bb = (b[0] - x).abs + (b[1] - y).abs
        aa <=> bb
    }
    h = (sd[0][0] - x).abs + (sd[0][1] - y).abs + sd[0][2]
    ans = [x, y, h] if s.select{|v|
        v[2] != 0 || (v[0] - x).abs + (v[1] - y).abs <= h
    }.select{|v|
        (v[0] - x).abs + (v[1] - y).abs + v[2] != h}.length == 0
    }}
puts ans.join(" ")


Measured memory_bytes: 4500
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// Welcome to my source code!

int main() {
    int n;
    cin >> n;
    int p[n], q[n], t[n];
    for (int i = 0; i < n; i++) cin >> p[i];
    for (int i = 0; i < n; i++) {
        cin >> q[i];
        t[i] = i + 1;
    }
    int a, b, cnt = 0;
    do {
        cnt++;
        bool flag = true;
        for (int i = 0; i < n; i++) {
            if (p[i] != t[i]) flag = false;
        }
        if (flag) a = cnt;
        flag = true;
        for (int i = 0; i < n; i++) {
            if (q[i] != t[i]) flag = false;
        }
        if (flag) b = cnt;
    } while (next_permutation(t, t+n));
    cout << abs(a - b) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <time.h>
#include <stdio.h>
#include <vector>
#define int long long
#define endre getchar();getchar();return 0
int inf = 1000000000;
using namespace std;
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
int mypow(int x, int y) {
	if (y == 0)return 1;
	if (y % 2)return mypow(x, y - 1)*x;
	else return mypow(x, y / 2)*mypow(x, y / 2);
}
int Max(int x, int y) {
	if (x > y)return x;
	else return y;
}
int Min(int x, int y) {
	if (x < y)return x;
	else return y;
}
int kai(int x) {
	int cnt = 1;
	if (x == 0)return 1;
	cnt = kai(x - 1);
	return x * cnt;
}
int prime(int n) {
	for (int i = 2; i*i <= n; i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
void prime_factor(int n) {
	int cnt = 1;
	map<int, int>res;
	int m = n;
	for (int i = 2; i <= n; i++) {
		if (prime(i)) {
			while (m%i == 0) {
				++res[i];
				m /= i;
			}
		}
	}
	cout << n << ":" << endl;
	for (int i = 2; i <= n; i++) {
		if (res[i]) {
			cout << i << " " << res[i] << endl;
		}
	}
	cout << endl;
}
/*Library End!*/

int a, b, mea, meb, k;
signed main() {
	cin >> a >> b >> k;
	mea = a, meb = b;
	for (int i = 0; i < k; i++) {
		if (i % 2 == 0) {
			if (a % 2)a--;
			a /= 2;
			b += a;
		}
		else {
			if (b % 2)b--;
			b /= 2;
			a += b;
		}
	}
	cout << a << " " << b << endl;
	endre;
}


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


using namespace std;
 
int main(){
  
  int N,K;

  cin >> N >> K;
  long long int ans = K;

  for(int i = 0; i < N - 1; i++){
      ans *= K - 1;
  }

  cout << ans;
        return 0;

}


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

int main (void){
	long long int power = 1;
	int n;
	int cnt = 1;

	scanf("%d", &n);
	while(cnt <= n){
		power = (power * cnt)%1000000007;
		cnt++;
	}

	printf("%d\n", (int)power);


return 0;
}

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

using namespace std;

typedef pair<int, int> data_t;

int main() {
  int res=0;
  vector<data_t> a(5);
  for(int i=0;i<5;i++){
    cin >> a[i].second;
    a[i].first=a[i].second%10;
    if(a[i].first==0)a[i].first=10;
    res+=a[i].second-a[i].first;
  }
  int j = 0;
  sort(a.begin(),a.end());
  cout << res+40+a[0].first << endl;
}


Measured memory_bytes: 256
import java.io.*;

public class Main{
public static void main(String[] args){
try{
 BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
 StringBuilder sb = new StringBuilder();

	while(true){
	 String[] str = br.readLine().split(" ");
	 int H = Integer.parseInt(str [0]);
	 int W = Integer.parseInt(str [1]);

		if(H == 0 || W == 0){
		 break;
		}else{
			for(int i = 0; i < H; i++){
			 	if(i == 0 || i == H-1){
					for(int n = 0; n < W; n++){
				 	 sb.append("#");
					}
				}else{
				sb.append("#");
					for(int j = 1; j < W-1; j++){
					 sb.append(".");
					}
				sb.append("#");
				}
			 sb.append("\n");
			}
		}
	sb.append("\n");
	}
System.out.print(sb);

}catch(IOException e){
System.out.println(e);
}
}
}

Measured memory_bytes: 20460
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;

public class Main {
	
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		
		int n = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		char[] s = sc.next().toCharArray();
		
		int parti = 0;
		int forei = 0;
		
		for (int i = 0; i < n; i++) {
			switch (s[i]) {
				case 'a':
					if (parti < a + b) {
						parti++;
						out.println("Yes");
					} else {
						out.println("No");
					}
					break;
				case 'b':
					forei++;
					if (parti < a + b && forei <= b) {
						parti++;
						out.println("Yes");
					} else {
						out.println("No");
					}
					break;
				case 'c':
					out.println("No");
					break;
			}
		}
		
		out.flush();
	}
	
}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;
	
	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}
	
	private byte readByte() {
		if (hasNextByte()) {
			return buffer[ptr++];
		} else {
			return -1;
		}
	}
	
	private boolean isPrintableChar(int c) {
		return '!' <= c && c <= '~';
	}
	
	private void skipUnprintable() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
			ptr++;
		}
	}
	
	public boolean hasNext() {
		skipUnprintable();
		return hasNextByte();
	}
	
	public String next() {
		if (!hasNext()) {
			throw new NoSuchElementException();
		}
		StringBuilder sb = new StringBuilder();
		byte b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}
	
	public int nextInt() {
		if (!hasNext()) {
			throw new NoSuchElementException();
		}
		int n = 0;
		boolean minus = false;
		byte b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}
}

Measured memory_bytes: 12324
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define IINF 10e8
#define INF 10000000000000
#define MOD 1000000007
#define mod 1000000007
#define REP(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define REPE(i, a, n) for (ll i = a; i <= (ll)(n); i++)
#define rep(i,n)for(ll i=0;i<(n);i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair<int,int>Pin;
typedef pair<ll,ll>Pll;
template<class T> using V=vector<T>;
long long GCD(long long a, long long b) {return b?GCD(b,a%b):a;}
long long LCM(long long a, long long b) {return a/GCD(a,b)*b;}
int dx[4]={-1,0,1,0};
int dy[4]={0,-1,0,1};
int ddx[8]={-1,0,1,0,1,1,-1,-1};
int ddy[8]={0,-1,0,1,1,-1,1,-1};
ll cmp(pair<ll,ll>a,pair<ll,ll> b){
        if(a.se!=b.se)
        return a.se<b.se;
        else
        return a.fi<b.fi;
}
//----------------------------------------------------------------------

//----------------------------------------------------------------------
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------  
    //ll begin_time=clock();
    //-------------------------------
    ll n,q;cin>>n>>q;
    list<ll>a[1010];
    while(q--){
        int c;cin>>c;
        if(c==0){
            ll t,x;cin>>t>>x;
            a[t].insert(a[t].end(),x);
        }
        else if(c==1){
            ll t;cin>>t;
            for(auto it=a[t].begin();it!=a[t].end();it++){
                if(it!=a[t].begin())cout<<" "<<*it;
                else cout<<*it;
            }
            cout<<endl;
        }
        else{
            ll s,t;cin>>s>>t;
            a[t].splice(a[t].end(),a[s]);
        }
    }
    //-------------------------------  
    //ll end_time=clock();cout<<"time="<<end_time-begin_time<<"ms"<<endl;
    //-------------------------------
    return 0;
}
//----------------------------------------------------------------------













































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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

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

#define FF first
#define SS second

template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class T>
istream& operator>>(istream& is, vector<T>& xs){
  for(auto& x: xs)
	is >> x;
  return is;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
ostream& operator<<(ostream& os, const vector<T>& xs){
  for(unsigned int i=0;i<xs.size();++i)
	os << (i?" ":"") << xs[i];
  return os;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}
void debug(istringstream&){}
template <char sep=',', class Head, class... Tail>
void debug(istringstream& iss, Head&& head, Tail&&... tail)
{
  string name;
  getline(iss, name, ',');
  cerr << sep << name << "=" << head;
  debug(iss, forward<Tail>(tail)...);
}
#define DEBUG(...) \
  do{ \
    istringstream ss(#__VA_ARGS__); \
    debug<' '>(ss, __VA_ARGS__); \
    cerr<<endl; \
  }while(0)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

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

  int D;
  cin >> D;

  cout << "Christmas";
  REP(i,25-D) cout << " Eve";
  cout << endl;

  return 0;
}


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

using namespace std;

#define X first
#define Y second
#define eps  1e-5
#define gcd __gcd
#define pb push_back
#define PI acos(-1.0)
#define lowbit(x) (x)&(-x)
#define bug printf("!!!!!\n");
#define mem(x,y) memset(x,y,sizeof(x))

typedef long long LL;
typedef long double LD;
typedef pair<int,int> pii;
typedef unsigned long long uLL;

const int maxn = 1e5+7;
const int INF  = 1<<30;
const int mod  = 1e9+7;

int s[maxn];

void solve(){
    int n,tmp = 0,ans = 0;
    cin>>n;
    for(int i=1;i<=n;i++)cin>>s[i];
    for(int i=1;i<n;i++){
        if(s[i] >= s[i+1]){
            ++tmp;
        }else{
            ans = max(ans,tmp);
            tmp = 0;
        }
    }
    ans = max(ans,tmp);
    cout<<ans<<endl;
    return;
}

int main()
{
#ifndef ONLINE_JUDGE
  //  freopen("in.txt","r",stdin);
#endif
//    freopen("out.txt","w",stdout);
//    ios::sync_with_stdio(false);
    int t = 1;
    //scanf("%d",&t);
    while(t--){
    //    printf("Case %d: ",cas++);
        solve();
    }
#ifndef ONLINE_JUDGE
  //  printf("%.10f\n",1.0*clock()/CLOCKS_PER_SEC);
#endif
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <array>
#include <string>
#include <sstream>


template<typename T = int, int N = 1000>
class Stack {
public:
    Stack():pos(0)
    {};
    T push(T val){
        if(check_capacity()) {
            ary[pos++] = val;
            return pos;
        }
        else {
            std::cout << "Cap over" << std::endl;
            exit(-1);
        }
    }
    T pop() {
        return ary[--pos];
    };

private:
    bool check_capacity() {
        return (pos < N);
    }
//Attributes
    std::array<T, N> ary;
    T pos;
};

int main(int argc, char const* argv[])
{
    Stack<int, 1000> stack;
    std::string str;
    std::getline(std::cin, str, '\n');
    std::stringstream ss(str);
    while(!ss.eof()) {
        std::string c;
        std::getline(ss, c, ' ');
        if(c.c_str()[0] == '+') {
            int b = stack.pop();
            int a = stack.pop();
            stack.push(a + b);
        }
        else if(c.c_str()[0] == '-') {
            int b = stack.pop();
            int a = stack.pop();
            stack.push(a - b);
        }
        else if(c.c_str()[0] == '/') {
            int b = stack.pop();
            int a = stack.pop();
            stack.push(a / b);
        }
        else if(c.c_str()[0] == '*') {
            int b = stack.pop();
            int a = stack.pop();
            stack.push(a * b);
        }
        else {
            stack.push(std::atoi(c.c_str()));
        }
    }
    std::cout << stack.pop() << std::endl;
}

Measured memory_bytes: 3220
import std;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] lreads(T = long)(long n){return generate(()=>readln.chomp.to!T()).take(n).array();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);
// dfmt on

void main()
{
    long N = lread();
    long[string] d;
    foreach (i; 0 .. N)
    {
        d[sread()] = 0;
    }
    writeln(d.keys.length);
}


Measured memory_bytes: 27772
#include<bits/stdc++.h>
#define int long long
#define for0(i, n) for(int i = 0; i < (n); i++)
#define all(x) x.begin(),x.end()
using namespace std;
vector<int>v; int n, k;
signed main() {
	v.push_back(2);
	for (int i = 3; i <= 101197; i += 2) {
		bool b = 1;
		for (int p : v)if (i % p == 0)b = 0; else if (p * p > i)break;
		if (b) v.push_back(i);
	}
	while (cin >> n >> k, k >= 0) {
		auto itr = upper_bound(all(v), n);
		vector<int>v1, v2;
		for0(i, k) v1.push_back(*itr++);
		for0(i, k)for0(j, i + 1)v2.push_back(v1[i] + v1[j]);
		sort(all(v2));
		cout << v2[k - 1] << endl;
	}
}


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

int main() {
  int n, k;
  cin >> n >> k;
  cout << n - k + 1 << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <utility>
typedef long long ll;
ll MOD = 1e9+7;

using namespace std;

ll v[51];
ll p[51][51];

void ptable()
{
	for(int i=0;i<51;i++)
	{
		for(int j=0;j<i+1;j++)
		{
			if(j==0 || j==i)
				p[i][j]=1;
			else
				p[i][j]=p[i-1][j-1]+p[i-1][j];
		}
	}
}

int main()
{
	int n,a,b;
	int same=0;
	ll ans=0;
	double mm=0;
	
	cin>>n>>a>>b;
	for(int i=0;i<n;i++)
		cin>>v[i];
	sort(v,v+n);
	reverse(v,v+n);
	ptable();

	for(int i=0;i<a;i++)
	{
		mm+=(double)v[i];
	}
	mm/=(double)a;
	cout<<fixed<<mm<<endl;

	if(v[a-1]!=v[a])
	{
		ans=1;
	}else if(v[0]==v[a]){
		same=a+1;
		while(v[0]==v[same])
		{
			same++;
		}
		for(int i=a;i<min(same,b)+1;i++)
		{
			ll c=p[same][i];
			ans+=c;
		}
	}else{
		ll c=0;
		ll d=0;
		for(int i=0;i<a;i++)
		{
			if(v[i]==v[a-1])
				c++;
		}
		d=c;
		for(int i=a;i<n;i++)
		{
			if(v[i]==v[a-1])
			{
				//cerr<<i<<" "<<v[a-1]<<" "<<v[i]<<endl;
				d++;
			}
		}
		cerr<<d<<"C"<<c<<endl;
		ans=p[d][c];
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdlib>
#include <cmath>
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <map>
#define MOD 1000000007
#define INF 1000000000
typedef long long ll;
using namespace std;
typedef pair<int,int> P;

int main(void){
    int n,k;
    int l[51];
    cin>>n>>k;
    for(int i=0;i<n;i++){
        cin>>l[i];
    }
    sort(l,l+n,greater<int>());
    int sum=0;
    for(int i=0;i<k;i++){
        sum+=l[i];
    }
    cout<<sum<<endl;
    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 rep2(i, s, n) for (int i = (s); i < (int)(n); ++i)
#define fi first
#define se second
#define INF 1000000009
#define LLINF 1000000000000000009LL
using ll = long long;

int main(){
  int n,k;
  cin>>n>>k;
  vector<int>h(n);
  vector<int>dp(n,INF);
  rep(i,n)cin>>h[i];
  dp[0]=0;
  rep(i,n){
    rep(j,k){
      if(i+j+1<n){
        dp[i+j+1]=min(dp[i+j+1],dp[i]+abs(h[i+j+1]-h[i]));
      }
    }
  }
  cout<<dp[n-1]<<endl;
  return(0);
}


Measured memory_bytes: 1024
N = int(input())
A = list(map(int, input().split()))

from fractions import gcd

H = [A[0]]
x = A[0]
for i in range(1, N):
    x = gcd(x, A[i])
    H.append(x)


T = [A[-1]]
x = A[-1]
for i in range(2, N+1):
    x = gcd(x, A[-1 * i])
    T.append(x)

# print('H', H)
# print('T', T)

r = []
for i in range(N):
    if i == 0:
        ans = T[-2]
        r.append(ans)
    elif i == N - 1:
        ans = H[-2]
        r.append(ans)
    else:
        ans = gcd(H[i-1], T[N-i-2])
        r.append(ans)
print(max(r))

Measured memory_bytes: 14584
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int inf = 1e9, mod = 1e9+7;
#define endl     '\n'


void solve(){
    int n;
    cin >> n;
    if(n >= 30) cout << "Yes\n";
    else cout << "No\n";
}


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

    solve();
    return 0;
}


Measured memory_bytes: 3612
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    int n;
    cin >> n;
    int a[300000], b[300000];
    for(int i=0;i<n;i++){
        cin >> a[i];
        b[i]=a[i];
    }
    sort(b,b+n);
    int dif=0;
    for(int i=0;i<n;i++){
        if(a[i]!=b[i]){
            dif++;
        }
    }
    if(dif==0){
        cout << 0 << endl;
        return 0;
    }
    int q;
    cin >> q;
    for(int i=1;i<=q;i++){
        int x;
        int y;
        cin >> x >> y;
        if(a[x-1]!=b[x-1]){
            dif--;
        }
        if(a[y-1]!=b[y-1]){
            dif--;
        }
        swap(a[x-1],a[y-1]);
        if(a[x-1]!=b[x-1]){
            dif++;
        }
        if(a[y-1]!=b[y-1]){
            dif++;
        }
        if(dif==0){
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}


Measured memory_bytes: 5516
def slove():
    import sys
    input = sys.stdin.readline
    n = int(input().rstrip('\n'))
    k = int(input().rstrip('\n'))
    t = 1
    for _ in range(n):
        if t >= k:
            t += k
        else:
            t *= 2
    print(t)


if __name__ == '__main__':
    slove()


Measured memory_bytes: 38256
#include<iostream>
#include<map>
#include<algorithm>
#include<functional>
#include<bitset>
#include<vector>
#include<set>
using  namespace std;
#define ll long long
#define pb push_back
#define sc second
#define fr first
#define mp make_pair
const int  MOD = 1e9 + 7, OO = 1e9;
const int M = 1e5 + 10 , N = 1e2 + 10;
ll dp[N][M], acc[N] ,  bucket[N][M];
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll n, k;
	cin >> n >> k;
	int Sqrt;
	for (ll i = 1; i <= 100000; ++i) {
		if (i*i > n) {
			Sqrt = i;
			break;
		}
	}
	dp[0][1] = 1;
	for (int i = 0; i < k; i++) {
		for (int j = 1; j < Sqrt; j++) {
			dp[i][j] += dp[i][j - 1];
			dp[i][j] %= MOD;
		}
		for (int j = Sqrt - 2; j > 0; j--) {
			bucket[i][j] += bucket[i][j + 1];
			bucket[i][j] %= MOD;
		}

		for (int j = 1; j < Sqrt; j++) {
			bucket[i + 1][j] = dp[i][j] * (n / j - n / (j + 1));
			if (j == n / j)
				bucket[i + 1][j] = 0;

			bucket[i + 1][j] %= MOD;
		}
		for (int j = 1; j < Sqrt; j++) {
			dp[i + 1][j] = bucket[i][j] + dp[i][Sqrt - 1];
			dp[i + 1][j] %= MOD;
		}
	}
	ll ans = 0;
	for (int i = 1; i <M; ++i) {
		ans += dp[k][i];
		ans += bucket[k][i];
		ans %= MOD;
	}
	cout << ans << endl;
}

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

using namespace std;

typedef long long ll;
ll f(ll a,ll c)//1到a能被c整除的数
{
    return a/c;
}
ll f1(ll a, ll b, ll c)//a~b能被c整除的个数
{
    return f(b,c)-f(a-1,c);
}
ll gcd(ll a,ll b)//最大公约数
{
    return b==0?a:gcd(b,a%b);
}
ll gdx(ll a, ll b)
{
    return a * b / gcd(a,b);
}
int main()
{
    ll a,b,c,d;
    cin >> a >> b >> c >> d;
    cout << ((b-a+1)-f1(a,b,c)-f1(a,b,d)+f1(a,b,gdx(c,d))) << endl;
    return 0;
}


Measured memory_bytes: 256