akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
int main(){
  int N;
  cin >> N;
  string F[N];
  string BK[N];
  string BN[N];
  string SK[N];
  string SN[N];
  for(int i=0;i<N;i++){
    cin >> F[i];
    BK[i] = F[i].at(0);
    SK[i] = F[i].at(0);
    BN[i] = F[i].at(1);
    SN[i] = F[i].at(1);
  }
  for(int i=0;i<N;i++){
    for(int j=N-1;j>0;j--){
      if(BN[j]<BN[j-1]){
        swap(BN[j],BN[j-1]);
        swap(BK[j],BK[j-1]);
      }
    }
  }
  for(int i=0;i<N;i++){
    if(i<N-1){
    cout << BK[i] << BN[i] << " ";
    }
    else if(i==N-1){
      cout << BK[i] << BN[i] << endl << "Stable" << endl;
    }
  }
  for(int i=0;i<N-1;i++){
    int min=i;
    for(int j=i;j<N;j++){
      if(SN[j]<SN[min]){
        min =j;
      }
    }    
    swap(SN[i],SN[min]);
    swap(SK[i],SK[min]);
  }
  for(int i=0;i<N;i++){
    if(i<N-1){
      cout << SK[i] << SN[i] << " ";
    }
    else if(i==N-1){
      cout << SK[i] << SN[i] << endl;
    }
  }
  for(int i=0;i<N;i++){
    if(BK[i]!=SK[i]){
      cout << "Not stable" << endl;
      break;
    }
    if(i==N-1){
      cout << "Stable" << endl;
    }
  }
}  


Measured memory_bytes: 3128
#include <bits/stdc++.h>
#define in freopen("input.txt", "r" ,stdin)
#define out freopen("output.txt", "w" , stdout)
#define ll long long
#define inf 100005
#define fr first
#define  sc second
#define pb push_back
#define p_b pop_back
#define mp make_pair
using namespace std;
int n;
int a[100005];
int main (){
//in;out;
ios_base::sync_with_stdio(0);
cin >> n;
for (int i = 1; i <=n; i++){
    cin >> a[i];
}
for (int i = 1; i <= n; i++) {
     if (a[i]%2 != 0) {
        cout << "first";
        return 0;
     }
}
cout << "second";
}


Measured memory_bytes: 640
// AtCoder ABC139: C - Lower
// 2019.9.2 bal4u

#include <stdio.h>

//// 高速入力
#if 1
#define gc() getchar_unlocked()
#else
#define gc() getchar()
#endif

int in() {   // 非負整数の入力
	int n = 0, c = gc();
	do n = 10 * n + (c & 0xf); while ((c = gc()) >= '0');
	return n;
}

int main()
{
	int N, p, hi, n, ans;
	
	N = in();
	ans = 0, n = 0, p = 0; while (N--) {
		if ((hi = in()) <= p) n++;
		else {
			if (n > ans) ans = n;
			n = 0;
		}
		p = hi;
	}
	if (n > ans) ans = n;
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 128
N = int(input())
TEN = 1
NINE = 1
EIGHT = 1
a = 10
b = 9
c = 8

mod = 10 ** 9 + 7

while N:
    if N % 2:
        TEN *= a
        TEN %= mod
        NINE *= b
        NINE %= mod
        EIGHT *= c
        EIGHT %= mod
    N //= 2
    a *= a
    a %= mod
    b *= b
    b %= mod
    c *= c
    c %= mod

print((TEN - 2 * NINE + EIGHT + mod * 2)%mod)

Measured memory_bytes: 61824
a,b,c,k=map(int,input().split())
k-=a
sum=a
if k<=0:
    sum-=abs(k)
    print(sum)
else:
    k-=b
    if k<=0:
        print(sum)
    else:
        #print(sum)
        sum-=k
        print(sum)

Measured memory_bytes: 61664
#include"bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;
 
#define int long long int
#define pb push_back
#define mp make_pair
#define loop(i,x,n) for(int i=x;i<=n;i++)
#define rloop(i,x,n) for(int i=x;i>=n;i--)
#define ff first
#define ss second
#define N4RUTO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
 
typedef tree<int, null_type, less<int>, rb_tree_tag,  
// typedef tree<int, null_type, less_equal<int>, rb_tree_tag,  
tree_order_statistics_node_update>
ordered_set;
 
int32_t main(){
    N4RUTO;
    int t;
    t=1;
    // cin>>t;
    while(t--){
        int n;
        cin>>n;
        set<string> s;
        loop(i,0,n-1){
            string x;
            cin>>x;
            s.insert(x);
        }
        cout<<s.size()<<"\n";
    }
    return 0;
}

Measured memory_bytes: 19216
def f1(l1):
    ret = []
    for i in l1:
      for n,j in enumerate(li[i]):
        if j:
            if n in used or n in l1:
                return False
            elif n not in tree[nest-1] and n not in ret:
                ret.append(n)
    return ret


N = int(input())
li = []
for _ in range(N):
    li.append(list(map(int,list(input()))))
    
max_nest = 0
for i in range(N):
    tree = [[]]
    used = []
    tree.append([i])
    nest = 1
    while True:
        ret = f1(tree[nest])
        nest += 1
        if ret == False:
            break
        elif ret != []:
            tree.append(ret)
            used.extend(tree[nest-2])
        else:
            if max_nest < nest:
                max_nest = nest
            break
        
print(max_nest-1)

Measured memory_bytes: 44252
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<iomanip>
#include<list>
#include<deque>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define DEB2(X) cout<<X<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define DEB2(X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
//typedef std::pair<int,int> P;
struct edge{int to,cost;};
const int INF=100000000000000000;
const int INF2=9223372036854775807;
const int MOD=1000000007;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
#define NP(X,Y) next_permutation(X,Y)
#define setdouble(X,Y) cout<<fixed<<setprecision(X)<<Y
int ceil2(int a,int b){if(a%b==0){return a/b;}else{return a/b+1;}}
int pow2(int a,int b){int r=1;for(int i=1;i<=b;i++){r*=a;}return r;}
int Log2(int a){int t=0;while(1){if(a==0||a==1){break;}a/=2;t++;}return t;}

int N;
int A[100010];
set<int> U;
map<int,int> H;
int C[5];
int B[100010];

void solve(int a,int b){
	REP(i,N){
		B[i]=0;
	}
	REP(i,N){
		if(i%3==0){
			B[i]=a;
		}
		else if(i%3==1){
			B[i]=b;
		}
		else{
			B[i]=a^b;
		}
	}
	bool flag=true;
	sort(B,B+N);
	REP(i,N){
		if(A[i]!=B[i]){
			flag=false;
		}
	}
	if(flag==true){
		cout<<"Yes"<<endl;
		exit(0);
	}
}

signed main(){
	cin>>N;
	REP(i,N){
		cin>>A[i];
		U.insert(A[i]);
		H[A[i]]++;
	}
	sort(A,A+N);
	vector<int> v(U.begin(),U.end());
	if(U.size()>=4){
		cout<<"No"<<endl;
		return 0;
	}
	else if(U.size()==1){
		solve(v[0],v[0]);
	}
	else if(U.size()==2){
		solve(v[0],v[1]);
		solve(v[1],v[0]);
	}
	else{
		solve(v[0],v[1]);
		solve(v[1],v[0]);
		solve(v[1],v[2]);
		solve(v[2],v[1]);
		solve(v[0],v[2]);
		solve(v[2],v[0]);
	}
	cout<<"No"<<endl;
	return 0;
}


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

using namespace std;

#define ll long long
#define ff first
#define ss second
#define e endl

void solve() {
    ll n; cin >> n;
    ll count = 0;
    for(ll i = 1;i < n;i++){
        count += n/i;
        if(n%i == 0) count--;
    }
    cout << count << e;
}

int main()
{
	//ll t; cin >> t; while (t--)
	solve();
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
typedef long long ll;
#define pb push_back
using namespace std;
typedef pair<ll, ll> pll;


ll pw[100005];
ll dp[100005][15];
ll n;
string s;
const ll mod = 1e9 + 7;
const ll b = 13;
ll solve(ll id, ll rm)
{
        if(id == n){
                return (rm == 5);
        }
        ll &ret = dp[id][rm];
        if(ret != -1) return ret;
        if(s[id] != '?') {
                ll d = s[id] - '0';
                d = (d*pw[id])%b;
                d = (rm + d)%b;
                ret = solve(id+1, d);
        }else {
                ret = 0;
                for(ll i=0;i<=9;i++){

                        ll d = (i * pw[id])%b;
                        d = (rm + d)%b;
                        ret = (ret + solve(id+1, d))%mod;
                }
        }
        return ret;
}
int main()
{
        cin >> s;
        memset(dp,-1,sizeof dp);
        n = s.length();
        reverse(s.begin(), s.end());
        pw[0] = 1LL;
        for(ll i=1;i<=n+2;i++) {
                pw[i] = (pw[i-1] * 10LL)%b;
        }
        cout << solve(0, 0) << endl;
        return 0;
}


Measured memory_bytes: 20736
N,M = map(int,input().split())
XYZ = [tuple(map(int,input().split())) for _ in range(N)]
ans = 0
for b in range(8):
	arr = []
	for x,y,z in XYZ:
		if b&1: x *= -1
		if b&2: y *= -1
		if b&4: z *= -1
		arr.append(x+y+z)
	arr.sort(reverse=True)
	ans = max(ans, sum(arr[:M]))
print(ans)

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

int a[555], b[555];
int main() {
	int n, k, s = 0, r = 0;
	cin >> n >> k;
	for (int i = 0; i < n; i++)
		cin >> a[i], s += a[i];
	for (int c = 1; c*c <= s; c++) {
		if (s%c) continue;
		for (int d : {c, s / c}) {
			int t = 0;
			for (int i = 0; i < n; i++)
				t += b[i] = a[i] % d;
			nth_element(b, b + n - t / d, b + n);
			partial_sum(b, b + n - t / d, b);
			if (b[n - t / d - 1] <= k)
				r = max(r, d);
		}
	}
	cout << r << endl;
	return 0;
}


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

int main() {
    vector<int> vec(10000);
    for(int i=0;i<10000;i++){
        cin>>vec.at(i);
        if(vec.at(i)!=0){
            cout<<"Case "<<i+1<<": "<<vec.at(i)<<endl;
        }
        if(vec.at(i)==0){
            break;
        }

    }
}



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

#define int long long
#define pii pair<int, int>
#define pb push_back

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    int a;
    cin >> a;
    cout << a + a * a + a * a * a << endl;

    return 0;
}



Measured memory_bytes: 3616
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <math.h>

using namespace std;

typedef long long ll;

int main() {
	int m, f, r;
	while (cin >> m >> f >> r, m != -1 || f != -1 || r != -1) {
		if (m == -1 || f == -1) cout << 'F' << endl;
		else if ((m + f) >= 80) cout << 'A' << endl;
		else if ((m + f) >= 65) cout << 'B' << endl;
		else if ((m + f) >= 50) cout << 'C' << endl;
		else if ((m + f) >= 30 && r >= 50) cout << 'C' << endl;
		else if ((m + f) >= 30) cout << 'D' << endl;
		else cout << 'F' << endl;
	}
}

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

int main(){
   
    int N;
    cin>>N;
    int cnt=0;
    for(int i=0;i<262144;i++){
        vector<int> S(9,-1);
        int k=i,T=0;
        bool flag3=false,flag5=false,flag7=false,flag=true;
        for(int j=0;j<9;j++){
            if(k==0) break;
            S[j]=(k%4)*2+1;
            k/=4;
        }
        int l=1;
        for(int j=0;j<9;j++){
            if(S[j]==3) flag3=true;
            if(S[j]==5) flag5=true;
            if(S[j]==7) flag7=true;
            if(S[j]==-1) break;
            if(S[j]==1) flag=false;
            T+=(l*S[j]);
            l*=10;
        }
        if(flag3&&flag5&&flag7&&flag&&T<=N){
            cnt++;
        }
        if(T>N) break;
    }
    cout<<cnt<<endl;


}


Measured memory_bytes: 256
n = int(input())
A = list(map(int, input().split()))
ans = 0
for i in range(n - 1):
    if i+1 == A[i]:
        t = A[i+1]
        A[i+1] = A[i]
        A[i] = t
        ans += 1

if A[-1] == n:
    ans += 1

print(ans)

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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define MOD 1000000007
#define cey ce("Yes")
#define cen ce("No")
#define ceY ce("YES")
#define ceN ce("NO")
int table[365][26];
int main()
{	
	int D;
	cin >> D;
	vec(C);
	vec(Las);
	fx(26) {
		vecp(C);
		Las.push_back(0);
	}

	fx(D) {
		fy(26) {
			cin >> table[x][y];
		}
	}
	vector<int> T(D);
	int k = 0;
	fx(26) {
		if (k < table[0][x]) {
			T[0] = x+1;
			k = table[0][x];
		}
	}
	fx(D-1) {
		ll res = -LLONG_MAX;
		int las = 0;
		fy(26) {
			ll sum = 0;
			sum += table[x + 1][y];
			fz(26){
				if (y == z) { continue; }
				sum -= C[z] * (x + 1 - Las[z]);
			}

			if (res<sum) {
				res = sum;
				T[x + 1] = y+1;
				las = y;
			}
		}
		Las[las] = x + 1;
	}

	ll sum = -INT_MAX,sumPre=-INT_MAX;
	srand(time(NULL));
	fx(15000) {
		int d, q;
		d = rand() % D + 1;
		q = rand() % 26 + 1;
		if (sum==sumPre) {
			int d2 = rand() % D + 1;
			while (d2==d) {
				d2 = rand() % D + 1;
			}
			T[d - 1] ^= T[d2 - 1];
			T[d2 - 1] ^= T[d - 1];
			T[d - 1] ^= T[d2 - 1];
			continue;
		}
		int pre = T[d - 1];

		T[d - 1] = q;
		ll ans = 0;

		fy(26) {
			Las[y] = 0;
		}
		fw(D) {

			ans += table[w][T[w] - 1];
			Las[T[w] - 1] = w + 1;
			fz(26) {
				ans -= C[z] * (w + 1 - Las[z]);
			}

		}
		if (ans > sum) {
			sum = ans;
		}
		else {
			T[d - 1] = pre;

		}
	}


	fx(D) {
		ce(T[x])
	}
    return 0;
}



Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
int main(){
    string a;
    cin>>a;
    int n=a.size(),i;
    if(a[n-1]=='s'){
        cout<<a<<"es"<<endl;
    }
    else{
        cout<<a<<"s"<<endl;
    }
    return 0;
}


Measured memory_bytes: 3628
#include<iostream>
using namespace std;
typedef long long ll;
int main(){
    int n,i,j,k;
    cin>>n;
    ll A,B,C=0;
    cin>>A>>B;
    for(i=3;i<=n;i++){
        ll tmp;
        cin>>tmp;
        C^=tmp;
    }
    ll D=A+B-C>>1;
    if(A+B-C&1||D<0||D>A||D&C){
        cout<<"-1\n";
        return 0;
    }
    ll a=D;
    for(i=60;i>=0;i--){
        if(C>>i&1&&D>>i&1^1&&(a|1ll<<i)<=A){
            a|=1ll<<i;
        }
    }
    if(a==0){
        cout<<"-1\n";
        return 0;
    }
    cout<<A-a<<endl;

    return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
 
#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define si set<int>
#define stk stack<int>
#define que queue<int>
#define pb push_back
#define ff first
#define ss second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
const ll mod=1e9+7;
 
using namespace std;

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

	vi a(3),dp(3);

	int ans=0;

	for(int i=0;i<n;i++){
		cin>>a[0]>>a[1]>>a[2];

		vi ndp(3,0);

		for(int k=0;k<3;k++){
			for(int j=0;j<3;j++){
				if(k!=j){
					ndp[j]=max(ndp[j],dp[k]+a[j]);
				}
			}
		}
		dp=ndp;
		for(int j=0;j<3;j++){
			ans=max(ans,dp[j]);
		}
	}

	cout<<ans<<endl;

}

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

using ll = long long;
using pll = pair<ll, ll>;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}
template<class F, class S> istream& operator >> (istream& s, pair<F, S>& p)
{ s >> p.first >> p.second; return s;}

int main()
{
    ll N, C; cin >> N >> C;
    vector<pll> XV(N); cin >> XV;
    sort(XV.begin(), XV.end());

    vector<ll> s(N), srev(N);
    s[0] = XV[0].second;
    for (int i = 1; i < N; i++) s[i] = s[i-1] + XV[i].second;
    srev[0] = XV[N-1].second;
    for (int i = 1; i < N; i++) srev[i] = srev[i-1] + XV[N-1-i].second;

    vector<pair<ll, int>> m(N), mrev(N);
    m[0] = make_pair(s[0]-XV[0].first, 0); mrev[0] = make_pair(srev[0]-(C-XV[N-1].first), 0);
    for (int i = 1; i < N; i++) {
        if (s[i] - XV[i].first > m[i-1].first)
            m[i] = make_pair(s[i] - XV[i].first, i);
        else
            m[i] = m[i-1];
        if (srev[i] - (C-XV[N-1-i].first) > mrev[i-1].first)
            mrev[i] = make_pair(srev[i] - (C-XV[N-1-i].first), i);
        else
            mrev[i] = mrev[i-1];
    }

    ll ans = 0;

    for (int i = 0; i <= N; i++) {
        ll a = 0;
        int l = i, r = N - i;
        ll lc = 0, rc = 0;
        if (l > 0) {
            a += m[l-1].first;
            lc = XV[m[l-1].second].first;
        }
        if (r > 0) {
            a += mrev[r-1].first;
            rc = C-XV[N-1-mrev[r-1].second].first;
        }
        a -= min(lc, rc);
        ans = max(ans, a);
    }

    cout << ans << endl;
}


Measured memory_bytes: 6528
#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <algorithm>
#include <sstream>
#include <string>
#include <map>
#include <set>
using namespace std;

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


int main() {
	int n, m;
	cin >> n >> m;
	vector<pair<int64_t, int64_t> > vec(n);
	rep(i, n) {
		int64_t a, b;
		cin >> a >> b;
		vec.at(i) = make_pair(a, b);
	}
	sort(vec.begin(), vec.end());
	int num = 0;
	int64_t res = 0;
	int a = 0;
	rep(i, n) {
		if (num < m) {
			num += vec.at(i).second;
			res += vec.at(i).first * vec.at(i).second;
			a++;
		}
		else break;
	}
	a--;
	while (num > m) {
		res -= vec.at(a).first;
		num--;
	}
	cout << res << endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string n;
    cin>>n;
    int h=0;
   for(int i=0;i<n.size();i++)
   {
       if(i>3)
       {
           cout<<n[i];
       }
       if(i<=3&&h==0)
       {
           cout<<"2018";
           h=1;
       }
   }

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 

using namespace std;
using namespace __gnu_pbds; 
  
#define ll long long
#define X first
#define Y second
#define all(x) x.begin(), x.end()
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
	enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
	ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
	*this << "[";
	for (auto it = d.b; it != d.e; ++it)
		*this << ", " + 2 * (it == d.b) << *it;
	ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

const int mod = (int)1e9 + 7;
const int MX = (int)1e5 + 10;

void add_self(int &x, int y){x += y; if(x >= mod) x -= mod;}
void sub_self(int &x, int y){x -= y; if(x < 0) x += mod;}
void mul(int &x, int y){x = x * 1LL * y % mod;}

int main(){

	cin.tie(0); cout.tie(0);
	ios_base::sync_with_stdio(0);

	int a, b, c, d;
	cin >> a >> b >> c >> d;

	int it = 0;
	while(a > 0 && c > 0){
		if(it & 1){
			a -= d;
		}
		else{
			c -= b;
		}
		it++;
	}

	if(a <= 0) cout << "No";
	else cout << "Yes";

	return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int> >;
#define rep(i, n)         for(int i = 0; i < (int)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(int i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(int i = m; i < (int)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define itn int
#define mp make_pair
#define sum accumulate
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
typedef long long ll;
const int INF = 2000000000;
const ll INF64 = 9223372036854775806ll;
const int mod = 1000000007ll;
const ll  MOD = 1000000007LL;
/*メモ 
*/
int main(){
    int n;
    std::cin >> n;
    VEC(ll,a,n);
    if(a[0]!=0ll){
        std::cout << -1<< std::endl;
        exit(0);
    }
    bool han=1;
    rep(i,n-1){
        if(a[i+1]-a[i]>1ll)han=0;
    }
    if(!han){
        std::cout << -1 << std::endl;
        exit(0);
    }
    ll ans=sum(all(a),0ll);
    rep(i,n-1){
        if(a[i]<a[i+1])ans-=(a[i+1]-1);
    }
    std::cout << ans << std::endl;
}

Measured memory_bytes: 1792
N=int(input())
A=[0]+list(map(int,input().split()))

dp=[[0]*(N+1) for i in range(3)]

dp[0][1]=-float("inf")
dp[2][1]=A[1]
dp[0][2]=0
dp[1][2]=max(A[1],A[2])
dp[2][2]=-float("inf")

for i in range(3,N+1):
    if i%2==1:
        for j in range(3):
            dp[j][i]=max(dp[j][i-2]+A[i],dp[j][i-1])
    else:
        for j in range(2):
            dp[j][i]=max(dp[j][i-2]+A[i],dp[j+1][i-1])
        dp[2][i]=dp[2][i-2]+A[i]

print(dp[1][N])

Measured memory_bytes: 108540
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define mod2 998244353 
#define PI 3.14159265
#define ll long long
#define ld long double
#define pi pair<ll,ll>
#define pb push_back
#define vi vector<ll>
#define sz size()
#define fi first
#define se second
#define lz length()
#define all(x) (x).begin(),(x).end()
#define scf(x) scanf("%lld",&x)
#define rep(i,n) for(ll i=0;i<n;i++)
const int INF = (int)1e9;
const ll IINF=1LL<<62;
const int maxn=10000005;
int divr[maxn];
/*ll modexpo(ll a,ll b)
{
     ll res=1LL;
     while(b>0)
     {
          if(b&1)res=(res*a)%mod;
          a=(a*a)%mod;
          b>>=1;
     }
     return res;
}*/
void divisor()
{for(int i=2;i<sqrt(maxn);i++)
     {
          if(!divr[i])
          {
               for(int j=i*i;j<maxn;j+=i)if(!divr[j])divr[j]=i;     
          }
     }
     for(int i=1;i<maxn;i++)if(!divr[i])divr[i]=i;
}
 
/*const int N=1000005;
ll n;
struct line {
    long long m, c;
    long long eval(long long x) { return m * x + c; }
    long double intersectX(line l) { return (long double) (c - l.c) / (l.m - m); }
};
vector<pair<pi,ll>> rect;
deque<line> dq;
*/
 
 
 
 
 














int main()
{
    ll n,k;
    cin>>n>>k;
    ll x=n/k;
    ll fi=n-1LL*x*k;
    ll f2=abs(fi-k);
    cout<<min(f2,fi);
}
























 
 
 
 
 

















Measured memory_bytes: 3616
#include<iostream>
#include<cmath>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
ll a[200010], b[200010];
int main()
{
    ios::sync_with_stdio(false);
    ll n,ans=0;
    cin >> n;
    b[0] = 0x3fffffff;
    for (ll i = 1; i <= n; i++) cin >> a[i];
    for (ll i = 1; i <= n; i++)
    {
        b[i] = min(a[i], b[i - 1]);
        if (a[i] == b[i]) ans++;
    }
    cout << ans;
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
#define ll long long 
#define MM(arr,x) memset(arr,x,sizeof(arr))
#define INF 0x3f3f3f3f
#define Maxn 1e5+10;
using namespace std;
int a[200050],n,k;
bool check(int mid)
{
	int ans=0;
	for(int i=1;i<=n;i++)
	{
		if(a[i]>mid) ans+=a[i]/mid;
		if(ans>k) return 0;
	}
	return 1;
}
int main()
{
	ios::sync_with_stdio(0);
	cin>>n>>k;
	int l=1,r=-1;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		r=max(a[i],r);
	}
	int ans=0;
	while(l<=r)
	{
		int mid=(l+r)>>1;
		if(check(mid))
		{
			r=mid-1;
			ans=mid;
		}
		else l=mid+1;
	}
	cout<<ans;
	return 0;
} 

Measured memory_bytes: 4388
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<stdio.h>
#include<queue>
#include <climits>
#include <map>
#include <set>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int mod = 1e9 + 7;
const long long INF = 1LL << 60;

int main() 
{
    int a,b,c;
    cin >> a >> b >> c;
    cout << min(a*b,c) << endl;
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/dp/tasks/dp_b

#include <bits/stdc++.h>

using namespace std;

#define ll long long 
#define REPL(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define radrad(a)  180.0 * a / M_PI
#define pow(x) x*x
static const int MAX = 1000010;
static const ll INFTY = 1e12;
static const ll NUMMAX = 1000000007;
static const ll MOD = 1000000007;
#define LOOP 10000000
// 四方向への移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

// 入力
int H, W;
vector<string> field;
int result = 100;
int dfs_res = 0;

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }


 
int main() {
 
    int N;
    cin >> N;
    vector<vector<ll>> a;
    a = vector<vector<ll>>(100010, vector<ll>(3, 0));
    vector<vector<ll>> dp;
    dp = vector<vector<ll>>(100010, vector<ll>(3, 0));
    REP(i, N){
        cin >> a[i][0] >> a[i][1] >> a[i][2];
    }

    
    // ループ
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < 3; ++j) {
            for (int k = 0; k < 3; ++k) {
                if (j == k) continue;
                chmax(dp[i + 1][k], dp[i][j] + a[i][k]);
            }
        }
    }

    // 答え
    long long res = 0;
    for (int j = 0; j < 3; ++j) chmax(res, dp[N][j]);
    cout << res << endl;




 
    return 0;
}
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         pass System Test!
*/




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

using namespace std;

#define PB	push_back
#define ALL(x)	(x).begin(), (x).end()
#define ALLR(x)	(x).rbegin(), (x).rend()
#define MP	make_pair

#define debug(args...) { string _s = #args; replace(ALL(_s), ',', ' '); stringstream ss(_s); cerr << endl;_debug(ss, args); }
#define _rg auto it = next(v.begin()); it != v.end(); it++
#define _input ostream& operator <<(ostream& out

template<typename T, typename U>
_input, const pair<T, U>& p) {
	out << "(" << p.first << ", " << p.second << ")";
	return out;
}

#define cont(c) template<typename T> _input, const c<T>& v) { \
					if (v.empty()) return out; \
					out << "[" << *v.begin(); \
					for (_rg) out << ", " << *it; \
					out << "]"; return out; \
				}
				
#define cont2(c) template<typename T, typename U> _input, const c<T, U>& v) { \
					if (v.empty()) return out; \
					out << "[" << *v.begin(); \
					for (_rg) out << ", " << *it; \
					out << "]"; return out; \
				}

cont(vector) cont(set) cont(multiset) cont(queue) cont2(map)

template<typename T, size_t n, typename= enable_if_t<!is_same<T, char>::value>>
_input, const T(&v)[n]) {
	if (n == 0) return out;
	out << "[" << v[0];
	for (int i = 1; i < (int)n; i++) out << ", " << v[i];
	out  << "]"; return out;
}

template<typename T, typename... Ts>
void _debug(stringstream& ss, const T &arg) {
	string name; ss >> name;
	cerr << name << " = " << arg << endl;
}

template<typename T, typename... Ts>
void _debug(stringstream& ss, const T& arg, const Ts&... args) {
	string name; ss >> name; 
	cerr << name << " = " << arg << ", ";
	if (is_class<T>::value || is_array<T>::value) cerr << endl;
	_debug(ss, args...);
}

#define FAST_IO ios::sync_with_stdio(false); cin.tie(0)

#define int long long int

typedef pair<int, int> ii;
typedef pair<pair<int, int>, int> iii;
typedef vector<int> vi;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef unsigned long long ull;

const int INF = LONG_LONG_MAX>>1;
const int NINF = LONG_LONG_MIN/2;
const double PI = 3.141592653589793238;

int32_t main() {
	FAST_IO;
	
	string t;
	cin >> t;
	
	int n = (int)t.size();
	for (int i = 0; i < n; i++) {
		if (t[i] == '?') t[i] = 'D';
	}
	
	cout << t << endl;
}
// g++ -Wall -Wextra -Wshadow -fsanitize=undefined -std=c++17


Measured memory_bytes: 3768
package main

import (
	"fmt"
	//"math"
	// "sort"
	//"regexp"
)

var n int
var a, b, ans string

func main() {
	fmt.Scan(&n)
	fmt.Scan(&a)
	fmt.Scan(&b)
	for i := 0; i < n; i++ {
		ans = ans + a[i:i+1]
		ans = ans + b[i:i+1]
	}
	fmt.Println(ans)
}


Measured memory_bytes: 1800
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};
#[allow(unused_imports)]
use std::io::{stdout, stdin, BufWriter, Write};

fn main() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }

    input!{
      n: usize,
    }

    puts!("{}\n", n*n*n);
}


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

#define ff first
#define ss second
#define mp make_pair
#define MOD 1000000007
#define oo 1000000000000000000

using namespace std;

int n, k, v[100];

int main(){

    scanf("%d %d", &n, &k);

    for(int i = 0; i < n; i++)
        scanf("%d", v+i);

    int sum = 0;
    sort(v, v+n); reverse(v, v+n);

    for(int i = 0; i < k; i++)
        sum += v[i];

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




    return 0;
}


Measured memory_bytes: 256
H,W,K=map(int,input().split())
import copy
sq=[list(input()) for i in range(H)]
temp=copy.deepcopy(sq)
ans=0
lh=[j for j in range(H)]
lw=[k for k in range(W)]

import itertools
conH=[]
for m in range(1,H+1):
    for conb in itertools.combinations(lh,m):
        conH.append(list(conb))
conW=[]
for n in range(1,W+1):
    for conb2 in itertools.combinations(lw,n):
        conW.append(list(conb2))
conH.append([])
conW.append([])

for o in range(len(conH)):
    for p in range(len(conW)):
        c=0
        sq=copy.deepcopy(temp)
        for q in conH[o]:
            for r in range(W):
                sq[q][r]="!"
        for s in range(H):
            for t in conW[p]:
                sq[s][t]="!"
        for u in range(len(sq)):
            c+=sq[u].count("#")
        if c==K:
            ans+=1

print(ans)


Measured memory_bytes: 9288
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD=1e9+7;
ll powmod(ll a, ll k){
    ll ap=a, ans=1;
    while(k){
        if(k&1){
            ans*=ap;
            ans%=MOD;
        }
        ap=ap*ap;
        ap%=MOD;
        k>>=1;
    }
    return ans;
}
ll inv(ll a){
    return powmod(a, MOD-2);
}
int main()
{
    int n, a, b;
	cin>>n>>a>>b;
	ll ans=powmod(2, n)-1;
	ll c=1;
	for(int i=0; i<a; i++){
		(c*=(n-i))%=MOD;
		(c*=inv(i+1))%=MOD;
	}
	ans+=MOD-c;
	c=1;
	for(int i=0; i<b; i++){
		(c*=(n-i))%=MOD;
		(c*=inv(i+1))%=MOD;
	}
	ans+=MOD-c;
	ans%=MOD;
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define all(a) a.begin(),a.end()
#define sz(a) a.size()
#define re return 
#define MP make_pair
#define pb push_back
#define pii pair<int,int>
#define se second
#define fi first
using namespace std;
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};
char c[55][55];
int n,m;
signed main(){
	ios_base::sync_with_stdio(0);
	cin>>n>>m;
	for(int i=0;i<n;i++) for(int j=0;j<m;j++) cin>>c[i][j];
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			if(c[i][j]=='.') continue;
			bool check=0;
			for(int k=0;k<4;k++){
				int nx=i+dx[k],ny=j+dy[k];
				if(0<=nx&&nx<n&&0<=ny&&ny<m){
					if(c[nx][ny]=='#') check=1;
				}
			}
			if(!check){
				cout<<"No";
				re 0;
			}
		}
	} 
	cout<<"Yes";
	re 0;
}

Measured memory_bytes: 3588
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		double y = sc.nextDouble();

		for(int i=0; i<=n; i++) {
			for(int j=0; j<=n-i; j++) {
				int k=n-(i+j);
					if(10000*i+5000*j+1000*k==y && i+j+k==n) {
						System.out.println(i +" "+ j+" "+ k);
						return;
					}
			}
		}
		System.out.println("-1 -1 -1");
	}
}

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

int main() {
    int n; cin >>n;
    string s; cin >>s;
    int ret = 0;
    for (int i = 1; i < n; i++) {
        string sl = s.substr(0,i);
        string sr = s.substr(i,s.size()-i);
        int tmp = 0;
        vector<char> str;
        for (int j = 0; j < sl.size(); j++) {
            if (find(str.begin(), str.end(), sl[j])==str.end()) {
                str.push_back(sl[j]);
                if (find(sr.begin(), sr.end(), s[j])!=sr.end()) tmp++;
            }
        }
        ret = max(ret, tmp);
    }
    cout << ret << endl;
    return 0;
}

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

using namespace std;

vector<string> split(const string &s, char delim) {
  vector<string> elems;
  string item;
  for (char ch: s) {
    if (ch == delim) {
      if (!item.empty()) {
        elems.push_back(item);
      }
      item.clear();
    }
    else {
      item += ch;
    }
  }
  if (!item.empty()) {
    elems.push_back(item);
  }
  return elems;
}

string to_str_with_zero(int i, int w) {
  ostringstream sout;
  sout << std::setfill('0') << std::setw(w) << i;
  string s = sout.str();
  return s;
}

int letter_to_int(char c) {
  return tolower(c) - 'a';
}

int compare_array(vector<int> a1, vector<int>a2) {
  if (a1.size() != a2.size()) {
    return a1.size() - a2.size();
  }
  for (int i=0; i<a1.size(); i++) {
    if (a1.at(i) != a2.at(i)) {
      return a1.at(i) - a2.at(i);
    }
  }
  return 0;
}

int gcd(int a, int b) {
  if (a == b) {
    return a;
  }
  else if (a > b) {
    return gcd(a - b, b);
  }
  else {
    return gcd(a, b - a);
  }
}

char int_to_char(int a) {
  if (a == -1) {
    return 'z';
  }
  else {
    return 'a' + a;
  }
}

long nCr(int n, int r) {
    long ans = 1;
    for (int i = n; i > n - r; --i) {
        ans = ans*i;
    }
    for (int i = 1 ; i < r + 1; ++i) {
        ans = ans / i;
    }
    return ans;
}

long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
}

int divide_count(int a, int divider) {
  int r = 0;
  while(a % divider == 0) {
    a /= divider;
    r++;
  }
  return r;
}

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

int main() {
  std::cout << std::setprecision(9);
  long n;
  cin >> n;

  long ans = n * (n + 1) * (n + 2) / 6;
  for(int i=0; i<n - 1; i++) {
    long u, v;
    cin >> u >> v;
    ans -= (n + 1 - max(u, v)) * min(u, v);
  }
  cout << ans << endl;
}

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

int main() {
  for(int n, l; cin >> n >> l && (n|l); ) {
    vector<int> p(n), v(n), f(n);
    for(int i = 0; i < n; ++i) {
      char d;
      cin >> d >> p[i];
      v[i] = (d == 'L') ? -1 : 1;
    }
    int a, b;
    for(int t = 1, k = 0; k < n; ++t) {
      for(int i = 0; i < n; ++i) {
        if(f[i]) continue;
        p[i] += v[i];
      }
      for(int i = 0; i < n; ++i) {
        if(f[i]) continue;
        for(int j = i+1; j < n; ++j) {
          if(f[j]) continue;
          if(p[i] == p[j]) {
            v[i] *= -1; v[j] *= -1;
          }
        }
      }
      for(int i = 0; i < n; ++i) {
        if(!f[i] && p[i] == l) {
          f[i] = true;
          ++k;
          a = t; b = i+1;
        }
      }
      for(int i = 0; i < n; ++i) {
        if(!f[i] && p[i] == 0) {
          f[i] = true;
          ++k;
          a = t; b = i+1;
        }
      }
    }
    cout << a << " " << b << endl;
  }
  return 0;
}

Measured memory_bytes: 1196
#include <cstdio>
#include <cstdlib>

int main() {
  int N;
  scanf("%d", &N);

  int x = 0;
  int y = 0;
  int t = 0;
  for (int i = 0; i < N; ++i) {
    int ti, xi, yi;
    scanf("%d %d %d", &ti, &xi, &yi);
    int dx = abs(x-xi);
    int dy = abs(y-yi);
    int dt = abs(t-ti);
    if (dx+dy > dt) return puts("No"), 0;
    if ((dx+dy) % 2 != dt % 2) return puts("No"), 0;
    x = xi;
    y = yi;
    t = ti;
  }
  puts("Yes");
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <cmath>   
#include<cctype>
#include<string>
#include<set>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include <deque>
#include <typeinfo>
#include <utility> 
#define all(x) (x).begin(),(x).end()
#define rep(i,m,n) for(int i = m;i < n;++i)
using namespace std;
using ll = long long;
using R = double;
const ll inf = 1LL << 50;
const ll MOD = 1e9 + 7;

ll f(ll b,ll n) {
	if (n < b)return n;
	return f(b, n / b) + (n % b);
}


vector<ll>dev;

void devisor(ll n) {
	for (ll i = 1; i*i <= n; i++) {
		if (n%i == 0) {
			if (i == n / i) {
				dev.push_back(i);
			}
			else {
				dev.push_back(i);
				dev.push_back(n / i);
			}
		}
	}
}



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

	if (n < s) {
		cout << "-1" << endl;
		exit(0);
	}
	else if (n == s) {
		cout << n + 1 << endl;
		exit(0);
 	}

	ll b = 2;
	while (b*b <= n) {
		if (f(b, n) == s) {
			cout << b << endl;
			exit(0);
		}
		b++;
	}



	devisor(n - s);
	sort(dev.begin(), dev.end());
	reverse(dev.begin(), dev.end());
	for (auto x : dev) {
		b = (n - s) / x + 1;
		if (f(b, n) == s) {
			cout << b << endl;
			exit(0);
		}
	}

	cout << "-1" << endl;


}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int) n; i++)
using ll = long long;
template <class T>
using vt = std::vector<T>;
using vvi = std::vector<vt<int>>;

int main(){
  int n;
  std::cin >> n;
  std::set<std::string> s;
  rep(i,n){
    std::string S;
    std::cin >>  S;
    s.insert(S);
  }

  int ans = s.size();
  std::cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 19180
#!/usr/bin/env ruby

N = gets.chomp.to_i

A = gets.chomp.split.map(&:to_i)

xor = nil

A.each do |a|
  xor = xor ? xor ^ a : a
end

result = []

A.each do |a|
  result << (xor ^ a)
end

puts result.join(' ')


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

void print_str(int a, int b, const string& str)
{
	for (int i = a; i <= b; i++) cout << str[i];
	cout << endl;
}

void reverse_str(int a, int b, string& str)
{
	string s = str.substr(a, b - a + 1);
	reverse(s.begin(), s.end());
	str.replace(a, b - a + 1, s);
}

int main()
{
	string str;
	int n;
	cin >> str >> n;
	for (int i = 0; i < n; i++) {
		string cmd;
		int a, b;
		cin >> cmd >> a >> b;
		if (cmd == "print") print_str(a, b, str);
		else if (cmd == "reverse") reverse_str(a, b, str);
		else {
			string s;
			cin >> s;
			str.replace(a, b - a + 1, s);
		}
	}
}


Measured memory_bytes: 3236
code = """

# distutils: language=c++
# distutils: include_dirs=[/home/USERNAME/.local/lib/python3.8/site-packages/numpy/core/include, /opt/atcoder-stl]
# cython: boundscheck=False
# cython: wraparound=False

from libcpp.vector cimport vector
from libcpp cimport bool
from libc.stdio cimport getchar, printf
from libcpp.string cimport string
cpdef inline vector[int] ReadInt(int n):
    cdef int b, c
    cdef vector[int] *v = new vector[int]()
    for i in range(n):
        c = 0
        while 1:
            b = getchar() - 48
            if b < 0: break
            c = c * 10 + b
        v.push_back(c)
    return v[0]

cpdef inline vector[string] Read(int n):
    cdef char c
    cdef vector[string] *vs = new vector[string]()
    cdef string *s
    for i in range(n):
        s = new string()
        while 1:
            c = getchar()
            if c<=32: break
            s.push_back(c)
        vs.push_back(s[0])
    return vs[0]

cpdef inline void PrintLongN(vector[long] l, int n):
    for i in range(n): printf("%ld\\n", l[i])

cpdef inline void PrintLong(vector[long] l, int n):
    for i in range(n): printf("%ld ", l[i])
cdef extern from "<atcoder/twosat>" namespace "atcoder":
    cdef cppclass two_sat:
        two_sat(int n)
        void add_clause(int i, bool f, int j, bool g)
        bool satisfiable()
        vector[bool] answer()

cdef class TwoSat:
    cdef two_sat *_thisptr
    def __cinit__(self, int n):
        self._thisptr = new two_sat(n)
    cpdef void add_clause(self, int i, bool f, int j, bool g):
        self._thisptr.add_clause(i, f, j, g)
    cpdef bool satisfiable(self):
        return self._thisptr.satisfiable()
    cpdef vector[bool] answer(self):
        return self._thisptr.answer()
"""


import os, sys, getpass

if sys.argv[-1] == 'ONLINE_JUDGE':
    code = code.replace("USERNAME", getpass.getuser())
    open('atcoder.pyx','w').write(code)
    os.system('cythonize -i -3 -b atcoder.pyx')
    sys.exit(0)


from atcoder import ReadInt, TwoSat

def main():
  N,D=ReadInt(2)
  xy = [ReadInt(2) for _ in range(N)]
  ts=TwoSat(N)
  for i in range(N-1):
    for j in range(i+1,N):
      for k1,k2 in [(0,0),(0,1),(1,0),(1,1)]:
        pos1,pos2 = xy[i][k1],xy[j][k2]
        if abs(pos2-pos1)<D:
          ts.add_clause(i,k1^1,j,k2^1)

  if ts.satisfiable():
    print('Yes')
    ans = ts.answer()
    print(*[xy[i][ans[i]] for i in range(N)],sep="\n")
  else:
    print('No')

if __name__=="__main__":
  main()

Measured memory_bytes: 11068
n = int(input())
T_p, H_p = 0, 0
for i in range(n):
    T, H = input().split()
    if T > H:
        T_p += 3
    elif T < H:
        H_p += 3
    else:
        T_p += 1; H_p += 1
print(T_p, H_p)



Measured memory_bytes: 5600
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define reps(i,a,b) for(int i=a;i<b;++i)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<typename T> inline bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T &a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U &u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U &u,const V... v){for(auto &e:u)fill_v<T>(e,v...);}

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

    int n, t;
    cin >> n >> t;
    vector<int> a(t+1);
    rep(i, n) {
        int l, r;
        cin >> l >> r;
        a[l]++; a[r]--;
    }
    rep(i, t) a[i+1] += a[i];
    cout << *max_element(all(a)) << endl;
}



Measured memory_bytes: 3360
#ABC166-B

N, K = map(int, input().split())
d = []
a = []

for i in range(K):
    d.append(int(input()))
    a.append(list(map(int,input().split())))

child = list(range(N))
x = [0]*N

for j in child:
    for c in range(K):
        if j+1 in a[c]:
            x[j] += 1

count = 0

for h in child:
    if x[h] == 0:
        count += 1

print(count)


Measured memory_bytes: 9236
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.root = [-1] * (n+1)
        self.rnk = [0] * (n+1)
        
    def Find_Root(self, x):
        if(self.root[x] < 0):
            return x
        else:
            self.root[x] = self.Find_Root(self.root[x])
            return self.root[x]
    
    def Unite(self, x, y):
        x = self.Find_Root(x)
        y = self.Find_Root(y)
        if (x == y):
            return
        elif(self.rnk[x] > self.rnk[y]):
            self.root[x] += self.root[y]
            self.root[y] = x
        else:
            self.root[y] += self.root[x]
            self.root[x] = y
            if(self.rnk[x] == self.rnk[y]):
                self.rnk[y] += 1
                
    def isSameGroup(self,x,y):
        return self.Find_Root(x) == self.Find_Root(y)
    
    def Count(self, x):
        return -self.root[self.Find_Root(x)]

N,M = map(int,input().split())
t = UnionFind(N)
ab = []
for i in range(M):
    a,b = map(int,input().split())
    ab.append((a,b))
ans = []
tmp = N*(N-1)//2
while ab:
    ans.append(tmp)
    a,b = ab.pop()
    if not t.isSameGroup(a,b):
        tmp -= t.Count(a)*t.Count(b)
        t.Unite(a,b)
while ans:
    print(ans.pop())

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

using namespace std;


#define ss second
#define ff first
#define int long long
//#define double long double
#define pb push_back

const int N = 1e6 + 1, MOD = 1e9 + 7, mod = 998244353, INF = 3e18;

mt19937 Flash_new_51(51515);

using vi = vector <int>;
using vp = vector <pair <int, int>>;


bool used[N];

signed main() {
   cin.tie(0);
   ios_base::sync_with_stdio(0);
   int A, B, C, K;
   cin >> A >> B >> C >> K;
   if (abs(A - B) > 1e18) {
      cout << "Unfair";
      return 0; 
   }
   A-= B;
   if (K % 2 == 1) A*= -1;
   cout << A;

}

Measured memory_bytes: 256