akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(a) (a).begin(), (a).end()

using namespace std;
using i64 = long long;
using vi64 = vector<i64>;

i64 n;
vi64 a;
vi64 c;

void add(int x) {
  while (x <= 2 * n) {
    c[x]++;
    x += x & -x;
  }
}

i64 sum(int x) {
  i64 s = 0;
  while (x) {
    s += c[x];
    x -= x & -x;
  }
  return s;
}

bool check(i64 md) {
  vi64 s(n + 1);
  c = vi64(n * 3);
  rep(i, n) {
    if (a[i] >= md)
      s[i + 1] = s[i] + 1;
    else
      s[i + 1] = s[i] - 1;
  }
  i64 cnt = 0;
  rep(i, n + 1) {
    cnt += sum(s[i] + n);
    add(s[i] + n);
  }
  return cnt >= n * (n + 1) / 4;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(16);
  cerr << fixed << setprecision(16);
  cin >> n;
  a = vi64(n);
  rep(i, n) cin >> a[i];
  i64 ok = *min_element(all(a)), ng = *max_element(all(a)) + 1;
  while (ng - ok > 1) {
    i64 md = (ok + ng) / 2;
    if (check(md)) {
      ok = md;
    } else {
      ng = md;
    }
  }
  cout << ok << endl;
  return 0;
}


Measured memory_bytes: 6560
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

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

int main() {
  ll N, A, B;
  cin >> N >> A >> B;
  vector<ll> X(N);
  for (int i = 0; i < N; i++) {
    cin >> X[i];
  }
  vector<ll> dp(N);
  dp[0] = 0;
  for (int i = 1; i < N; i++) {
    dp[i] = dp[i - 1] + min((X[i] - X[i - 1]) * A, B);
  }
  cout << dp[N - 1] << endl;
  return 0;
}

Measured memory_bytes: 4772
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>

using namespace std;

vector<int> split(string delim,string str){
	vector<int> res;
	str += delim;
	for(int i=0;i<str.size();i++){
		for(int j=1;i+j<=str.size();j++){
			if(str.substr(i,j).find(delim) != string::npos){
				int num;
				sscanf(str.substr(i,j-1).c_str(),"%d",&num);
				if(0 < str.substr(i,j-1).size()) res.push_back(num);
				i+=j-1;
				break;
			}
		}
	}

	return res;
}

int main(){
	string str;
	vector<vector<int> > table;
	
	while(getline(cin,str)){
		vector<int> tmp = split(",",str);
		table.push_back(tmp);
	}
	
	for(int i=0; i+1 < table.size(); i++){
		if(table[i].size() < table[i+1].size()){
			for(int j = 0; j < table[i+1].size(); j++){
				if(j == 0){
					table[i+1][j] = table[i][j] + table[i+1][j];
				}
				else if(j == table[i+1].size()-1){
					table[i+1][j] = table[i][j-1] + table[i+1][j];
				}
				else{
					table[i+1][j] = max(table[i][j-1]+table[i+1][j], table[i][j]+table[i+1][j]);
				}			
			}
		}
		else{
			for(int j = 0; j < table[i+1].size(); j++){
				table[i+1][j] = max(table[i][j]+table[i+1][j], table[i][j+1]+table[i+1][j]);
			}
		}
	}

	cout << table[table.size()-1][0] << endl;
}

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

 
int main(){
    int N;
    string S;
    cin >> N >> S;
    int length=S.size();
    rep(i,length){
        int x=S.at(i)-'A';
        x=(x+N)%26;
        char y=x+'A';
        cout << y ;
    }

    cout << endl;
}


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

int main(){

  int n;
  int a,b,c,d;

  scanf("%d", &n);

  d = n % 10;
  c = (n/10) % 10;
  b = (n/100) % 10;
  a = n/1000;

  if(a + b + c + d == 7){
    printf("%d+%d+%d+%d=7\n", a, b, c, d);
    return 0;
  }

  if(a + b + c - d == 7){
    printf("%d+%d+%d-%d=7\n", a, b, c, d);
    return 0;
  }

  if(a + b - c + d == 7){
    printf("%d+%d-%d+%d=7\n", a, b, c, d);
    return 0;
  }

  if(a + b - c - d == 7){
    printf("%d+%d-%d-%d=7\n", a, b, c, d);
    return 0;
  }

  if(a - b + c + d == 7){
    printf("%d-%d+%d+%d=7\n", a, b, c, d);
    return 0;
  }

  if(a - b + c - d == 7){
    printf("%d-%d+%d-%d=7\n", a, b, c, d);
    return 0;
  }

  if(a - b - c + d == 7){
    printf("%d-%d-%d+%d=7\n", a, b, c, d);
    return 0;
  }

  if(a - b - c - d == 7){
    printf("%d-%d-%d-%d=7\n", a, b, c, d);
    return 0;
  }

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <queue>
#include <map>
#include <stack>
#include <bitset>
#include <numeric> //lcm
#include <iomanip> //double精度 setprecision


#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = n-1; i >= 0; --i)
#define rep1(i,n) for(int i = 1; i <= (n); ++i)
#define all(vec) (vec).begin(),(vec).end()

#define debug(vec) for(auto v : vec) cout << v << " "; cout << endl;
#define debug2D(vec2D) for(auto vec : vec2D) { for (auto v : vec) cout << v << " "; cout << endl; } 

using namespace std;

typedef long long ll;

const ll INF = 1000000000; //10^10
//const ll MOD = 998244353;
const ll MOD = 1000000007;

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

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

	vector<int> a(n);
	int sum = 0;
	rep(i, n) {
		cin >> a[i];
		sum += a[i];
	}
	int cnt = 0;
	rep(i, n) {
		if(4*m*a[i] >= sum) cnt++;
		if(cnt >= m) {cout << "Yes" << endl; return 0; }
	}

	cout << "No" << endl;
}


Measured memory_bytes: 256
<?php
  fscanf(STDIN, "%d", $a);
  $num = range(1, 9);
  for($i=1;$i<=10;$i++) {
    if($i==10) {
      echo 'No';
      exit();
    }
    $an = $a / $i;
    if(in_array($an, $num)) {
      echo 'Yes';
      exit();
    }
  }

Measured memory_bytes: 4604
#include <iostream>
#include<queue>
#include<stack>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include<cassert>
#include<cmath>
#include<climits>
#include<iomanip>
#include<bitset>
#include<unordered_map>

using namespace std;

#define rep(i,m,n) for(int (i)=(int)(m);(i)<(int)(n);(i)++)
#define rep2(i,m,n) for(int (i)=(int)(n)-1;(i)>=(int)(m);(i)--)
#define REP(i,n) rep(i,0,n)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define ll long long
#define ull unsigned long long
#define all(hoge) (hoge).begin(),(hoge).end()
#define en '\n'
typedef pair<ll, ll> P;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
constexpr long long MOD = 998244353;
typedef vector<ll> Array;
typedef vector<Array> Matrix;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;


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

struct Edge {
	ll to, cap, rev;
	Edge(ll _to, ll _cap, ll _rev) {
		to = _to; cap = _cap; rev = _rev;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}


void solve() {
	ll n;
	cin >> n;
	map<ll, ll> mp;
	REP(i, n) {
		ll d;
		cin >> d;
		mp[d]++;
	}

	ll m;
	cin >> m;
	bool flag = true;
	REP(i, m) {
		ll t;
		cin >> t;
		mp[t]--;
		if (mp[t] < 0) flag = false;
	}
	cout << (flag ? "YES" : "NO") << en;
}

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

	solve();
	//int t; cin >> t; REP(i, t) solve();

	return 0;
}


Measured memory_bytes: 12800
using System;
 
class Program
{
	static void Main()
    {
        var K = int.Parse(Console.ReadLine());
        int uc;
        long ans = 0;
        
        for (int a = 1; a <= K; a++) {
            for (int b = 1; b <= K; b++) {
                for (int c = 1; c <= K; c++) {
                    int x = a;
                    int y = b;
                    int z = c;
                    while(true){
                        if (x % y == 0){
                            break;
                        }
                        else{
                            uc = x % y;
                            x = y;
                            y = uc;
                        }
                    }
                    while(true){
                        if (y % z == 0){
                            break;
                        }
                        else{
                            uc = y % z;
                            y = z;
                            z = uc;
                        }
                    }
                    ans = ans + z;
                }
            }
        }
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 27388
#include "bits/stdc++.h"
#define F first
#define S second
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define eb emplace_back
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  ll n = 0, r = 0;
  cin >> n >> r;
  if (n >= 10) cout << r;
  else {
    cout << r + (10 - n) * 100;
  }
}


Measured memory_bytes: 3592
import math
import fractions
import bisect
import collections
import itertools
import heapq
import string
import sys
import copy
from collections import deque
sys.setrecursionlimit(10**7)
MOD = 10**9+7
def gcd(a,b):return fractions.gcd(a,b) #最大公約数
def lcm(a,b):return (a*b) // fractions.gcd(a,b) #最小公倍数
def iin(): return int(input()) #整数読み込み
def ifn(): return float(input()) #浮動小数点読み込み
def isn(): return input().split() #文字列読み込み
def imn(): return map(int, input().split()) #整数map取得
def fmn(): return map(float, input().split()) #浮動小数点map取得
def iln(): return list(map(int, input().split())) #整数リスト取得
def iln_s(): return sorted(iln()) # 昇順の整数リスト取得
def iln_r(): return sorted(iln(), reverse=True) # 降順の整数リスト取得
def fln(): return list(map(float, input().split())) # 浮動小数点リスト取得
def join(l, s=''): return s.join(l) #リストを文字列に変換
def perm(l, n): return itertools.permutations(l, n) # 順列取得
def perm_count(n, r): return math.factorial(n) // math.factorial(n-r) # 順列の総数
def comb(l, n): return itertools.combinations(l, n) # 組み合わせ取得
def comb_count(n, r): return math.factorial(n) // (math.factorial(n-r) * math.factorial(r)) #組み合わせの総数
def two_distance(a, b, c, d): return ((c-a)**2 + (d-b)**2)**.5 # 2点間の距離
def add_mod(a,b): return (a+b) % MOD

N,K = imn()
h = iln()

dp = [10**10 for _ in range(N)]
dp[0] = 0

for i in range(N):
    for j in range(1,K+1):
        if i+j < N: dp[i+j] = min(dp[i+j], dp[i]+abs(h[i]-h[i+j]))
print(dp[N-1])


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

string S;

int main() {
    cin >> S;
    bool flag = false;
    for (int i = 0; i < S.length(); i++) {
        if ((i & 1 && S[i] == 'R') || (!(i & 1) && S[i] == 'L')) {
            flag = true;
            break;
        }
    }
    cout << (flag? "No": "Yes") << endl;
}



Measured memory_bytes: 256
import heapq
N = int(input())
A = [[] for i in range(N)]
Q = []
for i in range(N):
  A[i] = [int(x) for x in input().split()]
  for j in range(i + 1, N):
    heapq.heappush(Q, [A[i][j], i, j])
G = [[10 ** 9 + 1 for j in range(N)] for i in range(N)]
for i in range(N):
  G[i][i] = 0
cnt = 0
while Q:
  [d, s, t] = heapq.heappop(Q)
  add = True
  for k in range(N):
    if d > G[s][k] + G[k][t]:
      break
    if d == G[s][k] + G[k][t]:
      add = False
  else:
    G[s][t] = d
    G[t][s] = d
    cnt += d if add else 0
    continue
  print(-1)
  break
else:
  print(cnt)

Measured memory_bytes: 55644
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <cmath>
#include <iostream>

using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i, n)	 for(int i = 0; i < (n); i++)
#define all(a)		 begin(a), end(a)

typedef long long int		   ll;
typedef long long unsigned int llu;

void solve(ll N, ll K, vector <ll> l) {
	sort(l.rbegin(), l.rend());
	int a = 0;
	rep(i, K) a += l[i];
	printf("%d", a);
}

int main() {
	ll K;
	ll N;
	scanf("%lld", &N);
	vector <ll> l(N - 1 + 1);
	scanf("%lld", &K);
	for(int i = 0; i <= N - 1; i++) {
		scanf("%lld", &l[i]);
	}
	solve(N, K, l);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, s, e) for (int i = s; i < e; ++i)
#define sort_(a) stable_sort(a.begin(), a.end())
#define rsort(a) stable_sort(a.rbegin(), a.rend())
#define sum(a) accumulate(a.begin(), a.end(), 0LL)
#define join(a, d) accumulate(a.begin() + 1, a.end(), a[0], [](string s, string t) {return s + d + t;})
#define all(a) a.begin(), a.end()
// #define __lcm(a, b) std::__detail::__lcm(a, b)
typedef long long ll;
const long mod = 1e9 + 7;

int main(void) {
#ifdef DEBUG
  freopen("input.txt", "r", stdin);
#endif

  ios_base::sync_with_stdio(false);
  cin.tie(0);

  int P, Q, R;
  cin >> P >> Q >> R;
  cout << P + Q + R - max({P, Q, R}) << endl;
  return 0;
}


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

#define ll long long
#define endl "\n"
#define int ll
const int INF = 2e9;
vector <vector <int> > dp(500, vector <int> (500, INF));

void debug()
{
	cerr << "New " << endl;
	for (int i=0; i<=20; i++)
	{
		for (int j=0; j<=27; j++)
		{
			cerr << "a " << i << " b " << j << " " << dp[i][j] << endl;
		}
	}
}

signed main ()
{

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n, ma, mb;
    cin >> n >> ma >> mb;

    dp[0][0] = 0;

    for (int k=0; k<n; k++){
    	int a, b, c;
    	cin >> a >> b >> c;
    	for (int i=450; i>=0; i--){
    		for (int j=450; j>=0; j--){
    			if (i >= a and j >= b){
    				dp[i][j] = min(dp[i][j], dp[i-a][j-b] + c);
				}
			}
		}
		//debug();
	}

    int ans = INF;

	for (int i=1; i<500; i++){
		for (int j=1; j<500; j++){
			if (i*mb == j*ma){
				ans = min(ans, dp[i][j]);
			}
		}
	}

	if (ans == INF) cout << -1 << endl;
	else cout << ans << endl;

    return 0;
}


Measured memory_bytes: 5616
/* おまじない　*/
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
typedef long long ll;
typedef long double ld;
using namespace std;
const ll MOD=pow(10,9)+7;
const ll INF=(1LL<<62);
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};
void init(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
    cout<<fixed;
}
int main(){
    init();

    ll N;cin>>N;
    vector<string>A(N);
    for(int i=0;i<N;i++)cin>>A[i];

    ll ans=0;
    for(int i=0;i<N;i++){
        if(A[i]=="E869120")ans++;
    }

    cout<<ans<<endl;
}


Measured memory_bytes: 3300
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<functional>
#include<string>

typedef long long int ll;

using namespace std;

int main(void){
    
    int n;
    string str;
    cin >> n;
    cin >> str;

    for(int i = 0;str[i] != '\0';i++){
        cout << char(((str[i] - 'A' + n) % ('Z' - 'A' + 1)) + 'A');
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define FOR(a, c) for (int(a) = 0; (a) < (c); (a)++)
#define FORL(a, b, c) for (int(a) = (b); (a) <= (c); (a)++)
#define FORR(a, b, c) for (int(a) = (b); (a) >= (c); (a)--)
#define INF 1000000000000000003
#define all(a) a.begin(),a.end()
typedef long long int ll;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef unordered_map<int, int>  mii;
#define ff first
#define ss second
#define pb push_back 
#define pob pop_back
#define mp make_pair

void solve(){
	string s;
	cin>>s;
	int countRain=0;
	if(s[0] == 'R' && s[1]=='R' && s[2] == 'R')
		countRain=3;
	else if(s[0] == 'R' && s[1] == 'R' && s[2] != 'R')
		countRain=2;
	else if(s[1] == 'R' && s[2] == 'R' && s[0] != 'R')
		countRain=2;
	else if(s[0] == 'R' || s[1] == 'R' || s[2] == 'R')
		countRain=1;
	else
		countRain=0;
	cout<<countRain<<endl;

}

int main(){

    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1; 
    // cin>>t;
    while(t--){
      solve();
    }
    return 0;
}

Measured memory_bytes: 3632
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
const int mod= 1e+9+7;


int main(){
    double a,b; cin>>a>>b;
    double h,m; cin>>h>>m;
    //double c=abs(30.0*h-6.0*m);
    double c=min(abs(30*h+0.5*m-6*m),abs(360-(30*h+0.5*m-6*m)));
    double d=180.0/c;
    double pi = 3.141592653589793;
    double ans=a*a+b*b-2.0*a*b*cos(pi/d);
    cout << fixed << setprecision(10);
    cout<<sqrt(ans)<<endl;


}








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

int main()
{
    ll d, t, s;
    cin >> d >> t >> s;
    if (s * t < d)
        cout << "No" << endl;
    else
        cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 3628
#include<iostream>
#include <climits>
#include<vector>
#include<list>
#include<numeric>
#include<algorithm>
#include<string>
#include<cmath>
#include<set>
#include<map>
#include<stack>
#include<queue>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;

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

	vector<int> A(3);
	REP(i, 3) cin >> A[i];
	int min = 300;
	for (int i = 0;i < 3;i++) {
		for (int j = 0;j < 3;j++) {
			for (int k = 0;k < 3;k++) {
				if (i != j&&j != k&&k != i) {
					int x = abs(A[i] - A[j]) + abs(A[j] - A[k]);
					if (min > x) min = x;
				}
			}
		}
	}
	cout << min << "\n";

	return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	nextReader = NewScanner()
	line1 := nextString()

	s0 := strings.Count(line1[0], "0")
	s1 := strings.Count(line1[0], "1")

	fmt.Println(min([]int{s0, s1}...) * 2)

}

// ------ Mathライブラリ ---------------------------------//
func max(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r < a[i] {
			r = a[i]
		}
	}
	return r
}

func maxIdx(a ...int) int {
	r := a[0]
	index := 0
	for i := 0; i < len(a); i++ {
		if r < a[i] {
			r = a[i]
			index = i
		}
	}
	return index
}

func min(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r > a[i] {
			r = a[i]
		}
	}
	return r
}

func minIdx(a ...int) int {
	r := a[0]
	index := 0
	for i := 0; i < len(a); i++ {
		if r > a[i] {
			r = a[i]
			index = i
		}
	}
	return index
}

func sum(a []int) (r int) {
	for i := range a {
		r += a[i]
	}
	return r
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

// ------ Mathライブラリ ---------------------------------//

// ----- 標準入力用の関数 ----------------------------------//
var nextReader func() []string

func NewScanner() func() []string {
	r := bufio.NewScanner(os.Stdin)
	r.Buffer(make([]byte, 1024), int(1e+11))
	return func() []string {
		r.Scan()
		return strings.Fields(r.Text())
	}
}

func nextString() []string {
	return nextReader()
}

func nextInt() []int {
	var intArray []int
	strArray := nextReader()
	for _, v := range strArray {
		i, _ := strconv.Atoi(v)
		intArray = append(intArray, i)
	}
	return intArray
}

func nextFloat64() []float64 {
	var floatArray []float64
	strArray := nextReader()
	for _, v := range strArray {
		f, _ := strconv.ParseFloat(v, 64)
		floatArray = append(floatArray, f)
	}
	return floatArray
}

// ------ 標準入力用の関数 ---------------------------------//

// ------ あまり使わない -----------------------------------//
func nextInt64() []int64 {
	var int64Array []int64
	strArray := nextReader()
	for _, v := range strArray {
		i, _ := strconv.ParseInt(v, 10, 64)
		int64Array = append(int64Array, i)
	}
	return int64Array
}

// ------ あまり使わない -----------------------------------//


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

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

  long long a[n];
  for (int i=0; i<n; i++) {
    cin >> a[i];
  }

  int signs[2] = {-1, 1};
  long long cnt[2] = {0, 0};

  for (int i=0; i<2; i++) {
    long long sum=0;
    int sign = signs[i];
    for (int j=0; j<n; j++) {
      sum += a[j];
      //cout << sum << "->";
      if (sum == 0) {
        sum += sign;
        cnt[i]++;
      } else if (sum*sign < 0) {
        cnt[i] = cnt[i] + abs(sum) + 1;
        sum = sum + sum*(-1) + sign;
      }
      //cout << sum << " " << cnt[i] << endl;
      sign *= -1;
    }
    //cout << endl;
  }

  cout << (cnt[0] < cnt[1] ? cnt[0] : cnt[1]) << endl;
  return 0;
}


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

long long n,k,cnt[5000][5000],mod=1e9+7;

int main()
{
	cin>>n>>k;
	for(int i=0;i<=2005;i++)
	{
		cnt[i][0]=1;
		for(int j=1;j<=i;j++)
			cnt[i][j]=(cnt[i-1][j-1]+cnt[i-1][j])%mod;
	}
	for(int i=1;i<=k;i++)
		cout<<(cnt[k-1][i-1]*cnt[n-k+1][i])%mod<<endl;
	return 0;
}

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

int descending_compare(const void *a, const void *b){
    if (*(long long*)a > *(long long*)b){
        return -1;
    }else if (*(long long*)a == *(long long*)b){
        return 0;
    }else{
        return 1;
    }
}

int ascending_compare(const void *a, const void *b){
    if (*(int*)a < *(int*)b){
        return -1;
    }else if (*(int*)a == *(int*)b){
        return 0;
    }else{
        return 1;
    }
}


int lower_bound(int *a, int n, int key){
    int left, mid, right;
    left = 0, right = n;
    mid = (left + right)/2;
    while ((left+1 != mid || mid+1 != right) && mid != left){
        if (key > a[mid]){
            left = mid;
        }else{
            right = mid+1;
        }
        mid = (left + right)/2;
    }
    if (a[left] >= key)return left;
    if (a[mid] >= key)return mid;
    if (a[right] >= key)return right;
    return n;
}

//greatest common divisor
unsigned long gcd(unsigned long x, unsigned long y){
    if (y == 0){ 
        return x;
    }else if (x > y){
        return gcd(y, x % y);
    }else{
        return gcd(x, y % x);
    }
}

unsigned long lcm(unsigned long x, unsigned long y){
    unsigned long g = gcd(x, y);
    return x*y/g;

}



long long factorial(int x){
    long long rtn = 1;
    int i;
    for (i = x; i > 1; i--){
        rtn = (rtn*i);
    }
    return rtn;
}

/*
int struct_ascending_compare(const void *p, const void *q) {
return ((struct_name*)p)->member_name - ((struct_name*)q)->member_name;
}*/

/*unsigned long long pascal[100][100] = {0};
void make_pascal(void){
    for (int i = 0; i < 100; i++){
        pascal[i][0] = 1;
    }
    pascal[1][1] = 1;
    for (int i = 2; i < 100; i++){
        for (int j = 1; j < 100; j++){
           pascal[i][j] = (pascal[i-1][j-1]+pascal[i-1][j]);
        }
    }
}*/
long long mod = 1000000007;

long long mod_pow(long long x, long long n){
    long long res = 1;
    for(int i = 0;i < 60; i++){
        if(n >> i & 1) res = res * x % mod;
        x = x * x % mod;
    }
    return res;
}

char s[100005];
int animal[100005] = {0};
int n;

void print_animals(void){
    for (int i = 0; i < n; i++){
        if (animal[i]) printf("W");
        else printf("S");
    }
    printf("\n");
}

int main(void){
    scanf("%d", &n);
    scanf(" %s", s);
    s[n] = s[0];
    for (int i = 0; i < 2; i++){
        for (int j = 0; j < 2; j++){
            animal[0] = i;
            animal[1] = j;
            for (int k = 1; k <= n; k++){
                if (animal[k]){
                    if (s[k] == 'x') animal[k+1] = animal[k-1];
                    else animal[k+1] = animal[k-1] ^ 1;
                }else{
                    if (s[k] == 'o') animal[k+1] = animal[k-1];
                    else animal[k+1] = animal[k-1] ^ 1;
                }
            }
            if (animal[0] == animal[n] && animal[1] == animal[n+1]){
                print_animals();
                return 0;
            }
        }
    }
    printf("-1\n");


    return 0;
}

Measured memory_bytes: 768
#include <stdio.h>
  
  int main(void){
            int a,b,tem;
          while(1){
            scanf("%d %d",&a,&b);
            if( a==0 && b==0 )
                  break;
            if( a>b){
                  tem =a;
                    a =b;
                    b =tem;
                 }
              printf("%d %d\n",a,b);
                }
             return 0;
              }



Measured memory_bytes: 2032
import sys
input=sys.stdin.readline
n,k=map(int,input().split())
a=list(map(int,input().split()))
a=sorted(a)
f=list(map(int,input().split()))
f=sorted(f,reverse=True)

s=sum(a)
if k>=s:
    print(0)
    exit()

def is_ok(b):
    m=0
    for p,q in zip(a,f):
        if p>b//q:
            m+=p-(b//q)
            if m>k:
                return False
    return True

ok=10**12+1
ng=0
while ok-ng>1:
    m=(ok+ng)//2
    if is_ok(m):
        ok=m
    else:
        ng=m

print(ok)


Measured memory_bytes: 108620
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pair<int, int>> vpii;
typedef pair<int, int> pii;
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define ALL(a) (a).begin(), (a).end()
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

constexpr ll MOD = 1000000007;
#define N 112345
int a[N];
int b[3] = {};

int main(){
	int n; scanf("%d", &n);
	REP(i, n) scanf("%d", a+i);
	
	ll ans = 1;
	REP(i, n){
		int cnt = 0;
		REP(j, 3) if(b[j] == a[i]) cnt++;
		DEBUG("%d %d\n", i, cnt);
		if(cnt == 0){
			ans = 0;
			break;
		}
		ans *= cnt;
		ans %= MOD;
		REP(j, 3){
			if(b[j] == a[i]){
				b[j]++;
				break;
			}
		}
	}
	printf("%lld\n", ans);
}


Measured memory_bytes: 640
import sys
sys.setrecursionlimit(10**7)

import queue

P=10**9+7
N=int(input())
G=[[] for index1 in range(N+1)]
for index3 in range(N-1):
    x,y=map(int,input().split())
    G[x].append(y)
    G[y].append(x)


DP=[]
DP_sum=[0]*(N+1)
for index4 in range(N+1):
    DP.append([-1,-1])  #白、黒
q=queue.Queue()
q.put(1)
DP_sum[1]=2

def dfs(v,pv=0):
    #if DP[v]!=[-1,-1]:#不要
        #return DP[v]
    nvs=G[v]
    if v!=1:
        nvs.remove(pv)
    if not nvs:
        DP[v]=[1,1]
        DP_sum[v]=DP[v][0]+DP[v][1]
        return DP[v]
    else:
        v_white=1
        v_black=1
        for nv in nvs:
            nvxy=dfs(nv,v)
            v_white*=(nvxy[0]+nvxy[1])
            v_black*=nvxy[0]
            v_white%=P
            v_black%=P
        DP[v]=[v_white,v_black]
        DP_sum[v]=(DP[v][0]+DP[v][1])%P
        return DP[v]

dfs(1)
print(DP_sum[1])





Measured memory_bytes: 128428
#include <vector> 
#include <list> 
 #include <map>
 #include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << '=' << (x) << endl;
#define debug(x) cerr << #x << '=' << (x) << '('<<'L' << __LINE__ << ')' << ' ' << __FILE__ << endl;

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

    REP(i,s.size()){
        if(i%2==0){
            cout<<s[i];
        }
    }
    cout<<endl;




}


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

using namespace std;

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

struct Team {
  Team() {ac = pe = 0; rep (i, 10) p[i] = 0;}
  int ac, pe, num, p[10];
  bool operator<(Team t) const {
    if (ac != t.ac) return ac > t.ac;
    if (pe != t.pe) return pe < t.pe;
    return num > t.num;
  }
  bool operator==(Team t) {
    if (ac != t.ac) return false;
    if (pe != t.pe) return false;
    return true;
  }
};

int main() {
  while (true) {
    int M, T, P, R;
    cin >> M >> T >> P >> R;
    if (M == 0) break;
    Team team[T];
    rep (i, T) team[i].num = i + 1;
    rep (_, R) {
      int m, t, p, j;
      cin >> m >> t >> p >> j;
      --t;
      --p;
      if (j == 0) {
	++team[t].ac;
	team[t].pe += team[t].p[p] * 20 + m;
      } else {
	++team[t].p[p];
      }
    }
    sort(team, team + T);
    rep (i, T) {
      if (i != 0) {
	cout << (team[i] == team[i -1] ? '=' : ',');
      }
      cout << team[i].num;
    }
    cout << endl;
  }
}

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

using namespace std;

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

    long long last = t[0];
    long long ans = 0;
    for (long long i = 1; i < N; ++i) {
        ans += min(t[i] - last, T);
        last = t[i];
    }
    ans += T;

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main()
{
           int n,K;
			cin>>n>>K;
			int h[200000];
			for(int i=0;i<n;i++)
				cin>>h[i];
			int cost[200000];
			cost[0]=0;
		
			for(int i=1;i<n;i++)
			{
				cost[i]=INT_MAX;
				for(int k=1;k<=K;k++){
					if(i-k>=0)
					cost[i]=min(cost[i-k]+abs(h[i]-h[i-k]),cost[i]);
				}
			}
		cout<<cost[n-1];
}

Measured memory_bytes: 1024
require 'prime'
require 'set'
require 'tsort'
include Math
ALP = ('a'..'z').to_a
INF = 0xffffffffffffffff
def max(a,b);              a > b ? a : b                              end
def min(a,b);              a < b ?  a : b                             end
def swap(a,b);             a, b = b, a                                end
def gif;                   gets.to_i                                  end
def gff;                   gets.to_f                                  end
def gsf;                   gets.chomp                                 end
def gi;                    gets.split.map(&:to_i)                     end
def gf;                    gets.split.map(&:to_f)                     end
def gs;                    gets.chomp.split.map(&:to_s)               end
def gc;                    gets.chomp.split('')                       end
def pr(num);               num.prime_division                         end
def pr?(num);              Prime.prime?(num)                          end
def digit(num);            num.to_s.length                            end
def array(s,ini=nil);      Array.new(s){ini}                          end
def darray(s1,s2,ini=nil); Array.new(s1){Array.new(s2){ini}}          end
def rep(num);              num.times{|i|yield(i)}                     end
def repl(st,en,n=1);       st.step(en,n){|i|yield(i)}                 end
n = gc
stack = []
repl 0,n.size-1,2 do |i|
  stack << n[i]
end
puts stack.join


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

using namespace std;

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

  int cnt = 0;
  for(int j=1; j<(n-1); j++){
    if(p[j-1] < p[j] && p[j] < p[j+1]) cnt++;
    else if(p[j-1] > p[j] && p[j] > p[j+1]) cnt++;
  }
  cout << cnt;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repe(i,n) rep(i,(n)+1)
#define per(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define pere(i,n) rep(i,(n)+1)
#define all(x) (x).begin(),(x).end()
#define SP <<" "<<
#define RET return 0
#define MOD 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000

typedef long long LL;
typedef long double LD;

int main(){
  int n;
  cin >> n;
  vector<LL> a(n);
  for(int i=0;i<n;i++) cin >> a[i];
  vector<LL> rl(n+1,0),rr(n+1,0);
  for(int i=1;i<=n;i++){
    rl[i]=rl[i-1]+a[i-1];
  }
  for(int i=n-1;i>=0;i--){
    rr[i]=rr[i+1]+a[i];
  }
  vector<LL> gl(n+1,LINF),gr(n+2,LINF);
  gl[0]=0;
  for(int i=1;i<=n;i++){
    gl[i]=min(rl[i],gl[i-1]+(a[i-1]==0?2:a[i-1]%2));
  }
  gr[n]=0;
  for(int i=n-1;i>=0;i--){
    gr[i]=min(rr[i],gr[i+1]+(a[i]==0?2:a[i]%2));
  }
  vector<LL> dp(n+1,LINF);
  dp[0]=0;
  for(int i=1;i<=n;i++){
    dp[i]=min(gl[i],dp[i-1]+1-a[i-1]%2);
  }
  LL ans=LINF;
  for(int i=0;i<=n;i++){
    ans=min(ans,dp[i]+gr[i]);
    // cout << dp[i] SP gr[i] << endl;
  } 
  cout << ans << endl;
  return 0;
}

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

#define debug(x) cerr << x << " = "(x) << endl;
#define ll long long
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    int h,w,k; cin >> h >> w >> k;
    bool graph[h][w];
    int cnt = 0;
    int kosu = 0;
    int ans = 0;
    rep(i,0,h) {
        rep(j,0,w) {
            char tmp;
            cin >> tmp;
            if(tmp == '#') {graph[i][j] = true; kosu++; }
            else graph[i][j] = false;
        }
    }
    //if(cnt == k) ans++;
    rep( i,0,(1 << h)-1) {
        rep(j ,0, (1 << w)-1) {
            cnt = 0;
            rep(a,0,h) {
                rep(b,0,w) {
                    if( (i & ( 1 << a) || j & ( 1 << b )) && graph[a][b])cnt++;
                }
            }
            if(cnt == kosu - k){
                ans++;
                //cout << i << " " << j << endl;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3620
#include<iostream>
#include<queue>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
#define MAX 15
#define rep(i,n) for(int i=0;i<int(n);i++)
int nn,m;
vector<int> g[MAX],r[MAX];
bool used[1<<MAX][MAX];
struct Q{
  bool is_move;
  bool is_on;
  int s;
  bool operator<(const Q& q)const{return s<q.s;}
  Q(){}
  Q(bool i,bool o,int s_):is_move(i),is_on(o),s(s_){}
};
struct P{
  int u,n;
  vector<Q> v;
  P(int u_,int n_,const vector<Q>& v_):u(u_),n(n_),v(v_){}
};
void solve(int u)
{
  memset(used,0,sizeof(used));
  queue<P> q;
  vector<Q> v;
  q.push( P(u,0,vector<Q>()) );
  used[u][0]=true;
  bool can=false,all=false;
  if( !(u&1) )goto END;
  while( !q.empty() ){
    P p=q.front(); q.pop();
    int n=p.n;
    u=p.u;
    if( n==nn-1 ){
      can=true;
      if( u==(1<<(nn-1)) ){
        all=true;
        v=p.v;
        goto END;
      }
    }
    //move
    rep(i,g[n].size()){
      //printf("%d -> %d %d\n",n,g[n][i],i);
      if( u&(1<<g[n][i]) && !used[u][g[n][i]] ){
        used[u][g[n][i]]=true;
        v=p.v;
        v.push_back( Q(true,false,g[n][i]) );
        q.push( P(u,g[n][i],v) );
      }
    }
    //switch
    rep(i,r[n].size()){
      bool is_on=!(u&(1<<r[n][i]));
      int uu=u^(1<<r[n][i]);
      if( !used[uu][n] ){
        used[uu][n]=true;
        v=p.v;
        v.push_back( Q(false,is_on,r[n][i]) );
        q.push( P(uu,n,v) );
      }
    }
  }
END:;
  if( !can ){
    puts("Help me!");
  } else if( !all ){
    puts("You can not switch off all lights.");
  } else {
    printf("You can go home in %d steps.\n",v.size());
    /*
    for(vector<Q>::iterator it=v.begin();it!=v.end();++it){
      if(!it->is_move){
        vector<Q>::iterator iit;
        for(iit=it;iit+1!=v.end() && !iit->is_move;++iit);
        sort(it,iit);
        it=iit;
      }
    }
      */
    rep(i,v.size()){
      Q& q=v[i];
      if(q.is_move){
        printf("Move to room %d.\n",q.s+1);
      } else {
        printf("Switch %s room %d.\n",q.is_on?"on":"off",q.s+1);
      }
    }
  }
}
int main(void)
{
  for(;;){
    scanf("%d%d",&nn,&m); if(!nn)break;
    int s,t;
    rep(i,m){
      scanf("%d%d",&s,&t);
      s--; t--;
      g[s].push_back(t);
      g[t].push_back(s);
    }
    int a,u=0;
    rep(i,nn){
      scanf("%d",&a);
      u|=a<<i;
    }
    int k,l;
    rep(i,nn){
      scanf("%d",&k);
      rep(j,k){
        scanf("%d",&l); l--;
        if(l==i)continue;
        r[i].push_back(l);
      }
      sort(r[i].begin(),r[i].end());
      sort(g[i].begin(),g[i].end());
    }
    solve(u);
    rep(i,nn)g[i].clear();
    rep(i,nn)r[i].clear();
  }
}

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

const int mx = 1e5 + 5;
priority_queue<int> arr;

int main(){
    
    int n, m;
    cin >> n >> m;
    for(int i = 0; i < n; i++){
        int x;
        cin >> x;
        arr.push(x);
    }

    while(m > 0){
    	int x = arr.top();
    	x = round(x / 2);
    	arr.pop();	
    	m--;
    	arr.push(x);
    }

    long long ans = 0;
    while(!arr.empty()){
    	ans += (long long) arr.top();
    	arr.pop();
    }

    cout << ans;
    
}


Measured memory_bytes: 892
import java.util.*;

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

        int n = sc.nextInt();

        List<Integer> list = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            list.add(sc.nextInt());
        }

        int count = 0;
        for (int i = 1; i <= n; i++) {
            if (i != list.get(i-1)) {
                count++;
            }
        }

        if (count <= 2) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
    }
}

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

using namespace std;
typedef long long int ll;

ll sol(ll a, ll n, ll k){
	if(n==0) return a;
	return min(sol(a*2,n-1,k),sol(a+k,n-1,k));
}

int main(){
	int n, k;
	cin>>n>>k;
	cout<<sol(1ll,n,k)<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <cstdlib> 
#include <cmath>
#include <algorithm>
#include <sstream>
#include <string>
using namespace std;

int main() {
	int a, b;
	cin >> a >> b;
	
	if (b >= a) {
		cout << a << endl;
		return 0;
	}
	cout << a - 1 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/indexed.hpp>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x) begin(x),end(x)

using namespace std;
using namespace boost::adaptors;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;
using boost::irange;

constexpr ll MOD = 998244353;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,s;
  cin>>n>>s;
  vecll a(n);
  for(auto&& e:a)cin>>e;
  ll ans = 0;
  vecll dp(s);
  dp[0] = 1;
  REP(i,n) {
    vecll tmp = dp;
    if (a[i] < s) {
      tmp[a[i]] += dp[0] * (i+1);
      tmp[a[i]] %= MOD;
    }
    FOR(j,a[i]+1,s) {
      tmp[j] += dp[j-a[i]];
      tmp[j] %= MOD;
    }
    if (s > a[i]) {
      ans += dp[s-a[i]] * (n-i);
      ans %= MOD;
    } else if (s == a[i]) {
      ans += (i+1) * (n-i);
      ans %= MOD;
    }
    swap(tmp, dp);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main(void){
    
    //*
    int a;
    cin >> a ;
    //*/

    /*
    vector<int> vec(3);
    cin >> vec.at(0) >> vec.at(1) >> vec.at(2) ;
    
    sort(vec.begin(), vec.end());
    //*/
    
    /*
    if( a == 3 || a == 5 || a == 7 ){
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    //*/
    
    cout << "Christmas";
    for(int i = a; i < 25; i++){
        cout << " Eve";
    }
    cout << endl;

    return 0; 
}


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

void solve(){
	int arr[6];
	for(int i=1;i<=5;i++) cin>>arr[i];
	for(int i=1;i<=5;i++){
		if(arr[i]==0){
			cout<<i<<"\n";
			return ;
		}
	}
	return ;
}

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

    #ifndef ONLINE_JUDGE
	    freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
		
	int t=1;

	while(t--){
		solve();
	}
    return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <stack>
#include <queue>
#include <list>
using namespace std;

#define is_uruu leapyear
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ROF(i,a,b) for(int i=(a);i>(b);--i)
#define REP(i,a) for(int i=0;i<(a);++i)

int count=0, n, S[100000];

int BinaryS(int t){
	int left=0, right=n, mid;
	while(left < right){
		mid = (right+left)/2;
		if(S[mid] == t){
			count++;
			return 0;
		}
		if(S[mid] < t) left = mid+1;
		if(S[mid] > t) right = mid;
	}
	return 0;
}

int main() {
	int q, t;
    cin >> n;
    FOR(i, 0, n) cin >> S[i];
    cin >> q;
    
    REP(i, q){
    	cin >> t;
    	BinaryS(t);
    }
    
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 3484
import java.io.*;
import java.lang.reflect.Array;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main (String[] args) throws IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        Scanner sc = new Scanner(System.in);

        List<Integer> list = Arrays.asList(1, 9, 7, 4);

        Integer n1 = sc.nextInt();
        Integer n2 = sc.nextInt();
        Integer n3 = sc.nextInt();
        Integer n4 = sc.nextInt();
        Integer count = 0;

        //list.forEach(num -> {
        //    if (num == n1 || num == n2 || num == n3 || num == n4) {
        //        count += 1;
        //    }
        //});

        for (Integer num : list) {
            if (num == n1 || num == n2 || num == n3 || num == n4) {
                count += 1;
            }
        }

        if (count == 4) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
    }
}

Measured memory_bytes: 23252
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
#define IOI 101
#define IOIOIOIOI 101010101
int dp[10 * IOI][10 * IOI];
string S, T;
int main() {
	for (int i = 0; i < 10 * IOI; i++) {
		for (int j = 0; j < 10 * IOI; j++) {
			dp[i][j] = IOIOIOIOI;
		}
	}
	cin >> S; cin >> T;
	for (int i = 0; i <= S.size(); i++)dp[i][0] = i;
	for (int i = 0; i <= T.size(); i++)dp[0][i] = i;
	for (int i = 0; i < S.size(); i++) {
		for (int j = 0; j < T.size(); j++) {
			dp[i + 1][j + 1] = min(dp[i][j], min(dp[i + 1][j], dp[i][j + 1])) + 1;
			if (S[i] == T[j]) dp[i + 1][j + 1] = min(dp[i + 1][j + 1], dp[i][j]);
		}
	}
	cout << dp[S.size()][T.size()] << endl;
	return 0;
}

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

using namespace std;

typedef long long ll;

int main() {
    int n, k;
    cin >> n >> k;
    vector<pair<ll, int>> sushis;
    for (int i = 0; i < n; i++) {
        int t;
        ll d;
        cin >> t >> d;
        sushis.push_back({d, t});
    }
    sort(sushis.begin(), sushis.end());
    reverse(sushis.begin(), sushis.end());
    ll cur = 0;
    vector<bool> aleady(n + 1, false);
    priority_queue<ll, vector<ll>, greater<ll>> can_reduce;
    ll count = 0;
    for (int i = 0; i < k; i++) {
        ll d = sushis[i].first;
        int t = sushis[i].second;
        cur += d;
        if (aleady[t]) {
            can_reduce.push(d);
        } else {
            aleady[t] = true;
            count++;
        }
    }
    ll ans = cur + count * count;
    for (int i = k; i < n; i++) {
        int t = sushis[i].second;
        if (aleady[t])
            continue;
        if (can_reduce.empty() || count >= k)
            break;
        count++;
        auto top = can_reduce.top();
        can_reduce.pop();
        cur += -top + sushis[i].first;
        ans = max(ans, cur + count * count);
        aleady[t] = true;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 2672
#include<stdio.h>
int main(){
    int h,w;
    int i,j;
    bool flag=true;
    while(1){
        scanf("%d%d",&h,&w);
        if(h==0 && w==0) break;
        for(i=0;i<h;i++){
            if(flag){
                flag=false;
                for(j=0;j<w;j++){
                if(j%2==0){
                    printf("#");
                }
                else{
                    printf(".");
                }
            }
            printf("\n");
            }
            else{
                flag=true;
                for(j=0;j<w;j++){
                if(j%2==0){
                    printf(".");
                }
                else{
                    printf("#");
                }
            }
            printf("\n");
            }
        }
        flag=true;
        printf("\n");
    }    
    return 0;
}



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

#define PI 3.1415926535897932
#define MOD 1000000007
#define INF 1e9

#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define FOR(i, start, end) for(int i = (start); i < (end); i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;

ll fact(ll n)
{
    if(n == 0) return 1;
    else return n * fact(n-1);
}

void solve()
{
    int N; cin >> N;
    vi MARCH(5, 0);
    vs S(N);
    REP(i, N) 
    {
        cin >> S[i];
        if(S[i][0] == 'M') MARCH[0]++;
        else if(S[i][0] == 'A') MARCH[1]++;
        else if(S[i][0] == 'R') MARCH[2]++;
        else if(S[i][0] == 'C') MARCH[3]++;
        else if(S[i][0] == 'H') MARCH[4]++;
    }
    ll ans = 0;
    for(int i = 1; i < 32; i++)
    {
        ll count = 1;
        if(bitset<5>(i).count() == 3)
        {
            for(int j = 0; j < 5; j++)
            {
                if(i & 1 << j) count *= MARCH[j];
            }
            ans += count;
        }
    }
    cout << ans << endl;
}

int main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    solve();

    return 0;
}

Measured memory_bytes: 5760
#include <iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
using namespace std;
int main()
{
    int n,k;
    int sum=0;
    cin>>n>>k;
    int arr[n];
    for(int i=0;i<n;i++)
    {
        cin>>arr[i];
    }
    sort(arr,arr+n);
    for(int i=0;i<k;i++)
    {
       sum=sum+arr[i];
    }   
    cout<<sum<<endl;
}






Measured memory_bytes: 3564
#include<bits/stdc++.h>
using namespace std;
int main (){
  int x,y,z;
  scanf("%d %d %d",&x,&y,&z);
  if((x==y&&x!=z)||(x==z&&x!=y)||(y==z&&z!=x))cout<<"Yes";
  else cout<<"No";
  return 0;
}

Measured memory_bytes: 256