akhauriyash/Code-Regression huggingface dataset:
n, k = map(int, input().split())
class factorial:
  def __init__(self, n, p=10**9 + 7):
    self.__p  = p
    self.__fac  = [0] * (n+1)
    self.__inv  = [0] * (n+1)
    self.__finv = [0] * (n+1)

    self.__fac[0] = self.__fac[1] = 1
    self.__inv[1] = 1
    self.__finv[0] = self.__finv[1] = 1

    for i in range(2, n+1):
      self.__fac[i] = self.__fac[i-1] * i % p
      self.__inv[i] = p - self.__inv[p%i] * (p // i) % p
      self.__finv[i] = self.__finv[i-1] * self.__inv[i] % p
  
  def fact(self, n):
    return self.__fac[n]
  
  def perm(self, n, k):
    return self.__fac[n] * self.__finv[n-k] % self.__p
  
  def comb(self, n, k):
    return self.perm(n, k) * self.__finv[k] % self.__p

f = factorial(n)
p = 10**9 + 7
ans = 0
for i in range(min(k+1, n)):
  ans = (ans + f.comb(n, i) * f.comb(n-1, n-i-1)) % p
print(ans)

Measured memory_bytes: 26740
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
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; }
typedef long long ll;
const long long INF = 1LL << 60;
int main()
{
    int n, m;
    cin >> n >> m;

    cout << (n - 1) * (m - 1) << endl;
    return 0;
}

Measured memory_bytes: 256
import collections

n, m = map(int, raw_input().split(' '))
hs = map(int, raw_input().split(' '))
adj = collections.defaultdict(list)
for _ in range(m):
	a,b = map(int, raw_input().split(' '))
	adj[a].append(b)
	adj[b].append(a)
count = 0
for u in range(1, n + 1):
	if all([hs[v - 1] < hs[u - 1] for v in adj[u]] or [True]):
		count+=1
print count


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

namespace AC {
#define ll long long
#define PLL pair<ll, ll>
#define PDD pair<double, double>
#define PDPLL pair<double, PLL>
#define PLPLL pair<ll, PLL>
#define pb push_back
#define fi first
#define se second
#define ls rt << 1
#define rs rt << 1 | 1

    const ll N = 1e5 + 66;

    ll BUGS = 1;

    inline ll read(){
        ll x = 0;    bool flag = 1;   char ch = getchar();
        while(ch < '0' || ch > '9') { if(ch == '-') flag = 0; ch = getchar(); }
        while(ch >= '0' && ch <= '9') { x = (x << 1) + (x << 3) + ch - '0'; ch = getchar(); }
        if(flag) return x;  return (~(x - 1));
    }

    inline void read(ll arr[], ll s, ll e) { for(ll i = s; i <= e; ++i) arr[i] = read(); }

    inline void write(ll x){
        if(x < 0) { x = ~(x - 1); putchar('-'); }
        if(x > 9) write(x / 10); putchar(x % 10 + '0');
    }

    inline void print(ll x) { write(x); puts(""); }

    inline void print(ll arr[], ll s, ll e) {
        for(ll i = s; i <= e - 1; ++i) write(arr[i]), putchar(' ');
        write(arr[e]); puts("");
    }

    inline ll max3(ll a, ll b, ll c) { return max(a, max(b, c)); }

    inline ll min3(ll a, ll b, ll c) { return min(a, min(b, c)); }

    inline void debugNum(ll num, string ss) { cout << "BUGS" << BUGS++ << " : " << ss << " : " << num << endl; }

    inline void debugArr(ll arr[], ll s, ll e, string ss) {
        cout << "BUGS" << BUGS++ << " : " << ss << " : " << endl;
        for(ll i = s; i <= e; ++i) cout << "i : " << i << " val : " << arr[i] << endl;
    }

    inline void IO() {
        //ios::sync_with_stdio(false), cout.tie(0), cin.tie(0);
        //cout << setiosflags(ios::fixed) << setprecision(1); //保留小数点后1位
        //cout << setprecision(1); //保留1位有效数字
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    }
}using namespace AC;

int main() {
    //IO();
    ll n = read();
    print(n + n * n + n * n * n);
    return 0;
}



Measured memory_bytes: 3592
/******************************************************************************

Welcome to GDB Online.
GDB online is an online compiler and debugger tool for C, C++, Python, Java, PHP, Ruby, Perl,
C#, VB, Swift, Pascal, Fortran, Haskell, Objective-C, Assembly, HTML, CSS, JS, SQLite, Prolog.
Code, Compile, Run and Debug online from anywhere in world.

*******************************************************************************/
#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 10;
int h , n , a[N] , b[N] , OO = 1e9 + 1 , dp[1003][10004];

int calc(int i , int h){
    if(h <= 0)return 0;
    if(i == n)
        if(h <= 0)
            return 0;
        else return OO;
    int &ret = dp[i][h];
    if(ret != -1)return ret;
    ret = calc(i + 1 , h);
    ret = min(ret , b[i] + calc(i , h - a[i]));
    return ret;
}
int main(){
    cin >> h >> n;
    for(int i = 0 ; i < n ; i++)
        cin >> a[i] >> b[i];
    memset(dp , -1 , sizeof dp);
    cout << calc(0 , h) << endl;
    return 0;
}


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

public class Main {
    static StringTokenizer st;
    static BufferedReader br;  
    static PrintWriter out;
 
    public static void main(String[] args) throws IOException {
        br = new BufferedReader(new InputStreamReader(System.in));

        int N = nextInt();
        int K = nextInt();

        int[] input = new int[N];

        for (int i=0; i<N; i++) {
            input[i] = nextInt();
        }

        Arrays.sort(input);

        int ans = 0;
        for (int i=0; i<K; i++) {
            ans += input[i] ;
        }
        System.out.println(ans);
 
        
    }
    
      
    public static int nextInt() throws IOException {
        return Integer.parseInt(next());
    }
    public static long nextLong() throws IOException {
        return Long.parseLong(next());
    }

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

    static String next() throws IOException {
        while (st == null || !st.hasMoreTokens())
            st = new StringTokenizer(br.readLine().trim());
        return st.nextToken();
    }
}

Measured memory_bytes: 32524
x,y = map(int,input().split())
dic = {
    1:1,3:1,5:1,7:1,8:1,10:1,12:1,
    4:2,6:2,9:2,11:2,
    2:3
}
if dic[x]==dic[y]:
    print("Yes")
else:
    print("No")

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

using namespace std;


void solve() {
    string S, T; cin >> S >> T;

    vector<string> v;

    for (int i = 0; i < S.length() - T.length() + 1; i++) {
        bool flag = true;
        string tmp = S;
        for (int j = 0; j < T.length(); j++) {
            if (S[i + j] != '?' && S[i + j] != T[j]) flag = false;
            tmp[i + j] = T[j];
        }
        if (flag) v.push_back(tmp);        
    }

    for (int i = 0; i < v.size() ; i++) {
        for (int j = 0; j < S.length(); j++) {
            if (v[i][j] == '?') v[i][j] = 'a';
        }
        //cout << v[i] << endl;
    }

    sort(v.begin(), v.end());

    if (v.empty()) cout << "UNRESTORABLE" << endl;
    else cout << v.front() << endl;
}


int main() {
    solve();
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
long long fac(ll a){
    long long ans=1;
    while(a>1){
        ans*=a;
        ans%=1000000007;
        a--;
    }
    return ans;
}
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
}
int main(){
    ll n,m;
    cin >> n >> m;
    vl v(n,-1),a(m),b(m);
    rep(i,m){
        cin >> a[i] >> b[i];
        a[i]--;
    }
    if(n==1){
        rep(i,m){
        
        if(v[a[i]]==b[i])continue;
        if(v[a[i]]==-1){
            v[a[i]]=b[i];
            continue;
        }
        cout << -1 << endl;
        return 0;
    }
    if(v[0]==-1)v[0]=0;
        cout << v[0]<< endl;
    }
    if(n>=2){
    rep(i,m){
        if(a[i]==0&&b[i]==0){
            cout << -1 << endl;
            return 0;
        }
        if(v[a[i]]==b[i])continue;
        if(v[a[i]]==-1){
            v[a[i]]=b[i];
            continue;
        }
        cout << -1 << endl;
        return 0;
    }
    if(v[0]==-1)v[0]=1;
    for(int i=1;i<n;i++){
        if(v[i]==-1)v[i]=0;
    }
    rep(i,n){
        cout << v[i];
    }
    cout << endl;
    }
}
    

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

int main() {
	ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
	string str; cin >> str; int n = str.size();

	vector <int> a(n + 1, 0), b(n + 1, 0);

	for(int i = 2; i <= n; i++) {
		a[i] = a[i - 1] + (str[i - 1] != str[i - 2]);
	}
	for(int i = n - 1; i >= 1; i--) {
		b[i] = b[i + 1] + (str[i - 1] != str[i]);
	}

	int ans = a[n];

	for(int i = 1; i < n; i++) {
		ans = min(ans, a[i] + b[i + 1] + (str[i - 1] != str[i]));
	}

	cout << ans << endl;
}

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

template<typename T_char>
T_char ToUpper(T_char cX){return toupper(cX);}

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

  for(int i=0; i<2; ++i){
    for(int j=0; j<n; ++j){
      if(i==0 && j==0) continue;
      if(i==0 && j>0){
        a[i][j] += a[i][j-1];
      }
      else if(i==1 && j==0){
        a[i][j] += a[0][0];
      }
      else{
        a[i][j] = max(a[i-1][j], a[i][j-1]) + a[i][j];
      }
    }
  }
  cout << a[1][n-1] << endl;

}

Measured memory_bytes: 3592
//=======================================
// abc144b
//
//  2019/10/27
//=======================================

#include <bits/stdc++.h>
using namespace std;

int main(int argc, char* argv[])
{
	cin.tie(0);
  ios::sync_with_stdio(false);

  int n; cin >> n;

  for(int i=1; i<10; ++i)
  {
    for(int j=1; j<10; ++j)
    {
      if(i*j == n)
      {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;

  return 0;
}

Measured memory_bytes: 256
#!/usr/bin/ruby
require 'mathn'
h={};2.step(36){|i|h[i]=i.prime_division}
while(l=gets.chomp)!="0 0"
	l=l.split
	n=l[0].to_i;m=l[1].to_i(n)
	p h[n].map{|a,b|
		z=m;r=0
		while z>0 do r+=(z=z.div(a)) end
		r.div(b)
	}.min
end

Measured memory_bytes: 3988
#include <bits/stdc++.h>
using namespace std;
long long n,i,j,nr,v[2010],st,mij,dr,x;
int cb()
{
    int stcb=mij+1,drcb=n,mijcb=0,poz=0;
    while(stcb<=drcb)
    {
        mijcb=(stcb+drcb)/2;
        if(v[st] + v[mij] > v[mijcb] && v[mij] + v[mijcb] > v[st] && v[st] + v[mijcb] > v[mij])
            poz=mijcb , stcb=mijcb+1;
        else drcb=mijcb-1;
    }
    return poz;
}
int main()
{
    cin>>n;
    for(i=1; i<=n; i++)
        cin>>v[i];
    sort(v+1,v+n+1);
    st=1;
    mij=2;
    while(st<=n-2)
    {
        x=cb();
        nr=nr+max(x-mij,(long long)0);
        mij++;
        if(mij==n)
            st++, mij=st+1;
    }
    cout<<nr;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <algorithm>
#include <numeric>
#include <functional>
#include <tuple>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <vector>

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

using namespace std;
typedef long long ll;

int main() {
  int k, t;
  cin >> k >> t;
  vector<int> v(t);
  int m = 0;
  REP(i,0,t) {
    cin >> v[i];
    m = max(m, v[i]);
  }
  // int x = (k + 1) / 2;
  // cout << (t == 1 ? k - 1 : max(0, m - x)) << endl;
  cout << max(0, k - 2 * (k - m) - 1) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <map>
#include <set>
#include <sstream>
#include <stdio.h>

using namespace std;

#define Rep(i,a,b) for(int i = a; i < b; i++)
#define rep(i,b) Rep(i,0,b)
#define rrep(i,a) for(int i = a; i >= 0; i--)
#define allof(a) (a).begin(), (a).end()
#define pb push_back

typedef long long ll;
const int inf = 1e9 + 7;
const ll infll = 1 << 60LL;
const ll mod = 1e9 + 7;
// 0~3までは右左下上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

// 型による変数のオーバーフローに気をつけろ！！
// 悩んだら図やグラフを書け！！悩む前から書け！！

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

	int cnt;
	cnt = n / 3;

	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {

	/** YES:??´?§?????§???¢??§?????? */
	private static final String RIGHT_TRIANGLE = "YES";

	/** NO:??´?§?????§???¢??§????????? */
	private static final String NOT_RIGHT_TRIANGLE = "NO";

	/**
	 * AOJ Is it a Right Triangle?
	 *
	 * @param args
	 * @throws IOException
	 *             ??\?????¨??????
	 */
	public static void main(String[] args) throws IOException {
		BufferedReader bufferedReader = new BufferedReader(
				new InputStreamReader(System.in));

		int numsOfDataSets = Integer.parseInt(bufferedReader.readLine());

		for (int i = 0; i < numsOfDataSets; i++) {
			String[] triangle = bufferedReader.readLine().split("\\s");

			int[] sides = getIntArray(triangle);
			if (isRightTriangle(sides)) {
				System.out.println(RIGHT_TRIANGLE);
			} else {
				System.out.println(NOT_RIGHT_TRIANGLE);
			}
		}

		bufferedReader.close();
	}

	/**
	 * 3???????????????????????´?§?????§???¢????????????????????????
	 *
	 * @param triangle
	 * @return
	 */
	private static boolean isRightTriangle(int[] sides) {

		Arrays.sort(sides);
		if (calcSumPower(sides[0], sides[1]) == calcPower(sides[2])) {
			return true;
		}
		return false;
	}

	/**
	 * String????????????int?????????????????????????????´??????
	 *
	 * @param strArray
	 *            String?????????
	 * @return int?????????
	 */
	private static int[] getIntArray(String[] strArray) {
		int[] intArray = new int[3];
		for (int i = 0; i < 3; i++) {
			intArray[i] = Integer.parseInt(strArray[i]);
		}
		return intArray;
	}

	/**
	 * ?????°???????????????????????´??????
	 *
	 * @param n
	 *            ???????????????
	 * @return ?????°??????????????????
	 */
	private static int calcPower(int n) {
		return n * n;
	}

	/**
	 * ????????°??????????????????????????´??????
	 *
	 * @param n
	 *            ??´??°1
	 * @param m
	 *            ??´??°2
	 * @return ????????°??????????????????
	 */
	private static int calcSumPower(int n, int m) {
		return calcPower(n) + calcPower(m);
	}

}

Measured memory_bytes: 20192
#include <bits/stdc++.h>
using ll = long long;
using itn = int;
using namespace std;
int GCD(int a, int b){
    return b ? GCD(b, a%b) : a;
}
int main() {
	ll a,b,c,d;
	cin >> a >> b >> c >> d;
	//[1,b]
	ll l = (c*d)/GCD(c,d);
	ll ub_c=b/c;
	ll ub_d=b/d;
	ll ub_cd=b/l;
	//[1,a)
	ll ua_c=(a-1)/c;
	ll ua_d=(a-1)/d;
	ll ua_cd=(a-1)/l;
	//[a,b]
	ll ab_c=ub_c-ua_c;
	ll ab_d=ub_d-ua_d;
	ll ab_cd=ub_cd-ua_cd;

/*
	ab_c = (ab_c<0?0:ab_c);
	ab_d = (ab_d<0?0:ab_d);
	ab_cd = (ab_cd<0?0:ab_cd);
*/
	ll ans = (b-a+1) - ab_c - ab_d + ab_cd;
	cout << ans << endl;
}

Measured memory_bytes: 256
N, K = map(int, input().split())
V = list(map(int, input().split()))

ans = 0
for left in range(K + 1):
    for right in range(K + 1):
        if left + right > K or left + right > N:
            break

        diff = K - left - right
        takes = V[:left] + V[N - right:]
        takes.sort(reverse=True)

        while diff > 0 and takes and takes[-1] < 0:
            takes.pop()
            diff -= 1

        ans = max(ans, sum(takes))

print(ans)

Measured memory_bytes: 3064
n, m = map(int, input().split())
dat_x = list(map(int, input().split()))

dat_x.sort()
dat_x = list(map(lambda x: x + (1-dat_x[0]), dat_x))

if m == 1:
    print(0)
elif(n == m):
    print(0)
else:
    distance = [0] * (m)
    for i in range(m - 1):
        distance[i] = dat_x[i+1] - dat_x[i]
    distance.sort(reverse=True)
    distance = distance[n - 1:]
    print(sum(distance))

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int h, w;
  cin >> h >> w;
  vector<string> grid(h);
  for (int i = 0; i < h; i++) {
    cin >> grid[i];
  }
  vector<vector<int>> dist(h, vector<int>(w, -1));
  vector<pair<int, int>> que;
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (grid[i][j] == '#') {
        que.emplace_back(i, j);
        dist[i][j] = 0;
      }
    }
  }
  for (int b = 0; b < (int) que.size(); b++) {
    for (int dx = -1; dx <= 1; dx++) {
      for (int dy = -1; dy <= 1; dy++) {
        if (dx * dx + dy * dy == 1) {
          int xk = que[b].first + dx;
          int yk = que[b].second + dy;
          if (xk >= 0 && yk >= 0 && xk < h && yk < w && dist[xk][yk] == -1) {
            que.emplace_back(xk, yk);
            dist[xk][yk] = dist[que[b].first][que[b].second] + 1;
          }
        }
      }
    }
  }
  cout << dist[que.back().first][que.back().second] << '\n';
  // last point in queue will be at farthest distance from any '#'
  return 0;
}


Measured memory_bytes: 15468
#include<bits/stdc++.h> 
using namespace std;
int A,B,C;
int main()
{
    //freopen(".in","r",stdin);
    //freopen(".out","w",stdout); 
    cin>>A>>B>>C;
    int y=min(A,B+C);
    int u=y-B;
    int o=C-u;
    cout<<o;
    return 0;   
}

Measured memory_bytes: 256
f = lambda x, y, z: (x + y + z) ** 2 - x * y - y * z - z * x - 1

n = int(input())
a = [0] * n
z = 1
while f(1, 1, z) < n:
  y = 1
  while f(1, y, z) < n:
    x = 1
    while f(x, y, z) < n:
      a[f(x, y, z)] += 1
      x += 1
    y += 1
  z += 1
print(*a, sep='\n')


Measured memory_bytes: 9384
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vdo=vector<double>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vvdo=vector<vector<double>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using pqin=priority_queue<int>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define _GLIBCXX_DEBUG
int main()
{
    int n;
    cin>>n;
    string s;
    cin>>s;
    int allr=0;
    int allg=0;
    int allb=0;
    rep(i,n){
        if(s[i]=='R')allr++;
        else if(s[i]=='G')allg++;
        else if(s[i]=='B')allb++;
    }
    ll sum=0;
    if(n>3){
        int partri=0;
        int partgi=0;
        int partbi=0;
        rep(i,n-2){
            if(s[i]=='R')partri++;
            else if(s[i]=='G')partgi++;
            else if(s[i]=='B')partbi++;
            int partrj=0;
            int partgj=0;
            int partbj=0;
            rep2(j,i+1,n-1){
                if(s[j]=='R')partrj++;
                else if(s[j]=='G')partgj++;
                else if(s[j]=='B')partbj++;
                if(s[i]!=s[j]){
                    if((s[i]=='R'&&s[j]=='G')||(s[i]=='G'&&s[j]=='R')){
                        if(s[2*j-i]=='B')sum+=(ll)(allb-partbi-partbj-1);
                        else sum+=(ll)(allb-partbi-partbj);
                    }
                    if((s[i]=='R'&&s[j]=='B')||(s[i]=='B'&&s[j]=='R')){
                        if(s[2*j-i]=='G')sum+=(ll)(allg-partgi-partgj-1);
                        else sum+=(ll)(allg-partgi-partgj);
                    }
                    if((s[i]=='B'&&s[j]=='G')||(s[i]=='G'&&s[j]=='B')){
                        if(s[2*j-i]=='R')sum+=(ll)(allr-partri-partrj-1);
                        else sum+=(ll)(allr-partri-partrj);
                    }
                }
            }
        }
    }
    cout<<sum<<endl;
}

Measured memory_bytes: 3640
#include<iostream>
#include<string>
#include<vector>
#include<numeric>
#include<math.h>
#include<algorithm>
#include<iomanip>
#include<list>
#include<bitset>
using namespace std;

int main() {

	int L, R;
	int d;
	cin >> L >> R >> d;

	int ans = 0;

	for (int i = L; i <= R; i++) {
		if (i % d == 0) {
			ans += 1;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3632
program name
    use,intrinsic :: iso_fortran_env
    implicit none
    integer(int64):: a,b,n
    read*, a,b,n
    ! print'(i0)', min(n,(b-1))
    print'(i0)', (a*min(n,(b-1)))/b - a*(min(n,(b-1))/b)

    
end program name

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

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

    map<int, int> m;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        m[a]++;
        m[a + 1]++;
        m[a - 1]++;
    }

    int ans = 0;
    for (auto& x : m) ans = max(ans, x.second);
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 4736
#include<stdio.h>
#include<math.h>
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<complex>

#define rep(i,n) for(int i=0; i<n; i++)
#define rep1(i,n) for(int i = 1; i<n+1; i++)
typedef long long ll;

using namespace std;
const int V = 100005;
int INF = 1000000000;

int x,y;
int n;
int a[1000];

int main(){
  cin >> n;
  int cnt = 0;
  rep(i,n) cin >> a[i];

  rep(i,n){
    int m = 10000;
    int pos = 0;
    for(int j = i; j < n; j++) {
      if (m > a[j]){
        pos = j;
        m = a[j];
      }
    }
    if(i!=pos) cnt++;
    a[pos] = a[i];
    a[i] = m;
  }


  rep(i,n){
    cout << a[i];
    if (i == n-1) break;
    cout << ' ';
  }
  cout << endl;
  cout << cnt << endl;
}



Measured memory_bytes: 3092
#include<stdio.h>
#include<iostream>
using namespace std;

int N;
int main (){
    cin >> N;
    int col = 10000;
    int cnt = 0;
    for(int i=0; i<N; i++){
        int cur;
        cin >> cur;
        if( cur == col ) {
            cnt++;
            col = 10000;
        } else {
            col = cur;
        }
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
#include<cmath>
#include<iostream>
using namespace std;
int main(){
    int a,v,b,w,t;
    cin >> a >> v >> b >> w >> t;

    int s, d;
    d = abs(a - b);
    s = abs(w - v);

    if(w >= v) cout << "NO" << endl;
    else if(d <= (long long)s * t) cout << "YES" << endl;
    else cout << "NO" << endl;
}



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

int main() {
  int n;
  cin >> n;
  string S[51];
  for (int i = 0; i < n; i++) cin >> S[i];
  
  int INF = 1e5;
  vector<int> A(26);
  for (char c = 'a'; c <= 'z'; c++) {
    int cnt = 100000;
    for (int i = 0; i < n; i++) {
      int tmp = 0;
      for (int j = 0; j < S[i].length(); j++) {
        if (S[i][j] == c) tmp++;
      }
      cnt = min(tmp, cnt);
    }
    int k = c - 'a';
    A[k] = cnt;
  }
  
  string ans = "";
  for (int i = 0; i < 26; i++) {  
    int c = 'a' + i;
    for (int j = 0; j < A[i]; j++) {
      ans += c;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define in(x) cin >> x
#define out(str) cout << str << endl

#define mod 1000000007

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int N;

long long gcd(long long x, long long y){
	return y==0 ? x:gcd(y,x % y);
}
long long lcm(long long x, long long y){
    return x/gcd(x,y)*y;
}

int main(){
    cin>>N;
    long long T[N],ans=1;
    rep(i,N){
        cin>>T[i];
        ans=lcm(ans,T[i]);
    }
    printf("%llu\n",ans);
}

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

int main(){
	int H, N, A;
	scanf("%d%d", &H, &N);
	while(N--){
		scanf("%d", &A);
		H -= A;
	}
	if(H <= 0){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}
	return 0;
}

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

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


Measured memory_bytes: 512
//#pragma warning(disable:4996)
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>
#include <complex>
#include <cstdio>
#include <list>
#include <bitset>
//#include <stdio.h>

//< in.txt > out.txt
using namespace std;
//std::ios::sync_with_stdio(false);
//std::cin.tie(0);
const long long MOD = 1e9 + 7;
const long long INF = 1e15;
typedef long long LL;
typedef long double LD;
//typedef boost::multiprecision::cpp_int bigint;
typedef pair<LL, LL> PLL;
typedef pair<int, int> PI;
typedef pair<LD, LL> pdl;
typedef pair<LD, LD> pdd;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef unsigned long long ULL;

LL S(LL N) {
	LL ans = 0;
	while (N > 0) {
		ans += N % 10;
		N /= 10;
	}
	return ans;
}

//n/S(n) <=m/S(m) -> true
bool comp(LL n, LL m) {
	return (m * S(n) - n * S(m) >= 0);
}

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	int K;
	cin >> K;
	VLL snukes;
	for (int n = 1; n <= 9; n++)snukes.push_back(n);
	for (int n = 19; n <= 100; n += 10)snukes.push_back(n);
	LL ten = 1;
	LL nine = 0;
	for (int n = 0; n < 14; n++) {
		for (int a = 100; a <= 999; a++) {
			bool flag = true;
			for (int b = a + 1; b <= 999; b++) {
				if (!comp(ten * a + nine, ten * b + nine)) {
					flag = false;
					break;
				}
			}
			if (flag)snukes.push_back(ten * a + nine);
		}
		ten *= 10;
		nine = nine * 10 + 9;
	}
	for (int n = 0; n < K; n++) {
		cout << snukes[n] << "\n";
	}
	return 0;
}


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

#define rep(i,s,n) for (int i = (int)s; i < (int)n; i++)
#define ll long long
#define ld long double
#define pb push_back
#define eb emplace_back
#define All(x) x.begin(), x.end()
#define Range(x, i, j) x.begin() + i, x.begin() + j
#define lbidx(x, y) lower_bound(x.begin(), x.end(), y) - x.begin()
#define ubidx(x, y) upper_bound(x.begin(), x.end(), y) - x.begin()
#define llbidx(x, y, z) lower_bound(x.begin(), x.end(), z) - lower_bound(x.begin(), x.end(), y) // 二要素間の距離
#define deg2rad(deg) ((((double)deg)/((double)360)*2*M_PI))
#define rad2deg(rad) ((((double)rad)/(double)2/M_PI)*(double)360)
#define Find(set, element) set.find(element) != set.end()
#define Decimal(x) printf("%.10f\n", x) // 小数点を10桁まで表示
// debug用
#define PrintVec(x) for (auto elementPrintVec: x) { cout << elementPrintVec << " "; } cout << "\n";
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define endl "\n"
// gcj print用
#define Case(x) printf("Case #%d: ", x);

typedef pair<int, int> PI;
typedef pair<ll, ll> PLL;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<int>>> vvvl;
typedef vector<PI> vpi;
typedef vector<vector<PI>> vvpi;
typedef vector<vector<vector<PI>>> vvvpi;
typedef vector<PLL> vpl;
typedef vector<vector<PLL>> vvpl;
typedef vector<vector<vector<PLL>>> vvvpl;

int POWINT(int x, int n) {
  int ret = 1;
  while (n > 0) {
    if (n & 1) ret *= x;
    x *= x;
    n >>= 1;
  }
  return ret;
};

ll POWLL(ll x, int n) {
  ll ret = 1;
  while (n > 0) {
    if (n & 1) ret *= x;
    x *= x;
    n >>= 1;
  }
  return ret;
};

template<class T>
inline bool chmax(T &a, T b) {
  if(a < b) {
    a = b;
    return true;
  }
  return false;
};

template<class T>
inline bool chmin(T &a, T b) {
  if(a > b) {
    a = b;
    return true;
  }
  return false;
};

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

  int N; cin >> N;
  vi ans(N, 0);
  int a;
  rep(i, 0, N-1) {
    cin >> a; a--;
    ans[a]++;
  }

  rep(i, 0, N) {
    cout << ans[i] << endl;
  }



  return 0;
};


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

using namespace std;

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

#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

#define CHMIN(a, b) a=min((a), (b))
#define CHMAX(a, b) a=max((a), (b))

const ll MOD=1000000007ll;
// const ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int dp[20][114];

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int d, g, p[20], c[20];
	cin>>d>>g;
	REP(i, d){
		cin>>p[i]>>c[i];
	}
	REP(i, d){
		REP(j, p[i]-1){
			dp[i][j]=100*(i+1)*(j+1);
		}
		dp[i][p[i]-1]=100*(i+1)*(p[i])+c[i];
	}
	int m[20];
	REP(i, d){
		m[i]=dp[i][p[i]-1];
	}
	int ans=114514;
	REP(i, 1<<d){
		int tmp1=0, tmp2=-1, tmpg=g;
		REP(j, d){
			if(i & (1<<j)){
				tmpg-=m[j];
				tmp1+=p[j];
			}
			else{
				tmp2=j;
			}
		}
		if(tmpg>0 && tmp2!=-1){
			REP(j, p[tmp2]){
				if(dp[tmp2][j]>=tmpg){
					tmp1+=j+1;
					tmpg-=dp[tmp2][j];
					break;
				}
			}
		}
		if(tmpg<=0){
			ans=min(ans, tmp1);
		}
	}
	cout<<ans<<'\n';
	return 0;
}


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

using namespace std;

int a[300000];
int b[300000];

int main(){
	
	int n;
	
	cin >> n;
	
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	
	for(int i = 0; n - 1 - i * 2 >= 0; i++){
		b[i] = a[n - 1 - i * 2];
	}
	for(int i = (n + 1) / 2; i < n; i++){
		b[i] = a[(i - (n + 1) / 2) * 2 + n % 2];
	}
	
	for(int i = 0; i < n; i++){
		cout << b[i];
		if(i != n - 1){
			cout << " ";
		}
	}
	cout << endl;
	
	return 0;
}


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

vector<int> par(100000);

void init(int n){
  for(int i=0; i<n; i++){
    par.at(i) = i;
  }
}
int root(int x){
  if(par.at(x) == x){
    return x;
  }
  else{
    return par.at(x) = root(par.at(x));
  }
}
bool same(int x, int y){
  return root(x) == root(y);
}
void unite(int x, int y){
  x = root(x);
  y = root(y);
  if(x == y){
    return;
  }
  par.at(x) = y;
}

int main(){
  int N, M;
  cin >> N >> M;
  vector<int> vec(N);
  for(int i=0; i<N; i++){
    cin >> vec.at(i);
    vec.at(i)--;
  }
  
  vector<pair<int,int>> shift(M);
  pair<int,int> P;
  for(int i=0; i<M; i++){
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    P = make_pair(min(a,b),max(a,b));
    shift.at(i) = P;
  }
  sort(shift.begin(),shift.end());
  
  init(N);
  for(int i=0; i<M; i++){
    P = shift.at(i);
    unite(P.first,P.second);
  }
  
  for(int i=0; i<N; i++){
    par.at(i) = root(i);
  }
  
  int cnt = 0;
  for(int i=0; i<N; i++){
    if(same(vec.at(i),i)){
      cnt++;
    }
  }
  
  cout << cnt << endl;
  
}    

Measured memory_bytes: 1792
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
#define ROF(i,a,b) for(int i=a;i>=b;i--)
#define per(i,a) ROF(i,a,0)
#define pb push_back
using namespace std;
using ll=long long;
using ld=long double;
using ch=char;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vP;
typedef vector<ch> vc;
typedef vector<vc> vvc;
const ll MOD=1000000007;
const ll MOD2=998244353;
const ld PI=acos(-1);
const ll INF=1e18;
struct edge{ll to,cost;};
struct edge2{ll from,to,cost;};

template <typename T>
bool chmax(T &a, const T& b) {
    if (a < b) {
      a = b;
        return true;
    }
    return false;
}

template <typename T>
bool chmin(T &a, const T& b) {
    if (a > b) {
      a = b;
      return true;
    }
    return false;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N;
    cin >> N;
    vl L(N);
    rep(i,N){
        cin >> L[i];
    }
    ll ans=0;
    rep(i,N-2){
        FOR(j,i+1,N-1){
            FOR(k,j+1,N){
                if(L[i]==L[j]||L[j]==L[k]||L[k]==L[i])continue;
                if(L[k]+L[i]+L[j]>2*max({L[k],L[i],L[j]})&&max({L[k],L[i],L[j]})){
                    ans++;
                }
            }
        }
    }
    cout << ans << endl;
}
/*
overflow checked?
corner case checked?
boundary checked?
not TLE in worst case checked?
*/

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

int main() {
 
  int N,X ;
  cin >> N ;
  int x=0 ;
  X = N;
  
  for (int i=0; i<8; i++) {
    x = X%10 + x;
      X = X/10;
  }
  
  if(N%x == 0){
    cout << "Yes" << endl;
  }
  
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
import heapq
N,M = map(int,input().split())
prices = list(map(int,input().split()))
for i in range(len(prices)):
  prices[i] *= -1

heapq.heapify(prices)
for i in range(M):
  temp = heapq.heappop(prices)
  temp *= -1
  temp //= 2
  temp *= -1
  heapq.heappush(prices,temp)

print(sum(prices)*-1)

Measured memory_bytes: 14180
#include<cstdio>
#include<algorithm>
using namespace std;
int main(){
	int n;
	int ans = 1000000000;
	int a[100];
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",a+i);
	}
	for(int i=-100;i<=100;i++){
		int sum = 0;
		for(int j=0;j<n;j++){
			sum += (i-a[j])*(i-a[j]);
		}
		ans = min(ans,sum);
	}
	printf("%d\n",ans);
	return 0;
}


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

int n;
string s, t;

int main(){
  cin >> n >> s >> t;
  int ans = n * 2;
  for(int i = 0; i < n; i++){
    bool flag = true;
    for(int j = 0; j < n - i; j++){
      //cerr << s.at(i + j) <<" "<< t.at(j)<<endl;
      if(s.at(i + j) != t.at(j)){
        flag = false;
        cerr << endl;
        break;
      }
    }
    if(flag){
      ans -= n - i;
      break;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define X first
#define Y second
#define pb push_back
#define mp make_pair

const int maxn = 1e5 + 100 , maxc = 115, mod = 1e9 + 7, inf = 1e9+10;

ll n, a, b;

int32_t main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n >> a >> b;
	cout << min (b, a * n) << endl;
	return 0;
}

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

int main()
{int N, K;
 cin >> N >> K;
 string s[200];
 for(int i=0; i<N; i++){
   cin >> s[i];}
 int X[8]={-1, 0, 1, -1, 1, -1, 0, 1};
 int Y[8]={1, 1, 1, 0, 0, -1, -1, -1};
 for(int i=0; i<N; i++){
     for(int j=0; j<K; j++){
       if(s[i][j]=='#') continue;
       else{
         int count = 0;
         for(int d=0; d<8; d++){
         const int ni = i + X[d];
         const int nj = j + Y[d];
         if(ni<0 || ni == N || nj < 0 || nj == K){
           continue;}
           if (s[ni][nj]=='#'){
           count ++;}}
         s[i][j]= '0' + count;

       }
     }
 }
    for(int i=0; i<N; i++){
       cout << s[i] << endl;
     }
    
 }
         

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

long long N, M;
vector<long long> A;
priority_queue<pair<long long, long long> >BC;

int main(){
	cin >> N >> M;
	for(long long i = 0; i < N; i++){
		long long tmp;
		cin >> tmp;
		A.push_back(tmp);
	}
	sort(A.begin(), A.end());

	for(long long i = 0; i < M; i++){
		long long b, c;
		cin >> b >> c;
		BC.push(make_pair(c,b));
	}

	long long count = 0;
	for(long long i = 0; i < N; i++) {
		long long target = A[i];
		if(!BC.empty() && BC.top().first > target){
			pair<long long, long long> tmp = BC.top();
			BC.pop();
			count += tmp.first;
			tmp.second--;
			if(tmp.second > 0){
				BC.push(tmp);
			}
		}else{
			count += target;
		}
	}
	cout << count << endl;
}



Measured memory_bytes: 3188
//
//  main.cpp
//  3
//
//  Created by RISHAV SINGH MEHTA on 19/01/20.
//  Copyright © 2020 RISHAV SINGH MEHTA. All rights reserved.
//

#include <iostream>
#include <vector>
#include <algorithm>
#define ll long long
using namespace std;
int main(int argc, const char * argv[]) {
    // insert code here...
    ll int T,N,i,j,k,l,a,b,c;
    cin>>N;
    vector< pair<ll int, ll int> > v;
    vector<ll int > g,h;
    for (i=0; i<N; i++) {
        cin>>a;
        g.push_back(a);
        //v.push_back({a,i});
    }
    //sort(v.begin(), v.end(), greater<>());
    //h.push_back(g[0]);
    ll int ans=1;c=g[0];
    for (i=1; i<N; i++) {
       
        if (g[i]<c) {
            ans=ans+1;
        }
        c=min(c, g[i] );
        
    
    }
    
    cout<<ans<<endl;
    return 0;
}


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

int main (){
  int n;
  vector <int> x(100);
  
  cin >> n;
  for(int i=0; i<n;i++){
    cin >> x.at(i);
  }
  int min=1000000;
  
  for(int p=1; p<=100; p++){
    int sum=0;
    for(int i=0;i<n;i++){
      sum += (x.at(i)-p)*(x.at(i)-p);
    }
    if(sum<min)
      min = sum;
  }
  
  cout << min << endl;
  
  return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var S string
	var r int
	fmt.Scan(&S)
	for i := 1; i < len(S); i++ {
		w := (len(S) - i) / 2
		if S[:w] == S[w:len(S)-i] {
			r = len(S) - i
			break
		}
	}
	fmt.Println(r)
}

Measured memory_bytes: 512
#include <iostream>

using namespace std;

int main()
{
   long H,N;
   cin >> H >> N;
   long A[N],sum=0;
   for(int i=0;i<N;i++){
       cin >> A[i];
       sum+=A[i];
   }
   if(sum>=H){
       printf("Yes");
   }
   else {
       printf("No");
   }
   return 0;
}

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

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

vector<int> a(3);
int main() {
    rep(i,3) cin >> a[i];
    sort(all(a));
    if (a.at(0) == 5 && a.at(1) == 5 && a.at(2) == 7) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}

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

typedef long long ll;
typedef long double ld;

#define pb push_back
#define sort(s) sort(s.begin(),s.end())
#define reverse(s) reverse(s.begin(),s.end())
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)

const ll mod = 1e9+7;

//最大公約数
ll gcd(ll a, ll b) {
    return b ? gcd(b, a%b) : a;
}

//最小公倍数
ll lcm(ll a, ll b) {
    return a / gcd(a, b) * b;
}

//素数判定
bool isPrime(ll x){
    ll i;
    if(x < 2)return 0;
    else if(x == 2) return 1;
    if(x%2 == 0) return 0;
    for(i = 3; i*i <= x; i += 2) if(x%i == 0) return 0;
    return 1;
}

//桁和
int digsum(ll n) {
    int res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

//桁数
int dignum(ll n) {
    int res = 0;
    while(n > 0) {
        res++;
        n /= 10;
    }
    return res;
}

//文字列中の特定の文字カウント
ll stringcount(string s,char c){
    return count(s.cbegin(),s.cend(),c);
}

//階乗
ll ka(ll i){
    ll res=1;
    while(i>0){
        res=res*i;
        i--;
    }
    return res;
}
 
//ncr
ll ncr(ll x,ll y){
    ll a = x;
    ll b = 1;
    if(y>(x/2)){
        y=x-y;
    }
    for(ll i=1;i<y;i++){
        a*=x-i;
        b*=i+1;
    }
    return a/b;
}

//フィボナッチ数列 -92
ll f(ll x){
    ll dp[x+1];
    dp[1]=1;
    dp[2]=1;
    for(ll i=3;i<=x;i++){
        dp[i]=dp[i-1]+dp[i-2];
    }
    return dp[x];
}



int main(){
    string s;
    cin >> s;
    bool check[26];
    rep(i,26)check[i]=false;

    for(int i=0;i<s.size();i++){
        check[s[i]-'a'] = true;
    }

    for(int i=0;i<26;i++){
        if(!check[i]){
            cout << char('a'+i) << endl;
            return 0;
        }
    }

    cout << "None" << endl;
}

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

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

   int r=0;
   rep(i,n){
      if(c[i]=='R') r++;
   }

   int ans=0;
   rep(i,r){
      if(c[i]=='W') ans++;
   }
   cout<<ans<<endl;
}

Measured memory_bytes: 3716
N=int(input())
h=[0]+list(map(int,input().split()))
dp=[0]*(N+1)

dp[1]=0
dp[2]=abs(h[2]-h[1])

if N>=3:
  for i in range(3,N+1):
    dp[i]= min( dp[i-2]+abs(h[i]-h[i-2]), dp[i-1]+abs(h[i]-h[i-1]))
  
print(dp[-1])

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

int main(){
    int d,g;
    cin >> d >> g;
    vector<pair<int,int>> pro(d);
    for(int i = 0; i < d; i++){
        int a,b;
        cin >> a >> b;
        pro[i] = {a,b};
    }    
    map<int,bool> memo;
    int ans = mod;
    for(int bit = 0; bit < (1<<d); bit++){
        memo.clear();
        int can = 0;
        int cnt = 0;
        for(int i = 0; i < d; i++){
            if(bit & (1<<i)) memo[i] = true;
        }
        for(int i = 0; i < d; i++){
            if(memo[i]){
                can += pro[i].second;
                can += (i+1)*100*pro[i].first;
                cnt += pro[i].first;
            }
        }
        if(can >= g){
            ans = min(ans,cnt);
            continue;
        }
        for(int i = d-1; i >= 0; i--){
            if(!memo[i]){
                for(int j = 0; j < pro[i].first; j++){
                    can += (i+1)*100;
                    cnt++;
                    if(can >= g){
                        ans = min(ans,cnt);
                    }
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
x=[]
y=[]
for i in range(28):
    n=int(input())
    x.append(n)
#print(x)

for j in range(1,31):
    y.append(j)
#print(y)

z=set(x)^set(y)

print(list(z)[0])
print(list(z)[1])



Measured memory_bytes: 5600
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll=long long;
int main(){
    string s1,s2;
    cin>>s1>>s2;
    int n1=s1.length(),n2=s2.length();
    if(n1>n2){
        cout<<"GREATER"<<endl;
        return 0;
    }
    else if(n1<n2){
        cout<<"LESS"<<endl;
        return 0;
    }
    else{
        rep(i,n1){
            if(s1[i]-'0'>s2[i]-'0'){
                cout<<"GREATER"<<endl;
                return 0;
            }
            else if(s1[i]-'0'<s2[i]-'0'){
                cout<<"LESS"<<endl;
                return 0;
            }
        }
    }
    cout<<"EQUAL"<<endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
#define rep(i, n) for (int i=0; i<(int) (n);i++)
using ll = long long;
using P = pair<int, int>;

void solve_1() {
	int a, b;
	cin >> a >> b;
	int total;
	int n = 0;
	while (!((a-1)*n + 1 >= b)) {
		n++;
	}
	cout << n << endl;

}

void solve_2() {

}

void solve_3() {

}

void solve_4() {

}

void solve_5() {

}

void solve_6() {

}

int main() {
	solve_1();
	//solve_2();
	//solve_3();
	//solve_4();
	//solve_5();
	//solve_6();
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cmath>
using namespace std;
int main(){
    int n;
    cin >> n;
    int a[100000+3];
    long long ans=0;
    int negative=0;
    bool zero=false;
    int absmin=1000000000+2;
    for(int i=0;i<n;i++){
        cin >>a[i];
        absmin=min(absmin,abs(a[i]));
        if(a[i] <0){
            negative++;
        }else if(a[i]==0){
            zero=true;
        }
        ans+=abs(a[i]);
    }

    if(zero==false and negative%2==1){
        ans-=(absmin*2);
    }
    cout<<ans;

}

Measured memory_bytes: 640
#include <iostream>

int main()
{
  int N, M;
  std::cin >> N >> M;
  
  int bunboN = N * (N - 1);
  int bunboM = M * (M - 1);
  
  std::cout << (bunboN / 2) + (bunboM / 2);
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    vector<int> a(10000);
    for (int i = 0; i < 10000; i++)
        cin >> a.at(i);
    for (int i = 0; i < 10000; i++){
        if (a.at(i) == 0)
            break;
        cout << "Case " << i + 1 << ": " << a.at(i) << endl;
    }
}



Measured memory_bytes: 3120
#include <iostream>
#include <cstdio>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <cstring>
#include <functional>
#include <cmath>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define rep1(i,n) for(int i=1;i<=(n);++i)
#define all(c) (c).begin(),(c).end()
#define fs first
#define sc second
#define pb push_back
#define show(x) cout << #x << " " << x << endl
#define MX 300
typedef long long ll;
ll sum[MX][MX];
bool visited[MX][MX];
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
void dfs(int x,int y){
	visited[x][y]=true;
	rep(i,4){
		int nx=x+dx[i],ny=y+dy[i];
		if(0<=nx&&nx<MX&0<=ny&&ny<MX&&!visited[nx][ny]&&sum[x][y]==sum[nx][ny]) dfs(nx,ny);
	}
}
int main(){
	while(true){
		int n,l[50],r[50],t[50],b[50];
		vector<int> hs,ws;
		cin>>n;
		if(n==0) break;
		rep(i,n){
			cin>>l[i]>>t[i]>>r[i]>>b[i];
			hs.pb(t[i]-1);
			hs.pb(t[i]);
			hs.pb(t[i]+1);
			hs.pb(b[i]-1);
			hs.pb(b[i]);
			hs.pb(b[i]+1);
			ws.pb(l[i]-1);
			ws.pb(l[i]);
			ws.pb(l[i]+1);
			ws.pb(r[i]-1);
			ws.pb(r[i]);
			ws.pb(r[i]+1);
		}
		sort(all(hs));
		sort(all(ws));
		hs.erase(unique(all(hs)),hs.end());
		ws.erase(unique(all(ws)),ws.end());
		rep(i,n){
			l[i]=lower_bound(all(ws),l[i])-ws.begin();
			r[i]=lower_bound(all(ws),r[i])-ws.begin();
			t[i]=lower_bound(all(hs),t[i])-hs.begin();
			b[i]=lower_bound(all(hs),b[i])-hs.begin();
		}
		rep(i,MX) rep(j,MX) sum[i][j]=0;
		ll p=1;
		rep(i,n){
			for(int x=l[i];x<r[i];x++) for(int y=b[i];y<t[i];y++) sum[x][y]+=p;
			p*=2;
		}
		rep(i,MX) rep(j,MX) visited[i][j]=false;
		int cnt=0;
		rep(i,MX) rep(j,MX){
			if(!visited[i][j]) cnt++,dfs(i,j);
		}
		cout<<cnt<<endl;
	}
}

Measured memory_bytes: 6232
n = int(input())
an = list(map(int, input().split(' ')))
bn = list(map(int, input().split(' ')))
cn = list(map(int, input().split(' ')))

an = sorted(an)
bn = sorted(bn)
cn = sorted(cn)

bcount = [0] * n
ccount = [0] * n

ai = 0
for bi in range(n):
    while ai < n and bn[bi] > an[ai]:
        bcount[bi] += 1
        ai += 1
    if bi < len(bn) - 1:
        bcount[bi + 1] = bcount[bi]

bi = 0
for ci in range(n):
    while bi < n and cn[ci] > bn[bi]:
        ccount[ci] += bcount[bi]
        bi += 1
    if ci < len(cn) - 1:
        ccount[ci + 1] = ccount[ci]
        
print(sum(ccount))



Measured memory_bytes: 109276
#include<iostream>
#include<algorithm>
using namespace std;
#define INF (1<<29)
  
int coin[]={1,5,10,50,100,500};

int main(){
	int p;
	while(cin>>p&&p){
		int n[6];
		int ans=INF;
		for(int i=0;i<6;i++){
			cin>>n[i];
		}
		for(int over=0;over<500;over++){
			int cnt=0;
			int m=p+over;
			for(int i=5;i>=0;i--){
				cnt+=min(n[i],m/coin[i]);
				m-=coin[i]*min(n[i],m/coin[i]);
			}
			if(m)continue;
			m=over;
			for(int i=5;i>=0;i--){
				cnt+=m/coin[i];
				m%=coin[i];
			}
			ans=min(ans,cnt);
		}
		cout<<ans<<endl;
	}
    return 0;
}

Measured memory_bytes: 1160