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

#define CEIL(a,b) ((a) / (b) + ((a) % (b) == 0 ? 0 : 1))

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

constexpr int MOD = 1'000'000'007;
constexpr int INF = 1'000'000'001;
constexpr ll LLINF = 4'000'000'000'000'000'001;
// constexpr int INF = 2147483647; // 2 * 1e9
// constexpr ll LLINF = 9223372036854775807; // 9 * 1e18

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    int n, l;
    cin >> n >> l;
    vector<int> a(n);
    for(int i = 0; i < n; ++i){
        a[i] = l + i;
    }
    int mi = INF, mii = -1;
    for(int i = 0; i < n; ++i){
        if(abs(a[i]) < mi){
            mi = abs(a[i]);
            mii = i;
        }
    }
    cout << accumulate(begin(a), end(a), -a[mii])  << "\n";
    return 0;
}

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

using namespace std;

int main(int argc, char* argv[]) {
  int N;
  cin >> N;

  int a[N];
  for (int i = 0; i < N; ++i)
    cin >> a[i];

  long long ret = 1000000000;
  for (int i = -100; i <= 100; ++i) {
    long long target = i;
    long long tmp = 0;
    for (int j = 0; j < N; ++j) {
      tmp += abs(pow(target - a[j], 2));
    }
    ret = min(ret, tmp);
  }

  cout << ret << endl;

  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int ar1[10000000];
int main()
{
    int a,b,c,d,i,j;
    ar1[0]=1;
   int ar[]= {100,101,102,103,104,105};
    scanf("%d",&a);
    for(i=100; i<=a; i++)
    {
        for(j=0; j<6; j++)
        {
            if(ar[j]<=i)
            {
                if(ar1[i-ar[j]]==1)ar1[i]=1;
            }
        }
    }
    if(ar1[a]==1)printf("1\n");
    else printf("0\n");
    return 0;
}


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

#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 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--)
typedef long long ll;
typedef long double ld;
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){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>
void emp(map<T,ll>&m, T x){m.emplace(x,0).first->second++;}

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>a(n);
  rep(i,0,n)cin>>a[i];
  vector<ll>b(2001),c(n);
  rep(i,0,n){
    c[i]=b[a[i]];
    rep(j,0,a[i])b[j]++;
  }
  rep(i,0,n){
    ll x=(c[i]*k)%MOD;
    ll y=(k*(k-1)/2)%MOD;
    qmod(y,b[a[i]]);
    pmod(x,y);
    pmod(res,x);
  }
  cout<<res<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
const int Mod = 1e9+7;
const int MaxN = 200000;
const int MaxM = 8000;
const int add = 2002;
const int half = 4002;
const int inf = 500000004;
int n,a[MaxN+10],b[MaxN+10],ans;
int frac[MaxM+10],infc[MaxM+10];
int f[half+5][half+5];
int power(int a,int b) {
	int ans=1;
	for(;b;b>>=1) {
		if(b&1) ans=1ll*ans*a%Mod;
		a=1ll*a*a%Mod;
	}
	return ans;
}
void solve() {
	frac[0]=1;
	for(int i=1;i<=MaxM;i++) {
		frac[i]=1ll*frac[i-1]*i%Mod;
	}
	infc[MaxM]=power(frac[MaxM],Mod-2);
	for(int i=MaxM-1;i>=0;i--) {
		infc[i]=1ll*infc[i+1]*(i+1)%Mod;
	}
}
int C(int n,int m) {return 1ll*frac[n]*infc[m]%Mod*infc[n-m]%Mod;}
int main () {
	solve();
	scanf("%d",&n);
	for(int i=1;i<=n;i++) {
		scanf("%d%d",&a[i],&b[i]);
		f[add-a[i]][add-b[i]]++;
	}
	for(int i=1;i<=half;i++) {
		for(int j=1;j<=half;j++) {
			f[i][j]=(f[i][j]+(f[i-1][j]+f[i][j-1])%Mod)%Mod;
		}
	}
	for(int i=1;i<=n;i++) {
		ans=(ans+f[a[i]+add][b[i]+add])%Mod;
		ans=(ans-C(2*a[i]+2*b[i],2*a[i]))%Mod;
	}
	ans=(ans+Mod)%Mod;
	ans=1ll*ans*inf%Mod;
	printf("%d",ans);
} 

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





int ok[] = {0, 3, 6, 1, 4, 7, 2, 5, 8, 0, 1, 2, 3, 4, 5, 6, 7, 8, 0, 4, 8, 2, 4, 6};

int main(){
    while(cin >> str){
	for(int i = 0;i < 24;i += 3){
	    if(str[ok[i]] == str[ok[i + 1]] && str[ok[i]] == str[ok[i + 2]]){
		if(str[ok[i]] == 's')continue;
		cout << str[ok[i]] << endl;
		break;
	    }
	    if(i == 21)cout << 'd' << endl;
	}
    }
}

Measured memory_bytes: 1172
n = gets.to_i
cards = gets.split

value = ->(card) {
  card[1].to_i
}

bubble_sort = ->(ar) {
  n.times do |i|
    (n - 1).downto(i + 1) do |j|
      ar[j], ar[j - 1] = ar[j - 1], ar[j] if value.(ar[j]) < value.(ar[j - 1])
    end
  end
  ar
}

selection_sort = ->(ar) {
  result = "Stable"
  n.times do |i|
    minj = i
    f = false
    (i + 1).upto(n - 1) do |j|
      f = true if value.(ar[i]) == value.(ar[j])
      if value.(ar[j]) < value.(ar[minj])
        minj = j
        result = "Not stable" if f
      end
    end
    ar[i], ar[minj] = ar[minj], ar[i]
  end
  [ar, result]
}

puts bubble_sort.(cards.dup).join(" ")
puts "Stable"
ar, result = selection_sort.(cards.dup)
puts ar.join(" ")
puts result



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

int main(){
  ll X, K, D;
  cin >> X >> K >> D;
  ll cnt;
  ll mod;
  X = abs(X);
  
  if(K <= 1000000000000000/D && K*D <= X){
    cout << X-K*D << endl;
    return 0;
  }
  
  cnt = X/D;
  mod = X%D;
  if((K-cnt)%2==0){
    cout << mod << endl;
  }else{
   cout << abs(mod-D) << endl;
  }
  
  
  return 0;
}


Measured memory_bytes: 3608
#include<iostream>
#include<cstring>
#include<algorithm>
#include<vector>
#include<cmath>
#include<limits>
#include<map>
#define ll long long
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define int_INF 2147483647
#define ll_INF 	9223372036854775807
#define vi vector<int>
#define vii vector<vector<int>>
#define vll vector<long long>
#define pii pair<int,int>
using namespace std;

char i_to_c(int i) {
	char c;
	c = 'a' + i;
	return c;
}

void solve(int length, int max, string s){
  if(length == 1){
    cout << "a" << endl;
  }
  else{
    if(length == s.size() + 1){
      for(int i = 0; i <= max + 1; i++){
        cout << s + i_to_c(i) << endl;
      }
    }
    else{
      for(int i = 0; i <= max; i++){
        solve(length,max,s + i_to_c(i));
      }
      solve(length,max + 1,s + i_to_c(max + 1));
    }
  }
}
int main(){
  int N;
  cin >> N;
  solve(N,0,"a");
}


Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
string s,p;
int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t,i,j,n,m,a,b,l,r,c=0;
    char ch;
    cin>>s>>t;
    while(t--){
        cin>>l;
        if(l==1){
            c=(c+1)%2;
        }
        else{
            cin>>r>>ch;
            if(r==1){
                if(c==0){
                    p+=ch;
                }
                else{
                    s+=ch;
                }
            }
            else{
                if(c==0){

                    s+=ch;
                }
                else{
                    p+=ch;
                }
            }
        }
    }
    if(c==1){
        reverse(s.begin(),s.end());
        cout<<s<<p<<"\n";
    }
    else{
        reverse(p.begin(),p.end());
        cout<<p<<s<<"\n";
    }
    return 0;
}


Measured memory_bytes: 980
var lines = [];

var readline = require('readline')
var rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout,
});


rl.on('line', (x) => {
    lines.push(x)
});

rl.on('close', () => {
    var A = Number(lines[0].split(" ")[0])
    var P = Number(lines[0].split(" ")[1])

    var t = Math.floor(A * 3) + P;
    console.log(Math.floor(t / 2));
});

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

//#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

#define LL long long

const int MX = 1e5 + 5;

int n, m;
vector<int> G[MX];
int par[MX];
int vis[MX];

void bfs() {
	queue<int> q;
	q.push(1);
	vis[1] = 1;
	while(!q.empty()) {
		int node = q.front();
		q.pop();

		for(int i=0;i<G[node].size();i++) {
			int v = G[node][i];
			if(vis[v] == 0) {
				q.push(v);
				par[v] = node;
				vis[v] = 1;
			}
		}
	}
}

int main() {
	cin >> n >> m;
	int u,v;
	for(int i=0;i<m;i++) {
		cin >> u >> v;
		G[u].push_back(v);
		G[v].push_back(u);
	}
	bfs();

	int pos = 1;
	for(int i=2;i<=n;i++) {
		if(vis[i] == 0) {
			pos = 0;
			break;
		}
	}

	if(pos == 0) {
		cout << "No" << endl;
		return 0;
	}

	cout << "Yes" << endl;
	for(int i=2;i<=n;i++)
		cout << par[i] << endl;

	return 0;
}


Measured memory_bytes: 10780
package main

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

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

// Sort
type Val struct {
	id, num int
}
type ByNum []Val

func (a ByNum) Len() int           { return len(a) }
func (a ByNum) Less(i, j int) bool { return a[i].num < a[j].num }
func (a ByNum) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	A, B, C, K := sc.nextInt(), sc.nextInt(), sc.nextInt(), sc.nextInt()
	ma := max(A, B, C)
	rest := 0
	if ma == A {
		rest += B + C
	} else if ma == B {
		rest += A + C
	} else {
		rest += A + B
	}
	for i := 1; i <= K; i++ {
		ma *= 2
	}

	fmt.Fprintln(wtr, ma+rest)
	wtr.Flush()
}


Measured memory_bytes: 640
a = [input().split() for l in range(3)]

x0 = 0
x1 = 0
x2 = 0
y0 = 0
y1 = 0
y2 = 0
judg = 0
for i in range(3):
    for j in range(3):
        a[i][j] = int(a[i][j])

for i in range(100):
    x0 = i
    y0 = a[0][0] - i
    y1 = a[0][1] - i
    y2 = a[0][2] - i
    x1 = a[1][1] - y1
    x2 = a[2][2] - y2
    if a[1][0] == x1 + y0 and a[1][2] == x1 + y2 and a[2][0] == x2 + y0 and a[2][1] == x2 + y1:
        judg = 1
    break

if judg == 0:
    print("No")
else:
    print("Yes")


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <string>
#include <bitset>
#include <cmath>
#include <queue>
#include <iomanip>
#include <algorithm>
#include <stack>
using namespace std;

#define INF 1e18
#define int long long

signed main() {
    string s; cin >> s;

    int ans = 0;
    for(int i = 1; i < s.size(); i++) {
        if(s[i] != s[i -1]) ans++;
    }

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


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define sz(c)       int(c.size())
#define rep(i,a,b)  for (int i=a; i<(b); ++i)
#define per(i,a,b)  for (int i=(b)-1; i>=(a); --i)
#define fore(c,...) for (auto __VA_ARGS__:(c))
using namespace std;
typedef long long ll;



int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	cout<<fixed<<setprecision(10);

	int H,N;
	cin>>H>>N;
	int s=0;
	rep(i,0,N) {
		int x;
		cin>>x;
		s+=x;
	}
	if (s>=H) cout<<"Yes\n"; else cout<<"No\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdio.h>
#include<iostream>
#include<cstdio>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>
#include<cctype>
#include<fstream>
#include <numeric>
#include <iomanip>
#include <cstring> 
using namespace std;
using ll=long long;

#define FOR(i, a, b) for( int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for( int i=(a);i>=(b);i--)
#define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define LLONG_MAXs 9223372036854775800

#include <iostream>
#include <cmath>
using namespace std;
 

 
bool isPrimeNum( ll x ){ // 素数である場合 true を返す
  if( x <= 1 ){ // 1以下である場合は素数でないことがすぐにわかる
    return false;
  }
  // sqrt( double型 ) は引数の平方根を double型で返すので、int型でキャスト
  int n = (int)sqrt( (double)x );
  for( int i = 2; i <= n; i++ ){
    if( x % i == 0 ){ // 割り切る整数がある場合、即判定終了
      return false;
    }
  }
  return true; // 割り切る整数がない場合、素数である
}

constexpr ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
constexpr ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll abs(ll a,ll b){
if(a>=b)return a-b;
if(a<b)return b-a;
}
constexpr ll min(ll a,ll b){
if(a>=b)return b;
if(a<b)return a;
}

constexpr ll max(ll a,ll b){
if(a>=b)return a;
if(a<b)return b;
}

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

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main() {
  ll ans=0;
  ll a,b,c;
  ll max1;

  cin>>a>>b>>c;

  max1=max(a,b);
  max1=max(max1,c);

  ll tmp=3*max1-a-c-b;
  if(tmp%2==0){
    ans=tmp/2;
  }else{
    ans=tmp/2+2;
  }

cout<<ans<<endl;
return 0;

}
 


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#define _USE_MATH_DEFINES
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;
typedef complex<double> xy_t;
#define REP(i, x, y) for(ll i = x; i < y; i++)
#define PER(i, x, y) for(ll i = x; i > y; i--)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
int iinf = intmax / 8;
ll inf = llmax / 8;
double eps = 1e-11;

int main() {
    ll N;
    cin >> N;
    ll maxnum = 0;
    while (1) {
        ll tmp = maxnum * (maxnum + 1) / 2;
        if (tmp >= N) {
            break;
        }
        maxnum++;
    }
    PER(i, maxnum, 0) {
        if (N >= i) {
            cout << i << endl;
            N -= i;
        }
    }
}


Measured memory_bytes: 256
import java.util.*;

class Main {
  public static void main(String... args) {
    Scanner scan = new Scanner(System.in);
    String S = scan.next();
    scan.close();
    
    HashMap<String, Integer> days = new HashMap();
    days.put("SAT", 1);
    days.put("FRI", 2);
    days.put("THU", 3);
    days.put("WED", 4);
    days.put("TUE", 5);
    days.put("MON", 6);
    days.put("SUN", 7);
    
    System.out.println(days.get(S));
  }
}

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

int main()
{
  int x, y;
  cin >> x >> y;
  for (int a = 0; a <= x; ++a)
  {
    for (int b = 0; b <= x; ++b)
    {
      if (a + b == x && 2 * a + 4 * b == y)
      {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
template <class T> inline bool chmin(T &a, T b) {if (a > b){a = b;return true;}return false;}
template <class T> inline bool chmax(T &a, T b) {if (a < b){a = b;return true;}return false;}

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

int ngcd(vector<int> a){
    int res;
    res = a[0];
    for(int i = 1; i < a.size() && res != 1; i++) {
        res = gcd(a[i], res);
    }
    return res;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    vector<int> p;
    int n; cin>>n;
    rep(i, n){
        int t; cin>>t;
        p.push_back(t);
    }
    cout <<ngcd(p)<<endl;
}

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


#define FOR(i, start, end) for(uint64_t i=start; i<end; i++)
#define REP(i, n) FOR(i, 0, n)

// 最大公約数gcd
// 最小公倍数lcm=m*n/gcd
uint64_t gcd(uint64_t m, uint64_t n) {
  uint64_t temp;
  while (m % n != 0){
    temp = n;
    n = m % n;
    m = temp;
  }
  return n;
}

uint64_t lcm(uint64_t m, uint64_t n) {
  return (m*n)/gcd(m,n);
}

// vector<vector<uint64_t> > v(n+1, vector<uint64_t>(n+1, 0))
// v[n][k]に組み合わせ数が入る。
void comb(vector<vector <uint64_t> > &v){
  for(uint64_t i = 0;i <v.size(); i++){
    v[i][0]=1;
    v[i][i]=1;
  }
  for(uint64_t k = 1;k <v.size();k++){
    for(uint64_t j = 1;j<k;j++){
      v[k][j]=(v[k-1][j-1]+v[k-1][j]);
    }
  }
}

// 掛け算オーバーフロー判定
bool is_product_overflow(uint64_t a, uint64_t b) {

	uint64_t prod = a * b;
	
	return (prod / b != a);
}

//素因数分解
void primeFactorization(uint64_t a, list<uint64_t> &factors){ //素因数分解を出力するプログラム
  long i,sq;
  if(a%2==0){ //偶数の場合
    factors.push_back(2);
    primeFactorization(a/2,factors); //2で割った値で再帰
    return;
  }
  sq = sqrt(a);
  for(i=3;i<=sq;i+=2){ //3以上√a以下の奇数の場合
	if(a%i==0){
	  factors.push_back(i);
      primeFactorization(a/i,factors); //割れた値で再帰
      return;
	}
  }
  //偶数でも3以上√a以下の奇数の場合でも割り切れない場合
  if(a!=1){ //aが1でないなら、a自身は素数
    factors.push_back(a);
  }
}

// フェルマーの小定理
// mod. m での a の逆元 a^{-1} を計算する
// (a/b)%m = a*movinv(b,m)%m  
int64_t modinv(int64_t a, int64_t m) {
    int64_t b = m, u = 1, v = 0;
    while (b) {
        int64_t t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

// 円周率
// M_PI

// #include <iomanip> // setprecisionを使用するのに必要
// cout << std::fixed << std::setprecision(15) << y << endl;

// 昇順
// priority_queue<int, vector<int>, greater<int> > queue;

signed main() {
  int n;
  cin >> n;
  int a;
  int count = 0;
  int index = 1;
  for(int i=0;i<n;i++){
    cin >> a;
    if(a == index){
      index++;
    }
    else{
      count++;
    }
  }
  
  if(index==1) cout << "-1" << endl;
  else cout << count << endl;
  
  return 0;
}




Measured memory_bytes: 3612
fun main(args: Array<String>) {
    readLine()
    var a = readLine()!!.split(' ').map(String::toInt)
    var min: Int
    do {
        min = a.min()!!
        if (min == 1) break
        a = a.map { if (it == min) min else it % min }.filter { it != 0 }.distinct()
    } while (1 < a.size)
    println(min)
}


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

using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int N, Q, l, r;
	string s;
	vector<int> pos;
	cin >> N >> Q >> s;
	for (int i = 0; i < s.size()-1; ++i){
		if (s[i] == 'A' && s[i+1] == 'C'){
			pos.push_back(i+1);
		}
	}
	for (int i = 1; i <= Q; ++i){
		cin >> l >> r;
		cout << upper_bound(pos.begin(),pos.end(),r-1) - lower_bound(pos.begin(),pos.end(),l) << '\n';
	}
}

Measured memory_bytes: 1228
import java.io._
import java.util.StringTokenizer
import scala.util.control.Breaks.{breakable,break}
import scala.collection.mutable.{Map, Stack, Queue, PriorityQueue, Set}

object Main extends App {
  val in = new InputReader(System.in)
  val pw = new PrintWriter(System.out)

  // 
  // val a, b = in.next().toInt
  // val s = in.next()

  //
  val N = in.next().toInt
  val a = new Array[Int](N+1)
  for (i <- 1 to N) {
    a(i) = in.next().toInt
  }

  //
  var cnt = 0
  for (i <- 1 to N) {
    if (a(i) == cnt+1) {
      cnt += 1
    }
  }

  if (cnt == 0)
    println(-1)
  else {
    val ans = N - cnt
    println(ans)
  }
}

object Sub {
  def print2DimArray[A](mat: Array[Array[A]]): Unit = {
    mat.foreach(lin => println(lin.deep))
  }
}

class InputReader(stream: InputStream) {
  private[this] val reader = new BufferedReader(new InputStreamReader(stream))
  private[this] var tokenizer: StringTokenizer = new StringTokenizer(reader.readLine())
  def next(): String = {
    while (!tokenizer.hasMoreTokens()) {
      tokenizer = new StringTokenizer(reader.readLine())
    }
    tokenizer.nextToken()
  }
}


Measured memory_bytes: 46468
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        Long A = Long.parseLong(sc.next());
        String B = sc.next();
        String[] B_array = B.split("\\.",-1);
        System.out.println(A*Long.parseLong(B_array[0]) +(A*Integer.parseInt(B_array[1]))/100 );
    }
}

Measured memory_bytes: 35716
// #include <bits/stdc++.h>
#include <iostream> // cin, cout, string
#include <algorithm> // sort, min, max
#include <vector>
#include <utility> // pair, swap
#include <functional>
#include <iomanip>

using namespace std;

// #define int long long

using ll = long long;
using ld = long double;

using vi = vector<int>;
using pii =  pair<int, int>;

const int IINF =  0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
// const int INF = sizeof(int) == sizeof(long long) ? LINF : IINF;
const ll MOD = 1e9+7;

#define for_(i, a, b) for(int i = (a);i < (b);++i)
#define rfor_(i, a, b) for(int i = (b)-1;i >= (a);--i)

#define rep(i, n) for_(i, 0, n)
#define rrep(i, n) rfor_(i, 0, n)

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define ft first
#define sd second

#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()
#define rev(a) reverse(all(a))

#define endl '\n'

const int limit = 100007;

int N, K;

ld prob(int k) {
  if(K <= k) return 1.0;
  return prob(k*2) / 2;
}

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

  cin >> N >> K;

  ld ans = 0;

  for_(i, 1, N+1) {
    ans += prob(i);
  }

  ans /= N;

  cout << fixed << setprecision(12) << ans << endl;

  return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
#define io() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); srand(time(NULL));
 
using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

signed main(){
    io();
    ll r; cin >> r;
    cout << r*r*3 << '\n';
    return 0;
}

Measured memory_bytes: 3604
H,W=map(int,input().split())
a=[[] for _ in range(H)]

for i in range(H):
    a[i]=list(map(int,input().split()))
    
n=0
ans=[]

for i in range(H):
    for j in range(W-1):
        if a[i][j]%2==1:
            n+=1
            ans.append([i+1,j+1,i+1,j+2])
            a[i][j+1]+=1
            
for i in range(H-1):
    if a[i][-1]%2==1:
        n+=1
        ans.append([i+1,W,i+2,W])
        a[i+1][-1]+=1
        
print(n)
for i in range(len(ans)):
    print(' '.join(map(str, ans[i])))





Measured memory_bytes: 29880
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<deque>
#include<queue>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
typedef pair<int, int>P;
const int MOD = 1e9 + 7;
const int INF = 1e10;
const long double PI = (acos(-1));


signed main() {
	int N, A, B;
	cin >> N >> A >> B;
	int mx = min(A, B);
	int mn;
	if (A + B <= N)mn = 0;
	else mn = A + B - N;
	cout << mx << " " << mn << endl;
}

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

using namespace std;

using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using vvvll = vector<vector<vector<ll>>>;
using vvvvll = vector<vector<vector<vector<ll>>>>;
using pl4 = pair<ll,ll>;
using str = string;
using vpl4 = vector<pair<ll,ll>>;

#define sz size()
#define be begin()
#define en end()
#define fi first
#define se second
#define pb push_back
#define mp make_pair

#define llin(x) ll (x);cin >>(x);
#define stin(x) str (x);cin >>(x);
#define vllin(x,n) vll (x)(n);FOR(i,0,n-1){cin >>(x)[i];}
#define vllin2(a,b,n) vll (a)(n);vll (b)(n);FOR(i,0,n-1){cin >>(a)[i]>>(b)[i];}
#define vllin3(a,b,c,n) vll (a)(n);vll (b)(n);vll (c)(n);FOR(i,0,n-1){cin >>(a)[i]>>(b)[i]>>(c)[i];}
#define vlling(x,n) (x).assign(n,0);FOR(i,0,n-1){cin >>(x)[i];}
#define vlling2(a,b,n) (a).assign(n,0);(b).assign(n,0);FOR(i,0,n-1){cin >>(a)[i]>>(b)[i];}
#define vlling3(a,b,c,n) (a).assign(n,0);(b).assign(n,0);(c).assign(n,0);FOR(i,0,n-1){cin >>(a)[i]>>(b)[i]>>(c)[i];}
#define vpl4in(x,n) vpl4 (x)((n),mp(0,0));FOR(i,0,n-1){cin >>x[i].fi>>x[i].se;}
#define FOR(i,a,b) for(ll i = a ; i <= b ; i++)
#define rFOR(i,b,a) for(ll i = a; i >= b ; i--)
#define SORT(x) sort(x.be, x.en)
#define rSORT(x) sort(x.rbegin(), x.rend())
#define say(x) cout<<(x);
#define sal(x) cout<<(x)<<endl;
#define says(x) cout<<(x)<<(' ');
#define sas cout<<(' ');
#define sayR(x) cout<<fixed<<setprecision(10)<<(x);
#define salR(x) cout<<fixed<<setprecision(10)<<(x)<<endl;
#define yn(a) cout <<((a)?"yes":"no")<<endl;
#define Yn(a) cout <<((a)?"Yes":"No")<<endl;
#define YN(a) cout <<((a)?"YES":"NO")<<endl;
#define Imp(a) cout <<((a)?"Possible":"Impossible")<<endl;
#define IMP(a) cout <<((a)?"POSSIBLE":"IMPOSSIBLE")<<endl;
#define pow(a,b) ll(pow(a,b))

ll MOD=998244353;
ll MAX = 5000000;

vll fac(MAX);
vll finv(MAX);
vll inv(MAX);

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long com(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
signed main(){
    llin(n);
    sal((n-1)/2)
}


Measured memory_bytes: 117376
#include <bits/stdc++.h>
#define repl(i, l, r) for (int i = l; i < r; i++)
#define rep(i, n) repl(i, 0, n)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main()
{
    int n;
    cin >> n;
    string s;
    cin >> s;
    int ans = 0;
    rep(i, 1000) {
        string t;
        int x = i;
        rep(j, 3) {
            t += '0' + x % 10;
            x /= 10;
        }
        int ti = 0;
        rep(j, n) {
            if(s[j] == t[ti]) {
                ++ti;
                if(ti == 3) {
                    break;
                }
            }
        }
        if(ti == 3) {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

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

#define int long long
#define endl "\n"
#define REP(i,a,n) for(int i=a;i<n;++i)
#define REPR(i,a,n) for(int i=a;i>n;--i)
#define RUP(a,b) ((a+b-1)/(b))
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define INF LLONG_MAX/2

typedef long long ll;
typedef pair<int,int> Pii;
typedef tuple<int,int,int> Tiii;
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef vector<Pii> VPii;
typedef vector<string> Vs;

template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T> void YesNo(T a) {cout<<(a?"Yes":"No")<<endl;}
template<class T> void YESNO(T a) {cout<<(a?"YES":"NO")<<endl;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}
void uniq(Vi &v){sort(v.begin(),v.end()); v.erase(unique(v.begin(),v.end()),v.end());}
bool comp(Pii a,Pii b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

signed main(){cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
    int n;
    string ss;
    cin>>n>>ss;
    VVi z(n,Vi(n));
    
    REP(l,0,n){
    string s=ss.substr(l);
    z[l][0] = s.size();
    int i=1,j=0;
    while (i<s.size()) {
        while(i+j<s.size() && s[j]==s[i+j]) j++;
        z[l][i]=j;
        if(j==0){
            i++;
            continue;
        }
        int k=1;
        while(i+k<s.size() && k+z[l][k]<j){
            z[l][i+k] = z[l][k];
            k++;
        }
        i += k;
        j -= k;
    }
    }

    // REP(i,0,n){
    //     REP(j,0,n){
    //         cout<<z[i][j]<<" ";
    //     }
    //     cout<<endl;
    // }
    int ans=0;
    REP(i,0,n){
        REP(j,0,n){
            chmax(ans,min(j,z[i][j]));
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 195840
#include<bits/stdc++.h>
using namespace std;
int gcd(int a,int b) {return b==0?a:gcd(b,a%b);}
int main(){
  int w,h,c,x;
  cin>>w>>h>>c;
  if(w<h) swap(w,h);
  x=gcd(w,h);
  cout<<w/x*h/x*c<<endl;
  return 0;
}



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

int main() {
  int n;
  cin >> n;
  vector<int> a;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    a.push_back(x);
  }
  sort(a.begin(), a.end());
  int alice, bob;
  alice = 0;
  bob = 0;
  for (int i = 0; i < n; i++) {
    if (i % 2 == 0)
      alice += a[n-i-1];
    else
      bob += a[n-i-1];
  }
  cout << alice - bob << endl;
  return 0;
}


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

int n,A[30];

int solve(int i,int m)
{
	if (m == 0)
	{
		return 1;
	}
	else if (i >= n)
	{
		return 0;
	}
	int res = solve(i+1,m) || solve(i+1,m - A[i]);
	return res;
}

int main()
{
	int q,m;
	cin >> n;
	for (int i = 0; i < n; ++i)
	{
		cin >> A[i];
	}

	cin >> q;
	for (int i = 0; i < q; ++i)
	{
		cin >> m;
		if (solve(0,m))
		{
			cout << "yes\n";
		}
		else
		{
			cout << "no\n";
		}
	}
	return 0;
} 


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

public class Main {
    private void solve() {
        long t = sc.nextLong();
        long a = 100;
        int ans = 0;
        while (a < t) {
            a = a + a / 100;
            ++ans;
        }
        out.println(ans);
    }

    private static PrintWriter out;
    private static MyScanner sc;

    private static class MyScanner {
        BufferedReader br;
        StringTokenizer st;

        private MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }
    }

    public static void main(String[] args) {
        out = new PrintWriter(new BufferedOutputStream(System.out));
        sc = new MyScanner();
        new Main().solve();
        out.close();
    }
}


Measured memory_bytes: 32852
#include <iostream>
#include <string>
#include <algorithm>
#include <list>
#include <vector>
#include <sstream>
#include <bits/stdc++.h>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
using namespace std;
int main(){
    int a,b,c;
    int Num=0;
    int ans=0;
    cin>>a>>b>>c>>Num;
    for(int i=0;i<=a;i++)
        for(int j=0;j<=b;j++)
            for(int k=0;k<=c;k++){
                int TOSHIBA=i*500+j*100+k*50;
                if(TOSHIBA==Num)
                    ans++;
                if(TOSHIBA>Num) 
                    break;
            }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
a=b=c=0
loop do
    d = gets.split.map(&:to_i).sort
    break if d[0]+d[1]<=d[2]
    
    temp=d[0]**2+d[1]**2
    if temp==d[2]**2
        a += 1
    elsif temp<=d[2]**2
        c += 1
    else
        b += 1
    end
end
puts [a+b+c, a, b, c].join(' ')

Measured memory_bytes: 8632
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include <cmath>
#include <limits>
#include<set>
#include <iomanip>
#include <queue>
#include <string>
#pragma GCC optimize("Ofast")
using namespace std;
const long long INF=200000000;
//setprecision(2) <<

const int MOD = 1000000007;

long long max(long long a,long long b){
	if(a<b)return b;
	else return a;	
}
long long min(long long a,long long b){
	if(a>b)return b;
	else return a;	
}

class Edge{
public:
	long long from;
	long long to;
	long long w;
};


int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	long long a,b;
	cin>>a>>b;
	if(a<=0 && 0<=b){
		cout<<"Zero"<<endl;
		return 0;
	}
	if(a<0 && b<0 &&(abs(b-a)%2==0)){
		cout<<"Negative"<<endl;
		return 0;
	}
	cout<<"Positive"<<endl;
	
	
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define LL long long
#define Max 100005
#define Mod 1e9+7
const LL mod=1e9+7;
const LL inf=0x3f3f3f3f;
using namespace std;
int dfs(int x,int step)
{
	if(x%2)
		return step;
	dfs(x/2,step+1);
}
int main()
{
	int n,a[10005];
	scanf("%d",&n);
	for(int i=0;i<n;i++)
		scanf("%d",&a[i]);
	int ans=0;
	for(int i=0;i<n;i++)
	{
		if(a[i]%2==0)
			ans+=max(dfs(a[i],0),dfs(a[i]*3,0));
	}
	printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 256
def gcd(x,y):
    if x%y==0: return y
    else: return gcd(y,x%y)
n = int(input())
a = list(map(int,input().split()))
a.sort()
ans = a[0]
for i in range(1,n):
    ans = min(ans,gcd(ans,a[i]))
print(ans)

Measured memory_bytes: 14224
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const double PI = acos(-1);
const ll MOD = 1000000007;
using Graph = vector<vector<int>>;

ll N,X;
vector<ll> A,B;

ll dfs (int N,ll x) {
  if (N == 0) return 1;
  if (x == 1) return 0;
  if (x == 2 + A[N-1]) return 1 + B[N-1];
  if (x == A[N]) return B[N];
  if (x > 2 + A[N-1]) return dfs(N-1,x - 2 - A[N-1]) + 1 + B[N-1]; 
  if (x < 2 + A[N-1]) return dfs(N-1,x-1);
}

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

  A.resize(N+1); B.resize(N+1);
  A[0] = 1;
  B[0] = 1;
  int k;
  rep(i,N) {
    A[i+1] = 2 * A[i] + 3;
    B[i+1] = 2 * B[i] + 1;
  }

  cout << dfs(N,X) << endl;
}

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

using namespace std;

//#define FILE_IO

typedef long double LD;

int N;
int fq[4];
LD dp[305][305][305];
bool done[305][305][305];

LD solve(int x, int y, int z)
{
    if(done[x][y][z])   return dp[x][y][z];
    done[x][y][z] = 1;

    LD dr = 1.0;
    LD coef = LD(N) / LD(x + y + z);
    if(x > 0)   dr += LD(x) / LD(N) * solve(x - 1, y, z);
    if(y > 0)   dr += LD(y) / LD(N) * solve(x + 1, y - 1, z);
    if(z > 0)   dr += LD(z) / LD(N) * solve(x, y + 1, z - 1);

    LD ans = dr * coef;
    dp[x][y][z] = ans;
    return ans;
}

int main()
{
    #ifdef FILE_IO
    freopen("1.in", "r", stdin);
    //freopen("1.out", "w", stdout);
    #endif

    cin >> N;
    for(int i = 1; i <= N; i++)
    {
        int x;
        cin >> x;
        fq[x]++;
    }

    done[0][0][0] = true;

    LD ans = solve(fq[1], fq[2], fq[3]);
    cout << fixed << setprecision(15) << ans << '\n';

    return 0;
}


Measured memory_bytes: 465152
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <string>
#include <cstring>
#include <sstream>
#include <cmath>
#include <functional>
#include <fstream>
#include <cstdlib>
typedef long long ll;
const int MOD = 1e9+7;


#define REP(i, N) for (int i = 0; i < (N); i++)
#define REPP(i, a, b) for (int i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define VSORT(c) sort((c).begin(),(c).end())
#define SZ(x) ((int)(x).size())
//vvintを作る　マクロで　 #define vvint(N,M) vector<vector<int>>

using namespace std;


int main(){
    
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    long ans,cnt,idx;
    ans = cnt = 0;
    idx = 1;
    int num;

    for(int i = 0; i < n;i++){
        cin >> num;
        if(num == idx){
            idx++;
        }else{
            ans++;
        }
    }

    if(ans != n) cout << ans << endl;
    else cout << -1 << endl;
    

    return 0;
}

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

fun main(args: Array<String>) = IO().exec {
    val n = int()
    val a = long()
    val b = long()
    val x = LongArray(n){long()}
    var ret = 0L
    for (i in 0 until n - 1) {
        ret += if ((x[i + 1] - x[i]) * a > b) b
        else (x[i + 1] - x[i]) * a
    }
    println(ret)
}

class IO {
    val printable = 33..126
    val buffer = ByteArray(1024)
    var ptr = 0
    var buflen = 0
    val out = PrintWriter(System.out)
    fun hasNextByte(): Boolean {
        if (ptr < buflen) {
            return true
        } else {
            ptr = 0
            buflen = System.`in`.read(buffer)
            if (buflen <= 0) {
                return false
            }
        }
        return true
    }
    fun readByte(): Byte {
        return if (hasNextByte()) buffer[ptr++] else return -1
    }
    fun hasNext(): Boolean {
        while (hasNextByte() && buffer[ptr] !in printable) ptr++
        return hasNextByte()
    }
    fun string(): String {
        if (!hasNext()) throw NoSuchElementException()
        val sb = StringBuilder()
        var b = readByte()
        while (b in printable) {
            sb.appendCodePoint(b.toInt())
            b = readByte()
        }
        return sb.toString()
    }
    fun long(): Long {
        if (!hasNext()) throw NoSuchElementException()
        var n = 0L
        var minus = false
        var b = readByte()
        if (b == '-'.toByte()) {
            minus = true
            b = readByte()
        }
        if (b !in '0'.toByte()..'9'.toByte()) {
            throw NumberFormatException()
        }
        while (true) {
            if (b in '0'.toByte()..'9'.toByte()) {
                n *= 10
                n += b - '0'.toByte()
            } else if (b == (-1).toByte() || b !in printable) {
                return if (minus) -n else n
            } else {
                throw NumberFormatException()
            }
            b = readByte()
        }
    }
    fun int(): Int {
        val nl = long()
        if (nl !in Integer.MIN_VALUE..Integer.MAX_VALUE) throw NumberFormatException()
        return nl.toInt()
    }
    fun double(): Double {
        return string().toDouble()
    }
    fun print(obj: Any) = out.print(obj)
    fun print(i: Int) = out.print(i)
    fun print(l: Long) = out.print(l)
    fun println(obj: Any) = out.println(obj)
    fun println(i: Int) = out.println(i)
    fun println(l: Long) = out.println(l)
    inline fun exec(block: IO.() -> Unit) {
        block()
        out.flush()
    }
}

Measured memory_bytes: 33568
n = int(input())
h = input().split()
h = [int(i) for i in h]

aux = [10000000000 for i in range(n)] 
aux[0] = 0
aux[1] = abs(h[1] - h[0])

for i in range(2,n):
    aux[i] = min(aux[i - 2] + abs(h[i] - h[i - 2]), aux[i - 1] + abs(h[i] - h[i - 1]))

print(aux[n-1])
    

Measured memory_bytes: 13924
def main():
    H,W = map(int, input().split())
    S = [input() for i in range(H)]
    
    #S[1][1] = 1
    #print(S)
    
    #exit()
    #S.insert(0,"." * (W))
    #S.append("." * (W))
    
    #print(S)
    #exit()
    
    i = 0
    T = S
    
    #H=y=i
    for i in range(H):
        Ten = ''
        #W=x=j
        for j in range(W):
            if S[i][j] == "#":
                Ten += '#'
                #l = 1
            else:
                count = 0
                #y増分
                for k in range(3):
                    #x増分
                    for l in range(3):
                        if 0 <= i + (k - 1) < H and 0 <= j + (l-1) < W and S[i+(k-1)][j+(l-1)] == '#':
                            count = count + 1
                Ten += str(count)
    #S.insert(0,"." * W)
    #S.append("." * W)
        print(Ten)
        #print("A"*100)
main()


Measured memory_bytes: 3064
#include <cstdio>
#include <iostream>
#include <vector>

#define lson (idx << 1)
#define rson (idx << 1 | 1)
#define INF 1000000000000LL
#define MAXN 200010

using namespace std;
typedef long long ll;

template <typename T> void read(T &x) {
  x = 0;
  char c = getchar();
  T sig = 1;
  for (; !isdigit(c); c = getchar())
    if (c == '-')
      sig = -1;
  for (; isdigit(c); c = getchar())
    x = (x << 3) + (x << 1) + c - '0';
  x *= sig;
}

// `lo` is the current minimum of the segment.
// `lh` is the current value of the left endpoint.
// `lazy` is the lazy tag for addition.
// `flag` is the lazy tag for assignment.
struct Node {
  int l, r;
  ll lo, lh, lazy = 0;
  bool flag = false;
} s[MAXN << 2];
int h, w;

// Push up
void calc(int idx) {
  s[idx].lo = min(s[lson].lo, s[rson].lo);
  s[idx].lh = s[lson].lh;
}

void build(int idx, int l, int r) {
  s[idx].l = l, s[idx].r = r;
  if (l == r)
    return;
  int mid = (l + r) >> 1;
  build(lson, l, mid);
  build(rson, mid + 1, r);
}

// Lazy propagation
void pushdown(int idx) {
  if (s[idx].flag) {
    ll L = s[idx].lh;
    int l = s[idx].l;
    for (int i = lson; i <= rson; ++i) {
      s[i].lo = s[i].lh = L + s[i].l - l;
      s[i].flag = true;
      s[i].lazy = 0;
    }
  } else if (s[idx].lazy) {
    for (int i = lson; i <= rson; ++i) {
      s[i].lh += s[idx].lazy;
      s[i].lo += s[idx].lazy;
      s[i].lazy += s[idx].lazy;
    }
  }
  s[idx].flag = false;
  s[idx].lazy = 0;
}

// Assign segment [l, r] according to f[l-1] = L
void update(int idx, int l, int r, ll L) {
  if (s[idx].l >= l && s[idx].r <= r) {
    s[idx].lo = s[idx].lh = L + s[idx].l - l + 1;
    s[idx].flag = true;
    s[idx].lazy = 0;
    return;
  }
  pushdown(idx);
  int mid = (s[idx].l + s[idx].r) >> 1;
  if (l <= mid)
    update(lson, l, r, L);
  if (mid + 1 <= r)
    update(rson, l, r, L);
  calc(idx);
}

// Range addition
void add(int idx, int l, int r) {
  if (s[idx].l >= l && s[idx].r <= r) {
    s[idx].lh++;
    s[idx].lo++;
    s[idx].lazy++;
    return;
  }
  pushdown(idx);
  int mid = (s[idx].l + s[idx].r) >> 1;
  if (l <= mid)
    add(lson, l, r);
  if (mid + 1 <= r)
    add(rson, l, r);
  calc(idx);
}

// Range minimum query
ll query(int idx, int l, int r) {
  if (r < 1 || l > w)
    return INF;
  if (s[idx].l >= l && s[idx].r <= r)
    return s[idx].lo;
  pushdown(idx);
  ll ans = INF;
  int mid = (s[idx].l + s[idx].r) >> 1;
  if (l <= mid)
    ans = min(ans, query(lson, l, r));
  if (mid + 1 <= r)
    ans = min(ans, query(rson, l, r));
  return ans;
}

class Solution {
public:
  void solve() {
    read(h), read(w);
    vector<int> l(h), r(h);
    for (int i = 0; i < h; ++i)
      read(l[i]), read(r[i]);
    vector<ll> ans(h, INF);
    build(1, 1, w);
    for (int i = 0; i < h; ++i) {
      if (l[i] > 1)
        add(1, 1, l[i] - 1);
      if (r[i] < w)
        add(1, r[i] + 1, w);
      ll L = query(1, l[i] - 1, l[i] - 1);
      update(1, l[i], r[i], L);
      ans[i] = query(1, 1, w);
    }
    for (ll i : ans)
      cout << (i >= INF ? -1 : i) << endl;
  }
};

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  Solution solution = Solution();
  solution.solve();
}


Measured memory_bytes: 37464
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<tuple>
#include<set>
#include<cmath>
#include<numeric>
#define ll long long
#define MOD = 1e9+7
const double PI=3.14159265358979323846; 
using namespace std;

int main(){
  double A,B,H,M;
  cin >> A >> B >> H >> M;

  double theta = abs(H*30 - M*6 + 0.5*M);
  if(theta > 180){
    theta = 360 - theta;
  }
  double rad = PI * theta/180;
  double ans = sqrt(A*A + B*B - 2.0 * A * B * cos(rad));
  cout << setprecision(30) << ans << endl;
}


Measured memory_bytes: 3600
a = list(map(int,input().split())) #input from array of integer like "1 2 3"

day = a[1]
cnt = 0

for x in range(day+1):
  if x >10:
    if int(str(x)[0]) >= 2 and int(str(x)[1]) >=2:
      if int(str(x)[0]) * int(str(x)[1]) <= a[0]:
        cnt += 1
        #print("{}/{}".format(int(str(x)[0]) * int(str(x)[1]), x))

print(cnt)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define pu push_back
#define fi first
#define se second
#define mp make_pair
#define int long long
#define sz 200005
int dp[110][100010];
signed main()
{
	
	int n,w;
	cin>>n>>w;
	
	int P[n+5];
	int W[n+5];
	
	for(int i=1;i<=n;i++)
	{
		cin>>W[i]>>P[i];
	}
	int ans=0;
	for(int i=1;i<=n;i++)
	{
		for(int j=0;j<=w;j++)
		{
			dp[i][j]=max(dp[i][j],dp[i-1][j]);
			if(j>=W[i]) dp[i][j]=max(dp[i][j],dp[i-1][j-W[i]]+P[i]);
			ans=max(ans,dp[i][j]);
		}
	}
	
	cout<<ans<<endl;
	
	
}

Measured memory_bytes: 79360
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
//環境で固定された変数を宣言
#define IN 200000
#define INPUTSIZE IN+2

int main() {
	//変数宣言
	int i, j;
	char Sin[INPUTSIZE], Tin[INPUTSIZE];
	char c;
	
	//入力受付
	fgets(Sin, INPUTSIZE, stdin);
	fgets(Tin, INPUTSIZE, stdin);
	int size = strlen(Sin);

	//文字列交換
	for (i = 0; i < size; i++) {
		if (Sin[i] != Tin[i]) {
			c = Sin[i];
			for (j = 0; j < size; j++) {
				if (Sin[j] == c || Sin[j] == Tin[i]) {
					if (Sin[j] == c) Sin[j] = Tin[i];
					else if(Sin[j] == Tin[i]) Sin[j] = c;
					//代入後に終了判定
					if (j <= i && Sin[j] != Tin[j]) {
						//終了タグに強制移動
						goto MyEndFlag;
					}
				}
			}
		}
	}
	//プログラムの終了
	MyEndFlag:
	printf(i == size ? "Yes\n":"No\n");
	return 0;
}

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


int main(){
    int a,b,ans;cin >> a >> b;
    ans = a*b;
    if(ans%2 == 1){
        cout << "Odd" << endl;
    }else{
        cout << "Even" << endl;
    }
}

Measured memory_bytes: 764