akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define nl "\n"
#define rep(i,n) for(ll i=0; i<(n); i++)
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
#define F first
#define S second
#define sortup(V) sort(V.begin(), V.end())


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

    // solution comes here
    ll N, M;
    cin >> N >> M;

    vp v(N);//pair(A円, B本)
    rep(i, N) cin >> v[i].F >> v[i].S;

    sortup(v);

    ll ans=0, m=0;
    for(ll i=0; m<M; i++) {
        if(m + v[i].S < M) {
            m += v[i].S;
            ans += v[i].F * v[i].S;
        }
        else {
            ans += v[i].F *(M-m);
            break;
        }
    }

    cout << ans << nl;
}

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

#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define pf printf
#define sc scanf
#define sf(num) scanf("%d",&num)
#define sff(num1,num2) scanf("%d %d",&num1,&num2)
#define sfff(num1,num2,num3) scanf("%d %d %d",&num1,&num2,&num3)
#define sl(num) scanf("%lld",&num)
#define sll(num1,num2) scanf("%lld %lld",&num1,&num2)
#define slll(num1,num2,num3) scanf("%lld %lld %lld",&num1,&num2,&num3)
#define rep(i,n) for(i=1;i<=n;i++)
#define rep0(i,n) for(i=0;i<n;i++)
#define reps(i,a,n) for(i=a;i<=n;i++)
#define pb push_back
#define mpp make_pair
#define MOD 1000000007
#define fi first
#define se second
#define N 100005
#define mem(ara,n) memset(ara,n,sizeof(ara))
#define memb(ara) memset(ara,false,sizeof(ara))
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define pi pair<int,int>
#define pii pair<pair<int,int>,pair<int,int> >
#define db(x) cout<<#x<<" :: "<<x<<"\n";
#define dbb(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define fr freopen("input.txt","r",stdin);
#define fw freopen("output.txt","w",stdout);
#define TIME cerr<<"Time : "<<(double)clock()/(double)CLOCKS_PER_SEC<<"s\n";
typedef long long int ll;
using namespace std;
int main()
{
    int i,n;
    sf(n);
    double k,sum=0;
    rep0(i,n)
    {
        cin>>k;
        sum+=(1.0/k);
    }
    cout<<fixed<<setprecision(10)<<double(1.0/sum);
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Math;
using static System.Console;
using System.Text;

class Program
{
    static void Main(string[] args)
    {
        solve();
    }
    static Scanner cin;

    static int A, B, C, X, Y;
    static void input()
    {
        cin = new Scanner();
        A = cin.nextInt();
        B = cin.nextInt();
        C = cin.nextInt();
        X = cin.nextInt();
        Y = cin.nextInt();
    }
    static void solve()
    {
        input();
        int sum = A * X + B * Y;
        if (X > Y)
            sum = Min(sum, A * (X - Y) + 2 * C * Y);
        else
            sum = Min(sum, 2 * C * X + B * (Y - X));

        sum = Min(sum, 2 * C * Max(X, Y));
        WriteLine(sum);

    }
    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }
        
        public string next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return next();
            i = 0;
            return s[i++];
        }

        public int nextInt()
        {
            return int.Parse(next());
        }

        public int[] ArrayInt(int N, int add = 0)
        {
            int[] Array = new int[N];
            for(int i = 0; i < N; i++)
            {
                Array[i] = nextInt() + add;
            }
            return Array;
        }

        public long nextLong()
        {
            return long.Parse(next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for(int i = 0; i < N; i++)
            {
                Array[i] = nextLong() + add;
            }
            return Array;
        }

        public double nextDouble()
        {
            return double.Parse(next());
        }

        public double[] ArrayDounble(int N, int add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextDouble() + add;
            }
            return Array;
        }
    }
}

Measured memory_bytes: 11220
#include <bits/stdc++.h>
using namespace std;
 
int main(void) {
  long long result;
  long long x, y;
  
  cin >> x >> y;
  if(x==1 || y==1){
    result = 1;
  }
  else{
    result = ((x * y) + 1) / 2;
  }
  cout << result << endl;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include <bits/stdc++.h>
#include <vector>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define int         long long
#define ll          long long
#define ld	    long double
#define pb          push_back
#define pp	    pop_back()
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define vii         vector<pii>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define mp          make_pair
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),a.rend()
#define F           first
#define S           second
#define sz(x)       (ll)x.size()
#define endl        '\n'
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define repj(j,a,b) for(ll j=a;j<b;j++)
#define lexistr(x,y)      lexicographical_compare(x.begin(),x.end(),y.begin(),y.end())
#define IOS	    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

typedef tree<ll,null_type,less<ll>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;

//CONSTANTS----------------------------------
#define PI 	    3.141592653589793238462643
const ll hell=1000000007;
const ll mod=1000000007;
//function-----------------------------------
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*(b/GCD(a,b));
}
bool isPrime(ll n) {

    if (n <= 1) return false;
    if (n <= 3) return true;
    if (n % 2 == 0 || n % 3 == 0) return false;
    for (ll i = 5; i * i <= n; i = i + 6)
        if (n % i == 0 || n % (i + 2) == 0)
            return false;
    return true;
}
ll fact(ll n)
{
    ll f=1;
    for(ll i=2;i<=n;i++)
	f=f*i;
    return f;
}
ll power(ll a,ll b)
{
  if(b==0)return 1;
  if(b==1)return a;
  ll t=power(a,b/2);
  t%=hell;
  t*=t;
  t%=hell;
  if(b%2)return (t*a)%hell;
  else
     return t;
}
//CODE------------------------------------------
ll solve()
{
    ll n; cin>>n;
    vi v(n);
    ll avg=0;
    rep(i,0,n)
        cin>>v[i];
    ll ans = INT_MAX;
    rep(i,-100,101)
    {
        ll sum = 0;
        repj(j,0,n) {
            sum += (v[j]-i)*(v[j]-i);
        }
        ans = min(ans, sum);
    }
    cout<<ans;
    return 0;
}
//MAIN------------------------------------------
signed main(){
    IOS
    #ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
    #endif
    int t=1;
    //cin>>t;
    while(t--) {
        solve();
        cout<<endl;
    }
    return 0;
}


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

using namespace std;

void fun2(string a,string b,int n,int m)
{
    int dp[n+1][m+1];

    for(int i=0;i<n+1;i++)
    {
        for(int j=0;j<m+1;j++)
        {
            if(i==0||j==0)
                dp[i][j]=0;
        }
    }

    for(int i=1;i<n+1;i++)
    {
        for(int j=1;j<m+1;j++)
        {
            if(a[i-1]==b[j-1])
            {
                dp[i][j]=1+dp[i-1][j-1];
            }
            else
                dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
        }
    }

    vector<char>vec;

    int i=n,j=m;
    while(i&&j)
    {
        if(a[i-1]==b[j-1])
        {
            vec.push_back(a[i-1]);
            i--;
            j--;
        }
        else
        {
            if(dp[i][j-1]>dp[i-1][j])
                j--;
            else
                i--;
        }
    }

    for(int i=vec.size()-1;i>=0;i--)
        cout<<vec[i];

    cout<<"\n";
}

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

    string a,b;
    cin>>a>>b;

    fun2(a,b,a.size(),b.size());
    return 0;
}


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

int ctoi(const char c){
    if('0' <= c && c <= '9')
        return (c-'0');
    return -1;
}
 
int main(){
    string S;
    cin >> S;
    
    int l, X, min = 999;
    l = S.length();
    for(int i=2;i<l;i++){
        X = ctoi(S[i-2])*100 + ctoi(S[i-1])*10 + ctoi(S[i]);
        if(abs(X - 753) < min)
            min = abs(X - 753);
    }

    cout << min << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main {
	Scanner sc;
	
	private void calc() {
		sc = new Scanner(System.in);
		int H = sc.nextInt();
		int N = sc.nextInt();
		long s = 0;
		for (int i = 0; i < N; i++) {
			s += sc.nextInt();
		}
		System.out.println((s>=H)?"Yes":"No");
	}

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


Measured memory_bytes: 50304
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cassert>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <complex>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <iterator>

using namespace std;

#define dump(n) cout<<"# "<<#n<<'='<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define iter(c) __typeof__((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();++i)
#define all(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;
typedef pair<int,int> pii;

const int INFTY=1<<29;
const double EPS=1e-9;

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& a){
	os<<'[';
	rep(i,a.size()) os<<(i?" ":"")<<a[i];
	return os<<']';
}

struct Edge{
	int src,dst;
	Edge(){}
	Edge(int s,int d):src(s),dst(d){}
};
typedef vector<vector<Edge> > Graph;

bool Augment(const Graph& g,int u,vi& vis,vi& match)
{
	rep(i,g[u].size()){
		int v=g[u][i].dst;
		if(vis[v]) continue;
		vis[v]=1;
		if(match[v]==-1 || Augment(g,match[v],vis,match)){
			match[u]=v;
			match[v]=u;
			return true;
		}
	}
	return false;
}

int BipartiteMatching(const Graph& g,vi& match)
{
	int n=g.size();
	match.assign(n,-1);
	int res=0;
	rep(i,n) if(match[i]==-1){
		vi vis(n);
		res+=Augment(g,i,vis,match);
	}
	return res;
}

typedef complex<double> Point;

int main()
{
	for(int n,m;scanf("%d%d",&n,&m),n|m;){
		vector<Point> ts(n),bs(m);
		vd vs(n);
		rep(i,n){
			double x,y; cin>>x>>y>>vs[i];
			ts[i]=Point(x,y);
		}
		rep(i,m){
			double x,y; cin>>x>>y;
			bs[i]=Point(x,y);
		}
		
		vvd t(n,vd(m));
		rep(i,n) rep(j,m)
			t[i][j]=abs(bs[j]-ts[i])/vs[i];
		
		double lo=0,hi=20000;
		rep(_,50){
			double mi=(lo+hi)/2;
			Graph g(n+m);
			rep(i,n) rep(j,m) if(t[i][j]<mi){
				g[i].emplace_back(i,n+j);
				g[n+j].emplace_back(n+j,i);
			}
			vi match;
			if(BipartiteMatching(g,match)==m)
				hi=mi;
			else
				lo=mi;
		}
		printf("%.8f\n",lo);
	}
	
	return 0;
}

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

int main() {
    int N;
    ll K;
    cin >> N >> K;
    vector<int> A(N), seen(N, -1);
    rep(i, N) cin >> A[i];
    int index = 0;
    int c1 = 0;
    while (seen[index] == -1) {
        seen[index] = 1;
        index = A[index] - 1;
        c1++;
    }
    int c2 = 0;
    while (seen[index] == 1) {
        seen[index] = 2;
        index = A[index] - 1;
        c2++;
    }

    int town, num;
    if (K < c1) {
        num = K;
        town = 1;
    } else {
        num = (K-c1) % c2;
        town = index+1;
    }
    rep(j, num) {
        town = A[town-1];
    }
    cout << town << endl;
}

Measured memory_bytes: 4844
#include<iostream>
#include<cmath>
#include<string>
#include<string.h>

using namespace std;
int main()
{
    int n;
    cin >> n;
    char a[25];
    cin >> a;
    
    int cnt=0;
    for(int i=0;i<n;i++){
        char b[100];
        cin >> b;
        int cnt2=0;
        for(int j=0;j<strlen(b);j++){
            for(int k=1;j+(strlen(a)-1)*k<strlen(b);k++){
                char c[25];
                int m=j;
                for(int l=0;l<strlen(a);l++){
                    if(b[j+l*k]!=a[l]){
                        goto fail;
                    }
                }
                cnt++;
                goto nexti;
            fail:;
            }
        }
    nexti:;
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 3088
import java.io.*;
import java.util.*;
public class Main {

	public static void main(String[] args) throws Exception{
		// TODO Auto-generated method stub
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		String[] cmd=br.readLine().split(" ");
		int n=Integer.valueOf(cmd[0]);
		int a=Integer.valueOf(cmd[1]);
		int b=Integer.valueOf(cmd[2]);
		int c=Integer.valueOf(cmd[3]);
		String[] arr=new String[n];
		for(int i=0;i<n;i++)
		{
			arr[i]=br.readLine();
		}
		String[] ans=new String[n];
		int bool=0;
		for(int i=0;i<n;i++)
		{
			String g=arr[i];
			if(g.equals("AB"))
			{
				if(a>b)
				{
					a--;
					b++;
					ans[i]="B";
				}
				else if(a<b)
				{
					a++;
					b--;
					ans[i]="A";
				}
				else
				{
					if(i+1<n && arr[i+1].equals("AC"))
					{
						a++;
						b--;
						ans[i]="A";
					}
					else
					{
						a--;
						b++;
						ans[i]="B";
					}
				}
				if(a<0 || b<0)
				{
					bool=1;
					break;
				}
			}
			else if(g.equals("AC"))
			{
				if(a>c)
				{
					a--;
					c++;
					ans[i]="C";
				}
				else if(a<c)
				{
					a++;
					c--;
					ans[i]="A";
				}
				else
				{
					if(i+1<n && arr[i+1].equals("AB"))
					{
						a++;
						c--;
						ans[i]="A";
					}
					else
					{
						a--;
						c++;
						ans[i]="C";
					}
				}
				if(a<0 || c<0)
				{
					bool=1;
					break;
				}
			}
			else if(g.equals("BC"))
			{
				if(b>c)
				{
					b--;
					c++;
					ans[i]="C";
				}
				else if(b<c)
				{
					b++;
					c--;
					ans[i]="B";
				}
				else
				{
					if(i+1<n && arr[i+1].equals("AB"))
					{
						b++;
						c--;
						ans[i]="B";
					}
					else
					{
						b--;
						c++;
						ans[i]="C";
					}
				}
				if(c<0 || b<0)
				{
					bool=1;
					break;
				}
			}
		}
		if(bool==1)
			System.out.println("No");
		else
		{
			System.out.println("Yes");
			for(int i=0;i<n;i++)
			{
				System.out.println(ans[i]);
			}
		}
	}

}


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

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  if(a <= b && c <= d){
    cout << a + c << endl;
  }
  else if(a >= b && c <= d){
    cout << b + c << endl;
  }
  else if(a <= b && c >= d){
    cout << a + d << endl;
  }
  else{
    cout << b + d << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  int n;
  cin >> n;
  string s;
  cin >> s;
  char arr[26] = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q',
  'R','S','T','U','V','W','X','Y','Z'};
  for(int i = 0; i < s.length(); i++){
    for(int j = 0; j < 26; j++){
      if(s[i] == arr[j]){
        cout << arr[(j + n) % 26];
      }
    }
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<unordered_map>
#include<unordered_set>
#include <limits>
using namespace std;
// numeric_limits<double>::epsilon()
 
#define int int64_t
#define pr(x) cout << x << endl;
#define vi vector<int>
#define vii vector< vector<int> >
#define mp make_pair
#define f(i,n) for(i =0 ; i< n ; i++)
#define ff first
#define ss second
#define pb push_back
#define INF 1e9
#define SIZE 200001
#define mod 1000000007
void solve();


int power(int a, int b)
{
    if(b==0) return 1;
    else if(b&1) return a*power(a*a,b/2);
    else return power(a*a, b/2);
}
 


int32_t main()
{
    ios::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    solve();
    return 0;
}
bool AreSame(double a, double b) {
    return std::fabs(a - b) < std::numeric_limits<double>::epsilon();
}
 
int  j=1, n, t, m=0, dot=0, i, k, a, x, y, n1, m1, l;

// void extendGcd(int m, int n)
// {
//     if(n==0)
//     {
//         x=1;
//         y=0;
//         dot=m;
//     }
//     else
//     {
//         extendGcd(n,m%n);
//         q = x;
//         x = y;
//         y = q - (m/n)*y;
//     }
    

// }



string s1, s2,s3;
void solve()
{
    // cin >> t;while(t--)
    {
        cin >> n;
        vi monster(n+1,0), hero(n,0);
        f(i,n+1) cin >> monster[i];
        f(i,n) cin >> hero[i];
        f(i,n+1) m+= monster[i]; 

        f(i,n)
        {
            if(hero[i] <= monster[i] ) monster[i]-=hero[i];
            else 
            {
                monster[i+1]-=hero[i]-monster[i];
                monster[i]=0;

                if(monster[i+1]<0) monster[i+1]=0;
            }
        }
        x=0;
        f(i,n+1) x+=monster[i];
        pr(m-x)
    }

}

Measured memory_bytes: 1792
#include <stdio.h>

void printHash() {
    for (int i=0; i<20; ++i) {
        printf("#");
    }
    printf("\n");
}

void printArray(int ary[3][10]) {
    for (int i=0; i<3; ++i) {
        for (int j=0; j<10; ++j) {
            printf(" %d", ary[i][j]);
        }
        printf("\n");
    }
}

int main() {
    int n;
    int b, f, r, v;
    int building1[3][10] = {
        {0,0,0,0,0,0,0,0,0,0,},
        {0,0,0,0,0,0,0,0,0,0,},
        {0,0,0,0,0,0,0,0,0,0,},
    };
    int building2[3][10] = {
        {0,0,0,0,0,0,0,0,0,0,},
        {0,0,0,0,0,0,0,0,0,0,},
        {0,0,0,0,0,0,0,0,0,0,},
    };
    int building3[3][10] = {
        {0,0,0,0,0,0,0,0,0,0,},
        {0,0,0,0,0,0,0,0,0,0,},
        {0,0,0,0,0,0,0,0,0,0,},
    };
    int building4[3][10] = {
        {0,0,0,0,0,0,0,0,0,0,},
        {0,0,0,0,0,0,0,0,0,0,},
        {0,0,0,0,0,0,0,0,0,0,},
    };

    scanf("%d", &n);
    for (int i=0; i<n; ++i) {
        scanf("%d %d %d %d", &b, &f, &r, &v);
        if (b == 1) {
            building1[f-1][r-1] += v;
        } else if (b == 2) {
            building2[f-1][r-1] += v;
        } else if (b == 3) {
            building3[f-1][r-1] += v;
        } else if (b == 4) {
            building4[f-1][r-1] += v;
        }
    }

    printArray(building1);
    printHash();
    printArray(building2);
    printHash();
    printArray(building3);
    printHash();
    printArray(building4);

    return 0;
}



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

//#include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;
// using cint = cpp_int;

// Define
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const ll MOD = 1e9 + 7;
const ll INF = LONG_MAX;
const ull MAX = ULONG_MAX;
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define x first
#define y second
#define endl '\n'
#define space ' '
#define def inline auto
#define func inline constexpr ll
#define run __attribute__((constructor)) def _
#define all(v) begin(v), end(v)
#define input(a) scanf("%lld", &(a))
#define print(a) printf("%lld\n", (a))

// Debug
#define debug(...)                                                             \
    {                                                                          \
        cerr << __LINE__ << ": " << #__VA_ARGS__ << " = ";                     \
        for (auto &&X : {__VA_ARGS__}) cerr << "[" << X << "] ";               \
        cerr << endl;                                                          \
    }

#define dump(a, h, w)                                                          \
    rep(i, h) {                                                                \
        rep(j, w) cerr << a[i][j] << space;                                    \
        cerr << endl;                                                          \
    }
#define lldump(a, n) dump(vector<vector<ll>>{a}, 1, n)

// Loop
#define inc(i, a, n) for (ll i = (a), _##i = (n); i <= _##i; ++i)
#define dec(i, a, n) for (ll i = (a), _##i = (n); i >= _##i; --i)
#define each(i, a) for (auto &&i : a)
#define rep(i, n) inc(i, 0, n - 1)
#define loop() for (;;)

// Stream
#define fout(n) cout << fixed << setprecision(n)
#define fasten cin.tie(0), ios::sync_with_stdio(0)

// Speed
run() { fasten, fout(10); }
#pragma GCC optimize("O3")
#pragma GCC optimization_level 3
#pragma GCC target("avx")

// Math
func gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
func lcm(ll a, ll b) { return a * b / gcd(a, b); }
func sign(ll a) { return a ? abs(a) / a : 0; }

def in() {
    ll A;
    cin >> A;
    return A;
}

signed main() {
    ll N, A, B, all = 0, foreign = 0;
    string S;
    cin >> N >> A >> B >> S;
    rep(i, N) {
        if (S[i] == 'a') {
            if (all < A + B) {
                all++, puts("Yes");
            } else {
                puts("No");
            }
        }
        if (S[i] == 'b') {
            if (all < A + B && foreign < B) {
                all++, foreign++, puts("Yes");
            } else {
                puts("No");
            }
        }
        if (S[i] == 'c') {
            puts("No");
        }
    }
}

// for compilation: g++ -Ofast -march=native -o _ _.cpp -std=c++17


Measured memory_bytes: 848
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define mp make_pair
#define PI pair<ll,ll>
#define poly vector<ll>
#define mem(a) memset((a),0,sizeof(a))
#define For(i,l,r) for(int i=(int)(l);i<=(int)(r);i++)
#define Rep(i,r,l) for(int i=(int)(r);i>=(int)(l);i--)
#define pb push_back
#define fi first
#define se second
#define SZ(x) ((int)(x.size()))
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline ll read(){
	ll x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(ll a){
    if(a<0){
    	a=-a; putchar('-');
	}
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(ll a){write(a); puts("");}
inline void wri(ll a){write(a); putchar(' ');}
ll rnd(){
	ull ans=0;
	For(i,0,4)ans=ans<<15^rand();
	return ans%((ull)1<<63);
}
const int mod=998244353,N=10000005;
ll fac[N],ni[N];
ll ksm(ll a,int b){
	int ans=1;
	for(;b;b>>=1){
		if(b&1)ans=ans*a%mod;
		a=a*a%mod;
	}
	return ans;
}

ll c(int a,int b){
	return a>=b&&b>=0?fac[a]*ni[b]%mod*ni[a-b]%mod:0;
}
ll g(int a,int b){
	if(!b)return a==0;
	return c(a+b-1,b-1);
}
ll f(int a,int b){
	assert((a+b)%2==0);
	return c(a,(a+b)/2);
}
int main(){
	#ifdef Brollan
		freopen("1.in","r",stdin);
	#endif
	
	int n=read(),a=read(),b=read();
	if(!a){puts("1"); return 0;}
	For(i,fac[0]=1,n)fac[i]=fac[i-1]*i%mod;
	ni[n]=ksm(fac[n],mod-2);
	Rep(i,n,1)ni[i-1]=ni[i]*i%mod;
	ll ans=0;
	For(k,b,n){
		int sn=b-(k-b);
		if(sn>0&&k-b<=min(b-1,a)){
			ans=(ans+(k<n?g(n-k-1,sn-(b-a)+1):(sn==b-a))*(f(k-1,sn-1)-f(k-1,sn+1)+mod))%mod;
			//cout<<sn<<" "<<n-k-1<<" "<<sn-(b-a)<<" "<<(k<n?g(n-k-1,sn-(b-a)+1):(sn==b-a))<<" "<<f(k,sn)<<" "<<f(k,sn+2)<<" "<<ans<<endl;
		}
	}
	cout<<ans<<endl;
	
}


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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  string ans;

  if (a== b && b==c) {
    ans = "No";;
  }else if (a== b || b==c || a==c) {
    ans = "Yes";
  }else{
  ans = "No";
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3616
n=int(input())
p=[int(input())-1for _ in[0]*n]
q=[0]*n
for i in range(n):q[p[i]]=i
r,c=0,1
for i in range(n-1):
    c=c+1if q[i]<q[i+1]else 1
    if r<c:r=c
if r<c:r=c
print(n-r)

Measured memory_bytes: 18832
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>//sort,reverse
#include<utility>//pair
#include<queue>//queue,priority queue
#include<deque>//double_ended queue
using namespace std;

int main()
{ 
    long long int n,m;
    cin>>n>>m;
    long long int s=0;
    while(s*s<=m){s++;}
    vector<int> div;
    for(int i=1;i<s;i++){
        if(m%i==0){
            div.push_back(i);
        }
    }
    int length=div.size();
    for(int i=1;i<length+1;i++){
        div.push_back(m/div[length-i]);
    }
    int l=div.back();
    div.pop_back();
    while(l*n>m){
        l=div.back();
        div.pop_back();
    }
    cout<<l<<endl;
    return 0;
}

Measured memory_bytes: 256
n = input()
x = []
y = []
for i in range(n):
	a, b = map(int, raw_input().split())
	x.append(a)
	y.append(b)
for i in range(n):
	if (x[0] + y[0]) % 2 != (x[i] + y[i]) % 2:
		print -1
		exit()
d = [1 << i for i in range(32)][::-1]
if (x[0] + y[0]) % 2 == 0:
	d.append(1)

print len(d)
for i in d:
	print i,
print
for i in range(n):
	s = ''
	for j in d:
		if abs(x[i]) > abs(y[i]):
			if x[i] > 0:
				x[i] -= j
				s += 'R'
			else:
				x[i] += j
				s += 'L'
		else:
			if y[i] > 0:
				y[i] -= j
				s += 'U'
			else:
				y[i] += j
				s += 'D'
	print s


Measured memory_bytes: 2812
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ for(auto it : P) { s << "<" << it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ for(auto it : P) { s << "<" << it.first << "->" << it.second << "> "; } return s << endl; }


const long long INF = 1LL<<60;
int main() {
    int N, M;
    long long K;
    cin >> N >> M >> K;
    vector<long long> A(N), B(M), SA(N+1, 0), SB(M+1, 0);
    for (int i = 0; i < N; ++i) cin >> A[i], SA[i+1] = SA[i] + A[i];
    for (int i = 0; i < M; ++i) cin >> B[i], SB[i+1] = SB[i] + B[i];
    SB.push_back(INF);

    int res = 0;
    for (int i = 0; i <= N; ++i) {
        long long rem = K - SA[i];
        if (rem < 0) continue;
        int id = upper_bound(SB.begin(), SB.end(), rem) - SB.begin();
        chmax(res, i + id - 1);
    }

    cout << res << endl;
}



Measured memory_bytes: 11088
#%%
h, w, k = map(int, input().split())
s = [[] for i in range(h)]
for i in range(h):
    s[i] = list(input())

ans = [[0] * w for _ in range(h)]
c = 1
for i in range(h):
    for j in range(w):
        if s[i][j] == '#':
            ans[i][j] = c
            c += 1

for i in range(h-1, -1, -1):
    for j in range(w):
        if ans[i][j] == 0:
            if 0 <= i+1 < h:
                ans[i][j] = ans[i+1][j]


for i in range(h):
    for j in range(w):
        if ans[i][j] == 0:
            if 0 <= i-1 < h:
                ans[i][j] = ans[i-1][j]

for i in range(h):
    for j in range(w-1, -1, -1):
        if ans[i][j] == 0:
            if 0 <= j+1 < w:
                ans[i][j] = ans[i][j+1]

for i in range(h):
    for j in range(w):
        if ans[i][j] == 0:
            if 0 <= j-1 < w:
                ans[i][j] = ans[i][j-1]

for i in range(h):
    for j in range(w):
        ans[i][j] = str(ans[i][j])

    tmp = ' '.join(ans[i])
    print(tmp)


# %%


Measured memory_bytes: 10100
"""nを素因数分解"""
"""2以上の整数n => [[素因数, 指数], ...]の2次元リスト"""

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

n = int(input())
if(n==1):print(0);exit()
a = factorization(n)
#print(a)
ans = 0
for i in a:
  t = i[1]
  c=1
  tmp = 0
  while(tmp<=t):
    tmp+=c
    c+=1
  ans+=(c-2)
print(ans)

Measured memory_bytes: 63368
n,k,s = map(int,input().split())
ans = []
for i in range(k):
    ans.append(s)
if s == int(1e9):
    for j in range(n-k):
            ans.append(1)
else:
    for j in range(n-k):
        ans.append(s+1)
print(*ans)


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

ll a[100050],sum[100050],psum[100050];

template<class T>
ll part(const T& s,int l, int r){return s[r] - s[l];}

int main(){
  int N,K; cin>>N>>K;
  for(int i=0;i<N;i++) cin>>a[i];
  for(int i=0;i<N;i++)
    sum[i+1] = sum[i] + a[i];
  for(int i=0;i<N;i++){
    if(a[i] > 0) psum[i+1] = psum[i] + a[i];
    else psum[i+1] = psum[i];
  }
  ll ans = 0;
  for(int i=0;i+K<=N;i++){
    ll tmp = part(psum,0,i) + part(psum,i+K,N);
    ll b = part(sum,i,i+K);
    if(b > 0) tmp += b;
    if(ans < tmp) ans = tmp;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 2560
n, m = map(int, raw_input().strip().split())

food = [0 for i in xrange(m + 1)]

ans = 0
for _ in xrange(n):
    l = map(int, raw_input().strip().split())
    for i in xrange(1, len(l)):
        food[l[i]] += 1
        if food[l[i]] == n: ans += 1

print ans
        
 

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

int main(){
    int n;
    cin >> n;
    vector<P> town(n);
    rep(i,n){
        cin >> town[i].first >> town[i].second;
    }
    vector<int> v;
    rep(i,n){
        v.push_back(i);
    }
    int num=0;
    double dist=0.0;
    do{
        rep(i,n-1){
            double temp = 0.0;
            temp+=(town[v[i]].second-town[v[i+1]].second)*(town[v[i]].second-town[v[i+1]].second);
            temp+=(town[v[i]].first-town[v[i+1]].first)*(town[v[i]].first-town[v[i+1]].first);
            dist += sqrt(temp);
        }
        num++;
        //printf("%f\n",dist);
    }while(next_permutation(v.begin(),v.end()));

    dist = dist/double(num);

    printf("%.8f\n",dist);
}

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

int main() {
	int H,W;
	cin >> H >> W;
	string a[H];
	int cnt=0;
	for(int i=0; i<H; i++) {
		cin >> a[i];
		for(int j=0; j<W; j++) {
			if(a[i].at(j)=='#') cnt++;
		}
	}
	if(cnt==H+W-1) cout << "Possible" << endl;
	else           cout << "Impossible" << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

public class Program
{
  public static void Main()
  {
    var n = int.Parse(Console.ReadLine());
    var input = new Dictionary<string, long>();

    for (var count = 0; count < n; count++)
    {
      var value = string.Join("", Console.ReadLine().OrderBy(charactor => charactor));
      
      if (input.ContainsKey(value))
      {
        input[value]++;
      }
      else
      {
        input.Add(value, 1);
      }
    }

    long result = 0;

    foreach (var value in input.Values)
    {
      long temp = value;
      while (temp > 1)
      {
        temp--;
        result += temp;
      }
    }
	
    Console.WriteLine(result);
  }
}


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

using namespace std;

long long int A, a, n, m, y, s;
string str_1, str_2, str_3;


long long int gcd(int m, int n){
	while (true) {
		if (m%n == 0)return n;
		m %= n;
		if (n%m == 0)return m;
		n %= m;
	}
	return 0;
}



int main() {
	cin >> n >> m;
	cin >> str_1 >> str_2;

	y = gcd(n, m);

	for (int i = 0; i < y; i++) {
		if (str_1[i*n / y] != str_2[i*m / y]) {
			cout << -1 << endl;
			return 0;
		}
	}
	cout << n * m / y << endl;
	return 0;
}


Measured memory_bytes: 640
// 失敗するからこそ そこから立ち向かって行く強さがあってそんな強さが本当の強さだと私は思うから
// ぜったいあきらめない
#if defined(DAIJOBU)
#include "/home/ichigo/includes.hpp"
#include "/home/ichigo/debug.hpp"
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#include <bits/stdc++.h>
#define deb(x...)
#endif
#define FIO {ios::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);}

using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());


int main(){
	FIO
	
	int x, a, b;
	cin >> x >> a >> b;
	if(b - a <= 0)cout << "delicious";
	else if(b - a > x)cout << "dangerous";
	else cout << "safe";
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;int a[n+1];int count=0;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		if(i%2==1&&a[i]%2==1)
		count++;
	}
	cout<<count<<endl;
	return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(ll i = 0; i < n; i++)
const ll INF = 1LL << 60;

int main(){
    int N, K; cin >> N >> K;
    vector<int> A(N);
    rep(i, N) cin >> A[i];
    sort(all(A), greater<int>());
    int l = 0, r = A[0]; //左は絶対に無理、右は絶対に可能
    while(r - 1 > l){
        int middle = (l + r) / 2;
        int tmp = 0;
        rep(i, N){
            tmp += (A[i] + middle - 1) / middle - 1;
        }
        if(tmp <= K) r = middle;
        else l = middle;
    }
    cout << r << endl;
}

Measured memory_bytes: 4016
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
using namespace std;
int main(){
	long int a[200];
	long int n,max,min;
	max=0;
	min=1000000000;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	for(int i=0;i<n;i++){
		if(a[i]>max){
			max=a[i];
		}
	}
	
	
	for(int i=0;i<n;i++){
		if(a[i]<min){
			min=a[i];
		}
	}
	int ans=max-min;
		cout<<ans;
	return 0;
} 

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

// region template
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define trav(a, x) for (auto &a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;

ll gcd(ll a, ll b) { return __gcd(a, b); }

ll euclid(ll a, ll b, ll &x, ll &y) {
    if (b) { ll d = euclid(b, a % b, y, x);
        return y -= a/b * x, d; }
    return x = 1, y = 0, a;
}

typedef unsigned long long ull;
typedef long double ld;
ull mod_mul(ull a, ull b, ull M) {
    ll ret = a * b - M * ull(ld(a) * ld(b) / ld(M));
    return ret + M * (ret < 0) - M * (ret >= (ll)M);
}
ull mod_pow(ull b, ull e, ull mod) {
    ull ans = 1;
    for (; e; b = mod_mul(b, b, mod), e /= 2)
        if (e & 1) ans = mod_mul(ans, b, mod);
    return ans;
}

const ll mod = 1000000007;
struct Mod {
    ll x;
    Mod(ll xx) : x(xx) {}
    Mod operator+(Mod b) { return Mod((x + b.x) % mod); }
    Mod operator-(Mod b) { return Mod((x - b.x) % mod); }
    Mod operator*(Mod b) { return Mod((x * b.x) % mod); }
    Mod operator/(Mod b) { return *this * invert(b); }
    Mod invert(Mod a) {
        ll x, y, g = euclid(a.x, mod, x, y);
        assert(g == 1); return Mod((x + mod) % mod);
    }
    Mod operator^(ll e) {
        if (!e) return Mod(1);
        Mod r = *this ^ (e / 2); r = r * r;
        return e & 1 ? *this * r : r;
    }
};
// endregion

int dir[][3] = {{1, 0, 0}, {0, 1, 0}, {0, 0, 1}, {1, 1, 0}, {1, -1, 0}, {0, 1, 1}, {0, 1, -1}, {1, 0, 1}, {1, 0, -1},
            {1, 1, 1}, {1, 1, -1}, {1, -1, -1}, {-1, 1, -1}};
int n, m, p;
char mp[9][9][9];

void reset() {
    rep(i, 0, 9) rep(j, 0, 9) rep(k, 0, 9) mp[i][j][k] = ' ';
}

bool win(char usr) {
    rep(i, 1, n + 1) rep(j, 1, n + 1) rep(k, 1, n + 1) if (mp[i][j][k] == usr) rep(d, 0, 13) {
        int len = 0;
        for (int ii = i, jj = j, kk = k; mp[ii][jj][kk] == usr; ii += dir[d][0], jj += dir[d][1], kk += dir[d][2])
            len++;
        // if (len > 1 )printf("  %d %d %d (%d %d %d) %d\n", i, j, k, dir[i][0], dir[i][1], dir[i][2], len);
        if (len >= m) return true;
    }
    return false;
}

int main() {
    for (;;) {
        reset();
        cin >> n >> m >> p;
        if (!n) break;

        vector<int> x(p), y(p);
        rep(i, 0, p) cin >> x[i] >> y[i];

        char usr = 'B';

        rep(i, 0, p) {
            rep(j, 1, n + 1) if (mp[x[i]][y[i]][j] == ' ') {
                mp[x[i]][y[i]][j] = usr;
                // cout << usr << " " << x[i] << " " << y[i] << " " << j << endl;
                break;
            }
            if (win(usr)) {
                cout << (usr == 'B' ? "Black " : "White ") << (i + 1) << endl;
                goto done;
            }
            usr ^= 'B' ^ 'W';
        }
        cout << "Draw" << endl;
        done: void(0);
    }
}


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

const int MAX = 510000;
const int MOD = 1000000007;



int main() {
    ll N, M; cin >> N >> M;
    vector<ll> V(M);
    for(int i = 0; i < M; i++){
        cin >> V[i];
        if(i != 0) if(V[i-1] + 1 == V[i]){
            cout << 0 << endl; return 0;
        }
    }
    ll ans = 1;
    vector<ll> T(100005);
    T[0] = 1;
    T[1] = 1;

    for(int i = 2; i <= 100005; i++) T[i] = (T[i-1] + T[i-2])%MOD;

    if(M == 0) {
        cout << T[N] << endl;
        return 0;
    }
    ans *= T[V[0]-1];
    for(int i = 1; i < V.size(); i++){
        //cout << V[i] - V[i-1]-2 << endl;
        if(V[i] - V[i-1]-2 < 0){
            cout << 0 << endl;
            return 0;
        }
        ans *= T[V[i] - V[i-1]-2];
        ans%=MOD;
        //cout << ans << endl;
    }
    ans*= T[N-V[M-1]-1];
    ans%=MOD;
    cout << ans << endl;



}


Measured memory_bytes: 1408
def gcd(a, b):
	while b:
		a, b = b, a % b
	return a
  


N = int(input())
A = input().split()
for i in range(N):
    A[i] = int(A[i])
    
if N == 2:
    print(max(A[0],A[1]))
if N >= 3:
    gcd_all = gcd(A[0], A[1])
    gcd_without_1 = A[0]
    gcd_without_2 = A[1]
    gcd_without_1 = max(gcd_all, max( gcd(gcd_without_1, A[i]),gcd(gcd_without_2, A[i])))
    gcd_all = gcd(gcd_all,A[2])
    for i in range(3,N):
        gcd_without_1 = max(gcd_all, gcd(gcd_without_1, A[i]))
        gcd_all = gcd(gcd_all,A[i])
    print(max(gcd_all, gcd_without_1))





Measured memory_bytes: 11508
#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma comment(linker, "/stack:200000000")
 
#include <bits/stdc++.h>
#include<fcntl.h>
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
 
#define X first
#define Y second
 
//#include <boost/unordered_map.hpp>
//using namespace boost;
 
/*
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> rbtree;
rbtree T;
*/
 
using i32 = int;
using i64 = long long;
using u8 = unsigned char;
using u32 = unsigned;
using u64 = unsigned long long;
using f64 = double;
using f80 = long double;
//using i128 = __int128_t;
//using u128 = __uint128_t;
//using i128 = i64;
//using u128 = u64;
 
ll power(ll a, ll b, ll p)
{
	if (!b) return 1;
	ll t = power(a, b/2, p);
	t = t*t%p;
	if (b&1) t = t*a%p;
	return t;
}
 
ll exgcd(ll a, ll b, ll &x, ll &y)
{
	if (b == 0)
	{
		x = 1;
		y = 0;
		return a;
	}
	ll px, py;
	ll d = exgcd(b, a%b, px, py);
	x = py;
	y = px-a/b*py;
	return d;
}
 
template<class T>
inline void freshmin(T &a, const T &b)
{
	if (a > b) a = b;
}
 
template<class T>
inline void freshmax(T &a, const T &b)
{
	if (a < b) a = b;
}

template<class T>
void print(const T &a)
{
	for (auto x : a) printf("%d ", x); puts("");
}

const int MAXN = 100010;
const int MAXM = 26;
//const i64 INF = 1000000000000000000LL;
const int INF = 1000000000;
//const int MOD = 998244353;
const int MOD = 998244853;
const int INV2 = (MOD+1)/2;
const ld pi = 3.1415926535897932384626433;

int n;
int a[MAXN];

void solve()
{
	int a, b;
	scanf("%d%d", &a, &b);
	int cur = 1;
	int ans = 0;
	while (cur < b)
	{
		ans ++;
		cur += a-1;
	}
	printf("%d\n", ans);
}

int main()
{
	/*
	int T;
	scanf("%d", &T);
	while (T --)*/
		solve();
	
	return 0;
}


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

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int S = sc.nextInt();
        int r = S % 100;
        if (S >= 100 && S < 1300) {
            if (r <= 12 & r != 0) {
                System.out.println("AMBIGUOUS");
            }
            else{
                System.out.println("MMYY");
            }
        }
        else{
            if (r <= 12 & r != 0) {
                System.out.println("YYMM");
            }
            else{
                System.out.println("NA");
            }
        }
    }
}



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

typedef long long int int64;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))

void run(void){
  int n;
  scanf("%d",&n);
  char *s=(char *)calloc(n+1,sizeof(char));
  scanf("%s",s);
  int cnt[26]={0};
  const int mod=1000000007;
  int i;
  for(i=0;i<n;i++) cnt[s[i]-'a']++;
  int ans=1;
  for(i=0;i<26;i++) ans=(int64)ans*(cnt[i]+1)%mod;
  printf("%d\n",(ans+mod-1)%mod);
}

int main(void){
  run();
  return 0;
}

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
























bool isprime (int a) {
    for (int i = 2; i * i  <= a; i++) {
        if (a % i == 0) {
            return false;
        }
    }
    return true;
}



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

    for (int i = x; ; i++) {
        if (isprime(i)) {
            cout << i << endl;
            break;
        }
    }
}

Measured memory_bytes: 3616
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#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 <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower

using namespace std;



int main(){
	int a;
	cin >> a;
	int x = a + a * a + a * a * a;
	cout << x << endl;
}

Measured memory_bytes: 3620
#include <cstdio>
using namespace std;

int main(){
	char a[5], b[5];
	int c, d;
	while (true) {
		c = d = 0;
		scanf("%s %s", a, b);
		if (a[1] == '\0') break;
		for (int i = 0; i < 4; i++) {
			for (int j = 0; j < 4; j++) {
				if (a[i] == b[j]) {
					i == j ? c++ : d++;
				}
			}
		}
		printf("%d %d\n", c, d);
	}

	return 0;
}

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

const int maxn=1e5+5;
const int inf=1e9;
int n,k;
vector<int>g[maxn];
int w[maxn];
int vis[maxn];
int flag;
int l[maxn],r[maxn];

void dfs(int x,int f)
{
//	if(flag)return ;
	if(!vis[x])
	{
		l[x]=-inf;
		r[x]=inf;
	}
	for(int i=0; i<(int)g[x].size(); i++)
	{
		int to=g[x][i];
		if(to==f)continue;
		dfs(to,x);
		if(l[x]==-inf)
		{
			l[x]=l[to]-1;
			r[x]=r[to]+1;
		}
		else
		{
			l[x]=max(l[x],l[to]-1);
			r[x]=min(r[x],r[to]+1);
			if(l[to]>-inf&&abs(l[x])%2==abs(l[to])%2)flag=1;
		}
		if(l[x]>r[x])flag=1;
	}
}

void fill(int x,int f)
{
	if(x==1&&!vis[x])
	{
		w[x]=l[x];
	}
	else
	{
		if(vis[x])
		{
			;
		}
		else
		{
			if(w[f]-1>=l[x]&&w[f]-1<=r[x])w[x]=w[f]-1;
			else w[x]=w[f]+1;
		}

	}
	for(int i=0; i<(int)g[x].size(); i++)
	{
		if(g[x][i]==f)continue;
		fill(g[x][i],x);
	}
}

int main()
{
	scanf("%d",&n);
	for(int i=1; i<n; i++)
	{
		int a,b;
		scanf("%d%d",&a,&b);
		g[a].push_back(b);
		g[b].push_back(a);
	}
	scanf("%d",&k);
	for(int i=1; i<=k; i++)
	{
		int p,val;
		scanf("%d%d",&p,&val);
		w[p]=val;
		l[p]=r[p]=val;
		vis[p]=1;
	}
	dfs(1,0);
	fill(1,0);
	if(flag)
	{
		puts("No");
	}
	else
	{
		puts("Yes");
		for(int i=1; i<=n; i++)
		{
			printf("%d\n",w[i]);
		}
	}
	return 0;
}

Measured memory_bytes: 15744
#include <iostream>

using namespace std;

int main(){
  int p[3];
  int ju[2];
  int sum=0,min=0;
  
  cin>>p[0]>>p[1]>>p[2];
  cin>>ju[0]>>ju[1];

  min=p[0]+ju[0];
  for(int i=0;i<3;i++){
    for(int j=0;j<2;j++){
      sum=p[i]+ju[j];
      if(min>sum)
        min=sum;
    }
  }

  min-=50;

  cout<<min<<endl;
}



Measured memory_bytes: 3120
DIV = 10 ** 9 + 7


max_num, min_select = map(int, input().split())

ans = 0
for select in range(min_select, max_num + 2):
    sum_min = (select * (select - 1)) // 2
    sum_max = max_num * select - sum_min
    ans += (sum_max - sum_min + 1) % DIV

print(ans % DIV)


Measured memory_bytes: 9164
import sys
input = sys.stdin.readline
sys.setrecursionlimit(200000)


def read():
    N, K = list(map(int, input().strip().split()))
    P = list(map(int, input().strip().split()))
    return N, K, P


def solve(N, K, P):
    P.sort()
    return sum(P[:K])


if __name__ == '__main__':
    inputs = read()
    outputs = solve(*inputs)
    if outputs is not None:
        print("%s" % str(outputs))


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

void BubbleSort(int n, int *A) {
    int count = 0;
    bool flag = true;
    while(flag) {
        flag = false;
        for (int i = n - 1; i >= 1; --i) {
            if(A[i-1] > A[i]) {
                swap(A[i], A[i-1]);
                flag = true;
                count++;
            }
        }
    }

    // output
    for (int i = 0; i < n; ++i) {
        cout << A[i] << ((i != n - 1) ? " " : "\n");
    }
    cout << count << "\n";
}

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

    BubbleSort(n, array);
    return 0;
}


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


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

	int n;
	cin>>n;
	string s;
	set<string> list;

	for(int i=1;i<=n;i++)
	{
		cin>>s;
		list.insert(s);
	}

	cout<<list.size()<<"\n";



	return 0;
}


Measured memory_bytes: 19216
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String op = "";
        while(!op.equals("?")){
            int answer = 0;
            String tmp = in.nextLine();
            String[] line = tmp.split(" ");
            int num1 = Integer.parseInt(line[0]);
            int num2 = Integer.parseInt(line[2]);
            op = line[1];
            switch(op){
                case "+":
                    answer = num1 + num2;
                    System.out.printf("%d%n",answer);
                    break;
                case "-":
                    answer = num1 - num2;
                    System.out.printf("%d%n",answer);
                    break;
                case "*":
                    answer = num1 * num2;
                    System.out.printf("%d%n",answer);
                    break;
                case "/":
                    answer = num1 / num2;
                    System.out.printf("%d%n",answer);
                    break;
            }
        }
    }
}


Measured memory_bytes: 26312