akhauriyash/Code-Regression huggingface dataset:
#include <iostream>

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

    int counter = 0;
    for (int ii = 0; ii <= a; ++ii)
    {
        for (int jj = 0; jj <= b; ++jj)
        {
            for (int kk = 0; kk <= c; ++kk)
            {
                if (ii * 500 + jj * 100 + kk * 50 == x)
                {
                    ++counter;
                }
            }
        }
    }

    std::cout << counter;
}


Measured memory_bytes: 256
#include <cstdlib>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <map>
#include <set>
#include <deque>
#include <cstring>
#include <functional>
#include <climits>
#include <list>
#include <ctime>
#include <complex>

#define F1(x,y,z) for(int x=(y);x<(z);x++)
#define F2(x,y,z) for(int x=(y);x<=(z);x++)
#define F3(x,y,z) for(int x=(y);x>(z);x--)
#define F4(x,y,z) for(int x=(y);x>=(z);x--)
#define mp make_pair
#define pb push_back
#define LL long long
#define co complex<double>
#define fi first
#define se second

#define MAX 100005
#define AMAX 1025*1005
#define MOD 1000000007

#define f(c,d) ((1<<(c))*(d))

using namespace std;

int n,ta,tb,cnt[MAX];
LL x[MAX],m[MAX],ma[MAX];
set<int> s[MAX];
bool o=1;

void go(int a){
	if(s[a].size()>1)return;
	LL tt=min(m[a]-ma[a],m[a]/2);
	LL t=m[a]-x[a];
	if(t<0||t>tt){
		o=0;
		return;
	}
	tt=m[a]-t*2;
	int tc=*s[a].begin();
	if(cnt[tc]==1){
		if(tt!=x[tc])o=0;
		cnt[tc]=-1;
	}else{
		m[tc]+=tt;
		ma[tc]=max(ma[tc],tt);
		s[tc].erase(a);
		go(tc);
	}
}

int main(){
	scanf("%d",&n);
	F2(a,1,n)scanf("%lld",x+a);
	F1(a,1,n){
		scanf("%d%d",&ta,&tb);
		cnt[ta]++,cnt[tb]++;
		s[ta].insert(tb);
		s[tb].insert(ta);
	}
	F2(a,1,n)if(cnt[a]==1){
		ta=*s[a].begin();
		if(cnt[ta]==1){
			if(x[ta]!=x[a])o=0;
			cnt[ta]=-1;
		}else{
			m[ta]+=x[a];
			ma[ta]=max(ma[ta],x[a]);
			s[ta].erase(a);
			go(ta);
		}
	}
	if(o)printf("YES\n");
	else printf("NO\n");
	#ifdef LOCAL_PROJECT
	system("pause");
	#endif
	return 0;
}


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

int main(){
    int64_t N;
    int64_t ans = 0;
    cin >> N;
    vector<int64_t> A(N);
    for(int64_t i = 0; i < N; i++){
        cin >> A.at(i);
    }
    sort(A.begin(), A.end());
    reverse(A.begin(), A.end());
    
    queue<int64_t> que;
    que.push(A.at(0));

    for(int64_t i = 1; i < N; i++){
        ans += que.front();
        que.pop();
        que.push(A.at(i));
        que.push(A.at(i));
    }

    cout << ans << endl;
}


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

int main() 
{
    int dis,time,speed;
    cin>>dis>>time>>speed;
    float newtime=float(dis)/float(speed);
    if(newtime<=time)
        cout<<"Yes";
    else
        cout<<"No";
    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>

using namespace std;

int main()
{
	int a, b;
	bool flag = false;
	cin >> a >> b;

	int digit = to_string(b).size();
	int num = a * pow(10, digit) + b;

	for (int i = 1; i * i <= num; i++)
	{
		if (i * i == num)
		{
			flag = true;
			break;
		}
	}

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

	return 0;
}

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

string s, t;

int main() {
  while (cin >> s >> t) {
    int n = s.length(), m = t.length(), x = 0;
    for (int i = 0; i <= n - m; ++i) {
      int z = 0;
      for (int j = 0; j < m; ++j) z += s[i + j] == t[j];
      x = max(x, z);
    }
    cout << m - x << endl;
  }
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define pb push_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=1000000000;
int n,k,a[2010],b[2010],ans=INF;
vector<int>v[2010];
int d[2010];
bool memo[2010];
void dfs(int x){
	for(int i:v[x]){
		if(d[i]==INF){
			d[i]=d[x]+1;
			dfs(i);
		}
	}
}
signed main(){
	cin>>n>>k;
	rep(i,n-1){
		cin>>a[i]>>b[i];
		a[i]--,b[i]--;
		v[a[i]].pb(b[i]);
		v[b[i]].pb(a[i]);
	}
	if(k%2){
		rep(i,n-1){
			fill(memo,memo+n,true);
			fill(d,d+n,INF);d[a[i]]=0;
			dfs(a[i]);
			rep(j,n)if(d[j]<=k/2)memo[j]=false;
			fill(d,d+n,INF);d[b[i]]=0;
			dfs(b[i]);
			rep(j,n)if(d[j]<=k/2)memo[j]=false;
			int cnt=0;
			rep(j,n)if(memo[j])cnt++;
			chmin(ans,cnt);
		}
		cout<<ans<<endl;
	}
	else{
		rep(i,n){
			fill(d,d+n,INF);
			d[i]=0;
			dfs(i);
			int cnt=0;
			rep(j,n)if(d[j]>k/2)cnt++;
			chmin(ans,cnt);
		}
		cout<<ans<<endl;
	}
    return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
using ll  = long long;
using vl  = vector<ll>;
using vi  = vector<int>;
#define _GLIBCXX_DEBUG
#define IO_STREAM cin.tie(0);ios::sync_with_stdio(false)
#define all(x) x.begin(),x.end()
#define rep(i,sta,end) for(int i=sta;i<end;++i)
#define lcm(a,b) (a)/__gcd((a),(b))*(b)
#define pb push_back
const ll INF = 1000000000000000;
const ll MOD = 1000000007;
const double PI = acos(-1);
//||
#define DBG(a,b,c,d) //cout<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<endl
//DBG("","","","");

#define TOP_NUM 15
#define NOTOP_NUM 11

int main(){
	IO_STREAM;
	int D;	cin>>D;
	vi c(26);
	vector<pair<int,int>>cs(26);
	rep(i,0,26){
		cin>>c[i];
		cs[i].first=c[i];
		cs[i].second=i;
	}
	int s[D][26];
	rep(i,0,D){
		rep(j,0,26){
			cin>>s[i][j];
		}
	}

	sort(all(cs));
	reverse(all(cs));
	vi top(D,1);
	rep(i,0,TOP_NUM){
		top[i]=cs[i].second+1;
	}
	vi notop(D,1);
	rep(i,0,NOTOP_NUM){
		notop[i]=cs[i+TOP_NUM].second+1;
	}

	int cnt=1;
	int nt_idx=0;
	while(1){
		rep(i,0,TOP_NUM){
			cout<<top[i]<<endl;
			cnt++;
			if(cnt>D) return 0;
		}
		rep(i,0,5){
			cout<<notop[nt_idx]<<endl;
			nt_idx++;
			if(nt_idx>=NOTOP_NUM) nt_idx=0;
			cnt++;
			if(cnt>D) return 0;
		}
	}
	return 0;
}


Measured memory_bytes: 3704
import java.util.Scanner;
class Main {
	
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		
		for (int num = 1;; num++ ){
			int numx = scanner.nextInt();
			int numy = scanner.nextInt();
			
			if(numx == 0 && numy == 0){
				break;
			}		    
				else if(numx < numy){
					System.out.println(numx+" "+numy);
				}
				else {
					System.out.println(numy+" "+numx);
				}
	    	}
	}	

}

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

int main() {
  #define ld long double
  int n;
  scanf("%d", &n);
  vector<pair<ld, ld>> v(n);
  for (int i = 0; i < n; ++i)
    cin >> v[i].first >> v[i].second;
  vector<int> p(n);
  iota(p.begin(), p.end(), 0);
  ld fac = 1;
  for (ld i = 1; i <= n; ++i)
    fac *= i;
  ld ans = 0;
  do {
    ld cur = 0, x = v[p[0]].first, y = v[p[0]].second;
    for (int i = 1; i < n; ++i) {
      ld xx = v[p[i]].first, yy = v[p[i]].second;
      cur += sqrt((xx - x) * (xx - x) + (yy - y) * (yy - y));
      x = xx, y = yy;
    }
    cur /= fac;
    ans += cur;
  } while (next_permutation(p.begin(), p.end()));
  cout << fixed << setprecision(20) << ans << '\n';
  return 0;
}

Measured memory_bytes: 384
import sys
from itertools import product
import numpy as np

n, m, x = map(int, input().split())
a = np.array([list(map(int, input().split())) for _ in range(n)], dtype = np.int32)
ans = sys.maxsize
for bit in product((False, True), repeat = n):
    row_sum = np.sum(a[np.where(bit)], axis = 0)
    if m == np.count_nonzero(row_sum[1:] >= x):
        ans = min(ans, row_sum[0])
print(-1 if ans == sys.maxsize else ans)

Measured memory_bytes: 27296
#include<iostream>
#include<algorithm>
using namespace std;
const int VMAX=10001;
int T[VMAX+1];
int solve(int A[],int n,int Min){
  int ans=0;
  int *B=new int[n];
  bool *v=new bool[n];
  for(int i=0;i<n;i++){
  	B[i]=A[i];
  	v[i]=false;
  }

  sort(B,B+n);
  for(int i=0;i<n;i++) T[B[i]]=i;
  for(int i=0;i<n;i++){
  	if(v[i])continue;
  	int an = 0;
	int m = VMAX;//
	int cur = i;
	int s = 0;
	while(1){
	  	  an++;
	      v[cur]=true;
	      int t=A[cur];
	      m=min(m,t);
	      s+=t;
	      cur=T[t];
	      if(v[cur])break;
	   }

	   ans+=min(s+(an-2)*m,s+m+(an+1)*Min);    

  	}
   return ans;
}
int main(){
	int n;
	int Min=VMAX;//
	cin>>n;
	int *A=new int[n];
	for(int i=0;i<n;i++){
		cin>>A[i];
		Min=min(Min,A[i]);
	}
	int ans=solve(A,n,Min);
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3180
import itertools

n, m = map(int, input().split())

lst = [[0 for _ in range(n)] for _ in range(n)]

for i in range(m):
	a, b = map(int, input().split())
	a, b = a - 1, b -1
	lst[a][b] = 1
	lst[b][a] = 1

l = list(range(n))

cnt = 0
for v in itertools.permutations(l):
	flg = True
	if v[0] == 0:
		for i in range(n-1):
			x, y = v[i], v[i + 1]
			if lst[x][y] == 0: # pathがなければ
				flg = False
		if flg:
			cnt += 1

print(cnt)

Measured memory_bytes: 39920
#include "bits/stdc++.h"
using namespace std;
typedef int64_t ll;
typedef vector<int64_t> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SIZE(a) int((a).size())

int main(){
  ll n,m;
  cin>>n>>m;
  vp v(n+m);
  REP(i,n){
    ll a;
    cin>>a;
    v[i].first=a;v[i].second=1;
  }
  REP(i,m){
    ll b,c;
    cin>>b>>c;
    v[i+n].first=c;v[i+n].second=b;
  }
  sort(v.begin(),v.end());reverse(v.begin(),v.end());
  int i=0;
  ll ans=0;
  while(n>0){
    ans+=v[i].first*min(v[i].second,n);
    n-=v[i].second;
    i++;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 3328
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    static class CDividetheProblems
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var dList = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToList();
            dList.Sort();

            Console.WriteLine(dList[n / 2] - dList[(n / 2) - 1]);
            Console.ReadLine();
        }
    }
}

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

int main() {
  int n;
  cin >> n;
  vector<pair<int, int>> a(n);
  for (int i = 0; i < n; i++) {
    a.at(i).second = i + 1;
    cin >> a.at(i).first;
  }
  sort(a.begin(), a.end());
  for (int i = 0; i < n; i++) {
    cout << a.at(i).second;
    if (i == n - 1) {
      cout << endl;
    } else {
      cout << ' ';
    }
  }
}

Measured memory_bytes: 1536
N, W = map(int, input().split())
w, v = [0] * N, [0] * N
for i in range(N):
	w[i], v[i] = map(int, input().split())

V = sum(v)
# dp[i][j]:i番目までの品物から価値がj以上になるよう選んだときの重さの総和の最小値
dp = [[float("inf")] * (V + 1) for _ in range(N + 1)]
dp[0][0] = 0

for i in range(N):
    for j in range(V + 1):
        # i+1番目を入れる場合vs入れない場合（前の段階から足し合わせることで価値がj以上になる場合）
        if j - v[i] >= 0:
            dp[i + 1][j] = min(dp[i][j], dp[i][j - v[i]] + w[i])
        else:
            dp[i + 1][j] = dp[i][j]

# dp[N][j]がW以下であるようなjの最大値が答えになる
ans = 0
for j in range(V + 1):
	if dp[N][j] <= W:
		ans = j

print(ans)

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

#include<cstdio>
#define r(i,n) for(int i=0;i<n;i++)

int main(void){
  int n,d,x;
  cin>>n>>d>>x;
  vector<int> a(n);
  int sum=0;
  r(i,n)cin>>a.at(i);

  r(i,n){
    int j=0;
    while(a.at(i)*j+1<=d){
      sum++;
      
      j++;
    }
  }

  cout<<sum+x<<endl;



return 0;}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;
inline int getInt() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MX = 200005;



int main() {
  ll n;
  cin>>n;
  vi a(3), b(3);
  cin>>a>>b;
  rep(_,2) {
    vl dp(n+1);
    rep(i,3) {
      rep(j,n-a[i]+1) maxs(dp[j+a[i]], dp[j]+b[i]);
    }
    ll mx = 0;
    rep(i,n+1) maxs(mx, n-i+dp[i]);
    n = mx;
    swap(a,b);
  }
  cout<<n<<endl;
  return 0;
}






















Measured memory_bytes: 195584
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	long long s=0;
	int a,b,c,d,e,f;
	for(int i=1;i<=n;i++)
	{
		int o=0;
		if(i%10==0)
		continue;
		b=i;
		for(int k=1;k<=1000000;k++)
			{
				if(b<10)
				{
					e=b;
					break;
				}
				b=b/10;
			}
			f=i%10;
			if(e==f && e<=n)
			s++;
			if((f*10+e)<=n)
			s++;
			else
			continue;
			if((f*100+e)<=n)
			{
				for(int x=0;x<=9;x++)
				{
					int p=(f*10+x)*10+e;
					if(p<=n)
					s++;
					else
					{
						o=1;
						break;
					}
				}
			}
			if(o==1)
			continue;
			if((f*1000+e)<=n)
			{
				for(int x=0;x<=99;x++)
				{
					int p=(f*100+x)*10+e;
					if(p<=n)
					s++;
					else
					{
						o=1;
						break;
					}
				}
			}
			if(o==1)
			continue;
			if((f*10000+e)<=n)
			{
				for(int x=0;x<=999;x++)
				{
					int p=(f*1000+x)*10+e;
					if(p<=n)
					s++;
					else
					{
						o=1;
						break;
					}
				}
			}
			if(o==1)
			continue;
			if((f*100000+e)<=n)
			{
				for(int x=0;x<=9999;x++)
				{
					int p=(f*10000+x)*10+e;
					if(p<=n)
					s++;
					else
					{
						o=1;
						break;
					}
				}
			}
			if(o==1)
			continue;
	}
	cout<<s;
	return 0;
}

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

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

using namespace std;

int main(){
  
  vector<int> abc;
  int a,b,c;
  cin>>a>>b>>c;
  
  abc.push_back(a);
  abc.push_back(b);
  abc.push_back(c);
  
  sort(abc.begin(), abc.end());
  cout<<abs(abc[2] - abc[1])+abs(abc[1] - abc[0]);
  
  return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <math.h>
#include <algorithm>
#include <functional>
#include <string>
#include <array>
#include <vector>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <queue>
#include <complex>
#include <bitset>
#define full(c) c.begin(), c.end()
#define vector2d(name,type,h,w,init) vector<vector<type>> name(h,vector<type>(w,init)) 
const int PRIME = 1000000007;
const int INT_INF = 2147483647;
const long long int LL_INF = 9223372036854775807;
const double PI = acos(-1);
const double EPS = 0.000000001;
typedef unsigned long long int ull;
typedef long long int ll;
using namespace std;

class UnionFind{
private:
	vector<int> parent, rank;
public:
	UnionFind(int n){
		for (int i = 0; i < n; i++){
			parent.push_back(i);
			rank.push_back(0);
		}
	}
	int root(int x){
		return parent[x] == x ? x : parent[x] = root(parent[x]);
	}
	bool same(int x, int y){
		return root(x) == root(y);
	}
	void unite(int x, int y){
		x = root(x);
		y = root(y);
		if (x == y) return;
		if (rank[x] < rank[y]){
			parent[x] = y;
		}
		else{
			parent[y] = x;
			if (rank[x] == rank[y]) rank[x]++;
		}
	}
};
int main(){
	//ios_base::sync_with_stdio(false);
	//cin.tie(NULL);
	int i, n, m, cnt = 0;
	cin >> n >> m;
	vector<int> p(n);
	for (i = 0; i < n; i++) cin >> p[i];
	UnionFind uf(n);
	for (i = 0; i < m; i++){
		int a, b;
		cin >> a >> b;
		uf.unite(a - 1, b - 1);
	}
	for (i = 0; i < n; i++){
		if (uf.same(i, p[i] - 1)) cnt++;
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 1660
require 'set'

def merge(s, w)
	return w if s == ""
	([0, s.size-w.size].max..s.size-1).each{|i|
		if s[i..s.size-1] == w[0..s.size-i-1]
			return s[0..i-1] + w
		end
	}
	return s + w
end

loop {
	n = gets.to_i
	break if n == 0
	words = (1..n).map {gets.chomp}.sort_by(&:size)
	tmp = []
	until words.empty?
		tmp << words.pop
		words.delete_if{|w| tmp[-1] =~ /#{w}/}
	end
	words = tmp
	n = words.size

	dist = (1..n).map{[Float::INFINITY] * n}
	(0..n-1).each{|i|
		(0..n-1).each{|j|
			next if i == j
			dist[i][j] = merge(words[i], words[j]).size - words[i].size
		}
	}

	opt = {}
	(0..n-1).each{|i|
		opt[[[i], i]] = [words[i].size, words[i]]
	}

	(1..n-1).each{|k|			
		(0..n-1).to_a.combination(k){|reached|
			reached.each{|i|
				((0..n-1).to_a - reached).each{|j|
					key = [(reached + [j]).sort, j]
					prev = opt[[reached, i]]
					value = prev[0] + dist[i][j]
					new_s = merge(prev[1], words[j])
					if opt[key]
						opt[key] = [value, new_s] if value < opt[key][0] || (value == opt[key][0] && new_s < opt[key][1])
					else
						opt[key] = [value, new_s]
					end
				}
			}
		}
	}

	candidates = (0..n-1).map{|i| opt[[(0..n-1).to_a, i]]} 
	min_len = candidates.map(&:first).min
	strs = candidates.select{|l, a| l == min_len}.map(&:last)
	puts strs.min
}

Measured memory_bytes: 10784
#include <array>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
using namespace std;


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

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
	stringstream ss;
	ss << f;
	ss >> t;
}


#define REP(i,n) for(int i=0;i<int(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define RALL(v) (v).rbegin(),(v).rend()
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define PB push


#define MOD 1000000007LL
#define EPS 1e-10

int main()
{
    LL N, K;
    cin >> N >> K;
    map<LL, LL> m;
    LL a, b;
    REP(i, N)
    {
        cin >> a >> b;
        m[a] += b;
    }
    LL sum = 0;
    for (const auto& p : m)
    {
        sum += p.second;
        if (sum >= K)
        {
            cout << p.first << endl;
            break;
        }
    }
    return 0;
}


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

int dp[(int)1e5 + 1];

int dfs(int s,vector<int>*adj){
    if(dp[s]) return dp[s];
    dp[s] = 0;
    for(auto u : adj[s]){
        dp[s] = max(dp[s],1+dfs(u,adj));
    }
    return dp[s];
}

int main(){
    int n,m,x,y;
    cin >> n >> m;
    vector<int> adj[n];
    for(int i = 0;i < m ;i++){
        cin >> x >> y;
        x--,y--;
        adj[x].emplace_back(y);
    }
    int maxm = INT_MIN;
    for(int i = 0;i < n;i++){
        maxm = max(maxm,dfs(i,adj));
    }
    cout<<maxm;
}

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

#define rep(i, n) for (size_t i = 0; i < (n); i++)

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

int main() {
  size_t N;
  scanf("%ld", &N);
  vector<pair<int, int>> ts[N];
  rep(i, N) {
    size_t a;
    scanf("%ld", &a);
    rep(j, a) {
      int x, y;
      scanf("%d%d", &x, &y);
      ts[i].push_back(make_pair(x - 1, y));
    }
  }
  int r = 0;
  for (int b = 0; b < (1 << N); b++) {
    int c = 0;
    rep(i, N)
      if ((b >> i) & 1) {
        c++;
        for (auto p: ts[i])
          if (((b >> p.first) & 1) != p.second)
            goto escape;
      }
    chmax(r, c);
escape:
    ;
  }
  printf("%d\n", r);
}


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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;

#define INF (1LL << 60)
#define MOD 1000000007

#define REP(i,m,n) for(ll (i)=(m),i_len=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define pb push_back
#define mp make_pair

int main()
{
    ll N;
    cin >> N;
    vec A(N), B(N);
    REP(i,0,N) {
        cin >> A[i];
        B[i] = A[i];
    }
    sort(ALL(B));
    
    REP(i,0,N) {
        if(A[i] == B[N-1]) PR(B[N-2]);
        else PR(B[N-1]);
    }

    return 0;
}

/*



*/

Measured memory_bytes: 4736
#include <algorithm>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <cctype>
#include <iostream>
#include <set>
#include <string>
#include <queue>
#include <map>
#include <utility>
using namespace std;
int size(string x){
	string::size_type size=x.size();
	return size;
}
#define fu(l,k) for(int i=l;i<k;i++)
#define fd(l,k) for(int i=l;i>k;i--)
#define sort(ss) sort(ss.begin(), ss.end())
#define rsort(ss) sort(ss.rbegin(), ss.rend())
typedef  vector<string> vs;
typedef  vector<int> vi;
double pi(){
	return M_PI;
}
typedef set<int> set_i;
typedef set<string> set_s;
int INF=1000000;
int main(){
	int a,b,ll;
	int ssr=0,sr=0;
	char qq;
	while(cin>>a>>qq>>b>>qq>>ll){
		if(a==b){
			ssr++;
		}
		else if(a*a+b*b==ll*ll){
			sr++;
		}
	}
	cout<<sr<<endl;
	cout<<ssr<<endl;
}

Measured memory_bytes: 1156
#include <cstdio>
#include <cstring>
#include <algorithm>
#define MOD 1000000007

using namespace std;

typedef long long ll;

ll pow_mod(ll x,int k) {
  ll ans=1;
  while (k) {
  	if (k&1) ans=ans*x%MOD;
  	x=x*x%MOD;
  	k>>=1;
  }
  return ans;
}

ll facd[200005],inv[200005];

void pre(int n) {
  facd[0]=1;
  for(int i=1;i<=n;i++) facd[i]=facd[i-1]*i%MOD;
  inv[1]=1;
  for(int i=2;i<=n;i++) inv[i]=(MOD-MOD/i)*inv[MOD%i]%MOD;
}

struct Edge {
  int t,next;
  Edge() {}
  Edge(int a,int b):t(a),next(b) {}
};

Edge e[400005],e2[400005];
int head[200005],head2[200005];

int s1,s2;
bool vis[200005];

void dfs1(int x) {
  vis[x]=1;
  s1++;
  for(int i=head[x];i;i=e[i].next) {
  	int u=e[i].t;
  	s2++;
  	if (!vis[u]) dfs1(u);
  }
}

int cir[200005],cnt;
int st[200005],top;
bool hh[200005];

bool dfs2(int x,int fa) {
  st[++top]=x;
  hh[x]=1;
  for(int i=head[x];i;i=e[i].next)
    if (e[i].t!=fa) {
    	int u=e[i].t;
    	if (!hh[u]) {
		  if (dfs2(u,x)) return 1;
	    }
    	else {
    		cnt=0;
    		int t;
    		do {
    			t=st[top--];
    			cir[++cnt]=t;
			} while (t!=u);
			return 1;
		}
	}
  top--;
  return 0;
}

bool in[200005];
int p[200005],now[200005],ns;

void dfs3(int x,int fa) {
  now[++ns]=x;
  for(int i=head[x];i;i=e[i].next)
    if (e[i].t!=fa&&!in[e[i].t]) {
    	int u=e[i].t;
    	p[u]=x;
    	dfs3(u,x);
	}
}

int size[200005];

ll dfs4(int x) {
  size[x]=1;
  ll s=1;
  for(int i=head2[x];i;i=e2[i].next) {
  	int u=e2[i].t;
    s=s*dfs4(u)%MOD;
    size[x]+=size[u];
  }
  return s*inv[size[x]]%MOD;
}

bool rt[200005];

ll calc(int n) {
  for(int i=1;i<=ns;i++) {
    head2[now[i]]=0;
    rt[now[i]]=1;
  }
  int tot=0;
  for(int i=1;i<=ns;i++) {
  	int x=now[i];
  	for(int j=head[x];j;j=e[j].next)
  	  if (e[j].t<p[x]) {
  	  	  int u=e[j].t;
  	  	  e2[++tot]=Edge(u,head2[x]);
  	  	  head2[x]=tot;
  	  	  rt[u]=0;
		}
  }
  ll s=1;
  for(int i=1;i<=ns;i++)
    if (rt[now[i]]) s=s*dfs4(now[i])%MOD;
  return s;
}

ll solve(int x) {
  top=0;
  dfs2(x,0);
  for(int i=1;i<=cnt;i++) in[cir[i]]=1;
  ns=0;
  for(int i=1;i<=cnt;i++) dfs3(cir[i],0);
  ll s=0;
  p[cir[cnt]]=cir[1];
  for(int i=cnt-1;i>0;i--) p[cir[i]]=cir[i+1];
  s=(s+calc(cnt))%MOD;
  p[cir[1]]=cir[cnt];
  for(int i=2;i<=cnt;i++) p[cir[i]]=cir[i-1];
  s=(s+calc(cnt))%MOD;
  return s;
}

int main() {
  int n;
  scanf("%d",&n);
  pre(2*n);
  for(int i=1;i<=2*n;i++) {
  	int x,y;
  	scanf("%d%d",&x,&y);
  	e[2*i-1]=Edge(n+y,head[x]);
  	head[x]=2*i-1;
  	e[2*i]=Edge(x,head[n+y]);
  	head[n+y]=2*i;
  }
  ll ans=1;
  for(int i=1;i<=2*n;i++)
    if (!vis[i]) {
    	s1=s2=0;
    	dfs1(i);
    	if (s1*2!=s2) {
    		puts("0");
    		return 0;
		}
		ans=ans*solve(i)%MOD;
	}
  printf("%lld\n",ans*facd[2*n]%MOD);
  return 0;
}

Measured memory_bytes: 17536
#include<iostream>
#include<stdio.h>
#include<vector>//s1.erase(n)=文字列s1の、n文字目以降削除
#include<algorithm>//辞書順=next_permutation
#include<set>
#include<string>//char 小文字のほうが32大きい
#include<sstream>
#include<string.h>
#include<complex>
#include<time.h>
#include<random>
#include<cmath>
#include<math.h>
#include<queue>
#include<time.h>
#include<iomanip>
#include<locale>
#include<utility>//swap=数値交換
#define rt "\n"
#define rep(i,n) for(int i=0;i<n;i++)
#define rop(i,n) for(int i=1;i<=n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define drop(i,n) for(int i=n;0<i;i--)
#define yes(ans) if(ans)cout<<"yes"<<rt;else cout<<"no"<<rt;
#define Yes(ans) if(ans)cout<<"Yes"<<rt;else cout<<"No"<<rt;
#define YES(ans) if(ans)cout<<"YES"<<rt;else cout<<"NO"<<rt;
#define sec(a,b,ans) if(ans)cout<<a<<rt;else cout<<b<<rt;
#define vcin(s,n) rep(i,n)cin>>s[i];//vcin(配列名),(繰り返し回数)
#define sort(s) sort(s.begin(),s.end())//標準=昇順
#define reve(s) reverse(s.begin(),s.end())
#define asas int ans=0
#define llcncn llint cnt=0
#define llasas llint ans=0
#define str string
#define please return
#define AC 0
#define Rapid cin.tie(0);ios::sync_with_stdio(false)
#define Pi 3.1415926535897932384626
#define nine 1000000000
//END OF DEFINE.
using namespace std;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vchar;
typedef vector<double> vdou;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair<llint, llint> pllint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<char>> vvchar;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<string>> vvstr;
typedef vector<vector<bool>> vvbool;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;

long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}
long long LCM(long long a, long long b) {
	return a * b / GCD(a, b);
}
unsigned GetDigit(unsigned num) {
	return std::to_string(num).length();
}
int tow(int n) {//2のn乗
	if (n == 0)return 1;
	int x = tow(n / 2);
	x *= x;
	if (n % 2 == 1)x *= 2;
	return x;//@domino
}
/*
 
 (char)toupper(a[n])=文字列のn文字目を大文字で出力

  pow(a,b)=aのb乗

  */
int a=0, b=0, c = 0;

int main(void) {
	Rapid;//固定高速

	vint a(9);
	vcin(a, 9);
	int n;
	cin >> n;
	vint b(n);
	vcin(b, n);
	vint ans(9,0);
	rep(i, n) {
		rep(j, 9) {
			if (a[j] == b[i]) {
				ans[j] = 3;
			}
		}
	}
	bool cnt = false;
	if (ans[0] ==3&& ans[1]==3&&ans[2]==3)cnt = true;
	if (ans[3] ==3&&ans[4]==3&&ans[5]==3)cnt = true;
	if (ans[6] ==3&& ans[7]==3&& ans[8]==3)cnt = true;
	if (ans[0] ==3&& ans[3]==3&&ans[6]==3)cnt = true;
	if (ans[1] ==3&&ans[4] ==3&& ans[7]==3)cnt = true;
	if (ans[2] ==3&&ans[5]==3&& ans[8]==3)cnt = true;
	if (ans[0] ==3&& ans[4]==3&& ans[8]==3)cnt = true;
	if (ans[2] ==3&& ans[4]==3&& ans[6]==3)cnt = true;
	Yes(cnt == true);

	please AC;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;
const int INF=1e9;
using namespace std;

int main(){
    int a, b;
    cin>>a>>b;
    if((a*b)%2==0) cout<<"Even"<<endl;
    else cout<<"Odd"<<endl;
}


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

typedef long long ll;

int main() {
  int N,Q;
  cin>>N>>Q;
  string S;
  cin>>S;
  vector<int> l(Q,0),r(Q,0);
  for(int i = 0; i < Q; i++) cin>>l[i]>>r[i];
  vector<int> ACnum(N+2,0);
  int ACcount;
  ACcount = 0;
  for (int i = 0; i < N; i++) {
    ACnum[i] = ACcount;
    if(S[i] == 'A' && S[i+1] == 'C') {
      ACcount += 1;
      ACnum[i] = ACcount;
    }
  }
  for(int i = 0; i < Q; i++) cout<<ACnum[r[i]-2]-ACnum[l[i]-2]<<endl;
  return 0;
}

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

int main(){
  int N,remain,sum = 0,mina = INT_MAX;
  cin >> N >> remain;
  for (int i = 0;i < N ;i++ ){
    int now;
    cin >> now;
    sum += now;
    mina = min(now,mina);
  }
  cout << N + (remain - sum)/mina << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define int long long
constexpr long long INF = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    string S;
    cin>>S;

    int N=S.size();
    int c=15-N;
    
    rep(i,N){
        if(S[i]=='o') c++;
    }
    if(c>=8)cout << "YES" << endl;
    else cout << "NO" << endl;



}


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

int main() 
{
    ll a,b,k;
    cin >> a >> b >> k;
    ll x = 0;
    if (a-k>=0)
        cout << a-k << " " << b;
    else 
        cout << "0 " << max(x,b+(a-k));    
    return 0;
}

Measured memory_bytes: 256
N = int(input())
A_lst = []
max_num = -1
max_index_lst = []
next_num = -1

for i in range(N):
    Ai = int(input())
    A_lst.append(Ai)
    if max_num == -1:
        max_num = Ai
        max_index_lst.append(i)
    elif next_num == -1:
        if max_num > Ai:
            next_num = Ai
        else:
            if max_num == Ai:
                max_index_lst.append(i)
            else:
                max_index_lst = [i]
            next_num = max_num
            max_num = Ai


    elif max_num <= Ai:
        if max_num == Ai:
            max_index_lst.append(i)
        else:
            max_index_lst = [i]
        next_num = max_num
        max_num = Ai

    
    elif next_num < Ai:
        next_num = Ai
#print()
ans_lst = [max_num]*N

if len(max_index_lst) == 1:
    ans_lst[max_index_lst[0]] = next_num

for i in ans_lst:
    print(i)

Measured memory_bytes: 83032
from collections import deque
h, w = map(int, input().split())
ch, cw = map(int, input().split())
dh, dw = map(int, input().split())
maze = [[9]*(w+4)]
maze.append([9]*(w+4))
for i in range(h):
  s = input()
  tmp = [9,9]
  for i in s:
    if i == "#":
      tmp.append(9)
    else:
      tmp.append(0)
  tmp.append(9)
  tmp.append(9)
  maze.append(tmp)
maze.append([9]*(w+4))
maze.append([9]*(w+4))
#print(maze)

pos = deque()
pos.append([ch+1,cw+1,0])
while len(pos)>0:
  x, y, hop = pos.popleft()
  #print(pos)
  #print[x,y,hop)
  if (x,y) == (dh+1,dw+1):
    print(hop)
    break
  maze[x][y] = 3
  
  if maze[x-1][y] <3:
    pos.appendleft([x-1,y,hop])
    maze[x-1][y] = 3  
    
  if maze[x+1][y] <3:
    pos.appendleft([x+1,y,hop])
    maze[x+1][y] = 3
    
  if maze[x][y-1] <3:
    pos.appendleft([x,y-1,hop])
    maze[x][y-1] = 3
    
  if maze[x][y+1] <3:
    pos.appendleft([x,y+1,hop])
    maze[x][y+1] = 3

  move =[(-2,0),(-2,1),(-2,2),(-2,-1),(-2,-2),(2,0),(2,1),(2,2),(2,-1),(2,-2),(0,-2),(-1,-2),(1,-2),(0,2),(-1,2),(1,2),(-1,1),(-1,-1),(1,1),(1,-1)]
  for dx,dy in move:
    if maze[x+dx][y+dy] <2:
      pos.append([x+dx,y+dy,hop+1])
      maze[x+dx][y+dy] = 2
  
else:
  print(-1)

Measured memory_bytes: 110460
from itertools import combinations
inf = 1 << 30

d, g = [int(x) for x in input().split()]
p, c = zip(*[[int(x) for x in input().split()] for _ in range(d)])

def n_prob(l):
  t = sum([p[i]*(i+1)*100+c[i] for i in l])
  n = sum([p[i] for i in l])
  if t<g:
    for j in range(d-1, -1, -1):
      if j not in l:
        if t+p[j]*(j+1)*100 >= g:
          n += (g-t+(j+1)*100-1)//((j+1)*100)
          return n        
    return inf
  return n

print(min([n_prob(l) for x in range(d+1) for l in combinations(range(d), x) ]))

Measured memory_bytes: 3192
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
int main(){
    long N;
    std::cin >> N;
    std::map<std::string, long> cnt;
    std::vector<std::string> ans;
    for(int i = 0; i < N; i++) {
        std::string s;
        std::cin >> s;
        cnt[s]++;
    }
    long max = 0;
    for(auto& m : cnt) {
        if(max < m.second)
            max = m.second;
    }
    for(auto& m : cnt) {
        if(max == m.second)
            ans.push_back(m.first);
    }
    for(auto& s : ans)
        std::cout << s << std::endl;
    return 0;
}

Measured memory_bytes: 25196
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <cstdlib>
using namespace std;
const long long INF = 1LL << 60;

int main() {
  int N;
  cin>>N;
  int bar[N];
  long long all=0; //全部の和
  for(int i=0; i<N; i++){
    cin>>bar[i];
    all+=bar[i];
  }
  long long min=INF;
  int kiru=0;
  long long zenhan=0;
  for(int i=0; i<N; i++){
    zenhan+=bar[i];
    if(abs(all-2*zenhan)<min){
      min=abs(all-2*zenhan);
      kiru=i; //i番目で切ると差が最小
  } //if
  } //i
  cout<<min<<endl;
  // cout<<kiru<<endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>

using namespace std;

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

    int ans = 0;
    for (int i=a; i<=b; i++) {
        string s = to_string(i);
        bool r = true;
        for (int j=0; j<s.size(); j++)
            if (s[j] != s[s.size()-j-1]) r = false;
        if (r) ans++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 888
// 基本テンプレート
 
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#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>
using namespace std;
 
#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
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;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;
 
signed main() {
    int X, A, B; cin >> X >> A >> B;
    cout << X - A - (X - A) / B * B << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fastio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define ull unsigned long long
#define vi vector<int>
#define pi pair<int, int>
#define F first
#define S second
#define PB push_back
#define EPB emplace_back
#define MP make_pair
#define d(x) cerr << #x << ":" << x << endl;
#define da(x) cerr << #x << endl; for (auto a : x) cerr << a << " "; cerr << endl;
const int MOD = 1000000007;

int main() {
	fastio();
	int n, ai, q;
	ll t=0;
	cin >> n;
	map<int, int> m; // <ai, occ>
	for(int i=0;i<n;i++) {
		cin >> ai;
		t += ai;
		m[ai]++;
	}
	cin >> q;
	int b, c;
	while(q--) {
		cin >> b >> c;
		t -= (long long)b * m[b];
		t += (long long)c * m[b];
		cout << t << "\n";
		m[c] += m[b];
		m[b] = 0;
	}
	return 0;
}



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

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

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

    int ans = 0;
    while (b > (ans - 1)*(a - 1) + (a)){
        ans++;
    }
    
    cout << ans << endl;
}


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

int main(){
    int a,b,c = 0;
    cin >> a >> b >> c;
    int cnt = 0;
    for (int i=a;i<b+1;i++){
        if (c%i==0){
            cnt++;
        }
    }
    cout << cnt << endl;
}


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

int main() {
  	int N;
  	cin >> N;	
  
	vector<vector<int>> data(N+1, vector<int>(3));
  
 for (int i = 0; i < N; i++) {
    for (int j = 0; j < 3; j++) {
      cin >> data.at(i+1).at(j);
    }
  }
  
  bool can = true;
  for (int i = 0; i < N; ++i) {
    for (int j = 0; j < 3; j++) {
      int dt = data.at(i+1).at(0) - data.at(i).at(0);
      int dist = abs(data.at(i+1).at(1) - data.at(i).at(1)) 
        + abs(data.at(i+1).at(2) - data.at(i).at(2));
      if (dt < dist) can = false;
      if (dist % 2 != dt % 2) can = false;
    }
   }

    if (can) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 5760
#require 'prime'
#require 'openssl'
MOD=10**9+7;  cnt=0; sum=0; prev=nil; can=true; h=Hash.new(0)
def gs() gets.chomp end
def gi() gets.chomp.to_i end
def gsmi() gets.chomp.split.map(&:to_i) end

def ar2(s1,s2,de=nil) Array.new(s1){Array.new(s2,de)} end
def ar3(s1,s2,s3,de=nil) Array.new(s1){Array.new(s2){Array.new(s3,de)}} end

def desc(ar) ar.sort!{|x,y| y<=>x} end
def min(a,b) a<=b ? a : b end
def max(a,b) a>=b ? a : b end
def sum(ar) ar.inject(:+).to_i end
def ceil(a,b) (a.to_f/b).ceil end

def C(a,b) b==0||a==b ? 1 : (b=a-b if a/2<b;(a-b+1..a).inject(:*)/(1..b).inject(:*)) end
def rui(ar) s=[0]; ar.size.times{|i| s<<s[-1]+ar[i]}; s end
def rev_rui(ar) s=[0]; ar.size.times.reverse_each{|i| s<<s[-1]+ar[i]}; s end

def puts_yesno(b) puts(b ? 'Yes' : 'No') end
def putsend(s) puts s; exit end
def pu(h) begin; require './../nemi_lib/debug.rb'; puts_val(h); rescue LoadError; end; end
########### ( ˘ω˘ )ｽﾔｧ… ###########
n,k=gsmi
m=n%k
puts min(m,(k-m).abs)

Measured memory_bytes: 1788
/**
 *    Author:  "Robin Singh" !!!
 *    BrainyIsTheNewSexy     (CodeForces)
 *    rob_in_1               (Other OJs)
**/
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define IO  freopen("in.txt", "r", stdin); freopen("out.txt", "w", stdout);
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define make_unique(x) sort(all((x))); (x).resize(unique(all((x))) - (x).begin())
#define ff first
#define ss second
#define mp make_pair
#define szz(v) ((int)(v).size())  
#define fr(i, j, k) for(int i = j; i < k; i++)     
#define bk(i, j, k) for(int i = j-1; i >= k; i--)
#define mem(ptr)  memset(ptr, 0, sizeof ptr) 
#define nl "\n"
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector <int> vi;
typedef vector <long long> vll;
typedef vector < pair<int,int> > vpii;
typedef vector < pair<ll, ll> > vpll;
const long long mod = 1e9+7;
const long double eps = 1e-9;
const long long INF = (1LL<<61);
const int inf = (1<<30);
const int nn = 1e6+5;
//---------------------------------------------*DEBUGGING*--------------------------------------------------------->]
#define dbg( args...) { vector<string> _v = split( #args, ','); err( _v.begin(), args); cerr << '\n'; }
vector<string> split( const string& s, char c) { vector<string> v; stringstream ss( s); string x; 
while ( getline( ss, x, c)) v.emplace_back(x); return move(v); }
void err( vector<string>::iterator it) { } 
template<typename T, typename... Args>
void err( vector<string>::iterator it, T a, Args... args) {
    cerr << it -> substr( ( *it)[0] == ' ', it -> length()) << " = " << a << '\t'; err( ++it, args...); }
//----------------------------------------------------------------------------------------------------------------->]
//*****************************************!Template Ends Here!*****************************************************]

int main()
{
    // IO;
    IOS;
    int n, t, mn = inf;
    cin >> n >> t;
    fr(i, 0, n){
    	int c , tt;
    	cin >> c >> tt;
    	if(tt <= t) mn = min(mn, c);
    }
    if(mn == inf) cout << "TLE";
    else cout << mn;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main()
{
    int n, m;
    cin >> n >> m;
    vector<int> h(100000);
    vector<int> c(100000, 0);
    for (int i = 0; i < n; i++) {
        cin >> h[i];
    }
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        if (h[a-1] >= h[b-1]) {
            c[b-1]++;
        }
        if (h[a-1] <= h[b-1]) {
            c[a-1]++;
        }
    }
    int count = 0;
    for (int i = 0; i < n; i++) {
        if (c[i] == 0) {
            count++;
        }
    }
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 4048
//by rko27
//One more....
//---------------------------------------------------------------------------------------------------------------------------------------------------

#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define int  long long 
#define ll  long long 
#define pb push_back
#define mp make_pair
#define fe first
#define se second
#define nl "\n"
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define god ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

//----------------------------------------------------------------------------------------------------------------------------------------------------


int mod=1000000000+7;
int modu=998244353;

//----------------------------------------------------------------------------------------------------------------------------------------------------

ll power(ll x,ll y){ll res=1;x=x;while(y>0){if(y&1)res=(res*x);y=y>>1;x=(x*x);}return res;}
ll powe(ll x, ll y){ x = x%mod, y=y%(mod-1);ll ans = 1;while(y>0){if (y&1){ans = (1ll * x * ans)%mod;}y>>=1;x = (1ll * x * x)%mod;}return ans;}
void fun()
{
	//#ifndef ONLINE_JUDGE
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	//#endif
	//786
}
bool isPrime(int n){for(int i=2;i*i<=n;i++)if(n%i==0) return false;return true;}
ll ncr(ll n,ll r){ll res=1;if(r>n)return 0;if(r>n-r)r=n-r;for(ll i=0;i<r;i++){res*=(n-i);res/=(i+1);}return res;}

//-------------------------------------------------------------------------------------------------------------------------------------------------------

std::vector<pair<int,int > > v;

//--------------------------------------------------------------------------------------------------------------------------------------------------------


//--------------------------------------------------------------------------------------------------------------------------------------------------------
signed main() 
{
	god;
	//rko;
	fun();
	int tt=1; //cin>>tt;
	while(tt--)
	{
		int n; cin>>n;
		int h[n+1]; h[0]=0;
		for(int i=1;i<=n;i++) cin>>h[i];
		int dp[n+1];
		dp[0]=0; dp[1]=0;
		dp[2]=abs(h[1]-h[2]);
		for(int i=3;i<=n;i++) dp[i]=min(dp[i-2]+abs(h[i]-h[i-2]), dp[i-1]+abs(h[i]-h[i-1]));
		cout<<dp[n];
	}
	return 0;
}


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

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



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <utility> // pair
#include <string>
#include <vector>
#define MAX_N 100001
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define FOR(i, a, b) for(ll i=a; i<b; i++)
#define REP(i, n) for(ll i=0; i<n; i++)
#define REV(i, n) for(ll i=n-1; i>=0; i--)
#define ALL(v) v.begin(), v.end()
#define pb push_back
const ll INF = 9e18;
ll n;

signed main(){
	cin >> n;
	for(int i=1; i<MAX_N; i++){
		if((ll)floor(i * 1.08) == n){
			cout << i << endl;
			return 0;
		}
	}
	cout << ":(" << endl;
    return 0;
}

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

int data[101];

int cmp(const void *a, const void *b)
{
    return *(int *)a - *(int *)b;
}

int main(void)
{
    int i, n, ans = 0;

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

    qsort(data, n*2, sizeof(int), cmp);

    for (i = 0; i < 2*n; i+=2) {
        ans += data[i];
    }

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

    return 0;
}




Measured memory_bytes: 128
#![allow(non_snake_case)]
//use std::f64::consts;
fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let a:f64 = sc.read();
    let b:f64 = sc.read();
    let x:f64 = sc.read();
//    let angle = consts::PI * (180 as f64);
    if (a as usize)*(a as usize)*(b as usize) <= (x as usize)*(2 as usize) {
        println!("{}", ((a*a*b - x)*(2 as f64)/(a*a*a)).atan().to_degrees());
    }else{
        
        println!("{}", ((a*b*b)/((2 as f64)*x)).atan().to_degrees());
    }
    
}

pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n')
            .take_while(|&b| b != b' ' && b != b'\n')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
        .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}



Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define MD 1000000007
typedef long long int ll;

int main(){
    int N;
    cin>>N;
    vector<ll> C(N,0),S(N,0),F(N,0),ans(N,0);
    for(int i=0;i<N-1;i++){
        cin>>C[i]>>S[i]>>F[i];
    }
    for(int i=N-2;i>=0;i--){
        ll time=0;
        for(int j=i;j<N-1;j++){
            if(j==i){
                time+=S[j];
            }
            if(time>=S[j]){//既に列車が稼働している
                ll tmp=time-S[j];
                if(tmp%F[j]==0){
                    time+=C[j];
                }else{
                    time=S[j]+F[j]*(tmp/F[j]+1)+C[j];
                }
            }else{
                time=S[j]+C[j];
            }
        }
        ans[i]=time;
    }
    for(int i=0;i<N;i++){
        cout<<ans[i]<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        int n = Integer.parseInt(sc.next());
        
        if(n%10==2 ||n%10==4 || n%10==5 || n%10==7 || n%10==9) System.out.println("hon");
        else if(n%10==0 ||n%10==1 || n%10==6 || n%10==8) System.out.println("pon");
        else System.out.println("bon");
    }
}

Measured memory_bytes: 35644