akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
int N;
vector<int64_t> A(200000);
int64_t INF = -1e15;
void even_solve(){
    int M = N/2;

    //dp[i][j] = i番目の偶数A[2*i+1]で最後がA[2*i+1-j]の時の最大値
    vector<vector<int64_t>> dp(M,vector<int64_t>(2,INF));
    dp[0][0] = A[1];
    dp[0][1] = A[0];

    for(int i=0;i<M-1;i++){
        dp[i+1][1] = dp[i][1] + A[2*i+2];
        dp[i+1][0] = max(dp[i][1],dp[i][0]) + A[2*i+3];
    }
    cout << max(dp[M-1][0],dp[M-1][1]) << endl;
}

void odd_solve(){
    int M = N/2 +1;//奇数の個数

    //dp[i][j] = i番目の奇数a[2*i]で最後がA[2*i-j]のときの最大値
    vector<vector<int64_t>> dp(M,vector<int64_t>(3,INF));
    //初期条件、N>=2よりM>=2
    dp[1][0] = A.at(2);
    dp[1][1] = A.at(1);
    dp[1][2] = A.at(0);

    for(int i=1; i<M-1;i++){
        int64_t mx2 = dp[i][2];
        int64_t mx1 = max(mx2,dp[i][1]);
        int64_t mx0 = max(mx1,dp[i][0]);

        //dp漸化式
        dp[i+1][2] = mx2 + A[2*i];
        dp[i+1][1] = mx1 + A[2*i+1];
        dp[i+1][0] = mx0 + A[2*i+2];

    }
    cout << max(dp[M-1][0],max(dp[M-1][1],dp[M-1][2])) << endl;
}
    

void solve(){
    if(N%2) odd_solve();
    else even_solve();
}

int main(){
    cin >> N;
    rep(i,N){cin >> A.at(i);}
    solve();
}   

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

int s[50];

int main(){
  int n, p;
  
  while(cin >> n >> p, n * p){
    for(int i = 0; i < n; i++) s[i] = 0;
    int ans = 0, sum = p;
    int c = 0;
    while(1){
      if(sum == 0){
	sum += s[c];
	s[c] = 0;
      }
      else{
	sum--;
	s[c]++;
	if(s[c] == p) break;
      }
      c = (c + 1) % n;
      ans++;
    }
    cout << c << endl;
  }
}

Measured memory_bytes: 3028
#include <iostream>
using namespace std;
int main()
{
    int W, H, x, y, r;
    cin >> W >> H >> x >> y >> r;
    if(x + r <= W && x - r >= 0 && y + r <= H && y - r >= 0)
        cout << "Yes" << "\n";
    else
        cout << "No" << "\n";

}



Measured memory_bytes: 3088
n, m = map(int, input().split())
l = list()
r = list()
for i in range(m):
    tmp_l, tmp_r = map(int, input().split())
    l.append(tmp_l)
    r.append(tmp_r)
maxl = max(l)
minr = min(r)
if maxl > minr:
    print(0)
elif maxl == minr:
    print(1)
else:
    print(minr - maxl + 1)

Measured memory_bytes: 55896
#include <iostream>
#include <iomanip>
#include <cassert>

#include <cstring>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <limits>
#include <queue>
#include <unordered_map>
#include <list>
#include <set>
#include <numeric>
using namespace std;

using ll = long long;

#define rep_init(i, init, n) for(int i = (init); i < (n); ++i)
#define rep(i, n) rep_init(i, 0, n)

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

	vector<int> l(N);
	rep(i, N)
	{
		cin >> l[i];
	}

	auto ans = numeric_limits<int>::max();
	rep(i, 1 << (N * 2))
	{
		vector<int> uA, uB, uC;
		rep(j, N)
		{
			auto k = (i >> (j * 2)) % (1 << 2);
			if (k == 0)
			{
				uA.push_back(l[j]);
			}
			else if (k == 1)
			{
				uB.push_back(l[j]);
			}
			else if (k == 2)
			{
				uC.push_back(l[j]);
			}
		}

		if (uA.empty() || uB.empty() || uC.empty())
		{
			continue;
		}

		auto sumA = accumulate(uA.begin(), uA.end(), 0);
		auto sumB = accumulate(uB.begin(), uB.end(), 0);
		auto sumC = accumulate(uC.begin(), uC.end(), 0);

		ans = min(ans, abs(sumA - A) + abs(sumB - B) + abs(sumC - C) + static_cast<int>(uA.size() + uB.size() + uC.size() - 3) * 10);
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3616
from collections import defaultdict

H,W = map(int, input().split())
S = [input() for _ in range(H)]

es = defaultdict(list)

for i in range(H):
    for j in range(W):
        if 0 <= i < H-1:
            if S[i][j] != S[i+1][j]:
                es[(i,j)].append((i+1, j))
                es[(i+1,j)].append((i, j))

        if 0 <= j < W-1:
            if S[i][j] != S[i][j+1]:
                es[(i,j)].append((i, j+1))
                es[(i,j+1)].append((i, j))

checked = [[False for _ in range(W)] for _ in range(H)]

ans = 0
for i in range(H):
    for j in range(W):
        b,w = 0,0
        if not checked[i][j]:
            checked[i][j] = True
            if S[i][j] == "#":
                b += 1
            else:
                w += 1
            q = es[(i,j)]
            while q:
                y,x = q.pop()
                if not checked[y][x]:
                    checked[y][x] = True
                    if S[y][x] == "#":
                        b += 1
                    else:
                        w += 1
                    q.extend(es[(y,x)])
            ans += b * w

print(ans)


Measured memory_bytes: 89068
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<bitset>
#include<vector>
#include<deque>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<iomanip>
#include <functional>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
const double EPS = 1e-10;
const int INF = 2147483647;
//cout << fixed << std::setprecision(9)
//memset(a, 0, sizeof(a));
//--------------------------

int numbers[] = { 1, 6, 36,216,1296,7776,46656,9,81,729,6561,59049 };
int dp[100005];

void solve(int n)
{
	dp[0] = 0;
	for (int i = 1;i <= n;i++) {
		dp[i] = INF;
		for (int j = 0;j < 12;j++) {
			if (i - numbers[j] >= 0) {
				dp[i] = min(dp[i], 1 + dp[i - numbers[j]]);
			}
		}
	}

}

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

	solve(n);
	cout << dp[n] << endl;

	return 0;
}


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

vector<int> tree[100001];
ll dp[100001][2];

ll totalWays(int src,bool constraint,int parent){
    if(dp[src][constraint]!=-1){
        return dp[src][constraint];
    }
    ll ans = 0;
    ll w1 = 1;
    for(int child: tree[src]){
        if(child!=parent){
            w1 = (w1 * totalWays(child,0,src))% mod;
        }
    }
    ans += w1;
    
    if(!constraint){  
        ll w2 = 1;  
        for(int child: tree[src]){
            if(child!=parent){
                w2 = (w2 * totalWays(child,1,src))% mod;
            }
        }
        ans = (ans + w2)% mod;   
    }
    return dp[src][constraint] = ans;
}

int main() 
{
    int n;
    cin>>n;
    memset(dp,-1,sizeof(dp));
    for(int i=0;i<n-1;i++){
        int u,v;
        cin>>u>>v;
        tree[u].push_back(v);
        tree[v].push_back(u);
    }
    cout<<totalWays(1,0,-1);
    return 0;
}


Measured memory_bytes: 15616
#import
#import math
#import numpy as np
x= int(input())
#= input()
#= map(int, input().split())
#= list(map(int, input().split()))
#= [input(), input()]
#= [list(map(int, input().split())) for _ in range(N)]
#= [int(input()) for _ in range(N)]
#= {i:[] for i in range(N)}

if x:
    print(0)
else:
    print(1)

Measured memory_bytes: 9084
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <numeric>
#include <complex>
#define ll long long
using namespace std;

int main() {
	ll r, g, b, n, hoge, ans = 0;
	cin >> r >> g >> b >> n;
	for (int i = 0; i <= 3000; i++) {
		for (int j = 0; j <= 3000; j++) {
			hoge = n - i*r - j*g;
			if (hoge % b != 0)continue;
			hoge = hoge / b;
			if (hoge >= 0 && hoge <= 3000)ans++;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
long long mo = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}
ld PI=3.14159265358979323846;

int main(){
    ll N;
    cin >> N;
    vector<ll> A(N),v;
    rep(i,N){
        cin >> A[i];
    }
    if(N==1){
        cout << 1 << endl;
        return 0;
    }
    /*
    rep(i,N){
        ll now = 0;
        bool flag = false;
        REP(j,i,N){
            if((now + A[j]) == (now | A[j])){
                now += A[j];
            }else{
                v.push_back(j);
                flag = true;
                break;
            }
        }
        if(flag) continue;
        v.push_back(N);
    }*/
    ll l=0,r=1;
    ll now = A[0];
    while(l<=r){
        if(now + A[r] == (now | A[r])){
            now += A[r];
            r++;
        }else{
            v.push_back(r);
            now -= A[l];
            l++;
        }
        if(r==N){
            REP(i,l,r){
                v.push_back(r);
            }
            break;
        }
    }
    //PR(v,v.size());
    ll ans = 0;
    rep(i,v.size()){
        ll j = v[i];
        ll tmp = j-i;
        //ll a = (tmp*tmp - tmp)/2 + tmp;
        ans += tmp;
    }
    cout << ans << endl;
}

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

typedef vector<int> VI;
#define PB push_back
#define X first
#define Y second
#define fixed aslasdmadsm
#define LL long long
const int mod = 1000 * 1000 * 1000 + 7;
const int MAX = 1005;
int a[MAX] , b[MAX];
int fixed[MAX * MAX];
int fact[MAX * MAX];
int inv[MAX * MAX];
map<int , int> MM;
map<int , int> M;
int mult(int a , int b)
{
	return (a * (LL)b) % mod;
}
int modPow(int a , int step)
{
	int ans = 1;
	while(step)
	{
		if(step & 1)
		{
			ans = mult(ans , a);
		}
		a =mult(a , a);
		step >>= 1;
	}
	return ans;
}
int main()
{
	
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    //freopen("In.txt" , "r" , stdin);
	inv[0] = fact[0] = 1;
	for(int i = 1; i < MAX * MAX; i++)
	{	
		fact[i] = mult(fact[i - 1] , i);
		inv[i] = modPow(fact[i] , mod - 2);
	}
	int n , m;
	cin >> n >> m;
	set<int> s;
	for(int i = 0; i < n; i++)
	{
		cin >> a[i];
		MM[a[i]]++;
		s.insert(a[i]);
	}
	if(s.size() != n)
	{
		cout << 0;
		return 0;
	}
	s.clear();
	
	for(int j = 0; j < m; j++)
	{
		cin >> b[j];	
		MM[b[j]]++;
		s.insert(b[j]);
	}
	if(s.size() != m)
	{
		cout << 0;
		return 0;
	}
	for(int i = 0; i < n; i++)
		for(int j = 0; j < m; j++)
		{
			M[min(a[i] , b[j])]++;
		}
	int ways = 1;
	int was = 0;
	int suma = 0;
	int prev = 0;
	for(auto x : M)
	{
		int ob = x.first;
		int cnt = x.second;
		int was = ob - suma;
		suma += cnt;

		if(MM[ob] == 2)
		{
			if(was < cnt)
			{
				cout << 0;
				return 0;
			}
			ways = mult(ways , mult(fact[was - 1] , inv[was - cnt]));
		}
		else
		{
			if(was < cnt)
			{
				cout << 0;
				return 0;
			}
			ways = mult(ways , mult(fact[was - 1] , inv[was - cnt]));	
			ways = mult(ways , cnt);
		}
		
		
	}

	cout << ways;
}

Measured memory_bytes: 8704
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef pair<ll,ll> P;
#define all(v) (v).begin(),v.end()
#define fi first
#define se second
set<string> c;
map<ll,ll> mp;
const ll inf=(1e18);
const ll mod=1000000007;
const ll mod2=998244353;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
int main(){
int n,m;
cin>>n>>m;
vector<vector<ll>> t(n);
for(int i=0;i<n;i++){
    ll a,b,c;
    cin>>a>>b>>c;
    t.at(i).push_back(a);
    t.at(i).push_back(b);
    t.at(i).push_back(c);
}
ll ans=0;
for(int i=0;i<8;i++){
   priority_queue<ll> tmp;
   int times=m;
   ll sum=0;
   for(int j=0;j<n;j++){
       ll res=0;
         for(int k=0;k<3;k++){
             if(i&(1<<k))res-=t.at(j).at(k);
             else res+=t.at(j).at(k);
         }
         tmp.push(res);
   }
   while(times--){
     sum+=tmp.top();
     tmp.pop();
   }
   ans=max(ans,sum);
}
cout<<ans<<endl;
}


Measured memory_bytes: 384
import sys
sys.setrecursionlimit(1000000000)
ii = lambda: int(input())
ii0 = lambda: ii() - 1
mis = lambda: map(int, input().split())
lmis = lambda: list(mis())
INF = float('inf')

def gen_divs(n):
    for i in range(1, int(n**0.5)+1):
        if n%i == 0:
            yield i
            if i != n // i:
                yield n // i
    return


def main():
    N = ii()
    divs = [i for i in gen_divs(N)]
    divs.sort()
    if len(divs) % 2 == 1:
        print((divs[len(divs)//2]-1)*2)
    else:
        p = len(divs) // 2
        print(divs[p]-1 + divs[p-1]-1)




main()


Measured memory_bytes: 3276
n = int(input())
w = list(map(int,input().split()))
#print(w)
x = []
big = 0
small = 0

for i in range(n):
    big = w[i:]
    small = w[:i]
    big1 = sum(big)
    small1 = sum(small)
    x.append(int(abs(big1-small1)))
print(min(x))
#print(min(x))

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

int main()
{
  string s;
  cin>>s;
  if(s == "Sunny")
  {
    cout<<"Cloudy";
  }
  else if(s == "Cloudy")
  {
    cout<<"Rainy";
  }
  else
    cout<<"Sunny";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int x,y;
    while(1)
    {
        cin>>x>>y;
        if((x==0) && (y==0))
            break;
        if(x<y)
            cout<<x<<" "<<y<<endl;
        else
            cout<<y<<" "<<x<<endl;
    }

    return 0;
}


Measured memory_bytes: 3088
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<math.h>
using namespace std;

int main() {
	bool cards[4][13];
	for (int i = 0; i < 4; i++) {
		for (int j = 0; j < 13; j++)cards[i][j] = 0;
	}
	int num, n;
	scanf("%d", &n);
	char mark;
	for (int i = 0; i < n; i++) {
		scanf("%s %d", &mark, &num);
		switch (mark) {
		case 'S':
			cards[0][num - 1] = 1;
			break;
		case 'H':
			cards[1][num - 1] = 1;
			break;
		case 'C':
			cards[2][num - 1] = 1;
			break;
		case 'D':
			cards[3][num - 1] = 1;
			break;
		}
	}
	for (int i = 0; i < 4; i++) {
		for (int j = 0; j < 13; j++) {
			if (cards[i][j] == 0) {
				if (i == 0)printf("%c %d\n", 'S', j + 1);
				else if (i == 1)printf("%c %d\n", 'H', j + 1);
				else if (i == 2)printf("%c %d\n", 'C', j + 1);
				else if (i == 3)printf("%c %d\n", 'D', j + 1);
			}
		}
	}
}


Measured memory_bytes: 3196
#include <bits/stdc++.h>
using i64 = long long;

int main() {
    int n, w;
    std::cin >> n >> w;
    std::vector<i64> wt(n), v(n);
    for (int i = 0; i < n; i++) {
        std::cin >> wt[i] >> v[i];
    }

    std::vector<i64> dp(w + 1);
    for (int i = wt[0]; i <= w; i++) {
        dp[i] = v[0];
    }
    for (int i = 1; i < n; i++) {
        auto tmp(dp);
        for (int j = wt[i]; j <= w; j++) {
            dp[j] = std::max(tmp[j], tmp[j - wt[i]] + v[i]);
        }
    }
    std::cout << dp[w] << std::endl;

    return 0;
}

Measured memory_bytes: 1804
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fast ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
int main(){
	fast;
	int n, a,b,c; cin>>n>>a>>b>>c;
	string s[n];
	for(int i=0; i<n; i++)
		cin>>s[i];
	if(a>=3 && b>=3 && c>=3){
		cout<<"Yes\n";
		map<string, int>mp;
		mp["AB"]=1; mp["BC"]=1; mp["AC"]=1;
		for(int i=0; i<n; i++){
			cout<<s[i][mp[s[i]]]<<endl;
			mp[s[i]]^=1;
		}
		return 0;
	}
	a=min(a, 3), b=min(b, 3), c=min(c, 3);
	bool dp[n+1][4][4][4]; memset(dp, false, sizeof(dp));
	for(int i=0; i<4; i++) for(int j=0; j<4; j++) for(int k=0; k<4; k++) dp[n][i][j][k]=true;
	for(int i=n-1; i>=0; i--){
		for(int x=0; x<4; x++) for(int y=0; y<4; y++) for(int z=0; z<4; z++){
			if(s[i]=="AB"){
				if(x>0) dp[i][x][y][z]|=dp[i+1][x-1][y+1][z];
				if(y>0) dp[i][x][y][z]|=dp[i+1][x+1][y-1][z];
			}
			if(s[i]=="BC"){
				if(y>0) dp[i][x][y][z]|=dp[i+1][x][y-1][z+1];
				if(z>0) dp[i][x][y][z]|=dp[i+1][x][y+1][z-1];
			}
			if(s[i]=="AC"){
				if(x>0) dp[i][x][y][z]|=dp[i+1][x-1][y][z+1];
				if(z>0) dp[i][x][y][z]|=dp[i+1][x+1][y][z-1];
			}
		}
	}
	bool yea=false;
	for(int i=0; i<=a; i++) for(int j=0; j<=b; j++) for(int k=0; k<=c; k++){
		if(dp[0][i][j][k]){
			a=i; b=j; c=k; yea=true; break;
		}
	}
	if(!yea){cout<<"No\n"; return 0;}
	cout<<"Yes\n";
	for(int i=0; i<n; i++){
		if(s[i]=="AB"){
			if(b>0 && dp[i+1][a+1][b-1][c]) a++, b--, cout<<"A\n";
			else if(a>0 && dp[i+1][a-1][b+1][c]) a--, b++, cout<<"B\n";
		}
		if(s[i]=="BC"){
			if(c>0 && dp[i+1][a][b+1][c-1]) b++, c--, cout<<"B\n";
			else if(b>0 && dp[i+1][a][b-1][c+1]) c++, b--, cout<<"C\n";
		}
		if(s[i]=="AC"){
			if(a>0 && dp[i+1][a-1][b][c+1]) a--, c++, cout<<"C\n";
			else if(c>0 && dp[i+1][a+1][b][c-1]) a++, c--, cout<<"A\n";
		}
	}
	return 0;
}

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

int main() {
    int n,k;
    cin >> n >> k;
    vector<int> p(n), c(n);
    rep(i,n) {
        cin >> p[i];
        p[i]--;
    }
    rep(i,n) cin >> c[i];
    ll ans = -1e18;
    rep(si,n) {
        int x = si;
        vector<int> s;
        ll total = 0;
        while (1) {
            x = p[x];
            s.push_back(c[x]);
            total += c[x];
            if (x==si) break;
        }
        int l = s.size();
        ll t = 0;
        rep(i,l) {
            t += s[i];
            if (i+1 > k) break;
            ll now = t;
            if (total > 0) {
                ll e = (k-i-1)/l;
                now += total*e;
            }
            ans = max(ans, now);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3728
#include<stdio.h>
#include<string.h>

int main () {
    int tp=0, hp=0;//ポイント（初期化しておく
    int n; //ターン数
    int res;
    char t[101], h[101];
    
    //ターン数入力
    scanf("%d", &n);
    
    while (n--) { //n--する間
        scanf("%s %s", t, h); //具体的なカード名
        
        res = strcmp(t, h); //文字列を比較して値を返す
        if (res > 0) {
            tp += 3;
        }else if (res < 0) {
            hp += 3;
        }else{
            tp++;
            hp++;
        }
    }
    
    printf("%d %d\n", tp, hp);
    
    return 0;
}


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

int main() {
    int A, B, C, D, E, F;
    cin >> A >> B >> C >> D >> E >> F;
    int ans_1 = 100;
    int ans_2 = 0;
    double conc_max = -1;
    for (int i=0; i<=30; i++) {
        for (int j=0; j<=30; j++) {
            for (int k=0; k<=100; k++) {
                for (int l=0; l<=100; l++){
                    int water = 100 * A * i + 100 * B * j;
                    int sugar = C * k + D * l;
                    int sum = water + sugar;
                    if (water == 0) continue;
                    double conc = (100 * sugar) / (double)sum;
                    double Threshold = (E * water) / 100;
                    if (sum > F) continue;
                    if (sugar > Threshold) continue;
                    if (conc > conc_max) {
                            ans_1 = sum;
                            ans_2 = sugar;
                            conc_max = conc;
                    } 
                }
            }
        }
    }
    cout << ans_1 << " " << ans_2 << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
  int time[4], total = 0, i;

  for(i = 0; i < 4; i++){
    scanf("%d", &time[i]);
    total += time[i];
  }

  printf("%d\n", total/60);
  printf("%d\n", total%60);

  return 0;
}

Measured memory_bytes: 596
N, M = map(int, input().split())
S = []
for _ in range(M):
    arr = list(map(int, input().split()))
    bit = 0
    for i in arr[1:]:
        # print(i)
        bit = bit | (1 << (i - 1))
    # print('bit', bit, bin(bit))
    S.append(bit)
    # S.append(arr[1:])
P = list(map(int, input().split()))
# print('S')
# print(S)
# print('P', P)
ans = 0
for bit in range(1 << N):
    cnt = 0
    for i in range(M):
        # print('S[i], bit', bin(S[i]), bin(bit))
        p = S[i] & bit
        # print('p', bin(p))
        on = 0
        for j in range(N):
            # print('judge', 1 << j, p & (1 << j))
            if p & (1 << j):
                on += 1
            # if p & (1 << j):
            #     on += 1
        # print('P[i], i, on', P[i], i, on)
        # print('on', on)
        if (on % 2) == P[i]:
            cnt += 1
    if cnt == M:
        ans += 1
print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for(int i = (a); i < (int)(b); i++)
#define pw(x) (1LL<<(x))
static const int fast_io = [](){ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);return 0;}();
static const int precise_doubles = [](){cout<<fixed<<setprecision(20);return 0;}();
typedef pair<int, int> PII;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// find_by_order(k) - iterator to kth largest, order_of_key(k) - #things < k
typedef long double LD;
typedef long long LL;
#define EVAL(x) x
#define SPA(x) EVAL({cout << #x" = " << x << ' ';})
#define NEWL EVAL({cout << '\n';})
#define SPAR(a, b) EVAL({cout<<#a" = ";for(auto it=a;it!=b;)cout<<*(it++)<<" ";cout<<'\n';})
#define SPAV(v) EVAL({cout<<#v" = ";for(auto it=v.begin();it!=v.end();)cout<<*(it++)<<" ";cout<<'\n';})
const int INF = 0x3f3f3f3f; // 1.0e9
const LL LINF = 0x3f3f3f3f3f3f3f3fll; // 4.5e18
const LD eps = 1e-20;
const int mod = 3;
inline int msum(int x, int y) {return (x+y<mod ? x+y : x+y-mod);}
inline int mdif(int x, int y) {return (x>=y ? x-y : x-y+mod);}
inline int mprod(int x, int y) { return (1ll*x*y) % mod; }
inline int mpow(int x, LL y) {LL r=1;while(y){if(y&1)r=mprod(r,x);x=mprod(x,x);y>>=1;}return r;}
inline int minv(int x) { return mpow(x, mod-2); }
#define DIE EVAL({cout << -1 << '\n'; exit(0);})
//------------------------------------------------------------------------------------------------------

LL K;

int main() {
    cin >> K;
    LL x = K % 50;
    LL m = (K-x)/50 + 49;
    cout << 50 << '\n';
    REP(i, 50-x) cout << (m-x) << ' ';
    REP(i, x) cout << (m+51-x) << ' ';
    cout << '\n';
}






























Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
using namespace std;
const long long mod=998244353;
long long C[5005][5005];
int n,k;
long long calc(int n, int k)
{
    if (n<0 || k<0 || k>n) return 0;
    return C[n][k];
}
int main()
{
	scanf("%d%d",&k,&n);
	for (int i=0;i<=5001;i++)
	{
		C[i][0]=C[i][i]=1;
		for (int j=1;j<i;j++)
			C[i][j]=(C[i-1][j-1]+C[i-1][j])%mod;
	}
	for (int i=2;i<=k+k;i++)
	{
		int u=min(k,i/2),v=max(1,i-k);
		long long ans=0;
		for (int j=0;j<=u-v+1;j++)
			ans=(ans+calc(u-v+1,j)*calc(n+k-j-j-1,n-j-j)*((j%2==0)?1:-1)%mod)%mod;
		printf("%lld\n",(ans+mod)%mod);
	}
	return 0;
}

Measured memory_bytes: 194048
using System;
using System.Linq;
namespace AtCoder {
    class Program {
        static void Main(string[] args) {
            var N = int.Parse(Console.ReadLine());
            var H = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            for (int i = 1; i < H.Length; i++) {
                if (H[H.Length - i] - H[H.Length - i - 1] < 0) {
                    H[H.Length - i - 1]--;
                    if (H[H.Length - i] - H[H.Length - i - 1] < 0) {
                        Console.WriteLine("No");
                        return;
                    }
                }
            }
            Console.WriteLine("Yes");
        }
    }
}


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

using namespace std;

int t[100001], x[100001], y[100001];

int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> t[i] >> x[i] >> y[i];
	}
	for (int i = 1; i < n; i++) {
		int d = abs(x[i] - x[i - 1]) + abs(y[i] - y[i - 1]);
		int nt = t[i] - t[i - 1];
		if ((d % 2) != (nt % 2) || d > nt) {
			cout << "No" << endl;
			return 0;
		}
	}
	if (n == 1) {
		int d = x[0] + y[0];
		int nt = t[0];
		if ((d % 2) != (nt % 2) || d > nt) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <set> 
#include <map>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <cctype>
#define REP(i,n) for(int i=0; i<(n); ++i)
#define FOR(i,a,b) for(int i=(a); i<(b); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const ll INFLL = 1001001001001001001;  // > 10^18
const int MOD = (int)1e9 + 7;
const ll MODLL = (ll)1e9 + 7;
const double EPS = 1e-9;



int main () {

    int n,m; cin >>n>>m;
    vector<vector<char> > a(n, vector<char>(n)); REP(i,n) REP(j,n) cin >> a[i][j];
    vector<vector<char> > b(m, vector<char>(m)); REP(i,m) REP(j,m) cin >> b[i][j];

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            bool flag = true;
            for (int k = 0; k < m; k++) {
                for (int l = 0; l < m; l++) {
                    if (i+k >= n || j+l >= n || b[k][l] != a[i+k][j+l]) {
                        flag = false;
                    } 
                }
            }
            if (flag) {
                cout << "Yes" << endl;
                return 0;
            } 
        }
    }

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




Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>
#include <bitset>
#include<stack>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;

template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T>
map<T, T> getPrimeFactor(T n) {
	map<T, T> res;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			res[i] ++;
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}

long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}


#define in(x) cin >> x
#define out(x) cout << x
#define outn(x) cout << x << '\n'
#define outs(x) cout << x << ' '
#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)


int main() {
	ll h,x=1,ans=1;
	std::cin >> h;
	while (true) {
		x *= 2;
		if (x > h) {
			break;
		}
		ans = 2 * ans + 1;
	}
	outn(ans);
	return 0;

}


Measured memory_bytes: 256
ans = []

while True:
    n, l, r = map(int, input().split())
    if n + l + r == 0:
        break

    a = []
    for i in range(n):
        a.append(int(input()))
   
    cnt = 0
    for x in range(l, r + 1):
        
        for j in range(n):
            if x % a[j] == 0:
                if (j + 1) % 2 == 1:
                    cnt += 1
                break
            elif j == (n - 1):
                if n % 2 == 0:
                    cnt += 1
                 
    ans.append(cnt)

for i in ans:
    print(i)



Measured memory_bytes: 5600
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <deque>
#include <tuple>
#include <map>
#include <sstream>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort(ALL(x))
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const long double PI  = acos(-1.0L);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a,b) a = (((a)<(b))?(b):(a))
#define chmin(a,b) a = (((a)>(b))?(b):(a))

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}


signed main(){
  ll n,k,x,y; cin>>n>>k>>x>>y;
  ll ans = 0;
  ll day = 1;
  while(day<=k){
    ans += x;
    if(day==n) return cout<<ans<<endl,0;
    day++;
  }
  while(day<=n){
    ans += y;
    day++;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#![allow(unused_imports, unused_variables, dead_code)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

trait InputValue {
    fn parse(s: &str) -> Self;
}

fn read<T: InputValue>() -> T {
    let mut buf = String::new();
    let _ = stdin().read_line(&mut buf);
    T::parse(&buf.trim())
}

fn readnc<T: InputValue>() -> Vec<T> {
    let mut vec = vec![];
    let line: String = read();
    for token in line.split_whitespace() {
        vec.push(T::parse(token));
    }
    vec
}

fn readn<T: InputValue>(n: usize) -> Vec<T> {
    let mut vec = vec![];
    for _ in 0..n {
        vec.push(read());
    }
    vec
}

macro_rules! parse_single_value {
    ($($t:ty),*) => {
        $(
            impl InputValue for $t {
                fn parse(s: &str) -> $t { s.parse().unwrap() }
            }
        )*
	}
}
parse_single_value!(i32, i64, f32, f64, usize, String);

macro_rules! parse_tuple {
	($($t:ident),*) => {
		impl<$($t),*> InputValue for ($($t),*) where $($t: InputValue),* {
			fn parse(s: &str) -> ($($t),*) {
				let mut tokens = s.split_whitespace();
				let t = ($($t::parse(tokens.next().unwrap())),*);
				t
			}
		}
	}
}
parse_tuple!(A, B);
parse_tuple!(A, B, C);

// ===

fn dist(u: usize, v: usize, n: usize) -> usize {
    if u <= v {
        v - u
    } else {
        v + n - u
    }
}

fn add2(fr: usize, to: usize, d: i64, x2: &mut Vec<i64>) {
    let l = (to - fr + 1) as i64;
    x2[fr] += 1;
    x2[to+1] -= l + 1;
    x2[to+2] += l;

    x2[fr] += d - 1;
    x2[fr+1] -= d - 1;
    x2[to+1] -= d - 1;
    x2[to+2] += d - 1;
}

fn main() {
    let (n, m): (usize, usize) = read();
    let mut a: Vec<usize> = readnc();
    for i in 0..n {
        a[i] -= 1;
    }

    let mut sum = 0;
    for i in 1..n {
        sum += dist(a[i-1], a[i], m);
    }

    let mut x0 = vec![0; m+2];
    let mut x1 = vec![0; m+2];
    let mut x2 = vec![0; m+2];

    for i in 1..n {
        let fr = a[i-1];
        let to = a[i];
        if dist(fr, to, m) <= 1 {
            continue
        }
        let fr = (fr + 2) % m;
        if fr <= to {
            add2(fr, to, 1, &mut x2);
        } else {
            add2(fr, m-1, 1, &mut x2);
            add2(0, to, (m - fr + 1) as i64, &mut x2);
        }
    }

    x1[0] = x2[0];
    for i in 1..m+1 {
        x1[i] = x1[i-1] + x2[i];
    }
    x0[0] = x1[0];
    for i in 1..m+1 {
        x0[i] = x0[i-1] + x1[i];
    }

    let mut bestdec = 0;
    for i in 0..m {
        bestdec = max(bestdec, x0[i]);
    }
    println!("{}", sum as i64 - bestdec);
}

Measured memory_bytes: 8444
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        char[] lis = new char[256];

        for (int i = 0; i < 4; ++i) {
            lis[s.charAt(i)] += 1;
        }
        for (int i = 0; i < 256; ++i) {
            if (lis[i] != 0 && lis[i] != 2) {
                System.out.println("No");
                return;
            }
        }
        System.out.println("Yes");
    }
}



Measured memory_bytes: 20692
//
// D - すぬけ君の塗り絵 / Snuke's Coloring
//

#include <iostream>
#include <unordered_map>

using namespace std;
using ULL =  unsigned long long;

int main() {

    int H, W, N;
    cin >> H >> W >> N;

    unordered_map<string, ULL> map;

    for (int i = 0; i < N; i++) {
        int a, b;
        cin >> a >> b;
        for (int y = a - 2; y <= a; y++) {
            for (int x = b - 2; x <= b; x++) {
                if (y > 0 && y <= H - 2 && x > 0 && x <= W - 2) {
                    string k = to_string(y) + "-" + to_string(x);
                    if (map.find(k) == map.end()) {
                        map[k] = 1;
                    } else {
                        map[k]++;
                    }
                }
            }
        }
    }

    ULL ans[10] = {0};
    ULL zero = (ULL)(H - 2) * (ULL)(W - 2);

    for (auto it = map.begin(); it != map.end(); it++) {
        ans[it->second]++;
        zero--;
    }
    ans[0] = zero;

    for (int i = 0; i < 10; i++) {
        cout << ans[i] << endl;
    }
}

Measured memory_bytes: 69380
def is_word(i):
  # T文字の長さを切り取り
  sub_S = S[i:i+len(T)]
  for s, t in zip(sub_S, T):
    if s == "?":
      continue
    if s != t:
      return False
  return True

S = input()
rep_S = S.replace("?", "a")
T = input()

word_L = []
for i in range(len(S)-len(T)+1):
  if is_word(i):
    s = rep_S[:i] + T + rep_S[i+len(T):]
    word_L.append(s)

ans = "UNRESTORABLE"
if word_L:
  ans = sorted(word_L)[0]
print(ans)  
  

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define sayyes cout<<"Yes"<<endl;
#define sayno cout<<"No"<<endl;
using namespace std;
typedef long long ll;
const double PI=acos(-1);
typedef pair<int,int>P;
const int mod =1e9+7;

int main()
{
    int n;
    cin>>n;
    vector<ll> a(n);
    rep(i,n)cin>>a[i];
    ll total=0;
    rep(i,n)total ^=a[i];
    rep(i,n)
    {
        ll ans=total^a[i];
        cout<<ans<<" ";
    }
}


Measured memory_bytes: 4748
#include <vector>
#include <iostream>
#include <algorithm>
#include <limits>
#include <string>
#include <stack>
#include <queue>

#define INT_MAX 2147483647
#define INT_MIN -2147483647
using namespace std;

int partition(vector<int> &vec, int l, int r)
{
	if (vec.empty()) return -1;

	int len = vec.size();
	int tmp = vec[len - 1];

	int pre = l;
	for (int idx = l; idx <= r; ++idx)
	{
		if (vec[idx] <= tmp)
			swap(vec[idx], vec[pre++]);
	}
	vec[pre - 1] = tmp;
	return pre - 1;
}

int main()
{
	vector<int> data;
	int v;
	cin >> v;
	while (cin >> v)
		data.push_back(v);

	int len = data.size();
	int pos = partition(data, 0, len - 1);
	if (pos >= 0)
	{
		for (int i = 0; i < pos; ++i) cout << data[i] << " ";
		cout << "[" << data[pos] << "] ";
		for (int i = pos+1; i < len - 1; ++i) cout << data[i] << " ";
		if (pos != len - 1) cout << data[len - 1];
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 3308
#pragma GCC optimize("Ofast")
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define flash ios_base::sync_with_stdio(false);     cin.tie(NULL);
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define all(v) v.begin(),v.end()
#define f first
#define s second



using namespace std;

int main()
{
  flash
  string s;
  cin>>s;
  int flag=0;
  for(int i=0;i<s.length();i++){
    if(s[i]=='7')
      {
        flag=1;
        break;
      }
  }
  if(flag)
    cout<<"Yes\n";
  else
    cout<<"No\n";


}


Measured memory_bytes: 3640
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    int r = scanner.nextInt();
    int D = scanner.nextInt();
    int x2000 = scanner.nextInt();

    long prev_x = x2000;

    for (int i = 0; i < 10; i++) {
      prev_x = r * prev_x - D;
      System.out.println(prev_x);
    }
  }
}

Measured memory_bytes: 21844
#include <stdio.h>

int main(void)
{
	int n;
	int money;
	
	scanf("%d", &n);
	
	money = 100000;
	while (n != 0){
		money += money * 0.05;
		
		if (money % 1000 != 0){
			money = money - (money % 1000) + 1000;
		}
		n--;
	}
	printf("%d\n", money);
	
	return (0);
}

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

void print(std::vector<int> readvec){
    int sz = readvec.size();
    for(int i = 0; i < sz; ++i){
        std::cout << readvec.at(i);
        if(sz - 1 != i){
            std::cout << " ";
        }else{
            std::cout << std::endl;
        }
    }
}

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

    std::vector<int> a(n);
    for(int i = 0; i < n; ++i){
        std::cin >> a.at(i);
    }

    bool flg = true;
    int min;
    while(flg){
        std::sort(a.begin(), a.end());
        a.erase(std::unique(a.begin(), a.end()), a.end());
        
        auto itr = std::find_if(a.begin(), a.end(), [](int i){
            return 0 < i;
        });

        min = *itr;

        for(auto jtr = itr + 1; a.end() != jtr; ++jtr){
            *jtr %= min;
        }

        if(1 == a.size() || 2 == a.size() && 0 == a.at(0)){
            flg = false;
        }
    }

    std::cout << min << std::endl;

    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <stack>
using namespace std;

struct node{
	int value = 0;
	vector<int> next;
};

int main(){
	int n, a, b, q, p, x, num;
	stack<int> st;
	cin >> n >> q;
	node tree[n+1];

	for(int i=0; i<n-1; i++){
		cin >> a >> b;
		tree[a].next.push_back(b);
	}
	for(int i=0; i<q; i++){
		cin >> p >> x;
		tree[p].value += x;
	}

	st.push(1);
	while(!st.empty()){
		num = st.top();
		st.pop();
		for(int i=0; i<tree[num].next.size(); i++){
			st.push(tree[num].next[i]);
			tree[tree[num].next[i]].value += tree[num].value;
		}
	}
	for(int i=1; i<=n; i++){
		cout << tree[i].value << endl;
	}
	return 0;
}



Measured memory_bytes: 14848
n = int(input())
L = list(map(int, input().split()))
L.sort()
ans = 0

for i in range(n):
    for j in range(i+1, n):
        for k in range(j+1, n):
            if len(list(set([L[i], L[j], L[k]]))) < 3:
                continue
            if L[i] + L[j] <= L[k]:
                continue
            ans += 1
print(ans)


Measured memory_bytes: 73840
#include <stdio.h>
#include <string.h>
#define M 100005

typedef struct QQ{
    char name[100];
    int t;
}Q;

Q proc[M];
int head,tail;

void enqu(char name[100], int t){
    strcpy(proc[tail].name,name);
    proc[tail].t = t;
    tail = (tail + 1) % M;
}

void robbin(int waste,int n){
   int time=0,ct=0;
   while(head!=tail){
       if(waste < proc[head].t){
           time += waste;
           proc[head].t -= waste;
           enqu(proc[head].name,proc[head].t);
       }
       else {
           time += proc[head].t;
           printf("%s %d\n",proc[head].name,time);
       }
       head= (head + 1 )% M;
   }
}

int main(void){
    head=0;
    int n,waste,i,t;
    char name[100];
    scanf("%d%d",&n,&waste);
    tail = 0;
    for(i=0;i<n;i++){
        scanf("%s%d",name,&t);
        enqu(name,t);
    }
    robbin(waste,n);
    return 0;
}



Measured memory_bytes: 11856
/// Rustで競技プログラミングの入力をスッキリ記述するマクロ
///
/// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        d: u64,
    }

    let ans = match d {
        25 => "Christmas",
        24 => "Christmas Eve",
        23 => "Christmas Eve Eve",
        _  => "Christmas Eve Eve Eve",
    };
    println!("{}", ans);
}


Measured memory_bytes: 4352
#!/usr/bin/env ruby

N = gets.chomp.to_i
A = gets.chomp.split.map(&:to_i)

ans = 0

1.upto(N-1) do |i|
  diff = A[i-1] - A[i] 

  if diff > 0
    ans += diff
    A[i] += diff
  end
end

puts ans


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

int main(){
	long long int N,K,Posibles=1;
	scanf("%lld %lld",&N,&K);
	for (int i = 0; i < N; ++i)
	{
		if (i==0) Posibles*=K;
		else Posibles*=K-1;
	}
	cout << Posibles;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <iostream>

#include <bitset>
#include <cassert>
#include <queue>
#include <random>
#include <stack>
#include <iomanip>

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define repf(i, a, b) for (int i = (int)a; i < (int)b; i++)
#define repv(x, arr) for (auto &x : arr)
#define all(v) (v).begin(), (v).end()
#define vec(name, num) vector<ll> name((num), 0);
#define mp(a, b) make_pair(a, b)
#define op(i) cout << (i) << endl;
#define F first
#define S second

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;

const ll mod = 1e9 + 7;
const ll infl = 1e17;

typedef unsigned long long ull;


int main()
{
    ll n;
    cin >> n;
    map<ll, set<ll>> branch;
    ll a, b;
    rep(i,n-1){
        cin >> a >> b;
        branch[a - 1].insert(b - 1);
        branch[b - 1].insert(a - 1);
    }
    vector<ll> c(n);
    rep(i, n) cin >> c[i];
    sort(all(c));
    queue<ll> cc;
    rep(i, n) cc.push(c[n-1-i]);
    vector<ll> d(n, infl);
    d[0] = cc.front();
    cc.pop();
    queue<ll> check;
    check.push(0);
    ll m = 0;
    while (!(check.empty())){
        ll now = check.front();
        check.pop();
        for (auto nex:branch[now]){
            if (d[nex] == infl){
                d[nex] = cc.front();
                m += d[nex];
                cc.pop();
                check.push(nex);
            }
        }
    }
    cout << m << endl;
    rep(i, n) cout << d[i] << " ";
    cout << endl;
}


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

using namespace std;

int main()
{
    string str;
    cin>>str;
    if(str== "SUN")
    {
        cout<<7;
    }
    if(str== "MON")
    {
        cout<<6;
    }if(str== "TUE")
    {
        cout<<5;
    }if(str== "WED")
    {
        cout<<4;
    }if(str== "THU")
    {
        cout<<3;
    }if(str== "FRI")
    {
     cout<<2;
    }if(str== "SAT")
    {
        cout<<1;
    }

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
  int i, j;
  int n;
  long a[100000];
  long x[100000];
  scanf("%d", &n);
  for (i = 0; i<n; i++) {
    scanf("%ld", &a[i]);
  }
  int xsum=0;
  for (i = 0; i<n-1; i++) {
    if(i%2==0)
      xsum-=a[i];
    else
      xsum+=a[i];
  }
  xsum+=a[n-1];
  x[n-1]=xsum;
  for(i=n-2;i>=0;i--){
    x[i]=2*a[i]-x[i+1];
  }
  for (i = 0; i<n; i++) {
    printf("%ld", x[i]);
    if(i<n-1) printf(" ");
  }
  printf("\n");  
  return 0;
}

Measured memory_bytes: 2816
#include <stdio.h>
 
int main(void)
{
    char m[102][102];
 
    while(1)
    {
        int h,w,x,y;
        scanf("%d%d",&h,&w);
        if(h==0&&w==0)return 0;
        for(y=0;y<h;y++)
            scanf("%s",m[y]);
        x=0;y=0;
        for(;;)
        {
            h=m[y][x];m[y][x]='!';
            if(h=='!')
            {
                puts("LOOP");
                break;
            }
            else if(h=='v') y++;
            else if(h=='^') y--;
            else if(h=='>') x++;
            else if(h=='<') x--;
            else
            {
                printf("%d %d\n",x,y);
                break;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 1056
use input::*;
use std::cmp::*;
use std::collections::HashMap;
use std::io::*;
use std::num::*;
use std::str::*;

mod input {
    use super::*;

    pub fn read<T: FromStr>() -> T {
        stdin()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>()
            .parse::<T>()
            .ok()
            .unwrap()
    }
    pub fn str() -> String {
        read()
    }
    pub fn s() -> Vec<char> {
        str().chars().collect()
    }
    pub fn i() -> i64 {
        read()
    }
    pub fn u() -> usize {
        read()
    }
    pub fn f() -> f64 {
        read()
    }
    pub fn c() -> char {
        read::<String>().pop().unwrap()
    }
    pub fn iv(n: usize) -> Vec<i64> {
        (0..n).map(|_| i()).collect()
    }
    pub fn uv(n: usize) -> Vec<usize> {
        (0..n).map(|_| u()).collect()
    }
    pub fn fv(n: usize) -> Vec<f64> {
        (0..n).map(|_| f()).collect()
    }
    pub fn cmap(h: usize) -> Vec<Vec<char>> {
        (0..h).map(|_| s()).collect()
    }
}

fn main() {
    let (S, T) = (str(), str());
    let mut A = u();
    let mut B = u();
    let U = str();
    let mut map = HashMap::new();
    if S == U {
        A -= 1
    } else {
        B -= 1;
    };
    map.insert(S.clone(), A);
    map.insert(T.clone(), B);
    println!("{} {}", map[&S], map[&T]);
}


Measured memory_bytes: 4352
# import sys  sys.exit()を使う時に必要

def main():
  if 'get_ipython' not in globals():  
    # For Subsession
    N = int(input())
    # A, B, C = input().split()
    A = [int(i) for i in input().split()] 
    # S = [input() for _ in range(N)]  縦持ち／行数N
    # t = [0] * N  　　ti xi yi 縦持ち/行数N
    # x = [0] * N
    # y = [0] * N
    # for i in range(N):
    #   t[i], x[i], y[i] = map(int, input().split())
  else:
    #A = [-10,5,-4]
    #A = [10,-4,-8,-11,3]
    A = [-1000000000,1000000000,-1000000000,1000000000,-1000000000,0,1000000000,-1000000000,1000000000,-1000000000,1000000000]
    N = len(A)

  # Processing
  # if 'get_ipython' in globals(): print("debug")
  sumA = 0
  min_abs = 1000000000
  cnt_minus = 0
  for a in A:
    if a < 0 :
      cnt_minus +=1
    if abs(a) < min_abs: 
      min_abs = abs(a)
    sumA += abs(a)
  
  if cnt_minus % 2 > 0:
    sumA -= min_abs * 2
  
  print(sumA)

main()

Measured memory_bytes: 14212
#include<stdio.h>

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

     if(n%2==0)
     {
         printf("%d\n",(n/2)*(n/2));
     }
     else
     {
         printf("%d\n",(n/2)*((n/2)+1));
     }
     return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (int)(n); i++)
#define int long long
#define ll long long
using namespace std;
signed main(){
    string s;
    cin>>s;
    cout<<s.at(0)<<s.at(1)<<s.at(2)<<endl;
    return 0;
}

Measured memory_bytes: 3556
n = int(input())
h = list(map(int,input().split()))
flg = "Yes"
pre = -999
for i in range(1,n):
    #print(h[i])
    if pre <= h[i]-1 :
        pre = h[i]-1
    elif pre <= h[i]:
        pre = h[i]
    else:
        flg = "No"
        break
    
print(flg)






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

using namespace std;

int main(){
  int n;
  cin >> n;
  vector<int> p;
  for(int i = 0;i < n;i++){
    int a;
    cin >> a;
    p.push_back(a);
  }
  sort(p.begin(),p.end());
  p[n-1] = p[n-1]/2;
  long long int ans = 0;
  for(int i = 0;i < n;i++){
    ans += p[i];
  }
  cout << ans << endl;
}


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

int main(){
  int data[2]={};
  for(int i=0;i<3;i++){
    int a;cin>>a;
    if(a==5){
      data[0]++;
    }else if(a==7){
      data[1]++;
    }else{
      cout<<"NO"<<endl;
      return 0;
    }
  }
  if(data[0]==2 and data[1]==1){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }
  return 0;
}

Measured memory_bytes: 256