akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;
#define sqr(x) ((x)*(x))
#define cube(x) ((x)*(x)*(x))
#define GCD(a, b) __gcd(a, b)
#define LCM(a, b) ((a)*(b)/GCD(a,b))
#define PI (3.141592653589793238462643383279502884197169399375105820974944)
#define MP make_pair
#define n1 first
#define n2 second
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define PDB pair<db,db>
#define SI set<int>
#define SL set<ll>
#define MS multiset
#define MSI multiset<int>
#define MSLL multiset<ll>
#define PB push_back
#define PF push_front
#define VI vector<int>
#define VPI vector<pair<int,int>>
#define VLL vector<ll>
#define VS vector<string>
#define SZ(x) ((int)x.size())

typedef long long ll;

typedef unsigned long long ull;
typedef long double ld;
typedef double db;
const int INF = 1000000007;
const ll LINF = 1000000000000000555;
const int N = 550555;
const int L = 21;
const int M = 2155;
const int K = 555;

db a[N];
void solve(){
    int n,m;
    cin >> n >> m;

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

    sort(a+1, a+n+1);
    reverse(a+1, a+n+1);

    db k = 0.25*sum/m;
    if (a[m] >= k) cout << "Yes"; else
        cout << "No";

}

int main() {
    //ios_base::sync_with_stdio(false);
#ifdef dxz05
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else

#endif

    int T = 1;
    //cin >> T;

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

    return 0;
}

Measured memory_bytes: 256
import numpy as np
import scipy as sp
from collections import Counter

N = int(input())
S = []
for _ in range(N):
    a = input()[0]
    if a in {'M','A','R','C','H'}:
        S.append(a)

a = Counter(S)

num = list(a.values())

l = len(num)
s = 0
for i in range(l-2):
    for j in range(i+1,l-1):
        for k in range(j+1,l):
            s += num[i] * num[j] * num[k]
print(s)
        





Measured memory_bytes: 22932
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>

using namespace std;
typedef long long ll;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, f, n) for (ll i = (f); i < (n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define repv(v) for (auto it = (v).begin(); it != (v).end(); it++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define INIT    \
    cin.tie(0); \
    ios::sync_with_stdio(false);

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

ll const INF = 1LL << 60;
ll const MOD = 1000000007;

struct mint {
    ll x;  // typedef long long ll;
    mint(ll x = 0) : x((x % MOD + MOD) % MOD) {}

    mint operator-() const { return mint(-x); }

    mint& operator+=(const mint a) {
        if ((x += a.x) >= MOD) x -= MOD;
        return *this;
    }

    mint& operator-=(const mint a) {
        if ((x += MOD - a.x) >= MOD) x -= MOD;
        return *this;
    }

    mint& operator*=(const mint a) {
        (x *= a.x) %= MOD;
        return *this;
    }

    mint operator+(const mint a) const { return mint(*this) += a; }

    mint operator-(const mint a) const { return mint(*this) -= a; }

    mint operator*(const mint a) const { return mint(*this) *= a; }

    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(MOD - 2); }
    mint& operator/=(const mint a) { return *this *= a.inv(); }
    mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }

int main() {
    INIT;
    ll N;
    cin >> N;
    vector<ll> A(N);
    rep(i, N) cin >> A[i];

    vector<ll> cnt(N, 0);
    rep(i, N) cnt[A[i]]++;

    // repv(cnt) cout << *it << " ";
    // cout << endl;

    if (N % 2 == 0) {
        for (ll i = 1; i <= N - 1; i += 2) {
            if (cnt[i] != 2) {
                cout << 0 << endl;
                return 0;
            }
        }
    } else {
        if (cnt[0] != 1) {
            cout << 0 << endl;
            return 0;
        }
        for (ll i = 2; i <= N - 2; i += 2) {
            if (cnt[i] != 2) {
                cout << 0 << endl;
                return 0;
            }
        }
    }

    mint ans = 1;
    rep(i, N) {
        ans *= cnt[A[i]];
        cnt[A[i]]--;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4756
N, M = list(map(int, input().split()))
V = [list(map(lambda x: int(x) - 1, input().split()))[1:] for _ in range(M)]
P = list(map(int, input().split()))
res = 0
for i in range(1 << N):
    B = format(i, f'0{N}b')[::-1]
    flg = True
    for j in range(M):
        cnt = 0
        for s in V[j]:
            if B[s] == '1':
                cnt += 1
        if cnt % 2 != P[j]:
            flg = False
    res += int(flg)
print(res)


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

class D
{
	static int[] Read() => Console.ReadLine().Split().Select(int.Parse).ToArray();
	static void Main()
	{
		var M = 998244353;
		var h = Read();
		var n = h[0];
		var rs = new int[h[1]].Select(_ => Read()).ToArray();

		var dp = new long[n + 1];
		var d = new long[n + 1];
		d[1] = 1;
		d[2] = -1;

		for (int i = 1; i <= n; i++)
		{
			dp[i] = (dp[i - 1] + d[i]) % M;
			foreach (var r in rs)
			{
				if (i + r[0] <= n) d[i + r[0]] = (d[i + r[0]] + dp[i]) % M;
				if (i + r[1] + 1 <= n) d[i + r[1] + 1] = (d[i + r[1] + 1] - dp[i] + M) % M;
			}
		}
		Console.WriteLine(dp[n]);
	}
}


Measured memory_bytes: 31220
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
#include <set>
#include <cmath>
using namespace std;

int beki(int x,int N){
  int ans=1;
  for (size_t i = 0; i < N; i++) {
    ans *= x;
  }
  return ans;
}


int main(void) {
  int N,K;
  scanf("%d %d",&N,&K);
  printf("%d\n",K*beki(K-1,N-1));
  return 0;
}


Measured memory_bytes: 256
<?php
$n = trim(fgets(STDIN));
$a = explode(' ', trim(fgets(STDIN)));

echo implode(' ', $a) . PHP_EOL;

for ($i = 1; $i < $n; $i++) {
    $v = $a[$i];
    $j = $i - 1;

    while ($j >= 0 && $a[$j] > $v) {
        $a[$j + 1] = $a[$j];
        $j--;
    }

    $a[$j + 1] = $v;

    echo implode(' ', $a) . PHP_EOL;
}


Measured memory_bytes: 9268
#include<iostream>
#include <bits/stdc++.h>
#include<utility>
#include<algorithm>
#define int long long int
int mod=1e9+7;
#define p_b push_back
#define p_f push_front
#define P_f pop_front
#define P_b pop_back
#define m_p make_pair
#define m_t make_tuple
#define len() length()
#define sz() size()
#define u_b upper_bound
#define l_b lower_bound
#define ins insert
#define str string 
#define bitcount __builtin_popcount
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define ld long double
#define db double
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define F first
#define S second
#define T third
#define endl "\n"
#define done return 0;
#define Fill(a,n,x) fill(a,a+n,x);
// #define fill(a,val) memset(a,val,sizeof(a))
using namespace std;
typedef map<int,int> Map;
typedef pair<int,int> pr;
typedef vector<int> vec;
const int INF = 1e18;
const int MAX =1e18;
int power(int a,int b)
{   
    if(b==0)
    return 1;
    int num=1;
    int m=mod+2;
    while(b!=1)
    { 
        if(b%2==0)
        { 
            a*=a;
            a%=m;
            b/=2;
        }
        else
        { 
            num*=a;
            num%=m;
            b--;
        }
        
    }
    return (a*num)%m;
}
void solve()
{   
    int n;
    cin>>n;
    Map mp;
	 while (n % 2 == 0)  
    {  
        mp[2]++;
        n = n/2;  
    }  
   
    for (int i = 3; i <= sqrt(n); i = i + 2)  
    {  

        while (n % i == 0)  
        {  
            mp[i]++;
            n = n/i;  
        }  
    }  
  

    if (n > 2)  
        mp[n]++;
    int ans=0;
    for(auto x:mp)
    {
        int y=x.second;
        int val=1;
        while(val*val+val<=2*y)
        {
              ans++;
              val++;
        }
    }
    cout<<ans<<endl;
}
int32_t main()
{
    fio;
    int t;
    t=1;
    // cin>>t;
    while(t--)
    {
        solve();
    }
    done;
}

Measured memory_bytes: 3568
#include<stdio.h>

int main(){
  char str[1001];
  while(1){
    scanf("%s",str);
    if(str[0]=='0')break;
    int i=0,sum=0;
    while(1){
      if(str[i]=='\0')break;
      sum+=str[i]-'0';
      i++;
    }
    printf("%d\n",sum);
  }
  return 0;
}



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

int main(){
    string s;
    cin >> s;
    int i = s.size();
    bool tag = true;
    while (i != 0)
    {
        if(i > 4 && s.substr(i-5,5) == "dream"){
            i -= 5;
        }
        else if(i > 6 && s.substr(i-7,7) == "dreamer"){
            i -= 7;
        }
        else if(i > 4 && s.substr(i-5,5) == "erase"){
            i -= 5;
        }
        else if(i > 5 && s.substr(i - 6, 6) == "eraser"){
            i -= 6;
        }
        else{
            tag = false;
            break;
        }


    }
    if(tag) cout << "YES" << endl;
    else cout << "NO" << endl;
}


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

// 小数点以下桁数
// fixed << setprecision(i)

int64_t gcd(int64_t a,int64_t b){return (a%b==0?b:gcd(b, a%b));}
int64_t lcm(int64_t a,int64_t b){return a/gcd(a, b)*b;}
int factorial(int a){int b=1;while(a){b*=a--;}return b;} //13以下対応
bool is_prime(int a){if(a<=1)return false;for(int i=2;(int64_t)i*i<=a;i++){if(a%i==0)return false;}return true;}
int get_adp(double x, int n){return (int)round((x-(int)x)*pow(10,n))%10;} // 小数点以下の指定桁の値を取得
int64_t sigma(int64_t s, int64_t n){return n*(2*s+n-1)/2;}

//順列の全列挙
// vector<int> v(N);
// iota(v.begin(), v.end(), 1);       // v に 1, 2, ... N を設定
// do {
//	for(auto x : v) cout << x << " "; cout << "\n";     // v の要素を表示
// } while( next_permutation(v.begin(), v.end()) ); 

//bit全探索
// for (int tmp = 0; tmp < (1 << ビット数); tmp++) {
//	bitset<ビット数> s(tmp);
//	// (ビット列sに対する処理)
// }

int main()
{
	int64_t x;
	cin >> x;
	cout << x / 11 * 2 + (x % 11 == 0 ? 0 : x % 11 < 7 ? 1 : 2) << endl;
}


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

int main() {
    int A,B; cin >> A >> B;
    if (A<B) swap(A,B);
    if (A==3 && B==2) cout << 1;
    if (A==3 && B==1) cout << 2;
    if (A==2 && B==1) cout << 3;
    cout << endl;
}


Measured memory_bytes: 256
/**/
#include<bits/stdc++.h>
using namespace std;
char e[5];
int a,b,c,d;
int main(){
	ios::sync_with_stdio(false);
	cin>>e;
	a=(int)(e[0]-48),b=(int)(e[1]-48),c=(int)(e[2]-48),d=(int)(e[3]-48);
	if(a+b+c+d==7){
		cout<<a<<'+'<<b<<'+'<<c<<'+'<<d<<"=7"<<endl;
		return 0;
	}
	if(a-b+c+d==7){
		cout<<a<<'-'<<b<<'+'<<c<<'+'<<d<<"=7"<<endl;
		return 0;
	}
	if(a+b-c+d==7){
		cout<<a<<'+'<<b<<'-'<<c<<'+'<<d<<"=7"<<endl;
		return 0;
	}
	if(a+b+c-d==7){
		cout<<a<<'+'<<b<<'+'<<c<<'-'<<d<<"=7"<<endl;
		return 0;
	}
	if(a-b-c+d==7){
		cout<<a<<'-'<<b<<'-'<<c<<'+'<<d<<"=7"<<endl;
		return 0;
	}
	if(a+b-c-d==7){
		cout<<a<<'+'<<b<<'-'<<c<<'-'<<d<<"=7"<<endl;
		return 0;
	}
	if(a-b+c-d==7){
		cout<<a<<'-'<<b<<'+'<<c<<'-'<<d<<"=7"<<endl;
		return 0;
	}
	if(a-b-c-d==7){
		cout<<a<<'-'<<b<<'-'<<c<<'-'<<d<<"=7"<<endl;
		return 0;
	}
	return 0;
}


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

int main() {
  int N;
  string S, T;
  cin >> N >> S >> T;
  
  string ans = "";
  for (int i = 0; i < N; i++) {
    ans += S[i];
    ans += T[i];
  }
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication3
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                var HW = Console.ReadLine().Split().Select(int.Parse).ToArray();
                var H = HW[0];
                var W = HW[1];
                if (H == 0)
                    break;
                foreach (var i in Enumerable.Range(0, H))
                {
                    foreach (var j in Enumerable.Range(0, W - 1))
                    {
                        Console.Write("#");
                    }
                    Console.WriteLine("#");
                }
                Console.WriteLine();
            }
        }
    }
}

Measured memory_bytes: 9388
s = (input())
#a,b = map(int,input().split())
n = len(s)
b = n//2
s1 = s[0:b]
s2 = s[b+1:]
#print(s1,s2)
if n == 3:
    if s[0] == s[-1]:
        print("Yes")
        exit()
    else:
        print("No")
        exit()
        
flag1 = True
for i in range(len(s1)//2):
    if s1[i] == s1[-i-1]:
        flag1 = True
    else:
        flag1 = False
        break

if flag1 and (s1 == s2):
    print("Yes")
else:
    print("No")

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

#define int long long
#define pb push_back
#define in insert
#define F first
#define S second
#define mod 1000000007
#define endl '\n'
#define all(x)  x.begin(),x.end()
#define w(x) int x;cin>>x; while(x-->0)
#define memset(a,b) memset(a,b,sizeof(a))
#define debug(x) cout << "[ " << #x  << " : " << x << " ]" << endl;

void fast()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}
/*
think fast
think simple
*/
void mysol()
{
	int n; cin >> n ;
	vector<int> v(n);
	for (int &a : v)
		cin >> a;
	sort(all(v));

	int ans = 0;
	ans += v.back();
	v.pop_back();
	n--;
	int i = 0;
	while (n-- > 1)
	{
		ans += v.back();
		if (i++ & 1)
			v.pop_back();
	}
	cout << ans << endl;

}

int32_t main()
{
	fast();
	// w(t)
	{
		mysol();
	}
	//cerr << sizeof(dp)*(1e-6) << " megabytes\n";
	return 0;
}


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


int main(){
    int n;
    cin >> n;
    vector<int> ans(10005);
    for(int x = 1; x <= 100; x++) {
        for(int y = 1; y <= 100; y++) {
            for(int z = 1; z <= 100; z++) {
                int d = x*x + y*y + z*z + x*y + y*z + z*x;
                if(d > 10000) continue;
                ans[d]++;
            }
        }
    }
    for(int i = 1; i <= n; i++) {
        cout << ans[i] << endl;
    }
}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define gcd(a,b) __gcd(a,b)
#define ff first
#define ss second
#define p pair<int,int>
#define pb push_back
#define endl '\n'
#define w(t) ll test;cin>>test;while(test--)
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(0);
#define pi acos(-1)

int main()
{
    fast;
    string s;
    map<char,int>mp;
    cin>>s;
    for(auto i:s)
    {
        mp[i]++;
    }
    int flag=1;
    for(auto i:mp)
    {
        if(i.ss&1)flag=0;
    }
    cout<<(flag?"Yes":"No")<<endl;

}



Measured memory_bytes: 3664
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <algorithm>
#include <set>
#include <climits>
 
using namespace std;
 
 
int main() {
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
 
	int n;
	cin >> n;
	vector<vector<int>> g(n);
	for (int i = 0; i < n; ++i) {
		g[i].resize(n);
		for (int j = 0; j < n; ++j) {
			cin >> g[i][j];
		}
	}

	long long dist = 0;
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < n; ++j) {
			bool add = true;
			for (int c = 0; c < n; ++c) {
				if (g[i][j] > g[i][c] + g[c][j])
				{
					cout << -1 << endl;
					return 0;
				}

				if (c != i && c != j && g[i][j] == g[i][c] + g[c][j])
					add = false;
			}
			if (add)
				dist += g[i][j];
		}
	}

	cout << dist / 2 << endl;
 
	return 0;
}

Measured memory_bytes: 640
///
// File:  a.go
// Author: ymiyamoto
//
// Created on Sat Apr 21 21:01:36 2018
//
package main

import (
	"fmt"
)

var A, B, C, X, Y int

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func main() {
	cost := 0
	fmt.Scan(&A, &B, &C, &X, &Y)
	if 2*C < (A + B) {
		n := min(X, Y)
		cost += min(2*C*max(X, Y), 2*C*n+A*(X-n)+B*(Y-n))
	} else {
		cost += A*X + B*Y
	}

	fmt.Println(cost)
}


Measured memory_bytes: 512
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int K = sc.nextInt();
    sc.nextLine();
    String tmp = sc.nextLine();
    String Spl[] = tmp.split(" ");
    Long A[] = new Long[N];
    for (int i=0;i<N;i++){
      A[i] = Long.parseLong(Spl[i]);
    }
    Arrays.sort(A,Comparator.reverseOrder());
    long ans = 0;
    for (int i=(K);i<N;i++){
      ans += A[i];
    }
    System.out.println(ans);
  }
}


Measured memory_bytes: 79472
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner scan = new Scanner(System.in);
		int second = scan.nextInt();
		if (second < 0 || second >= 86400) {
			System.out.println("Error!");
		} else {
			int hour = second/3600;
			int minute = (second - hour*3600)/60;
			System.out.println(hour + ":" + minute + ":" + (second - hour*3600 - minute*60));
		}
	}

}

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

using namespace std;

#define cerr if(false)cerr
#define what(x) cerr<<#x<<" = "<<x<<endl
 
typedef int ll;
typedef pair<ll, ll> ii;

const int maxN = 1e6 + 9, maxV = 1e6 + 9, MOD = 1e9 + 7, SQ = 322;
const int INF = 1e9;
vector<ii> diff;
ii segment[4 * maxN];
int n;

void build(int node, int left, int right){
	if(left == right){
		segment[node] = {diff[left].first, left};
	}else{
		int mid = (left + right) / 2;
		build(2 * node, left, mid);
		build(2 * node + 1, mid + 1, right);
		segment[node] = max(segment[2*node], segment[2*node+1]);
	}
}

ii query(int node, int curl, int curr, int l, int r){
	if(curr < l || curl > r) return {-INF, -INF};
	if(l <= curl && curr <= r) return segment[node];
	int mid = (curr + curl) / 2;
	return max(query(2 * node, curl, mid, l , r), query(2*node+1, mid+1, curr, l, r));
}

int SearchPos(ll x){
	int left = 0;
	int right = n-1;
	int pos = -1;
	while(left <= right){
		int mid = (left + right) / 2;
		if(diff[mid].second < x){
			left = mid + 1;
		}else{
			pos = mid;
			right = mid - 1;
		}
	}
	return pos;
}

void update(int node, int left, int right, int pos, int val){
	if(left == right){
		segment[node] = {val, pos};
	}else{
		int mid = (left + right) / 2;
		if(pos <= mid)
			update(2*node, left, mid, pos, val);
		else
			update(2*node+1, mid+1, right, pos, val);
		segment[node] = max(segment[2*node], segment[2*node+1]);
	}
}

int main(){

	ios_base::sync_with_stdio(false); 
	cin.tie(0);
	cout.tie(0);

	cin >> n;

	diff.assign(n, {0,0});

	string s;
	int diffe = 0;
	for(int i = 0 ; i < n; i++){
		cin >> s;
		what(i);
		diffe = 0;
		for(int j = 0 ; j < s.size(); j++){
			diffe += (s[j] == '(' ? 1 : -1);
			diff[i].first += (s[j] == '(' ? 1 : -1);
			diff[i].first = max(0, diff[i].first);
			diff[i].second = min(diffe, diff[i].second);
		}
	}

	sort(diff.begin(), diff.end(), [](const ii& a, const ii& b){
		if(a.second == b.second)return a.first < b.first;
		return a.second < b.second;
	});

	build(1, 0, n-1);

	for(int i = 0; i < n; i++){
		what("----------------");
		what(i);
		what(diff[i].first);
		what(diff[i].second);
	}

	ll cur_dif = 0;
	int pos;
	for(int i = 0; i < n; i++){
		what("----------------");
		what(cur_dif);
		what(i);
		pos = SearchPos(-cur_dif);
		what(pos);
		if(pos == -1){
			cout << "No" << endl;
			return 0;
		}
		auto it = query(1, 0, n-1, pos, n-1);
		what(it.first);
		what(it.second);
		//Actualizar
		cur_dif += it.first + diff[it.second].second;
		what(cur_dif);
		update(1, 0, n-1, it.second, -INF);
		if(cur_dif < 0){
			cout << "No" << endl;
			return 0;
		}
	}

	cout << (cur_dif == 0 ? "Yes" : "No") << endl;

	return 0;
}

Measured memory_bytes: 27400
import java.io.*;

class Main{
    public static void main(String[] args)throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        
for(;;){
int n=Integer.parseInt(br.readLine());
if(n==0)break;
int taro[]=new int[2*n]; 
int hanako[]=new int[2*n];
for(int i=0;i<2*n;i++)hanako[i]=1;
for(int i=0;i<n;i++){
int m=Integer.parseInt(br.readLine())-1;
taro[m]=1;hanako[m]=0;
}
int tp=n,hp=n,max=-1; boolean f=true;
for(;;){
for(int i=0;i<2*n;i++){
	if(f==true)max=-1;
	if(max<i&&taro[i]==1){
     max=i; taro[i]=0;
     hp-=1; f=true;
     break;
     }}
if(hp==0)break;
for(int i=0;i<2*n;i++){
	if(f==false)max=-1;
	if(max<i&&hanako[i]==1){
     max=i; hanako[i]=0;
     tp-=1; f=false;
     break;
     }}
if(tp==0)break;
}
System.out.println(tp);
System.out.println(hp);
}
}
}

Measured memory_bytes: 17800
#include<bits/stdc++.h>
using namespace std;
const int maxn = 100001;
int n, val[maxn];
bool used[maxn];
long long ans;
int main(){
	ios_base::sync_with_stdio(0), cin.tie(0);
	cin >> n;
	for(int i = 0;i < n;++i)cin >> val[i];
	--n;
	for(int c = 1;c < n;++c){
		long long sum = 0;
		for(int k = 1;(k + 1) * c < n and !used[c * k] and !used[n - c * k] and (((c * k) << 1) != n);++k){
			ans = max(sum += val[c * k] + val[n - c * k], ans);
			used[c * k] = used[n - c * k] = true;
		}
		for(int k = 1;k * c < n and (used[c * k] || used[n - c * k]);++k){
			used[c * k] = used[n - c * k] = false;
		}
	}
	cout << ans << '\n';
}

Measured memory_bytes: 768
from collections import *
from itertools import *
from bisect import *
import copy

k,q=map(int,input().split())
D=list(map(int,input().split()))
nxm=[list(map(int,input().split())) for i in range(q)]

for n,x,m in nxm:
    dlst=[d%m for d in D]
    count0=[(dlst[0]==0 )* 1]

    lst=[dlst[0]]
    for i in range(1,k):
        lst.append(lst[i-1]+dlst[i])
        count0.append(count0[i-1]+1*(dlst[i]==0))

    num2=(n-1)//k * lst[-1] +  x
    a=(n-1)%k-1
    if a>=0:
        num2+=lst[a]
    #print(num2,n%k)
    num1=n-1-((n-1)//k)*count0[-1]-(num2//m-x//m)
    if a>=0:
        num1-=count0[a]
    print(num1)


Measured memory_bytes: 119320
#include <bits/stdc++.h>
using namespace std;
    int main(){
        int n;cin>>n;
        vector<int> a(n);
        for(int i=0;i<n;i++){
            cin>>a[i];
        }
        sort(a.begin(),a.end());
        bool ok=true;
        for(int i=0;i<n-1;i++){
            if(a[i]==a[i+1])ok=false;
        }
        if(ok)cout<<"YES"<<endl;
        else cout<<"NO"<<endl;
    }
        






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

#define ll long long int
#define hell 998244353
#define vi vector <ll>
#define pb push_back
#define pii pair<ll,ll>
#define vii vector <pii>
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define sep(i,a,b)  for(ll i=a-1;i>=b;i--)
#define inf (ll)(1e16)

using namespace std;

void solve(){
    ll n,W;
    cin>>n>>W;
    vi v(n),w(n);
    rep(i,0,n)
        cin>>w[i]>>v[i];
    ll ans=0;
    vi c(100005),p(100005);
    rep(i,0,n+1)
    {
        rep(j,0,100005)
        {
            if(i==0&&j==0)
                c[j]=0;
            else if(i==0)
                c[j]=inf;
            else if(j==0)
                c[j]=0;
            else if(v[i-1]>j)
                c[j]=p[j];
            else
                c[j]=min(p[j],w[i-1]+p[j-v[i-1]]);
            if(c[j]<=W)
                ans=max(ans,j);
        }
        p.swap(c);
    }
    cout<<ans;
}

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


Measured memory_bytes: 1792
import java.util.Scanner;
class Main{
  public static void main(String[] args){

  Scanner scan = new Scanner(System.in);

  int a = scan.nextInt();
  int b = scan.nextInt();

  if(a<b) System.out.println("a < b");
  else if(a>b) System.out.println("a > b");
  else System.out.println("a == b");
   }
}

Measured memory_bytes: 17348
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>
using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)
#define eprintf(...) fprintf(stderr, __VA_ARGS__)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}

int N;
int A[300011];

bool ok(LL mid) {
    LL pre = A[0];
    for (int i=1; i<N; i+=2) {
	if (pre >= mid && A[i] >= pre) {
	    pre = A[i+1];
	} else {
	    pre = pre - A[i] + A[i+1];
	}
    }
    return pre >= mid;
}

void MAIN() {
    scanf("%d", &N);
    REP (i, N) scanf("%d", A+i);

    LL ansA = 0, ansB = 0;
    if (N % 2 == 0) {
	REP (i, N) {
	    if (i&1) ansB += A[i];
	    else ansA += A[i];
	}
	if (ansA < ansB) swap(ansA, ansB);
    } else {
	LL lo = 0, hi = 1LL<<40;
	while (hi - lo > 1) {
	    LL mid = (lo + hi) / 2;
	    (ok(mid)? lo: hi) = mid;
	}

	LL sum = 0, alt = 0;
	REP (i, N) {
	    sum += A[i];
	    if (i&1) alt -= A[i];
	    else alt += A[i];
	}
	ansA = (lo*2-alt+sum)/2;
	ansB = sum - ansA;
    }
    printf("%lld %lld\n", ansA, ansB);
}

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}



Measured memory_bytes: 1408
#include<bits/stdc++.h>
#include<numeric>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define repk(i,k,n) for (ll i = k; i <= (ll)(n); ++i)
#define MAX 500000001000000000
#define MOD 1000000007
typedef long long  ll;

using namespace std;

ll ans;

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

	ll N,H;
	cin >> N >> H;

	vector<ll> a(N),b(N);
	ll amax = 0, amaxindex = 0;
	rep(i, N){
		cin >> a[i] >> b[i];
		if(a[i] > amax){
			amax = a[i];
			amaxindex = i;
		}
	}

	sort(b.begin(),b.end(),greater<ll>());
	rep(index,N){
		if(b[index]>=amax){
			H -= b[index];
			ans++;
			if(H <= 0){
				cout << ans << endl;
				return 0;
			}
		}
		else{
			break;
		}
	}

	if(H % amax == 0){
		ans += H / amax;
	}
	else{
		ans += H / amax + 1;
	}

	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 1792
#include<algorithm>
#include<climits>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<list>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<utility>
#include<vector>
 
#define lint long long
#define VI vector<int>
#define VL vector<lint>
#define VC vector<char>
#define VS vector<string>
#define VVI vector<VI>
#define rep(i, n) for(int i = 0 ; i < n ; i++)
#define repr(i, n) for(int i = n - 1 ; i >= 0 ; i--)
#define SORT(c) sort((c).begin(), (c).end())
#define SORT_INV(c) sort((c).begin(), (c).end(), greater<int>())
#define IINF INT_MAX
#define LLINF LLONG_MAX

using namespace std;

int main(){
    list<int> l;
    string s;
    cin >> s;
    rep(i, s.size()){
        if(s[i] == '0'){
            l.push_back(0);
        }else if(s[i] == '1'){
            l.push_back(1);
        }else if(!l.empty()){
            l.pop_back();
        }
    }
    list<int>::iterator itr, e;
    for(itr = l.begin(), e = l.end() ; itr != e ; ++itr){
        cout << *itr;
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
n, w = map(int, input().split())
ws, vs = [], []
for _ in range(n):
    wi, vi = map(int, input().split())
    ws.append(wi)
    vs.append(vi)
sum_v = sum(vs)
dp = [float('inf')] * (sum_v + 1)
dp[0] = 0
for i in range(n):
    for j in range(sum_v - vs[i], -1, -1):
        dp[j + vs[i]] = min(dp[j] + ws[i], dp[j + vs[i]])
ans = 0
for vi, wi in enumerate(dp):
    if wi <= w:
        ans = vi
print(ans)


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

int BubbleSort(int A[], int N) {
	int sw = 0;
	bool flag = 1;
	for (int i = 0; flag; i++) {
		flag = 0;
		for (int j = N - 1; j > 0; j--) {
			if (A[j] < A[j - 1]) {
				swap(A[j], A[j - 1]);
				sw++;
				flag = 1;
			}
		}
	}
	return sw;
}

int main() {
	int A[100], N, sw;
	cin >> N;
	
	for (int i = 0; i < N; i++) {
			cin >> A[i];
		}

	sw = BubbleSort(A, N);

	for (int i = 0; i < N; i++) {
		if (i) {
			cout << " ";
		}
		cout << A[i];
	}
	cout << endl;
	cout << sw << endl;

	return 0;
}

Measured memory_bytes: 3092
#include <iostream>
#include <string>
#include <map>
#include <queue>
using namespace std;

typedef pair<string, int> P;

int bfs(string worm){
	queue<P> que;
	que.push(P(worm, 0));

	map<string, int> d;
	
	while(!que.empty()){
		P p = que.front();
		que.pop();

		//d¡p^[Ícontinue
		if(d[p.first]) continue;

		string str = p.first;

		//SF¯¶©Ç¤©Ì`FbN
		bool flag = false;
		for(int i=0;i<str.size()-1;i++){
			if(str[i] != str[i+1]){
				flag = true;
				break;
			}
		}
		//¯¶Èçreturn
		if(!flag) return p.second;

		//d¡p^[»Êp
		d[p.first] = p.second;

		for(int i=0;i<str.size()-1;i++){
			//×èí¹ÅFªÙÈéÆ«
			if(str[i] != str[i+1]){
				char temp;
				string next;

				//tempÉÜÜêÈ¢êFðãü
				if(str[i] != 'b' && str[i+1] != 'b'){
					temp = 'b';
				}else if(str[i] != 'g' && str[i+1] != 'g'){
					temp = 'g';
				}else{
					temp = 'r';
				}

				//Ï»ãÌÔðnextÉlßÞ
				next = str;
				next[i] = next[i+1] = temp;

				//L[ÉvbV
				que.push(P(next, p.second+1));
			}
		}
	}
	return -1;
}

int main(){
	string worm;
	while(cin >> worm && worm != "0"){
		int ret = bfs(worm);
		if(ret>=0) cout << ret << endl;
		else cout << "NA" << endl;
	}
}

Measured memory_bytes: 0
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

int main() {
    int N;
    cin >> N;
    vector<int> a, b;

    for(int i = 0; i < N; i++) {
        int x;
        cin >> x;
        if(i % 2 == 0) {
            a.push_back(x);
        } else {
            b.push_back(x);
        }
    }

    sort(a.begin(), a.end());
    sort(b.begin(), b.end());

    N = a.size();
    int M = b.size();

    vector<int> aa, bb;
    for(int bit = 0; bit < (1 << N); bit++) {
        int sum = 0;
        for(int i = 0; i < N; i++) {
            if(bit & (1 << i)) sum += a[i];
        }
        aa.push_back(sum);
    }

    for(int bit = 0; bit < (1 << M); bit++) {
        int sum = 0;
        for(int i = 0; i < M; i++) {
            if(bit & (1 << i)) sum += b[i];
        }
        bb.push_back(sum);
    }

    sort(aa.begin(), aa.end());
    sort(bb.begin(), bb.end());

    int Q;
    cin >> Q;
    for(int q = 0; q < Q; q++) {
        int m;
        cin >> m;

        bool can_make = false;
        for(int i = 0; i < (1 << N); i++) {
            if(binary_search(bb.begin(), bb.end(), m - aa[i])) {
                can_make = true;
                break;
            }
        }

        if(can_make) {
            cout << "yes" << endl;
        } else {
            cout << "no" << endl;
        }
    }

    return 0;


}



Measured memory_bytes: 3144
#include <bits/stdc++.h>
#include <cassert>
typedef long long int ll;
using namespace std;

int solve() {
  int X; cin >> X;
  if (X >= 2000) return 1;
  int p = X / 100;
  int q = X % 100;
  if (q <= p * 5) return 1;
  else return 0;
}

int main(int argc, char *argv[]) {
  // C-style stdio functions should not be used.
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  cout << solve() << endl;

  return 0;
}



Measured memory_bytes: 256
while True:
    n = int(input())
    if n == 0:
        break

    data = [0 for i in range(10)]
    for i in range(n):
        data[int(input())] += 1

    for i in range(10):
        if data[i] == 0:
            print("-")
        else:
            print("*" * data[i])


Measured memory_bytes: 5628
# -*- coding: utf-8 -*-
"""
http://abc063.contest.atcoder.jp/tasks/abc063_b

"""
import sys
from sys import stdin
input = stdin.readline


def main(args):
    ans = 'yes'
    S = input().strip('\n')

    alphabet = dict()
    for c in S:
        if c in alphabet:
            ans = 'no'
            break
        else:
            alphabet[c] = 1

    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])

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

const int MOD = 1000000007;
const int64_t INF = 1LL << 60;

int findSumOfDigits(int n)
{
    int sum = 0;
    while (n > 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}

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

    int f = findSumOfDigits(N);
    if (N % f == 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
   
#define x first
#define y second
#define pii pair<int,int>
#define sz(x) (int)(x).size()
#define Max(x,y) (x)>(y)?(x):(y)
#define Min(x,y) (x)<(y)?(x):(y)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long LL;
int main(){
    int n,m,v,p;
    cin >> n >> m >> v >> p;
    vector<int> ve;
    for(int i = 1,val;i <= n; ++i){
        cin >> val; 
        ve.push_back(val);
    }
    sort(all(ve),greater<int>());
    int ans = p;
    LL sum = 0,num = 0,pos = p-1;
    for(int i = p;i < n; ++i){
        while(ve[pos] != ve[i]){
            sum += ve[pos];
            pos++; num++;
        }
        if(ve[i]+m >= ve[p-1]){
            if(n - num >= v) ans++;
            else if(1ll*num*(ve[i]+m)-sum >= 1ll*m*(v-(n-num))) ans++;
        }
        else break;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1020
<?php
fscanf(STDIN, "%d", $n);
$a = explode(" ",fgets(STDIN));
$b = explode(" ",fgets(STDIN));
$c = explode(" ",fgets(STDIN));

$a = array_map("intval", $a);
$b = array_map("intval", $b);
$c = array_map("intval", $c);

$bs = array_sum($b);
$cs = 0;
$s = 0;

for ($i=0; $i<$n-1; $i++) {
    if($a[$i]+1 === $a[$i+1]) {
        $cs += $c[$a[$i]-1];
    }
}

$s = $bs + $cs;
echo $s;

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

int main()
{
    char mun[55][55], num[55][55];
    int i = 0, j = 0, m = 0, n = 0, x = 0, k = 0, z = -1, s = 0, p = -1, o = 0, d = 0;
    cin >> m >> n;
    for(i = 0; i < m; i++)
    {
        for(j = 0; j < m; j++)
        {
            cin >> mun[i][j];
        }
    }
     for(i = 0; i < n; i++)
    {
        for(j = 0; j < n; j++)
        {
            cin >> num[i][j];
        }
    }
    for(i = 0; i < m - n + 1; i++)
    {
        z++;
        for(s = 0; s < m - n + 1; s++)
        {
            p++;
        for(j = z; j < m; j++)
        {
            d++;
            for(k = p; k < m; k++)
            {
                o++;
                if(num[j - z][k - p] == mun[j][k])
                {
                    x++;

                }
                if(x == n * n)
                {
                    cout << "Yes";
                    break;
                }
                if(o == n)
                {
                    o = 0;
                    break;
                }
            }
            if(x == n * n)
                {

                    break;
                }
             if(d == n)
                {
                    d = 0;
                    break;
                }
        }
        if(x == n * n)
                {

                    break;
                }
         x = 0;
        }
        if(x == n * n)
                {

                    break;
                }
        p = -1;
    }
if(x != n * n)
{
    cout << "No";
}


return 0;
}

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

using namespace std;

#define DB( x ) cout << #x << " = " << x << endl;
#define LEFT(n) (2 * (n))
#define RIGHT(n) (2 * (n) + 1)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> node;
//typedef vector <vector <ll>> matrix;

const ll INF = 1e9;
const double EPS = 1e-9;
const ll MOD = (ll)(1000000007);
const ll MAXV = (ll)(2e5 + 10);
const ll MAXE = (ll)(1e6 + 10);

ll x, y;

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

	cin >> x >> y;

	for(ll i = max(-10000000LL, y - x + 1LL);i <= min(1000000LL, y + x - 1LL);i ++)
		cout << i << " ";
	cout << "\n";

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using  namespace std;
typedef long long ll;
#define RAP(i, n) for(ll i=0;i<(n);i++)
#define FOR(i, a, b) for(ll i=(a);i<(b);i++)

ll calcNumOfCombination(ll n, ll r){
        ll num = 1;
        for(ll i = 1; i <= r; i++){
            num = num * (n - i + 1) / i;
        }
        return num;
    }
    
int main(){
  ll n, sum = 0, ans;
  map<ll ,ll> mp;
  cin >> n;
  vector<ll> num(n);
  RAP(i, n){
    cin >> num[i];
    mp[num[i]]++;
  }
  for(auto x : mp){
    if(x.second >= 2){
      sum += calcNumOfCombination(x.second, 2);
    }
  }
  RAP(i, n){
    ans = sum;
    if(mp[num[i]] >= 2){
      ans -= calcNumOfCombination(mp[num[i]], 2);
      if((mp[num[i]]-1) >= 2){
        ans += calcNumOfCombination(mp[num[i]]-1, 2);
      }
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 11008
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cassert>
#include <cctype>
#include <algorithm>
using namespace std;
typedef long long lint;
#define cout cerr
#define ni (next_num<int>())
template<class T>inline T next_num(){
	T i=0;char c;
	while(!isdigit(c=getchar())&&c!='-');
	bool flag=c=='-';
	flag?(c=getchar()):0;
	while(i=i*10-'0'+c,isdigit(c=getchar()));
	return flag?-i:i;
}
const int N=100010;
int a[N];
inline bool Main(){
	int n=ni;
	for(int i=1;i<=n;i++){
		a[i]=ni;
	}
	sort(a+1,a+n+1);
	bool win=true;
	a[0]=1;
	for(int i=1,j=0,k=0;i<=n;i++){
		if(k>=a[j]-1){
			j++;
			win=!win||((a[j]-a[j-1])&1);
		}else{
			win=((a[j]-++k)&1)==0;
		}
	}
	return win;
}
int main(){
	puts(Main()?"First":"Second");
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//name[i][j]-> vvl name(i,vl(j))
//map<int,int>mp
//余りを切り上げる =>  (a + b - 1) / b 

signed main(){
	int n; cin>>n;
	vi a(n+2),b(n+2);
	a[0]=0; a[n+1]=0; 
	b[0]=0; a[n+1]=0;
	rep(i,1,n+1){
		cin>>a[i];
		a[i]+=a[i-1];
	}
	rep(i,1,n+1){
		cin>>b[i];
	}
	for(int i=n;i>=1;i--){
		b[i]+=b[i+1];
	}
	int m;
	int ans=0;
	rep(i,1,n+1){
		if(ans<a[i]+b[i]){
			ans=a[i]+b[i];
			m=i;
		}
	}
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 3632
#include<iostream>
using namespace std;
int main() {
	char board[50][50];
	int h, w;
	const int dx[] = { 1,0,-1,0,1,1,-1,-1 };
	const int dy[] = { 0,1,0,-1,-1,1,1,-1 };
	cin >> h >> w;
	for (int i = 0; i < h; i++) {
		for (int k = 0; k < w; k++) {
			cin >> board[i][k];
		}
	}
	for (int i = 0; i < h; i++) {
		for (int k = 0; k < w; k++) {
			int num = 0;
			if (board[i][k] == '#')continue;
			

			for (int q = 0; q < 8; q++) {
				const int ni = i + dy[q];
				const int nk = k + dx[q];
				if (ni<0 || ni>h-1)continue;
				if (nk<0 || nk>w-1)continue;
				if (board[ni][nk] == '#')num++;
			}
			board[i][k] = char('0'+num);
		}
	}
	for (int i = 0; i < h; i++) {
		for (int k = 0; k < w; k++) {
			cout << board[i][k];
		}
		cout << endl;
	}
	return 0;
}

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

using namespace std;

int n;
int a[200001];
int cur = 1;

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

	cin >> n;
	for (int i=1;i<=n;i++)
	{
		cin >> a[i];
		if (a[i] == cur)
			cur++;
	}
	if (cur == 1)
	{
		cout << -1;
		return 0;
	}
	cout << n - (cur - 1);
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define int ll
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define Rep(i,a,b) for(register int i=(a);i<=int(b);++i)
#define Dep(i,a,b) for(register int i=(a);i>=int(b);--i)
#define rep(i,a,b) for(register int i=(a);i<int(b);++i)
#define mem(x,v) memset(x,v,sizeof(x))
#define gc getchar
#define pc putchar
inline ll rd(){
    ll x=0,f=1;char c=gc();
    for(;!isdigit(c);c=gc())if(c=='-')f=-1;
    for(;isdigit(c);c=gc())x=(x<<1)+(x<<3)+(c^48);
    return x*f;
}
void write(ll x){if(x<0)x=-x,pc('-');if(x>=10)write(x/10);putchar(x%10+'0');}
void writeln(ll x){write(x);puts("");}
#define N 500005
using namespace std;
int n,m,top,b[N],f[N],ans[N];
signed main(){
	n = rd(),m = rd();
	b[++top]=n;
	for (int i=1;i<=m;i++){
		b[++top] = rd();
		while (top>1&&b[top]<=b[top-1]) b[top-1]=b[top],top--;
	}
	f[top]=1;
    for (int i=top-1;~i;i--){
    	int len=b[i+1];
    	while (len>b[1]){
    		int pos=upper_bound(b+1,b+i+1,len)-b-1;
    		f[pos]+=len/b[pos]*f[i+1];
    		len%=b[pos];
    	}
    	ans[len]+=f[i+1];
    }
    for (int i=b[1];i;i--) ans[i]+=ans[i+1];
    for (int i=1;i<=n;i++) writeln(ans[i]);
	return 0;
}



Measured memory_bytes: 10624
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

#include <limits.h>

using namespace std;

typedef long long ll;

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

// ref. YouTube ABC 152 E
class EratosthenesSieve {
    public:
        const int N;

        EratosthenesSieve(const int N): N(N) {
            numbers.resize(N + 1, 0);
            init();
        }

        // assume that n > 0 && n <= N
        map<int, int> factors(int n) {
            // assert(n > 0 && n <= N); 
            map<int, int> res;
            while (n > 1) {
                res[numbers[n]]++;
                n /= numbers[n];
            }
            return res;
        }

        void primes(vector<int> &p) {
            for (int i = 2; i <= N; i++) {
                if (is_prime(i)) {
                    p.push_back(i);
                }
            }
        }

        // assume that n > 0 && n <= N
        bool is_prime(const int n) {
            // assert(n > 0 && n <= N);
            return numbers[n] == n;
        }

    private:
        vector<int> numbers; // numbers[i] means minimum prime factor for i (e.g. numbers[12] = 2)

        void init() {
            // O(N * log(logN)) ???
            int i = 2;
            for (; i * i <= N; i++) {
                if (numbers[i] == 0) {
                    numbers[i] = i;
                    for (int j = i * i; j <= N; j += i) {
                        if (numbers[j] == 0) {
                            numbers[j] = i;
                        }
                    }
                }
            }
            for (; i <= N; i++) {
                if (numbers[i] == 0) {
                    numbers[i] = i;
                }
            }
        }
};

const int MAX_N = 10 * 1000 * 1000 + 1;

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

    EratosthenesSieve *sieve = new EratosthenesSieve(MAX_N);

    ll ans = 1;
    for (int i = 2; i <= N; i++) {
        map<int, int> fs = sieve->factors(i);
        ll acc = i;
        for (auto &p : fs) {
            acc *= p.second + 1;
        }
        // printf("i: %d, acc: %lld\n", i, acc);
        ans += acc;
    }

    cout << ans << endl;

    delete sieve;
    return 0;
}


Measured memory_bytes: 42324
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define E "\n"

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

int vis[1009][1009];
bool vis2[1009][1009];
int n, m, sx, sy, dx, dy;
string s[1009];
vector<pair<int, int> > dat;
set < pair<int, int> > tmp;
bool flag;

void dfs(int x, int y, int v)
{
	vis[x][y] = v;
	if (x == dx && y == dy) flag = true;
	for (int i = x - 1; i <= x + 1; i++) {
		for (int j = y - 1; j <= y + 1; j++) {
			if (i < 0 || i >= n) continue;
			if (j < 0 || j >= m) continue;
			if (i != x && j != y) continue;
			if (i == x && j == y) continue;
			if (s[i][j] == '#') continue;
			if (vis[i][j] >= 0) continue;
			dfs(i, j, v);
		}
	}
}

void gun(int x, int y)
{
	for (int i = x - 2; i <= x + 2; i++) {
		for (int j = y - 2; j <= y + 2; j++) {
			if (i < 0 || i >= n) continue;
			if (j < 0 || j >= m) continue;
			//if (i != x && j != y) continue;
			if (i == x && j == y) continue;
			if (s[i][j] == '#') continue;
			if (vis[i][j] != -1) continue;
			tmp.insert({ i, j });
		}
	}
}

void fun(int x, int y, int v)
{
	gun(x, y);
	vis2[x][y] = true;
	for (int i = x - 1; i <= x + 1; i++) {
		for (int j = y - 1; j <= y + 1; j++) {
			if (i < 0 || i >= n) continue;
			if (j < 0 || j >= m) continue;
			if (i != x && j != y) continue;
			if (i == x && j == y) continue;
			if (s[i][j] == '#') continue;
			if (vis[i][j] != v) continue;
			if (vis2[i][j]) continue;
			fun(i, j, v);
		}
	}
}

int main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n >> m;
	cin >> sx >> sy; sx--; sy--;
	cin >> dx >> dy; dx--; dy--;
	for (int i = 0; i < n; i++) {
		cin >> s[i];
	}
	memset(vis, 0xff, sizeof(vis));
	dat.pb({ sx, sy });
	//vis[sx][sy] = 0;
	flag = false;
	int cur = 0;
	while (!flag) {
		if (dat.size() == 0) break;
		for (int i = 0; i < (int)dat.size(); i++)
			dfs(dat[i].fi, dat[i].se, cur);
		tmp.clear();
		for (int i = 0; i < (int)dat.size(); i++)
			fun(dat[i].fi, dat[i].se, cur);
		dat.clear();
		//dat.resize(tmp.size());
		for (auto p : tmp) {
			dat.pb(p);
		}
		cur++;
	}
	if (flag) cout << vis[dx][dy] << E;
	else cout << -1 << E;
	//system("pause");
	return 0;
}

Measured memory_bytes: 9848
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
/* clang-format off */
#define INF (INT_MAX / 4)
#define REP(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(a) (a).begin(), (a).end()
// #define __DEBUG__
#ifdef __DEBUG__
#define CH_P(a) cout <<"check_point("<<#a<<")" << "\n";
#define DEBUG(x) cout<<#x<<":"<<x<<"\n"
#define DEBUGS(v) cout << #v << ":";for(auto x:v){cout<<x<<" ";}cout<<"\n"
#endif
#ifndef __DEBUG__
#define CH_P(a) 
#define DEBUG(x) 
#define DEBUGS(v) 
#endif
#define TIMER_S(start) chrono::system_clock::time_point start = chrono::system_clock::now();
#define TIMER_E(end) chrono::system_clock::time_point end = chrono::system_clock::now();
#define TIME(start, end) cout << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count()) << "ms" << "\n";
/* clang-format on */

int main() {
  int a, b;
  cin >> a >> b;
  cout << a*b << "\n";
  return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>

using namespace std;
typedef long long ll;
const ll MOD = 1000000007;

template <typename T>
T gcd(T a, T b){
    if(a < b) swap(a, b);
    while(b != 0){
        T tmp = b;
        b = a%b;
        a = tmp;
    }
    return a;
}

template <typename T>
T lcm(T a, T b){
    return (a*b)/gcd<T>(a, b);
}

template <typename T>
T pow(T a, ll n){
    T ans = 1;
    T tmp = a;
    for(int i = 0; i <= 60; i++){
        ll m = (ll)1 << i;
        if(m&n){
            ans *= tmp;
            ans %= MOD;
        }
        tmp *= tmp;
        tmp %= MOD;
    }
    return ans;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    ll H, W, T;
    cin >> H >> W >> T;
    ll h, w;
    h = lcm<ll>(H, T)/T;
    w = lcm<ll>(W, T)/T;
    ll ans = 0;
    if(gcd<ll>(h, w) != 1) {
        ll p = h*w/lcm<ll>(h, w);
        ans += (pow<ll>(2, p)-2);
        ans %= MOD;
        // ans += (pow<ll>(2, p)-2);
        // ans %= MOD;
    }
    ans += pow<ll>(2, h);
    ans %= MOD;
    ans += pow<ll>(2, w);
    ans--;
    ans %= MOD;
    ans = pow<ll>(ans, H*W/(h*w));
    cout << ans << endl;
}

Measured memory_bytes: 256