akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <map>
#include <cmath>
int main()
{
	int N, M;
	std::cin >> N >> M;
	std::map<int, int> answer;
	for (int i = 0; i < N+1; i++)
	{
		answer[i] = -1;
	}
	for (int i = 0; i < M; i++)
	{
		int index, value = 0;
		std::cin >> index >> value;
		if (answer.find(index) != answer.end() && answer[index] != -1 && answer[index] != value)
		{
			std::cout << -1;
			return 0;
		}
		else if (index > N)
		{
			std::cout << -1;
			return 0;
		}
		answer[index] = value;
	}
	if (answer[1] == 0 && N != 1)
	{
		std::cout << -1;
		return 0;
	} else if(answer[1] == -1 && N != 1)
	{
		answer[1] = 1;
	}
	else if (answer[1] == -1 && N == 1) 
	{
		answer[1] = 0;
	}
	int sum = 0;
	for (int i = 1; i < N + 1; i++)
	{
		if (answer[i] != -1)
			sum += answer[i] * std::pow(10, N - i);
	}
	std::cout << sum;
	return 0;
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/abc154/tasks/abc154_a

#include "algorithm"
#include "bitset"
#include "cmath"
#include "functional"
#include "iomanip"
#include "iostream"
#include "map"
#include "numeric"
#include "queue"
#include "set"
#include "string"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define rep1(i, to) for (ll i = 1; i <= (to); ++i)
#define repf(i, from, to) for (ll i = from; i < (to); ++i)
#define repr(i, from) for (ll i = from - 1; i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define unless(cond) if (!(cond))
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef long double ld;
template <typename T>
using V = vector<T>;
using VL = V<ll>;
using VVL = V<VL>;
template <typename T, typename U>
using P = pair<T, U>;
using PL = P<ll, ll>;
using VPL = V<PL>;
template <typename T>
inline bool chmax(T& a, T b);
template <typename T>
inline bool chmin(T& a, T b);
void print_ints(vector<ll> v);
template <typename T>
void drop(T a);

const ll INF = 1e18;

void solve() {
  string S, T, U;
  ll A, B;
  cin >> S >> T >> A >> B >> U;

  if (S == U) {
    print_ints({A - 1, B});
  } else {
    print_ints({A, B - 1});
  }
}

struct exit_exception : public std::exception {
  const char* what() const throw() { return "Exited"; }
};

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

  try {
    solve();
  } catch (exit_exception& e) {
  }

  return 0;
}
#endif

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

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

void print_ints(vector<ll> v) {
  rep(i, v.size()) {
    if (i > 0) {
      cout << " ";
    }

    cout << v[i];
  }

  cout << endl;
}

template <typename T>
void drop(T res) {
  cout << res << endl;
  throw exit_exception();
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int h, w;
vector<char*> s;

int main(void) {
	cin >> h >> w;
	for (int i = 0; i < h; i++){
		s.push_back(new char[w]);
		cin >> s[i];
	}
	
	for (int i = 0; i < h; i++){
		for (int j = 0; j < w; j++){
			if (s[i][j] == '#') continue;
			
			int cnt = 0;
			if (i > 0 && j > 0 && s[i - 1][j - 1] == '#') cnt++;
			if (i > 0 && j < w - 1 && s[i - 1][j + 1] == '#') cnt++;
			if (i < h - 1 && j < w - 1 && s[i + 1][j + 1] == '#') cnt++;
			if (i < h - 1 && j > 0 && s[i + 1][j - 1] == '#') cnt++;
			if (i > 0 && s[i - 1][j] == '#') cnt++;
			if (j < w - 1 && s[i][j + 1] == '#') cnt++;
			if (i < h - 1 && s[i + 1][j] == '#') cnt++;
			if (j > 0 && s[i][j - 1] == '#') cnt++;
			
			s[i][j] = cnt + '0';
		}
	}
	
	for (char* si : s){
		cout << si << endl;
		delete si;
	}
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const int iinf = 1 << 28;
const long long llinf = 1ll << 60;
const double PI = 3.14159265;

ll f[200001], inv[200001], invf[200001];

ll nck(ll n, ll k) {
    ll res = (f[n] * invf[k]) % MOD;
    return (res * invf[n-k]) % MOD;
}

void work() {
    ll n,k; cin>>n>>k;

    f[0] = f[1] = 1;
    inv[0] = inv[1] = 1;
    invf[0] = invf[1] = 1;
    for (ll i = 2; i <= n; ++i) {
        f[i] = (i * f[i-1]) % MOD;
        inv[i] = (MOD - (MOD/i) * inv[MOD%i] % MOD) % MOD;
        invf[i] = (inv[i] * invf[i-1]) % MOD;
    }

    ll ans = 0;
    ll limit = (k < n) ? k : n - 1;
    for (ll i = 0; i <= limit; ++i) {
        ans = (ans + ((nck(n,i) * nck(n-1, n-i-1)) % MOD)) % MOD;
    }
    cout << ans << endl;
}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    work();
    return 0;
}


Measured memory_bytes: 4992
import sys
import resource
sys.setrecursionlimit(10000)
n,k=map(int,input().rstrip().split())
p=list(map(int,input().rstrip().split()))
c=list(map(int,input().rstrip().split()))
def find(start,now,up,max,sum,count,flag):
    if start==now:
        flag+=1
    if start==now and flag==2:
        return [max,sum,count]
    elif count==up:
        return [max,sum,count]
    else:
        count+=1
        sum+=c[p[now-1]-1]
        if max<sum:
            max=sum
        return find(start,p[now-1],up,max,sum,count,flag)
kara=[-10000000000]
for i in range(1,n+1):
    m=find(i,i,n,c[p[i-1]-1],0,0,0)
    if m[2]>=k:
        m=find(i,i,k,c[p[i-1]-1],0,0,0)
        if m[0]>kara[0]:
            kara[0]=m[0]
        result=kara[0]
    elif m[1]<=0:
        if m[0]>kara[0]:
            kara[0]=m[0]
        result=kara[0]
    else:
        w=k%m[2]
        if w==0:
            w=m[2]
        spe=find(i,i,w,c[p[i-1]-1],0,0,0)[0]
        if m[1]+spe>m[0] and m[1]*(k-w)//m[2]+spe>kara[0]:
            kara[0]=m[1]*(k-w)//m[2]+spe
        elif m[1]+spe<=m[0] and m[1]*((k-w)//m[2]-1)+m[0]>kara[0]:
            kara[0]=m[1]*((k-w)//m[2]-1)+m[0]
        result=kara[0]
print(result)

Measured memory_bytes: 235564
#pragma GCC optimize("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target ("avx")
#include <bits/stdc++.h>
constexpr int INF = 2147483647;
constexpr long long int INF_LL = 9223372036854775807;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;


int main() {
	int N, A;
	cin >> N >> A;
	vector<int> x(N);
	for (int i = 0; i < N; i++)cin >> x[i];
	//i個目まで見て、j個選んで和がkになるときの場合の数
	vector<vector<vector<ll>>> dp(N + 1, vector<vector<ll>>(N + 1, vector<ll>(3000, 0)));
	dp[0][0][0] = 1;
	for (int i = 0; i < N; i++)for (int j = 0; j < N; j++)for (int k = 0; k < 2600; k++) {
		dp[i + 1][j][k] += dp[i][j][k];
		dp[i + 1][j + 1][k + x[i]] += dp[i][j][k];
	}
	ll ans = 0;
	for (int i = 1; i <= N; i++) {
		ans += dp[N][i][A * i];
	}
	cout << ans << endl;
}

Measured memory_bytes: 62592
#include<bits/stdc++.h>
using namespace std;
int prime[1000005],e;
bool is_prime[1000005];
int presum[1000005];
void solve()
{
    prime[0]=prime[1]=1;
    for(int i=2;i<=1000000;i++)
    {
        if(!is_prime[i])
        {
            prime[++e]=i;
            if((long long)i*i>1000000) continue;
            for(int j=i*i;j<=1000000;j+=i) is_prime[j]=1;
        }
    }
}
void pre()
{
    presum[0] =presum[1]= 0;
    for(int i = 2; i <=1000000; i++)
        presum[i] = is_prime[i] ? presum[i - 1]: presum[i - 1]+1;
}
int main()
{
    int n;
    solve();
    pre();
    //cout<<e;
    while(cin>>n)
    {
       cout<<presum[n]<<endl;
    }

   return 0;
}


Measured memory_bytes: 8196
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <queue>
#include <climits>
#include <set>
#include <map>
#include <stack>
#include <iomanip>
#include <tuple>
#define ll long long
#define rep(i,s,n) for(ll i = (ll)(s); i < (ll)(n); i++)
#define all(a) (a).begin(),a.end()
#define mod 1000000007
using namespace std;
using graph =vector<vector<ll>>;
/*階乗*/
ll factorial(ll n){
    if(n==0){
        return 1;
    }
    else{
        return n*factorial(n-1);
    }
}

/* ユークリッドの互除法 最大公約数*/
ll gcd(ll a, ll b) {
	return b ? gcd(b,a%b) : a;
}



/*最小公倍数*/

ll lcm(ll a,ll b){
	return a/gcd(a,b)*b;
}


/*二点間の距離*/
double dist(pair<double,double> a,pair<double,double> b){
	return sqrt(pow((a.first - b.first) ,2) + pow((a.second - b.second),2));
}

//繰り返し自乗法
double ism(double aa,ll p){
    double ap=aa;
    double ans=1;
    while(p>0){
        //cout<<"p="<<p<<",ap="<<ap<<endl;
        if(p&1){//奇数が真
            ans*=ap;
        }
        p/=2;
        ap=ap*ap;
    }
    return ans;

}
//繰り返し自乗法(アマリトリバージョン)
ll ismm(ll aa,ll p,ll m){
    ll ap=aa;
    ll ans=1;
    while(p>0){
        //cout<<"p="<<p<<",ap="<<ap<<endl;
        if(p&1){//奇数が真
            ans=(ans*ap)%m;    
        }
        p/=2;              
        ap=(ap*ap)%m;
    }
    return ans;

}
/*
ll solve(ll i,ll m,vector<ll>t,ll n){
    if(m==0){
        return 1;
    }
    if(i>=n){
        return 0;
    }
    
    
    cout<<i+1<<" "<<m<<endl;
    cout<<i+1<<" "<<m-t[i]<<endl;
    ll res=solve(i+1,m,t,n)||solve(i+1,m-t[i],t,n);
    return res;
}
*/

//小数点12桁
struct all_init
{
    all_init()
    {
        cout << fixed << setprecision(12);
    }
} All_init;


int main()
{
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    ll ans = b-a+1;
    ans -= b/c + b/d - b/lcm(c,d);
    ans += (a-1)/c + (a-1)/d - (a-1)/lcm(c,d);
	cout << ans << endl;    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define ll long long
#define db long double
#define ii pair<int,int>
#define vi vector<int>
#define fi first
#define se second
#define sz(a) (int)(a).size()
#define all(a) (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
#define FN(i, n) for (int i = 0; i < (int)(n); ++i)
#define FEN(i,n) for (int i = 1;i <= (int)(n); ++i)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repv(i,a,b) for(int i=b-1;i>=a;i--)
#define SET(A, val) memset(A, val, sizeof(A))
typedef tree<int ,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set ;
// order_of_key (val): returns the no. of values less than val
// find_by_order (k): returns the kth largest element.(0-based)
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
const int N=100005,N1=2005;
int pre[N1][N1],k;
int fun(int x1,int y1,int x2,int y2)
{
  if(x1<0 || y1<0 || x2<0 || y2<0 || x1>x2 || y1>y2 || x2>=(2*k) || y2>=(2*k)) return 0;
  if(x1==0 && y1==0) return pre[x2][y2];
  else if(!x1) return pre[x2][y2]-pre[x2][y1-1];
  else if(!y1) return pre[x2][y2]-pre[x1-1][y2];
  else return pre[x2][y2]-pre[x2][y1-1]-pre[x1-1][y2]+pre[x1-1][y1-1];
}
int main()
{
  std::ios::sync_with_stdio(false);
  cin.tie(NULL) ; cout.tie(NULL) ;
  int n,x,y;
  cin>>n>>k;
  rep(i,1,n+1)
    {
      char c;
      cin>>x>>y>>c;
      if(c=='B') y+=k;
      pre[x%(2*k)][y%(2*k)]++;
    }
  rep(i,0,2*k)
    rep(j,0,2*k)
    {
      if(i==0 && j==0) continue;
      else if(!i) pre[i][j]+=pre[i][j-1];
      else if(!j) pre[i][j]+=pre[i-1][j];
      else
	pre[i][j]+=pre[i-1][j]+pre[i][j-1]-pre[i-1][j-1];
    }
  int ans=0;
  rep(i,0,k)
    rep(j,0,k)
    {
      int tmp=fun(i,j,i+k-1,j+k-1)+fun(i+k,j+k,2*k-1,2*k-1)+fun(0,0,i-1,j-1)+fun(i+k,0,2*k-1,j-1)+fun(0,j+k,i-1,2*k-1);
      assert(tmp<=n);
      ans=max(ans,max(tmp,n-tmp));
    }
  cout<<ans<<endl;
  return 0 ;
}


Measured memory_bytes: 15872
s = int(input())
A = 10 ** 9
if s <= A:
    x1, y2 = 1, s
    x2, y1 = 0, 0
elif s == 10 ** 18:
    x1, y2 = A, A
    x2, y1 = 0, 0
else:
    s1 = s % A
    s2 = s // A
    x1, y2 = s2 + 1, A
    x2, y1 = A - s1, 1
print(0, 0, x1, x2, y1, y2)


Measured memory_bytes: 3060
#include<cstdio>
#define pritnf printf
#define scnaf scanf
#define retrun return
#define sizoef sizeof
#define inl inline
#define br break
#define con continue
#define mst(mst_a,mst_b) memset(mst_a,mst_b,sizeof(mst_a))
#define fora(fora_x,fora_a,fora_b) for(re nti (fora_x)=(fora_a);(fora_x)<=(fora_b);++(fora_x))
#define forb(forb_x,forb_a,forb_b) for(re nit (forb_x)=(forb_a);(forb_x)>=(forb_b);--(forb_x))
#define foral(foral_x,foral_a,foral_b) for(re ll (foral_x)=(foral_a);(foral_x)<=(foral_b);++(foral_x))
#define forbl(forbl_x,forbl_a,forbl_b) for(re ll (forbl_x)=(forbl_a);(forbl_x)>=(forbl_b);--(forbl_x))
#define re register
#define stt struct
#define nms namespace
#define gc getchar
#define sl(sl_a) strlen(sl_a)
#define gt(gt_a) goto gt_a
#define rt return
#define infa (0x3f3f3f3f)
#define infb (0x7fffffff)
#define infd (0x7f)
#define in(in_a) freopen("D:/""/in"in_a".in","r",stdin)
#define out(out_a) freopen("D:/""/out"out_a".out","w",stdout)
#define filein(filein_a) freopen(filein_a".in","r",stdin)
#define fileout(fileout_a) freopen(fileout_a".out","w",stdout)
#define file(file_a) filein(file_a);fileout(file_a)
typedef long long ll;
typedef int itn,nti,tin,tni,nit;
using namespace std;
const nit maxa=100004;
const nit maxb=1000004;
const nit maxc=4;
const tni maxd=10004;
#include<cstring>

tni s,ls;
char x[maxa];
bool f=1;

tni main()
{
	scanf("%s",x+1);
	s=sl(x+1);
	//
	ls=s>>1;
	fora(i,1,ls)
	{
		if(x[i]!=x[s-i+1])
		{
			f=0;
			br;
		}
	}
	//
	if(f)
	{
		pritnf("Yes\n");
		rt 0;
	}
	//
	if(!(s%2))
	{
		f=1;
		fora(i,1,ls)
		{
			if(((x[i]=='p')&&(x[s-i+1]!='q'))||((x[i]=='q')&&(x[s-i+1]!='p'))||((x[i]=='b')&&(x[s-i+1]!='d'))||((x[i]=='d')&&(x[s-i+1]!='b')))
			{
				f=0;
				br;
			}
		}
		//
		if(f)
		{
			printf("Yes\n");
			rt 0;
		}
	}
	//
	printf("No\n");
	rt 0;
}

Measured memory_bytes: 256
import java.util.*;


public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a1 = sc.nextInt();
        int a2 = sc.nextInt();
        int a3 = sc.nextInt();

        if(a1 + a2 + a3 >= 22){
            System.out.println("bust");
        }

        else System.out.println("win");

        // write your code here
    }
}

Measured memory_bytes: 22996
import sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**6)

def resolve():
    N, Q = map(int, input().split())
    edge = [[] for _ in range(N)]
    for i in range(N-1):
        a, b = map(int, input().split())
        edge[a-1].append(b-1)
        edge[b-1].append(a-1)
    cnt = [0]*N
    for i in range(Q):
        p, x = map(int, input().split())
        cnt[p-1] += x

    def dfs(v, par):
        if v>0:
            cnt[v] += cnt[par]
        for i in edge[v]:
            if i!=par:
                dfs(i, v)

    dfs(0, -1)

    print(*cnt)

if __name__ == '__main__':
    resolve()


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

using namespace std;

#define pb push_back
#define F first
#define S second
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define rep(i, n) FOR(i, 0, n)
#define REP(i, n) FOR(i, 0, n)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define RREP(i, n) FOR(i, n, 0)
#define MFOR(i, m) for(auto i=m.begin();i!=m.end();i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())

typedef long long int ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;

const double eps = 1e-10;

void printv(vector<auto> const& s) {
  rep(i, s.size()) {
    cout << s[i] << endl;
  }
}

void printp(P const& p) {
  cout << p.first << p.second << endl;
}

void print(auto const s) {
  cout << s << endl;
}

vvi d;

void warshall_floyd(int n) {
  rep(i, n) {
    rep(j, n) {
      rep(k, n) {
        d[j][k] = min(d[j][k], d[j][i] + d[i][k]);
      }
    }
  }
}

int main () {
  cin.tie(0);
  cout << setprecision(10);

  int n, m; cin >> n >> m;
  d = vvi(n, vi(n, 100000000));
  REP(i, n) {
    d[i][i] = 0;
  }
  vi a(m), b(m), c(m);
  REP(i, m) {
    cin >> a[i] >> b[i] >> c[i];
    d[a[i]-1][b[i]-1] = c[i];
    d[b[i]-1][a[i]-1] = c[i];
  }

  
  warshall_floyd(n);

  int cnt = 0;
  P p;
  bool ok = true;
  REP(i, m) {
    ok = true;
    REP(j, n) {
      if(d[j][a[i]-1] + c[i] == d[j][b[i]-1]) ok = false;
    }
    if(ok) {
      cnt++;
    }
  }
  print(cnt);
}


Measured memory_bytes: 256
// Why am I so dumb? :c
#include <bits/stdc++.h>

#define pb push_back
#define mp make_pair

#define all(x) (x).begin(), (x).end()

#define fi first
#define se second

using namespace std;

typedef long long ll;

int n, a, goal, mn, mx;

bool ans;

void solve() {                   
	scanf("%d %d %d", &n, &mn, &goal);

	goal -= mn;
	n -= 2;

	scanf("%d %d", &mn, &mx);

	for (int k = 0; k <= n; ++k) {
		ll l1 = k * 1ll * mn;
		ll r1 = k * 1ll * mx;
		ll l2 = (n - k) * 1ll * mn + goal;
		ll r2 = (n - k) * 1ll * mx + goal;
		ll cl = mn, cr = mx;
            
        for (int step = 0; step < 2; ++step) {
        	{	// first case
        		ll mn1 = max({cl, r1 - r2});
        		ll mx1 = min({cr, l1 - l2});

        		if (mn1 <= mx1) {
        			ans |= (l1 <= r1);
        		}
        	}

        	{	// second case
				ll mn1 = max({cl, r1 - r2, l1 - l2 + 1});
				ll mx1 = min({cr});

	        	if (mn1 <= mx1) {
	        		ans |= (l2 + mn1 <= r1);
	        	}
        	}

        	{	// third case
				ll mn1 = max({cl});
				ll mx1 = min({cr, l1 - l2, r1 - r2 - 1});

	        	if (mn1 <= mx1) {
	        		ans |= (l1 <= r2 + mx1);
	        	}
        	}

        	{	// fourth case
				ll mn1 = max({cl, l1 - l2 + 1});
				ll mx1 = min({cr, r1 - r2 - 1});

	        	if (mn1 <= mx1) {
	        		ans |= (l2 <= r2);
	        	}
        	}

        	cl *= -1;
        	cr *= -1;
        	swap(cl, cr);
        }                                               
	}

	printf(ans ? "YES\n" : "NO\n");	    
}

int main() {    
    int tt = 1;

    while (tt--) {
        solve();
    }

    return 0;
}

Measured memory_bytes: 256
import sys

input = sys.stdin.readline


def main():
    N = int(input())
    xyh = [None] * N
    for i in range(N):
        xyh[i] = tuple(map(int, input().split()))

    for i in range(N):
        if xyh[i][2] > 0:
            Bx, By, Bh = xyh[i]
            break

    for Cx in range(0, 101):
        for Cy in range(0, 101):
            H = Bh + abs(Bx - Cx) + abs(By - Cy)
            is_ok = True
            for x, y, h in xyh:
                if max(H - abs(x - Cx) - abs(y - Cy), 0) != h:
                    is_ok = False
                    break
            if is_ok:
                print(Cx, Cy, H)
                exit()


if __name__ == "__main__":
    main()


Measured memory_bytes: 9036
// ALDS1_4_D: Allocation

use std::str::FromStr;

fn check(n: u32, k: u32, p: u32, t: &Vec<u32>) -> u32 {
    let mut i: usize = 0;
    'a: for _ in 0..k {
        let mut s: u32 = 0;
        while s + t[i] <= p {
            s += t[i];
            i += 1;
            if i as u32 == n {
                break 'a
            }
        }
    }
    i as u32
}
  
fn solve(n: u32, k: u32, t: &Vec<u32>) -> u32 {
    let mut left: u32 = 0;
    let mut right: u32 = 100000 * 10000;
    while right - left > 1 {
        let mid = (right + left) / 2;
        let v = check(n, k, mid, t);
        if v >= n {
            right = mid;
        } else {
            left = mid;
        }
    }
    right
}

fn main() {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    let a: Vec<u32> = s.split_whitespace().map(|n| u32::from_str(n).unwrap()).collect();
    let n = a[0];
    let k = a[1];

    let mut t: Vec<u32> = Vec::new();
    for _ in 0..n {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        let v: u32 = s.trim().parse().ok().unwrap();
        t.push(v);
    }

    let ans = solve(n, k, &t);
    println!("{}", ans);
}


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

/*
void parray(int *a, int n) {
    int i;
    for(i = 0; i < n; ++i) { printf("%d ", a[i]); }
    printf("\n"); 
}
*/

int *sep(int *a, int n, int *cnt) { // 0がある場所の要素番号の配列を渡す
    int *p = (int*)malloc((n+3) * sizeof(int));
    int i, c = 0;
    p[c] = -1; ++c;
    for(i = 0; i < n; ++i) {
        if(a[i] == 0) { p[c] = i; ++c; }
    }
    p[c] = n; ++c;
    *cnt = c;
    return p;
}

int min(int *a, int i, int j) {
    int k, min = a[i];
    for(k = i; k <= j; ++k) {
        if( a[k] > 0 && a[k] < min) { min = a[k]; }
    }
    return min;
}

int sub(int *a, int i, int j) {
    int k, x = min(a, i, j);
    for(k = i; k <= j; ++k) { a[k] -= x; }
    return x;
}

void solve(int *a, int n) {
    int i, cnt, ans, *chk, check;
    ans = 0;
    do {
        chk = sep(a, n, &cnt);
        check = 0;
        //printf("chk: "); parray(chk, cnt);
        for(i = 0; i < cnt - 1; ++i) {
            check += sub(a, chk[i] + 1, chk[i+1] - 1);
        }
        ans += check;
        //printf("a: "); parray(a, n);
        free(chk);
    } while(check > 0);
    printf("%d\n", ans);
}

int main(void)
{
    int n, i;
    scanf("%d", &n);
    int *h = (int*)malloc((n+2)*sizeof(int));
    for(i = 0; i < n; ++i) { scanf("%d", &h[i]); }
    solve(h, n);
    return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define endl '\n';
#define FASTER ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const ll POSITIVE_INFINITY = 9223372036854775807;
const ll NEGATIVE_INFINITY = -9223372036854775807;
const ll MOD = 1000000007;
const ld PI = acos(-1.0);

template <typename T> inline T bigMod(T A,T B,T M = MOD){A %= M;T ret = 1;while(B){if(B & 1) ret = (ret * A) % M;A = (A * A) % M;B = B >> 1;}return ret;}
template <typename T> inline T invMod (T A,T M = MOD){return bigMod(A,M-2,M);}

const int N = 200005;

int main(){
  FASTER;
  vector<int>ar(3);
  for (int &v : ar){
    cin >> v;
  }
  sort(ar.begin(), ar.end());
  vector<int>tmp = {5, 5, 7};
  if (ar == tmp){
    cout << "YES\n";
  } else {
    cout << "NO\n";
  }
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String inString = scanner.next();
        scanner.close();

        char[] subSt1 = inString.substring(0, (inString.length() - 1) / 2).toCharArray();
        char[] subSt2 = inString.substring((inString.length() + 3) / 2 - 1, inString.length()).toCharArray();
        char[] inst = inString.toCharArray();
        boolean ans = true;
        inString = null;

        for (int i = 0; i < inst.length; i++) {
            if (inst[i] != inst[inst.length - 1 - i]) {
                ans = false;
                break;
            }
        }

        for (int i = 0; i < subSt1.length; i++) {
            if (subSt1[i] != subSt1[subSt1.length - 1 - i]) {
                ans = false;
                break;
            }
        }

        for (int i = 0; i < subSt2.length; i++) {
            if (subSt2[i] != subSt2[subSt2.length - 1 - i]) {
                ans = false;
                break;
            }
        }

        System.out.println(ans ? "Yes" : "No");

    }
}

Measured memory_bytes: 21844
import sys
readline = sys.stdin.buffer.readline
def even(n): return 1 if n%2==0 else 0

n = int(readline())
lst1 = list(map(int,readline().split()))

lst1.sort(reverse=True)

i = lst1[0]
lst1 = lst1[1:]

res = i/2
res2 = -1
minimum = 10**18
for j in lst1:
    if abs(j-res) < minimum:
        res2 = j
        minimum = abs(j-res)

print(i,res2)

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

int main(){

int tri[1000][3];
int num = 0;
cin >> num;
for(int i = 0;i<num;i++)
cin >> tri[i][0] >> tri[i][1] >> tri[i][2];

long int a,b,c=0;

for(int i = 0;i<num;i++){
a = tri[i][0]*tri[i][0];
b = tri[i][1]*tri[i][1];
c = tri[i][2]*tri[i][2];
if(a == b+c || b == a+c || c == a + b)
cout << "YES\n";
else
cout << "NO\n";
}
    return 0;
}

Measured memory_bytes: 1128
/*
 * WelcomeToAtCoder.cpp
 *
 *  Created on: 2020/02/19
 *      Author: black
 */

#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <list>
#include <cstring>
#include <stdio.h>
using namespace std;


int main(){

	int x[5];

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

	for(int i=0; i<5; ++i){
		if(x[i] == 0){
			cout << i+1 << endl;
			break;
		}
	}



	return 0;

}


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

int main() {
  int s1s2s3;
  cin >> s1s2s3;
  int s1 = s1s2s3 / 100;
  int s2 = (s1s2s3 - s1 * 100) / 10;
  int s3 = (s1s2s3 - s1 * 100 - s2 * 10) / 1;
  cout << s1 % 2 + s2 % 2 + s3 % 2 << endl;
}


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

B = [0]*N

for i in range(N-1, -1, -1):
  count = 0
  for j in range(i, N, i+1):
    count += B[j]
    if count%2 == A[i]:
      B[i] = 0
    else:
      B[i] = 1

sum = sum(B)
if sum == 0:
  print(0)
else:
  print(sum)
  ans = []
  for i in range(N):
    if B[i] == 1:
      ans.append(i+1)
  print(*ans)


Measured memory_bytes: 14136
#include <bits/stdc++.h>
#define debug(x) cerr << "\n" \
                      << #x << " = " << x << ".\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define int long long
using namespace std;
typedef long long ll;
//using pii pair<int,int>;
typedef pair<int, int> pii;
//using ll long long;
const int INF = ((1LL << 30) + (1LL << 29));
const ll MOD = 1000000007;

//=============================================================
string S;
vector<int> si;
int N;


int c2i(char c)
{
  int zero = '0';
  return c - zero;
}

void msi(){
  for (int i=0; i<S.size(); ++i){
    si.push_back(c2i(S[i]));
  }
}


int aaa = 0;
int v = 0;
void dfs(int id, int s1, int s2) {
  if (S.size() == id){
    aaa += s1 + s2;
    return;
  }
  dfs(id+1, s1, s2*10 + si[id]);
  dfs(id+1, s1+s2,si[id]);
}



// int dfs(int now, int sum) {
//   cout<<"dfs(" << now<< "," << sum<< ")" <<endl;

//   if ( now >= S.size() ) {
//     cout<<"aa: "<< sum << endl;;
//     return sum;
    
//   }


//   else {
//     int tmp = 0;
//     debug(now);
//     int cn = c2i(S[now]);
//     tmp += sum + dfs(now+1, );
//     tmp += dfs(now+1, sum*10 + cn);
//     debug(tmp);
//     aaa += tmp;
//     return 0 ;
//   }

  
// }

/*
 diff
 */
int diff(int x, int y)
{
  if (x > y)
  {
    return abs(x - y);
  }
  else
    return abs(y - x);
}
void solve()
{

  int n;
  /*
  int t = S;
  for (n=0; t != 0; ++n){
    t /= 10;
  }
  debug(n);
  */
  n = S.size();

  int ans = 0;
  int one = (n % 2 == 0) ? n : n - 1;

  for (int i = 0; i <= n; ++i)
  {
    for (int ketasu = 1; ketasu + i <= n; ++ketasu)
    {
      cout << endl;
      debug(ketasu);

      int tmp = 0;
      for (int j = 0; j < ketasu; ++j)
      {
        tmp *= 10;
        tmp += c2i(S[i + j]);
      }

      int kosu = diff(i,n/2);
      debug(tmp);
      debug(kosu);
      ans += tmp * kosu;


      debug(ans);
    }
  }

  cout << ans << endl;
}

signed main()
{
  cin >> S;
  //solve();
  int N = S.size();
  msi();
  int zero = 0;
  dfs(zero,zero,zero);
  //debug(aaa/2);
  aaa /= 2;
  cout<<aaa<<endl;
  //debug(ans);
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int n, tt, c, t, tle = 0, ans = 10000;
    cin >> n >> tt;
    for (int i = 1; i <= n; i++) {
        cin >> c >> t;
        if (tt >= t) {
            tle++;
            if (ans > c) ans = c;
        }
    }
    if (tle == 0) cout << "TLE";
    else cout << ans;
}



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

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

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

int main(){
	int a,b,c,d;
	long long ans;
	cin >> a >> b >> c >> d;
	ans = 1ll*a*c;
	ans = max(ans,1ll*a*d);
	ans = max(ans,1ll*b*c);
	ans = max(ans,1ll*b*d);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3636
import qualified Data.ByteString.Char8 as BC
import Data.IORef
import Control.Monad(forM_, when)
import Data.Maybe(fromJust)

main :: IO()
main = BC.getContents >>= solve.map (fst.fromJust.BC.readInt).BC.lines >>= print

solve :: [Int] -> IO Int
solve (_:x:y:xs) = do
                a <- newIORef (y - x)
                b <- newIORef (min x y)
                forM_ xs $ \z -> do
                    a' <- readIORef a
                    b' <- readIORef b
                    when (z - b' > a') $ writeIORef a (z - b')
                    when (z < b')      $ writeIORef b z
                readIORef a

Measured memory_bytes: 5880
#include<stdio.h>

int main()
{
int p[4]={};
int q[4]={};
int x,H,B;
H=0;B=0;
/*
for(int i=0;i<4;i++)
{scanf("%d",&x);p[i]=x;}
for(int i=0;i<4;i++)
{scanf("%d",&x);q[i]=x;}*/
while(scanf("%d %d %d %d %d %d %d %d",&p[0],&p[1],&p[2],&p[3],&q[0],&q[1],&q[2],&q[3])!=EOF)
{

for(int i=0;i<4;i++)
for(int j=0;j<4;j++)
{if(p[i]==q[j]){
	if(i==j)H++;
    else if(i!=j)B++;
}}
printf("%d %d\n",H,B);
H=0;B=0;
}

return 0;
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb emplace_back
#define INF (1e9+1)


//2部最大マッチング verified AOJ GRL_7_A
#define MAX_V 800
vector<int> G[MAX_V];
int match[MAX_V];
bool used[MAX_V];

void add_edge(int u,int v){
    G[u].pb(v);
    G[v].pb(u);
}

// 増大路をDFSで探す
bool dfs(int v){
    used[v]=true;
    rep(i,G[v].size()){
        int u=G[v][i],w=match[u];           //u:vからの移動先の頂点 , w:uとマッチングしている頂点
        if(w<0 || (!used[w] && dfs(w))){    //uがフリーか、このdfsではwを使っておらず かつwの別のペアが見つかった(=増大路発見) 場合
            match[v]=u;
            match[u]=v;
            return true;
        }
    }
    return false;
}

int bipartite_matching(int V){
    int res=0;
    rep(i,MAX_V)match[i]=-1;
    rep(v,V){
        if(match[v]<0){
            rep(i,MAX_V)used[i]=0;
            if( dfs(v) ) res++;       //増大路が見つかればres+=1
        }
    }
    return res;
}

int main(){
    int ans = 0;
    int v,a,b;
    cin>>v>>a>>b;
    
    vector<int> s(v),t(v);
    rep(i,v){
        cin>>s[i]>>t[i];
        if(abs(s[i]-t[i])<=a or (b<=abs(s[i]-t[i]) and abs(s[i]-t[i])<=2*a))ans++;
    }
    
    auto g = [](int ai,int bi, int aj, int bj){
        return abs((ai+aj)-(bi+bj));
    };
    
    rep(i,v){
        if(abs(s[i]-t[i])<=a or (b<=abs(s[i]-t[i]) and abs(s[i]-t[i])<=2*a))continue;
        rep(j,v){
            if(abs(s[j]-t[j])<=a or (b<=abs(s[j]-t[j]) and abs(s[j]-t[j])<=2*a))continue;
            
            if(g(s[i],t[i],s[j],t[j])<=a or (b<=g(s[i],t[i],s[j],t[j]) and g(s[i],t[i],s[j],t[j])<=2*a) ){
                G[i].pb(j);
            }
        }
    }
    cout<<bipartite_matching(v)+ans<<endl;
}



Measured memory_bytes: 3464
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define mkp make_pair
#define SZ(x) ((int)(x).size())
#define MEM(x,a) memset(x,a,sizeof(x))
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
typedef long long ll;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef vector<int> VI;
typedef vector<ll> VL;
const ll mod=1000000007,N=1e5+5,M=1e5+5,INF=0x3f3f3f3f;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
//head

int main(void){
    int x,y,a,b,c;
    cin>>x>>y>>a>>b>>c;
    VI p(a),q(b),r(c);
    rep(i,0,a)cin>>p[i];
    rep(i,0,b)cin>>q[i];
    rep(i,0,c)cin>>r[i];
    sort(p.begin(),p.end());
    sort(q.begin(),q.end());
    sort(r.begin(),r.end());
    reverse(p.begin(),p.end());
    reverse(q.begin(),q.end());
    reverse(r.begin(),r.end());
    ll ans=0;
    rep(i,0,x)ans+=p[i];
    rep(i,0,y)ans+=q[i];
    --x;
    --y;
    int cur=0;
    while(x>=0&&y>=0&&cur<c){
        if(p[x]>q[y]){
            if(q[y]<r[cur]){
                ans-=q[y]-r[cur];
                ++cur;
            }
            --y;
        }
        else{
            if(p[x]<r[cur]){
                ans-=p[x]-r[cur];
                ++cur;
            }
            --x;
        }
    }
    while(x>=0&&cur<c){
        if(p[x]<r[cur]){
                ans-=p[x]-r[cur];
                ++cur;
        }
        --x;
    }
    while(y>=0&&cur<c){
            if(q[y]<r[cur]){
                ans-=q[y]-r[cur];
                ++cur;
            }
            --y;
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
  int n, k;
  cin >> n >> k;
  int x[200100] = {0};
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    x[a]++;
  }
  vector<int> v;
  int cnt = 0;
  for (int i = 1; i <= n; i++) {
    if (x[i] >= 1) {
      cnt++;
      v.push_back(x[i]);
    }
  }
  sort(v.begin(), v.end());
  int ans = 0;
  int i = 0;
  while (true) {
    if (cnt <= k) {
      break;
    }
    cnt--;
    ans += v[i];
    i++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 2168
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>

typedef long long ll;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define print(x) cout<<(x)<<endl
#define rep(i,n) for(int i = 0;i < ((int)(n));++i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SUM(vec) accumulate(all(vec),0LL)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define test(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;

ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;}
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);}
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;}
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;}


bool isOk(ll key,ll value){
  return key >= value;
}

ll binary_search(vector<ll> a,ll key){
  ll ok = a.size()-1;
  ll ng = 0;

  while(abs(ok - ng) > 1){
    ll mid = (ok + ng) / 2;
    if(isOk(key,a[mid]))ok = mid;
    else ng = mid;
  }
  return ok;
}

bool isPrime(ll n) {
	for (int i = 2; n >= i * i; ++i) {
		if(!(n % i))return false;
	}
  return true;
}

int main() {
  cin.tie(0); ios::sync_with_stdio(0);
  ll n;cin>>n;
  vector<ll> a(n);rep(i,n)cin>>a[i];
  rep(i,n)if(i)a[i] += a[i-1];
  ll ans = INFL;
  rep(i,n-1){
    ans = min(ans,abs((a[a.size()-1] - a[i])-a[i]));
  }
  print(ans);
  return 0;
}

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

#define M 1000000007
#define MM 998244353 
#define ll long long 
#define pb push_back
#define mem0(a) memset(a,0,sizeof(a))
#define mem1(a) memset(a,-1,sizeof(a))
#define memf(a) memset(a,false,sizeof(a))
#define all(v) v.begin(),v.end()
#define sz(a) (ll)a.size()
#define F first
#define S second
#define PI 3.1415926536
#define INF 2000000000000000000
#define endl "\n"
#define _time_ 1.0 * clock() / CLOCKS_PER_SEC
//RNG based on mersenne_twister 
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
ll power(ll b,ll e,ll m)
{
	if(e==0) return 1;
	if(e&1) return b*power(b*b%m,e/2,m)%m;
	return power(b*b%m,e/2,m);
}
ll power( ll b, ll e)
{
	if(e==0) return 1;
	if(e&1) return b*power(b*b,e/2);
	return power(b*b,e/2);
}
template<typename T, typename U> static inline void amin(T &x, U y){ if(y<x) x=y; }
template<typename T, typename U> static inline void amax(T &x, U y){ if(x<y) x=y; }
ll phi[100005];
void computeTotient(ll n) 
{ 
    // Create and initialize an array to store 
    // phi or totient values 
    for (ll i=1; i<=n; i++) 
        phi[i] = i; // indicates not evaluated yet 
                    // and initializes for product 
                    // formula. 
  
    // Compute other Phi values 
    for (ll p=2; p<=n; p++) 
    { 
        // If phi[p] is not computed already, 
        // then number p is prime 
        if (phi[p] == p) 
        { 
            // Phi of a prime number p is 
            // always equal to p-1. 
            phi[p] = p-1; 
  
            // Update phi values of all 
            // multiples of p 
            for (ll i = 2*p; i<=n; i += p) 
            { 
               // Add contribution of p to its 
               // multiple i by multiplying with 
               // (1 - 1/p) 
               phi[i] = (phi[i]/p) * (p-1); 
            } 
        } 
    } 
}
ll _runtimeTerror_()
{
	ll n,k;
	cin>>n>>k;
	computeTotient(k+1);
	ll ans=0;
	for(ll i=1;i<=k;++i)
	{
		ans+=power(k/i,n,M)*phi[i]%M;
		ans%=M;
	}
	cout<<ans<<endl;
	return 0;
}

int main()
{
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	#ifdef runSieve
		sieve();
	#endif
	#ifdef NCR
		initialize();
	#endif
	ll TESTS=1;
	//cin>>TESTS;
	while(TESTS--)
		_runtimeTerror_();
	cerr<<"\n"<<_time_;
	return 0;
}


Measured memory_bytes: 4580
N = int(input())
s = input()

ans = ['SS', 'SW', 'WS', 'WW']
s += s[0]
for i in range(4):
    for j in range(1, N+1):
        if ans[i][j] == 'S':
            if s[j] == 'o':
                ans[i] += ans[i][j-1]
            else:
                if ans[i][j-1] == 'S':
                    ans[i] += 'W'
                else:
                    ans[i] += 'S'
        else:
            if s[j] == 'x':
                ans[i] += ans[i][j-1]
            else:
                if ans[i][j-1] == 'S':
                    ans[i] += 'W'
                else:
                    ans[i] += 'S'

    if ans[i][0] == ans[i][-2] and ans[i][1] == ans[i][-1]:
        print(ans[i][:-2])
        exit()

print(-1)

Measured memory_bytes: 3828
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);
  std::cerr << std::fixed << std::setprecision(6);

  int N;

  std::cin >> N;

  std::vector<int> a(N + 1, -1);

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

  std::vector<int> A;

  while (a.size() > 1) {
    int size = a.size() - 1, ii = -1;
    
    for (int i = 1, size = a.size() - 1; i <= size; i ++) {	// i in [1, size]
      if (a[i] == i) {
        bool valid = true;
        
        for (int j = i + 1; j <= size; j ++)
          if (a[j] == j) {
            valid = false;

            break;
          }

        if (! valid)
          continue;

        ii = i;

        break;
      }
    }

    if (ii == -1) {
      std::cout << -1 << std::endl;

      return 0;
    }

    A.push_back(ii);
    
    a.erase(std::begin(a) + ii);
  }
  
  for (auto it = A.rbegin(); it != A.rend(); ++ it)
    std::cout << *it << std::endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <limits.h>
#include <math.h>
#include <functional>
#include <bitset>

#define repeat(i,n) for (long long i = 0; (i) < (n); ++ (i))
#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i] << '\n'
#define debugArrayP(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i].first<< " " << x[i].second << '\n'

using namespace std;

typedef long long ll;
typedef pair<int,int> Pii;
typedef vector<int> vint;
typedef vector<ll> vll;
const ll INF = LLONG_MAX/10;
const ll MOD = 1e9+7;

int main(){
  int H,W;cin>>H>>W;
  vector<string> c(W,string(H,'?'));
  repeat(i,H){
    repeat(j,W){
      cin >> c[j][H-1-i];
    }
  }
  ll ans = 0;
  repeat(i,W-1){
    vector<vll> dp(H+2,vll(H+2,INF));
    dp[0][0]=0;
    vector<vll> cost(H+1,vll(H+1,0));
    repeat(dif,H+1){
      repeat(j,H-dif){
        cost[0][dif] += c[i][j]==c[i+1][j+dif];
      }
      repeat(k,H-dif){
        cost[k+1][k+1+dif] = cost[k][k+dif]-(c[i][k]==c[i+1][k+dif]);
      }
    }
    //debugArray(cost[0],H+1);
    repeat(dif,H+1){
      if(dif==0)continue;
      repeat(j,H-dif){
        cost[dif][0] += c[i][j+dif]==c[i+1][j];
      }
      repeat(k,H-dif){
        cost[k+1+dif][k+1] = cost[k+dif][k]-(c[i][k+dif]==c[i+1][k]);
      }
    }
    repeat(j,H+1){
      repeat(k,H+1){
        dp[j+1][k] = min(dp[j+1][k],dp[j][k]+cost[j][k]);
        dp[j][k+1] = min(dp[j][k+1],dp[j][k]+cost[j][k]);
      }
    }
    ans += dp[H][H];
    //sdebug(ans);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1844
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <list>
#include <ctime>
#include <sstream>
#include <queue>
#include <stack>
#include <bitset>
#include <numeric>
#include <cassert>
using namespace std;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;
#define FOR(x, b, e) for(int x=(b); x<=(e); ++x)
#define FORD(x, b, e) for(int x=((int)(b))-1; x>=(e); --x)
#define REP(x, n) for(int x=0; x<(n); ++x)
#define ALL(c) c.begin(),c.end()
#define sz(x) ((int)((x).size()))
#define pb push_back
#define st first
#define nd second
#define mp(x,y) make_pair(x,y)
typedef short int sint;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it) {
	*this << ((it != d.b) ? ", " : "") << *it;
  }
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

int main() {
	ios_base::sync_with_stdio(false);
	int n,k;
	cin >> n >> k;
	vi has(n);
	REP(i, k) {
		int d;
		cin >> d;
		REP(j, d) {
			int x;
			cin >> x;
			--x;
			has[x] = 1;
		}
	}
	int res = n;
	REP(i, n) if (has[i]) --res;
	cout << res << endl;
}

Measured memory_bytes: 3616
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		int x = input.nextInt();
		int y = input.nextInt();
		greatestCommonDivisor(x, y);

	}
	
	public static void greatestCommonDivisor(int x, int y) {
		while (y > 0) {
			int remainder = x % y;
			x = y;
			y = remainder;
		}
		System.out.println(x);
	}
}


Measured memory_bytes: 26052
import java.util.*

fun main(args: Array<String>) {
    val (N, M) = readLine()!!.split(" ").map{it.toInt()}
    val g = Graph(N, 0L, 0L) { x, y -> x + y }

    for (i in 1..M) {
        val (a, b) = readLine()!!.split(" ").map{it.toInt()}
        g.edges[a - 1].add(Edge(a - 1, b - 1, 0L))
        g.edges[b - 1].add(Edge(b - 1, a - 1, 0L))
    }

    val dp = Array(1 shl N) { Array(N) { 0 } }

    dp[1][0] = 1
    for (s in 1 until (1 shl N) - 1) {
        for (u in 0 until N) {
            if (s and (1 shl u) == 0) {
                continue
            }

            for (e in g.edges[u]) {
                if (s and (1 shl e.to) != 0) {
                    continue
                }

                val t = s or (1 shl e.to)
                dp[t][e.to] += dp[s][u]
            }
        }
    }

    println(dp[(1 shl N) - 1].sum())
}

data class Edge<T: Comparable<T>>(val from: Int, val to: Int, val weight: T): Comparable<Edge<T>> {
    constructor(from: Long, to: Long, weight: T) : this(from.toInt(), to.toInt(), weight)

    override fun compareTo(other: Edge<T>) = weight.compareTo(other.weight)
}

class Graph<T: Comparable<T>>(val n: Int, val zero: T, val inf: T, val plus: (T, T) -> T) {
    val edges = Array(n) { ArrayList<Edge<T>>() }
}



Measured memory_bytes: 37920
import java.util.*;

public class Main {
    public static void main(String... args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        ArrayList<Integer> d = new ArrayList();

        for (int i = 0; i < N; i++) {
            d.add(sc.nextInt());
        }
        sc.close();
        System.out.println(d.stream().distinct().count());
    }
}

Measured memory_bytes: 26964
import java.util.Scanner;

public class Main
{
    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        long a = sc.nextInt();
        long b = sc.nextInt();
        
        long m = a;
        long n = b;
        long r;
        
        if(m<n)
        {
            long swap = n;
            n = m;
            m = swap;
        }
        
        while(m%n != 0)
        {
            r = m%n;
            m = n;
            n = r;
        }
        
        a /= n;
        b /= n;
        
        long ans = a*b*n;
        
        //System.out.println(a + "*" + b +"*" + n);
        System.out.println(ans);
    }
}


Measured memory_bytes: 23124
using System;
using System.Linq;

namespace ABC119_C
{
    class Program
    {
        static int A, B, C, N;
        static int[] l;
        static void Main(string[] args)
        {
            var NABC = Console.ReadLine().Split().Select(int.Parse).ToArray();
            N = NABC[0];
            A = NABC[1];
            B = NABC[2];
            C = NABC[3];

            l = new int[N];
            for (int i = 0; i < N; i++)
            {
                l[i] = int.Parse(Console.ReadLine());
            }

            Console.WriteLine(Calc(0, 0, 0, 0));
        }

        static int Calc(int cnt, int a, int b, int c)
        {
            if (cnt == N) return a == 0 || b == 0 || c == 0 ? 100000 : Math.Abs(A - a) + Math.Abs(B - b) + Math.Abs(C - c) - 30;

            var pattern = new int[4];
            pattern[0] = Calc(cnt + 1, a, b, c);
            pattern[1] = Calc(cnt + 1, a + l[cnt], b, c) + 10;
            pattern[2] = Calc(cnt + 1, a, b + l[cnt], c) + 10;
            pattern[3] = Calc(cnt + 1, a, b, c + l[cnt]) + 10;

            return pattern.Min();
        }
    }
}


Measured memory_bytes: 13396