akhauriyash/Code-Regression huggingface dataset:
a = int(input())
b = int(input())
c = int(input())
x = int(input())

count = 0
for i in range(0, a + 1):
    for j in range(0, b + 1):
        for k in range(0, c + 1):
            if 500 * i + 100 * j + 50 * k == x:
                count += 1
                
print(count)

Measured memory_bytes: 3060
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <set>
#include <queue>
#include <map>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<ld> vld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define INF ((int)1e9)
#define INFLL ((ll)1e18)
#define MOD (1000000007LL)


int main(int argc, const char * argv[]) {
    ios_base::sync_with_stdio(false);
    int N;
    cin >> N;
    
    int K = N / 2;
    
    if (N%2 == 0) {
        cout << 2*K*(K-1) << '\n';
        for (int k = 0; k < K; ++k) {
            int a[2] = {k+1, N-k};
            for (int l = k+1; l < K; ++l) {
                int b[2] = {l+1, N-l};
                for (int i = 0; i < 2; ++i) {
                    for (int j = 0; j < 2; ++j) {
                        cout << a[i] << ' ' << b[j] << '\n';
                    }
                }
            }
        }
    } else {
        cout << N-1 + 2*K*(K-1) << '\n';
        for (int n = 0; n < N-1; ++n) {
            cout << n+1 << ' ' << N << '\n';
        }
        for (int k = 0; k < K; ++k) {
            int a[2] = {k+1, N-1-k};
            for (int l = k+1; l < K; ++l) {
                int b[2] = {l+1, N-1-l};
                for (int i = 0; i < 2; ++i) {
                    for (int j = 0; j < 2; ++j) {
                        cout << a[i] << ' ' << b[j] << '\n';
                    }
                }
            }
        }
    }

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
#define erep(i,n) for(int i = 0;i<=n;i++)
#define rep1(i,n) for(int i = 1;i<n;i++)
#define erep1(i,n) for(int i = 1;i<=n;i++)
typedef long long ll;
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstring vector<string>
#define vdouble vector<double>
#define vll vector<ll>:
#define vbool vector<bool>
#define INF 1101010101010101010
#define MOD 1000000007
#define int long long
using P = pair<int,int>;

signed main(){
  int ss;
  cin >> ss;
  int a = ss/1000;
  int b = ss%1000/100;
  int c = ss%100/10;
  int d = ss%10;
  bool flag = false;
  string op = "+-";
  rep(j,2){
    int tmp = a;
    if(j == 0) tmp += b;
    else tmp -= b;
    rep(s,2){
      int ttmp = tmp;
      if(s == 0) ttmp += c;
      else ttmp -= c;
      rep(t,2){
        int tttmp = ttmp;
        if(t == 0) tttmp += d;
        else tttmp -= d;
        if(tttmp == 7){
          cout << a << op[j] << b << op[s] << c << op[t] << d << "=7" << endl;
          flag = true;
          break;
        }
        if(flag) break;
      }
      if(flag) break;
    }
    if(flag) break;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <set>
#include <map>
#include <unordered_map>
#include <vector>
#include <queue>
#include <string>
#include <iomanip>
#include <stdio.h>
#include <cstring>
#include <random>
#include <chrono>
#include <bitset>
#include <fstream>
#include <sstream>

using namespace std;

typedef long long ll;
typedef long double ld;

ll big = 1000000007ll;
ll n,m,k;



int main()
{
    ll a,b,c,d,e,f;
    ll c1,c2,c3;

    string s;
    cin >> s;

    ll ss = 0;
    char lc = 'A';

    for(c1 = 0; c1 < s.length(); c1++){

        if(lc != s[c1])ss++;
        lc = s[c1];

    }

    cout << ss-1 << "\n";

    return 0;
}


Measured memory_bytes: 512
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int s = sc.nextInt();

        while (!(n == 0 && s == 0)) {
            System.out.println(dfs(n, s, 0, 0, -1));
            n = sc.nextInt();
            s = sc.nextInt();
        }

        sc.close();
    }

    static int dfs(int maxdepth, int target, int sum, int depth, int lastNum) {
        if (depth == maxdepth) {
            if (sum == target) {
                return 1;
            } else {
                return 0;
            }
        }

        int ans = 0;

        for (int i = 0; i < 10; i++) {
            if (lastNum < i) {
                ans += dfs(maxdepth, target, sum + i, depth + 1, i);
            }
        }

        return ans;
    }

}



Measured memory_bytes: 26404
#include <stdio.h>
int main(){
    long int a,b,c,d,e;
    scanf("%ld",&a);
  for(b=0;b<=400;b++){
  for(c=-400;c<=400;c++){
  if(b*b*b*b*b-c*c*c*c*c==a){
    d=b;
    e=c;
    break;
  }
  }
  }
  printf("%ld %ld",d,e);
  return 0;
}


Measured memory_bytes: 1652
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader input =new BufferedReader (new InputStreamReader (System.in));
		String str = input.readLine( );
		String[] strlist = str.split(" ");
		int sx = Integer.parseInt(strlist[0]);
		int sy = Integer.parseInt(strlist[1]);
		int tx = Integer.parseInt(strlist[2]);
		int ty = Integer.parseInt(strlist[3]);

		int x = tx -sx;
		int y = ty -sy;

		for(int i=0; i<y; i++){
			System.out.print("U");
		}
		for(int i=0; i<x; i++){
			System.out.print("R");
		}
		for(int i=0; i<y; i++){
			System.out.print("D");
		}
		for(int i=0; i<x; i++){
			System.out.print("L");
		}

		System.out.print("L");

		for(int i=0; i<y+1; i++){
			System.out.print("U");
		}
		for(int i=0; i<x+1; i++){
			System.out.print("R");
		}

		System.out.print("D");
		System.out.print("R");

		for(int i=0; i<y+1; i++){
			System.out.print("D");
		}
		for(int i=0; i<x+1; i++){
			System.out.print("L");
		}

		System.out.print("U");

	}

}


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

#define all(x) (x).begin(),(x).end()
#define SP <<" "<<
#define MOD 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000

typedef long long LL;
typedef long double LD;

int main(){
  int n;
  cin >> n;
  int x=n+(n+1)%2;
  int c=0;
  for(int i=1;i<=n;i++){
    for(int j=i+1;j<=n;j++){
      if(i+j!=x){
        c++;
      }
    }
  }
  cout << c << endl;
  for(int i=1;i<=n;i++){
    for(int j=i+1;j<=n;j++){
      if(i+j!=x){
        cout << i SP j << endl;
      }
    }
  }
  return 0;
}


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

int main(){
    int N; cin >> N;
    string s[N];
    int a=0,w=0,t=0,r=0;
    for(int i=0;i<N;i++){
        cin >> s[i];
        if(s[i]=="AC") a++;
        else if(s[i]=="WA") w++;
        else if(s[i]=="TLE") t++;
        else r++;
    }
    cout << "AC x " << a << endl;
    cout << "WA x " << w << endl;
    cout << "TLE x " << t << endl;
    cout << "RE x " << r << endl;
}

Measured memory_bytes: 6756
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<string.h>
using namespace std;
int main() {
	std::string s;
	cin >> s;
	int n = s.size();
	string p = "Yes";
	for (int i = 0; i < (n - 1) / 2; i++) {
		if (s[i] != s[n - i - 1]) {
			p = "No";
			break;
		}
	}
	if (p == "Yes") {
		for (int j = 0; j < (n - 1) / 2; j++) {
			if (s[j] != s[((n - 1) / 2)- j -1]) {
				p="No";
				break;
			}
		}
	}
	cout << p ;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <queue>
#include <sstream>
#include <fstream>
#include <float.h>
#include <cmath>
#include <cstring>

using namespace std;
#define int long long

signed main() {
	int N, M;
	char A[52][52] = {}, B[52][52] = {};
	cin >> N >> M;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			cin >> A[i][j];
		}
	}
	for (int i = 0; i < M; i++) {
		for (int j = 0; j < M; j++) {
			cin >> B[i][j];
		}
	}
	for (int i = 0; i <= N-M; i++) {
		for (int j = 0; j <= N-M; j++) {
			int tmp = 0;
			for (int k = 0; k < M; k++) {
				for (int l = 0; l < M; l++) {
					if (A[i + k][j + l] == B[k][l]) tmp++;
				}
			}
			if (tmp == M*M) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int N,K,X,Y;
    int total=0;
    int i;
    cin >> N >> K >>X >> Y;

    for(i=0;i<N;i++){
        if(i<K){
       total=total+X;
       }else{
       total=total+Y;
       } 
    }

    cout << total << endl;


    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstring>
#include <algorithm> // sort

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

using namespace std;

int main(){
    ll N,M;
    cin >> N >> M;

    ll wa = M*1900 + 100*(N-M);
    //Mケースについての期待値のみ
    ll yari = 1;
    REP(i,M) yari *= 2;
    ll res = wa * yari;
    cout << res << endl;

    return 0;

}

Measured memory_bytes: 256
import math
A, B, H, M = map(int, input().split())

time = 60*H + M
theta_a = time / 2

theta_b = 6*M

theta = abs(theta_a - theta_b)

# c^2 = a^2 + b^2 - 2ab cosC
c = A*A + B*B - 2*A*B*math.cos(math.radians(theta))
print(math.sqrt(c))

Measured memory_bytes: 9500
//保留所有权利。
#include<iostream>
#include<stdio.h>//printするよ
#include<vector>
#include<algorithm>//辞書順はnext_permutationだよ
#include<set>
#include<string>
#include<string.h>
#include<time.h>
#include<random>
#include<cmath>
#include<math.h>
#include<queue>
#include<time.h>
#include<iomanip>
#include<utility>//swapで数値交換するよ
//END OF LIBRARIES.
#define rt "\n"//改行を最速化させるよ
#define rep(i,n) for(int i=0;i<n;i++)
#define rop(i,n) for(int i=1;i<=n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define yes(ans) if(ans)cout<<"yes"<<rt;else cout<<"no"<<rt;
#define Yes(ans) if(ans)cout<<"Yes"<<rt;else cout<<"No"<<rt;
#define YES(ans) if(ans)cout<<"YES"<<rt;else cout<<"NO"<<rt;
#define vcin(V) for (int i = 0; i < (V).size(); i++) { cin >> (V).at(i); }
#define sort(s) sort(s.begin(),s.end())
#define reve(s) reverse(s.begin(),s.end())
#define asas int ans=0
#define cncn int cnt=0
#define smsm int sum=0
#define nn int n=0
#define please return
#define AC 0//おまじないだよ
#define Rapid cin.tie(0);ios::sync_with_stdio(false)
//END OF DEFINE.
using namespace std;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vcha;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair<llint, llint> pllint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool; 
//END OF TYPEDEF.

//最大公約数（GCD）を求めるよ
//最小公倍数（LCM）は＜＜　A × B ÷ GCD　 ＞＞で求まるよ

long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}
//BEGIN OF CODE.
int c = 0;
int main(void){
	llint a, b;
	cin >> a >> b;
	cout << (a * b) / GCD(a, b) << rt;
	please AC;
}
//THE END.

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int INF = pow(2,31) - 1;
int n;
void powset(int size){
  n = 1;
  while( n < size ) n *= 2;
}

struct RMQ{
  vector< int > seg;
  void update( int i, int x){
    i += n - 1;
    seg[i] = x;
    while(i > 0){
      i = ( i - 1 ) / 2;
      seg[i] = min( seg[i * 2 + 1], seg[i * 2 + 2]);
    }
  }
  int query( int a, int b, int k, int l, int r){
    if( r <= a || b <= l ) return INF;
    if( a <= l && r <= b ) return seg[k];
    int vl = query( a, b, k * 2 + 1, l, (l + r) / 2);
    int vr = query( a, b, k * 2 + 2, (l + r) / 2, r);
    return min( vl, vr);
  }
  int query( int a, int b){
    return query( a, b, 0, 0, n);
  }
  RMQ(){
    seg.assign( n * 2 - 1, INF);
  }
};

int main(){
  int R, C, Q;
  while(cin >> R >> C >> Q, R){
    if(R < C){
      powset(C);
      vector< RMQ > rmq( R, RMQ());
      for(int i = 0; i < R; i++){
        for(int j = 0; j < C; j++){
          int grid;
          cin >> grid;
          rmq[i].update(j,grid);
        }
      }
      while(Q--){
        int r1, c1, r2, c2;
        cin >> r1 >> c1 >> r2 >> c2;
        int ret = INF;
        for(int i = r1; i <= r2; i++){
          ret = min( ret, rmq[i].query( c1, c2 + 1));
        }
        cout << ret << endl;
      }
    }else{
      powset(R);
      vector< RMQ > rmq( C, RMQ());
      for(int i = 0; i < R; i++){
        for(int j = 0; j < C; j++){
          int grid;
          cin >> grid;
          rmq[j].update(i,grid);
        }
      }
      while(Q--){
        int r1, c1, r2, c2;
        cin >> r1 >> c1 >> r2 >> c2;
        int ret = INF;
        for(int i = c1; i <= c2; i++){
          ret = min( ret, rmq[i].query( r1, r2 + 1));
        }
        cout << ret << endl;
      }
    }
  }
}

Measured memory_bytes: 17492
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <utility>
using namespace std;

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

const int list[3] = { 2, 3, 5 };
const int MAX_N = 1000002;
char dp[MAX_N];
int m, n;

int main() {
  fill(dp, dp + MAX_N, 0);
  dp[1] = 1;
  rep (i,MAX_N) if (dp[i]) {
    rep (j,3) if (i * list[j] < MAX_N) {
      dp[i * list[j] ] = 1;
    }
  }
  while (cin >> m, m) {
    cin >> n;
    int ans = 0;
    for (int i = m; i <= n; ++i) if (dp[i]) ans++;
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 0
def comb(n,r,mod=10**9+7):
    ans1=1
    for i in range(1,r+1):
        ans1*=(n-i+1)*pow(i,mod-2,mod)
        ans1%=mod
    return ans1

n,a,b=map(int,input().split())
mod=10**9+7

ans=(pow(2,n,mod)-1-(comb(n,a)+comb(n,b)))%mod
print(ans)

Measured memory_bytes: 41924
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
bool ispal(string a)
{
    long long int n=a.length();
    if(n==1)
        return true;
    else{
    int i=0,j;
    j=n-1;
    while(1)
    {
        if(a[i]!=a[j])
        {
            cout<<i<<" "<<j;
           return false;
        }
        i++,j--;
        if(i==j)
         {
        //     cout<<i<<" ";
             break;
        }
    }
    return true;
}}

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
 ll n;
 cin>>n;
 n*=2;
 int a[n];
 for(int i=0;i<n;i++)
 {
     cin>>a[i];
 }
 sort(a,a+n);
 ll ans=0;
 for(int i=0;i<n;i+=2)
 {
    ans+=a[i];
 }
 cout<<ans;
 }

Measured memory_bytes: 3608
//
//  main.cpp
//  A
//
//  Created by Hashizo on 2020/01/19.
//  Copyright © 2020 Hashizo. All rights reserved.
//

#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <regex>
#include <cmath>

using namespace std;
 
#undef LONG_MAX
#undef LONG_MIN
 
#define LONG_MAX    9223372036854775807
#define LONG_MIN    (-LONG_MAX  -1)
 
#define ll long long
 
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
 
#define SORT(c) sort((c).begin(), (c).end())
#define REVERSE(v) reverse((v).begin(), (v).end())


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


	ll n,m;
	cin >> n >> m;

	if (n == m) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	
	return 0;
}


Measured memory_bytes: 256
A,B,C,D = gets.chomp.split(' ').map(&:to_i)
result = 0
if A <= C && D <= B
  result = D - C
elsif C <= A && B <= D
  result = B - A
elsif A <= C && C <= B && B <= D
  result = B - C
elsif C <= A && A <= D && D <= B
  result = D - A
end

puts result

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define REP(i, n) for (int i = 0; i < (n); i++)

const long double EPS = 1e-10;
const long long INF = 1e18;
const long double PI = acos(-1.0L);


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


int main() {


int n,m,x,y;
cin>>n>>m>>x>>y;
int a[n],b[m];
REP(i,n){
  cin>>a[i];
}
REP(i,m){
  cin>>b[i];
}

int max_a = INT_MIN;
int min_b = INT_MAX;

REP(i,n){
  max_a = max(max_a,a[i]);
}
REP(i,m){
  min_b = min(min_b,b[i]);
}

int ans;
int flag = 0;

for(int i=x+1;i<y;i++){
  if( i > max_a && i<=min_b){
    flag = 1;
    ans = i;
    break;
  }
}

if(flag){
 cout<<"No War\n";
}
else{
  cout<<"War\n";
}


  
  return 0;
}


Measured memory_bytes: 3604
import java.util.*

fun main(args: Array<String>) {
    val N = readLine()!!.toInt()
    val S = readLine()!!
    val st = Array<TreeSet<String>>(4) { TreeSet<String>() }
    st[0].add("")

    for (i in S.indices) {
        for (j in 2 downTo 0) {
            for (t in st[j]) {
                st[j + 1].add(t + S[i])
            }
        }
    }

    println(st[3].size)
}

Measured memory_bytes: 104536
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    public static void Main()
    {
        int N = int.Parse(Console.ReadLine());
        string []input=Console.ReadLine().Split();
        int []A = new int[N];
        string flag = "YES";
        for (int i = 0; i < N; i++)
        {
            A[i] = int.Parse(input[i]);
        }
        Array.Sort(A);
        for (int i = 1; i < N; i++)
        {
            if (A[i] == A[i - 1]) { flag = "NO"; }
        }
        Console.WriteLine(flag);
    }
}

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

int main() {
  int n;cin>>n;
  vector<int> a(n);
  rep(i,n) a[i]=i+1;
  
  vector<int> b(n);
  rep(i,n) cin>>b[i];
  
  int count=0;
  if (a==b) cout<<"YES"<<endl;
  else {
    for (int i=0;i<n;i++) {
      if (a[i]!=b[i]) {
        count++;
      }
    }
    if (count==2) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
  }
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
   int x,y,z;
   scanf("%d ", &x);
   scanf("%d ", &y);
   scanf("%d ", &z);

    int temp = x;
    x=y;
    y=temp;
    temp=x;
    x=z;
    z=temp;
    
    printf("%d %d %d", x,y,z);
    

    return 0;
}


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

using namespace std;

#define ll long long 
#define ld long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mkp make_pair
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define ff first
#define ss second
#define endl "\n"
#define MOD 1000000007
#define MOD1 998244353
#define inf 1e18

ll GCD(ll x,ll y){if(y==0)return x;return GCD(y,x%y);}
ll LCM(ll x,ll y){return (x*y)/(GCD(x,y));}
ll LOGK(ll x,ll k){if(x>=k)return 1+LOGK(x/k,k);return 0;}
ll MPOW( ll a, ll b, ll m) { if(b==0) return 1; ll x=MPOW(a,b/2,m); x=(x*x)%m; if(b%2==1) x=(x*a)%m; return x;}
ll MINV(ll a,ll m) {return MPOW(a,m-2,m);}

class pnc{
  ll FACT_MAX,MODU;
  vector<ll> fact;
public:
  pnc( ll n, ll m) { FACT_MAX = n; fact.resize(FACT_MAX); MODU = m; MFACT_INIT(MODU);}
  void MFACT_INIT( ll m) { fact[0]=1; for(ll i=1;i<FACT_MAX;++i) fact[i]=(i*fact[i-1])%MODU;}
  ll MFACT( ll n) { return fact[n];}
  ll PERM( ll n, ll r) { return (fact[n]*::MINV(fact[n-r],MODU))%MODU;}
  ll COMB( ll n , ll r) { return (PERM(n,r)*::MINV(fact[r],MODU))%MODU;}
};

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

    ll test=1;
    // cin>>test;
    while(test--)
    {
        ll n;
        cin>>n;

        if(n==7 || n==1)
        {
            cout<<1;
            continue;
        }

        if(n%7==0)
        n/=7;

        n*=9;

        ll num=1;
        ll flag=0;

        for(ll i=1;i<=10000000;i++)
        {
            num*=10;

            if(num%n==1)
            {
                cout<<i;
                flag=1;
                break;
            }

            num%=n;
        }

        if(flag==0)
        cout<<-1;
    }
}

Measured memory_bytes: 3604
#include<stdio.h>

int main( void ){
   int a, b;
   scanf("%d%d", &a, &b);
   if(a > 9 || a < 0 || b > 9 || b < 0){
      printf("-1\n");
   } else {
      printf("%d\n", a*b);
   }
   return 0;
}


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

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long[] A = new long [N];
		
		for(int i=0;i<N;i++) {
			A[i]=sc.nextLong();
			if(A[i]==0) {
				System.out.println(0);
				return;
			}
		}
		
		Arrays.sort(A);
		
		long ans =1;
		
		for(int i=N-1;i>=0;i--) {
			if(A[i]> 1000000000000000000L/ans) {
				System.out.println(-1);
				return;
			}else {
				ans *= A[i];
			}
		}
		System.out.println(ans);
		sc.close();
	}

}

Measured memory_bytes: 61976
#include <cmath>
#include <cstring>
#include <iostream>
#include <algorithm>

#define ctz(x) __builtin_ctz(x)

using f64 = double;

const int N = 13, M = 1 << 6 | 3, NC = 600;

int n, m, c;
int a[N], p[N], q[N];
f64 ans, res;
f64 f[M][NC][NC], g[M][NC][NC];

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

	scanf("%d%d", &n, &c), m = (1 << n) - 1;
	for (int i = 0; i < n; ++i)
		scanf("%d", a + i), p[i] = i + 1;
	std::sort(a, a + n, [](int a, int b){ return a > b; });
	do {
		for (int i = 0; i < n; ++i) q[p[i]] = i;
		memset(f, 0, sizeof f);
		f[0][0][1] = 1;
		for (int i = 1; i <= n * c; ++i)
			for (int j = i; j <= n * c + 1; ++j)
				for (int k = 0; k <= m; ++k) {
					f[k][i][j] += f[k][i - 1][j];
					int l = q[(i - 1) % n + 1];
					if (k >> l & 1) continue;
					f[k | 1 << l][i][std::min(std::max(j, i + a[l] * n), n * c + 1)] += f[k][i - 1][j];
				}
		ans += f[m][n * c][n * c + 1], ++res;
	} while (std::next_permutation(p + 1, p + n));
	printf("%.12lf", ans / res / pow(c, n - 1));

	return 0;
}


Measured memory_bytes: 192604
# ファイルをオープンする
#test_data = open("test.txt", "r")

# 行ごとにすべて読み込んでリストデータにする
#line = test_data.readline()


#N, M, C = map(int, line.split())
N, M, C = map(int, input().split())
B = []
A = []

#line = test_data.readline()


#B = [int(b) for b in line.split()]
B = [int(b) for b in input().split()]
for i in range(N):
	A.append(list(map(int, input().split())))
	#line = test_data.readline()
	#A.append(list(map(int, line.split())))

sum = 0
count = 0

for i in range(N):
	sum = 0
	for j in range(M):
		sum += A[i][j] * B[j]
	sum += C
	if sum > 0:
		count += 1

print(count)

Measured memory_bytes: 3064
IDENTIFICATION DIVISION.
      PROGRAM-ID. 057A.
      DATA DIVISION.
      WORKING-STORAGE SECTION.
      01 INP PIC X(100).
      01 A   PIC 9(2).
      01 B   PIC 9(2).
      01 ANS1 PIC 9(2).
      01 ANS2 PIC 9(2).
      01 ANSX PIC Z9.
      
      PROCEDURE DIVISION.
      ACCEPT INP.
      UNSTRING INP DELIMITED BY " "
      INTO A B.
      COMPUTE ANS1 = A + B.
      IF ANS1 >= 24
      	COMPUTE ANS2 = ANS1 - 24
      ELSE
      	MOVE ANS1 TO ANS2
      END-IF.
      MOVE ANS2 TO ANSX.
      DISPLAY FUNCTION TRIM(ANSX).
      
      STOP RUN.

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) begin(v),end(v)
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//

#include <cassert>
#include <utility>

namespace tk {
template<typename T>
T gcd(T a, T b) {
	assert(a >= 0);
	assert(b >= 0);
	while (b != 0) {
		T t = a % b;
		a = b; b = t;
	}
	return a;
}

template<typename T>
T lcm(T a, T b) {
	assert(a >= 0);
	assert(b >= 0);
	if (a == 0 || b == 0) return 0;
	return a / gcd(a, b) * b;
}

template<typename T>
T ext_gcd(const T & a, T & x, const T & b, T & y) {
	assert(a > 0);
	assert(b > 0);
	T a0 = a, a1 = 1, a2 = 0, b0 = b, b1 = 0, b2 = 1;
	while (b0 > 0) {
		T q = a0 / b0, r = a0 % b0;
		T nb1 = a1 - q * b1, nb2 = a2 - q * b2;
		a0 = b0; b0 = r;
		a1 = b1; b1 = nb1;
		a2 = b2; b2 = nb2;
	}
	x = a1;
	y = a2;
	return a0;
}

template<typename T>
T mod_pow(T x, T n, const T & mod) {
	assert(mod > 0);
	assert(n >= 0);
	x = (x % mod + mod) % mod;
	T res = 1 % mod;
	while (n > 0) {
		if (n & 1) res = res * x % mod;
		x = x * x % mod;
		n >>= 1;
	}
	return res;
}

template<typename T>
T mod_inv(const T & x, const T & mod) {
	assert(mod > 0);
	T a, b;
	T g = ext_gcd(x, a, mod, b);
	assert(g == 1);
	return (a % mod + mod) % mod;
}

template<typename T>
std::pair<T, T> chinese_remainder(T b1, T m1, T b2, T & m2) {
	assert(m1 > 0);
	assert(m2 > 0);
	if (m1 < m2) { std::swap(b1, b2); std::swap(m1, m2); }
	b1 = (b1 % m1 + m1) % m1;
	b2 = (b2 % m2 + m2) % m2;
	
	T x, y;
	T g = ext_gcd(m1, x, m2, y);
	const T pm2 = m2 / g;
	x = (x % pm2 + pm2) % pm2;
	
	if ((b2 - b1) % g != 0) return {0, 0};
	const T t = ((b2 - b1) / g % pm2 + pm2) % pm2 * x % pm2;
	return {b1 + t * m1, m1 * pm2};
}
} // namespace tk

vector<ll> find_divisor(ll n) {
	vector<ll> divisor;
	
	ll i = 1;
	for (; i * i <= n; i++) if (n % i == 0) divisor.push_back(i);
	i--;
	if (i * i == n) i--;
	for (; i >= 1; i--) if (n % i == 0) divisor.push_back(n / i);
	
	return divisor;
}

int main() {
	ll N;
	cin >> N;
	N *= 2;
	
	ll ans = longINF;
	auto div = find_divisor(N);
	
	for (auto x : div) {
		ll y = N / x;
		// k(k + 1) \equiv 0 (mod. N)
		// x | k, y | k + 1
		// k \equiv 1 (mod. x)
		// k \equiv -1 (mod. y)
		auto res = tk::chinese_remainder<ll>(0, x, y - 1, y);
		if (res.second == 0) continue;
		
		ll p = res.first;
		if (p == 0) p += res.second;
		chmin(ans, p);
	}
	
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3732
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#define MOD 1000000007
typedef long long ll;
using namespace std;

int N;

vector<int> g[100010];
bool used[100010];

int dfs(int now){
    used[now]=true;
    int res=0;
    for(int i=0;i<g[now].size();i++){
        int next=g[now][i];
        if(used[next]) continue;

        res^=dfs(next);
    }
    return(res+1);
}

int main(){
  cin>>N;
  for(int i=1;i<N;i++){
      int x,y;
      cin>>x>>y;
      x--;
      y--;
      g[x].push_back(y);
      g[y].push_back(x);
  }

  used[0]=true;
  int ans=0;
  for(int i=0;i<g[0].size();i++){
      int grundy=dfs(g[0][i]);
      //grundy--;
      ans^=grundy;
  }

  if(ans==0) cout<<"Bob"<<endl;
  else cout<<"Alice"<<endl;

  return 0;
}


Measured memory_bytes: 10496
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

using namespace std;

int main() {
	int n, m;
	cin >> n >> m;
	string ans(n, 'x');
	bool ng = false;
	for (int i = 0; i < m; i++) {
		int s;
		char c;
		cin >> s >> c;
		s--;
		if (ans[s] == 'x')
			ans[s] = c;
		else if (ans[s] != c) {
			ng = true;
			break;
		}

	}
	if (ng)
		cout << -1 << endl;
	else {

		if (ans == "0" || ans == "x")
			cout << 0 << endl;
		else if (ans[0] == '0')
			cout << -1 << endl;
		else {
			if (ans[0] == 'x')
				ans[0] = '1';
			for (int i = 1; i < n; i++) {
				if (ans[i] == 'x')
					ans[i] = '0';
			}
			cout << ans << endl;
		}


	}
	return 0;
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author emli
 */


#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

class BBalance {
public:

    void solve(std::istream& cin, std::ostream& cout) {
		ios::sync_with_stdio(false);
        cin.tie(nullptr);
        int n;
        cin >> n;
        vector<int> a(n + 1),prefix(n + 1);
        for (int i = 1; i <= n; ++i) {
            cin >> a[i];
            prefix[i] = prefix[i - 1] + a[i];
        }

        int ans = int(1e9);

        for (int i = 1; i <= n; ++i) {
            ans = min(ans,abs(prefix[i] - (prefix[n] - prefix[i])));
        }
        cout << ans << endl;
	}
};


int main() {
	BBalance solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
//#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<numeric>
#include<vector>
#include<set>
#include<map>
using namespace std;

int main(){
  long long n;
  cin >> n;
  long long a[n];
  long long b[n];

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

  sort(b,b+n);
  
  for(int i=0;i<n;i++){
    if(a[i] == b[n-1]) cout << b[n-2] << endl;
    else cout << b[n-1] << endl;
  }
  
  return 0;
}

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

using namespace std;

int main()
{
    vector<int> masu(9);
    for(int i =0; i < 9; ++i){
            cin >> masu.at(i);
    }

    int n;
    cin >> n;
    vector<bool> bingo(9);
    for (int i = 0; i < n;++i)
    {
        int tmp;
        cin >> tmp;
        auto itr = find(masu.begin(), masu.end(), tmp);
        if (itr != masu.end())
        {
            bingo.at(std::distance(masu.begin(), itr)) = true;
        }
    }
    string res = "No";
    if (bingo.at(2) && bingo.at(4) && bingo.at(6)) res = "Yes";
    else if (bingo.at(0) && bingo.at(1) && bingo.at(2)) res = "Yes";
    else if (bingo.at(3) && bingo.at(4) && bingo.at(5)) res = "Yes";
    else if (bingo.at(6) && bingo.at(7) && bingo.at(8)) res = "Yes";
    else if (bingo.at(0) && bingo.at(3) && bingo.at(6)) res = "Yes";
    else if (bingo.at(1) && bingo.at(4) && bingo.at(7)) res = "Yes";
    else if (bingo.at(2) && bingo.at(5) && bingo.at(8)) res = "Yes";
    else if (bingo.at(0) && bingo.at(4) && bingo.at(8)) res = "Yes";

    cout << res << endl;
    return 0;
}


Measured memory_bytes: 504
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vi;
typedef pair<ll,ll> ii;
typedef vector<ii> vii;
#define all(v) v.begin(), v.end()
#define rep(i, from, to) for (ll i = from; i < ll(to); ++i)

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

    ll n;
    cin >> n;
    ii cur = {0,0};
    ll curt = 0;
    bool cr = true;
    rep(i,0,n) {
        ll t, x, y;
        cin >> t >> x >> y;
        ll dt = t - curt;
        curt = t;
        ll md = abs(x-cur.first) + abs(y-cur.second);
        cur = {x,y};
        if (md > dt) cr = false;
        if (md % 2 != dt % 2) cr = false;
    }

    if (cr)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;



    return 0;
}


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

using namespace std;

int main(){
  int n, t, mod=0, sum=0;
  cin >> n;
  t=n;
  while(n!=0){
    mod=n%10;
    sum+=mod;
    n/=10;
  }
  string ans;
  if(t%sum==0)ans="Yes";
  else ans="No";
  cout << ans << endl;
}

Measured memory_bytes: 256
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
// clang-format on

class UFT {
private:
  vi data, rnk, _size;

public:
  UFT(const int &n)
    : data(n), rnk(n), _size(n, 1) {
    iota(all(data), 0);
  }

  int root(const int &x) {
    return data[x] == x ? x : data[x] = root(data[x]);
  }

  bool same(const int &a, const int &b) {
    return root(a) == root(b);
  }

  void unite(int a, int b) {
    a = root(a), b = root(b);
    if (a == b) return;
    if (rnk[a] < rnk[b]) swap(a, b);
    data[b] = a;
    _size[a] += _size[b];
    if (rnk[a] == rnk[b]) rnk[a]++;
  }

  int size(int x) {
    return _size[root(x)];
  }
};

template<typename V>
constexpr string join(const V &v, const string &sep) {
  stringstream ss;
  if (v.size()) ss << v[0];
  loop(i, 1, v.size()) ss << sep << v[i];
  return ss.str();
}

main {
  int n, k, l;
  cin >> n >> k >> l;
  UFT a(n), b(n);
  auto f = [](int k, UFT &a) {
    while (k--) {
      int p, q;
      cin >> p >> q;
      a.unite(--p, --q);
    }
  };
  f(k, a);
  f(l, b);
  map<pii, int> m;
  rep(i, n) m[mp(a.root(i), b.root(i))]++;
  vi v(n);
  rep(i, n) v[i] = m[mp(a.root(i), b.root(i))];
  cout << join(v, " ") << endl;
}


Measured memory_bytes: 23172
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cmath>
#include<vector>
typedef long long ll;
using namespace std;
const int wa=1e9+7;
ll N;
int main(void) {
	cin >> N;
	int mi = 10;
	for (int i = 1; i <= (int)sqrt(N); i++) {
		if (N%i != 0)continue;
		ll u = N / i;
		int k = 0;
		while(u > 0) {
			k++;
			u /= 10;
		}
		mi = min(mi, k);
	}
	cout << mi << endl;
	return 0;
}



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

using namespace std;
typedef long long  ll;
#define rep(i,s,n)for(ll i = s;i<n;i++)

int digit(char* x) {
	int digit;
	rep(i, 0, 101) {
		if (x[i] == '\0') {
			digit = i;
			break;
		}
	}
	return digit;
}
int main() {
	char O[51], E[51]; cin >> O >> E;

	rep(i, 0, 52) {
		if (O[i] == '\0')break;
		cout << O[i];

		if (E[i] == '\0')break;
		cout << E[i];
	}
	cout << endl;

	return 0;
}

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

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

const long long INF = 1LL << 60;

int main(void){
	int n;cin >> n;
	vector<int> v(n+1,100000);
	v[0] = 0;v[1] = 1; 
	for(int i=1;i<=n;i++){
		int a = 6,b = 9;
		while(i-a>=0){
			chmin(v[i],v[i-a]+1);
			a *= 6;
		}
		while(i-b>=0){
			chmin(v[i],v[i-b]+1);
			b *= 9;
		}
		chmin(v[i],v[i-1]+1);
		//cout << i << "v[" << i << "]=" <<  v[i] << endl;
	}
	cout << v[n] << endl;
	return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
//cervello|Phoenix
using namespace std;
#define ll long long int
#define eb emplace_back
#define mk make_pair
#define all(x) x.begin(),x.end()
#define mod 1000000007

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int x; cin>>x;
  cout<<(x^1)<<"\n";
  return 0;
}

Measured memory_bytes: 3584
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;

int main(void)
{
    int x,a,b;
    cin >> x >> a >> b;
    if(a >= b){cout << "delicious" << endl;}
    else if(x + a >= b){cout << "safe" << endl;}
    else{cout << "dangerous" << endl;}
    return 0;
}

Measured memory_bytes: 256
N=int(input())
dp=[[[[0]*5 for i in range(5)] for j in range(5)] for k in range(N+1)]
dp[0][0][0][0]=1
for n in range(N):
    for i in range(5):
        for j in range(5):
            for k in range(5):
                for l in range(1,5):
                    if i==1 and j==2 and l==3:continue
                    if i==1 and k==2 and l==3:continue
                    if j==1 and k==2 and l==3:continue
                    if j==2 and k==1 and l==3:continue
                    if j==1 and k==3 and l==2:continue
                    dp[n+1][j][k][l]+=dp[n][i][j][k]
                    dp[n+1][j][k][l]%=(10**9+7)

ans=0
for i in range(1,5):
    for j in range(1,5):
        for k in range(1,5):
            ans+=dp[N][i][j][k]
            ans%=(10**9+7)
print(ans)


Measured memory_bytes: 48240
use std::io::*;

fn read_int() -> i64 {
  let mut buf = String::new();
  stdin().read_line(&mut buf).ok();
  buf.trim().parse().unwrap()
}

fn main() {
  let n = read_int();
  let ans = if n.to_string().chars().any(|c| c=='9') {"Yes"} else {"No"};
  println!("{}", ans);
}


Measured memory_bytes: 4352
#include <cstdio>

using namespace std;
#define MAX_N 25
#define NIL -1

struct Node {
	int parent;
	int left;
	int right;
	Node() :parent(NIL), left(NIL), right(NIL) {}
	~Node(){}
};

Node tree[MAX_N];

// ???????????????
void preParse(int id) {
	if (id == NIL) return;
	printf(" %d", id);
	preParse(tree[id].left);
	preParse(tree[id].right);
	return;
}

// ???????????????
void inParse(int id) {
	if (id == NIL) return;
	inParse(tree[id].left);
	printf(" %d", id);
	inParse(tree[id].right);
	return;
}


// ???????????????
void postParse(int id) {
	if (id == NIL) return;
	postParse(tree[id].left);
	postParse(tree[id].right);
	printf(" %d", id);
	return;
}

int main() {
	int n = 0;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		int id, l, r;
		scanf("%d%d%d", &id, &l, &r);
		tree[id].left = l;
		tree[id].right = r;
		if (tree[l].parent == NIL) {
			tree[l].parent = id;
		}
		if (tree[r].parent == NIL) {
			tree[r].parent = id;
		}
	}
	int root = 0;
	for (int i = 0; i < n; i++) {
		if (tree[i].parent == NIL) {
			root = i;
			break;
		}
	}
	printf("Preorder\n");
	preParse(root);
	printf("\n");
	printf("Inorder\n");
	inParse(root);
	printf("\n");
	printf("Postorder\n");
	postParse(root);
	printf("\n");
	return 0;
}

Measured memory_bytes: 2668
#include <stdio.h>

int main(void)
{
    int n=0,sum=0;
    int a[25]={},b[25]={},c[25]={};
    scanf("%d",&n);
    for(int i=0;i<n;i++) scanf("%d",&a[i]);
    for(int i=0;i<n;i++) scanf("%d",&b[i]);
    for(int i=0;i<n-1;i++) scanf("%d",&c[i]);

    for(int i=0;i<n;i++){
        sum+=b[i];
        if(a[i]+1==a[i+1]) sum+=c[a[i]-1];
    }

    printf("%d",sum);
    return 0;
}


Measured memory_bytes: 1708
import java.util.*;

public class Main{
  public static void main(String[] args) {
    Scanner sc=new Scanner(System.in);
    int x=sc.nextInt();
    int a=sc.nextInt();
    int b=sc.nextInt();

    if ((b-a)<=0) {
      System.out.println("delicious");
    }else{
      if ((b-a)<=x) {
        System.out.println("safe");
      }else{
        System.out.println("dangerous");
      }
    }
  }
}


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

int main() {
    int A, B;
   cin >> A >> B ;
   int sum=A+B;
   int sum1=A-B;
   int sum2=A*B;
   int answer=max(sum, sum1);
   int final=max(answer, sum2);
   cout << final <<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define int long long
#define mkp make_pair
#define pb push_back
#define ff first
#define ss second
#define debug1(a) cout<<a<<endl;
#define debug2(a,b) cout<<a<<' '<<b<<endl;
#define debug3(a,b,c) cout<<a<' '<<b<<' '<<c<<endl;
#define rep(i,n) for(int i=0;i<n;i++)
#define repre(i,a,b)for(int i=a;i<=b;i++)
#define clr1(arr) memset(arr,-1,sizeof(arr));
#define clr0(arr) memset(arr,0,sizeof(arr));
#define pi pair<int,int>
#define pii pair<int,pi>
#define aint(v) v.begin(),v.end()
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace __gnu_pbds;
using namespace std;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> orderedSet;
typedef tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update> orderedMSet;
struct custom_hash {
static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
#define ump gp_hash_table<int,int,custom_hash>
//*p.find_by_order(index) return value at index
//p.order_of_key(key) return index
/*int **dp,in main function,int row,col;dp=new int*[n];rep(i,n)dp[i]=new int[m]*/
//**** Maths Section*******/
int power(int x,int y);
bool isPrime(int n);
int modInv(int a,int b);
int gcdExtended(int a,int b,int *x,int* y);
int mpower(int a,int b,int p);
/***************************/
int32_t main()
{
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
  fastio
  int n;
  cin>>n;
  int arr[n];
  rep(i,n)cin>>arr[i];
  int cur=1;

  rep(i,n)
    if(arr[i]==cur)cur++;

  cur-=1;
  if(cur==0)cout<<-1<<endl;
  else cout<<n-cur<<endl;

  return 0;
}

int modInv(int a, int m)
{
int x, y;
int g = gcdExtended(a, m, &x, &y);
int res = (x%m + m) % m;
return res;
}

int gcdExtended(int a, int b, int *x, int *y)
{
if (a == 0){
    *x = 0, *y = 1;
    return b;
  }
  int x1, y1;
  int gcd = gcdExtended(b%a, a, &x1, &y1);
  *x = y1 - (b/a) * x1;
  *y = x1;
  return gcd;
}

int mpower(int x, int y, int p)
{
int res = 1;
x = x % p;
while(y > 0){
    if(y & 1) res = (res*x) % p;
      y = y>>1;
      x = (x*x) % p;
    }
    return res;
}
int power(int x, int y)
{
int res = 1;
while (y > 0){
    if (y & 1) res = res*x;
      y = y>>1;
      x = x*x;
    }
    return res;
}

bool isPrime(int n)
{
if (n <= 1)  return false;
  if (n <= 3)  return true;
    if (n%2 == 0 || n%3 == 0) return false;
      int p=sqrt(n);
      for(int i=5;i<=p;i=i+6)
        if (n%i == 0 || n%(i+2) == 0)
          return false;
      return true;
}


Measured memory_bytes: 1792
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int [] values = new int [3];
		for (int i = 0; i < 3; i++) {
			values[i] = sc.nextInt();
		}
		Arrays.sort(values);
		int val = values[2] * 10 + values[1];
		System.out.println(val + values[0]);
	}
}


Measured memory_bytes: 35736
#include <stdio.h>
#include <string.h>
int main(){
	int N;
	scanf("%d",&N);
	char zz[10000];
	scanf("%s",zz);
	int len = strlen(zz);
	char hasil[len];
	for (int i=0;i<len;i++){
		hasil[i] = zz[i]+N;
		if (hasil[i]>'Z'){
			hasil[i] -=26;
		}
	}
	for(int i=0;i<len;i++){
		printf("%c",hasil[i]);
	}
return 0;
}

Measured memory_bytes: 1672
#include<bits/stdc++.h>
using namespace std;
int n,eu,ev,sid,dis[2][100100];
vector<int> ga[100100];
void dfs(int u,int p){
	dis[sid][u]=dis[sid][p]+1;
	for(int v:ga[u])
		if(v!=p) dfs(v,u);
}
int main(){
	ios::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n;
	for(int i=1;i<n;i++){
		cin>>eu>>ev;
		ga[eu].push_back(ev);
		ga[ev].push_back(eu);
	}
	sid=0;dfs(1,0);
	sid=1;dfs(n,0);
	int fen,snu;
	fen=0;snu=0;
	for(int i=1;i<=n;i++){
		if(dis[0][i]<=dis[1][i]) fen++;
		else snu++;
	}
	if(fen>snu) cout<<"Fennec"<<endl;
	else cout<<"Snuke"<<endl;
	return 0;
}


Measured memory_bytes: 14436
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
h,w = map(int,readline().split())
lst1 = [list(map(int,readline().split())) for i in range(10)]

#まず、数字をiから１に変える時の最小コストを計算する。
from scipy.sparse.csgraph import shortest_path,floyd_warshall
from scipy.sparse import csr_matrix
lc = csr_matrix(lst1)
cost_lst = shortest_path(lc,method="FW")

#全探索でコストを求める。
ans = 0
for i in range(h):
    lst2 = list(map(int,readline().split()))
    for j in lst2:
        if j != -1:
            ans += cost_lst[j][1]

print(int(ans))


Measured memory_bytes: 17668
//ACCEPT????????????????????????Wrong Answer?????????????????£?????????????????????????????¨?????¨????????????
#include <iostream>
#include <string>
#include <tuple>
#include <algorithm>
using namespace std;

int T, P, R;
int team, prob, t; string mes;

bool isAccepted[50][10];
int acTimeSum[50];
int wrongCnt[50][10];

int main() {
	int i, j;
	
	while (cin >> T >> P >> R) {
		if (!T) break;
		for (i = 0; i < T; i++) {
			acTimeSum[i] = 0;
			for (j = 0; j < P; j++) {
				isAccepted[i][j] = false;
				wrongCnt[i][j] = 0;
			}
		}
		
		for (i = 0; i < R; i++) {
			cin >> team >> prob >> t >> mes;
			team--; prob--;
			if (mes == "CORRECT") {
				isAccepted[team][prob]++;
				acTimeSum[team] += t;
			}
			else {
				wrongCnt[team][prob]++;
			}
		}
		
		typedef tuple<int, int, int> Tuple;
		Tuple d[50];
		for (i = 0; i < T; i++) {
			int penalty = acTimeSum[i];
			int acCnt = 0;
			for (j = 0; j < P; j++) {
				if (isAccepted[i][j]) {
					acCnt++;
					penalty += 1200 * wrongCnt[i][j];
				}
			}
			d[i] = Tuple(-acCnt, penalty, i);
		}
		sort(d, d + T);
		
		for (i = 0; i < T; i++) {
			cout << get<2>(d[i]) + 1 << " " << -get<0>(d[i]) << " " << get<1>(d[i]) << endl;
		}
	}
	return 0;
}

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

int main()
{
	string ss;int ans;cin>>ss;
	int L=ss.length();ans=L;
	
	if(L==1){
		cout<<1<<endl;return 0;
	}
	
	for(int i=0;i<L-1;i++)
	{
		if(ss[i]!=ss[i+1])
			ans=min(ans,max(i+1,L-i-1));
	}
	cout<<ans<<endl;
	return 0;
}

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

const string YES = "Yes";
const string NO = "No";

void solve(long long a, long long b, long long c, long long d)
{
    cout << ((abs(a - c) <= d || (abs(a - b) <= d && abs(b - c) <= d)) ? YES : NO) << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main()
{
    long long a;
    scanf("%lld", &a);
    long long b;
    scanf("%lld", &b);
    long long c;
    scanf("%lld", &c);
    long long d;
    scanf("%lld", &d);
    solve(a, b, c, d);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define LLMAX (1ll << 60) - 1
#define INTMAX (1 << 30) - 1
#define MOD 1000000007 
#define NMAX 1000*100+1

#define numberOfSetBits(S) __builtin_popcount(S) // __builtin_popcountl(S) __builtin_popcountll(S)
#define MSET(x,y) memset(x,y,sizeof(x))
#define gcd(a,b) __gcd(a,b)
#define all(x)  x.begin(),x.end()
#define isOn(S, j) (S & (1 << j))
#define endl '\n'
#define setBit(S, j) (S |= (1 << j))
#define clearBit(S, j) (S &= ~(1 << j))
#define toggleBit(S, j) (S ^= (1 << j))
#define print(x)    for(auto it:x) cout<<it<<' '; cout<<endl;
#define printii(x)  for(auto it:x) cout<<it.F<<' '<<it.S<<'\t';  cout<<endl;
#define in(x,n)   for(int e=0;e<n;e++){ll y;cin>>y;x.pb(y);}

#define vi vector<ll>
#define vvi vector<vi>
#define ii pair<ll,ll>
#define pll pair<ll,ll>
#define vii vector<ii>
#define vvii vector<vii>
#define viii vector<pair<ii,ll>>
#define pb push_back
#define F first
#define S second
#define mp make_pair
#define mc(a,b,c) mp(mp(a,b),c)


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,x,t,m,y,z;

    for(int i=0;i<5;i++){
        cin>>x;
        if(!x)y = i+1;
    }
    cout<<y;
    
    return 0;
}

Measured memory_bytes: 3648
class myResi():
    def __init__(self):
        self.val=[[0]*10 for _ in range(3)]
    def __str__(self):
        ret = ''
        for i in range(3):
            ret += ' '+(str(self.val[i]).replace(',','')[1:10*2])+'\n'
        return ret.rstrip("\n")
    def setVal(self,f,r,v):
        self.val[f-1][r-1] += v
        
def fill(allb,b,f,r,v):
    bname=allb[b-1]
    bname.setVal(f,r,v)
    
b1=myResi()
b2=myResi()
b3=myResi()
b4=myResi()
allb=[b1,b2,b3,b4]
n=int(input())
for _ in range(n):
    b,f,r,v = map(int,input().split())
    fill(allb,b,f,r,v)
    
print(b1)
print('#'*20)
print(b2)
print('#'*20)
print(b3)
print('#'*20)
print(b4)

Measured memory_bytes: 7768