akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
#define rep(i, n) for (ll (i) = 0; (i) < (n); (i)++)
#define For(i, a, n) for (ll (i) = (a); (i) < (n); (i)++)
#define prl(x) cout << (x) << endl
#define pr(x) cout << (x)
#define all(v) (v).begin(), (v).end()

template <typename A, typename B>
string to_string(pair<A, B> p);
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);
string to_string(const string& s) {return '"' + s + '"';}
string to_string(char c){return string(1, c);}
string to_string(const char* s) {return to_string((string) s);}
string to_string(bool b){return (b ? "true" : "false");}
template <typename A, typename B>
string to_string(pair<A, B> p){return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p){return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";}
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p){return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";}
string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) res += ", ";
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}

template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) res += static_cast<char>('0' + v[i]);
  return res;
}

template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for (const auto &x : v) {
        if (!first) {
            res += ", ";
        }
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}

template<typename T>
string to_string(priority_queue<T>& q){
    priority_queue<T> copy;
    bool first = true;
    string res = "{";
    while(!q.empty()){
        if (!first) {
            res += ", ";
        }
        first = false;
        res += to_string(q.top());
        copy.push(q.top());
        q.pop();
    }

    swap(q, copy);
    res += "}";
    return res;
}

void debug_out() {cerr << endl;}

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T){
    cerr << " " << to_string(H);
    debug_out(T...);
}

#ifdef _LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

int main(void){
    string s, t; int n, m; map<char, vector<int>> ms;
    cin >> s >> t; n = s.length(), m = t.length();
    rep(i, n) ms[s[i]].push_back(i);
    rep(i, m) if (ms[t[i]].size() == 0) {prl(-1); return 0;}

    ll cur = 0;
    rep(i, m){
        vector<int>& v = ms[t[i]]; auto it = lower_bound(all(v), cur % n);
        (cur = cur / n * n + 1) += it == v.end() ? *(v.begin()) + n : *it;
    }

    prl(cur);

    return 0;
}


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

int main(){
  ll a,b,c,n;
  cin>>a>>b>>c>>n;
  set<PP> st;
  ll dx[6]={1,-1,0,0,0,0};
  ll dy[6]={0,0,1,-1,0,0};
  ll dz[6]={0,0,0,0,1,-1};
  ll ans=2*(a*b+b*c+c*a);
  for(int i=0;i<n;i++){
    ll x,y,z;
    cin>>x>>y>>z;
    for(int j=0;j<6;j++){
      ll tx=x+dx[j];
      ll ty=y+dy[j];
      ll tz=z+dz[j];
      if(st.count(PP(tx,P(ty,tz)))||tx<0||a<=tx||ty<0||b<=ty||tz<0||c<=tz){
	ans--;
      }else ans++;
    }
    st.insert(PP(x,P(y,z)));
  }
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 3176
import scala.math.min

object Main {
  def main(args: Array[String]): Unit = {
    solve
  }

  def solve(): Unit = {
    val sc = new java.util.Scanner(System.in)
    val a, b, c, x, y = sc.nextInt

    val aPrice = min(a, c * 2)
    val bPrice = min(b, c * 2)
    val abPrice = min(a + b, c * 2)
    val abFlg = a != aPrice || b != bPrice || (a + b) != abPrice

    val payment =
      if (abFlg) {
        val abPayment = abPrice * min(x, y)
        val notAbPayment =
          if (x == y) 0
          else if (x < y) (y - x) * bPrice
          else (x - y) * aPrice
        abPayment + notAbPayment
      } else {
        x * aPrice + y * bPrice
      }

    println(payment)

  }
}


Measured memory_bytes: 25544
//---------- Begin IO utilities ----------
#[macro_use]
#[allow(dead_code, unused_macros)]
mod io {
    // Thanks to https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
    macro_rules! input {
        ($($r:tt)*) => {
            let s = {
                use std::io::Read;
                let mut s = String::new();
                std::io::stdin().read_to_string(&mut s).unwrap();
                s
            };
            let mut iter = s.split_whitespace();
            input_inner!{iter, $($r)*}
        };
    }
    macro_rules! input_inner {
        ($iter:expr) => {};
        ($iter:expr, ) => {};
        ($iter:expr, $var:tt : $t:tt $($r:tt)*) => {
            let $var = read_value!($iter, $t);
            input_inner!{$iter $($r)*}
        };
    }
    macro_rules! read_value {
        ($iter:expr, ( $($t:tt),* )) => {
            ( $(read_value!($iter, $t)),* )
        };
        ($iter:expr, [ $t:tt ; $len:expr ]) => {
            (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
        };
        ($iter:expr, chars) => {
            read_value!($iter, String).chars().collect::<Vec<char>>()
        };
        ($iter:expr, usize1) => {
            read_value!($iter, usize) - 1
        };
        ($iter:expr, $t:ty) => {
            $iter.next().unwrap().parse::<$t>().expect("Parse error")
        };
    }

    macro_rules! p {
        ($v:expr) => {
            println!("{}", $v);
        };
        ($v:expr, $($t:expr),*) => {
            print!("{}", $v);
            ($(print!(" {}", $t)),*);
            println!();
        }
    }

    macro_rules! ps {
        ($v:expr) => {
            println!("{}", $v.iter().collect::<String>());
        };
        ($v:expr, $($t:expr),*) => {
            print!("{}", $v.iter().collect::<String>());
            ($(print!(" {}", $t.iter().collect::<String>())),*);
            println!();
        }
    }

    pub fn pv<T: std::string::ToString>(v: &[T], sep: &str) {
        let s = v.iter().map(|e| e.to_string()).collect::<Vec<String>>().join(sep);
        println!("{}", s);
    }

    pub fn pvs(v: &[Vec<char>], sep:&str) {
        let s = v.iter().map(|e| e.iter().collect::<String>()).collect::<Vec<String>>().join(sep);
        println!("{}", s);
    }
}
//---------- End IO utilities ----------

//---------- Start solve ----------
#[allow(unused_imports)]
use io::*;
fn main() {
    input!{
        s: chars
    }
    if s[1] == 'B' {
        p!("ARC");
    } else {
        p!("ABC");
    }
}


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

int main()
{
  int n;
  double sum=0;
  cin>>n;
  vector<pair<int,int>> a(n);
  for(int i=0;i<n;i++)
  {
    cin>>a.at(i).first>>a.at(i).second;
  }
  for(int i=0;i<n-1;i++)
  {
    for(int j=i+1;j<n;j++)
    {
      sum+=sqrt((a.at(i).first-a.at(j).first)*(a.at(i).first-a.at(j).first)+(a.at(i).second-a.at(j).second)*(a.at(i).second-a.at(j).second));
    }
  }
  double ans=sum*(n-1)/(n*(n-1)/2);
  cout<<fixed<<setprecision(10);
  cout<<ans<<endl;
}

Measured memory_bytes: 3780
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <utility>
#include <cstddef>
#include <queue>
#include <math.h>
#include <cstdlib>
using namespace std;

int main()
{
    int N, a, b;
    cin >> N;
    vector<int> h(N);
    vector<long long> dp(N);
    const long long INF = 1LL << 60;
    for(int i = 0; i < N; i++)
    {
        cin >> h.at(i); 
        dp.at(i) = INF;
    }
    dp.at(0) = 0;
    dp.at(1) = abs(h.at(1) - h.at(0));
    for(int i = 2; i < N; i++)
    {
        dp.at(i) = min((dp.at(i - 1) + abs(h.at(i) - h.at(i - 1))), dp.at(i));
        dp.at(i) = min((dp.at(i - 2) + abs(h.at(i) - h.at(i - 2))), dp.at(i));
    }
    cout << dp.at(N - 1) << endl; 
    return 0;
}

Measured memory_bytes: 1408
#include <stdio.h>
#include <math.h>
int main(void) {
    int n, a[1000], i;
    double b[1000], c=0;
    
    scanf("%d",&n);
    for(i=0;i<n;i++) scanf("%d",&a[i]);
    
    for(i=0;i<n;i++){
        b[i]=pow(a[i],-1);
        c+=b[i];
    }
    printf("%lf\n",pow(c,-1));
    return 0;
}

Measured memory_bytes: 1732
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }
int main(int argc, char* argv[]) {
    int t,x;
    cin >> t >> x;
    cout << (double)t/x << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main{
	public static void main(String args[]){
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
        int num = 0;
        for(int i=1;i<=n;i++){
          if(i!=scan.nextInt())num++;
        }
      if(num==0 || num==2){
        System.out.println("YES");
      }else{
        System.out.println("NO");
      }
	}
}

Measured memory_bytes: 23764
#!/usr/bin/env pypy3

import collections
import heapq


def maximize(x, y, a, b, c, ps0, qs0, rs0):
    init_apples = heapq.nlargest(x, ps0)
    init_apples.extend(heapq.nlargest(y, qs0))
    init_apples.sort()
    all_whites = collections.deque(sorted(rs0))
    total_score = 0
    for v in init_apples:
        if all_whites and all_whites[-1] > v:
            total_score += all_whites.pop()
        else:
            total_score += v
    return total_score


def main():
    x, y, a, b, c = (int(z) for z in input().split())
    ps = [int(p) for p in input().split()]
    qs = [int(q) for q in input().split()]
    rs = [int(r) for r in input().split()]
    ans = maximize(x, y, a, b, c, ps, qs, rs)
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 120940
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;

void f(int index, vector<int>& v, const vector<int>& vr, const vector<vector<int>>& min_dist, int c, int& res) {
    int flag = 1;
    for (int i = 0; i < v.size(); i++) {
        if (v[i] == 0) {
            flag = 0;
            v[i] = 1;
            f(i, v, vr, min_dist, c + min_dist[vr[index]][vr[i]], res);
            v[i] = 0;
        }
    }
    if (flag == 1) {
        res = min(res, c);
    }
}

int main() {
    int n, m, r;
    cin >> n >> m >> r;
    vector<int> vr(r, 0);
    for (int i = 0; i < r; i++) {
        cin >> vr[i];
    }
    vector<vector<int>> path(n + 1, vector<int>(n + 1, 0x3f3f3f3f));
    for (int i = 0; i < m; i++) {
        int a, b, c;
        cin >> a >> b >> c;
        path[a][b] = c;
        path[b][a] = c;
    }
    vector<vector<int>> min_dist(n + 1, vector<int>(n + 1, 0x3f3f3f3f));
    for (int i = 1; i <= n; i++) {
        map<int, unordered_set<int>> mp;
        mp[0].insert(i);
        min_dist[i][i] = 0;
        while (mp.size() > 0) {
            int dist = mp.begin()->first;
            int index = *mp.begin()->second.begin();
            mp[dist].erase(index);
            if (mp[dist].size() == 0) mp.erase(dist);

            for (int j = 1; j <= n; j++) {
                if (dist + path[index][j] < min_dist[i][j]) {
                    if (min_dist[i][j] != 0x3f3f3f3f) {
                        mp[min_dist[i][j]].erase(j);
                        if (mp[min_dist[i][j]].size() == 0) mp.erase(min_dist[i][j]);
                    }
                    min_dist[i][j] = dist + path[index][j];
                    mp[min_dist[i][j]].insert(j);
                }
            }
        }
    }
    
    int res = 0x3f3f3f3f;
    vector<int> v(r, 0);
    for (int i = 0; i < r; i++) {
        v[i] = 1;
        f(i, v, vr, min_dist, 0, res);    
        v[i] = 0;
    }
    cout << res << endl;
}


Measured memory_bytes: 3908
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds; 
using namespace std;
#define int long long
#define ll long long
#define pll pair<ll,ll>
#define pii pair<int,int>
#define mll map<ll,ll>
#define mii map<int,int>
#define mp make_pair
#define pb push_back
#define rep(i,b) for(ll (i)=0;i<(b);i++)
#define all(c) (c).begin(), (c).end()
#define F first
#define S second
#define CLR(p) memset(p, 0, sizeof(p))
#define SET(p) memset(p, -1, sizeof(p))
#define DEBUG true
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);
//typedef long long int ll;
typedef tree<int, null_type, less<int>, rb_tree_tag, 
tree_order_statistics_node_update> new_data_set; 
const int MAX=1e6+5;
#define MOD 1000000007
/*std::cout << std::fixed;
std::cout << std::setprecision(6);*/
//(a%mod-b%mod+mod)%mod



/************************************


 
*************************************/

vector<vector<ll>>v;
ll T=0;
ll cnt1=0,cnt0=0;
vector<ll>dep;
bool visited[MAX];
vector<ll>par;
vector<ll>tin,tout;
vector<ll>col;

int countDivisibles(int A, int B, int M) 
{ 
    
    if (A % M == 0) 
        return (B / M) - (A / M) + 1; 
  
    // A is not divisible by M 
    return (B / M) - (A / M); 
} 







signed main(){
    int t=1;
    // cin>>t;
    while(t--){
        int x;
        cin>>x;
        // x = x;
        // cout<<x<<endl;
        double p=100;
        int i=1;
        int a=p;
        while(p<x){
            int ci = 0.01*p;
            p+=ci;
            // p=a;
            i++;
        }
        cout<<i-1<<endl;
    }
    return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

int_fast64_t MOD;
struct modint{
    using i64=int_fast64_t;
    i64 a;
    modint(){a=0;}
    modint(i64 a_){
        a=a_%MOD;
        if(a<0) a+=MOD;
    }
    modint inv()const{
        i64 n=1,m=MOD-2,A=a;
        while(m){
            if(m&1)(n*=A)%=MOD;
            (A*=A)%=MOD;
            m>>=1;
        }
        modint y;
        y.a=n;
        return y;
    }
    bool operator==(const modint& x){
        return a==x.a;
    }
    bool operator!=(const modint& x){
        return a!=x.a;
    }
    modint& operator=(const modint& x){
        a=x.a;
        return *this;
    }
    modint operator+(const modint& x){
        modint y;
        y.a=a+x.a;
        if(y.a>=MOD) y.a-=MOD;
        return y;
    }
    modint operator-(const modint& x){
        modint y;
        y.a=a-x.a;
        if(y.a<0) y.a+=MOD;
        return y;
    }
    modint operator*(const modint& x){
        modint y;
        y.a=(a*x.a)%MOD;
        return y;
    }
    modint operator/(const modint& x){
        modint y;
        y.a=(a*x.inv().a)%MOD;
        return y;
    }
    modint& operator+=(const modint& x){
        a+=x.a;
        if(a>=MOD) a-=MOD;
        return *this;
    }
    modint& operator-=(const modint& x){
        a-=x.a;
        if(a<0) a+=MOD;
        return *this;
    }
    modint& operator*=(const modint& x){
        (a*=x.a)%=MOD;
        return *this;
    }
    modint& operator/=(const modint& x){
        (a*=x.inv().a)%=MOD;
        return *this;
    }
};
istream& operator>>(istream &in,modint& x){
    int_fast64_t a_;
    in>>a_;
    modint y(a_);
    x=y;
    return in;
}
ostream& operator<<(ostream &out,const modint& x){
    out<<x.a;
    return out;
}

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    istream& in(cin);
    ostream& out(cout);
    int n;
    in>>n>>MOD;
    vector<vector<modint>> dp(3*n+1,vector<modint>(n+1));
    dp[3*n][0]=1;
    iFr(i,3*n) fr(j,n+1){
        dp[i-1][j]+=dp[i][j];
        if(j<n){
            if(i>1) dp[i-2][j+1]+=dp[i][j]*(i-1);
            if(i>2) dp[i-3][j+1]+=dp[i][j]*(i-1)*(i-2);
        }
    }
    modint ans{};
    fr(j,n+1) ans+=dp[0][j];
    cout<<ans<<endl;

}

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

#define int long long
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define endl "\n"
typedef long long ll;
typedef long double ld;
const int mod = 1000000007;

int power(int x,int y){int res=1;x=x%mod;while(y>0){if(y&1)res=(res*x)%mod;y=y>>1;x=(x*x)%mod;}return res;}
int ncr(int n,int r){int res=1;if(r>n-r)r=n-r;for(int i=0;i<r;i++){res*=(n-i);res/=(i+1);}return res;}
int gcd(int a,int b){if (a==0)return b;return gcd(b%a,a);}
int lcm(int a,int b){return (a/gcd(a,b)*b);}
int max(int a,int b){int ans=a>b?a:b;return ans;}
int min(int a,int b){int ans=a<b?a:b;return ans;}
//cout<<fixed<<setprecision(8)<<x<<endl;
clock_t time_p=clock();
void rtime(){time_p=clock()-time_p;cerr<<"******************\nTime taken : "<<(double)(time_p)/CLOCKS_PER_SEC<<"\n";}


signed main()
{
    //fast;
    //int t=1; cin>>t; while(t--)
    {
        //cout<<"AAYE \n";
        string s;
        cin>>s;
        int n=s.size();

        int dp[n+5][15];
        memset(dp,0,sizeof(dp));

        if(s[0]=='?')
        {
            for(int i=0;i<10;i++)
                dp[0][i]=1;
        }
        else dp[0][s[0]-'0']=1;

        for(int i=1;i<n;i++)
        {
            int x=s[i]-'0';
            if(s[i]=='?') 
            {
                for(int j=0;j<10;j++)
                {
                    x=j;
                    for(int k=0;k<13;k++)
                        dp[i][(k*10+x)%13]=(dp[i][(k*10+x)%13]+dp[i-1][k])%mod;
                }
            }
            else 
            {
                for(int j=0;j<13;j++)
                    dp[i][(j*10+x)%13]=(dp[i][(j*10+x)%13]+dp[i-1][j])%mod;
            }
        }
        cout<<dp[n-1][5]<<endl;   
    }
    rtime();
    return 0;
}




Measured memory_bytes: 12160
import java.io.*;

class Main
{
	public static void main(String args[]) throws IOException
	{

		BufferedReader br =
		new BufferedReader( new InputStreamReader(System.in));

		String str = br.readLine();
		
		int S=Integer.parseInt(str);
                int h=S/3600;
                int m=(S%3600)/60;
                int s=(S%3600)%60;

		System.out.println(h+":"+m+":"+s);
	}
}

Measured memory_bytes: 24368
//参考：https://qiita.com/DaikiSuyama/items/9dba963ba74396b9b7fd
//インクルード(アルファベット順)
#include <algorithm>     //sort,二分探索,など
#include <bitset>        //固定長bit集合
#include <cmath>         //pow,logなど
#include <complex>       //複素数
#include <deque>         //両端アクセスのキュー
#include <functional>    //sortのgreater
#include <iomanip>       //setprecision(浮動小数点の出力の誤差)
#include <iostream>      //入出力
#include <iterator>      //集合演算(積集合,和集合,差集合など)
#include <map>           //map(辞書)
#include <numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include <queue>         //キュー
#include <set>           //集合
#include <stack>         //スタック
#include <string>        //文字列
#include <unordered_map> //イテレータあるけど順序保持しないmap
#include <unordered_set> //イテレータあるけど順序保持しないset
#include <utility>       //pair
#include <vector>        //可変長配列

using namespace std;
typedef long long ll;

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

signed main()
{
    //入力の高速化用のコード
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    ll N;
    cin >> N;

    vector<ll> A(N);
    REP(i, N)
    cin >> A[i];

    ll height = A[0];
    ll sum = 0;

    FOR(i, 1, N - 1)
    {
        if (height > A[i])
        {
            sum += height - A[i];
        }
        else
        {
            height = A[i];
        }
    }

    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 4468
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)
input = sys.stdin.readline


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, D):
    D.sort()
    return D[N//2] - D[N//2-1]


def main():
    N = read_int()
    D = read_int_n()
    print(slv(N, D))


if __name__ == '__main__':
    main()


Measured memory_bytes: 16176
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define tmax(a,b,c) max(a,max(b,c))
#define tmin(a,b,c) min(a,min(b,c))
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vs vector<string>
#define vc vector<char>
#define vb vector<bool>
#define vp vector<P>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
template<class T> istream& operator>>(istream& is,vector<T>& v) { for(T& t:v){is>>t;} return is; }
template<class T> ostream& operator<<(ostream& os,const vector<T>& v) { for(T t:v){os<<t<<" ";} os<<"\n"; return os; }
void Yes(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YES(bool b) { cout << (b ? "YES" : "NO") << endl; }
template<class T> inline bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> inline bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    int x,a,b;
    cin >> x >> a >> b;
    a = abs(x-a);
    b = abs(x-b);
    cout << (a < b ? 'A' : 'B') << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize(3, "Ofast", "inline")

#include <bits/stdc++.h>

#define start ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define int ll
#define ls st<<1
#define rs st<<1|1
#define pii pair<int,int>
#define rep(z, x, y) for(int z=x;z<=y;++z)
#define com bool operator<(const node &b)
using namespace std;
const int maxn = (ll) 3e5 + 5;
const int mod = 1e9 + 7;
const int inf = 0x3f3f3f3f;
int T = 1;
int cntb, cnta, cntab;
int fac[maxn];

void solve() {
    fac[0] = 1;
    rep(i, 1, maxn - 1)fac[i] = fac[i - 1] * 2 % mod;
    map<pii, int> mp;
    int n;
    cin >> n;
    rep(i, 1, n) {
        int a, b;
        cin >> a >> b;
        if (a * b == 0) {
            if (a == 0 && b == 0)
                ++cntab;
            else if (a == 0)
                ++cnta;
            else if (b == 0)
                ++cntb;
            continue;
        }
        int d = __gcd(a, b);
        a /= d, b /= d;
        if (b < 0)
            a = -a, b = -b;
        mp[{a, b}]++;
    }
    int ans = ((fac[cnta] + fac[cntb] - 1) % mod + mod) % mod;
//    for (auto &to:mp) {
//        if (to.second == 0)
//            continue;
//        int a = to.first.first, b = to.first.second;
//        int num = to.second;
//        pii j = a > 0 ? pii(-b, a) : pii(b, -a);
//        ans = ans * ((fac[num] + fac[mp[j]] - 1 + mod) % mod) % mod;
//        mp[j] = 0;
//    }
    for (auto it : mp) {
        if (it.second == 0) continue;
        ll a = it.first.first, b = it.first.second;
        ll d = fac[mp[{a, b}]];
        if (a < 0)
            a = -a;
        else
            b = -b;
        pii j = pii(b, a);
        if (mp.count(j)) {
            d = (d + fac[mp[j]] - 1) % mod;
            mp[j] = 0;
        }
        ans = ans * d % mod;
    }
    cout << (ans - 1 + cntab + mod) % mod;
}

signed main() {
    start;
    while (T--)
        solve();
    return 0;
}
/*
6
 1 4
 1 4
 -4 1
 -3 1
 1 3
 1 3
 */

Measured memory_bytes: 18412
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<limits>

using namespace std;

int main(){
  string s;
  int n,flag=1;
  	
  cin >> n >> s;
  
  if(n%2 == 1){
    cout << "No" << endl;
    return 0;
  }else{
    for(int i=0;i<n/2;i++){
      if(s[i] != s[i+n/2])flag = 0;
    }
  }
  
  if(flag == 0)cout << "No" << endl;
  else cout << "Yes" << endl;
  
  
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
    char data[10];
    scanf("%s", data);
    if(data[0] == 'S') printf("Cloudy\n");
        if(data[0] == 'C') printf("Rainy\n");
        if(data[0] == 'R') printf("Sunny\n");
    return 0;
}


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

#define int         long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
using namespace std;
int m,ans,s;
void solve(){
    cin>>m;
    rep(i,0,m){
        int x,y;
        cin>>x>>y;
        ans+=y;
        s+=x*y;
    }
    ans--;
    ans+=(s-1)/9;
    cout<<ans<<endl;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

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

five = 0; seven = 0

for i in list:
    if i == 5:
        five += 1
    elif i == 7:
        seven += 1
    else:
        pass

if five == 2 and seven == 1:
    print('YES')
else:
    print('NO')

Measured memory_bytes: 3060
#include <stdio.h>
#include <iostream>
#include <map>
using namespace std;
#define rep(i, n) for(int i=0; i<(int)(n); i++)
typedef long long Int;

int N, S, W, Q, a[200000];

Int solve() {
    if(Q==2 || Q==5) {
        Int ans=0, c=0;
        rep(i, N) {
            if(a[i]!=0) c += 1;
            if(a[i]%Q==0) ans += c;
        }
        return ans;
    }
    else {
        Int ans=0, cur=0, p=1;
        map<int, int> cnt;
        cnt[0] = 1;
        for(int i=N-1; i>=0; i--) {
            cur = (cur+a[i]*p) % Q;
            p = p*10 % Q;
            if(a[i]!=0) ans += cnt[cur];
            cnt[cur] += 1;
        }
        return ans;
    }
}

int main() {
    for(;;) {
        scanf("%d%d%d%d", &N, &S, &W, &Q);
        if(N==0) return 0;
        int g = S;
        rep(i, N) {
            a[i] = (g/7) % 10;
            if(g%2==0) g = g/2;
            else g = (g/2) ^ W;
        }
        cout << solve() << endl;
    }
}

Measured memory_bytes: 4144
#include<bits/stdc++.h>
using namespace std;
const int md = 1e9+7;
int n, a[30];
string s;
long long x = 1;
int main(){
    cin >> n >> s;
    for(int i = 0; i < n; i++) a[s[i]-'a']++;
    for(int i = 0; i < 26; i++) (x *= a[i]+1) %= md;
    printf("%lld\n", x-- ? x : md-1);
}

Measured memory_bytes: 512
import sys
sys.setrecursionlimit(100000)
input=sys.stdin.readline
n,m=map(int,input().split())
l=[-1]*n
b=[input().split() for _ in range(m)]
c=[0]*m+[n*(n-1)//2]
def r(s):
  t=l[s]
  if t<0:
    return s
  else:
    l[s]=r(t)
    return l[s]
def f(s):
  return r(int(s)-1)
for i in range(m-1,-1,-1):
  x,y=map(f,b[i])
  s,t=0,0
  if x!=y:
    s,t=l[x],l[y]
    if s>t:
      l[x]=y
      l[y]+=s
    else:
      l[y]=x
      l[x]+=t
  c[i]=c[i+1]-s*t
for x in c[1:]:
  print(x)

Measured memory_bytes: 40268
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;


public class Main {

    int N;

    private void solve() {
        N = nextInt();

        long m = 0;
        long a = 0;
        long r = 0;
        long c = 0;
        long h = 0;

        for(int i = 0;i < N;i++) {
            char ch = next().charAt(0);

            if (ch == 'M') {
                m++;
            } else if (ch == 'A') {
                a++;
            } else if (ch == 'R') {
                r++;
            } else if (ch == 'C') {
                c++;
            } else if (ch == 'H') {
                h++;
            }
        }


        long[] P = {m, a, r, c, h};
        long ans = 0;

        for(int i = 0;i < P.length;i++) {
            for(int j = i + 1;j < P.length;j++) {
                for(int k = j + 1;k < P.length;k++) {
                    ans += P[i] * P[j] * P[k];
                }
            }
        }

        out.println(ans);
    }
    public static void main(String[] args) {
        out.flush();
        new Main().solve();
        out.close();
    }

    /* Input */
    private static final InputStream in = System.in;
    private static final PrintWriter out = new PrintWriter(System.out);
    private final byte[] buffer = new byte[4096];
    private int p = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (p < buflen)
            return true;
        p = 0;
        try {
            buflen = in.read(buffer);
        } catch (IOException e) {
            e.printStackTrace();
        }
        if (buflen <= 0)
            return false;
        return true;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrint(buffer[p])) {
            p++;
        }
        return hasNextByte();
    }

    private boolean isPrint(int ch) {
        if (ch >= '!' && ch <= '~')
            return true;
        return false;
    }

    private int nextByte() {
        if (!hasNextByte())
            return -1;
        return buffer[p++];
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = -1;
        while (isPrint((b = nextByte()))) {
            sb.appendCodePoint(b);
        }
        return sb.toString();
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}


Measured memory_bytes: 36356
PROGRAM piyo
      IMPLICIT NONE
      INTEGER,PARAMETER :: prec = 16
      integer(prec) :: x(5),i
      
      read*,x
      
      do i = 1,5
        if( x(i)/=i)then
          print'(i0)',i
        end if
      end do
      
      
      
      
      stop
      !debugg
      
      
      
      END PROGRAM

Measured memory_bytes: 2868
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef vector<LL> VI;
typedef vector<VI> VVI;
typedef pair<LL, LL> PII;
typedef vector<string> VS;
inline LL toInt(string s) {LL v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
#define PB push_back
#define MP make_pair
#define SZ(a) LL((a).size())
#define EACH(x,c) for(auto x: (c))
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define ALL(c) (c).begin(), (c).end()
#define REVERSE(c) reverse(ALL(c))
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define STABLE_SORT(c) stable_sort(ALL(c))
#define STABLE_RSORT(c) stable_sort((c).rbegin(),(c).rend())
#define UNIQUE(c) SORT(c); (c).erase(unique(ALL(c)), (c).end());
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
const double INF = 1e7;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
#define dump(x)  cerr << #x << " = " << (x) << endl;


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

	if (B - A <= 2) {
		cout << K + 1 << endl;
	} else {
		LL tot;
		if (K < A + 1) {
			cout << K + 1 << endl;
		} else {
			K -= A + 1;
			tot = B;
			if (K % 2 == 1) {
				tot++;
			}
			tot += (K / 2) * (B - A);
			cout << tot << endl;
		}
	}
	
	
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<queue>
#include<functional>
using namespace std;
int n, a[100], s = 1, t = 1;
int main() {
	cin >> n; for (int i = 0; i < n; i++)cin >> a[i];
	for (int i = 0; i < n; i++) {
		t *= 3;
		if (a[i] % 2 == 0)s *= 2;
	}
	cout << t - s << endl;
	return 0;
}

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

using namespace std;

int n,m;
int i,j,k;
string str;

int main(){
    cin >> n;
    vector<int> a(n);
    for(i = 0;i < n;i++){
        cin >> a[i];
    }
    sort(a.begin(),a.end());
    int f = 0;
    for(i = 0,j = 0;i < n;i++){
        if((a[i]-j)%2) f^=n-i;
        j = a[i];
    }
    if(f) cout << "first" << endl;
    else cout << "second" << endl;
}


Measured memory_bytes: 640
#include <iostream>

using namespace std;

int main(void){
  char a[2];
  int num[2];
  
  cin >> a[0] >> a[1];
  
  for(int i = 0 ; i < 2 ; i++){
    num[i] = (a[i] == 'H' ? 1 : -1);
  }
  
  cout << (num[0] * num[1] == 1 ? "H" : "D") << endl;
  
  return 0;
}

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

int main(){
	int n;
	scanf("%d", &n);
	int val[2*n];
	for (int i = 0; i < 2 * n; i++){
		scanf("%d",&val[i]);
	}
	sort(val, val + 2*n);
	int res = 0;
	for (int i = 0; i < 2 * n - 1; i+=2){
		res += min(val[i], val[i+1]);
	}
	printf("%d\n",res);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fast_io {cin.sync_with_stdio(0); cout.sync_with_stdio(0);}
#define out(x,y) {cout<<x<<y;}
using ll = int;


int main(){
	fast_io;
	ll n;
	cin>>n;
	set<string>s;
	while(n--){
		string s1;
		cin>>s1;
		s.insert(s1);
	}
	cout<<s.size()<<endl;
}

Measured memory_bytes: 19132
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

  public static void main(String[] args) {
    BufferedReader stdin = null;
    try {
      stdin = new BufferedReader(new InputStreamReader(System.in));
      String str = stdin.readLine();
      int len = str.length();
      char[] chars = new char[len];

      for (int i = 0; i < len; i++) {
        char ch = str.charAt(i);
        if (Character.isUpperCase(ch)) {
          chars[i] = Character.toLowerCase(ch);
        } else if (Character.isLowerCase(ch)) {
          chars[i] = Character.toUpperCase(ch);
        } else {
          chars[i] = ch;
        }
      }

      System.out.println(chars);
    } catch (IOException e) {
      e.printStackTrace();
    } finally {
      try {
        if (stdin != null) {
          stdin.close();
        }
      } catch (IOException e) {
      }
    }
  }

}

Measured memory_bytes: 16876
#include<bits/stdc++.h>
using namespace std;
int n,m,mx,top;
char a[2010][2010];
int t[2010][2010],b[200010],st[200010];
int f(int x,int y){
	return (a[x][y]=='#')?1:0;
}
void solve(){
	cin>>n>>m;
	mx=max(n,m);
	/*for(int i=1;i<=n;++i){
		scanf("%s",a+1);
	}*/
	for(int i=1;i<=n;++i){
		for(int j=1;j<=m;++j){
			cin>>a[i][j];
		}
	}
	--n,--m;
	for(int i=1;i<=n;++i){
		for(int j=1;j<=m;++j){
			t[i][j]=f(i,j)^f(i+1,j)^f(i,j+1)^f(i+1,j+1);
		}
	}
	for(int i=1,top;i<=n;++i){
		for(int j=1;j<=m;++j){
			if(t[i][j])b[j]=0;
			else ++b[j];
		}
		top=0;
		for(int j=1;j<=m;++j){
			for(;top&&b[st[top]]>=b[j];--top)
				mx=max(mx,(j-st[top-1])*(b[st[top]]+1));
			st[++top]=j;
		}
		for(;top;--top)
			mx=max(mx,(m-st[top-1]+1)*(b[st[top]]+1));
	}
	cout<<mx<<endl;
}
int main(){
	solve();
	
	return 0;
}
/*
10 8
##...#.#
##...#.#
..###.#.
#.##.#.#
.#..#.#.
..##.#.#
##.#.#..
...#.#..
###.#.##
###..###
*/

Measured memory_bytes: 20096
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>

using namespace std;
#define int  long long

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()


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



void solve(void)
{
  int X;cin>>X;
  int P = X/100;
  if(X <= P*105 && X >= P*100)
  {
    cout<<1<<endl;
  }
  else
  {
    cout<<0<<endl;
  }
  
  return;

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

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

return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int arr[ 110 ];

int k, t;


int main( void ) {

	cin >> k >> t;
	for ( int i = 1 ; i <= t ; ++i ) {
		cin >> arr[ i ];
	}

	int ans = 0, last = -1;
	for ( int i = 0 ; i < k ; ++i ) {
		int nw = -1;
		for ( int j = 0 ; j <= t ; ++j ) {
			if ( arr[j] == 0 ) continue;
			if ( j != last and ( nw == -1 or arr[j] > arr[nw] ) ) {
				nw = j;
			} 
		}
		if ( nw == -1 ) {
			nw = last;
			++ans;
		}
		--arr[ last = nw ];
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
//i ll be the king
#include<bits/stdc++.h>
#define ll long long int
#define sync ios_base::sync_with_stdio(false); cin.tie(NULL) 
#define input(arr,n) for(ll i1=0;i1<n;i1++ )cin>>arr[i1]
#define rep(n) for(ll i2=0;i2<n;i2++)
#define vmp(v,a,b) v.push_back(make_pair(a,b))
#define si(a) scanf("%lld",&a)
#define pi(a) printf("%lld",a)
#define aset(a,n,k) for(ll i3=0;i3<n;i3++)a[i3]=k; 	
#define mod 1000000007
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
using namespace std;
int main()
{
	sync;
	string s,t,ans="";
	cin>>s>>t;
	ll n=s.length();
	ll m=t.length();
	ll dp[n+1][m+1];
	for(ll i=0;i<=n;i++)dp[i][0]=0;
	for(ll i=0;i<=m;i++)dp[0][i]=0;
	for(ll i=1;i<=n;i++)
	{
		for(ll j=1;j<=m;j++)
		{
		if(s[i-1]==t[j-1])
		dp[i][j]=dp[i-1][j-1]+1;
		else
		dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
		}
	}
	ll movl=n,movu=m;
	while(movl*movu)
	{
		if(dp[movl][movu]==dp[movl-1][movu])
		movl--;
		else if(dp[movl][movu]==dp[movl][movu-1])
		movu--;
		else
		{
		ans=s[movl-1]+ans;
		movl--;
		movu--;
	}
	}
	
	cout<<ans<<endl;
}

Measured memory_bytes: 70656
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <cstdlib>

using namespace std;

int main(){
	long long a,i,n, Sum=0, min;
	cin >> n;
	vector <long long> sum(n);

	for (i=0; i<n-1; i++){
		cin >>a;
		Sum += a;
		sum[i] = Sum;
	}
	cin >> a;
	Sum += a;
	// cout << "Sum=" << Sum << endl;
	
	min = abs(2*sum[0] - Sum);
	for(i=1; i<n-1; i++){
		sum[i] = abs(2*sum[i] - Sum);
		// cout << "sum[i]=" << sum[i] << endl;
		if (sum[i] < min){
			min = sum[i];
		}
	}
	cout << min << endl;

	return 0;
}

Measured memory_bytes: 1792
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
#include <list>
#include <limits>
#include <numeric>
#include <utility>
#include <deque>
#include <valarray>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#include <array>
#include <bitset>
#include <complex>
#include <tuple>

using namespace std;
using ll = long long;
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main()
{
  int n;
  cin >> n;
  vector<int> b(n);
  bool c = false;
  for (auto &e : b)
  {
    cin >> e;
    if (e == 1)
      c = true;
  }

  if (!c)
  {
    cout << -1 << endl;
    return 0;
  }

  vector<int> ans;
  int cnt = 0;
  while (!b.empty())
  {
    int t = 0;
    for (int i = b.size() - 1; i >= 0; --i)
    {
      if (i + 1 == b[i])
      {
        ans.push_back(i + 1);
        b.erase(b.begin() + i);
        break;
      }
      else
      {
        t++;
      }
    }
    if (t == b.size())
      cnt++;
    if (cnt == 100)
    {
      cout << -1 << endl;
      return 0;
    }
  }

  for (int i = ans.size() - 1; i >= 0; --i)
    cout << ans[i] << endl;

  return 0;
}


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

int main()
{
    int X,A;
    scanf("%d %d",&X,&A);
    if (X>=0&&X<=9&&A>=0&&A<=9)
    {
        if (X<A)
            printf("0");
        else
            printf("10");
    }
    return 0;
}


Measured memory_bytes: 128
#include <cstdlib>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cstring>

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;

#define SIZE(x) (int((x).size()))
#define rep(i,l,r) for (int i=(l); i<=(r); i++)
#define repd(i,r,l) for (int i=(r); i>=(l); i--)
#define rept(i,c) for (typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)

#ifndef ONLINE_JUDGE
#define debug(x) { cerr<<#x<<" = "<<(x)<<endl; }
#else
#define debug(x) {}
#endif

#define maxn 100010
#define MD 1000000007

int a[maxn], b[maxn];

void lemon()
{
	int n; scanf("%d",&n);
	rep(i,1,n) scanf("%d",&a[i]);
	rep(i,1,n) scanf("%d",&b[i]);
	int s=1;
	rep(i,1,n)
	{
		if (a[i]>a[i-1]) 
			if (b[i]>b[i+1])
				if (a[i]==b[i])
					s*=1;
				else 
					s*=0;
			else
				if (a[i]<=b[i])
					s*=1;
				else
					s*=0;
		else
			if (b[i]>b[i+1])
				if (b[i]<=a[i])
					s*=1;
				else
					s*=0;
			else
				s=LL(s)*min(a[i],b[i])%MD;
		//printf("%d\n",s);
	}
	printf("%d\n",s);
	
}

int main()
{
	ios::sync_with_stdio(true);
	#ifndef ONLINE_JUDGE
		//freopen("c.in","r",stdin);
	#endif
	lemon();
	return 0;
}



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

long long calc(string s) {
	long long sum=0;
	long long num=0;
	for(int i=0; i<s.length(); i++) {
		if (i == s.length()-1) {
			num = num * 10 + s[i] - '0';
			sum += num;
		} else if (s[i] == '+' ) {	
			sum += num;
			num = 0;
		} else {
			num = num * 10 + s[i] - '0';
		}
	}
	return sum;
}

int main() {
	string S;
	cin >> S;
	long long sum =0;
	string eq="";

	int N = S.length()-1;
	for(int i=0;i<(1<<N);i++) {
		for(int j=0; j<N; j++) {
			eq += S.substr(j,1);
			if (i&(1<<j)) {		
				eq += "+";
			}	
		}
		eq += S.substr(N,1);
		sum += calc(eq);
		eq = "";
	}
	cout << sum << endl;
	return 0;
}

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

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

	int xa = min(a,k);
	k -= xa;

	int xb = min(b,k);
	k -= xb;

	int xc = k;

	int ans = xa - xc;

	cout << ans << endl;
}



Measured memory_bytes: 3636
x, n = map(int, input().split())
p = list(map(int, input().split()))
s = []
for i in range(202):
    s.append(i)
for i in range(n):
    s.remove(p[i])

for i in range(202):
    if (x-i) in s:
        print(x-i)
        break
    elif (x+i) in s:
        print(x+i)
        break

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

using namespace std ;

int ans = 1e9 ;

int vis[305][305][305] ;

void solve(int x , int y , int z , int steps)
{
	if(x > 300 || y > 300 || z > 300)
		return ;
	if(vis[x][y][z])
		return ;
	vis[x][y][z] = 1 ;
	if(x == y && y == z)
	{
		ans = min(ans,steps);
		return ;
	}
	solve(x+2 , y , z , steps+1) ;
	solve(x , y+2 , z , steps+1) ;
	solve(x , y , z+2 , steps+1) ;
	solve(x+1 , y+1 , z , steps+1) ;
	solve(x+1 , y , z+1 , steps+1) ;
	solve(x , y+1 , z+1 , steps+1) ;
	return ;
}

int main()
{
	ios_base::sync_with_stdio(0) ;
	cin.tie(0) ;
	int arr[3] ;
	cin>>arr[0]>>arr[1]>>arr[2] ;
	solve(arr[0] , arr[1] , arr[2] , 0) ;
	return cout<<ans<<"\n" , 0 ;
}

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

#define FasterIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

int main(){
    FasterIO;

    int a, b, c;

    while(cin>>a>>b>>c){
        int total = b;
        total += min(b, c);

        c -= min(b, c);

        total += min(a, c);
        c -= min(a, c);

        if(c) total++;

        cout<<total<<endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bit>
#include <bitset>
#include <assert.h>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <set>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <stdlib.h>
#include <queue>
#include <stack>
using namespace std;
int main() {
	int64_t X = 0;
	int64_t K = 0;
	int64_t D = 0;
	cin >> X >> K >> D;
	X = abs(X);
	int64_t A = 0;
	A = X / D;
	if (A < K) {
		if (X - A * D > abs(X - (A + 1) * D)) {
			if ((A + K) % 2 == 0) {
				cout << X - A * D;
			}
			else {
				cout << abs(X - (A + 1) * D);
			}
		}
		else {
			if ((A + K) % 2 == 0) {
				cout << X - A * D;
			}
			else {
				cout << abs(X - (A + 1) * D);
			}
		}
	}
	else {
		cout << X - K * D;
	}
}


Measured memory_bytes: 3596
#include <cstdio>
#include <algorithm>
#include<bits/stdc++.h>
#define ll long long 
#define f(i,n) for(int i=0;i<n;i++) 
#define fr(i,a,b) for(int i=a;i<b;i++) 
#define mp make_pair 
#define pb push_back 
#define F first 
#define S second 
#define N 500005
#define A 500005
#define BLOCK 700 // ~sqrt(N)

using namespace std;

ll cnt[A], a[N], ans[N], answer = 0;

struct node {
	int L, R, i;
}q[N];

bool cmp(node x, node y) {
	if(x.L/BLOCK != y.L/BLOCK) {
		// different blocks, so sort by block.
		return x.L/BLOCK < y.L/BLOCK;
	}
	// same block, so sort by R value
	return x.R < y.R;
}


// modify answer and cnt in add and remove 

void add(int position) {
	cnt[a[position]]++;
	if(cnt[a[position]]==1)answer++;
	
}

void remove(int position) {
	cnt[a[position]]--;
	if(cnt[a[position]]==0)answer--;
}

int main() {
	int n,query;
	scanf("%d%d", &n, &query);
	f(i,n)cin>>a[i];
	
	for(int i=0; i<query; i++) {
		scanf("%d%d", &q[i].L, &q[i].R);
		q[i].L--; q[i].R--;
		q[i].i = i;
	}

	sort(q, q + query, cmp);

	int currentL = 0, currentR = 0;
	for(int i=0; i<query; i++) {
		int L = q[i].L, R = q[i].R;
		while(currentL < L) {
			remove(currentL);
			currentL++;
		}
		while(currentL > L) {
			add(currentL-1);
			currentL--;
		}
		while(currentR <= R) {
			add(currentR);
			currentR++;
		}
		while(currentR > R+1) {
			remove(currentR-1);
			currentR--;
		}
		ans[q[i].i] = answer;
	}

	f(i,query)printf("%lld \n",ans[i]); //cout<<ans[i]<<"\n";
}

Measured memory_bytes: 21840