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

#define LL long long
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(x) (x).begin(),(x).end()
const int IINF = 1e9;
const LL LINF = 1e18;
const LL mod = 1e9+7;

int main() {
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    cout << min(A, B) + min(C, D) << endl;
    return 0;
}



Measured memory_bytes: 256
n = int(input())
s = list(input())
 
str = "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ"
alist = list(str)
#print(s)
m=0
ans = ""
for i in s:
  ans += alist[alist.index(i) + n]
print(ans)

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

using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> Vi;
//typedef tuple<int, int, int> T;
#define FOR(i,s,x) for(int i=s;i<(int)(x);i++)
#define REP(i,x) FOR(i,0,x)
#define ALL(c) c.begin(), c.end()
#define DUMP( x ) cerr << #x << " = " << ( x ) << endl
#define UNIQUE(c) sort(ALL(c)), c.erase(unique(ALL(c)), c.end())

const int dr[4] = {-1, 0, 1, 0};
const int dc[4] = {0, 1, 0, -1};

template <typename T>
T powmod(T n, T k, T mod) {
  if (k == 0) {
    return 1;
  } else if (k % 2 == 0) {
    return powmod(n * n % mod, k / 2, mod);
  } else {
    return n * powmod(n, k-1, mod) % mod;
  }
}

template <typename T>
T inv(T x, T mod) {
  return powmod(x, mod-2, mod);
}

int main() {
  int N; ll A, B, K; cin >> N >> A >> B >> K;
  const ll mod = 998244353;
  vector<ll> fact(N + 1), rev_fact(N + 1);
  fact[0] = fact[1] = 1;
  rev_fact[0] = rev_fact[1] = inv(1LL, mod);
  FOR(i, 2, N + 1) {
    fact[i] = (fact[i - 1] * (ll)i) % mod;
    rev_fact[i] = inv(fact[i], mod);
  }
  ll ans = 0;
  for (ll i = 0; i <= N and i * A <= K; ++i) {
    if ((K - A * i) % B == 0 and (K - A * i) / B <= N) {
      int x = i, y = (K - A * i) / B;
      ans += fact[N] * rev_fact[x] % mod * rev_fact[N - x] % mod * fact[N] % mod * rev_fact[y] % mod * rev_fact[N - y] % mod;
      ans %= mod;
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;

/* short */
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)

/* REPmacro */
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define FORR(i, a, b) for(int i = (a); i >= (b); i--)
#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOREACH(x, a) for(auto x : a)

/* exchange */
#define CHMIN(a, b) (a) = min((ll)(a), (ll)(b))
#define CHMAX(a, b) (a) = max((ll)(a), (ll)(b))

/* function */
#define IN(x) cin >> x
#define DEBUG(x) cerr << (x) << " "
#define LN() cerr << "\n"
#define PRINT(x) cout << (x) << endl
#define BR cout << endl

/* const */
const int ARRAY = 100005;
const int INF = 1001001001; // 10^9
const ll LINF = 1001001001001001001; // 10^18
const int MOD = 1e9 + 7;

ll N = 0;
ll M = 0;
ll t;
ll ret = 0;
string s;
ll AC[ARRAY];
ll WA[ARRAY];
ll ac = 0;
ll wa = 0;

void input() {
  IN(N);
  IN(M);
  REP(i, ARRAY) {
    AC[i] = -1;
    WA[i] = 0;
  }
  REP(i, M) {
    IN(t);
    IN(s);
    if (s == "AC") {
      if (AC[t] == -1) {
        AC[t] = 1;
        ac += 1;
        wa += WA[t];
      }
    } else if (s == "WA") {
      if (AC[t] == -1) {
        WA[t] += 1;
      }
    }
  }
}

void solve() {
  cout << ac << " " << wa << endl;
}

int main(void){
  input();
  solve();
}


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

int N, M;
const int MAX = 100000;
vector<int> edges[MAX];
int color[MAX];

bool check_bipart(int i, int prev, int c){
    color[i] = c;
    bool ret = true;
    for(auto j : edges[i]){
        if(j == prev) continue;
        if(color[j] == 0){
            ret &= check_bipart(j, i, -c);
        }else{
            ret &= (c != color[j]);
        }
    }
    return ret;
}

int main(){
    int i, j, k;
    cin >> N >> M;
    for(i=0; i<M; i++){
        int a, b;
        scanf("%d %d", &a, &b);
        edges[a-1].push_back(b-1);
        edges[b-1].push_back(a-1);
    }

    long long I=0, P=0, Q=0;
    for(i=0; i<N; i++){
        if(color[i] != 0) continue;
        if(edges[i].size()==0){
            I++;
        }else if(check_bipart(i, -1, 1)){
            Q++;
        }else{
            P++;
        }
    }
    long long ans = I*I + 2*I*(N-I) + P*P + 2*P*Q + 2*Q*Q;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 11776
import numpy as np
import itertools
H, W, K = [int(_) for _ in input().split()]
S = np.zeros((H + 1, W + 1), dtype=int)
S[1:, 1:] = [[int(_) for _ in input()] for _ in range(H)]
cum = S.cumsum(axis=0).cumsum(axis=1)
# print(cum)

ans = 10**10
for bs in itertools.product([True, False], repeat=H - 1):
    bs = [True] + list(bs) + [True]
#     print(bs)
    idxs = []
    for i, b in enumerate(bs):
        if b:
            idxs += [i]
    cum2 = np.array([cum[i2] - cum[i1] for i1, i2 in zip(idxs, idxs[1:])])
    i = 0
    cnt = sum(bs) - 3
    while i < W:
        di = min(
            np.searchsorted(c[i + 1:] - c[i], K, side='right') for c in cum2)
        if di == 0:
            cnt = 10**10
            break
        i += di
        cnt += 1
    ans = min(ans, cnt)
print(ans)

Measured memory_bytes: 27668
#include <iostream>
#include <vector>

using namespace std;

int value(int n)
{
	if (n < 0) n = n * -1;
	return n;
}

int main() 
{
	int n, m, near,num;
	cin >> n >> m;
	vector<int> a, b, c, d;
	a.resize(n); b.resize(n); c.resize(m); d.resize(m);
	for (int i = 0;i < n;i++)cin >> a[i] >> b[i];
	for (int i = 0;i < m;i++)cin >> c[i] >> d[i];

	for (int i = 0;i < n;i++)
	{
		near = value(a[i] - c[0]) + value(b[i] - d[0]);
		num = 0;
		
		for (int j = 1;j < m;j++)
		{
			if (value(a[i] - c[j]) + value(b[i] - d[j]) < near)
			{
				near = value(a[i] - c[j]) + value(b[i] - d[j]);
				num = j;
			}
		}
		cout << num+1 << endl;
	}
	
	return 0;
}


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

long long GCD(long long former, long long latter){
    if(former%latter==0)return latter;
    if(latter%former==0)return former;
    return GCD(latter, former%latter);
}

int main(void){

    int N, M, abuf;
    vector<int> ahalf;

    cin >> N >> M;
    for(int i=0; i<N; i++){
        cin >> abuf;
        ahalf.push_back(abuf/2);
    }

    int halfcount = 0;
    int halfcountbuf = 0;
    for(int i=0; i<N; i++){
        abuf = ahalf[i];
        halfcount = 0;
        while(abuf%2==0){
            abuf /= 2;
            halfcount++;
        }
        if(i==0)halfcountbuf=halfcount;
        if(halfcount!=halfcountbuf){
            cout << 0 << endl;
            return 0;
        }
    }

    long long LCM = ahalf[0];
    for(int i=1; i<N; i++){
        LCM = LCM / GCD(LCM, ahalf[i]) * ahalf[i];
        if(LCM>M){
            cout << 0 << endl;
            return 0;
        }
    }

    cout << (M+LCM)/(2*LCM) << endl;

    return 0;
}

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

using ll = long long;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vector<vector<int>> g(N, vector<int>(N, 0));
  for (int i = 0; i < N; ++i) {
    int A;
    cin >> A;
    for (int j = 0; j < A; ++j) {
      int x, y;
      cin >> x >> y;
      --x;
      ++y;
      g[i][x] = y;
    }
  }
  auto count = [](unsigned int x) { 
    int res = 0;
    for (int i = 0; i < 32; ++i) if (((x >> i) & 1) == 1) ++res;
    return res;
  };
  int ans = 0;
  for (int i = 0; i < (1 << N); ++i) {
    int honest = count(i);
    if (honest <= ans) continue;
    bool ok = true;
    vector<int> state(N, 0);
    for (int j = 0; j < N; ++j) {
      if (((i >> j) & 1) == 0) continue;
      for (int k = 0; k < N; ++k) {
        if (g[j][k] == 0) continue;
        else if (g[j][k] == 1) {
          if (state[k] == 2 || (i >> k & 1) == 1) {
            ok = false;
            break;
          }
        } else {
          if (state[k] == 1 || (i >> k & 1) == 0) {
            ok = false;
            break;
          }
        }
      }
    }
    if (ok) ans = max(ans, honest);
  }
  cout << ans << endl;
}

Measured memory_bytes: 384
#include <float.h>
#include <inttypes.h>
#include <limits.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <math.h>
#ifdef __cplusplus
#endif

//#define P 1000000007

int comp(const void *a, const void *b){return (*(int*)a>*(int*)b)-(*(int*)a<*(int*)b);}
int compr(const void *a, const void *b){return (*(int*)a<*(int*)b)-(*(int*)a>*(int*)b);}

uint32_t nextpint(void){ char c=getchar(); while(c<'0'||'9'<c) c=getchar(); uint32_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar(); } return x; }
uint64_t nextplong(void){ char c=getchar(); while(c<'0'||'9'<c) c=getchar(); uint64_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar(); } return x; }
uint32_t nextstr(char *s){ char c=getchar(); while(c==' '||c=='\n') c=getchar(); uint32_t len=0; while(c!=' '&&c!='\n'){ *s++=c; len++; c=getchar(); } *s='\0'; return len; }

inline int max2(const int a, const int b){return a>b?a:b;}
inline int min2(const int a, const int b){return a>b?b:a;}
inline int dif2(const int a, const int b){return a>b?a-b:b-a;}
inline int abs2(const int a){return a>=0?a:-a;}

int main(void){
	int m=nextpint();
	int n=1<<m;
	int k=nextpint();
	if(k>=n){
		puts("-1");
	}else if(m==0){
		puts("0 0");
	}else if(m==1){
		puts(k==0?"0 0 1 1":"-1");
	}else{
		for(int i=0; i<n; i++){
			if(i!=k){
				printf("%d ", i);
			}
		}
		printf("%d ", k);
		for(int i=n-1; i>=0; i--){
			if(i!=k){
				printf("%d ", i);
			}
		}
		printf("%d\n", k);
	}
}


Measured memory_bytes: 1792
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
const long long Maxn=200000+20;
long long n,m,ans;
long long a[Maxn];
int main()
{
//	freopen("in.txt","r",stdin);
	scanf("%lld%lld",&n,&m);
	for(long long i=1;i<=n;++i)
	scanf("%lld",a+i);
	sort(a+1,a+1+n);
	for(long long i=1;i<=n-m;++i)
	ans+=a[i];
	printf("%lld\n",ans);
	
	return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>

int main(){

int i , j, k;
int n, b, f, r, v, count[5][4][11];

    //count?????????
    for ( i = 1; i <= 4; i++) {
      for ( j = 1; j <= 3; j++) {
        for ( k = 1; k <= 10; k++) {

          count[i][j][k] = 0;

        }
      }
    }



  scanf("%d", &n);


    
//?£???????d, ?????????f, ??¨?±???????r, ??\???????????°v
  for ( i = 0; i < n; i++) {

    scanf("%d %d %d %d", &b, &f, &r, &v);

    count[b][f][r] += v;

  }

    

//??????
  for ( i = 1; i <= 4; i++) {
    for ( j = 1; j <= 3; j++) {
      for ( k = 1; k <= 10; k++) {

        printf(" %d", count[i][j][k]);

      }

      printf("\n");

    }
      if( i != 4){
            
          printf("####################\n");

      }
  }

  return 0;
}

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

//短縮
#define rep(i,n) for(int i=0;i<(n);++i)
//sort()用
#define all(v) v.begin(), v.end()

#define PB(N) push_back(N)

using namespace std;

using Graph = vector<vector<int>>;

int main(){
  int N,R;cin >> N >> R;
  int d;cin >> d;
  int count=0;
  for(int i=N;i<=R;i++){
    if(i%d==0){
      count++;
    }
  }
  cout << count;
  return 0;
}


Measured memory_bytes: 3620
n = int(input())
x, y = 1,1

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors

s = make_divisors(n)
l  = []
res = 10e+12
for i in range(len(s)):
    a = s[i] - x+  n // s[i] - y 
    if res > a:
        res = a
print(res)        

Measured memory_bytes: 3272
# -*- coding: utf-8 -*-
N = int(input())
An = list(map(int, input().split()))
Bn = list(map(int, input().split()))

if sum(An) < sum(Bn):
    print(-1)
    exit()

fusoku = [b-a for a,b in zip(An,Bn) if a < b ]
yojo = [a-b for a, b in zip(An, Bn) if a > b]
yojo.sort(reverse=True)
sum_fusoku = sum(fusoku)
ans = len(fusoku)
sum_score = 0
for y in yojo:
    if sum_score >= sum_fusoku:
        break
    ans += 1
    sum_score += y

# print(sum_score)
print(ans)


Measured memory_bytes: 18356
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c,d,e;
    cin>>a>>b>>c;
	d=min(min(a,b),c);
	if(d==a)  e=min(b,c);
	if(d==b)  e=min(a,c);
	if(d==c)  e=min(a,b);
	cout<<d+e;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cfloat>
#include <complex>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <list>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define rep(i,n) for(int i = 0;i < n; i++)
#define REP(i,n) for(int i = 1;i <= n; i++)
// ----GCC ONLY---- //
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
// ----        ---- //
#define ll long long
#define MOD 10000007
#define PB push_back
 
using namespace std;

int main(){

    int a,b;
    cin >> a >> b;

    int plus = a + b;
    int minus = a - b;
    int kakeru = a * b;


    int ans = max(max(minus,kakeru),plus);

    cout << ans <<endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int a , b;

    do {
        scanf("%d %d" , &a ,&b);
    } while (a < -1000 || a > 1000 || b < -1000 || b > 1000);

   if ( a < b) 
        printf("a < b\n");

    else if ( a > b)
        printf("a > b\n");

    else
        printf("a == b\n");

    return 0;

}


Measured memory_bytes: 2080
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	int a[n];
	int i,j,minv=9999999;
	int suma=0,sumb=0;
	for(int i=0;i<n;i++)cin>>a[i];
	//for(int i=0;i<n;i++)cout<<a[i]<<' ';
	for(int i=1;i<n;i++){
		//cout<<i<<endl;
		suma=0;
		sumb=0;
		for(int j=0;j<i;j++)suma+=a[j];
		for(int j=i;j<n;j++)sumb+=a[j];
		//cout<<suma<<' '<<sumb<<endl;
		minv=min(minv,abs(suma-sumb));
	}
	cout<<minv;
}

Measured memory_bytes: 256
n,m=map(int,input().split())
h=list(map(int,input().split()))
li=[]
for i in range(m):
    a,b=map(int,input().split())
    if h[a-1]<h[b-1]:
        li.append(a)
    elif h[a-1]==h[b-1]:
        li.append(a)
        li.append(b)
    else:
        li.append(b)
print(n-len(set(li)))
    

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP1(i,n) for(int i=1, i##_len=(n); i<i##_len; ++i)
#define ll long long
static const int MAX = 10000;
static const ll INFTY = 1e12;

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

const ll MRINF = 5000000000000000;

int main() {

  ll N;
  cin >> N;
  vector<ll> A(N);
  REP(i, N)cin >> A[i];
  sort(A.begin(), A.end());
  cout << A[N-1]-A[0] << endl;


  
}
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         pass System Test!
*/

Measured memory_bytes: 3624
#include <iostream>
#include <vector> 
using namespace std; //cin, coutを使う
int main()
{
    int N;
    cin >> N;

    if(N >= 10){
        if(N % 10 == 2 || N % 10 == 4 || N % 10 == 5 || N % 10 == 7 || N % 10 == 9){
            cout << "hon" << endl;
            return 0;
        }
        if(N % 10 == 0|| N % 10 == 1|| N % 10 == 6 || N % 10 == 8){
            cout << "pon" << endl;
            return 0;
        }
        if(N % 10 == 3){
            cout << "bon" << endl;
            return 0;
        }
    }else{
        if(N == 2 || N == 4 || N == 5 || N == 7 || N == 9){
            cout << "hon" << endl;
            return 0;            
        }
        if(N == 0 || N == 1 || N == 6 || N == 8){
            cout << "pon" << endl;
            return 0;
        }
        if(N == 3){
            cout << "bon" << endl;
            return 0;            
        }
    }
}

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

#define pb push_back
#define eb emplace_back
#define rep(i, a, b) for (long i = (a); i <= (b); ++i)
#define per(i, a, b) for (long i = (a); i >= (b); --i)
#define mmst(v) memset(v, 0, sizeof(v))

const long kMax2 = 109;
const long kMax3 = 1009;
const long kMax4 = 10009;
const long kMax5 = 100009;
const long kMax6 = 1000009;
const long kInfI = 0x3F3F3F3F;
const float kInfF = 1e15;

using namespace std;
using ll = long long;

void solve() {
}

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

  int n, idx_mx, idx_mx_ed = 0, ans = 0;
  int a[2 * kMax5], b[2 * kMax5];
  cin >> n;
  rep(i, 1, n) {
    cin >> a[i];
  }
  per(i, n, n / 2 + 1) {
    b[i] = a[i];
    if (b[i]) {
      ++ans;
    }
    if (!idx_mx_ed && b[i]) {
      idx_mx = i;
      idx_mx_ed = 1;
    }
  }
  per(i, n / 2, 1) {
    int cnt = 0;
    int c = 2 * i;
    while (c <= n) {
      cnt += b[c];
      c += i;
    }
    if (cnt % 2 == 1) {
      b[i] = 1 - a[i];
    } else {
      b[i] = a[i];
    }
    if (b[i]) {
      ++ans;
    }
    if (!idx_mx_ed && b[i]) {
      idx_mx = i;
      idx_mx_ed = 1;
    }
  }
  cout << ans << "\n";
  rep(i, 1, n) {
    if (!b[i]) continue;

    cout << i;
    if (i != idx_mx) {
      cout << ' ';
    } else {
      cout << "\n";
      break;
    }
  }

  return 0;
}


Measured memory_bytes: 2560
#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 ll long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;

unsigned long long  f(unsigned long long b,unsigned long long x) {
    if (b == -1) {
        return 0;
    }
    return b/x+1;
}

int main() {
    unsigned long long a,b,x,ans;
    cin >> a >> b >>x;
    
    cout << f(b,x)-f(a-1,x);
}

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

int main(){
  int N;
  cin >> N;
  vector<int> vec(N);
  for(int i=0; i<N; i++){
    cin >> vec.at(i);
  }
  
  sort(vec.begin(),vec.end());
  
  cout << vec.at(N-1) - vec.at(0)  << endl;
  
}

Measured memory_bytes: 256
from collections import Counter as C

_ = input()
a = C([int(x) for x in input().split()])

b = []
for k, v in a.items():
    for _ in range(v // 2):
        b.append(k)
else:
    if 2 <= len(b):
        b.sort()
        print(b[-1] * b[-2])
    else:
        print(0)

Measured memory_bytes: 22084
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define inf (ll)1e9
#define d(x) cerr<<#x<<"="<<x<<endl

ll ans,temp,c[5],s[5],sum;

int main(void){
    int n;
    string name;
    cin>>n;
    rep(i,n){
        cin>>name;
        if(name[0]=='M')c[0]++;
        else if(name[0]=='A')c[1]++;
        else if(name[0]=='R')c[2]++;
        else if(name[0]=='C')c[3]++;
        else if(name[0]=='H')c[4]++;
    }
    rep(i,1<<5){
        sum=0;
        rep(j,5)s[j]=0;
        rep(j,5)if(i>>j & 1)s[j]=1;
        rep(j,5)if(s[j])sum++;
        if(sum!=3)continue;
        temp=1;
        rep(j,5)if(s[j])temp*=c[j];
        ans+=temp;
    }        
    cout<<ans<<endl;
}


Measured memory_bytes: 256
n,k = map(int,input().split())
a = list(map(int,input().split()))
minus = [-x for x in a if x < 0]
plus = [x for x in a if x >= 0]

minus.sort()
plus.sort()

def solve(x):
    ans = 0
    if x < 0:
        x = -x
        r = 0
        for mi in minus[::-1]:
            while r < len(plus) and plus[r]* mi < x:
                r += 1
            ans += len(plus) - r
        return ans

    r = 0
    for l in minus[::-1]:
        if l * l <= x:ans -= 1
        while r < len(minus) and minus[r]*l <= x:
            r += 1
        ans += r
    r = 0
    for l in plus[::-1]:
        if l * l <= x: ans -= 1
        while r < len(plus) and plus[r] * l <= x:
            r += 1
        ans += r

    ans //= 2
    ans += len(minus)*len(plus)
    return ans

low = -10**18-1
high = 10**18+1
while high - low > 1:
    mid = (high + low) // 2
    if solve(mid) < k:
        low = mid
    else:
        high = mid

print(high)

Measured memory_bytes: 119556
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <set>
#include <utility>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>
#include <cstdio>
#include <map>

using namespace std;

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

#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define rrep(i,x) for(ll i = ((ll)(x) - 1); i >= 0; i--)

#define _upgrade ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define all(x) (x).begin(), (x).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

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

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

const ll mod = 1e9 + 7;
const ll INF = 1LL << 60;
const double PI = 3.14159265358979323846;


// ****************************************CODE***************************************//




int N,C,X;
int D[30][39];
int t[3][30];

int main()
{
        cin >> N >> C;
        for(int i = 0; i < C; i++){
                for(int j = 0; j < C; j++) cin >> D[i][j];
        }

        for(int i = 0; i < N; i++){
                for(int j = 0; j < N; j++){
                        cin >> X;
                        t[(i+j)%3][X-1]++;
                }
        }

        int res = 1 << 30;
        for(int i = 0; i < C; i++){
                for(int j = 0; j < C; j++){
                        if(i != j){
                                for(int k = 0; k < C; k++){
                                        if(i != k && j != k){
                                                int tt = 0;
                                                for(int l = 0; l < C; l++){
                                                        tt += D[l][i]*t[0][l];
                                                }
                                                for(int l = 0; l < C; l++){
                                                        tt += D[l][j]*t[1][l];
                                                }
                                                for(int l = 0; l < C; l++){
                                                        tt += D[l][k]*t[2][l];
                                                }
                                                res = min(res,tt);
                                        }
                                }
                        }
                }
        }

        cout << res << endl;
}


Measured memory_bytes: 888
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <deque>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <tuple>
#include <numeric>
#include <string>
#include <bitset>
#include <functional>

using ld = long double;
using vld = std::vector<ld>;
using vvld = std::vector<vld>;
using vvvld = std::vector<vvld>;
using ll = long long;
using vll = std::vector<ll>;
using vvll = std::vector<vll>;
using vvvll = std::vector<vvll>;
using pll = std::pair<ll, ll>;
using vpll = std::vector<pll>;
using str = std::string;
using vstr = std::vector<str>;

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

constexpr ld PI = 3.141592653589793L;
constexpr ld EPS = std::numeric_limits<ld>::epsilon();

ll gcd(ll n, ll m) { return m ? gcd(m, n % m) : n; }
ll lcm(ll n, ll m) { return n / gcd(n, m) * m; }
bool is_prime(ll n) {
    if (n == 1) return false;
    for (ll i = 2; i * i <= n; i++)
        if (n % i == 0) return false;
    return true;
}

/*------------------------------------------------------------------------*/

void solve();

int main() {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    std::cout << std::setprecision(15);

    solve();
}

void solve() {
    ll x;
    std::cin >> x;

    auto func = [](auto &func, ll n) -> ll {
        if (n == 0) return 0;
        return n <= 6 ? 1 : n <= 11 ? 2 : func(func, n % 11) + n / 11 * 2;
    };

	std::cout << func(func, x) << '\n';
}


Measured memory_bytes: 3628
a = input()
if a[-1] == "2" or a[-1] == "4" or  a[-1] == "5" or  a[-1] ==  "7" or a[-1] == "9":
   print("hon")
elif a[-1] == "0" or a[-1] == "1" or a[-1] == "6" or a[-1] == "8":
    print("pon")
else:
    print("bon")

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

template <typename T> inline void rd(T& x) {
	int si = 1; char c = getchar(); x = 0;
	while(!isdigit(c)) si = c == '-' ? -1 : si, c = getchar();
	while(isdigit(c)) x = x * 10 + c - 48, c = getchar();
	x *= si;
}
template <typename T, typename... Args>
inline void rd(T& x, Args&... args) { rd(x); rd(args...); }

#define fi first
#define se second

typedef long long ll;
typedef double ff;
typedef std::pair<int, int> pii;

const int kN = 1e5 + 5, kD = 12;

int n, m, c[kN], t[kN][kD];
std::vector <int> E[kN];

int main() {
	rd(n, m);
	for(int i = 1; i <= m; ++i) {
		int x, y; rd(x, y);
		E[x].push_back(y); E[y].push_back(x);
	}
	int q; rd(q);
	for(int i = 1; i <= q; ++i) {
		int v, d; rd(v, d, c[i]);
		t[v][d] = i;
	}
	for(int k = 10; k; --k) 
		for(int i = 1; i <= n; ++i)
			for(auto v : E[i])
				t[v][k - 1] = std::max(t[i][k], t[v][k - 1]);
	for(int i = 1; i <= n; ++i) {
		int x = 0;
		for(int j = 0; j <= 10; ++j) x = std::max(x, t[i][j]);
		printf("%d\n", c[x]);
	}
	return 0;
}

Measured memory_bytes: 11512
package main

import (
	"fmt"
)

func main() {
	var a, b int
	fmt.Scanf("%d %d", &a, &b)

	fmt.Println(logic(a, b))
}

func logic(a, b int) int {
	result := a - b*2
	if result < 0 {
		return 0
	}
	return result
}

Measured memory_bytes: 512
import math
N=int(input())

rN=int(math.sqrt(N))

ans=8101919114514
for i in range(rN):
  i=i+1
  if N%i==0:
    tmp=N/i
    if tmp<ans:
      #print(i,tmp)
      ans=i+tmp-2
print(int(ans))

Measured memory_bytes: 3060
N = int(input())
A = [int(i) for i in input().split()]

appeared = dict()

for a in A:
    if a in appeared.keys():
        appeared[a] += 1
    else:
        appeared[a] = 1

ans = 0
for i in appeared.keys():
    if appeared[i] > i:
        ans += appeared[i] - i
    elif appeared[i] < i:
        ans += appeared[i]

print(ans)


Measured memory_bytes: 18168
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

typedef long long ll;
typedef uint64_t ull;
typedef pair<int, int> P;
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

template<class T>
inline bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

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

    int n;
    ll k;
    cin >> n >> k;
    vector<ll> a(n);
    for(int i = 0; i < n; ++i)  cin >> a[i];

    ll x = 0;
    ll ans = 0;
    for(int d = 40; d >= 0; --d){
        int zero = 0, one = 0;
        for(int i = 0; i < n; ++i){
            if((a[i] >> d) & 1) ++one;
            else    ++zero;
        }
        if(zero > one){
            if(x + (1LL << d) <= k){
                x += 1LL << d;
                ans += (1LL << d) * zero;
            }
            else{
                ans += (1LL << d) * one;
            }
        }
        else{
            ans += (1LL << d) * one;
        }
    }
    cout << ans << endl;
}

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

int main()
{
  int N, D;
  cin >> N >> D;
  
  int count = 0;
  long x, y;
  
  for(int i=0; i<N; i++)
  {
    cin >> x >> y;
    if (sqrt(x*x + y*y) <= D)
    {
      count++;
    }
  }
  
  cout << count << endl;
  
  return 0;
}

Measured memory_bytes: 3672
import sys
input = sys.stdin.readline

N, M, = map(int, input().split())

ans = 10 ** 18
for i in range(N, M):
    for j in range(i + 1, M + 1):
        ans = min(ans, i * j % 2019)
        if ans == 0:
            print(ans)
            exit()
print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <numeric>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF 1e18
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define PI (acos(-1))

#define REP(i, n) for(ll i = 0; i < (ll)(n); i++)

long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
}

int main() {
    const ll MOD = 1e9 + 7;
    ll N;
    cin >> N;
    vector<ll> x(N);
    REP(i, N) cin >> x[i];
    vector<ll> d(N-1);
    REP(i, N-1) {
        d[i] = (x[i+1] - x[i]) % MOD;
        //cout << d[i] << endl;
    }

    ll f = 1;
    for(ll i = 1; i < N; i++) f = (f * i) % MOD;

    vector<ll> C(N-1);
    ll tmp;
    ll ans = 0;
    C[0] = 1;
    REP(i, N-1){
        tmp = (f * modinv(i+1, MOD)) % MOD;
        //cout << tmp << endl;
        if (i != 0) C[i] = (C[i-1] + tmp) % MOD;
        else C[i] = tmp;
        //cout << (i+1) << " " << C[i] << endl;
        tmp = (C[i] * d[i]) % MOD;
        ans = (ans + tmp) % MOD;
    }
    
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <string.h>
#include <math.h>
#include <set>
#include <map>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
#define FOR(i,n,m) for(int i=n; i<m; i++)
#define ROF(i,n,m) for(int i=n; i>m; i--)
#define ri(a) scanf("%d",&a)
#define rii(a,b) ri(a),ri(b)
#define riii(a,b,c) rii(a,b),ri(c)
#define lri(a) scanf("%lld",&a)
#define lrii(a,b) lri(a),lri(b)
#define pb push_back
#define _1 first
#define _2 second

const int INF = 0x3f3f3f3f;
const ll INFLL = 1e18;
const int MOD = 998244353; //1000000007;
const int alphabet = 26;
const int MAXINT = 2e5+1;

int main() {
    int n, k;
    string s;

    cin >> k >> s;

    if(s.size()<=k) cout << s << endl;
    else{
        FOR(i,0,k) cout << s[i];
        cout <<"..."<<endl;
    }
}

/*

*/  



Measured memory_bytes: 3624
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
	String a = sc.next();
	String b = sc.next();
	String c = sc.next();
    System.out.print(a.charAt(0));
    System.out.print(b.charAt(1));
    System.out.println(c.charAt(2));
  }
}


Measured memory_bytes: 21844
#include<iostream>
#include<cstring>
const int MAX_STR = 35;
const int MAX_NUM_OF_STR = 1010;
using namespace std;

int main(){
	int cnt = -1, len = 0, tango = 0;
	char str[MAX_NUM_OF_STR][MAX_STR], max[MAX_STR], maxlen[MAX_STR];
	
	while(cin >>str[tango]){
		int tmpcnt = 0;
		for(int i = 0; i <= tango; i++){
			if(strcmp(str[i], str[tango]) == 0){
				tmpcnt++;
			}
		}
		if(cnt < tmpcnt){
			strcpy(max, str[tango]);
			cnt = tmpcnt;
		}
		
		if(strlen(str[tango]) > (unsigned)len){
			len = strlen(str[tango]);
			strcpy(maxlen, str[tango]);
		}
		tango++;
	}
	cout <<max <<" " <<maxlen <<endl;
	return 0;
}

Measured memory_bytes: 0
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#include<set>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define brep(index,num) for(int index=num-1;index>=0;index--)
#define brep1(index,num) for(int index=num;index>0;index--)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-9
#define mp(a1,a2) make_pair(a1,a2)
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	int N,A[51],B[51],C[51];
	scan(N);
	rep(i,N) scan(A[i]),A[i]--;
	rep(i,N) scan(B[i]);
	rep(i,N-1) scan(C[i]);
	int sum=0;
	rep(i,N){
		sum+=B[A[i]];
		if(i>0){
			if(A[i-1]+1==A[i]){
				sum+=C[A[i-1]];
			}
		}
	}
	prin(sum);
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int linerSearch(int,int [],int);
int main(){
  int N,M,i,j,c,sum=0;
  scanf("%d",&N);
  int A[N];
  for(i=0;i<N;i++){
    scanf("%d",&A[i]);
  }
  scanf("%d",&M);
  int B[M];
  for(j=0;j<M;j++){
    scanf("%d",&B[j]);
  }
  for(j=0;j<M;j++){
    c=linerSearch(N,A,B[j]);
    if(c!=-1)sum++;
  }
  printf("%d\n",sum);
  return 0;
}
int linerSearch(int N,int A[],int key){
  int i=0;
  A[N]=key;
  while(A[i]!=key){
    i++;
    if(i==N)return -1;
  }
  return i;
}



Measured memory_bytes: 2700
h;w;f(y){y=w/3;return w%3-1|y<h?(h/2>y?h/2:y)+y+1:h+y;}main(){scanf("%d%d",&h,&w);printf("%.f",h%3&&w%3?fmin(fmin(h%2?h:h/2,w%2?w:w/2),fmin(f(),(h^=w^=h^=w,f()))):0);}

Measured memory_bytes: 128
#include <stdio.h>
int main(void)
{
  int a,b;
  scanf("%d %d",&a,&b);
  if(a<b){
    printf("a < b\n");
  }else if(a>b){
    printf("a > b\n");
  }else{
    printf("a == b\n");
  }
  return 0;
}

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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////
ll N,A[101010];
ll As1[101010], As2[101010];
ll i,j,k,ans;
int main(){
    scanf("%lld", &N);
    fornum(i,0,N){
        scanf("%lld", &A[i]);
    }
    fornum(i,0,N){
        As1[i + 2] = As1[i + 1] = As1[i] + A[i];
        As2[i + 2] = A[i + 1] + (As2[i + 1] = As2[i]);
        //printf("%lld,%lld\n%lld,%lld\n", As1[i + 1], As2[i + 1], As1[i + 2], As2[i + 2]);
        i++;
    }
    fornum(i,0,N){
        if(i%2==0){
            ll a = As1[N] - As2[N] + (As2[i] - As1[i]) * 2;
            printf("%lld ", a);
        }else{
            ll a = As2[N] - As1[N] + (As1[i] - As2[i]) * 2;
            printf("%lld ", a);
        }
    }


    return 0;
}

Measured memory_bytes: 3712
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author dyominov
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ASnukesFavoriteYAKINIKU solver = new ASnukesFavoriteYAKINIKU();
        solver.solve(1, in, out);
        out.close();
    }

    static class ASnukesFavoriteYAKINIKU {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            String s = in.next();
            out.println(s.startsWith("YAKI") ? "Yes" : "No");
        }

    }

    static class InputReader implements AutoCloseable {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public void close() {
        }

    }
}



Measured memory_bytes: 21716
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    s = input()
    t = input()
    n = len(s)

    for i in range(n):
        if s[i] != t[i]:
            print("No")
            break
    else:
        print("Yes")


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 9072
#include<iostream>
#include<array>
#include<vector>

int main(){

    std::array<std::array<int, 3>, 3> c;

    for(auto&& v : c){
        for(auto&& e : v){
            std::cin >> e;
        }
    }

    std::array<int, 3> a{}, b{};

    for(size_t i = 0; i < 3; i++){
        b[i] = c[0][i];
    }

    for(size_t i = 1; i < 3; i++){
        a[i] = c[i][0] - b[0];
    }

    bool flag = true;
    for(size_t i = 0; i < 3; i++){
        for(size_t j = 0; j < 3; j++){
            if(a[i] + b[j] != c[i][j]) flag = false;
        }
    }

    if(flag){
        std::cout << "Yes" << std::endl;
    }else{
        std::cout << "No" << std::endl;
    }

    return 0;
}


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

ll cal_sum(ll n){
    return (n*(n+1))/2;
}
vector<int> adj[100005];
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n,m;
	cin>>n>>m;
	for(int i=0; i<m; i++){
	    int a,b;
	    cin>>a>>b;
	    adj[a].push_back(b);
	    adj[b].push_back(a);
	}
	int dis[100005]={0};
	queue<pair<int,int>> q;
    q.push(pair<int,int>(1,0));
    while(!q.empty())
    {
        pair<int,int> tmp=q.front();q.pop();
        int u=tmp.first,d=tmp.second;
        if(dis[u]) continue;
        dis[u]=d;
        for(int i=0;i<adj[u].size();i++)
            if(adj[u][i]>1)
                q.push(pair<int,int>(adj[u][i],u));
    }
    for(int i=2;i<=n;i++)
        if(!dis[i])
            return printf("No\n")*0;
    puts("Yes");
    for(int i=2;i<=n;i++)
        printf("%d\n",dis[i]);
    return 0;
}

Measured memory_bytes: 11712
import sys
# 許容する再帰処理の回数を変更
sys.setrecursionlimit(10**5+10)
# input処理を高速化する
input = lambda: sys.stdin.readline().rstrip()

H, W = map(int, input().split())
grid = [input() for _ in range(H)]

#dp[i][j]は(i,j)までの経路の数
dp = [[0 for _ in range(W)] for _ in range(H)]
dp[0][0] = 1
for i in range(H):
    for j in range(W):
        if grid[i][j] == '#':
            dp[i][j] = 0
            continue

        if i > 0 and j > 0:
            dp[i][j] = dp[i-1][j] + dp[i][j-1]
        elif i > 0:
            dp[i][j] = dp[i - 1][j]
        elif j > 0:
            dp[i][j] = dp[i][j - 1]
        else:
            dp[i][j] = 1

print(dp[H-1][W-1] % (10**9+7))

Measured memory_bytes: 158368
#include<bits/stdc++.h>
using namespace std;
#define fo(i,a,n) for(i=a;i<n;i++)
#define ll long long
#define ld long double
#define deb(x) cout << #x << "=" << x << endl
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define sortrev(x) sort(all(x),greater<int>())
#define pi 3.1415926535897932384626

typedef pair<int,int> pii;
typedef pair<ll, ll> pl;
typedef vector<int>	vi;
typedef vector<ll>	vl;
typedef vector<pii>	vpii;
typedef vector<pl>	vpl;
typedef vector<vi>	vvi;
typedef vector<vl>	vvl;


const int mod = 100000007;
const int inf = 100005;
const int N = 3e5, M = N;
ll i,j,n,m,idx,cnt;
char d[31][31];
int dx[] = {-1,1,0,0};
int dy[] = {0,0,-1,1};


void solve() {
   ll n,x;
   cin>>n;

   vi vec(n+1 , 0);
   fo(i,0,n) cin>>vec[i];

   ll curr = 1;
   fo(i,0,n) {
    if(curr == vec[i]) curr++;
   }
   if(curr == 1) cout<<"-1\n";
   else cout<<n - curr + 1<<"\n";
}




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

    int t = 1;
    //cin >> t;
    while(t--) {
      solve();
    }

    return 0;
}




Measured memory_bytes: 3940
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <map>
using namespace std;

long long gcd(long long a, long long b) {
    if (b == 0){
      return a;
    }
    else return gcd(b, a % b);
}

//上記のgcdを用いて計算する
long long lcm(long long a, long long b) {
	long long g;
	g = gcd(a, b);
    //a*b/gで良いが、これをするとa*bの桁数が大きいとlong longでもオーバーフローする．
	return ((a/g)*(b/g))*g;
}

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

    vector<long long> T(N);

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

    long long res = T[0];
    for(int i=0;i<N;i++){
        res = lcm(res, T[i]);
    }
    cout << res << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define forn(i,n) for(ll i=0;i<n;i++)
#define nforn(i,n) for(ll i=n-1;i>=0;i--)
#define forne(i,n) for(ll i=1;i<=n;i++)
#define forse(i,s,e) for(ll i=s;i<e;i++)
#define all(v) v.begin(),v.end()
#define MOD 1000000007
#define d1(x) cerr <<"> "<<#x<<" = "<<x<<'\n'
#define d2(x, y) cerr <<"> "<<#x<<" = "<<x<<' '<<#y<<" = "<<y<<'\n'
#define d3(x, y, z) cerr <<"> "<<#x<<" = "<<x<<' '<<#y<<" = "<<y<<' '<<#z<<" = "<<z<<'\n'
int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int t = 1;
	// cin>>t;
	while(t--){
		int n,m;
		cin>>n>>m;
		if(m>=n)
			cout<<"Yes\n";
		else
			cout<<"No\n";
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <climits>

using namespace std;

static const int MAX = 100;
static const long long INFTY = (1LL << 32);
int n;
long long d[MAX][MAX];

//???????????£????????????????????¢?????´?????????????????£?????¨?????????????????????????????¢????±???????
void floyd() {
	for (int k = 0; k < n; k++) {
		for (int i = 0; i < n; i++) {
			if (d[i][k] == INFTY) {
				continue;
			}
			for (int j = 0; j < n; j++) {
				if (d[k][j] == INFTY) {
					continue;
				}
				d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
			}
		}
	}
}

int main(void)
{
	int e, u, v, c;
	cin >> n >> e;

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			d[i][j] = ((i == j) ? 0 : INFTY);
		}
	}

	for (int i = 0; i < e; i++) {
		cin >> u >> v >> c;
		d[u][v] = c;
	}

	bool negative = false;

	floyd();

	for (int i = 0; i < n; i++) {
		if (d[i][i] < 0) {
			negative = true;
		}
	}

	if (negative) {
		cout << "NEGATIVE CYCLE" << endl;
	}
	else {
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				if (j > 0) {
					cout << " ";
				}
				if (d[i][j] == INFTY) {
					cout << "INF";
				}
				else {
					cout << d[i][j];
				}
			}
			cout << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 3188
[A,B,K] = [int(s) for s in input().split()]

if A + K - 1 < B - K + 1:
    for i in range(A,A+K):
        print(i)

    for i in range(B-K+1, B+1):
        print(i)
else:
    for i in range(A,B+1):
        print(i)



Measured memory_bytes: 3060
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

// Returns the longest repeating non-overlapping 
// substring in str 
string longestRepeatedSubstring(string str)
{
	int n = str.length();

	vector<vector<int>> LCSRe(n+1, vector<int>(n+1,0));
	
	string res; // To store result 
	int res_length = 0; // To store length of result 

	// building table in bottom-up manner 
	int i, index = 0;
	for (i = 1; i <= n; i++)
	{
		for (int j = i + 1; j <= n; j++)
		{
			// (j-i) > LCSRe[i-1][j-1] to remove 
			// overlapping 
			if (str[i - 1] == str[j - 1] &&
				LCSRe[i - 1][j - 1] < (j - i))
			{
				LCSRe[i][j] = LCSRe[i - 1][j - 1] + 1;

				// updating maximum length of the 
				// substring and updating the finishing 
				// index of the suffix 
				if (LCSRe[i][j] > res_length)
				{
					res_length = LCSRe[i][j];
					index = max(i, index);
				}
			}
			else
				LCSRe[i][j] = 0;
		}
	}

	// If we have non-empty result, then insert all 
	// characters from first character to last 
	// character of string 
	if (res_length > 0)
		for (i = index - res_length + 1; i <= index; i++)
			res.push_back(str[i - 1]);

	return res;
}

// Driver program to test the above function 
int main()
{
	int n; string s; cin >> n >> s;

	cout << longestRepeatedSubstring(s).size() << endl;
	return 0;
}


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

int main() {
	int n;
	cin >> n;
	vector<int> mochi(n);
	for (int i = 0; i < n; i++)
	{
		cin >> mochi.at(i);
	}
	sort(mochi.rbegin(), mochi.rend());
	int dan = 1;
	for (int i = 0; i < n; i++)
	{
		if (!i) continue;
		if (mochi.at(i) < mochi.at(i - 1)) dan++;
	}
	cout << dan << endl;
}


Measured memory_bytes: 3552