akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
LL N;
string str;
int main()
{
    cin >> N;
    LL A[2][1001];
    LL ans = 0;
    for(int a = 0;a < 2;a++){
        for(int b = 0;b < N;b++){
            cin >>A[a][b];
       }
    }
    for(int a = 0;a < N;a++){
        LL ins = 0;
        for(int b = 0;b < N;b++){
            if(a < b){
                ins += A[1][b];
                //cout<<"- "<<ins<<endl;
            }else
            if(a==b){
                ins += A[0][b];
                //cout<<ins<<" ";
                ins += A[1][b];
                //cout<<ins<<endl;
            }else
            if(a > b){
                ins += A[0][b];
                //cout<<ins<<" -"<<endl;
            }
        }
        //cout<<ins<<endl;
        ans = max(ins,ans);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
import math
def chk(X):
    for i in range(2,int(math.sqrt(X))+1):
        if X % i == 0:
            return False
    return True
def main():
    X = int(input())
    for i in range(X, 100005):
        if chk(i):
            print(i)
            return
main()


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

int main() {
    int n;
    cin>>n;
    int i = 1;
    while(i<=n){
        int x = i;
        if(x%3==0){
            printf(" %d", i);
        }else{
            while(x){
                if(x%10==3){
                    printf(" %d", i);
                    break;
                }
                x/=10;
            }
        }
        i++;
    }
    printf("\n");
    return 0;
    
   
}



Measured memory_bytes: 3208
s=input()
t=input()
ss=[0]
for i in range(len(s)):
    ss.append(ss[i] + (1 if s[i] == 'A' else 2))
tt=[0]
for i in range(len(t)):
    tt.append(tt[i] + (1 if t[i] == 'A' else 2))
q=int(input())
for _ in range(q):
    a,b,c,d=map(int,input().split())
    x = (ss[b]-ss[a-1]) % 3
    y = (tt[d]-tt[c-1]) % 3
    print('YES' if x == y else 'NO')

Measured memory_bytes: 11588
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <iomanip>
#include <map>
using namespace std;

int main() {
    int n;
    int ans = 0;
    cin >> n;
    vector<int> l(n);
    vector<int> r(n);
    for (int i = 0; i < n; i++) {
        cin >> l.at(i) >> r.at(i);
        ans += r.at(i) - l.at(i) + 1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#pragma region template 2.4
#include <bits/stdc++.h>
using namespace std;
template <typename T>
using pq_asc = priority_queue<T, vector<T>, greater<T>>;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP1(i, n) for (ll i = 1; i <= (n); ++i)
#define FOR(i, a) for (auto &i : a)
#define CH(f, x, y) x = f(x, y)
#define IN(T, x) \
    T x;         \
    cin >> x;
#define AIN(T, a, n) \
    vector<T> a(n);  \
    FOR(i, a)        \
    cin >> i;
#define A2IN(T1, a, T2, b, n) \
    vector<T1> a(n);          \
    vector<T2> b(n);          \
    REP(i, n)                 \
    cin >> a[i] >> b[i];
#define OUT(x) cout << (x) << endl;
#define FOUT(x) cout << fixed << setprecision(15) << (x) << endl;
#define ALL(a) (a).begin(), (a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) \
    SORT(a);     \
    reverse(ALL(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define DUMPA(a)          \
    cout << #a << " = {"; \
    JOUT(ALL(a), ", ", cout) << "}" << endl;

template <typename T>
ostream &JOUT(T s, T e, string sep = " ", ostream &os = cout)
{
    if (s != e)
    {
        os << *s;
        ++s;
    }
    while (s != e)
    {
        os << sep << *s;
        ++s;
    }
    return os;
}

ostream &YES(bool cond, string yes = "Yes", string no = "No", ostream &os = cout)
{
    if (cond)
    {
        os << yes << endl;
    }
    else
    {
        os << no << endl;
    }
    return os;
}

template <typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p)
{
    os << '(' << p.first << ", " << p.second << ')';
    return os;
}

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
    os << '[';
    JOUT(ALL(v), ", ", os) << ']';
    return os;
}

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#pragma endregion template

int main()
{
    IN(ll, N);
    IN(ll, A);
    AIN(ll, x, N);
    REP(i, N)
    {
        x[i] -= A;
    }
    ll M = 50;
    vvi dp(N + 1, vi(2 * M * N + 1));
    dp[0][M * N] = 1;
    REP(i, N)
    {
        for (ll j = 2 * M * N; j >= 0; --j)
        {
            dp[i + 1][j] = dp[i][j];
            ll k = j - x[i];
            if (0 <= k and k <= 2 * M * N)
            {
                dp[i + 1][j] += dp[i][k];
            }
        }
    }
    OUT(dp[N][M * N] - 1);
}

Measured memory_bytes: 5264
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
			    Scanner sc = new Scanner(System.in);
			    String s = sc.next();
			    List<String> week = Arrays.asList("SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT");
			    System.out.println(7 - week.indexOf(s));
			    sc.close();
			  }

			}


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

#define rep(i, a, n)  for(ll i=a; i<n; i++)
#define per(i, a, n)  for(ll i=n-1; i>=a; i--)
#define fill0(n)  setfill('0') << right << setw(n)
#define all(x)  (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define LONGMAX 1e18
#define intMAX 1000000000
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod = 1e9+7;

int a, b, c;

int main(){
	cin >> a >> b >> c;
	int ans = max(b+c-a, 0);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		long N = sc.nextLong();
		long M = sc.nextLong();
		long ans = Math.min(N, M/2);
		N -= ans;
		M -= ans*2;
		ans += M/4;
		
		System.out.println(ans);
		sc.close();
	}
}


Measured memory_bytes: 23632
#include <cstdio>

using namespace std;
const int M = 1000000007;

int main()
{
    int n;
    scanf("%d", &n);

    int c[100000] = {};
    for (int i = 0; i < n; ++i) {
        int a;
        scanf("%d", &a);
        c[a] += 1;
    }

    bool f = true;
    for (int i = n - 1; i > 0; i -= 2)
        f = f && (c[i] == 2);
    for (int i = n - 2; i > 0; i -= 2)
        f = f && (c[i] == 0);
    if (n % 2 == 0)
        f = f && (c[0] == 0) && (c[1] == 2);
    else if (n > 1)
        f = f && (c[0] == 1) && (c[1] == 0);
    else // n == 1
        f = f && (c[0] == 1);

    if (!f) {
        printf("0\n");
        return 0;
    }

    int ans = 1;
    for (int i = 0; i < n / 2; ++i)
        ans = (ans * 2) % M;
    printf("%d\n", ans);

    return 0;
}


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

using namespace std;

#define rep(i, a, b)  for(int i = (a); i < (b); i++)
#define rrep(i, a, b) for(int i = (a); i > (b); i--)
#define sq(x) ((x) * (x))
#define bit(x) bitset<32>(x)
#define vsort(v)  sort(v.begin(), v.end())
#define rvsort(v) sort(v.begin(), v.end(), greater<llint>())
#define debug(x) cout << #x << " " << (x) << endl
#define ci cin
#define co cout
#define en endl
#define ln cout<< '\n'
#define pb push_back
#define fi first
#define se second
#define MOD 1000000007

typedef long long int llint;
typedef pair<int, int> pii;
typedef pair<llint, llint> pll;
typedef vector<int> vi;
typedef vector<llint> vl;
typedef vector<pii> vii;
typedef vector<pll> vll;


template<typename Tn> Tn __lcm(Tn a, Tn b)
{
    return a / __gcd(a, b) * b;
}

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

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

    int cnt = 0;
    for(int i = 0; i < s.size(); i++) if(s[i] == 'o') cnt++;
    
    if(cnt + 15 - s.size()>= 8) co << "YES" << en;
    else co << "NO" << en;
    
    return 0;
}


Measured memory_bytes: 256
using System;
using System.IO;
using System.Linq;
using System.Runtime;
using System.Reflection;
using System.Diagnostics;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using System.Text;
using System.Text.RegularExpressions;
using static System.Math;

class P
{
    static void Main()
    {
        int[] abc = Console.ReadLine().Split().Select(int.Parse).ToArray();
        Console.WriteLine(abc.Max() * 9 + abc.Sum());
    }
}


Measured memory_bytes: 13396
#include <iostream>
#include <algorithm>
#include <string>
#include <functional>
#include <math.h>
#include <map>
#include <vector>
using namespace std;

int main() {
	int a, b;
	cin >> a >> b;
	int ans = 0;
	for (int i = a; i <= b; i++) {
		int i1 = i % 10;
		int i2 = ((i - i1) / 10) % 10;
		int i3 = ((((i - i1) / 10) - i2) / 10) % 10;
		int i4 = ((((((i - i1) / 10) - i2) / 10) - i3) / 10) % 10;
		int i5 = ((((((((i - i1) / 10) - i2) / 10) - i3) / 10) - i4) / 10) % 10;
		if (i1 == i5&&i2 == i4) {
			ans++;
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int S,h,m,s;
	
	scanf("%d",&S);
	
	h=S/3600;
	m=(S%3600)/60;
	s=(S%60);
	
	printf("%d:%d:%d\n",h,m,s);
	
	return 0;
}


Measured memory_bytes: 2056
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
using namespace std;

int main() {
    const long long int mod = 1000000007;
	map<long long int, long long int>mp;
	cout << fixed << setprecision(10);
    string str[120];
    
    long long int h,w,num[200]={},modfour[5]={};
    cin>>h>>w;
    for(int i=0;i<h;i++){
        cin>>str[i];
    }
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            num[str[i][j]]++;
        }
    }
    for(int i='a';i<='z';i++){
        modfour[num[i]%4]++;
    }

    if(h==1&&w==1){
        cout<<"Yes"<<endl;
        return 0;
    }else if((h==1||w==1)&&(h*w)%2==0&&modfour[1]==0&&modfour[3]==0&&modfour[2]%2==(h*w)%4/2){
        cout<<"Yes"<<endl;
        return 0;
    }else if((h==1||w==1)&&(h*w)%2==1&&(modfour[1]+modfour[3])==1&&modfour[2]%2==(h*w-1)%4/2){
        cout<<"Yes"<<endl;
        return 0;
    }else if(h%2==0&&w%2==0&&modfour[1]==0&&modfour[2]==0&&modfour[3]==0){
        cout<<"Yes"<<endl;
        return 0;
    }else if(h%2==1&&w%2==0&&modfour[1]==0&&modfour[3]==0&&modfour[2]<=w/2&&modfour[2]%2==w%4/2){
        cout<<"Yes"<<endl;
        return 0;

    }else if(w%2==1&&h%2==0&&modfour[1]==0&&modfour[3]==0&&modfour[2]<=h/2&&modfour[2]%2==h%4/2){
        cout<<"Yes"<<endl;
        return 0;
    }else if(h%2==1&&w%2==1&&(modfour[1]+modfour[3]==1)&&(modfour[3]+modfour[2])<=(w/2+h/2)&&(modfour[3]+modfour[2])%2==((w-1)+(h-1))%4/2){
        cout<<"Yes"<<endl;
        return 0;
    }else{
        cout<<"No"<<endl;
        return 0;
    }
} 


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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#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 repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

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

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


Measured memory_bytes: 3668
mod=10**9+7
S=input()
N=len(S)
Acnt=[[0,0] for i in range(N+2)]
Ccnt=[[0,0] for i in range(N+2)]
for i in range(N):
    Acnt[i+1]=Acnt[i].copy()
    Ccnt[-i-2]=Ccnt[-i-1].copy()
    if S[i]=="A":
        Acnt[i+1][0]+=1
    if S[i]=="?":
        Acnt[i+1][1]+=1
    if S[-i-1]=="C":
        Ccnt[-i-2][0]+=1
    if S[-i-1]=="?":
        Ccnt[-i-2][1]+=1
Acnt[N+1]=Acnt[N]
Ccnt[-N-2]=Ccnt[-N-1]
ans=0
ruijo=[1]*(N+1)
for i in range(N):
    ruijo[i+1]=ruijo[i]*3%mod
ruijo.append(0)
for i in range(N):
    if S[i]=="B" or S[i]=="?":
        a,b,c,d=0,0,0,0
        a=Acnt[i][0]*Ccnt[i+2][0]*ruijo[Acnt[i][1]+Ccnt[i+2][1]]%mod
        if Ccnt[i+2][1]>0:
            b=Acnt[i][0]*Ccnt[i+2][1]*ruijo[Acnt[i][1]+Ccnt[i+2][1]-1]%mod
        if Acnt[i][1]>0:
            c=Acnt[i][1]*Ccnt[i+2][0]*ruijo[Acnt[i][1]+Ccnt[i+2][1]-1]%mod
        if Acnt[i][1]>0 and Ccnt[i+2][1]>0:
            d=Acnt[i][1]*Ccnt[i+2][1]*ruijo[Acnt[i][1]+Ccnt[i+2][1]-2]%mod
        ans=(ans+a+b+c+d)%mod
print(ans)

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


#define f(i,a,b) for(int i=(int)(a);i<=(int)(b);i++)
#define char_f(i,a) for(int i=(int)(a);(char)s[i]!='\0';i++)
#define rf(i,a,b) for(int i=(int)(a);i>=(int)(b);i--)
#define llf(i,a,b) for(long long int i=(long long int)(a);i<=(long long int)(b);i++)
#define llrf(i,a,b) for(long long int i=(long long int)(a);i>=(long long int)(b);i--)



#define ll long long
#define fi first
#define se second
#define pb push_back
#define pop pop_back
#define mem(ara) memset((ara),0,sizeof(ara))
#define memn(ara) memset((ara),-1,sizeof(ara))
#define bb begin()
#define ee end()
#define em emplace
#define eb emplace_back





#define si set<int>
#define sd set<double>
#define sll set<long long int>
#define ss set<string>
#define sc set<char>

#define pii pair<int,int>
#define pli pair<long long int,int>
#define pil pair<int,long long int>
#define pll pair<long long int,long long int>
#define pci pair<char,int>
#define pic pair<int,char>
#define pcl pair<char,long long int>
#define plc pair<long long int,char>

#define pss pair<string,string>
#define pcc pair<char,char>

#define pis pair<int,string>
#define psi pair<string,int>
#define pls pair<long long int,string>
#define psl pair<string,long long int>
#define pdd pair<double,double>
#define pcs pair<char,string>
#define psc pair<string,char>



#define vi  vector<int>
#define vll vector<long long int>
#define vd vector<double>
#define vs vector<string>
#define vc vector<char>
#define vii vector<pii>



#define mod 1000000007
#define mx (1<<30)-1
#define llmx (1ll<<62)
#define n_size 100005
#define g_size 10000005
double PI=acos(-1);



///unsigned int uMAX=4294967295;
///unsigned ll int ullMAX=18446744073709551615;





int arr[g_size],arr2[g_size];



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

	int n,m,T,res;

	int maxi=-mx,mini=mx,count=0;

	int i,j,k;

	bool flag;

	string s1,s2;

	char s[100000];

	int ara[n_size],ara2[n_size];

    arr[1]=1;
    arr[3]=1;
    arr[5]=1;
    arr[7]=1;
    arr[8]=1;
    arr[10]=1;
    arr[12]=1;

	arr2[4]=1;
	arr2[6]=1;
	arr2[9]=1;
	arr2[11]=1;

	cin>>n>>m;

	if(arr[n]==1 && arr[m]==1) cout<<"Yes"<<endl;
	else if(arr2[n]==1 && arr2[m]==1) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;

}


Measured memory_bytes: 2304
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; 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());

using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

ll mod = 1e9 + 7;

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

  ll h, w;
  cin >> h >> w;
  string s;
  REP(i, h){
    REP(j, w){
      cin >> s;
      if(s == "snuke"){
        cout << char('A' + j) << i + 1 << endl;
        return 0;
      }
    }
  }
}


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

using namespace std;
using ll = long long;
using ull = unsigned long long;

typedef pair<int, int>pi;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
typedef pair<P, P> PPP;

const ll MOD = 1e9 + 7;
const ll INF = 9e18;
const double DINF = 5e14;
const double eps = 1e-10;
const int di[4] = { 1,0,-1,0 }, dj[4] = { 0,1,0,-1 };

#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define pb push_back
#define eb emplace_back
#define fr first
#define sc second

int a, b, c;

int main() {
	cin >> a >> b >> c;
	cout << a + b + c << endl;
	return 0;
}


Measured memory_bytes: 3088
#include<stdio.h>
#include<queue>
#include<assert.h>
#include<tuple>
#include<string>
#include<algorithm>
#include<iostream>
#include<map>
#include<string.h>
#include<vector>
#include<math.h>
#include<stdlib.h>
#include<set>
#include<ctype.h>
using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef tuple<int,int,int> t3;

const int MX = 100005;
const int MM = 1000000007;

vector<int> G[MX];

int gcd(int a, int b){
	return b ? gcd(b, a%b) : a;
}

int D[MX], cnt[MX], vst[MX];

void dfs(int x, vector<int> &L){
	vst[x] = 1;
	sort(G[x].begin(), G[x].end());
	for(int c : G[x]){
		if( vst[c] ) continue;
		vector<int> t, u;
		dfs(c, t);
		std::merge(t.begin(), t.end(), L.begin(), L.end(), std::back_inserter(u), greater<int>());
		swap(u, L);
	}
	L.insert(L.begin(), x);
}

int main()
{
	int N;
	scanf("%d", &N);
	for(int i = 1; i <= N; i++) scanf("%d", D+i);
	sort(D+1, D+N+1);
	for(int i = 1; i <= N; i++){
		for(int j = i+1; j <= N; j++){
			if( gcd(D[i], D[j]) != 1 ){
				G[i].push_back(j);
				G[j].push_back(i);
			}
		}
	}
	for(int i = 1; i <= N; i++){
		G[i].push_back(0);
		G[0].push_back(i);
	}
	vector<int> L;
	dfs(0, L);
	for(int i = 1; i < L.size(); i++) printf("%d ", D[L[i]]);
	printf("\n");
}


Measured memory_bytes: 20224
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define int ll
#define double long double
#define YES cout<<"YES"<<'\n'
#define NO cout<<"NO"<<'\n'
#define Yes cout<<"Yes"<<'\n'
#define No cout<<"No"<<'\n'
#define yes cout<<"yes"<<'\n'
#define no cout<<"no"<<'\n'
void YN(bool flg) {cout<<(flg?"YES":"NO")<<'\n';}
void Yn(bool flg) {cout<<(flg?"Yes":"No")<<'\n';}
void yn(bool flg) {cout<<(flg?"yes":"no")<<'\n';}
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
#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 out(n) cout << n << '\n'
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<VI> VVI;
const int MOD = 1000000007;
const long long INF = 10e10;
const double PI = acos(-1.0);
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; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }
int POW(int a, int n) { int r = 1; while (n > 0) { if (n & 1)r *= a; a *= a; n >>= 1; }return r; }
int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*素因数分解*/map< int, int >prime_factor(int n){map< int, int > ret;for(int i = 2; i * i <= n; i++) {while(n % i == 0) {ret[i]++;n /= i;}}if(n != 1) ret[n] = 1;return ret;}
/*約数列挙*/vector<int> divisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------ライブラリとか----------------

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

    string s; cin >> s;
    REP(al,26){
        bool ok = 1;
        REP(i,s.size()){
            if(s[i]==char('a'+al)) ok = 0;
        }
        if(ok){out(char('a'+al)); return 0;}
    }
    out("None");

    return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<string>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= (int)end; --i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return 0;}
template<typename T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return 0;}

ll f(ll A, ll M) {
    return (A * A) % M;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, X, M;
    cin >> N >> X >> M;
    vector<bool> visited(M, false);
    --N;
    ll ans = X;
    // ループを求める
    ll A = f(X, M);
    while (!visited[A]) {
        visited[A] = true;
        A = f(A, M);
    }
    // Aまでの値を足す
    X = f(X, M);
    while (X != A) {
        if (N) {
            ans += X;
            --N;
        } else {
            cout << ans << endl;
            return 0;
        }
        X = f(X, M);
    }
    // ループ長と総和を求める
    ll len = 0;
    ll sum = 0;
    do {
        ++len;
        sum += X;
        X = f(X, M);
    } while (X != A);
    ans += sum * (N / len);
    N %= len;
    rep(i, 0, N) {
        ans += X;
        X = f(X, M);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define MAX_INF 0x7f
#define MAX_INF_VAL 0x7f7f7f7f
#define pi 3.141592653589
#define eps 1e-10
//#define p 2173412051LL
#define sz 2

using namespace std;

int main() {
	ll x, ans = 0, y = 1;
	scanf( "%lld", &x );
	while( y <= x ) {
		ans += y;
		y <<= 1;
	}
	printf( "%lld", ans );
	return 0;
}

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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

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

    int d[n];
    rep(i, n) cin >> d[i];

    ll ans = 0;

    rep(i, n)
    {
        for (int j = i + 1; j < n; j++)
        {
            ans += d[i] * d[j];
        }
    }

    OP(ans);

    return 0;
}

Measured memory_bytes: 256
#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 <iomanip>
#include <limits>
using namespace std;
// 素因数分解
typedef pair<long long, long long> P;
vector<P> prime_factorize(long long n)
{
vector<P> res;
for (long long p = 2; p * p <= n; ++p)
{
if (n % p != 0)
continue;
int num = 0;
while (n % p == 0)
{
++num;
n /= p;
}
res.push_back(make_pair(p, num));
}
if (n != 1)
res.push_back(make_pair(n, 1));
return res;
}
// 因数分解
long long gcd(long long x, long long y)
{
  if (y == 0)
  {
    return x;
  }
  else
  {
    return gcd(y, x % y);
  }
}
const int MOD = 1000000007;
typedef long long int ll;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i, n) for (int i = 0; i < (n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main()
{
    ll n, k;
    cin >> n >> k;
    vector<ll> H(n);
    rep(i,n){
        cin >> H[i];
    }
    sort(H.begin(),H.end());
    for (ll i = 0; i < k&&i<=n-1;i++){
        H[n-1-i] = 0;
    }
    ll ans = 0;
    rep(i,n){
        ans += H[i];
    }
    cout << ans << endl;

    return 0;
}

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

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

    int t[n];

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

    int m;
    cin >> m;

    for(int i=0;i<m;i++){
        int p,x;
        cin >> p >> x;
        int sum=0;
        for(int i=0;i<n;i++){
            if(i == p-1){
                sum += x;
            }else{
                sum += t[i];
            }
        }
        cout << sum << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>

using namespace std;
long long cnt;
int A[1000005];
vector<int> G;
void insertionSort(int A[], int n, int g);
void shellSort(int A[], int n);

int main()
{
  int n;
  cin >> n;
  for (int i = 0; i < n; i++)
  {
    scanf("%d", &A[i]);
  }
  cnt = 0;
  shellSort(A, n);
  cout << G.size() << endl;
  for (int i = G.size() - 1; i >= 0; i--)
  {
    printf("%d", G[i]);
    if (i)
    {
      printf(" ");
    }
  }
  printf("\n");
  printf("%lld\n", cnt);
  for (int i = 0; i < n; i++)
  {
    printf("%d\n", A[i]);
  }
  return 0;
}

void insertionSort(int A[], int n, int g)
{
  for (int i = g; i < n; i++)
  {
    int v = A[i];
    int j = i - g;
    while (j >= 0 && A[j] > v)
    {
      A[j + g] = A[j];
      j -= g;
      cnt++;
    }
    A[j + g] = v;
  }
}

void shellSort(int A[], int n)
{
  for (int h = 1;;)
  {
    if (h > n)
    {
      break;
    }
    G.push_back(h);
    h = 3 * h + 1;
  }

  for (int i = G.size() - 1; i >= 0; i--)
  {
    insertionSort(A, n, G[i]);
  }
}



Measured memory_bytes: 7180
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdlib>
#include<bitset>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<queue>
#include<map>

using namespace std;

int read()
{
	int ans=0,f=1;
	char c=getchar();
	while(c>'9'||c<'0'){if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9'){ans=ans*10+c-'0';c=getchar();}
	return ans*f;
}

int main()
{
	if(read()>=30)
		printf("Yes\n");
	else printf("No\n");
	return 0;
} 

Measured memory_bytes: 3620
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
	int n, d;
	string s;
	cin >> n >> s >> d;
	string t(s);
	for(int i = 0; i < n; ++i){
		if(d > 0 && s[i] == '0'){
			t[i] = '1';
			--d;
		}
	}
	for(int i = n - 1; i >= 0; --i){
		if(d > 0 && s[i] == '1' && t[i] == '1'){
			t[i] = '0';
			--d;
		}
	}
	cout << t << endl;
	return 0;
}

Measured memory_bytes: 1208
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(int i = 0; i < x; i++)
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
const ll MOD = 1e9+7;
const int n_max = 1e5+10;

int main(){
    int a,b; cin >> a >> b;
    int ans;
    if(a < 10 && b < 10)ans = a * b;
    else ans = -1;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
package main

import(
    "fmt"
    "strings"
)



func main() {
    var s string
    fmt.Scan(&s)
    ans := strings.Count(s,"1")
    fmt.Println(ans)
}





func abs32(a int) int {
    if a<0{
        return -a
    }
    return a
}

func abs64(a int64) int64 {
    if a<0{
        return -a
    }
    return a
}

func min32(a, b int) int {
    if a >= b {
        return b
    }
    return a
}

func max32(a, b int) int {
    if a >= b {
        return a
    }
    return b
}

func min64(a, b int64) int64 {
    if a >= b {
        return b
    }
    return a
}

func max64(a, b int64) int64 {
    if a >= b {
        return a
    }
    return b
}

func gcd(a, b int64) int64 {
    if a % b == 0 {
        return b
    } else {
        return gcd(b, a%b)
    }
}

func lcm(a, b int64) int64 {
    return a / gcd(a, b) * b
}

func scanNums(len int) (nums []int){
    var num int
    for i:=0; i<len; i++{
        fmt.Scan(&num)
        nums = append(nums,num)
    }
    return
}

func scanNums64(len int) (nums []int64){
    var num int64
    for i:=0; i<len; i++{
        fmt.Scan(&num)
        nums = append(nums,num)
    }
    return
}

func scanString(len int) (str []string){
    var s string
    for i:=0; i<len; i++{
        fmt.Scan(&s)
        str = append(str,s)
    }
    return
}

func scanTwoNums(n,m int) ([][]int){
    Nums := make([][]int, n)
    for i:=0; i<n; i++{
        Nums[i] = make([]int, m)
    }
    return Nums
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define N 250
#define ll long long
#define pb push_back
#define pi pair<ll , ll>
#define mp make_pair
bool check(string v , string& str){
	int j = 0 ; 
 for(int i = 0 ; i <(int)str.length() && j < (int)v.length() ; i++){
    if(v[j] == str[i]){
	 j++;
	 if(j == (int)v.length())return true;
	}
 }
 return false;
}
int main(){
int n;
cin>>n;
string str;
cin>>str;
set<string> v;
for(int i = 0 ; i < 10 ; i++){
 for(int j = 0 ; j < 10 ; j++){
   for(int k = 0 ; k < 10 ; k++){
        int l =  i*100 + j*10 + k;
        string s ="123";
        s[0] = char(i+'0');
        s[1] = (j+'0');
        s[2] = (k+'0');
       v.insert(s);
   }
 }
}

int ans = 0;
for(auto it : v){
   if(check(it , str) && it.length() == 3){
    ans++;
   }
}
cout<<ans<<endl;
}


Measured memory_bytes: 3716
#include <stdio.h>

unsigned long long kazu[100][21];
unsigned long long kazoe(int*,int,int,int);

int main(int argc,char* argv[]) {
	/*declare values*/
	int suuzi[100];
	int kosuu;
	unsigned long long count;
	int i,j;
	/*do work*/
	scanf("%d",&kosuu);
	for(i=0;i<kosuu;i++) {
		scanf("%d",&suuzi[i]);
		for(j=0;j<=20;j++)kazu[i][j]=-1;
	}
	count=kazoe(suuzi,1,suuzi[0],kosuu);
	printf("%llu\n",count);
	return 0;
}

unsigned long long kazoe(int *suuzi,int now,int nowsum,int max) {
	unsigned long long sum=0,result;
	int nowsuuzi;
	if(now==max-1) {
		if(nowsum==suuzi[now])return 1;
		else return 0;
	}
	if(suuzi[now]!=0) {
		nowsuuzi=nowsum+suuzi[now];
		if(nowsuuzi>=0 && nowsuuzi<=20) {
			if(kazu[now][nowsuuzi]==-1) {
				result=kazoe(suuzi,now+1,nowsuuzi,max);
				kazu[now][nowsuuzi]=result;
			}
			sum+=kazu[now][nowsuuzi];
		}
		nowsuuzi=nowsum-suuzi[now];
		if(nowsuuzi>=0 && nowsuuzi<=20) {
			if(kazu[now][nowsuuzi]==-1) {
				result=kazoe(suuzi,now+1,nowsuuzi,max);
				kazu[now][nowsuuzi]=result;
			}
			sum+=kazu[now][nowsuuzi];
		}
	} else {
		if(kazu[now][nowsum]==-1) {
			result=kazoe(suuzi,now+1,nowsum,max)*2;
			kazu[now][nowsum]=result;
		}
		sum+=kazu[now][nowsum];
	}
	return sum;
}

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

#define MIN_INT -2147483648
#define MAX_INT 2147483647
#define MIN_LONG -9223372036854775808L
#define MAX_LONG 9223372036854775807L

#define long long long int

using namespace std;

// @author: pashka

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

    int n;
    cin >> n;
    vector<int> a(n + 1);
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    vector<int> b(n + 1);
    for (int i = n; i >= 1; i--) {
        b[i] = a[i];
        for (int j = i + i; j <= n; j += i) {
            b[i] ^= b[j];
        }
    }
    int k = 0;
    for (int x : b) k += x;
    cout << k << "\n";
    for (int i = 1; i <= n; i++) {
        if (b[i]) cout << i << "\n";
    }

    return 0;
}

Measured memory_bytes: 2560
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;

import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main{

	Scanner sc=new Scanner(System.in);

	int INF=1<<28;
	double EPS=1e-9;

	void run(){
		for(;;){
			int n=sc.nextInt();
			if(n==0){
				break;
			}
			int q=0;
			int d=0;
			for(int i=0; i<n; i++){
				int p=sc.nextInt();
				int d1=sc.nextInt();
				int d2=sc.nextInt();
				if(d1+d2>d){
					d=d1+d2;
					q=p;
				}
			}
			println(q+" "+d);
		}
	}

	void debug(Object... os){
		System.err.println(Arrays.deepToString(os));
	}

	void print(String s){
		System.out.print(s);
	}

	void println(String s){
		System.out.println(s);
	}

	public static void main(String[] args){
		// System.setOut(new PrintStream(new BufferedOutputStream(System.out)));
		new Main().run();
	}
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B, C, D;
  cin >> A >> B>> C >> D;
   if (A+B<C+D) {
    cout << "Right" << endl;
  }
  else if (A+B>C+D){
    cout << "Left" << endl;
  }
  else{
  	cout << "Balanced" << endl;
  }
}

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

int main() {
    int n; 
	scanf("%d", &n); bool ok = 1;
    while(n --) {
        int x; scanf("%d", &x);
        if(x % 2 == 0 && (x % 3 != 0 && x % 5 != 0)) {
            ok = 0;
        }
    }
    puts(ok ? "APPROVED" : "DENIED");
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class  Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int  m = sc.nextInt();
        int n = sc.nextInt();
        if(m==n)
            System.out.println("Yes");
        else
            System.out.println("No");
    }
}

Measured memory_bytes: 22868
console.log(function(args){
  const [[N,K],A] = args.trim().split('\n').map( r=>r.split(' ').map(v=>v|0) );
  for ( let i = 0; i < K; i++ ) {
    const m = Array(N+1).fill(0);
    for ( let j = 0; j < N; j++ ) {
      m[Math.max( 0, j - A[j] )]++;
      m[Math.min( N, j + A[j] + 1)]--;
    }
    let s = 0, nx = 0;
    for ( let j = 0; j < N; j++ ) {
      A[j] = s += m[j];
      if ( A[j] === N ) nx++;
    }
    if ( nx === N ) break;
  }
  return A.join(' ');
}(require('fs').readFileSync('/dev/stdin', 'utf8')));


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

#define deb(x) cerr<<"["#x<<" : "<<x<<"]\n";

int main() {
	int a, b;
	cin >> a >> b;
	double k = (a+b)/2.0;
	if(k > int(k)) printf("%d", int(k+1));
	else printf("%d", int(k));
}


Measured memory_bytes: 3712
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vll vector<ll>
typedef long long int ll;
typedef long double ld;
using namespace std;

int main(int argc, char const *argv[]) {
  ll n, m;std::cin >> n >> m;
  vvl cake = vv(n, 3, 0, ll);
  ll ans = 0, tmp = 0;
  for(int i=0;i<n;i++) std::cin >> cake[i][0] >> cake[i][1] >> cake[i][2];
  for(int i = 0;i<2;i++){
    for(int j=0;j<2;j++){
      for(int k=0;k<2;k++){
        tmp = 0;
        vector<ll> num(n);
        for(int h=0;h<n;h++){
          num[h] = (i==0?1:-1)*cake[h][0] + (j==0?1:-1)*cake[h][1] + (k==0?1:-1)*cake[h][2];
        }
        sort(num.begin(), num.end());
        reverse(num.begin(), num.end());
        for(int h=0;h<m;h++) tmp += num[h];
        ans = max(ans, tmp);
      }
    }
  }
  std::cout << ans << '\n';
  return 0;
}


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

using namespace std;

typedef long long int ll;

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

typedef pair<int,int> pair;

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

    if(a==0){
        puts("0");
        return 0;
    }

    ll one=a+b;
    ll num=n%one;

    ll ans;
    if(num<=a){
        ans=(n-num)/one*a+num;
    }else{
        ans=(n-num)/one*a+a;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#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 VRSORT(v) sort(v.rbegin(), v.rend())//vectorの降順ソート
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;

typedef tuple<ll, ll, ll> T;

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b;
    char c;
    cin>>a>>c>>b;
    if(c=='+') cout<<a+b<<endl;
    else cout<<a-b<<endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define nl '\n'

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int , int> pi;

const ll MOD = 1e9+7;

void solve()
{
	int n, k;
	cin>>n>>k;
	vector<ll> pos, neg;
	int zero = 0;
	for(int i=0; i<n; i++)
	{
		ll temp;
		cin>>temp;
		if(temp > 0) pos.pb(temp);
		else if(temp < 0) neg.pb(temp);
		else zero++;
	}
	if(n-k < zero) 
	{
		cout<<0<<nl;
	}
	else if(n-zero == k && (int)neg.size()%2==1)
	{
		if(zero > 0) cout<<0<<nl;
		else 
		{
			ll answer = 1;
			for(auto i: pos)
			{
				answer *= i;
				answer %= MOD;
			}
			for(auto i: neg)
			{
				answer *= i;
				answer %= MOD;
			}
			if(answer < 0) answer += MOD;
			cout<<answer<<nl;
		}
	}
	else if(zero == 0 && (int)pos.size() == 0 && k%2 == 1)
	{
		ll answer = 1;
		sort(neg.rbegin(), neg.rend());
		for(int i=0; i<k; i++)
		{
			answer *= neg[i];
			answer %= MOD;
		}
		if(answer < 0) answer += MOD;
		cout<<answer<<nl;
	}
	else 
	{
		ll answer = 1;
		pos.pb(0); neg.pb(0);
		pos.pb(0); neg.pb(0);
		sort(pos.begin(), pos.end());
		sort(neg.rbegin(), neg.rend());
		int i =0;
		while(i<k-1)
		{
			i+=2;
			ll negt = neg.back()*neg[(int)neg.size()-2];
			ll post = pos.back()*pos[(int)pos.size()-2];
			if(negt >= post)
			{
				answer *= negt%MOD;
				answer %= MOD;
				neg.pop_back();
				neg.pop_back();
			}
			else 
			{
				answer *= post%MOD;
				answer %= MOD;
				pos.pop_back();
				pos.pop_back();
			}
		}
		while(i<k)
		{
			i++;
			answer *= pos.back();
			answer %= MOD;
			pos.pop_back();
		}
		if(answer < 0) answer += MOD;
		cout<<answer<<nl;
	}
}

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


Measured memory_bytes: 5448
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;

class Program
{
    static void Main(string[] args)
    {
        var N = int.Parse(ReadLine());
        var a = ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();

        var n = 1;
        for (int i = 0; i < N; i++)
        {
            if (a[i] != n)
                continue;

            n++;
        }

        var ans = N - n + 1;

        if (ans == N)
            ans = -1;

        WriteLine(ans);
    }
}


Measured memory_bytes: 43960
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pi M_PI
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

void Main() {
  ll n;
  string s;
  cin >> n >> s;
  int x=0,ans=0;
  rep(i,n) {
    if(s[i]=='I') x++;
    else x--;
    ans=max(ans,x);
  }
  pr(ans);
}

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


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <cstdio>
#include <algorithm>
using namespace std;
const double eps = 1e-8;
const double pi = acos(-1.0);
typedef long long ll;
int sgn(double x){
    if(fabs(x)<eps){
        return 0;
    }
    if(x<0){
        return -1;
    }else{
        return 1;
    }
}
struct Point{
    double x,y;
    Point(){}
    Point(double _x,double _y){
        x = _x;
        y = _y;
    }
    void input(){
        scanf("%lf%lf",&x,&y);
    }
    Point operator+(const Point &b)const{
        return Point(x+b.x,y+b.y);
    }
    Point operator -(const Point &b)const{
        return Point(x-b.x,y-b.y);
    }
    double operator *(const Point &b)const{
        return x*b.x+y*b.y;
    }
    Point operator *(const double &k)const{
        return Point(x*k,y*k);
    }
    Point operator /(const double &k)const{
        return Point(x/k,y/k);
    }
    double len2(){
        return x*x+y*y;
    }
};
struct Line{
    Point s,e;
    Line(){}
    Line(Point _s,Point _e){
        s = _s;
        e = _e;
    }
    //返回点p在直线上的投影
    Point lineprog(Point p){
        return s+(((e-s)*((e-s)*(p-s)))/((e-s).len2()));
    }
    //返回p关于直线的对称点
    Point symmetrypoint(Point p){
        Point q = lineprog(p);
        return Point(2*q.x-p.x,2*q.y-p.y);
    }
};
int main(){
    Point p1,p2,p3;
    p1.input();
    p2.input();
    Line line(p1,p2);
    int q;
    scanf("%d",&q);
    Point ans;
    while(q--){
        p3.input();
        ans = line.symmetrypoint(p3);
        printf("%.10f %.10f\n",ans.x,ans.y);
    }
   
    return 0;
}


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

int main (){
  int A,B,C;
  cin >> A >> B >> C;
  if(A==B && B!=C){
    cout << C << endl;
  }
  else if(A!=B && B==C){
    cout << A << endl;
  }
  else {
    cout << B << endl;
  }
}

    

Measured memory_bytes: 256
def isPrime(x):
  if x % 2 == 0:
    return x == 2
  else:
    for y in range(3, int(x ** 0.5) + 1, 2):
      if x % y == 0:
        return False
    return True

x = int(input())

while True:
  if isPrime(x):
    break
  else:
    x += 1

print(x)

Measured memory_bytes: 3060
#include <assert.h>
#include <limits.h>
#include <cmath>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <complex>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

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

#define rep(i, a, b) for (ll(i) = (a); i < (b); i++)
#define all(i) i.begin(), i.end()
#define debug(i) std::cout << i << "\n"

const ll MOD = 998244353;
// const ll MOD = 1e9+7;

//とりあえず1-indexedでつくったBIT
template <class T>
struct BinaryIndexedTree {
  T n;
  std::vector<T> bit;

  BinaryIndexedTree(T i) : n(i), bit(i + 1, 0){};

  // a番目にwを加算
  void add(T a, T w) {
    for (T x = a; x <= n; x += (x & -x)) {
      bit[x] += w;
    }
  }

  //[1,a]の和
  T sum(T a) {
    T ret = 0;
    for (T x = a; x > 0; x -= (x & -x)) {
      ret += bit[x];
    }
    return ret;
  }
};

ll pri2[200010];

int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  //問題文中の添え字が0-indexか1-indexか確認!

  ll n;
  std::cin>>n;

  std::vector<P> point(n);
  std::vector<ll> xp(n),yp(n);
  rep(i,0,n){
    ll x,y;
    std::cin>>x>>y;
    point[i]=P(x,y);
    xp[i]=x;
    yp[i]=y;
  }

  std::sort(all(xp));
  std::sort(all(yp));

  rep(i,0,n){
    ll x=point[i].first,y=point[i].second;
    ll nx=(ll)(std::lower_bound(all(xp),x)-xp.begin());
    ll ny=(ll)(std::lower_bound(all(yp),y)-yp.begin());
    point[i]=P(nx,ny);
  }

  std::sort(all(point));

  std::vector<std::vector<ll>> count(n,std::vector<ll>(4,0));

  rep(j,0,2){
    BinaryIndexedTree<int> Y(n);
    rep(i,0,n){
      if(j==0){
        count[i][0]=Y.sum(point[i].second);
        count[i][1]=i-Y.sum(point[i].second+1);
      }else{
        count[n-1-i][2]=Y.sum(point[i].second);
        count[n-1-i][3]=i-Y.sum(point[i].second+1);
      }
      Y.add(point[i].second+1,1);
    }

    std::reverse(all(point));
  }

  ll ans=0;

  pri2[0]=1;

  rep(i,1,200010){
    pri2[i]=(2*pri2[i-1])%MOD;
  }

  rep(i,0,n){
    ll a=(pri2[count[i][0]]+pri2[count[i][3]]-1)%MOD;
    ll b=(pri2[count[i][1]]+pri2[count[i][2]]-1)%MOD;

    ll v=(pri2[n]-a*b)%MOD;
    if(v<0)v+=MOD;
    ans=(ans+v)%MOD;
  }

  std::cout<<ans;

  return 0;
}


Measured memory_bytes: 22900
//
// Created by kuroneko on 2019-09-28.
//

#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>
#include <string>

using namespace std;

typedef long long ll;

#define INF 1000000000000009LL
#define MOD 1000000007LL

typedef int Weight;
struct Edge {
    int src, dst;
    Weight weight;
    Edge(int src, int dst, Weight weight):src(src), dst(dst), weight(weight) {}
};

typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

typedef vector<Weight> Array;
typedef vector<Array> Matrix;

bool is_prime[1000000 + 1];
vector<ll> P;
void Eratosthenes(ll N)
{
    for (ll i; i < N; i++){

    }
    for(ll i = 0; i <= N; i++ )
    {
        is_prime[ i ] = true;//初期化
    }
    for(ll i = 2; i <= N; i++ )
    {
        if( is_prime[ i ] )
        {
            for(ll j = 2 * i; j <= N; j += i )
            {
                is_prime[ j ] = false;
            }
            P.emplace_back( ll(i) );
        }
    }
}

int main() {
    ll A, B; cin >> A >> B;
    ll num = max(A,B);
    for (ll i = 2; i < ll(sqrt(max(A, B)) + 1); i++) {
        if (num%i == 0) P.emplace_back(i);
        while (num%i == 0) {
            num /= i;
        }
    }
    if (num != 1) P.emplace_back(num);

    ll res = 0;

    for (int i = 0; i < P.size(); i++) {
        if (A % P[i] == 0 && B % P[i] == 0) res++;
    }
    cout << res + 1 << endl;
    return 0;

}


Measured memory_bytes: 256
def cornerval(i, j, a, dp, h, w):

	if a[i][j] == '#':
		return 0
	elif(j== w-1):
		if(dp[i+1][j] == 0):
			return 0
		else:
			return 1
	elif(i==h-1):
		if(dp[i][j+1] == 0):
			return 0
		else:
			return 1

l = 10**9 + 7
h, w = map(int, raw_input().split())
a = []
for i in range(h):
	t= raw_input()
	t = list(t)
	a.append(t)
# print(a)
dp=[[0 for x in range(w)] for x in range(h)]
dp[h-1][w-1] = 1
i=h-1
for j in range(w-2, -1, -1):
	dp[i][j] = cornerval(i, j, a, dp, h, w)
j = w-1
for i in range(h-2, -1, -1):
	dp[i][j] = cornerval(i, j, a, dp, h, w)
dp[h-1][w-1] = 0


for i in range(h-2, -1, -1):
	for j in range(w-2, -1, -1):
		if(a[i][j] == '#'):
			dp[i][j] = 0
		else:
			dp[i][j] = ((dp[i+1][j] % l) + (dp[i][j+1] % l)) % l
# for i in dp:
# 	print(i)
print(dp[0][0])

Measured memory_bytes: 44420
#include<iostream>
#include<vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <limits>
#include <map>
#include <bitset>

#define rep(i,n) for(int (i) = 0;(i)<(n);(i)++)

using namespace std;
using p = pair<int, int>;
using ll = long long;

vector< vector<int> > memo;

int gcd(int a, int b, int c) {
	int min_num = (a > b) ? b : a;
	if (min_num > c) min_num = c;
	while (min_num != 1) {
		if (a % min_num == 0 && b % min_num == 0 && c % min_num == 0) break;
		min_num--;
	}
	return min_num;
}

int gcd(int a, int b) {
	int m = (a < b) ? a : b;
	while (m != 1) {
		if (a % m == 0 && b % m == 0)break;
		m--;
	}
	return m;
}

int main() {
	int r;
	cin >> r;
	cout << 2 * r * acos(-1) << endl;
	return 0;
}


Measured memory_bytes: 3788