akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,sse3,sse4,popcnt,abm,mmx")

#include <bits/stdc++.h>	
#include <stdio.h>    
 
using namespace std;
     
#define F first
#define S second
#define lb lower_bound          	
#define ub upper_bound
#define pb push_back
#define pf push_front    
#define ppb pop_back
#define mp make_pair
#define bpp __builtin_popcount                                                                                        
#define sqr(x) ((x) * (x))
#define al 0x3F3F3F3F
#define sz(x) x.size()
#define all(x) x.begin(), x.end()
#define in insert
#define ppf pop_front
#define endl '\n'
#define int long long
 
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
 
const int mod = (int)1e9 + 7;                                  
const int N = (int)2e5 + 123;
const ll inf = (ll)3e18 + 1;
                                       
const double pi = acos(-1.0);
const double eps = 1e-7;
const int dx[] = {0, 0, 1, 0, -1};   																																					
const int dy[] = {0, 1, 0, -1, 0};                                                                                                                                                                                                                 

int n, a[N], pref[N][21];

inline void boost () {
	ios_base :: sync_with_stdio (NULL);
	cin.tie (NULL), cout.tie (NULL);                                                                                        
}        

inline void Solve () {  
	boost ();
	cin >> n;
	for (int i = 1; i <= n; i ++) {
		int x;
		cin >> x;
		for (int bit = 0; bit < 20; bit ++) {
			pref[i][bit] = pref[i - 1][bit];
			if (x & (1 << bit))
				pref[i][bit] ++;
		}
	}
	int ans = 0;
	for (int i = 1; i <= n; i ++) {
		int pos = i, l = i + 1, r = n;
		while (l <= r) {
			int mid = l + r >> 1;
			bool ok = 1;
			for (int bit = 0; bit < 20; bit ++)
				if (pref[mid][bit] != pref[i - 1][bit] && pref[mid][bit] - pref[i - 1][bit] != 1) {
					ok = 0;
					break;	
			   }
			if (ok) pos = mid, l = mid + 1;
			else r = mid - 1;
		}
		ans += pos - i + 1;
	}
	cout << ans;
}                                                  
                 
main () { 
//	freopen("t/reasure.in", "r", stdin);    
//	freopen("treasure.out", "w", stdout);          
	int tt = 1;
//	cin >> tt;
	while (tt --) {
		Solve ();
	}        
	return 0;      
}                       

Measured memory_bytes: 33024
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
using namespace std;

int main() {
	long long int n,m,a,b,c,d,e;
	long double z,w;
	string str;
	char ch;
	long long int x[130]={};
	cout << fixed << setprecision(10);
	cin>>a;
	if(a%2==0){cout<<a;}
	else{cout<<2*a;}
	



	cout<<endl;
} 


Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int res = 0;
        if(a%2 == 0){
            res = a/2;
        }
        if(a%2 != 0){
            res = a/2 + 1;
        }
        System.out.println(res);
    }
}

Measured memory_bytes: 21588
#include <algorithm>
#include <iostream> //入出力
#include <stdio.h>
#include <map>
#include <set>
#include <string>
#include <math.h> //算術演算子
#include <vector>
#include <cstdlib>
#include <queue>
#include <stack>
#include <list>
#include <iomanip> //小数点以下を表示させる(setprecision())
//#include <bits/stdc++.h>
using namespace std;
typedef long long ll; //64bit型

#define debug(x) cerr << x << " " \
                      << "(L:" << __LINE__ << ")" << '\n'
#define PRINT(V)                                   \
        {                                          \
                for (int i = 0; i < V.size(); i++) \
                {                                  \
                        cout << V[i] << " ";       \
                }                                  \
                cout << endl;                      \
        }

int gcd(int a, int b)
{
        return b ? gcd(b, a % b) : a;
}

int main()
{
        //input->compute->output//

        string S, T;
        cin >> S >> T;

        int n = S.size();

        for (int i = 0; i < n; i++)
        {
                char a = S[n - 1];
                for (int j = n - 1; j > 0; j--)
                {

                        S[j] = S[j - 1];
                }
                S[0] = a;

                if (S == T)
                {
                        cout << "Yes" << endl;
                        return 0;
                }
        }

        cout << "No" << endl;
        return 0;
}


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

using namespace std;

char stones[200005];

int bChange[200005];
int wChange[200005];

int main(){

	int n;
	cin >> n;
	for(int i=1;i<=n;i++)
		cin >> stones[i];
	int w=0,b=0;
	for(int i=1;i<=n;i++){
		if(stones[i]=='#'){
			w++;
			wChange[i]=wChange[i-1];
		}
		if(stones[i]=='.'){
			wChange[i]=w+wChange[i-1];
			w=0;
		}
	}
	w=0;
	for(int i=n;i>0;i--){
		if(stones[i]=='.'){
			b++;
			w++;
			bChange[i] = bChange[i+1];
		}
		if(stones[i]=='#'){
			bChange[i]=b+bChange[i+1];
			b=0;
		}
	}
	int ans=1e9;
	for(int i=1;i<=n;i++){
		ans = min(ans,bChange[i]+wChange[i]);
	}
	ans = min(ans,min(n,n-w));
	cout << ans;
}

Measured memory_bytes: 2048
#include <iostream>
#include <iomanip>
#include <random>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <sstream>
#include <bitset>
#include <cassert>
#include <fstream>
#include <queue>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <limits>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
#define DBG(X) cout << #X << "=" << (X) << '\n';
#define SAY(X) cout << (X) << '\n';
#else
#define DBG(X)
#define SAY(X)
#endif

#define M_PI       3.14159265358979323846

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

const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);

const int NIL = -1;
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> inline T sign(T x) { return T(x > 0) - T(x < 0); }
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> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

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

    if (s == "Sunny")
        std::cout << "Cloudy";
    else if (s == "Cloudy")
        std::cout << "Rainy";
    else if (s == "Rainy")
        std::cout << "Sunny";


    return 0;
}


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

void solve(){
  string s, ans; cin >> s;
  int n = s.size();
  for(int i = 0; i < n; i++){
    if(i % 2 == 0) ans += s[i];
  }
  cout << ans << endl;
  return;
}

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


Measured memory_bytes: 512
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return list(map(list, input().split()))
def S(): return list(input().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    n = II()
    ans = 0
    for i in range(1, n + 1):
        ans += i & 1
    print(ans/n)
    return

#B
def B():
    n, k = LI()
    h = LI()
    ans = 0
    for i in h:
        ans += i >= k
    print(ans)
    return

#C
def C():
    n = II()
    a = LI()
    d = defaultdict(int)
    for i in range(n):
        d[a[i] + 1] = i + 1
    for _, v in sorted(d.items()):
        print(v, end=" ")
    print()
    return

def primes(n):
    """ Input n>=6, Returns a list of primes, 2 <= p < n """
    """ 6以上の数であれば p (素数) <= n のlistを返す """
    n, correction = n-n%6+6, 2-(n%6>1)
    sieve = [True] * (n//3)
    for i in range(1,int(n**0.5)//3+1):
        if sieve[i]:
            k=3*i+1|1
            sieve[      k*k//3      ::2*k] = [False] * ((n//6-k*k//6-1)//k+1)
            sieve[k*(k-2*(i&1)+4)//3::2*k] = [False] * ((n//6-k*(k-2*(i&1)+4)//6-1)//k+1)
    return [2,3] + [3*i+1|1 for i in range(1,n//3-correction) if sieve[i]]

#D
def D():
    a, b = LI()
    p = primes(int(math.sqrt(max(a, b))) + 1)
    ans = 1
    for i in p:
        if a % i == b % i == 0:
            ans += 1
    print(ans)
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == '__main__':
    B()


Measured memory_bytes: 51568
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define inf 1e18
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define pb push_back
#define ff first
#define ss second
#define vll vector<ll>
#define pii pair<ll,ll>
#define sz(v) (v).size()
#define srt(v) sort(v.begin(),v.end())
#define ull unsigned long long
#define tell(a) cout<<a<<" "
#define el cout<<endl
#define rev(v) reverse(v.begin(),v.end())
#define rep(i,a,n) for(int i=a;i<n;i++)
ll power(ll x, ll y, ll p){ll res = 1;x = x % p;while (y > 0){   if (y & 1)res = (res*x) % p;y = y>>1;
x = (x*x) % p;}return res;}

int main()
{
	IOS;
	int k,a,b;
	cin>>k>>a>>b;
	for(int i=a;i<=b;i++)
	{
		if(i%k==0)
		return cout<<"OK",0;
	}
	cout<<"NG";
}



Measured memory_bytes: 3608
#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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repk(i,k,n) for (int i = k; i <= (int)(n); i++)
#define MAX 100010
#define PI 3.14159265359

using namespace std;


int main(){
    double a,b,x;
    scanf("%lf%lf%lf",&a,&b,&x);

    double ans;
    if(a * a * b / 2.0 <= x) {
        ans = atan(2 * (a * a * b - x) / (a * a * a));
    } else {
        ans = PI / 2 - atan(2 * x / (a * b * b));
    }
    
    printf("%.11lf\n",ans * 180.0 / PI);



    return 0;
}

Measured memory_bytes: 888
#include <iostream>

using namespace std;

int main()
{
    int N;
    cin >> N;
    if (N % 1000 == 0)
    {
        cout << 0;
    }
    else
    {
        cout << 1000 * (N / 1000 + 1) - N;
    }
    return 0;
}

Measured memory_bytes: 3628
//#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define MP make_pair
#define PB push_back
#define MOD 1000000007
#define INF (1LL<<30)
#define LLINF (1LL<<60)
#define PI 3.14159265359
#define EPS 1e-12
//#define int ll

bool prime[100010];

signed main(void)
{
	while(true) {
		int m, a, b;
		cin >> m >> a >> b;
		if(!m && !a && !b) break;

		memset(prime, true, sizeof(prime));
		prime[0] = prime[1] = false;
		for (int i = 2; i * i <= m; i++) {
			if (prime[i]) {
				for (int j = 2 * i; j <= m; j += i) {
					prime[j] = false;
				}
			}
		}

		//cout << "a:" << endl;
		int ma = -1, p, q;
		for(int i=2; i*i<=m; ++i) {
			for(int j=2; i*j<=m; ++j) {
				//cout << i << " " << j << endl;
				if(!prime[i] || !prime[j] || i > j) continue;
				//cout << i << " " << j << endl;
				if(i*j <= m && a*j <= b*i) {
					if(ma < i*j) {
						ma = i*j;
						p = i;
						q = j;
					}
				}
			}
		}
		cout << p << " " << q << endl;
	}

	return 0;
}

Measured memory_bytes: 3180
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
using namespace std;
bool find(vector<char>l, char c) {
	for (int i = 0; i < l.size(); i++)
		if (l[i] == c)return true;
	return false;
}
int main() {
	int n; cin >> n;
	string s[60];
	vector<char>l;
	for (int i = 0; i < n; i++){
		cin >> s[i];
		for (int j = 0; j < s[i].size(); j++)
			if (!find(l, s[i][j]))l.push_back(s[i][j]);
	}
	sort(l.begin(), l.end());
	string str;
	for (int i = 0; i < l.size(); i++){
		int kn = 60;
		for (int j = 0; j < n; j++){
			int sum = 0;
			for (int k = 0; k < s[j].size(); k++){
				if (s[j][k] == l[i])sum++;
			}
			kn = min(sum, kn);
		}
		for (int j = 0; j < kn; j++)str += l[i];
	}
	cout << str << endl;
}

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

#define F first
#define S second
#define prev azaza
#define MP make_pair
#define PB push_back

using namespace std;
typedef long long ll;
typedef long double ld;

const int max_n = 350, inf = 1000111222;

vector<pair<int, int> > p;

int main()
{
    //freopen("input.txt", "r", stdin);
    int n;
    cin >> n;
    bool ch = 0, nech = 0;
    for (int i = 0; i < n; ++i) {
        int x, y;
        cin >> x >> y;
        if ((x + y) % 2 == 0) {
            ch = 1;
        }  else {
            nech = 1;
        }
        p.push_back({x, y});
    }
    if (ch && nech) {
        cout << -1;
        return 0;
    }
    vector<ll> lengths={1};
    while (lengths.size() < 39) {
        lengths.PB(lengths.back() * 2);
    }
    if (ch) {
        lengths.insert(lengths.begin(), 1);
    }
    int m = lengths.size();
    cout << m << endl;
    for (int i = m - 1; i >= 0; --i) {
        cout << lengths[i] << ' ';
    }
    cout << endl;
    for (int i = 0; i < n; ++i) {
        ll x = p[i].F, y = p[i].S;
        for (int j = lengths.size() - 1; j >= 0; --j) {
            ll len = lengths[j];
            if (abs(x) > abs(y)) {
                if (x > 0) {
                    x -= len;
                    cout << 'R';
                } else {
                    x += len;
                    cout << 'L';
                }
            } else {
                if (y > 0) {
                    y -= len;
                    cout << 'U';
                } else {
                    y += len;
                    cout << 'D';
                }
            }
        }
        cout << endl;
    }


    return 0;
}




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

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

typedef long long ll;

const int INF = 1 << 30;
const ll LLINF = 1LL << 62;

int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N; cin >> N;
    int ans = 0;
    //A*B <= N-1を満たすものの個数
    for(int a = 1; a <= N-1; a++){
        //b <= (N-1)/A
        ans += (N-1)/a;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3664
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc =new Scanner(System.in);
		int N=sc.nextInt();
		int K=sc.nextInt();
		int[] a=new int[N];
		int[] data=new int[200000];
		Arrays.fill(data,0);
		int i,A,cnt=0,m,ans=0;
		for(i=0;i<N;i++) {
			a[i]=sc.nextInt();
			A=a[i];
			data[A]++;
		}
		for(i=0;i<200000;i++) {
			if(data[i]>0)cnt++;
		}
		m=cnt-K;
		Arrays.sort(data);
		for(i=200000-cnt;i<200000-cnt+m;i++) {
			ans+=data[i];
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 69448
#include <stdio.h>

int main(){
  int K;
  scanf("%d",&K);
  
  int even=0,odd=0;
  for(int i=1;i<=K;i++){
    if((i%2) == 0) even++;
    if((i%2) != 0) odd++;
  }
  
  printf("%d",even*odd);
}

Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<functional>
#include<map>
#include<cstring>
#include<unordered_map>
using namespace std;

vector<int>a[100005];
int saiki(int c) {
	if (a[c].size() == 0)return 0;
	vector<int>k;
	for (int d = 0; d < a[c].size(); d++) {
		k.push_back(saiki(a[c][d]));
	}
	sort(k.begin(),k.end(), greater<int>());
	int MAX = 0;
	for (int e = 0; e < a[c].size(); e++) {
		MAX = max(MAX, k[e] + e + 1);
	}
	return MAX;
}
int main() {
	int c; cin >> c;
	for (int d = 1; d < c; d++) {
		int e; scanf("%d", &e); e--;
		a[e].push_back(d);
	}
	cout << saiki(0) << endl;
}

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

#define for_(i,a,b) for(int i=a;i<b;++i)
#define ALL(a) a.begin(),a.end()
#define INIT(a,b) memset(a,b,sizeof(a))
using lint = long long int;

template< typename T >
class RangeMinimumQuery {
private:
	int N;
	vector< T > rmq;
	
public:
	RangeMinimumQuery() {}
	RangeMinimumQuery(vector< T >& ary) { build(ary); }
	
	void build(vector< T >& ary) {
		N = ary.size();
		
		int logN = 1;
		for (int k = 1; k < N; k *= 2) ++logN;
		
		int *r = new int[N * logN];
		int *b = r; copy(ary.begin(), ary.begin() + N, b);
		
		for (int k = 1; k < N; k *= 2) {
			copy(b, b + N, b + N); b += N;
			for_(i,0,N-k) b[i] = min(b[i], b[i + k]);
		}
		
		rmq.assign(N * logN, 0);
		int len = N * logN;
		for_(i,0,len) rmq[i] = r[i];
		
		delete [] r;
	}
	
	T query(int l, int r) {//[l,r]
		int z = r - l, k = 0, e = 1, s;
		s = ( (z & 0xffff0000) != 0 ) << 4; z >>= s; e <<= s; k |= s;
		s = ( (z & 0x0000ff00) != 0 ) << 3; z >>= s; e <<= s; k |= s;
		s = ( (z & 0x000000f0) != 0 ) << 2; z >>= s; e <<= s; k |= s;
		s = ( (z & 0x0000000c) != 0 ) << 1; z >>= s; e <<= s; k |= s;
		s = ( (z & 0x00000002) != 0 ) << 0; z >>= s; e <<= s; k |= s;
		return min( rmq[l + N * k], rmq[r + N * k - e + 1] );
	}
};

int main() {
    int H, W, M;
    cin >> H >> W >> M;

    vector<int> y(M), x(M);
    for_(i,0,M) {
        cin >> y[i] >> x[i];
        --y[i];
        --x[i];
    }

    vector<int> sum_y(H, 0), sum_x(W, 0);
    for_(i,0,M) {
        sum_y[y[i]]++;
        sum_x[x[i]]++;
    }

    int ans = 0;
    for_(i,0,M) ans = max(ans, sum_y[y[i]] + sum_x[x[i]] - 1);
    
    //
    vector<vector<int>> X(H, vector<int>());
    for_(i,0,M) X[y[i]].push_back(x[i]);
    for_(y,0,H) {
        X[y].push_back(-1);
        X[y].push_back(W);
        sort(ALL(X[y]));
    }

    for_(x,0,W) sum_x[x] *= -1;
    RangeMinimumQuery<int> RMQ(sum_x);
    for_(y,0,H) {
        int m = X[y].size();
        for_(i,0,m-1) {
            int L = X[y][i] + 1, R = X[y][i + 1] - 1;
            if (L > R) continue;
            int a = RMQ.query(L, R);
            ans = max(ans, sum_y[y] - a);
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 73472
def operate(a, ops)
  n = a.size
  m = ops.size
  i = 0
  m.times do |j|
    b, c = ops[j]
    b.times do
      return if i == n
      return if c <= a[i]
      a[i] = c
      i += 1
    end
  end
end


n, m = gets.split.map(&:to_i)
a = gets.split.map(&:to_i).sort

ops = []
m.times do
  ops << gets.split.map(&:to_i)
end
ops.sort!{|a,b| -(a[1] <=> b[1])}

operate(a, ops)

puts a.inject{|result,x| result += x}


Measured memory_bytes: 19224
#include<cstdio>
#include<cmath>
#include<iostream>
#include<cstring>
#include<ctime>
#include<map>
#include<queue>
#include<cctype>
#include<cstdlib>
#include<algorithm>
#include<stack>

using namespace std;

	#define MOD 1000000007
	int n; bool prvi = true;
	long long mat[50][50];
	long long mat3[50][50],mat4[50][50];

	void mul(long long mat1[][50], long long mat2[][50]){
		
		memset(mat3,0,sizeof mat3);
		
		for(int i = 0; i < n; i++){
			for(int j = 0; j < n; j++){
				for(int k = 0; k < n; k++){
					mat3[i][j] += (mat1[i][k]*mat2[k][j])%MOD;
					mat3[i][j]%=MOD;
				}
	//			cout << mat3[i][j] << " ";
			}
	//		cout << endl;
		}
		
	//	system("pause");
		return;
		
	}
	
	/*
		
	    101
	    010
	    000
	    
	010 010
	101 101
	000 000
	
	*/
	
	void izjednaci(){
		
		for(int i = 0; i < 50; i++)
			for(int j = 0; j < 50; j++)
				mat3[i][j] = mat[i][j];
				
		prvi = false;
		return;
		
	}


int main(){
	
	cin >> n;
	long long k; cin >> k;
	for(int i = 0; i < n; i++) 
		for(int j = 0; j < n; j++)
			cin >> mat[i][j];
			

			
	for(int i = 61; i >= 0; i--){
		
		mul(mat4,mat4);
		swap(mat4,mat3);
		if((1ll<<i)&k){
			if(prvi == true) izjednaci();
			else mul(mat4,mat);
			swap(mat3,mat4);
		}
		
	}
	long long sol = 0;
	for(int i = 0; i < n; i++){
		for(int j = 0; j < n; j++){
			sol += mat4[i][j];
			sol%=MOD;
		}
	}
	cout <<sol;


return 0;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
score_list = []
for i in range(N):
    score_list.append(list(map(int, input().split())))
test = [[-1, -1, -1], [-1, 1, -1], [-1, 1, -1], [-1, -1, 1], [-1, 1, 1], [1, -1, 1], [1, 1, -1], [1, 1, 1]]
max_score = -5e10
for t in test:
    score_cake = []
    for i in range(N):
        score_cake.append(score_list[i][0]*t[0] + score_list[i][1]*t[1] + score_list[i][2]*t[2])
    score_cake.sort()
    score_cake.reverse()
    score_sum = 0
    for i in range(M):
        score_sum += score_cake[i]
    max_score = max(max_score, score_sum)
print(max_score)

Measured memory_bytes: 3316
#pragma region header
#include <bits/stdc++.h>
using namespace std;

#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_CAT_I(x,y) x ## y
//#define CPP_STR(x) CPP_STR_I(x)
//#define CPP_STR_I(args...) #args
//#define ASSERT(expr...) assert((expr))

using i8 = int8_t;
using u8 = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
//using f80 = __float80;
#pragma endregion

#pragma region const
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
#pragma endregion

#pragma region util
#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }
template<typename T, size_t N>
i64 SIZE(const T(&)[N]) { return static_cast<i64>(N); }

template<typename T, typename U, typename Comp = less<>>
bool chmax(T& xmax, const U& x, Comp comp = {}) {
	if (comp(xmax, x)) {
		xmax = x;
		return true;
	}
	return false;
}
template<typename T, typename U, typename Comp = less<>>
bool chmin(T& xmin, const U& x, Comp comp = {}) {
	if (comp(x, xmin)) {
		xmin = x;
		return true;
	}
	return false;
}
#pragma endregion

#pragma region init
struct ProconInit {
	static constexpr int IOS_PREC = 15;
	static constexpr bool AUTOFLUSH = false;

	ProconInit() {
		cin.tie(nullptr);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(IOS_PREC);
		if (AUTOFLUSH)
			cout << unitbuf;
	}
} PROCON_INIT;
#pragma endregion

int main()
{
	string n;
	cin >> n;
	string ans = "";
	REP(i, SIZE(n))
	{
		if (n[i] == '1')
			ans += "9";
		else
			ans += "1";
	}
	cout << atoi(ans.c_str()) << endl;
	return 0;
}


Measured memory_bytes: 256
from math import sqrt
N = int(input())
xy = [list(map(int, input().split())) for _ in range(N)]
count = 1
summary = 0
for i in range(N):
    
    for j in range(N):
        if i == j:
            continue
        
        summary += sqrt(((xy[i][0] - xy[j][0]) ** 2) + ((xy[i][1] - xy[j][1]) ** 2))

print((summary / N))


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

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define REPV(iter, v) for(auto (iter)=(v).begin(); (iter)!=(v).end();++(iter))
#define ALL(v) (v).begin(),(v).end()

#define MOD 1000000007

using namespace std;

typedef long long ll;

int main()
{
    ll N, M;
    cin >> N >> M;
    vector<ll> A(N);
    ll sum = 0;
    REP(i, N) 
    {
        cin >> A[i];
        sum += A[i];
    }
    ll count = 0;
    REP(i, N) if (A[i] * 4 * M >= sum) count++;
    string ans;
    if (count >= M) ans = "Yes";
    else ans = "No";

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=1LL<<60;
const double EPS = 1e-10;
const ll mod=1000000007;
//const ll mod=998244353;

int main(void){
    string s;
    cin>>s;
    if(s=="SSS") cout<<0<<endl;
    if(s=="RSS") cout<<1<<endl;
    if(s=="SRS") cout<<1<<endl;
    if(s=="SSR") cout<<1<<endl;
    if(s=="RRS") cout<<2<<endl;
    if(s=="SRR") cout<<2<<endl;
    if(s=="RSR") cout<<1<<endl;
    if(s=="RRR") cout<<3<<endl;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define ll long long
#define ld long double

using namespace std;

int main(){
    int x;
    cin >> x;
    if(x == 0){
        cout << 1 << endl;
    }
    else {
        cout << 0 << endl;
    }


    
    return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define long long long
const long MOD = 1e9+7;
signed main()
{
    long test;
    test=1;
    // cin>>test;
    while(test--){
    long i,j,a,b,n,x,ans,most,index,c,maxi=0,temp;
    char p,q;
    cin>>p>>q;
    if(p=='H')
    cout<<q;
    else
    {
        if(q=='H')cout<<"D";
        else cout<<"H";
    }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for (int i = (int)(s); i < (int)(n); i++)
const ll mod = ll(1e9) + 7;
const int INF = int(1e9);
int main()
{
    int N, A, B, C, D;
    cin >> N >> A >> B >> C >> D;
    string S;
    cin >> S;
    A--;
    B--;
    C--;
    D--;
    if (C < D)
    {
        int cnt = 0;
        reps(i, A, D + 1)
        {
            if (S[i] == '#')
            {
                cnt += 1;
                if (cnt == 2)
                    break;
            }
            else
            {
                cnt = 0;
            }
        }
        if (cnt == 2)
        {
            cout << "No" << endl;
        }
        else
        {
            cout << "Yes" << endl;
        }
    }
    else
    {
        int cnt = 0;
        reps(i, A, B + 1)
        {
            if (S[i] == '#')
            {
                cnt += 1;
                if (cnt == 2)
                    break;
            }
            else
            {
                cnt = 0;
            }
        }
        if (cnt == 2)
        {
            cout << "No" << endl;
            return 0;
        }
        cnt = 0;
        reps(i, B - 1, D + 2)
        {

            if (S[i] == '.')
            {
                cnt++;
                if (cnt == 3)
                    break;
            }
            else
                cnt = 0;
        }

        if (cnt == 3)
        {
            cout << "Yes" << endl;
        }
        else
        {
            cout << "No" << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 640
x,n = map(int,input().split())
p = list(map(int,input().split()))

p.sort()
s = 0
t = 0

for i in range(0,103-x):
    if x+i not in p:
        s = x+i
        break

for j in range(0,-100,-1):
    if x+j not in p:
        t = x+j
        break

if abs(x-s) < abs(x-t):
    print(s)
else:
    print(t)


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

int main(void) {
  int64_t N, A, B;
  cin >> N >> A >> B;

  int64_t answer;
  if (A > B) {
    answer = 0;
  } else if (N == 1) {
    answer = (A == B) ? 1 : 0;
  } else {
    N -= 2;
    answer = (B * N) - (A * N) + 1;
  }
  cout << answer << endl;
  return 0;
}

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

int main()
{
  long int a,b,x,r,tmp;
  scanf("%ld %ld",&a,&b);
  x=a*b;

  //a>b
  if(a<b){
    tmp=a;
    a=b;
    b=tmp;
  }

  //ユークリッドの互除法
  r=a%b;
  while(r!=0){
    a=b;
    b=r;
    r=a%b;
  }
  printf("%ld\n",x/b);
  return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
using namespace std;

const int maxn = 2 * 100000 + 5;
typedef long long ll;

const ll NEG_INF = ll(-1e17);

ll dp[maxn][2], arr[maxn];
int n;

inline int cal(int i, int j) {
  return ((i + 1) >> 1) - j;
}

inline bool check(int i, int j, int need) {
  return need == cal(i, j);
}

ll solve() {
  dp[1][0] = arr[1];
  dp[1][1] = 0LL;
  dp[2][0] = arr[2];
  dp[2][1] = 0LL;
  int bd = min(n, 5);
  for (int i = 3; i <= bd; i++) {
    if (i == 3) {
      dp[3][0] = arr[1] + arr[3];
      dp[3][1] = arr[3];
    }
    else if (i == 4) {
      dp[4][0] = arr[4] + max(dp[2][0], dp[1][0]);
      dp[4][1] = arr[4];
    }
    else if (i == 5) {
      dp[5][0] = arr[5] + arr[3] + arr[1];
      dp[5][1] = arr[5] + max(arr[1], max(arr[2], arr[3]));
    }
  }
  for (int i = 6; i <= n; i++) {
    dp[i][0] = dp[i][1] = arr[i];
    
    int need = cal(i, 0) - 1;
    ll buf = NEG_INF;
    for (int j = i - 4; j <= i - 2; j++)
      for (int k = 0; k <= 1; k++)
        if (check(j, k, need))
          buf = max(buf, dp[j][k]);
    dp[i][0] += buf;
    
    need = cal(i, 1) - 1;
    buf = NEG_INF;
    for (int j = i - 4; j <= i - 2; j++)
      for (int k = 0; k <= 1; k++)
        if (check(j, k, need))
          buf = max(buf, dp[j][k]);
    dp[i][1] += buf;
  }
  ll ans = NEG_INF;
  int need = (n >> 1);
  for (int i = n; (i > 0) && (i > (n - 4)); --i)
    for (int j = 0; j <= 1; j++)
      if (check(i, j, need))
        ans = max(ans, dp[i][j]);
  return ans;
}

int main() {
  //freopen("input.txt", "r", stdin);
  while (~scanf("%d", &n)) {
    for (int i = 1; i <= n; i++) scanf("%lld", &arr[i]);
    printf("%lld\n", solve());
  }
  return 0;
}


Measured memory_bytes: 6420
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define first_more_idx(ve, num) upper_bound(all(ve), num)-ve.begin() // idx = first_more_idx(ve,num); if(idx = ve.size()) , then not exist
#define first_lessequal_idx(ve, num) lower_bound(all(ve), num)-ve.begin()
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > >
#define pq_pair_ts priority_queue <pair<ll,ll> > // only sort first param
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
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 power(ll x, ll n){if(n == 0) return 1;return  (n%2)? x*power(x, n-1)%MOD : power(x*x%MOD, n/2);}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll N, A, B;
    cin >> N >> A >> B ;
    cout << min(N*A, B) << endl;

    //cout << fixed << setprecision(16) << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define vll vector<ll>
#define vi vector<int>
#define vvi vector<vector<int>>
#define vpll vector<pair<ll,ll>>
#define pii pair<int,int>
#define REP(i,a) for(int (i)=0; (i)<(a); (i)++)
#define RREP(i,a) for(int (i)=a-1; (i)>=(0); (i)--)
#define REP2(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define MOD 1000000007
#define INF 0x7FFFFFFF
#define ALL(v) v.begin(), v.end()  
#define m0(x) memset(x,0,sizeof(x))
typedef long long ll;

using namespace std;

int main(){
    int A, B,cnt = 0;
    cin >> A >> B;
    if(B==1) {cout<<"0";return 0;}
    B--;
    while(B>0){
     B=B-A+1;
      cnt++;
    }
    cout<<cnt;
    return 0;
}

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



int main() {
  int N;
  cin >> N;
  vector<pair<pair<string, int>, int>> rd;       //restaurant dictionary (<<name, point>, order>)
  string a;
  int b;
  int i = 0;
  while(cin >> a >> b){
    i++;
    rd.push_back(make_pair(make_pair(a, -b), i));
  }

  sort(rd.begin(), rd.end());             //bの要素をソート

  for(int i = 0; i < rd.size(); i++)
    cout << rd.at(i).second << endl;
  

}

Measured memory_bytes: 256
N,W = map(int,input().split())

mv = 100100
weight = []
value = []
for i in range(N):
    w,v = map(int,input().split())
    
    weight.append(w)
    value.append(v)

INF = 1001001000100

dp = [[INF]*mv for i in range(110)]

dp[0][0] = 0

for i in range(N):
    for sum_v in range(mv):
        if sum_v - value[i] >= 0:
            dp[i+1][sum_v] = min(dp[i+1][sum_v], dp[i][sum_v - value[i]] +
            weight[i])

        dp[i+1][sum_v] = min(dp[i+1][sum_v], dp[i][sum_v])    
        
ans = 0
l = []
for sum_v in range(mv):
    if dp[N][sum_v] <= W:
        ans = sum_v

print(ans)

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

int main(void) {
  int n;
  cin >> n;
  vector<pair<long, pair<int, int> > > v(n);
  int a, b, s;
  for (int i = 0; i < n; i++) {
    cin >> a >> b;
    s = a + b;
    v[i] = make_pair(s, make_pair(a, b));
  }
  sort(v.begin(), v.end());
  long a_res = 0, b_res = 0;
  for (int i = 0; i < n; i++) {
    if (i % 2 == 0) a_res += v[n - i - 1].second.first;
    if (i % 2 == 1) b_res += v[n - i - 1].second.second;
  }
  cout << (a_res - b_res) << endl;

  return 0;
}

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

#define fio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define int long long 

using namespace std;

int32_t main()
{
	fio;
	int n;
	cin>>n;
	string s;
	cin>>s;
	int **cnt=new int*[n];
	for(int i=0;i<n;i++)
	{
		cnt[i]=new int[3];
	}

	int r=0,g=0,b=0;
	for(int i=0;i<n;i++)
	{
		switch(s[i])
		{
			case 'R':r++;
				break;
			case 'G':g++;
				break;
			case 'B':b++;
				break;
		}
		cnt[i][0]=r;
		cnt[i][1]=g;
		cnt[i][2]=b;
	}
	unordered_map<char,int> mp;
	mp['R']=0;
	mp['G']=1;
	mp['B']=2;

	int ans=0;
	for(int i=0;i<n-3;i++)
	{
		for(int k=3+i;k<n;k++)
		{
			if(s[i]==s[k])
			{
				continue;
			}

			int j=(k+i)/2;

			int c=3-mp[s[i]]-mp[s[k]];

			// cout<<s[i]<<" "<<c<<" "<<s[k]<<endl;

			ans+=cnt[j-1][c]-cnt[i][c];
			ans+=cnt[k-1][c]-cnt[j][c];

			if((k+i)%2!=0 and mp[s[j]]==c)
			{
				ans++;
			}

			// cout<<ans<<endl;
		}
	}

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

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

typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define dump(x)  cout << #x << " = " << (x) << endl;	//debug
#define SZ(x) ((int)(x).size())
#define REP(i, n) for(ll i = 0; i < (n); i++)
#define REPR(i, n) for (ll i = (n); i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define ps(s) cout << #s << endl;
#define pv(v) cout << (v) << endl;
#define ALL(a)  (a).begin(),(a).end()

int main() {
	int k, x;
	cin >> k >> x;
	FOR(i, x - k + 1, x + k - 1) {
		cout << i;
		if (i != (x + k - 1)) {
			cout << " ";
		}
		else {
			cout << endl;
		}
	}
	return(0);
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int n;
    cin >> n;
    int a[n];
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    for (int i = 0; i < n-1; i++) {
        cout << a[n-i-1] << " ";
    }
    cout << a[0] << endl;
}

Measured memory_bytes: 3028
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <cmath>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>

using namespace std;


int n,q;
vector <int> A,M;
int solve(int i, int m){
    if (m==0){
        return true;
    }
    if (i >= n){
        return false;
    }
    bool res = solve(i+1,m) or solve(i+1,m-A[i]);
    return res;
}
int main() {
    
    cin >> n;
    for (int i=0;i<n;i++){
        int p;
        cin >> p;
        A.push_back(p);
    }
    cin >> q;
    for (int i=0;i<q;i++){
        int p;
        cin >> p;
        if(solve(0,p)){
            cout << "yes" <<endl;
        }else{
            cout << "no" << endl;
        }
    }

}


Measured memory_bytes: 3168
#include <iostream>
#include <iomanip>
#include <random>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <sstream>
#include <bitset>
#include <cassert>
#include <fstream>
#include <queue>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
	#define DBG(X) cout << #X << "=" << (X) << endl;
#else
	#define DBG(X)
	#define endl '\n'
#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>;

const int INT_INF = (int)(2e9);
const ll  LL_INF  = (ll)(2e18);

const ll mod = 1e9 + 7;
const int NIL = -1;
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> inline T sign(T x) { return T(x > 0) - T(x < 0); }
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> inline ostream& operator<<(ostream& os, const vector<T>& v) { for(auto el: v) cout << el << " "; return os; }

struct Vector
{
	ll x, y;

	Vector(): x(NIL), y(NIL)
	{
	}

	Vector(ll _x, ll _y): x(_x), y(_y)
	{
	}

	Vector operator+(const Vector& other) const
	{
		return Vector(x + other.x, y + other.y);
	}

	ll sqlen() const
	{
		return x * x + y * y;
	}
};

const int MAX_N = 107;

Vector v[MAX_N];
int ord[MAX_N];
int n;

void solve()
{
	cin >> n;
	iota(ord, ord + n, 0);

	for(int i = 0; i < n; ++i)
		cin >> v[i].x >> v[i].y;

	ll answ = 0;

	for(int step = 0; step < 300; ++step)
	{
		for(int i = 0; i < n; ++i)
		{
			Vector u = v[i];
			shuffle(ord, ord + n, _g);

			for(int ind = 0; ind < n; ++ind)
			{
				int j = ord[ind];

				if(j != i)
				{
					Vector u2 = u + v[j];

					if(u2.sqlen() > u.sqlen())
						u = u2;
				}
			}

			answ = max(answ, u.sqlen());
		}
	}

	cout << fixed << setprecision(12) << sqrtl(answ) << endl;
}

int main()
{
	fast_io();
	solve();

	return 0;
}


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

int main(){
    ll n,m,k;
    cin>>n>>m;
    vector<ll> list;
    rep(i,m){
        list.push_back(0);
    }
    ll tmp;
    rep(i,n){
        cin>>k;
        rep(j,k){
           cin>>tmp;
           list[tmp]++; 
        }
    }
    ll ans=0;
    rep(i,m+1){
        // cout<<":"<<list[i]<<endl;
        if(list[i]==n)ans++;
    }

    cout<<ans<<endl;
}



Measured memory_bytes: 3528
A, B, K =[int(_) for _ in input().split()]

def cd(a,b,n):
    cnt = 0
    st = min(a,b)
    for i in range(st,0,-1):
        if a % i == 0 and b % i == 0:
            cnt +=1
            if n == cnt:
                return i
print(cd(A,B,K))


Measured memory_bytes: 2940
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cstdio>
#include <vector>
#define PII pair<int, int>
#define SIZE(x) ((int) x.size())
using namespace std;
int main()
{
	int N, M, L, R;
	scanf("%d%d%d%d", &N, &L, &M, &R);
	R *=2; L *= 2; M *= 2;
	int l = R, r = L / 2;
	vector<PII> las, cur;
	las.push_back(PII(0, 0));
	for (int i = 1; i <= N; ++ i)
	{
		int m;
		scanf("%d", &m);
		cur.clear();
		int c = m * l, d = m * r;
		for (int i = 0; i < SIZE(las); ++ i)
		{
			int a = las[i].first, b = las[i].second;
			int q = a + c, w = min(b + d, M);
			if (q <= w) cur.push_back(PII(q, w));
			q = max(a - d, -M); w = b - c;
			if (q <= w) cur.push_back(PII(q, w));
		}
		sort(cur.begin(), cur.end());
		las.clear();
		for (int j = 0; j < SIZE(cur); ++ j)
		{
			if (SIZE(las) == 0 || las[SIZE(las) - 1].second < cur[j].first)
			{
				las.push_back(cur[j]);
			}
			else
			{
				las[SIZE(las) - 1].second = max(las[SIZE(las) - 1].second, cur[j].second);
			}
		}
		/*for (int i = 0; i < SIZE(las); ++ i)
		{
			printf("%d %d\n", las[i].first, las[i].second);
		}
		printf("-----\n")*/;
	}
	bool flag = false;
	for (int i = 0; i < SIZE(las); ++ i)
	{
		//printf("%d %d\n", las[i].first, las[i].second);
		if (las[i].first <= M || las[i].second >= -M)
		{
			flag = true;
			break;
		}
	}
	if (flag) puts("Yes"); else puts("No");
	return 0;
}

Measured memory_bytes: 1176
using System;
using System.Linq;
using System.Collections.Generic;

namespace D
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var s = Console.ReadLine();

            var count = 0;

            for (int i = 0; i <= 999; i++)
            {
                var password = $"{i:000}";

                if (check(password, s))
                {
                    count++;
                }
            }

            Console.WriteLine(count);
        }

        public static bool check(string pass, string s)
        {
            // stringの中にpassが含まれるかをチェックする。
            var index = 0;
            foreach (var c in s)
            {
                if (c == pass[index])
                {
                    index++;
                    if (index == 3) break;
                }
            }
            return index == 3;
        }
    }
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
void dfs(vector<int> *G, int &n, int m, int u, vector<bool> &visited) {
  visited[u] = true;
  n++;
  for (int v : G[u]) {
    if (!visited[v] && v != m) {
      visited[v] = true;
      dfs(G,n,m,v,visited);
    }
  }
}
int main() {
  int N,a,b,n1=0,n2=0,m1,m2;
  cin >> N;
  vector<int> G[N];
  vector<bool> visited(N);
  int d[N],p[N];
  for (int i = 1; i < N; i++) {
    cin >> a >> b;
    G[--a].push_back(--b);
    G[b].push_back(a);
  }
  queue<int> q;
  for (q.push(0), d[0] = 0, p[0] = -1; !q.empty(); q.pop()) {
    for (int v : G[q.front()]) {
      if (!visited[v]) {
        visited[v] = true;
        d[v] = d[q.front()]+1;
        q.push(v);
        p[v] = q.front();
      }
    }
  }
  m1 = N-1;
  m2 = p[m1];
  for (int n = (d[N-1]-1)/2; n; n--, m1 = m2, m2 = p[m2]);
  visited = vector<bool>(N);
  dfs(G,n1,m1,m2,visited);
  visited = vector<bool>(N);
  dfs(G,n2,m2,m1,visited);
  if (n1 > n2) {
    cout << "Fennec";
  } else {
    cout << "Snuke";
  }
}

Measured memory_bytes: 13776
#include <algorithm>
#include <bitset>
#include <cassert>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<ll, ll> P;
inline ll min(ll x, ll y) { return x < y ? x : y; }
inline ll max(ll x, ll y) { return x > y ? x : y; }

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#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 all(c) c.begin(), c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << (x) << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)

int main() {
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    cout << max(A * B, C * D);
    return 0;
}

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

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

    int max_cnt = 0;
    int ans = 1;
    for (int i = 1; i <= n; i++) {
        int temp = i;
        int cnt = 0;
        while (temp % 2 == 0) {
            temp /= 2;
            cnt++;
        }
        if (max_cnt < cnt) {
            max_cnt = cnt;
            ans = i;
        }
    }

    std::cout << ans << std::endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cctype>
#include <cstdio>
#include <bitset>
#include <complex>
#define ll long long
#define INF 1000000000000000001
#define MOD 1000000007
using namespace std;



int main(){
    string s;
    cin >> s;
    if(s=="ABC"){
        cout<<"ARC"<<endl;
    }else{
        cout<<"ABC"<<endl;
    }

    return 0;
}


Measured memory_bytes: 3604
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <utility>
#define endl '\n'
#define fi first
#define se second
#define pb push_back
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
const int MOD = 1e9 + 7;
const int maxn = 1e6 + 5;
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-8;
int a[105];
int main() {
    a[0] = 0;
    a[1] = 0;
    a[2] = 1;
    for(int i = 3; i < 101; ++i){
    	a[i] = a[i - 1] + i - 1;
    } 
    int n, m; cin >> n >> m;
    int ans = a[n] + a[m];
    cout << ans << endl;
	return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct Fast {
    Fast() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} fast;

long long mod = 1000000007;

long long div(long long a, long long b, long long c) { return b / c - (a - 1) / c; }

void print_binary(long long a) {
    for (int i = 31; i >= 0; i--) {
        cout << (a >> i & 1);
    }
    cout << endl;
}
long long modpow(long long m, long long n) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        long long t = modpow(m, n / 2);
        return t * t;
    } else {
        return modpow(m, n - 1) * m;
    }
}
void yes() {
    cout << "Yes" << endl;
    exit(0);
}
void no() {
    cout << "No" << endl;
    exit(0);
}
#define REP(i, n) for (long long i = 0; i < (n); i++)

int main() {
    long long n, m;
    cin >> n >> m;
    vector<int> as(n);
    vector<int> xs(m);
    for (int i = 0; i < n; i++) {
        cin >> as[i];
    }
    for (int i = 0; i < m; i++) {
        long long x, sum = 0, ans = 0, p2 = 0;
        cin >> x;
        for (int p1 = 0; p1 < n; p1++) {
            while (p2 < n && sum <= x - as[p2]) {
                sum += as[p2];
                p2++;
            }
            ans += p2 - p1;
            sum -= as[p1];
            // cout << p1 << " " << p2 << endl;
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 3320