akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main(){
    int N, M;
    cin >> N;
    map<int, int> count;
    rep(i, N){
        int d;
        cin >> d;
        count[d]++;
    }
    cin >> M;
    string ans = "YES";
    rep(i, M){
        int t;
        cin >> t;
        if(count[t] <= 0){
            ans = "NO";
            break;
        }
        count[t]--;
    }
    cout << ans << endl;
    return 0;
}


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

int main() {
    string src = "wa * nn * wo a i u e o ka ki ku ke ko sa si su se so ta ti tu te to na ni nu ne no ha hi hu he ho ma mi mu me mo ya * yu * yo ra ri ru re ro";
    istringstream iss(src);
    vector<vector<string> > vec(10);
    for(int i = 0; i < 10; i++) {
        for(int j = 0; j < 5; j++) {
            string ss; iss >> ss;
            vec[i].push_back(ss);
        }
    }

    string line; getline(cin, line);
    for(int i = 0; i < (int)line.length() / 2; i++) {
        char p = line[2 * i];
        char q = line[2 * i + 1];
        int ps = p - '0';
        string dir = "TLURD";
        int qs = find(begin(dir), end(dir), q) - begin(dir);
        cout << vec[ps][qs];
    }
    cout << endl;
}

Measured memory_bytes: 1204
#include<stdio.h>

int main(){

    int day;
    int homework;
    int homework_day[10001];
    int i=0;
    int homework_day_ruiseki=0;
    int play=0;

    scanf("%d%d",&day,&homework);

    while(i < homework){
        scanf("%d",&homework_day[i]);
        i++;
    }

    i = 0;

    while(i < homework){
        homework_day_ruiseki += homework_day[i];
        i++;   
    }

    play = day - homework_day_ruiseki;

    if(play <= -1)play = -1;
    
    printf("%d\n",play);

    return 0;
}

Measured memory_bytes: 1768
a, b, x = gets.split.map(&:to_f)
water = x / a
air = a * b - water

if water > air
    define_method(:overflow){|degree|
        air < a * a * Math::tan(degree * Math::PI / 180) / 2.0
    }
else
    define_method(:overflow){|degree|
        water > b * b * Math::tan((90 - degree) * Math::PI / 180) / 2.0
    }
end

flat = 0.0
steep = 90.0
while steep - flat > 0.0000001
    mid = (flat + steep) / 2.0
    if overflow(mid)
        steep = mid
    else
        flat = mid
    end
end

puts flat


Measured memory_bytes: 1788
#include <iostream>
using namespace std;
int main(){
  int A, B, C; cin >> A >> B >> C;
  if ( (A == 5) and (B==5) and (C==7) or
      (A == 5) and (B==7) and (C ==5) or
      (A ==7) and (B==5) and(C==5))
    cout << "YES" << endl;
  else cout << "NO" << endl;
}

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

int main() {
   string n;
  
   cin >> n;
  
  //  cout << n << endl;
  
   int num = n.size();
  
   //cout << num << endl;
  
   for(int i = num - 1;i >= 0;i--){
     
     // cout << i << endl;
     
      n.erase(i); 
     
      if((n.size()+1)%2!=0){
        
       // cout << n.size()/2 << endl;
        int k = n.size()/2;
        
        string mmm = n;
        string m = mmm.substr(k);
        string mm = mmm.erase(k);
        
      //  cout << m << endl;
       // cout << mm << endl;
        
        if(m==mm){
          cout << k*2 << endl;
          break;
          
        }
        
        
      }
      
        

   }
  
  
 //  cout << n << endl;
 
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>

int main(void)
{
    int n, m;
    scanf("%d %d", &n, &m);
    int a[n][m], b[m], c[n];
    for(int i=0; i<n; i++) c[i] = 0;
    for(int i=0; i<n; i++)
        for(int j=0; j<m; j++)
            scanf("%d", &a[i][j]);
    for(int i=0; i<m; i++)
        scanf("%d", &b[i]);
    for(int i=0; i<n; i++)
    {
        for(int j=0; j<m; j++)
            c[i] += a[i][j]*b[j];
        printf("%d\n", c[i]);
    }
    
    return 0;
}


Measured memory_bytes: 2780
#include<stdio.h>

int main(){
  int i,j,k,n,max,l;
  char map[1000][1001];
  while(1){
    scanf("%d",&n);
    if(n==0) break;
    max=0;
    for(i=0;i<n;i++)
      scanf("%s",map[i]);
    for(i=0;i<n;i++){
      for(j=0;j<n;j++){
	if(map[i][j]=='.'){
	  for(k=1;;k++){
	    for(l=i;l<=i+k&&l<n;l++)
	      if(map[l][j+k]!='.') break;
	    if(l!=i+k+1){
	      if(k>max) max=k;
	      break;
	    }
	    for(l=j;l<j+k&&l<n;l++){
	      if(map[i+k][l]!='.') break;
	    }
	    if(l!=j+k){
	      if(k>max) max=k;
	      break;
	    }
	  }
	}
      }
    }
    printf("%d\n",max);
  }
  return 0;
}

Measured memory_bytes: 1184
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

//std::cout << std::fixed << std::setprecision(10)
constexpr long long MOD = 1000000007;

int main()
{
  int r;
  std::cin >> r;
  std::cout << 3 * r * r << std::endl;
  return 0;
}



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

using namespace std;

#define mod 1000000007
#define inf 1e18

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

	int a, b;
	char c;
	cin >> a >> c >> b;
	if(c=='+')
		cout << a+b << endl;
	else
		cout << a-b << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define itn int
#define REP(i, n) for (ll i = 0; i < n; i++)
#define IREP(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define all(v) v.begin(), v.end()
#define SENTINEL 2000000000
#define NIL -1
using namespace std;
typedef long long ll;


const ll MAX = 510000;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template <class T>inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}

vector<bool> prime_table(int n)
{
    vector<bool> prime(n + 1, true);
    if (n >= 0)
        prime[0] = false;
    if (n >= 1)
        prime[1] = false;
    for (int i = 2; i * i <= n; i++)
    {
        if (!prime[i])
            continue;
        for (int j = i + i; j <= n; j += i)
        {
            prime[j] = false;
        }
    }
    return prime;
}
int main()
{
    vector<bool> table=prime_table(55555);
    int n;
    cin >> n;
    int now=2;
    vector<int> ans;
    while(n>0){
        if(table[now]&&now%5==1){
            ans.push_back(now);
            n--;
        }
        now++;
    }
    REP(i,ans.size()){
        cout << ans[i] << " ";
    }
    cout << endl;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
#define MAX(a,b) ((a)<(b) ? (b) : (a))

int main() {
  int N,M;
  int max;
  vector<string> blue,red;
  
  cin >> N;
  blue = vector<string>(N);
  for (int i=0;i<N;i++) {
    cin >> blue.at(i);
  }
  cin >> M;
  red = vector<string>(M);
  for (int i=0;i<M;i++) {
    cin >> red.at(i);
  }
  
  max = 0;
  for (int i=0; i<N; i++) {
    string target = blue.at(i);
    int count = 1;
    for (int j=i+1; j<N;j++) {
      if ( target==blue.at(j) ) {
        count++;
      }
    }
    for (int j=0; j<M;j++) {
      if ( target==red.at(j) ) {
        count--;
      }
    }
    max = MAX(max,count);
  }
  
  cout << max << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <cassert>
#include <string>
#include <memory.h>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <set>
#include <map>
#include <cctype>
#include <iomanip>
#include <sstream>
#include <cctype>
#include <fstream>
#include <cmath>
using namespace std;

#define REP2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define REP(i, n) REP2(i, 0, n)
#define ALL(c) (c).begin(), (c).end()
#define ITER(c) __typeof((c).begin())
#define PB(e) push_back(e)
#define FOREACH(i, c) for(ITER(c) i = (c).begin(); i != (c).end(); ++i)
#define MP(a, b) make_pair(a, b)
#define PARITY(n) ((n) & 1)

typedef long long ll;
typedef pair<ll, ll> P;
const int INF = 1000 * 1000 * 1000 + 7;
const double EPS = 1e-10;

typedef unsigned int uint;
int main(){
  int S;
  cin >> S;
  while(S--){
    vector<uint> N(9);
    REP(i, 9) cin >> hex >> N[i];
    
    uint K = 0;
    REP(b, 32){
      uint S = 0;
      REP(i, 8){
        S += N[i] & ((uint)1 << b);
        if(b > 0) S += (N[i] & (((uint)1 << b) - 1)) ^ K;
      }
      K |= (PARITY(N[8] >> b) ^ PARITY(S >> b)) ? (uint)1 << b : 0;
    }
    cout << hex << K << endl;
  }
    
  return 0;
}

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

using namespace std;

const int NAX = 1e5;

int n, m, ans[NAX];
vector<int> adj[NAX];
queue<int> q;
bool vis[NAX];

void bfs(int src = 0) {
	q.push(src);
	vis[src] = true;

	while (!q.empty()) {
		int u = q.front();
		q.pop();

		for (int v, i = 0; i < adj[u].size(); ++i) {
			v = adj[u][i];

			if (!vis[v]) {
				vis[v] = true;
				ans[v] = u + 1;
				q.push(v);
			}
		}
	}
}

int main() {
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);

	cin >> n >> m;
	for (int u, v, i = 0; i < m; ++i) {
		cin >> u >> v;

		adj[--u].push_back(--v);
		adj[v].push_back(u);
	}

	bfs();

	for (int i = 0; i < n; ++i)
		if (!vis[i])
			return cout << "No", 0;

	puts("Yes");
	for (int i = 1; i < n; ++i)
		cout << ans[i] << endl;
}


Measured memory_bytes: 10452
#include<stdio.h>
#include<iostream>
#include<cctype>
#include <algorithm>
using namespace std;

int main()
{
    string w, t;
    
    cin >> w;
    
    int count = 0;
    while (true) {
        cin >> t;
        
        if (t == "END_OF_TEXT") {
            break;
        }
        
        transform(t.begin(),t.end(),t.begin(),::tolower);
        
        if (t == w) {
            count += 1;
        }
    }
    
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 3204
#include <bits/stdc++.h>
#define dbug(x) cout<<#x<<"="<<x<<endl
using namespace std;
template <typename T> void read(T &t) {
	t=0; char ch=getchar(); int f=1;
	while ('0'>ch||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
	do {(t*=10)+=ch-'0';ch=getchar();} while ('0'<=ch&&ch<='9'); t*=f;
}
const int maxn=(2e5)+10;
int n,a,b,c,d,vis[maxn];
char s[maxn];
void go(int x,int y) {
	memset(vis,0,sizeof(vis));
	vis[x]=1;
	for (int i=x;i<=y;i++) {
		if (!vis[i]) continue;
		if (i<n&&s[i+1]=='.'&&i+1<=y) vis[i+1]=1;
		if (i<n-1&&s[i+2]=='.'&&i+2<=y) vis[i+2]=1;
	}
	if (!vis[y]) { printf("No\n"); exit(0); }
}
int v1[maxn],v2[maxn];
void go2(int x,int y) {
	v1[x]=1;
	for (int i=x;i<=y;i++) {
		if (!v1[i]) continue;
		if (i<n&&s[i+1]=='.') v1[i+1]=1;
		if (i<n-1&&s[i+2]=='.') v1[i+2]=1;
	} v2[y]=1;
	for (int i=y;i>=x;i--) {
		if (!v2[i]) continue;
		if (i>1&&s[i-1]=='.') v2[i-1]=1;
		if (i>2&&s[i-2]=='.') v2[i-2]=1;
	}
	for (int i=x;i<=y;i++)
		if (vis[i]&&v1[i-1]&&v2[i+1]) {
			printf("Yes\n"); exit(0);
		}
}
int main() {
	//freopen("1.txt","r",stdin);
	read(n); read(a); read(b); read(c); read(d);
	scanf("%s",s+1);
	if (a>b) swap(a,b),swap(c,d);
	if (c<d) {
		go(b,d); go(a,c); printf("Yes\n"); return 0;
	}
	go(a,c);
	go(b,d);
	go2(a,c);
	printf("No\n");
	return 0;
}

Measured memory_bytes: 2688
#define dbg(fmt,...) fprintf(stderr,fmt,__VA_ARGS__)
#define dpri(x) dbg(#x ": %d\n", x)
#define dprs(x) dbg(#x ": %s\n", x)
#include <stdio.h>
const int INF = 1e9+7;
typedef long long ll;

int main(int argc, char **argv)
{
	int i, n, a;
	ll min, max, sum;
	min = INF;
	max = -INF;
	sum = 0;
	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%d", &a);
		if (a < min) min = a;
		if (a > max) max = a;
		sum += a;
	}
	printf("%lld %lld %lld\n", min, max, sum);
	return 0;
}

Measured memory_bytes: 600
#include <stdio.h>

int main(void)
{
  long int x;
  long int money = 100;
  scanf("%ld", &x);
  for(long int i=1;i<=100000000000;i++){
    money = money * 1.01;
    if(money >= x){
      printf("%ld\n", i);
      break;
    }
  }
  return 0;
}


Measured memory_bytes: 1736
n = gets.to_i
s = readlines.map { |e| e.split(' ').map(&:to_f) }
result = 0.0
all_order = s.permutation(n).to_a
all_order.each do |el|
  el.each_with_index do |line, i|
    next if i == el.size - 1

    next_line = el[i + 1]
    x, y = line
    nx, ny = next_line
    result += Math.sqrt(((x - nx) * (x - nx)) + ((y - ny) * (y - ny)))
  end
end

p result / all_order.size.to_f


Measured memory_bytes: 8728
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<map>
#include<set>
#include<list>
#include<stack>
#include<queue>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<iomanip>
using namespace std;
typedef long long ll;
const int N = 100005;
int pre[N], sign[N], xot[N];
int n, k;
char s[N];
int main()
{
    //ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    scanf("%s", s + 1);
    memset(pre, 0, sizeof(pre));
    memset(sign, 0, sizeof(sign));
    memset(xot, 0, sizeof(xot));
    int cnt = 0, sum = 0, ans = 0;
    for(int i = 1; i <= n + 1
            ; i++)
    {
        if(s[i] != s[i - 1] && i != 1)
        {
            pre[++cnt] = sum;
            sign[cnt] = (s[i - 1] - '0');
            sum = 0;
        }
        sum++;
    }
    for(int i = 1; i <= cnt; i++)
    {
        if(sign[i] == 0)
        {
            xot[i] = xot[i - 1] + 1;
        }
        else if(sign[i] == 1)
        {
            xot[i] = xot[i - 1];
        }
        pre[i] += pre[i - 1];
    }
    // freopen("D:\\in.txt","r",stdin);
    // freopen("D:\\out.txt","w",stdout);
    for(int l = 0, r = 1; r <= cnt; r++)
    {
        while(l < r && xot[r] - xot[l - 1] > k)
        {
            l++;
        }
        ans = max(ans, pre[r] - pre[l - 1]);
    }
    cout << ans << endl;
    //system("pause");
    return 0;
}


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

int main() {
  int N, l, r;
  cin >> N;
  int count = 0;
  
  for (int i = 0; i < N; i++) {
    cin >> l >> r;
    
    count += r - l + 1;
  }
  
  cout << count << endl;
}



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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define _abs(x)((x) < 0 ? (x) * -1 : (x))
#define _max(x, y)(max(0, max((x), (y))))
#define _min(x, y)(max(0, min((x), (y))))

typedef struct Node {
    long id;
    map<long, char> connects;
} Node;

int main()
{
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    //freopen("debug.txt", "w", stderr);

    cin.tie(0);
    ios::sync_with_stdio(false);

    long n, m;
    long a, b;

    cin >> n >> m;

    static const string P = "POSSIBLE";
    static const string I = "IMPOSSIBLE";

    vector<Node> nodes(n);
    map<long, char>::iterator it;

    long i;

    for (i = 0; i < m; i++) {
        cin >> a >> b;

        a--;
        b--;

        nodes[a].connects[b] = 1;
        nodes[b].connects[a] = 1;
    }

    for (it = nodes[0].connects.begin(); it != nodes[0].connects.end(); it++) {
        if (nodes[n - 1].connects.find(it->first) != nodes[n - 1].connects.end()) {
            cout << P << endl;

            return 0;
        }
    }

    cout << I << endl;

    return 0;
}


Measured memory_bytes: 36224
#include <stdio.h>
void input(int*,int*);
int main(void){
    int a,b,c;
    input(&a,&b);
    if(b%a==0){
        c=a+b;
    }else{
        c=b-a;
    }
    printf("%d\n",c);
    return 0;
}
void input(int* p,int* q){
    scanf("%d %d",p,q);
}

Measured memory_bytes: 128
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
long long solve(int l, int r, vector<int> &v) {
	if (r - l == 1) return 0;
	int m = (l + r) >> 1;
	long long lc = solve(l, m, v);
	long long rc = solve(m, r, v);
	int ptr = l;
	long long subans = 0;
	for (int i = m; i < r; ++i) {
		while (ptr != m && v[ptr] < v[i]) ++ptr;
		subans += ptr - l;
	}
	vector<int> vmerged(r - l);
	merge(v.begin() + l, v.begin() + m, v.begin() + m, v.begin() + r, vmerged.begin());
	copy(vmerged.begin(), vmerged.end(), v.begin() + l);
	return lc + rc + subans;
}
int main() {
	int N;
	cin >> N;
	vector<int> A(N);
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
	}
	long long P = (long long)(N) * (N + 1) / 2;
	int L = 0, R = 1000000001;
	while (R - L > 1) {
		int M = (L + R) >> 1;
		vector<int> S(N + 1);
		for (int i = 0; i < N; ++i) {
			S[i + 1] = S[i] + (A[i] <= M ? 1 : -1);
		}
		long long res = solve(0, N + 1, S);
		if (res > P / 2) R = M;
		else L = M;
	}
	cout << R << endl;
	return 0;
}

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

#define endl '\n'

void solvetask(){
    int a,b,c; cin >> a >> b >> c;
    int k; cin >> k;
    while(k--){
        if (b <= a){
            b *= 2;
        } else c *= 2;
    }
    if (c > b && b > a) cout << "Yes\n";
    else cout << "No\n";
}
// b > a && c > b > a

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

Measured memory_bytes: 3612
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

vector<int> xx;
int xxx[1500010];
vector<int> yy;
int yyy[1500010];

int main() {
	int n,m;
	while(cin>>n>>m,n){
		int i;
		int x,y;
		x=y=0;
		xx.clear();
		yy.clear();
		xx.push_back(0);
		yy.push_back(0);
		for(i=0;i<n;i++){
			x+=in();
			xx.push_back(x);
		}
		for(i=0;i<m;i++){
			y+=in();
			yy.push_back(y);
		}
		memset(xxx,0,sizeof(xxx));
		memset(yyy,0,sizeof(yyy));
		int j;
		for(i=0;i<n;i++){
			for(j=i+1;j<=n;j++){
				xxx[xx[j]-xx[i]]++;
			}
		}
		for(i=0;i<m;i++){
			for(j=i+1;j<=m;j++){
				yyy[yy[j]-yy[i]]++;
			}
		}
		int res=0;
		for(i=0;i<1500010;i++){
//if(xxx[i])cout<<"x:"<<i<<" "<<xxx[i]<<endl;
//if(yyy[i])cout<<"y:"<<i<<" "<<yyy[i]<<endl;
			res+=xxx[i]*yyy[i];
		}
		cout<<res<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
// Begin Header {{{
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i,n) for(ll i=0; i<n; i++)
#define loop(i, j, n) for(ll i=j; i<n; i++)
#define all(x) (x).begin(), (x).end()
constexpr int INF  = 0x3f3f3f3f;
const long long mod=1e9+7;
const long double PI = acos(-1);
// }}} End Header

int main() {
	ll n, m, k, sum = 0;
	cin >> n >> m >> k;
	vector<ll> a(n+1);
	vector<ll> b(m+1);
	loop(i, 1, n+1) cin >> a[i];
	loop(i, 1, m+1){
		cin >> b[i];
		sum+=b[i];
	}

	ll cnt_b = m, ans=0;
	loop(i, 0, n+1){
		sum+=a[i];
		while(sum>k){
			if(cnt_b == 0) break;
			sum-=b[cnt_b];
			cnt_b--;
		}
		if(sum > k) break;
		if(ans < cnt_b+i) ans = cnt_b+i;
	}
	cout << ans << endl;
}

Measured memory_bytes: 6384
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<pair<pair<string,int>,int>> list(n);
  for(int i=0; i<n; i++) {
    string s;
    int p;
    cin >> s >> p;
    list[i].first.first = s;
    list[i].first.second = p*-1;
    list[i].second = i+1;
  }
  sort(list.begin(),list.end());
  for(int i=0; i<n; i++) {
    cout << list[i].second << endl;
  }
}


Measured memory_bytes: 3636
'use strict'
 
function main(s) {
  let n = s.split('\n')[0].split(' ').map(n =>Number(n));
  const abc_sum = n.reduce((x,y)=>x += y,0);
  let max3times = Math.max(...n)*3;
  // パリティチェック
  if(abc_sum%2 !== max3times%2){
  	max3times += 3;
  }
  // ３倍と足し合わせの誤差を2で割ったものがanswer
  let answer = (max3times - abc_sum)/2
	
  // console.log(answer);
  console.log(answer);
}
 
main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#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;
}

constexpr int stick[10] = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};

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

    int n, m;
    cin >> n >> m;
    vector<int> a(m);
    for(int i = 0; i < m; ++i)  cin >> a[i];
    sort(a.begin(), a.end(), greater<int>());
    
    vector<int> dp(n + 10, -1);
    dp[0] = 0;
    for(int i = 0; i < n; ++i){
        if(dp[i] == -1) continue;
        for(int j = 0; j < m; ++j){
            chmax(dp[i + stick[a[j]]], dp[i] + 1);
        }
    }

    int cur = n;
    int p = 0;
    string ans = "";
    while(cur > 0){
        if(cur - stick[a[p]] < 0){
            ++p;
            continue;
        }
        if(dp[cur - stick[a[p]]] == dp[cur] - 1){
            ans += (char)(a[p] + '0');
            cur -= stick[a[p]];
        }
        else{
            ++p;
        }
    }
    cout << ans << endl;
}

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

const int kMaxL = 2 * 100000;
const auto kInvalid = numeric_limits<int64_t>::max();

template <typename T> T Min(const T &t) { return t; }

template <typename T, typename... Args>
T Min(const T &t, const Args &... args) {
  return min(t, Min(args...));
}

int CostZero(int value) { return value; }
int CostEven(int value) { return value == 0 ? 2 : value % 2; }
int CostOdd(int value) { return 1 - value % 2; }

int g_as[kMaxL + 1];
int64_t g_dp[kMaxL + 1][5];

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

  int L;
  cin >> L;
  for (int i = 1; i <= L; ++i)
    cin >> g_as[i];

  g_dp[0][1] = g_dp[0][2] = g_dp[0][3] = kInvalid;
  for (int i = 1; i <= L; ++i) {
    g_dp[i][0] = CostZero(g_as[i]) + g_dp[i - 1][0];
    g_dp[i][1] = CostEven(g_as[i]) + Min(g_dp[i - 1][1], g_dp[i - 1][0]);
    g_dp[i][2] =
        CostOdd(g_as[i]) + Min(g_dp[i - 1][2], g_dp[i - 1][1], g_dp[i - 1][0]);
    g_dp[i][3] = CostEven(g_as[i]) + Min(g_dp[i - 1][3], g_dp[i - 1][2],
                                         g_dp[i - 1][1], g_dp[i - 1][0]);
    g_dp[i][4] =
        CostZero(g_as[i]) + Min(g_dp[i - 1][4], g_dp[i - 1][3], g_dp[i - 1][2],
                                g_dp[i - 1][1], g_dp[i - 1][0]);
  }

  cout << Min(g_dp[L][3], g_dp[L][4], g_dp[L][2]) << endl;

  return 0;
}


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

using namespace std;

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define rep1(i,n) for(ll i=1;i<=(ll)(n);i++)
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define rrep1(i,n) for(ll i=(ll)(n);i>0;i--)
#define REP(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(v) v.begin(),v.end()
#define UNIQUE(v) v.erase(unique(all(v)), v.end())
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
const ll inf = 1000000001;
const ll INF = 2e18;
const ll MOD = 1000000007;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { 1,0, -1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);


int a, b, c, n;
string s, t;

int main() {
	cin >> a >> b;
	if (a <= 8 && b <= 8) {
		cout << "Yay!" << endl;
	}
	else {
		cout << ":(" << endl;
	}

}

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

char str[101];
int L=0;
bool exists[27];

vector<char> available;

int main()
{
    int i,j;

    scanf("%s",str+1);
    L=strlen(str+1);

    if (L<26)
    {
        for (i=1;i<=L;i++)
        {
            exists[ str[i]-'a' ]=true;
        }
        for (i=0;i<=25;i++)
        {
            if (!exists[i])
            {
                printf("%s%c\n",str+1,(char)(i+'a'));

                return 0;
            }
        }
    }
    else
    {
        for (i=L;i>=1;i--)
        {
            for (j=0;j<available.size();j++)
            {
                if (str[i]<available[j])
                {
                    str[i]=available[j];
                    str[i+1]=0;

                    printf("%s\n",str+1);

                    return 0;
                }
            }

            available.push_back(str[i]);
        }

        printf("-1\n");
    }

    return 0;
}


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

template< typename T>
struct BinaryIndexedTree{
    vector<T> bit;
    BinaryIndexedTree(int size){
        bit.assign(size+1,0);
    }

    void add(int k, T num){
        k++;
        // k & -kで一番したのたってるbitを取り出せる
        for(k;k < bit.size();k += k & -k){
            bit[k] += num;
        }
    }
    T sum(int k) {
        T ret = 0;k++;
        for(k;k>0;k -= k & -k){
            ret += bit[k];
        }
        return ret;
    }
};

#define ll long long
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n,q;
    cin >> n >> q;
    BinaryIndexedTree<int> BIT(n);
    rep(i,0,q){
        int com,x,y;
        cin >> com >> x >> y;
        if(!com) BIT.add(x-1,y);
        else cout << BIT.sum(y-1) - BIT.sum(x-2) << endl;
    }
    
}


Measured memory_bytes: 3248
// Problem : D - RGB Triplets
// Contest : AtCoder - AtCoder Beginner Contest 162
// URL : https://atcoder.jp/contests/abc162/tasks/abc162_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update

using namespace std;
using namespace __gnu_pbds;

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

#define FOR(i,a,b) for(int i = (a); i <= (b); ++i)
#define FORD(i,a,b) for(int i = (a); i >= (b); --i)
#define RI(i,n) FOR(i,1,(n))
#define REP(i,n) FOR(i,0,(n)-1)
#define mini(a,b) a=min(a,b)
#define maxi(a,b) a=max(a,b)
#define pb push_back
#define st first
#define nd second
#define sz(w) (int) w.size()
typedef vector<int> vi;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<pii, int> para;
const ll inf = 1e18 + 7;
const ll maxN = 1e6 + 5;
const ll MOD = 1e9 + 7;

int sufB[maxN], sufR[maxN], sufG[maxN];

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int n; cin >> n;
	string s; cin >> s;
	FORD(i, n - 1, 0) {
		sufR[i] = sufR[i + 1];
		sufB[i] = sufB[i + 1];
		sufG[i] = sufG[i + 1];
		if (s[i] == 'R') sufR[i]++;
		if (s[i] == 'G') sufG[i]++;
		if (s[i] == 'B') sufB[i]++;
	}
	string p = "RGB";
	ll ans = 0;
	REP(i, n) {
		FOR(j, i + 1, n - 1) {
			if (s[i] != s[j]) {
				char c;
				REP(k, 3) {
					if (p[k] != s[i] && p[k] != s[j]) {
						c = p[k];
						break;
					}
				}
				int diff = j - i;
				if (c == 'R') {
					ans += sufR[j + 1];
					if (j + diff < n && s[j + diff] == 'R') ans--;
				}
				if (c == 'B') {
					ans += sufB[j + 1];
					if (j + diff < n && s[j + diff] == 'B') ans--;
				}
				if (c == 'G') {
					ans += sufG[j + 1];
					if (j + diff < n && s[j + diff] == 'G') ans--;
				}
			}
		}
	}
	cout << ans << endl;
	return 0;
}
 


Measured memory_bytes: 3680
/*suri_kumkaran*/

#include <bits/stdc++.h>

using namespace std;

#define UB upper_bound
#define LB lower_bound
#define BS binary_search
#define MP make_pair
#define EB emplace_back
#define endl "\n"
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define F first
#define S second
#define ALL(a) (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)

typedef long long int int64;
typedef vector<int64> VI64;
typedef vector<pair<int64,int64>> VII64;
typedef vector<string> VS;
typedef vector<vector<int64>> VVI;

int main()
{
    IOS;
    int64 T=1;
    //cin>>T;
    while(T--)
    {
        int64 n,k,ans=0,i,c=1;
        cin>>n>>k;
        string s,ss="";
        cin>>s;
        ss+=s[0];
        for(i=1;i<n;i++)
        {
            if(s[i]!=s[i-1])
            {
                ans+=c-1;
                c=1;
                ss+=s[i];
            }
            else
                c++;
        }
        ans+=c-1;
        //cout<<ans<<endl;
        //cout<<ss<<endl;
        ans+=2*min((int64)(ss.size()/2),k);
        cout<<min(ans,n-1);
    }

    return 0;
}

Measured memory_bytes: 592
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
    int n,k;
    cin >> n >> k;
    int index=0;
    
    int arr[10000];
    while(k--)
    {
        int s;
        
        cin >> s;
        for(int i=0;i<s;i++)
        {
            cin >> arr[index];
            index++;
        }
    }
    sort(arr,arr+index);
    
    int count=1;
    for(int i=1;i<index;i++)
    {
        if(arr[i]!=arr[i-1])
            count++;
    }
    cout << n-count;
    return 0;
}

Measured memory_bytes: 3636
MAX_DIGIT = 40

n, k = map(int, input().split())
an = list(map(int, input().split()))

digit = [1 << i for i in range(MAX_DIGIT)]

sum_d = [[0] * 2 for _ in range(MAX_DIGIT)]
for ai in an:
    for i in range(MAX_DIGIT):
        d = (ai >> i) & 1
        sum_d[i][d] += digit[i]

sum_max = [0] * MAX_DIGIT
sum_max[0] = max(sum_d[0])
for i in range(MAX_DIGIT - 1):
    sum_max[i + 1] = sum_max[i] + max(sum_d[i + 1])

dp = [-1] * MAX_DIGIT
dp[0] = sum_d[0][0 if (k & 1) == 1 else 1]
for i in range(MAX_DIGIT - 1):
    d = k >> (i + 1) & 1
    if d == 0:    # i+1 bit目が1のsum + 今までの最大
        dp[i + 1] = sum_d[i + 1][1] + dp[i]
    if d == 1:    # (i+1 bit目が0のsum + 今までの最大) or (i+1 bit目が1のsum + i bitまで任意)
        dp[i + 1] = max(sum_d[i + 1][0] + dp[i], sum_d[i + 1][1] + sum_max[i])
print(dp[-1])


Measured memory_bytes: 14620
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<queue>
#include<deque>
using namespace std;
typedef long long ll;

typedef struct Edeg {
    int to;
    int id;
} Edge;

vector<vector<Edge>> graph;
vector<int> ans;

void dfs (int now, int before = -1, int bcolor = -1) {
    int color = 1;
    for (int i = 0; i < graph[now].size(); i++) {
        int next = graph[now][i].to;
        int eid = graph[now][i].id;

        if (next == before) continue;
        if (color == bcolor) color++;

        ans[eid] = color;
        color++;
        dfs(next, now, ans[eid]);
    }
}

int main() {
    int n; cin >> n;
    graph.resize(n);
    for (int i = 0; i < n-1; i++)
    {
        int a, b; cin >> a >> b;
        a--; b--;
        graph[a].push_back((Edge){b, i});
        graph[b].push_back((Edge){a, i});
    }

    ans.resize(n-1);
    dfs(0);

    int mx = 0;
    for (int i = 0; i < n-1; i++) {
        mx = max(mx, ans[i]);
    }
    cout << mx << endl;

    for (int i = 0; i < n-1; i++) {
        cout << ans[i] << endl;
    }

     
    return 0;
}

Measured memory_bytes: 8320
#include <iostream>
#include <cstdio>
#include <iomanip>

#include <vector>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <stack>
#include <utility>

#include <numeric>
#include <algorithm>
#include <functional>

#include <cctype>

#include <complex>
#include <string>
#include <sstream>

using namespace std;

#define all(c) c.begin(),c.end()
#define rall(c) c.rbegin(),c.rend()
#define rep(i,n) for(unsigned int i=0;i<(n);i++)
#define tr(it,container) for(typeof(container.begin()) it = container.begin(); \
                             it != container.end(); ++it)
#define mp(a,b) make_pair((a),(b))

typedef long long ll;
typedef complex<double> P;
const int dx[] = {1,0,-1,0};
const int dy[] = {0,-1,0,1};
const double EPS = 1e-9;
const int days[] = {31,28,31,30,31,30,31,31,30,31,30,31};
const int daysleap[] = {31,29,31,30,31,30,31,31,30,31,30,31};

int main(){
    int n;
    cin >> n;
    rep(i,n){
        string OM;
        string ME;
        cin >> OM >> ME;
        reverse(all(OM));
        rep(j,OM.length()){
            int m = OM[j];
            switch(m){
            case 'J':
                rotate(ME.begin(),ME.end()-1,ME.end());
                break;
            case 'C':
                rotate(ME.begin(),ME.begin()+1,ME.end());
                break;
            case 'E':
                // a b c d
                if(ME.length() % 2 == 0) ME = ME.substr(ME.length()/2) + ME.substr(0,ME.length()/2);
                // a b c d e
                else ME = ME.substr(ME.length()/2+1) + ME[ME.length()/2] + ME.substr(0,ME.length()/2);
                break;
            case 'A':
                reverse(all(ME));
                break;
            case 'P':
            {
                string ret = "";
                rep(k,ME.length()){
                    if('0' <= ME[k] and ME[k] <= '9'){
                        if(ME[k] == '0') ret += '9';
                        else ret += ME[k]-1;
                    }else{
                        ret += ME[k];
                    }
                }
                ME = ret;
            }
            break;
            case 'M':
            {
                string ret = "";
                rep(k,ME.length()){
                    if('0' <= ME[k] and ME[k] <= '9'){
                        if(ME[k] == '9') ret += '0';
                        else ret += ME[k]+1;
                    }else{
                        ret += ME[k];
                    }
                }
                ME = ret;
            }
            }

        }
        cout << ME << endl;
    }
    return 0;
}

Measured memory_bytes: 1232
a = gets.to_i
b = gets.to_i
c = gets.to_i
x = gets.to_i

count = 0

(0..a).each do |i|
    (0..b).each do |j|
        (0..c).each do |k|
            count = count.succ if i * 500 + j * 100 + k * 50 == x
        end
    end
end

puts count

Measured memory_bytes: 3836
import java.io.*;
import java.util.*;
public class Main {
    public static void main(String[] args) throws IOException{
        Scanner sc = new Scanner(System.in);
        int N =sc.nextInt();
        ArrayList<Integer> List = new ArrayList<>();
        int max=0,max2 =0;
        for(int i=0;i<N;i++) {
            int num = sc.nextInt();
            List.add(num);
            if(max<num) max=num;
            else if(max==num) max2=num;
            else if(max>num&&max2<=num) max2 =num;
        }
        for(int i=0;i<N;i++){
            if(List.get(i)==max)System.out.println(max2);
            else System.out.println(max);
        }
    }
}

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

public class Main {
 
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();       
        sc.close();
        
        if (s.equals("ABC")) {
            System.out.println("ARC");   
        } else {
            System.out.println("ABC");   
        }
    }
}

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

using ll = long long;

const int INF = 1001001001;
const ll INF_LL = 1001001001001001001LL;

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

  if(a>=3200) cout << s << endl;
  else cout << "red" << endl;
  
  return 0;
}


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

using namespace std;

int n,bl[100100],sign=0;
char as[100100];
bool check()
{
	for(int i=1;i<=n;i++)
	{
		int pr=(i-1)? i-1:n,nx=(i==n)? 1:i+1; 
		if(bl[i]==1)
		{
			if(as[i]=='o')
			{
				if(bl[pr]&&bl[nx])
					if(bl[pr]!=bl[nx]) return 0;
				if(bl[pr]) bl[nx]=bl[pr];
				else bl[pr]=bl[nx];
			}	
			else
			{
				if(bl[pr]&&bl[nx])
					if(bl[pr]==bl[nx]) return 0;
				if(bl[pr]) bl[nx]=-bl[pr];
				else bl[pr]=-bl[nx];
			}
		}
		else
		{
			if(as[i]=='o')
			{
				if(bl[pr]&&bl[nx])
					if(bl[pr]==bl[nx]) return 0;
				if(bl[pr]) bl[nx]=-bl[pr];
				else bl[pr]=-bl[nx];
			}
			else
			{
				if(bl[pr]&&bl[nx])
					if(bl[pr]!=bl[nx]) return 0;
				if(bl[pr]) bl[nx]=bl[pr];
				else bl[pr]=bl[nx];
			}
		}
	}
	return 1;
}
int main()
{
	scanf("%d",&n);
	scanf("%s",as+1);
	for(int i=0;i<4;i++)
	{
		memset(bl,0,sizeof bl);
		bl[1]=(i&1)? 1:-1;
		bl[2]=(i&2)? 1:-1;
		if(check()){ sign=1; break; }
	}
	if(sign){ for(int i=1;i<=n;i++) printf((bl[i]==-1)? "W":"S");}
	if(!sign) printf("-1\n");
	printf("\n");
	return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define FOR(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
using namespace std;

// Binary Indexed Tree
template <class T> struct BIT {
    vector<T> d;
    BIT(int n) { init(n); }
    void init(int n) { d.assign(n + 1, 0); }
    // a: 1-indexed
    inline void add(int a, T x) {
        for (int i = a; i < (int)d.size(); i += i & -i) d[i] = d[i] + x;
    }
    // [1, a]
    // a: 1-indexed
    inline T sum(int a) {
        T res = 0;
        for (int i = a; i > 0; i -= i & -i) res = res + d[i];
        return res;
    }
    // [a, b)
    // a, b: 1-indexed
    inline T sum(int a, int b) {
        return sum(b - 1) - sum(a - 1);
    }
};

void _main() {
    int N, Q;
    string S;
    cin >> N >> S >> Q;
    vector<BIT<int>> bit(26, BIT<int>(N));
    REP (i, S.size()) bit[S[i] - 'a'].add(i + 1, 1);
    REP (_, Q) {
        int com;
        cin >> com;
        if (com == 1) {
            int i;
            char c;
            cin >> i >> c;
            bit[c - 'a'].add(i, 1);
            bit[S[i - 1] - 'a'].add(i, -1);
            S[i - 1] = c;
        } else {
            int l, r;
            cin >> l >> r;
            int ans = 0;
            REP (i, 26) ans += (bit[i].sum(l, r + 1) > 0);
            cout << ans << endl;
        }
    }
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    _main();
    return 0;
}

Measured memory_bytes: 106396
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        System.out.println((S.substring(0,1).equals(S.substring(1,2)) && S.substring(1,2).equals(S.substring(2,3))) ? "No" : "Yes");
    }
}

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


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

    if (4*a*b<(c-a-b)*(c-a-b) and c-a-b>0) cout << "Yes\n" ;
    else cout << "No\n" ;

    return 0 ;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;cin>>n;
    int brick=0,noofbrick=1;
    for(int i=1;i<=n;i++)
    {
        int x;cin>>x;
        if(x==noofbrick)
        {
        noofbrick++;}
        else
        {
            brick++;
        }
    }
    if(brick<n)
        cout<<brick<<endl;
    else
        cout<<"-1\n";
}


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

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

//INSERT ABOVE HERE
signed main(){
  Int n,g;
  cin>>n>>g;
  vector<Int> p(n),c(n);
  for(Int i=0;i<n;i++) cin>>p[i]>>c[i];

  Int ans=0;
  for(Int i=0;i<n;i++) ans+=p[i];

  for(Int b=0;b<(1<<n);b++){
    Int res=0,sum=0;
    for(Int i=0;i<n;i++){
      if((b>>i)&1){
	res+=p[i];
	sum+=p[i]*100*(i+1)+c[i];
      }      
    }
    //cout<<res<<" "<<sum<<endl;
    for(Int i=n-1;i>=0;i--){
      if((b>>i)&1) continue;
      Int x=p[i];
      chmin(x,(g-sum+100*(i+1)-1)/(100*(i+1)));
      chmax(x,0);
      res+=x;
      sum+=x*100*(i+1);
    }
    //cout<<res<<" "<<sum<<endl;
    if(sum>=g) chmin(ans,res);
  }
  
  cout<<ans<<endl;
  return 0;
}


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

// ----------- define --------------
#define int long long
#define vi vector<int>
#define ii pair<int,int>
#define fi first
#define sc second
#define stoi stoll
#define popcnt __builtin_popcount
#define getBit(x, k) ((x >> k) & 1)
#define all(x) (x).begin(),(x).end()
// ---------------------------------

void Main() {
  int n, m, l;
  cin >> n >> m >> l;
  vector<int> a(l);
  for (auto &i : a) cin >> i;
  int p = 0;
  vector<vi> res(n + 1, vi(m + 1));
  for (int i = 1; i <= n; i++) {
    if (i % 2) {
      for (int j = 1; j <= m; j++) {
        if (!a[p]) p++;
        a[p]--;
        res[i][j] = p + 1;
      }
    }
    else {
      for (int j = m; j >= 1; j--) {
        if (!a[p]) p++;
        a[p]--;
        res[i][j] = p + 1;
      }
    }
  }
  for (int i = 1; i <= n; i++)
  for (int j = 1; j <= m; j++) {
    cout << res[i][j] << " \n"[j == m];
  }
}

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
  cerr << "- ---- -- ----- <3\n";
#endif
  cin.tie(0)->sync_with_stdio(0);
  int T = 1;
  // cin >> T;
  while (T--) Main();
}


Measured memory_bytes: 3744
n = int(input())
ws = sorted([[int(i) for i in input().split()] for _ in range(n)], key=lambda x: -x[1])
t = ws[0][1]
for w in ws:
	if t > w[1]:
		t = w[1] - w[0]
	else:
		t -= w[0]
print('Yes' if t >= 0 else 'No')

Measured memory_bytes: 48988
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O3")
#pragma GCC target("sse4")
#define hash dalsklkdsakls
typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;
#define MP make_pair
#define PB push_back
#define pow2 ansdasdnml
#define X first
#define Y second

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define ITER(it, a) for(__typeof(a.begin()) it = a.begin(); it != a.end(); ++it)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())
#define FILL(a, value) memset(a, value, sizeof(a))

const double PI = acos(-1.0);
int mod = 998244353;
const LL INF = 1e9 + 47;
const LL LINF = INF * INF;
int N;
int a[10000];
int x;
int main()
{
	cin >> N >> x;
	for(int i = 0; i < N; i++)
		cin >> a[i];
	sort(a , a + N);
	//cin >> x;
	int ptr = 0;
	while(a[ptr] <= x && ptr != N)
	{
		x -= a[ptr];
		ptr++;
	}
	if(x && ptr == N)
	{
		ptr--;
	}
	cout << max(ptr , 0);

	//ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//freopen("In.txt" , "r" , stdin);
	//cout << ans;
	//freopen("basis.in", "r", stdin);
	//freopen("basis.out", "w", stdout);
	//cout << binSearch(q[i] , q[i + 1]) << endl;
	return 0;
}


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

int a,b,c,d,e;

int main()
{
    bool j=0;
    cin>>a>>b;
    if(b%2) j=1;
    if(2*a>b||4*a<b) j=1;
    if(j==1) cout<<"No";
    else cout<<"Yes";

    return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fast() ios_base::sync_with_stdio(0),cin.tie(0)
int32_t main()
{int n,i;
 cin>>n;
 vector<int> a(n),b(n),c(n);
 vector<vector<int>> dp(n,vector<int> (3));
 for(i=0;i<n;++i)
 cin>>a[i]>>b[i]>>c[i];
 dp[0][0]=a[0];
 dp[0][1]=b[0];
 dp[0][2]=c[0];
 for(i=1;i<n;++i)
 {dp[i][0]=a[i]+max(dp[i-1][1],dp[i-1][2]);
  dp[i][1]=b[i]+max(dp[i-1][0],dp[i-1][2]);
  dp[i][2]=c[i]+max(dp[i-1][0],dp[i-1][1]);
 }
 //for(i=0;i<n;++i)
 //{for(int j=0;j<3;++j)
 // cout<<dp[i][j]<<" ";
 // cout<<"\n";
 //}
 cout<<max({dp[n-1][0],dp[n-1][1],dp[i-1][2]});
 return 0;
}





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

using namespace std;
using ll = long long;
using ld = long double;

//#define int long long
//signed main(){
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    ll a[n];
    bool zero=false;
    for(int i = 0; i < n; i++) {
        cin >> a[i];
        if(a[i]==0) zero=true;
    }
    if(zero){
        cout << "0" << "\n";
        return 0;
    }
    else{
        ll ans=1;
        for(int i = 0; i < n; i++) {
            if(a[i]>1000000000000000000/ans){
                cout << "-1" << "\n";
                return 0;
            }
            else ans*=a[i];
        }
        cout << ans << "\n";
        return 0;
    }
}

Measured memory_bytes: 4448
#coding:utf-8
n = int(input())
blue = []
plus = []
for i in range(n):
    s = input()
    if s in blue:
        plus[blue.index(s)] += 1
    else:
        blue.append(s)
        plus.append(1)
m = int(input())
for i in range(m):
    s = input()
    if s in blue:
        plus[blue.index(s)] -= 1
    else:
        blue.append(s)
        plus.append(-1)
print(max(0, max(plus)))

Measured memory_bytes: 3064
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <utility>
#include <queue>
#include <stack>
#include <set>
#include <map>

using namespace std ; 

typedef long long ll ; 

int main()
{
    ll A, B, C ; 
    scanf("%lld%lld%lld", &A, &B, &C) ; 
    if(A%2 == 0 || B%2 == 0 || C%2 == 0)
        puts("0") ; 
    else
        printf("%lld\n", min(A*B, min(B*C, A*C))) ; 
    return 0 ; 
}


Measured memory_bytes: 128
#include<iostream>
#define int long long

using namespace std;

signed main(){
    int n;
    cin>>n;
    int sum = 0;
    for(int i=1;i<=n;i++){
        if(i%3!=0 && i%5!=0){
            sum += i;
        }
    }
    cout<<sum;
}


Measured memory_bytes: 3188
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <deque>
#include <cctype>
#include <cstdio>
#include <math.h>
#include <set>
using namespace std;
using ll = long long;
int main(){
    ll n;
    cin >> n;
    vector<ll> a(n);
    vector<ll> b(n);
    ll ans =0;
    ll cnt = 0;
    vector<ll> c(n);
    for(ll i=0;i<n;i++){
        cin >> a[i];
    }
    for(ll i=0;i<n;i++){
        cin >> b[i];
        if(a[i]<b[i]){
            ans++;
            cnt+=abs(a[i]-b[i]);
        }
        c[i]=a[i]-b[i];
    }
    sort(c.begin(),c.end());
    reverse(c.begin(),c.end());
    if(cnt>0){
        for(ll i=0;i<n;i++){
        cnt-=c[i];
        ans++;
        if(cnt<=0){
            break;
        }
        
    }
    }
    
    if(cnt>0){
        cout << -1 << endl;
    }else{
        cout << ans << endl;
    }
}

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

using namespace std;

long d[3333];
int main() {
	int n, p = 1e9 + 7;
	string s;
	cin >> n >> s;
	d[n - 1] = 1;
	for (int i = n; --i;) {
		for (int j = i - 1; j < n; j++) {
			if (s[n - i - 1] == '>')
				d[j] = d[n - 1] - d[j];
			d[j] %= p;
		}
		partial_sum(d, d + n, d);
	}
	cout << d[n - 1] % p << endl;
	return 0;
}


Measured memory_bytes: 256