akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#include <math.h>
#include <limits.h>
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) > (b) ? (b) : (a))
#define abs(x) ((x) > 0 ? (x) : -(x))
#define MOD (ll)1000000007 //10^9 + 7
#define endl printf("\n")
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, n, m) for (int i = (n), i < (m); i++)


int
main(int argc, char *argv[])
{
  int n, m, a[10010], b, c, x[10010] = {};
  scanf("%d %d", &n, &m);
  rep(i, m) {
    scanf("%d %d", &a[i], &b);
    rep(j, b) {
      scanf("%d", &c);
      x[i] += (1 << (c - 1));
    }
  }

  int dp[100010] = {};
  for (int i = 0; i < (1 << n); i++) dp[i] = INT_MAX;
  dp[0] = 0;
  for (int i = 0; i < (1 << n) - 1; i++) {
    if (dp[i] != INT_MAX){
      for (int j = 0; j < m; j++) {
	dp[i | x[j]] = Min(dp[i | x[j]], dp[i] + a[j]);
      }
    }
  }
  //printf("%d\n", dp[13]);

  if (dp[(1 << n) - 1] == INT_MAX) {
    printf("%d\n", -1);
    return 0;
  }
  printf("%d\n", dp[(1 << n) - 1]);

  return 0;
}

  


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



Measured memory_bytes: 3116
#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
long long int mod = 1e9+7;
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};
//////////////////////////////////

int main(){
    int n, m; cin >> n >> m;
    vector<pair<long long, long long>> p(n);
    for(int i=0; i<n; i++) cin >> p[i].first >> p[i].second;
    sort(p.begin(), p.end());
    
    long long sum = 0;
    int j = 0;
    priority_queue<long long> pq;
    for(long long i=1; i<=m; i++) {
        for(; j<n; j++) {
            if(p[j].first > i) break;
            pq.push(p[j].second);
        }
        if(!pq.empty()) {
            sum += pq.top();
            pq.pop();
        }
    }

    cout << sum << endl;

    return 0;
}

// EOF



Measured memory_bytes: 2936
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ll  long long
#define FASTINOUT ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const int N=2e5+9;
bool visited[N];
int main()
{
    FASTINOUT;
    ll x,k,ans,m=1;
    cin>>x>>k;
    vector<ll>v;
    ll y[x+1];
    for (int i=1; i<=x; i++)
    {
        cin>>y[i];
    }
    while (!visited[m])
    {
        v.push_back(m);
        visited[m]=1;
        m=y[m];
        k--;
        if (k==0)
            ans=m;
    }
    if (k<=0)
    {
        cout<<ans<<endl;
        return 0;
    }
    //cout<<m<<endl;
    memset(visited,false,sizeof visited);
    v.clear();
    while (!visited[m])
    {
        v.push_back(m);
        visited[m]=1;
        m=y[m];
    }
    int sz=v.size();
    cout<<v[k%sz]<<endl;
    return 0;
}


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

using namespace std;

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

    int counter = 0;
    for(int i = 0; i < s.size(); i++) {
        if(s[i] == 'o'){
            counter++;
        }
    }

    cout << 700 + counter * 100 << endl;
    return 0;
}


Measured memory_bytes: 888
#include <cstdio>
#include <iostream>
#include <queue>
#define int long long
using namespace std;

signed main() {
  int N, M; scanf("%lld %lld", &N, &M);
  priority_queue<int> que;
  for(int i = 0; i < N; i++) {
    int A; scanf("%lld", &A);
    que.push(A);
  }
  for(int i = 0; i < M; i++) {
    int m = que.top(); que.pop();
    que.push(m/2);
  }
  int ans = 0;
  while(!que.empty()) {
    ans += que.top(); que.pop();
  }
  printf("%lld\n", ans);
  return 0;
}



Measured memory_bytes: 1400
#include<stdio.h>
#include<string.h>
#include<math.h>

 
int main(){
   int a,b;
   int aa[3] = {1,2,3};
   scanf("%d", &a);
   a--;
   scanf("%d", &b);
   b--;
   aa[a]=0;aa[b]=0;
    for(int i=0;i<3;i++){
    	if(aa[i]>0){
        	printf("%d", aa[i]);
        }
    }
	return 0;
 
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
long long n, m, dp[1001][1001], mod = 1000000007;
char a[1001][1001];
int main()
{
	cin >> n >> m;
	for (int i = 1; i <= n; i ++)
	{
		for (int j = 1; j <= m; j ++)
		{
			cin >> a[i][j];
			if (a[i][j] == '#')
				dp[i][j] = -1;
		}
	}
	for (int i = 1; i <= n; i ++) {
		if (a[i][1] == '#') break;
		dp[i][1] = 1;	
	}
	for (int j = 1; j <= m; j ++) {
		if (a[1][j] == '#') break;
		dp[1][j] = 1;
	}
	
	for (int i = 2; i <= n; i ++)
	{
		for (int j = 2; j <= m; j ++)
		{
			if (dp[i][j] != -1)
			{
				if (dp[i-1][j] != -1) dp[i][j] = (dp[i][j] + dp[i-1][j]) % mod;
				if (dp[i][j-1] != -1) dp[i][j] = (dp[i][j] + dp[i][j-1]) % mod;	
			}
				
		}
	}
	/*
	for (int i = 1; i <= n; i ++)
	{
		for (int j = 1; j <= m; j ++)
			cout << dp[i][j] << " ";
		cout << endl;	
	}
	*/
	cout << dp[n][m];
	
	
	
}

Measured memory_bytes: 9088
#include <iostream>
#include <stack>
#include <math.h>
#include <vector>
#include <string>
#include <algorithm>
#include <map>

#define rep(i,n) for(int i=0; i < n; i++)
using ll =  long long;
using namespace std;
#define pi 3.14159265358979
int main()
{
    int x, total;
    cin >> x >> total;

    rep(kame, x+1)
    {
        int tmp = total;
        int turu = x - kame;
        if (turu != 0) tmp -= turu * 2;
        if (kame != 0) tmp -= kame *4;
        if (tmp == 0)
        {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
void printVector(const vector<int>& vec) {
    for (int value : vec) {
        cout << value << " ";
    }
    cout << endl;
}

int main() {
    int N,M;
    cin >> N >> M;
    vector<int> p(M);
    vector<string> S(M);
    for(int i=0;i<M;i++) {
        cin >> p.at(i) >> S.at(i);
    }
    vector<vector<int>> submits(N,vector<int>(2,0));
    for(int i=0;i<M;i++) {
        if(submits.at(p.at(i)-1).at(0) != 0) {
            continue;
        }
        if(S.at(i) == "WA") {
            submits.at(p.at(i)-1).at(1)++;
        }else{
            submits.at(p.at(i)-1).at(0)++;
        }
    }
    int ac = 0;
    int pena = 0;

    for(int i=0;i<N;i++) {
        if (submits.at(i).at(0) == 0) {
            continue;
        }
        ac += submits.at(i).at(0);
        pena += submits.at(i).at(1);
    }
    cout << ac << " " << pena << endl;
    /*
    cout << "ans" << endl;
    for(int i=0;i<N;i++) {
        cout << submits.at(i).at(0) <<" "<< submits.at(i).at(1) << endl;
    }
    */
}

Measured memory_bytes: 12188
fun main(args: Array<String>) {
    val (a, b, c, d) = readLine()!!.split(' ').map { it.toLong() }

    var ans = b*c
    ans = Math.max(ans, a*c)
    ans = Math.max(ans, b*d)
    ans = Math.max(ans, a*d)
    println(ans)
}


Measured memory_bytes: 36392
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#define  boost ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ull unsigned long long
#define deb(x) cout<<#x<<" "<<x<<endl;
#define fr(i,l,r) for(ll i=l;i<r;i++)
#define mems(a,x) memset(a,x,sizeof(a))
#define mod 1000000007
#define ff first
#define ss second
#define pb(x) push_back(x)
#define vll vector<ll>
#define pbp(x,y) push_back(make_pair(x,y))
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////



void solve(){
    ll n;cin>>n;

    string str;   
 cin>>str;
 string str2="ABC";
ll cnt=0,i=0;
while( i<str.size() && str.find(str2,i)!=string::npos){
    cnt++;
    i=str.find(str2,i);
    i+=3;
}
 
cout<<cnt;

}

int main(){
    ll t=1;
//cin>>t;
    while(t--){
     solve();
     cout<<endl;
    }
    return 0;
}


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


void solve(long long A, long long B, long long C){

}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    int a,b,c;cin >> a >> b >> c;
    int ans = c - (a - b);
    if(ans > 0) cout << ans << endl;
    else cout << 0 << endl;
}


Measured memory_bytes: 256
n, k, q= map(int, input().split())
a = [int(input()) for i in range(q)]

b = [k - q] * n

for i in range(q):
    b[a[i] - 1] += 1

for j in range(n):
    if b[j] > 0:
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 10448
#include <stdio.h>

int
main(int argc, char *argv[])
{
  int n, f[100], p[100][10], a, m;
  scanf("%d", &n);
  for(int i = 0; i < n; i++){
    f[i] = 0;
    for(int j = 0; j < 5; j++){
      scanf("%d %d", &m, &a);
      f[i] = (f[i] << 1) + m;
      f[i] = (f[i] << 1) + a;
    }
  }
  for(int i = 0; i < n; i++){
    for(int j = 0; j <= 10; j++){
      scanf("%d", &p[i][j]);
    }
  }

  int k = 1024; int l; int profit;
 
  int ans = -1000000000; int temp; int c;

  for(int i = 1; i < k; i++){
    profit = 0;
    for(int j = 0; j < n; j++){
      c = 0;
      temp = f[j];
      temp = temp & i;
      while(temp > 0){
	c += temp % 2;
	temp /= 2;
      }
      profit += p[j][c];
    }
    ans = (profit > ans ? profit : ans);
  }

  printf("%d\n", ans);

  return 0;
}
      
      
	


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>
#include <algorithm>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)

int main() {
	int n,ans=0,b,cnt,t;
	string s;
	vector<int> cntl(26),cntr(26);
	cin>>n>>s;
	rep(i,n){
	    cnt=0;
	    rep(k,26){
	        cntl[k]=0;cntr[k]=0;
	    }
	    rep(j,i){
	        t=s[j]-'a';
	        cntl[t]=1;
	    }
	    for(int j=i;j<n;j++){
	        t=s[j]-'a';
	        cntr[t]=1;
	    }
	    rep(k,26){
	        if(cntl[k]*cntr[k])cnt++;
	    }
	    ans=max(ans,cnt);
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 unsigned euclidean_gcd(unsigned a, unsigned b) {
  if(a < b) return euclidean_gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
int main() {
  long long a,b;
cin >> a >> b;
  vector<long long> c(a);
  long long n = 1;
    for(int i = 0;i < a;i++){
     cin >> c.at(i);
      int g = c.at(i)/2;
    n = n * g / euclidean_gcd(n,g);
    if(n > 100000000000)break;}
  
  long long ans = 0;
 
  b += n;
   ans = b / n / 2;
  long long q = 1;
  for(int i = 0;i < 100;i++){
    if(c.at(0)%2==0){c.at(0) /= 2;
                     q *= 2;}
    else{break;}
  }
  
   for(int i = 1;i < a;i++){  
     if(c.at(i)%(q*2) != q){ans = 0;}
   }
  

cout << ans << endl;
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
#define Tp template<typename Ty>
#define Ts template<typename Ty,typename... Ar>
#define Reg register
#define RI Reg int
#define Con const
#define CI Con int&
#define I inline
#define W while
#define N 100000
#define add(x,y) (a[++cnt]=x,b[cnt]=y,addE(x,y),addE(y,x))
#define addE(x,y) (e[++ee].nxt=lnk[x],e[lnk[x]=ee].to=y)
using namespace std;
int n,cnt,ee,s[2*N+5],p[N<<1],lnk[2*N+5],a[N<<1],b[N<<1];struct edge {int to,nxt;}e[N<<2];
I bool dfs(CI x,CI lst=0)
{
	if(p[n^s[x]^1]) return add(n,p[n^s[x]^1]),add(x,n<<1),true;p[s[x]]=x;
	for(RI i=lnk[x];i;i=e[i].nxt) if(e[i].to^lst&&(s[e[i].to]=s[x]^(e[i].to%n),dfs(e[i].to,x))) return true;
	return false;
}
int main()
{
	RI i,j,t;if(scanf("%d",&n),n==1) return puts("No"),0;
	for(i=2;i<n;i+=2) add(i,i+1),add(i+1,1),add(1,n+i),add(n+i,n+i+1);add(2,n+1);
	if(!(n&1)&&!dfs(s[1]=1)) return puts("No"),0;
	for(puts("Yes"),i=1;i<=cnt;++i) printf("%d %d\n",a[i],b[i]);
	return 0;
}

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

int main(void) {
  int N;
  cin >> N;
  vector<long long> T(N), A(N);
  for (int i = 0; i < N; i++) {
    cin >> T[i] >> A[i];
  }

  long long t = 1, a = 1;
  for (int i = 0; i < N; i++) {
    if (T[i] >= t && A[i] >= a) {
      t = T[i];
      a = A[i];
    } else {
      long long b = max( t / T[i] + ((t % T[i]) > 0 ? 1 : 0)
        , a / A[i] + ((a % A[i]) > 0 ? 1 : 0));
      t = T[i] * b;
      a = A[i] * b;
    }
  }
  cout << t + a << endl;
  return 0;
}

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

using namespace std;

int main()
{
    int n,q;
    cin>>n>>q;
    vector < list <int> > a(n);
    for(int i=0;i<q;i++)
    {
        int t,b;
        cin>>t>>b;
        if(t==0)
        {
            int x;
            cin>>x;
            a[b].emplace_back(x);
        }
        if(t==1)
        {
            if(!a[b].empty())
            {
                int m=0;
                for(auto it=a[b].begin();it!=a[b].end();it++,m++)
                {
                    if(m!=0)
                        cout<<" ";
                    cout<<*it;
                }
                cout<<endl;
            }
            else
                cout<<endl;
        }
        if(t==2)
        {
            int x;
            cin>>x;
            a[x].splice(a[x].end(),move(a[b]));
        }
    }
    return 0;
}



Measured memory_bytes: 18656
#include<bits/stdc++.h>
using namespace std;
int n, k, num[600007], p = 1, r;
char s[200007];
int main()
{
	scanf("%d%d%s", &n, &k, s + 1);
	for (int i = 1; i <= n; i++)
		num[i] = (s[i] == 'A');
	for (int i = 1; i <= min(2 * n, k); i++)
	{
		int f = (num[p] ^ r);
		if (f == 1)num[p] ^= 1;
		else num[p + n] = r, r ^= 1, p++;
	}
	for (int i = 1; i <= n; i++)
		num[p + i - 1] ^= r;
	if (k <= 2 * n)
	{
		for (int i = 1; i <= n; i++)
			putchar('B' - num[p + i - 1]);
		putchar('\n');
		return 0;
	}
	else
	{
		if (n % 2 == 1 && k % 2 == 1)num[p] ^= 1;
		for (int i = 1; i <= n; i++)
			putchar('B' - num[p + i - 1]);
		putchar('\n');
		return 0;
	}
	return 0;
}

Measured memory_bytes: 2560
#include <iostream>

using namespace std;

int main()
{
	int l, m, n;
	
	while (cin >> l, l){
		int ct = 0;
		for (int i = 0; i < 12; i++){
			cin >> m >> n;
			if (l > 0){
				l -= (m - n);
				ct++;
			}
		}
		if (l > 0){
			cout  << "NA";
		}
		else {
			cout << ct;
		}
		cout << endl;
	}
	return (0);
}

Measured memory_bytes: 1160
// ABC 052 C

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

using ll = long long;

vector<pair<ll, ll>> prime_factori(ll n) {
	vector<pair<ll, ll>> res;

	for(ll i = 2; i * i <= n; ++i) {
		if(n % i != 0) continue;

		ll exp = 0;
		while(n % i == 0) {
			++exp;
			n /= i;
		}
		res.push_back({i, exp});
	}

	if(n != 1) res.push_back({n, 1});

	return res;
}


int main()
{

	const int MOD = pow(10, 9) + 7;	

	ll n;
	cin >> n;

	vector<ll> ex(n+1, 0);
	for(int i = 2; i <= n; ++i) {
		const auto &pf = prime_factori(i);
		for(auto item : pf) ex[item.first] += item.second;
	}

	ll ans = 1;
	for(int i = 2; i <=n; ++i) {
		ans *= ex[i] + 1;
		ans %= MOD;
	}

	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 256
(let* ((h (read))
       (w (read))
       (ci (read))
       (cj (read))
       (di (read))
       (dj (read))
       (f (make-array (list (1+ h) (1+ w)) :initial-element t)))
  ;
  (loop :for i :from 1 :to h
        :for s := (read-line)
        :do (loop :for c :across s
                  :for j :from 1 :to w
                  :if (char= c #\#)
                  :do (setf (aref f i j) nil)))
  ;
  (defun check (q)
    (let ((c nil))
      (loop :while q
            :for pos := (pop q)
            :for i := (car pos)
            :for j := (cdr pos)
            :if (and (= i di) (= j dj))
            :do (progn
                  (setf (aref f i j) nil)
                  (return-from check nil))
            :if (aref f i j)
            :do (progn
                  (setf (aref f i j) nil)
                  (loop :for y :from (max 1 (- i 2)) :to (min h (+ i 2))
                        :do (loop :for x :from (max 1 (- j 2)) :to (min w (+ j 2))
                                  :do (when (aref f y x)
                                        (let ((d (+ (abs (- i y)) (abs (- j x)))))
                                          (if (= 1 d)
                                              (push (cons y x) q)
                                              (push (cons y x) c))))))))
      c))
  ;
  (let ((q nil)
        (cost 0))
    (push (cons ci cj) q)
    (loop :named main
          :while q
          :do (progn
                (setf q (check q))
                (unless (aref f di dj)
                  (format t "~A~%" cost)
                  (return-from main))
                (incf cost))
          :finally (format t "-1~%"))))


Measured memory_bytes: 78940
def main():
    H, W = map(int, input().split())
    c = []
    A = []
    for i in range(10):
        c.append(list(map(int, input().split())))
    for i in range(H):
        A.append(list(map(int, input().split())))
    
    for k in range(10):
        for i in range(10):
            for j in range(10):
                c[i][j] = min(c[i][j], c[i][k]+c[k][j])
    
    ans = 0
    for i in range(H):
        for j in range(W):
            if(A[i][j] == -1 or A[i][j] == 1):
                continue
            ans += c[A[i][j]][1]
    print(ans)    
main()

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

using namespace std;    
typedef long long ll;
typedef pair<ll, ll> pll;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const bool DEBUG = true;

int main(){

    string s, t;
    cin >> s >> t;

    int ans = 0;
    for(int i = 0; i < s.size(); i++){
        if( s[i] != t[i] ) ans ++;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3916
import heapq

n, m = (map(int, input().split()))
part = []
for i in range(n):
    a, b = map(int, input().split())
    part.append([a, b*-1])

part.sort()
# print(part)
idx = 0
takable = []
allmoney = 0

for i in range(m):
    if len(part) > idx:
        # print(part[idx])
        while part[idx][0] <= i+1:
            heapq.heappush(takable, part[idx][1])
            # print(takable, 0)
            idx += 1
            if len(part)-1 < idx:
                break
    if len(takable):
        pop = heapq.heappop(takable)
        # print(pop, 1)
        allmoney += pop*-1

print(allmoney)

Measured memory_bytes: 20712
#include <stdio.h>
#include <string.h>
#include <math.h>

int main() {

    int n, m, c, b, a;
    scanf("%d %d %d", &n, &m, &c);

    int arr[m];

    for (int i = 0; i < m; i++) {
        scanf("%d", &b);
        arr[i] = b;
    }
    int cnt = 0;

    for (int j = 0; j < n; j++) {
        int mysum = 0;
        for (int k = 0; k < m; k++) {
            scanf("%d", &a);
            mysum += a * arr[k];
        }
        if(mysum+c>0){
            cnt++;
        }
    }


    printf("%d",cnt);

    return 0;

} 

Measured memory_bytes: 128
#include<stdio.h>
#include<math.h>
int main(void)
{
	double a,b,h,m,c;
	scanf("%lf%lf%lf%lf",&a,&b,&h,&m);
	double A,B,x;
	A=h*30+0.5*m;
	B=6*m;
	c=A-B;
	x=a*a+b*b-2*a*b*cos(c*M_PI/180);
	x=pow(x,0.5);
	printf("%.10lf\n",x);
	return 0;
}

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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
#define LINF 1e18
typedef long long ll;

const int MOD = 1e9+7;

int main() {
    int N,M; cin >> N >> M;
    vector<int> dp(N+1,0);
    REP(i,M){
        int a; cin >> a;
        dp[a] = -1;
    }

    dp[0] = 1;

    REP(i,N){
        if(dp[i] == -1) continue;

        if(dp[i+1] != -1){
            dp[i+1] += dp[i];
            dp[i+1] %= MOD;
        }

        if(i+2<=N && dp[i+2]!=-1){
            dp[i+2] += dp[i];
            dp[i+2] %= MOD;
        }
    }
    cout << dp[N] << endl;
    return 0;
}

Measured memory_bytes: 3680
//verma_ankit484

#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>

typedef long long ll;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define pb push_back
const ll mod = (ll) 1e9+7;

using namespace std;
//using namespace __gnu_pbds;

//#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>


int main() {
  IOS
  #ifdef AV
  freopen("input.txt", "r", stdin);
  #endif
  ll h;
  cin >> h;
  ll ans = 0;
  ll p = 0;
  for (ll i = 40; i >= 0; i--) {
    if (h & (1ll << i)) {
      p = i;
      break;
    }
  }
  for (ll i = p; i >= 0; i--) {
    ans += (1ll << i);
  }
  cout << ans << 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;

int main() {
    int a, b;
    cin >> a >> b;
    if((a + b) % 2) cout << "IMPOSSIBLE" << endl;
    else cout << (a + b) / 2 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#define LL long long
using namespace std;
const int Maxn = 1000000 + 100, Mod = 1000000007;
LL N;
LL F[Maxn];
int main()
{
	scanf("%lld", &N);
	F[1] = N;
	F[2] = (N * N) % Mod;
	LL Sum = 0;
	for (int i = 3; i <= N; ++i)
	{
		F[i] = (F[i - 1] + Sum) % Mod;
		F[i] = (F[i] + ((N - 1) * (N - 1) % Mod)) % Mod;
		F[i] = (F[i] + N - i + 2) % Mod;
		Sum = (Sum + F[i - 2]) % Mod;
	}
	printf("%lld\n", F[N]);
	return 0;
}

Measured memory_bytes: 8064
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    
    int R,G,B,N;
    
    cin >> R;
    cin >> G;
    cin >> B;
    cin >> N;
    
    int c = 0;
    for( int r = 0 ; r <= 3000 ; r++ ){
        for( int g = 0; g <= 3000; g++ ){
            int v = r * R + g * G;
            
            if( N >= v  && ( N - v ) % B == 0) c++;

        }
    }
    
    cout << c;
    
}


Measured memory_bytes: 256
# 解説AC
# Tの部分集合をUとすると
# A[i]番目の項目について、
# (1)Tに選ばれない
# (2)Uに選ばれない
# (3)Uに選ばれる
# の3通りの遷移がある
# (1)(2)の場合も含めて数え上げていく（その場合、和は変わらない）

import sys
readline = sys.stdin.readline

N,S = map(int, readline().split())
A = list(map(int,readline().split()))
DIV = 998244353

dp = [0] * (S + 1)
dp[0] = 1
for i in range(N):
  newline = [0] * (S + 1)
  for j in range(len(dp)):
    # 選択肢(1)(2)の場合
    newline[j] += dp[j] * 2
    newline[j] %= DIV
    # 選択肢(3)の場合
    if j + A[i] <= S:
      newline[j + A[i]] += dp[j]
      newline[j + A[i]] %= DIV
  dp = newline

print(dp[S])

Measured memory_bytes: 68792
from bisect import bisect_left
n,m = map(int, input().split())
py = []
l = [[] for _ in range(n+1)]
for _ in range(m):
  p,y = map(int, input().split())
  l[p].append(y)
  py.append((p,y))
  
for i in l: i.sort()

for p,y in py:
  s = str(p)
  t = str(bisect_left(l[p],y)+1)
  ans = "0"*(6-len(s))+s + "0"*(6-len(t))+t
  print(ans)

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

// macro
#define rep(i,n) for(i=0;i<n;i++)
#define ll long long
#define all(v) v.begin(), v.end()

// code starts
int main()
{
	int h;
  cin>>h;
  while(h!=0)
  {
    vector<vector<int>> board(h,vector<int>(5));
    int i,j,k;
    rep(i,h)rep(j,5)cin>>board[i][j];
    int score=0;
    bool update=true;
    while(update)
    {
      update=false;
      rep(i,h)
      {
        int base=board[i][2];
        if(base==0)continue;
        int count=0;
        int kc=0;
        int st=0;
        rep(j,5)
        {
          if(board[i][j]==base)
          {
            if(kc==0&&j<3)st=j;
            kc++;
            count=max(count,kc);
          }
          else
          {
            kc=0;
          }
        }
        if(count>=3)
        {
          update=true;
          score+=base*count;
          for(j=st;j<st+count;j++)if(board[i][j]==base)
          {
            board[i][j]=0;
          }
        }
      }
      rep(j,5)
      {
        for(i=h-1;i>=0;i--)
        {
          if(board[i][j]!=0)continue;
          for(k=i-1;k>=0;k--)
          {
            if(board[k][j]!=0)
            {
              swap(board[i][j],board[k][j]);
              break;
            }
          }
        }
      }
    }
    cout<<score<<endl;
    cin>>h;
  }
}



Measured memory_bytes: 3144
using System;
class Program
{
    static void Main(string[] args)
    {
        var input = Console.ReadLine().Split(' ');
        var a = int.Parse(input[0]);
        var b = int.Parse(input[1]);
        int ans = 0;

        if(a > b){
            ans = a;
            a--;
        }else{
            ans = b;
            b--;
        }
        if(a > b){
            ans += a;
        }else{
            ans += b;
        }

        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pint pair<int, int>
#define pll pair<ll, ll>
#define vint vector<int >
#define vll vector<ll >
#define ALL(x) (x).begin(), (x).end()
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i,n) for (int i = 0; i < (n); ++i)
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
int main(){
    int k,x;
    cin >> k >> x;
    if(500*k >= x){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define fi first
#define se second
#define show(x) cerr<<#x<<"="<<x<<"\n"
using namespace std;

ll n,k;
ll a[100001];
string s;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout<<fixed;
#ifdef LOCAL_DEFINE
    FILE *stream1;
    //FILE *stream2;
    stream1=freopen("in","r",stdin);
    //stream2=freopen("out","w",stdout);
    if(stream1==NULL)return 0;
    //if(stream2==NULL)return 0;
#endif
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    ll r=2,l=2;
    for(int i=n-1;i>=0;i--){
        //show(l);
        //show(r);
        if(l/a[i]==r/a[i] && l%a[i]!=0){
            cout<<-1<<endl;
            return 0;
        }
        l=((l+a[i]-1)/a[i])*a[i];
        r=(r/a[i])*a[i]+a[i]-1;
    }
    cout<<l<<" "<<r<<endl;
#ifdef LOCAL_DEFINE
    cerr<<"Time elapsed: "<<1.0*clock()/CLOCKS_PER_SEC<<"s.\n";
    fclose(stream1);
    //fclose(stream2);
#endif
    return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>
int main(void)
{
	int n,k,sum,max=0,i,j,a[100001];
	while(1){
		scanf("%d%d",&n,&k);
		if(n==0&&k==0) break;
		for(i=1;i<=n;i++){
			scanf("%d",&a[i]);
		}
		for(i=1;i<=n;i++){
			sum=0;
			if(i+k<=n){
				for(j=i;j<i+k;j++){
					sum+=a[j];
				}
				if(max<sum){
					max=sum;
				}
			}
		}
		printf("%d\n",max);
	}
	return 0;
}

Measured memory_bytes: 3008
n = int(input())
HappyList = [list(map(int, input().split())) for i in range(n)]
dp = [[0]*(3) for i in range(n+1)]
for i in range(n):
    for j in range(3):
        for k in range(3):
            if k==j:
                continue
            dp[i+1][k] = max(dp[i+1][k], dp[i][j]+HappyList[i][k])

print(max(dp[n][0],dp[n][1],dp[n][2]))


Measured memory_bytes: 74072
io = STDIN
n=io.gets.to_i
ar=n.times.map{io.gets.split}
    .map
    .with_index(1){|(s,po),i|[s,po.to_i,i]}
    .sort_by{|s,po,no|[s,-po]}
puts  ar.map{|s,po,no|no}


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

int main() {
    int N;
    cin >> N;
    vector<int> ls(N), rs(N);
    for (int i = 0; i < N; ++i) {
        cin >> ls[i] >> rs[i];
    }
    sort(ls.begin(), ls.end());
    sort(rs.begin(), rs.end());
    int ans = 0;
    if (N%2 == 1) {
        ans = rs[N/2] - ls[N/2] + 1;
    }
    else {
        ans = rs[N/2-1] + rs[N/2] - ls[N/2-1] - ls[N/2] + 1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4360
//Be Name Khoda
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma optimize O3
using namespace __gnu_pbds;
using namespace std;
template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T> using ordered_multiset =  tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
typedef long long int LL;
typedef LL ll;
typedef long double ld;
typedef string str;
typedef pair<ll,ll> pll;
typedef vector<ll> vll;
typedef stringstream strs;
 
#define X first
#define Y second
#define PB push_back
#define For(i,a,b) for (int i=a;i<b;i++)
#define Ford(i,a,b) for (int i=a;i>=b;i--)
#define smax(a,b) a=max(a,b)
#define smin(a,b) a=min(a,b)
#define SZ(a) ((ll)a.size())
#define ER(a) cout << #a << ' ' << a << endl
#define LB(a,n,x) (lower_bound(a,(a)+(n),x)-(a))
#define RET(x) { cout << x; exit(0); } 
#define RETD(x) { cout << fixed << setprecision(15) << x; exit(0); }
const ll M=2e5+5,LG=32,SM=600+5,inf=1e18+5;
ll mod=1e9+7;

bitset<M> a;

int main()
{
    ll n,m,u,v;
    cin >> n >> m;
    For(i,0,m)
    {
        cin >> u >> v;
        u--;v--;
        a[u]=a[u]^1;
        a[v]=a[v]^1;
    }
    RET((a.count()?"NO":"YES"));
}    


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

using namespace std;

#define ll long long
#define ld long double
#define ff first
#define ss second
#define rsz resize
#define ins insert 
#define mp make_pair
#define pf push_front 
#define pb push_back
#define eb emplace_back 
#define ft front() 
#define bk back()
#define sz(x) (int)(x).size()
#define all(x) begin(x), end(x)
#define deb(x) cout<<#x<<" "<<x<<'\n';
#define rep(i,a,b) for (int i = (a); i < (b); ++i)

const ll mod = 1e9+7; // 998244353;
const ll inf = 1e9; 
const ld pie = acos((ld)-1);

int xd[] = {1, -1, 0, 0};
int yd[] = {0, 0, 1, -1};

int h,w;
int cx,cy;
int dx,dy;
int dis[1010][1010];
deque<pair<int,int>> q;


int main(){
    
	
	scanf("%d%d",&h,&w);
	scanf("%d%d",&cx,&cy);
	scanf("%d%d",&dx,&dy);
	char a[1010][1010];
	for(int i=0;i<h;++i){
		scanf("%s",a[i]);
	}

	cx--;cy--;dx--;dy--;

	memset(dis,0x3f3f3f3f,sizeof(dis));
	q.push_front({cx,cy});
	dis[cx][cy]=0;
	
	while(!q.empty()){

		pair<int,int> node = q.ft;
		q.pop_front();
		int x = node.first;
		int y = node.second;

		for(int i=max(0,x-2);i<min(h,x+3);++i){
			for(int j=max(0,y-2);j<min(w,y+3);++j){
				if(a[i][j]=='#') continue;
				int d = abs(x-i) + abs(y-j);
				d<=1?d=0:d=1;
				
				if(dis[i][j] > dis[x][y] + d){
					dis[i][j] = dis[x][y] + d;
					if(!d){
						q.push_front({i,j});
					}else{
						q.push_back({i,j});
					}
				}
			}
		}
	}

	if(dis[dx][dy]==0x3f3f3f3f) printf("-1\n");
	else printf("%d\n",dis[dx][dy]);


	return 0;

	/*STUFF TO LOOK:	
		1. Check the constraints
		2. Corner cases(n==0||n==1)
		3. Variables in loops
		4. Make sure two ints aren’t multiplied to get a long long
		5. Don't use scanf or printf while using ios_base
		6. using the local variable of the same name when global variable was required to be used
	*/
}


Measured memory_bytes: 8844
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#ifdef DEBUG
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__);
#else
#define show(...) 42
#endif
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <typename T, typename S>
ostream& operator<<(ostream& os, pair<T, S> a) {
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (auto x : v) os << x << ' ';
    return os;
}
void debug() {
    cerr << '\n';
}
template <typename H, typename... T>
void debug(H a, T... b) {
    cerr << a;
    if (sizeof...(b)) cerr << ", ";
    debug(b...);
}
int main(){
    int n;
    cin >> n;
    vector<int>a(n);
    rep(i,n)cin >> a[i];
    ll s = 0;
    rep(i,n)s ^= a[i];
    rep(i,n){
        cout << (s ^ a[i]) << " \n"[i == n - 1];
    }
}


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

int main(){
  string a,b;
  cin>>a>>b;
  
  bool flag = true;
  for(int i=0;i<3;i++){
    if(a[i] != b[2-i]) flag=false;
  }
  
  if(flag) cout<<"YES";
  else cout<<"NO";
}

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

#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define lb lower_bound
#define ub upper_bound

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;

//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b ? gcd(b,a%b) : a;}

//head

// dp[i] = winner if there are i stones remaining, TRUE if first player wins if there are i stones rem
int main()
{
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	int n, k;
	cin >> n >> k;
	vi a(n);
	for(int i = 0; i < n; i++) {
		cin >> a[i];
	}
	vector<bool> dp(k + 1);
	for(int stones = 0; stones <= k; stones++) {
		for(int x : a) {
			if(stones >= x && !dp[stones - x]) {
				dp[stones] = true;
			}
		}
	}
	cout << (dp[k] ? "First" : "Second") << endl;
	return 0;
}


Measured memory_bytes: 256
//#include<bits/stdc++.h>
#include<cstdio>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

const int dm = 1 << 21;
char dn[dm], * di = dn, dt;
inline void putint(ll X) {
	int keta = 0;
	char C[20];
	while (X) {
		*(C + keta) = '0' + X % 10;
		X /= 10;
		keta++;
	}
	for (int i = keta - 1; i >= 0; i--)* di++ = (*(C + i));
	*di++ = '\n';
}

int N;
ll D[100001];
int E[200001], Ed[200001], E2[200001], H[100001];
void dfs(int A, ll B) {
	*(D + A) = B;
	for (int i = H[A]; i; i = E2[i]) if (!(*(D + E[i]))) dfs(E[i], B + Ed[i]);
}

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


	int N = getint();
	int k = 1;
	rep(i, N - 1) {
		int a = getint();
		int b = getint();
		int c = getint();
		E[k] = b;
		Ed[k] = c;
		E2[k] = H[a];
		H[a] = k++;
		E[k] = a;
		Ed[k] = c;
		E2[k] = H[b];
		H[b] = k++;
	}
	int Q = getint();
	int K = getint();
	dfs(K, 1);
	rep(i, Q) {
		int x = getint();
		int y = getint();
		putint(*(D + x) + *(D + y) - 2);
	}

	fwrite_unlocked(dn, di - dn, 1, stdout);

	Would you please return 0;
}

Measured memory_bytes: 9984
#define _USE_MATH_DEFIMES
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <clocale>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

const int MOD = 1'000'000'007;
const int INF = 1'000'000'000; //1e9
const int NIL = -1;
const long long LINF = 1'000'000'000'000'000'000; // 1e18
const long double EPS = 1E-10;

template<class T, class S> inline bool chmax(T &a, const S &b){
    if(a < b){
        a = b; return true;
    }
    return false;
}
template<class T, class S> inline bool chmin(T &a, const S &b){
    if(b < a){
        a = b; return true;
    }
    return false;
}








int main(){
    std::string S, T; std::cin >> S >> T;
    int ans(T.length());
    for(int i(0), i_len(S.length() - T.length()); i <= i_len; ++i){
        int cnt(0);
        for(int j(0), j_len(T.length()); j < j_len; ++j){
            if(S[i+j] != T[j]) ++cnt;
        }
        chmin(ans, cnt);
    }
    std::cout << ans << std::endl;
    return 0;
}


Measured memory_bytes: 3608
#include<bits/stdc++.h>
 
#define INF 1000000007
#define LINF 1000000000000000007
 
using namespace std;
 
typedef long long ll;
typedef pair<ll, ll> P;


string s;

int main(){
	cin >> s;
	
	int cnt = 0;
	for(int i= 0; i < 3; i++){
		if(s[i] == '1') cnt++;
	}
	
	cout << cnt << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <time.h>
#include <stdio.h>
#include <vector>
#define int long long
using namespace std;
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
int mypow(int x, int y) {
	if (y == 0)return 1;
	if (y % 2)return mypow(x, y - 1)*x;
	else return mypow(x, y / 2)*mypow(x, y / 2);
}
int Max(int x, int y) {
	if (x > y)return x;
	else return y;
}
int Min(int x, int y) {
	if (x < y)return x;
	else return y;
}
int kai(int x) {
	int cnt = 1;
	if (x == 0)return 1;
	cnt = kai(x - 1);
	return x * cnt;
}
inline void shoki()
{
	srand((unsigned int)time(NULL));
}
 
/*Library End!*/
 
signed main() {
	string s;
	cin >> s;
	if (s.size() == 2)cout <<s<<endl;
	else {
		for(int i=s.size()-1;i>=0;i--){
			cout <<s[i];
	}
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mod 1000000007
#define ff first
#define ss second
#define endl '\n'
using namespace std;
const ll inf=1e18+7 ;
/*ll power(ll x,ll y)
{
    ll res=1;
    while(y>0)
    {
        if(y%2==1)
            res=(res*x)%mod;
        x=(x*x)%mod;
        y=y/2;
    }
    return res;
}*/
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
   ll c=1,i,n;
   cin>>n;
   string s;
   cin>>s;
   for(i=1;i<s.size();i++)
    if(s[i]!=s[i-1])
    c++;
   cout<<c<<endl;
}


Measured memory_bytes: 512
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>

typedef long long unsigned int ll;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

using namespace std;

int main()
{	
	int ans=0;
	int n,m;

	cin >> n;
	
	vector<string> s(n);
	for (int i = 0; i < n; i++) {
		cin >> s.at(i);
	}
	cin >> m;
	vector<string> t(m);
	for (int i = 0; i < m; i++) {
		cin >> t.at(i);
	}
	
	vector<int> tmp(n);
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			if (s.at(i) == s.at(j)) {
				tmp.at(i) += 1;
			}
		}
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			if (s.at(i) == t.at(j)) {
				tmp.at(i) -= 1;
			}
		}
		
	}
	for (int i = 0; i < n; i++) {
		ans = max(ans, tmp.at(i));
	}
	
	cout << ans << endl;

}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (int i = j; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//name[i][j]-> vvl name(i,vl(j))
//map<int,int>mp
//余りを切り上げる =>  (a + b - 1) / b 

signed main(){
	int n; cin>>n;
	if(n==25)cout<<"Christmas";
	else if(n==24)cout<<"Christmas Eve";
	else if(n==23)cout<<"Christmas Eve Eve";
	else cout<<"Christmas Eve Eve Eve";
	
	return 0;
}

Measured memory_bytes: 3568
N, W = map(int, input().split())
v = [0] * N
w = [0] * N
for i in range(N):
    w[i], v[i] = map(int, input().split())
dp = [[0 for i in range (W+5)] for i in range(N + 5)]

for i in range(N):
    for j in range(W+1):
        dp[i+1][j] = max(dp[i+1][j], dp[i][j])
        if(j + w[i] <= W):
            dp[i+1][j+w[i]] = max(dp[i+1][j+w[i]], dp[i][j] + v[i])

print(dp[N][W])


Measured memory_bytes: 171656
#ifdef _WIN32
#define NOMINMAX
#define _CRT_SECURE_NO_WARNINGS
#include <Windows.h>
#define DEBUGBREAK() ::DebugBreak()
#else
#define DEBUGBREAK() static_cast<void>(0)
#endif

#include <iostream>
#include <sstream>
#include <iomanip>
#include <valarray>
#include <vector>
#include <string>
#include <fstream>
#include <cstdlib>
#include <queue>
#include <array>
#include <functional>
#include <stack>
#include <bitset>
#include <random>
#include <algorithm>
#include <unordered_map>

using namespace std;

const int64_t dx4[4] = { 0, -1, 1, 0 };
const int64_t dy4[4] = { -1, 0, 0, 1 };
const int64_t dx5[5] = { 0, -1, 0, 1, 0 };
const int64_t dy5[5] = { -1, 0, 0, 0, 1 };
const int64_t dx8[8] = { -1, 0, 1, -1, 1, -1, 0, 1 };
const int64_t dy8[8] = { -1, -1, -1, 0, 0, 1, 1, 1 };
const int64_t dx9[9] = { -1, 0, 1, -1, 0, 1, -1, 0, 1 };
const int64_t dy9[9] = { -1, -1, -1, 0, 0, 0, 1, 1, 1 };

#define REP(i, K) for (int64_t i = 0; i < K; ++i)
#define REPYX() for (int64_t y = 0; y < H; ++y) for (int64_t x = 0; x < W; ++x)
#define REPX() REP(x, W)
#define REPY() REP(y, H)
#define INSIDE(x_, y_) (0 <= (x_) && 0 <= (y_) && (x_) < W && (y_) < H)
#define INSIDE_MARGIN(x_, y_, m_) ((m_) <= (x_) && (m_) <= (y_) && (x_) < W - (m_) && (y_) < H - (m_))

int get_assert_level() {
    const char* s = getenv("ASSERT_LEVEL");
    if (s) { return atoi(s); }
    return 0;
}
static int g_assert_level = get_assert_level();

#define LV_1() if (g_assert_level >= 1)
#define LV_2() if (g_assert_level >= 2)
#define LV_3() if (g_assert_level >= 3)
#define ASSERT_1(expr) do { const bool b = bool(expr); if (g_assert_level >= 1 && !b) { std::cerr << "[ASSERT 1] (" << #expr << ") failed." << std::endl; exit(-1); } } while (false)
#define ASSERT_2(expr) do { const bool b = bool(expr); if (g_assert_level >= 2 && !b) { std::cerr << "[ASSERT 2] (" << #expr << ") failed." << std::endl; exit(-1); } } while (false)
#define ASSERT_3(expr) do { const bool b = bool(expr); if (g_assert_level >= 3 && !b) { std::cerr << "[ASSERT 3] (" << #expr << ") failed." << std::endl; exit(-1); } } while (false)

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

    vector<int> xs(5);
    cin >> xs[0];
    cin >> xs[1];
    cin >> xs[2];
    cin >> xs[3];
    cin >> xs[4];

    REP(i, 5) {
        if (xs[i] == 0) { cout << (i + 1) << endl; }
    }

    return 0;
}



Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
int main(){
    int x1=1, x2=2, x3=3, x4=4, x5=5;
    cin >> x1 >> x2 >> x3 >> x4 >> x5;
    if (x1 == 0) cout << 1 << endl;
    else if (x2 == 0) cout << 2 << endl;
    else if (x3 == 0) cout << 3 << endl;
    else if (x4 == 0) cout << 4 << endl;
    else cout << 5 << endl;
    return 0;
}

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

int main() {
    char S[100000];
    scanf("%s", S);
    int i, j;
    for (i = 0; i < 'z' - 'a' + 1; i++){
        int flag = 1;
        for (j = 0; j < strlen(S); j++) {
            if (S[j] == 'a' + i) flag = 0;
        }
        if (flag == 1) {
            printf("%c\n",'a' + i);
            return 0;
        }
    }
    printf("None\n");
    return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
minus = 0
ab = abs(a[0])
plus = []
for i in range(n):
  if a[i] < 0:
    minus += 1
  if ab > abs(a[i]):
    ab = abs(a[i])
  plus.append(abs(a[i]))
if minus % 2 == 0:
  print(sum(plus))
else:
  print(sum(plus) - ab * 2)

Measured memory_bytes: 65440
#include <bits/stdc++.h>
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define all(x) x.begin(), x.end()

using namespace std;

typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
typedef long long ll;

template <typename T> void max_self(T& a, T b){
  a = max(a,b);
}

template <typename T> void min_self(T& a, T b){
  a = min(a,b);
}

void solve(){	
  int n;cin>>n;
  vi v(n);
  for(int i=0;i<n;i++) cin>>v[i];
  int tallest = v[0];
  ll ans = 0;
  for(int i=0;i<n;i++){
    if(v[i] < tallest){
      ans += tallest - v[i];
    }
    max_self(tallest, v[i]);
  }
  cout<<ans<<endl;
}

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  //int t; cin >> t;
  //while(t--) solve();
  //
  solve();
  return 0;
}


Measured memory_bytes: 3968
#include <bits/stdc++.h>
#define REP(a,b,c) for(int a=b; a<(int)c; a++)
#define REPE(a,b,c) for(int a=b; a<=(int)c; a++)
#define REPD(a,b,c) for(int a=b; a>=(int)c; a--)
#define rep(a,b) REP(a,0,b)
#define repd(a,b) REPD(a,b,0)
typedef long long int ll;
using namespace std;

int main(){
  while(true){
    int n;
    cin >> n;
    if(n == 0) break;
    int num = n + 1;
    int ans = 0;
    REPE(i,num,n*2){
      bool flag = false;
      for(int j=2; (j*j)<=i; j++){
        if((i%j) == 0){
          flag = true;
          break;
        }
      }
      if(!flag){
        // cout << i << endl;
        ans++;
      }
    }
    cout << ans << endl;
  }
  return 0;
}

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


int main(void){
    long long n, k;
    cin >> n >> k;
    long long ans = 0;

    for(long long a=1; a<=n; a++){
        if(((k-a%k)*2)%k == 0){
            long long b = k - a%k;
            ans += ((n-b)/k + 1)*((n-b)/k + 1);
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}

signed main() {
    int N, M;
    cin >> N >> M;
    int sum = 0;
    vi A(N);
    rep(i, N) {
        cin >> A[i];
        sum += A[i];
    }

    int t = sum/(4*M);
    if(sum%(4*M)) t++;

    int cnt = 0;
    rep(i, N) {
        cnt += (A[i]>=t ? 1 : 0);
    }

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

Measured memory_bytes: 256
import math

a,b,h,m=(map(int,input().split()))

c=h*30+m*0.5
d=m*6

kakudo=0
if c>=d:
  kakudo=min(c-d,360-(c-d))
else:
  kakudo=min(d-c,360-(d-c))

cos=math.cos(math.radians(kakudo))

ans=math.sqrt(a**2+b**2-2*a*b*cos)

print(ans)
#print(kakudo)

Measured memory_bytes: 9524
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

#define N 100
#define INF 100000

void matrixchainorder(int);
int min(int,int);

int n;
int m[N][N],p[N];
int r[N],c[N];

int main(){
  int i;


  scanf("%d",&n);

  for(i=1;i<=n;i++){
    scanf("%d%d",&r[i],&c[i]);
  }

matrixchainorder(n);

printf("%d\n",m[1][n]);

  return 0;
}

void  matrixchainorder(int n){
  int i,j,l,k,q;



  for(i=1;i<=n;i++){
    m[i][i]=0;
  }
  for(l=2;l<=n;l++){
    for(i=1;i<=n-l+1;i++){
      j=i+l-1;
      m[i][j]=INF;
      for(k=i;k<=j-1;k++){
	q=m[i][k]+m[k+1][j]+r[i]*c[k]*c[j];
	m[i][j]=min(m[i][j],q);
      }
    }
  }
}

int min(int x,int y){
  if(x<=y){
    return x;
  }
  else{
    return y;
  }
}



Measured memory_bytes: 2108