akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
// *テンプレート*
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define P pair<int, int>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const long long MOD = 1000000007;
const long long INF = 0x3f3f3f3f;
using namespace std;
typedef long long ll;
map<int, int> mp;
using Graph = vector<vector<int>>; 
//最大公約数
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
//最小公倍数
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}

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

// pair -> vector<pair<int,int>> 
//		   AandB.push_back(make_pair(a[i],b[i]))

string str;
signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin >> str;
	for (int bit = 0; bit < 8; bit++) {
		int tmp = (int)(str[0] - '0');
		rep(i, 3) {
			if (bit&(1 << i))tmp += (int)(str[i + 1] - '0');
			else tmp -= (int)(str[i + 1] - '0');
		}
		if (tmp == 7) {
			cout << str[0];
			rep(i, 3) {
				if (bit&(1 << i))cout << '+';
				else cout << '-';
				cout << str[i + 1];
			}
			cout << "=7" << endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 256
import kotlin.math.max

fun main() {
    val (n, m, k) = readLongList()
    val a = readLongList()
    val b = readLongList()
    var time = 0L
    var countA = 0
    run {
        a.forEach{
            time += it
            if(time >= k) {
                if(time == k) {
                    countA++
                } else {
                    time -= it
                }
                return@run
            }
            countA++
        }
    }
    var countMax = countA
    var countB = countA
    run {
        b.forEach {
            time += it
            while(time > k) {
                if(countB == 0) {
                    return@run
                } else {
                    countB--
                    countA--
                    time -= a[countB]
                }
            }
            countA++
            countMax = max(countA, countMax)
        }
    }
    println(countMax.toString())
}

fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readIntList() = readLine()!!.split(" ").map(String::toInt)
fun readLongList() = readLine()!!.split(" ").map(String::toLong)

Measured memory_bytes: 81688
N = int(input())

A = []
B = []
for _ in range(N):
    a, b = map(int, input().split(' '))
    A.append(a)
    B.append(b)

A.sort()
B.sort()

if N % 2 == 0:
    med_a = (A[N // 2 - 1] + A[N // 2])
    med_b = (B[N // 2 - 1] + B[N // 2])
else:
    med_a = A[N // 2]
    med_b = B[N // 2]

print(med_b - med_a + 1)


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

int main(){
  long long n, m;
  cin >> n >> m;

  if(n == 1 && m == 1){
    cout << 1 << endl;
    return 0;
  }
  
  if(n == 1 || m == 1){
    long long r = n * m;
    cout << r - 2 << endl;
    return 0;
  }

  long long r = n * m;
  long long ln = 2 * n;
  long long lm = 2 * m;
  long long rlt = r - ln - lm + 4;
  cout << rlt << endl;
  
  return 0;
}


Measured memory_bytes: 256
import bisect
N = int(input())
L = sorted([int(x) for x in input().split()])
cnt = 0
for i in range(N-2):
    for j in range(i+1, N-1):
        cnt +=  bisect.bisect_left(L, L[i]+L[j]) - (j+1)
print(cnt)


Measured memory_bytes: 42972
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define per(i,n) for(int i=(n)-1; i>=0; i--)
using namespace std;
using vi = vector<int>;
using vv = vector<vi>;

int main(){
    int n,k; cin >> n >> k;
    if((n+1)/2>=k)cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

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

const int MAX = 200000;
int main() {
	static int N, A[MAX];
	cin >> N;
	for (int i = 0;i < N;i ++) cin >> A[i];
	
	static int64_t sum[MAX + 1]; // 累積和
	sum[0] = 0;
	for (int i = 0;i < N;i ++) sum[i + 1] = A[i] + sum[i];
	sort(sum, sum+N+1);
	int64_t ans = 0;
	int num = 1;
	for (int i = 1;i <= N;i ++) {
		if (sum[i] == sum[i - 1]) num ++;
		else {
			ans += (int64_t)num * (num - 1) / 2;
			num = 1;
		}
	}
	ans += (int64_t)num * (num - 1) / 2;
	cout << ans;
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり

後で説明するね
*/

Measured memory_bytes: 2560
import math
x = int(input())
n = 16 // (math.log10(1.01))
a = 100
cnt = 0

while a < x:
    cnt += 1
    a = math.floor(a * 1.01)

'''
for i in range(1, math.floor(n)+1):
    a = math.floor(a * 1.01)
    cnt += 1
    if a >= x:
        break
    else:
        continue
'''

print(cnt)

Measured memory_bytes: 9304
#include<stdio.h>
int main(void)
{
	int S, h, m, s, keep, keep1, keep2;
	scanf("%d", &S);
	h = S / 3600;
	keep1 = S - h * 3600;
	m = keep1 / 60;
	keep2 = keep1 - m * 60;
	s = keep2;
	printf("%d:%d:%d\n", h, m, s);
	return 0;
}


Measured memory_bytes: 2056
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <set>
#include <map>
#include <cassert>
#include <fstream>
#include <iomanip>

using namespace std;

int n;
vector<vector<int>> g;
vector<bool> used;
vector<int> put;
priority_queue<int> c;

void dfs(int v)
{
    used[v] = 1;
    for (int i = 0; i < g[v].size(); ++i)
    {
        int nextv = g[v][i];
        if (!used[nextv])
        {
            put[nextv] = c.top();
            c.pop();
            dfs(nextv);
        }
    }
}

int main() {
    
    
    cin >> n;
    
    g = vector<vector<int>>(n, vector<int>());
    used = vector<bool>(n, 0);
    put = vector<int>(n, 0);
    
    for (int i = 0; i < n - 1; ++i)
    {
        int u, v;
        cin >> u >> v;
        u--;
        v--;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    
    int m = 0;
    int s = 0;
    for (int i = 0; i < n; ++i)
    {
        int cc;
        cin >> cc;
        m = max(m, cc);
        s += cc;
        c.push(cc);
    }
    
    s -= m;
    
    put[0] = c.top();
    c.pop();
    dfs(0);
    
    cout << s << endl;
    for (int i = 0; i < n; ++i)
    {
        if (i == n - 1)
        {
            cout << put[i];
            break;
        }
        cout << put[i] << " ";
    }
    cout << endl;
    
    return 0;
}

Measured memory_bytes: 1408
A,B,C,X,Y = (int(_) for _ in input().split())
all_ab =max(X,Y)*C*2
no_ab = A*X + B*Y
if X>=Y:
    ab = Y*2*C + (X-Y)*A
else:
    ab = X*2*C + (Y-X)*B
print(min(all_ab,no_ab,ab))




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

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

    string A, B;
    cin >> A >> B;
    if (A.size() < B.size()) {
        cout << "LESS" << endl;
        exit(0);
    } else if (A.size() > B.size()) {
        cout << "GREATER" << endl;
        exit(0);
    } else {
        for (int i = 0; i < A.size(); ++i) {
            int x = A.at(i) - '0';
            int y = B.at(i) - '0';
            if (x > y) {
                cout << "GREATER" << endl;
                exit(0);
            } else if (x < y) {
                cout << "LESS" << endl;
                exit(0);
            }
        }
        cout << "EQUAL" << endl;
        exit(0);
    }

    return 0;
}

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

int main() {
  int N;
  int Ai;
  int count;
  int min_count = 33; // 10の9乗は2進数で33ビットあれば足りるので最大回数として設定

  cin >> N;

  for (int i = 0; i < N; i++) {
    cin >> Ai;

    count = 0;
    while (!(Ai % 2)) {
      Ai /= 2;
      count++;    
    }

    if (count < min_count) {
      min_count = count;
    }
  }

  cout << min_count << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define to edge[i].v
#define mp make_pair
#define rint register int
#define debug(x) cerr<<#x<<"="<<x<<endl
#define fgx cerr<<"-------------"<<endl
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
int a[1000000],b[1000000];
int main()
{	int n,k,x,n1=0,n2=0,ans=1e9; cin>>n>>k;
	for(rint i=1;i<=n;i++)
	{	scanf("%d",&x);
		if(x>0) a[++n1]=x;
		else if(x==0) k--;
		else b[++n2]=x;
	}
	reverse(b+1,b+n2+1);
	if(n1>=k) ans=min(ans,a[k]);
	if(n2>=k) ans=min(ans,-b[k]);
	for(rint i=0;i<=min(n1,k);i++) if(k-i<=n2) ans=min(ans,2*a[i]-b[k-i]);
	for(rint i=0;i<=min(n2,k);i++) if(k-i<=n1) ans=min(ans,-2*b[i]+a[k-i]);
	cout<<ans;
	return 0;
}


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

#define ll long long
#define rep(i, n) for(ll i = 0; i < n; i++)
ll MOD = 1e9 + 7;
int INF = 1 << 30;
ll INFL = 1LL << 60;

bool P(ll tar){
    if(tar <= 1) return 0;
    for(ll i = 2; i * i <= tar; i++){
        if(tar % i == 0) return 0;
    }
    return 1;
}

int main() {
    int N;
    cin >> N;
    int count = 0;
    rep(i,55555){
        if(P(i) && i%5 == 1 && count < N){ 
        cout << i << " ";
        count += 1;
        }
    }
    
    
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <set>
#include <string>
#include <algorithm>
#include <utility>
using namespace std;

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

    int N, M;
    cin >> N >> M;
    vector<int> A(N);
    for (int i = 0; i < N; ++i) cin >> A[i];
    sort(A.begin(), A.end());

    vector<pair<int, int>> CB(M);
    for (int i = 0; i < M; ++i) cin >> CB[i].second >> CB[i].first;
    sort(CB.begin(), CB.end(), greater<pair<int, int>>());

    int i = 0;
    int j = 0;
    long long ans = 0;
    while (j < N && i < M) {
        if (CB[i].first <= A[j]) break;
        // A[j] = CB[i].first;
        ans += CB[i].first;
        --CB[i].second;
        ++j;
        if (CB[i].second == 0) ++i;
    }

    while (j < N) ans += A[j++];
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1408
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

typedef struct Node Node;

struct Node{
    int data;
    Node *parent;
    Node *left;
    Node *right;
};

void initNode(Node*);
Node copyNode(Node*,Node*);
void insert(Node*,Node*[],int);
void printTree(Node*);
void inorder(Node*);
void preorder(Node*);


int main(int argc, char** argv) {
    int commandSize;
    scanf("%d",&commandSize);
    Node *tree[commandSize-1];
    for(int i = 0; i < commandSize; i++)
        tree[i] = NULL;
    int loc = 0;
    Node temp[commandSize-1];
    char cmd[7];
    for(int i = 0; i < commandSize; i++){
        initNode(&temp[i]);
        scanf("%s",cmd);
        if(!strcmp(cmd,"insert")){
            scanf("%d", &temp[i].data);
            insert(&temp[i],tree,loc++);
        }
        else{
            for(int j = 0; j < loc; j++)
                tree[j] = &temp[j];
            printTree(tree[0]);
        }
    }
    return (EXIT_SUCCESS);
}

void initNode(Node *n){
    n->data = NULL;
    n->parent = NULL;
    n->left = NULL;
    n->right = NULL;
}

void insert(Node *node, Node *tree[], int loc){
    Node *parent = NULL;
    Node *current = tree[0];
    while(current != NULL){
        parent = current;
        if(node->data < current->data)
            current = current->left;
        else
            current = current->right;
    }
    node->parent = parent;
    if(parent == NULL){
        tree[loc] = node;
    }
    else if(node->data < parent->data){
        tree[loc] = node;
        parent->left = tree[loc];
    }
    else{
        tree[loc] = node;
        parent->right = tree[loc];
    }
}

Node copyNode(Node *dest, Node *orig){
    dest->data = orig->data;
    dest->parent = orig->parent;
    dest->left = orig->left;
    dest->right = orig->right;
}

void printTree(Node *root){
    inorder(root);
    printf("\n");
    preorder(root);
    printf("\n");
}

void inorder(Node *root){
    if(root->left != NULL)
        inorder(root->left);
    printf(" %d", root->data);
    if(root->right != NULL)
        inorder(root->right);
}

void preorder(Node *root){
    printf(" %d", root->data);
    if(root->left != NULL)
        preorder(root->left);
    if(root->right != NULL)
        preorder(root->right);
}



Measured memory_bytes: 21384
#include<bits/stdc++.h>
using namespace std;
 
#define MAXN (int)(2*1e5 + 1)
#define F first
#define S second
#define endl "\n"
#define MOD (lli)(1e9 + 7)
#define lli long long int
#define sz(a) int(a.size())
#define DEBUG if(0) cout << "aqui" << endl;
#define PI 2 * acos(0.0)
typedef pair<int,int> ii;
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};
int dddx[] = {1, -1, 0, 0, 1, 1, -1, -1};
int dddy[] = {0, 0, 1, -1, 1, -1, 1, -1};

vector<int> vec = {100, 101, 102, 103, 104, 105};
int pd[100001];
bool at = false;
int x;

int solve(int atual){
  if(at) return 1;
  if(atual > x) return 0;
  if(atual == x){
    at = true;
    return 1;
  }

  if(pd[atual] != -1) return pd[atual];
  int at = 0;
  for(auto i : vec){
    at = max(at, solve(atual+i));
  }

  return pd[atual] = at;
}

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

  cin >> x;
  memset(pd, -1, sizeof pd);

  solve(0);

  if(at) cout << 1 << endl;
  else cout << 0 << endl;

  return 0;
}

Measured memory_bytes: 640
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		String ss = sc.next();
		int cnt = 0;
		
		for (int i = 0; i < Math.floor(ss.length()/2); i++) {
			if (ss.charAt(i) != ss.charAt(ss.length() - i -1)) {
				cnt++;
			}
		}
		
		
		System.out.println(cnt);
	}
}

Measured memory_bytes: 22612
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<long>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using vvl = vector<vector<long>>;
using pii = pair<int, int>;
using pil = pair<int, long>;
using pll = pair<long, long>;
#define fix20 cout << fixed << setprecision(20)
#define YES cout << "Yes" << endl
#define NO cout << "No" << endl
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,s,t) for(int i=s; i<t; i++)
#define RNG(i,s,t,u) for(int i=s; i<t; i+=u)
#define MOD 1000000007
#define all(vec) vec.begin(), vec.end()

int main(){
  int n,m;
  cin >> n >> m;
  bool graph[10][10] = {};
  vi data(n);
  rep(i,n) data.at(i) = i;
  rep(i,m){
    int a,b;
    cin >> a >> b;
    graph[a-1][b-1] = true;
    graph[b-1][a-1] = true;
  }
  int cnt = 0;
  do{
    if(data.at(0) != 0) continue;
    bool flag = true;
    for(int i=0;i<n-1;i++){
      if(!graph[data[i]][data[i+1]]) flag = false;
    }
    cnt += flag;
  }while(next_permutation(data.begin(), data.end()));
  cout << cnt << endl;
}

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

#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define fastt ios_base::sync_with_stdio(false); cin.tie(NULL)

typedef long long ll;
typedef pair<ll,ll> pii;

/*-----------------------------------------------------------------------*/

int main(){
   fastt;

   int n,w;
   cin>>n>>w;

   int weight[n+1];
   int val[n+1];
   ll value[100001];

   memset(weight,0,sizeof(weight));
   memset(val,0,sizeof(val));
   memset(value,0,sizeof(value));

   for(int i=1;i<=n;i++){
      cin>>weight[i]>>val[i];
   }

   for(int i=1;i<=n;i++){
      for(int j=100000;j>=weight[i];j--){
         value[j]=max(value[j],val[i]+value[j-weight[i]]);
      }
   }

   ll ans=0;

   for(int i=0;i<=w;i++)
      ans=max(ans,value[i]);

   cout<<ans<<endl;

   return 0;
}


Measured memory_bytes: 1024
while True:
    H,W=map(int,input().split())
    if H==0 and W==0:
        break
    print(W*"#",end="")
    print("")
    for i in range(H-2):
        print("#"+(W-2)*"."+"#",end="")
        print("")
    print(W*"#",end="")
    print("")
    print("")


Measured memory_bytes: 5620
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.util.NoSuchElementException;

public class Main {

	static PrintWriter out;
	static InputReader ir;
	static int sl=600;

	static void solve() {
		int x=ir.nextInt();
		int y=ir.nextInt();
		out.println(x%y==0?-1:x);
	}

	public static void main(String[] args) throws Exception {
		ir = new InputReader(System.in);
		out = new PrintWriter(System.out);
		solve();
		out.flush();
	}

	static class InputReader {

		private InputStream in;
		private byte[] buffer = new byte[1024];
		private int curbuf;
		private int lenbuf;

		public InputReader(InputStream in) {
			this.in = in;
			this.curbuf = this.lenbuf = 0;
		}

		public boolean hasNextByte() {
			if (curbuf >= lenbuf) {
				curbuf = 0;
				try {
					lenbuf = in.read(buffer);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (lenbuf <= 0)
					return false;
			}
			return true;
		}

		private int readByte() {
			if (hasNextByte())
				return buffer[curbuf++];
			else
				return -1;
		}

		private boolean isSpaceChar(int c) {
			return !(c >= 33 && c <= 126);
		}

		private void skip() {
			while (hasNextByte() && isSpaceChar(buffer[curbuf]))
				curbuf++;
		}

		public boolean hasNext() {
			skip();
			return hasNextByte();
		}

		public String next() {
			if (!hasNext())
				throw new NoSuchElementException();
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while (!isSpaceChar(b)) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}

		public int nextInt() {
			if (!hasNext())
				throw new NoSuchElementException();
			int c = readByte();
			while (isSpaceChar(c))
				c = readByte();
			boolean minus = false;
			if (c == '-') {
				minus = true;
				c = readByte();
			}
			int res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res = res * 10 + c - '0';
				c = readByte();
			} while (!isSpaceChar(c));
			return (minus) ? -res : res;
		}

		public long nextLong() {
			if (!hasNext())
				throw new NoSuchElementException();
			int c = readByte();
			while (isSpaceChar(c))
				c = readByte();
			boolean minus = false;
			if (c == '-') {
				minus = true;
				c = readByte();
			}
			long res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res = res * 10 + c - '0';
				c = readByte();
			} while (!isSpaceChar(c));
			return (minus) ? -res : res;
		}

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

		public int[] nextIntArray(int n) {
			int[] a = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}

		public long[] nextLongArray(int n) {
			long[] a = new long[n];
			for (int i = 0; i < n; i++)
				a[i] = nextLong();
			return a;
		}

		public char[][] nextCharMap(int n, int m) {
			char[][] map = new char[n][m];
			for (int i = 0; i < n; i++)
				map[i] = next().toCharArray();
			return map;
		}
	}
}

Measured memory_bytes: 21332
from collections import defaultdict as dd
from itertools import accumulate
N, K = map(int, input().split())
As = [0] + list(map(int, input().split()))
S = list(accumulate(As))

ans = 0
counts = dd(int)
counts[0] = 1
for j in range(1, N+1):
    if j >= K:
        counts[(S[j-K] - (j-K)) % K] -= 1
    t = (S[j] - j) % K
    ans += counts[t]
    counts[t] += 1
print(ans)

Measured memory_bytes: 48360
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(),(v).end()
typedef pair<int,int> pii;
const int mod = (int) 1000000007;
const int inf = (int) 2e18;

int cost(string &s, string& t){
  int n = t.size(), c = 0;
  for(int i=0; i<n; i++)
    if(s[i] != t[i])
      c++;
  return c;
}

int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
  cout << fixed << setprecision(9);
	#ifdef LOCAL_DEFINE
		freopen("in.txt", "rt", stdin);
	#endif
  // code
  string s, t;
  cin >> s >> t;
  int ns = s.size(), nt = t.size();
  int res = INT_MAX;
  for(int i=0; i<=ns-nt; i++){
    string nstr = s.substr(i, nt);
    if(cost(nstr, t) < res) res = cost(nstr, t);
  }
  cout << res << "\n";
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file 
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional> // for less 
#define pb push_back
#define For(i,s,e) for (ll i=(s); i<(e); i++)
#define Debug_array(a,n) for (ll i=(0); i<(n); i++) cout<<a[i]<<" "
#define Foe(i,s,e) for (ll i=(s); i<=(e); i++)
#define Fod(i,s,e) for (ll i=(s)-1; i>=(e); i--)
#define pii pair<ll,ll>
#define fi first
#define se second
#define endl "\n"
#define mp make_pair
#define big_prime 15486277
#define bigger_prime 179424697
#define biggest_prime 32416188691
//#define random_shuffle(indices.begin(), indices.end());
//std::random_device rd;
//std::mt19937 g(rd());
//std::shuffle(v.begin(), v.end(), g);
using namespace __gnu_pbds; 
using namespace std;
template <class T> ostream& operator << (ostream &os, const vector<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T> ostream& operator << (ostream &os, const set<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T, class S> ostream& operator << (ostream &os, const pair<T, S> &v) { os << v.first << ' ' << v.second; return os; }
// template <class T, class S> ostream& operator << (ostream &os, const unordered_map<T, S> &v) { for (auto i : v) os << '(' << i.first << "=>" << i.second << ')' << ' '; return os; }
 
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <class Arg1> void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 << endl; }
    template <class Arg1, class... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args) {
        const char* sep = strchr(names + 1, ',');
        cerr.write(names, sep - names) << " : " << arg1 << "  ";
        __f(sep + 1, args...);
    }
#else
#define trace(...) 0
#define _CRT_SECURE_NO_WARNINGS
#endif // ifndef ONLINE_JUDGE


typedef long long ll;
typedef tree<ll, null_type, less<ll>, rb_tree_tag,tree_order_statistics_node_update> ordered_set; 

#define Mod 1000000007
#define MAX 5002

int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	ll n;cin>>n;
	ll a[n];For(i,0,n) cin>>a[i];
	vector<ll> b[n];
	For(i,0,n){
		a[i]--;
		b[a[i]].pb(i);
	}
	ll ans = 0;
	ll prev = -1;
	For(i,0,n){
		if(b[i].size()==0) break;
		ll index = lower_bound(b[i].begin(),b[i].end(),prev)-b[i].begin();
		if(index<b[i].size()){
			ans++;
			prev = b[i][index];
		}else{
			break;
		}
	}

	if(ans==0){
		cout<<-1<<endl;
	}else{
		cout<<n-ans<<endl;
	}































	
}

Measured memory_bytes: 12800
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;

auto rdsp(){return readln.splitter;}
void pick(R,T)(ref R r,ref T t){t=r.front.to!T;r.popFront;}
void readV(T...)(ref T t){auto r=rdsp;foreach(ref v;t)pick(r,v);}

void main()
{
  int n, i; readV(n, i);
  writeln(n-i+1);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<string>
#include<map>
using namespace std;
typedef long long ll;
const ll N=212345;
string s[N];
map<string,int>Q;

int main()
{
	int n;
	cin>>n;
	int tp=0;
	for(int i=1;i<=n;i++){
		cin>>s[i];
		Q[s[i]]++;
		if(Q[s[i]]>tp){
			tp=Q[s[i]];
		}
	}
	sort(s+1,s+n+1);
	for(int i=1;i<=n;i++){
		if(Q[s[i]]==tp){
			cout<<s[i]<<endl;
			Q[s[i]]=0;
		}
	}
	return 0;
 } 

Measured memory_bytes: 26880
import bisect
import heapq
import itertools
import math
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7




N, A, B = list(map(int, sys.stdin.readline().split()))
print(min(A*N, B))



Measured memory_bytes: 23652
n = gets.to_i
s = gets.chomp.split("")
max = 0

for en in 0..(n-2)
  s1 = s[0..en]
  s2 = s[(en+1)..(n-1)]
  tp1 = Hash.new(0)
  tp2 = Hash.new(0)
  s1.each{|c| tp1[c] += 1}
  s2.each{|c| tp2[c] += 1}
  cnt = 0
  tp1.each do |k1,v1|
    tp2.each do |k2,v2|
      if k1 == k2
        cnt += 1
        break
      end
    end
  end
  max = [max, cnt].max
end
puts max

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

using namespace std;

int a[4];

int main(){
	for (int i = 0; i < 3; i++){
		scanf("%d", a + i);
	}
	sort(a, a + 3);
	if (a[0] + a[1] == a[2])
		puts("Yes");
	else 
		puts("No");
	return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define ld long double
#define MOD 1000000007
#define mod9 1000000009
#define fast ios_base :: sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define mp make_pair
#define pb push_back
#define ct ll t;cin>>t;while(t--)
#define bi begin()
#define ei end()
#define fi first 
#define se second  
#define foe(i,a,b) for(ll i=a;i<b;i++)
#define rfoe(i,a,b) for(ll i=a;i>=0;i--)
#define sz(s) s.size() 
#define mem(a,s) memset(a,s,sizeof(a)) 
#define all(v) v.bi,v.ei
#define MAX             8000000000000000064LL
#define MIN            -8000000000000000064LL  
// ll MOD; 
// ll add(ll a, ll b){return (a%MOD + b%MOD + ((MAX)/MOD)*MOD)%MOD;}
// ll sub(ll a, ll b){return (a%MOD - b%MOD + ((MAX)/MOD)*MOD)%MOD;}
// ll mul(ll a, ll b){return ((a%MOD)*(b%MOD) + ((MAX)/MOD)*MOD)%MOD;}
// ll fact[1000007]={0};
// ll expo(ll x, ll y) {ll res=1;x=x%MOD;while(y>0){if(y&1)res=(1ll*res*x)%MOD;
// y=y>>1;x=(1ll*x*x)%MOD;} return res;}
// void facto() {fact[0]=1;fact[1]=1;for(ll i=2;i<1000007;i++)fact[i]=(fact[i-1]*i)%MOD;}
// ll ncr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(expo(fact[r],MOD-2)))%MOD; res=(res*(expo(fact[n-r],MOD-2)))%MOD; return res;}
// ll npr(ll n,ll r) {facto(); ll res=1; res=fact[n]; res=(res*(expo(fact[n-r],MOD-2)))%MOD; return res; }
int const N=2e5+9;
ll const INF = 2e18+5;
 
void solve()
{ 
    ll n;
    cin>>n;
    string s;
    cin>>s;
    ll t=0;
    foe(i,0,sz(s))
    {
        if(s[i]=='W')
        {
            t++;
        }
    }
    ll ans=0;
    for(ll i=sz(s)-1;i>=0;i--)
    {
        if(t==0)
        {
            break;
        }
        if(s[i]=='R')
        {
            ans++;
        }
        t--;
        if(t==0)
        {
            break;
        }
    }
    cout<<ans<<"\n";
}
int main()
{
    fast
    // ct
    { 
        solve();
    }
}

Measured memory_bytes: 3772
#include<iostream>
using namespace std;
int main() {
    int H, W;
    while (1) {
        cin >> H >> W;
        if (H==0 && W==0) break;
        for (int i=0; i < H; i++) {
            if (i==0 | i==H-1) {
                for (int j=0; j < W; j++) {
                    cout << "#";
                }
            } else {
                cout << "#";
                for (int k=2; k < W; k++) {
                    cout << ".";
                }
                cout << "#";
            }
            cout << endl;
            }
            cout << endl;
        }
}


Measured memory_bytes: 3080
#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;

typedef long long ll;
ll n;
string s;
ll a[9];
ll b[128];

int main()
{
    b['M'] = 1;
    b['A'] = 2;
    b['R'] = 3;
    b['C'] = 4;
    b['H'] = 5;
    scanf("%lld", &n);
    for(ll i = 0; i < n; i++)
    {
        cin>>s;
        for(ll j = 1; j <= 5; j++)
        {
            if(b[s[0]] == j) a[j]++;
        }
    }
    ll c[5] = {1, 2, 3, 4, 5};
    ll sum = 0;
    do
    {
        sum += a[c[0]] * a[c[1]] * a[c[2]];
    }while(next_permutation(c, c + 5));
    printf("%lld", sum / 12);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <math.h>
#include <sstream>
#include <numeric>
#include <string>
#include <cassert>

using namespace std;
typedef long long ll;

int main() {
  int N;
  cin >> N;
  int cnt = 0;
  for (int i = 1; i <= N; ++i) {
    if (i % 2 == 1) ++cnt;
  }
  double x = double(cnt) / N;
  cout << x << endl;
  return 0;
}


Measured memory_bytes: 256
n=int(input())

if n % 2 == 0:
    print(int(n*(n-2)/2))
    for i in range(1,n):
        for j in range(i+1,n+1):
            if i+j != n+1:
                print(i,j)

if n % 2 != 0:
    print(int((n-1)**2/2))
    for i in range(1,n):
        for j in range(i+1,n+1):
            if i+j != n:
                print(i,j)

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

#define DEBUG 0

#if DEBUG
  #define DLOG(...) fprintf(stderr, __VA_ARGS__)
#else
  #define DLOG(...)
#endif

void debug(auto f) {
#if DEBUG
  f();
#endif
}

int main() {
  ll n;
  string s;
  cin >> n >> s;
  ll red = 0;
  ll blue = 0;
  for (auto c : s) {
    if (c == 'R')  red++;
    else           blue++;
  }
  string ans = red > blue ? "Yes" : "No";
  cout << ans << endl;
  return 0;
}



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

using namespace std;

int main(){
	int n;
	scanf("%d", &n);
	int d[n];
	for (int i = 0; i < n; ++i)
		scanf("%d", &d[i]);

    int arrSum = 0; 
    for (int i = 0; i < n; i++) 
        arrSum = arrSum + d[i]; 
  
    int arrSumSquare = arrSum * arrSum; 
  
    int indSquareSum = 0; 
    for (int i = 0; i < n; i++) 
        indSquareSum += d[i]*d[i];

    printf("%d", (arrSumSquare - indSquareSum)/2 );
	return 0;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.Scanner;

public class Main {

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

    void solve() {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        int X = Integer.parseInt(sc.next());
        int Y = Integer.parseInt(sc.next());
        sc.close();

        ArrayList<LinkedList<Integer>> edge = new ArrayList<>();

        for(int i=0; i<N; i++){
            LinkedList<Integer> nodelist = new LinkedList<Integer>();
            if(i > 0){
                nodelist.add(i-1);
            }
            if(i < N-1){
                nodelist.add(i+1);
            }
            if(i == X-1){
                nodelist.add(Y-1);
            }
            if(i == Y-1){
                nodelist.add(X-1);
            }
            edge.add(nodelist);
        }

        int[] result = new int[N];

        for(int i=0; i<N; i++){
            int dist[] = bfs(i, edge, N);
            for(int j=i+1; j<N; j++){
                result[dist[j]] += 1;
            }
        }

        for(int i=1; i<N; i++){
            System.out.println(result[i]);
        }
    }

        static int[] bfs(int snode,  ArrayList<LinkedList<Integer>> g, int n) {
        // snode start node, g graph (list), n number of node

        // 初期条件
        int[] dist = new int[n];            //snode からの頂点xの距離
        Arrays.fill(dist, -1); // -1の頂点は未探索
        dist[snode] = 0;
        LinkedList<Integer> queue = new LinkedList<Integer>();
        queue.add(snode);

        while(!queue.isEmpty()){
            int v = queue.poll();

            for(int i: g.get(v)){
                if (dist[i] != -1){
                    continue;
                }

                if(g.get(v).contains(i)){
                    dist[i] = dist[v] + 1;              //前提条件　長さ1
                    queue.add(i);
                }
            }
        }
        return dist;
    }
}

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

int main() {
  vector<int> w,k;
  int t;
  for(int i=0; i<10; ++i) {
    cin>>t;
    w.push_back(t);
  }
  for(int i=0; i<10; ++i) {
    cin>>t;
    k.push_back(t);
  }
  sort(w.begin(), w.end());
  sort(k.begin(), k.end());
  cout<<w[9]+w[8]+w[7]<<" "<<k[9]+k[8]+k[7]<<endl;
}

Measured memory_bytes: 0
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define pii pair<int, int>
#define vii vector<pii>
#define pb push_back
#define fi first
#define se second
using namespace std;
typedef long long ll;
const int MAXN = 1e6 + 5;
int par[MAXN];

inline int qry(int x) { return x == par[x] ? x : par[x] = qry(par[x]); }
inline void join(int u, int v) { par[qry(u)] = qry(v); }

int main() {
	int n, q; ll m;
	scanf("%d %lld %d", &n, &m, &q);
	for (int i = 0; i < n; i++) par[i] = i;
	vii edg;
	int cnt = 0;
	for (int i = 0; i < q; i++) {
		int a, b, c;
		scanf("%d %d %d", &a, &b, &c);
		if (c == 0) {
			if (qry(a) != qry(b))
				cnt++;
			join(a, b);
		} else {
			if (m == n-1)
				return !printf("No\n");
			edg.pb(make_pair(a,b));
		}
	}
	if (m == n-1)
		return !printf("Yes\n");
	for (auto it: edg)
		if (qry(it.fi) == qry(it.se))
			return !printf("No\n");
	ll tmp = 0;
	for (int i = 0; i < n; i++)
		if (qry(i) == i)
			cnt++, tmp++;
	if (cnt <= m && m <= cnt + (tmp*(tmp-3)) / 2)
		return !printf("Yes\n");
	printf("No\n");
	return 0;
}


Measured memory_bytes: 1784
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <list>
#include <iterator>
#pragma warning(disable:4996)
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
#define MOD 1000000007
using namespace std;

const long max_comb=300000;
vector<ll> fac(max_comb+1); //n! (mod M)
vector<ll> ifac(max_comb+1); //k!^(-1) (mod M)

ll mpow(ll x, ll n){ //x^n(mod M)
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % MOD;
        x = x*x % MOD;
        n = n >> 1;
    }
    return ans;
}

ll minv(ll x){
    return mpow( x, MOD-2 );
}

ll comb(long a, long b){     // C(a,b) = a! * b!^(-1) * (a-b)^(-1)
    if(a == 0 && b == 0)return 1;
    if(a < b || a < 0)return 0;
    ll tmp = ifac[a-b]* ifac[b] % MOD;
    return tmp * fac[a] % MOD;
}

ll perm(long a, long b){     // P(a,b) = a! * (a-b)!^(-1)
    if(b == 0)return 1;
    if(a < b || a < 0)return 0;
    ll tmp = ifac[a-b] % MOD;
    return tmp * fac[a] % MOD;
}

void pre_comb()
{
    fac[0] = 1;
    ifac[0] = 1;
    for(long i = 0; i<max_comb; i++){
        fac[i+1] = fac[i]*(i+1) % MOD; // n!(mod M)
        ifac[i+1] = ifac[i]*minv(i+1) % MOD; // k!^(-1) (mod M)
    }
    return;
}


ll f[200005][2];
ll g[200005][2];

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

    long b, w;
    scanf("%ld%ld", &b, &w);

    long k;
    for(k=0; k<w; k++) {
        f[k][0] = comb(b-1+k,b-1)*minv(mpow(2,b+k)) %MOD;
        f[k][1] = comb(b+k-2,k)  *minv(mpow(2,b+k)) %MOD;
    }
    for(k=0; k<b; k++) {
        g[k][0] = comb(w-1+k,w-1)*minv(mpow(2,w+k)) %MOD;
        g[k][1] = (k==0? 0: comb(w+k-2,k-1)*minv(mpow(2,w+k)) %MOD);
    }

    vector<ll> ans(b+w,0);
    if(b==1) {
        ans[0] = (ans[0] + f[0][0]) %MOD;
    }
    else {
        for(k=0; k<w; k++) {
            ans[0] = (ans[0] + f[k][1]) %MOD;
        }
    }
    for(k=0; k<b; k++) {
        ans[0] = (ans[0] + g[k][1]) %MOD;
    }
    printf("%lld\n", ans[0]);

    for(k=1; k<b+w; k++) {
        ans[k] = ans[k-1];
        if(k>=b-1) {
            if(k<b+w-1) {
                ans[k] = (ans[k] + f[k-b+1][0]) %MOD;
            }
            if(k>b-1) {
                ans[k] = (ans[k] - f[k-b][0] +MOD) %MOD;
            }
            if(k<b+w-1) {
                ans[k] = (ans[k] - f[k-b+1][1] +MOD) %MOD;
            }
        }

        if(k>=w-1) {
            if(k<b+w-1) {
                ans[k] = (ans[k] - g[k-w+1][1] +MOD) %MOD;
            }
            if(k>=w) {
                ans[k] = (ans[k] + g[k-w][0]) %MOD;
            }
        }
        printf("%lld\n", ans[k]);
    }

    return 0;
}


Measured memory_bytes: 14080
import java.io.PrintWriter;
import java.math.BigDecimal;
import java.util.ArrayList;
        import java.util.Collections;
        import java.util.List;
        import java.util.Scanner;

public class Main {
    static private Scanner scan = new Scanner(System.in);
    public static void main(String args[]) {
//        int int1 = Integer.parseInt(scan.next());
//        int int2 = Integer.parseInt(scan.next());

//        String str1 = scan.next();
        int int1 = Integer.parseInt(scan.next());
        int int2 = Integer.parseInt(scan.next());
        String str3 = scan.next();
        int ans_int = 0;
        double ans_dob = 0;
        String ans = "";


        StringBuilder sb = new StringBuilder();
        sb.append(str3);
        sb.replace(int2-1,int2,String.valueOf(str3.charAt(int2-1)).toLowerCase());
        PrintWriter out = new PrintWriter(System.out);
        out.println(sb);
        out.flush();
        scan.close();
    }
}


Measured memory_bytes: 21716
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>


int main(void) {
  long long int n, x, y;
  scanf("%lld %lld %lld", &n, &x, &y);
  x--;
  y--;
  long long int center_xy = (x + y) / 2;

  long long int dis[n];
  for (long long int i = 0; i < n; i++) {
    dis[i] = 0;
  }
  for (long long int i = 0; i < n - 1; i++) {
    long long int i_x = x - i;
    if (i_x < 0) i_x *= -1;
    long long int i_y = i_x + 1;
    for (long long int j = i + 1; j < n; j++) {
      if (i <= x) {
        if (j <= center_xy) {
          dis[j - i]++;
        } else if (j > center_xy && j < y) {
          dis[i_y + y - j]++;
        } else if (j >= y) {
          dis[i_y + j - y]++;
        }
      } else if (i > x && (center_xy + i_x) < y) {
        if (j <= (center_xy + i_x)) {
          dis[j - i]++;
        } else if (j > (center_xy + i_x) && j < y) {
          dis[i_y + y - j]++;
        } else if (j >= y) {
          dis[i_y + j - y]++;
        }
      } else {
        dis[j - i]++;
      }
    }

    /*
    for (long long int i = 1; i < n; i++) {
      printf("%lld ", dis[i]);
    }
    printf("\n");
    */
  }

  for (long long int i = 1; i < n; i++) {
    printf("%lld\n", dis[i]);
  }

  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>
#include <functional>
#include <set>

#define INPUT_FROM_FILE (0) 
#if INPUT_FROM_FILE
#include <fstream>
#endif


int main(){
	int q, com;
	long x;
	long L, R;
	std::set<long> s;

#if INPUT_FROM_FILE
	std::ifstream ifs("test.txt");
#endif

#if INPUT_FROM_FILE
	ifs >> q;
#else
	std::cin >> q;
#endif
	
	for(int i = 0; i < q; i++){
#if INPUT_FROM_FILE
		ifs >> com >> x;
#else
		std::cin >> com >> x;
#endif
		if(com == 0){
			s.insert(x);
			std::cout << s.size() << std::endl;
		}
		else if(com == 1){
			std::cout << s.count(x) << std::endl;
		}
		else if(com == 2){
			s.erase(x);
		}
		else{
			L = x;
#if INPUT_FROM_FILE
			ifs >> R;
#else
			std::cin >> R;
#endif
			std::set<long>::iterator it = s.lower_bound(L);
			while(it != s.end() && *it <= R){
				std::cout <<  *it << std::endl;
				it++;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 12380
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;


class Program {

	static int testN=3;
	static long mod = 1000000007;
	//static long mod =998244353; 
	static System.IO.StringReader sr;
	static void Main(string[] args) {
		char[] cs = new char[] { ' ' };
		//char[] cs = new char[] { ' ', ',' };

		//int n = int.Parse(Console.ReadLine());
		//int val = int.Parse(Console.ReadLine());
		//int[] vals = parseAry(Console.ReadLine().Split(cs));
		//string str = Console.ReadLine();
		//string[] strs = Console.ReadLine().Split(cs);

		//string res = "";
		int res = 0;


		int[] vals = parseAry(Console.ReadLine().Split(cs));
		res = vals[1];
		if ( vals[0] >= 10 ) {

		} else {

			res = res + ( 100 * ( 10 - vals[0] ) );
		}


			Console.WriteLine(res);

		return;

	}



	//	文字列strをindex番目からdで上書き
	static string strOverWrite(string str, int i, string s) {
		return str.Remove(i, s.Length).Insert(i, s);
	}

	//　String[]  ----->  int[]
	static int[] parseAry(string[] str) {
		int[] nums = new int[str.Length];
		for ( int i = 0; i < str.Length; i++ ) { nums[i] = int.Parse(str[i]); }
		return nums;
	}
	//　String[]  ----->  long[]
	static long[] parseAryL(string[] str) {
		long[] nums = new long[str.Length];
		for ( int i = 0; i < str.Length; i++ ) { nums[i] = long.Parse(str[i]); }
		return nums;
	}

	//文字列を1文字ずつString[]に入れる
	static string[] strAry(String str) {
		string[] re = new string[str.Length];
		for ( int i = 0; i < str.Length; i++ ) { re[i] = str[i].ToString(); }
		return re;
	}



}

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

#define debug(x) cout << #x << " = " << x << endl
#define fori(i, ini, lim) for(int i = int(ini); i < int(lim); i++)
#define ford(i, ini, lim) for(int i = int(ini); i >= int(lim); i--)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;

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

	int n, k;
	cin >> n >> k;

	if(n == k) {
		cout << 1 << '\n';
		return 0;
	}

	n -= k;
	cout << ((n + k - 1 - 1) / (k - 1)) + 1 << '\n';

	return 0;
}


Measured memory_bytes: 384
/*<----------------------------------------------------------------------->

<-------------------------------------------------------------------------->
            _           __                _      _____ _____ _____ 
  ___ _   _| |__   ___ / _|_ __ ___  __ _| | __ |___  |___  |___  |
 / __| | | | '_ \ / _ \ |_| '__/ _ \/ _` | |/ /    / /   / /   / / 
| (__| |_| | |_) |  __/  _| | |  __/ (_| |   <    / /   / /   / /  
 \___|\__,_|_.__/ \___|_| |_|  \___|\__,_|_|\_\  /_/   /_/   /_/   

*/
#include<bits/stdc++.h>
using namespace std;
typedef long long ll ;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<ll> vi;
typedef vector<pll> vpll;
typedef unordered_map <ll,ll> umap ; 
//#pragma GCC optimize "trapv"
#define loop(i,a,b) for(ll i=a ;i<b;i++)
#define For(i,n) for(int i=0;i<(ll)n;i++)
#define Rev(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,n) for(int i=1;i<=n;++i)
#define F first
#define S second
#define pb push_back
#define em emplace_back
#define all(v) (v).begin(),(v).end()
#define mems(x, y) memset(x, y, sizeof(x))
#define sz(v) (v).size()
#define mp(a,b) make_pair(a,b)
#define pf(n) cout<<n<<"\n"
#define pff(n) cout << n << " " ; 
long const M=1e9+7;
const long mxN =1e5+2 ;
const long mxNN =1e6+2 ;
void solve(){
    int a,b,c ; cin >> a >> b >> c ;
    cout << c << " " << a << " " <<b << endl ;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //cout << setprecision(20) << fixed ;
    solve() ;
    //ll t ; cin >> t ; while(t--)solve();
	return 0;
}


Measured memory_bytes: 256
al="abcdefghijklmnopqrstuvwxyz"
count=[0]*26
while True:
    try:
        s=input()
    except:
        break
    for i in range(len(s)):
        for j in range(len(al)):
            if s[i]==al[j] or s[i]==al[j].upper():
                count[j]+=1

for i in range(len(al)):
    print("{0} : {1}".format(al[i],count[i]))



Measured memory_bytes: 5564
#include<bits/stdc++.h>
#define MAXN 2005
#define MAXM 4000005
#define INF 1000000000
#define MOD 1000000007
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int N,K,fact[MAXM],invf[MAXM];
void add(int &a,int b) {a+=b; if(a>=MOD) a-=MOD;}
void dec(int &a,int b) {a-=b; if(a<0) a+=MOD;}
int pow_mod(int a,int i)
{
    int s=1;
    while(i)
    {
        if(i&1) s=1LL*s*a%MOD;
        a=1LL*a*a%MOD;
        i>>=1;
    }
    return s;
}
int comb(int n,int k)
{
    if(n<k) return 0;
    return 1LL*fact[n]*invf[k]%MOD*invf[n-k]%MOD;
}
int dp[MAXN][MAXN];
int main()
{
    fact[0]=invf[0]=1;
    for(int i=1;i<=4000000;i++) fact[i]=1LL*fact[i-1]*i%MOD;
    invf[4000000]=pow_mod(fact[4000000],MOD-2);
    for(int i=3999999;i>=1;i--) invf[i]=1LL*invf[i+1]*(i+1)%MOD;
    scanf("%d%d",&N,&K);
    if(K==1) {puts("1"); return 0;}
    dp[0][0]=1;
    for(int i=0;i<=N;i++)
        for(int j=0;j<=N;j++)
        {
            if(i<N) add(dp[i+1][j],dp[i][j]);
            if(j<i) add(dp[i][j+1],1LL*dp[i][j]*comb(N-i+(N-j-1)*(K-1)+K-2,K-2)%MOD);
        }
    printf("%d\n",1LL*dp[N][N]*fact[N]%MOD);
    return 0;
}


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



long long n,bb[200001],t,c[200001];
long double a[200001],aa[200001],b[200001],ma=0,d[200001],sh[200001];


int main()
{
    cin>>n;
    ref(i,n) {
        cin>>aa[i];
        if(aa[i]>ma) t=i;
        ma=max(aa[i],ma);
    }

    ref(i,n) cin>>bb[i];

    ref(i,n) {a[i]=aa[(i+t)%n];b[i]=bb[(i+t)%n];}

    a[n]=a[0];

    long long k=0;
    ref(i,n-1) k+=2*b[i+1]*(n-i-1);
    d[1]=-1*(lb(k)/lb(n));
    ref(i,n-1) {d[i+2]=2*d[i+1]-d[i]+2*b[i+1];}
    //cout<<d[n-1]<<endl;
    //cout<<d[n]<<endl;

    ref(i,n) a[i]=a[i]-d[i];

    c[0]=0,sh[0]=0;
    for(int i=1;i<=n;i++) {

        ll t=i-1;
        c[i]=i-1;

        while(true){


            if(sh[t]<(a[i]-a[t])/(i-t)) {t=c[t];c[i]=t;sh[i]=(a[i]-a[t])/(i-t);}
            else {sh[i]=(a[i]-a[t])/(i-t);break;}
            if(t==0) break;
    }

    }

    for(int i=n;i>0;i--) {
        for(int j=c[i]+1;j<i;j++) a[j]=a[c[i]]+(a[i]-a[c[i]])/lb(i-c[i])*lb(j-c[i]);
        i=c[i]+1;
    }

    long double ans=0;

    ref(i,n){
        ans+=a[i]+d[i];
    }
    lb tt;
    tt=ans/lb(n);
    if(ll(tt*pow(10,11))%10>=5) tt+=pow(10,-10);
    cout<<fixed<<setprecision(40)<<tt;
    return 0;
}




Measured memory_bytes: 22484
#include <iostream>

using namespace std;

int main()
{
	long long n, d, ans = 0;

	cin >> n >> d;

	for (int i = 0; i < n; i++)
	{
		long long x, y;

		cin >> x >> y;

		if (x * x + y * y <= d * d)
		{
			ans++;
		}
	}

	cout << ans;
	return 0;
}

Measured memory_bytes: 3184
#include <iostream>
#include <algorithm>
#include <cmath>
#include <map>
using namespace std;

int main()
{
    int A, B, C, X, Y;

    cin >> A >> B >> C >> X >> Y;

    int ab = 2 * C;

    int ans = 0;

    int min = INT32_MAX;

    for (int i = 0; i <= 100000; i++)
    {
        ans = i * ab;

        if (i < X)
            ans += A * (X - i);
        if (i < Y)
            ans += B * (Y - i);
        if (min > ans)
            min = ans;
    }

    cout << min << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

const int MAX_H = 100;
const int MAX_W = 100;
const int MAX_N = MAX_H * MAX_W;

int main() {
    int h, w, n;
    cin >> h >> w;
    cin >> n;
    
    int a[MAX_N];
    int ans[MAX_H][MAX_W];

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

    int count = 0;
    int index = 0;

    for (int i = 0; i < h; i++) {
        if (i % 2 == 0) {
            for (int j = 0; j < w; j++) {
                ans[i][j] = index + 1;
                count++;
                if (count == a[index]) {
                    index++;
                    count = 0;
                }
            }
        }
        else {
            for (int j = w - 1; j >= 0; j--) {
                ans[i][j] = index + 1;
                count++;
                if (count == a[index]) {
                    index++;
                    count = 0;
                }
            }
        }
    }

    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            cout << ans[i][j] << " ";
        }
        cout << endl;
    }
}

Measured memory_bytes: 384
#include <stdio.h>

int max(int a, int b)
{
   if(a>b) return a;
   else return b;
}

int main(void)
{
   int q1, b, c1, c2, q2;
   int qa;

   while(scanf("%d", &q1)){
      if(q1==0) break;
      scanf("%d %d %d %d", &b, &c1, &c2, &q2);

      for(qa=q2; qa>0; qa--){
         if(c1*qa+c2*max(q1-qa, 0)<=b) break;
      }
      if(qa==0) printf("NA\n");
      else printf("%d %d\n", qa, (b-c1*qa)/c2);
   }
   return 0;
}

Measured memory_bytes: 612