akhauriyash/Code-Regression huggingface dataset:
/* monkukui 競技プログラミング用のテンプレート  (ここから) */
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
using lint = long long int;
using ll = long long int;
using lnt = long long int;
using Graph = vector<vector<int>>;
using Wgraph = vector<vector<pair<int, long long int>>>;
constexpr long long int INF = 1001001001001001LL;
constexpr long long int MOD = 1000000007LL;
constexpr double PI = 3.1415926535897932;
constexpr long long int di[] = {-1, 0, 1, 0, -1, 1, 1, -1};
constexpr long long int dj[] = {0, 1, 0, -1, 1, 1, -1, -1};

template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
inline void yes(){ cout << "yes" << endl; }
inline void Yes(){ cout << "Yes" << endl; }
inline void YES(){ cout << "YES" << endl; }
inline void no(){ cout << "no" << endl; }
inline void No(){ cout << "No" << endl; }
inline void NO(){ cout << "NO" << endl; }
inline void possible(){ cout << "possible" << endl; }
inline void Possible(){ cout << "Possible" << endl; }
inline void POSSIBLE(){ cout << "POSSIBLE" << endl; }
inline void impossible(){ cout << "impossible" << endl; }
inline void Impossible(){ cout << "Impossible" << endl; }
inline void IMPOSSIBLE(){ cout << "IMPOSSIBLE" << endl; }

#define REP(i,n) for(int i = 0; i < (n); i++)
#define RREP(i,n) for(int i = 1; i <= (n); i++)
#define DREP(i,n) for(int i = (n)-1; i >= 0; i--)
#define SREP(i,s,t) for(int i = s; i < t; i++)
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define PB push_back

/* monkukui 競技プログラミング用のテンプレート (ここまで)*/

int main(){
  
  int a, b, c; cin >> a >> b >> c;
  if(a + b + c >= 22) cout << "bust" << endl;
  else cout << "win" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int H,W,i,j;
  while(1){
    scanf("%d %d",&H,&W);
    if(H==0&&W==0)
      break;

    for(i = 0; i < H ; i++ ){
       for ( j = 0; j < W; j++ ){
	 if((i+j)%2==1 ){
            printf(".");
        } else {
            printf("#");
        }
       }
       printf("\n");
    }
     printf("\n");
  }
  return 0;
}

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

string A0[36];

void isStable(string A[], int N){
    string check[36][4], check2[36][4], mark; 
    int i, j, index;
    for (i=0;i<N;i++){
        index = atoi(A[i].substr(1).c_str());
        mark = A[i].substr(0);
        for (j=0;j<4;j++){
            if (check[index][j]=="") {
                check[index][j] = mark;
                mark = "";
            }
        }
    }
    for (i=0;i<N;i++){
        index = atoi(A0[i].substr(1).c_str());
        mark = A0[i].substr(0);
        for (j=0;j<4;j++){
            if (check2[index][j]=="") {
                check2[index][j] = mark;
                mark = "";
            }
        }
    }
    string result = "Stable";
    for (i=0;i<36;i++){
        for(j=0;j<4;j++){
            if (check[i][j] != check2[i][j] ) result = "Not stable";
        }
    }
    cout << result << endl;
}

void Output(string A[], int N){
    int i;
    for(i=0;i<N;i++) cout << (i!=0?" ":"") << A[i];
    cout << endl;
    isStable(A, N);
}

void SelectionSort(string A[], int N){
    int i, j, min;
    for(i=0;i<N;i++){
        min = i;
        for(j=i;j<N;j++){
            if ( atoi(A[j].substr(1).c_str())<atoi(A[min].substr(1).c_str())) min = j;
        }
        swap(A[i], A[min]);
    }
    Output(A, N);
}

void BubbleSort(string A[], int N){
    int i, j;
    for (i=N-1;i>0;i--){
        for(j=0;j<i;j++){
            if ( atoi(A[j].substr(1).c_str())>atoi(A[j+1].substr(1).c_str()) ) swap(A[j],A[j+1]);
        }
    }
    Output(A, N);
}

int main(){
    int N, i;
    string temp, A1[36], A2[36];
    cin >> N;
    for (i=0;i<N;i++) {
        cin >> temp;
        A0[i] = A1[i] = A2[i] = temp;
    }
    BubbleSort(A1, N);
    SelectionSort(A2, N);
    return 0;
}








Measured memory_bytes: 3212
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
template<class T,class U> inline bool chmin(T&x,U y){if(x>y){x=y;return true;}return false;}
template<class T,class U> inline bool chmax(T&x,U y){if(x<y){x=y;return true;}return false;}
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int a,b,k;
    cin>>k>>a>>b;
    for(;a<=b;++a) if(a%k==0) return puts("OK"),0;
    puts("NG");
}

Measured memory_bytes: 3656
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

s = list(input())
s = [int(i) for i in s]

for fl in itertools.product([0,1],repeat=3):
    cnt = s[0]
    for i,t in enumerate(fl):
        if t==0:
            cnt += s[i+1]
        else:
            cnt -= s[i+1]
    if cnt == 7:
        L = str(s[0])
        for i,t in enumerate(fl):
            if t==0:
                L += '+' + str(s[i+1])
            else:
                L += '-' + str(s[i+1])
        print(L + '=7')
        break

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

struct Interval { int first, last; };

Interval intersection(const Interval a, const Interval b)
{
    return {max(a.first, b.first), min(a.last, b.last)};
}

int length(const Interval a)
{
    return a.last >= a.first ? a.last-a.first+1 : 0;
}

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

    auto T = vector<int>(N);
    for (auto& x : T) cin >> x;

    auto A = vector<int>(N);
    for (auto& x : A) cin >> x;

    auto ranges = vector<Interval>(N, {1, numeric_limits<int>::max()});

    for (auto i = 0; i < N; i++)
    {
        auto constraint = Interval{1, T[i]};
        if (i == 0 || T[i] > T[i-1]) constraint.first = T[i];
        ranges[i] = intersection(ranges[i], constraint);
    }

    for (auto i = N-1; i >= 0; i--)
    {
        auto constraint = Interval{1, A[i]};
        if (i == N-1 || A[i] > A[i+1]) constraint.first = A[i];
        ranges[i] = intersection(ranges[i], constraint);
    }

    const auto mod = int(1e9+7);
    auto result = 1LL;
    for (const auto i : ranges)
        result = result * length(i) % mod;

    cout << result << endl;
}


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

#define for_(i,a,b) for(int i=a;i<b;++i)
#define ALL(a) a.begin(),a.end()
#define INIT(a,b) memset(a,b,sizeof(a))
using lint = long long int;

int N, A[81];
lint dp[81][81];

int main() {
    cin >> N;
    for_(i,0,N) cin >> A[i];

    INIT(dp, -1);
    dp[0][0] = 1000;
    for_(i,0,N-1) for_(j,0,N) {
        if (dp[i][j] == -1) continue;

        int nx = i + 1;
        dp[nx][j] = max(dp[nx][j], dp[i][j]);

        int mn = 200;
        for_(k,j,nx) mn = min(mn, A[k]);
        lint c = dp[i][j] / mn;
        lint val = dp[i][j] + (A[nx] - mn) * c;
        dp[nx][nx] = max(dp[nx][nx], val);
    }

    lint ans = 1000;
    for_(i,0,N) for_(j,0,N) ans = max(ans, dp[i][j]);
    cout << ans << endl;
}

Measured memory_bytes: 3664
import java.io.*;
import java.util.*;
class Main{
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		int n = saori.saori_hayami();
		int m = saori.saori_hayami();
		
		int one = -1;
		int fiv = -1;
		int min = -1;
		boolean flg = false;

		for(int x = 0;x < n+1;x++){
			for(int y = n-x;y>=0;y--){
				int z = n-x-y;
				if(m == 1000*x + 5000*y + 10000*z){
					one = x;
					fiv = y;
					min = z;
					flg = true;
					break;
				}
			}
			if(flg){
				break;
			}
		}
		System.out.println(min + " " + fiv + " " + one);
		
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

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

int main(){
  int a,b,j=0;
  vector<int> height(1000);
  for(int i=1;i<1000;i++){
    j+=i;
    height.at(i-1)=j;
  }
  cin >> a >> b;
  cout << height.at(b-a-2)-a << endl;
}


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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<P> VP;
typedef vector<vector<ll>> VV;
typedef vector<vector<int>> VVi;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
const ll INF=9*1e18+18;
const ll MAX=100005;
const ll MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgarr(n,m,arr) rep(i,n){rep(j,m){cerr<<arr[i][j]<<" ";}cerr<<endl;}
#define dbgdp(n,arr) rep(i,n){cerr<<arr[i]<<" ";}cerr<<endl;
#define Uniq(v) v.erase(unique(v.begin(), v.end()), v.end())
#define fi first
#define se second

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

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

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

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

    ll n,k;
    cin>>n>>k;

    VP point;
    Vec x(n);
    Vec y(n);
    rep(i,n){
        ll tmp1,tmp2;
        cin>>tmp1>>tmp2;
        x[i] = tmp1;
        y[i] = tmp2;
        point.pb(mp(tmp1,tmp2));
    }
    sort(ALL(x));
    sort(ALL(y));
    ll ans=INF;

    rep(tx_i,n)rep(sx_i,tx_i)rep(ty_i,n)rep(sy_i,ty_i){
        ll &tx = x[tx_i];
        ll &sx = x[sx_i];
        ll &ty = y[ty_i];
        ll &sy = y[sy_i];
        ll cnt = 0;
        rep(i,n){
            P &p = point[i];
            if(p.fi>=sx&&p.fi<=tx){
                if(p.se>=sy&&p.se<=ty){
                    cnt++;
                }
            }
        }
        if(cnt>=k){
            chmin(ans,(tx-sx)*(ty-sy));
        }
    }

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define mod 998244353

int a[200005], ans = 0, n;
signed main(){
	cin >> n;
	for(int i = 1 ; i <= n ; i ++) cin >> a[i];
	for(int l = 1, r = 1, s = 0, x = 0 ; l <= n ; l ++){
		while(r <= n && ((s + a[r]) == (x ^ a[r]))){
			s += a[r]; x ^= a[r]; ans += (r - l + 1); r ++;
		}
		s -= a[l]; x ^= a[l]; 		
	}
	cout << ans;
}


Measured memory_bytes: 1792
testCase = Array.new
i = 0
STDIN.each_line do |line|
  testCase[i] = line.to_i
  i += 1
end
testCase.length.times do |i|
counter = 0
 10.times do |a|
   10.times do |b|
     10.times do |c|
       10.times do |d|
        if a+b+c+d == testCase[i]
          counter += 1
        end
      end
    end
  end
end
puts counter
end

Measured memory_bytes: 8464
#include "bits/stdc++.h"
#define ll long long
#define rep2(i,a,b) for(int i=(a);i<=(b);++i)
#define rep(i,n) rep2(i,0,n-1)
int MOD=1000000000+7;

using namespace std;
string alphabet("abcdefghijklmnopqrstuvwxyz");

main(){
    int n;
    cin>>n;
    int a[n];
    int four=0,one=0;
    rep(i,n){
        cin>>a[i];
        if(!(a[i]%4)) four++;
        else if(a[i]%2) one++;
    }
    if(four>=one) { cout<<"Yes"; return 0;}
    else if(four==one-1&&four+one==n) { cout<<"Yes"; return 0;}
    cout<<"No";
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

using namespace std;

typedef long long int lli;
typedef pair<int, int> ii;

template<class T>bool chmax(T &a, const T &b) { if( a < b ) { a = b; return 1; } return 0;}
template<class T>bool chmin(T &a, const T &b) { if( b < a ) { a = b; return 1; } return 0;}

#ifdef LOCAL
	#define eprintf(...) printf(__VA_ARGS__)
#else 
	#define eprintf(...) 1
#endif

#define ROUNDUP(a, b) 		( ((a) + ((b) - 1) ) / b)
#define SET_ZERO(a)	 		( memset((a), 0, sizeof(a)))
#define SET_NUM_ARRAY(a,b)	( memset((a), b, sizeof(a)))
//#define int long long int //dont forget to change int to signed

#define waru (1000*1000*1000+7)

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

	lli n = 1, m = 1;
	for (lli i = 1; i <= N; i++) {
		n = (n*i)%(waru);
	}

	for (lli j = 1; j <= M; j++) {
		m = (m*j)%(waru);
	}
	lli ans = 0;
	if (N == M) {
		ans = (n * m * 2)%waru;
	} else if (N == M + 1 || N + 1 == M) {
		ans = (n * m)%waru;
	}

	printf("%lld \n", ans);
	return 0;
}

	


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

public class Main {
    void run() {
        int N = readInt();
        int M = readInt();
        int L = readInt();
        int[][] A = new int[N][M];
        for (int i = 0; i < N; i++) {
            for (int j = 0; j < M; j++) {
                A[i][j] = readInt();
            }
        }
        int[][] B = new int[M][L];
        for (int i = 0; i < M; i++) {
            for (int j = 0; j < L; j++) {
                B[i][j] = readInt();
            }
        }
        long[][] C = new long[N][L];
        for (int i = 0; i < N; i++) {
            for (int k = 0; k < M; k++) {
                for (int j = 0; j < L; j++) {
                    C[i][j] += A[i][k] * B[k][j];
                }
            }
        }
        for (int i = 0; i < N; i++) {
            for (int j = 0; j < L; j++) {
                if (j > 0) sysout.print(' ');
                sysout.print(C[i][j]);
            }
            sysout.println();
        }
    }

    public static void main(String[] args) {
        new Main().run();
    }

    // flush automatically iff you call `println` or `printf` or `format`.
    PrintWriter sysout = new PrintWriter(System.out, true);

    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer buffer = null;

    String readLine() {
        buffer = null;
        try {
            return in.readLine();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    String read() {
        if (buffer == null || !buffer.hasMoreTokens()) {
            buffer = new StringTokenizer(readLine());
        }
        return buffer.nextToken();
    }

    int readInt() {
        return Integer.parseInt(read());
    }

    long readLong() {
        return Long.parseLong(read());
    }

    double readDouble() {
        return Double.parseDouble(read());
    }
}

Measured memory_bytes: 27412
import sys
import math
import itertools
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7

x1 = l()
for i in range(5):
    if i+1 != x1[i]:
        print(i+1)

Measured memory_bytes: 9960
/*
 ------------------------------------------------------Read question very carefully------------------------------------------------------
 
                       In every question first approach must be basic, atleast give 15 mins for try to solve in basic approach
*/
 #include<iostream>
 #include<cstring>
 #include<string>
 #include<vector>
 #include<utility>
 #include<stdlib.h>
 #include<limits.h>
 #include<cmath>
 #include<set>
 #include<initializer_list>
 #include<unordered_set>
 #include<unordered_map>
 #include<map>
 #include<iomanip>
 #include<algorithm>
 #include<queue>
 #include<stack>
  
 #define sze 1000005
 #define ld long double
 //#define ll unsigned long long
 #define ll long long
 #define endl "\n"
 #define pb push_back
 #define mkp make_pair
 #define mod 1000000007
 #define ff first
 #define ss second
 #define F(i,a,b) for(int i = (int)(a); i <= (int)(b); i++)
 #define RF(i,a,b) for(int i = (int)(a); i >= (int)(b); i--)
 #define all(c) (c).begin(),(c).end()
 #define pi                   pair<int,int>
 #define pll                  pair<ll,ll>
  
 using namespace std;

//cout << fixed << setprecision(0) << pi <<" "<<npi<<endl;
 //const ll inf=1ll<<60;
 //const double pi = 3.14159265358979323846;

ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
      
}
ll binpow(ll a, ll b) {
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = (res%mod * a%mod)%mod;
        a = (a%mod * a%mod)%mod;
        b >>= 1;
    }
    return res;
}
//const int N=300005;

 int main()
 {
     ios_base::sync_with_stdio(false);
     cin.tie(NULL);
     ll a,b; cin>>a>>b;
     cout<<a*b<<endl;
 }


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

int main(){
  int N,K,Z=0,A;
  cin>>N>>K;
  vector<int> p(N);
  for(int i=0;i<N;i++){
    cin>>p[i];
    p[i]++;
    if(i<K){
      A+=p[i];
    }
  }
  Z=A;
  for(int i=K;i<N;i++){
    Z-=p[i-K];
    Z+=p[i];
    A=max(A,Z);
  }
  double E=A,P=2;
  cout<<fixed<<setprecision(15);
  cout<<E/P<<endl;
}

Measured memory_bytes: 3924
#include<cstdio>
#include<functional>
#include<algorithm>
using namespace std;
int main(void)
{
	int n,d[300001],i,flg1,flg2,mx;
	scanf("%d",&n);
	for(i=0;i<n;i++)	scanf("%d",&d[i]);
	flg1=1;	mx=0;
	for(i=0;i<n-1;i++)	{
		mx=max(mx,i*10+d[i]);
		if(mx<(i+1)*10)	{
			flg1=0;	break;
		}
	}
	for(i=0;i<n/2;i++)	swap(d[i],d[n-i-1]);
	flg2=1;	mx=0;
	for(i=0;i<n-1;i++)	{
		mx=max(mx,i*10+d[i]);
		if(mx<(i+1)*10)	{
			flg2=0;	break;
		}
	}	
	if(flg1==1 && flg2==1)	printf("yes\n");
	else printf("no\n");
	return 0;
}


Measured memory_bytes: 3772
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = (int)1e9 + 7;
const int INF = (int)100100100;

int main() {
    //ll N; cin >> N;
    ll N,M; cin >> N >> M;
    //string S; cin >> S;
    //ll H,W; cin >> H >> W;
    if(M==1)cout << 0;
  	else cout << N-M;
    


}

/*



 */


Measured memory_bytes: 256
i = [int(i) for i in input().split()]
N,C = i[0],i[2]
B = [int(i) for i in input().split()]
ans = 0
for _ in range(N):
    s = 0
    for i, a in enumerate(input().split()):
        s += int(a) * B[i]
    ans += 1 if s + C > 0 else 0
print(ans)


Measured memory_bytes: 3060
#ifdef DEBUG

#else

#    pragma GCC optimize("O3,no-stack-protector")
#    pragma GCC optimize("unroll-loops")

#    if __cplusplus < 201703L
#        pragma GCC target("avx")
#    else
#        pragma GCC target("avx2")
#    endif

#endif
// 実数の場合
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;
typedef long double Ld;

using namespace std;
using Graph = vector<vector<Int>>;

const Ld pi = M_PI;
const Int MOD = 1000000007;

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

    Ld a, b, h, m;
    cin >> a >> b >> h >> m;

    Ld aa = ((Ld)60.0 * h + m) / (Ld)12.0 / (Ld)60.0, bb = m / (Ld)60.0;
    Ld theta = (Ld)2.0 * pi * (aa - bb);

    cout << fixed << setprecision(15) << sqrtl(a * a + b * b - (Ld)2.0 * a * b * cosl(theta)) << endl;

    return 0;
}

Measured memory_bytes: 4184
#include <vector>
#include <string>
#include <iostream>
#include <queue>
#include <algorithm>
#include <functional>
#include <map>
#include <array>
#include <cmath>

long long PRIME = 1e9 + 7;
using namespace std;


int main(){ 
    long long A, B;
    cin >> A >> B;

    if(A != 1 && B != 1){
        cout << 1;
    }
    else if(A !=2 && B != 2){
        cout << 2;
    }
    else{
        cout << 3;
    }


}



Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#include<cmath>



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

using namespace std;
set<int> s;
int n;
int main(){
  cin >> n;
  REP(i,n){
    int k;
    cin >> k;
    s.insert(k);
  }
  cout << s.size() << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdint.h>
#include <algorithm>
#include <bitset>
#include <functional>
#include <iostream>
#include <string>
#include <vector>

int main(int argc, char *argv[]) {
  int a;
  std::cin >> a;
  int b = a / 1000 % 10, c = a / 100 % 10, d = a / 10 % 10, e = a % 10;
  std::cout << ((b == c && c == d) || (c == d && d == e) ? "Yes" : "No")
            << std::endl;
  ;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
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;

const int MAX_N = 110;
const int MAX_V = 100100;

// 入力
int N;
long long W, weight[MAX_N], value[MAX_N]; // 品物の個数は 100 個なので少し余裕持たせてサイズ 110 に

// DPテーブル
long long dp[MAX_N][MAX_V];

int main() {
    cin >> N >> W;
    for (int i = 0; i < N; ++i) cin >> weight[i] >> value[i];

    // 初期化
    for (int i = 0; i < MAX_N; ++i) for (int j = 0; j < MAX_V; ++j) dp[i][j] = INF;

    // 初期条件
    dp[0][0] = 0;

    // DPループ
    for (int i = 0; i < N; ++i) {
        for (int sum_v = 0; sum_v < MAX_V; ++sum_v) {

            // i 番目の品物を選ぶ場合
            if (sum_v - value[i] >= 0) chmin(dp[i+1][sum_v], dp[i][sum_v - value[i]] + weight[i]);

            // i 番目の品物を選ばない場合
            chmin(dp[i+1][sum_v], dp[i][sum_v]);
        }
    }

    // 最適値の出力
    long long res = 0;
    for (int sum_v = 0; sum_v < MAX_V; ++sum_v) {
        if (dp[N][sum_v] <= W) res = sum_v;
    }
    cout << res << endl;
}

Measured memory_bytes: 89660
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> p2;
ll p[3005],fac[3005],inv[3005],cnt[3005],dp[3005],pd[3005],hell=998244353;
ll exp(ll x,ll y){
	ll res=1;
	x%=hell;
	while(y>0){
		if(y&1)
		res=(res*x)%hell;
		y>>=1;
		x=(x*x)%hell;
	}
	return res;
}
ll bin(ll n,ll r){
	ll res=fac[n];
	res*=inv[r];
	res%=hell;
	res*=inv[n-r];
	res%=hell;
	return res;
}
void solve(){
	ll n,s;
	cin>>n>>s;
	for(ll i=0;i<n;i++){
		ll x;
		cin>>x;
		cnt[x]++;
	}
	pd[0]=1;
	for(ll i=1;i<=3000;i++)
	if(cnt[i]){
		for(ll sum=0;sum<=s;sum++)
		for(ll j=0;j<=cnt[i];j++)
		if(sum>=j*i){
			ll val=(pd[sum-j*i]*p[cnt[i]-j])%hell;
			val*=bin(cnt[i],j);
			val%=hell;
			dp[sum]=(dp[sum]+val)%hell;
		}
		for(ll j=0;j<=s;j++){
			pd[j]=dp[j];
			dp[j]=0;
		}	
	}
	cout<<pd[s];
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    p[0]=fac[0]=inv[0]=1;
    for(ll i=1;i<3005;i++)
    p[i]=(2*p[i-1])%hell;
    for(ll i=1;i<3005;i++){
		fac[i]=(i*fac[i-1])%hell;
		inv[i]=exp(fac[i],hell-2);
	}
	ll qc=1;
    for(ll i=1;i<=qc;i++)
    solve();
}


Measured memory_bytes: 3784
fun main(args: Array<String>) {
    data class Cookies(val a: Long, val b: Long, val c: Long) {
        fun invalid(): Boolean {
            return a % 2 == 1L || b % 2 == 1L || c % 2 == 1L
        }
    }

    var cookies = readLine()?.split(" ")?.map(String::toLong)?.let { Cookies(it[0], it[1], it[2]) } ?: return
    val history = hashMapOf<Cookies, Boolean>()
    if (cookies.invalid()) {
        println("0")
        return
    }
    var i = 1
    while (true) {
        val a = cookies.b / 2 + cookies.c / 2
        val b = cookies.a / 2 + cookies.c / 2
        val c = cookies.a / 2 + cookies.b / 2
        cookies = Cookies(a, b, c)
        if (history.containsKey(cookies)) {
            println("-1")
            return
        }
        if (cookies.invalid()) {
            println((i).toString())
            return
        }
        history[cookies] = true
        i++
    }
}


Measured memory_bytes: 37848
#include<bits/stdc++.h>
using namespace std;
 
int main()
{
    string str,str1,str2;
    cin>> str;
    
    str1 = str.substr(0,2);
    str2 = str.substr(2,2);
  
    if (stoi(str1)<=12 && stoi(str1)>0 && stoi(str2)<=12 && stoi(str2)>0)
        cout<<"AMBIGUOUS\n";   
    else if(stoi(str1)<=12 && stoi(str1)>0)
        cout<<"MMYY\n";
    else if(stoi(str2)<=12 && stoi(str2)>0)
        cout<<"YYMM\n";
    else
        cout<<"NA\n";
   
    return 0;
}

Measured memory_bytes: 3584
fun main(args: Array<String>) {
    val (n, k) = readLine()!!.split(" ").map { it.toLong() }
    if (n == 0L || k == 1L || n == k) {
        println(0)
        return
    }
    if (n == 1L) {
        println(1)
        return
    }

    if ((n / k) <= 0) {
        val ans1 = Math.abs(n - k)
        val ans2 = Math.abs(k - ans1)
        val result = Math.min(n, Math.min(ans1, ans2))
        println(result)
        return
    }

    val ans1 = n % k
    val ans2 = k % ans1
    val result = Math.min(ans1, ans2)
    println(result)
}

Measured memory_bytes: 36132
#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) (v).begin(),(v).end()
#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; }

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pll> pip;
const ll INF = 1ll<<29;
const ll MOD = 1000000007;
const double EPS  = 1e-9;

int H, W;
int maps[15][15];
ll dp[15][15];

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

int main() {
	while (cin >> W >> H, H || W) {
		REP(i, H) REP(j, W) scanf("%d", &maps[i][j]);
		
		memset(dp, 0, sizeof(dp));
		REP(j, W) dp[0][j] = maps[0][j] != 1;
		
		REP(i, H - 1) REP(j, W) if (dp[i][j]) {
			
			if (maps[i][j] == 2) { // jump
				if (i + 2 < H && maps[i + 2][j] == 1) continue;
				dp[min(i + 2, H - 1)][j] += dp[i][j];
			}
			else { // normal
				REP(k, 3) {
					int yy = i + dy[k], xx = j + dx[k];
					if (!(yy >= 0 && yy < H && xx >= 0 && xx < W)) continue;
					if (maps[yy][xx] == 1 || (k != 1 && maps[yy][xx] == 2)) continue;
					dp[yy][xx] += dp[i][j];
				}
			}
		}
		
		ll ans = 0;
		REP(j, W) ans += dp[H - 1][j];
		cout << ans << endl;
	}
	return 0;
}

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

#define endl '\n'
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define lfs <<fixed<<setprecision(10)<<
#define test cout<<"test"<<endl;
#define fi first
#define se second
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = n; i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = n - 1; i >= (ll)(m); i--)
using ll = long long;
using ld = long double;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T>
void chmin(T &a,T b){if(a>b)a=b;}
template<typename T>
void chmax(T &a,T b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void pmod(ll &a,ll b,ll c){a=(b+c)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void qmod(ll &a,ll b,ll c){a=(b*c)%MOD;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>v,ll n){if(n!=0)cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
template<typename T>
vector<ll>dx={1,0,-1,0,1,1,-1,-1};
vector<ll>dy={0,1,0,-1,1,-1,1,-1};
template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}

int main(){
  cin.tie(NULL);
  ios_base::sync_with_stdio(false);
  ll res=0,res1=INF,res2=-INF,buf=0;
  bool judge = true;
  ll n,k;cin>>n>>k;
  vector<ll>h(n);
  rep(i,0,n)cin>>h[i];
  rep(i,0,n){
    if(h[i]>=k)res++;
  }
  cout<<res<<endl;
  return 0;
}

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

int main() {
  int n,k;
  cin >> n >> k;
  int ans = 0;
  
  for(int i = 0;i<n; i++){
      int x;
      cin>>x;
      if(x*2<k){
          ans+= x*2;
      }
      else{
          ans+=(k-x)*2;
      }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include<list>
#include <algorithm>
#include <string>
#include <math.h>
#include<map>
#include <utility>
#include <iomanip>
#include<queue>
#include <iomanip>
#include<set>
using namespace std;
#define REP(i,k,n) for(int i=k;i<n;i++)
 
#define INF 1844674407370955161
typedef long long int ll;
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
#define MOD 1000000007



int main()
{
    ll N,K,Q;
    cin>>N>>K>>Q;
    ll A[Q];
    ll s[N];
    REP(i,0,N){
        s[i]=0;
    }
    REP(i,0,Q){
        cin>>A[i];
        A[i]--;
        s[A[i]]++;
    }
    REP(i,0,N){
        if(K-Q+s[i]>0){
            cout<<"Yes"<<endl;
        }else{
            cout<<"No"<<endl;
        }
    }
    
    return 0;
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)

vector<bool> done(100000, false);
vector<int> G[100000];


void dfs(int i) {
  done[i] = true;
  for (auto&& v: G[i]) {
    if (done[v]) continue;
    dfs(v);
  }
}

int main() {
  int n,m; cin >> n >> m;
  loop(i,0,m) {
    int a, b;
    cin >> a >> b;
    a--;b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }

  int ans = 0;
  loop(i,0,n) {
    if (done[i]) continue;
    ans++;
    dfs(i);
  }
  cout << ans-1 << endl;
  return 0;
}


Measured memory_bytes: 9608
#include <bits/stdc++.h>
using namespace std;
using vi=vector<int>;
using vvi=vector<vi>;
using vs=vector<string>;
using msi=map<string,int>;
using mii=map<int,int>;
using pii=pair<int,int>;
using vlai=valarray<int>;
using ll=long long;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1e9
#define EPS 1e-9

int main(){
	ll a,b,x;
	cin>>a>>b>>x;
    auto f=[&](ll n){return n!=-1?n/x+1:0ll;};
	cout<<f(b)-f(a-1)<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>

using namespace std;

int main() {
	int a, b, d, r;
	double f;
		
	cin >> a >> b;

	d = a / b;
	r = a % b;
	f = (double)a / (double)b;

	printf("%d %d %f\n", d, r, f);

	return 0;
}

Measured memory_bytes: 1188
#include <iostream>
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <iomanip>
#include <string>
#include <queue>
#include <numeric>
#include <functional>
#include <array>
#include <map>
#include <set>

#define INF 1000000007 //1000000000000000003
#define MOD 1000000007
#define MAX 2000005

#define ll long long

//printf("%.10f", );
//cout << fixed << setprecision(10) << heikin << endl;
//vector<vector<int>> data(3, vector<int>(4, -1));
//left + 1 < top

using namespace std;
using P = pair<long long, long long>;
using T = tuple<int, int, int>;
using edge = struct { int to; long long dist; };
const double PI = 3.141592653589793;
long long fact[MAX], inv[MAX];
int dx[] = { -1,0,1,0 };
int dy[] = { 0,-1,0,1 };

//////////////////////////////////

vector<vector<int>> tree(100005);
int color[100005];
map<P, int>colorMap;
int m = 0;

struct BridgeInfo {
	int town1;
	int town2;
	int year;
	BridgeInfo(int t1, int t2, int y) {
		town1 = t1;
		town2 = t2;
		year = y;
	}
};

struct People {
	int index;
	int town;
	int year;
	People(int i, int t, int y) {
		index = i;
		town = t;
		year = y;
	}
};

bool compare_by_second(pair<int, int> a, pair<int, int> b) {
	if (a.second != b.second) {
		return a.second < b.second;
	}
	else {
		return a.first < b.first;
	}
}

struct UnionFind {
	vector<int>uf;
	
	UnionFind(int size) :uf(size, -1) {};

	int root(int target) {
		if (uf[target] < 0)return target;
		else return uf[target] = root(uf[target]);
	}

	void merge(int a, int b) {
		a = root(a);
		b = root(b);
		if (a == b)return;
		if (uf[b] < uf[a])swap(a, b);
		uf[a] += uf[b];
		uf[b] = a;
	}
};

ll CalcPow(ll num, ll power) {
	if (power == 0)return 1;
	if (power % 2 == 0) {
		ll half = CalcPow(num, power / 2);
		return (half * half) % MOD;
	}
	else return (num * CalcPow(num, power - 1)) % MOD;
}

ll combination(ll all, ll select) {
	if (all < select) return 0;
	if (all < 0 || select < 0) return 0;
	return fact[all] * (inv[select] * inv[all - select] % MOD) % MOD;
}

void initCombination(int max) {
	fact[0] = fact[1] = 1;
	for (int i = 2; i <= max; ++i) {
		fact[i] = fact[i-1] * i % MOD;
	}

	inv[max] = CalcPow(fact[max], MOD - 2);
	for (int i = max - 1; 0 <= i; --i) {
		inv[i] = (inv[i + 1] * (i + 1)) % MOD;
	}
}

void dfs(int from) {
	int c = 1;
	for (auto t : tree[from]) {
		c = c != color[from] ? c : c + 1;
		color[t] = c;
		colorMap[make_pair(from, t)] = c;
		m = max(c, m);
		dfs(t);
		c++;
	}
}

int cnt;
int target;
void calc(int c) {
	cnt -= (target / c);
	target %= c;
}

int main() {
	int x;
	cin >> x;
	cnt = x / 100;
	target = x % 100;

	int ans = 0;
	for (int i = 5; 1 <= i;--i) {
		calc(i);
		if (cnt < 0 || target == 0)break;
	}
	if (target == 0 && 0 <= cnt)ans = 1;
	cout << ans << endl;	
}

Measured memory_bytes: 2560
#![allow(unused_macros)]

// cf. [Rustで競技プログラミングの入力をスッキリ記述するマクロ - Qiita](https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8)
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        N: usize,
        a: [u32; N],
    }
    use std::collections::HashSet;
    let mut to_red = HashSet::new();
    let mut over_red = 0;
    for i in 0..a.len() {
        match d2c(a[i]) {
            '金' => over_red += 1,
            x => {to_red.insert(x); ()},
        }
    }
    println!("{} {}", if to_red.is_empty() { 1 } else {to_red.len()}, to_red.len() + over_red);
}

fn d2c(d: u32) -> char {
    match d / 400 {
        0 => '灰',
        1 => '茶',
        2 => '緑',
        3 => '水',
        4 => '青',
        5 => '黄',
        6 => '橙',
        7 => '赤',
        _ => '金',
    }
}


Measured memory_bytes: 4352
object Main{
  def main(args: Array[String]){
    val s = new java.util.Scanner(System.in)

    val a = s.nextInt
    val b = s.nextInt
    val c = s.nextInt
    val d = s.nextInt

    if(a + b == c + d){
      println("Balanced")
    } else if (a + b > c + d){
      println("Left")
    } else {
      println("Right")
    }
  }
}



Measured memory_bytes: 25920
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <iostream>
using namespace std;
int a[105];
int main(){
	int n;
	scanf("%d",&n);
	int sum = 0;
	for(int i = 1; i <= n; i++){
		scanf("%d",&a[i]);
		sum += a[i];
	}
	sort(a+1,a+1+n);
	int ans = 0;
	for(int i = n; i >= 1; i-=2) ans += a[i];
	printf("%d\n",ans-(sum-ans));
	return 0;
}

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

int main()
{
    ll n;
    cin>>n;
    ll arr[n];
    
    for(ll i=0;i<n;i++)
    {
        cin>>arr[i];
    }
    
    ll check=1,cnt=0,flg=0;
    
    for(ll i=0;i<n;i++)
    {
        if(arr[i]==check)
        {
            flg=1;
            check+=1;
        }
        else
            cnt++;
    }
    
    if(flg==1)
        cout<<cnt<<"\n";
    else
        cout<<-1<<"\n";
    return 0;
}    


Measured memory_bytes: 1792
// --------------------<optimizations>--------------------
#pragma GCC optimize("O3")
//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)\
#pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN TRYING TO BRUTEFORCE WITH A LOT OF LOOPS)\
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>

using namespace std;

#define ll long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pii pair<ll,ll>
#define vpii vector<pair<ll,ll> >
#define F first
#define S second
#define ld long double
#define built __builtin_popcountll
#define mst(a,i) memset(a,i,sizeof(a))
#define all(x) x.begin(),x.end()
#define itit(it,a) for(auto it=(a).begin(); it!=(a).end(); it++)
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define repr(i,a,b) for(ll i=a; i>b; i--)
#define reprr(i,a,b) for(ll i=a; i>=b; i--)
#define pi 3.14159265358979323846264338327950288419716939937510582097494459230
ll max3(ll x,ll y,ll z) {return max(max(x,y),z);}
ll min3(ll x,ll y,ll z) {return min(min(x,y),z);}
const ll M=2e5+10,M2=1e6+10,mod=1e9+7,inf=1e17+10;
void add(int& a, int b) {a+=b;if(a>=mod){a-=mod;}}
#define trace1(x)			 	 cerr<<#x<<": "<<x<<endl
#define trace2(x, y)		 	 cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)		 	 cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)	 	 cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)	 cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
int X[] = {0, 1, 0, -1};
int Y[] = {-1, 0, 1, 0};
ll power(ll x,ll n){ll result=1;while(n>0){if(n%2==1)result=(result*x)%mod; x=((x%mod)*(x%mod))%mod;n=n/2;}return result;}


int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll a[3];
	cin >> a[0] >> a[1] >> a[2];
	ll k;
	cin >> k;
	sort(a,a+3);
	a[2]=a[2]*pow(2,k);
	cout << a[0]+a[1]+a[2];
	return 0;
}
/* The judge is never wrong! Your code is buggy 
   Look for:
 * * Read the problem carefully.
 * * Don't forget to sort(), mod, ll!!!!
 * * Initial value = +/- infinity instead of zero!!!
 * * an easier and alternate approach
 * * read the problem statement carefully
 * * if concept is correct and still WA, try with a different implementation
 * * special cases (n=1?)
 * * if you have no idea just guess the appropriate well-known algorithm instead of doing nothing :/
 */

Measured memory_bytes: 512
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	N := ReadInt()
	X := make([]int, N)
	Y := make([]int, N)
	for i := 0; i < N; i++ {
		X[i] = ReadInt()
		Y[i] = ReadInt()
	}

	x2 := make([]int, N)
	y2 := make([]int, N)
	for i := 0; i < N; i++ {
		x2[i] = X[i] + Y[i]
		y2[i] = X[i] - Y[i]
	}
	minX, maxX := MinMax(x2...)
	minY, maxY := MinMax(y2...)
	fmt.Println(Max(maxX-minX, maxY-minY))
}

func MinMax(slice ...int) (int, int) {
	min, max := slice[0], slice[0]
	for _, v := range slice[1:] {
		if min > v {
			min = v
		} else if max < v {
			max = v
		}
	}
	return min, max
}

func Max(xs ...int) int {
	max := xs[0]
	for _, x := range xs[1:] {
		if max < x {
			max = x
		}
	}
	return max
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


Measured memory_bytes: 11812
#include<bits/stdc++.h>
using namespace std;
#define pi acos(-1.0)
#define MOD 1000000007
typedef long long int ll;
int main()
{
    ll n,k,sum=0;
    cin>>n>>k;
    for(int i=k;i<=n+1;i++)
    {
        sum+=(n-i+1)*i+1;
        sum%=MOD;
    }
    printf("%lld\n",sum);
}


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

// ノードの構造体
typedef struct __bnode{
  int data;
  int cnt;
  struct __bnode *left;
  struct __bnode *right;
}BinNode;

// ノードの領域生成
BinNode *AllocBinNode(void){
  return (BinNode *)calloc(1, sizeof(BinNode));
}

// ノードの初期化
void SetBinNode(BinNode *n, int data, BinNode *left, BinNode *right){
  n->data = data;
  n->cnt = 1;
  n->left = left;
  n->right = right;
}

// ノードの追加
BinNode *Add(BinNode *p, int data){
  if(p == NULL){
   p =  AllocBinNode();
   SetBinNode(p, data, NULL, NULL);
  }else if(data < p->data){
    p->left = Add(p->left, data);
  }else if(data > p->data){
    p->right = Add(p->right, data);
  }else{
    (p->cnt)++;
  }
  return p;
}

// ゲーム終了後に紙に書かれている数字をカウント
void Count(const BinNode *p, int *sum){
  if(p != NULL){
    Count(p->left, sum);
    (*sum) += p->cnt % 2;
    Count(p->right, sum);
  } 
}

// 全ノードの表示
void PrintTree(const BinNode *p){
  if(p != NULL){
    PrintTree(p->left);
    cout << "data:" << p->data << ", cnt:" << p->cnt << endl;
    PrintTree(p->right);
  }
}

// 全ノードの削除
void FreeTree(BinNode *p){
  if(p != NULL){
    FreeTree(p->left);
    FreeTree(p->right);
    free(p);
  }
}

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

  int num;
  BinNode *root = NULL;
  int sum = 0;
  for(int i = 0; i < N; i++){
    cin >> num;
    root = Add(root, num);
  }

  //PrintTree(root);
  Count(root, &sum);
  cout << sum  << endl;

   FreeTree(root);
}

Measured memory_bytes: 3328
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <numeric>
#include <queue>
#include <map> 
#include <set>
#include <string>
#include <functional>
#include <list>
#include <random>
#include <time.h>
#include <iomanip>
#include <assert.h>
#define int long long
#define double long double
#define oku7 1000000007
#define MAXN (int)1e+5 * 2+1
#define LL_MAX 9223372036854775807	//ない環境用
#define LL_HALFMAX 9223372036854775807 / 2	//ない環境用
using namespace std;
std::mt19937 mt((int)time(0));

int dx[4] = { 0, 1, 0, -1 }; // x軸方向への変位
int dy[4] = { 1, 0, -1, 0 }; // y軸方向への変位

signed main() {
	int N;
	cin >> N;
	if (N % 2 == 0) {
		cout << N << "\n";
	}
	else {
		cout << N * 2 << "\n";
	}

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
   int t1, t2, b1, b2, t, b;

   scanf("%d%d%d%d", &t1, &t2, &b1, &b2);

   if(t1 > t2){
      t = t2;
   }
   else{
      t = t1;
   }

   if(b1 > b2){
      b = b2;
   }
   else{
      b = b1;
   }

   printf("%d\n", t+b);

   return 0;
}


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

int main() {
  vector<string> V;
  bool locked = true;
  int N,M;
  string S;
  scanf("%d", &N);
  for (int i=0; i<N; i++) {
    cin >> S;
    V.push_back(S);
  }
  scanf("%d", &M);
  for (int i=0; i<M; i++) {
    cin >> S;
    if (find(V.begin(), V.end(), S) != V.end()) { // 登録されている
      if (locked) {
	cout << "Opened by " << S << endl;
      } else {
	cout << "Closed by " << S << endl;
      }
      locked = !locked;
    } else {
      cout << "Unknown " << S << endl;
    }
  }  
}

Measured memory_bytes: 1248
def main():
    s = input()
    t = input()
    lens = len(s)
    lent = len(t)
    # dp[i][j] := s,tをそれぞれi,j文字目まででの最長一致部分列の長さ
    dp = [[0]*(len(t)+1) for _ in range(len(s)+1)]
    for i in range(lens):
        for j in range(lent):
            if s[i]==t[j]:
                dp[i+1][j+1] = max(dp[i+1][j+1], dp[i][j]+1)
            else:
                dp[i+1][j+1] = max(dp[i+1][j], dp[i][j+1])

    # dpの終点から文字列を復元していく
    ans = ""
    i,j = lens,lent
    while(i>0 and j>0):
        if dp[i][j]==dp[i-1][j]:
            i -= 1
        elif dp[i][j]==dp[i][j-1]:
            j -= 1
        else:
            ans = s[i-1]+ans
            i -= 1
            j -= 1
    print(ans)

main()


Measured memory_bytes: 111708