akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
/* Uncomment only if you are not using GNU compiler->
*/
#include <map>
#include <algorithm> 
#include <vector> 
#include <string.h> 
#include <math.h> 
#include <stdio.h> 
#include <stdlib.h> 
#include <chrono> 
#include <thread> 
#include <iomanip>
#include <typeinfo>
/**/ 
//define
#define rep(i,n)    for(int i=0;i<n;i++)
#define repu(i,k,n) for(int i=k;i<=n;i++)
#define repd(i,k,n) for(int i=k;i>=n;i--)
#define se second
#define fi first
#define pb push_back
#define mp make_pair
#define all(v)  v.begin(), v.end()

//typedef
typedef long long int ll;
typedef long double ld;
typedef std::pair<int, int> pii;
typedef std::vector<int> vi;
typedef std::vector< pii > vii;
typedef std::vector< ll > vll;
typedef std::vector< std::pair < pii, int > > vpp;
 
const long long MOD = 1000000007;
const long long inf = 1e18;
 
using namespace std;

ll modpow(ll x,ll n){
    ll res=1;
    while(n>0){
        if(n&1) res=res*x%MOD;
        x=x*x%MOD;
        n>>=1;
    }
    return res;
}

ll power(ll x, ll n)
{
    ll res=1;
    while(n>0){
        if(n&1) res=res*x;
        x=x*x;
        n>>=1;
    }
    return res;
}

bool custom_sort(int &x, int &y)
{
    if(x<y)
        return 1;
    else
        return 0;
}

void dragnoid99()
{
    int n;
    cin>>n;
    vll a(n);
    ll xorr=0;
    rep(i,n)
    {
        cin>>a[i];
    }
    repu(i,2,n-1)
    {
        xorr^=a[i];
    }
    if(xorr==0)
    {
        if((a[0]+a[1])%2!=0 || a[1]>a[0])
        {
            cout<<-1<<endl;
            return;
        }
        cout<<a[0]-(a[0]+a[1])/2<<endl;
        return;
    }
    ll s=a[0]+a[1];
    if((s-xorr)%2==1)
    {
        cout<<-1<<endl;
        return;
    }
    ll x=xorr;
    ll d=(s-x)/2;
    if((d&x))
    {
        cout<<-1<<endl;
        return;
    }
    ll b=d, c=d;
        repd(i,60,0)
        {
            if(((1LL<<i)&x) && (d+(1LL<<i))<=a[0])
            {
                d+=(1LL<<i);
            }
        }
    if(d>a[0] || d==0)
    {
        cout<<-1<<endl;
        return;
    }
    cout<<a[0]-d<<endl;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    int t = 1, tt=1;
    // cin>>t;
    while(tt<=t)
    {
        // cout<<"Case #"<<tt<<": ";
        dragnoid99();
        tt++;
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}


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

//XOR 桁DP　排他的論理和

int main() {
    int N;
    long long K;
    cin >> N >> K;
    vector<long long> A(N);
    for (int i = 0; i < N; ++i) cin >> A[i];
        
    long long res = 0;
    for (int d = 40; d >= -1; --d) { // d = -1 は X = K の場合　食い違う桁
        if (d != -1 && !(K & (1LL<<d))) continue; //X=Kでなく、かつd桁目に置いてX=1でK=0 すなわちオーバーしてる
        //Kのd桁目ビットが1ではない、つまり0の時Xのd桁目は1である必要があるがこれは考えなくて良い。
        
        long long tmp = 0;
        for (int e = 40; e >= 0; --e) {
            long long mask = 1LL<<e; //何桁目かを指定
            int num = 0; //1ビットの個数
            for (int i = 0; i < N; ++i) if (A[i] & mask) ++num; //1ビットの数を計測
            
            if (e > d) {
                if (K & mask) tmp += mask * (N - num); //dより大きい桁はビットが1で立っていると0の個数
                else tmp += mask * num;
            }
            else if (e == d) {
                tmp += mask * num; //Xのd桁目は0なので
            }
            else {
                tmp += mask * max(num, N - num); //あとはなんでもいいので大きい方
            }
        }
        res = max(res, tmp);
    }
    cout << res << endl;
}

Measured memory_bytes: 1024
while True:
    score=input()
    if score=='0':
        break
    
    score_a=score.count('A')
    score_b=score.count('B')
    if score[0]=='A':
        score_a-=1
    elif score[0]=='B':
        score_b-=1
    if score_a>score_b:
        score_a+=1
    else:
        score_b+=1
    print(score_a,score_b)


Measured memory_bytes: 5560
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(int i=0;i<int(n);i++)
#define N 200000






int main() {
	int a[N];
	int n, k;
	int x, y, z;
	int s, ans;
	bool v = true;
	ans = 0;
	scanf("%d", &n);
	f(i, n) {
		scanf("%d", &a[n-i-1]);
	}
	k = 0;
	f(i, n-1) {
		if (a[i] <= a[i + 1]) {
			k++;
			ans = max(ans, k);
		}
		else k = 0;
	}

	printf("%d\n", ans);


	return 0;
}

Measured memory_bytes: 512
[N,Q] = list(map(int,input().split()))
s = str(input())
magic = [input().split() for j in range(Q)]

def move_golem(ini,s,magic):
    golem_temp = ini
    for t,d in magic:
        if s[golem_temp] == t:
            if d == 'L':
                golem_temp -= 1
            elif d == 'R':
                golem_temp += 1
        if golem_temp == -1 or golem_temp == len(s):
            break
    return golem_temp

# check lower bound

def check_lower(s,magic):
    lb = -1
    ub = len(s)
    while ub - lb > 1:
        mid = (lb + ub)//2
        mid_golem_temp = move_golem(mid,s,magic)
        if mid_golem_temp == -1:
            lb = mid
        elif mid_golem_temp != -1:
            ub = mid
            
    return lb

def check_upper(s,magic):
    lb = -1
    ub = len(s)
    while ub - lb > 1:
        mid = (lb + ub)//2
        mid_golem_temp = move_golem(mid,s,magic)
        if mid_golem_temp == len(s):
            ub = mid
        elif mid_golem_temp != len(s):
            lb = mid
            
    return ub

print(check_upper(s,magic)-check_lower(s,magic)-1)

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

namespace AtCoderBiginnerContest179
{
	class Program
	{
		static void Main(string[] args)
		{
			var input = int.Parse(Console.ReadLine());

			var count = 0;
			for(var i = 0; i < input; i++)
			{
				var inputs = Console.ReadLine().Split().Select(int.Parse).ToArray();
				if(inputs[0] == inputs[1])
				{
					count++;
					if(count == 3)
					{
						Console.WriteLine("Yes");
						return;
					}
				}
				else
				{
					count = 0;
				}
			}
			Console.WriteLine("No");
		}
	}
}


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

using namespace std;

#define pb push_back
#define ll long long
#define speed ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define bug cout << "ok" << endl

const ll INF = 1e9 + 5, N = 3e5 + 5, mod = 1e9 + 7, M = 1e6 + 5;

int main(){
	int n;
	cin >> n;
	bool y = false;
	int a[n + 1][2];
	for(int i = 1; i <= n; i++){
		cin >> a[i][0] >> a[i][1];
	}
	for(int i = 1; i <= n - 2; i++){
		if(a[i][0] == a[i][1] && a[i + 1][0] == a[i + 1][1] && a[i + 2][0] == a[i + 2][1]) y = true;
	}
	if(y) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int main(int argc, const char *argv[])
{
  int n, k, c;
  string s;
  cin >> n >> k >> c >> s;

  vector<int> d1;
  for (int i = 0; i < n && d1.size() < k; i++) {
    if (s[i] == 'o' && (d1.empty() || i - d1.back() > c)) {
      d1.push_back(i);
    }
  }

  vector<int> d2;
  for (int i = n - 1; i >= 0 && d2.size() < k; i--) {
    if (s[i] == 'o' && (d2.empty() || d2.back() - i > c)) {
      d2.push_back(i);
    }
  }

  vector<int> ans;
  for (int i = 0; i < k; i++) {
    if (d1[i] == d2[k - i - 1]) {
      ans.push_back(d1[i]);
    }
  }

  for (int i = 0; i < ans.size(); i++) {
    cout << ans[i] + 1;
    cout << (i == ans.size() - 1 ? '\n' : ' ');
  }
  
  return 0;
}

Measured memory_bytes: 4216
#include <bits/stdc++.h>
#define mod 1000000007;
#define pi 3.14159265358979323846264
using namespace std;
string s;
int n, m;
vector <string> v;
int main() {
    scanf("%d %d", &n, &m);
    for (int i=0;i<n;i++) {
        cin >> s;
        v.push_back(s);
    }
    for (int i=0;i<v.size();i++) {
        cout<<v[i]<<endl<<v[i]<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	r := bufio.NewReader(os.Stdin)
	w := bufio.NewWriter(os.Stdout)
	defer w.Flush()

	var x int
	fmt.Fscan(r, &x)
	if x >= 30 {
		fmt.Fprintln(w, "Yes")
	} else {
		fmt.Fprintln(w, "No")
	}
}


Measured memory_bytes: 1848
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define reps(i,a,b) for(int i= a; i < b; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

bool yymm(string s) {
  int v = (s.at(2) - '0') * 10 + (s.at(3) - '0');
  if (v > 12 || v == 0) return false;
  return true;
}
bool mmyy(string s) {
  int v = (s.at(0) - '0') * 10 + (s.at(1) - '0');
  if (v > 12 || v == 0) return false;
  return true;
}

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

  if (yymm(s) && mmyy(s)) {
    cout << "AMBIGUOUS" << endl;
  } else if (yymm(s)) {
    cout << "YYMM" << endl;
  } else if (mmyy(s)) {
    cout << "MMYY" << endl;
  } else {
    cout << "NA" << endl;
  }
  
  return 0;
}

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

#define int int64_t
#define loop(i,s,e) for(int i=s;i<e;++i)
#define vi vector<int>
#define pb push_back
#define max(x,y) ((x>y)?x:y)
#define min(x,y) ((x>y)?y:x)

using namespace std;

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

	int x, y; cin >> x >> y;
	if(y%2 == 1) {
		cout << "No" << endl;
	}else{
		int k = 2*x - (y/2);
		if(k < 0 || k > x){
			cout << "No" << endl;
		}else{
			cout << "Yes" << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 3632
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int num = sc.nextInt();
		boolean odd[] = new boolean[num];
		for(int i = 0; i < num; i ++) {
			odd[i] = sc.nextLong() == 1;
		}
		boolean ans[] = new boolean[num];
		for(int i = num; i >= 1; i --) {
			ans[i - 1] = odd[i - 1];
			for(int j = 2; i * j <= num; j ++) {
				ans[i - 1] ^= ans[i * j - 1];
			}
		}
		int count = 0;
		for(int i = 0; i < num; i ++) {
			if(ans[i]) { count ++; }
		}
		System.out.println(count);
		for(int i = 0; i < num; i ++) {
			if(ans[i]) { System.out.print((i + 1)+" "); }
		}
		System.out.println();
	}
}

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

template<typename T>
void fin(T a){
  cout<<a<<endl;
  exit(0);
}
long long k,now;
set<long long>s;

int main(){
  cin>>k;
  for(int i=1;;i++){
    now=(now*10+7)%k;
    if(!now)fin(i);
    if(s.count(now))fin(-1);
    s.insert(now);
  }
}


Measured memory_bytes: 50364
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<map>
#include<set>
#include<stack>
#include<queue>
using namespace std;

int main(){
    int X,Y,Z;
    cin>>X>>Y>>Z;
    cout << Z << " " << X << " " << Y << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int (i) = 0; (i) < (n); i++)
#define ll long long
using namespace std;
int main() {
  string S,T,U;
  ll A = 0, B = 0;
  map<string,ll> mp;
  cin >> S >> T >> A >> B >> U;
  mp[S] = A;
  mp[T] = B;
  mp[U]--;
  cout << mp[S] << " " << mp[T];
}
  

Measured memory_bytes: 3556
#include <stdio.h>
#include <math.h>
int main(void){
  int n,i;
  double x1,y1,x2,y2,x3,y3;
  double x,y,r;
  double a,b,c,s;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%lf %lf %lf %lf %lf %lf",&x1,&y1,&x2,&y2,&x3,&y3);
    x=((y1-y3)*(y1*y1-y2*y2+x1*x1-x2*x2)-(y1-y2)*(y1*y1-y3*y3+x1*x1-x3*x3))/(2*(y1-y3)*(x1-x2)-2*(y1-y2)*(x1-x3));
    y=((x1-x3)*(x1*x1-x2*x2+y1*y1-y2*y2)-(x1-x2)*(x1*x1-x3*x3+y1*y1-y3*y3))/(2*(x1-x3)*(y1-y2)-2*(x1-x2)*(y1-y3));
    a=sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));
    b=sqrt((x3-x2)*(x3-x2)+(y3-y2)*(y3-y2));
    c=sqrt((x1-x3)*(x1-x3)+(y1-y3)*(y1-y3));
    s=(a+b+c)/2;
    r=a*b*c/4/sqrt(s*(s-a)*(s-b)*(s-c));
    printf("%.3f %.3f %.3f\n",x,y,r);
    }
  return 0;
}

Measured memory_bytes: 660
// AOJ 0300 (http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0300)
#include<cstdio>
#include<queue>
#include<vector>
#define rep(i,a) for(int i=0;i<(a);++i)

typedef std::pair<int, int> P;

const P map[4][5] = {
	{ P( 7, 22 ), P( 8, 23 ), P( 9, 24 ), P( 10, 12 ), P( 13, 18 ) },
	{ P( 1, 28 ), P( 2, 29 ), P( 3, 30 ), P( 15, 16 ), P( 19, 21 ) },
	{ P( 1, 24 ), P( 4, 27 ), P( 7, 30 ), P( 10, 21 ), P( 16, 18 ) },
	{ P( 3, 22 ), P( 6, 25 ), P( 9, 28 ), P( 12, 19 ), P( 13, 15 ) }
};

struct State
{
	std::vector<int> v;
	int d;

	State( const std::vector<int> &v, int d )
	:	v(v), d(d)
	{}
};

int N;
std::vector<int> p( 30 );

int main()
{
	scanf( "%d", &N );
	rep( i, N )
	{
		p.resize( 30 );

		rep( j, 30 )
			scanf( "%d", &p[j] );

		std::queue<State> que;
		que.push( State( p, 0 ) );

		while( !que.empty() )
		{
			State st = que.front(); que.pop();

			if( st.d == 8 )
			{
				printf( "%d\n", st.d );
				
				break;
			}

			bool fl = true;
			rep( j, 8 )
			{
				fl &= st.v[j]==st.v[j+1];
				fl &= st.v[j+21]==st.v[j+22];
			}

			rep( j, 2 )
			{
				fl &= st.v[j+9]==st.v[j+10];
				fl &= st.v[j+12]==st.v[j+13];
				fl &= st.v[j+15]==st.v[j+16];
				fl &= st.v[j+18]==st.v[j+19];
			}

			if( fl )
			{
				printf( "%d\n", st.d );

				break;
			}

			rep( t, 4 )
			{
				std::vector<int> v = st.v;

				rep( j, 5 )
					std::swap( v[map[t][j].first-1], v[map[t][j].second-1] );

				que.push( State( v, st.d+1 ) );
			}
		}
	}

	return 0;
}

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

char mat[2][4];

int flag;

int main() {

    for(int i = 0; i < 2; ++i)
        for(int j = 0; j < 3; ++j)
            cin>>mat[i][j];
    
    for(int i = 0, j = 2; i < 3 and j >= 0;i++,j--)
        if(mat[0][i] == mat[1][j])
            flag = 1;
        else {

            flag = 0; break;
        }

    (flag == 0)?cout<<"NO\n":cout<<"YES\n";
}

Measured memory_bytes: 384
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn read_vec2<T: std::str::FromStr>(n: usize) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

fn read_col<T: std::str::FromStr>(n: usize) -> Vec<T> {
    (0..n).map(|_| read()).collect()
}

fn f(n: u32) -> u32 {
    let mut tmp = n;
    let mut cnt: u32 = 0;
    while tmp > 0 {
        cnt += 1;
        tmp = tmp / 10;
    }
    cnt
}

fn pow(a: u32, b: u32) -> u32 {
    let mut ans: u32 = 1;
    for _ in 0..b {
        ans *= a;
    }
    ans
}

fn main() {
    let n: u32 = read();
    let keta = f(n);
    let mut ans: u32 = 0;
    for i in 0..(keta / 2) {
        ans += 9 * pow(100, i);
    }
    if keta % 2 == 1 {
        ans += n + 1 - pow(10, keta - 1);
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
	int power(int b,int p);
	int x,maxv=1;
	cin>>x;
	for(int i=2;i<=int(sqrt(x));++i)
		for(int j=2;j<=10;++j)
			if(power(i,j)<=x&&power(i,j)>maxv)
				maxv=power(i,j);
	cout<<maxv<<endl;
	return 0;
}
int power(int b,int p)
{
	int ans=1;
	for(int i=1;i<p;i++)
		ans*=b;
	return ans;
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

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

template < typename T >
void vprint(T &v){
	REP(i, v.size()){
		cout << v[i] << " ";
	}
	cout << endl;
}

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

	bool flag = true;
	REP(i, S.size()){
		if(i==A){
			if(S[i]!='-') flag = false;
		}else{
			if(S[i]=='-') flag = false;
		}
	}
	cout << (flag?"Yes":"No") << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <utility>
#include <functional>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_map>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
const int INF = (1<<30);
const ll INFL = (1LL<<62);
const int MOD = 1000000007;
template<class T> bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<class T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<class T> ll mod_pow(ll a, ll n, T mod) { mod=(ll)mod; ll res=1, p=a%mod; while(n){ if(n&1) res=res*p%mod; p=p*p%mod; n>>=1; } return res; }

int dp[22][505050];

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> c(m);
    for(auto &ci : c) cin >> ci;
    fill(dp[0], dp[0]+505049, INF);
    dp[0][0]=0;
    rep(i, m){
        rep(j, n+1){
            if(j >= c[i]) dp[i+1][j] = min(dp[i][j], dp[i+1][j-c[i]]+1);
            else dp[i+1][j] = dp[i][j];
        }
    }
    cout << dp[m][n] << endl;
    return 0;
}


Measured memory_bytes: 9032
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define endl '\n'
#define int long long int
using namespace std;
#define pii pair <int, int>
#define mii map<int, int>
#define pb push_back
#define deb(x) cout << #x << " " << x << endl
#define deb2(x, y) cout << #x << " " << x << " " << #y << " " << y << endl
#define Loop(s, e, itr) for (int itr = s; itr < e; itr++)
#define loop(n) for(int i = 0; i < n; i++)
#define vin vector<int>
#define w(t) int tc; cin >> tc; for(int t = 1; t <= tc; t++)
#define vec vector
#define mod 1000000007
#define all(x) x.begin(), x.end()

int n;
int arr[3005];

pii dp_fist[3005][3005];
pii dp_second[3005][3005];

int vis_first[3005][3005];
int vis_second[3005][3005];

pii second(int, int);

pii first(int i, int j){
    
    if(i == j) return {arr[i] , 0};
    if(vis_first[i][j] == -1){
        vis_first[i][j] = 1;
        pii a = second(i+1, j);
        a.first += arr[i];
        pii b = second(i, j-1);
        b.first += arr[j];

        if(a.first - a.second > b.first - b.second) dp_fist[i][j] = a;
        else dp_fist[i][j] = b;
    }
    return dp_fist[i][j];
}

pii second(int i, int j){

    if(i == j) return {0, arr[i]};
    if(vis_second[i][j] == -1){
        vis_second[i][j] = 1;
        pii a = first(i+1, j);
        a.second += arr[i];
        pii b = first(i, j-1);
        b.second += arr[j];

        if(a.first - a.second < b.first - b.second) dp_second[i][j] = a;
        else dp_second[i][j] = b;
    }
    return dp_second[i][j];
}


int32_t main(){
    memset(vis_first, -1, sizeof(vis_first));
    memset(vis_second, -1, sizeof(vis_second));
    cin >> n;
    loop(n) cin >> arr[i];
    pii ans = first(0, n-1);
    cout << ans.first - ans.second << endl;
}

Measured memory_bytes: 308264
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<vector>
#include<utility>

using namespace std;

int main(){

	long long int n;
	cin>>n;

	long long int a[n];
	for(int i=0;i<n;i++){
		cin>>a[i];
	}

	int key=1;
	for(int i=0;i<n;i++){
		if(a[i]==key){
			key++;
		}
	}
	if(key==1)cout<<-1;
	else cout<<n-key+1;
	cout<<endl;

	return 0;
}


Measured memory_bytes: 1792
//#include "stdafx.h"
#include <bits/stdc++.h>
#define ll long long
#define vi vector<int>
#define e "\n"
#define MaRiaMa { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); }
#define fix(n) cout << fixed << setprecision(n);
using namespace std;
int main()
{
	MaRiaMa;
	char a,b;
	cin >> a >> b;
	if (a < b)
		cout << "<";
	else if (a > b)
		cout << ">";
	else if (a == b)
		cout << "=";

}

Measured memory_bytes: 3624
# -*- 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
INF = 2**62-1

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(S, Q):
    ans = 0
    S = deque(S)
    r = False
    for q in Q:
        if q[0] =='1':
            r = not r
        else:
            f = q[1]
            c = q[2]
            if f == '1':
                if r:
                    S.append(c)
                else:
                    S.appendleft(c)
            else:
                if r:
                    S.appendleft(c)
                else:
                    S.append(c)
    S = list(S)
    if r:
        S.reverse()
    return ''.join(S)


def main():
    S = read_str()
    N = read_int()
    Q = [read_str_n() for _ in range(N)]
    print(slv(S, Q))


if __name__ == '__main__':
    main()


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

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

using namespace std;

typedef long long ll;

const ll MAX_N=1e6,MOD=1e9+7;

ll fact[MAX_N+1];
ll N;
ll mpw(ll n,ll m){
	if (!m){
		return 1;
	}
	ll ret=mpw(n,m/2);
	ret*=ret;
	ret%=MOD;
	if (m&1){
		ret*=n;
		ret%=MOD;
	}
	return ret;
}

ll inv(ll n){
	return mpw(n,MOD-2);
}

ll f(ll k){
	if (k<(N+1)/2){
		return 0;
	}
	return fact[k]*fact[N-k-1]%MOD*fact[k-1]%MOD*inv(fact[N-k-1])%MOD*inv(fact[2*k-N])%MOD;
}

int main(){
	cin>>N;
	ll ans=0;
	fact[0]=1;
	FOR(i,1,N){
		fact[i]=(fact[i-1]*i)%MOD;
	}
	FOR(k,1,N){
		ans+=(f(k)-f(k-1)+MOD)%MOD*k%MOD;
		ans%=MOD;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 8064
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <stdint.h>
#include <queue>
#include <bitset>
#include <iomanip>
#include <set>
#include <map>

using namespace std;

#define PI (3.14159265358979323846)
#define INF (2147483647)
#define INF_LL (9223372036854775807)
#define DIV_NUM (1000000007)
typedef long long ll;

// 配列初期化テンプレ
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T& val) {
	std::fill((T*)array, (T*)(array + N), val);
}



int main() {

	ll X;
	cin >> X;

	ll val = 100;
	int i = 0;
	while (true) {
		i++;
		val = (ll)((double)val * 1.01);
		if (val >= X) break;
	}

	cout << i << endl;

	return 0;

}


Measured memory_bytes: 3616
n, k = map(int, input().split())
a = list(map(int, input().split()))
ball = [0]*n

for i in a:
    ball[i - 1] += 1
ball.sort(reverse=True)

ans = 0
if len(ball) > k:
    for i in range(k):
        ans += ball[i]
    ans = n - ans
print(ans)


Measured memory_bytes: 76368
#include<iostream>
#include <string>
using namespace std;
int main()
{
    char a;
    char v[5]={'a','o','i','e','u'};
    cin>>a;
    bool f=false;
    for(int i=0;i<5;i++){
    if(a==v[i]){
    f=true;
    break;
    }
    }
    if(f==true)cout<<"vowel"<<endl;
    else cout<<"consonant"<<endl;
return 0;
}

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

using namespace std;


#include <boost/multiprecision/cpp_int.hpp>
namespace mp = boost::multiprecision;

int main(void) {
    mp::cpp_int X;
    mp::cpp_int money = 100;
    cin >> X;
    for(int64_t i=1;;i++) {
        money *= (101);
        money /= 100;
        if(money >= X) {
            cout << i << "\n";
            break;
        } 
    }
    return 0;
}


Measured memory_bytes: 3656
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    n,q = LI()
    s = S()
    aa = [LS() for _ in range(q)]
    
    li = -1
    ri = n
    for t,d in aa[::-1]:
        if s[li+1] == t and d == 'L':
            li += 1
            if li == n-1:
                return 0
        elif li >= 0 and s[li] == t and d == 'R':
            li -= 1
        if s[ri-1] == t and d == 'R':
            ri -= 1
            if ri == 0:
                return 0
        elif ri < n and s[ri] == t and d == 'L':
            ri += 1

    r = n - (li + 1) - (n - ri)

    return r


print(main())


Measured memory_bytes: 113096
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <iostream>
#include <string>
#include <set>
#include <map>
#include <unordered_map>
#include <complex>
#include <iomanip>
#include <cmath>
#include <tuple>
using namespace std;

long long const MOD = 1000000007LL;

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

    long long a[n + 1], b[n];
    for (int i = 0; i <= n; i++) cin >> a[i];
    for (int i = 0; i < n; i++) cin >> b[i];

    // 倒した敵の数
    long long res = 0;

    // 初期値の設定 街0
    // 勇者0 の残りの体力
    res += min(a[0], b[0]); // a[0] か b[0]
    b[0] = max(b[0] - a[0], 0LL);
    
    // 街1から街n - 1までを助ける
    for (int i = 1; i < n; i++) {
        // 勇者i - 1にできるだけ倒してもらう。
        // 勇者i - 1が戦った後に残る敵の数
        res += min(a[i], b[i - 1]);
        a[i] = max(a[i] - b[i - 1], 0LL);

        // 勇者i に残りの敵と戦ってもらう
        // 勇者i の残りの体力
        res += min(a[i], b[i]);
        b[i] = max(b[i] - a[i], 0LL);
    }

    // 街n を助ける
    // 勇者n - 1だけで戦う
    // 倒せる敵の数
    res += min(a[n], b[n - 1]); // b[n - 1] と a[n]

    cout << res << endl;
}


Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<queue>
#include<map>
#include<set>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstring>
using namespace std;
const int N=550;

typedef long long ll;
int mp[N][N], dp[N][N];

int main()
{
    memset(dp,0,sizeof(dp));
    int n,m,q;
    cin>>n>>m>>q;

    while(m--)
    {
        int a,b;
        cin>>a>>b;
        mp[a][b] ++;
    }

    for(int i=n; i>=1; i--)
        for(int j=1; j<=n; j++)
        {
            dp[i][j] = mp[i][j] + dp[i+1][j] + dp[i][j-1] - dp[i+1][j-1];
        }

    while(q--)
    {
        int a,b;
        cin>>a>>b;
        cout<<dp[a][b]<<endl;
    }



    return 0;
}



Measured memory_bytes: 3200
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 1000000000000000000LL
#define MOD 1000000007
#define writeln(n) cout<<n<<endl;
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
//vector<tuple<long long, long long, long long>>vec;

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

int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

int f(llong a){
    int res = 0;
    while(a>0){
        res++;
        a/=10;
    }
    return res;
}

int main()
{
    llong n;
    cin >> n;
    int res = INT_MAX;
    for(llong i=1;i*i<=n;++i){
        if(n%i==0){
            chmin(res,f(n/i));
        }
    }
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 256
s = input()
cnt = 1
maxcnt=1
for i in range(1,4):
  if s[i] == s[i-1]:
    cnt += 1
  else:
    maxcnt = max(maxcnt,cnt)
    cnt = 1
maxcnt = max(maxcnt,cnt)
if maxcnt>=3:
  print("Yes")
else:
  print("No")

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

    class Program
    {
        static void Main(string[] args)
        {
            for (int i = 1; i < 10; i++)
            {
                for (int j = 1; j < 10; j++)
                {
                    Console.WriteLine(i + "x" + j + "=" + i * j);
                }
            }
            Console.ReadLine();
        }
    }



Measured memory_bytes: 9160
#include<bits/stdc++.h>
using namespace std;
string s;
int main()
{
    int n,k,x,y;
    cin>>n>>k>>x>>y;
    if(n>=k)
    {
        cout<<x*k+y*(n-k)<<endl;
    }
    else
    {
        cout<<x*n<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<vector>
#include<cmath>
#include<queue>
#include<string.h>
#include<map>
#include<algorithm>
#define ll long long
#define rep(i,a,b) for(int i = a;i < b;i++)
#define N 1000004
#define INF 1e9+7

using namespace std;

bool ison(ll x,ll i)
{
    return ((x & (1<<i)));
}

ll n;
string s;
string b,r;
ll dp[20][20][20];

ll solve(ll curb,ll curr,ll i)
{
    if(i > n)
    {
        return 1;
    }

    if(dp[curb][curr][i] != -1)
    {
        return dp[curb][curr][i];
    }

    ll res = 0;

    if(curb < b.size() && s[2*n - i] == b[curb])
    {
        res += solve(curb+1,curr,i+1);
    }

    if(curr < r.size() && s[2*n - i] == r[curr])
    {
        res += solve(curb,curr+1,i+1);
    }

    return dp[curb][curr][i] = res;
}

int main()
{
    ios_base::sync_with_stdio(false);

    cin >> n;

    cin >> s;

    ll res = 0;

    rep(i,0,(1 << n))
    {
        b = "";
        r = "";

        rep(j,0,n)
        {
            if(ison(i,j))
            {
                b += s[j];
            }
            else
            {
                r += s[j];
            }
        }

        memset(dp,-1,sizeof dp);

        res += solve(0,0,1);
    }

    cout << res << endl;

    return 0;
}



Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;

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

    int n, m, p[112345], y[112345];
    vector<P> q[112345];
    cin >> n >> m;
    vector<P> res(m);
    REP(i, m)
    {
        cin >> p[i] >> y[i];
        q[p[i]].push_back(make_pair(y[i], i));
    }

    REP(i, n + 1)
    {
        if (q[i].size())
        {
            SORT(q[i]);
            int cnt = 1;
            REP(j, q[i].size())
            {
                res[q[i][j].second].first = p[q[i][j].second];
                res[q[i][j].second].second = cnt;
                cnt++;
            }
        }
    }

    REP(i, m)
    {
        printf("%06d%06d\n", res[i].first, res[i].second);
    }

    return 0;
}

Measured memory_bytes: 8832
import core.bitop, std.bitmanip;
import core.checkedint;
import std.algorithm, std.functional;
import std.array, std.container;
import std.bigint;
import std.conv;
import std.math, std.numeric;
import std.range, std.range.interfaces;
import std.stdio, std.string;
import std.typecons;

void main()
{
    int n;
    readf("%s", &n);
    readln;
    
    auto arr = readln.chomp.split.map!(to!int).array;
    
    if (arr.isSorted()) {
        writeln("YES");
        return;
    }
    
    foreach (i; 0 .. n) {
        foreach (j; i+1 .. n) {
            swap(arr[i], arr[j]);
            if (arr.isSorted()) {
                writeln("YES");
                return;
            }
            
            swap(arr[i], arr[j]);
        }
    }
    
    writeln("NO");
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string.h>
#include<math.h>
#include<cstring>
using namespace std;

int main(){
	while(1){
		int sum,N,M,r,i,j,k,q,ts,te,start,m,rec[1001][4],in=0,flg1=0;
		cin>>N>>M;
		if(N==0&&M==0)break;
		cin>>r;
		for(i=0;i<r;i++){
			cin>>rec[i][0]>>rec[i][1]>>rec[i][2]>>rec[i][3];
		}
		rec[r][0]=1261;
		cin>>q;
		for(i=0;i<q;i++){
			in=0;
			sum=0;
			cin>>ts>>te>>m;
			flg1=0;
			if(ts<rec[0][0])flg1=1;
			if(te>rec[r-1][0])te=rec[r-1][0];
			for(j=0;rec[j][0]<ts;j++){
				if(rec[j][2]!=m)continue;
				if(flg1==1){
					ts=rec[j][0];flg1=0;
				}
				if(rec[j][3]==1){
					in++;
				}else if(rec[j][3]==0){
					in--;
				}
			}
			if(in>0){
				start=ts;
			}else{
				start=te;
			}
			for(;rec[j][0]<te;j++){
				if(rec[j][2]!=m)continue;
				if(flg1==1){
					ts=rec[j][0];flg1=0;start=ts;
				}
				if(rec[j][3]==1&&in!=0){
					in++;
				}else if(rec[j][3]==1&&in==0){
					start=rec[j][0];
					in++;
				}else if(rec[j][3]==0&&in==1){
					in--;
					sum+=rec[j][0]-start;
					start=te;
				}else{
					in--;
				}
			}
			sum+=(te-start);
			cout<<sum<<endl;
		}
	}
    return 0;
}

Measured memory_bytes: 1176
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define ld long double
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; }
using P=pair<long long,long long>;
#define rep(i,n) for(long long i=0; i<(long long)n; i++)
#define FOR(i,a,b) for(long long i=a; i<b; i++)
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((long long)(x).size())
#define COUT(x) cout << x << endl
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstr vector<string>
#define vp vector<pair<int,int>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define SUM(x) accumulate(x.begin(),x.end(),0)
#define MAX(x) *max_element(x.begin(),x.end())
#define MIN(x) *min_element(x.begin(),x.end())
#define couty cout<<"Yes"<<endl
#define coutn cout<<"No"<<endl
#define coutY cout<<"YES"<<endl
#define coutN cout<<"NO"<<endl
#define yn(x) cout<<(x?"Yes":"No")<<endl
#define YN(x) cout<<(x?"YES":"NO")<<endl
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
const long long dx[4]={1,0,-1,0};
const long long dy[4]={0,1,0,-1};
const long long INF = 1e12;
const long long MOD = 1e9+7;
#define map unordered_map

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(15);

    int n; cin >> n;
    vint a(n);
    map<int,int> map;
    rep(i,n){
        cin >> a[i];
        map[a[i]]++;
    }

    /*
    sort(all(a));
    int res=0;
    for(int i=0; i<n; i++){
        bool can=true;
        for(int j=0; a[j]*a[j]<=a[i]; j++){
            if(i==j) continue;
            if(a[i]%a[j]==0){
                can=false; break;
            }
        }
        
        if(can) res++;
        if(can) cout<<a[i]<<endl;
    }
    cout<<res<<endl;
    */

    sort(all(a));
    if(a[0]==1){
        if(map[1]==1){
            cout<<1<<endl;
            return 0;
        }else if(map[1]>2){
            cout<<0<<endl;
            return 0;
        }
    }
    int res=0;
    rep(i,n){
        bool can=true;
        if(map[a[i]]>=2) continue;
        for(int j=1; j*j<=a[i]; j++){
            //if(map[a[i]]>1) { break;}
            if(a[i]%j==0){
                if(map[j]>0) {can=false; break;}
                if(j*j!=a[i] && j!=1){
                    if(map[a[i]/j]>0) {can=false; break;}
                }
            }
        }
        if(can) res++;
    }
    cout<<res<<endl;
    
}

Measured memory_bytes: 33340
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ll n,x,y,i,j,p=0,q=0,s=0,r,t;
	cin>>n;
	ll a[n];
	for(i=1;i<=n;i++)
	{cin>>a[i];s=s+a[i];
	}
	for(i=1;i<=n;i++)
	{
		p=q;
		q=q+a[i];
		if(q>s/2)
		{	
			break;
		}
	}
	r=s-p;
	t=s-q;
	cout<<std::min(abs(p-r),abs(q-t));
	
}

Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;


int main(){
    int N;
    while(cin>>N){
        vector<int> skew(2*N);
        for(int i=0;i<2*N;i++)
            cin>>skew[i];
        sort(skew.begin(),skew.end());
        /* for(int i=0;i<2*N;i++) */
            /* cout<<skew[i]<<endl; */
        
        int sum=0;
        for(int i=0;i<2*N;i=i+2)
            sum+=skew[i];
        cout<<sum<<endl;

        return 0;


    }
}


Measured memory_bytes: 256
n = int(input())
mini = float('inf')
n_iter = int(n**(1/2)+2)

for i in range(1, n_iter):
    if n%i==0:
        a, b = i, int(n/i)
        dist = (a-1) + (b-1)
        mini = min(mini, dist)

print(mini)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
int n, x;
int f[100];
void process(int x) {
	if (x <= 399) {
		f[1] = 1;
		return;
	}
	if (x <= 799) {
		f[2] = 1;
		return;
	}
	if (x <= 1199) {
		f[3] = 1;
		return;
	}
	if (x < 1600) {
		f[4] = 1;
		return;
	}
	if (x < 2000) {
		f[5] = 1;
		return;
	}
	if (x < 2400) {
		f[6] = 1;
		return;
	}
	if (x < 2800) {
		f[7] = 1;
		return;
	}
	if (x < 3200) {
		f[8] = 1;
		return;
	}
	f[9] ++;
// 	Rating 1-399 : gray
// Rating 400-799 : brown
// Rating 800-1199 : green
// Rating 1200-1599 : cyan
// Rating 1600-1999 : blue
// Rating 2000-2399 : yellow
// Rating 2400-2799 : orange
// Rating 2800-3199 : red
}
int main() {
	//freopen("a.inp", "r", stdin);
	// freopen("a.out", "w", stdout);
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d", &x);
		process(x);
	}
	int t = 0;
	for (int i = 1; i <= 8; i++) {
		t += f[i];
	}
	if (t==0) cout<<1<<" "<<f[9];
	else cout << t << " " << t + f[9];
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;


int main() {
  int n,m;
  cin >> n >> m;
  vector<pp> a(n),b(m);
  rep(i,n){
    cin >> a[i].first >> a[i].second;
  }
  rep(i,m){
    cin >> b[i].first >> b[i].second;
  }
  rep(i,n){
    int u=inf,e;
    rep(j,m){
      if (u>abs(a[i].first-b[j].first)+abs(a[i].second-b[j].second)){
        u=abs(a[i].first-b[j].first)+abs(a[i].second-b[j].second);
        e=j+1;
      }
    }
    cout << e << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl "\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using ll = long long;
const int INF = 0x3f3f3f3f;
using namespace std;

int n;
pair<string, pair<int, int>> arr[101];
int main()
{
    IOS
    //freopen("planet.in", "r", stdin);
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> arr[i].first >> arr[i].second.first;
        arr[i].second.second = i+1;
    }
    sort(arr, arr+n, [](const pair<string, pair<int, int>>& a, const pair<string, pair<int, int>>& b) {
         if (a.first == b.first) {
            return b.second.first < a.second.first;
         }
         return a.first < b.first;
         });
    for (int i = 0; i < n; ++i) {
        cout << arr[i].second.second << endl;
    }


    return 0;
}


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

int main()
{
	int x;
	cin >> x;
	if (x>=30) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 3648
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int gcd(int a,int b){
  return b==0?a:gcd(b,a%b);
}
const int maxn=100005;
int a[maxn];
int main(){
  int n,k;scanf("%d%d",&n,&k);
  for(int i=1;i<=n;++i){
    scanf("%d",a+i);
  }
  int g=a[1];
  for(int i=2;i<=n;++i)g=gcd(g,a[i]);
  bool flag=false;
  for(int i=1;i<=n;++i){
    if(a[i]>=k&&k%g==a[i]%g)flag=true;
  }
  if(flag)printf("POSSIBLE\n");
  else printf("IMPOSSIBLE\n");
  return 0;
}


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

#define int long long
#define rep(i,a,n) for(int i = a; i < n; i++)
#define pb push_back
#define eb emplace_back
#define dump(x) cout << #x << " = " << (x) << endl
#define chk() cout << "now" << endl;
#define ALL(x) (x).begin(),(x).end()
#define SORT(c) sort((c).begin(), (c).end())
#define SORTG(c) sort(ALL(c), greater<int>());
#define fi first
#define se second
int INF = 1e9 + 7;

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

int N;

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

    cin>>N;
    vi a(N);
    rep(i,0,N) {
        cin>>a[i];
    }

    int sum=a[N-1];
    rep(i,0,N) {
        sum = sum^a[i];
    }
    if(sum==a[N-1]) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


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

int main(void){
    int n, k;
    scanf("%d %d", &n, &k);
    double p=0;
    for(int i=1; i<=n; i++){
        int point=i;
        double temp=1.0/n;
        while(point<k){
            point*=2;
            temp/=2;
        }
        p+=temp;
    }
    printf("%.12lf\n", p);
    return 0;
}


Measured memory_bytes: 1716
#include<iostream>
using namespace std;
class A{
    public:
        void solve(int a,int b){
            if(a==1||b==1){
                if(a==b)cout<<"Draw"<<endl;
                else if(a<b)cout<<"Alice"<<endl;
                else cout<<"Bob"<<endl;
            }
            else{
                if(a==b)cout<<"Draw"<<endl;
                else if(a<b)cout<<"Bob"<<endl;
                else cout<<"Alice"<<endl;
            }
        }
};
int main(){
    A inst;
    int a,b;
    cin>>a>>b;
    inst.solve(a,b);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
    int n;
    scanf("%d",&n);
    ll a=0,b=0,x,y,sum=0,maxn,t,p;
    while(n--){
        t=-1,p=-1;
        scanf("%lld %lld",&x,&y);
        if(x>=a&&y>=b) {a=x,b=y;}
        else if(x>a&&y==b){a=x;}
        else if(y>b&&x==a){b=y;}
        else if(a>x||b>y){
            if(a>x){
                t=a/x;
                if(a%x!=0) t++;
            }
            if(b>y){
                p=b/y;
                if(b%y!=0) p++;
            }
            maxn=max(t,p);
            a=x*maxn;
            b=y*maxn;
        }
    }
     printf("%lld\n",a+b);
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

#define N 100000
#define A 100000
#define MD 1000000007

int main() {
	static int kk[N];
	int n, i, a;
	long long ans;

	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%d", &a);
		kk[a]++;
		if (a % 2 == n % 2 || kk[a] > 2) {
			printf("0\n");
			return 0;
		}
	}
	if ((n % 2 == 0 && kk[0] != 0) || (n % 2 && kk[0] != 1)) {
		printf("0\n");
		return 0;
	}
	ans = 1;
	for (a = 1; a < n; a++)
		if (kk[a] > 0)
			ans = (ans * 2) % MD;
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 512
//
//  main.cpp
//  CoderWork
//
//  Created by Minoru Hayashi on 2020/02/29.
//  Copyright © 2020 Minoru Hayashi. All rights reserved.
//

#include <bits/stdc++.h>
using namespace std;

#define REP(i,n) for (int i=0; i<(n); i++)
#define REP2(i,x,n) for (int i=x; i<(n); i++)
#define ALL(n) begin(n), end(n)

using ll = long long;

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


const int INF = 1LL<<29;

//#define __DBG__


void solve(void){

  int N;
  cin >> N;

  vector<int> DP(N*3+3);
  vector<int> a(N*3+3);
  
  REP(i,N*3) {
    cin >> a[i];
    DP[i]=0;
  }
  
  DP[0]=a[0];  //A
  DP[1]=a[1];  //B
  DP[2]=a[2];  //C

  for(int i=3;i<N*3; i++){
    int x=i/3;
    int y=i%3;
    for(int j=0; j<3; j++){
      if(j==y){continue;}
      chmax(DP[i],(DP[(x-1)*3+j]+a[i]));
    }
  }
  
  int ans=0;
  
  for(int i=N*3-3;i<N*3;i++){
    chmax(ans,DP[i]);
  }
  cout << ans << endl;
  
  return;
}


int main(int argc, const char * argv[]) {


    // cinを高速にするためのおまじない
    cin.tie(0);
    ios::sync_with_stdio(false);
  
    solve();
 
    return 0;
}




Measured memory_bytes: 2560
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int di[] = {0, 0, 1, -1};
constexpr int dj[] = {1, -1, 0, 0};

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

    string s, t;
    cin >> s >> t;

    cout << t << s << endl;

    return 0;
}

Measured memory_bytes: 256
import itertools
while True:
    n = int(input())
    k = int(input())
    if n == 0 and k == 0:
        break
    li = [int(input()) for i in range(n)]
    p = list(itertools.permutations(li,k))
    s = set()
    for i in p:
        c  = ""
        for j in range(len(i)):
            c += str(i[j])
        if c in s:
            continue
        else:
            s.add(int(c))
    print(len(s))


Measured memory_bytes: 6732
#!/usr/bin/env python
# -*- coding: utf-8 -*-

#number of amidakuji

h,w,k=map(int,input().split())

dp=[[0 for i in range(w+1)] for i in range(h+1)]

#dp[i][j]=i段目まででjというところにいくために必要な方法の総和
#求めるのはdp[h][k]である
dp[0][1] = 1
mod=10**9+7
if w>1:
    for i in range(1,h+1):
        for j in range(2**(w-1)):
            st=format(j,"0%ib"%(w-1))
            flag=True
            for _ in range(w-2):
                if st[_]=="1" and st[_+1]=="1":
                    flag=False
            connect=[False for kyopuro in range(w+1)]
            if flag:
                li=[]
                for ss in range(w-1):
                    if st[ss]=="1":
                        li.append(ss+1)
                        connect[ss+1]=True
                        connect[ss+2]=True

                for some in li:
                    dp[i][some+1]+=dp[i-1][some]
                    dp[i][some+1]%=mod
                    dp[i][some]+=dp[i-1][some+1]
                    dp[i][some]%=mod
                for number in range(1,w+1):
                    if connect[number]==False:
                        dp[i][number]+=dp[i-1][number]
                        dp[i][number]%=mod
    print(dp[h][k]%mod)
                
        
else:
    print(1)


        

Measured memory_bytes: 3064
import java.util.*;
import java.io.*;

public class Main {

	public static void main(String[] args)
	{
			Scanner in = new Scanner(System.in);

			int n = in.nextInt();
			int a = in.nextInt();

			int mo = n % 500;
			int r = a - mo;
			if(r >= 0)
				System.out.println("Yes");
			else
				System.out.println("No");
}}

Measured memory_bytes: 19796
n = int(input())
t  = list(map(int, input().split()))
m = int(input())
problem = []
for _ in range(m):
  hoge = list(map(int, input().split()))
  problem.append(hoge)
for i, fuga in enumerate(problem):
  drink_p, drink_p_time= fuga
  res = 0
  for p, p_time in enumerate(t):
    if(p == drink_p-1):
      res += drink_p_time
    else:
      res += p_time
  print(res)

Measured memory_bytes: 38512