akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;

namespace CSharpScript
{
	class Program
	{
		static void Main(string[] args)
		{
			var input = Console.ReadLine();
			var stack = new Stack<char>();

			foreach (var item in input)
			{
				if (stack.Count > 0 && item == 'T' && stack.Peek() == 'S')
				{
					stack.Pop();
				}
				else
				{
					stack.Push(item);
				}
			}

			System.Console.WriteLine(stack.Count);

		}
	}
}

Measured memory_bytes: 12256
#include<bits/stdc++.h>
using namespace std;
    int main(){
        string S;
            int x = 0;
                cin >> S;
                    for(int i = 0; i < 3; i++){
                        if(S.at(i) == '1'){
                            x += 1;
                        }else{}
                    }
                        cout << x << endl;
    return 0;}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define pb push_back
#define ALL(v) v.begin(),v.end()
const long long INF = 1LL << 60; // 仮想的な無限大の値;
using namespace std;
using ll = long long;
using P = pair<int, int>;
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; }
using Graph = vector<vector<int>>;
int main()
{
    int N;
    cin >> N;
    vector<int> X(N, 0);
    rep2(i, 1,  N){
        int a;cin >> a;--a;
        X[a]++;
    }
    rep(i, N){
        cout << X[i] <<endl;
    }
    return 0;
}

Measured memory_bytes: 3996
#include <cstdio>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
using namespace std;
vector<bool> prime_table(int n) {
  vector<bool> prime(n + 1, true);
  if(n >= 0) prime[0] = false;
  if(n >= 1) prime[1] = false;
  for(int i = 2; i * i <= n; i++) {
    if(!prime[i]) continue;
    for(int j = i + i; j <= n; j += i) {
      prime[j] = false;
    }
  }
  return prime;
}
int main() {
    int Q;
    scanf("%d%*c", &Q);
    auto primes = prime_table(100000);
    vector<int> s(primes.size(), 0);
    for (int i = 1; i < s.size(); i++) {
        s[i] = s[i - 1] + (primes[i] && primes[(i + 1) / 2]);        
    }
    for (int i = 0, l, r; i < Q; i++) {
        scanf("%d %d%*c", &l, &r);
        printf("%d\n", s[r] - s[l - 1]);
    }
}


Measured memory_bytes: 1024
#include<iostream>
#include<cstring>
#include<cstdio>
#define MN 500000
using namespace std;
inline int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
struct data
{
	int l,r,mx,ok,nine,zero,Lp;
	data(){}
	data(int k,int p){l=r=k;Lp=mx=p;nine=k==9,zero=k==0;ok=1;}
	data operator + (const data&b)
	{
		data c;c.l=l;c.r=b.r;c.Lp=Lp;
		c.ok=ok&b.ok&(r<=b.l);
		if(b.mx>b.Lp) c.mx=max(mx,(ok&&r<=b.l)?b.mx:0);
		else c.mx=max(mx,(ok&&r<b.l)?b.mx:0);
		c.nine=nine&b.nine;
		c.zero=zero&b.zero;
		return c;
	}
};
char st[MN+5];int n,ans=0;
struct Tree{int l,r,tag;data x;}T[MN*4+5];
void Build(int x,int l,int r)
{
	if((T[x].l=l)==(T[x].r=r)){T[x].x=data(st[l]-'0',l);return;}
	int mid=l+r>>1;
	Build(x<<1,l,mid);Build(x<<1|1,mid+1,r);
	T[x].x=T[x<<1].x+T[x<<1|1].x;
}
inline void Mark(int x){T[x].tag=1;T[x].x=data(0,T[x].l);}
inline void pushdown(int x){Mark(x<<1),Mark(x<<1|1),T[x].tag=0;}
void Modify(int x,int l,int r)
{
	if(T[x].l==l&&T[x].r==r)return Mark(x);
	int mid=T[x].l+T[x].r>>1;
	if(T[x].tag) pushdown(x);
	if(r<=mid) Modify(x<<1,l,r);
	else if(l>mid) Modify(x<<1|1,l,r);
	else Modify(x<<1,l,mid),Modify(x<<1|1,mid+1,r);
	T[x].x=T[x<<1].x+T[x<<1|1].x; 
}
void Add(int x)
{
	if(T[x].l==T[x].r) {T[x].x=data(T[x].x.l+1,T[x].l);return;}
	if(T[x].tag) pushdown(x);
	if(T[x<<1|1].x.nine) Mark(x<<1|1),Add(x<<1);
	else Add(x<<1|1);
	T[x].x=T[x<<1].x+T[x<<1|1].x; 
}
int main()
{
	scanf("%s",st+1);n=strlen(st+1);
	Build(1,1,n);
	while(!T[1].x.zero)
	{
		int p=T[1].x.ok?n:T[1].x.mx;
		Modify(1,1,p);if(p^n) Add(1);
		++ans;
	}
	cout<<ans;
	return 0;
}



Measured memory_bytes: 43776
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <string>
#include <sstream>
#include <iomanip>
#include <complex>
using namespace std;

#define ll long long
#define vvi vector< vector<int> >
#define vi vector<int>
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define pi 3.14159265359
#define shosu(X) fixed << setprecision(X)
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int data[10] = {-999,-1,0,1,-1,-999,1,-1,0,1};

int main(){
	string str;
	while(1){
		cin >> str;
		if(str=="#") break;
		int pos[2] = {0,0};//left,right
		int nextuse = 1;//0 left 1 right
		int rst1 = 0,rst2 = 0;
		pos[0] = data[str[0]-'0'];
		FOR(i,1,str.size()){
			int nextpos = data[str[i]-'0'];
			bool isok = true;
			if(nextuse==0){
				if(pos[1]>nextpos) isok = false;
			}else{
				if(pos[0]<nextpos) isok = false;
			}
			if(isok){
				pos[nextuse] = nextpos;
				nextuse = 1 - nextuse;
			}else{
				pos[1-nextuse] = nextpos;
				rst1++;
			}
		}

		nextuse = 0;
		pos[1] = data[str[0]-'0'];
		FOR(i,1,str.size()){
			int nextpos = data[str[i]-'0'];
			bool isok = true;
			if(nextuse==0){
				if(pos[1]>nextpos) isok = false;
			}else{
				if(pos[0]<nextpos) isok = false;
			}
			if(isok){
				pos[nextuse] = nextpos;
				nextuse = 1 - nextuse;
			}else{
				pos[1-nextuse] = nextpos;
				rst2++;
			}
		}
		cout << min(rst1,rst2) << endl;

	}
}

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

int main()
{
    string ans="YES";
    vector<int> a(3);
    cin >> a.at(0) >> a.at(1) >> a.at(2);
    REP(i,3){
        if(a.at(i)!=5&&a.at(i)!=7){
            ans = "NO";
        }
    }
    if (a.at(0) + a.at(1) + a.at(2)!=17){
        ans = "NO";
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iomanip>
#include <math.h>
#include <unistd.h>
#include <stdio.h>
#define all(a) (a).begin(),(a).end()
#define vecin(a) rep(i,a.size())cin >> a[i]
#define vecout(a) rep(i,a.size()){cout << a[i];cout << (i == a.size() - 1 ? "\n":" ");}
#define rep(i,x) for(int i = 0;i<x;i++)
#define REP(i,x) for(ll i = 1;i<=x;i++)
#define mp make_pair
using ll = long long;
using ld = long double;
using namespace std;
using dou = double;
const ll inf = 2147483647;
const ll INF = 1LL << 60;
const dou pi = 3.14159265358;
const ll mod = 1000000007LL;
//const ll mod = 998244353LL;
typedef pair<ll,ll> P;
using graph = vector<vector<ll>>;
template<class T> inline bool chmax(T& a, T b){if(a < b){a = b; return true;}return false;}
template<class T> inline bool chmin(T& a, T b){if(a > b){a = b; return true;}return false;}
template<class T> inline bool change(T a,T b){if(a > b){swap(a,b);return true;}return false;}
ll gcd(ll a,ll b){
    if(a < b)swap(a,b);
    if(a % b == 0)return b;
    else return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    return a / gcd(a,b) * b;
}

//素数判定O(sqrt(N))
bool isp(ll n){
    bool res = true;
    if(n == 1)return false;
    else{
        for(ll i = 2;i * i <= n;i++){
            if(n % i == 0){
                res = false;
                break;
            }
        }
        return res;
    }
}
const ll cmax = 1000000;
ll fac[cmax], finv[cmax], inv[cmax];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < cmax; i++){
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = mod - inv[mod%i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}

// 二項係数計算
ll nCk(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
//nのm乗をMODで割ったあまりO(logm)
ll modpow(ll n,ll m,ll MOD){
    if(m == 0)return 1;
    if(m < 0)return -1;
    ll res = 1;
    while(m){
        if(m & 1)res = (res * n) % MOD;
        m >>= 1;
        n *= n;
        n %= MOD;
    }
    return res;
}
ll mypow(ll n,ll m){
    if(m == 0)return 1;
    if(m < 0)return -1;
    ll res = 1;
    while(m){
        if(m & 1)res = (res * n);
        m >>= 1;
        n *= n;
    }
    return res;
}

ll num(ll n){//10^n~10^1
    ll res = 0;
    rep(i,n){
        res += mypow(10,i);
    }
    return res;
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll N,K;
    cin >> N >> K;
    vector<ll> vec(N);
    vecin(vec);
    rep(i,N - K){
        if(vec[i] < vec[i + K]){
            cout << "Yes\n";
        }
        else cout << "No\n";
    }
}

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

int main() {
  vector<long>table(100001,0);
  int n,max = 0;
  cin >> n;
  for(int i = 0;i < n;i++){
    long a;
    cin >> a;
    table[a]++;
    if(a != 0) table[a-1]++;
    table[a+1]++;
  }
  for(long i = 0;i < table.size();i++){
    if(max < table[i]){
      max = table[i];
    }
  }
  cout << max << endl;
}


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

#define pb push_back
#define mp make_pair
#define f1 first
#define s2 second

#define fastio ios :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define debug(x...) cerr << "[" << #x << "]: " << x << "\n";

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef pair<ll, ll> pl;

ld const PI = 4*atan((ld)1);

int main()
{
	fastio;

	int x;
	cin >> x;
	cout << 10 - x/200 << '\n';
	return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define INF (1<<30)-1
using ll = long long;
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if(a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if(b<a) { a=b; return 1; } return 0; }

int main(){
  int n,m; cin >> n >> m;
  if(2 <= abs(n-m)){
    cout << 0;
  }else{
    ll res1 = 1, res2 = 1;
    rep(i,n){ res1 *= i+1; res1 %= 1000000007; }
    rep(i,m){ res2 *= i+1; res2 %= 1000000007; }
    ll ans = 1;
    if(abs(n-m)==0) ans = 2;
    cout << ans*res1*res2 % 1000000007;
  }
  cout << "\n";
  return 0;
}


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

using namespace std;

#define INF ((1<<30)-1)  //int32_t
#define MOD 1000000007
#define MOD2 

#define all(a)  (a).begin(),(a).end()

#define mkp make_pair
#define pb push_back

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

int main(){

    bool flag=true;

    ll ans=0;
    
    int a,b,c;
    cin >>a>>b>>c;

    if(a!=b || b!=c || c!=a)flag=false;

    //cout <<fixed<<setprecision(16)<< << endl;
    //cout << ans << endl;

    if(flag)cout << "Yes" <<endl;
    else cout << "No" <<endl;
    
    return 0;
}


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

using namespace std;
typedef long long ll;





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

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


int main() {
    int N; cin >> N;
    vector<ll> T(N);
    for(ll& t:T) cin >> t;

    if(T.size()==1){
        cout << T[0] << endl;
        return 0;
    }

    vector<ll> l(N-1);
    for(int i=0; i<N-1; i++){
        if(i==0) l[i] = lcm(T[i], T[i+1]);
        else l[i] = lcm(l[i-1], T[i+1]);
    }

    cout << l[N-2] << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
int N,T;
  cin>>N>>T;
  vector<int>A(N);
  vector<int>B(N);
  vector<pair<int,int>>C(N);
  for(int i=0;i<N;i++){
  int a,b; cin>>a>>b;
    pair<int,int>p(a,b);
    C.at(i)=p;
  }sort(C.begin(),C.end());
  for(int i=0;i<N;i++){
  A.at(i)=C.at(i).first;
    B.at(i)=C.at(i).second;
  }vector<int>D(N);D.at(N-1)=B.at(N-1);
  for(int i=N-2;0<=i;i--)
    D.at(i)=max(B.at(i),D.at(i+1));
  vector<vector<int>>dp(N+1,vector<int>(T+1,0));
  for(int i=1;i<=N;i++){
  for(int j=0;j<T;j++){
  if(j<A[i-1])
    dp[i][j]=dp[i-1][j];
    else
      dp[i][j]=max(dp[i-1][j],dp[i-1][j-A[i-1]]+B[i-1]);
  }
  }int ans=0;
  for(int i=0;i<N;i++)
    if(ans<dp[i][T-1]+D[i])
      ans=dp[i][T-1]+D[i];
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 38552
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,k;
  long long int n[3];
  cin>>a>>b>>c;
  n[0]=a;
  n[1]=b;
  n[2]=c;
  sort(n,n+3);
  cin>>k;
  for(int i=0;i<k;i++){
    n[2]*=2;
  }
  cout<<n[0]+n[1]+n[2]<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cassert>
typedef long long lint;
const int N=2e5+5;
const int mod=1e9+7;
int n,pw2[N];

namespace utils{
	template <class T> inline void apn(T &x,const T y){x=x<y?x:y;}
	template <class T> inline void apx(T &x,const T y){x=x>y?x:y;}
	inline int nxi(){
		int x=0;
		char c;
		while(((c=getchar())>'9'||c<'0')&&c!='-');
		const bool f=c=='-'&&(c=getchar());
		while(x=x*10-48+c,(c=getchar())>='0'&&c<='9');
		return f?-x:x;
	}
}
using namespace utils;

namespace G{
	int cnt,fir[N],dep[N],xdep[N],son[N],dfn[N],idx[N];
	int cdep[N],dp[N][3],top[N];
	struct edge{
		int to,nx;
	}eg[N];

	inline void add(const int a,const int b){
		eg[++cnt]=(edge){b,fir[a]};
		fir[a]=cnt;
	}

	void upd(const int x,const int f){
		if(top[x]==f) return;
		top[x]=f;
		dp[x][0]=(dp[x][0]+dp[x][2])%mod;
		dp[x][2]=0;
	}

	void dfs_dep(const int x){
		++cdep[dep[x]];
		xdep[x]=dep[x];
		for(int i=fir[x]; i; i=eg[i].nx){
			const int y=eg[i].to;
			dep[y]=dep[x]+1;
			dfs_dep(y);
			if(xdep[x]<xdep[y]){
				son[x]=y;
				xdep[x]=xdep[y];
			}
		}
	}

	void dfs_ans(const int x){
		static int cnd;
		dfn[x]=++cnd;
		idx[cnd]=x;
		dp[x][0]=dp[x][1]=1;
		if(son[x]){
			dfs_ans(son[x]);
		}
		for(int i=fir[x]; i; i=eg[i].nx){
			const int y=eg[i].to;
			if(y==son[x]) continue;
			dfs_ans(y);
			for(int i=0; i<=xdep[y]-dep[y]; ++i){
				int tx=idx[dfn[x]+1+i],ty=idx[dfn[y]+i];
				upd(tx,x);
				int x0=dp[tx][0],x1=dp[tx][1],x2=dp[tx][2];
				int y0=(dp[ty][0]+dp[ty][2])%mod,y1=dp[ty][1];
				dp[tx][0]=(lint)x0*y0%mod;
				dp[tx][1]=((lint)x0*y1+(lint)x1*y0)%mod;
				dp[tx][2]=((lint)x1*y1+(lint)x2*(y0+y1))%mod;
			}
		}
	}

	int get_ans(){
		int ans=0;
		for(int x=0; ; x=son[x]){
			ans=(ans+(lint)dp[x][1]*pw2[n+1-cdep[dep[x]]])%mod;
			if(!son[x]) break;
		}
		return ans;
	}
}

int main(){
	n=nxi();
	pw2[0]=1;
	for(int i=1; i<=n; ++i){
		pw2[i]=(pw2[i-1]<<1)%mod;
	}
	for(int i=1; i<=n; ++i){
		G::add(nxi(),i);
	}
	G::dfs_dep(0);
	G::dfs_ans(0);
	printf("%d\n",G::get_ans());
	return 0;
}


Measured memory_bytes: 29440
#include<iostream>
using namespace std;
const int NMAX = 101;
const int WMAX = 100001;
template<class T> inline bool chmax(T& a, T b){if(a<b){a=b; return true;}return false;}

int N, W;
int w[NMAX], v[NMAX];
long long DP[NMAX][WMAX] = {};

int main(){
    cin >> N >> W;
    for(int i=0; i<N; i++) cin >> w[i] >> v[i];
    for(int i=0; i<N; i++){
        for(int j=0; j<W+1; j++){
            chmax(DP[i+1][j], DP[i][j]);
            if(j+w[i] > W) continue;
            chmax(DP[i+1][j+w[i]], DP[i][j]+v[i]);
        }
    }
    /*
    for(int i=0; i<N+1; i++){
        for(int j=0; j<W+1; j++) cout << DP[i][j] << " ";
        cout << endl;
    }*/
    cout << DP[N][W] << endl;
}

Measured memory_bytes: 78336
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <cmath>

using namespace std;

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

int main() {
    size_t a, b;
    cin >> a >> b;
    auto c = min(a, b);
    auto d = a * b;
    for (size_t i = c; i < d; i += c) {
        if (i % a == 0 && i % b == 0) {
            cout << i << endl;
            return 0;
        }
    }
    cout << d << endl;
    return 0;
}




Measured memory_bytes: 256
def resolve():
    N = int(input())
    A = list(map(int, input().split()))
    count = [0] * 10 ** 5
    for i in A:
        if i > 1:
            count[i - 1] += 1
        count[i] += 1
        if i < 10**5-1:
            count[i + 1] += 1
    print(max(count))
resolve()

Measured memory_bytes: 20692
import sys
n = int(input())

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


fn = factorization(n)

memo = {}
def f(a):
    fa = a
    if a in memo:
        return memo[a]
    if a == 1:
        memo[1] = 1
        return 1
    else: # a>1
        i = 1
        ret = 0
        while a >= i:
            a-=i
            i+=1
            ret+=1
        memo[fa] = ret
        return ret

ans = 0
for u, v in fn:
    ans+=f(v)
if n == 1:
    print(0)
else:
    print(ans)

Measured memory_bytes: 9444
#include<cstdio>
#include<queue>
#include<cmath>
#include<cstring>
using namespace std;
struct E{int to,next;long double cost;}g[5000005];
int xs,xt,ys,yt,x,y,r,n,h[2005],num,ringx[2005],ringy[2005],ringr[2005];
long double dis[2005],md;
bool vis[2005];
void ins(int u,int v,long double c){g[++num].to=v,g[num].next=h[u],g[num].cost=c,h[u]=num;}
long double dist(int a,int b){return sqrt(1ll*(ringx[a]-ringx[b])*(ringx[a]-ringx[b])+1ll*(ringy[a]-ringy[b])*(ringy[a]-ringy[b]))-ringr[a]-ringr[b];}
int main(){
	scanf("%d%d%d%d",&xs,&ys,&xt,&yt);
	scanf("%d",&n);
	for(int i=1;i<=n;++i) scanf("%d%d%d",&ringx[i],&ringy[i],&ringr[i]);
	ringx[n+1]=xs,ringy[n+1]=ys,ringx[n+2]=xt,ringy[n+2]=yt;
	for(int i=1;i<=n+2;++i)
		for(int j=i+1;j<=n+2;++j){
			long double d=dist(i,j);
			if(d<0) d=0;
			ins(i,j,d); ins(j,i,d);
		}
	for(int i=1;i<=n+2;++i) dis[i]=1e10;
    dis[n+1]=0;
    for(int i=1;i<=n+1;++i){
    	int u;md=1e10;
		for(int j=1;j<=n+2;++j)
			if(!vis[j]&&dis[j]<md)
				u=j,md=dis[j];
		vis[u]=1;
        if(u==n+2) break;
        for(int j=h[u];j;j=g[j].next){
            int v=g[j].to; long double c=g[j].cost;
            if(dis[v]>dis[u]+c) dis[v]=dis[u]+c;
        }
    }
    printf("%.15lf\n",(double)dis[n+2]);
}

Measured memory_bytes: 33024
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define FOR(i, s, n) for (int i = (s); i < (n); i++)
#define rep(i, n) FOR(i, 0, n)
#define repi(i, n) FOR(i, 1, n + 1)
#define pp(v) cout << #v "=" << (v) << endl;
#define ppa(v) cout << "----\n"; rep(i,v.size()) cout << #v << "[" << i << "] = " << v[i] << endl;
#define div_ceil(a,b) ((a) + ((b) - 1)) / (b)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using namespace std;
using Graph = vector<vector<int>>;
using ll = long long;

int main() {
  int w,a,b;cin>>w>>a>>b;
  int ans = max(0, max(b-a-w, a-b-w));
  cout << ans << endl;
}


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

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

  int ans = 0;
  for (int i = 0; i + 1 < n; ++i) {
    set<char> a, b;
    for (int j = 0; j < n; ++j) {
      if (j <= i)
        a.insert(s[j]);
      else
        b.insert(s[j]);
    }

    int cnt = 0;
    for (char c = 'a'; c <= 'z'; ++c) {
      if (a.count(c) && b.count(c)) cnt++;
    }

    ans = max(ans, cnt);
  }

  cout << ans << endl;
}


Measured memory_bytes: 764
#include <stdio.h>
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue> 
#include <tuple>
#include <map>
 
using namespace std;

typedef long long ll;

long long gcd(long long a, long long b) {

   	if(a < b) {
       swap(a, b);
   	}

	long long r = a % b;
	while(r != 0) {
		a = b;
		b = r;
		r = a % b;
	}

	return b;
}

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

    ll A, B;

    cin >> A >> B;

    ll x = gcd(A, B);

    ll c = 1;

    for(ll i = 2; i * i < x; i++) {
        if(x % i == 0) {
            c++;
            while(x % i == 0) {
                x /= i;
            }
        }
    }

    if(x != 1) c++;

    cout << c << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  long n,sum = 0;
  
  cin >> n;
  
  vector<int>a(n),h(n);
  for(int i = 0;i < n;i++)
    cin >> a.at(i);
  
  for(int i = 1;i < n;i++){
    int j = a.at(i - 1);
    int k = a.at(i);
    if(j > k){
      a.at(i) += j - k;
      sum += j - k;
    }
  }
  
  cout << sum << endl;
}

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

int main()
{
	int H,W;

	cin >> H >>W;

	vector<string> vec(H);
	for (int i = 0; i < H;i++) {
		cin >> vec.at(i);
	}
	for (int i = 0; i < W + 2;i++) {
		cout << '#';
	}
	cout << endl;
	for (int i = 0; i < H; i++) {
		cout << '#';
		cout << vec.at(i);
		cout << '#'<<endl;
	}
	for (int i = 0; i < W + 2; i++) {

		cout << '#';
	}
	cout << endl;

}


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

constexpr int inf = 0x3f3f3f3f;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  vector<vector<int>> g(n, vector<int>(n));
  int sum_w = 0;
  while (m--) {
    int u, v, w;
    cin >> u >> v >> w;
    --u, --v;
    g[u][v] = g[v][u] = w;
    sum_w += w;
  }
  vector<int> sum(1 << n);
  for (int bt = 1; bt < 1 << n; ++bt) {
    int v = __builtin_ctz(bt);
    sum[bt] = sum[bt ^ 1 << v];
    for (int u = 0; u < n; ++u) {
      if (bt >> u & 1) {
        sum[bt] += g[v][u];
      }
    }
  }
  vector<vector<int>> dp(n, vector<int>(1 << n, -inf));
  for (int bt = 1; bt < 1 << n; bt += 2) {
    dp[0][bt] = sum[bt];
  }
  for (int bt = 0; bt < 1 << n; ++bt) {
    for (int v = 0; v < n; ++v) {
      if (dp[v][bt] == -inf) {
        continue;
      }
      int cbt = bt ^ ~-(1 << n);
      for (int nxt = cbt; nxt; nxt = (nxt - 1) & cbt) {
        for (int nv = 0; nv < n; ++nv) {
          if (nxt >> nv & 1 and g[v][nv]) {
            dp[nv][bt | nxt] = max(dp[nv][bt | nxt], dp[v][bt] + g[v][nv] + sum[nxt]);
          }
        }
      }
    }
  }
  int res = sum_w - dp.back().back();
  cout << res << '\n';
}


Measured memory_bytes: 2560
function Main(input) {
  var list = input.split("\n");
  var N = parseInt(list[0]);
  var Hlist = list[1].split(" ");
  var H = Array(N);
  var check;
  var ans = 0;
  
  for(i=0;i<N;i++){
    H[i] = parseInt(Hlist[i]);
  }
  
  for(i=0;i<N;i++){
    check = 0;
    for(j=0;j<i;j++){
      if(H[i]<H[j])check = 1;
    }
    if (check == 0) ans++;
  }
    
    
  console.log(ans);
}
 
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
# ARC061C - たくさんの数式 / Many Formulas (ABC045C)
from itertools import product


def main():
    S = input()
    if "\n" in S:
	    return
    ans = 0
    for ops in tuple(product(("", "+"), repeat=len(S) - 1)):
        ops = ops + ("",)  # operators
        exp = "".join(i + j for i, j in zip(S, ops))  # expression
        ans += eval(exp)
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
import sys

input = sys.stdin.readline


def solve():
    MOD = 10**9+7
    N = int(input())
    A_L = tuple(int(x) for x in input().split())
    cum_a_l = [0] * N
    cum_a_l[0] = A_L[0]
    for i in range(1, N):
        cum_a_l[i] = (cum_a_l[i-1] + A_L[i]) % MOD
    ans = 0

    for i in range(N-1, 0, -1):
        ans = (ans + cum_a_l[i-1]*A_L[i] % MOD) % MOD
    print(ans)


solve()


Measured memory_bytes: 93568
#include<stdio.h>
#include<cstdio>
#include<stdlib.h>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cmath>
#include<vector>

#include<stack>
#include<queue>
#include<time.h>
#include<set>
#include<map>
#include <iomanip>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i>b;i--)
#define vint vector<int> 
#define vvint vector<vint>
#define ct(a) cout<<a<<endl
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll mod = 998244353;

string S;

ll N,K,cnt;
ll p[35];
ll ans;
bool flag;
int main() {

	cin.tie(0);
	ios::sync_with_stdio(false);


	cin >> N;
	FOR(i, 0, N) {
		cin >> p[i];
	}
	FOR(i, 0, N - 2) {
		if (max({ p[i],p[i + 1],p[i + 2] }) != p[i+1]) {
			if (min({ p[i],p[i + 1],p[i + 2] }) != p[i + 1]) {
				cnt++;
			}
		}
	}
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <algorithm>
#include <iomanip>
using namespace std;
typedef vector<int> vint;
typedef vector<string> vstr;




int main()
{
	int A, B;
	char op;
	cin>>A>>op>>B;
	if (op == '+')cout << A + B << endl;
	else cout << A - B << endl;
}

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

int main(void){
    int R, G, B, N, r, g, b, n;
	cin >> R >> G >> B >> N;
	g = 0;
	n = 0;
	int inter;
	for (int r = 0; r <= (N / R); r++){
        for (int g = 0; g <= (N - r * R) / G; g++){
			inter = N - R * r - G * g;
			if (inter % B == 0){
				b = inter / B;
				n++;
				continue;
			}else{
				continue;
			}
		}
	}
	cout << n << endl;
}

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

using namespace std;

int main(void) {

	vector<string> w;

	string s,tmp;

	bool jud = true;

	int n;

	cin >> n;

	for (int i = 0; i < n; i++) {
		cin >> tmp;
		w.push_back(tmp);
		//cout << w.at(i) << "\n";
		for (int l = 0; l <= i; l++) {
			if (l != i&&w.at(i)==w.at(l)) {
				jud = false;
				//cout << "t\n";
			}	
		}
		
		if (i >= 1 && w[i].front() != w[i-1].back()) {
			jud = false;
			//cout << "d\n";
		}
	}

	if (jud == true)cout << "Yes\n";
	else cout << "No\n";
	

	return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
h = list(map(int, input().split()))
peaks = {}
for i in range(n):
    peaks[i] = []
for j in range(m):
    a, b = map(int, input().split())
    peaks[a-1].append(b-1)
    peaks[b-1].append(a-1)
cnt = 0
for key, value in peaks.items():
    maxVal = 0
    for num in value:
        if h[num] > maxVal:
            maxVal = h[num]
        else:
            continue
    if h[key] > maxVal:
        cnt += 1
print(cnt)


Measured memory_bytes: 37944
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template <typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010

ll dp[201][201];

ll build(int num[5], bool hasZero) {
  int N = num[1] + num[2] + num[3] + num[4];
  ll log10a[5] = {1, 10, 100, 1000, 10000};

  memset(dp, 0, sizeof(dp));

  dp[0][0] = 1;
  int i = 0;

  for (int d=1; d<=4; d++) {
    for (int _=0; _<num[d]; _++) {
      for (int j=i; j>=0; j--) {
        for (int k=i-j; k>=0; k--) {
          //左
          dp[j+1][k] = (dp[j+1][k] + dp[j][k] * (j+1)) % mod;
          //右
          dp[j][k+1] = (dp[j][k+1] + dp[j][k] * log10a[d] % mod * (k+1)) % mod;
          //無
          ;
        }
      }
      i++;
    }
  }

  ll sum = 0;

  debug(num[1]);
  debug(hasZero);

  for (int i=0; i<=N; i++) {
    for (int j=0; i+j<=N; j++) {
      sum += dp[i][j];

      if (hasZero) {
        //左
        sum += dp[i][j] * i % mod;
        //右
        sum += dp[i][j] * 10 * (j+1) % mod;
      }
    }
  }

  return sum % mod;
}


int main(){
  int N, a[201];
  bool has0 = false;

  scanf("%d", &N);

  for (int i=0; i<N; i++) {
    scanf("%d", a+i);
    has0 |= a[i] == 0;
  }

  int num[5] = {};
  ll sum[5] = {};

  for (int i=0; i<N; i++) {
    int j = 0;
    int tmp = a[i];

    while(tmp >= 1) {
      j++;
      tmp /= 10;
    }

    num[j]++;
    sum[j] += a[i];
  }

  ll ans = 0;

  for(int i=1; i<=4; i++) {
    if (!num[i]) continue;

    num[i]--;
    ll res = build(num, has0);
    num[i]++;

    ans += res * sum[i] % mod;
  }

  printf("%lld\n", ans % mod);

  return 0;
}



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

using namespace std;

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

struct Edge {
    ll to;
    ll from;
    ll cost;
};

Edge E[5005];
ll C[2505];
bool A[2505];
bool B[2505];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, M, P;
    cin >> N >> M >> P;
    REP(i, M) {
        cin >> E[i].from >> E[i].to >> E[i].cost;
        E[i].from--;
        E[i].to--;
        E[i].cost -= P;
    }
    REP(i, N) {
        C[i] = INF;
        A[i] = false;
        B[i] = false;
    }
    C[0] = 0;
    A[N - 1] = true;
    B[0] = true;

    REP(_, N + 5) {
        REP(i, M) {
            if (A[E[i].to])
                A[E[i].from] = true;
            if (B[E[i].from])
                B[E[i].to] = true;
        }
    }

    REP(_, N + 5) {
        bool update = false;
        REP(i, M) {
            ll c = C[E[i].from] - E[i].cost;
            if (c < C[E[i].to]) {
                update = true;
                C[E[i].to] = c;
            }
        }

        if (!update)
            break;
    }

    bool inf = false;
    REP(i, M) {
        ll c = C[E[i].from] - E[i].cost;
        if (c < C[E[i].to]) {
            if (A[E[i].to] && B[E[i].to]) {
                inf = true;
                break;
            }
        }
    }

    if (inf)
        cout << -1 << endl;
    else
        cout << std::max(0LL, -C[N - 1]) << endl;
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define mod 1000000007
int count(int a)
{
    int sum=0;
    while(a)
    {
        a= a& (a-1);
        sum++;
    }
    return sum;
}
int main()
{
    int n;
    cin>>n;
    int arr[n][n];
    for(int i=0;i<n;i++)
        for(int j=0;j<n;j++)
             cin>>arr[i][j];
    vector<lli> dp(1<<n);
    dp[0]=1;
    for(int mask=0;mask<(1<<n)-1;mask++)
    {
        int x=count(mask);
        for(int j=0;j<n;j++)
        {
            if(arr[x][j] && !(mask & 1<<j))
            {
                int m2=mask | (1<<j);
                //dp[mask]%=mod;
                dp[m2]+=dp[mask];
                dp[m2]%=mod;
            }
        }
    }
    cout<<dp[(1<<n)-1]<<endl;
    return 0;
}

Measured memory_bytes: 16640
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <set>
#include <queue>
#include <deque>
#include <map>
#include <stack>
#include <cmath>
using namespace std;

#define mod 1000000007
#define ten5 100005
#define ten52 200005
#define ten6 1000005
#define PI 3.1415926
#define pb(x) push_back(x)
#define all(x) x.begin(),x.end()
#define mkpr(x1,x2) make_pair(x1,x2)
typedef long long int ll;


//stack<char> stk;
//set<ll> sll;
//set<pair<ll,ll>> spll;
//map<string,ll> mp;
//map<pair<ll,ll>,ll>::iterator iter;
//map<ll,ll> mp;
//deque<ll> deq;
//vector<ll> vll;
ll num[ten52];
//priority_queue<ll> pq;          //decreasing

int main(void)
{
    ll m,n,i,j,k=0,d,pre=0,now;
    string s;
    cin>>n;
    cin>>pre;
    for(i=1;i<n;i++)
    {
        cin>>now;
        if(pre>now)
            k+=pre-now;
        pre=max(pre,now);
    }
    cout<<k;
    return 0;
}





Measured memory_bytes: 3588
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC optimize("fast-math")
#pragma GCC optimize("O3")

#define int long long

using namespace std;

const int MOD = 1e9 + 7;
vector<int> factor(1e6 + 11);


int binvos(int n, const int p) {
    if (p == 0) return 1;
    else if (p % 2 == 1) return (binvos(n, p - 1) * n) % MOD;
    else {
        int d = binvos(n, p / 2);
        return (d * d) % MOD;
    }
}

void build_factor() {
    factor[0] = 1;
    for (int i = 1; i <= 1e6 + 5; ++i) factor[i] = (i * factor[i - 1]) % MOD;
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n, m; cin >> n >> m;
    build_factor();
    int k1 = 0, k2 = 0;
    while (n * 2 > m && n > 1 && m > 0) {
        k1++;
        n -= 2;
        m--;
    }
    if (2 * n != m) {
        cout << 0;
        return 0;
    }
    while (n > 0 && m > 0) {
        k2++;
        n--;
        m -= 2;
    }
    cout << ((factor[k1 + k2] * binvos(factor[k1], MOD - 2)) % MOD * binvos(factor[k2], MOD - 2)) % MOD;
}




Measured memory_bytes: 8064
#include<bits/stdc++.h>
#define int long long int
#define rep(a,b,c) for(int a=b;a<c;a++)
#define repm(a,b,c) for(int a=(b-1);a>=c;a--)
#define pb push_back
#define str string
#define INF 100000000000000000000;
#define sf(a) scanf("%d",&a)
using namespace std;
int replac(str s){double ans=0;rep(i,0,s.length()){ans+=(s[i]-'0')*pow(10,s.length()-i-1);}return (int)ans;}
typedef pair<int,int> pii;
vector<pii> vii;
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    char c;
    bool red[505][505],copi[505][505],blue[505][505];
    int h,w;
    fill((bool*)red,(bool*)red+505,0);
    fill((bool*)blue,(bool*)blue+505,0);
    fill((bool*)copi,(bool*)copi+505,0);
    cin >> h >> w;
    rep(i,0,h){
        rep(j,0,w){
            cin >> c;
            if(c=='#')copi[i][j]=true;
        }
    }
    rep(i,0,h){
        red[i][0]=true;
        blue[i][w-1]=true;
    }
    rep(i,0,h){
        rep(j,1,w-1){
            if(i%2){
                red[i][j]=true;
                blue[i][j]=false;
            }else{
                red[i][j]=false;
                blue[i][j]=true;
            }
            if(copi[i][j]){
                blue[i][j]=true;
                red[i][j]=true;
            }
        }
    }
    rep(i,0,h){
        rep(j,0,w){
            if(red[i][j])cout << "#";
            else cout << ".";
        }
        cout << endl;
    }
    cout << endl;
    rep(i,0,h){
        rep(j,0,w){
            if(blue[i][j])cout << "#";
            else cout << ".";
        }
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 1536
D = int(input())
c = list(map(int, input().split()))
s = []
for k in range(D):
    s.append(list(map(int, input().split())))

#print(s)
ans = [s[k].index(max(s[k]))+1 for k in range(D)]

p = 0

ch = c.index(min(c))

scheduled = [0 for _ in range(26)]

for k in range(D):
    t = ans[k]
    scheduled[t-1] = -1
    for j in range(26):
        scheduled[j] +=1
        p -= c[j]*scheduled[j]
    p += s[k][t-1]

np = p

for n in range(D):
    op = 0+ np
    oa = 0 + ans[n]
    ans[n] = ch
    for k in range(D):
        t = ans[k]
        scheduled[t-1] = -1
        for j in range(26):
            scheduled[j] +=1
            np -= c[j]*scheduled[j]
        np += s[k][t-1]
    if np > op:
        continue
    else:
        ans[n] = oa



for k in range(D):
    print(ans[k])


Measured memory_bytes: 9472
#include<bits/stdc++.h>
using namespace std;
using Graph=vector<vector<int>>;
int main(){
int H,W;
  cin>>H>>W;
  vector<vector<char>>A(H+2,vector<char>(W+2,'#'));
  for(int i=1;i<=H;i++){
  string s; cin>>s;
    for(int j=1;j<=W;j++)
      A[i][j]=s.at(j-1);
  
  }int X[4]={-1,0,0,1};
  int Y[4]={0,1,-1,0};
  Graph G(H*W);
  for(int i=1;i<=H;i++){
  for(int j=1;j<=W;j++){
  if(A[i][j]=='.'){
      int v=W*(i-1)+j-1;
    for(int a=0;a<4;a++){
    if(A[i+X[a]][j+Y[a]]=='.')
      G[v].push_back(W*(i+X[a]-1)+j+Y[a]-1);
    }
  }
    }
  }queue<int>que;
  que.push(0);
  vector<int>dist(H*W,-1);
  dist[0]=0;
  while(!que.empty()){
  int v=que.front();
    que.pop();
    for(auto u:G[v]){
    if(dist[u]!=-1)
      continue;
      else{
        dist[u]=dist[v]+1;
        que.push(u);
      }
    }
  }int sum=0;
  for(int i=1;i<=H;i++){
  for(int j=1;j<=W;j++){
  if(A[i][j]=='.')
    sum++;
  }
  }if(dist[H*W-1]==-1)
    cout<<-1<<endl;
  else
    cout<<sum-dist[H*W-1]-1<<endl;
  
    return 0;
}

Measured memory_bytes: 3756
/* tempate
 *
 *
 */

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>

using namespace std;


#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int (i)=(n); (i)>=(0); (i)--)
#define SIZE(x) ((int)(x).size())
#define GCD(a, b) int gcd(int a,int b){return b?gcd(b,a%b):a;}
#define QP(a, b) int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define all(v) (v).begin(),(v).end()


template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
template<typename A, size_t N, typename T>
void FILL(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

typedef vector<int, int> vint;
typedef pair<int,int> pint;
typedef vector<pint>vpint;
typedef long long ll;

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1LL << 60;
const ll MOD = 1000000007LL;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a, b; cin >> a >> b;
    if(b == 1){
        cout << 0 << endl;
        return 0;
    }
    ll res = 1;
    b -= a;
    a--;
    while(b > 0){
        res++;
        b -= a;
    }
    cout << res;
    cout << endl;
    return 0;
}


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

int main(){
    int a,b;cin>>a>>b;
    if(a>=b){
        ll ans = 0;
        rep(i,a){
            ans += b * pow(10,i);
        }
        cout<<ans<<endl;
    }else if(a<b){
        ll ans = 0;
        rep(i,b){
            ans += a * pow(10,i);
        }
        cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <fstream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>

#define _GLIBCXX_DEBUG
using namespace std;
using vi = vector<int64_t>;
using vvi = vector<vi>;

int main(int argc, const char * argv[]) {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    int64_t n;
    cin >> n;
    vi h(n);
    for(int i=0; i<n; i++){
        cin >> h.at(i);
    }
    int64_t res = 1, max = h.at(0);
    for(int i=1; i<n; i++){
        if(h.at(i) >= max){
            res++;
            max = h.at(i);
        }
    }
    cout << res << endl;
}


Measured memory_bytes: 256
from heapq import heappush,heappop,heapify
from collections import deque,defaultdict,Counter
from itertools import permutations,combinations,groupby
import sys,bisect,string,math,time,functools,random
def Golf():*a,=map(int,open(0))
def I():return int(input())
def S_():return input()
def IS():return input().split()
def LS():return [i for i in input().split()]
def LI():return [int(i) for i in input().split()]
def LI_():return [int(i)-1 for i in input().split()]
def NI(n):return [int(input()) for i in range(n)]
def NI_(n):return [int(input())-1 for i in range(n)]
def StoLI():return [ord(i)-97 for i in input()]
def ItoS(n):return chr(n+97)
def LtoS(ls):return ''.join([chr(i+97) for i in ls])
def GI(V,E,Directed=False,index=0):
    org_inp=[];g=[[] for i in range(n)]
    for i in range(E):
        inp=LI();org_inp.append(inp)
        if index==0:inp[0]-=1;inp[1]-=1
        if len(inp)==2:
            a,b=inp;g[a].append(b)
            if not Directed:g[b].append(a)
        elif len(inp)==3:
            a,b,c=inp;aa=(inp[0],inp[2]);bb=(inp[1],inp[2]);g[a].append(bb)
            if not Directed:g[b].append(aa)
    return g,org_inp
def GGI(h,w,search=None,replacement_of_found='.',mp_def={'#':1,'.':0}):
#h,w,g,sg=GGI(h,w,search=['S','G'],replacement_of_found='.',mp_def={'#':1,'.':0}) # sample usage
    mp=[1]*(w+2);found={}
    for i in range(h):
        s=input()
        for char in search:
            if char in s:
                found[char]=((i+1)*(w+2)+s.index(char)+1)
                mp_def[char]=mp_def[replacement_of_found]
        mp+=[1]+[mp_def[j] for j in s]+[1]
    mp+=[1]*(w+2)
    return h+2,w+2,mp,found
def TI(n):return GI(n,n-1)
def bit_combination(k,n=2):return [[tb//(n**bt)%n for bt in range(k)] for tb in range(n**k)]
def show(*inp,end='\n'):
    if show_flg:print(*inp,end=end)

YN=['YES','NO'];Yn=['Yes','No']
mo=10**9+7
inf=float('inf')
l_alp=string.ascii_lowercase
#sys.setrecursionlimit(10**7)
input=lambda: sys.stdin.readline().rstrip()

def ran_input():
    n=random.randint(4,16)
    rmin,rmax=1,10
    a=[random.randint(rmin,rmax) for _ in range(n)]
    return n,a

show_flg=False
show_flg=True

h,w=LI()
h,w,g,sg=GGI(h,w,search=['S','G'],replacement_of_found='.',mp_def={'#':1,'.':0})
dp=[1e6]*(h*w)
dp[w+1]=g[w+1]

for j in range(h*w-w):
        dp[j+1]=min(dp[j]+1 if (g[j],g[j+1])==(0,1) else dp[j],dp[j+1])
        dp[j+w]=min(dp[j]+1 if (g[j],g[j+w])==(0,1) else dp[j],dp[j+w])

print(dp[(h-2)*w+w-2])


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

int main(){
	int a[100002] = {};
	int n,x,y,res = 0;
	a[1] = 1;
	cin >> n;
	for(int i = 0;i < n;i++){
		cin >> x >> y;
		y++;
		a[x]++;
		a[y]--;
	}
	for(int i = 0;i < 100002;i++){
		a[i+1] += a[i];
	}
	for(int i = 0;i < 100002;i++){
		if(a[i] >= i){
			res = i;
		}
	}
	res--;
	cout << res <<endl;

	return 0;
}

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define endl "\n"     
#define pb push_back
#define mp make_pair
#define ff first
#define ss second

const int N=1e5+5;
int a[N],b[N];
int sum1=0,sum2=0;
vector <int> v1;

int32_t main()
{
     IOS;
     
     int n;
     cin>>n;
     int ans=0;
     
     for(int i=1;i<=n;i++)
          cin>>a[i];
     for(int i=1;i<=n;i++)
     {
          cin>>b[i];
          if(a[i]>=b[i])
          {
               if(a[i]!=b[i])
                    v1.pb(a[i]-b[i]);
               sum1+=(a[i]-b[i]);
          }
          else
          {
               ans++;
               sum2+=(b[i]-a[i]);
          }
     }
     
     sort(v1.begin(),v1.end(),greater<int>());
     
     if(sum1>=sum2)
     {
          int temp=0;
          for(auto &itr:v1)
          {
               if(temp>=sum2)
                    break;
               ans++;
               temp+=itr;
          }
          cout<<ans;
          return 0;
     }
     cout<<"-1";
     return 0;
}

Measured memory_bytes: 2424
////////////////////////
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
namespace my {
char itoc(int i) { return i + '0'; }
int ctoi(char c) { return c - '0'; }
ll gcd(ll a, ll b) {
  a = abs(a);
  b = abs(b);
  if (a < b) swap(a, b);
  while (b != 0) {
    a %= b;
    swap(a, b);
  }
  return a;
}
ll lcm(ll a, ll b) { return a * b / my::gcd(a, b); }
}  // namespace my
////////////////////////

int main() {
  int h1, m1, h2, m2, k;
  cin >> h1 >> m1 >> h2 >> m2 >> k;
  int a = h1 * 60 + m1;
  int b = h2 * 60 + m2;
  int ans = b - a - k;
  cout << ans << endl;
}

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

void	ft_check(int temp)
{
	if (temp >= 30)
		printf("Yes");
	else
		printf("No");
}

int		main(void)
{
	int temp;

	scanf("%d",&temp);
	ft_check(temp);
	return (0);
}

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

int main()
{
  int a, b, c;
  cin >> a >> b >> c;
  if((a <= c && c <= b) || (b <= c && c <= a))
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
  return 0;
}


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

public class Main {
	static class Node {
		int key;
		Node left;
		Node right;
		
		public Node(int key) {
			this.key = key;
		}
	}
	
	Node root;
	
	void run() {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		for(int i = 0; i < n; i++) {
			String s = sc.next();
			if(s.startsWith("i")) {
				insert(sc.nextInt());
			}else if (s.startsWith("f")) {
				Node ans = find(root, sc.nextInt());
				if(ans != null) System.out.println("yes");
				else System.out.println("no");
			}else {
				inorder(root);
				System.out.println();
				preorder(root);
				System.out.println();
			}
		}
		sc.close();
	}
	
	void preorder(Node u) {
		if(u == null) return;
		System.out.print(" " + u.key);
		preorder(u.left);
		preorder(u.right);
	}
	
	void inorder(Node u) {
		if(u == null) return;
		inorder(u.left);
		System.out.print(" " + u.key);
		inorder(u.right);
	}
	
	void insert (int key) {
		Node y = null;
		Node x = root;
		Node z = new Node(key);
		while (x != null) {
			y = x;
			if(z.key < x.key) {
				x = x.left;
			} else {
				x = x.right;
			}
		}
		if(y == null) {
			root = z;
		} else if (z.key < y.key) {
			y.left = z;
		}else {
			y.right = z;
		}
	}
	
	Node find(Node x, int k) {
		while(x != null && k != x.key) {
			if(k < x.key) x = x.left;
			else x = x.right;
		}
		return x;
	}

	void debug(Object... o) {
		System.out.println(Arrays.deepToString(o));
	}

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


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

#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
using namespace std;

int main(){
	int n;	cin >> n;
	long long int a[n];
	for( int i = 0; i < n; i++ ){
		cin >> a[i];
	}
	long long int ans;

	sort( a, a + n, greater<int>() );

	ans = 0;
	int j = 0;
	for( int i = 0; i < n - 1; i++ ){
		ans += a[j];
		if( i % 2 == 0 )	j++;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 5180
N, M = gets.split.map(&:to_i)
roads = []
M.times do
  roads << gets.split.map(&:to_i).sort
end
results = Array.new(N, 0)
roads.each do |road|
  results[road[0] - 1] += 1
  results[road[1] - 1] += 1
end
results.each do |result|
  puts result
end

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

#ifdef LOCAL
#include<debug.h>
#else
#define db(...) 21
#endif

#define debug(x) cout << #x << " = " << x << endl;
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define FOR(it, b, e) for (typeof(b) it = (b); it != (e); ++it)
#define MSET(c, v) memset(c, v, sizeof(c))

const int INF = 0x3F3F3F3F; 
const int NEGINF = 0xC0C0C0C0;
const int NULO = -1;
const double EPS = 1e-10;
const ll mod = 1e9 + 7;

inline int cmp(double x, double y = 0) 
{  
  if(fabs(x - y) < EPS)
    return 0;
  return x > y ? 1 : -1;
}

ll exp(ll a, ll b)
{
  ll ans = 1;
  while(b)
  {
    if(b & 1)
      ans = (ans * a) % mod;
    a = (a * a) % mod;
    b >>= 1;
  }
  return ans;
}

const int maxn = 2e5 + 10;
ll fat[maxn], inv[maxn];

ll C(int n, int k)
{
  if(n < k) 
    return 0;
  if(n < 0 || k < 0) 
    return 0;
  return (((fat[n] * inv[k]) % mod) * inv[n - k]) % mod;
}

map<ll, ll>mapa;

int main()
{
  ios::sync_with_stdio(false);
  int n,p;
  cin >> n >> p;
  string s;
  cin >> s;
  
  ll ans = 0;
  if(p == 2 || p == 5)
  {
    for(int i = 0; i < n ; i++)
    {
      if((s[i] - '0') % p == 0)
        ans += i + 1;
    }
    cout << ans << endl;
    return 0;
  }

  ll sum = 0;
  ll d = 1;
  for(int i = n-1 ; i >= 0 ; i--)
  {
    sum = ((s[i] - '0') * d + sum) % p ;
    d = (d * 10) % p;
    mapa[sum]++;
  }

  ans = mapa[0];

  for(const auto &x : mapa)
  {
    ans += (x.second * (x.second - 1)) / 2;
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 4056