akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define fir first
#define sec second
#define pb 	push_back
#define ll  long long
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define pii pair<int,int>
#define debug(x) cerr<<#x<<" =: "<<x<<endl;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define Find find_by_order
#define Order order_of_key
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
mt19937 mrand(random_device{}());
ll rnd(ll x) { return mrand() % x;}
ll ksm(ll a,ll b,ll mod){ll ans=1;a%=mod;while(b){if(b&1) ans=ans*a%mod;b>>=1;a=a*a%mod;}return ans;}
ll phi(ll n){ll ans=n;for(ll i=2;i*i<=n;i++){if(n%i==0) {while(n%i==0) n/=i;ans=ans*(i-1)/i;}}if(n>1) ans=ans*(n-1)/n;return ans;}
//head

const ll mod=1e6+3;
const int maxn=2e6+100;
ll a[maxn];

ll fac[maxn],inv[maxn],finv[maxn];



void init(){
	inv[0]=inv[1]=fac[0]=fac[1]=finv[1]=finv[0]=1;
	for(int i=2;i<maxn;i++){
		fac[i]=fac[i-1]*i%mod;
		inv[i]=mod-inv[mod%i]*(mod/i)%mod;
		finv[i]=finv[i-1]*inv[i]%mod;
	}
}

void solve(int x,int d,int n){
	if(d==0){
		cout<<ksm(x,n,mod)<<endl;
		return ;
	}
	ll zx=1ll*x*inv[d]%mod;
	if(zx+n-1>=mod) {
		cout<<0<<endl;
		return ;
	}
	ll ret=ksm(d,n,mod);
	ret=ret*fac[zx+n-1]%mod;
	ret=ret*finv[zx-1]%mod;
	cout<<ret%mod<<endl;
	return ;
}


int main() {
	init();
//	int tmp=x/d;
//	 pro = tmp*(tmp+1)*(tmp+2)*....*(tmp+n-1);
	int q;cin>>q;
	while(q--){
		int x,d,n;cin>>x>>d>>n;
		solve(x,d,n);
	}
}

// 1  ....... 1


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

ll gcd(ll a,ll b){
  if(b == 0) return a;
  return gcd(b, a % b);
}

ll lcm(ll a, ll b){
  return a/gcd(a,b) * b;
}
ll func2(ll n){
  ll res = 0;
  while(n%2 == 0){
    n /= 2;
    res++;
  }
  return res;
}

ll zyou(ll a,ll b){//a＾b
  ll res = 1;
  for(int i = 1;i<=b;i++){
    res *= a;
  }
  return res;
}
struct Edge{
  int to;
  int weight;
  Edge(int t, int w) : to(t),weight(w){ }
};

typedef pair<int,int> P;
using Graph = vector<vector<Edge>>;

ll calc(ll a, ll b, ll p){//aのb乗をpで割った余り
  if(b == 0) return 1;

  else if(b%2 == 0){
    ll d = calc(a,b/2,p);
    return (d*d)%p;
  }
  else if(b%2 == 1){
    return (a * calc(a,b-1,p))%p;
  }
}



bool is_prime(int n){//nが素数であるかどうか判定 iで割り切れると素数でない
    if(n == 1) return false;//1は例外
    for(int i = 2;i*i <= n;i++){
        if(n%i == 0) return false;
    }
    
    return true;
}
int dfs(int x,int y,int H,int W,vector<vector<char>> &masu){
  if(masu[x][y] == '#'){

  }
}
bool palin(string S){
  int n = S.size();
  bool flag = true;
  if(n%2 == 0){
    for(int i = 0;i<=n/2-1;i++){
      if(S[i] != S[n-i-1]){
        flag = false;
        break;
      }
    }
  }
  else if(n%2 == 1){
    for(int i = 0;i<=n/2-1;i++){
      if(S[i] != S[n-i-1]){
        flag = false;
        break;
      }
    }
  }
  return flag;
}
int main(){
  int N;
  cin >> N;
  vector<string> s(N);
  rep(i,N){
    cin >> s[i];
  }
  int M;
  cin >> M;
  vector<string> t(M);
  rep(i,M){
    cin >> t[i];
  }
  map<string,int> mab;
  rep(i,N){
    mab[s[i]]++;
  }
  map<string,int> mar;
  rep(i,M){
    mar[t[i]]++;
  }
  int ans = 0;
  rep(i,N){
    ans = max(ans,mab[s[i]] - mar[s[i]]);
  }
  cout << ans << endl;
}

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

using namespace std;

typedef long long ll;

const ll MOD = 1e9+7;

signed main()
{
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    vector<int> v(4, 0);
    auto f = [&](int p){
        if(p == 1)
            ++v[0];
        if(p == 9)
            ++v[1];
        if(p == 7)
            ++v[2];
        if(p == 4)
            ++v[3];
    };
    f(a);
    f(b);
    f(c);
    f(d);
    bool flag = true;
    for(int i = 0; i < 4; ++i)
        flag &= (v[i] == 1);
    cout << (flag ? "YES" : "NO") << endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
const int N = 210;
char s[N];
bool check(int pos) {
	int mid = pos / 2;
	for(int i = 1; i <= mid; i++) {
		if(s[i] != s[i+mid]) return 0;
	} 
	return 1;
} 
int main() {
	
	scanf("%s", s + 1);
	int n = strlen(s + 1);
	for(int i = n-1; i >= 2; i--) {
		if(i & 1) continue;
		if(check(i)) {
			printf("%d\n", i);
			break;
		}
	}
	
	return 0;
}

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

int main(){
  int a,b;
  char op;
  int result;

  while(true){
    cin >> a >> op >> b; 
    if(op == '?'){
      break;
    }
 
    switch(op){
	case '+': result = a + b; break;
	case '-': result = a - b; break;
	case '*': result = a * b; break;
	case '/': result = a / b; break;
      }
    
    printf("%d\n",result);
  } 
 

}

Measured memory_bytes: 3172
import fractions
def main31():
    num = int(input())
    txy = []
    txy.append([0,0,0])
    for i in range(num):
        kari = []
        data = input().split()
        for j in range(3):
            kari.append(int(data[j]))
        txy.append(kari)
    for i in range(num):
        kyori = abs(txy[i][1]-txy[i+1][1]) + abs(txy[i][2]-txy[i+1][2])
        zikan = txy[i+1][0] - txy[i][0]
        if not(kyori <= zikan and (kyori - zikan) % 2 == 0):
            print("No")
            return
    print("Yes")

if __name__ == "__main__":
    main31()

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

using namespace std;

#define ll long long

int main (){

    ll n,a,i,sum=0,k,r;

    cin>>a>>n;

    for(i=1; i<=n; i++){

        cin>>k;

        a-=k;

    }

    if(a <= 0)cout<<"Yes"<<endl;

    else cout<<"No"<<endl;

    return 0;

}


Measured memory_bytes: 256
import math
n = int(input())
prime = []
for i in range(2,math.floor(n**0.5)+1):
    for k in range(len(prime)):
        if i % prime[k] == 0: 
           break
    else:
        prime.append(i)
for i in range(10000):
    for k in range(len(prime)):
        if (n+i) % prime[k] == 0:
            break
    else:
        print(n+i)
        exit()

Measured memory_bytes: 3064
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int A ,B ,C;
    std::cin >> A >> B >> C;
    int D = C-(A-B);
    if (D < 0){
        std::cout << 0 << std::endl;
    }
    if (D >= 0){
        std::cout << D << std::endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
int N;
vector <int> G[100005];
char Color[100005];
bool Block[100005];
int Grade[100005], cnt, root, Cost[100005], Max[100005], Sum[100005], aux;
int ans = 0;
void Read()
{
    cin >> N;
    for(int i = 1; i < N; i++)
    {
        int x, y;
        cin >> x >> y;
        Grade[x]++;Grade[y]++;
        G[x].push_back(y);
        G[y].push_back(x);
    }
    for(int i = 1; i <= N; i++)
    {
        cin >> Color[i];
        if(Color[i] == 'W')
            ++cnt;
    }
}

void deleteNodes()
{
    queue <int> Q;
    for(int i = 1; i <= N; i++)
        if(Grade[i] == 1 && Color[i] == 'B')
        {
            Q.push(i);
            Block[i] = 1;
        }

    while(!Q.empty())
    {
        int node = Q.front();
        Q.pop();
        Block[node] = 1;
        for(int i = 0; i < G[node].size(); i++)
        {
            int neighb = G[node][i];
            if(Block[neighb] == 1)
                continue;
            Grade[neighb]--;
            if(Grade[neighb] == 1 && Color[neighb] == 'B')
            {
                Block[neighb] = 1;
                Q.push(neighb);
            }
        }
    }
}

void findRoot()
{
    for(int i = 1; i <= N; i++)
        if(Block[i] == 0)
        {
            root = i;
            break;
        }
}

void precalcCost()
{
    for(int i = 1; i <= N; i++)
    {
        Grade[i] = 0;
        if(Block[i] == 1)
            continue;
        for(int j = 0; j < G[i].size(); j++)
        {
            int neighb = G[i][j];
            if(Block[neighb] == 0)
                Grade[i]++;
        }
        int val = 0;
        if(Color[i] == 'W')
            val = 1;
        if(Grade[i] % 2 == 1)
            val = 1 - val;
        if(val == 0)
            val = 0;
        else
            val = 2, aux++;
        Cost[i] = val;
    }
}

void DFS(int node, int father)
{
    int Mx = 0, Mx2 = 0;
    Sum[node] = Sum[father] + Cost[node];
    Max[node] = Sum[node];
    Mx = Sum[node]; Mx2 = Sum[node];
    for(int i = 0; i < G[node].size(); i++)
    {
        int neighb = G[node][i];
        if(neighb == father || Block[neighb] == 1)
            continue;
        DFS(neighb, node);
        Max[node] = max(Max[node], Max[neighb]);
        if(Max[neighb] > Mx)
        {
            Mx2 = Mx;
            Mx = Max[neighb];
        }
        else
            if(Max[neighb] > Mx2)
            {
                Mx2 = Max[neighb];
            }

        //++cnt;
    }
    ans = max(ans, Mx + Mx2 - 2 * Sum[father] - Cost[node]);
}
int main()
{
    Read();
    if(cnt <= 1)
    {
        cout << cnt << "\n";
        return 0;
    }
    deleteNodes();
    findRoot();
    precalcCost();
    DFS(root, 0);
    int nb =0;
    for(int i = 1; i <= N; i++)
        if(Block[i] == 0)
            nb++;
    cout << -ans + (2 * nb - 2 + aux) << '\n';
    return 0;
}


Measured memory_bytes: 15744
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 2147483647 / 2;
const long long int llINF = 9223372036854775807 / 2;

using namespace std;
using ll = long long int;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;

typedef pair<ll, ll> pll;
bool paircomp(const pll &a, const pll &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}

#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define ARGMAX(vec)                                                            \
  std::distance(vec.begin(), std::max_element(vec.begin(), vec.end()))
#define ARGMIN(vec)                                                            \
  std::distance(vec.begin(), std::min_element(vec.begin(), vec.end()))
#define REV(T) greater<T>()
#define PQ(T) priority_queue<T, vector<T>, greater<T>>
#define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c))
#define VVVL(a, b, c, d)                                                       \
  vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))
#define SP(a) setprecision(a)
#define SQRT(a) sqrt((long double)(a))
#define DPOW(a, b) pow((long double)(a), (long double)(b))
#define UNIQUE(vec)                                                            \
  do {                                                                         \
    sort(ALL((vec)));                                                          \
    (vec).erase(std::unique(ALL((vec))), (vec).end());                         \
  } while (0)

ll POW(ll n, ll m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = POW(n, m / 2);
    return (tmp * tmp);
  } else {
    return (n * POW(n, m - 1));
  }
}

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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  string S;
  cin >> S;
  bool ok = true;
  REP(i, S.size()) {
    if (i % 2 == 0 && S[i] == 'L')
      ok = false;
    else if (i % 2 == 1 && S[i] == 'R')
      ok = false;
  }
  if (ok)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}


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

int main() {
	while (1) {
		int n;
		cin >> n;
		if ( n == 0 ) break;
		int a[5000];
		for ( int i = 0; i < n; i++ ) {
			cin >> a[i];
		}
		int ans = a[0];
		int pn;
		for ( int i = 0; i < n; i++ ) {
			pn = 0;
			for ( int j = 0; i + j < n; j++ ) {
				pn += a[i + j];
				if ( pn > ans ) ans = pn;
			}
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 1172
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
using namespace std;
typedef long long ll;

int N, M, Q;
vector<int> a, b, c, d;

// スコア計算関数
int score(vector<int> A) {
    int res = 0;
    rep(i, Q) if (A[b[i]] - A[a[i]] == c[i]) res += d[i];
    return res;
}

int main() {
    cin >> N >> M >> Q;
    a.resize(Q); b.resize(Q); c.resize(Q); d.resize(Q);
    rep(i, Q){
        cin >> a[i] >> b[i] >> c[i] >> d[i];
        a[i]--, b[i]--;
    }

    // スタックの初期値は{{1},{2},{3},{4}}
    stack<vector<int>> st;
    rep(i, M){
        vector<int> s = {i+1};
        st.push(s);
    }

    int ans = 0;
    // スタックが空になるまで回し続ける
    while (!st.empty()){
        // スタックの一番上の要素について処理を行う
        vector<int> elem = st.top();
        // 読み取ったら削除しておく
        st.pop();
        // 数列の長さがNであればスコアを計算して最大値を更新していく
        if (elem.size() == N) ans = max(ans, score(elem));
        // 数列の長さがNでなければ要素を追加してスタックにプッシュする
        else {
            repi(i, elem[elem.size()-1], M+1){
                vector<int> elem_new = elem;
                elem_new.push_back(i);
                st.push(elem_new);
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3612
/*

                              Jai Shree Krishna !!
                                 Radhe Radhe !!
                                 
             उद्यमेन हि सिद्ध्यन्ति कार्याणि न मनोरथैः। नहि सुप्तस्य सिंहस्य मुखे प्रविशन्ति मृगाः।।
             
*/
   
   
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
typedef long long ll;
#define loop(i,n)  for(int i=0;i<n;i++)
#define read(a) int a; cin >>a;
#define readarr(a,n) int a[n] ; for(int i=0;i<n;i++) cin >> a[i];
#define readmat(a,n,m) int a[n][m]; for(int i=0;i<n;i++) for(int j=0;j<m;j++) cin >> a[i][j];
#define pb push_back
#define ff first
#define ss second
#define vi vector<int>
#define pi pair<int,int>
#define vvi vector<vector<int>>
#define sti set<int>
#define vpi vector<pair<int,int>>
#define print(a,n) for(int i=0;i<n;i++) cout<<a[i]<<" "; cout<<endl;
#define printmat(a,n,m) for(int i=0;i<n;i++) {for(int j=0;j<m;j++) cout<<a[i][j]<<" "; cout<<endl;}
#define fast ios_base::sync_with_stdio(false);  cin.tie(NULL);
#define endl "\n"
#define mp make_pair
#define ins insert
#define rep(i,s,e)   for(int i=s;i<=e;i++)
#define repd(i,s,e)  for(int i=e;i>=s;i--)
#define vb vector<bool>
#define read2(n,m) int n,m; cin >> n >> m;
#define range(v) v.begin(),v.end()
#define sortd(v) sort(v.begin(),v.end(),greater<int>())
#define sorti(v) sort(v.begin(),v.end())

const ll inf = 1e18;
const ll mod = 1e9 + 7;
 
signed main()
{
 
    fast;
    int k,a,b;
    cin >> k >> a >> b;
    int c = b/k - a/k ;
    if(a%k==0) c++;
    if(c!=0) cout<<"OK"<<endl;
    else
    cout<<"NG"<<endl;
    return 0;
}

/* Pooja Yadav */

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

long long n, ar[5], mini;

int main(){
	scanf("%lld", &n);
	mini = LLONG_MAX;
	for(int i = 0; i < 5; i++){
		scanf("%lld", &ar[i]);
		mini = min(mini, ar[i]);
	}

	printf("%lld\n", (n-1)/mini + 5);
	
	return 0;
}	

Measured memory_bytes: 256
#!/usr/bin/env python3
N = int(input())
C = input()
W = []
R = []
for i in range(N):
    if C[i] == 'W':
        W.append(i)
    else:
        R.append(i)
R.reverse()
ans = 0
for i in range(min(len(W), len(R))):
    if W[i] > R[i]:
        break
    ans += 1
print(ans)

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

int main(){
   int x;
   cin >> x;
   vector<int> pw;
   for(int i = 1;i < 32;i++){
       for(int j = 2;j < 10;j++){
           ll temp = pow(i,j);
           if(temp > (ll)x)break;
           else pw.push_back(temp);
       }
   }
   sort(pw.begin(),pw.end());
   cout << pw[pw.size()-1] << endl;
}

Measured memory_bytes: 256
X = int(input())

def prime(q):
    count = 0
    for i in range(2,q):
        if q%i == 0:
            count = count +1
        else:
            count = count
    if count == 0:
        return 1
    else:
        return 0
  
ans = X
for i in range(X, X**2):
    if prime(i) == 1:
        print(ans)
        break
    else:
        ans =ans + 1
        

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<(n);++i)
#define rep2(i,a,b) for (ll i=(a);i<(b);++i)
#define debug(x) cout << #x << '=' << x << endl
#define all(v) (v).begin(),(v).end()
const ll MOD=1e9+7;
//const ll MOD=998244353;
const ll INF=1e9;
const ll IINF=1e18;
const double EPS=1e-9;
const double pi=acos(-1);
#define LE(n,m) (n<m+EPS)
#define GE(n,m) (n+EPS>m)

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

const int MAX_N=51;

int N;
vector<complex<double>> p;

inline std::complex<double> Circumcenter(std::complex<double> a, std::complex<double> b, std::complex<double> c) {

	//辺
	double eAB = abs(b - a);
	double eBC = abs(c - b);
	double eCA = abs(a - c);

	//角度(余弦定理)
	double aCAB = acos((eCA*eCA + eAB*eAB - eBC*eBC) / (2 * eCA*eAB));
	double aABC = acos((eAB*eAB + eBC*eBC - eCA*eCA) / (2 * eAB*eBC));
	double aBCA = acos((eBC*eBC + eCA*eCA - eAB*eAB) / (2 * eBC*eCA));

	double A = sin(2 * aCAB);
	double B = sin(2 * aABC);
	double C = sin(2 * aBCA);

	//外心の位置ベクトル(ベクトルの面積比の公式)
	std::complex<double> ans;
	ans.real((A*a.real() + B*b.real() + C*c.real()) / (A + B + C));
	ans.imag((A*a.imag() + B*b.imag() + C*c.imag()) / (A + B + C));

	return(ans);
}

inline double Circumradius(std::complex<double> a, std::complex<double> b, std::complex<double> c) {

	//辺
	double eAB = abs(b - a);
	double eBC = abs(c - b);
	double eCA = abs(a - c);

	//角度(余弦定理)
	double aCAB = acos((eCA*eCA + eAB*eAB - eBC*eBC) / (2 * eCA*eAB));

	//外接円の半径(正弦定理)
	double R = 0.5*eBC / sin(aCAB);

	return(R);

}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    rep(i,N){
        double a,b; cin >> a >> b;
        p.emplace_back(a,b);
    }
    double ans=100000;
    rep(i,N) rep2(j,i+1,N) rep2(k,j+1,N){
        complex<double> c=Circumcenter(p[i],p[j],p[k]);
        double r=Circumradius(p[i],p[j],p[k]);
        rep(l,N){
            if (!LE(abs(p[l]-c),r)) break;
            if (l==N-1) chmin(ans,r);
        }
    }
    rep(i,N) rep2(j,i+1,N){
        complex<double> c=(p[i]+p[j])/2.0;
        double r=abs(p[i]-p[j])/2.0;
        rep(l,N){
            if (!LE(abs(p[l]-c),r)) break;
            if (l==N-1) chmin(ans,r);
        }
    }
    if (N==2) ans=abs(p[0]-p[1])/2.0;
    cout << fixed << setprecision(10);
    cout << ans << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define rep2(i,j,n) for(int j=i;j<n;j++)
#define rep3(i,j,n) for(int j=i;j<=n;j++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define sp(n) cout << fixed << setprecision(n)
typedef long long ll;
using namespace std;
//const int mod = 1000000007;
int main(void){
    int n;ll k;cin>>n>>k;
    vector<ll> a(n);
    vector<int> d(100,0);
    rep(i,n){
        cin>>a[i];
        rep(j,40){
            if((a[i]&((ll)1<<j)))d[j]++;
        }
    }
    
    ll X=0;
    rrep(i,40){
        if(d[i]<=n/2){
            if(X+((ll)1<<i)>k)continue;
            X+=(ll)1<<i;
        }
    }
    
    ll res=0;
    rep(i,n){
        res+=(a[i]^X);
    }
    cout<<res<<endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
const int n_max = 1e5+10;
vector<int> g[n_max];
set<int> used;
bool tot_ok = true;

void dfs(int cv, int pv){
  // cout << cv << " " << pv << endl;
  bool ok = false;
  for(auto &nv : g[cv]){
    if(nv == pv) continue;
    dfs(nv,cv);    
  }
  if(used.count(cv)==1){
    ok = true;
  }
  if(!ok){
    if(used.count(pv)==0){
      ok = true;
      used.insert(cv);
      used.insert(pv);
    }
  }

  if(!ok){
    tot_ok = false;
  }

}


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

  int n;
  cin >> n;

  rep(i,n-1){
    int a,b;
    cin >> a >> b;
    --a;--b;
    g[a].pb(b);
    g[b].pb(a);
  }
  used.insert(-1);
  dfs(0,-1);

  cout << (tot_ok ? "Second" : "First") << endl;


  return 0;
    

}


Measured memory_bytes: 10496
#include <bits/stdc++.h>
#define Phuong_ ios_base::sync_with_stdio(0); cin.tie(0);

using namespace std;
using ll = long long;
char a[102][102];
int dx[4]={0, 0, -1, 1};
int dy[4]={1, -1, 0, 0};

struct inf
{
    int x,y;
    inf (int a, int b)
    {
        x=a; y=b;
    }
};

int main()
{
#ifndef RICARDO
    //freopen("input.txt", "r",stdin);
#endif
    Phuong_;
    int a,b,c;
    cin >> a >> b >> c;
    if (a+b+c>=22) cout << "bust"; else cout << "win";
    return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int N;
        int[] V,C,Z;
        int sum = 0;
        N = sc.nextInt();
        V = new int[N];
        C = new int[N];
        Z = new int[N];
        for (int i = 0; i < N; i++) {
            V[i] = sc.nextInt();
        }
        for (int i = 0; i < N; i++) {
            C[i] = sc.nextInt();
        }
        for (int i = 0; i < N; i++) {
            Z[i] = V[i] - C[i];
        }
        for (int i = 0; i < N; i++) {
            if (Z[i] > 0) {
                sum = sum + Z[i];
            }
        }
        System.out.println(sum);
    }
}

Measured memory_bytes: 21712
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Runtime.Remoting.Contexts;
using System.Security.Cryptography.X509Certificates;
using System.Security.Policy;
using System.Threading;

namespace Contest
{
    class Scanner
    {
        private string[] line = new string[0];
        private int index = 0;
        public string Next()
        {
            if (line.Length <= index)
            {
                line = Console.ReadLine().Split(' ');
                index = 0;
            }
            var res = line[index];
            index++;
            return res;
        }
        public int NextInt()
        {
            return int.Parse(Next());
        }
        public long NextLong()
        {
            return long.Parse(Next());
        }
        public string[] Array()
        {
            line = Console.ReadLine().Split(' ');
            index = line.Length;
            return line;
        }
        public int[] IntArray()
        {
            var array = Array();
            var result = new int[array.Length];
            for (int i = 0; i < array.Length; i++)
            {
                result[i] = int.Parse(array[i]);
            }

            return result;
        }
        public long[] LongArray()
        {
            var array = Array();
            var result = new long[array.Length];
            for (int i = 0; i < array.Length; i++)
            {
                result[i] = long.Parse(array[i]);
            }

            return result;
        }
    }

    class Program
    {
        private int N;
        private int[] A;
        private void Scan()
        {
            var sc = new Scanner();
            N = sc.NextInt();
            A = sc.IntArray();
        }

        public void Solve()
        {
            Scan();
            var arr = new long[N + 1];
            for (int i = 1; i <= N; i++)
            {
                arr[i] = arr[i - 1] + A[i - 1];
            }
            var map = new Dictionary<long, long>();
            foreach (var l in arr)
            {
                long o;
                map.TryGetValue(l, out o);
                map[l] = o + 1;
            }

            long ans = 0;
            foreach (var l in map)
            {
                ans += (l.Value - 1) * (l.Value) / 2;
            }
            Console.WriteLine(ans);
        }


        static void Main(string[] args)
        {
            new Program().Solve();
        }
    }
}

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

int main()
{
  int n;
  cin >> n;
  vector<int> l(n);
  int ans = 0;
  for (int i = 0; i < n; i++)
  {
    cin >> l[i];
  }

  for (int i = 0; i < n; i++)
  {
    for (int j = 0; j < n; j++)
    {
      for (int k = 0; k < n; k++)
      {
        if (i < j && j < k)
        {
          if (l[i] == l[j])
            continue;
          if (l[j] == l[k])
            continue;
          if (l[i] == l[k])
            continue;
          if ((ll)l[i] + l[j] + l[k] <= max({l[i], l[j], l[k]}) * 2)
            continue;
          ans++;
        }
      }
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3636
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define rep(i,n)for(ll i=0;i<n;i++)
#define ll long long
#define double long double
using namespace std;
signed main() {
	ll a, b, c;
	cin >> a >> b >> c;
	cout << a << " " << b << " " << 3 * c - b - a << endl;
	cout << 4 * c - 2 * a - b << " " << c << " " << 2 * a + b - 2 * c << endl;
	cout << b - c + a << " " << 2 * c - b << " " << 2 * c - a << endl;
	getchar(); getchar(); return 0;
}

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

typedef long long ll;
typedef pair<ll,ll> P;

const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;

#define rep(i, a, b) for(ll (i) = (a); (i) < (b);++i)



int main() {
	ll N;
	cin >> N;
	ll a, b;
	vector<ll> G[N];
	vector<P> vp;
	rep(i,1,N) {
		cin >> a >> b;
		a--;b--;
		G[a].emplace_back(b);
		G[b].emplace_back(a);
		vp.emplace_back(a,b);
	}

	ll K = 0;
	map<P, ll> I;
	vector<ll> cs(N, 0); // color of edge between its parent
	vector<ll> used(N, 0);
	queue<ll> que;

	used[0] = 1;
	que.emplace(0);
	while(!que.empty()) {
		ll v = que.front();que.pop();
		if (K < (ll)G[v].size()) K = G[v].size();
		ll cur = 1;
		for (auto u: G[v]) {
			if (used[u]) continue;
			if (cur == cs[v]) cur++;
			cs[u] = I[make_pair(u, v)] = I[make_pair(v, u)] = cur++;
			used[u] = 1;
			que.emplace(u);
		}
	}
	
	cout << K << endl;
	for (auto p: vp) cout << I[p] << endl;
	return 0;
}

Measured memory_bytes: 22128
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>
using namespace std; using ll = long long; using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vpll = vector<pll>;
//**デバッグ準備**//
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
void debug_out() { cerr << endl; }
template<typename Head, typename... Tail>
void debug_out(Head h, Tail... t) {
	cerr << " " << h;
	if (sizeof...(t) > 0) cerr << " :";
	debug_out(t...);
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> vec) {
	for (size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	return os;
}
ll ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.first > secondElof.first;
}
//**Snippetリスト**//
//rep, vin, all, iteLoop//
//bitSearch, bitList, gcdlcm, isPrime, primeFactorize, Npow, divisor, modinv, dfs, bfs, eratos//
//dijkstra, WarshallFloyd, BellmanFord, UnionFind, COM, digitDP ,RMQ//
ll i, j, k, l; ll N, M, K, H, W, L, X, Y, Z, R;
ll MOD = 1000000007; ll INF = 1LL << 62; ll ans = 0; ll z = 0, o = 1;
vl flag, color, D; vll path;
int main() {
	cin >> N;
	vector<string>S(N);
	for (i = 0; i < N; i++) cin >> S[i];
	sort(S.begin(), S.end());
	ans = 1;
	for (i = 0; i < N-1; i++) {
		if (S[i] != S[i + 1]) ans++;
	}
	cout << ans;
}

Measured memory_bytes: 9600
def read_input():
    s = input().strip()
    return s


def find_from_head(s, c):
    for i, sub in enumerate(s):
        if c == sub:
            return i

def find_from_tail(s, c):
    total = len(s) - 1

    for i, sub in enumerate(s[::-1]):
        if c == sub:
            return total - i

def submit():
    s = read_input()

    ai = find_from_head(s, 'A')
    zi = find_from_tail(s, 'Z')

    print(zi - ai + 1)

if __name__ == '__main__':
    submit()


Measured memory_bytes: 41456
# -*- coding: utf-8 -*-

N, K = map(int, input().split())

# スペースなしの入力
S = list(input())
s = S[K-1]

if s == 'A':
	S[K-1] = 'a'
elif s == 'B':
	S[K-1] = 'b'
else:
	S[K-1] = 'c'

print(''.join(S))

Measured memory_bytes: 3060
#include<stdio.h>

int main(){
	char O[51],E[51];
	scanf("%s%s",O,E);
	for(int i=0;;i++){
		if(O[i]=='\0')break;
		printf("%c",O[i]);
		if(E[i]=='\0')break;
		printf("%c",E[i]);
	}
	printf("\n");
	return 0;
}

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

const int mod = 998244353;
long long int ksm(long long int x,int b){
	long long int res = 1;
	while(b){
		if(b&1)	res=res*x%mod;
		x=x*x%mod;
		b>>=1;
	}
	return res;
}

long long int fac[300001];
long long int C(int n,int k){
	return fac[n]*ksm(fac[k],mod-2)%mod*ksm(fac[n-k],mod-2)%mod;
}


int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	fac[0]=fac[1]=1;
	for(int i=2;i<=300000;i++)
		fac[i]=fac[i-1]*i%mod;
	int n,a,b;
	cin>>n>>a>>b;
	long long int k;
	cin>>k;
	long long int res = 0;
	for(int i=0;i<=n;i++){
		int j;
		long long int z = k-i*a;
		if(z%b==0&&z/b<=n&&z/b>=0)
			j=z/b;
		else
			continue;
		res = (res + C(n,i)*C(n,j))%mod;
	}
	cout<<res<<endl;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<ll>;
using vs = vector<string>;
#define  rep(i,n) for(ll i = 0; i < (n); ++i)
#define  red(i,n) for(ll i = (n)-1; i >= 0; --i)
#define  all(a)   begin(a),end(a)
#define  pb(a)    push_back(a)
#define  yn(a)    cout << ( (a)?"Yes\n":"No\n" );
inline ll gcd(ll a,ll b) { return b?gcd(b,a%b):a; }
const ll INF = 1e9+9, LINF = 1e18;


int main()
{
    ll n,m,ans=0;
    cin>>n>>m;
    ll a[m][2];
    rep(i,m)cin>>a[i][0]>>a[i][1],a[i][0]--,a[i][1]--;

    rep(i,m){ 
        bool x[n]={0};
        x[a[i][0]]=1;
        rep(k,m)rep(j,m){
            if(i==j)continue;
            if(x[a[j][0]]==1)x[a[j][1]]=1;
            if(x[a[j][1]]==1)x[a[j][0]]=1;
        }
        rep(k,n)if(x[k]==0){
            ans++;
            break;
        }
    }
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	cin>>s;
	char a=s.at(2);
	char b=s.at(3);
	char c=s.at(4);
	char d=s.at(5);
	if(a==b && c==d)
	cout<<"Yes\n";
	else
	cout<<"No\n"; 
	return 0;
} 

Measured memory_bytes: 256
n = int(input())
a = str(input())
b = str(input())
c = str(input())
d = 0
for i in range(n):
    if a[i] == b[i] == c[i]:
        pass
    elif a[i] != b[i] and b[i] != c[i] and c[i] != a[i]:
        d += 2
    else:
        d += 1
print(d)

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

int N;
vector<int> h;

int getminindex(vector<int> vec) {
    vector<int>::iterator iter = min_element(vec.begin(), vec.end());
    return distance(vec.begin(), iter);
}

int mizuyari(vector<int> hana) {
    int n = hana.size();
    if (n == 0) return 0;
    int minindex = getminindex(hana);
    int count, tempmin;
    count = tempmin = hana[minindex];
    for (int i = 0; i < n; i++) hana[i] -= tempmin;
    vector<int> lefthana, righthana;
    for (int i = 0; i < minindex; i++) lefthana.push_back(hana[i]);
    for (int i = minindex+1; i < n; i++) righthana.push_back(hana[i]);
    count += mizuyari(lefthana);
    count += mizuyari(righthana);
    return count;
}

int main() {
    scanf("%d", &N);
    h.resize(N);
    for (int i = 0; i < N; i++) scanf("%d", &h[i]);
    int ans = mizuyari(h);
    cout << ans << endl;  // ans を mizuyari にしちゃっていた　なんで成立？
    return 0;
}

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

int main(void){
  int n; cin >> n;
  int l[n]; rep(i,n) cin >> l[i];
  sort(l,l+n);
  ll ans = 0;
  for(int i = n-1; i > 0; i--){
    for(int j = i - 1; j >= 0; j--){
      int left = -1,right = j;
      while(right - left != 1){
        int mid = (left+right)/2;
        if(l[mid] + l[j] > l[i]){
          right = mid;
        }
        else left = mid;
        if(right - left == 1) break;
      }
      ans += j - right;
    }
  }
  cout << ans << endl;
  return 0;
}


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

int main(){
  int n;
  int i;
  cin >> n;
  vector<int> height(n);
  for(i=0; i<n; i++){
     cin >> height.at(i);
  }
  vector<int> chiisai(n);
  chiisai.at(0) = 0;
  chiisai.at(1) = abs(height.at(1)-height.at(0));
  for(int j=2; j<n; j++){
     chiisai.at(j) = min(chiisai.at(j-2)+abs(height.at(j)-height.at(j-2)),chiisai.at(j-1)+abs(height.at(j)-height.at(j-1)));
  }
  cout << chiisai.at(n-1) <<endl;
}

Measured memory_bytes: 4056
# -*- coding: utf-8 -*-
# スペース区切りの整数の入力
X, Y = map(int, input().split())
# 文字列の入力
#s = input()
#開業されたN個要素を受け付ける
#input_list = [list(map(int, input().split())) for i in range(N)]

ans = "Yes"

if not Y%2 == 0:
    ans = "No"
elif Y < 2*X:
    ans = "No"
elif 4*X < Y:
    ans = "No"

print(ans)


Measured memory_bytes: 9188
package main

import (
	"fmt"
)

func main() {
	var x int
	fmt.Scan(&x)
	goods := [6]int{100, 101, 102, 103, 104, 105}
	dp := make([]bool, x+1)
	dp[0] = true
	for i := 1; i <= x; i++ {
		for _, price := range goods {
			j := i - price
			if j >= 0 && dp[j] {
				dp[i] = true
				break
			}
		}
	}
	if dp[x] {
		fmt.Println(1)
	} else {
		fmt.Println(0)
	}
}


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

int main() {
  string s;
  cin >> s;
  map<char, int> ms;
  for(int i = 0; i < s.size(); ++i) {
    ms[s[i]]++;
  }
  for(auto c : ms) {
    if(c.second != 1) {
      cout << "no" << endl;
      return 0;
    }
  }
  cout << "yes" << endl;
  return 0;
}

Measured memory_bytes: 256
import math

N, D = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(N)]
count = 0
for i in range(N-1):
    for j in range(i+1, N):
        squared_sub = [pow(X_i - X_j, 2) for (X_i, X_j) in zip(X[i], X[j])]
        distance = math.sqrt(sum(squared_sub))
        if distance == int(distance):
            count += 1
print(count)

Measured memory_bytes: 38512
#A,G,C,T=0,1,2,3
#AGC,ACG,GACを含まない
#A?GC,AG?Cを含まない
import copy

n=int(input())
A=[[1,1,1,1],[1,1,0,1],[1,0,1,1],[1,1,1,1]] #3文字前がAのとき
B=[[3,3,2,3],[3,3,3,3],[3,3,3,3],[3,3,3,3]] #それ以外
mod=10**9+7

for _ in range(n-3):
    nA=[[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0]]
    nB=[[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0]]
    for i in range(4):
        for j in range(4): #付け足す文字
            if j!=2: #3文字前がAで、Cを足さないとき
                if not (i==2 and j==1): #ACG
                    nA[i][j]+=A[0][i]
                nB[i][j]+=A[1][i]
                nB[i][j]+=A[2][i]
                nB[i][j]+=A[3][i]
            else: #Cを足すとき
                if i!=1: #A?GC
                    nA[i][j]+=A[0][i]
                    #nB[i][j]+=A[1][i] #AG?C
                    nB[i][j]+=A[2][i]
                    nB[i][j]+=A[3][i]
            
            if not i*j==2: #AGC,ACG
                nA[i][j]+=B[0][i]
            if not (i==0 and j==2): #GAC
                nB[i][j]+=B[1][i]
            nB[i][j]+=B[2][i]
            nB[i][j]+=B[3][i]
    for a in nA:
        for i in range(4):
            a[i]%=mod
    for b in nB:
        for i in range(4):
            b[i]%=mod
    A=copy.copy(nA)
    B=copy.copy(nB)
    
ans=0
for a in A:
    ans+=sum(a)%mod
for b in B:
    ans+=sum(b)%mod 
print(ans%mod)

Measured memory_bytes: 3444
import numpy as np

minDis = np.zeros((10,10),dtype = int)
minDis.fill(10**18)

edge = np.zeros((10,10),dtype = int)
for i in range(10):
    minDis[i][i] = 0

h,w = map(int,input().split())
mat = np.zeros((h,w),dtype = int)
for i in range(10):
    edge[i] = list(map(int,input().split()))
for i in range(h):
    mat[i] = list(map(int,input().split()))

for start in range(10):
    #shortest path
    dis = [10**18] *10
    points = set(range(10))
    dis[start] = 0
    
    while points:
        #find point with min dis
        md = 10**18+1
        idx = start
        for point in points:
            if dis[point] <md:
                md = dis[point]
                idx = point
        points.remove(idx)
        for neighbour in range(10):
            if neighbour == idx:
                continue
            dis[neighbour] = min(dis[neighbour],dis[idx]+edge[idx][neighbour])
    minDis[start] = dis
#print(minDis) 
res = 0
for i in range(h):
    for j in range(w):
        if mat[i][j] == -1:
            continue
        res += minDis[mat[i][j]][1]
print(res)


Measured memory_bytes: 13460
N=int(input())
S=list(str(input()))

S_right=[]
S_left=[]
for i in range(0,(N//2)):
    S_left.append(S[i])
for i in range((N//2),N):
    S_right.append(S[i])
    
S_left=("").join(S_left)
S_right=("").join(S_right)

print("Yes" if S_left==S_right else "No")

Measured memory_bytes: 3064
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

int main() {
    int N;
    cin >> N;
    vector<int> W(N + 1);
    W[0] = 0;
    for (int i = 1; i <= N; ++i) {
        cin >> W[i];
        W[i] += W[i - 1];
    }

    int ans = 1 << 30;

    for (int T = 1; T < N; ++T) {
        ans = min(ans, abs(W[N] - W[T] - W[T]));
    }

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

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

int main() {
    //input
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    if(a+b > c+d){
        cout << "Left";
    }else if(a+b < c+d){
        cout << "Right";
    }else{
        cout << "Balanced";
    }

    return 0;
}

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

using namespace std;

typedef long long int ll;

#define fastIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define f(i,n) for(int i=0;i<n;i++)

int main() {
	
	fastIO
	ll a,b;
	cin>>a>>b;
  if(a<(2*b))
    cout<<0;
  else cout<<(a-2*b);
	return 0;
}

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

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
#include <string>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <climits>
#include <bitset>
#include <array>
#include <deque>
#include <queue>
#include <map>
#include <set>
#define all(x) (x).begin(),(x).end()

const int MOD = 1e9 + 7;

void solve(){

}
int main(){
    string a,b;
    cin >> a >> b;
    int s = (int)a.size() - (int)b.size();
    if (s == 0) {
        s = a.compare(b);
    }
    if (s > 0) {
        cout << "GREATER" << endl;
    } else if (s < 0) {
        cout << "LESS" << endl;
    } else {
        cout << "EQUAL" << endl;
    }

    return 0;
}


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

int main(){
  int h,w,x,y,r;
  cin>>h>>w>>x>>y>>r;
  if(x-r>=0&&y-r>=0&&x+r<=h&&y+r<=w){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}



Measured memory_bytes: 3116
#include <iostream>

using namespace std;

int N, Z, W;
int a[2005];
int dp[2005][2];

int dfs(int p, int t)
{
	if(dp[p][t] != -1) return dp[p][t];
	int ret = a[p];
	
	for(int i = p+1; i < N; i++){
		if(t == 0) ret = max(ret, dfs(i, 1));
		else ret = min(ret, dfs(i, 0));
	}
	return dp[p][t] = ret;
}

int main(void)
{
	cin >> N >> Z >> W;
	for(int i = 1; i <= N; i++){
		cin >> a[i];
	}
	a[0] = W;
	for(int i = 0; i <= N; i++) a[i] = abs(a[N] - a[i]);
	for(int i = 0; i <= N; i++){
		dp[i][0] = dp[i][1] = -1;
	}
	
	cout << dfs(0, 0) << endl;
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
typedef long long ll;
#define  rep(i,a,b)for(long long i=a;i<b;++i)
#define  rrep(i,a,b)for(int i=a;i>=b;--i)
#define  yesno(flag)if(flag)cout<<"Yes"<<endl; else cout<<"No"<<endl;
using namespace std;
const ll INF=1000000000000LL;
const ll r197=1000000007;
typedef pair<ll,ll>P;
typedef pair<int,P>Pa;
bool Inframe(int a,int b,int c,int d,int h,int w){
	if(a+b>=0&&a+b<h&&c+d>=0&&c+d<w)return true;
	return false;
}
int h,w,k;
vector<P> v[100001];
P g[100001];
ll dp[101][8];
ll zet(int b,int i){
	if(i>=w-1)return 1;
	if(i==b)return zet(b,i+2);
	if(i+1==b)return zet(b,i+1);
	return zet(b,i+2)+zet(b,i+1);
}
ll met(int b,int i){
	if(i>=w-1)return 1;
	if(i==b-1)return met(b,i+2);
	if(i==b)return met(b,i+1);
	return met(b,i+1)+met(b,i+2);
}
ll calc(int n,int m){
	if(dp[n][m]!=-1)return dp[n][m];
	if(n==h&&m==k-1)return 1;
	if(n==h&&m!=k-1)return 0;
	ll res=0;
	if(m>0)res=(res+calc(n+1,m-1)*zet(m-1,0))%r197;
	if(m<w-1)res=(res+calc(n+1,m+1)*zet(m,0))%r197;
	res=(res+calc(n+1,m)*met(m,0))%r197;
	return dp[n][m]=res;
}
int main() {
	memset(dp,-1,sizeof(dp));
	cin>>h>>w>>k;
//	cout<<zet(0,0)<<endl;
	cout<<calc(0,0)<<endl;
	return 0;
}


Measured memory_bytes: 2560
#include <iostream>
#include <algorithm>
#include <utility>
#include <map>
#include <numeric>

using namespace std;

const int MOD = 1000000007;

long long mpow(long long x, long long n) {
	if (n == 0) return 1;
	if (n & 1) return x * mpow(x * x % MOD, n >> 1) % MOD;
	return mpow(x * x % MOD, n >> 1);
}

int main() {
	int n; cin >> n;
	map<pair<long long, long long>, pair<int, int> > mp;
	int azero = 0, bzero = 0, ans = 0;
	for (int i = 0; i < n; ++i) {
		long long a, b; cin >> a >> b;
		if (!a && !b) ++ans;
		else if (!a) ++azero;
		else if (!b) ++bzero;
		else {
			long long g = gcd(a, b); //gcd(a,0)=gcd(0,a)=|a|
			a /= g, b /= g;
			if ((a < 0) ^ (b < 0)) ++mp[make_pair(abs(a), abs(b))].first;
			else ++mp[make_pair(abs(b), abs(a))].second;
		}
	}
	long long tmp = (mpow(2, azero) + mpow(2, bzero) - 1 + MOD) % MOD;
	for (auto [_, e] : mp)
		(tmp *= (mpow(2, e.first) + mpow(2, e.second) - 1 + MOD) % MOD) %= MOD;
	ans = (ans + tmp - 1 + MOD) % MOD;
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 15984
n, m = map(int, input().split())
data = list(map(int, input().split()))
rule = [list(map(int, input().split())) for _ in range(m)]
bord = [[] for _ in range(n)]
for i in range(m):
    bord[rule[i][0]-1].append(rule[i][1]-1)
    bord[rule[i][1]-1].append(rule[i][0]-1)
for j in range(n):
    bord[j] = set(bord[j])
    bord[j] = list(bord[j])
ans = 0
for s in range(n):
    bl = True
    if len(bord[s]) == 0:
        ans += 1
    else:
        for t in range(len(bord[s])):
            if data[s] <= data[bord[s][t]]:
                bl = False
        if bl:
            ans += 1
print(ans)


Measured memory_bytes: 50660
def main():
    N,M = map(int, input().split())
    A = list(map(int,input().split()))

    A.sort(reverse=True)

    all_num = 0
    for i in range(N):
        all_num += A[i]

    thr = all_num / (4*M)

    for i in range(M):
        if A[i] < thr:
            print("No")
            exit()
    
    print("Yes")

main()

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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

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




void solve() {
    ld a, b; cin >> a >> b;
    cout << a/b << endl;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


Measured memory_bytes: 7888
#include<map>
#include<iostream>
#include<string>
using namespace std;
int main(){
	int n;
	cin>>n;
	map<string, bool> mp;
	for(int i=0;i<n;i++){
		string s1, s2;
		cin>>s1>>s2;
		if(s1 == "insert"){
			mp[s2] = true;
		}else{
			if(mp[s2]){
				cout<<"yes"<<endl;
			}else{
				cout<<"no"<<endl;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 52468
taro = 0
hanako = 0
nums = int(input())

for _ in range(nums):
    t, h = input().split()
    if t > h:
        taro += 3
    elif t < h:
        hanako += 3
    else:
        taro += 1
        hanako += 1

print(taro, hanako)


Measured memory_bytes: 5596
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  int a[n];
  for(int i=0;i<n;i++)
  {
	cin>>a[i];
  }
  map<int,int> d;
  for(int i=0;i<n;i++)
  {
    ++d[a[i]];
  }
  if(n==d.size())
    cout<<"YES";
  else
    cout<<"NO";
  return 0;
}

Measured memory_bytes: 10368
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int count = 0;
		for(int i = 1;i<=x;i++) {
			String temp = String.valueOf(i);
			if(temp.length()%2!=0)count++;
		}
		System.out.println(count);
	}

}


Measured memory_bytes: 25424
#Pythonだと少し間に合わない
N = int(input())

x = (3500 * N + (4 * 2500 - 2 * N) - 1) //(4 * 2500 - 2 * N)
for h in range(x + 1, 0, -1):
    for n in range(3500, 0, -1):
        if (N * h * n) >= (4 * h * n - N * (h + n)) > 0:
            if (N * h * n) % (4 * h * n - N * (h + n)) == 0:
                w = (N * h * n) // (4 * h * n - N * (h + n))
                print (h, n, w)
                exit()


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#define print(n) std::cout << n << std::endl
#define FOR(i,n) for(int i = 0; i < n; i++)
using namespace std;

int main(){
    int x,t;
    cin >> x >> t;
    if(x > t) print(x-t);
    else print(0);
}

Measured memory_bytes: 256