akhauriyash/Code-Regression huggingface dataset:
#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;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    string S;
    cin >> N >> S;
    map<pair<string, string>, ll> map;
    REP(p, pow(2LL, N)) {
        string r = "", b = "";
        REP(i, N) {
            if ((p >> i) & 1)
                r.push_back(S[N + i]);
            else
                b.push_back(S[N + i]);
        }
        reverse(b.begin(), b.end());
        map[pair<string, string>(r, b)]++;
    }

    ll ans = 0;
    REP(p, pow(2LL, N)) {
        string r = "", b = "";
        REP(i, N) {
            if ((p >> i) & 1)
                r.push_back(S[i]);
            else
                b.push_back(S[i]);
        }
        reverse(b.begin(), b.end());
        ans += map[pair<string, string>(b, r)];
    }
    cout << ans << endl;
    return 0;
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

ll f[101][11], p[101][11];
int main() {
  int n;
  cin >> n;
  rep(i, n) rep(j, 10) cin >> f[i][j];
  rep(i, n) rep(j, 11) cin >> p[i][j];

  ll ans = -INF;
  for (int b = 1; b < (1 << 10); b++) {
    ll t = 0;
    for (int i = 0; i < n; i++) {
      ll c = 0;
      for (int j = 0; j < 10; j++)
        if ((b & 1 << j) && f[i][j]) c++;
      t += p[i][c];
    }
    ans = max(ans, t);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <string.h>
using namespace std;
int n, m, a[1005], b[1005], c[1005][12], f[1 << 12], maxx, w[1 << 12];
int getx(int x) {
	int res= 0;
	for(int i= 1; i <= b[x]; i++) res+= (1 << (c[x][i] - 1));
	return res;
}
int getg(int x) {
	int res= 0;
	while(x) ++res, x-= (x & -x);
	return res;
}
int main() {
	cin >> n >> m, maxx= (1 << n);
	for(int i= 0; i < maxx; i++) w[i]= getg(i);
	for(int i= 1; i <= m; i++) {
		cin >> a[i] >> b[i];
		for(int j= 1; j <= b[i]; j++) cin >> c[i][j];
	}
	memset(f, 0x3f, sizeof(f));
	for(int i= 1, j; i <= m; i++) {
		j= getx(i);
		for(int k= j; k; k= (k - 1) & j) f[k]= min(f[k], a[i]);
	}
	for(int i= 1; i <= n; i++) {
		for(int j= 0; j < maxx; j++) {
			if(w[j] != i) continue;
			for(int k= 0; k < maxx; k++) {
				if(j == k || w[k] >= i || (k & (~j))) continue;
				f[j]= min(f[j], f[k] + f[k ^ j]);
			}
		}
	}
	if(f[maxx - 1] == 0x3f3f3f3f) f[maxx - 1]= -1;
	cout << f[maxx - 1] << endl;
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<ll,ll> P;
#define M 1000000007
#define F first
#define S second
#define PB push_back
#define INF 100000000000000000
struct SEG{
	ll seg[1<<19],la[1<<19];
	void ini(void){
		for(int i=0;i<1<<19;i++)seg[i]=0,la[i]=0;
	}
	void lazy(int l,int r,int k){
		if(la[k]!=0){
			seg[k]+=la[k]*ll(r-l+1);
			if(l!=r){
				la[k*2+1]+=la[k];
				la[k*2+2]+=la[k];
			}
			la[k]=0;
		}
	}
	void add(int a,int b,int l,int r,int k,ll x){
		if(r<a||b<l){
			lazy(l,r,k);
			return;
		}
		if(a<=l&&r<=b){
			la[k]+=x;
			lazy(l,r,k);
			return;
		}
		lazy(l,r,k);
		add(a,b,l,(l+r)/2,k*2+1,x);
		add(a,b,(l+r)/2+1,r,k*2+2,x);
		seg[k]=seg[k*2+1]+seg[k*2+2];
	}
	ll sum(int a,int b,int l,int r,int k){
		lazy(l,r,k);
		if(r<a||b<l)return 0;
		if(a<=l&&r<=b)return seg[k];
		return sum(a,b,l,(l+r)/2,k*2+1)+sum(a,b,(l+r)/2+1,r,k*2+2);
	}
};
int n,q,k,sz[150005],hd[150005],cn[150005],in[150005],out[150005],vs[150005],dp[150005],hv[150005];
vector<int>g[150005];
void dfs1(int v,int p){
	sz[v]=1;
	for(int i=0;i<g[v].size();i++){
		int u=g[v][i];
		if(u!=p){
			dfs1(u,v);
			sz[v]+=sz[u];
			if(hv[v]==-1||sz[hv[v]]<sz[u])hv[v]=u;
		}
	}
}
void dfs2(int v,int p,int d,int h){
	in[v]=k;
	dp[k]=d;
	vs[k]=v;
	hd[k]=h;
	cn[k]=cn[h];
	k++;
	if(hv[v]!=-1)dfs2(hv[v],v,d+1,h);
	for(int i=0;i<g[v].size();i++){
		int u=g[v][i];
		if(u!=p&&u!=hv[v]){
			cn[k]=in[v];
			dfs2(u,v,d+1,k);
		}
	}
	out[v]=k;
}
SEG seg;
int main(void){
    scanf("%d%d",&n,&q);
    for(int i=0;i<n;i++)hv[i]=-1;
    for(int i=0;i<n-1;i++){
		int a,b;
		scanf("%d%d",&a,&b);
		g[a].PB(b);
		g[b].PB(a);
	}
	dfs1(0,-1);
	dfs2(0,-1,0,0);
	while(q--){
		int t,v,u;
		scanf("%d%d%d",&t,&v,&u);
		if(t==1){
			if(in[v]+1<=out[v]-1)seg.add(in[v]+1,out[v]-1,0,(1<<18)-1,0,u);
		}else{
			ll ans=0;
			v=in[v],u=in[u];
			while(hd[v]!=hd[u]){
				if(dp[hd[v]]>dp[hd[u]])swap(v,u);
				ans+=seg.sum(hd[u],u,0,(1<<18)-1,0);
				u=cn[u];
			}
			if(min(v,u)<max(v,u))ans+=seg.sum(min(v,u)+1,max(v,u),0,(1<<18)-1,0);
			printf("%lld\n",ans);
		}
	}
}


Measured memory_bytes: 30268
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <array>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include <math.h>
#include <queue>
#include <stdio.h>
using namespace std;
using i64 = int64_t;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep2(i, x, n) for(int i=x;i<n;++i)

int main()
{    
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    
    sort(a.begin(),a.end());
    cout << a[n-1] << " ";

    int best_aj = -1;
    int min_dist = 1 << 29;
    int b0 = a[n-1]%2==0 ? a[n-1]/2 : (a[n-1]-1)/2;
    int b1 = a[n-1]%2==0 ? a[n-1]/2 : (a[n-1]+1)/2;
    rep(i,n-1)
    {
        int tmp_dist = min(abs(a[i]-b0),abs(a[i]-b1));
        if(tmp_dist < min_dist)
        {
            min_dist = tmp_dist;
            best_aj = a[i];
        }
    }
    
    cout << best_aj << endl;
    return 0;
}

Measured memory_bytes: 640
import java.io.BufferedReader;
import java.io.InputStreamReader;

class Main {
	public static void main(String[] args) {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String line;
		try {
			while ((line = br.readLine()) != null) {
				String[] v = line.split(" ");

				int size = 0;
				for (String s : v) {
					if ("+-*/".indexOf(s) == -1) {
						size++;
					}
				}

				DoubleStack stack = new DoubleStack(size);
				for (String s : v) {
					switch (s) {
					case "+": {
						double a = stack.pop();
						double b = stack.pop();
						stack.push(b + a);
					}
						break;

					case "-": {
						double a = stack.pop();
						double b = stack.pop();
						stack.push(b - a);
					}
						break;

					case "*": {
						double a = stack.pop();
						double b = stack.pop();
						stack.push(b * a);
					}
						break;

					case "/": {
						double a = stack.pop();
						double b = stack.pop();
						stack.push(b / a);
					}
						break;

					default:
						stack.push(Double.parseDouble(s));
						break;
					}
				}

				System.out.println(String.format("%.6f", stack.pop()));
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	private static class DoubleStack {
		private double[] data;
		private int index = -1;

		public DoubleStack(int maxSize) {
			data = new double[maxSize];
		}

		public void push(double d) {
			data[++index] = d;
		}

		public double pop() {
			return data[index--];
		}
	}
}

Measured memory_bytes: 24720
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;


int main(){
	long long ans = 0;
	string s;
	cin >> s;
	for(auto c : s ){
		ans ^= (1<<(c-'a'));
	}
	if( ans == 0 ) cout << "Yes" << endl;
	else cout << "No" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string a;
    int i,j,k,l;
    cin>>a;
    l=a.size();
    if(l==6 && a[2]==a[3] &&  a[4]==a[5])
    {
        cout<<"Yes\n";
    }
    else cout<<"No\n";
    return 0;
}


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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;

int main()
{
    int a[26] = {};
    string s;
    cin >> s;
    rep(i, s.size())
    {
        a[s[i] - 'a']++;
        if (a[s[i] - 'a'] >= 2)
        {
            OP("no");
            return 0;
        }
    }

    OP("yes");

    return 0;
}

Measured memory_bytes: 256
INF = 10 ** 10
n, m = map(int, input().split())
dp = [[INF] * (2 ** n) for _ in range(m + 1)]
a = [0] * m
c = [0] * m
for i in range(m):
    a[i], b = map(int, input().split())
    t = 0
    for k in list(map(int, input().split())):
        t += 1 << (k - 1)
    c[i] = t
dp[0][0] = 0
for i in range(m):
    for j in range(2 ** n):
        dp[i + 1][j | c[i]] = min(dp[i + 1][j | c[i]], dp[i][j] + a[i])
        dp[i + 1][j] = min(dp[i + 1][j], dp[i][j])
ans = dp[m][(1 << n) - 1]
if ans == INF:
    print(-1)
else:
    print(ans)


Measured memory_bytes: 78424
#include<stdio.h>

int main(void){

    int n,i,c[4] = {0,0,0,0};
    char s[4];

    scanf("%d",&n);

    for(i = 0; i < n; i++){
        scanf("%s",s);
        if(s[0] == 'A')
            c[0]++;
            else if(s[0] == 'W')
                c[1]++;
                else if(s[0] == 'T')
                    c[2]++;
                    else if(s[0] == 'R')
                        c[3]++;
    }

    printf("AC x %d\n",c[0]);
    printf("WA x %d\n",c[1]);
    printf("TLE x %d\n",c[2]);
    printf("RE x %d\n",c[3]);


    return 0;
}

Measured memory_bytes: 1728
#include<bits/stdc++.h>
using namespace std;
 
long long n; int h1=1001,r1=1000,h2=2001,r2=2000,stp,a[105],ans[10005];
void solve(long long n){
	if (n==1 || n%2==0){
		if (n>1) solve(n-1);
		stp++;
		ans[++r1]=stp; ans[--h2]=stp;
	} else{
		solve(n/2);
		stp++; ans[++r1]=stp; ans[++r2]=stp;
	}
}
int main(){
	scanf("%lld",&n); solve(n);int i;
	printf("%d\n",r1-h1+r2-h2+2);
	for (i=h1; i<=r1; i++) printf("%d ",ans[i]);
	for (i=h2; i<=r2; i++) printf("%d ",ans[i]);
	return 0;
}

Measured memory_bytes: 256
//Heaplax
//别让自己后悔
#include<bits/stdc++.h>
#define LL long long
#define LOG(x) cerr<<#x<<" = "<<x<<endl
#define add_edge(u,v) nxt[++cnt]=head[u],head[u]=cnt,to[cnt]=v
#define open(x) freopen(#x".in","r",stdin),freopen(#x".out","w",stdout)
char ch;bool fs;void re(int& x)
{
	while(ch=getchar(),ch<33);
	if(ch=='-')fs=1,x=0;else fs=0,x=ch-48;
	while(ch=getchar(),ch>33)x=x*10+ch-48;
	if(fs)x=-x;
}
using namespace std;
const int mod=1000000007;
int n,m,ans,f[3005][3005][2];
void add(int &a,int b)
{
	a=a+b<mod?a+b:a+b-mod;
}
int main()
{
	re(n),re(m);
	for(int i=0;i<=n;++i)
		f[0][i][0]=1;
	for(int i=1;i<=m;++i)
		for(int j=0;j<=n;++j)
			for(int k=0;k<2;++k)
			{
				if(j)add(f[i][j][k|(j==1)],f[i-1][j][k]),add(f[i][j-1][k|(j==1)],f[i-1][j][k]);
				if(j<n)add(f[i][j][k|(j==0)],f[i-1][j][k]),add(f[i][j+1][k|(j==0)],f[i-1][j][k]);
			}
	for(int i=0;i<=n;++i)
		add(ans,f[m][i][1]);
	printf("%d\n",ans);
}


Measured memory_bytes: 70656
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s[3];
	int a;
	for (a=0; a<3; a++)
	{
		cin >> s[a];
	}
	cout << s[0][0] << s[1][1] << s[2][2] <<endl;
	return 0;
}

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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    
    ll n,k;
    cin>>n>>k;
    ll rem=n%k;
    cout<<min(rem,abs(rem-k));
}

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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)
#define mp make_pair

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int32 n,k,s;
    cin >> n >> k >> s;
    REP(i,k){
        if(i != 0)cout << " ";
        cout << s;
    }
    REP(i,n-k){
        if(k != 0 || i != 0)cout << " ";
        cout <<  ((s != 1e9) ? (s + 1) : 987654321);
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 1280
#include<stdio.h>
#include<string.h>
int main()
{
	int n,i;
	int count=0;
	char a[100005];
	scanf("%s",a);  //gets 
	n=strlen(a);
    if(a[0]==a[n-1])
	{
		if(n%2==0)
		{
		printf("First");	
		}
		else 
		printf("Second");
	 } 
	 else
	 {
	 	if(n%2==0)
		 {
		 printf("Second");
		 }
		 else
		 {
		 printf("First");	
		 }
	 }
	//开头结尾一样 or  不一样
	return 0;
	 
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <complex>
#include <cstdio>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define INF 1e9
#define rep(i,n) for(int i=0;i<n;i++)
typedef pair<double,int> P;
struct edge{int to;double cost;};

int n,m,s,go;
double d[27002];
vector<edge> g[27002];

void dijkstra(int s){
	multimap<double,int> q;
	fill(d,d+27002,INF);
	d[s]=0;
	q.insert(P(0,s));
	while(!q.empty()){
		P p=*(q.begin());
		q.erase(q.begin());
		int v=p.second;
		if(d[v]<p.first)continue;
		if(v==1)break;
		rep(i,g[v].size()){
			edge e=g[v][i];
			if(d[e.to]>d[v]+e.cost){
				d[e.to]=d[v]+e.cost;
				q.insert(P(d[e.to],e.to));
			}
		}
	}
}

int main(){
	while(cin>>n>>m&&n){
		rep(i,27002)g[i].clear();
		cin>>s>>go;s--;go--;
		edge e;
		rep(i,n){
			e.to=1;
			e.cost=0;
			g[i*n+go+2].push_back(e);
		}
		rep(i,m){
			int x,y,c;
			double dd;
			cin>>x>>y>>dd>>c;
			x--;y--;
			rep(v,c+2)rep(p,n){
				if(v==31)break;
				if(v==0){
					if(x==s){
						e.to=x*n+y+2;
						e.cost=dd;
						g[0].push_back(e);
					}
					if(y==s){
						e.to=y*n+x+2;
						e.cost=dd;
						g[0].push_back(e);
					}
				}
				else{
					for(int j=-1;j<2;j++){
						if(v+j>0&&v+j<=c&&p!=x&&p!=y){
							e.to=(v+j-1)*n*n+x*n+y+2;
							e.cost=dd/(v+j);
							g[(v-1)*n*n+p*n+x+2].push_back(e);
							e.to=(v+j-1)*n*n+y*n+x+2;
							g[(v-1)*n*n+p*n+y+2].push_back(e);
						}
					}
				}
			}
		}
		dijkstra(0);
		if(d[1]<INF)cout<<d[1]<<endl;
		else cout<<"unreachable"<<endl;
	}
}

Measured memory_bytes: 0
#include <iostream>
using namespace std;
int main(){int A,B,C,X,Y,p;cin >> A >> B >> C >> X >> Y;
cout << min(min(A*X+B*Y,2*C*min(X,Y)+ (X > Y ? A * (X-Y) : B * (Y - X))),2 * C * ( X > Y ? X : Y));
}

Measured memory_bytes: 256
s = list(input())

ans = len(s)
for t in s:
    m = 0
    cnt = 0
    # 同じ文字の区間の最大値がその文字の最小値
    for S in s:
        if S == t: 
            m = max(m,cnt)
            cnt = 0
        else:
            cnt += 1
    m = max(m,cnt)
    ans = min(ans,m)
print(ans)

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

using namespace std;

typedef long long lli;
typedef double lld;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<double> vdl;
typedef vector<vector<lli>> mat;
typedef vector<vdl> mad;
typedef unordered_map<lli,unordered_map<lli,lli>> graph;
typedef complex<double> cmp;
typedef vector<cmp> vcl;

lli n;
mat ans;

void error(){
  cout << "No" << endl;
  exit(0);
}

int main(){
  cin >> n;
  lli k = 1;
  for(;(k*k-k)/2 < n;k++);
  if((k*k-k)/2 != n) error();
  ans = mat(k);
  lli j = 0;
  lli s = 1;
  for(lli i = 1;i <= n;i++){
    // cout << j << " " << j+s << endl;
    ans[j].push_back(i);
    ans[j+s].push_back(i);
    s++;
    if(ans[j].size() == k-1) j++;
    if(j+s >= k) s = 1;
  }
  cout << "Yes" << endl;
  cout << k << endl;
  for(lli i = 0;i < k;i++){
    cout << ans[i].size();
    for(lli x : ans[i]) cout << " " << x;
    cout << endl;
  }

}


Measured memory_bytes: 3200
#include<bits/stdc++.h>
using namespace std;
#define eps 0.0000001
int n,m,i,j,k=0,l,t=0,vis[456]={};
double a,b,c,d,cost[34][34],dis[34],arr1[3][23],brr1[92345];
vector<int>adj[23];
/*
void Dijkstra(int source)
{
    priority_queue<pair<double,int>, vector<pair<double,int> >, greater<pair<double,int> > >pq;
    pq.push(make_pair(0,source));
    dis[source]=0;
    vis[source]=1;
    while(!pq.empty())
    {
        int u = pq.top().second;
        pq.pop();
        int szz = adj[u].size();
        for(int i=0; i<szz; i++)
        {
            int v = adj[u][i];
            if(v==u)
                continue;
            if(vis[v]==0)
            {
                dis[v]=max(dis[u],cost[u][v]);
                pq.push(make_pair(dis[v],v));
                vis[v]=1;
            }
            else if(max(dis[u],cost[u][v])<dis[v]){
                dis[v]=max(dis[u],cost[u][v]);
                pq.push(make_pair(dis[v],v));
            }
        }
    }
}
*/
int main()
{
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%lf %lf",&arr1[0][i],&arr1[1][i]);
    }
    for(i=0;i<n;i++){
        for(j=i+1;j<n;j++){
         a=arr1[0][i]-arr1[0][j];
         a*=a;
         b=arr1[1][i]-arr1[1][j];
         b*=b;
         c=a+b;
         c=sqrt(c);
       //  brr1[k++]=c;
         d+=c;
        // adj[i].push_back(j);
      //   cost[i][j]=c;
        }
    }
  // Dijkstra(0);
  l=(n*(n-1))/2;
  k=n-1;
  t=n-1;
  while(n>1){
    k*=n;
    n--;
  }
  n=k/(t);
  k/=l;
  d*=k;
   printf("%0.8f",d/n);
 //  for(i=0;i<n;i++)
  //  printf("%f ",dis[i]);


}


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#pragma GCC target ("sse4")

#include "bits/stdc++.h"
#include "ext/pb_ds/tree_policy.hpp"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/rope"

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) for(int i = 0; i < (a); ++i)
#define pb push_back
#define mp make_pair
#define sz(x) (int)x.size()
#define f first
#define s second

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

struct custom_hash 
{
    static uint64_t splitmix64(uint64_t x) 
    {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const 
    {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
int a, b;
int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> a >> b;
    int r = 1, ans = 0;
    while(r < b) r += (a - 1), ans++;
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
public class Main {
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc=new Scanner(System.in);
		int N=sc.nextInt();
		//System.out.println(N);
		int []n=new int[N];
		for(int i=0;i<n.length;i++){
			n[i]=sc.nextInt();
			//System.out.println(n[i]);
		}
		int M=sc.nextInt();
		for(int i=0;i<M;i++){
			int sum=0;
			int m=sc.nextInt();
			//System.out.println(m);
			//System.out.println(n[m-1]);
			int s=sc.nextInt();
			//System.out.println(s);
			int x=s-n[m-1];
			for(int j=0;j<N;j++){
				sum+=n[j];
			}
			sum+=x;
			System.out.println(sum);
		}
	}
}


Measured memory_bytes: 24020
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>
#include <string>

using namespace std;

typedef long long ll;

int main()
{
    int n;
    cin >> n;
    vector<ll> A(n);
    for(int i=0; i<n; i++){
        cin >> A[i];
    }
    sort(A.begin(), A.end());
    cout << A[n-1]-A[0] << endl;

    return 0;
}

Measured memory_bytes: 888
h,w,k = map(int, input().split())
s = [None]*h
for i in range(h):
    s[i] = list(input())
ans = [[0 for i in range(w)] for j in range(h)]
ans2 = [[0 for i in range(w)] for j in range(h)]
cnt=1
for i in range(h):
    for j in range(w):
        if s[i][j] == "#":
            ans[i][j] = cnt
            cnt+=1
piece=[0]*h
cnt=0
for i in range(h):
    for j in range(w):
        if ans[i][j] != 0:
            cnt+=1
            break
    piece[i] = cnt

for i in range(h):
    if piece[i] == 0:
        piece[i] = 1
for p in range(1,cnt+1):
    top=-1
    for j in range(h):
        if piece[j] == p:
            if top==-1:
                top=j
            bot=j

    beries=[]
    first_w=-1
    for j in range(w):
        berry=0
        for i in range(top,bot+1):
            if ans[i][j] != 0:
                berry=ans[i][j]
                if first_w==-1:
                    first_w = j
                    first_b = berry

        beries.append(berry)

    for j in range(first_w):
        beries[j] = first_b

    now_b = first_b
    for j in range(first_w,w):
        if beries[j] == 0:
            beries[j] = now_b
        else:
            now_b=beries[j]

    for i in range(top,bot+1):
        ans2[i] = beries


for row in ans2:
    print(*row,sep=" ")

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

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

	unordered_map<string, int> dict;

	dict["SUN"] = 7;
	dict["SAT"] = 1;
	dict["MON"] = 6;
	dict["TUE"] = 5;
	dict["WED"] = 4;
	dict["THU"] = 3;
	dict["FRI"] = 2;

	cout << dict[s];
}

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

int main()
{
	vector< pair <int,int> > vec;
	int n,i,k;
	cin>>n;
	for(i=0;i<n;i++) {
		cin>>k;
		vec.push_back(make_pair(k,i+1));
	}
	sort(vec.begin(),vec.end());
	for(i=0;i<n;i++)
		cout<<vec[i].second<<" ";
}

Measured memory_bytes: 1780
// SeeAlso: https://atcoder.jp/contests/abc063/tasks/abc063_b

#include <bits/stdc++.h>

using namespace std;

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

#define MAX 100000
#define NIL -1
#define MOD 1000000007

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

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

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

// 最大公約数
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
// 最小公倍数
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
template<class T> void print(const T& x){cout << setprecision(12) << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }

string S;
int hoge[MAX];
int main() {
    cin >> S;

    REP(i, MAX) {
        hoge[i]=0;
    }
    bool flag = false;
    REP(i, S.length()) {
        hoge[S[i]]++;

        if (hoge[S[i]]>1) {
            flag = true;
            break;
        }
    }
    print(flag?"no":"yes");
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using ll = long long;
constexpr int INF = 1e9;
constexpr long long LINF = 1e18;
constexpr long long MOD = 1e9 + 7;

template <typename T1, typename T2>
inline void chmax(T1 &a, T2 b) {
    if (a < b) a = b;
}

template <typename T1, typename T2>
inline void chmin(T1 &a, T2 b) {
    if (a > b) a = b;
}

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

signed main() {
    int n;
    cin >> n;
    double mxx[4], mxy[4], mnx[4], mny[4];
    fill(mxx, mxx + 4, -INF);
    fill(mxy, mxy + 4, -INF);
    fill(mnx, mnx + 4, INF);
    fill(mny, mny + 4, INF);
    map<char, int> mp;
    mp['R'] = 0;
    mp['L'] = 1;
    mp['U'] = 2;
    mp['D'] = 3;
    double x[n], y[n];
    char d[n];
    rep(i, n) {
        cin >> x[i] >> y[i] >> d[i];
        chmax(mxx[mp[d[i]]], x[i]);
        chmax(mxy[mp[d[i]]], y[i]);
        chmin(mnx[mp[d[i]]], x[i]);
        chmin(mny[mp[d[i]]], y[i]);
    }
    set<double> S;
    S.emplace(0);
    for (int i = 0; i < 4; i++){
        for (int j = i + 1; j < 4; j++){
            S.emplace(abs(mnx[i] - mnx[j]) / (i == 0 && j == 1 ? 2 : 1));
            S.emplace(abs(mnx[i] - mxx[j]) / (i == 0 && j == 1 ? 2 : 1));
            S.emplace(abs(mxx[i] - mnx[j]) / (i == 0 && j == 1 ? 2 : 1));
            S.emplace(abs(mxx[i] - mxx[j]) / (i == 0 && j == 1 ? 2 : 1));
            S.emplace(abs(mny[i] - mny[j]) / (i == 2 && j == 3 ? 2 : 1));
            S.emplace(abs(mny[i] - mxy[j]) / (i == 2 && j == 3 ? 2 : 1));
            S.emplace(abs(mxy[i] - mny[j]) / (i == 2 && j == 3 ? 2 : 1));
            S.emplace(abs(mxy[i] - mxy[j]) / (i == 2 && j == 3 ? 2 : 1));
        }
    }
    double ans = LINF;
    for (auto s : S) {
        double xmx = -INF, xmn = INF, ymx = -INF, ymn = INF;
        rep(i, n) {
            double nx = x[i] + s * dx[mp[d[i]]], ny = y[i] + s * dy[mp[d[i]]];
            chmax(xmx, nx);
            chmin(xmn, nx);
            chmax(ymx, ny);
            chmin(ymn, ny);
        }
        ans = min(ans, (xmx - xmn) * (ymx - ymn));
    }
    printf("%.12lf\n", ans);
    return 0;
}

Measured memory_bytes: 5484
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define int long long
#define ar array<int,2>
#define inf 1000000000000000000 
int mod=1e9+7;
int min(int a,int b){return (a<b)?a:b;}
int max(int a,int b){return (a>b)?a:b;}
int fp(int a,int b){if(b==0) return 1;int x=fp(a,b/2);x=(x*x)%mod;if(b&1) x=(x*a)%mod;return x;}


const int N=2e5+5;



void solve()
{
    
}

signed main() {
 ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); 
 srand(time(0));
 int t;
 cin>>t;
 cout<<(t^1);
 for(int i=1;i<=t;i++)
 {
   solve();
 }


}

Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <map>
#include <set>
typedef long long ll;
using namespace std;
int main() {
    ll n;
    string a, b, c;
    cin >> n >> a >> b >> c;
    ll count = 0;
    for (int i = 0; i < n; i++) {
        char _a = a[i];
        char _b = b[i];
        char _c = c[i];
        if (_a == _b && _b == _c) {
        }
        else if (_a == _b || _b == _c || _a == _c) {
            count++;
        }
        else {
            count += 2;
        }
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
#include <random>
#include <cassert>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 2e5 + 10;
int a[N];
int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int cnt0 = 0, cnt1 = 0, cnt2 = 0;
	int n;
	cin >> n;
	while (n--)
	{
		int x;
		cin >> x;
		if (x % 4 == 0) cnt0++;
		else if (x % 4 == 2) cnt2 = 1;
		else cnt1++;
	}
	if (cnt1 == 0) puts("Yes"), exit(0);
	if (cnt0 == 0) puts("No"), exit(0);
	if (cnt0 + 1 >= cnt1 + cnt2) puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
int main()
{
	int x,i,j,a,max,s1,s2,t;
	scanf("%d", &x);
	max=10000;
	if(x==1)
	{
		printf("1\n");
		return 0;
	}
	for(i=2; i<=sqrt(x); i++)
	{
		t=1;
		while(t<=x)
			t*=i;
		t/=i;
		if(x-t<max)
			max=x-t;
	}
	printf("%d\n",x-max);
	return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
K = []
S = []
for i in range(M):
    _input = list(map(int, input().split()))
    k = _input[0]
    s = _input[1:]
    s_bin = 0
    for j in s:
        cur_bin = 1 << (N-j)
        s_bin = s_bin | cur_bin
    K.append(k)
    S.append(s_bin)
P = list(map(int, input().split()))

def count_set_bit(i):
    n_count = 0
    while i:
        n_count += (i & 1)
        i = i >> 1
    return n_count

ans = 0

for i in range(2**N):
    is_ans = True
    for j in range(M):
        if count_set_bit(i & S[j]) % 2 != P[j]:
            is_ans = False
    if is_ans:
        ans += 1
print(ans)


Measured memory_bytes: 3064
// Created by sz
#include <bits/stdc++.h>
using namespace std;

const int N = 50 + 5, INF = 1e8;
int h,w, g[N][N], d[N][N], vis[N][N];

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

int main(){
#ifdef LOCAL
    freopen("./input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    cin>>h>>w;
    
    char c;
    int cnt_w = 0;
    for (int i = 1; i <= h; i++){
        for (int j = 1; j <= w; j++){
            cin>>c;
            if(c == '.'){
                g[i][j] = 0;  //可以通过
                cnt_w ++;
            }
            else g[i][j] = 1;
        }
    }
    
    
    fill_n(&d[0][0], N*N, INF);
    d[1][1] = 1;
    vis[1][1] = 1;
    queue<pair<int, int>> q;
    q.push({1,1});
    
    while (!q.empty()) {
        auto node = q.front();
        q.pop();
        int curx = node.first;
        int cury = node.second;
        for (int i = 0; i < 4; i++){
            int nx = curx + dx[i];
            int ny = cury + dy[i];
            if(nx<=0 || nx>h|| ny<=0||ny>w)continue;
            if(vis[nx][ny]||g[nx][ny])continue;
            d[nx][ny] = d[curx][cury] + 1;
            vis[nx][ny] = 1;
            q.push({nx,ny});
        }
    }
    
    
    
    if(d[h][w]==INF) cout<<-1<<endl;
    else cout<<cnt_w - d[h][w]<<endl;
    
    
    return 0;
}



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

const int N = 1e5 + 100, inF = N;

int n, k, ans, out[N], dis[N];
bool mark[N];
vector<int> in[N];

void dfs(int v, bool change = false) {
	mark[v] = change;
	for (int u: in[v]) 
		if(mark[u] == false) {
			dis[u] = dis[v] + 1;
			dfs(u, change);
		}
}

int main() {
	ios::sync_with_stdio(false), cin.tie(0);
	cin >> n >> k;
	cin >> out[0];
	ans += (out[0] != 1);
	
	for (int i = 1; i < n; i++) {
		cin >> out[i];
		in[--out[i]].push_back(i);
	}
	dfs(0);
	vector<int> vec(n);
	iota(vec.begin(), vec.end(), 0);
	sort(vec.begin(), vec.end(), [](int a, int b) {
		return dis[a] > dis[b];
	});
	for (int u: vec) {
		if(mark[u] || dis[u] <= k)
			continue;
		for (int i = 0; i < k - 1; i++)
			u = out[u];
		ans++;
		dfs(u, true);
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 11648
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <queue>
using namespace std;
typedef long long LL;
const int inf = 1 << 30;
const LL INF = 1LL << 60;
const int MaxN = 10005;

int H, W;
int all;
int pre[2 * MaxN + 5], last[MaxN + 5], other[2 * MaxN + 5];
int cost[2 * MaxN + 5], dis[MaxN + 5];
bool inq[MaxN + 5];

void build(int x, int y, int w) {
	pre[++all] = last[x];
	last[x] = all;
	other[all] = y;
	cost[all] = w;
}

int SPFA(int s) {
	for(int i = 0; i <= 9; i++) dis[i] = inf;
	dis[s] = 0;
	queue <int> q;
	q.push(s);
	inq[s] = 1;
	while(!q.empty()) {
		int x = q.front();
		q.pop();
		for(int ed = last[x]; ed != -1; ed = pre[ed]) {
			int dr = other[ed];
			if(dis[x] + cost[ed] < dis[dr]) {
				dis[dr] = dis[x] + cost[ed];
				if(inq[dr] == 0) {
					inq[dr] = 1;
				}
				q.push(dr);
			}
		}
		inq[x] = 0;
	}
	return dis[1];
}

int main()
{
	while(scanf("%d %d", &H, &W) != EOF)
	{
		all = -1; memset(last, -1, sizeof(last));
		for(int i = 0; i <= 9; i++) {
			for(int j = 0; j <= 9; j++) {
				int x;
				scanf("%d", &x);
				if(i == j) continue;
				build(i, j, x);
			}
		}
		LL ans = 0;
		for(int i = 1; i <= H; i++) {
			for(int j = 1; j <= W; j++) {
				int x;
				scanf("%d", &x);
				if(x != 1 && x != -1) {
					ans += (LL)SPFA(x);
				}
			}
		}
		printf("%lld\n", ans);
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n,i;
cin>>n;
int a[n];
for(i=0;i<n;i++)cin>>a[i];
for(i=0;i<n;i++){
	if(a[i]%2==0&&(a[i]%3!=0&&a[i]%5!=0)){
		cout<<"DENIED";
		return 0;
	}
}
cout<<"APPROVED";
return 0;
}

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

int main(){
vector<int> v;
int a;
//配列に格納
for(int i=0; i<3; i++){
    cin >> a;
    v.push_back(a);
}
sort(v.begin(),v.end(),greater<int>());//降順ソート
int x,y;
x=10*v[0]+v[1];
y=v[2];
cout <<x+y <<endl;    
return 0;
}

Measured memory_bytes: 256
import java.nio.file.*;
import java.nio.charset.*;
import java.util.*;


public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        if(n == 1){
            System.out.println("Hello World");
        }
        else{
            int a = sc.nextInt();
            int b = sc.nextInt();
            System.out.println(a + b);
        }
    }
}



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

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

  vector<int> x={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  cout << x.at(K-1) << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
using namespace std;
int N, a[100005], savea[100005], aida2[100005], aida3[100005], i, aida2sum, ans;
int main() {
	a[0] = 0;
	ans = 0;
	aida2sum = 0;
	cin >> N;
	for (i = 1;i <= N;i++) {
		cin >> savea[i];
		a[i] = savea[i];
	}
	aida2[1] = abs(a[1] - a[0]);
	for (i = 2;i <= N;i++) {
			aida2[i] = abs(a[i] - a[i - 1]);
			aida3[i] = abs(a[i] - a[i - 2]);
		}
	for (i = 1;i <= N;i++) {
		aida2sum += aida2[i];
	}
	for (i = 1;i <= N;i++) {
		if (i < N) {
			ans = aida2sum - aida2[i] - aida2[i + 1] + aida3[i + 1] + abs(a[N]);
			cout << ans << endl;
		}
		else {
			ans = aida2sum - aida2[i] - aida2[i + 1] + aida3[i + 1] + abs(a[N - 1]);
			cout << ans << endl;
		}
	}
}

Measured memory_bytes: 2816
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
static const ll mod=1000000007;
ll a[1005][1005];
ll modpow(ll x,ll y){
if(y==0)
  return 1;
  else if(y%2==0){
  ll z=modpow(x,y/2);
    return (z*z)%mod;
  }else{
  ll z=modpow(x,y/2);
    return (x*((z*z)%mod))%mod;
  }
}
ll dp[1005][1005];
ll comb[1005];
ll N,A,B,C,D;
int main(){
  for(int i=0;i<1005;i++)
    for(int j=0;j<1005;j++)
      a[i][j]=-1;
  cin>>N>>A>>B>>C>>D;
  comb[0]=1;
  for(ll i=1;i<=1004;i++)
    comb[i]=(i*comb[i-1])%mod;
  for(ll i=A;i<=B;i++)
    for(ll j=C;j<=D;j++){
    if(N<i*j)break;
      a[i][j]=modpow((modpow(comb[i],j)*comb[j])%mod,mod-2);
    }
  dp[A-1][0]=1;
  for(int i=A;i<=B;i++){
    for(int j=0;j<=N;j++)
      dp[i][j]=dp[i-1][j];
    for(int j=0;j<=N;j++){
    for(ll k=C;k<=D;k++){
    ll y=a[i][k];if(y<0)break;
      if(0<=j-i*k)
        dp[i][j]=(dp[i][j]+((dp[i-1][j-i*k]*y)%mod))%mod;
    }
    }
  }
    ll ans=(dp[B][N]*comb[N])%mod;
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 19196
#include<iostream>
#include<algorithm>
using lint=int64_t;
using namespace std;

int main()
{
	int N,M;
	lint x[1010]={};
	lint y[1010]={};
	lint z[1010]={};
	lint p[1010]={};

	cin >> N >> M;
	for(int i=0;i<N;i++)
		cin >> x[i] >> y[i] >> z[i];
	
	lint ans=0;
	for(int bit=0;bit<8;bit++)
	{
		for(int i=0;i<N;i++)
		{
			p[i]=0;
			if(bit&1)p[i]+=x[i];
			else p[i]-=x[i];
			if(bit&2)p[i]+=y[i];
			else p[i]-=y[i];
			if(bit&4)p[i]+=z[i];
			else p[i]-=z[i];
		}
		sort(p,p+N,greater<lint>());
		lint tmp=0;
		for(int i=0;i<M;i++)
			tmp+=p[i];
		ans=max(ans,tmp);
	}

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


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

int par[100001];
int dist[100001];

void init_union_find() {
    fill(par, par+100001, -1);
    fill(dist, dist+100001, 0);
}

int root(int x) {
    if(par[x] < 0) return x;
    int r = root(par[x]);
    dist[x] += dist[par[x]];
    return par[x] = r;
}

bool same(int x, int y) {
    return root(x) == root(y);
}

int weight(int x) {
    root(x);
    return dist[x];
}

int diff(int x, int y) {
    return weight(y) - weight(x);
}

void unite(int x, int y, int w) {
    w += weight(x);
    w -= weight(y);
    x = root(x);
    y = root(y);
    if(x == y) return;
    if(par[y] < par[x]) swap(x, y), w = -w;
    par[x] += par[y];
    par[y] = x;
    dist[y] = w;
}

int main() {
    int N, M;
    cin >> N >> M;
    init_union_find();
    for(int i = 0; i < M; i++) {
        int l, r, d;
        cin >> l >> r >> d;
        if(same(l, r)) {
            if((diff(l, r)) != d) {
                cout << "No" << endl;
                return 0;
            }
        } else {
            unite(l, r, d);
        }
    }

    cout << "Yes" << endl;

    return 0;
}


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

int main()
{
	int n = 0, k = 0, ans = 0;

	cin >> n >> k;

	if (k == 0)
		ans = 0;
	else if (n < k)
		ans = 1;
	else if (n%k == 0)
		ans = 0;
	else
		ans = 1;


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


Measured memory_bytes: 256
#include <cstdio>

using namespace std;

const long long inf=1e18;
long long v[100010],a,b;
int n;

int solve(long long nr)
{
    long long sol=0;
    for(int i=1;i<=n;i++)
    {
        long long x=v[i]-nr*b;
        if(x>0) sol+=(x/(a-b))+((x%(a-b))>0);
    }
    return (sol<=nr);
}

int main()
{
    //freopen("file.in", "r", stdin);
    //freopen("file.out", "w", stdout);
    scanf("%d%lld%lld",&n,&a,&b);
    for(int i=1;i<=n;i++) scanf("%lld",&v[i]);
    long long st=1,dr=inf/b;
    while(st<=dr)
    {
        long long mid=(st+dr)/2;
        if(solve(mid)) dr=mid-1;
        else st=mid+1;
    }
    printf("%lld",st);
    return 0;
}


Measured memory_bytes: 896
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<map>
#include<utility>
#include<tuple>
#include<algorithm>
#include<cmath>
using namespace std;

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

int main(){
  int N, M;
  cin >> N >> M;
  vector<pair<int, int>> a(M);
  rep(i,M) cin >> a[i].first >> a[i].second;
  sort(a.begin(), a.end(), [](pair<int, int> x, pair<int, int> y){
    return x.second<y.second;
  });
  int recent=0, ans=0;
  rep(i,M){
    if(recent <= a[i].first){
      recent=a[i].second;
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1024
import sys

a, v = map(int, sys.stdin.readline().split())
b, w = map(int, sys.stdin.readline().split())
t = int(sys.stdin.readline())

if a < b:
    print('YES' if a + v * t >= b + w * t else 'NO')
else:
    print('YES' if a - v * t <= b - w * t else 'NO')


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

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
        #define eprintf(...) 42
#endif

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define all(x) (x).begin(),(x).end()
#define foreach(u,v) for(auto (u) : (v))
#define pb push_back
#define mp make_pair
#define mt make_tuple

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

const int inf = 1e9;
const ll linf = 1LL<<60;
const ll mod = 1e9 + 7;
const double eps = 1e-9;

/*
*/

int n;
string s[300];

bool check(int a, int b)
{
  string ns[n];
  rep(i, n){
    rep(j, n){
      ns[i] += s[(i+a)%n][(j+b)%n];
    }
  }

  rep(i, n){
    rep(j, n){
      if(ns[i][j] != ns[j][i]) return false;
    }
  }

  return true;
}

int main()
{
  cin >> n;
  rep(i, n) cin >> s[i];

  ll cnt = 0;
  repi(k, 0, n){
    if(check(k, 0)) cnt += n-k;
//    cout << k << ": " << cnt << endl;
  }
  repi(k, 1, n){
    if(check(0, k)) cnt += n-k;
//    cout << k << ": " << cnt << endl;
  }
  
  cout << cnt << endl;

  return 0;
}


Measured memory_bytes: 632
// This file is a "Hello, world!" in C++ language by GCC for wandbox.
#include <iostream>
#include <cstdlib>
using namespace std;
int main()
{
    int x;cin>>x;
    cout<<x*x*x<<endl;
}

// GCC reference:
//   https://gcc.gnu.org/

// C++ language references:
//   https://cppreference.com/
//   https://isocpp.org/
//   http://www.open-std.org/jtc1/sc22/wg21/

// Boost libraries references:
//   https://www.boost.org/doc/



Measured memory_bytes: 3092
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    N = int(readline())
    dp = [[0] * 10 for _ in range(10)]

    ans = 0
    for i in range(1, N + 1):
        s = str(i)
        first = int(s[0])
        second = int(s[-1])

        ans += 2 * dp[second][first]

        if first == second:
            ans += 1

        dp[first][second] += 1

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 73660
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>
#include<boost/operators.hpp>
#include<boost/dynamic_bitset.hpp>

namespace adaptor = boost::adaptors;
using index_t = std::size_t;		

void Main()
{
	int N;
	std::cin >> N;
	--N;
	std::vector<int> bs(N);
	for (auto& b : bs)
	{
		std::cin >> b;
	}
	int sum = bs.front() + bs.back();
	for (int i : boost::irange(0, N - 1))
	{
		sum += std::min(bs[i], bs[i + 1]);
	}
	std::cout << sum << std::endl;
}

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,pos=1e9,ans;
struct number{
	int l,w;
}a[200005];
bool cmp(number x,number y) {
	return x.l<y.l;
}
int main() {
	cin>>n;
	for(int i=1;i<=n;i++) {
		scanf("%d",&a[i].l);
		a[i].w=i;
	}
	sort(a+1,a+n+1,cmp);
	for(int i=1;i<=n;i++) if(a[i].w<pos) pos=a[i].w,ans++;
	cout<<ans;
	return 0;
}

Measured memory_bytes: 1792
class DisjointSet
  attr_reader :parent, :rank

  def initialize(ids = [])
    @parent, @rank = {}, {}
    ids.each do |id|
      @parent[id] = id
      @rank[id] = 0
    end
  end

  def make_set(x)
    @parent[x] = x
    @rank[x] = 0
  end

  def find(x)
    return x if (@parent[x] == x)
    @parent[x] = find(@parent[x])
    @parent[x]
  end

  def union(x, y)
    x, y = find(x), find(y)
    rank_x, rank_y = @rank[x], @rank[y]

    return if (x == y)

    if (rank_x > rank_y)
      @parent[y] = x
    elsif (rank_x < rank_y)
      @parent[x] = y
    else
      @parent[y] = x
      @rank[x] += 1
    end
  end

  def same?(x, y)
    find(x) == find(y)
  end
end

n, m = gets.chop.split.map(&:to_i)

g = DisjointSet.new

n.times do |i|
  g.make_set i
end

m.times do
  g.union *gets.chop.split.map(&:to_i)
end

q = gets.chop.to_i

q.times do
  puts (g.same?(*gets.chop.split.map(&:to_i))) ? 'yes' : 'no'
end

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

int X,Y,A,B,C;
vector<int> P, Q, R;

signed main() {
  cin >> X >> Y >> A >> B >> C;
  P.resize(A);
  Q.resize(B);
  R.resize(C);
  for(int i=0; i<A; i++) cin >> P[i];
  for(int i=0; i<B; i++) cin >> Q[i];
  for(int i=0; i<C; i++) cin >> R[i];

  sort(P.begin(), P.end(), greater<int>());
  sort(Q.begin(), Q.end(), greater<int>());
  sort(R.begin(), R.end(), greater<int>());

  int pi = X-1;
  int qi = Y-1;
  int ri = 0;

  while(true) {
    if(ri >= C) break;

    bool p_update = (pi>=0 && P[pi] < R[ri]);
    bool q_update = (qi>=0 && Q[qi] < R[ri]);

    if( !p_update && !q_update) break;

    if(!p_update) {
      Q[qi] = R[ri];
      qi--; ri++;
      continue;
    }

    if(!q_update) {
      P[pi] = R[ri];
      pi--; ri++;
      continue;
    }

    if(Q[qi] < P[pi]) {
      Q[qi] = R[ri];
      qi--; ri++;
      continue;
    }
    else {
      P[pi] = R[ri];
      pi--; ri++;
      continue;
    }
  }

  int ans = 0;
  for(int x=0; x<X; x++) ans += P[x];
  for(int y=0; y<Y; y++) ans += Q[y];
  cout << ans << endl;
}


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

using namespace std;

int main(){
    long long int N,K,R,S,P,ans=0;
    string T;
    cin >> N >> K;
    cin >> R >> S >> P;
    cin >> T;
    for(int i=0;i<N;i++){
        if(i<K){
            if(T[i]=='r'){
                ans += P;
            }else if(T[i]=='s'){
                ans += R;
            }else{
                ans += S;
            }
        }else{
            if(T[i-K]!=T[i]){
                if(T[i]=='r'){
                    ans += P;
                }else if(T[i]=='s'){
                    ans += R;
                }else{
                    ans += S;
                }
            }else{
                T[i] = 'a';
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <complex>
#include <deque>
#include <valarray>
#include <unordered_map>
#include <unordered_set>
#include <array>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <chrono>
#include <random>
#include <numeric>
using namespace std;
using ll = long long;
using ld = long double;
using str = string;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vs> vvs;
typedef vector<vc> vvc;
typedef vector<vb> vvb;
using P = pair<ll,ll>;
#define REP(i, n) for (ll i = 0; i < (int)(n); i++)
#define RREP(i, n) for (ll i = (int)(n)-1; i > -1 ; i--)
#define IN(T, x) T x;cin >> x;
#define AIN(T, a, n) vector<T> a(n);REP(i, n){cin >> a[i];}
#define A2IN(T1, a, T2, b, n) vector<T1> a(n);vector<T2> b(n);REP(i, n){cin >> a[i] >> b[i];}
#define ALL(a) (a).begin(),(a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) SORT(a);reverse(ALL(a))
#define pb push_back
#define mp make_pair
#define PF first
#define PS second
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;}
template<typename A, size_t N, typename T>void Fill(A (&array)[N], const T &val){fill( (T*)array, (T*)(array+N), val );}
#define OUT(x) cout << x << endl;
#define OUTD(x) cout << fixed << x << endl;
#define BOUT(b) if(b){OUT("Yes");}else{OUT("No");}
const ll MOD = 1000000007;
const ll INF = 10e9;
#define PI 3.14159265369;
ll dx[4] = {1,-1,0,0};
ll dy[4] = {0,0,1,-1};
ll ddx[8] = {1,1,1,-1,-1,-1,0,0};
ll ddy[8] = {0,1,-1,0,1,-1,1,-1};

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  IN(ll,K);
  IN(str,S);
  if(S.size() <= K){
    OUT(S);
  }else{
    REP(i,K){
      cout << S[i];
    }
    OUT("...");
  }

}

Measured memory_bytes: 3620
#include <stdio.h>
int main(){
  int a,b,c,i;
  scanf("%d %d %d",&a,&b,&c);
  if(a>b){
    i=a;
    a=b;
    b=i;
  }
  if(a>c){
    i=a;
    a=c;
    c=i;
  }
  if(b>c){
    i=b;
    b=c;
    c=i;
  }
  printf("%d %d %d\n",a,b,c);
  return 0;
}

Measured memory_bytes: 596