akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

const int maxn = 200005;
typedef long long ll;
ll a[maxn];
ll dp[maxn][2];
ll si[maxn], sp[maxn];
int memo[maxn][2];

ll solve( int n, int k ){

    if( !k ) return 0;
    if( k > (n+1)/2 ) return -1LL << 50;
    if( n == 3 && k == 2 )
        return a[1] + a[3];
    if( n == 3 && k == 1 )
        return max({a[1], a[2], a[3]});
    if( n == 4 && k == 1 )
        return max({a[1], a[2], a[3], a[4]});
    if( n == 4 && k == 2 ){
        ll ret = -1LL << 50;
        for( int i = 1; i <= 2; i++ )
            for( int j = i+2; j <= 4; j++ )
                ret = max(ret, a[i] + a[j]);
        return ret;
    }
    if( n == 2 && k == 1 )
        return max(a[1], a[2]);

    if( n % 2 == 0 ){
        int kk = n/2;
        if( k > kk ) return -1LL << 50;
        if( memo[n][0] ) return dp[n][0];
        memo[n][0] = 1;
        ll val = max( a[n] + solve(n-2, k-1), solve(n-1, k) );
        dp[n][0] = val;
        return val;
    }
    else{
        if( k == (n+1)/2 )
            return si[n];
        if( k == n/2 ){
            if( memo[n][0] ) return dp[n][0];
            memo[n][0] = 1;
            ll val = max( {a[n] + solve(n-2, k-1), solve(n-1, k), solve(n-2, k)} );
            dp[n][0] = val;
            return val;
        }
    }
    return 0;

}

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    #ifdef acm
    freopen("a.in","r",stdin);
    #endif // acm

    int n;
    cin >> n;

    for( int i = 1; i <= n; i++ ){
        cin >> a[i];
        si[i] = si[i-1];
        sp[i] = sp[i-1];
        if( i & 1 )
            si[i] += a[i];
        else sp[i] = sp[i-1];
    }

    int k = n/2;

    cout << solve(n, k) << "\n";
    return 0;
}


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


using namespace std;
 
int main(){
    int x[100001];
    int y[100001];
    int t[100001];
    x[0] = y[0] = t[0] = 0;
    int N;
    cin >> N;
    bool hantei = true;
    for(int i = 0; i < N; i++){
        cin >> t[i+1] >> x[i+1] >> y[i+1]; 
    }

    for(int i = 0; i < N; i++){
        int dt = t[i+1] - t[i];
        int dist = abs(x[i+1] - x[i]) + abs(y[i+1] - y[i]);
        if(dt < dist){ hantei = false; break; }
        else{
            if(dt % 2 != dist % 2){ hantei = false; break; }
        }
     }

    if(hantei == true){
     cout << "Yes";
    }else{
        cout << "No";
    }

    return 0;


}


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

int main(){
  int N,K,S;
  cin>>N>>K>>S;
  vector<int> A(N);
  
  for(int i=0;i<K;i++){
    A.at(i)=S;
  }
  if(S!=1000000000){
    for(int i=K;i<N;i++){
      A.at(i)=S+1;
    }
  }else{
    if(K!=0){
      for(int i=K;i<N;i++){
        A.at(i)=1;
      }
    }else{
      for(int i=K;i<N;i++){
        A.at(i)=999999999;
      }
    }
  }
  
  for(int i=0;i<N-1;i++){
    cout<<A.at(i)<<" ";
  }
  cout<<A.at(N-1)<<endl;
}

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

void digit(int n, int k)
  {
    if (n < 0)
      n = -1 * n;

    if (n % 10 == k)
    {
      cout << "Yes\n";
      return;
    }
    else if (n / 10 > 0)
       digit(n / 10, k);
    else
      cout << "No" << endl;
 }
 
 int main()
{   
    int n;
    cin>>n;
    
    digit(n, 7);
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define pb push_back
#define eb emplace_back
template<class T>void chmax(T &a,T b){if(a<b)a=b;}
template<class T>void chmin(T &a,T b){if(a>b)a=b;}
constexpr int INF=1000000000000000000;
constexpr int mod=1000000007;
constexpr double eps=1e-8;
const double pi=acos(-1);
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int Random(int mi,int ma){
    random_device rnd;
    mt19937 mt(rnd());//32bit
    //[mi,ma]
    uniform_int_distribution<int>engine(mi,ma);
    return engine(mt);
}
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%mod;
    int memo=modpow(a,b/2);
    return memo*memo%mod;
}
vector<int>kaijo,invkaijo;
void init_fact(int n){
    kaijo.resize(n+1);
    invkaijo.resize(n+1);
    kaijo[0]=1;
    for(int i=1;i<=n;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=mod;
    }
    rep(i,n+1)invkaijo[i]=modpow(kaijo[i],mod-2);
}
int comb(int a,int b){
    if(a<b)return 0;
    if(a<0||b<0)return 0;
    return kaijo[a]*modpow(kaijo[a-b],mod-2)%mod*modpow(kaijo[b],mod-2)%mod;
}
int inv(int x){
    x=modpow(x,mod-2);
    return x;
}
int n,dp[61][3];
signed main(){
    cin.tie(0);ios::sync_with_stdio(false);
    cin>>n;
    dp[60][0]=1;
    for(int i=59;i>=0;i--){
        rep(j,3){
            //dp[i+1][j]
            int s=(n>>i)&1;
            //1,1
            if(j*2-2+s>=0){
                dp[i][min(2ll,j*2-2+s)]+=dp[i+1][j];
                dp[i][min(2ll,j*2-2+s)]%=mod;
            }
            //0,1
            if(j*2-1+s>=0){
                dp[i][min(2ll,j*2-1+s)]+=dp[i+1][j];
                dp[i][min(2ll,j*2-1+s)]%=mod;
            }
            //0,0
            dp[i][min(2ll,j*2+s)]+=dp[i+1][j];
            dp[i][min(2ll,j*2+s)]%=mod;
        }
    }
    int ans=0;
    rep(i,3){
        ans+=dp[0][i];
        ans%=mod;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3632
macro_rules! scan {
    () => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().to_string()
        }
    };
    (;;$n:expr) => {
        (0..$n).map(|_| scan!()).collect::<Vec<_>>()
    };
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty;;$n:expr) => {
        (0..$n).map(|_| scan!($t;;)).collect::<Vec<_>>()
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    scan!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    scan!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let n = scan!(usize);
    let mut ans = 0;
    for _ in 0..n {
        let (l, r) = scan!(i64, i64);
        ans += r - l + 1;
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
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 repr(i, n) for(int i=n-1; i>=0; i--)
#define repr1(i, n) for(int i=n; i>=1; i--)
#define all(v) v.begin(),v.end()
using ll = long long;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
    string s; cin >> s;

    int n = s.size();
    vector<vector<int>> v(26, vector<int>(1, 0));
    rep(i, n) {
        v[s[i] - 'a'].push_back(i+1);
    }
    rep(i, 26) v[i].push_back(n+1);

    int res = INF;
    rep(i, 26) {
        int curMax = -1;
        rep(j, v[i].size()-1) chmax(curMax, v[i][j+1] - v[i][j]);
        chmin(res, curMax);
    }
    cout << res - 1 << endl;
}


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

#define ll long long
#define p_q priority_queue
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)


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

    vector<ll> a(n);
    rep(i,n){
        cin>>a.at(i);
    }

    ll co=0;
    for(int i=0;i<n;i++){
        if(a.at(i)==(co+1)){
            co++;
        }
    }
    if(co==0){
        cout<<-1<<endl;
    }else{
        cout<<n-co<<endl;
    }
}



Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
	int A, B, M;
	cin >> A >> B >> M;

	vector<int> a(A);
	vector<int> b(B);
	vector<int> x(M);
	vector<int> y(M);
	vector<int> c(M);

	for (int i = 0; i < A; ++i) {
		cin >> a[i];
	}
	for (int i = 0; i < B; ++i) {
		cin >> b[i];
	}
	for (int i = 0; i < M; ++i) {
		cin >> x[i] >> y[i] >> c[i];
		--x[i];
		--y[i];
	}

	int ans = *min_element(a.begin(), a.end()) + *min_element(b.begin(), b.end());

	for (int i = 0; i < M; ++i) {
		int t = a[x[i]] + b[y[i]] - c[i];
		ans = min(ans, t);
	}
	cout << ans << endl;
}


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

int main()
{
	int n;
	cin >> n;
	vector<int> l(n);
	int max = 0;
	int index = -1;
	int sum = 0;

	for (int i = 0; i < n; i++)
	{
		cin >> l.at(i);
		sum += l.at(i);
		if (max < l.at(i))
		{
			max = l.at(i);
			index = i;
		}
	}

	if (max < sum - max)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}
}


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

int main(void){
    int a;
    int b;
    int c;
    scanf("%d %d %d",&a, &b, &c);
    
    if(1<=a<=10000 && 1<=b<=10000 && 1<=c<=10000){
        if((a+b)<=(b+c) && (a+b)<=(a+c)){
            printf("%d",a+b);
        }else if((b+c)<=(a+b) && (b+c)<=(a+c)){
            printf("%d",b+c);
        } else if((a+c)<=(a+b) && (a+c)<=(b+c)){
                printf("%d",a+c);
        }
    } else {
        exit(1);
    }
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <queue>
#include <vector>
#include <algorithm>
#include <set>
#include <math.h>
#include <tuple>
#include <map>
#include <iomanip>
using namespace std;
typedef long long ll;

int main() {
    string s[8] = {"0", "SAT", "FRI", "THU", "WED", "TUE", "MON", "SUN"};
    string t;
    cin >> t;
    for (int i = 0; i < 8; i++) {
        if (t == s[i]) {
            cout << i << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 256
import Control.Monad
main :: IO ()
main = do
    [n,m] <- map read . words <$> getLine :: IO [Int]
    a <- replicateM n $ drop 1 . map read . words <$> getLine :: IO [[Int]]
    print $ length [ i | i <- [1..m], all (\ai -> i `elem` ai) a ]


Measured memory_bytes: 1020
A = int(input())
B = int(input())
C = int(input())
X = int(input())
 
count = 0
for i in range(A+1):
    for j in range(B+1):
        for k in range(C+1):
            price = i*500 + j*100 + k*50 
            if price == X:
                count += 1
            price = 0
 
print(count)


Measured memory_bytes: 3060
n = int(input())
lst = list(map(int, input().split()))
cnt = 0
for i, e in enumerate(lst):
    flag = True
    ci = 0
    while ci < i:
        if e < lst[ci]:
            flag = False
            break
        ci += 1
    ci = 0
    if flag:
        cnt += 1
print(cnt)

Measured memory_bytes: 3060
#include <cstdio>
#define N 100000
#define MAX 1000000000

typedef struct {
    char type;
    long long value;
} Card;

void exchange(Card A[], int index, int r) {
    Card tmp = A[index];
    A[index] = A[r];
    A[r] = tmp;
}

int Partition(Card A[], int p, int r) {
    int x = A[r].value;
    int i = p - 1;
    for (int j = p; j<r; j++) {
        if (A[j].value <= x) {
            i++;
            exchange(A, i, j);
        }
    }
    exchange(A, i+1, r);
    return i + 1;
}

void Quicksort(Card A[], int p, int r) {
    if (p < r) {
        int q = Partition(A, p, r);
        Quicksort(A, p, q - 1);
        Quicksort(A, q + 1, r);
    }
}

void merge(Card A[], long long left, long long mid, long long right) {
    long long n1 = mid - left + 2;
    long long n2 = right - mid + 1;
    Card L[n1], R[n2];
    for (long long i=0; i<n1-1; i++) {
        L[i] = A[left + i];
    }
    for (long long i=0; i<n2-1; i++) {
        R[i] = A[mid + 1 + i];
    }

    L[n1-1].value = MAX;
    R[n2-1].value = MAX;

    long long l = 0, r = 0;
    for (long long i=left; i<=right; i++) {
        if (L[l].value <= R[r].value) {
            A[i] = L[l];
            l++;
        } else {
            A[i] = R[r];
            r++;
        }
    }
}

void merge_sort(Card A[], long long left, long long right) {
    if (left < right) {
        long long mid = (left + right) / 2;
        merge_sort(A, left, mid);
        merge_sort(A, mid + 1, right);
        merge(A, left, mid, right);
    }
}

int
main() {
    int n;
    Card A[N];
    Card B[N];
    scanf("%d", &n);
    for (int i=0; i<n; i++) {
        char c;
        long long s;
        scanf(" %c %lld", &c, &s);
        A[i].type = B[i].type = c;
        A[i].value = B[i].value = s;
    }

    merge_sort(B, 0, n - 1);
    Quicksort(A, 0, n - 1);
    bool isStable = true;
    for (int i=0; i<n; i++) {
        if (A[i].type != B[i].type || A[i].value != B[i].value) {
            isStable = false;
            break;
        }
    }

    if (isStable) printf("Stable\n");
    else printf("Not stable\n");

    for (int i=0; i<n; i++) {
        printf("%c %lld\n", A[i].type, A[i].value);
    }


    return 0;
}

Measured memory_bytes: 5720
#include <bits/stdc++.h>
#define pb emplace_back
#define fi first
#define se second
#define int long long
using namespace std;
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int l) { uniform_int_distribution<int> uid(0, l - 1); return uid(rang); }
int dp[1003][1003];
int32_t main() {
	ios::sync_with_stdio(false); cin.tie(NULL); cout.precision(10); srand(chrono::high_resolution_clock::now().time_since_epoch().count());
	int n; cin >> n;
	int m; cin >> m;
	vector<string> s(n + 1); for (int o = 0; o < n; o++) { cin >> s[o]; s[o] += "#";}
	s[n] = s[n - 1];
	dp[0][0] = 1;
	int mod = 1e9 + 7;
	for (int i = 0; i < n; ++i)
		for (int j = 0; j < m; ++j)
			dp[i + 1][j] = (dp[i + 1][j] + (s[i + 1][j] == '#' ? 0 : dp[i][j])) % mod,
			               dp[i][j + 1] = (dp[i][j + 1] + (s[i][j + 1] == '#' ? 0 : dp[i][j])) % mod;
	cout << (dp[n - 2][m - 1] + dp[n - 1][m - 2]) % mod;
}

Measured memory_bytes: 10112
#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<int, int>;

const int INF = 1001001001;

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

    // RGBの全ての組み合わせ: R*G*B
    vector<int> rgb(3);
    rep(i,n) {
        if (s[i] == 'R') rgb[0]++;
        else if (s[i] == 'G') rgb[1]++;
        else rgb[2]++;
    }
    ll ans = 1;
    rep(i,3) ans *= rgb[i];

    // 条件(j-i = k-j)を満たすRGBの組み合わせを引く
    // i,jを固定して考える
    rep(i,n-2) {
        for (int j = i+1; j < n-1; ++j) {
            int k = (2*j)-i;
            if (k >= n) continue;
            if (s[i] != s[j] && s[j] != s[k] && s[k] != s[i]) ans--;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3620
#include<algorithm>
#include<stdio.h>
using namespace std;
struct node{
    int t,c;
}a[101];
int n,T;
bool cmp(node A,node B)
{
    if(A.t<=T&&B.t<=T) return A.c<B.c;
    else return A.t<B.t;
}
int main()
{
    scanf("%d%d",&n,&T);
    for(int i=1;i<=n;i++)
      scanf("%d%d",&a[i].c,&a[i].t);
    sort(a+1,a+n+1,cmp);
    if(a[1].t<=T) printf("%d",a[1].c);
    else puts("TLE");
    return 0;
}


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


int main(){
  int n;
  cin >> n;
  vector<int> a(n+1);
  a.at(0) = 0;
  rep(i,n) cin >> a.at(i+1);
  
  bool flag = false;
  int ans = 0;
  int cnt = 1;
  for(int i=1;i<=n;i++){
    if( a.at(i) == 1 ) flag = true;
    if( a.at(i) != cnt ){
      ans++;
    }else{
      cnt++;
    }
  }
  if( flag ){
    cout << ans << endl;
  }else{
    cout << -1 << endl;
  }
  return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <string.h>
int max(int a,int b)
{
	if(a>b) return a;
	else return b;
}
int dp[4000][4000];
int main()
{
	char a[4000],b[4000];
	scanf("%s%s",a,b);
	int n1=strlen(a),n2=strlen(b);
	for(int i=n1;i>=0;i--)
	{
		for(int j=n2;j>=0;j--)
		{
			if(j==n2 || i==n1){ dp[i][j]=0; continue;}
			if(a[i]==b[j]) dp[i][j]=1+dp[i+1][j+1];
			else dp[i][j]=max(dp[i+1][j],dp[i][j+1]);
		}
	}
//	printf("1\n");
//	printf("%d\n",dp[0][0]);
	char ans[3005];
	int k=0;
	int i=0,j=0;
		while(i<n1&&j<n2)
		{
			if(dp[i][j]>dp[i+1][j]&&dp[i][j]>dp[i][j+1])
			{
				ans[k++]=a[i];
				i++;
				j++;
			}
			if(dp[i][j]==dp[i+1][j]){ i++;  continue;}
			if(dp[i][j]==dp[i][j+1]){ j++;continue;}
		}
	
	if(k==0)
	{
		printf(" ");
		return 0;
	}
	printf("%s",ans);
	return 0;
}


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

const long double EPS = 1e-10;
const long long INF = 1e18;
const long double PI = acos(-1.0L);


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


vector<int> row,col;

int row_check(int num ){

  for(int i=0;i<row.size();i++){
    if(row[i] == num){
      return 0;
    }
  }
return 1;
}

int col_check(int num ){

  for(int i=0;i<col.size();i++){
    if(col[i] == num){
      return 0;
    }
  }
return 1;
}



int main() {

 
int n,m;
cin>>n>>m;

char a[n][m];
REP(i,n){
  REP(j,m){
    cin>>a[i][j];
  }
}


// REP(i,n) {
//   REP(j,m) {
//     cout<<a[i][j];
//   }
//   cout<<"\n";
// }

REP(i,n) {
  int cnt = 0;


  REP(j,m){
    if(a[i][j] == '.'){
      cnt++;
    }
  }
  if(cnt == m){
    row.push_back(i);
  }
}
// cout<<"\n\n";

REP(i,m){
  int cnt = 0;
  REP(j,n){
     if(a[j][i] == '.')
     { cnt++;}
    // cout<<a[j][i];
    
  }
 
 if(cnt == n){
   col.push_back(i);
 }

  // cout<<"\n";
}



// for(int i=0;i<row.size();i++){
//   cout<<row[i]<<" ";
// }
// cout<<"\n";

// for(int i=0;i<col.size();i++){
//   cout<<col[i]<<" ";
// }


for(int i=0;i<n;i++){
  for(int j=0;j<m;j++){

    if( row_check(i) && col_check(j)){
      cout<<a[i][j];
    }
  }
  cout<<"\n";
}





  
  return 0;
}


Measured memory_bytes: 3632
#include<iostream>
using namespace std;
unsigned gcd(unsigned a, unsigned b);


int main(){
    int N,X;
    cin >> N >> X;
    int max = 0,x[N];
    cin >> x[0];
    max = abs(x[0]-X);
    for(int i=1;i<N;i++){
        cin >> x[i];
        max = gcd(max, abs(x[i]-X));
        if(max == 1){
            break;
        }
    }
    cout << max << endl;
    return 0;
}

unsigned gcd(unsigned a, unsigned b) {
    if(a < b) gcd(b, a);
    unsigned r;
    while ((r=a%b)) {
        a = b;
        b = r;
    }
    return b;
}

Measured memory_bytes: 640
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Numerics;

class Program
{
    const int MOD = 1000000007;
    static void Main(string[] args)
    {
        new Program().Solve();
    }

    void Solve()
    {
        Scanner cin = new Scanner();
        int n = cin.NextInt();
        int l = cin.NextInt();

        int minTaste = 10000;
        int sum = 0;

        for (int i = 1; i <= n; i++)
        {
            int taste = i + l - 1;
            if (Math.Abs(minTaste) > Math.Abs(taste))
            {
                minTaste = taste;
            }
            sum += taste;
        }

        var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(sw);

        Console.WriteLine(sum - minTaste);
        Console.Out.Flush();
        
    }
}


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 char[] ArrayChar()
    {
        return Next().ToCharArray();
    }
    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[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = NextDouble() + add;
        }
        return Array;
    }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
const int MOD=1e9+7;


int main() {
    ios_base::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    ll ans=0;
    rep(i,n) {
        ans+=a[i]/2;
        if (a[i+1]>0) a[i+1]+=a[i]%2;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
cal = []
cals = []

while True:
    cal =list(map(str, input().split()))
    if cal[1] == "?":
        break
    cals.append(cal)

for i in range(len(cals)):
    cal = cals[i]
    a = int(cals[i][0])
    b = int(cals[i][2])
    op = cals[i][1]
    if op == "+":
        print(a + b)
    elif op == "-":
        print(a - b)
    elif op == "*":
        print(a * b)
    elif op == "/":
        print(a // b)


Measured memory_bytes: 5600
y=raw_input()
f=0
if len(y)==1:
    print -1,-1
elif len(y)==2:
    if y[0]==y[1]:
        print 1,2
    else:
        print -1,-1
else:
    for i in range(len(y)-2):
        if y[i]==y[i+1] or y[i+1]==y[i+2] or y[i+2]==y[i]:
            print i+1,i+3
            f=1
            break
    if f!=1:
        print -1,-1

Measured memory_bytes: 10864
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int di[] = {0, 0, 1, -1};
constexpr int dj[] = {1, -1, 0, 0};

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

    string s;
    cin >> s;

    ll dp[100010][13];
    memset(dp, 0, sizeof(dp));

    dp[0][0] = 1;

    for (int i = 0; i < s.size(); i++)
    {
        for (int j = 0; j < 13; j++)
        {
            if (s[i] == '?')
            {
                for (int k = 0; k <= 9; k++)
                {
                    int num = j * 10 + k;
                    num %= 13;

                    (dp[i + 1][num] += dp[i][j]) %= MOD;
                }
            }
            else
            {
                int num = j * 10 + (s[i] - '0');
                num %= 13;

                (dp[i + 1][num] += dp[i][j]) %= MOD;
            }
        }
    }

    cout << dp[s.size()][5] << endl;

    return 0;
}

Measured memory_bytes: 10704
//Vatsal Gupta
#ifdef __APPLE__
#include <iostream>
#include <cstring>
#include <string>
#include <cstdio>
#include <cctype>
#include <stack>
#include <list>
#include <queue>
#include <map>
#include <sstream>
#include <cmath>
#include <limits>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <bitset>
#include <utility>
#include <set>
#include <numeric>
#else
#include<bits/stdc++.h>
#endif

using namespace std;

typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<vi> vvi;

#define lli long long int
#define ulli unsigned long long int

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define ALL(a) a.begin(),a.end()
#define SZ(a) (int)(a.size())

#define loop(i,a,b) for(int i=a; i<b; i++)

int gcd(int a, int b) {return b==0?a:gcd(b,a%b);}
int lcm(int a, int b) {return a*(b/gcd(a,b));}

#define INF 1000000000  //(10^9)
#define MOD 1000000007  //(10^9+7)

//FILE *fin = freopen("in","r",stdin);
//FILE *fout = freopen("out","w",stdout);

vector<lli> arr(100010);

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

	lli n, x, ans=0;
	cin>> n>> x;
	loop(i,0,n)
		cin>> arr[i];
	loop(i,0,n-1)
	{
		lli val;
		val= arr[i]+arr[i+1];
		if(val>x)
		{
			val= val-x;
			ans+= val;
			if(arr[i+1]>= val)
				arr[i+1]= arr[i+1]-val;
			else
			{
				val= val-arr[i+1];
				arr[i+1]= 0;
				arr[i]= arr[i]-val;
			}
		}
	}
	cout<< ans<< "\n";


	return 0;
}


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

using namespace std;

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

  int a, b, c, x, y;
  cin >> a >> b >> c >> x >> y;

  int total = 0;

  if (a >= 2 * c) {
    y -= x;
    total += 2 * c * x;
    x = 0;
  }

  if (b >= 2 * c && y > 0) {
    x -= y;
    total += 2 * c * y;
    y = 0;
  }

  if (a + b >= 2 * c && x > 0 && y > 0) {
    int n = min(x, y);
    x -= n;
    y -= n;
    total += 2 * n * c;
  }

  if (x > 0) {
    total += a * x;
  }

  if (y > 0) {
    total += b * y;
  }

  cout << fixed << total << endl;

  return 0;
}


Measured memory_bytes: 256
N = int(input())
S = input()
x = 0
add = [0]
S_list = [i for i in S]
for j in S_list:
    if j == 'I':
        x += 1
        add.append(x)
    elif j == 'D':
        x -= 1
        add.append(x)
print(max(add))

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

//#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

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;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main()
{
  gearup;
  int n; cin >> n;
  vl a(n);
  rep(i,n)cin>>a[i];
  ll res = 0;
  rep(i,n){
    while(a[i]%2 == 0){  
      res++;
      a[i]/=2;
    }
  }
  out(res);
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define newl "\n"
using namespace std;
using lli = long long int;
using vvint = vector <vector <int>>;
const int mod = 1e9 + 7;

const int N = 2e5 + 1;

void solve(){
	lli n;
	cin >> n;
	lli ten = 1, nine = 1, eight = 1;
	for(int i = n;i >= 1;--i){
		ten = ten * 10 % mod;
		nine = nine * 9 % mod;
		eight = eight * 8 % mod;
	}
	lli ans = ten - nine * 2 + eight;
	ans = ans % mod;
	cout << (ans + mod) % mod << newl;
	return;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout << fixed << setprecision(10);
	#ifdef EXECUTE_LOCALLY
		   freopen("in.txt","r",stdin);
	#endif
	int t = 1;
	//cin >> t;
	while(t--) solve();
	#ifdef EXECUTE_LOCALLY
    	cout << setprecision(3) << "program time: " << (double)clock() / CLOCKS_PER_SEC << newl;
	#endif
	return 0;
}


Measured memory_bytes: 3644
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;
static const int giga = pow(10,9);

int main(void){
  int s;
  cin >> s;
  vector<int> a;
  a.push_back(s);
  
  for(int i = 0; ; i++){
    for(int j = 0; j < i; j++){
      if(a[i] == a[j]){
	cout << i+1 << endl;
	return 0;
      } else {
	
      }
    }
    int temp;
    if(a[i]%2 == 0){
      temp = a[i]/2;
      a.push_back(temp);
    } else {
      temp = a[i]*3 + 1;
      a.push_back(temp);      
    }
  }
  return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int num1 = sc.nextInt();
        int num2 = sc.nextInt();
        String str = sc.next();
        
        String str1 = str.substring(0,num2 - 1);
        String str2 = str.substring(num2 - 1, num2);
        String str3 = str.substring(num2);

        System.out.println(str1 + str2.toLowerCase() + str3);
    }
}

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

int main(){
    char N[4];
    
    for(int i=0; i<4; i++){
        cin >> N[i];
    }
    if(N[0]==0){
        cout << "No" << endl;
    }else if(N[1]==N[2] && N[2]==N[3]){
        cout << "Yes" << endl;
    }else if(N[0]==N[1] && N[1]==N[2]){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

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

ans = []
chars = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j"]
def func(N, s):
    if len(s) == N:
        ans.append(s)
        return

    if len(s) == 0:
        size = 1
    else:
        size = 0
        for c in s:
            size = max(size, ord(c) - 95)
    for c in chars[:size]:
        func(N, s+c)

func(N,"")

ans.sort()
for i in range(len(ans)):
    print(ans[i])

Measured memory_bytes: 12664
#include<bits/stdc++.h>
using namespace std;
char c[21][21];

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int maximum(int i,int j,int n,int m)
{
    int d[n][m],ans=0; bool v[n][m];
    memset(d,0,sizeof(d));
    memset(v,0,sizeof(v));
    d[i][j]=0; v[i][j]=1;
    queue<pair<int,int> >q; q.push(make_pair(i,j));
    while(!q.empty())
    {
        pair<int,int> z=q.front(); q.pop();
        int a=z.first,b=z.second;
        for(int i=0; i<4; i++)
        {
            int g,h;
            g=a+dx[i];
            h=b+dy[i];
            if(g>=0 && g<n && h>=0 && h<m && c[g][h]=='.' && !v[g][h])
            {
                v[g][h]=1;
                q.push(make_pair(g,h));
                d[g][h]=d[a][b]+1;
            }
        }
    }
    for(int i=0; i<n; i++)
        for(int j=0; j<m; j++)
            ans=max(ans,d[i][j]);
    return ans;
}

int main()
{
    int n,m,ans=0;
    cin>>n>>m;
    for(int i=0; i<n; i++)
        cin>>c[i];
    for(int i=0; i<n; i++)
        for(int j=0; j<m; j++)
            if(c[i][j]=='.') ans=max(ans,maximum(i,j,n,m));
    cout<<ans<<endl;
    return 0;
}


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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define all2(a, b) (a).begin(), (a).begin() + (b)
#define debug(vari) cerr << #vari << " = " << (vari) << endl;

int ck(ll a, ll b)
{
    int t_a = 0, t_b = 0;
    while (a)
    {
        t_a++;
        a /= 10;
    }
    while (b)
    {
        t_b++;
        b /= 10;
    }

    return max(t_a, t_b);
}

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

    int ans = 1001001001;
    for (ll a = 1; a * a <= n; a++)
    {
        if (n % a != 0)
        {
            continue;
        }
        ll b = n / a;
        ans = min(ans, ck(a, b));
    }

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

Measured memory_bytes: 3644
/**
 *    author:  tourist
 *    created: 16.03.2019 15:14:06       
**/
#include <bits/stdc++.h>

using namespace std;

vector<int> inv(vector<int> a) {
  int n = (int) a.size();
  vector<int> b(n);
  for (int i = 0; i < n; i++) b[a[i]] = i;
  return b;
}

void output(vector<int> a) {
  int n = (int) a.size();
  for (int i = 0; i < n; i++) {
    if (i > 0) cout << " ";
    cout << a[i] + 1;
  }
  cout << '\n';
  exit(0);
}

vector<int> apply(vector<int> a, vector<int> b) {
  int n = (int) a.size();
  vector<int> c(n);
  for (int i = 0; i < n; i++) {
    c[i] = a[b[i]];
  }
  return c;
}

vector<int> power(vector<int> a, int b) {
  int n = (int) a.size();
  vector<int> x(n);
  iota(x.begin(), x.end(), 0);
  while (b > 0) {
    if (b & 1) {
      x = apply(x, a);
    }
    a = apply(a, a);
    b >>= 1;
  }
  return x;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    a[i]--;
  }
  vector<int> b(n);
  for (int i = 0; i < n; i++) {
    cin >> b[i];
    b[i]--;
  }
  vector<int> A = inv(a);
  vector<int> B = inv(b);
  if (k == 1) {
    output(a);
  }
  if (k == 2) {
    output(b);
  }
  int pref = (k * 2 - 4) / 3;
  vector<int> p = power(apply(b, apply(A, apply(B, a))), pref / 4);
  if (pref % 4 == 3) p = apply(p, apply(b, apply(A, B)));
  if (pref % 4 == 2) p = apply(p, apply(b, A));
  if (pref % 4 == 1) p = apply(p, b);
  vector<int> P = inv(p);
  vector<int> res = P;
  if (k % 6 == 1) res = apply(a, res);
  if (k % 6 == 2) res = apply(b, res);
  if (k % 6 == 3) res = apply(b, apply(A, res));
  if (k % 6 == 4) res = apply(A, res);
  if (k % 6 == 5) res = apply(B, res);
  if (k % 6 == 0) res = apply(B, apply(a, res));
  res = apply(p, res);
  output(res);
  return 0;
}


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

/** Application main entry point. */
int main (
  int     argc,
  char  * argv[ ]
  )
{
  char buf[ 1024 ], *p;
  int n;

  fgets ( buf, sizeof ( buf ), stdin );
  n = atoi ( buf );

  while ( n-- )
  {
    fgets ( buf, sizeof ( buf ), stdin );

    p = buf;
    while ( ( p = strstr ( p, "Hoshino" ) ) != NULL )
    {
      p += 6;
      *p = 'a';
    }

    fputs ( buf, stdout );
  }

  return ( 0 );
}

Measured memory_bytes: 0
// ------- PBDS ------ //
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
// ------- PBDS ------ //

#pragma GCC optimize("Ofast")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define ll long long
#define testcase ll tt; cin>>tt; while(tt--)
#define pb push_back
#define nn cout<<"\n"
#define MOD 1000000007
#define pi 3.1415926535
#define endl "\n"
#define vll vector<ll>
#define MULTI int T; cin >> T; while(T--)
#define all(a)      (a).begin(),(a).end()
#define here cout<<"I'm here\n";
void vout(vector<ll> ans){
    for(auto ele:ans) cout<<ele<<" "; cout<<endl;
}
vector<ll> adj[200001];
bool vis[200001];

// ------- PBDS ------ //
typedef tree<
// change this for any data-type
string,
null_type,
// change this for any data-type
less<string>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;

/*
    to get the position of an element in set , do
    s.order_of_key(ele);
    this returns the number of elements strictly lesser than ele in set s
    Let us assume we have a set s : {1, 5, 6, 17, 88}, then :
    s.order_of_key(6) : Count of elements strictly smaller than 6 is 2.
    s.order_of_key(25) : Count of elements strictly smaller than 25 is 4.

    to get the element at position k
    s.find_by_order(k);
    returns an iterator to the ele counting from 0
    Let us assume we have a set s : {1, 5, 6, 17, 88}, then :
    *(s.find_by_order(2)) : 3rd element in the set i.e. 6
    *(s.find_by_order(4)) : 5th element in the set i.e. 88
*/

// ------- PBDS ------ //

clock_t time_p=clock();
void purvansh11()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}

//BINARY EXPONENTIATION  -- O(log2(b))
ll power(ll a, ll b) {
    /*
        for 3^11 :
        as 11 -> 1011, we mean 3^8 * 3^2 * 3^1
        so multiply for all ones in binary rep of b
    */

    ll ans = 1;
    ll num = a;
    while (b > 0) {
        if (b & 1) ans = ((ans % MOD) * (num % MOD)) % MOD;
        num = ((num % MOD) * (num % MOD)) % MOD;
        b /= 2;
    }
    return ans;
}
ll n,w;
vector<ll> wt,val;
ll dp[101][100001];
ll solve(ll i,ll w){
    if(i==n) return 0;

    if(dp[i][w]!=-1) return dp[i][w];

    if(w-wt[i]>=0){
        return dp[i][w] = max(val[i] + solve(i+1,w-wt[i]),solve(i+1,w));
    }
    else{
        return dp[i][w] = solve(i+1,w);
    }
}
int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    SPEED;
    cout.precision(8);
    cout << fixed;
    memset(dp,-1,sizeof(dp));
    cin>>n>>w;
    for(ll i=0;i<n;i++){
        ll a,b;
        cin>>a>>b;
        wt.pb(a);
        val.pb(b);
    }
    cout<<solve(0,w);
    purvansh11();
    return 0;
}

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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n; cin>>n;
	vector<int>v(n,1);
	int ans=1;
	for(int i=2;i<=n;++i){
		int num=i;
		for(int j=2;j<=n;++j){
			while(num&&num%j==0){
				num/=j;
				++v.at(j-1);
			}
		}
	}
	for(auto&i:v)ans=(int64_t)ans*i%(int64_t)(1e9+7);
	cout<<ans<<"\n"s;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define inf 1000000000
#define INF 1000000000000000
#define ll long long
#define ull unsigned long long
#define M 1000000007
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S second
#define int ll

int n;
int a[1000000];
int m = 1;

signed main(){
  int ans=0;
  cin>>n;
  rep(i,n){
    cin>>a[i];
    ans += a[i]-1;
  }

  cout<<ans<<endl;
}

Measured memory_bytes: 256
'use strict';
(function(stdin) {
  var line = stdin.split('\n');
  var param = line[0].split(' ').map(Number);
  var result = (function(a,b,c) {
    return {true:'Yes',false:'No'}[(a < b && b < c)];
 
  }(
    param[0],param[1],param[2]
  ));
  console.log(result);
}(require('fs').readFileSync('/dev/stdin', 'utf8')));

Measured memory_bytes: 7380
#include<bits/stdc++.h>
using namespace std;
#define TRACE
#define M 1000000007
#define oo 1000000000000000007
#define F first
#define S second
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> pll;
#define pb push_back
#define M6 5000009
#define M5 100009
#define pi 3.14159265
#define epsilon 1e-6

#ifdef TRACE
    #define trace1(x)                cerr << #x << ": " << x << endl;
    #define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
    #define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
    #define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
    #define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
    #define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;
 
#else
 
    #define trace1(x)
    #define trace2(x, y)
    #define trace3(x, y, z)
    #define trace4(a, b, c, d)
    #define trace5(a, b, c, d, e)
    #define trace6(a, b, c, d, e, f)
 
#endif

ll n,m,A[M6],F[M6];
int  main()
{   //ios_base::sync_with_stdio (0), cin.tie (0);
    //sieve();
    //init();
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    ll tc=1,t=0,i,j,k,a,b,c,d,l,r;
    //cin>>tc;
    while(t++<tc){
//        cout<<"Case #"<<t<<": ";
        cin>>a>>b;
        b-=a;
        cout<<ceil(b*1.0/(a-1))+1;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int a,b,c,d;
    
    cin >> a >> b >> c >> d;
    if((abs(b - a) <= d && abs(c - b) <= d) || abs(c - a) <= d)
    cout << "Yes" << endl;
    else{
        cout << "No" << endl;
    }
    return 0;
}

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

using namespace std;

using ll = long long;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int ans = 0;
    for (int i = 1; i <= n; i++) {
        string s = to_string(i);
        ans += (s.size() % 2 == 1);
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
    int n,cnt;
    string s;
    cin>>n>>s;
    
    for(int i=0;i<1000;i++){
        int c[3]={i/100,(i/10)%10,i%10};
        int f=0;
        
        for(int j=0;j<n;j++){
            if((s[j]-'0')==(c[f])) f++;
            if(f==3) break;
        }
        if(f==3){
            //cout<<c[2]<<c[1]<<c[0]<<endl;
            cnt++;
        }
    }
    
    cout<<cnt<<endl;
    
}

Measured memory_bytes: 256
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys, math, bisect, random, itertools
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return list(map(list, input().split()))
def S(): return list(input().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    a, b = LI()
    if (a + b) % 2:
        print("IMPOSSIBLE")
        return
    print((a + b) // 2)
    return

#B
def B():
    n = II()
    p = LI()
    for i in range(n):
        for k in range(i+1, n):
            pi = p[::1]
            pi[i], pi[k] = pi[k], pi[i]
            for j in range(n-1):
                if pi[j] > pi[j + 1]:
                    break
            else:
                print("YES")
                return
    print("NO")
    return

#C
def C():
    n = II()
    a = LI()
    b = LI()
    ans = 0
    for i in range(n):
        if a[i] >= b[i]:
            ans += b[i]
            continue
        ans += a[i]
        b[i] -= a[i]
        if a[i + 1] >= b[i]:
            ans += b[i]
            a[i + 1] -= b[i]
            continue
        ans += a[i + 1]
        a[i + 1] = 0
    print(ans)
    return

#D
def D():
    s = S()
    s = s[::-1]
    dp = [[0] * 13 for _ in range(len(s))]
    remain = 1
    if s[0] == "?":
        for i in range(10):
            dp[0][i] = 1
    else:
        dp[0][int(s[0])] = 1
    for i in range(1, len(s)):
        remain = (remain * 10) % 13
        dpi = dp[i]
        dpi1 = dp[i-1]
        if s[i] == "?":
            for k in range(10):
                for j in range(13):
                    dpi[(j + remain * k) % 13] += dpi1[j]
                    dpi[(j + remain * k) % 13] %= mod
        else:
            for j in range(13):
                dpi[(j + remain * int(s[i])) % 13] += dpi1[j]
    print(dp[-1][5])
    return

#E
def E():
    return

#F
def F():
    return

#Solve
if __name__ == '__main__':
    A()


Measured memory_bytes: 40560
#include<stdio.h>

static void CheckZero(int* a_aiX);

static int s_iCount;

int main(void) {
	int aiX[5] = { 0,0,0,0,0 };
	int i;
	//5つの変数それぞれに数値を入力
	for (i = 0;i < 5;i++) {
		scanf("%d", &aiX[i]);
	}
	//結果を出力

	CheckZero(aiX);

	printf("\n%d\n", s_iCount);

	return 0;
}

/**********
*	0を確認する関数
*	*a_aiX	入力された5つの変数
*/
static void CheckZero(int* a_aiX) {
	int j;
	for (j = 0;j < 5;j++) {
		//0があったらループを抜ける
		if (a_aiX[j] == 0) {
			break;
		}
		else {}
	}
	s_iCount = j + 1;
	return;
}


Measured memory_bytes: 1672
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define ALL(x) (x).begin(),(x).end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
int main(){
  int n;
  cin >> n;
  vector<int> vec(n);
  set<int> s;
  REP(i,n){
    cin >> vec.at(i);
    s.insert(vec.at(i));
  }
  if (n > s.size())
    cout << "NO" << endl;
  else
    cout << "YES" << endl;
}

Measured memory_bytes: 10368
#include <iostream>
#include <map>
#include <string>
using namespace std;

int main() {
  string w;
  cin >> w;

  map<char, int> count;
  for (auto s : w) {
    count[s] += 1;
  }
  for (auto itr = count.begin(); itr != count.end(); itr++) {
    if (itr->second % 2 == 1) {
      cout << "No" << endl;
      return 0;
    }
  }

  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 888