akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>

using namespace std;
typedef long long ll;

int ar[1000];

int main() {
	int n;
	cin >> n;
	int cnt = 0;
	bool f = true;
	for (int i = 0; i < n; i++) {
		string S;
		cin >> S;
		if (S == "A")cnt++;
		else cnt--;
		if (cnt < 0)f = false;
	}
	if (f && cnt > 0)f = false;
	if (f)cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}


Measured memory_bytes: 3152
#include<bits/stdc++.h>
#define STIZE(x) fprintf(stderr, "STIZE%d\n", x);
#define PRINT(x) fprintf(stderr, "%s = %d\n", #x, x);
#define NL(x) printf("%c", " \n"[(x)]);
#define lld long long
#define pii pair<int,int>
#define pb push_back
#define fi first
#define se second
#define mid (l+r)/2
#define endl '\n'
#define all(a) begin(a),end(a)
#define sz(a) int((a).size())
#define LINF 1000000000000000LL
#define INF 1000000000
#define EPS 1e-9
using namespace std;


int main() {
    ios::sync_with_stdio(false);cin.tie(0);
    lld K, A, B;
    cin >> K >> A >> B;
    lld rez = K+1;
    lld preostalo = K-A+1;
    if(K >= A-1) {
        if(B >= A) rez = max(K+1, preostalo/2*(B-A) + preostalo%2 + A);
    }
    cout << rez;
    return 0;
}


Measured memory_bytes: 256
import sys
from bisect import *
from heapq import *
from collections import *
from itertools import *
from functools import *
from math import *
from fractions import *

sys.setrecursionlimit(100000000)
input = lambda: sys.stdin.readline().rstrip()

N, M, C = map(int, input().split())
B = list(map(int, input().split()))
ans = 0
for _ in range(N):
    A = list(map(int, input().split()))
    if sum(i * j for i, j in zip(A, B)) + C > 0:
        ans += 1
print(ans)




Measured memory_bytes: 64876
/*
 * http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_5_A&lang=jp
 */

import java.util.*;
public class Main {
	int[] A;
	byte[][] dp;
	boolean solve(int m, int d) {
		//System.out.println(m + ", " + d);
		if (d >= A.length) return false;
		if (dp[m][d] == 1) return true;
		else if (dp[m][d] == -1) return false;
		int x = m - A[d];
		if (x == 0) return true;
		else {
			boolean b = solve(m, d+1);
			if (!b && x > 0) b = solve(x, d+1);
			dp[m][d] = (byte) (b ? 1 : -1);
			return b;
		}
	}
	
	void run() {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		A = new int[n];
		for (int i = 0; i < n; i++) A[i] = sc.nextInt();
		int q = sc.nextInt();
		for (int i = 0; i < q; i++) {
			int m = sc.nextInt();
			dp = new byte[m+1][A.length];
			if (solve(m, 0)) System.out.println("yes");
			else System.out.println("no");
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}

}



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

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef priority_queue<int> PQ_DESC;
typedef priority_queue<int, vector<int>, greater<int>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define SORT_ASC(c) sort(ALL(c))
#define SORT_DESC(c) sort(ALL(c), greater<typeof(*((c).begin()))>())
#define SIZE(a) int((a).size())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ROF(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n) FOR(i,0,n)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int LARGE_INT = 1e9+100;
const int INF = 2e9+100;

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

void Main()
{
	int n; cin>>n;
	
	VI l(n);
	REP(i, n) cin >> l[i];

	SORT_ASC(l);



	int result = 0;
	FOR(i,0,n){
		FOR(j,i+1,n){
			result += lower_bound(ALL(l),l[i]+l[j])-l.begin()-j-1;
		}
	}

	cout << result << endl;
	

	return;
}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(long long i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using ll = long long;
using P = pair<int, int>;
const int mod = 1000000007;


int main(){
    ll n;
    cin >> n;
    vector<ll> a(n);
    ll sum = 0;
    rep(i, n) {
        cin >> a[i];
        sum += a[i];
    }
    
    vector<ll> x(n);

    ll temp = 0;
    rep(i, n) {
        if (i%2==1) {
            temp += a[i];
        }
    }
    temp *= 2;
    x[0] = sum - temp;
    cout << x[0] << " ";
    rep(i, n-1) {
        x[i+1] = 2 * a[i]- x[i];
        cout << x[i+1] << " ";
    }

    cout << endl;

    return 0;
}


Measured memory_bytes: 2944
#include<bits/stdc++.h>
#define ll long long int
#define llu unsigned long long int
#define vi vector<int>
#define vll vector<ll>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define pb push_back
#define M 1000000007
#define endl "\n"
using namespace std;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    int n; cin>>n;
    int arr[n+1];
    rep(i,n) cin>>arr[i];
    ll dp[n+1];
    dp[0]=0;
    dp[1]=abs(arr[0]-arr[1]);
    for(int i=2;i<n;i++)
        dp[i]=min(dp[i-1]+abs(arr[i]-arr[i-1]),dp[i-2]+abs(arr[i]-arr[i-2]));
    cout<<dp[n-1]<<"\n";
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
typedef long long ll;

const int maxn = 2e5 + 10;
int n , ans[maxn] , a[maxn];

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(NULL);
	cin >> n;
	for(int i=0;i<n;i++) cin >> a[i];
	int j = n - 1 , k = 0;
	for(int i=n-1,ct=0;i>=0;i--,ct++)
	{
		if(ct % 2 == 0) ans[k++] = a[i];
		else ans[j--] = a[i];
	}
	for(int i=0;i<n;i++) cout << ans[i] << " ";
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
#define dhoom ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);  
typedef long long ll;
typedef long double ld;
const ll inf = 1e18;
const int nax = 2e6 + 7;
const ll mod = 1e9 + 7;
//ll tree[4 * nax];
//9uS-22RSwk7gQqh
int count(ll x){
	int cnt = 0;
	while(x != 0){
		cnt++;
		x /= 10;
	}
	return cnt;
}
int main()
{
	int a , b , c;
	cin >> a >> b >> c;
	int num = a*100 + b * 10 + c;
	if(num % 4 == 0)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
	return 0;
} 




Measured memory_bytes: 256
main(i,n,x,a,b,c,p,q,r){
  char s[6];
  for(;scanf("%d",&n),n;printf("%d\n",x)){
    for(x=1,a=1,b=2,c=3,i=0;i<n;i++){
      scanf("%s",s);
      switch(*s){
        case 'L':
          p=a,  q=7-c,r=b;   break;
        case 'R':
          p=a,  q=c,  r=7-b; break;
        case 'N':
          p=b,  q=7-a,r=c;   break;
        case 'S':
          p=7-b,q=a,  r=c;   break;
        case 'E':
          p=7-c,q=b,  r=a;   break;
        case 'W':
          p=c,  q=b,  r=7-a; break;
      }
      a=p,b=q,c=r;x+=a;
    }
  }
  return 0;
}

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

#define rep(i,n) for (decay_t <decltype (n)> i = 0, i ## __len = (n); i < i ## __len; ++ i)

auto main () -> int
{
  cin.tie (nullptr);
  ios::sync_with_stdio (false);

  size_t n, w;
  cin >> n >> w;

  vector <vector <int64_t>> value (n + 1, vector <int64_t> (w + 1, 0));
  // value[i][j] = i番目までのitemのうち、重さj入れた中身の価値の最大

  rep (i, n)
  {
    size_t wi;
    int64_t vi;
    cin >> wi >> vi;

    rep (j, w + 1)
    {
      value [i + 1] [j] = max (value [i + 1] [j], value [i] [j]);
      if (j + wi > w) continue;
      value [i + 1] [j + wi] = max (value [i + 1] [j + wi], value [i] [j] + vi);
    }
  }

  int64_t ans = 0;
  rep (j, w + 1)
  {
    ans = max (ans, value [n] [j]);
  }
  cout << ans << endl;
}



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

using ll = long long; 
using P = pair<int,int>;

int main() {

  string s;
  cin >> s;

  int N = s.size();
  int count = 0;
  rep(i,N){
    if (s.at(i)!=s.at(N-i-1) && i < N-i-1){
      count++;
    }
  }
  cout << count << endl;
  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <utility>
#include <map>
 
using namespace std;
 
constexpr int MOD = 1e9 + 7;
 
vector<vector<int>> tree;
vector<vector<int>> dp;
 
size_t solution(int v, int p, bool black)
{ 
  if (dp[v][black] != -1)
  { 
    return dp[v][black];
  }
  auto& nodes = tree[v];
  size_t res = 1;
  for (auto n : nodes)
  { 
    if (n == p) continue;
    if (black)
    { 
      res *= solution(n, v, !black);
      res %= MOD;
    }
    else
    { 
      res = (res * (solution(n, v, !black) + solution(n, v, black))) % MOD;
    }
  }
  dp[v][black] = res;
  return res;
}
 
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(0);
 
  int N;
  cin >> N;
 
  tree = vector<vector<int>>(N+1);
  dp = vector<vector<int>>(N+1, vector<int>(2, -1));
 
  for (int i = 0; i < N-1; ++i)
  {
    int x, y;
    cin >> x >> y;
    tree[x].push_back(y);
    tree[y].push_back(x);
  }
 
  cout << (solution(1, 0, true) + solution(1, 0, false)) % MOD << endl;
 
  return 0;
}

Measured memory_bytes: 21904
#include <bits/stdc++.h>
typedef long long int LL;
typedef unsigned long long int ULL;
using namespace std;

// 插入此處
namespace Number {
    typedef long long int LL;
    // 求取 a, b 的最大公因數
    LL gcd(LL a, LL b) {
        if (a % b == 0) {
            return b;
        }
        return gcd(b, a % b);
    }
    // 求取 a, b 的最大公因數 gcd
    // 以及 x, y 使得 a*x + b*y = gcd
    LL gcd_extend(LL a, LL b, LL *x, LL *y) { 
        if (a == 0) { 
            *x = 0, *y = 1; 
            return b; 
        } 
    
        LL x1, y1; // To store results of recursive call 
        LL gcd = gcd_extend(b%a, a, &x1, &y1); 
    
        *x = y1 - (b/a) * x1; 
        *y = x1; 
    
        return gcd; 
    }
    // 求 a_inv 使得 (a * a_inv) % m = gcd(a, m)
    // 若 a, m 互質，即求 a 在 mod m 群的反元素 a_inv 
    LL mod_inv(LL a, LL m) { 
        LL x, y; 
        LL g = gcd_extend(a, m, &x, &y); 
        // 處理 x 爲負的情形 
        LL a_inv = (x%m + m) % m; 
        return a_inv;
    }
    // 求 x^n % m
    LL mod_pow(LL x, LL n, LL m) {
        if (n == 0) {
            return 1;
        } else if (n & 1) {
            LL half = mod_pow(x, n/2, m);
            return (half * half % m) * x % m;
        } else {
            LL half = mod_pow(x, n/2, m);
            return half * half % m;
        }
    }
    // 連乘
    LL mul(LL from, LL to, LL m) {
        LL ret = 1;
        for (LL i = from; i <= to; i++) {
            ret *= i;
            ret %= m;
        }
        return ret;
    }
    // 求 (C n 取 k) % m
    LL mod_comb(LL n, LL k, LL m) {
        LL mi = k < n-k ? k : n-k;
        LL up = mul(n - mi + 1, n, m);
        LL down = mul(1, mi, m);
        return (up * mod_inv(down, m)) % m;
    }
}
  
const int MAXN = 1e5 + 2;
const int MOD = 1e9 + 7;
LL f[MAXN];

int main() {
    std::ios::sync_with_stdio(false);
    cin.tie(0);
    int N, K; cin >> N >> K;
    int cnt[MAXN];
    memset(cnt, 0, sizeof(cnt));
    for (int i = 1; i <= K; ++i) {
        f[i] = Number::mod_pow(K/i, N, MOD);
        // cout << f[i] << ' ';
    }
    // cout << endl;
    LL ans = 0;
    for (int i = 1; i <= K; ++i) {
        ans = (ans + (i - cnt[i]) * f[i]) % MOD;
        for (int j = 2; i * j <= K; ++j) {
            cnt[i*j] += (i - cnt[i]);
        }
        // cout << ans << endl;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4740
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B,L,R;
string S,T;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

typedef vector<P> vp;
typedef vector<vp> matP;

int main(){
    ll C, X, Y;
    cin>>A>>B>>C>>X>>Y;
    ll ans = 1e+18;
    for(ll i = 0; i <= max(X,Y)*2; i += 2){
        ll temp = C*i;
        temp += max(0LL, X - i/2)*A;
        temp += max(0LL, Y - i/2)*B;
        ans = min(ans, temp);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  char X, Y;
  cin >> X >> Y;
  int i,j; 
  if(X == 'A') i = 10; 
  else if(X == 'B') i = 11; 
  else if(X == 'C') i = 12; 
  else if(X == 'D') i = 13; 
  else if(X == 'E') i = 14; 
  else if(X == 'F') i = 15; 
  if(Y == 'A') j = 10; 
  else if(Y == 'B') j = 11; 
  else if(Y == 'C') j = 12; 
  else if(Y == 'D') j = 13; 
  else if(Y == 'E') j = 14; 
  else if(Y == 'F') j = 15; 
  if (i<j) cout << "<" << endl; 
  if (i==j) cout << "=" << endl;
  if (i>j) cout << ">" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include <vector>
#include <cstdlib>
#include<algorithm>
#include<string>
#include<cmath>
#include<math.h>
#include <list>
#define ll long long 
using namespace std;
vector <ll> arr (100000);


int main() {
   ll h,w;
   cin>>h>>w;
   vector <vector <ll>> arr (h+1,vector <ll> (w+1,0));
   for( ll i=0;i<=h;i++)
   {
     for(ll j=0;j<=w;j++)
     arr[i][j]=-1;
   }
   for( ll i=0;i<=h;i++)
   {
     for(ll j=0;j<=w;j++)
     {
       if(i==0 || j==0)
       {
         arr[i][j]=0;
         continue;
       }
       char a;
       cin>>a;
       if(a=='#')
       arr[i][j]=0;
     }
   }
   arr[0][1]=1;
   for(ll i=1;i<=h;i++)
   {
     for(ll j=1;j<=w;j++)
     {
       if(arr[i][j]==0)
       continue;
       arr[i][j]=(arr[i-1][j]+arr[i][j-1])%1000000007;
     }

   }
  /* for(ll i=1;i<=h;i++)
   {
     for(ll j=1;j<=w;j++)
     {
    
       cout<<arr[i][j]<<" ";
     }
     cout<<endl;

   }
   */
   cout<<arr[h][w]<<endl;
  // cin>>h;
return 0;
	// Write your code here
}

Measured memory_bytes: 11792
#include <iostream>
#include <vector>
#include <utility>
#include <numeric>
#include <functional>
#include <stdio.h>
#include <math.h>
#include <string>
#include <algorithm>
#include <deque>
#include <queue>
#include <map>

#define rep(i, m, n) for (int (i)(m); (i)<(n); ++(i))
#define repr(i, m, n) for (int (i)(m - 1); (i)>=(n); --(i))
#define repv(i, v) for (unsigned (i)(0); (i)<(v.size()); ++(i))
#define all(v) (v).begin(), (v).end()
#define sortv(v) sort(all(v))
#define sortgi(v) sort(all(v), greater<int>())
#define sortgd(v) sort(all(v), greater<double>())
#define sortgll(v) sort(all(v), greater<ll>())
#define debug(x) cerr << #x << ": " << x << '\n'

using namespace std;
using pii = pair<int, int>;
using pss = pair<string, string>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vd = vector<double>;
using vvd = vector<vd>;
using vs = vector<string>;
using ll = long long;
using pllll = pair<ll, ll>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvvb = vector<vvb>;
using pqi = priority_queue<int>;
using pqd = priority_queue<double>;
using pqll = priority_queue<ll>;
using pqvi = priority_queue<vi>;
using pqvll = priority_queue<vll>;

int main() {
	int N;
	cin >> N;
	int sum = 0;
	rep(i, 0, N) {
		int a;
		cin >> a;
		sum += a - 1;
	}
	cout << sum << endl;
	return 0;
}


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

int main() {
    string s1, s2;
    cin>>s1>>s2;
    if(s1==s2) {
        cout<<"Yes";
        return 0;
    }
    int c = 0;
    for(int i=0;i<s1.size();++i) {
        string x, y;
        for(int j=0;j<=i;++j) x+=s1[j];
        for(int j=i+1;j<s1.size();++j) y+=s1[j];
        string z=y+x;
        if(z==s2) {
            c=1;
            break;
        }
    }
    if(c) cout<<"Yes";
    else cout<<"No";
    return 0;
}

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

#include <atcoder/all>
using namespace atcoder;
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = (ll)1e18;
const ll MOD = 1000000007;
int main() {
  string s = "ACL";
  int n;
  cin >> n;
  REP(i, n) { cout << s; }
  cout << endl;
}

Measured memory_bytes: 3604
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int N = in.nextInt();
		long[] A = new long[N];
		for (int i = 0; i < N; i++) {
			A[i] = in.nextLong() - (i + 1);
		}
		Arrays.sort(A);
		long b = A[N / 2];
		long ans = 0;
		for (int i = 0; i < N; i++) {
			ans += Math.abs(A[i] - b);
		}
		System.out.println(ans);
		in.close();
	}
}

Measured memory_bytes: 66776
import sys
input = sys.stdin.readline
N,M = map(int,input().split())
ABC = [tuple(map(int,input().split())) for i in range(N)]
DEF = [tuple(map(int,input().split())) for i in range(M)]
INF = float('inf')

def solve():
    xs = set([-INF,0,INF])
    ys = set([-INF,0,INF])
    for a,b,c in ABC:
        xs.add(a)
        xs.add(b)
        ys.add(c)
    for d,e,f in DEF:
        xs.add(d)
        ys.add(e)
        ys.add(f)
    xs = sorted(xs)
    ys = sorted(ys)
    xd = {x:i*2 for i,x in enumerate(xs)}
    yd = {y:i*2 for i,y in enumerate(ys)}

    W = len(xs)*2 - 1
    H = len(ys)*2 - 1
    S = [[0]*W for _ in range(H)]
    for y in (0,-1):
        for x in range(W):
            S[y][x] = 1
    for x in (0,-1):
        for y in range(H):
            S[y][x] = 1
    for a,b,c in ABC:
        for x in range(xd[a], xd[b]+1):
            S[yd[c]][x] = 1
    for d,e,f in DEF:
        for y in range(yd[e], yd[f]+1):
            S[y][xd[d]] = 1

    from collections import deque
    sx,sy = xd[0]+1, yd[0]+1
    q = deque([(sx,sy)])
    visited = [[0]*W for _ in range(H)]
    visited[sy][sx] = 1
    dxy = [(0,1),(1,0),(0,-1),(-1,0)]
    ans = (xs[sx//2+1] - xs[sx//2]) * (ys[sy//2+1] - ys[sy//2])
    while q:
        x,y = q.popleft()
        for dx,dy in dxy:
            nx,ny = x+dx,y+dy
            if S[ny][nx] == 1: continue
            nnx,nny = nx+dx,ny+dy
            if visited[nny][nnx]: continue
            visited[nny][nnx] = 1
            q.append((nnx,nny))
            tx,ty = (nx,nny) if nx%2 else (nnx,ny)
            assert tx%2 and ty%2
            w = xs[tx//2+1] - xs[tx//2]
            h = ys[ty//2+1] - ys[ty//2]
            ans += w*h
            if ans==INF:
                print('INF')
                exit()
    print(ans)
solve()

Measured memory_bytes: 714628
#include<iostream>

using namespace std;

int main(){
  int P,N,ndata[55],wan,lop;
  while(1){
    cin>>N;
    cin>>P;
    if(N==0&&P==0){
      break;
    }
    for(lop=0;lop<N;lop++){
      ndata[lop]=0;
    }
    lop=0;
    wan=P;
    while(1){
      if(N==3&&P==3){
        lop=0;
        cout<<lop<<endl;
        break;
      }
      for(lop=0;lop<N;lop++){
        if(wan!=0){
          wan--;
          ndata[lop]++;
        }else{
          wan=wan+ndata[lop];
          ndata[lop]=0;
        }
        /*cout<<"wan="<<wan<<endl;
        for(lop=0;lop<N;lop++){
          cout<<lop<<"  "<<ndata[lop]<<endl;
        }
        cout<<endl;*/
        if(ndata[lop]==P&&wan==0){
          break;
        }
      }
      if(ndata[lop]==P&&wan==0){
        cout<<lop<<endl;
        break;
      }
    }

  }
  return 0;
}

Measured memory_bytes: 3060
MAX = 10**5
fib = [0]*MAX

def fibonacci(n):
    if fib[n]:
        return fib[n]
    if n == 0 or n == 1:
        return 1
    
    fib[n] = fibonacci(n-1)+fibonacci(n-2)
    return fib[n]

N = int(input())
print(fibonacci(N))



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

int main() {
    int N;
    cin >> N;
    vector<int>d(N);
    for (int i = 0; i < N; ++i) {
      cin >> d[i];
    }
    if(N % 2 == 1){
        cout << 0;
        return 0;
    }
    sort(d.begin(), d.end());
    int ans = d[N/2] - d[N/2 - 1];
    cout << ans;
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <bits/stdc++.h>
#include <string>
#include <vector>

using namespace std;

int main() {
  
  int a,b,c,d ;
  cin >>a>>b>>c>>d ;

  int l = max(a,c) ;
  int m = min(b,d) ;

  if(l>m) cout << 0 ;
  else cout << m-l ;

  cout << endl ;
  
}

Measured memory_bytes: 256
#include <iostream>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <bits/stdc++.h>
#define FIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
using namespace std;
using namespace __gnu_pbds;

typedef tree<pair<long long int,long long int>,null_type,less<pair<long long int,long long int> >,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

void go()
{
    int a,b,c,k;
    cin>>a>>b>>c>>k;
    int cnt=0;
    while(b<=a)
        b*=2,cnt++;
    while(c<=b)
        c*=2,cnt++;
    if(cnt > k)
        cout<<"No";
    else
        cout<<"Yes";
}
int main()
{
    FIO;
//    int t;
//    cin>>t;
//    while(t--)
        go();
    return 0;
}


Measured memory_bytes: 3644
const input=require('fs').readFileSync('/dev/stdin', 'utf8').split(/[\s]/);const nin=()=>{const r = input[0];input.shift();return Number(r)};const nrin=(n)=>{const a:number[]=[];rep(n,()=>a.push(nin()));return a};const sin=()=>{const r = input[0];input.shift();return String(r)};const out=(...a)=>{console.log(...a)};const floor=(a)=>{return Math.floor(a)};const abs=(a)=>{return Math.abs(a)};const min=(...a)=>{return Math.min(...a)};const max=(...a)=>{return Math.max(...a)};const rep=(n, callback)=>{for(let i = 0;i < n; i++){callback()}};const strrep=(s, i, v)=>{return s.slice(0, i)+v+s.slice(i+1);};const permutation=({result=[],pre=[],post,n=post.length})=>{if(n>0){post.forEach((_,i)=>{const rest=[...post];const elem=rest.splice(i, 1);permutation({result, pre: [...pre,...elem],post:rest,n:n-1})})}else{result.push(pre)}return result};const sw=(s,a:any[],op:'=='|'>='|'>'|'<='|'<'='==')=>{for(let i=0;i<a.length;i+=2){if(op==='=='){if(s==a[i])return a[i+1]}else if(op==='>='){if(s>=a[i])return a[i+1]}else if(op==='<='){if(s<=a[i])return a[i+1]}else if(op==='>'){if(s>a[i])return a[i+1]}else if(op==='<'){if(s<a[i])return a[i+1]}}return a[a.length-1];};const or=(a,...b)=>{for(let i=0;i<b.length;i++)if(a==b[i])return true;return false};const maxindex=(...a)=>{return a.indexOf(Math.max.apply(null,a))};const asc=(ar:number[])=>{return ar.sort((a,b)=>{return a-b})};const desc=(ar:number[])=>{return ar.sort((a,b)=>{return b-a})};const ceil=a=>{return Math.ceil(a)};const srin=s=>{const a:string[]=[];rep(s,()=>a.push(sin()));return a};let ssinteger=-1;const ssin=()=>{ssinteger++;return input[0][ssinteger]};
const main = ()=>{
  out(sw(sin(),[
    'a', 'vowel',
    'e', 'vowel',
    'i', 'vowel',
    'o', 'vowel',
    'u', 'vowel',
    'consonant'
  ]))
}
main()

Measured memory_bytes: 7372
def solve(s):
  cnt="abcdefghijklmnopqrstuvwxyz"
  res=[0 for x in range(26)]
  for i in range(len(s)):
    a=cnt.index(s[i])
    res[a]+=1
  for i in range(26):
    if res[i]==0:
      return s+cnt[i]

def solve26(ss):
  s=ss
  cnt="abcdefghijklmnopqrstuvwxyz"
  pos=s[-1]
  res=cnt.index(pos)+1
  s=s[:-1]
  for i in range(res,26):
    jud=True
    pos=cnt[i]
    for j in range(len(s)):
      if s[j]==cnt[i]:
        jud=False
        break
    if jud:
      return s+pos
  return solve26(s)

S=input()
if len(S)==26 and S=='zyxwvutsrqponmlkjihgfedcba':
  print(-1)
elif len(S)==26:
  S=solve26(S)
  print(S)
else:
  S=solve(S)
  print(S)

Measured memory_bytes: 3064
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define INF (1e9)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
const long double PI = acos(-1.0L);
const long long MOD = 1000000007LL;
// const long long MOD = 998244353LL;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
template<class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true;} return false; }
template<class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true;} return false; }
////////////////////////////////////////////////////////////////////////////////////////////////////////

ll N,K;

ll f(int x, vector<pll> A) {
    ll val = 0;
    if (x < 0) {
        for (auto i : A) val += i.second;
        return val;
    }
    vector<pll> B;
    if (K & (1LL<<x)) {
        for (auto i : A) {
            if (i.first & (1LL<<x)) continue;
            val += i.second;
        }
        return max(val, f(x-1,A));
    } else {
        for (auto i : A) {
            if (i.first & (1LL<<x)) continue;
            B.emplace_back(i);
        }
        return f(x-1,B);
    }
}

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    cin >> N >> K;
    vector<pll> A(N);
    rep(i,N) cin >> A[i].first >> A[i].second;

    cout << f(30,A) << endl;
}

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

long long int a[100005] = {0};

int main(){
      int n;
      cin >> n;
      for(int i = 0; i < n; i++){
        cin >> a[i];
      }
      sort(a, a + n);
      long long int x = 0, y = 0;
      for(int  i = n - 1; i >= 0; i--){
        if(a[i] == a[i - 1]){
            if(x == 0){
                x = a[i];
            }else if(y == 0){
                y = a[i];
                break;
            }
            i--;
        }
      }
      cout << x * y << '\n';
}


Measured memory_bytes: 1024
#include <iostream>

using namespace std;

bool in_group2(int a){
	if (a ==4 || a == 6 || a == 9 || a ==11){
		return true;
	}else{
		return false;
	}
}

int main()
{
	int x,y;
	cin >> x >> y;
	
	if (x==2 || y==2){
		cout << "No\n";
	}else{
		bool x_group2 ,y_group2;
		x_group2 = in_group2(x);
		y_group2 = in_group2(y);
		if (x_group2==y_group2){
			cout << "Yes\n";
		}else{
			cout<< "No\n";
		}
	}

}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<deque>
#include<cstdlib>
#include<cstring>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<stack>
#include<iomanip>
#include<sstream>
using namespace std;

#define pi acos(-1.0)
#define ms(x,n) memset(x,n,sizeof(x));

typedef long long ll;//string::npos
typedef long long iint;

ll gcd(ll a,ll b) {
	return a%b==0?b:gcd(b,a%b);
}
ll lcm(ll x,ll y) {
	ll z=gcd(x,y);
	return x*y/z;
}

const int MAXX=2e5+5;
const int INF=1e7+5;
const int mod=998244353;

//vector<int> vt;
//pair<int,int> p;
//map<int,int> m;
int main() {
	ios::sync_with_stdio(false);
	
	int x;
	cin>>x;
	int q=x/500;
	x=x%500;
	int e=x/5;
	cout<<q*1000+e*5<<endl;
	
	
	
	
	
	
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define mp make_pair
#define pb(x) push_back(x)
#define vll vector<long long>
#define pll pair<long long, long long>
#define mll map<long long, long long>
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
#define gcd __gcd
#define clr(x) memset(x, 0, sizeof(x))
#define mod 1000000007LL
#define mod2 998244353LL
#define INF 1e18
 

typedef long long ll;
typedef long double ld;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> o_tree;

const int N=1e5+5;
vll v[N];
ll vis[N];
vll path;
ll maxh[N];
ll f=0;

void dfs(ll x,ll s,ll dest)
{
  if(f)return;
  if(x==dest)
  {
    f=1;
    path.pb(x);
    return;
  }
  path.pb(x);
  for(auto it:v[x])
  {
    if(it==s)continue;
    dfs(it,x,dest);
  }
  if(f)return;
  path.pop_back();
}

void dfs2(ll x,ll s)
{
  ll f=0;
  // cout<<x+1<<"\n";
  for(auto it:v[x])
  {
    if(it==s)continue;
    f=1;
    dfs2(it,x);
    maxh[x]=max(maxh[x],maxh[it]+1ll);
  }
  if(!f)
  {
    maxh[x]=1;
  }
}



void solve()
{
  ll n;
  cin>>n;
  ll aa,bb;
  cin>>aa>>bb;
  aa--,bb--;
  ll i,j;
  for(i=1;i<n;i++)
  {
    ll x,y;
    cin>>x>>y;
    x--,y--;
    v[x].pb(y);
    v[y].pb(x);
  };
  dfs(aa,-1,bb);
  // for(auto it:path)
  // {
  //   cout<<it+1<<" ";
  // }
  // all i need is max height of subtree 
  dfs2(bb,-1);
  ll maxi=0;
  for(i=1;i<sz(path);i++)
  {
    // distance travelled to reach node path[i] = i; 
    ll dist_1 = i;
    ll dist_from_bb = sz(path)-1-i;
    if(dist_1>dist_from_bb)continue;
    ll maxheight = maxh[path[i]]-1;
    ll dif = dist_from_bb-dist_1;
    ll tans = dist_1;
    tans+=(dif+(maxheight-1));
    // ll tans = (maxheight)+dist_from_bb;
    // cout<<dif<<" "<<maxheight<<" "<<dist_from_bb<<" ";
    // cout<<path[i]+1<<"<-- "<<tans<<"\n";
    maxi=max(maxi,tans);
  }
  cout<<maxi<<"\n";
  
}


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


if (fopen("input.txt","r" ))
  {
     freopen("input.txt", "r", stdin);
     freopen("output.txt", "w", stdout);
  }
cout<<setprecision(20);


ll t=1;


// cin>>t;


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


return 0;
}

Measured memory_bytes: 15320
#include<bits/stdc++.h>
using namespace std;
 
#define int         long long
#define pb          push_back
#define mp          make_pair
#define scan(a, n)  for(int i = 0; i < n;i++)cin >> a[i];
#define print(a, n) for(int i = 0; i < n;i++)cout << a[i] <<' ';cout<<endl;
#define w(x)        int x; cin>>x; while(x--)
#define endl 		'\n'
#define Sort(v) 	sort(v.begin(), v.end())
// Tushar Goyal

const int INF = 1e9+5;
void solve() 
{
	int i, j, k, q ,n, m, ans = 0, cnt = 0, sum = 0,input;
	cin>>n>>k;
	vector<int> h(n);
	scan(h,n);
	// print(h,n);
	vector<int> dp(n,INF);
	dp[0] = 0;
	for(int i = 0 ; i<n ; i++){
		for(int j=i+1;j<=i+k and j<n;j++){
			dp[j] = min(dp[j],dp[i] + abs(h[j]-h[i]));
		}
	}

	cout<<dp[n-1]<<endl;

}
 
int32_t main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//    w(T)
    {
	    solve();
    }
    return 0;
}

Measured memory_bytes: 1792
/*
 * Codeforces Contest
 * Au: Lost_Deviation
 */
#ifndef open_dbg_func
#define err(args...)
#endif
#include <bits/stdc++.h>
using namespace std;
#define ll long long
static auto XxXOxO = []() {
    std::ios::sync_with_stdio(false); // turn off sync
    cin.tie(nullptr);                 // untie in/out streams
    return 0;
}();
struct T {
    int x, y;
};
int cmp(const T &a, const T &b) {
    if (a.x != b.x)
        return (a.x < b.x);
    else
        return (a.y < b.y);
}
int a[32] = {1, 1, 1, 2, 1, 2, 1, 5,  2, 2, 1, 5, 1, 2, 1, 14,
             1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
const double esp = 1e-8;
int main(void) {
    ll a, b, c;

    cin >> a >> b >> c;
    err(4 * a * b);
    if (a + b > c)
        cout << "No";
    else if (4 * a * b < (c - a - b) * (c - a - b))
        cout << "Yes";
    else
        cout << "No";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef pair<int,int> P;
constexpr int mod = 1e9+7;
int main(){
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  
  vector<int> dp(k+2,0);
  dp[0] = 1;
  rep(i,n) {
    vector<int> cum(k+2,0);
    rep(j,k+1) (cum[j+1] =  cum[j] + dp[j]) %= mod;
    rep(j,k+1) (dp[j] = (cum[j+1] - cum[max(0,j-a[i])]) + mod ) %= mod;
  }
  cout << dp[k] << endl;
  return 0;
} 

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

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll; typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename A,size_t N,typename T>void Fill(A(&array)[N],const T &val){fill((T*)array, (T*)(array+N), val);}
const int inf = INT_MAX / 2; const ll INF = LLONG_MAX / 2;
//template end



int main(){
    int n; scanf("%d",&n);
    vector<int> a(n),b(n),c(n-1);
    rep(i,0,n)scanf("%d",&a[i]),a[i]--;
    rep(i,0,n)scanf("%d",&b[i]);
    rep(i,0,n-1)scanf("%d",&c[i]);
    ll ans=0;
    int pre=-inf;
    for(int i:a){
        ans+=b[i];
        if(pre==i-1)ans+=c[i-1];
        pre=i;
    }
    printf("%lld\n",ans);
    return 0;
}

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

#if MYDEBUG
#include "lib/cp_debug.hpp"
#else
#define DBG(...) ;
#endif
#if __cplusplus <= 201402L
template <typename T>
T gcd(T a, T b) { return ((a % b == 0) ? b : gcd(b, a % b)); }
template <typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }
#endif
using LL = long long;
constexpr LL LINF = 334ll << 53;
constexpr int INF = 15 << 26;
constexpr LL MOD = 1E9 + 7;

namespace Problem {
using namespace std;

class Solver {
 public:
  int n;
  vector<LL> a, b;
  Solver(LL n) : n(n), a(n), b(n){};

  void solve() {
    for (int i = 0; i < n; ++i) {
      cin >> a[i] >> b[i];
    }
    vector<int> p(n);
    iota(p.begin(), p.end(), 0);
    sort(p.begin(), p.end(), [&](int x, int y) { return abs(a[x] + b[x]) > abs(a[y] + b[y]); });
    LL ta = 0, ao = 0;
    for (int i = 0; i < n; ++i) {
      if (i % 2 == 0) {
        ta += a[p[i]];
      } else {
        ao += b[p[i]];
      }
    }
    cout << ta - ao << endl;
  }
};
class Solver2 {
 public:
  int n, m;
  Solver2(LL n, LL m) : n(n), m(m){};

  void solve() {
  }
};
}  // namespace Problem

int main() {
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(false);
  // std::cout << std::fixed << std::setprecision(12);
  long long n = 0;
  std::cin >> n;

  Problem::Solver sol(n);
  sol.solve();
  return 0;
}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
int f[3010][3010];
int main()
{
	string s,t;
	char ans[3010];
	cin>>s>>t;
	int idx=0;
	for(int i=1;i<=s.size();i++)
		for(int j=1;j<=t.size();j++)
	{
		f[i][j]=max(f[i-1][j],f[i][j-1]);
		if(s[i-1]==t[j-1])
		{
			f[i][j]=max(f[i][j],f[i-1][j-1]+1);
		}
	}
	int i=s.size(),j=t.size();
	while(i&&j)
	{
		if(s[i-1]==t[j-1])
		{
			ans[idx++]=s[i-1];
			i--,j--;
		}
		else if(f[i-1][j]>f[i][j-1])i--;
		else j--;
	}
	for(int i=idx-1;i>-1;i--)cout<<ans[i];

   return 0;
}


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

int main() {
  int A,B,cnt=0;
  cin >> A >> B;
  for(int a=1; a<10; a++) {
    for(int b=0; b<10; b++) {
      for(int c=0; c<10; c++) {
        int x=10001*a+1010*b+100*c;
        if(A<=x && x<=B) {
          cnt++;
        }
      }
    }
  }
  cout << cnt << endl; 
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using Graph=vector<vector<int>>;
using P=pair<int,int>;


ll i,j,k,ans;
vector<ll> size;
vector<ll> island;

//Union find(begin)
void makeTree(ll x,vector<ll>& parents) {
    parents[x] = x;  // the parent of x is x
    size[x] = 1;
}
ll findRoot(ll x,vector<ll>& parents) {
    if (x != parents[x]) {
        parents[x] = findRoot(parents[x],parents);
    }
    return parents[x];
}
bool isSame(ll x,ll y,vector<ll>& parents) { return findRoot(x,parents) == findRoot(y,parents); }
bool unite(ll x,ll y,vector<ll>& parents) {
    x = findRoot(x,parents);
    y = findRoot(y,parents);
    if (x == y) return false;
    if (size[x] > size[y]) {
        parents[y] = x;
        size[x] += size[y];
    } else {
        parents[x] = y;
        size[y] += size[x];
    }
    return true;
}

ll treeSize(ll x,vector<ll>& parents) { return size[findRoot(x,parents)]; }
//Union find(end)
//今回はsizeがkeyなのでsizeによるUnion findを行う

int main(){
    ll n,m;cin>>n>>m;
    vector<ll> ans(m);//答え
    vector<P> p(m);//橋の順番を記憶する
    
    size.assign(n,1);//サイズはつなぐ前は1
    island.resize(n);

    for(i=0;i<n;i++){//dataの作成
        makeTree(i,island);
    }

    for(i=0;i<m;i++){//島をつなぐデータを保存
        ll a,b;cin>>a>>b;
        a--;b--;
        p[i]=make_pair(a,b);
    }

    ll number=n*(n-1)/2;
    ans[m-1]=number;
    for(i=m-1;i>=1;i--){
        if(!isSame(p[i].first,p[i].second,island)){//下からpを調べて、行ける組を数える。->壊れたときの減少数が分かる
            number-=treeSize(p[i].first,island)*treeSize(p[i].second,island);
            //島が分割されているとき、島の大きさの積を、全部つながっている状態から引けば答えになる
            unite(p[i].first,p[i].second,island);
        }
        ans[i-1]=number;
    }
    
    for(i=0;i<m;i++){
        cout<<ans[i]<<endl;
    }
    return 0;
}

Measured memory_bytes: 4480
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vl>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;

int main(){
  ll N, A, B;
  cin >> N >> A >> B;
  vl X(N);
  rep(i, N) cin >> X[i];

  ll cost = 0;

  rep2(i, 1, N) cost += min(A * (X[i] - X[i - 1]), B);

  cout << cost << endl;
  
  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int x,y,an,bn,cn,a[100001],b[100001],c[100001],ans[300001],ansn;
long long anss;
bool cmp(int i,int j){return i>j;}
int main()
{
	scanf("%d%d%d%d%d",&x,&y,&an,&bn,&cn);
	for(int i=1;i<=an;i++)scanf("%d",&a[i]);
	for(int i=1;i<=bn;i++)scanf("%d",&b[i]);
	for(int i=1;i<=cn;i++)scanf("%d",&c[i]);
	sort(a+1,a+an+1);
	sort(b+1,b+bn+1);
	sort(c+1,c+cn+1);
	for(int i=1;i<=x;i++)ans[++ansn]=a[an-i+1];
	for(int i=1;i<=y;i++)ans[++ansn]=b[bn-i+1];
	for(int i=1;i<=cn;i++)ans[++ansn]=c[i];
	sort(ans+1,ans+ansn+1,cmp);
	for(int i=1;i<=x+y;i++)anss+=ans[i];
	printf("%lld",anss);
	return 0;
}


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

using namespace std;

int main() {
    int a = 0, b = 0, c = 0;
    cin >> a >> b >> c;
    if (b - a == c - b) {
        cout << "YES" << endl;
        return 0;
    } else {
        cout << "NO" << endl;
        return 0;
    }
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
#define IO(i, o) freopen(i, "r", stdin), freopen(o, "w", stdout)

using namespace std;
int N, A[20], T;

bool valid(int m){
	for(int i = 0; i < m; i++)
		if(A[i] > A[m]) return false;
	return true;
}

int main(void){
	//IO("test.in", "test.out");
	scanf("%d", &N);
	for(int i = 0; i < N; i++){
		scanf("%d", &A[i]);
		if(valid(i)) T++;
	}
	printf("%d\n", T);
}

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


int main() {
int N;
cin >> N;
vector<int> b(N);
for(int i = 0;i<N;i++){
    cin >> b[i];
}
vector<int> ans;
bool flag = true;
while(b.size()){
    priority_queue<int> pq;
    for(int i = 0;i<b.size();i++){
        if(b[i] == i+1){
            pq.push(i);
        }
    }
    if(pq.size() ==0){
        flag = false;
        break;
    }
    int k  =pq.top();
    ans.push_back(k+1);
    b.erase(b.begin()+k);
}
if(flag){
reverse(ans.begin(),ans.end());
for(int i = 0;i<ans.size();i++){
    cout << ans[i] <<endl;
}
}
else cout << -1 << endl;
}

Measured memory_bytes: 384
/*
It's been a long day without you, my friend
And I'll tell you all about it when I see you again
We've come a long way from where we began
Oh I'll tell you all about it when I see you again
When I see you again
When I see you again
*/
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define null nullptr
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(), x.rend()
#define precise(x) cout << fixed << setprecision(x)
#define pb push_back
#define mp make_pair
#define test int t; cin>>t; while(t--)
#define FAST                          \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL)
 
using namespace std;
 

 
typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef pair<int,int> pii;
typedef unordered_map<int,int> mp;
 
const int mod = 1e9+7;
 
int sod(int n){int sum=0;while(n>0){sum+=n%10;n/=10;}return sum;}
 
int dig(int n){if(n==0)return 1;int cnt=0;while(n>0){n/=10;cnt++;}return cnt;}
 
int divs(int n){int cnt=0;for(int x=1;x*x<=n;x++){if(n%x==0){cnt++;if(n/x!=x)cnt++;}}return cnt;}
 
int isprime(int n){if(n<2)return false;for(int x=2;x*x<=n;x++)if(n%x==0)return false;return true;}
 
int power(int x,unsigned int y,int p=mod){int res=1;x=x%p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}

bool pal(string s){int l=0,r=s.size()-1;while(l<r){if(s[l++]!=s[r--])return false;}return true;} 

int lcm(int a,int b){return (a*b)/__gcd(a,b);}

bool isSquare(int n){int root=sqrt(n);return (root*root==n);}

const int inf = 1e18;



int32_t main(){
    FAST;

    int n;  cin >> n;
    string s;   cin >> s;
    int curr =0;
    int ans = 0;

    for(int x=0;x<n;x++){
        if(s[x] == 'I') curr++;
        else curr--;

        ans = max(ans , curr);
    }

    cout << ans << endl;


    return 0;
}
 
 
 

// const int N = 1e6;
// bool prime[N+3];
// vi primes;
// void sieve(){
 
//   memset(prime , true , sizeof prime );
 
//   prime[0] = false , prime[1] = false;
//   prime[2] = true;
 
//   for(int x=2;x*x<=N;x++){
//     if(prime[x] == true){
//       for(int i=x*x;i<=N;i+=x)
//         prime[i] = false;
//     }
//   }

//   //for(int x=0;x<N;x++)
//   //  if(prime[x])
//   //      primes.pb(x);
 
// } 


// const int N = 1e6+50;
// int spf[N+11];
 
// void SPF(){
 
// 	spf[1] = 1; 
  
//     for (int i = 2; i <= N; i++) 
//     { 
//         if (spf[i] == 0) 
//         { 
//             spf[i] = i; 
  
//             for (int j = 2*i; j <= N; j += i) 
//                 if (spf[j] == 0) 
//                    spf[j] = i; 
//         } 
//     } 
// }
 

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        long x = sc.nextLong();
        long rem = x % 11;
        long ans = x / 11 * 2;
        if(rem == 0){
            System.out.println(ans);
        }else{
            System.out.println(rem > 6 ? ans+2 : ans+1);
        }
    }
}


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

using namespace std;
typedef long long ll;
typedef long int li;
typedef long double lb;
#define rep(i,j,n) for (ll i = j; i < (n); i++)
#define repr(i,j,n) for(ll i = j; i >= (n); i--)
#define all(x) (x).begin(),(x).end()
#define CLR(mat,f) memset(mat, f, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<b)
#define out(ans) cout << ans << endl
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef pair<ll,ll>P;
const ll mod=1e9+7;
const ll INF = 1LL<<60;


const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll myPow(ll x, ll n, ll m){
  if(n == 0)
    return 1;
  if(n % 2 == 0)
    return myPow(x * x % m, n / 2, m);
  else
    return x * myPow(x, n - 1, m) % m;
}
// mod. m での a の逆元 a^{-1} を計算する
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

int main(){

  ll n,a,b;cin>>n>>a>>b;
  COMinit();

  ll sum=1;
  rep(i,0,a){
    sum*=(n-i);
    sum%=mod;
  }
  sum*=(modinv(fac[a],mod)%mod);
  sum%=mod;
  ll sumb=1;
  rep(i,0,b){
    sumb*=(n-i);
    sumb%=mod;
  }
  sumb*=(modinv(fac[b],mod)%mod);
  sumb%=mod;
  ll ans=(myPow(2,n,mod)-1-sum-sumb)%mod;

  if(ans<0){
    out(mod+ans);
  }else {
    if(mod+ans>=mod){
      out(ans);
    }else out(mod+ans);
  }


  return 0;
}


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

int main() {
	int a;
	cin >> a;
	
	if(a < 1200) {
		cout << "ABC\n";
	} else if (a >=1200 && a < 2800) {
		cout << "ARC\n";
	} else if (a >= 2800 && a <= 4208) {
		cout << "AGC\n";
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
// ==================================================
using i64 = int64_t; using u64 = uint64_t;
#define rep(i,a,b) for(i64 i=(int64_t)(a);i<(int64_t)(b);i++)
#define repn(i,n) rep(i,0,n)
#define din(t, ...) t __VA_ARGS__;_din(__VA_ARGS__)
#define v(t,n) vector<t> n
void _din() {} void dout() { cout << endl; }
template <typename T, typename ... Args> inline void _din(T& head, Args& ... rest) { cin >> head; _din(rest...); }
template <typename T, typename ... Args> inline void dout(T head, Args ... rest) { cout << head; if (sizeof...(rest)) cout << ' '; dout(rest...); }
template <typename T>inline void vsortg(vector<T>& v) { sort(v.begin(), v.end(), greater<T>()); }
template <typename T>inline void vsortl(vector<T>& v) { sort(v.begin(), v.end(), less<T>()); }
template <typename T> inline T nmax(T f1, T f2) { return max(f1, f2); }
template <typename T, typename ... Args> inline T nmax(T first, Args ... rest) { return nmax(first, nmax(rest...)); }
template <typename T> inline T nmin(T f1, T f2) { return min(f1, f2); }
template <typename T, typename ... Args> inline T nmin(T first, Args ... rest) { return nmin(first, nmin(rest...)); }
// ==================================================
int main()
{
	din(int, n);
	int mx = 0, t = 0;
	repn(i, n)
	{
		din(int, p);
		if (p > mx) mx = p;
		t += p;
	}
	t -= mx / 2;
	dout(t);
}

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


int main(){

	int n; cin>>n; 
	vector<int> time(n); int sum=0; 
	for(int i=0;i<n;i++)
		cin>>time[i],sum+=time[i];
		
	int m; cin>>m; 
	vector<int> p(m); vector<int> x(m); 
	for(int i=0;i<m;i++)
		cin>>p[i]>>x[i]; 


	for(int i=0;i<m;i++)
	{	int result=time[p[i]-1];
		cout<<(sum-result+x[i])<<endl;
	}




	return 0; 
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const ll MOD = 1000000007;
const double EPS = 1e-9;
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;


int main(void) {
    
    int h,w,k;
    cin>>h>>w>>k;

    vector<string> s(h);
    vvi v(h,vi(w,0));
    rep(i,h)cin>>s[i];
    int num=1;
    for(int i=0;i<h;i++){
        rep(j,w){
            if(s[i][j]=='#'){
                v[i][j]=num;
                num++;
            }
        }
    }

    for(int i=1;i<h;i++){
        for(int j=0;j<w;j++){
            if(!v[i][j]){
                v[i][j]=v[i-1][j];
            }
        }
    }
    for(int i=h-2;i>=0;i--){
        for(int j=0;j<w;j++){
            if(!v[i][j]){
                v[i][j]=v[i+1][j];
            }
        }
    }

    for(int i=1;i<w;i++){
        for(int j=0;j<h;j++){
            if(!v[j][i]){
                v[j][i]=v[j][i-1];
            }
        }
    }
    for(int i=w-2;i>=0;i--){
        for(int j=0;j<h;j++){
            if(!v[j][i]){
                v[j][i]=v[j][i+1];
            }
        }
    }

    rep(i,h){
        rep(j,w){
            if(j==0)cout<<v[i][0];
            else cout<<" "<<v[i][j];
        }
        cout<<endl;
    }

}


Measured memory_bytes: 1280