akhauriyash/Code-Regression huggingface dataset:
/*
 * Author: .-O_O-.
 */
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include<bits/stdc++.h>
using namespace __gnu_pbds;
using namespace std;
#define ll long long
#define pb push_back
#define vi vector<int>
#define rep0(a,b) for(int a=0;a<b;a++)
#define rep1(a,b) for(int a=1;a<=b;a++)
#define repp(a,b,c) for(int a=b;a<c;a++)
#define in insert
#define len length()
#define si size()
#define lb lower_bound
#define ub upper_bound
#define beg begin()
#define en end()
#define f first
#define s second
#define pr(a) cout<<a
#define pr2(a,b) cout<<a<<" "<<b<<"\n"
#define nx cout<<"\n"
#define int long long
// void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
                                                     
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]"<<endl;}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define deb(x...)
#endif
const ll mod = 1000000007;
const ll N = 200005;
const ll mm = 1e+18;
void solve()
{
    int n;
    cin>>n;
    int a[n];
    rep0(i,n) cin>>a[i];
    int ans=mm;
    repp(i,-100,101){
        int f=0;
        rep0(j,n){
            f+=(a[j]-i)*(a[j]-i);
        }
        ans=min(ans,f);
    }
    pr(ans);
}
signed main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t=1;
    //cin>>t;
    rep1(_i,t){
        //cout<<"Case #"<<_i<<": ";
        solve();
        //nx;
    }
    return 0;
}

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

typedef long long int LLI;

LLI mhtd(LLI x,LLI y)
{
    return abs(x-1)+abs(y-1);
}

int main() {
    LLI n;
    cin>>n;
    LLI limit=sqrt(n)+1;
    LLI dist=1e13;
    for(LLI i=1;i<=limit;++i){
        if(!(n%i)) dist=min(dist,mhtd(i,n/i)); 
    }
    cout<<dist;
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

//Whist
public class Main{

	int f(char s){
		return s=='A'?14:s=='K'?13:s=='Q'?12:s=='J'?11:s=='T'?10:s-'0';
	}
	
	void run(){
		Scanner sc = new Scanner(System.in);
		for(;;){
			char t = sc.next().charAt(0);
			if(t=='#')break;
			String[][] c = new String[4][13];
			for(int i=0;i<4;i++)for(int j=0;j<13;j++)c[i][j]=sc.next();
			int[] p = new int[2];
			int w = 0;
			for(int j=0;j<13;j++){
				String r = c[w][j];
				int m = w;
				for(int i=0;i<4;i++){
					if(i==w)continue;
					String v = c[i][j];
					if(r.charAt(1)==t){
						if(v.charAt(1)!=t)continue;
						if(f(r.charAt(0))<f(v.charAt(0))){
							m = i; r = v; continue;
						}
					}
					else if(v.charAt(1)==t){
						m = i; r = v;
					}
					else if(v.charAt(1)==r.charAt(1)&&f(r.charAt(0))<f(v.charAt(0))){
						m = i; r = v;
					}
				}
				p[m%2]++; w = m;
			}
			if(p[0]<p[1])System.out.println("EW "+(p[1]-6));
			else System.out.println("NS "+(p[0]-6));
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 12000
import java.util.*;
public class Main {
   public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);

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

      int[] a = new int[n];
      int[] b = new int[n];
      for (int i = 0; i < a.length; i++) {
         a[i] = sc.nextInt();
         b[i] = sc.nextInt();
      }

      long cost = 0;
      int sum = 0;

      mergeSort(a, b); 

      outer:
         for (int j = 0; j < a.length; j++) {
            for (int i = 0; i < b[j]; i++){
               cost = cost + a[j];
               sum = sum + 1;
               if (sum > m) {
                  cost = cost - a[j];
                  break outer;
               }
            }
         }

      System.out.println(cost);

   }

   public static void merge(int[] a1, int[] a2, int[] a, int[] b1, int[] b2, int[] b) {
      int i = 0;
      int j = 0;
      while (i < a1.length || j < a2.length) {
         if (j >= a2.length || (i < a1.length && a1[i] < a2[j])) {
            a[i + j] = a1[i];
            b[i + j] = b1[i];
            i++;
         } else {
            a[i + j] = a2[j];
            b[i + j] = b2[j];
            j++;
         }
      }
   }

   public static void mergeSort(int[] a, int[] b) {
      if (a.length > 1) {
         int m = a.length / 2;
         int n = a.length - m;
         int[] a1 = new int[m];
         int[] a2 = new int[n];
         int[] b1 = new int[m];
         int[] b2 = new int[n];
         for (int i = 0; i < m; i++) {
            a1[i] = a[i];
            b1[i] = b[i];
         }
         for (int i = 0; i < n; i++) {
            a2[i] = a[m + i];
            b2[i] = b[m + i];
         }
         mergeSort(a1, b1);
         mergeSort(a2, b2);
         merge(a1, a2, a, b1, b2, b);
      }
   }

}


Measured memory_bytes: 77740
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s,t;
    int m,n,c(0),i;
    cin>>s>>t;
    m=s.length();
    n=t.length();
    if(m==(n-1)){
        for(i=0;i<m;i++){
            if(s[i]==t[i])
                c++;
        }
        if(c==m)
            cout<<"Yes"<<endl;
        else
            cout<<"No"<<endl;
    }
    else
        cout<<"No"<<endl;
    return 0;

}


Measured memory_bytes: 3628
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>

using namespace std;

int n, a[200100];

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

    long long ans = 0;

    sort(a + 1, a + n + 1);
    for (int i = 1; i <= n; i++)
        for (int j = i + 1; j <= n; j++) {
            int st = j + 1;
            int dr = n;
            while (st <= dr) {
                int mid = (st + dr) / 2;
                if (a[mid] < a[i] + a[j])
                    st = mid + 1;
                else dr = mid - 1;
            }

            ans += (dr - (j + 1) + 1);
        }

    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<stack>
#include<set>
#include<climits>
#include<cstdlib>
#include<cmath>
#include<string>

using namespace std;

#define INF 1 << 29
#define LL long long int

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

    LL h,w;
    cin >> h >> w;

    LL result = INF;
    for(int i = 1; i < h; i++){
        LL rest = h - i;
        LL x = w/2;
        LL s1 = i*w;
        LL s2 = rest*x;
        LL s3 = rest*(w-x);
        LL smax = max(max(s1,s2),s3);
        LL smin = min(min(s1,s2),s3);
        if(smax - smin < result){
            result = smax - smin;
        }

        LL y = rest/2;
        s1 = i*w;
        s2 = y*w;
        s3 = (rest - y)*w;
        smax = max(max(s1,s2),s3);
        smin = min(min(s1,s2),s3);
        if(smax - smin < result){
            result = smax - smin;
        }
    }

    for(int i = 1; i < w; i++){
        LL rest = w - i;
        LL x = h/2;
        LL s1 = i*h;
        LL s2 = rest*x;
        LL s3 = rest*(h-x);
        LL smax = max(max(s1,s2),s3);
        LL smin = min(min(s1,s2),s3);
        if(smax - smin < result){
            result = smax - smin;
        }

        LL y = rest/2;
        s1 = i*h;
        s2 = y*h;
        s3 = (rest - y)*h;
        smax = max(max(s1,s2),s3);
        smin = min(min(s1,s2),s3);
        if(smax - smin < result){
            result = smax - smin;
        }
    }

    cout << result << endl;
    
    return 0;
}

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

int main(void) {
	int p;
	char str[11],ans[11];
	
	scanf("%s",str);
	
	memset(ans,'\0',sizeof(ans));
	p = 0;
	for (int i = 0;str[i] != '\0';i++) {
		if (str[i] == 'B') {
			p--;
			if (p < 0) {
				p = 0;
			}
			ans[p] = '\0';
		}else {
			ans[p++] = str[i];
		}
	}

	printf("%s\n",ans);

	return 0;
}


Measured memory_bytes: 128
n,k = map(int,input().split())
h = list( map(int,input().split()) )

dp = [0] * n
dp[0] = 0

for i in range(1,n):
  s = max(0,i-k)
  x = [ dp[j] + abs(h[j] - h[i]) for j in range(s,i) ]
  dp[i] = min([ dp[j] + abs(h[j] - h[i]) for j in range(s,i) ])

print(dp[n-1])

Measured memory_bytes: 54112
/* ex9_1:
    Jun_JPN*/

#include <stdio.h>
#include <stdlib.h>
#define SIZE 11
typedef struct{
    int size;       // 格納最大数
    int count;      // 現在のデータ数
    char str[SIZE]; // 文字列
    char *top;      // トップへのポインタ（トップは末尾の要素の1つ上の要素のポインタ）
}stack;

void initialize_stack(stack *stk);
void print_stack(stack *stk);
void push(stack *stk, char bin);
void pop(stack *stk);

int main(void){
    stack stk;
    char str[SIZE];
    int i;

    scanf("%s", str);           // 文字列を受け取る
    initialize_stack(&stk);     // スタックstkを初期化

    for(i=0; str[i] != '\0'; i++){
        if(str[i]=='B') pop(&stk);  // Bが来たらポップ
        else push(&stk, str[i]);    // B以外が来たらプッシュ
    }

    print_stack(&stk);

    return 0;
}

/* スタックを初期化 */
void initialize_stack(stack *stk){
    stk->count = 0;
    stk->size = SIZE;
    stk->str[0] = '\0';
    stk->top = &(stk->str[0]);  // 頭文字のポインタををtopに
}

/* スタックの中身を表示 */
void print_stack(stack *stk){
    for(int i=0; stk->str[i] != '\0'; i++){
        printf("%c", stk->str[i]);
    }
    printf("\n");
}

/* B以外の文字ををプッシュ */
void push(stack *stk, char bin){
    if(stk->count >= stk->size){    // オーバーフロー処理
        printf("Error: stack overflow\n");
        exit(1);
    }else{
        *(stk->top) = bin;  // スタックのトップに文字を加える
        stk->top++;         // スタックのトップを1つ上に
        *(stk->top) = '\0'; // スタックのトップをヌル文字に
        stk->count++;
    }
}

/* Bが来たらポップ
    要素を取り除く＝要素をヌル文字で書き換える */
void pop(stack *stk){
    if(stk->count <= 0){            // アンダーフロー処理
        ;   // 何もしない
    }else{
        stk->top--;         // スタックのトップを1つ下に
        *(stk->top) = '\0'; // スタックのトップをヌル文字に
        stk->count--;
    }
}

Measured memory_bytes: 1644
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <math.h>
#include <iomanip>
#include <vector>
#include <queue>
#include <functional>
#include <random>
#include <time.h>
using namespace std;
typedef long long int ll;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll h, w, ans, yan;
	cin >> h >> w;
	if (h % 3 && w % 3) {
		ll a = min(h, w), b = max(h, w);
		ll s[3] = { b / 3 * a,a / 2 + b / 3 * 2 * (a / 2),(a + 1) / 2 + b / 3 * 2 * ((a + 1) / 2) };
		if (b % 3 == 2)s[0] += a;
		sort(s, s + 3);
		ans = min(s[2] - s[0], a);
		swap(a, b);
		s[0] = b / 3 * a; s[1] = a / 2 + b / 3 * 2 * (a / 2); s[2] = (a + 1) / 2 + b / 3 * 2 * ((a + 1) / 2);
		if (b % 3 == 2)s[0] += a;
		sort(s, s + 3);
		yan = min(s[2] - s[0], a);
		ans = min(ans, yan);
	}
	else ans = 0;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
 
#define INF 2147483647
#define N 100
 
 
int main() {
  int n, p[N + 1], m[N + 1][N + 1];
  int l, i, j, k, q;
   
  scanf("%d", &n);
  for ( i = 1; i <= n; i++ ) {
    scanf("%d%d", &p[i-1], &p[i]);
  }
   
  for ( i = 1; i <= n; i++ ) m[i][i] = 0;
  for ( l = 2; l <= n; l++ ) {
    for ( i = 1; i <= n - l + 1; i++ ) {
      j = i + l - 1;
      m[i][j] = INF;
      for ( k = i; k <= j - 1; k++ ) {
    q =  m[i][k] + m[k + 1][j] + p[i - 1] * p[k] * p[j];
    m[i][j] = (m[i][j] < q ? m[i][j] : q );
      }
    }
  }
   
  printf("%d\n", m[1][n]);
   
  return 0;
}

Measured memory_bytes: 636
A,B,C,X,Y = (int(i) for i in input().split())
i = 0
a = []
while i <= 100000:
    p = i * 2*C + A*max(0,X-i)+B*max(0,Y-i)
    a.append(p)
    i += 1
print(min(a))

Measured memory_bytes: 7096
from collections import deque
n = int(input())
a = list(map(int, input().split()))
if a.count(1) == 0:
    print(-1)
else:
    q = deque(a)
    count = 0
    crash_count = 0
    while q:
        if q[0] != 1 + count:
            q.popleft()
            crash_count += 1
        else:
            q.popleft()
            count += 1
    print(crash_count)

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

int a[10];

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

    int n;
    cin>>n;

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

    int b=1;
    int c=1;

    for(int i=0;i<n;i++)
    {
        b*=3;
        if(a[i]%2==0)c*=2;
    }

    cout<<b-c<<"\n";

    return 0;
}


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

#include<cstdio>
#include<cstring>
#include<cctype>
#include<cmath>
#include<cstdlib>

#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<bitset>
#include<complex>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;


//4-side
//int xx[] = {0,0,-1,1};
//int yy[] = {-1,1,0,0};
//6-side hexagonal
//int xx[] = {2,-2,1,1,-1,-1};
//int yy[] = {0,0,1,-1,1,-1};

#define popc(a) (__builtin_popcount(a))
//ll bigmod(ll a,ll b,ll m){if(b == 0) return 1%m;ll x = bigmod(a,b/2,m);x = (x * x) % m;if(b % 2 == 1) x = (x * a) % m;return x;}
ll BigMod(ll B,ll P,ll M){ ll R=1%M; while(P>0) {if(P%2==1){R=(R*B)%M;}P/=2;B=(B*B)%M;} return R;} /// (B^P)%M

#define MX 100005
#define inf 100000000

const double pi = acos(-1.0);
const ll mod = 1000000007ll;

ll dp[2005];

int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    ll s;
    scanf("%lld", &s);
    dp[0] = 1;
    for(int i = 1; i <= s; i++) {
        for(int j = 3; j <= i; j++) {
            dp[i] = (dp[i]+dp[i-j])%mod;
        }
    }
    printf("%lld\n", dp[s]);
}


Measured memory_bytes: 3836
n = int(input())
list_1 = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
dic = {}
for al in list_1:
  dic[al] = 100
for i in range(n):
  s = input()
  for al in list_1:
    count = 0
    for t in s:
      if al == t:
        count += 1
    if dic[al] > count:
      dic[al] = count
ans = ''
for al in list_1:
  if dic[al] > 0:
    for i in range(dic[al]):
      ans += al
print(ans)


Measured memory_bytes: 3064
import java.util.*;
import java.math.*;

class Main{
	public static void main(String Args[]){
		Scanner sc = new Scanner(System.in);
		String str = sc.next();
		BigInteger A = new BigInteger(str);
		str = sc.next();
		BigInteger B = new BigInteger(str);
		System.out.println(A.add(B));
	}
}



Measured memory_bytes: 72464
L, R=gets.split.map(&:to_i)
if R-L >= 2019
  puts 0
  exit
end
ans = 10**9
(L..R).each do |i|
  (i..R).each do |j|
    next if i==j
    ans = [ans, i*j%2019].min
  end
end
puts ans
    
  


Measured memory_bytes: 1788
// Copyright lzt
#include<stdio.h>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<cmath>
#include<iostream>
#include<queue>
#include<string>
#include<ctime>
using namespace std;
typedef long long ll;
typedef std::pair<int, int> pii;
typedef long double ld;
typedef unsigned long long ull;
typedef std::pair<long long, long long> pll;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define rep(i, j, k)  for (register int i = (int)(j); i <= (int)(k); i++)
#define rrep(i, j, k) for (register int i = (int)(j); i >= (int)(k); i--)
#define Debug(...) fprintf(stderr, __VA_ARGS__)

inline ll read() {
  ll x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch <= '9' && ch >= '0') {
    x = 10 * x + ch - '0';
    ch = getchar();
  }
  return x * f;
}

int n;
double p[3030];
double f[3030][3030];

void work() {
  n = read();
  rep(i, 1, n) cin >> p[i];
  f[0][0] = 1;
  rep(i, 1, n) rep(j, 0, i) {
    if (j > 0) f[i][j] += f[i - 1][j - 1] * p[i];
    if (j < i) f[i][j] += f[i - 1][j] * (1 - p[i]);
  }
  double ans = 0;
  rep(i, 0, n) if (i > n - i) ans += f[n][i];
  printf("%.10lf\n", ans);
}

int main() {
  #ifdef LZT
    freopen("in", "r", stdin);
  #endif

  work();

  #ifdef LZT
    Debug("My Time: %.3lfms\n", (double)clock() / CLOCKS_PER_SEC);
  #endif
}


Measured memory_bytes: 70400
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>


using namespace std;

int main() {
	int k, t, a;

	cin >> k >> t;

	priority_queue<int> que;
	for (int i = 0; i < t; i++) {
		cin >> a;
		que.push(a);
	}

	while (que.size() > 1) {
		auto x = que.top();
		que.pop();
		auto y = que.top();
		que.pop();

		x--;
		y--;

		if (x > 0) {
			que.push(x);
		}
		if (y > 0) {
			que.push(y);
		}
	}

	int ans = 0;
	if (que.size() > 0) {
		ans = que.top() - 1;
	}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define MAX_N 1000001
#define MAX_M 100010
const long long mod=1e9+7;
#define vec vector<int>
#define vecll vector<ll>
#define vecllvec vector<vector<ll>>
#define vecb vector<bool>
#define vecBvec vector<vector<bool>>
#define vecst vector<string>
#define veche vector<char>
#define vecd vector<double>
#define vecvec vector<vector<int>>
#define vecDvec vector<vector<double>>
#define vecHvec vector<vector<char>>
#define all(x) (x).begin(),(x).end()
#define ent cout<<endl
#define printvec(vec) for(int aqw=0;aqw<vec.size();aqw++){cout<<vec[aqw]<<" ";}ent;
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define REP(i,m,n) for(int i=m;i<(int)n;++i)
#define INF 1e+9
using P = pair<int, int>;
#define YES "Yes"
#define NO "No"
#define MAX_V 1000
#define PI 3.141592653589793
// cout << setprecision(15) << std::fixed;

// テレンス「もしかしてACですかーッ!?」　ジョセフ「Yse! Yse! Yse! Oh~MyGod」

int main(){
  string s;
  cin>>s;
  veche a,b;
  for(int i=0;i<s.size()/2;i++){
    a.push_back(s[i]);
  }
  int q=0;
  if(s.size()%2==1) q=1; 
  for(int i=s.size()/2+q;i<s.size();i++){
    b.push_back(s[i]);
  }
  int ans=0;
  for(int i=0;i<a.size();i++){
    if(a[i]!=b[b.size()-i-1]) ans++;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
// 型エイリアス
using pii = pair<int, int>;
using tisb = tuple<int, string, bool>;
using vi = vector<int>;
using vii = vector<vi>;

struct Card{
  char suit;
  int value;
};

void bubbleSort(vector<Card> &C, int N){
  for(int i=0; i<N; ++i){
    for(int j=N-1; j>i; --j){
      if(C[j].value < C[j-1].value) swap(C[j], C[j-1]);
    }
  }
}

void selectionSort(vector<Card> &C, int N){
  for(int i=0; i<N; ++i){
    int minj=i;
    for(int j=i; j<N; ++j){
      if(C[j].value < C[minj].value) minj = j;
    }
    swap(C[i], C[minj]);
  }
}

void print(vector<Card> C, int N){
  for(int i=0; i<N; ++i){
    if(i>0) cout << " ";
    cout << C[i].suit << to_string(C[i].value);
  }
  cout << endl;
}

bool isStable(vector<Card> bubble, vector<Card> selection, int N){
  for(int i=0; i<N; ++i){
    if(bubble[i].suit != selection[i].suit) return false;
  }

  return true;
}

int main(){
  int N; cin >> N;
  vector<Card> bubble(N);
  for(int i=0; i<N; ++i) cin >> bubble[i].suit >> bubble[i].value;
  vector<Card> selection(N);
  for(int i=0; i<N; ++i) selection[i] = bubble[i];

  bubbleSort(bubble, N);
  print(bubble, N);
  cout << "Stable" << endl;

  selectionSort(selection, N);
  print(selection, N);
  if(isStable(bubble, selection, N)) cout << "Stable" << endl;
  else cout << "Not stable" << endl;
}


Measured memory_bytes: 3260
#include<bits/stdc++.h>
using namespace std;
using I = long long;
const I M = 998244353;
I bruteforce(auto S) {
  set<string> T;
  queue<string> q;
  q.emplace(S);
  while(!q.empty()) {
    auto s = q.front();
    q.pop();
    if(T.count(s)) continue;
    T.emplace(s);
    for(auto i=1; i<s.size(); ++i) if(s[i-1] != s[i]) {
      auto t = s;
      for(auto c: {'a', 'b', 'c'}) if(c!=s[i-1] && c!=s[i]) t[i-1] = t[i] = c;
      q.emplace(t);
    }
  }
  return T.size();
}
I solve(auto S) {
  if(all_of(begin(S), end(S), [X = S.front()](auto c) {return c == X;})) return 1;
  if(S.size() <= 3) return bruteforce(S);
  I res = 1;
  for(auto i=1; i<S.size(); ++i) if(S[i-1] == S[i]) res = 0;
  I dp[S.size()][3][3][2] = {};
  dp[0][0][0][0] = dp[0][1][1][0] = dp[0][2][2][0] = 1;
  for(auto i=1; i<S.size(); ++i) {
    auto& cur = dp[i-1];
    auto& nex = dp[i];
    for(auto c=0; c<3; ++c) for(auto s=0; s<3; ++s) for(auto f: {0, 1}) {
      for(auto d=0; d<3; ++d) {
        auto t = (s + d) % 3;
        auto e = f || (c==d);
        (nex[d][t][e] += cur[c][s][f]) %= M;
      }
    }
  }
  auto s = accumulate(begin(S), end(S), 0, [](auto r, auto c) {return r + c - 'a';}) % 3;
  for(auto c=0; c<3; ++c) (res += dp[S.size()-1][c][s][1]) %= M;
  return res;
}
int main() {
  string S;
  cin >> S;
  cout << solve(S) << endl;
}


Measured memory_bytes: 28932
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <climits>
#include <numeric>
#include <cmath>
#include <queue>
#include <sstream>
#include <string.h>
#include <bitset>
#include <stack>

using namespace std;
typedef long long ll;
const int maxn = 1e5 + 10;
bool dp[maxn];
int main(int argc, const char * argv[]) {
  int N, K;
  cin >> N >> K;
  vector<int> vec(N);
  for (int i = 0; i < N; i++) {
    cin >> vec[i];
  }
  
  for (int i = 1; i <= K; i++) {
    for (int j = 0; j < N; j++) {
      if (i - vec[j] >= 0) {
        dp[i] |= !dp[i - vec[j]];
      }
    }
  }
  
  if (dp[K]) cout << "First" << endl;
  else cout << "Second" << endl;
  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>

using namespace std;

int main() {
	int sx, sy, tx, ty;
	cin >> sx >> sy >> tx >> ty;

	int lr = tx - sx;
	int ud = ty - sy;


	string ans;
	ans += string(lr, lr > 0 ? 'R' : 'L');
	ans += string(ud, ud > 0 ? 'U' : 'D');
	ans += string(lr, lr < 0 ? 'R' : 'L');
	ans += string(ud, ud < 0 ? 'U' : 'D');

	ans += string(1, ud > 0 ? 'D' : 'U');
	ans += string(lr+1, lr > 0 ? 'R' : 'L');
	ans += string(ud+1, ud > 0 ? 'U' : 'D');
	ans += string(1, lr > 0 ? 'L' : 'R');

	ans += string(1, ud < 0 ? 'D' : 'U');
	ans += string(lr+1, lr < 0 ? 'R' : 'L');
	ans += string(ud+1, ud < 0 ? 'U' : 'D');
	ans += string(1, lr < 0 ? 'L' : 'R');


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


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<vector>
#include<string>
#include<iostream>
#include<queue>
#include<map>
#include<set>
#include<complex>
#include<stack>
#include<cmath>
 
using namespace std;
 
#define reps(i,f,n) for(int i=f;i<int(n);i++)
#define rep(i,n) reps(i,0,n)

#define X real()
#define Y imag()
typedef complex<double> P;

int main(){
	
	int n;
	while(cin>>n,n){
		
		int masu[33][33]={0};
		int stx = n/2;
		int sty = n/2+1;
		
		int cnt = 1;
		
		while(cnt<=n*n){
			if(masu[sty%n][stx%n]==0){
				masu[sty%n][stx%n]=cnt;
				sty++;
				stx++;
				cnt++;
			}
			if(masu[sty%n][stx%n]!=0){
				sty++;
				stx--;
			}
		}
		
		rep(i,n){
			rep(j,n){
				printf("%4d",masu[i][j]);
			}puts("");
		}
	}
	
}

Measured memory_bytes: 1164
#include <iostream>
#include <string>

using namespace std;

int main()
{
     string R;                             cin >> R;
    if(R.length()<=10 && R.length()>=4)
    {
        int lenR=R.length();
        if(R[0]!='A')
        {
            cout<< "WA"; return 0;
        }
        if(!(R[1]>='a' && R[1]<='z'))
        {
            cout<< "WA";          return 0;
        }
        if(!(R[lenR-1]>='a' && R[lenR-1]<='z'))
        {
            cout<< "WA";           return 0;
        }
        else
        {
            int count=0;
            for(int i=2;i<lenR-1;i++)
            {
                if(R[i]=='C')
                {
                    count++;
                }
                else if(!(R[i]>='a' && R[i]<='z'))
                {
                    cout<< "WA";                 return 0;
                }
            }
            if(count!=1)   {      cout<< "WA";         return 0;    }
            cout<< "AC";
            return 0;      }   }
    else   {
        cout<< "WA";
        return 0;
    }}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int N , i ;
    cin>>N;
    vector < int > A(N);
    vector < int > LA(N) , RA(N);
    stack < int > stk;
    for(i=0;i<N;++i)
    {
        cin>>A[i];
        while(!stk.empty() && A[stk.top()]>A[i])stk.pop();
        if(!stk.empty())
            LA[i] = stk.top()+1;
        else
            LA[i] = 0;

        stk.push(i);
    }
    while(!stk.empty())stk.pop();
    long long ans = 0;
    for(i=N-1;i>=0;--i)
    {

        while(!stk.empty() && A[stk.top()]>A[i])stk.pop();
        if(!stk.empty())
            RA[i] = stk.top()-1;
        else
            RA[i] = N-1;
        stk.push(i);
        ans+=A[i] *1LL*  (RA[i]-i+1) * 1LL * (i-LA[i]+1);
    }
//    for(i=0;i<N;++i)
//        cout<<LA[i]<<" "<<RA[i]<<'\n';

    cout<<ans;
    return 0;
}


Measured memory_bytes: 3456
#include<bits/stdc++.h>
using namespace std;
 
#define pb push_back
#define ll long long
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define ms(i) memset(i,0,sizeof(i));
#define ms1(i) memset(i,-1,sizeof(i));
#define F first
#define S second
const int mod = 998244353;

const int maxn = 1e5 + 5;
vector<pair<int,int>>g[maxn];
int c[maxn];
void dfs(int now, int pre) {
    for (auto i:g[now]) {
        if (i.F == pre) {
            continue;
        }
        c[i.F] = c[now] ^ i.S;
        dfs(i.F, now);
    }
}
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    f (n - 1) {
        int x, y, w;
        cin >> x >> y >> w;
        w %= 2;
        g[x].pb({y,w});
        g[y].pb({x,w});
    }
    dfs(1, 1);
    f1 (n) {
        cout << c[i] << '\n';
    }
}

Measured memory_bytes: 8448
import sys
import operator

readline = sys.stdin.buffer.readline
a, b = map(int, readline().split())
c = set(map(int, readline().split()))

L = [(i, abs(i - a)) for i in range(0, 102) if i not in c]
L.sort(key=operator.itemgetter(1))
print(L[0][0])

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

using namespace std;
 
typedef long long int ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector <string> vs;
typedef vector<vector<int>> vvi;
typedef pair<int,int> pi;

//#define int ll
#define forl(i,a,b) for (int i = a; i < b; i++)
#define rfor(i,b,a) for (int i = b; i >= a; i--)
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define srt(x) sort(x.begin(), x.end())
#define sumup(x) accumulate(x.begin(), x.end(), 0)
#define PI 3.141592653589793238
#define MOD 1000000007
#define loop(n) for(int i = 0; i < n; i++)
#define rloop(n) for(int i = n-1; i >= 0; i--)

void io() {
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}

int32_t main() {
    io();
    int t=1;
    //cin>>t;
    while(t--) {
        int n; cin>>n;
        string s; cin>>s;
        int c=0;
        set <int> r_in, w_in;
        for(int i=0; i<n; i++) {
          if(s[i]=='R')
            r_in.insert(i);
          else
            w_in.insert(i);
        }
        while((!w_in.empty() && !r_in.empty()) && *w_in.begin() < *r_in.rbegin()) {
          c++;
          w_in.erase(w_in.begin());
          auto it = r_in.end();
          it--;
          r_in.erase(it);
        }
        cout<<c<<"\n";
    }
    return 0;
}

Measured memory_bytes: 12996
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
const int MX = 200005;

int dp[MX];

int main() {
  int n;
  scanf("%d",&n);
  int k;
  scanf("%d",&k);
  vi h(n);
  cin>>h;
  h.pb(INF);
  h.pb(INF);
  h.pb(INF);
  rep(i,n) dp[i] = INF;
  dp[0] = 0;
  rep(i,n) {
    rrep(j,k) if (i+j < n) {
      mins(dp[i+j], dp[i]+abs(h[i]-h[i+j]));
    }
  }
  cout<<dp[n-1]<<endl;
  return 0;
}






















Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
  ll a,b;
  cin >> a >> b;
  cout << (a - 1) * (b - 1) << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(int argc, char const* argv[])
{
	double t,v,y;
	double h;
	int N;

	while( cin >> v ){
		t = v / 9.8;
		y = 4.9 * t * t;
		N = ( y + 5 ) / 5;
		N++;
		cout << N << endl;
	}
}

Measured memory_bytes: 0
import java.util.*;
import java.util.Map.Entry;
import java.io.*;
        public class Main {
        	public static void main(String[] args) throws IOException, InterruptedException {
        		Scanner sc =new Scanner(System.in);
        		PrintWriter pw =new PrintWriter(System.out);
        		char[] x =("0"+sc.next()).toCharArray(),y=("0"+sc.next()).toCharArray();
        		int [][] dp =new int [x.length][y.length];
        		for (int i =1;i<x.length;++i) {
        			for (int j =1;j<y.length;++j) {
        				if (x[i]==y[j])
        					dp[i][j]=dp[i-1][j-1]+1;
        				else
        					dp[i][j]=Math.max(dp[i-1][j], dp[i][j-1]);
        			}
        		}
        		Stack<Character>st =new Stack<Character>();
        		int i=x.length-1,j=y.length-1;
        		while (true) {
        			if (j<=0||i<=0)
        				break;
        			if (dp[i][j]!=dp[i-1][j]&&dp[i][j]!=dp[i][j-1])
        			{
        				st.push(x[i]);
        				i--;
        				j--;
        			}
        			else if (dp[i][j]==dp[i-1][j])
        				--i;
        			else
        				j--;
        		}
        		while (!st.isEmpty())
        			pw.print(st.pop());
        		pw.close();
        	}
            static int mod(int x,int y)
            {
                if(x<0)
                    x=x+(-x/y+1)*y;
                return x%y;
            }
    		static long gcd(long a, long b) 
    		{ 
    		    if (a == 0) 
    		        return b; 
    		    return gcd(b % a, a); 
    		}
			static class Scanner {
				StringTokenizer stringTokenizer;
				BufferedReader bfBufferedReader;
				public Scanner(InputStream system) {
					bfBufferedReader=new BufferedReader(new InputStreamReader( system));
				}
				 public Scanner(String file) throws Exception {
			            bfBufferedReader = new BufferedReader(new FileReader( file));
			        }			 
			        public String next() throws IOException {
			            while (stringTokenizer == null || !stringTokenizer.hasMoreTokens())
			                stringTokenizer = new StringTokenizer( bfBufferedReader.readLine());
			            return stringTokenizer.nextToken();
			        }
			 
			        public String nextLine() throws IOException {
			            return bfBufferedReader.readLine();
			        }
			 
			        public int nextInt() throws IOException {
			            return Integer.parseInt(next());
			        }
			 
			        public double nextDouble() throws IOException {
			            return Double.parseDouble(next());
			        }
			 
			        public char nextChar() throws IOException {
			            return next().charAt(0);
			        }
			 
			        public Long nextLong() throws IOException {
			            return Long.parseLong(next());
			        }
			 
			        public boolean ready() throws IOException {
			            return bfBufferedReader.ready();
			        }
			 
			        public void waitForInput() throws InterruptedException {
			            Thread.sleep(3000);
			        }
			    }
        }

Measured memory_bytes: 82516
#include <bits/stdc++.h>
#include<string.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define Max(x,y,z) max(x,max(y,z))
#define Min(x,y,z) min(x,min(y,z))
#define fr(i,s,e) for(i=s;i<e;i++)
#define rf(i,s,e) for(i=s-1;i>=e;i--)
#define pb push_back
#define eb emblace_back
#define mp make_pair
#define ff first
#define ss second
#define int   long long
#define ll   long long
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define vl vector<long long>
#define inf (1LL<<61)
#define vi vector<int> 
#define vii vector< vector<int> >
#define vll vector< vector<long long> >
#define vpi vector< pair<int,int> >   
#define vpl vector< pair<ll,ll> >   
#define viii vector< vector<vector<int> > >
typedef pair<pair<int, int>,int> P;
#define mod %1000000007
#define pi 3.14159265358979323846//20 decimals
#define ld long double
///#define inf 1000000000
bool less_vectors(const vector<int>& a,const vector<int>& b) 
{
  return a.size() < b.size();
}
int dx[]={-1,1};
int dy[]={-1,1};
int n,m;
vii v;
vector<pair<int,int> > g[3000000];
int c=0;
vii vis;
vii path;
void dfs(int i,int j)
{
    if(i==0 || i==n-1 || j==0 || j==m-1)
        g[c].pb(mp(i,j));
    for(int k=0;k<1;k++)
    {
        int x=i+dx[k];
        int y=j;
        if(x>=0 && x<n && v[x][y] && vis[x][y]==0)
            {vis[x][y]=c;dfs(x,y);}
    }
    for(int k=0;k<1;k++)
    {
        int y=j+dy[k];
        int x=i;
        if(y>=0 && y<m && v[x][y] && vis[x][y]==0)
            {vis[x][y]=c;dfs(x,y);}
    }
    return;
}
int32_t main()
{                
    IOS;
    /*#ifndef ONLINE_JUDGE
    freopen("int.txt","r",stdin);
    freopen("out.txt","w",stdout);
    #endif*/
    int n,k;
    cin>>n>>k;
    vi a(n);
    int ind;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        if(a[i]==1)
            ind=i;
    }
    int ans1=0;
    int j=0;
    while(j<n)
    {
        ans1++;
        if(j<=ind && j+k>ind)
            j+=k;
        else
            j+=k-1;

    }
    j=n-1;
    int ans2=0;
    while(j>=0)
    {
        if(j>=ind && j-k<ind)
            j-=k;
        else
            j-=(k-1);
     
        ans2++;

    }
    cout<<min(ans2,ans1);


    return 0;
}

Measured memory_bytes: 71296
#pragma GCC optimize("Ofast")
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define rep2(i,n) for(int i=0;i<=n;i++)
#define repr(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define uni(e) e.erase(unique(e.begin(),e.end()),e.end())
#define double long double
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 INF=1e10;
int MOD=1e9+7;
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void yesno(T b){if(b)out("yes");else out("no");}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
template<class T> void YESNO(T b){if(b)out("YES");else out("NO");}
template<class T> void noyes(T b){if(b)out("no");else out("yes");}
template<class T> void NoYes(T b){if(b)out("No");else out("Yes");}
template<class T> void NOYES(T b){if(b)out("NO");else out("YES");}
int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
}
int kurai(int a,int b){
  int m=pow(10,b),n=pow(10,b-1);
  return (a%m)/n;
}
int ketawa(int a){
  int k=0;
  rep(i,keta(a)){
  k+=kurai(a,i+1);
  }
  return k;
}
int gcd(int a,int b){
  if(a%b==0)
    return b;
  return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
int mid(int a,int b,int c){
  vector<int> k(3);
  k[0]=a;k[1]=b;k[2]=c;
  sort(all(k));
  return k[1];
}
bool sosuu(int a){
  bool b=1;
  if(a<=1)
    return 0;
  else{
  rep1(i,sqrt(a)-1){
  if(a%(i+1)==0)
  b=0;
  }
  return b;
  }
}
int modpow(int a,int b,int m=MOD){
 if(!b)return 1; if(b&1)return modpow(a,b-1,m)*a%m;
 int memo = modpow(a,b>>1,m);
 return memo*memo%m;
}
int fact_mod(int n) {
    int f=1; 
for(int i=2;i<n+1;i++) f=f*(i%MOD)% MOD;
    return f;
}
int mod_pow(int x,int n) {
    int res=1;
    while(n>0){
        if(n&1) res=(res*x)%MOD; 
        x=(x*x)%MOD;        
n>>=1; 
    }
    return res;
}
int c_mod(int n, int r) {
    if(r>n-r) r=n-r;
    if(r==0) return 1;
    int a=1;
    rep(i,r) 
a=a*((n-i)%MOD)%MOD;
    int b=mod_pow(fact_mod(r), MOD-2);
    return (a%MOD)*(b%MOD)%MOD;
}
signed main(){
  int a;
  cin>>a;
  vector<int> b(a);
  rep(i,a)
    cin>>b[i];
  int c;
  cin>>c;
  vector<int> d(c),e(c);
  rep(i,c)
    cin>>d[i]>>e[i];
  int f=0;
  rep(i,a)
    f+=b[i];
  rep(i,c){
  out(f+e[i]-b[d[i]-1]);
  }
}

Measured memory_bytes: 3688
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vi = vector<int>;
using vvi = vector<vi>;
#define ote(x) cout<<(x)<<endl
#define all(x) (x).begin(),(x).end()
#define rp(i,s,e) for(int i=(s);i<(e);++i)
#define rpz(i,e) rp(i,0,e)

int main(){
	int N; cin>>N; int K; cin>>K;
	vi A(N);
	rp(i,0,N){
		int a;cin>>a;
	}

	ote((N-1+(K-1)-1)/(K-1));
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define fill(arr,c) memset(arr,c,sizeof(arr))
#define perm(r) next_permutation(all(r))
//it gives bool value ans permute the string lexoggraphically
#define sortdesc greater<int>()
#define ll long long int 
//std::setfill('0') << std::setw(5) << 25; it adds leaing zeroes;
#define f(i,a) for(int i=0;i<a;i++)
#define fo(i,a) for(int i=1;i<=a;i++)
#define foo(i,x,n,c) for(ll i=x;i<n;i+=c)
#define foi(i,x,n,c) for(ll i=x;i>=n;i+=c)
#define fauto(i,m) for(auto i:m)
#define forall(a) for( auto itr=a.begin();itr!=a.end();itr++)
#define ld long double
#define in push_back
#define mll map<ll,ll>
#define mcl map<char,ll>
#define msl map<string,ll>
#define vi vector<int >
#define vl vector<ll >
#define vp vector< pair<int,int> >
#define vs vector <string> 
#define vc vector <char> 
#define o(a) cout<<a
#define os(a) cout<<a<<" "
#define en cout<<"\n";
#define testcase ll t ;cin>>t; while(t--)
#define ff first
#define ss second
#define pl pair<ll,ll>
#define pi pair<int,int>
#define all(a) (a).begin(), (a).end()

#define sz(a)  (a).size()
#define prec(n) fixed<<setprecision(n)
#define mp make_pair
#define bitcount  __builtin_popcountll
#define imin o("imin");en;
using namespace std;
bool comp(const pair<int,int> &a , const pair<int,int> &b){
    if(a.first == b.first)  return a.second < b.second;
     return a.first < b.first;
}
bool comps(const pair<int,int> &a , const pair<int,int> &b){
    if(a.second == b.second)  return a.first< b.first;
     return a.second < b.second;
}
//ll pi=acos(0.0)*2;
void fastio()
{
    	ios::sync_with_stdio(0);
cin.tie(0);

}
void inout()
{

    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);

     freopen("output.txt", "w", stdout);
     #endif
}

int main()
{

ll n;
cin>>n;
vp p;
ll flag=0;
ll cnt=0;
ll a,b;
f(i,n)
{

cin>>a>>b;p.in(mp(a,b));
if(flag==0)
{

if(a==b)
cnt++;
else
cnt=0;
if(cnt==3)
flag=1;
}

}
if(flag)
o("Yes");
else
o("No");
return 0;
}


Measured memory_bytes: 3604
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;

#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define RREP(i,n) for(int (i)=(int)(n)-1;i>=0;i--)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
typedef long long ll;

int main() {

    int N,A,B; cin >> N >> A >> B;

    if (abs(A - B) % 2 == 1) {
        cout << "Borys" << endl;
    } else {
        cout << "Alice" << endl;
    }


    return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 7)
read = sys.stdin.buffer.read 
input = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines  

from itertools import accumulate

N, K = map(int, input().split())
P = list(map(int, input().split()))
Pcum = list(accumulate([0] + [(1+p)/2 for p in P]))

ans = max(right - left for left, right in zip(Pcum, Pcum[K:]))
print(ans)  

Measured memory_bytes: 25116
#include <stdio.h>
     
    int main() {
        int N,A,B;
        scanf("%d %d %d",&N,&A,&B);
        if(N*A<=B){
            printf("%d\n",N*A);
            }
            else{
    		printf("%d\n",B);
    	}
    	return 0;
    }

Measured memory_bytes: 128
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <bitset>
using namespace std;

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define index(xs, x) (int)(lower_bound(all(xs), x) - xs.begin())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007
bool S[4000];
int B[4001];
void BIT_add(int i) {
  for (int x=i+1; x<=4000; x+=x&-x) B[x]++;
}
int BIT_sum(int i) {
  int s = 0;
  for (int x=i+1; x>0; x-=x&-x) s += B[x];
  return s;
}

int H, W, L, N;
vector<int> GX[4000], GY[4000];
int GXh[4000], GYh[4000];

signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> H >> W >> L >> N;
  rep(i, N) {
    int x, y;
    cin >> y >> x;
    x--, y--;
    GX[y].pb(x);
    GY[x].pb(y);
  }
  rep(y, H) sort(all(GX[y]));
  rep(x, W) sort(all(GY[x]));

  long long ctr = 0;
  for (int d=1-H; d<W; d++) {
    int bx = 0, by = 0;
    if (d < 0) by = -d;
    else bx = d;
    int len = min(H-by, W-bx);
    rep(x, W) GYh[x] = (int)GY[x].size()-1;
    rep(y, H) GXh[y] = (int)GX[y].size()-1;
    rep(i, 4000) S[i] = 0;
    rep(i, 4001) B[i] = 0;
    auto add = [&](int x, int y) {
      int s = max(x-bx, y-by);
      if (S[s]) return;
      S[s] = 1;
      BIT_add(s);
    };

    for (int s=len-1; s>=0; s--) {
      int x = bx+s, y = by+s;
      int mx = W, my = H;
      while (GXh[y] >= 0 && GX[y][GXh[y]] >= x) add(mx=GX[y][GXh[y]--], y);
      while (GYh[x] >= 0 && GY[x][GYh[x]] >= y) add(x, my=GY[x][GYh[x]--]);
      int X = min(mx-bx, my-by);
      // count [s+L-1, X)
      if (s+L-1 >= X) continue;
      //cout<< "("<<x<<","<<y<<"): ["<<s+L-1<<","<<X<<") | "; rep(i, W) cout<<S[i]<<",";cout<<"\n";
      //for (int p=s+L-1; p<X; p++) ctr += 1-S[p];
      ctr += (X-(s+L-1)) - (BIT_sum(X-1) - BIT_sum(s+L-2));
    }
  }
  cout << ctr << "\n";
  return 0;
}

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

int main(){
	int N,cnt=0;
    string s = "Yes";
    cin >> N;
    int a[N];
    for(int i=0;i<N;i++){
      cin >> a[i];
      cnt += a[i];
    }
    sort(a,a+N);
    if(cnt<= 2*a[N-1])
      s = "No";
    cout << s << endl;
}

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

struct Node {
	int key;
	Node *right, *left, *parent;
};

Node *root, *NIL;

void insert(int k) {
	Node *y=NIL;
	Node *x=root;
	Node *z;
	
	z=(Node *)malloc(sizeof(Node));
	z->key=k;
	z->left=NIL;
	z->right=NIL;
	
	while(x!=NIL)
	{
		y=x;
		if(z->key < x->key) x=x->left;
		else x=x->right;
	}
	z->parent=y;
	if(y==NIL) root=z;
	else
	{
		if(z->key < y->key) y->left=z;
		else y->right=z;
	}
}

void inorder(Node *u) {
	if(u==NIL) return;
	inorder(u->left);
	printf(" %d", u->key);
	inorder(u->right);
}

void preorder(Node *u) {
	if(u==NIL) return;
	printf(" %d", u->key);
	preorder(u->left);
	preorder(u->right);
}

int main() {
	int i,n,x;
	string com;
	
	scanf("%d",&n);
	
	for(i=0;i<=n-1;i++) {
		cin >> com;
		if(com=="insert") {
			scanf("%d",&x);
			insert(x);
		}
		else if(com=="print") {
			inorder(root);
			printf("\n");
			preorder(root);
			printf("\n");
		}
	}
	return 0;
}



Measured memory_bytes: 26700
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <tuple>
#include <cassert>

using namespace std;

#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define tr(c, i) for (iter(c) i = (c).begin(); i != (c).end(); ++i)
#define pb(e) push_back(e)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define mp(a,b) make_pair((a), (b))
#define mt(a,b,c) make_tuple((a),(b),(c))

typedef long long ll;

int main(){
    int n,k; cin >> n >> k;
    cout << n-k+1 << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
 
 
public class Main{
     
    public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
    	
    	while(true){
    		final int n = sc.nextInt();
    	
    		if(n == 0){
    			break;
    		}
    		
    		int sum = 0;
    		
    		if(n != 1){
    			sum = 1;
    		}
    		
    		for(int i = 2; i <= Math.sqrt(n); i++){
    			if(n % i == 0){
    				if(i*i != n){
    					sum += i + n / i;
    				}else{
    					sum += i;
    				}
    			}
    		}
    		
    		if(sum > n){
    			System.out.println("abundant number");
    		}else if(sum < n){
    			System.out.println("deficient number");
    		}else{
    			System.out.println("perfect number");
    		}
    		
    	}
    	
    }
     
}

Measured memory_bytes: 12000