akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <numeric>

using namespace std;
typedef long long ll;

bool can_reach(const string &S, int N, int x, int y) {
  char prev = '.';
  for (int i = x+1; i <= y; i++) {
    if (prev == '#' && S[i-1] == '#')
      return false;
    prev = S[i-1];
  }
  return true;
}

bool solve(const string &S, int N, int A, int B, int C, int D) {
  if (!can_reach(S, N, A, C))
    return false;
  if (!can_reach(S, N, B, D))
    return false;
  if (C < D)
    return true;
  for (int i = B; i <= D; i++) {
    if (S[i-2] == '.' && S[i-1] == '.' && S[i] == '.') {
      return true;
    }
  }
  return false;
}

int main() {
  int N, A, B, C, D;
  string S;
  cin >> N >> A >> B >> C >> D;
  cin >> S;
  bool ans = solve(S, N, A, B, C, D);
  cout << (ans ? "Yes" : "No") << endl;
}


Measured memory_bytes: 640
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

const ll inf = (ll)1e9;
const ll mod = (ll)1e9 + 7;

int main()
{
	ll n, a, b, c, d, e;
	cin >> n >> a >> b >> c >> d >> e;

	ll m = min({a, b, c, d, e});

	ll x = (n - 1) / m;

	cout << 5 + x << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define REP(i,st,ed) for(int i=(int)(st),i##end=(int)(ed);i<=i##end;++i)
#define DREP(i,st,ed) for(int i=(int)(st),i##end=(int)(ed);i>=i##end;--i)
template<typename T>bool chkmin(T &x,const T &y){return x>y?x=y,1:0;}
template<typename T>bool chkmax(T &x,const T &y){return x<y?x=y,1:0;}
#ifdef __linux__
#define getchar getchar_unlocked
#define putchar putchar_unlocked
#endif
template<typename T>T read(){
	T x=0,f=1;
	char c=getchar();
	while((c<'0')||(c>'9')){if(c=='-')f=-1;c=getchar();}
	while((c>='0')&&(c<='9'))x=(x<<1)+(x<<3)+(c^48),c=getchar();
	return x*f;
}
#define read() read<int>()
template<typename T>void write(T x,char c){
	static char t[25];
	static int tlen;
	t[tlen=1]=c;
	if(x<0)putchar('-'),x=-x;
	do t[++tlen]=(x%10)^48;
	while(x/=10);
	while(tlen)putchar(t[tlen--]);
}
#define pb push_back
typedef long long ll;
typedef double lf;
const int maxn=200005,mod=924844033;
int n;
int fac[maxn],ifac[maxn],sz[maxn],ans[maxn];
int N,A[maxn*3],B[maxn*3],rev[maxn*3],pw[20][2];
vector<int>E[maxn];
int ksm(int x,int y){
	int res=1;
	while(y){
		if(y&1)res=1ll*res*x%mod;
		x=1ll*x*x%mod,y>>=1;
	}return res;
}
void init(){
	fac[0]=1;
	REP(i,1,n)fac[i]=1ll*fac[i-1]*i%mod;
	ifac[n]=ksm(fac[n],mod-2);
	DREP(i,n,1)ifac[i-1]=1ll*ifac[i]*i%mod;
}
void dfs(int u,int fa){
	sz[u]=1;
	REP(i,0,E[u].size()-1){
		int v=E[u][i];
		if(v==fa)continue;
		dfs(v,u);
		sz[u]+=sz[v];
		A[sz[v]]++,A[n-sz[v]]++;
	}
}
void dft(int *y,int n,int flag){
	REP(i,0,n-1)
		if(rev[i]>i)swap(y[i],y[rev[i]]);
	for(int k=2,l=1;k<=n;k<<=1,l++)
		for(int i=0;i<n;i+=k)
			for(int j=0,x=1,wn=pw[l][flag];j<(k>>1);j++,x=1ll*x*wn%mod){
				int y0=y[i+j],y1=1ll*x*y[i+j+(k>>1)]%mod;
				y[i+j]=(y0+y1)%mod,y[i+j+(k>>1)]=(y0+mod-y1)%mod;
			}
}
void ntt(int *A,int *B,int n){
	REP(i,0,n-1)
		rev[i]=(rev[i>>1]>>1)^((i&1)*(n>>1));
	for(int k=2,l=1;k<=n;k<<=1,l++){
		pw[l][0]=ksm(5,(mod-1)/k);
		pw[l][1]=ksm(pw[l][0],mod-2);
	}
	dft(A,n,0),dft(B,n,0);
	REP(i,0,n-1)A[i]=1ll*A[i]*B[i]%mod;
	dft(A,n,1);
	int revn=ksm(n,mod-2);
	REP(i,0,n-1)A[i]=1ll*A[i]*revn%mod;
}
int main(){
	int u,v;
	n=read();
	init();
	REP(i,1,n-1){
		u=read(),v=read();
		E[u].pb(v),E[v].pb(u);
	}
	dfs(1,0);
	REP(i,0,n)A[i]=1ll*A[i]*fac[i]%mod,B[i]=ifac[i];
	reverse(A,A+1+n);
	N=1;
	while(N<=2*n)N<<=1;
	ntt(A,B,N);
	REP(i,1,n){
		ans[i]=1ll*(n)*fac[n]%mod*ifac[i]%mod*ifac[n-i]%mod;
		ans[i]=(ans[i]+mod-1ll*A[n-i]*ifac[i]%mod)%mod;
	}
	REP(i,1,n)write(ans[i],'\n');
	return 0;
}

Measured memory_bytes: 36480
#include <cstdio>
#include <cmath>
#include <algorithm>
using namespace std;

int main(void) {
    int a, b, c;
    while(scanf("%d%d%d", &a, &b, &c) != EOF) {
        if(a < b) swap(a, b);
        if(a < c) swap(a, c);
        if(a == b + c) {
            printf("Yes\n");
        }
        else {
            printf("No\n");
        }
    }
    return 0;
}


Measured memory_bytes: 128
def main():
    N,K = map(int,input().split())
    XY = [list(map(int,input().split())) for _ in [0]*N]
    XY.sort()
    
    iX = [x for x,y in XY]
    iY = [y for x,y in XY]
    iY.sort()
    X = {x:i for i,x in enumerate(iX)}
    Y = {y:i for i,y in enumerate(iY)}

    c = [[0]*(N+1) for i in [0]*(N+1)]
    for x,y in XY:
        c[Y[y]+1][X[x]+1] = 1

    for i in range(N):
        ci1 = c[i+1]
        for j in range(N):
            ci1[j+1] += ci1[j]
    for i in range(N):
        ci1 = c[i+1]
        ci = c[i]
        for j in range(N):
            ci1[j+1] += ci[j+1]

    ans = 10**20
    for u in range(N):
        for d in range(u+K-1,N):
            l = 0
            r = K-1
            dY = iY[d]-iY[u]
            cd = c[d+1]
            cu = c[u]
            while r<N:
                if cd[r+1]+cu[l]-cu[r+1]-cd[l] >=K:
                    ans = min(ans, (iX[r] - iX[l])*dY)
                    l+=1
                else:r+=1

    print(ans)
main()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, a, b) for(int i = a; i < b; i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fi first
#define se second
#define debug(x) cerr <<__LINE__<< ": " <<#x<< " = " << x << endl
#define debug_vec(v) cerr<<__LINE__<<": "<<#v<<" = ";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
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; }
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

void solve() {
    int a, b, c;
    cin >> a >> b >> c;
    if (a + b + c >= 22) {
        cout << "bust" << endl;
    } else {
        cout << "win" << endl;
    }
}

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


Measured memory_bytes: 3620
#include <stdio.h>

int main(void) {
  int i, j, k, n, cnt = 0;
  scanf("%d", &n);
  for(i = 0; i < n; ++i) {
    scanf("%d", &j);
    if(j != i + 1) cnt++;
  }
  if(cnt >= 3) printf("NO");
  else printf("YES");
  return 0;
}

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

int main() {
    int N, X, Y;
    cin >> N >> X >> Y;
    int A[2200];
    X = X- 1;
    Y = Y -1;
    for (int i = 0; i < N; i++) A[i] = 0;

    for(int i = 0; i < N; i++) {
        for(int j = 0; j < i; j++) {
            if (abs(i -j) > (abs(j -X) + abs(i -Y) + 1)) {
                A[abs(j -X) + abs(i -Y) + 1] += 1;
            } else {
                A[abs(i -j)] += 1;
            }
        }
    }

    for(int i = 1; i < N; i++) {
        cout << A[i] << "\n";
    }
    return 0;
}

Measured memory_bytes: 256
N = int(input())
list_A = list(map(int,input().split()))
flag = 0
count = 0

while(True):
    for i in range(N):
        if list_A[i] % 2 != 0:
            flag = 1
    if flag == 0:
        list_A = list(map(lambda x: x/2 , list_A))
        count += 1
    else:
        break


print(count)




Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
int n;
int a[51];
int main(){
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	sort(a,a+n);
	double ans=a[0];
	for(int i=1;i<n;i++){
		ans=(ans+(double)(a[i]))/2;
	}
	cout<<ans;
	return 0;
}

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

namespace CSharp_AtCoder
{

    class Program
    {
        static int N;
        static List<int>[] edges;
        static int[] d;
        static bool[] find;

        static void BFS()
        {
            Queue<int> que = new Queue<int>();
            que.Enqueue(0);
            find[0] = true;

            while(que.Count != 0)
            {
                int from = que.Dequeue();
                //Console.WriteLine($"from:{from}");
                foreach(var to in edges[from])
                {
                    if (!find[to])
                    {
                        que.Enqueue(to);
                        find[to] = true;
                    }

                    // from -> to の更新処理
                    // -1 or d[from] + 1 < d[to] で更新
                    if(d[to] == -1 || d[from] + 1 < d[to])
                    {
                        d[to] = d[from] + 1;
                    }                   
                }
            }

        }
        
        static void Main(string[] args)
        {
            // 入力
            N = int.Parse(Console.ReadLine());

            // 初期化
            edges = new List<int>[N];
            d = new int[N];
            find = new bool[N];
            for (int i = 0; i < N; i++)
            {
                edges[i] = new List<int>();
                d[i] = -1;
            }
            d[0] = 0;        

            // 隣接リスト生成
            // u k v(1) ... v(k)
            for(int i = 0; i < N; i++)
            {
                int[] input = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
                int from = input[0] - 1;
                int k = input[1];
                for(int j = 0; j < k; j++)
                {
                    edges[from].Add(input[j + 2] - 1);
                }
            }

            BFS();

            // 出力
            for(int i = 0; i < N; i++)
            {
                Console.WriteLine($"{i + 1} {d[i]}");
            }

        }
    }
}



Measured memory_bytes: 16784
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <functional>
#include <ctime>
#include <cmath>
#include <limits>
#include <numeric>
#include <type_traits>
using namespace std;
using ll = long long;

unsigned euclidean_gcd(unsigned a, unsigned b) {
    if (a < b) return euclidean_gcd(b, a);
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

class UnionFind {
public:
    vector <ll> par;
    vector <ll> siz;
    UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    ll root(ll x) {
        while (par[x] != x) {
            x = par[x] = par[par[x]];
        }
        return x;
    }
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) {
        return root(x) == root(y);
    }

    ll size(ll x) {
        return siz[root(x)];
    }
};

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}

int main() {
    ll a,b;
    cin >> a >> b;
    int mn = 0;
    int mx = 100000000;
    for (int i = 0; i < b; i++) {
        int x, y;
        cin >> x >> y;
        mn = max(mn, x);
        mx = min(mx, y);
    }
    cout << max(0, mx - mn + 1) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define vi vector<int>
#define vll vector<long long>
#define FOR(n) for(int i=0;i<n;i++)
#define till(n) for(int i=1;i<=n;i++)
#define mod 1000000007
using namespace std;

ll u[101], v[101];

ll dp[101][100001];

ll getAns(int n, int w){
    if(n==0) return 0;
    if(w==0) return 0;

    if(dp[n][w]!=-1) return dp[n][w] ;

    ll x = 0,y = 0;

    if(w >= u[n])
    x = getAns(n-1, w-u[n]) + v[n];

    y = getAns(n-1, w);

    return dp[n][w] = max(x, y);
}

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

    int n, w;cin>>n>>w;

    for(int i=0;i<=n;i++){
        for(int  j=0;j<=w;j++)
            dp[i][j] = -1;
    }

    for(int i=1;i<=n;i++) cin >> u[i] >> v[i];

    cout << getAns(n, w) << endl;

	return 0;
}


Measured memory_bytes: 79232
n, m = map(int, input().split())
a = []
for i in range(n):
    a.append(list(map(int, input().split())))
l = [0] * m
for i in range(n):
    for j in range(m):
        if j + 1 in a[i][1:]:
            l[j] += 1
count = 0
for i in range(m):
    if l[i] == n:
        count += 1
print(count)

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

int main(void) {
	long long X;
	scanf("%lld", &X);
	long long ans = 0;
	long long deposit = 100;
	while (deposit < X) {
		deposit += deposit / 100;
		ans++;
	}

	printf("%lld", ans);

	return 0;
}


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

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

	vector<bool> al(26);
	rep(i, 26) al.at(i) = false;

	rep(i, s.size()){
		al.at(s.at(i) -'a') = true;
	}
	
	rep(i, 26){
		if(!al.at(i)){
			cout << (char)(i+'a') << endl;
			return 0;
		}
	}
	cout << "None" << endl;
	return 0;
}

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

int main(){
    int N;
    cin >> N;
    vector<int> V(N), C(N);
    for (int i=0;i<N;i++)
        cin >> V[i];
    for(int i=0;i<N;i++)
        cin >> C[i];
    int ans = 0;
    for (int i=0;i<N;i++){
        if (V[i] - C[i] >0)
            ans += V[i]-C[i];
    }
    cout << ans << endl;
}

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

using ll = long long;
#define mod 1000000007
#define init ios::sync_with_stdio(0), cin.tie(0);
typedef vector<int> vi;
typedef pair<int, int> pi;
#define MS(x, y) memset(x, y, sizeof(x))
#define F first
#define S second
#define PB push_back
#define MP make_pair

int main()
{
    init;

    int k;
    cin>>k;

    if(k%2==0||k%5==0)
        cout<<-1;
    else{
        ll n=7;
        int cnt=1;
        while(n%k!=0){
            cnt++;
            n*=10;
            n+=7;
            n%=k;
         //   cout<<n<<' ';
        }
        cout<<cnt;
    }        

    
}

Measured memory_bytes: 3600
#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];
  int ans = 0;
  for(int i = 0; i < N; i++){
    for(int j = i + 1; j < N; j++) ans = max(ans, abs(a[j] - a[i]));
  }
  cout << ans << endl;
}

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

class KMPSearch {
private:
    std::string T;

public:
    std::vector<int> border;
    // S[0,border[i]-1]はS[0,i-1]の接頭辞かつ接尾辞
    // かつS[border[i]] != S[i]を満たす

    KMPSearch(std::string T) : T(T), border(T.length() + 1, -1) {
        int j = -1;  // border[i+1]を指す
        for (int i = 0; i < T.length(); ++i) {
            while (j >= 0 && T[i] != T[j]) j = border[j];
            ++j;
            if (i + 1 < T.length() && T[i + 1] == T[j]) {
                border[i + 1] = border[j];
            } else {
                border[i + 1] = j;
            }
        }
    }

    std::vector<int> search(std::string S) {
        std::vector<int> ret;
        int j = 0;
        for (int i = 0; i + T.length() - 1 < S.length();) {
            for (; j < T.length(); ++j) {
                if (S[i + j] != T[j]) break;
            }
            if (j == T.length()) ret.push_back(i);
            // T[0,j-1]は一致している
            // よってj-border[j]ずらせる
            i += j - border[j];
            // このとき既にT[0,border[j]-1]は一致している
            j = std::max(0, border[j]);
        }
        return ret;
    }
};

int main() {
    std::string S, T;
    std::cin >> S >> T;
    KMPSearch kmps(T);
    auto ans = kmps.search(S);
    for (auto i : ans) std::cout << i << std::endl;
    return 0;
}



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

typedef vector<int> vec;
typedef vector<vec> mat;

void add(vector<deque<int> >& v, int x, int y) {
    int next_y = -1;
    if (v[x].size()) {
        next_y = v[x].front();
        v[x].pop_front();
    }
    v[x].push_back(y);
    if (next_y > -1) {
        if (v[next_y].size() == 0) return ;
        int next_x = v[next_y].front();
        v[next_y].pop_front();
        add(v, next_x, next_y);
    }
}

int main() {
    int N;
    cin >> N;
    vector<int> u(N), d(N), q(N);
    for (int i = 0; i < N; i++) {
        string str;
        cin >> u[i] >> str >> d[i];
        if (str == "wait") q[i] = 1;
        u[i] += 99;
        d[i]--;
    }

    vector<deque<int> > v(200);
    bool ans = false;
    for (int i = 0; i < N; i++) {
        if (q[i]) {
            v[d[i]].push_back(u[i]);
        } else {
            add(v, u[i], d[i]);
        }

        for (int j = 100; j < 200; j++) {
            if (v[j].size() == 0) continue;
            vector<bool> used(200, false);
            queue<int> que;
            que.push(v[j].front());
            used[j] = true;
            while (que.size()) {
                int now = que.front(); que.pop();
                if (now == j) {
                    ans = true;
                    goto FAILURE;
                }
                for (auto k : v[now]) que.push(k);
                if (used[now]) break;
                used[now] = true;
            }
        }
    }

  FAILURE:

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3356
#include<stdio.h>
#include <stdlib.h>
#include<string.h>
#include<math.h>
#define loop(i, l, r) for(i=l; i<r; i++)/*Instead of function, (for).*/
#define rep(i,r) for(i=0; i<r; i++)
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) < (b) ? (a) : (b))
typedef long long int lli;
/*Return Combination ,(nCr)*/
int combi(int n, int r)
{
	if(r==0 || r==n) return 1;
	else return combi(n-1,r) + combi(n-1,r-1);
}
/*Return gcd(a, b)*/
int gcd(int a, int b){
	if(b == 0) return a;
	else return gcd(b, a % b);
}
int main(void)
{
	int a, b, k=1, cut = 0;
	scanf("%d%d", &a, &b);
	
	while(k < b){
		k += a-1;
		cut++;
	}
	printf("%d", cut);
	return 0;
}

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

using namespace std;

using ll = long long;

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

const double EPS = 1e-5;
const int MOD = 1e9+7;

double func(int *a, int n){
  double mother = 0.0;

  repn(i,n){
    mother += 1.0 / a[i];
  }

  return 1.0 / mother;
}

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

  int *a = new int[n];

  repn(i,n){
    cin >> a[i];
  }

  printf("%16.14f", func(a, n));

  return 0;

}


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))[::-1]

if len(a) == 1 and a[0] == 1:
    ans = 0
else:
    ans = 0
    i = 1
    while len(a):
        ai = a.pop()
        if ai == i:
            i += 1
        else:
            ans += 1
    if i == 1:
        ans = -1
print(ans)




Measured memory_bytes: 26268
#include<iostream>
#include<fstream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cstring>

using namespace std;
long long a,b;
int main()
{
	cin>>a>>b;
	if(a>b)swap(b,a);
	if(a>0)
	{
		cout<<"Positive";return 0;
	}
	if(a<=0&&b>0||a==0)
	{
		cout<<"Zero";return 0;
	}
	else
	if(((abs(b)-abs(a)+1)%2==0))
	{
		cout<<"Positive";return 0;
	}
	else
	cout<<"Negative";
	return 0;
}

Measured memory_bytes: 256
from sys import stdin, stdout

def main():
	H, N = (int(x) for x in stdin.readline().split())
	moves = [int(dmg) for dmg in stdin.readline().split()]
	if sum(moves) >= H:
		stdout.write("Yes")
	else:
		stdout.write("No")

if __name__ == "__main__":
	main()

Measured memory_bytes: 13272
#include <iostream>
#include <vector>

using namespace std;

int main() {
    int N;
    cin >> N;
    vector<long long int> b(N);
    for(int n=0; n<N; n++) {
        long long int a;
        cin >> a;
        if(n%2) {
            b[N/2-n/2-1]=a;
        } else {
            b[N/2+n/2]=a;
        }
    }
    if(N%2==0) {
        for(int n=0; n<N; n++) {
            cout << b[n] << " ";
        }
    } else {
        for(int n=N-1; n>=0; n--) {
            cout << b[n] << " ";
        }
    }
    cout << endl;


    return 0;
    
}

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

const double PI = 3.14159265358979323846;
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//typedef pair<ll, ll> P;
typedef pair<double, double> P;
const ll INF = 1e15;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

std::istream &operator>>(std::istream &in, set<int> &o) {
    ll a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
const int mod = 1000000007;
//const ll mod = 1e10;
typedef priority_queue<string, vector<string>, greater<string> > PQ_ASK;

struct Attack {
    int attack, magic_point;
};

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

    vector<Attack> attacks(n);
    rep(i, n) cin >> attacks[i].attack >> attacks[i].magic_point;

    vector<int> stamina(h + 1, INT_MAX);
    stamina[0] = 0;

    auto set = [&](int now, int attack, int magic_point) {
        int next = now + attack;
        int now_magic_point = stamina[now];
        if (now_magic_point == INT_MAX) return;
        if (next > h) {
            next = h;
        }
        if (now_magic_point + magic_point >= stamina[next]) {
            return;
        }
        stamina[next] = now_magic_point + magic_point;
    };

    for (int i = 0; i <= h; i++) {
        for (Attack &a : attacks) {
            set(i, a.attack, a.magic_point);
        }
    }

    cout << stamina.back() << endl;

}


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

using namespace std;

int main(void){
  int N, M;
  cin >> N >> M;
  int ans = 0;
  for(int i = 1; i * i <= M; i++){
    if(M % i == 0){
      if(i >= N) ans = max(ans, M / i);
      if(M / i >= N) ans = max(ans, i);
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int n1,n2,m1,m2,A,B,C,D;

int main(){
	cin>>n1>>n2>>m1>>m2>>A>>B>>C>>D;
	int a=n1*A+n2*B+n1/10*C+n2/20*D,b=m1*A+m2*B+m1/10*C+m2/20*D;
	if(a>b) cout<<"hiroshi"<<endl;
	else if(a<b) cout<<"kenjiro"<<endl;
	else cout<<"even"<<endl;
}


Measured memory_bytes: 3088
# https://atcoder.jp/contests/abc060/tasks/abc060_a

import itertools
import collections
import bisect

def main():
    A, B, C = input().split()
    print('YES' if A[-1] == B[0] and B[-1] == C[0] else 'NO')

if __name__ == '__main__':
    main()


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

const int N = 5500;

long long dp[55][N];

int main() {
	
	ios::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);
	
	int n, A; cin >> n >> A;
	dp[0][0] = 1;
	for (int i = 1; i <= n; i++) {
		int x; cin >> x;
		for (int j = i; j >= 1; j--) {
			for (int s = N - 1; s >= 0; s--) if (dp[j - 1][s]) {
				if (s + x < N) dp[j][s + x] += dp[j - 1][s];
			}
		}
	}
	
	long long ans = 0;
	for (int i = 1; i <= n; i++) ans += dp[i][A * i];
	cout << ans << "\n";
	
	return 0;
}


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

int main() {
  string a, b, c;
  cin >> a >> b >> c;
  
  if (a[a.length() - 1] == b[0] && b[b.length() - 1] == c[0]) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;

using ll = long long;
using P = pair<int, int>;

const int INF = 2147483600;
const int MOD = 1e9 + 7;

// 4近傍、8近傍
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int f(int x, int y) {
  if (x <= y) {
    return y - x;
  } else {
    return INF;
  }
}

int main() {
  // 入力
  int x, y;
  cin >> x >> y;

  int ans = f(x, y);
  ans = min(ans, f(-x, y) + 1);
  ans = min(ans, f(-x, -y) + 2);
  ans = min(ans, f(x, -y) + 1);

  // 解答
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define debug 0
#define esc(ret) cout << (ret) << endl,quick_exit(0)
#define fcout(d) cout << fixed << setprecision(d)
#define repU(i,s,t) for(int i = (int)(s); i <= (int)(t); ++i)
#define repD(i,s,t) for(int i = (int)(s); i >= (int)(t); --i)
#define rep(i,n) repU(i,0,(n) - 1)
#define rep1(i,n) repU(i,1,(n))
#define all(v) begin(v),end(v)
#define vct vector
#define prique priority_queue
#define l_bnd lower_bound
#define u_bnd upper_bound
#define puf push_front
#define pub push_back
#define pof pop_front
#define pob pop_back
#define mkp make_pair
#define mkt make_tuple
#define fir first
#define sec second
#define qceil(n,d) ((n) > 0 ? ((n) - 1) / (d) + 1 : (n) / (d))
#define parity(a,b) (a & 1 ^ b & 1 ^ 1)

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef pair<int,int> pii;
typedef pair<db,int> pdi;

const pii dir[] = { {1,0},{0,1},{-1,0},{0,-1},{1,1},{-1,1},{-1,-1},{1,-1} };
const int mod = 1e9 + 7;
const int inf32 = (1 << 30) - 1;
const ll inf64 = (1LL << 62) - 1;


ll N,M,Q,K,L,H,W,D;
string S;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	string T;
	cin >> S >> T >> Q;
	int sca[100010],scb[100010],tca[100010],tcb[100010];
	sca[0] = scb[0] = tca[0] = tcb[0] = 0;
	rep(i,S.size()) if(S[i] == 'A') sca[i + 1] = sca[i] + 1,scb[i + 1] = scb[i]; else sca[i + 1] = sca[i],scb[i + 1] = scb[i] + 1;
	rep(i,T.size()) if(T[i] == 'A') tca[i + 1] = tca[i] + 1,tcb[i + 1] = tcb[i]; else tca[i + 1] = tca[i],tcb[i + 1] = tcb[i] + 1;
	rep(i,Q){
	    int a,b,c,d; cin >> a >> b >> c >> d;
	    int ds = sca[b] - sca[a - 1] + scb[a - 1] - scb[b];
	    int dt = tca[d] - tca[c - 1] + tcb[c - 1] - tcb[d];
	    if(abs(ds - dt) % 3) cout << "NO\n";
	    else cout << "YES\n";
	}
}


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

using namespace std;

typedef long long ll;

const ll INF = 20000000000;

ll solve(ll H, ll W){
  // split H
  ll minv = INF;
  for(ll i=0;i<=1;i++){
    for(ll j=0;j<=1;j++){
      ll a = (H/3 + i)*W;
      ll b = (H/3 + j)*W;
      ll c = H*W - a - b;
      ll smax = max(a, max(b, c));
      ll smin = min(a, min(b, c));
      minv = min(minv, smax-smin);
    }
  }
  // split W
  for(ll i=0;i<=1;i++){
    for(ll j=0;j<=1;j++){
      ll a = (W/3 + i)*H;
      ll b = (W - (W/3 + i))*(H/2 + j);
      ll c = H*W - a - b;
      ll smax = max(a, max(b, c));
      ll smin = min(a, min(b, c));
      minv = min(minv, smax-smin);
    }
  }
  return minv;
}

int main(){
  ll H, W; cin >> H >> W;
  cout << min(solve(H, W), solve(W, H)) << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	static Scanner sc = new Scanner(System.in);
	
	public static void main(String[] args) {
		String c1 = sc.next();
		String c2 = sc.next();
		
		if (c1.toCharArray()[0] == c2.toCharArray()[2] &&
		    c1.toCharArray()[1] == c2.toCharArray()[1] && 
		    c1.toCharArray()[2] == c2.toCharArray()[0]) {
			
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
	}
}


Measured memory_bytes: 23252
#include <bits/stdc++.h>
#define rep(i, to) for (int i = 0; i < (to); ++i)
#define repf(i, from, to) for (int i = (from); i < (to); ++i)
#define unless(cond) if (!(cond))
using namespace std;
using ll = long long;
template <typename T>
using V = vector<T>;
template <typename T, typename U>
using P = pair<T, U>;

int main() {
  int n;
  string s;
  V<char> ch_list;
  repf(i, 0, 10) {
    ch_list.push_back('0' + i);
  }
  cin >> n >> s;

  int count = 0;
  rep(i, 10) rep(j, 10) rep(k, 10) {
    string pin;
    pin.push_back(ch_list[i]);
    pin.push_back(ch_list[j]);
    pin.push_back(ch_list[k]);

    // Creatable
    int find_tail = 0;
    rep(i, n){
      if(s[i] == pin[find_tail]) {
        find_tail++;
      }
      if(find_tail == pin.size()) {
        break;
      }
    }

    // Find
    if(find_tail == pin.size()) {
      count++;
    }
  }

  cout << count << endl;

}

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

struct BIT {
    int max_val;
    int a[505505];

	BIT() {}
    BIT(int maxv) { max_val = maxv; }

    inline int lowbit(int x) { return x & (-x); }

    void clear() { memset(a, 0, sizeof(a)); }
    void clear(int max_id) {
        for(int i=0;i<=max_id;i++) a[i]=0;
    }

    void add(int pos, int val) {
        for (pos = max(1, pos); pos <= max_val; pos += lowbit(pos))
            a[pos] += val;
    }

    int query(int pos) {
        int res = 0;
        for (; pos; pos -= lowbit(pos))
            res += a[pos];
        return res;
    }

    int query(int l, int r) {
        return query(r) - (l ? query(l-1) : 0);
    }
} b[26];

int n, q;
char s[505505];

int main() {
	scanf("%d%s", &n, s);
	for(int i=0;i<26;i++)
		b[i] = BIT(n);
	for(int i=0;i<n;i++) {
		int ch = s[i]-'a';
		b[ch].add(i+1, 1);
	}
	
	scanf("%d", &q);
	for(int i=0;i<q;i++) {
		int op;
		scanf("%d", &op);
		if(op==1) {
			int id;
			char ss[11];
			scanf("%d%s", &id, ss);
			id--;
			
			int ch = s[id]-'a';
			b[ch].add(id+1, -1);
			
			s[id] = ss[0];
			ch = ss[0]-'a';
			b[ch].add(id+1, 1);
		} else {
			int l, r;
			scanf("%d%d", &l, &r);
			
			int res = 0;
			for(int i=0;i<26;i++)
				if(b[i].query(l, r)>0) res++;
			printf("%d\n", res);
		}
	}
	
	return 0;
}

Measured memory_bytes: 52096
N,M = (int(i) for i in input().split())
X = [int(i) for i in input().split()]

X.sort()
D = []
for i in range(M-1):
    D.append(X[i+1]-X[i])

D.sort()
ans=0
for i in range(M-N):
    ans+=D[i]

print(ans)

Measured memory_bytes: 56872
lines = []
while line = gets
    lines << line.chomp.split(' ').map(&:to_i)
end

N = lines[0][0]

num = []
for i in 1..10 ** 6 do
  num[i-1] = 0
end

for i in 1..N do
  num[lines[1][i-1]-1] += 1
end

max_num_div = 0
for i in 2..10 ** 6 do
  num_div = 0
  multi = 1
  while i * multi <= 10 ** 6 do
    num_div += num[i * multi - 1]
    multi += 1
  end
  if max_num_div < num_div then
    max_num_div = num_div
  end
end
  
if max_num_div == 1 or max_num_div == 0 then
  puts "pairwise coprime"
elsif max_num_div < N then
  puts "setwise coprime"
else
  puts "not coprime"
end

Measured memory_bytes: 98296
#include <bits/stdc++.h>
using namespace std;
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cout<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cout<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 1120000000

int main(){
  using P = pair<int,int>;
  int c,n,m,s,t;
  while(cin>>c>>n>>m>>s>>t, c|n|m){
    s--;t--;
    vector<vector<P>> vec(n);
    rep(i,m){
      int a,b,f;
      cin>>a>>b>>f;
      a--;b--;
      vec[a].pb(mp(f,b));
      vec[b].pb(mp(f,a));
    }

    vector<vector<int>> d(n,vector<int>(c+1,INF));
    priority_queue<P, vector<P>, greater<P>> pq;
    pq.push(mp(0,s*(c+1)));
    d[s][c] = 0;
    while(!pq.empty()){
      auto p = pq.top(); pq.pop();
      int v = p.se/(c+1);
      int k = p.se%(c+1);
      if(d[v][k] < p.fi) continue;

      auto go = [&](int nv, int nk, int dist){
        if(d[nv][nk] > dist){
          pq.push(mp(dist, nv*(c+1)+nk));
          d[nv][nk] = dist;
        }
      };

      for(auto to : vec[v]){
        go(to.se, k, p.fi + to.fi);
        if(k<c) go(to.se, k+1, p.fi + to.fi/2);
      }
    }

    cout << *min_element(all(d[t])) << endl;
  }

  return 0;
}

Measured memory_bytes: 3084
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <bitset>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <utility>
#include <set>
#include <map>
#include <tuple> 
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <list>
using namespace  std;
using ll = long long;
using P = pair<ll, ll>;
#define REP(i, n) for(long long (i)=0, i_bound = (long long)(n); (i)<i_bound; ++i)
#define FOR(i, a, b) for(long long (i)=(a); (i)<(b); ++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
const long long MOD = static_cast<long long>(1e9) + 7LL;
const long long INF = 1234567891234567890LL;
int main(){
    cin.tie(0);
    cout.sync_with_stdio(false);
    int x; cin>>x;
    int res = 1;
    for(int i=2; i<x; i++){
        int tmp = i*i;
        while(tmp<=x) res = max(res, tmp), tmp*=i;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n;
int dp[5001][2];
vector<int> G[5001];

void dfs(int v){
	int sum=0;
	for(int i=0;i<G[v].size();i++){
		dfs(G[v][i]);
		sum+=max(dp[G[v][i]][0],0);
	}
	dp[v][1]=sum;
	int tmp=0;
	for(int i=0;i<G[v].size();i++){
		tmp=max(dp[G[v][i]][1]+1-dp[G[v][i]][0],tmp);
	}
	dp[v][0]=sum+tmp;
}

int main(void){
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		int p;
		scanf("%d",&p);
		G[p].push_back(i+1);
		memset(dp,-1,sizeof(dp));
		dfs(0);
		printf("%d\n",max(dp[0][0],dp[0][1]));
	}
	return 0;
}

Measured memory_bytes: 3508
#include <bits/stdc++.h>
#define va first
#define vb second
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int MN = 2e5+5;
bool ch[MN];
int main()
{
    ios_base::sync_with_stdio(0),cin.tie(0);
    string S;
    cin >> S;
    if(S.size()%2){
        cout << "No";
        return 0;
    }
    for(int i=0; i<S.size(); i++){
        if(i%2){
            if(S[i]!='i'){
                cout << "No";
                return 0;
            }
        }
        else if(S[i]!='h'){
            cout << "No";
            return 0;
        }
    }
    cout << "Yes";
}


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

#define endl "\n"
#define F first
#define S second
#define pb push_back
#define ll long long
#define faster ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

ll n,a[200008],r[200008],l[200008],ans;
stack <ll> st;
stack <ll> stt;

int main() {
	faster;
	cin>>n;
	for (int i = 1; i<=n; i++) {
		cin>>a[i];
	}
	for (int i = 1; i<=n; i++) {
		while (!st.empty() && a[st.top()]>=a[i]) {
			st.pop();
		}
		if (st.empty()) {
			l[i] = 0;
		}
		else {
			l[i] = st.top();
		}
		st.push(i);
	}
	for (int i = n; i>=1; i--) {
		while (!stt.empty() && a[stt.top()]>=a[i]) {
			stt.pop();
		}
		if (stt.empty()) {
			r[i] = n+1;
		}
		else {
			r[i] = stt.top();
		}
		stt.push(i);
	}
	for (int i = 1; i<=n; i++) {
		//cout<<l[i]<<' '<<r[i]<<endl;
		ll id = (r[i]-i)*(i-l[i]);
		ans+= id*a[i];
	}
	cout<<ans;

    return 0;
}


Measured memory_bytes: 6656
#include<bits/stdc++.h>
using namespace std;
int n,m,k,j,h;
int main()
{
	cin>>n>>m>>k;
	cin>>j;
	int s=max(n,m);
	s=max(s,k);
	if(s==n) h=1;
	else if(s==m) h=2;
	else if(s==k) h=3;
	for(int i=1;i<=j;i++){
		s*=2;
	}
	if(h==1) cout<<s+m+k;
	else if(h==2) cout<<s+n+k;
	else if(h==3) cout<<s+n+m;
	return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target ("avx2")

#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <queue>
#include <stack>

#include <x86intrin.h>

using namespace std;

typedef long long int ll;
typedef pair<int, int> Pii;

const ll mod = 1000000007;

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

  int n;
  cin >> n;
  vector<ll> a(n+16);
  for (int i = 0; i < n; i++) cin >> a[i];

/*
  if (n % 2 == 0) {
    ll now = 0;
    for (int i = 0; i < n; i += 2) now += a[i];
    ll maximum = now;
    for (int i = n-2; i >= 0; i -= 2) {
      now += (a[i+1] - a[i]);
      if (now > maximum) maximum = now;
    }

    cout << maximum << endl;
  }
  else {
    vector<vector<ll> > dp(n+2, vector<ll>(3, (ll) -1e18));
    dp[0][0] = a[0];
    dp[1][1] = a[1];
    dp[2][2] = a[2];
    for (int i = 0; i < n; i++) {
      if (i+2 < n) dp[i+2][0] = max(dp[i+2][0], dp[i][0] + a[i+2]);
      if (i+2 < n) dp[i+2][1] = max(dp[i+2][1], dp[i][1] + a[i+2]);
      if (i+2 < n) dp[i+2][2] = max(dp[i+2][2], dp[i][2] + a[i+2]);
      if (i+3 < n) dp[i+3][1] = max(dp[i+3][1], dp[i][0] + a[i+3]);
      if (i+3 < n) dp[i+3][2] = max(dp[i+3][2], dp[i][1] + a[i+3]);
      if (i+4 < n) dp[i+4][2] = max(dp[i+4][2], dp[i][0] + a[i+4]);
    }

    cout << max(max(dp[n-3][0], dp[n-2][1]), dp[n-1][2]) << endl;
  }
*/

  vector<vector<ll> > dp(n/2, vector<ll>(3, (ll) -1e18));
  dp[0][0] = a[0];
  dp[0][1] = a[1];
  dp[0][2] = a[2];
  for (int i = 1; i < n/2; i++) {
    dp[i][0] = dp[i-1][0];
    dp[i][1] = max(dp[i][0], dp[i-1][1]);
    dp[i][2] = max(dp[i][1], dp[i-1][2]);
    dp[i][0] += a[i*2];
    dp[i][1] += a[i*2+1];
    dp[i][2] += a[i*2+2];
  }

  ll ans = max(dp[n/2-1][0], dp[n/2-1][1]);
  if (n % 2 == 1) ans = max(ans, dp[n/2-1][2]);

  cout << ans << endl;

  return 0;
}


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

const int MN=200000;
const long long INF=10000000000ll;

const long long mod=1000000007ll;
void ad(long long &a,long long b){a+=b;a%=mod;}
void mn(long long &a,long long b){a+=mod-b;a%=mod;}
void ml(long long &a,long long b){a*=b;a%=mod;}
long long sq(long long a){return a*a%mod;}
long long pw(long long a,long long n)
{
  return n==0?1ll:sq(pw(a,n/2))*(n%2==1?a:1ll)%mod;
}
long long iv(long long a){return pw(a,mod-2);}
const int MSIZE=MN+10;
long long inv[MSIZE],F[MSIZE],iF[MSIZE];

void prev(int N)
{
  inv[0]=0;
  inv[1]=1;
  for(int i=2;i<N;i++){
    inv[i]=(mod-mod/i)*inv[mod%i]%mod;
  }
  F[0]=iF[0]=1;
  for(int i=1;i<N;i++){
    F[i]=F[i-1]*i%mod;
    iF[i]=iF[i-1]*inv[i]%mod;
  }
}

long long Ch(int i,int j)
{
  return F[i]*iF[j]%mod*iF[i-j]%mod;
}

int main()
{
  int n;
  long long X,Y;
  scanf("%d%lld%lld",&n,&X,&Y);
  prev(n+10);
  static int c[MN];
  static long long w[MN];
  for(int i=0;i<n;i++){
    scanf("%d%lld",c+i,w+i);
    c[i]--;
  }
  static long long M[MN];
  for(int i=0;i<n;i++){
    M[i]=INF;
  }
  for(int i=0;i<n;i++){
    M[c[i]]=min(M[c[i]],w[i]);
  }
  long long mw=INF,mi=-1,mw2=INF;
  for(int i=0;i<n;i++){
    if(mw>w[i]){
      mw=w[i];
      mi=i;
    }
  }
  for(int i=0;i<n;i++){
    if(c[i]!=c[mi]&&mw2>w[i]){
      mw2=w[i];
    }
  }
  int N=0;
  static int C[MN]={0};
  for(int i=0;i<n;i++){
    if((c[i]!=c[mi]&&w[i]+mw<=Y||(w[i]+M[c[i]]<=X&&M[c[i]]+mw<=Y))
       ||(c[i]==c[mi]&&(i==mi||w[i]+mw<=X||(w[i]+mw2<=Y&&mw2+mw<=Y)))){
      N++;
      C[c[i]]++;
    }
  }
  long long ans=F[N];
  for(int i=0;i<n;i++){
    ml(ans,iF[C[i]]);
  }
  printf("%lld\n",ans);
  return 0;
}



Measured memory_bytes: 9728
#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 <cmath>
#include <iomanip>
#include <ctype.h>

using namespace std;
using ll = long long;
using PAIR = pair<int, int>;
using PAIRLL = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;

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

ll GCD(ll x, ll y) {
    if (y == 0) return x;
    else return GCD(y, x % y);
}

ll LCM(ll x, ll y) {
    return x / GCD(x, y) * y;
}

bool my_compare(pair<string, int> a, pair<string, int> b) {
    if (a.first != b.first) {
        return a.first < b.first;
    }

    if (a.second != b.second) {
        return a.second > b.second;
    }
    else {
        return true;
    }
}

int main()
{
    int X, Y, Z;
    cin >> X >> Y >> Z;

    int N = 0;

    while (1) {
        ++N;
        if (Y * N + Z * (N + 1) > X) { break; }
    }
    cout << N - 1 << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
#include<string.h>
using namespace std;
#define NIL -2000000001
#define MAX 2000000

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

  if (a<=8 && b <= 8) {
    printf("Yay!\n");
  } else {
    printf(":(\n");
  }



  return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
 
 
int main()
{
    int r, c, i, j, data[150][150], sum1 = 0, sum2 = 0;
    scanf("%d%d", &r, &c);
    for (i = 0; i < r; i++) {
        for (j = 0; j < c; j++) {
            scanf("%d", &data[i][j]);
            sum1 += data[i][j];
        }
        data[i][c] = sum1;
        sum1 = 0;
    }
    for (j = 0; j <= c; j++) {
        for (i = 0; i < r; i++) {
            sum2 += data[i][j];
        }
        data[r][j] = sum2;
        sum2 = 0;
    }
    for (i = 0; i <= r; i++) {
        for (j = 0; j < c; j++) {
            printf("%d ", data[i][j]);
        }
        printf("%d\n", data[i][c]);
    }
 
    return 0;
}

Measured memory_bytes: 664
#include<iostream>
#include<stack>
#include<string>

using namespace std;

int main(void){
	string str;

	while(getline(cin,str)){
		
		stack<char> st;
		bool flag=true;
		
		if(str=="."){
			break;
		}
		
		for(int i=0;i<str.size();i++){
			
			
		
			
			if(str[i]=='('|| str[i]=='['){
				st.push(str[i]);
			}
						
			else if(str[i]==')'){
				if(st.empty()||st.top()!='('){
					flag=false;
					break;
				}
				else if('('==st.top()){
					st.pop();
				}
			}
			
			else if(str[i]==']'){
				if(st.empty()||st.top()!='['){
					flag=false;
				}
				else if('['==st.top()){
					st.pop();
				}
			}
		}
		
		if(flag && st.empty()){
			cout<<"yes"<<endl;
		}
		else{
			cout<<"no"<<endl;
		}

		
	}
}

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

int main() {

    int N;
    cin >> N ;

    vector<long long int> A;
    long long int tmp;
    long long int sum = 0;
    int count = 0;
    for (int i = 0; i<N; i++) {
        cin >> tmp;
        if (tmp < 0) {
            count++;
        }
        A.push_back(abs(tmp));
        sum += abs(tmp);
    }

    sort(A.begin(), A.end());

    if (count % 2 == 1) {
        sum -= A[0]*2;
    }

    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 1400
#include <bits/stdc++.h>
#ifdef __LOCAL
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
#else
    #define DBG(X)
    #define SAY(X)
#endif

#ifdef __LOCAL
    #include <filesystem>
    namespace fs = std::filesystem;
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int dx[]={1, 0, -1, 0, 1,-1, 1,-1};
int dy[]={0, 1, 0, -1, 1, 1,-1,-1};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);
static mt19937 _g(time(nullptr));
 
inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << ";" << el.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

int A,B,C;
void input(){
    fast_io();
    #ifdef __LOCAL
        fs::path p = __FILE__;
        fs::path input,output;
        input = output = p.parent_path();
        input += string("/input/") + string(p.stem()) + string(".txt");
        output += string("/output/") + string(p.stem()) + string(".txt");
        freopen(input.c_str(), "r", stdin);
        freopen(output.c_str(), "w", stdout);
    #endif
    cin >> A >> B >> C;
}

int solve(){
    int Mx = max({A,B,C});
    int Mn = min({A,B,C});
    int ans=0;
    int chk=0;
    for(auto x:{A,B,C}) {ans += (Mx-x)/2; chk += (Mx-x)%2;}
    if(chk==1) ans+=2;
    if(chk==2) ans++;
    cout << ans << endl;
    return 0;
}   

int main()
{
    input();
    solve();
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
using namespace std;
using ll = long long;

int main() {
    ll X, A;
    cin >> X >> A;
    if (X < A) cout << 0 << endl;
    else cout << 10 << endl;
    return 0;
}

Measured memory_bytes: 256