akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;

int main() {
	vector<string> v;
	string s;
	int k;
	cin >> s >> k;
	//cout << s.size() << endl;
	for (int i = 0; i < s.size(); i++) {
		for (int j = 1; j <= 5; j++) {
			if((i+j) <= s.size())
				v.push_back(s.substr(i, j));
		// 	cout << s.substr(i, j) << endl;
		}

	}
	sort(v.begin(), v.end());
	v.erase(unique(v.begin(), v.end()), v.end());
	//cout << "sorted" << endl;
	for (auto itr = v.begin(); itr != v.end(); itr++) {
	//	cout << (*itr) << endl;
	}

	auto itr = v.begin();
	for (int i = 0; i < k -1; i++) {
		itr++;
	}
	cout << (*itr) << endl;

	return 0;
}

Measured memory_bytes: 1660
#include <iostream>

using namespace std;

int city[100001];
int yusha[100000];

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

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

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

	int64_t count = 0;

	for(int i = 1; i <= n; ++i){
		if((city[n+1-i] - yusha[n-i]) > 0){
			count += yusha[n-i];
			city[n+1-i] -= yusha[n-i];
			yusha[n-i] = 0;
		}else{
			count += city[n+1-i];
			yusha[n-i] -= city[n+1-i];

			if((city[n-i] - yusha[n-i]) > 0){
				count += yusha[n-i];
				city[n-i] -= yusha[n-i];
				yusha[n-i] = 0;
			}else{
				count += city[n-i];
				yusha[n-i] -= city[n-i];
				city[n-i] = 0;
			}
		}
	}

	cout << count << endl;

}

Measured memory_bytes: 1024
n = int(input())
d = [1 for _ in range(n+1)]

for i in range(2,n+1):
  for j in range(1,n//i+1):
    a = i*j
    if a > n:
      break
    d[a] += 1
ans = 0
for k in range(1,n+1):
  ans += k*d[k]
print(ans)

Measured memory_bytes: 219380
package main

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

func main() {
	scan_init()
	s := scan()
	t := scan()
	s_slice := strings.Split(s,"")
	t_slice := strings.Split(t,"")
	// k := 0
	min := 1000
	for i:= 0; i<=len(s_slice)-len(t_slice); i++ {
		count := 0
		for j := 0; j<len(t_slice);j++ {
			if i+j == len(s_slice) {
				break
			}
			if s_slice[i+j] != t_slice[j] {
				count ++
			}
		}
		if min > count {
			min = count
		}
	}
	fmt.Println(min)
}

var sc = bufio.NewScanner(os.Stdin)

func scan_init() {
	sc.Split(bufio.ScanWords)
}
func scanInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}
func scan() string {
	sc.Scan()
	return sc.Text()
}

var rdr = bufio.NewReaderSize(os.Stdin, 200000)

func readLine() string {
	buf := make([]byte, 0, 200000)
	for {
		l, p, e := rdr.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}
func readLineToNumber() int {
	S := readLine()
	number, _ := strconv.Atoi(S)
	return number
}
func readLineToSlice() []string {
	S := readLine()
	list := strings.Split(S, "")
	return list
}
func readLineToNumberSlice(memo map[string]int) []int {
	// err時は-1を代入
	S := readLine()
	intList := make([]int, len(S))
	for i := 0; i < len(S); i++ {
		if val, ok := memo[string(S[i])]; ok {
			intList[i] = val
		} else {
			intList[i] = -1
		}
	}
	return intList
}

Measured memory_bytes: 1836
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>
#include <set>

#define DIV 1000000007
using namespace std;
using ll = long long;

typedef struct {
	int parent;
	int height = 1;
}node_t;
vector<node_t> node;

int root(int n) {
	if (node[n].parent == 0) return n;
	root(node[n].parent);
}

bool same(int x, int y) {
	if (root(x) == root(y))
		return true;
	else
		return false;
}

void unite(int a, int b) {
	int root_a = root(a), root_b = root(b);

	if (root_a != root_b) {
		if (node[root_a].height >= node[root_b].height) {
			node[root_a].height = max(node[root_a].height, node[root_b].height + 1);
			node[root_b].parent = root_a;

		}

		else {
			node[root_b].height = max(node[root_b].height, node[root_a].height + 1);
			node[root_a].parent = root_b;
		}
	}

}

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

	map<pair<int, int>, int> mp;
	vector<pair<int, int>> grp(N + 1);
	node = vector<node_t>(N + 1);
	for (int i = 0; i < K; i++) {
		int p, q;
		cin >> p >> q;
			unite(p, q);
	}

	
	for (int i = 1; i <= N; i++) {
		grp[i].first = root(i);
	}
		
	node = vector<node_t>(N + 1);
	for (int i = 0; i < L; i++) {
		int r, s;
		cin >> r >> s;
		unite(r, s);
	}

	for (int i = 1; i <= N; i++) {
		grp[i].second = root(i);
		mp[grp[i]]++;
	}

	for (int i = 1; i <= N; i++)
		cout << mp[grp[i]] << " ";
	cout << endl;

}


Measured memory_bytes: 15140
package main

import (
	"fmt"
	"sort"
	"strings"
)

func main() {
	var s string
	fmt.Scan(&s)

	cs := strings.Split(s,"")
	sort.StringSlice(cs).Sort()

	if cs[0] == cs[1] && cs[2] == cs[3] && cs[1] != cs[2] {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

Measured memory_bytes: 640
//package com.atcoder.contest170.a;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) {
        FastScanner fs = new FastScanner();
        int x;
        for(int i=1; i<=5; ++i)
        {
            x = fs.nextInt();
            if(x == i) continue;
            if(x == 0) {
                System.out.println(i);
                break;
            }
        }
    }

    static class FastScanner {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer("");

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

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

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

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


Measured memory_bytes: 32692
#include "bits/stdc++.h"
using namespace std;

#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define dump(o) if(DEBUG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DEBUG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
using ll = long long; using ull = unsigned long long; using pii = pair<int, int>;
static const int INF = 0x3f3f3f3f; static const long long INFL = 0x3f3f3f3f3f3f3f3fLL;
static const int MOD = 1e9 + 7;
static const bool DEBUG = false;

#define MAX 100010
//100010
signed main() {
	int N; cin >> N;
	int A[MAX] = {};
	rep(i, 0, N)cin >> A[i];
	int M = 0;
	int ans = 0;
	rep(i, 0, N) {
		dump(A[i]);
		if (M + 2 <= A[i]) {
			if (M == 0) {
				ans += A[i] - 1;
				A[i] = 1;
			}
			else {
				ans += (A[i] - M) / (M + 1);
				A[i] -= (M + 1)*((A[i] - M) / (M + 1));
				if (M + 2 <= A[i]) {
					ans++;
					A[i] -= M + 1;
				}
				if (M + 1 == A[i])A[i]--;
			}
		}
		M = max(M, A[i]);
		dump(M);
		dumpc(A);
		dump(ans);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
#define lson root<<1,l,midd
#define rson root<<1|1,midd+1,r
#define pb push_back
typedef long long ll;
const int M=1e6+6;
int a[M];
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,x,y;
    cin>>n>>x>>y;
    if(x>y)
        swap(x,y);
    int m=(y-x+1);
    if((y-x+1)&1){
        for(int i=1;i<=m/2;i++)
            a[i]=m;
    }
    else{
        a[m/2]=m/2;
        for(int i=1;i<m/2;i++)
            a[i]=m;
    }

    int lin=x+n-y+1;
    //cout<<lin<<"@@"<<endl;
    for(int i=1;i<lin;i++)
        a[i]+=lin-i;
    a[1]--;
    /*for(int i=1;i<n;i++)
        cout<<a[i]<<' ';*/
    for(int i=1;i<x;i++){
        if((y-x+1)&1){
            for(int j=1;j<=m/2;j++)
                a[i+j]+=2;
            a[i+1]--;
        }
        else{
            for(int j=1;j<m/2;j++)
                a[i+j]+=2;
            a[i+m/2]++;
            a[i+1]--;
        }
    }
    for(int i=1;i<=n-y;i++){
        if((y-x+1)&1){
            for(int j=1;j<=m/2;j++)
                a[i+j]+=2;
            a[i+1]--;
        }
        else{
            for(int j=1;j<m/2;j++)
                a[i+j]+=2;
            a[i+m/2]++;
            a[i+1]--;
        }
    }
    for(int i=1;i<n;i++)
        cout<<a[i]<<'\n';
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A;int x=1;
  cin >> A;
 vector<int>mochi(A);
 for(int i=0;i<A;i++)cin>>mochi.at(i);
sort(mochi.begin(),mochi.end());

for(int i=0;i<A-1;i++)if(mochi.at(i)<mochi.at(i+1))x++;

cout<<x;
return 0;

}

Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<cstdio>
#include<cstring>
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define MAXN 1000010
int main()
{
	int n,time=0;
	int flag=1;
	cin>>n;
	for(int i=0;i<n;i++){
        int t, x, y;
        cin >>t>>x>>y;
       if((t%(x+y)==0||(t-x-y)%2==0)&&t>=(x+y)&&flag)
        flag=1;
        else flag=0;
	}
	if(!flag)
        cout<<"No"<<endl;
    else
	cout<<"Yes"<<endl;
	return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
class Program
{
    static int MAX_WAIGHT = 100;

    static List<int> weights = new List<int>(); 

    static void Main(string[] args)
    {
        string unuseinput = Console.ReadLine();
        // スペース区切りの整数の入力
        string[] inputs = Console.ReadLine().Split(' ');
        foreach (string input in inputs)
        {
            weights.Add(int.Parse(input));
        }
        //出力
        Console.WriteLine(logic());
    }

    static string logic()
    {
        // 入力はすべて static 変数に入っているものを用いる
        List<int> differences = new List<int>();
        for(int i = 0; i < weights.Count; i++)
        {
            differences.Add(Math.Abs(Utils.sum(weights.GetRange(0, i + 1).ToArray()) - Utils.sum(weights.GetRange(i + 1, weights.Count - i - 1).ToArray())));
        }
        int result = Utils.min(differences.ToArray(), MAX_WAIGHT);
        return result.ToString();
    }
}

class Utils
{
    public static int max(int[] values, int logical_min)
    {
        int result = logical_min;
        foreach(int value in values)
        {
            if (result < value)
            {
                result = value;
            }
        }
        return result;
    }

    public static int min(int[] values, int logical_max)
    {
        int result = logical_max;
        foreach (int value in values)
        {
            if (result > value)
            {
                result = value;
            }
        }
        return result;
    }

    public static int sum(int[] values)
    {
        int result = 0;
        foreach(int value in values)
        {
            result += value;
        }
        return result;
    }
}

Measured memory_bytes: 11220
#include<stdio.h>
long long cmp(long long a,long long b)
{
	long long w,k;
	long long x,y;
	x=a;y=b;
	//k=a*b;
	while(y)
	{
		w=x%y;
		x=y;
		y=w;
	}
	return a/x*b;
}
int main()
{
	long long  n;
	while(~scanf("%lld",&n))
	{
		long long a[999],i,t=1;
			for(i=0;i<n;i++)
			{
				scanf("%lld",&a[i]);
			}
			for(i=0;i<n;i++)
			{
				t=cmp(t,a[i]); 
			}
			printf("%lld\n",t);
		
	}
}

Measured memory_bytes: 128
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

A,B = map(int,input().split())

if A >= 13:
    ans = B
elif A >= 6:
    ans = B//2
else:
    ans = 0
print(ans)


Measured memory_bytes: 7876
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define INF 1000000007
#define mod 1005
#define ll long long int
int main()
{
	int t = 1;
//	cin>>t;
	
	while(t--)
	{
		int n, k;
		cin>>n>>k;
		vector<int> vect(n);
		ll sum = 0;
		REP(i,n)
		{
			cin>>vect[i];
			sum+=vect[i];
		}
		sort(all(vect));
		ll diff = 0;
		int i = n-1;
		while(k!=0 && i>-1)
		{
			diff+=vect[i];
			k--;
			i--;
		}
		cout<<max(0*1LL, sum-diff)<<"\n";
	}
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstring>
#include <algorithm>
#include<vector>
#include <climits>
using namespace std;
using ll = long long;
ll N, M, X;

int main() {
    cin >> N >> M >> X;
    vector<ll> value(N);
    vector<vector<ll>> v(N);
    
    ll ans = INT_MAX - 10;
    bool flag = false;
    for (ll i = 0;i < N;i++) {
        cin >> value[i];
        for (ll j = 0;j < M;j++) {
            ll a = 0;
            cin >> a;
            v[i].push_back(a);
        }
    }
    for (int bit = 0; bit < (1 << N); ++bit)
    {
        vector<ll> vSum(N);
        ll sum = 0;
        for (ll i = 0; i < N; ++i) {
            if (bit & (1 << i)) { // i が bit に入るかどうか
                for (ll j = 0;j < M;j++) {
                    vSum[j] += v[i][j];
                }
                sum += value[i];
            }
        }
        bool overflag = true;
        for (ll k = 0;k < M;k++) {
            if (vSum[k] < X) {
                overflag = false;
            }
        }
        if((overflag)&&(sum<ans)) {
            ans = sum;
            flag = true;
        }
    }
    if (flag) {
        cout << ans << endl;
    }
    else {
        cout << -1 << endl;
    }

    return 0;
}

Measured memory_bytes: 3596
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

#define rep(i, N) for(int i = 0; i < N; ++i)

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

string s;
string t;
vector<vector<int>> idxs(26, vector<int>(1, -1));

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

    cin >> s >> t;
    rep (i, s.size())
    {
        idxs[s[i] - 'a'].push_back(i);
    }
    rep (i, s.size())
    {
        idxs[s[i] - 'a'].push_back(i + s.size());
    }

    s64 ret = 0;
    int now = -1, prev = -1;
    rep (i, t.size())
    {
        int c = t[i] - 'a';
        auto temp = lower_bound(idxs[c].begin(), idxs[c].end(), now + 1);
        if (temp == idxs[c].end())
        {
            ret = -1;
            break;
        }
        now = *temp;
        ret += now - prev;
        now = (now >= s.size()) ? now - s.size() : now;
        prev = now;
    }

    cout << ret << "\n";
    return 0;
}



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

int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= 3; i++){
    if(i == n || i == m) continue;
    cout << i << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define codefor int test;scanf("%d",&test);while(test--)
#define yn(ans) if(ans)printf("Yes\n");else printf("No\n")
#define YN(ans) if(ans)printf("YES\n");else printf("NO\n")
#define umap unordered_map
#define uset unordered_set
using namespace std;
using ll = long long;
const int MOD=1000000007;
//入力系
void scan(int& a){scanf("%d",&a);}
void scan(long long& a){scanf("%lld",&a);}
template<class T> void scan(T& a){cin>>a;}
template<class T> void scan(vector<T>& vec){for(auto&& it:vec)scan(it);}
void in(){}
template <class Head, class... Tail> void in(Head& head, Tail&... tail){scan(head);in(tail...);}
//出力系
void print(const int& a){printf("%d",a);}
void print(const long long& a){printf("%lld",a);}
void print(const double& a){printf("%.15lf",a);}
template<class T> void print(const T& a){cout<<a;}
template<class T> void print(const vector<T>& vec){if(vec.empty())return;print(vec[0]);for(auto it=vec.begin();++it!= vec.end();){putchar(' ');print(*it);}}
void out(){putchar('\n');}
template<class T> void out(const T& t){print(t);putchar('\n');}
template <class Head, class... Tail> void out(const Head& head,const Tail&... tail){print(head);putchar(' ');out(tail...);}
//デバッグ系
template<class T> void dprint(const T& a){cerr<<a;}
template<class T> void dprint(const vector<T>& vec){if(vec.empty())return;cerr<<vec[0];for(auto it=vec.begin();++it!= vec.end();){cerr<<" "<<*it;}}
void debug(){cerr<<endl;}
template<class T> void debug(const T& t){dprint(t);cerr<<endl;}
template <class Head, class... Tail> void debug(const Head& head, const Tail&... tail){dprint(head);cerr<<" ";debug(tail...);}

int main(){
    int n,m;
    in(n,m);
    vector<int> kosuu(n+1,1);
    uset<int> kouho;
    kouho.insert(1);
    int x,y;
    rep(i,m){
        in(x,y);
        kosuu[x]--;
        kosuu[y]++;
        if(kouho.count(x)){
            kouho.insert(y);
        }
        if(kosuu[x]==0){
            kouho.erase(x);
        }
    }
    out(kouho.size());
}


Measured memory_bytes: 7524
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include<list>
#include<map>
#include<utility>
#include<tuple>
#include<numeric>
#include<set>

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(a) (a).begin(),a.end()
using namespace std;

int main()
{
	int x, a, b;
	cin >> x >> a >> b;

	cout << (x - a) % b << endl;

}



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

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

    map<int,int>m;

    vector<long long>A(2);
    A[0]=0LL;
    A[1]=X;

    for(int i=1;i<=N;i++){
        //cout<<"A"<<i<<"="<<A[i]<<endl;

        if(m[A[i]]){
            //cout<<"used:"<<i<<" "<<m[A[i]]<<endl;

            long long l=m[A[i]],r=i,loop_size=r-l,loop_val=0LL;
            //cout<<"size"<<loop_size<<endl;
            for(int j=1;j<l;j++){
                ans+=A[j];
            }
            for(int j=l;j<r;j++){
                loop_val+=A[j];
            }
            //cout<<loop_val<<endl;
            ans+=loop_val*((N-(l-1))/loop_size);

            //cout<<"loop num"<<((N-l)/loop_size)<<endl;

            for(int j=0;j<((N-(l-1))%loop_size);j++){
                ans+=A[l+j];
            }
            cout<<ans<<endl;
            return 0;
        }

        m[A[i]]=i;
        A.push_back(A[i]*A[i]);
        A[i+1]%=M;

    }
    for(int i=1;i<=N;i++)ans+=A[i];
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 5988
#include<bits/stdc++.h>
using namespace std;
#define rep0(i,n) for(i=0;i<n;i++)
#define rep1(i,n) for(i=1;i<=n;i++)
#define test(a) cout << "*" << a << endl;
#define ll long long
int main(){
  int i,j,k;
  int iTmp;
  ll N,M,X;
  ll C[13];
  ll A[13][13];
  ll sum = 0;
  bool exist[13];
  ll US[13];
  ll sumMin = 1000000000;
  bool breakFrag = false;
  
  
  cin  >> N >> M >> X;
  rep0(i,N){
    cin >> C[i];
    rep0(j,M){
      cin >> A[i][j];
    }
  } 
  /*rep1(i,N){
    cout << C[i];
    rep1(j,M){
      cout << A[i][j];
    }
    cout << endl;
  }*/
  rep1(i,pow(2,N)-1){
     rep0(j,M){
          US[j] = 0;
    }
    iTmp = i;
    for(j=N-1;j>=0;j--){
      if(i >= pow(2,j)){
        i -= pow(2,j);
        exist[j] = true;
      }
      else{
        exist[j] = false;
      }
      
    }//*ビット１、０を調べる*/
    //test(exist[2]);
    //test(exist[1]);
    //test(exist[0]);
    
    rep0(k,N){
      if(exist[k]){
        rep0(j,M){
          US[j] += A[k][j];
        }
      }
    }
      //if(k==N-1){
        rep0(j,M){
          if(US[j]<X){
            breakFrag = true;
            break;
          }
        }
        if(breakFrag == false){
          rep0(j,N){
            if(exist[j])
              sum += C[j];
          }
          sumMin = min(sumMin,sum);
        }
      
      //}
    //}
    breakFrag = false;
    i = iTmp;
    sum = 0;
  }
   
  if(sumMin == 1000000000)
    cout << -1 << endl;
  else
    cout << sumMin << endl;
  
  
  
  

    
  
}

Measured memory_bytes: 4064
#include <iostream>
using namespace std;
using ll = long long;

ll f(ll n,ll x){
  if(n>=0) return n/x + 1;
  else return 0;
}

int main(){
  ll a,b,x;
  cin >> a >> b >> x;
  /*
  ll ans = b/x - (a-1)/x;
  if(a == 0 && x != 1) ans++;
  */
  ll ans = f(b,x) - f(a-1,x);
  cout << ans << endl;
}


Measured memory_bytes: 256
# ALDS1_2_A

N = int(input())
A = [int(i) for i in input().split()]
c = 0
flag = 1
while flag:
    flag = 0
    for j in range(N-1, 0, -1):
        if A[j] < A[j-1]:
            A[j], A[j-1] = A[j-1], A[j]
            flag = 1
            c += 1
print(" ".join(map(str, A)))
print(c)


Measured memory_bytes: 5604
#include<cstdio>
#include<cstring>
#include<algorithm>
#define ll long long
#define N 200005
#define mod 1000000007
#define rep(i,j,k) for (ll i=j;i<=k;++i)
#define per(i,j,k) for (ll i=j;i>=k;--i)
using namespace std;
inline ll read(){
	char ch=getchar(); ll x=0,f=1;
	while (ch<'0'||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
	while (ch>='0'&&ch<='9') { x=x*10+ch-'0'; ch=getchar(); }
	return x*f;
}
ll n,a[N],ans=1;
int main(){
	n=read();
	rep(i,1,n) ++a[read()];
	for (ll i=n-1;i>0;i-=2) if (a[i]!=2) return puts("0")&0;
	rep(i,1,n/2) (ans*=2)%=mod; printf("%lld",ans);
}

Measured memory_bytes: 896
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] d = new int[N];
		for (int i = 0; i < N; i++) {
			d[i] = sc.nextInt();
		}
		Arrays.sort(d);
		System.out.println(d[N / 2] - d[N / 2 - 1]);

	}
}


Measured memory_bytes: 59548
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i <(n) ; ++i)
using namespace std;
using ll = long long;
void self_max(int &a,int b){
  a = max(a,b);
}

int main(){
  int a,b; cin >> a >> b;

  if(a>=b) cout << 10 << endl;
  else cout << 0 << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>

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

using namespace std;
typedef long long ll;

int main()
{
    int n;
    while(cin >> n && n ) {

        vector<vector<int> > v(n);
        rep(i,n) {
            int m,p;
            cin >> m;
            rep(j,m) {
                cin >> p;
                v[i].push_back(p);
            }
        }

        rep(i,n) {
            sort(v[i].begin(),v[i].end());
        }

        int k;
        cin >> k;

        vector<int> l(k);
        rep(i,k) cin >> l[i];

        int cnt = 0;
        int ans = 0;

        rep(i,n) {
            bool flag = true;
            rep(j,k){
                if(!binary_search(v[i].begin(),v[i].end(),l[j])) {
                    flag = false;
                }
            }

            if(flag) {
                cnt++;
                ans = i;
            }
        }


        if(cnt == 1) cout << ans+1 << endl;
        else cout << -1 << endl;
    }

    return 0;
}

Measured memory_bytes: 1272
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;
import std.container;

alias sread = () => readln.chomp();
long bignum = 1_000_000_007;

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}

void main()
{
    long a, b, c, k;
    scan(a, b, c, k);
    if (k % 2)
        writeln(b - a);
    else
        writeln(a - b);
}


Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;
using static System.Console;
using static System.Math;
class Z { static void Main() => new K(); }
class K
{
	int F => int.Parse(Str);
	long FL => long.Parse(Str);
	int[] G => Strs.Select(int.Parse).ToArray();
	decimal[] GD => Strs.Select(decimal.Parse).ToArray();
	long[] GL => Strs.Select(long.Parse).ToArray();
	string Str => ReadLine();
	string[] Strs => Str.Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
	static T[] ConstantArray<T>(int n, T val) { var a = new T[n]; for (var i = 0; i < n; i++) a[i] = val; return a; }
	static T[] MakeArray<T>(int n, Func<int, T> f) { var a = new T[n]; for (var i = 0; i < n; i++) a[i] = f(i); return a; }
	const int MOD = 1000000007;
	public K()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		Out.Flush();
	}
	void Solve()
	{
		var N = F;
		var ans = 0m;
		var BTC = 380000m;
		while (N-- > 0)
		{
			var S = Strs;
			if (S[1] == "JPY") ans += int.Parse(S[0]);
			else ans += decimal.Parse(S[0]) * BTC;
		}
		WriteLine(ans);
	}
}


Measured memory_bytes: 13140
#include <stdio.h>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <queue>

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

int main() {
  int N, X, m, ans = 0;
  cin >> N >> X;
  int min_n = X;

  rep(i, N){
    cin >> m;
    X -= m;
    ans++;
    min_n = min(min_n, m);
  }
  ans += X/min_n;


  
  cout << ans << endl;

}


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

// 4方向へ移動可能
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
char masu[50][50];
int h,w;


int main(){

  	cin >> h >> w;

  	for(int i = 0; i < h; i++) {
    	for(int j = 0; j < w; j++) {
        	cin >> masu[i][j];
        }
    }
  	bool flag = true;
	for(int i = 0; i < h; i++){
    	for(int j = 0; j < w; j++){
        	if(masu[i][j] == '#'){
              	bool ok = false;
        		for(int k = 0; k < 4; k++){
            		if(0 <= i+dy[k] && i+dy[k] < h && 0 <= j+dx[k] && j+dx[k] < w && masu[i+dy[k]][j+dx[k]] == '#'){
                    	//masuの上下左右に#が1つもなかったらfalse
    					ok = true;
                    }
        		}
              	if(!ok) {
                	flag = false;
                }
            }
        }
    }
	
	if(flag) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<math.h>
#include<algorithm>

using namespace std;

long long A[200000] = { 0 };

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


	long long N = 0;
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		A[i] -= i+1;
	}

	sort(A,A+N);
	long long b = 0;

	if (N % 2 == 0)
		b = A[(N / 2) - 1];
	else
		b = A[(N / 2)];

	long long ans = 0;
	for (int i = 0; i < N; i++) {
		ans += abs(A[i] - b);
	}


	cout << ans << endl;
	
	cin >> b;

}

Measured memory_bytes: 1792
from sys import maxsize as infinity


def exchange(amount: int) -> int:
    dp = [0] * (amount + 1)

    for to_exchange in range(amount + 1):
        dp[to_exchange] = 0

        for (coin, gain) in [(500, 1000), (5, 5), (100, 0), (50, 0), (10, 0), (1, 0)]:
            if coin <= to_exchange:
                dp[to_exchange] = max(
                    dp[to_exchange],
                    gain + dp[to_exchange - coin]
                )

    return dp[amount]


amount = int(input())
n_500, new_amount = divmod(amount, 500)
n_5, new_amount_2 = divmod(new_amount, 5)

print(n_500 * 1000 + n_5 * 5)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define int long long
const int INF=1e15;
const int MOD=1e13+7;

int C[51][51];

void com_table(int N){
    REP(i,N+1){
        REP(j,i+1){
            if(j==0||j==i)C[i][j]=1;
            else C[i][j]=(C[i-1][j-1]+C[i-1][j]);
        }
    }
}

signed main(){
    int N,A,B;cin>>N>>A>>B;
    com_table(N);
    vector<int>V(N);
    REP(i,N)cin>>V[i];
    sort(V.rbegin(),V.rend());
    double maxave=0;
    int stop=0;
    for(int i=A;i<=B;i++){
        double d=0;
        REP(j,i)d+=V[j];
        d/=i;
        maxave=max(d,maxave);
    }
  	cout<<setprecision(20.10);
  	cout<<maxave<<endl;
    map<int,int>memo;
    int count=0;
  	int z=0;
  	int v=0;
    REP(i,A){
        if(V[A-1]==V[i]){
            z++;
            v++;
        }
    }
    for(int i=A;i<N;i++){
        if(V[i]==V[A-1])v++;
    }
  	if(z!=A){
          int ans=C[v][z];
      	  cout<<setprecision(20.10);
          cout<<ans<<endl;
    }
  	else{
        int ans=0;
        for(int i=A;i<=B;i++){
            ans+=C[v][i];
        }
      	cout<<setprecision(20.10);
      	cout<<ans<<endl;
    }  	
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define    fio     ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define    eps     1e-9
#define    pi      acos(-1.0)
#define    mod     1e9+7

using namespace std;
typedef long long ll;

void solve()
{
    int n;
    cin>>n;
    int a[n];
    int cnt=0;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        if((i+1)%2!=0 && a[i]%2!=0)
        {
            cnt++;
        }
    }
    cout<<cnt<<endl;
}

int main()
{
    fio;
///    freopen ("output.txt","w",stdout);
///    freopen ("input.txt","r",stdin);
    int tc=1;
///    cin>>tc;
///    int i=0;
    while(tc--)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 3636
import numpy as np

q = int(input())

# 高速素数判定
is_prime = np.ones(100001, dtype=int)
is_prime[0]=0
is_prime[1]=0

for i in range(2,100001):
    if is_prime[i]==1:
        j=i+i
        while j <= 100000:
            is_prime[j] = 0
            j += i

like2017 = [is_prime[x]*is_prime[(x+1)//2] for x in range(0,100001)]

for i in range(1,100001):
    like2017[i] += like2017[i-1]
for i in range(q):
    l,r = map(int, input().split())
    print(like2017[r]-like2017[l-1])


Measured memory_bytes: 17448
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> P;
const int INF = 100002;
P arr[100003];
int t[100003];

int main()
{
	int n, l;
	scanf("%d %d", &n, &l);
	
	arr[0].second = INF;
	for (int i = 1; i <= n; i++){
		scanf("%d", &arr[i].first);
		arr[i].second = i;
	}
	
	sort(arr + 1, arr + n + 1);
	reverse(arr + 1, arr + n + 1);
	for (int i = 1; i <= n; i++){
		t[arr[i].second] = l - arr[i].first;
		t[arr[i].second] += max(t[arr[i].second - 1], t[arr[i].second + 1]);
	}
	
	int maxi = 0;
	for (int i = 1; i <= n; i++){
		//printf("%d\n", t[i]);
		maxi = max(maxi, t[i]);
	}
	printf("%d\n", maxi);
	
	return 0;
}

Measured memory_bytes: 2360
#include <cstdlib>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>


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

  int n, l;
  std::cin >> n >> l;
  std::vector<std::string> sn(n);
  for (auto&& s : sn) {
    std::cin >> s;
  }
  std::sort(sn.begin(), sn.end());
  for (const auto& s : sn) {
    std::cout << s;
  }
  std::cout << std::endl;

  return EXIT_SUCCESS;
}


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

#define int long long

signed main() {
    int n;
    cin >> n;
    vector<string> s(n);
    for(int i=0; i<n; ++i) {
        cin >> s[i];
    }
    int m;
    cin >> m;
    vector<string> t(m);
    for(int i=0; i<m; ++i) {
        cin >> t[i];
    }

    int ans = 0;
    for(int i=0; i<n; ++i) {
        string u = s[i];
        int tmp = count(s.begin(), s.end(), u);
        for(int j=0; j<m; ++j) {
            if(u==t[j]) tmp--;
        }
        ans = max(tmp, ans);
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <algorithm>

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

using namespace std;

int main() {
  while(1){
    int n;
    cin>>n;
    if(!n)break;
    vector<int> x;
    vector<int> y;
    x.push_back(0);
    y.push_back(0);
    REP(i,n-1){
      int m,d;
      cin>>m>>d;
      int di[] = {0,1,0,-1};
      int dj[] = {-1,0,1,0};
      y.push_back(y[m] + di[d]);
      x.push_back(x[m] + dj[d]);
    }
    auto pw = minmax_element(begin(x),end(x));
    auto ph = minmax_element(begin(y),end(y));
    int w=(*(pw.second) - *(pw.first)) + 1;
    int h=(*(ph.second) - *(ph.first)) + 1;
    cout << w << ' ' << h << endl;
  }
  return 0;
}

Measured memory_bytes: 1220
#include <bits/stdc++.h>
using namespace std;
int main(void){
    string S;
    cin >> S;
    sort(S.begin(),S.end());
    char x = 'a';
    for(int i = 0; i < S.size(); i++){
        if(S[i] == x) x++;
    }
    if('z' >= x) cout << x << endl;
    else cout << "None" << endl;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL)
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define trace(x)  cerr << #x << ": " << x << endl;
typedef long long ll;
typedef long double ld;const ll N=1e5+5;
int main()
{
    ll h,w,k;cin>>h>>w>>k;
    ll m[h][w];
    for(ll i=0;i<h;i++)
        for(ll j=0;j<w;j++)
        {
            char x;cin>>x;
            m[i][j]=(x=='#');
        }
    ll ans=0;
    for(ll mskr=0;mskr<(1LL<<h);mskr++)
    {
        for(ll mskc=0;mskc<(1LL<<w);mskc++)
        {
            ll tmp=0;
            for(ll i=0;i<h;i++)
            {
                for(ll j=0;j<w;j++)
                {
                    if(m[i][j]==1 && (mskr&(1LL<<i))==0 && (mskc&(1LL<<j))==0 )tmp++;
                }
            }
            ans+=(tmp==k);

        }
    }
    cout<<ans;
}

Measured memory_bytes: 3644
import sys

INF = float('inf')

def Bellmanford(n, edges, r): #r: 始点
    d = [INF] * n
    d[r] = 0
    
    for i in range(n):
        for (u, v, c) in edges:
            if d[u] != INF and d[u] + c < d[v]:
                d[v] = d[u] + c
                if i == n-1 and v == n-1:
                    return 'inf'
    
    return -d[n-1]
    

N, M = map(int, sys.stdin.readline().split())
Edges = [None] * M

for i in range(M):
    ai, bi, ci = map(int, sys.stdin.readline().split())
    Edges[i] = (ai-1, bi-1, -ci)
    
ans = Bellmanford(N, Edges, 0)

print(ans)


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

using namespace std;

int main(){
        int a[3][3];
        string ans="No";
        for(int i=0;i<3;i++){
                for(int j=0;j<3;j++){
                        cin>>a[i][j];
                }
        }
        int n;
        cin>>n;
        for(int i=0;i<n;i++){
                int b;
                cin>>b;
                for(int j=0;j<3;j++){
                        for(int k=0;k<3;k++){
                                if(a[j][k]==b){
                                        a[j][k]=0;
                                        break;
                                }
                        }
                }
        }
        for(int i=0;i<3;i++){
                if((a[i][0]==a[i][1]&&a[i][1]==a[i][2])||(a[0][i]==a[1][i]&&a[2][i]==a[1][i])){
                        ans="Yes";
                }
        }
        if((a[0][0]==a[1][1]&&a[1][1]==a[2][2])||(a[0][2]==a[1][1]&&a[1][1]==a[2][0])){
                ans="Yes";
        }
        cout<<ans<<endl;
        return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner get = new Scanner(System.in);
        int n, m, a[] = new int[102], total = 0, minval;
        n = get.nextInt();
        m = get.nextInt();
        for(int i = 1; i <= n; ++i) {
            a[i] = get.nextInt();
            total += a[i];
        }
        minval = total / (4 * m);
        if(total % (4 * m) > 0) ++minval;
        int maxAmount = 0;
        for(int i = 1; i <= n; ++i) {
            if(a[i] >= minval) {
                ++maxAmount;
            }
        }
        if(maxAmount >= m) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 23636
#pragma GCC optimize("Ofast")
/*#pragma GCC target("avx,avx2,fma")
#pragma GCC target ("sse4")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")*/
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define ld double 
#define rep(i,a,b) for(ll i=a; i<b; ++i)
#define BOOST std::ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb push_back
#define all(v) v.begin(),v.end()
#define sl(a) a.size()
#define mod 1000000007 
#define lcm(a,b) (a*b)/__gcd(a,b)
#define MAX1 100006
#define f first
#define s second
#define pi 2*acos(0.0)
bool isPowerOfTwo (int x) {  return x && (!(x&(x-1)));  }
ll Modular_Exponentiation(ll x, ll n, ll M)
{
    if(n==0) return 1;
    if(n%2) return (x*Modular_Exponentiation((x*x)%M,n/2,M))%M;
    else return (Modular_Exponentiation((x*x)%M,n/2,M))%M;
}
void solve()
{
    ll n;  cin>>n;
    cout<<(Modular_Exponentiation(10,n,mod)%mod-(2*Modular_Exponentiation(9,n,mod))%mod+Modular_Exponentiation(8,n,mod)%mod+mod)%mod;

}
int main()
{
    #ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt","r",stdin);
    //for getting error from error.txt
    freopen("error.txt", "w", stderr);
    // for writing output to output.txt
    freopen("output.txt","w",stdout);
    #endif
    BOOST
    int T=1;  //cin>>T;
    while(T--) solve();
    cerr<<"Time taken : "<<fixed<<setprecision(5)<<(float)clock()/CLOCKS_PER_SEC<<" secs"<<"\n";
    cerr<<"My CLOCKS_PER_SEC= "<<CLOCKS_PER_SEC<<"\n";
    return 0;
}

Measured memory_bytes: 3816
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
//前処理としてDの倍数でk余るやつのsumをすべて覚えときたい
//O(D^3)

map<int,P> mp;
int sum[1001001]; 
//sum[d][r][q+1]でr→q+r→....→d*q+rを表す

int main(){
    int H, W, D;
    cin >> H >> W >> D;
    for(int i=0; i<H; i++){
        for(int j=0; j<W; j++){
            int a; scanf("%d", &a);
            mp[a]=P(i,j);
        }
    }

    //前処理していく
    int d=D;
    for(int i=1; i<=H*W; i++){
        int q = i/d; int r=i%d;
        if(q==0){
            sum[i]=0;
        }
        else{
            P now = mp[i];  int nowx=now.first, nowy=now.second;
            P bef =mp[i-d]; int befx=bef.first, befy=bef.second;
            sum[i]=sum[i-d]+abs(nowx-befx)+abs(nowy-befy);
        }
    }

    //答えていく
    int Q;
    cin >> Q;
    for(int i=0; i<Q; i++){
        int l, r;
        scanf("%d%d",&l, &r);
        int q1 = l/D, q2=r/D; int ama= l%D;
        cout << sum[r] -sum[l] << endl;
    }
}

Measured memory_bytes: 7168
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
    int n, y; cin >> n >> y;
    int a = -1, b = -1, c = -1;
    for(int i = 0; i <= n; i++){
        for(int j = 0; j <=n-i; j++){
            if(i * 10000 + j * 5000 + (n - i - j) * 1000 == y){
                a = i; b = j, c = n-i-j;
            }
        }
    }
    cout << a << " " << b << " " << c << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int n = 100;

int main(){
  int m[n][n];
  int n,u,k,v,i,j;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      m[i][j] = 0;
    }
  }

  for(i=0;i<n;i++){
    scanf("%d%d",&u,&k);
    u--;
    for(j=0;j<k;j++){
    scanf("%d",&v);
    v--;
    m[u][v]=1;
    }
  }

  for(i=0;i<n;i++){
      printf("%d",m[i][0]);
    for(j=1;j<n;j++){
    printf(" %d",m[i][j]);
    }
    printf("\n");
  }

return 0;

}



Measured memory_bytes: 2108
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
	int N;
	cin >> N;
	vector<int> values;
	int s;
	for (int i = 0; i < N; ++i)
	{
		cin >> s;
		values.push_back(s);
	}

	int sum = 0;
	for (auto& value : values)
	{
		sum += value;
	}
	if (sum % 10 == 0)
	{
		sort(values.begin(), values.end());
		int mvalue = 0;
		for (int i = 0; i < values.size(); ++i)
		{
			if (values[i] % 10 != 0)
			{
				mvalue = values[i];
				break;
			}
		}
		if (mvalue == 0)
		{
			cout << 0 << endl;
		}
		else
		{
			cout << sum - mvalue << endl;
		}
	}
	else
	{
		cout << sum << endl;
	}

}

Measured memory_bytes: 256
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
*$* WRITER:kakitamasziru/OxOmisosiru *$*
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#ifdef LOCAL_JUDGE
#define _GLIBCXX_DEBUG //FOR THE DEBUG! COMMENT OUT THIS WHEN SUBMITTING!
#endif
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <iomanip>
#include <limits>//setprecision
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
#include <bitset> // bitset
//It is so troublesome that I include bits/stdc++.h !
using namespace std;

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const long long INF = 100100100100;
const long long MOD = 1000000007;
typedef pair<int,int> P;
//NのM乗を求める(繰り返し二乗法)
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;

    return res %= MOD;
}
long long nCr(long long n, long long r) {
    long long A = 1, B = 1;
    //Aが分子Bが1/r!
    for (long long i = n - r + 1; i <= n; i++) {
        A = A * i % MOD;
    }
    for (long long i = 1; i <= r; i++) {
        B = B * i % MOD;
    }
    B = mod_pow(B, MOD - 2);
    B %= MOD;
    //Bは割るのではなく掛ける
    return (A * B) % MOD;
}

long long gcd(long long a, long long b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}
 
long long lcm(long long a, long long b) {
    return a * b / gcd(a, b);
}

long long A,B;
bool ok(long long key,long long index){
    string S = to_string(index);
    long long nagasa = S.size();
    if(index*A+nagasa*B > key) return true;
    else if(index*A+nagasa*B <= key) return false;
}
long long binary_search(long long key,long long size){
    //left,right,midはいずれもindex
    long long left = -1,right = size;
    while(right - left > 1){
        long long mid = left + (right-left)/2;
        long long hantei = ok(key,mid);
        if(hantei) right = mid;
        else left = mid;
    }
    if(left == -1)return 0;
    return left;
}

int main() {
    int N,A,B;cin >> N >> A >> B;
    for(int i = N;i<=B;i += N){
        if(i % N == 0 && i >= A) {
            cout << "OK" << endl;
            return 0;
        }
    }
    cout << "NG" << endl;

    // PLEASE GIVE ME THE "ACCEPTED" !
}


Measured memory_bytes: 3592
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iostream>
#include <iostream>
#include <fstream>
#include <numeric>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <cmath>
#include <set>
#include <map>
#include <functional>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <cstdint>
using namespace std;
#define     loop(n,i,a)     for(ll i=a;i<n;i++)
#define     loopR(n,i,a)    for(ll i=n-1;i>=a;i--)
#define     all(arr,n)      arr,arr+n
#define     allv(v)         (v).begin(),(v).end()
#define     rallv(v)        (v).rbegin(),(v).rend()
#define     m_p             make_pair
#define     ll              long long
#define     pii             pair<ll,ll>
#define     vi              vector<int>
#define     vll             vector<ll>
#define     vii             vector<pair<ll,ll>>
#define     sz(x)           (int)x.size()
#define     pb              push_back
#define     endl            "\n"
#define     Endl            "\n"
#define     f               first
#define     s               second
#define     mem(dp,n)       memset(dp,n,sizeof dp)
int dx[] = { 1 , 0 ,-1 , 0 ,-1 ,-1 , 1 , 1 };
int dy[] = { 0 , 1 , 0 ,-1 ,-1 , 1 ,-1 , 1 };
int KnightI[] = { 2, 1, -1, -2, -2, -1, 1, 2 };
int KnightJ[] = { 1, 2, 2, 1, -1, -2, -2, -1 };
template<typename T>
void max_self(T &a,T b){
    a=max(a,b);
}
template<typename T>
void min_self(T &a,T b){
    a=min(a,b);
}
void fast(){
    std::ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
}
vector<string> vec_splitter(string s) {
    s += ',';
    vector<string> res;
    while(!s.empty()) {
        res.push_back(s.substr(0, s.find(',')));
        s = s.substr(s.find(',') + 1);
    }
    return res;
}
void debug_out(
        vector<string> __attribute__ ((unused)) args,
        __attribute__ ((unused)) int idx,
        __attribute__ ((unused)) int LINE_NUM) { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
    if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
    stringstream ss; ss << H;
    cerr << args[idx] << " = " << ss.str();
    debug_out(args, idx + 1, LINE_NUM, T...);
}
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
const ll mxN=5e5+10,oo=0x3f3f3f3f,MOD=998244353;
const double PI = acos(-1);

void solve(){
    int a,b;
    cin>>a>>b;
    if(b==1){
        cout<<0<<endl;
        return;
    }
    int res=b/a+(bool)(b%a);
    while(res*a-res+1<b)res++;
    cout<<res<<endl;
}
int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    fast();
    solve();

}


Measured memory_bytes: 3644
#include <iostream>

using namespace std;

int main(void){
  int a, b, c;
  cin >> a >> b >> c;
  int min, mid, max;
  bool fa = 0, fb = 0, fc = 0;

  // decide min
  if(a <= b && a <= c) min = a, fa = 1;
  if(b <= c && b <= a) min = b, fb = 1;
  if(c <= a && c <= b) min = c, fc = 1;

  // decide max
  if(a >= b && a >= c) max = a, fa = 1;
  if(b >= c && b >= a) max = b, fb = 1;
  if(c >= a && c >= b) max = c, fc = 1;

  // decide mid
  if(fb == 1 && fc == 1) mid = a;
  if(fc == 1 && fa == 1) mid = b;
  if(fa == 1 && fb == 1) mid = c;

  // print
  cout << min << " " << mid << " " << max << endl;
  return 0;
}


Measured memory_bytes: 3096
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
const long long int INF = 1e18;
const long long int mod = 1e9+7;

typedef pair<ll, ll> pairs;
typedef vector<pairs> p;

struct Edge{
    ll to, weight;
    Edge(ll t, ll w) : to(t), weight(w){}
};
using graph = vector<vector<ll>>;
using Graph = vector<vector<Edge>>;


ll gcd(ll a,ll b){
    if(b == 0){
        return a;
    }else{
        return gcd(b, a%b);
    }
}

ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

// 回文
bool kai(string S){
    bool flag = true;
    for(ll i=0;i<S.size()/2;++i){
        if(S[i] != S[S.size()-i-1]){
            flag = false;
            break;
        }
    }
    return flag;
}
// ---------------------------------------------

int main(){
    ll n, x;
    cin>>n>>x;
    vector<ll> a(n);
    for(ll i=0;i<n;++i){
        cin>>a[i];
    }

    ll ans = abs(x-a[0]);
    for(ll i=1;i<n;++i){
        ans = gcd(ans, abs(x-a[i]));
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 1024