akhauriyash/Code-Regression huggingface dataset:
#define _DEBUG 1
#define _GLIBCXX_DEBUG

#include <bits/stdc++.h>
using namespace std;

using ll = long long;

#ifdef _DEBUG
#define dump(x) cerr << #x << "=" << x << endl
#define dump2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define dump3(x, y, z)                                                     \
  cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z \
       << endl
#define check(s) cerr << s << endl
#else
#define dump(x)
#define dump2(x, y)
#define dump3(x, y, z)
#define check(s)
#endif

#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define unique(v) v.erase(unique(v.begin(), v.end()), v.end());

const ll LINF = 2e18;
const int INF = 1e9;

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
  ll x;  // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod - a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const { return mint(*this) += a; }
  mint operator-(const mint a) const { return mint(*this) -= a; }
  mint operator*(const mint a) const { return mint(*this) *= a; }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod - 2); }
  mint& operator/=(const mint a) { return *this *= a.inv(); }
  mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream& is, mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }

// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
  vector<mint> fact, ifact;
  combination(int n) : fact(n + 1), ifact(n + 1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n] * ifact[k] * ifact[n - k];
  }
};

void solve(ll X, ll Y) {
  if ((X + Y) % 3 != 0) {
    cout << 0 << endl;
    return;
  }

  ll n = (2 * Y - X) / 3;
  ll m = (2 * X - Y) / 3;
  if (n < 0 || m < 0) {
    cout << 0 << endl;
    return;
  }

  combination c = combination(n + m);
  cout << c(n + m, n) << endl;
}

int main() {
  ll X;
  scanf("%lld", &X);
  ll Y;
  scanf("%lld", &Y);
  solve(X, Y);
  return 0;
}


Measured memory_bytes: 13896
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<ll>
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(),x.end()
#define vll vector<ll>
#define M 200011
#define MD 1000000007
ll md=MD;

ll a[3000][3000],r[3000][3000];
void mul(ll b[3000][3000],ll n){
	ll i,j,k;
	ll c[n][n];
	memset(c,0,sizeof(c));
	for(i=0;i<n;i++)	
		for(j=0;j<n;j++)
			for(k=0;k<n;k++)
				c[i][j]+=(a[i][k]%MD*b[k][j]%MD)%MD;
	for(i=0;i<n;i++)
		for(j=0;j<n;j++)
			b[i][j]=c[i][j]%MD;
}
ll exp(ll b,ll n){

	while(b>0){
		if(b&1)
			mul(r,n);
		b>>=1;
		mul(a,n);		
	}
}
int main()
{

    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	ll t,i,j,m,x,y,n,z,p,k,T;string s2,s3;x=1;
	cin>>n>>k;
    for(i=0;i<n;++i)r[i][i]=1;
    for(i=0;i<n;++i)for(j=0;j<n;++j)cin>>a[i][j];
	exp(k,n);
	p=0;
	for(i=0;i<n;++i)for(j=0;j<n;++j)p=p+r[i][j]%md,p%=md;
	cout<<p%md;

















	
	return 0;
}

Measured memory_bytes: 2688
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<memory>
using namespace std;


template <typename T>
class Stack {
public:
    int top_idx;
    T S[1000];

    Stack() {
        top_idx = 0;
    }

    void push(T x) {
        S[++top_idx] = x;
    }

    T pop() {
        top_idx--;
        return S[top_idx+1];
    }
};

int main() {
    int a, b;
    unique_ptr<Stack<int>> stack(new Stack<int>);
    char s[100];

    while( scanf("%s", s) != EOF) {
        if (s[0] == '+') {
            a = stack->pop();
            b = stack->pop();
            stack->push(a + b);
        } else if (s[0] == '-') {
            b = stack->pop();
            a = stack->pop();
            stack->push(a - b);
        } else if (s[0] == '*') {
            a = stack->pop();
            b = stack->pop();
            stack->push(a * b);
        } else {
            stack->push(atoi(s));
        }
    }

    printf("%d\n", stack->pop());
}


Measured memory_bytes: 2744
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n; i >= 0; i--)
#define inf LLONG_MAX
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;


int main()
{
    ll a, b, c, x, y; cin >> a >> b >> c >> x >> y;
    ll total = 0;
    total += min(a + b, 2 * c) * min(x, y);
    ll _x = x - min(x, y), _y = y - min(x, y);
    total += min(a, 2 * c) * _x + min(b, 2 * c) * _y;
    cout << total << endl;
    return 0;
}

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

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
	ll x; // typedef long long ll;
	mint(ll x = 0) :x((x%mod + mod) % mod) {}
	mint operator-() const { return mint(-x); }
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
	mint operator+(const mint a) const { return mint(*this) += a; }
	mint operator-(const mint a) const { return mint(*this) -= a; }
	mint operator*(const mint a) const { return mint(*this) *= a; }
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime mod
	mint inv() const { return pow(mod - 2); }
	mint& operator/=(const mint a) { return *this *= a.inv(); }
	mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }
// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
	vector<mint> fact, ifact;
	combination(int n) :fact(n + 1), ifact(n + 1) {
		assert(n < mod);
		fact[0] = 1;
		for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
		ifact[n] = fact[n].inv();
		for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
	}
	mint operator()(int n, int k) {
		if (k < 0 || k > n) return 0;
		return fact[n] * ifact[k] * ifact[n - k];
	}
}c(200005);


//m^n
mint f(int m, int n) {
	if (0 == n) {
		return 1;
	}
	mint x = f(m, n / 2);
	x *= x;
	if (1 == n % 2) {
		x *= (mint)m;
	}
	return x;
}
// nCa
mint choose(int n, int a) {
	mint x = 1;
	mint y = 1;
	for (int m = 0; m < a; ++m) {
		x *= (mint)(n - m);
		y *= (mint)(a - m);
	}
	return x / y;
}
// nPk
mint nPk(int n, int a) {
	mint ret = choose(n, a);
	for (int n = 1; n <= a; ++n) {
		ret *= n;
	}
	return ret;
}
int main() {
	int N,K;
	cin >> N>>K;
	for (int k = 0; k < K; ++k) {
		mint ans = c((N - K + 1),k + 1)*c(K-1,k); 
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 6128
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using vpii = vector<pair<int, int>>;
using vpll = vector<pair<ll, ll>>;
// ceil() 切り上げ, floor() 切り捨て
// next_permutation(all(x))

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

	vector<vector<int>> F(n, vector<int>(10));
	vector<vector<int>> P(n, vector<int>(11));
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < 10; j++)
			cin >> F[i][j];
	}
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < 11; j++)
			cin >> P[i][j];
	}

	int ans = -1e9;
	for (int i = 1; i < (1 << 10); i++)
	{
		bitset<10> S(i);
		int sum = 0;
		for (int j = 0; j < n; j++)
		{
			int cnt = 0;
			for (int k = 9; k >= 0; k--)
			{
				if (S[k] && F[j][k])
					cnt++;
			}
			sum += P[j][cnt];
		}
		ans = max(ans, sum);
	}
	cout << ans << endl;
}



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

using namespace std;

int main(){

    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cout.precision(20);

    int a, b;
    cin >> a >> b;
    if(a > 8 or b > 8) cout << ":(\n";
    else cout << "Yay!\n";
}

Measured memory_bytes: 256
package main

import . "fmt"

// github.com/EndlessCheng/codeforces-go
func main() {
	var n int
	Scan(&n)
	if n&1 == 0 {
		Print(0.5)
	} else {
		Print(float64(n+1) / float64(2 * n))
	}
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
signed main(){
  int N,M;
  cin>>N>>M;
  vector<set<int>> A(N);
  vector<vector<int>> B(N);
  deque<int> D;
  while(M--){
    int a,b;
    cin>>a>>b;
    if(D.size()==0)D.push_front(a-1),D.push_back(b-1);
    else A[a-1].insert(b-1),A[b-1].insert(a-1);
    B[a-1].push_back(b-1);
    B[b-1].push_back(a-1);
  }
  for(int i:A[D.front()])A[i].erase(D.front());
  for(int i:A[D.back()])A[i].erase(D.back());
  while(true){
    if(A[D.front()].size()){
      D.push_front(*(A[D.front()].begin()));
      for(int i:B[D.front()])A[i].erase(D.front());
    }else if(A[D.back()].size()){
      D.push_back(*(A[D.back()].begin()));
      for(int i:B[D.back()])A[i].erase(D.back());
    }else break;

  }
  cout<<D.size()<<endl;
  for(int i=0;i<D.size();i++)cout<<D[i]+1<<(i+1==D.size()?'\n':' ');
}

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

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

    if (a > 0) {
        if (a >= k) {
            a -= k;
        } else {
            if (b >= k - a) {
                b -= k - a;
            } else {
                b = 0;
            }
            a = 0;
        }
    } else {
        if (b >= k) {
            b -= k;
        } else {
            b = 0;
        }
    }

    cout << a << " " << b << endl;
}

Measured memory_bytes: 256
N,W = map(int,input().split())
V = 10**5
dp=[float('inf')]*(V+1)
dp[0]=0
for i in range(N):
	w,v = map(int,input().split())
	for j in range(V,v-1,-1):
		dp[j]=min(dp[j],dp[j-v]+w)
for i in range(V,-1,-1):
	if dp[i] <= W:
		print(i)
		exit()


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

int main() {
  int n;
  cin >> n;
  
  bool ans = false;
  for(int i = 1; i <= 9; i++){
    for(int j = 1; j <= 9; j++){
      if(i * j == n) ans = true;
    }
  }
  
  if(ans) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
 
const ll mol = 1e9 + 7;
const int maxn = 2e5;
 
int a[maxn + 11],b[maxn + 11];
 
int main() {
	int k,n;
	scanf("%d %d",&n,&k);
	int ca = 0 , cb = 0;
	for (int i = 1; i <= n; i++) {
		int x;
		scanf("%d",&x);
		if (x >= 0) a[++ca] = x;
		else b[++cb] = -x;
	}
	sort(a + 1 , a + 1 + ca , [&](int x,int y) { return x > y; });
	sort(b + 1 , b + 1 + cb , [&](int x,int y) { return x > y; });
	if (ca == 0) {
		ll ans = 1;
		if (k % 2 == 1) {
			for (int i = cb; i >= cb - k + 1; i--)
				ans = ans * b[i] % mol;
			ans = mol - ans;
		}
		else {
			for (int i = 1; i <= k; i++)
				ans = ans * b[i] % mol;
		}
		printf("%lld\n" , ans);
		return 0;
	}
	if (n == k) {
		ll ans = 1;
		for (int i = 1; i <= ca; i++)
			ans = ans * a[i] % mol;
		for (int i = 1; i <= cb; i++)
			ans = ans * b[i] % mol;
		if (cb & 1) ans = mol - ans;
		printf("%lld\n" , ans);
		return 0;
	}
	int u,d;
	if (ca >= k) { u = k; d = 0; }
	else if ((k - ca) % 2 == 0) {
		u = ca; d = k - ca;
	}
	else {
		u = ca - 1; d = k - ca + 1;
	}
	while (1) {
		if (u < 2 || d + 2 > cb) break;
		if (1ll * a[u] * a[u - 1] > 1ll * b[d + 1] * b[d + 2]) break;
		u -= 2; d += 2;
	} 
	ll ans = 1;
	for (int i = 1; i <= u; i++) ans = ans * a[i] % mol;
	for (int i = 1; i <= d; i++) ans = ans * b[i] % mol;
	printf("%lld\n" , ans);
} 


Measured memory_bytes: 4532
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const ll M1 = 1e18, M2 = 1e9;
ll s, x2, y2, x3, y3;
int main()
{
    cin >> s;
    if(s <= M2){
        printf("0 0 1 0 0 %lld\n",s);
    }
    else if(s % M2 == 0){
        printf("0 0 %lld 1 0 %lld\n", s / M2, M2);
    }
    else{
        x2 = s / M2 + 1;
        y3 = M2;
        x3 = 1;
        y2 = x2 * y3 - s;
        printf("0 0 %lld %lld %lld %lld\n", x2, y2, x3, y3);
    }
    return 0;
}

Measured memory_bytes: 3764
def abc133_c():
  L,R = map(int,input().split())
  if R - L > 673: return 0
  ans = 2019
  for i in range(L, R):
    for j in range(i+1, R+1):
      ans = min(ans, i*j%2019)
      if ans == 1: return 1
  return ans

print(abc133_c())

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

#define DUMP(x) cerr << #x << "=" << x << endl
#define DUMP2(x, y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<")"<< endl
#define BINARY(x) static_cast<bitset<16> >(x)

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

#define in_range(x, y, w, h) (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))
#define ALL(a) (a).begin(),(a).end()

typedef long long ll;
const int INF = 1e9;
typedef pair<int, int> PII;
int dx[4]={0, -1, 1, 0}, dy[4]={-1, 0, 0, 1};

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

    rep(i, 4) cout << S[i];
    cout << " ";
    REP(i, 4, 12) cout << S[i];
    cout << endl;
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
#define ll long long
#define f(i, a, b) for(ll i = a; i <= b; ++i)
#define ff(i, a, b) for(ll i = a; i < b; ++i)
#define F(i, a, b) for(ll i = a; i >= b; --i)
#define FF(i, a, b) for(ll i = a; i > b; --i)
#define x first
#define y second
#define X real()
#define Y imag()
using namespace std;
typedef complex<ll> P;
typedef pair<ll, ll> ii;
typedef tuple<ll, ll, ll> iii;

const ll N = 55;
ll n, cnt, ans = -1;
ii a[N];
set<ii> sett;
vector<ii> arr;
map<ii, ll> mp; 

signed main(){
	scanf("%lld", &n);
	f(i,1,n){
		scanf("%lld %lld", &a[i].x, &a[i].y);
		mp[{a[i].x, a[i].y}] = 1;
	}
	sort(a+1, a+1+n);
	ff(i,1,n){
		f(j,1+i,n){
			sett.insert({a[j].x-a[i].x, a[j].y-a[i].y});
		}
	}
	for(auto i : sett) arr.push_back(i);
	for(auto i : arr){
		cnt = 0;
		f(j,1,n){
			if(!mp[{a[j].x - i.x, a[j].y - i.y}]){
				cnt++;
			}
			mp[a[j]] = 2;
		}
		if(ans == -1 || ans > cnt) ans = cnt;
	}
	if(ans != -1) printf("%d", ans);
	else printf("1");
}


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

using namespace std;

int main(){
  int n, total, m,p,x;
  int inp;
  map<int,int> t;
  total = 0;
  cin >> n;
  for(int i = 1; i<=n; i++){
    cin >> inp;
    total+= inp;
    t[i]=inp;
  }
  cin >> m;
  while(m){
    cin >> p >> x;
    int ans = t[p]-x;
    ans = total - ans;
    cout << ans << "\n";
    m--;
  }

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int mod=998244353;
const int N=4001;
char s[N];
int t[N];
typedef long long ll;
int fac[N],inv[N],finv[N];
template<class T>inline void Inc(T&x,int y){x+=y;if(x>=mod) x-=mod;}
inline int C(int n,int m){if(n<m) return 0;return (ll)fac[n]*finv[m]%mod*finv[n-m]%mod;}
int n;
int dp[N][N];
int main()
{
	scanf("%s",s+1);n=strlen(s+1);
	int red=0,blue=0;fac[0]=finv[0]=1;inv[1]=1;
	for(int i=2;i<=n;++i) inv[i]=(ll)(mod-mod/i)*inv[mod%i]%mod;
	for(int i=1;i<=n;++i) fac[i]=(ll)fac[i-1]*i%mod,finv[i]=(ll)finv[i-1]*inv[i]%mod;
	for(int i=1;i<=n;++i) t[i]=s[i]-'0';
	dp[0][0]=1;
	for(int i=1;i<=n;++i) {
		if(t[i]==1) ++red,++blue;else if(t[i]==0) red+=2;else blue+=2;
		for(int j=0;j<=red;++j){
			if(j>0) Inc(dp[i][j],dp[i-1][j-1]);
			if(i-j<=blue) Inc(dp[i][j],dp[i-1][j]);
		}
	}
	int ans=0;
	for(int i=0;i<=red;++i) {int f=dp[n][i];Inc(ans,(ll)f*C(n,red-i)%mod);}
	printf("%d\n",ans);
}


Measured memory_bytes: 31616
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<iostream>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<algorithm>

#define rep(n) for(int i=0;i<n;i++)
#define repp(j, n) for(int j=0;j<n;j++)
#define reppp(i, m, n) for(int i=m;i<=n;i++)
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define pb(x) push_back(x)
#define eb(x,y) emplace_back(x,y)
#define MOD 1000000007
#define MAX 1000000001
#define INF 3e13
#define EPS 1e-9
 
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
struct edge{int from, to; ll cost;};

vector<ll> d;
ll V, E;
vector<edge> edges;

bool bellman_ford(ll start){
  rep(V){
	  d.push_back(INF);
  }
  d[start] = 0;

  ll cnt = E+1, cost_tmp = 0;
  bool update = true;
  while(update){
	update = false;
	  rep(E){
	    edge e = edges[i];
	    if(d[e.from] != INF && d[e.to] > d[e.from] + e.cost){
		    d[e.to] = d[e.from] + e.cost;
		    update = true;
	    }
	  }
	  cnt--;
	  if(cnt == 0){
		 cost_tmp = d[V-1];
	  }else if(cnt == -E-1){
		  if(d[V-1] < cost_tmp){
			  return true;
		  }else{
			  break;
		  }
	  }
  }
  return false;
}



signed main(){
	cin >> V >> E;
	rep(E){
		edge e;
		cin >> e.from >> e.to >> e.cost;
		e.from--; e.to--;
		e.cost *= -1;
		edges.push_back(e);
	}
	bool flag = bellman_ford(0);
	if(flag){
		cout << "inf";
	}else{
		cout << -d[V-1];
	}
}


Measured memory_bytes: 764
import math

def nyu():
    K = int(input())
    return K


def check(K ):
    sum =0

    for k1 in range(1,K+1):
        for k2 in range(1,K+1):
            for k3 in range(1,K+1):
                sum +=  (math.gcd(k1,math.gcd(k2,k3)))
    print(sum)
     
            
K = nyu()
check(K)
#print(S)



Measured memory_bytes: 9196
#include <bits/stdc++.h>
using namespace std;
const int N=6005;
int n,p[N],pp[N],t[N];
int q[N],head,tail;
string res[N],now;
char s[N];
vector <int> a,b;
int main(){
	scanf("%d",&n);
	n<<=1;
	scanf("%s",s+1);
	a.clear(),b.clear();
	for (int i=1;i<=n;i++)
		if (s[i]=='a')
			a.push_back(i);
		else
			b.push_back(i);
	for (int i=1;i<=n/2;i++)
		p[b[i-1]]=a[i-1],pp[a[i-1]]=b[i-1];
	for (int i=1;i<=n+1;i++)
		res[i]="";
	int tot=0;
	int nxt=n+1;
	for (int i=n;i>=1;i--){
		if (s[i]=='a')
			tot++;
		else
			tot--;
		if (tot)
			continue;
		memset(t,0,sizeof t);
		head=1,tail=0;
		res[i]=res[nxt];
		for (int j=i;j<nxt;j++){
			if (s[j]=='a'){
				if (t[j]){
					now="";
					for (int k=i;k<nxt;k++)
						if (s[k]=='b'){
							if (t[k]||k>j)
								now+="b";
						}
						else if (t[k]||k>p[q[tail]])
							now+="a";
					res[i]=max(res[i],now+res[nxt]);
					head++;
					t[j]=t[pp[j]]=0;
				}
				continue;
			}
			if (p[j]<j)
				continue;
			q[++tail]=j;
			t[j]=t[p[j]]=1;
		}
		memset(t,0,sizeof t);
		if (tail==0){
			for (int j=i;j<nxt;j++){
				if (s[j]=='b')
					continue;
				t[j]=t[pp[j]]=1;
				now="";
				for (int k=i;k<=pp[j];k++)
					if (t[k])
						now+=s[k];
				res[i]=max(res[i],now+res[nxt]);
				j=pp[j];
			}
		}
		nxt=i;
	}
	cout << res[1];
	return 0;
}

Measured memory_bytes: 10624
#include <bits/stdc++.h>
using namespace std;
#define ll  long long int
#define endl '\n'


int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
	
	//ll t; cin>>t; while(t--)
	{
		ll x,n;
		cin>>x>>n;
		if(n%2)
		{
			cout<<"No\n";
			return 0;
		}
		ll cnt1=0;
		ll cnt2=0;
		while(n>=4)
		{
			n-=4;
			cnt1++;
		}
		while(n>=2)
		{
			n-=2;
			cnt2++;
		}
		if(cnt1+cnt2==x)
		{
			cout<<"Yes\n";
			return 0;
		}
		while(cnt1>0)
		{
			cnt1--;
			cnt2+=2;
			if(cnt1+cnt2==x)
			{
				cout<<"Yes\n";
				return 0;
			}
		}
		cout<<"No\n";
	}
	
   
	
}

Measured memory_bytes: 3648
//DoomsDay861.

#include<bits/stdc++.h>
#include<time.h>
#define ll long long
#define testcase ll t;cin>>t;while(t--)
using namespace std;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
using namespace std::chrono;
//freopen("in.txt","r",stdin);
//freopen("output.ans","w",stdout);
// auto start = high_resolution_clock::now(); 
 ll n, m;
 cin >> n >> m;
 if((500*n)>=m)
 cout << "Yes"<<endl;
 else
 cout <<"No"<<endl;
//	auto stop = high_resolution_clock::now(); 
//    auto duration = duration_cast<seconds>(stop - start); 
//cout << "Time taken by function: "
//         << duration.count() << "seconds" << endl; 
  
    return 0; 
} 


Measured memory_bytes: 256
#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 rep1(i,n) for(int i = 1; i <= (n); i++)
#define rrep1(i,n) for(int i = (n); i > 0; i--)

#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>

#define MOD 1000000007
#define INF 1000000000000000LL

using namespace std;

struct UnionFind {
  vector<int> data;

  UnionFind(int n){
    data.resize(n+1);
    fill(data.begin(), data.end(), -1);
  }

  int root(int x){
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }

  void unite(int x, int y){
    int rx=root(x);
    int ry=root(y);

    if(rx!=ry){
      if(data[ry] < data[rx])swap(rx, ry);

      data[rx]+=data[ry];
      data[ry]=rx;
    }
  }

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

  int size(int x){
    return -data[root(x)];
  }
};

int main(){
  ll n, m;cin>>n>>m;
  vector<ll> a(m), b(m);
  rep(i, m)cin>>a[i]>>b[i];
  UnionFind uf(n);
  ll unc=n*(n-1)/2;
  vector<ll>results;
  rrep(i, m){
    results.push_back(unc);
    if(!uf.same(a[i], b[i])){
      ll l = (ll)uf.size(a[i]);
      ll r = (ll)uf.size(b[i]);
      unc -= l*r;
      uf.unite(a[i], b[i]);
    }
  }
  rrep(i, m)cout<<results[i]<<endl;

  return 0;
}


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

int main(){
    using namespace std;
    unsigned long Q;
    cin >> Q;
    constexpr unsigned long M{205891132094649UL};
    const auto& calc = [](unsigned long a, unsigned long b, unsigned long c, unsigned long d) -> unsigned long {
        auto ub{b}, lb{b}, p{M};
        while(p /= 3)if(a / p % 3 == 1 || a / p * p + p * (1 + (a / p % 3 == 2)) <= c){
            if(ub / p % 3 == 1)ub = ub / (3 * p) * 3 * p + 2 * p;
            if(lb / p % 3 == 1)lb = lb / (3 * p) * 3 * p + p - 1;
        }
        return c - a + min(ub - b + max(ub, d) - min(ub, d), b + d - 2 * lb);
    };
    for(unsigned long _{0}, a, b, c, d; _ < Q; ++_){
        cin >> a >> b >> c >> d;
        if(--a > --c){
            swap(a, c);
            swap(b, d);
        }
        if(--b > --d){
            b = M - b - 1;
            d = M - d - 1;
        }
        cout << max(calc(a, b, c, d), calc(b, a, d, c)) << endl;
    }
    return 0;
}

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

#define int long long
#define rep(i, a, n) for (int i = a; i < n; i++)
#define pb push_back
#define eb emplace_back
#define dump(x) cout << #x << " = " << (x) << endl
#define chk() cout << "now" << endl;
#define ALL(x) (x).begin(), (x).end()
#define SORT(c) sort((c).begin(), (c).end())
#define SORTG(c) sort(ALL(c), greater<int>());
#define fi first
#define se second
int INF = 1e9 + 7;

typedef pair<int, int> P;
typedef vector<int> vi;

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 n;
vi p, q;

void solve() {
  cin >> n;

  rep(i, 0, n) {
    int a;
    cin >> a;
    p.pb(a);
    q.pb(a);
  }

  SORT(p);
  int ctn = 0;
  rep(i, 0, n) {
    if (p[i] != q[i]) {
      ctn++;
    }
  }
  if (ctn == 2 or ctn==0)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}

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

  // cout << fixed << setprecision(10);

  solve();

  return 0;
}


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

using namespace std;

int main()
{
    int n;
    cin >> n;
    int d[n];
    for (int i = 0; i < n; i++)
    {
        cin >> d[i];
    }
    sort(d, d + n);
    int a, b;
    a = d[n / 2];
    b = d[n / 2 - 1];
    cout << a - b << endl;
    return 0;
}

Measured memory_bytes: 640
var MAX = Math.pow(2, 31) - 1;

var data = [];
function init(n) {
    for (var i = 0; i < n * 2 - 1; i++) data[i] = MAX;
}
function find(s, t, k, l, r) {
    if (r <= s || t <= l) return MAX;
    if (s <= l && r <= t) return data[k];

    var mid = Math.floor((l + r) / 2);
    var lv = find(s, t, k * 2 + 1, l, mid);
    var rv = find(s, t, k * 2 + 2, mid, r);

    return Math.min(lv, rv);
}

var input = require('fs').readFileSync('/dev/stdin', 'utf8').trim();
var lines = input.split('\n');

var items = lines.shift().trim().split(' ');
var n = +items[0];
var q = +items[1];

var m = 1;
while (m < n) m *= 2;

function update(i, x) {
    i += m - 1;
    data[i] = x;
    while (i > 0) {
        i = Math.floor((i - 1) / 2);
        var c1 = data[i * 2 + 1];
        var c2 = data[i * 2 + 2];
        data[i] = Math.min(c1, c2);
    }
}

init(m);

var line;
while (line = lines.shift()) {
    var com = line.trim().split(' ').map(function(n){return +n;});
    if (com[0] == 0) {
        update(com[1], com[2]);
    } else {
        console.log(find(com[1], com[2] + 1, 0, 0, m));
    }
}

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

int main()
{
  int n;
  int cnt[7];

  while( cin >> n, n ) {
    fill_n(cnt, 7, 0);
    for(int i=0; i<n; i++) {
      int data;
      cin >> data;
      if( data >= 60 ) cnt[6]++;
      else if( data >= 50 ) cnt[5]++;
      else if( data >= 40 ) cnt[4]++;
      else if( data >= 30 ) cnt[3]++;
      else if( data >= 20 ) cnt[2]++;
      else if( data >= 10 ) cnt[1]++;
      else cnt[0]++;
    }

    for(int i=0; i<7; i++) cout << cnt[i] << endl;
  }

}
     

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
const double eps = 1e-10;
struct Node
{
    double x, y;
    Node(double xx = 0, double yy = 0){
        x = xx; y = yy;
    }

    Node operator + (Node b){
        return Node(x+b.x, y+b.y);
    }
    Node operator - (Node b){
        return Node(x-b.x, y-b.y);
    }
    Node operator * (double a){
        return Node(a*x, a*y);
    }
    Node operator / (double a){
        return Node(x/a, y/a);
    }

    double norm(){return x*x+y*y;}
    double len(){
        return sqrt(norm());
    }

    bool operator < (const Node &p) const{
        return x!=p.x ? x<p.x : y<p.y;
    }

    bool operator == (const Node &p) const {
        return fabs(x-p.x)<eps && fabs(y-p.y)<eps;
    }
};

typedef Node vtr;

struct line{
    Node a, b;
    line(Node x, Node y){
        a = x, b = y;
    }
};

//向量点积
double dot(vtr a, vtr b){
    return a.x*b.x+a.y*b.y;
}

//向量叉积
double cross(vtr a, vtr b){
    return a.x*b.y-a.y*b.x;
}

//投影 求垂足坐标
//点p在直线p1p2上的投影
Node project(line s, Node p)
{
    vtr base = s.b-s.a;
    double r = dot(p-s.a, base)/base.norm();
    return s.a+base*r;
}

//映象 求p以s为对称轴的对称点
Node reflect(line s, Node p){
    return p+(project(s, p)-p)*2.0;
}

int ccw(Node p0, Node p1, Node p2)
{
    vtr a = p1-p0;
    vtr b = p2-p0;
    if(cross(a, b) > eps) return 1;
    if(cross(a, b) < -eps) return -1;
    if(dot(a, b) < -eps) return 2;
    if(a.norm() < b.norm()) return -2;
    return 0;
}

int main()
{
    Node p0, p1, p2;
    cin>>p0.x>>p0.y>>p1.x>>p1.y;
    int q; scanf("%d", &q);
    while(q--)
    {
        cin >> p2.x >> p2.y;
        switch(ccw(p0, p1, p2))
        {
            case 1:cout<<"COUNTER_CLOCKWISE"<<endl; break;
			case -1: cout<<"CLOCKWISE"<<endl; break;
			case 2: cout<<"ONLINE_BACK"<<endl; break;
			case -2: cout<<"ONLINE_FRONT"<<endl; break;
			case 0: cout<<"ON_SEGMENT"<<endl; break;
        }
    }
    return 0;
}



Measured memory_bytes: 3284
#include<bits/stdc++.h>
#define REP(i,first,last) for(int i=first;i<=last;++i)
#define DOW(i,first,last) for(int i=first;i>=last;--i)
using namespace std;
inline int Read()
{
	int x(0),f(1);
	char c(getchar());
	while(c<'0'||'9'<c)
	{
		if(c=='-')
		{
			f=-1;
		}
		c=getchar();
	}
	while('0'<=c&&c<='9')
	{
		x=(x<<1)+(x<<3)+c-'0';
		c=getchar();
	}
	return f*x;
}
void Write(int x)
{
	if(x<0)
	{
		printf("-");
		x=-x;
	}
	if(9<x)
	{
		Write(x/10);
	}
	putchar(x%10+'0');
}
inline void Writeln(int x)
{
	Write(x);
	puts("");
}
struct Point
{
	double x,y;
	Point(double fx=0,double fy=0)
	{
		x=fx;
		y=fy;
	}
	void Read()
	{
		scanf("%lf%lf",&x,&y);
	}
	void Write(int len=2)
	{
		printf("%.9lf %.9lf",x,y);
	}
	double operator ^(Point const b)const
	{
		return x*b.x+y*b.y;
	}
	double operator |(Point const b)const
	{
		return x*b.y-b.x*y;
	}
	double operator ==(Point const b)const
	{
		return sqrt((x-b.x)*(x-b.x)+(y-b.y)*(y-b.y));
	}
	Point operator *(double const b)const
	{
		return Point(x*b,y*b);
	}
	Point operator +(Point const b)const
	{
		return Point(x+b.x,y+b.y);
	}
	Point operator -(Point const b)const
	{
		return Point(x-b.x,y-b.y);
	}
};
struct Vector
{
	Point a,b;
	Vector(Point f=Point(0,0),Point e=Point(0,0))
	{
		a=f;
		b=e;
	}
	double operator ^(Vector const c)const
	{
		return (a.x-b.x)*(c.a.x-c.b.x)+(c.a.y-c.b.y)*(a.y-b.y);
	}
	double operator |(Vector const c)const
	{
		return (a.x-b.x)*(c.a.y-c.b.y)-(c.a.x-c.b.x)*(a.y-b.y);
	}
};
Point p0,p1,p2;
const int MAXN=1e5+5;
void Work()
{
	p0.Read();
	double b=Vector(p1,p0)^Vector(p1,p2);
	double c=b;
	b/=(p1==p2)*(p1==p2);
	Point answer=(p2-p1)*b+p1;
	answer.Write();
	puts("");
}
int main()
{
	p1.Read();
	p2.Read();
	int q;
	scanf("%d",&q);
	REP(i,1,q)
	{
		Work();
	}
	return 0;
}


Measured memory_bytes: 3244
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<stack>
#include<cstring>
#include<utility>

#define int long long
using namespace std;
#define rep(i, n) for(int i=0;i<(n);++i)
typedef pair<int, int> pii;
const int INF = 1l << 60;
#define u_b upper_bound
#define l_b lower_bound

int N, K;
int A[1010];
int Asum[1010];
vector<int> Alr;

signed main() {
    cin >> N >> K;
    rep(i, N) {
        cin >> A[i];
        Asum[i + 1] = Asum[i] + A[i];
    }
    rep(l, N) {
        for (int r = l; r < N; ++r) {
            Alr.push_back(Asum[r + 1] - Asum[l]);
        }
    }

    sort(Alr.begin(), Alr.end());
    int ans = 0;

    for (int max_bit = (1l << 40); max_bit > 0; max_bit >>= 1) {
        auto tmp = lower_bound(Alr.begin(), Alr.end(), max_bit);
        int n = Alr.end() - tmp;
        if (n >= K) {
            ans |= max_bit;
            vector<int> Blr;
            rep(i, Alr.size()) {
                if (Alr[i] >= max_bit)Alr[i] -= max_bit;
            }
            copy(tmp, Alr.end(), back_inserter(Blr));
            swap(Alr, Blr);
        } else {
            rep(i, Alr.size()) {
                if (Alr[i] >= max_bit)Alr[i] -= max_bit;
            }
            sort(Alr.begin(), Alr.end());
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 6512
#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, const T& b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, const 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 main(){
    int a, b;
    cin >> a >> b;
    int now = 1;
    int cnt = 0;
    while(now < b){
        now = now - 1 + a;
        cnt++;
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
#51 ABC131E
n,k=map(int,input().split())
import sys
if k>(n-1)*(n-2)//2:
	print(-1)
	sys.exit()
res=[[1,i+1] for i in range(1,n)]
c=0
for i in range(1,n-1):
	for j in range(i+1,n):
		if c<(n-1)*(n-2)//2-k:
			res.append([i+1,j+1])
		c+=1
print(len(res))
for t in res:
	print(" ".join(map(str,t)))

Measured memory_bytes: 41968
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll, int> PL;
constexpr int mod = 1e9+7;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
// combination mod prime

struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
} comb(2000010);

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

  vector<mint> fac1(k + 1, 1), fac2(k + 1, 1);

  for (int i = 0; i < k; i++) {
    fac1[i + 1] = fac1[i] * 25;
    fac2[i + 1] = fac2[i] * 26;
  }
  mint res = 0;
  int n = s.size();
  for (int i = 0; i <= k; i++) {
    res += fac1[i] * comb(i + n - 1, n - 1) * fac2[k - i];
  }
  cout << res.x << endl;
  return 0;
} 

Measured memory_bytes: 51244
k = int(input())
a = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(a[k-1])

Measured memory_bytes: 38256
import java.util.*;

public class Main {
    static TreeSet<Integer> all = new TreeSet<>();
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextLine().charAt(0) - '0';
		int[] base = new int[n];
		for (int i = 0; i < n; i++) {
		    base[i] = i + 1;
		}
		make(0, 0, base, n);
		StringBuilder sb = new StringBuilder();
		for (int x : all) {
		    sb.append(toString(x, n)).append("\n");
		}
		System.out.print(sb);
	}
	
	static void make(int value, int mask, int[] base, int size) {
	    if (mask == (1 << size) - 1) {
	        all.add(value);
	        return;
	    }
	    value *= 10;
	    for (int i = 0; i < size; i++) {
	        if ((mask & (1 << i)) != 0) {
	            continue;
	        }
	        make(value + base[i], mask | (1 << i), base, size);
	    }
	}
	
	static char[] toString(int x, int size) {
	    char[] ans = new char[size * 2 - 1];
	    Arrays.fill(ans, ' ');
	    int idx = ans.length - 1;
	    for (int i = 0; i < size; i++) {
	        ans[idx] = (char)(x % 10 + '0');
	        x /= 10;
	        idx -= 2;
	    }
	    return ans;
	}
}



Measured memory_bytes: 103864
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i8 = int8_t;
using i16 = int16_t;
using i32 = int32_t;
using i64 = int64_t;

constexpr char newl = '\n';
constexpr double eps = 1e-10;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
#define fi first
#define se second
#define debug(x) cout << #x << ": " << x << '\n';
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

template<typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
template<class T> void Print(vector<T> v) {
  F0R(i, v.size()) {
    cout << v[i] << ' ';
  }
  cout << newl;
}

#if 1


// INSERT ABOVE HERE
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int a, b, t;
  cin >> a >> b >> t;
  cout << (t / a * b);
}
#endif


Measured memory_bytes: 3576
#include <bits/stdc++.h>
#define int long long 
#define pb push_back
#define MAX 10000005
#define mod 1000000007
#define sp fixed<<setprecision(12)
using namespace std;
/*
vector<int> primes;
ll sumprime[MAX];
bool is_prime[MAX];
void sieve(){
	is_prime[0]=is_prime[1]=true;
	for(int i=4;i<MAX;i+=2){
		is_prime[i]=true;
	}
	for(int i=3;i*i<MAX;i+=2){
		if(!is_prime[i]){
			for(int j=i*i;j<MAX;j+=i){
				is_prime[j]=true;
			}
		}
	}
	for(int i=0;i<MAX;i++){
		if(!is_prime[i]){
			sumprime[i]=sumprime[i-1]+i;
		}else{
			sumprime[i]=sumprime[i-1];
		}
	}
}
*/


int32_t main(){

	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
	//double	pi=3.14159265358979323846;
	//sieve();
	
	
	int a,b,c,d,t;
	cin>>a>>c;
	cin>>b>>d;
	cin>>t;
	int ans1=abs(a-b);
	int ans2=(c-d)*t;
	if(ans2>=ans1){
		cout<<"YES\n";
	}else{
		cout<<"NO\n";
	}
	
	return 0;
	
}

Measured memory_bytes: 3640
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <list>
#include <algorithm>
#include <set>
#include <queue>

using namespace std;
#define ll long long
#define  mod 1000000007

long long binpow(long long a, long long b, long long m) {
    a %= m;
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("aa_input.txt", "r", stdin);
    int t=1;
    //cin>>t;
    while (t--)
    {
       int a, b, c, d;
       cin>>a>>b>>c>>d;
       int m = 0;
       while(a>0 && c>0){
          if(m == 0){
              c -= b;
              m = m ^ 1;

          }
          else{
              a -= d;
              m = m ^ 1;
          }
       }

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

    }
    
    return 0;
}
/*

riaadmorshed@gmail.com

*/

Measured memory_bytes: 3648
import sys
import math

def is_capable(n, k, w, P):
    track = 0
    cnt = 0
    i = 0

    while cnt < k:
        if i == n:
            return i

        if track + w[i] > P:
            track = 0
            cnt += 1
        else:
            track += w[i]
            i += 1

    return i
    pass

# ??\?????¨
n, k = map(int, sys.stdin.readline().split())
w = []
for i in range(n):
    w.append(int(sys.stdin.readline().strip()))

'''
print(n,k)
print(w)
'''

# ????????¨

if k == 1:
    ans = sum(w)
    print(ans)
elif n == 1:
    ans = w[0]
    print(ans)
else:
    max_p = sum(w)
    min_p = math.ceil(max_p / k) - 1

    # print(max_p, min_p)
    # sys.exit(0)
    
    bottom = min_p
    top = max_p

    while top - bottom > 1:
        mid = (bottom + top) // 2

        if is_capable(n, k, w, mid) == n:
            top = mid
        else:
            bottom = mid

    print(top)

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

namespace AtCoder
{

    class Program
    {
        static void Main()
        {
            //ここから
            int[] str = new int[6];
            for(int i = 0; i < 6; i++)
            {
                str[i] = IO.ReadLineToInt();
            }

            string ans = "Yay!";

            for(int i = 0; i < 5; i++)
            {
                for(int j = 0; j < 5; j++)
                {
                    if (Math.Abs(str[i] - str[j]) > str[5])
                    {
                        ans = ":(";
                    }
                }
            }

            Console.WriteLine(ans);
            Console.ReadKey();
        }
    }

    class Func
    {
        long mod = 1000000007;
        static public void Swap<T>(ref T a, ref T b) { T temp = a; a = b; b = temp; }
        static public long GCD(int a, int b) { return b != 0 ? GCD(b, a % b) : a; }
        static public long LCM(int a, int b) { return (long)a * b / GCD(a, b); }
        static public int Factorial(int a) { return a == 1 ? a : a * Factorial(a - 1); }
        static public int Conbin(int n, int m) { return Factorial(n) / (Factorial(n - m) * Factorial(m)); }
        static public void Factoring(long num, ref long[] vs)
        {
            if (num == 1)
            {
                vs[1]++;
            }
            for (long i = 2; i < (long)Math.Sqrt(num); i++)
            {
                if (num % i == 0)
                {
                    vs[i]++;
                    Factoring(num / i, ref vs);
                }
            }
            vs[1]++;
        }
    }

    class IO
    {
        static public string ReadLineToString() { return Console.ReadLine(); }
        static public int ReadLineToInt() { return int.Parse(Console.ReadLine()); }
        static public long ReadLineToLong() { return long.Parse(Console.ReadLine()); }
        static public string[] ReadLineToStringArray() { return Console.ReadLine().Split(' ').ToArray(); }
        static public int[] ReadLineToIntArray() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
        static public long[] ReadLineToLongArray() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
        static public List<string> ReadLineToStringList() { return Console.ReadLine().Split(' ').ToList(); }
        static public List<int> ReadLineToIntList() { return Console.ReadLine().Split(' ').Select(int.Parse).ToList(); }
        static public List<long> ReadLineToLongList() { return Console.ReadLine().Split(' ').Select(long.Parse).ToList(); }
    }
}

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

ll power(ll x, ll y){
    ll res = 1;
    if(y > 0){
        res = power(x, y / 2);
        if(y % 2 == 0){
            res = (res * res) % t;
        }
        else{
            res = (((res * res) % t) * x) % t;
        }
    }
    return res;
}

int main(){
    ll N, ans;
    cin >> N;
    ans = power(10, N) - 2 * power(9, N) + power(8, N);
    ans = ans % t;
    ans = (ans + t) % t;
    cout << ans << endl;
    return 0;  
}

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

int main(){
    using namespace std;
    unsigned long N, P, Q;
    cin >> N >> P >> Q;
    vector<long> C(N);
    for(auto& i : C)cin >> i;
    
    vector<long> D(N);
    for(size_t i = 0; i < N; ++i)D[i] = (Q - i) * P - C[i];
    sort(D.rbegin(), D.rend());
    
    long ans{accumulate(C.begin(), C.end(), 0L)}, ad{ans};
    for(unsigned long k = 0; k < N; ++k)ans = max(ad += 2 * k * P + D[k], ans);
    
    cout << ans << endl;
}


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

string get_longer(string s, string t) {
  if (s.length() >= t.length()) {
    return s;
  } else {
    return t;
  }
}
int main() {
  string s, t;
  cin>>s>>t;

  int n = s.length();
  int m = t.length();
  int dp[n][m];
  if (s[0] == t[0]) {
    dp[0][0] = 1;
  } else {
    dp[0][0] = 0;
  }
  for (int i=1; i<m; i++) {
    dp[0][i] = dp[0][i-1];
    if (s[0] == t[i]) {
      dp[0][i] = 1;
    }
  }
  for (int i=1; i<n; i++) {
    dp[i][0] = dp[i-1][0];
    if (t[0] == s[i]) {
      dp[i][0] = 1;
    }
  }
  for (int i=1; i<n; i++) {
    for (int j=1; j<m; j++) {
      if (s[i] == t[j]) {
        dp[i][j] = max(dp[i-1][j], max(dp[i][j-1], dp[i-1][j-1] + 1));
      } else {
        dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
      }
    }
  }

  int max_idx_t = m - 1;
  int len = dp[n-1][m-1];
  string ans = "";
  for (int i=n-1; i>=0; i--) {
    for (int j=max_idx_t; j>=0; j--) {
      if (dp[i][j] != len) {
        break;
      }
      if (i == 0 && j == 0 && dp[0][0] == 1) {
        ans = s[0] + ans;
        break;
      }
      if (i == 0 && dp[i][j-1] < len) {
        ans = s[i] + ans;
        break;
      }
      if (j == 0 && dp[i-1][j] < len) {
        ans = s[i] + ans;
        max_idx_t = j - 1;
        --len;
        break;
      }
      if (dp[i-1][j] < len && dp[i][j-1] < len) {
        ans = s[i] + ans;
        max_idx_t = j - 1;
        --len;
        break;
      }
    }
  }

  cout<<ans<<endl;
}

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

int main() {
	int64_t w, h; cin >> w >> h;
	vector<pair<int64_t, int>> v(w + h);
	for(int i = 0; i < w + h; ++i) {
		int64_t a; cin >> a;
		v[i] = {a, i < w};
	}
	sort(v.begin(), v.end());
	int64_t wcnt = w + 1, hcnt = h + 1;
	int64_t ans = 0;
	for(auto e : v) {
		int64_t cost, flg;
		tie(cost, flg) = e;
		if(flg) {
			ans += hcnt * cost;
			--wcnt;
		} else {
			ans += wcnt * cost;
			--hcnt;
		}
	}
	cout << ans << '\n';
	return 0;
}


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

int main() {
    int a[5], k;
    cin >> a[0] >> a[1] >> a[2] >> a[3] >> a[4] >> k;
    REP(i, 4) {
        for(int j = i+1; j < 5; j++) {
            if((a[j] - a[i]) > k) {
                puts(":(");
                return 0;
            }
        }
    }
    puts("Yay!");
}

Measured memory_bytes: 256
def gcd(x, y):
    if y == 0:
        return x
    return gcd(y, x%y)

def lcm(x, y):
    if x < y:
        z = x
        x = y
        y = z
    return x / gcd(x, y) * y

print(int(lcm(int(input()), 2)))


Measured memory_bytes: 2940
#include <vector>
#include <stack>
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <queue>

#include <cmath>
#include <cstdio>

using namespace std;


int main(int argc,char **argv){
	
	size_t N;
	cin >> N;
	vector<long> A(N+2);

	A[0]=-1;
	for(size_t i=1;i<N+1;++i){
		cin >> A[i];
	}
	A[N+1]=A[N];

	long long sum=0;
	for(size_t i=1;i<A.size();++i){
		if(A[i]>A[i-1]+1){
			sum=-1;
			break;
		}else if(A[i]<=A[i-1]){
			sum += A[i-1];
		}
	}
	cout << sum << endl;

	return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include<stdio.h>
#include <cstdint>
#include <stdlib.h> 
#include <time.h>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rrep(i,n) REP(i,1,n+1)
#define all(a) a.begin(), a.end()
#define fi first
#define se second
#define RNG(x, a, n) &((x)[a]), &((x)[n])
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> PII;
typedef vector<ll> Vl;
typedef vector<int> VI;
typedef tuple<int, int, int> TT;
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define dmt(x, y, z) make_tuple(x, y, z)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
const int MAX = 500000;
const int inf = 1000000007;
const ll mod = 998244353;
const long double PI = (acos(-1));
const long double EPS = 0.0000000001;

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


int n, m, ans;
string b[105], r[105];
map<string, int> mp;

int main() {

	cin >> n;
	rep(i, n) {
		cin >> b[i];
		mp[b[i]]++;
	}
	cin >> m;
	rep(i, m) {
		cin >> r[i];
		mp[r[i]]--;
	}

	for (auto& x : mp) {
		ans = max(ans, x.se);
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256