akhauriyash/Code-Regression huggingface dataset:
import sys
import heapq

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    N, K = [int(x) for x in input().split()]
    A = [int(x) for x in input().split()]

    MOD = 10 ** 9 + 7

    plus = []
    minus = []
    for a in A:
        if a >= 0:
            heapq.heappush(plus, -a)
        else:
            heapq.heappush(minus, a)

    ans = 1

    # 絶対マイナスになる場合
    if len(plus) < K - min((K - K % 2), (len(minus) - len(minus) % 2)):
        plus = []
        minus = []
        for a in A:
            if a >= 0:
                heapq.heappush(plus, a)
            else:
                heapq.heappush(minus, -a)

        while K > 0:
            if plus:
                x = plus[0]
            else:
                x = float("inf")

            if minus:
                y = -minus[0]
            else:
                y = float("inf")

            if abs(x) <= abs(y):
                ans *= x
                if plus:
                    heapq.heappop(plus)
            else:
                ans *= y
                if minus:
                    heapq.heappop(minus)

            ans %= MOD
            K -= 1

        print(ans)

    else:
        while K > 0:
            if K >= 2 and len(minus) >= 2 and len(plus) >= 2:
                x1 = plus[0]
                x2 = plus[1]
                y1 = minus[0]
                y2 = minus[1]
                if x1 * x2 <= y1 * y2:
                    y1 = heapq.heappop(minus)
                    y2 = heapq.heappop(minus)
                    ans *= (y1 * y2)
                    ans %= MOD
                    K -= 2
                else:
                    x1 = -heapq.heappop(plus)
                    ans *= x1
                    ans %= MOD
                    K -= 1
            elif K >= 2 and len(minus) >= 2:
                y1 = heapq.heappop(minus)
                y2 = heapq.heappop(minus)
                ans *= (y1 * y2)
                ans %= MOD
                K -= 2
            else:
                x = -heapq.heappop(plus)
                ans *= x
                ans %= MOD
                K -= 1

        print(ans % MOD)


if __name__ == '__main__':
    main()


Measured memory_bytes: 31692
from collections import Counter
N=int(input())
A=list(map(int,input().split()))
Q=int(input())
#print()
#print(N)
#print(A)
#print(Q)
#print()
counterA = dict(Counter(A))
counterAkeys=set(counterA.keys())
#print(counterAkeys)

sumA = sum(A)

#print(sumA,counterA)
for _ in range(Q):
  b,c=map(int,input().split())
  #print(b,c)
  if b not in counterAkeys:
    print(sumA)
    continue
  b_cnt = counterA[b]
  counterA[b]=0
  if c in counterAkeys:
    counterA[c] += b_cnt
  else:
    counterA[c] = b_cnt
    counterAkeys.add(c)

  sumA+=(c-b)*b_cnt
  print(sumA)

Measured memory_bytes: 23676
#include <bits/stdc++.h>
using namespace std;
const unsigned int MOD = 1000000007;
#define ll long long
#define PI 3.1416
string day[]={"SUN","MON","TUE","WED","THU","FRI","SAT"};
int main() {
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int n;
    while(cin>>n){
        if(n%2==0)cout<<fixed<<setprecision(10)<<((n/2.0)/n)<<endl;
        else cout<<fixed<<setprecision(10)<<((floor(n/2)+1)/n)<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <iomanip>
#include <vector>
#include <map>
#include <tuple>
#include <algorithm>
#include <cmath>
#include <set>
#include <queue>
#include <numeric>

using namespace std;
typedef long long ll;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
typedef pair<int, int> DI;
string s[] = {
	"2431",
	"0352",
	"0154",
	"0451",
	"0253",
	"4213",
};

int getn(DI d, int dir) {
	//printf("%d %d %d\n", d.first, d.second, dir);
	int t, f;
	tie(t, f) = d;
	while (s[t][0]-'0' != f) {
		string s2 = s[t];
		for (int i = 1; i < 4; i++) {
			s[t][i-1] = s2[i];
		}
		s[t][3] = s2[0];
	}
	return s[t][dir]-'0';
}

DI rotn(DI d, int dir) {
	int a = getn(d, (dir+3)%4);
	int b = getn(d, dir);
//	printf("asdfjalkdfjlkj %d %d\n", a, b);
	while (s[a][0]-'0' != b) {
		string s2 = s[a];
		for (int i = 1; i < 4; i++) {
			s[a][i-1] = s2[i];
		}
		s[a][3] = s2[0];
	}
	//cout << s[a] << endl;
	DI dd = d;
	switch (dir) {
	case 0:
		dd.first = s[a][2]-'0';
		dd.second = s[a][1]-'0';
		break;
	case 1:
		dd.first = s[a][2]-'0';
		break;
	case 2:
		dd.first = s[a][2]-'0';
		dd.second = s[a][3]-'0';
		break;
	case 3:
		dd.first = s[a][2]-'0';
		break;
	}
	return dd;
}

int di[4][2] = {
	{1, 0},
	{0, 1},
	{-1, 0},
	{0, -1}
};
int main() {
	while (true) {
		int n;
		cin >> n;
		if (!n) break;
		int rank[300][300] = {};
		int up[300][300] = {};
		for (int i = 0; i < n; i++) {
			int a, b;
			cin >> a >> b; a--; b--;
			DI d = DI(a, b);
			int x = 150, y = 150;
			while (true) {

				bool f = false;
				int mm = 0, md = 0;
				for (int k = 0; k < 4; k++) {
					int xx = x+di[k][0], yy = y+di[k][1];
					if (rank[x][y] > rank[xx][yy]) {
						if (getn(d, k) >= 3) {
							f = true;
							if (getn(d, k) > mm) {
								mm = getn(d, k);
								md = k;
							}
						}
					}
				}

				if (!f) break;
				d = rotn(d, md);
				x += di[md][0];
				y += di[md][1];
				//printf("rot %d %d %d\n", md, d.first, d.second);
			}
			rank[x][y]++;
			up[x][y] = d.first;
		}
		int d[6] = {};
		for (int x = 0; x < 300; x++) {
			for (int y = 0; y < 300; y++) {
				if (rank[x][y]) {
					d[up[x][y]]++;
				}
			}
		}
		for (int i = 0; i < 5; i++) {
			printf("%d ", d[i]);
		}
		printf("%d\n", d[5]);
	}

	return 0;
}

Measured memory_bytes: 1912
# copy and paste (check calc time)
import sys
 
read = sys.stdin.buffer.read
input = sys.stdin.buffer.readline
inputs = sys.stdin.buffer.readlines
 
 
# mod=10**9+7
# rstrip().decode('utf-8')
# map(int,input().split())
# import numpy as np
 
def main():
	n=int(input())
	dp=[[0]*3 for _ in range(n+1)]
	
	
	for i in range(n):
		a,b,c=map(int,input().split())
		dp[i+1][0]=max(dp[i][1],dp[i][2])+a
		dp[i+1][1] = max(dp[i][2], dp[i][0]) + b
		dp[i+1][2] = max(dp[i][0], dp[i][1]) + c
		
	print(max(dp[n][0],dp[n][1],dp[n][2]))
	
	
	
if __name__ == "__main__":
	main()

Measured memory_bytes: 53484
facts = [1]
mod =  10**9 + 7
for i in range(1, 2010):
	facts.append((i*facts[-1])%mod)
modinv = []
for i in facts:
	modinv.append(pow(i, mod - 2, mod))

def choose(p, r):
	return (((facts[p]*modinv[r])%mod)*modinv[p-r])%mod

n, k = map(int, raw_input().split())
blue = k
red = n - k
for i in range(1, k+1):
	if i <= n - k + 1:
		print (choose(red + 1, i)*choose(k - 1, i - 1))%mod
	else:
		print 0

Measured memory_bytes: 2820
import math
X=int(input())

n=int(math.sqrt(X))
ans=0

if(X==1 or X==2 or X==3):
    print(1)
else:
    for i in range(2,n+1):
        j=2
        while(i**j<=X):
            if(i**j>ans):
                ans=i**j
            j+=1
    print(ans)

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

int main(){
    int a,b,c,d;
    string res;
    cin >> a >> b >> c >> d;
    while(1){
        a-=d;
        c-=b;
        if(a<=0 || c<=0) break;
    }
    if(a<=0 && c<=0){
        res="Yes";
    }else if(a<=0){
        res="No";
    }else{
        res="Yes";
    }
    cout << res << endl;
}

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

string leng(int n,string s){
  while(n != (int)s.size()) s = '0' + s;
  return s;
}

string add(string a,string b){
  a = leng(200,a);
  b = leng(200,b);
  int n=0;
  for(int i = (int)a.size()-1; i >= 0; i--){
    a[i] -= '0'; b[i] -= '0';
    a[i] += b[i] + n;
    n = a[i] /10;
    a[i] %=10;
    a[i] += '0';
  }
  return a;
}

int main(void){
  string str;
  while(cin >> str){

    bool f = true;
    for(int k = 0; k < 10; k++){
      int l = 0,p = 0;
      string a[3];
      string s = str + '=';
      for(int i = 0; i < (int)s.size(); i++){
	if(s[i] == 'X') s[i] = k + '0';
	else if('0' > s[i] || s[i] > '9'){
	  a[p] = s.substr(l,i-l);
	  p++;
	  l = i+1;
	}
      }
      if((a[0][0] == '0' && a[0].size()-1) ||
	 (a[1][0] == '0' && a[1].size()-1) ||
	 (a[2][0] == '0' && a[2].size()-1)) continue;
      //cout << "a = " << add(a[0],a[1]) << endl;
      //cout << "b = " << leng(200,a[2]) << endl;
      if(add(a[0],a[1]) == leng(200,a[2])){
	f = false;
	cout << k << endl;
	break;
      }
    }
    if(f) cout << "NA" << endl;
  }
}

Measured memory_bytes: 1200
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
constexpr int INF = 1e8;

int main(){ 
  int n, m, R;
  cin >> n >> m >> R;
  vector<int> r(R);
  rep(i,R) cin >> r[i], r[i]--;
  sort(r.begin(), r.end());
  vector<vector<int>> dp(n, vector<int>(n, INF));
  rep(i,n) dp[i][i] = 0;
  rep(i,m) {
    int a, b, c;
    cin >> a >> b >> c;
    a--; b--;
    dp[a][b] = c;
    dp[b][a] = c;
  }

  for (int k = 0; k < n; k++) {
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j]);
      }
    }
  }

  int res = INF;

  do {
    int tmp = 0; 
    for (int i = 0; i < R - 1; i++) tmp += dp[r[i]][r[i + 1]];
    res = min(res, tmp);
  } while (next_permutation(r.begin(), r.end()));

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


Measured memory_bytes: 3828
/*apna time ayega*/ 
#include <bits/stdc++.h>
using namespace std;

#define pb push_back
#define mp make_pair
#define ll long long

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int a,h,m,b;
    cin>>a>>b>>h>>m;
    
   double angle=(h*30) + (double)m/2 - m*6 ;
    
  double angle1;
   angle1 = angle*3.1415926535897932384626433/180;
  double len =sqrt(a*a + b*b - 2*a*b*cos(angle1));
   //cout<<cos(angle1)<<endl;
  printf("%0.20lf",len);
   
 }
  

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

int main() {
    int N, M; cin >> N >> M;
    vector<int> num(N, 1), red(N, 0);
    red[0] = 1;

    for (int i = 0; i < M; i++) {
        int s, t; cin >> s >> t; s--, t--;
        red[t] |= red[s];
        num[s]--, num[t]++;
        if (num[s] == 0) red[s] = 0;
    }

    int cnt = 0;
    for (int i = 0; i < N; i++) {
        if (red[i]) cnt++;
    }
    cout << cnt << endl;
    return 0;
}

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


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    ll n;
    cin>>n;
    vector<ll> a(n+1),b(n+1),c(n+1);
    for(ll i=1;i<=n;i++) cin>>a[i];
    for(ll i=1;i<=n;i++) cin>>b[i];
    for(ll i=1;i<n;i++) cin>>c[i];

    ll sum=0;
    for(ll i=1;i<=n;i++){
        ll x=a[i];
        sum+=b[x];
        if(i<n){
            if(a[i+1]-a[i]==1){
                ll y=a[i];
                sum+=c[y];
            }
        }
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  double W, H, x, y, b=0;
  cin >> W >> H >> x >> y;
  double s;
  s = W * H /2.0;
  
  if (W/2.0 == x && H/2.0 == y ) {
    b++;
  }
  
  cout << s << " " << b << endl;
  return 0;
}


Measured memory_bytes: 256
def gcm(a,b):
  while b:
    a,b=b,a%b
  return a
n = input()
a = [int(x) for x in [i for i in input().split()]]
r=-1
for i in a:
  if r==-1:
    r=i
    continue
  r=gcm(r,i)
x=0
while r!=1:
  if r%2!=0:
    x=-1
    break
  r/=2
  x+=1
  
print(x)

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

#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define spa << " " <<
#define MP make_pair
ll MOD = 1e9+7;
//ll MOD = 998244353;
ll INF = 1e18;
void chmin(ll &a, ll b) { if (a > b) a = b; }
void chmax(ll &a, ll b) { if (a < b) a = b; }
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;}
void ans(bool x, ll y, ll z){
  if(x) cout<<y<<endl;else cout<<z<<endl;}   


int main(){
  ll i,j;
  ll n,k; cin>>n>>k;
  //ll a,b,c,d,e,f; cin>>a>>b;
  //ll a,b,c,d,e,f; cin>>a>>b>>c;
  //ll a,b,c,d,e,f; cin>>a>>b>>c>>d;
  bool judge = true;
  ld count[n+1];
  ll buf;
  for(i=1;i<=n;i++){
    buf = i;
    count[i]=1;
    for(;buf<k;buf*=2) count[i]*=2;
  }
  ld result=0;
  for(i=1;i<=n;i++){
    result+=1/(n*count[i]);
  }
  cout<<fixed<<setprecision(13)<<result<<endl;
  return 0;
}

Measured memory_bytes: 1792
import functools

import os

INF = float('inf')


def inp():
    return int(input())


def inpf():
    return float(input())


def inps():
    return input()


def inl():
    return list(map(int, input().split()))


def inlf():
    return list(map(float, input().split()))


def inls():
    return input().split()


def inpm(line):
    return [inp() for _ in range(line)]


def inpfm(line):
    return [inpf() for _ in range(line)]


def inpsm(line):
    return [inps() for _ in range(line)]


def inlm(line):
    return [inl() for _ in range(line)]


def inlfm(line):
    return [inlf() for _ in range(line)]


def inlsm(line):
    return [inls() for _ in range(line)]


def debug(fn):
    if not os.getenv('LOCAL'):
        return fn

    @functools.wraps(fn)
    def wrapper(*args, **kwargs):
        print('DEBUG: {}({}) -> '.format(
            fn.__name__,
            ', '.join(
                list(map(str, args)) +
                ['{}={}'.format(k, str(v)) for k, v in kwargs.items()]
            )
        ), end='')
        ret = fn(*args, **kwargs)
        print(ret)
        return ret

    return wrapper


x, y = inl()
print(max(x-y,0))


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

const int MOD = 1000000007;
const ll INF = numeric_limits<ll>::max();
const int inf = 1e8;

//少数点表示
//cout <<std::fixed << std::setprecision(14)

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

    vector<int> a(5);
    rep(i,5) cin>>a[i];
    int last=inf;
    rep(i,5){
        if(a[i]%10!=0){
            last=min(last,a[i]%10);
        }
    }
    int ans=0;
    rep(i,5){
        if(a[i]%10!=0){
            ans+=a[i]+(10-a[i]%10);
        }else{
            ans+=a[i];
        }
    }
    
    cout << ((last==inf) ? ans : ans-10+last);



}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll am[300];
ll n;
char str[300000];
int main()
{
	ll ans = 1;
	scanf(" %s", str);
	n = strlen(str);
	for (ll i = 0; i < n; i++)
	{
		ans+=i-am[str[i]];
		am[str[i]]++;
	}
	printf("%lld\n", ans);
}

Measured memory_bytes: 384
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

int main()
{
	string S;
	cin>>S;
	cout<<S[0]<<S.length()-2<<S[S.length()-1]<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<stack>
#include<queue>
#include<algorithm>
#include<vector>
#include<math.h>
#include<bitset>
#include<iomanip>
#include<numeric>
#include<list>
using namespace std;

typedef stack<int> IntStack;
typedef queue<int> IntQueue;

const double pi = 3.141592653589793;


//最大公約数
template<class T> T gcd(T a, T b)
{
	while (true)
	{
		T r;
		if (a%b == 0) return b;
		else
		{
			r = a % b;
			a = b;
			b = r;
		}
	}
}
//最小公倍数
template<class T> T lcm(T a, T b)
{
	return a / gcd(a, b)*b;
}
//文字0~9をint型0~9に変換
int char_to_int(char c)
{
	if (c == '0') return 0;
	if (c == '1') return 1;
	if (c == '2') return 2;
	if (c == '3') return 3;
	if (c == '4') return 4;
	if (c == '5') return 5;
	if (c == '6') return 6;
	if (c == '7') return 7;
	if (c == '8') return 8;
	if (c == '9') return 9;
	else return -1;
}
//int型0~9を文字0~9に変換
char int_to_char(int c) {
	if (c == 0) return '0';
	if (c == 1) return '1';
	if (c == 2) return '2';
	if (c == 3) return '3';
	if (c == 4) return '4';
	if (c == 5) return '5';
	if (c == 6) return '6';
	if (c == 7) return '7';
	if (c == 8) return '8';
	if (c == 9) return '9';
	else return'x';
}
//a^b mod MODを計算
long long int ModPower(long long int a, long long int b, long long int MOD)
{
	if (b == 0) return 1;
	else if (b % 2 == 0)
	{
		long long int d = ModPower(a, b / 2, MOD);
		return (d*d) % MOD;
	}
	else
	{
		return (a*ModPower(a, b - 1, MOD)) % MOD;
	}
}
//nCr mod MODを計算
long long int ModCombi(long long int n, long long int r, long long int MOD)
{
	if (n == 0 || r == 0) return 1;

	long long int Kn = 1, Kr = 1, Knr = 1;

	long long int temp = 1;
	for (long long int i = 1; i <= n; i++)
	{
		temp *= i;
		temp %= MOD;
		if (i == n) Kn = temp;
		if (i == r) Kr = temp;
		if (i == n - r) Knr = temp;
	}

	long long int x = ModPower(Kr, MOD - 2, MOD);
	long long int y = ModPower(Knr, MOD - 2, MOD);

	long long int ans;
	ans = Kn * x;
	ans %= MOD;
	ans *= y;
	ans %= MOD;

	return ans;
}
//int型10進数をord桁のstring型2進数に変換する
string binary(int x, int ord)
{
	int y;
	string ans = "";
	for (int i = 0; i < ord; i++)
	{
		y = x / (int)pow(2, ord - 1 - i);
		y %= 2;
		if (y == 0) ans += "0";
		else ans += "1";
	}

	return ans;
}
//ord桁のstring型2進数をint型10進数に変換する
int rep_binary(string x, int ord)
{
	int res = 0;
	for (int i = 0; i < ord; i++)
	{
		if (x[i] == '1') res += (int)pow(2, ord - 1 - i);
	}
	return res;
}
//xとyのビットごとの排他的論理和
template<class T> T XOR(T x, T y)
{
	T n = 0;
	while (max(x, y) > pow(2, n)) n++;
	T ans=0;
	for (int i = 0; i <= n; i++)
	{
		T x1 = (x % (T)pow(2, i + 1)) / (T)pow(2, i);
		T y1 = (y % (T)pow(2, i + 1)) / (T)pow(2, i);
		if (x1 != y1) ans += (T)pow(2, i);
	}
	return ans;
}

/*ここまでテンプレ*//*ここまでテンプレ*//*ここまでテンプレ*//*ここまでテンプレ*/



int main()
{
	int N, K, S;
	cin >> N >> K >> S;

	if (S <= 2)
	{
		for (int i = 0; i < K; i++)
		{
			cout << S << " ";
		}
		for (int i = K; i < N; i++)
		{
			cout << S + 1 << " ";
		}
	}
	else
	{
		for (int i = 0; i < K; i++)
		{
			cout << S << " ";
		}
		for (int i = K; i < N; i++)
		{
			cout << S - 1 << " ";
		}
	}
}

Measured memory_bytes: 1280
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		int n;
		int[] d;

		Scanner sc = new Scanner(System.in);
		n = sc.nextInt();

		d = new int[n];

		for (int i = 0; i < n; i++) {
			d[i] = sc.nextInt();
		}

		int sum = 0;
		int right = 0;

		for (int i = 0; i < n; i++) {
			for (int j = i+1; j < n; j++) {
				right += d[j];
              
			}
            sum += d[i] * right;
            right = 0;
		}

		System.out.println(sum);

		return;
	}
}

Measured memory_bytes: 35696
#include <iostream>
#include <vector>
#include <algorithm>
#include <limits>
#include <cmath>

using namespace std;

template <class T> struct SegmentTreeMin
{
	int N;
	vector<T> node;
	const T INF = (1<<31)-(T)1;

	SegmentTreeMin (int n){
		N = 2 << (int)log2(n);
		node.resize(N*2, INF);
	}

	void update(int idx, T val){
		idx += N;
		node[idx] = val;
		while (idx > 0){
			node[idx>>1] = min(node[idx], node[idx^1]);
			idx >>= 1;
		}
	}

	T get_min(int l, int r){
		T ret = INF;
		for (l += N, r += N; l < r; l >>= 1, r >>= 1) {
			if (l&1) ret = min(ret, node[l++]);
			if (r&1) ret = min(ret, node[--r]);
		}
		return ret;
	}
};

int main(int argc, char const *argv[])
{
	int n, q;
	cin >> n >> q;

	vector<unsigned int> ans;

	SegmentTreeMin <unsigned int> st(n);
	for (int i = 0; i < q; ++i) {
		int com, x, y;
		cin >> com >> x >> y;
		if (com==0) st.update(x, y);
		else ans.push_back(st.get_min(x, y+1));
	}

	for (int i = 0; i < ans.size(); ++i){
		cout << ans[i] << endl;
	}
	return 0;
}


Measured memory_bytes: 4508
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int i = 0;
        while(true){
            int n = sc.nextInt();
            int a = sc.nextInt();
            if(n == 0 && a == 0)break;
            if(n < a){
                System.out.print(n+" "+a);
            }else{
                System.out.print(a+" "+n);
            }
            System.out.println();
            i++;
            sc.nextLine();
        }
        //System.out.println();
    }
}


Measured memory_bytes: 41604
#include <bits/stdc++.h>
using namespace std;
#define rep(i, N) for(int i=0; i<N; i++)
typedef long long ll;
#define dump(x) cerr<<#x<<"="<<x<<endl

int main() {
    int t, x;
    cin >> t >> x;

    cout << fixed << setprecision(10) << t/(double)x << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    // TODO 自動生成されたメソッド・スタブ
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();

    if (a < b) {
      String x = "";
      for (int i = 0; i < b; i++) {
        x += a;
      }
      System.out.println(x);
    } else {
      String x = "";
      for (int i = 0; i < a; i++) {
        x += b;
      }
      System.out.println(x);
    }
  }
}


Measured memory_bytes: 21716
strSen = input()
listSen = list(strSen)
pattern1 = 'abcdefghijklmnopqrstuvwxyz'
pattern2 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
for i in range(len(listSen)):
    if listSen[i] in pattern1:
        if i != len(listSen)-1:
            print(listSen[i].upper(), end = "")
        else:
            print(listSen[i].upper())
    elif listSen[i] in pattern2:
        if i != len(listSen)-1:
            print(listSen[i].lower(), end = "")
        else:
            print(listSen[i].lower())
    else:
        if i != len(listSen)-1:
            print(listSen[i], end = "")
        else:
            print(listSen[i])


Measured memory_bytes: 5716
#include<bits/stdc++.h>
#define EPS 1e-10
#define equals(a,b) (fabs((a)-(b)) < EPS)
#define rep(i,n) for(int i=0;i<n;++i)
typedef long long ll;
using namespace std;

static const int COUNTER_CLOCKWISE = 1;
static const int CLOCKWISE = -1;
static const int ONLINE_BACK = 2;
static const int ONLINE_FRONT = -2;
static const int ON_SEGMENT = 0;

struct Point {
    double x,y;
    Point(){}
    Point(double x, double y) : x(x),y(y){}
    Point operator+(Point p) {return Point(x+p.x, y+p.y);}
    Point operator-(Point p) {return Point(x-p.x, y-p.y);}
    Point operator*(double k){return Point(x*k,y*k);}
    Point operator/(double k){return Point(x/k,y/k);}
    double norm(){return x*x+y*y;}
    double abs(){sqrt(norm());}
    bool operator == (const Point &p) const {return equals(x,p.x)&&equals(y,p.y);}
};
typedef Point P;

double norm(P a){return a.x*a.x+a.y*a.y;}
double abs(P a){return sqrt(norm(a));}

// 線分
struct Segment {
    Point p1,p2;
    Segment(){}
    Segment(Point p1, Point p2):p1(p1),p2(p2){}
};

// 内積
double dot(Point a, Point b) {return a.x*b.x + a.y*b.y;}

// 外積
double cross(Point a, Point b) {return a.x*b.y-a.y*b.x;}
// 2直線の直行判定
bool is_orthogonal(Point a1, Point a2, Point b1, Point b2) {
    return equals(dot(a1-a2, b1-b2), 0.0);
}
// 2直線の平行判定
bool is_parallel(Point a1, Point a2, Point b1, Point b2) {
    return equals(cross(a1-a2, b1-b2), 0.0);
}

int ccw(Point p0,Point p1,Point p2) {
    P a = p1-p0;
    P b = p2-p0;
    if(cross(a,b) > EPS) return COUNTER_CLOCKWISE;
    if(cross(a,b) < -EPS) return CLOCKWISE;
    if(dot(a,b) < -EPS) return ONLINE_BACK;
    if(a.norm()<b.norm()) return ONLINE_FRONT;
    return ON_SEGMENT;
}

bool is_intersected_ls(Point p1, Point p2, Point p3, Point p4) {
    return (ccw(p1,p2,p3)*ccw(p1,p2,p4) <= 0&&ccw(p3,p4,p1)*ccw(p3,p4,p2) <= 0 );
}

P intersection_ls(P a1, P a2, P b1, P b2) {
    P b = b2-b1;
    double d1 = abs(cross(b, a1-b1));
    double d2 = abs(cross(b, a2-b1));
    double t = d1/(d1+d2);
    return a1+(a2-a1)*t;
}

int main() {
    int q;
    cin>>q;
    rep(i,q){
        double x0,y0,x1,y1,x2,y2,x3,y3;
        cin>>x0>>y0>>x1>>y1>>x2>>y2>>x3>>y3;
        P p0(x0,y0),p1(x1,y1),p2(x2,y2),p3(x3,y3);
        P ans = intersection_ls(p0,p1,p2,p3);
        cout << fixed << setprecision(12);
        cout << ans.x << " " << ans.y << endl;
    }
    return 0;
}


Measured memory_bytes: 3292
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <set>
#include <vector>
#include <map>
#include <cstdio>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <cassert>
#include <climits>
using namespace std;
typedef long long ll;
#define DEBUG
#ifdef DEBUG
	#define debug printf
#else
	#define debug(...)
#endif
int main(int argc, char const *argv[])
{
	int n,a,b;
	cin>>n>>a>>b;
	printf("%d\n",min(n * a,b));
	return 0;
}

Measured memory_bytes: 256
module app;

import core.bitop;

import std.algorithm;
import std.array;
import std.bigint;
import std.conv;
import std.stdio;
import std.string;

struct Input
{
	int n;
}

void parseInput(T)(out Input input, T file)
{
	with (file) with (input)
	{
		auto single = readln().strip();
        n = single.to!int;
	}
}

struct Output
{
}

auto main2(Input* input)
{
    foreach (a; 1..10)
        foreach (b; 1..10)
            if (a * b == input.n)
                return "Yes";
    return "No";
}

unittest { writeln("begin unittest"); }

unittest // example1
{
	string example =
`10`;
	Input input = void;
	parseExample(input, example);
	auto result = main2(&input);
	writeln(result);
	assert(result == "Yes");
}

unittest // example2
{
	string example =
`50`;
	Input input = void;
	parseExample(input, example);
	auto result = main2(&input);
	writeln(result);
	assert(result == "No");
}

unittest // example3
{
	string example =
`81`;
	Input input = void;
	parseExample(input, example);
	auto result = main2(&input);
	writeln(result);
	assert(result == "Yes");
}

unittest { writeln("end unittest"); }

void parseExample(out Input input, string example)
{
	struct Adapter
	{
		string[] _lines;
		this(string input) { _lines = input.splitLines(); }
		string readln() { auto line = _lines[0]; _lines = _lines[1..$]; return line; }
	}
	parseInput(input, Adapter(example));
}

void main()
{
	Input input = void;
	parseInput(input, stdin);
	auto result = main2(&input);
	writeln(result);
}


Measured memory_bytes: 256
var output;
var input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
var obj = {
  "list" : input,
  "index" : 0,
  "max" : input.length,
  "next" : function(){
    if(!this.hasNext()){return null;}
    var returnObj = this.list[this.index];
    this.index++;
    return returnObj;
  },
  "hasNext" : function(){return (this.index < this.max);}
}
Main();
function next(){return obj.next();}
function hasNext(){return obj.hasNext();}
function myout(t){console.log(t);}//standard output
function myerr(t){console.error(t);}//standard error
//[no]param
//不明値:何もしない 異常時:文字列「error」を返す（できる？）
//1:数値へ変換 2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字に分割 7:1文字に分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return "error";}}
function Main() {
  var N = myconv(next(),1);
  input.shift();
  input = input.map((a)=>{var tmp = a.split(" ").map(Number);return [tmp[0]-tmp[1],tmp[0]+tmp[1]]});
  input.sort(function(a,b){
  	return a[1] - b[1]
  });
  output = N;
  var end = 0;
  for(var i = 0; i < N; i++){
    if(i == 0){
       end = input[i][1];
    }else{
      if(end > input[i][0]){
         output--;
      }else{
         end = input[i][1];
      }
    }
  }
  myout(output);
}


Measured memory_bytes: 53488
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll GCD(ll x,ll y){
    if(y == 0) return x;
    else return GCD(y,x%y);
}
const int MOD = 1000000007;

int main() {
    int n,a,b,ans=0; cin >> n >> a >> b;
    for(int i = 1;i <= n;i++){
        int c = i;
        int total = 0;
        while(c){
            total += c%10;
            c/=10;
        }
        if(total <= b && total >= a){
            ans+=i;
        }
    }
    cout << ans;
}




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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

constexpr int INF = std::numeric_limits<int>::max();
int N, K, Q;
int A[2000];

int f(int i){
    std::vector<int> v;

    int j = 0;
    while(A[j] < A[i]){
        j += 1;
    }

    for(int k=j;j<N;j=k){
        std::vector<int> w;

        while(k < N && A[k] >= A[i]){
            w.emplace_back(A[k]);
            k += 1;
        }

        std::sort(w.begin(), w.end());

        if(w.size() >= K){
            std::copy(w.begin(), w.begin() + (w.size() - (K - 1)), std::back_inserter(v));
        }

        while(k < N && A[k] < A[i]){
            k += 1;
        }
    }

    if(v.size() >= Q){
        std::sort(v.begin(), v.end());
        return v[Q - 1] - v[0];
    }
    return INF;
}

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

    std::cin >> N >> K >> Q;

    for(int i=0;i<N;++i){
        std::cin >> A[i];
    }

    int mn = INF;

    for(int i=0;i<N;++i){
        mn = std::min(mn, f(i));
    }

    std::cout << mn << std::endl;
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
using ll = int64_t;

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

    constexpr ll MAX = 1e5;

    vector<ll> x(N), y(N);
    for (ll i = 0; i < N; i++) {
        cin >> x[i] >> y[i];
        y[i] += MAX + 1;
    }

    vector<vector<ll>> edges(2 * MAX + 2);

    for (ll i = 0; i < N; i++) {
        edges[x[i]].push_back(y[i]);
        edges[y[i]].push_back(x[i]);
    }

    ll ans = 0;

    vector<bool> visit(2 * MAX + 2, false);
    for (ll i = 0; i < 2 * MAX + 2; i++) {
        ll X_num = 0, Y_num = 0;
        stack<ll> st;
        st.push(i);
        while (!st.empty()) {
            ll t = st.top();
            st.pop();
            if (visit[t]) {
                continue;
            }

            visit[t] = true;
            (t <= MAX ? X_num++ : Y_num++);

            for (ll next : edges[t]) {
                if (!visit[next]) {
                    st.push(next);
                }
            }
        }

        ans += X_num * Y_num;
    }

    cout << ans - N << endl;
}

Measured memory_bytes: 10240
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;

int main(){
    ll n;
    cin>>n;
    ll p[n];
    for(ll i=0;i<n;++i){
        cin>>p[i];
    }
    ll ans=0;
    for(ll i=2;i<n;++i){
        if(min(p[i-2], p[i])<p[i-1] and p[i-1]<max(p[i-2], p[i])){
            ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (ll i=0; i<(n); i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
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; }
 
int main(){
    char a,b; cin >> a >> b;
    bool ok=false;
    if (a=='H' && b=='H') ok=true;
    if (a=='D' && b=='D') ok=true;
    
    if (ok) cout << 'H' << endl;
    else cout << 'D' << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
readline = sys.stdin.readline

S = readline().strip()
T = readline().strip()

s = len(S)
t = len(T)
ans = t
for i in range(0, s-t+1):
  n = t
  for j in range(t):
    if S[i+j] == T[j]:
      n -= 1
  if n < ans:
    ans = n
  if ans == 0:
    break
print(ans)


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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define _GLIBCXX_DEBUG

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;
using vvll = vector<vll>;
using vvd = vector<vd>;
using vvvi = vector<vvi>;
using vvvll = vector<vvll>;
using vvvd = vector<vvd>;

const double pi=3.141592653589793;

int main() {
    int n;
    cin>>n;
    string s;
    cin>>s;
    int ans=0;
    for (int i=0;i<10;i++){
        for (int j=0;j<10;j++){
            for (int k=0;k<10;k++){
                int now=0;
                rep(l,n){
                    if (now==0){
                        if (s.at(l)-'0'==i){
                            now+=1;
                        }
                    }
                    else if (now==1){
                        if (s.at(l)-'0'==j){
                            now+=1;
                        }
                    }
                    else if (now==2){
                        if (s.at(l)-'0'==k){
                            ans+=1;
                            //cout<<i<<" "<<j<<" "<<k<<endl;
                            break;
                        }
                    }
                }
            }
        }
    }
    cout<<ans<<endl;
   

    return 0;
}   

Measured memory_bytes: 256
import java.util.*;
 
public class Main {
 
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int sum=0;
        for(int i=1;i<=n;i++){
            sum=sum+i;
        }
        System.out.println(sum);
    }
}

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

#define int long long
#define rep(i,l,r) for(int i=(int)(l);i<(int)(r);i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)x.size())
template<class T>bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,T b){if(a>b){a=b;return 1;}return 0;}

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;

const int inf = 1LL<<60;
const int mod = 1e9 + 7;
const double eps = 1e-9;

/*{
  }*/

int dp[10001][2][101];

signed main(){
  string k;
  int D;
  cin >> k >> D;
  int n = sz(k);

  dp[0][0][0] = 1;
  rep(i, 0, n) rep(j, 0, 2) rep(l, 0, 101){
    int d = j ? 9 : k[i]-'0';
    rep(x, 0, d+1){
      (dp[i+1][j||x<d][(l+x)%D] += dp[i][j][l]) %= mod;
    }
  }

  cout << (dp[n][0][0]+dp[n][1][0]+mod-1)%mod << endl;

  return 0;
}



Measured memory_bytes: 16000
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
using ll = long long;
const ll mod = 1000000007;
const ll INF = 100000000000000000LL;
signed main(){
    string s;
    cin>>s;
    int l = s.length();
    cout<<s[0]<<l-2<<s[l-1]<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<string.h>
#include<complex>
#include<math.h>
using namespace std;
typedef long long int llint;
typedef vector<int> vint;
typedef vector<llint> vllint;
#define rep(i,n) for(int i=0;i<n;i++)
#define yes(ans) if(ans)cout<<"yes"<<endl;else cout<<"no"<<endl;
#define Yes(ans) if(ans)cout<<"Yes"<<endl;else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl;else cout<<"NO"<<endl;

bool check(int a, int b) {
	return a > b;
}

int main() {
	char s[1010];
	cin >> s;
	int a[4] = {};
	rep(i, strlen(s)) {
		if (s[i] == 'N') {
			a[0] = 1;
		}
		if (s[i] == 'W') {
			a[1] = 1;
		}
		if (s[i] == 'S') {
			a[2] = 1;
		}
		if (s[i] == 'E') {
			a[3] = 1;
		}
	}
	rep(i, 4) {
		cerr << a[i] << endl;
	}
	Yes(a[0] == a[2] && a[1] == a[3]);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define pp pop_back
#define in insert
#define ff first
#define ss second
#define  show for(int j=0;j<v.size();j++) cout<<v[j]<<" ";
#define ld long double
#define e endl
#define bc __builtin_popcount
#define MOD 1000000007
#define INT_SIZE 32
#define me(x) memset(x,0,sizeof(x))
ll fast_expo(ll x,ll p)
{if(p==0) return 1;
else if(p%2==0){ ll t=fast_expo(x,p/2)%MOD;return (t*t)%MOD;} else return (x*(fast_expo(x,p-1))%MOD)%MOD;}
int main()
{
    int x,y,na,nb,nc,i;
    cin>>x>>y>>na>>nb>>nc;
    ll a[na],b[nb],c[nc];
    priority_queue<ll> pq;
    for(int i=0;i<na;i++)
    {
         cin>>a[i];
    }
    sort(a,a+na,greater<ll>());
    for(i=0;i<x;i++)
    {
         pq.push(a[i]);
    }
    for(int i=0;i<nb;i++)
    {
         cin>>b[i];
    }
    sort(b,b+nb,greater<ll>());
    for(i=0;i<y;i++)
    {
         pq.push(b[i]);
    }
    for(i=0;i<nc;i++)
    {
         cin>>c[i];
    }
    sort(c,c+nc,greater<ll>());
    for(i=0;i<min(x+y,nc);i++)
    {
         pq.push(c[i]);
    }
    int sz=x+y;
    ll ans=0;
    while(sz--)
    {
         ans+=pq.top();
         pq.pop();
    }
    cout<<ans<<e;
}


Measured memory_bytes: 8432
#include<stdio.h>
    #include<string.h>
    int main(void){
            int b=0,r=0,i,n;
            char s[100000];
            scanf("%s",&s);
            n=strlen(s);
            for(i=0;i<n;i++){
                    if(s[i]==0x30) r++;
                    else b++;}
            if(r>=b) printf("%d",2*b);
            else printf("%d",2*r);
            return 0;
    }

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


long long shakutori(vector<long long> a, long long x) {
    long long res = 0;
    long long n = a.size();

    long long right = 0, sum = 0;
    for (long long left = 0; left < n; left++) {
        while (right < n && sum + a[right] <= x) {
            sum += a[right];
            right++;
        }

        res += (right - left);

        if (right == left) right++;
        else sum -= a[left];
    }

    return res;
}

int main() {
    long long n, q;
    cin >> n >> q;
    vector<long long> a(n);
    for (long long i = 0; i < n; i++) {
        cin >> a[i];
    }
    for (long long i = 0; i < q; i++) {
        long long x;
        cin >> x;
        cout << shakutori(a, x) << endl;
    }
}


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

//typedef
//------------------------------------------
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;

// grid
//--------------------------------------------
VL dx = {0, 1, 0, -1};
VL dy = {1, 0, -1, 0};
VL dx2 = {-1, 0, 1, -1, 1, -1, 0, 1};
VL dy2 = {-1, -1, -1, 0, 0, 1, 1, 1};

//debug
//--------------------------------------------
#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

//IO accelerate
//--------------------------------------------
struct InitIO {
    InitIO() {
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(30);
    }
} init_io;

//template
//--------------------------------------------
template<typename T>
istream& operator >>(istream& is, vector<T>& vec) {
  for(T& x: vec) is >> x;
  return is;
}
template<typename T>
ostream& operator <<(ostream& os, const vector<T>& vec) {
  for(int i=0; i<vec.size(); i++){
    os << vec[i] << ( i+1 == vec.size() ? "" : "\t" );
  }
  return os;
}
template<typename T>
ostream& operator <<(ostream& s, const vector<vector<T>>& vv) {
	for (int i = 0; i < vv.size(); ++i) {
		s << vv[i] << endl;
	}
	return s;
}
template<typename T>
ostream& operator <<(ostream& s, const vector<pair<T, T>>& vp) {
	for (int i = 0; i < vp.size(); ++i) {
		s << "(" << vp[i].first << "," << vp[i].second << ")" << ( i+1 == vp.size() ? "" : ",\t" );
	}
	return s;
}

// 多重vector
// auto dp=make_v<int>(4,h,w) みたいに使える
template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

// 多重vectorのためのfill
// fill_v(dp,0) みたいに使える
template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}

//main code

int main(int argc, char const* argv[])
{
	int n;
	cin >> n;
	VL a(n);
	cin >> a;
	int num = 0;
	for (int i = 0; i < n; i++) {
		if (a[i] == num+1) {
			num++;
		}
	}
	if (num == 0) {
		cout << -1 << endl;
	} else {
		cout << n-num << endl;
	}
	return 0;
}


Measured memory_bytes: 1792
#include <iostream>
//#include <string>
//#include <algorithm>

using namespace std;

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

    long result = 0;

    if (N == 1 && M == 1) {
        cout << 1 << endl;
        return 0;
    }else if (N == 1 || M == 1) {
        cout << max(M,N)-2 << endl;
        return 0;
    }
        //result = (N*M) - (2*(N-1) + 2*(M-1));
        result = (N-2)*(M-2);


    cout << result << endl;

    return 0;
}


Measured memory_bytes: 256
N, M, Q = map(int, input().split())
L = [list(map(int, input().split())) for _ in range(Q)]


def main(l, m):
    ret = 0
    if len(l) == N:
        for a, b, c, d in L:
            if l[b - 1] - l[a - 1] == c:
                ret += d
        return ret

    for i in range(m, M + 1):
        ret = max(ret, main(l + [i + 1], i))
    return ret


print(main([], 1))


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

#define lli long long int
#define REP(i,s,l) for(lli i=s;i<l;i++)
#define DEBUG 0
#define INF (1LL<<50)
#define MOD 1000000007
#define rev(v) reverse(v.begin(), v.end());

bool comp(int a, int b){
    return (a<b);
}

int main(){
    int k; cin >> k;
    string s; cin >> s;
    if(k<s.length()){
        REP(i,0,k) cout << s[i];
        cout << "...";
    }
    else{
        cout << s;
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
#include <vector>
#include <numeric>
#define PI 3.14159265358979323846
#define MAXINF 1e18L
#define INF 1e9L
#define EPS 1e-9
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
typedef long long ll;
typedef pair<int, int> pii;

int main(void)
{
    int n,m;
    cin >> n >> m;
    vector<int> c(m);
    REP(i, m){
        cin >> c[i];
    }
    SORT(c);

    vector<int> minimum(n+1, INF);

    minimum[0] = 0;
    minimum[1] = 1;
    Rep(i, 2, n+1){
        REP(j, m){
            int pi = i - c[j];
            if(pi < 0) continue;
            int tmp = minimum[pi] + 1;
            if(minimum[i] > tmp) minimum[i] = tmp;
        }    
    }

    pr(minimum[n]);
}


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

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef pair<ll, ll> pair_t;
using Graph = vector<vector<ll>>;

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
/***** define constant start *******/
const ll MOD = 1000000007;
const double PI = 3.1415926535897932;
const ll INF = LLONG_MAX;
/****** define constant end ********/
/****** define variable start ******/
ll r;
/******* define variable end *******/
int solve() {
	cin >> r;
	cout << 2 * PI * r << endl;
	return 0;
}

int main() {
	// clock_t start = clock();
	cout << std::fixed << std::setprecision(10);
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int end_solve = solve();
	/*
	clock_t end = clock();
	const double time = static_cast<double>(end - start) / CLOCKS_PER_SEC *
	1000.0; printf("time %lf[ms]\n", time);
	*/

	return end_solve;
}


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

using namespace std;
typedef long long lint;

#define RPT(i, b, e) for (int i = ((int)b); i <= ((int)e); i++)
#define RPT0(i, n) RPT(i, 0, ((int)n) - 1)
#define RPT1(i, n) RPT(i, 1, (n))
#define EACH(it, v) for (const auto& it : v)
#define ALL(v) v.begin(), v.end()

void resolve()
{
    lint A, B, N;
    cin >> A >> B >> N;

    lint z = N + 1 / B;
    lint x = (N >= B) ? B - 1 : N;
    lint ans = floor((double)A * x / B) - A * floor((double)x / B);
    cout << ans << endl;
}

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


Measured memory_bytes: 3632
console.log(function(args){
  const [[N,M],...tmp] = args.trim().split('\n').map( r=>r.split(' ').map(v=>v|0) );
  const e = Array(N).fill(0).map(_=>[]), d = Array(N).fill(0);
  for ( let [x,y] of tmp ) {
    e[x-1].push( y-1 );
    d[y-1]++;
  }
  const queue = [], dp = Array(N).fill(0);
  for ( let i = 0; i < N; i++ ) if ( !d[i] ) queue.push(i);
  while ( queue.length ) {
    const v = queue.shift();
    for ( const child of e[v] ) {
      d[child]--;
      if ( d[child] === 0 ) {
        queue.push( child );
        if ( dp[child] < dp[v] + 1 ) dp[child] = dp[v] + 1;
      }
    }
  };
  return dp.reduce((a,b)=>Math.max(a,b|0)).toString();
}(require('fs').readFileSync('/dev/stdin', 'utf8')));


Measured memory_bytes: 96528
/**
*    created: 13.05.2020 20:04:32
**/
#include <bits/stdc++.h>
#define int long long
const int INF = 1e18L + 5;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using namespace std;

signed main() {

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

    int a, b;
    cin >> a >> b;
    int g = __gcd(a,b);
    set<int> div;
    if (g == 1) {
        cout << 1 << endl;
        return 0;
    }

    if (g % 2 == 0){
        while (g % 2 == 0){
            div.insert(2);
            g /= 2;
        }
    }
    for (int i = 3; i*i <= g; i += 2){
        while (g % i == 0){
            div.insert(i);
            g /= i;
        }
    }
    if (g != 1) div.insert(g);
    cout << div.size() + 1 << endl;
    return 0;
}

Measured memory_bytes: 256