akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define REP(i, a, b) for (int i = a; i < b; i++)
typedef long long ll;
using namespace std;

int main(){
  string s;
  cin >> s;
  string ans = "No";
  if(s[2] == s[3] && s[4] == s[5]) ans = "Yes";
  cout << ans << endl; 
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int k[10000000];

int main()
{
    while (true)
    {
        int N;
        cin>>N;
        if (N==0)
            break;
        for (int i=0; i<N; i++)
            cin>>k[i];

        bool ok = false;
        int ans = 1;
        for (int i=0; i<N; i++)
        {
            if (k[i]>=1)
                ans++;
            if (k[i]>=2)
                ok = true;
        }
        if (ok)
            cout<<ans<<endl;
        else
            cout<<"NA"<<endl;
    }
}

Measured memory_bytes: 1200
#include <bits/stdc++.h>
using namespace std;
int main() {
    long long INF = 1LL << 60;
    int L;
    cin >> L;
    long long a;
    vector<vector<long long>> c(5,vector<long long>(L+2));
    vector<vector<long long>> dp(5,vector<long long>(L+2, INF));
    for(int i=1; i<=L; i++) {
        cin >> a;
        c[0][i] = c[4][i] = a;
        c[1][i] = c[3][i] = a==0 ? 2 : a%2;
        c[2][i] = (a+1)%2;
    }
    dp[0][0] = 0;
    for (int k=0; k<5; k++) {
        for (int i=1;i<=L+1;i++) {
            for (int j=0; j<=k; j++) {
                dp[k][i] = min(dp[k][i], dp[k-j][i-1] + c[k][i]);
            }
        }
    }
    cout << dp[4][L+1] << '\n';
    return 0;
}

Measured memory_bytes: 17380
#include<iostream>
#include<algorithm>
#include<memory.h>
using namespace std;
int main()
{
	int n, m, t[1001], c[201],c2[201],v[201],dp[1001][201];
	cin >> n >> m;
	for (int i = 1; i <= n; i++)cin >> t[i];
	for (int i = 1; i <= m; i++){
		cin >> c[i] >> c2[i] >> v[i];
	}
	memset(dp, -1, sizeof(dp));

	for (int i = 1; i <= m; i++){
		if (t[1] >= c[i] && t[1]<=c2[i])
			dp[1][i] = 0;
	}

	for (int i = 1; i <= n; i++){
		for (int i2 = 1; i2 <= m; i2++){
			if (dp[i][i2] >= 0){
				for (int i3 = 1; i3 <= m; i3++){
					if (t[i + 1] >= c[i3] && t[i + 1] <= c2[i3]){
						dp[i + 1][i3] = max(dp[i][i2] + abs(v[i2] - v[i3]), dp[i+1][i3]);
					}
				}
			}
		}
	}
		int maxv=0;
		for (int i = 1; i <= m; i++){
			maxv = max(maxv, dp[n][i]);
		}
		cout << maxv << endl;
}

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

#define MOD 1000000007
#define MAX_N 100000
#define MAX_P 1000005
Int fact[MAX_P],inv[MAX_P],finv[MAX_P];

void init(Int mod){
  fact[0]=1;
  for(Int i=1;i<MAX_P;i++)
    fact[i]=(fact[i-1]*i)%mod;

  inv[1]=1;
  for(Int i=2;i<MAX_P;i++)
    inv[i]=inv[mod%i]*(mod-mod/i)%mod;
  
  finv[0]=1;
  for(Int i=1;i<MAX_P;i++)
    finv[i]=(finv[i-1]*inv[i])%mod;
}


Int mod_pow(Int x,Int n,Int mod){
  Int res=1;
  while(n){
    if(n&1) (res*=x)%=mod;
    (x*=x)%=mod;
    n>>=1;
  }
  return res;
}

Int mod_inv(Int a,Int mod=MOD){
  return mod_pow(a,mod-2,mod);
}

Int mod_comb(Int x,Int y){
  if(y<0) return 0;
  return fact[x]*mod_inv(fact[y])%MOD*mod_inv(fact[x-y])%MOD;
}

//INSERT ABOVE HERE
signed main(){
  init(MOD);
  Int n,m,k;
  cin>>n>>m>>k;
  Int s=n+m+k*2;
  vector<Int> dpx(s+1,0),dpy(s+1,0);
  
  for(Int i=n;i<=s;i+=2)
    dpx[i]=(mod_comb(i,(i+n)/2)+MOD-mod_comb(i,(i-n)/2-1))%MOD;
  
  for(Int i=m;i<=s;i+=2)
    dpy[i]=(mod_comb(i,(i+m)/2)+MOD-mod_comb(i,(i-m)/2-1))%MOD;

  Int ans=0;
  for(Int i=0;i<=s;i++)
    (ans+=dpx[i]*dpy[s-i]%MOD*mod_comb(s,i)%MOD)%=MOD;
  
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 29624
n = int(input())
d = {}
for a in [int(x) for x in input().split()]:
    if a in d:
        d[a] += 1
    else:
        d[a] = 1
ans = "No"
key = list(d.keys())
l_key = len(key)
if l_key == 1:
    if 0 in d:
        ans = "Yes"
elif l_key == 2:
    if 0 in d:
        if d[0] * 3 == n:
            ans = "Yes"
elif l_key == 3:
    flag = 0
    for v in d.values():
        if v * 3 == n:
            flag += 1

    if key[0] ^ key[1] ^ key[2] == 0 and flag == 3:
        ans = "Yes"

print(ans)


Measured memory_bytes: 14212
#include<stdio.h>

int main(void)
{
	int i, N,ans,now;
	char S[101];

	scanf("%d%s", &N, S);

	ans = 0;
	now = 0;

	for (i = 0; i < N; i++)
	{
		if (S[i] == 'I')
			now++;
		else
			now--;

		if (ans < now)
			ans = now;
	}

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

	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	vector<int> A(n);
	for(int i=0;i<n;i++)
		cin>>A[i];
	vector<long long> sum_front(n+1,0),sum_back(n+1,0);
	for(int i=0;i<n;i++)
		sum_front[i+1]=sum_front[i]+A[i];
	for(int i=n-1;i>=0;i--)
		sum_back[i]=sum_back[i+1]+A[i];
	vector<long long> less2(n+1),less2i(n+1);
	int a=0;
	for(int i=0;i<=n;i++)
	{
		while(a<i&&2*sum_front[a+1]<=sum_front[i])
			a++;
		less2[i]=sum_front[a];
		if(a<i)
			less2[i]=max(less2[i],sum_front[i]-sum_front[a+1]);
	}
	a=n;
	for(int i=n;i>=0;i--)
	{
		while(a>i&&2*sum_back[a-1]<=sum_back[i])
			a--;
		less2i[i]=sum_back[a];
		if(a>i)
			less2i[i]=max(less2i[i],sum_back[i]-sum_back[a-1]);
	}
	long long ans=-1;
	for(int i=0;i<n;i++)
	{
		long long v[4]={0};
		v[0]=less2[i],v[1]=sum_front[i]-less2[i];
		v[2]=less2i[i],v[3]=sum_back[i]-less2i[i];
		long long mx=v[0],mn=v[0];
		for(int j=1;j<=3;j++)
			mx=max(mx,v[j]);
		for(int j=1;j<=3;j++)
			mn=min(mn,v[j]);
		if(ans==-1||ans>mx-mn)
			ans=mx-mn;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 7296
#include "bits/stdc++.h"
using namespace std;
using ll=long long;
#define rep(i,a,n) for(ll i=a;i<n;i++)
#define ALL(s) s.begin(),s.end()
#define P pair<ll,ll>
#define vl vector<ll>
#define vi vector<int>
#define vvl vector<vector<ll>>
#define vvi vector<vector<int>>
#define print(n) cout<<n<<endl
const int M=100111;
const int inf=1000000007;
const long long INF=1000000000000000007;
int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};
int ddx[8]={1,-1,0,0,1,-1,-1,1},ddy[8]={0,0,1,-1,1,-1,1,-1};


int main(){
	int n,a,b,c,q,k,x,y;
	vector<P> g[M];
	ll dist[M];
	cin>>n;
	rep(i,0,n-1){
		cin>>a>>b>>c;
		g[a].push_back(P(c,b));
		g[b].push_back(P(c,a));
	}
	cin>>q>>k;
	rep(i,0,M)dist[i]=INF;
	dist[k]=0;
	priority_queue<P,vector<P>,greater<P>> que;
	que.push(P(0,k));
	while(que.size()){
		P p=que.top();que.pop();
		ll cost=p.first,now=p.second;
		if(dist[now]<cost)continue;
		for(auto e:g[now]){
			ll cost=e.first,next=e.second;
//			print("now="<<now<<" "<<"next="<<next);
//			print("dist[next]="<<dist[next]<<" dist[now]="<<dist[now]<<" cost="<<cost);
			if(dist[next]>dist[now]+cost){
				dist[next]=dist[now]+cost;
				que.push(P(dist[next],next));
			}
//			print(dist[next]);
		}
	}
	rep(i,0,q){
		cin>>x>>y;
		print(dist[x]+dist[y]);
	}
}

Measured memory_bytes: 11120
#include <bits/stdc++.h>
#define ll long long
#define PB push_back
#define MP make_pair

#define REP(i, n) for(int i=0;i<(int)(n);++i)
#define FOR(i,l,h) for(int i=(int)(l);i<=(int)(h);++i)
#define FORD(i,h,l) for(int i=(int)(h);i>=(int)(l);--i)

#define max(a,b) a>b?a:b
#define min(a,b) a>b?b:a

ll gcd(ll a, ll b) { return !b ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }

#define dump(x)  cerr << #x << " = " << (x) << endl
#define ALL(t) (t).begin(),(t).end()

using namespace std;

const ll int nax = 1e18;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int a,k;
    for (int i = 0; i < 5; ++i)
    {
        cin>>a;
        if(a==0)k = i+1;
    }
    cout<<k;
    return 0;
}


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

int main(){
  int n;
  cin >> n;
  int a = n/10;
  int b = n%1000;
  if(a%111==0 or b%111==0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))

res = 0
for i in range(N):
    ind = A[i]-1
    res += B[ind]
    if i > 0:
        prevind = A[i-1]-1
        if prevind + 1 == ind:
            res += C[prevind] 
print(res)

Measured memory_bytes: 3064
#include <iostream>
#include <cstring>
#include <vector>

using namespace std;

const int MAX_N = 105, MAX_K = 1e5 + 5, MOD = 1e9 + 7;
long long no_of_ways[MAX_N][MAX_K], sum_no_of_ways[MAX_N][MAX_K];

int main()
{
    int no_of_people, no_of_candies;
    cin >> no_of_people >> no_of_candies;

    vector <int> limit(no_of_people + 1);
    for(int i = 1; i <= no_of_people; i++)
        cin >> limit[i];

    //f(i, j) = f(i - 1, j) + f(i - 1, j - 1) + f(i - 1, j - 2) + f(i - 1, j - 3) + ... + f(i - 1, j - a_i);

    no_of_ways[0][0] = 1;
    for(int i = 1; i <= no_of_candies; i++)
        no_of_ways[0][i] = 0;

    for(int i = 1; i <= no_of_people; i++)
    {
        sum_no_of_ways[i - 1][0] = no_of_ways[i - 1][0];
        for(int j = 1; j <= no_of_candies; j++)
        {
            sum_no_of_ways[i - 1][j] = (sum_no_of_ways[i - 1][j - 1] + no_of_ways[i - 1][j])%MOD;
        }

        for(int j = 0; j <= no_of_candies; j++)
        {
            int left = j, right = (j - limit[i] - 1);

            no_of_ways[i][j] = sum_no_of_ways[i - 1][left];

            if(right >= 0)
            {
                no_of_ways[i][j] = (no_of_ways[i][j] - sum_no_of_ways[i - 1][right] + MOD)%MOD;
            }
        }
    }

    cout << no_of_ways[no_of_people][no_of_candies];
    return 0;
}

Measured memory_bytes: 160000
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <map>
#include <set>
#include <vector>
#include <list>
#include <queue>
#include <sstream>
#include <cmath>
#include <functional>
#include <climits>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define reps(s,i,n) for(int i=s;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define skip(i,n,p) for(int i=0;i<n;i+=p)
#define all(a)  (a).begin(),(a).end()
#define int64 long long
#define debug cerr << __FILE__ << ":" << __LINE__ << endl;
#define INF 2147483647

struct Init {
    Init() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout.precision(20);
        cout << fixed;
        // setw(6) << setfill('0')
    }
} init;

template <typename _Ty>
ostream& operator << (ostream& ostr, const vector<_Ty>& v) {
    for(int i = 0; i < (int) v.size(); i++) {
        ostr << v[i] << (i + 1 != v.size() ? " " : "");
    }
    return ostr;
}

template <typename _K, typename _V>
ostream& operator << (ostream& ostr, const map<_K, _V>& v) {
    ostr << "{";
    for (auto iter = v.begin(); iter != v.end(); ++iter) {
        ostr << (*iter).first << ": " << (*iter).second << ", ";
    }
    ostr << "}";
    return ostr;
}

template <typename _K>
ostream& operator << (ostream& ostr, const set<_K>& v) {
    for (auto iter = v.begin(); iter != v.end(); ++iter) {
        ostr << *iter << (iter != v.end() ? " " : "");
    }
    return ostr;
}

template <typename _K, typename _V>
ostream& operator << (ostream& ostr, const pair<_K, _V>& v) {
    ostr << "(" << v.first << ", " << v.second << ")";
    return ostr;
}

vector<string> split(const string &s, char delim) {
    vector<string> result;
    stringstream ss(s);
    string item;
    while (getline(ss, item, delim)) {
        if (!item.empty()) {
            result.push_back(item);
        }
    }
    return result;
}

int main() {
    char S; cin >> S;
    if (S == toupper(S)) {
        cout << "A" << endl;
    } else {
        cout << "a" << endl;
    }
}


Measured memory_bytes: 3656
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<iomanip>
#include<map>
#include<utility>
#include<string>
#include<unordered_map>
#include<queue>

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; }

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
int gcd(int a, int b){return b ? gcd(b, a%b) : a;}
int lcm(int a, int b){return a*b / gcd(a, b);}

int main(){
    string s;
    cin >> s;
    int n = s.size();
    //左側にW，右側にBが集まるまで続く
    ll w_cnt = 0, ans = 0;
    for(int i = 0; i < n; i++){
        if(s[i] == 'W'){
            ans += i-w_cnt;
            w_cnt++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
namespace io{
    const int l=1<<20;
    char buf[l],*s,*t,c;
    inline void gc(){
        if(s==t){
            t=(s=buf)+fread(buf,1,l,stdin);
            c=s==t?EOF:*s++;
        }else c=*s++;
    }
    template<class IT>inline void gi(IT &x){
        x=0;gc();while(c<'0'||c>'9')gc();
        while('0'<=c&&c<='9'){x=(x<<1)+(x<<3)+(c^48);gc();}
    }
    char buf0[20];int a;
    template<class IT>inline void pi(IT x){
        if(x<0){putchar('-');x=-x;}
        do buf0[++a]=x%10+48;while(x/=10);
        while(a)putchar(buf0[a--]);
        putchar('\n');
    }
};
using io::gi;
using io::pi;
typedef unsigned int ui;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<int,ll > pil;
typedef pair<ll ,int> pli;
typedef pair<ll ,ll > pll;
typedef vector<int> vi;
typedef vector<ll > vl;
#define pque priority_queue
#define rep(i,l,r) for(i=(l);i<=(r);++i)
#define per(i,l,r) for(i=(l);i>=(r);--i)
#define REP(i,l,r) for(i=(l);i< (r);++i)
#define PER(i,l,r) for(i=(l);i> (r);--i)
#define mp make_pair
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define fi first
#define se second
template<class IT>inline void cmax(IT &a,IT b){if(a<b)a=b;}
template<class IT>inline void cmin(IT &a,IT b){if(b<a)a=b;}
const int N=100005;
char c[N];int x[26];
int main(){
    //freopen("a.in","r",stdin);
    //freopen("a.out","w",stdout);
    int n,i;ll t=1ll;
	rep(i,0,25)x[i]=1;
    scanf("%d%s",&n,c);
    REP(i,0,n)++x[c[i]-'a'];
	rep(i,0,25)t=t*x[i]%1000000007ll;
	printf("%lld",t-1ll);
    return 0;
}

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

ll N, K;
vector<int> Tele(200010);  //Tele[i] = (iの転送先)
map<int, ll> m;

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

  for(int i = 1; i <= N; i++) cin >> Tele[i];

  ll s = 1;  //start
  ll cn = 1;
  while(!m.count(s)){  //一度行ったことがあるか？
    m[s] = cn;  //何番目の町だったか
    ++cn;
    s = Tele[s];  //次の移動先
  }

  if(m[s] > K){
    int tmp = 1;
    for(int i = 0; i < K; i++) tmp = Tele[tmp];
    cout << tmp << endl;
  }else{
      
    K -= m[s]-1;  //ループ始点にたどり着くまでを除去
    ll loop_n = cn - m[s];  //一度のループ幅

    ll af = K % loop_n;
    for(int i = 0; i < af; i++) s = Tele[s];
    cout << s << endl;
  }
  return 0;
}

  


Measured memory_bytes: 16392
n,m=map(int,input().split())
a=list(map(int,input().split()))
bc=[list(map(int,input().split())) for _ in range(m)]


bc=sorted(bc, key=lambda x:(x[1], x[0]), reverse=True)
count=0
i=0
while count<n and i<m:
    for j in range(bc[i][0]):
        a.append(bc[i][1])
        count+=1
    i+=1
    

a.sort(reverse=True)
#print(a)
ans=0
for i in range(n):
    ans+=a[i]
print(ans)

Measured memory_bytes: 41928
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll MOD = 1e9+7;

#define vec     vector<int>
#define vecll   vector<ll>
#define vec2    vector<vector<int>>
#define vec2ll  vector<vector<ll>>
#define vpair   vector<pair<int, int>>
#define vpairll vector<pair<ll, ll>>
#define vecst   vector<string>
#define vecb    vector<bool>

#define rep(i,n)         for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n)       for(ll i=(ll)m; i<(ll)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define uniqueall(v)     v.erase(unique(v.begin(), v.end()), v.end());
#define f_sum(var)       accumulate(all(var), 0)
#define f_sumll(var)     accumulate(all(var), 0LL)
#define chmin(v1, v2)    v1 = min(v1, v2)
#define chmax(v1, v2)    v1 = max(v1, v2)
#define mpair(v1, v2)    make_pair(v1, v2)
#define pb(var)          push_back(var)
#define prt(var)         cout << var << "\n"
#define prtd(n, var)     cout << fixed << setprecision(n) << var << "\n"
#define prtfill(n, var)  cout << setw(n) << setfill('0') << var;
#define prt2(v1, v2)     cout << v1 << " " << v2 << "\n"
#define prt3(v1, v2, v3) cout << v1 << " " << v2 << " " << v3 << "\n"
#define prtall(v)        rep(i,v.size()){cout<<v[i]<<(i!=v.size()-1?" ":"\n");}
void prtok(bool ok){prt((ok ? "Yes" : "No"));}
//----------------------------------------------------------------

int main(void) {
  int n, m;
  cin >> n >> m;
  arrll(a,m);

  ll ans = n - f_sumll(a);
  if(ans<0){
    prt(-1);
  } else {
    prt(ans);
  }


}


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

int main()
{
	char twn[100 + 10][100 + 10];
	int cl[100 + 10][100 + 10];

	int y, x;

	int i, j;

	cin >> y >> x;

	for (i = 0; i < y; i++)
	{
		cin >> twn[i];

		for (j = 0; j < x; j++)
		{
			cl[i][j] = -1;
		}

		if (twn[i][0] == 'c')
		{
			cl[i][0] = 0;
		}
	}

	for (i = 0; i < y; i++)
	{

		cout << cl[i][0] << ' ';
		
		for (j = 1; j < x; j++)
		{
			if (twn[i][j] == 'c')
			{
				cl[i][j] = 0;
			}
			else if (cl[i][j-1] != -1)
			{
				cl[i][j] = cl[i][j - 1] + 1;
			}

			if(j<x-1) cout << cl[i][j] << ' ';
		}

		cout << cl[i][x-1]<< endl;

	}

	return 0;
}

Measured memory_bytes: 3148
#include <stdio.h>
int main(){
    int A[100];
    int n;
    int j,t;
    int flag=1,count=0;
    
    scanf("%d",&n);
    for(j=0;j<n;j++){
        scanf("%d",&A[j]);
    }

    while(flag){
        flag = 0;
        for (j=n-1;j>0;j--){
            if(A[j]<A[j-1]){
                t=A[j];
                A[j]=A[j-1];
                A[j-1]=t;
                flag=1;
                count++;
            }
        }
    }
    for(j=0;j<n;j++){
        printf("%d",A[j]);
        if(j<n-1)printf(" ");
    }
    printf("\n%d\n",count);
    
    return 0;
}



Measured memory_bytes: 1968
import java.io.*;
import java.util.*;

class Main{
  public static void main(String[] args) throws IOException{
    Scanner scan=new Scanner(System.in);
    int a=Integer.parseInt(scan.next());
    int b=Integer.parseInt(scan.next());

    int d=a/b;
    int r=a%b;
    double f=(double)a/b;

    System.out.println(d+" "+r+" "+String.format("%.5f",f));
  }
}


Measured memory_bytes: 26400
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>

using namespace std;

int main() {
  char c;
  cin >> c;
  if(c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u') {
    cout << "vowel" << endl;
  } else {
    cout << "consonant" << endl;
  }
}


Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) {

		FastScanner fs = new FastScanner();
		int a = fs.nextInt();
		int v = fs.nextInt();
		int b = fs.nextInt();
		int w = fs.nextInt();
		int t = fs.nextInt();

		int diffBase = Math.abs(a - b);
		int diffMove = Math.abs(v * t - w * t);

		//Output
		PrintWriter out = new PrintWriter(System.out);
		//out.println(diffBase + "," + diffMove);

		if (w - v > 0) {

			out.println("NO");

		} else if (a - b == 0) {
			out.println("YES");
		} else {
			if (diffBase <= diffMove) {
				out.println("YES");
			} else {
				out.println("NO");
			}
		}

		out.flush();

	}

}

//Input
class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}


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

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pairInt;
#define FOR(i, n) for (int i = 0; i < int(n); i++)
#define FOR1(i, m, n) for (int i = int(m); i < int(n); i++)
#define MAX(a, b) ((a) >= (b) ? (a) : (b))
#define MIN(a, b) ((a) <= (b) ? (a) : (b))

int main(int argc, char *argv[]) {
  int q;
  array<int, 2> p1, p2, p, v1, v2;

  scanf("%d%d%d%d%d", &p1[0], &p1[1], &p2[0], &p2[1], &q);
  v1[0] = p2[0] - p1[0];
  v1[1] = p2[1] - p1[1];

  FOR(i, q) {
    scanf("%d%d", &p[0], &p[1]);
    v2[0] = p[0] - p1[0];
    v2[1] = p[1] - p1[1];

    int ip1 = inner_product(v1.begin(), v1.end(), v1.begin(), 0);
    int ip2 = inner_product(v2.begin(), v2.end(), v1.begin(), 0);

    printf("%.10lf %.10lf\n", p1[0] + (double)ip2 / ip1 * (p2[0] - p1[0]),
           p1[1] + (double)ip2 / ip1 * (p2[1] - p1[1]));
  }
  
  return 0;
}

Measured memory_bytes: 3228
def fact(n):
    res = 1
    for i in range(1, n+1):
        res *= i
    return res
 
def combination(n, k):
    return fact(n)//fact(n-k)//fact(k)
 
n, m, r = list(map(int, input().split()))
 
print(combination(r - n*m + n - 1, n-1))

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

void call(int n){
  int i = 1;
 CHECK_NUM:
  int x = i;
  if ( x % 3 == 0 ){
    cout << " " << i;
    goto END_CHECK_NUM;
  }
 INCLUDE3:
  if ( x % 10 == 3 ){
    cout << " " << i;
    goto END_CHECK_NUM;
  }
  x /= 10;
  if ( x ) goto INCLUDE3;
 END_CHECK_NUM:
  if ( ++i <= n ) goto CHECK_NUM;

  cout << endl;
}

int main(){
    int n;
    cin >> n;
    call(n);
    
    return 0;
}


Measured memory_bytes: 3092
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>
#include <cmath>
#include <map>
using namespace std;

typedef long long ll;

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

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

  int res = max(a + b, max(a - b, a * b));
  cout << res << endl;

  return 0;
}


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


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

    if( S[0] == '7' or S[1] == '7' or S[2] == '7' ){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}

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

int main(){
	int x, a, b;
	cin>>x>>a>>b;
	int c = b - a;
	string ans = "safe";
	if(c > x) ans = "dangerous";
	if(c <= 0) ans = "delicious";
	cout<< ans <<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
using namespace std;
const int max_n= 100000;
long long cnt[111];
long long n,a=0,b,W,L,kk,c,m,V,e;
const int INF = 1e9+1;
const int mod = 1e9 + 7;
int mincost[max_n];
string s1,s2;
int prev[max_n];
long long x[max_n],y[max_n],s[max_n],d[max_n],ppar[max_n],rrank[max_n],spf[max_n],co[max_n];
typedef pair<long , long> pii;
pii cow[max_n];
//int cost[max_n][max_n];
pii bo[max_n];
int color[max_n];
vector<long long> G[max_n];
bool used[max_n];
struct edge{
    int u,cost,v;
};
bool comp(const edge& e1, const edge& e2){
    return e1.cost < e2.cost;   
}
edge es[max_n];
typedef pair<int, int> P;
struct Cmp{
    bool operator()(const pii &a,const pii &b){
        return a.second > b.second;
    }
};
void init(int n){
    for(int i=0 ; i<n ; i++){
        ppar[i] = i;
        rrank[i] = 0;
    }
}
int find(int x){
    if(ppar[x] == x){
        return x;
    }else{
        return ppar[x] = find(ppar[x]);
    }
}
void unite(int x, int y){
    x = find(x);
    y = find(y);
    if(x == y)  return;

    if(rrank[x] < rrank[y]){
        ppar[x] = y;
    }else{
        ppar[y] = x;
        if(rrank[x] == rrank[y])  rrank[x]++;
    }
}
bool same(int x, int y){
    return find(x) == find(y);
}
bool nibu_match(int v, int c){
    color[v] = c;
    for(int i=0 ; i<G[v].size() ; i++){
        int vv = G[v][i];
        if(color[vv] == c){
            return false;
        }
        if(color[vv] == 0 && !nibu_match(vv, -c)){
            return false;
        }
    }
    return true;
}
void solve(){
    if(nibu_match(0,1)){
        long long B = 0, W = 0;
        for(int i=0 ; i<V ; i++){
            if(color[i] == 1)   B++;
        }
        W = V-B;
        cout << B*W-e << endl;
        return;
    }else{
        cout << (V*(V-1))/2 - e << endl;
    }
}
int main(){
    cin >> V >> e;
    for(int i=0 ; i<e ; i++){
        int xx; int yy;
        cin >> xx >> yy;
        xx--;   yy--;
        G[xx].push_back(yy);
        G[yy].push_back(xx);
    }
    solve();
    return 0;
}

Measured memory_bytes: 7168
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false), cin.tie(0)
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define ALL(x) (x).begin(), (x).end()
#define dump(x) cout << (x) << endl
#define LMAX 9223372036854775807LL
#define LMIN -9223372036854775807LL
using ll = int64_t;
template<typename T>
using vec = vector<T>;
using P = pair<ll, ll>;
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    fill((T *)array, (T *)(array + N), val);
}

const ll INF = 1e16;
const ll MOD = 1e9 + 7;
//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//ll pas[51][52];

signed main(){
    IOS;
    ll n;
    cin >> n;
    string l,r,m;
    ll left = 0,right = n - 1;
    ll mid;
    dump(left);
    cin >> l;
    if(l == "Vacant"){
        return 0;
    }
    dump(right);
    cin >> r;
    if(l == "Vacant"){
        return 0;
    }
    REP(i,20){
        ll mid = (right + left) / 2;
        dump(mid);
        cin >> m;
        if(m == "Vacant"){
            return 0;
        }
        if(((right - mid) % 2 == 0 && m != r) || ((right - mid) % 2 == 1 && m == r)){
            left = mid;
            l = m;
        }
        else if(((mid - left) % 2 == 0 && l != m) || ((mid - left) % 2 == 1 && l == m)){
            right = mid;
            r = m;
        }
    }
}


Measured memory_bytes: 976
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <fstream> //ofstream
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
int m1,m2,d1,d2;


void solve(){
        if(m1!=m2&&d1+1!=d2) {
                cout<<1<<endl;
        }else{
                cout<<0<<endl;
        }
}

int main(){
        cin>>m1>>d1>>m2>>d2;

        solve();
        return 0;
}


Measured memory_bytes: 504
#!/usr/bin/env python3
import collections
import itertools as it
import math
#import numpy as np
 
#  = input()
n  = int(input())
#  = map(int, input().split())
a  = list(map(int, input().split()))
#  = [int(input()) for i in range(N)]
#

colors = [a_ // 400 for a_ in a if a_ < 3200]
colors_3200 = [a_ // 400 for a_ in a if a_ >= 3200]
c = collections.Counter(colors)

min_ = len(c) if c else 1
max_ = len(c) + len(colors_3200)
print(min_, max_)


Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define rep(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<x<<endl
using namespace std;
using ll = long long;
const ll MOD = 1e9+7;
const ll LINF = LLONG_MAX;
const int INF = INT_MAX;
const double PI=acos(-1);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
	string s,t; cin >> s >> t;
	int ans = 10000;
	rep(i,0,s.size() - t.size() + 1){
		int temp = 0;
		rep(j,0,t.size()){
			if(s[i + j] != t[j]){
				temp++;
			}
		}
		ans = min(ans, temp);
	}
	cout << ans << endl;
}

Measured memory_bytes: 3628
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
using namespace std;


int main() {
	long long int a=0, b=0, c, d, n, res = 0, m, tmp = 1, q, sum[200000] = {}, x[200000] = {}, v[200000] = {};
	string str;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> x[i];
	}
	sort(x + 1, x + n + 1);
	for (int i = n; i >1; i--) {
		if (x[i] == x[i - 1] && a == 0) { a = x[i]; i--; }
		else if(x[i]==x[i-1]&&b==0){
			b = x[i];
			cout << a * b;
			return 0;
		}
	}

	
	cout << 0;
}


Measured memory_bytes: 1792
// Author : Sarthak Kapoor
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define rep(i,n) for(int i=0;i<n;++i)
#define repa(i,a,n) for(int i=a;i<n;++i)
#define repr(i,n) for(int i=n-1;i>=0;--i)
#define repba(i,b,a) for(int i=b;i>=a;--i)
#define repab(i,a,b) for(int i=a;i<b;++i)
#define ll long long
#define ull unsigned long long
#define vi vector<int>
#define msi map<string,int>
#define mii map<int,int>
#define viip vector<pair<int,pair<int,int> > > 
#define mp make_pair
#define vip vector<pair<int,int> >
#define pb push_back 
#define po pop_back
#define fi first
#define sec second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define s(v) v.size()
ll mod = 1000000007;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());//use rng()%n for numbers in range [0,n-1]
ll gcd(ll a,ll b){
	if(b==0)return a;
	return gcd(b,a%b);
}
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	int n;
	cin>>n;
	int c1=0;
	repa(i,1,n+1){
		int j = i;
		int c = 0;
		while(j > 0){
			j /= 10;
			c++;
		}
		if(c%2)c1++;
	}	
	cout<<c1;
	return 0;
}

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

int main(void) {
	char S[101];
	int  len,i,j,cnt=0;

	scanf("%s",S);
	len=strlen(S);

	for(i=0,j=len-1;i<len/2;i++,j--) {
		if(S[i]==S[j]) continue;
		cnt++;
	}

    printf("%d",cnt);

return 0;
}

Measured memory_bytes: 128
//https://atcoder.jp/contests/abc172/tasks/abc172_b


#include<stdio.h>     //AA06( 23/ 07/ 20) If u see my code, Have a Good Day! (^_^)
#include<string.h>
#define LENTH 200001

int main()
{
    char S[LENTH], T[LENTH];

    int i, count = 0;

    scanf("%s%s", S, T);

    for(i = 0; i < strlen(S); ++i) {

        if(S[i] != T[i])
            count++;
    }

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

    return 0;
}


Measured memory_bytes: 2100
#import sys
MOD = 10 ** 9 + 7
INFI = 10**10
#input = sys.stdin.readline
import math

import itertools

#import bisect

import copy
from functools import lru_cache

def sosuhante(n):
    for k in range(2, int(math.sqrt(n))+1):
        if n% k ==0:
            return False
    return True
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

def kingaku(a,b,n):
    keta=len(str(n))
    return a*n+b*keta

def my_index(l, x, default=False):
    if x in l:
        return l.index(x)
    else:
        return default

#    h,w,a,b = map(int, input().split())
#    c = [[0 for j in range(n)] for i in range(n)]



def main():
    n,m=map(int,input().split())
    ans=[-1 for i in range(n)]
    num=0
    for i in range(m):
        s,c=map(int,input().split())
        if ans[s-1]!=-1 and ans[s-1]!=c:
            num=-1
        else:
            ans[s-1]=c

    else:
        for i in range(n):
            if ans[i]==-1 and i>0:
                ans[i]=0
            if ans[i]==-1 and i==0 and n>=2:
                ans[i]=1
    if ans[0]==-1 and n==1:
        ans[0]=0
    if ans[0]==0 and n>=2:
        num=-1
    if num==-1:
        print(-1)
    else:
        print("".join(map(str,ans)))
if __name__ == "__main__":
    main()

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

using namespace std;

#define LL long long
#define DD double
#define Pb push_back
#define Bp pop_back
#define Pf push_front
#define Fp pop_front
#define Ub upper_bound
#define Lb lower_bound
#define In insert
#define All(x) x.begin(), x.end()
#define mem(a, b) memset(a, b, sizeof(a))
#define fast ios_base::sync_with_stdio(0);cin.tie(0)
#define X first
#define Y second
#define mx1 10
#define mx2 110
#define mx3 1010
#define mx4 10010
#define mx5 100010
#define mx6 1000010

typedef vector<LL> Vl;
typedef vector<DD> Vd;
typedef vector<bool> Vb;
typedef vector<Vl> VVl;
typedef pair<LL, LL> Pll;
typedef pair<DD, DD> Pdd;
typedef vector<Pll> Vpl;
typedef vector<Pdd> Vpd;
typedef queue<LL> Ql;
typedef stack<LL> Sl;
typedef deque<LL> Dl;

LL _set(LL N, LL pos) {return N = N | (1 << pos);}
LL _reset(LL N, LL pos) {return N = N & ~(1 << pos);}
bool _check(LL N, LL pos) {return (bool)(N & (1 << pos));}
bool _upper(char a) {return a >= 'A' && a <= 'Z';}
bool _lower(char a) {return a >= 'a' && a <= 'z';}
bool _digit(char a) {return a >= '0' && a <= '9';}

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

///**************************DONE****************************///

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

    int L = s.size();
    LL cnt = 0, ans;

    for(int i = 0; i < L; i++){
        if(s[i] != '1'){
            ans = s[i] - '0';
            break;
        }
        cnt++;
    }

    if(k <= cnt)
        cout << 1 << '\n';
    else
        cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 3572
N,M=map(int,input().split())
A=[list(map(int,input().split())) for i in range(M)]
L=1
R=N
for i in range(M):
  L=max(L,A[i][0])
  R=min(R,A[i][1])
ans=R-L+1
if ans>0:
  print(ans)
else:
  print(0)

Measured memory_bytes: 27332
import sys
A,B,C,K=map(int, sys.stdin.readline().split())
ans=0
a_cards=min(K,A)
K-=a_cards
ans+=a_cards*1

b_cards=min(K,B)
K-=b_cards
ans+=b_cards*0

c_cards=min(K,C)
K-=c_cards
ans+=c_cards*-1

print ans


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

using namespace std;

typedef long long ll;

int main(){
  ll n;
  ll cnt = 0;

  //vector<ll> ans;
  
  cin >> n;

  for(int i = 1; i <= 1000000; i++){
    if(n % i == 0){
      ll v = n/i-1;
      if( v > i ) cnt += v;
    }
  }
  cout << cnt << endl;
  return 0;
}


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

int n;
char s[40];
int p1,p2;
string r1[262144],b1[262144];
string r2[262144],b2[262144];

char t1[20],t2[20];
int pos;

void f1(int num){
	if(num==n){
		t1[pos]=0;	t2[num-pos]=0;
		r1[p1]=t1;	b1[p1]=t2;	p1++;	return;
	}

	t2[num-pos]=s[num];	f1(num+1);

	pos++;
	t1[pos-1]=s[num];	f1(num+1);
	pos--;
}

void f2(int num){
	if(num==n){
		t1[pos]=0;	t2[num-pos]=0;
		r2[p2]=t1;	b2[p2]=t2;	p2++;	return;
	}

	t2[num-pos]=s[num+n];	f2(num+1);

	pos++;
	t1[pos-1]=s[num+n];	f2(num+1);
	pos--;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>n>>s;
	int i,j;
	pos=0;	f1(0);
	pos=0;	f2(0);

	for(i=0;i<p1;i++){
		reverse(b1[i].begin(),b1[i].end());
		reverse(r2[i].begin(), r2[i].end());
	}

	vector<pair<string,string> > v1,v2;

	for(i=0;i<p1;i++){
		v1.push_back(make_pair(r1[i],b1[i]));
		v2.push_back(make_pair(r2[i],b2[i]));
	}

	sort(v1.begin(), v1.end());
	sort(v2.begin(), v2.end());

	i=0,j=0;

	ll ans=0;

	for(i=0;i<p1;i++){
		vector<pair<string,string> >::iterator it1,it2;
		it1=upper_bound(v1.begin(), v1.end(), v2[i]);
		it2=lower_bound(v1.begin(), v1.end(), v2[i]);
		ans+=distance(it2,it1);
	}

	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 92376
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); ++i)
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using Graph = vector<vl>;  // vi <=> vl
using P = pair<int, int>;  // int <=> ll
const int MOD = 1e9+7;
const double EPS = 1e-9;

int main() {
  int n, a; cin >> n >> a;
  vi arr(n);
  rep(i,n) {
    cin >> arr[i];
    arr[i] -= a;
  }

  Graph dp(n+1, vl(5001, 0));  // -2500 ~ 2500
  const int zero = 2500;
  dp[0][zero] = 1;

  rep(i,n) {
    rep(j,5001) {
      if (j-arr[i] < 0 || j-arr[i] >= 5001) {
        dp[i+1][j] = dp[i][j];
      } else {
        dp[i+1][j] = dp[i][j] + dp[i][j-arr[i]];
      }
    }
  }

  cout << dp[n][zero] - 1 << endl;
  return 0;
}


Measured memory_bytes: 2304
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from functools import lru_cache
import bisect
import re
import queue


class Scanner():
    @staticmethod
    def int():
        return int(sys.stdin.readline().rstrip())

    @staticmethod
    def string():
        return sys.stdin.readline().rstrip()

    @staticmethod
    def map_int():
        return [int(x) for x in Scanner.string().split()]

    @staticmethod
    def string_list(n):
        return [input() for i in range(n)]

    @staticmethod
    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    @staticmethod
    def int_cols_list(n):
        return [int(input()) for i in range(n)]


class Math():
    @staticmethod
    def gcd(a, b):
        if b == 0:
            return a
        return Math.gcd(b, a % b)

    @staticmethod
    def lcm(a, b):
        return (a * b) // Math.gcd(a, b)

    @staticmethod
    def roundUp(a, b):
        return -(-a // b)

    @staticmethod
    def toUpperMultiple(a, x):
        return Math.roundUp(a, x) * x

    @staticmethod
    def toLowerMultiple(a, x):
        return (a // x) * x

    @staticmethod
    def nearPow2(n):
        if n <= 0:
            return 0
        if n & (n - 1) == 0:
            return n
        ret = 1
        while(n > 0):
            ret <<= 1
            n >>= 1
        return ret

    @staticmethod
    def sign(n):
        if n == 0:
            return 0
        if n < 0:
            return -1
        return 1

    @staticmethod
    def isPrime(n):
        if n < 2:
            return False
        if n == 2:
            return True
        if n % 2 == 0:
            return False
        d = int(n ** 0.5) + 1
        for i in range(3, d + 1, 2):
            if n % i == 0:
                return False
        return True


MOD = int(1e09) + 7
INF = int(1e15)

T_MAX = int(1e05) + 1


def main():
    # sys.stdin = open("sample.txt")
    N, K = Scanner.map_int()
    T = defaultdict(list)
    for _ in range(N):
        t, d = Scanner.map_int()
        t -= 1
        T[t].append(d)
    for v in T.values():
        v.sort(reverse=True)
    M = []
    for v in T.values():
        M.append((v[0], 1))
        for i in range(1, len(v)):
            M.append((v[i], 0))
    M.sort(reverse=True)

    q = []
    x = 0
    y = 0
    for i in range(K):
        x += M[i][0]
        y += M[i][1]
        if M[i][1] == 0:
            heapq.heappush(q, M[i][0])
    ans = x + y * y
    for i in range(K, N):
        if q == []:
            break
        if M[i][1] == 1:
            x -= heapq.heappop(q)
            x += M[i][0]
            y += 1
            ans = max(ans, x + y * y)
    print(ans)


if __name__ == "__main__":
    main()


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

void solve() {
  int x, y;
  cin >> x >> y;
  int a[3][7]= {{1, 3, 5, 7, 8, 10, 12}, {4, 6, 9, 11,0,0,0}, {2,0,0,0,0,0,0}};
  vector<int>ans(3);
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 7; j++) {
      if(a[i][j] == x || a[i][j] == y) {
        ans[i]++;
      }
    }
  }
  for (auto x : ans) {
    if(x == 2) {
      cout << "Yes";
      return;
    }
  }
  cout << "No";
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  solve();
  return 0;
 }


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

#define int long long
typedef pair<int, int> P;

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

/*
#define cin ifs
#define cout ofs
ifstream ifs("in.txt");
ofstream ofs("out.txt");
//*/

int N, K;
int A[110000], B[110000], V[110000], P_[110000];
vector<int> G[110000];
bool decided[110000], visited1[110000], visited2[110000];
int odd[110000];
P seg[110000];
int ans[110000];

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

void dfs1(int x, int n) {
    if (decided[n] && ans[n] % 2 != x) no();
    visited1[n] = true;
    odd[n] = x;
    for (int i = 0; i < G[n].size(); i++) {
        if (visited1[G[n][i]]) continue;
        dfs1((x + 1) % 2, G[n][i]);
    }
}

P dfs2(int n) {
    visited2[n] = true;
    if (decided[n]) return seg[n] = P(ans[n], ans[n]);
    int l = -1e13, r = 1e13;
    for (int i = 0; i < G[n].size(); i++) {
        if (visited2[G[n][i]] && !decided[G[n][i]]) continue;
        P p = dfs2(G[n][i]);
        l = max(l, p.first);
        r = min(r, p.second);
    }
    l--; r++;
    if (abs(l) % 2 != odd[n]) l++;
    if (abs(r) % 2 != odd[n]) r--;
    if (l > r) no();
    return seg[n] = P(l, r);
}

void dfs3(int x, int n) {
    decided[n] = true;
    ans[n] = seg[n].first <= x - 1 ? x - 1 : x + 1;
    for (int i = 0; i < G[n].size(); i++) {
        if (decided[G[n][i]]) continue;
        dfs3(ans[n], G[n][i]);
    }
}
void check(int n) {
    for (int i = 0; i < G[n].size(); i++) {
        if (!decided[G[n][i]]) continue;
        if (abs(ans[n] - ans[G[n][i]]) != 1) no();
    }
}

signed main() {
    cin >> N;
    for (int i = 0; i < N - 1; i++) {
        cin >> A[i] >> B[i];
        G[A[i]].push_back(B[i]);
        G[B[i]].push_back(A[i]);
    }
    cin >> K;
    for (int i = 0; i < K; i++) {
        cin >> V[i] >> P_[i];
        decided[V[i]] = true;
        ans[V[i]] = P_[i];
    }
    for (int i = 0; i < K; i++) {
        check(V[i]);
    }
    dfs1(P_[0] % 2, V[0]);
    for (int i = 1; i <= N; i++) {
        if (decided[i]) continue;
        dfs2(i);
        dfs3(seg[i].first + 1, i);
    }
    cout << "Yes" << endl;
    for (int i = 1; i <= N; i++) {
        cout << ans[i] << endl;
    }
    return 0;
}

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

int main() {
  int n;
  double t, a;
  cin >> n >> t >> a;
  
  vector<double> diff;
  
  for (int i = 0; i < n; ++i) {
    double height; cin >> height;
    double abs_diff = abs(a - (t - 0.006 * height));
    
    diff.push_back(abs_diff);
  }
  
  int min_idx = min_element(diff.begin(), diff.end()) - diff.begin() + 1;
  cout << min_idx << endl;
  
  return 0;
}

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

vector<ll>G[10];
vector<ll> ans[100005];

int main() {
  ll n;
  cin >> n;
  
  rep(i, 10) {
    if(i != 0) G[i].push_back(i-1);
    G[i].push_back(i);
    if(i != 9) G[i].push_back(i+1);
  }

  // vector<int> dist(n, INF);
  queue<ll> que;
  for(ll i = 1; i <= 9 ; ++i) {
    que.push(i);
  }

  ll u;
  ll count = 0;
  while(!que.empty()) {
    u = que.front(); que.pop();
    // cout << u << endl;
    count++;
    // cout << count << endl;
    if(count == n) {
      cout << u << endl;
      return 0;
    }
    ll d = u % 10;
    for(ll v: G[d]){
      v = u * 10 + v; 
      que.push(v);
    }
  }

  return 0;
}

Measured memory_bytes: 4224
N = int(input())
p = list(map(int, input().split()))

s = p[:]
s.sort()

sum = 0

for i in range(len(p)):
    if s[i] != p[i]:
        sum += 1

if sum == 0 or sum == 2:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 38384
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "functional"

using namespace std;

//constexpr long long int MOD = 1000000007;
constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-8;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;


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

	cin >> N;
	for (int i = 1; i <= 9; i++) {
		for (int j = 1; j <= 9; j++) {
			if (i*j == N) {
				cout << "Yes\n";
              return 0;
			}
		}
	}
	cout << "No\n";
}



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

int cnt[100010];

bool vis[100010],vise[100010];
set<int> st;
vector<pair<int,int> > e[100010];
int u[100010],v[100010];
void dfs(int x,int p){
	vis[x]=true;
	for(auto it:e[x]){
		int y = it.first;
		if(!vis[y]){
			vise[it.second]=true;
			dfs(y,x);
		}
	}
}

void dfs2(int x,int p){
	vis[x]=true;
	for(auto it:e[x]){
		int y = it.first;
		if(!vis[y]){
			dfs2(y,x);
		}
	}
	if(p!=0){
		if(cnt[x]){
			cout<<x<<' '<<p<<'\n';
		}
		else{
			cout<<p<<' '<<x<<'\n';
			cnt[p]^=1;
		}
	}
}
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n,m;
	cin>>n>>m;
	for(int i=1;i<=m;i++){
		cin>>u[i]>>v[i];
		e[u[i]].emplace_back(v[i],i);
		e[v[i]].emplace_back(u[i],i);
	}
	if(m&1){
		cout<<-1<<endl;
		return 0;
	}
	dfs(1,0);
	for(int i=1;i<=m;i++)
		if(!vise[i]){
			cout<<u[i]<<' '<<v[i]<<'\n';
			cnt[u[i]]^=1;
		}
	memset(vis,0,sizeof vis);
	dfs2(1,0);
}


Measured memory_bytes: 14464