akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define SORT(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define EQ(a,b) (abs((a)-(b))<eps)
vector<string> buf;
string tmp;
int curline=0,curcol=0;
void a(){curcol=0;}
void e(){curcol=buf[curline].size();}
void p()
{
	if(curline==0)a();
	else curline--,curcol=0;
}
void n()
{
	if(curline+1==buf.size())a();
	else curline++,curcol=0;
}
void f()
{
	if(curcol==buf[curline].size()&&curline+1!=buf.size())curline++,curcol=0;
	else if(curcol!=buf[curline].size())curcol++;
}
void b()
{
	if(curcol==0&&curline!=0)
	{
		curline--;
		curcol=buf[curline].size();
	}
	else if(curcol!=0)curcol--;
}
void d()
{
	if(curcol==buf[curline].size()&&curline+1!=buf.size())
	{
		buf[curline]+=buf[curline+1];
		for(int i=curline+1;i<buf.size()-1;i++)buf[i]=buf[i+1];
		buf.pop_back();
	}
	else if(curcol!=buf[curline].size())
	{
		buf[curline]=buf[curline].substr(0,curcol)+buf[curline].substr(curcol+1);
	}
}
void k()
{
	if(curcol==buf[curline].size()&&curline+1!=buf.size())
	{
		d();
		tmp="\n";
	}
	else if(curcol!=buf[curline].size())
	{
		tmp=buf[curline].substr(curcol);
		buf[curline]=buf[curline].substr(0,curcol);
		curcol=buf[curline].size();
	}
}
void y()
{
	if(tmp=="")return;
	if(tmp=="\n")
	{
		buf.pb("");
		for(int i=buf.size()-1;i>curline;i--)buf[i]=buf[i-1];
		buf[curline+1]=buf[curline].substr(curcol);
		buf[curline]=buf[curline].substr(0,curcol);
		curline++;
		curcol=0;
	}
	else
	{
		buf[curline]=buf[curline].substr(0,curcol)+tmp+buf[curline].substr(curcol);
		curcol+=tmp.size();
	}
}
void print()
{
	cout << "*****************************************" << endl;
	for(int i=0;i<buf.size();i++)cout<<buf[i]<<endl;	
	cout << "*****************************************" << endl;
}
int main()
{
	string s;
	char op;
	while(getline(cin,s),s!="END_OF_TEXT")buf.pb(s);
	while(cin>>op,op!='-')
	{
		switch(op)
		{
			case 'a':a();break;
			case 'e':e();break;
			case 'p':p();break;
			case 'n':n();break;
			case 'f':f();break;
			case 'b':b();break;
			case 'd':d();break;
			case 'k':k();break;
			case 'y':y();break;
		}
		//print();
	}
	for(int i=0;i<buf.size();i++)cout << buf[i] << endl;
	return 0;
}

Measured memory_bytes: 1208
#include <algorithm>
#include<iostream>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<list>
#include<map>
#include<set>
#include<string>
#include <sstream>
#include<bitset>

#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>
const int INF = 0x7fffffff;
using lll = long long;
using ull = unsigned long long;
using namespace std;


int main(){
  lll ii,jj,kk,ll,mm;
  vector<int> ret;
  int h,w,k;

  cin >> h >> w >> k;

  int matrix[h][w];
  int tmpm[h][w];
  string tmp;
  
  for(ii=0;ii<h;ii++){
    cin >> tmp;
    for(jj=0;jj<w;jj++){
      if(tmp[jj] == '.'){
        matrix[ii][jj] = 0;
      }
      else{
        matrix[ii][jj] = 1;
      }
    }
  }
  int selecth[h],selectw[w];

  //for(ii=0;ii<pow(2,h);ii++){
  //
  //  for(jj=0;jj<h;jj++){
  //
  //    if( ( (ii >> jj) & 1 ) == 1){
  //      selecth[jj] = 1;
  //    }
  //    else{
  //      selecth[jj] = 0;
  //    }
  //  }
  //  cout << "ii:" << ii << " ";
  //  for(jj=0;jj<h;jj++){
  //    if(selecth[jj] == 1){
  //      cout << jj << ",";
  //    }
  //  }
  //  cout << endl;
  //}


  
  int sum = 0;
  for(ii=0;ii<pow(2,h);ii++){
    for(jj=0;jj<pow(2,w);jj++){

      memcpy(tmpm,matrix,sizeof(tmpm));

      
      for(ll=0;ll<h;ll++){
        if( (( ii >> ll ) & 1) == 1){
          selecth[ll] = 1;
        }
        else{
          selecth[ll] = 0;
        }
      }
      
      for(ll=0;ll<w;ll++){
        if( (( jj >> ll ) & 1) == 1){
          selectw[ll] = 1;
        }
        else{
          selectw[ll] = 0;
        }        
      }

      //同じ行を0
      for(ll=0;ll<h;ll++){
        if(selecth[ll] == 1){
          for(mm=0;mm<w;mm++){
            tmpm[ll][mm] = 0;
          }
        }
      }

      //同じ列を0
      for(ll=0;ll<w;ll++){
        if(selectw[ll] == 1){
          for(mm=0;mm<h;mm++){
            tmpm[mm][ll] = 0;
          }
        }
      }
      int cnt = 0;


      //for(ll=0;ll<h;ll++){
      //  for(mm=0;mm<w;mm++){
      //    cout << tmpm[ll][mm];
      //  }
      //  cout <<  endl;
      //}
      //
      //cout << "=============" << endl;
      for(ll=0;ll<h;ll++){
        for(mm=0;mm<w;mm++){
          if(tmpm[ll][mm] == 1){
            cnt ++;
          }
        }
      }
      //cout << "k:" << k << "cnt:" << cnt << endl;
      if(cnt == k){
        sum++;
      }
      
    }
  }

  cout << sum;
  
  return 0;
}


Measured memory_bytes: 3992
//#include<bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<numeric>
#include<vector>
#include<set>
#include<map>
#include<unordered_map>
#include<stack>
#include<queue>
#include<list>
using namespace std;

typedef long long ll;

#define MOD 1000000007

class Comb{
private:
  ll *fac,*finv,*inv;
public:
  Comb(){
    fac = new ll[1000000];
    finv = new ll[1000000];
    inv = new ll[1000000];
    fac[0] = 1;
    for(int i=1;i<1000000;i++){
      fac[i] = i*fac[i-1];
      fac[i] %= MOD;
    }
    inv[1] = 1;
    for(int i=2;i<1000000;i++){
      inv[i] = MOD-inv[MOD%i]*(MOD/i)%MOD;
    }
    finv[0] = 1;
    for(int i=1;i<1000000;i++){
      finv[i] = inv[i]*finv[i-1];
      finv[i] %= MOD;
    }
  }
  ll calc(ll n,ll k){
    ll c = fac[n];
    c *= finv[k];c %= MOD;
    c *= finv[n-k];c %= MOD;
    return c;
  }
};

int main(){
  string s;
  cin >> s;
  if(s[0] == s[1] && s[1] == s[2]){
    cout << "No" << endl;
  }
  else cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void) {
	int a, b, c;
	int ans;
	
	scanf("%d", &a);
	scanf("%d", &b);
	scanf("%d", &c);

	ans = c - (a - b);

	if (ans > 0) {
		printf("%d", ans);
	}
	else {
		printf("0");
	}
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 3e3 + 10;

int n, m, k;
int a[N][N];
ll f[N][N][4];

int main() {
#ifdef ACM_LOCAL
    freopen("input.in", "r", stdin);
    freopen("output.out", "w", stdout);
#endif
    scanf("%d%d%d", &n, &m, &k);
    for (int i = 1; i <= k; i++) {
        int x, y, w; scanf("%d%d%d", &x, &y, &w);
        a[x][y] = w;
    }
    ll ans = 0;
    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= m; j++) {
            ll mx = max(max(f[i - 1][j][0], f[i - 1][j][3]), max(f[i - 1][j][1], f[i - 1][j][2]));
            f[i][j][0] = max(mx, f[i][j - 1][0]);
            f[i][j][1] = max(mx + 1ll * a[i][j], max(f[i][j - 1][1], f[i][j - 1][0] + a[i][j]));
            f[i][j][2] = max(f[i][j - 1][2], f[i][j - 1][1] + a[i][j]);
            f[i][j][3] = max(f[i][j - 1][3], f[i][j - 1][2] + a[i][j]);
            ans = max(ans, f[i][j][0]);
            ans = max(ans, f[i][j][1]);
            ans = max(ans, f[i][j][2]);
            ans = max(ans, f[i][j][3]);
        }
    printf("%lld\n", ans);



    return 0;
}

Measured memory_bytes: 321228
import heapq


class Dijkstra(object):
    def dijkstra(self, adj, start, goal=None):
        num = len(adj)
        dist = [float('inf') for i in range(num)]
        prev = [float('inf') for i in range(num)]

        dist[start] = 0
        q = []
        heapq.heappush(q, (0, start))
        
        while len(q) != 0:
            prov_const, src = heapq.heappop(q)

            if dist[src] < prov_const:
                continue

            for i in range(len(adj[src])):
                dest, cost = adj[src][i][0], adj[src][i][1]
                if dist[dest] > dist[src] + cost:
                    dist[dest] = dist[src] + cost
                    heapq.heappush(q, (dist[dest], dest))
                    prev[dest] = src

        if goal is not None:
            return self.get_path(goal, prev)
        else:
            return dist

    def get_path(self, goal, prev):
        path = [goal]
        dest = goal

        while prev[dest] != float('inf'):
            path.append(prev[dest])
            dest = prev[dest]

        return list(reversed(path))

if __name__ == '__main__':
    p_inf = float('inf')
    l = map(int, raw_input().split())
    V, E, r = l[0], l[1], l[2]
    
    adj = [[] for i in range(V)]
    for i in range(E):
        l = map(int, raw_input().split())
        s, t, d = l[0], l[1], l[2]
        adj[s].append((t, d))

    d = Dijkstra()
    result = d.dijkstra(adj, r)
    for i in result:
        if i == p_inf:
            print 'INF'
        else:
            print i

Measured memory_bytes: 102904
#include<iostream>
using namespace std;
int main(void){
    int n,k;
    cin>>n>>k;
    int sum(1);
    for(int i(0);i<n;i++){
        if(sum<k)sum *=2;
        else sum += k;
    }
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::collections::HashMap;
use std::collections::HashSet;
use std::collections::VecDeque;

#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($t:ty) =>
        (rl().parse::<$t>().unwrap());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    buf.trim_end().to_owned()
}

fn main() {
    let s = read!(String);
    let t = read!(String);
    let s: Vec<char> = s.chars().collect();
    let t: Vec<char> = t.chars().collect();

    if s[0..s.len()] == t[0..t.len()-1] {
        println!("Yes");
    } else {
        println!("No");
    }
}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef complex<double> P;
typedef pair<int,int> pii;
#define REP(i,n) for(ll i=0;i<n;++i)
#define REPR(i,n) for(ll i=1;i<n;++i)
#define FOR(i,a,b) for(ll i=a;i<b;++i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define MOD (ll)(1e9+7)
#define ADD(a,b) a=((a)+(b))%MOD
#define FIX(a) ((a)%MOD+MOD)%MOD

#define N_MAX 101
#define INF 1e9

int n;
int x[N_MAX];
vector<vi> edges(N_MAX);

struct edge{int to,cap,rev;};
vector<edge> g[2*N_MAX+2];
bool used[2*N_MAX+2];

void add_edge(int from,int to,int cap){
  g[from].push_back((edge){to,cap,g[to].size()});
  g[to].push_back((edge){from,0,g[from].size()-1});
}

int dfs(int v,int t,int f){
  if(v==t)return f;
  used[v]=true;
  REP(i,g[v].size()){
    edge &e = g[v][i];
    if(!used[e.to]&&e.cap>0){
      int d = dfs(e.to,t,min(f,e.cap));
      if(d>0){
        e.cap -= d;
        g[e.to][e.rev].cap += d;
        return d;
      }
    }
  }
  return 0;
}

int calc(vi usd){
  vi ver;
  REP(i,n){
    bool flag = true;
    REP(j,usd.size()){
      if(x[i]%usd[j]==0 || usd[j]%x[i]==0){
        flag = false;
        break;
      }
    }
    if(flag)ver.push_back(x[i]);
  }

  int sz = ver.size();
  REP(i,2*sz+2)g[i].clear();
  // 0: s
  // i+1(1~n): s-side node
  // i+1+n(n+1~2*n): t-side node
  // 2*n+1: t
  // create bipartile graph
  REP(i,sz)REP(j,sz){
    if(i==j)continue;
    if(ver[i]%ver[j]==0){
      add_edge(i+1,j+sz+1,1);
    }
  }
  REP(i,sz){
    add_edge(0,i+1,1);
    add_edge(i+sz+1,2*sz+1,1);
  }

  // ford-fulkerson
  int flow = 0;
  while(true){
    REP(i,2*sz+2)used[i]=false;
    int f = dfs(0,2*sz+1,INF);
    if(f==0)break;
    flow += f;
  }

  int min_path_cover = sz - flow;

  return (usd.size() + min_path_cover);

}

int main(){
  cin >> n;
  REP(i,n)cin>>x[i];

  // int mx = calc(vi());
  vi result;
  vi ids;
  int mx = calc(vi());
  REP(i,n){
    if(result.size() == mx)break;
    bool flag = false;
    REP(j,result.size()){
      if(x[i]%result[j]==0 || result[j]%x[i]==0){
        flag = true;
        break;
      }
    }
    if(flag)continue;
    result.push_back(x[i]);
    ids.push_back(i+1);
    int ts = calc(result);
    if(ts<mx){
      result.pop_back();
      ids.pop_back();
    }
  }

  cout << ids[0];
  REPR(i,ids.size()) cout << " " << ids[i];
  cout << endl;

  return 0;
}

Measured memory_bytes: 1316
let n = Scanf.scanf " %d" (+) 0
let bs = Array.init (n - 1) @@ fun _ -> Scanf.scanf " %d" (+) 0
let ans = ref @@ bs.(0) + bs.(n - 2)
let _ = for i = 1 to n - 2 do ans := !ans + min bs.(i - 1) bs.(i) done; Printf.printf "%d\n" !ans

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

int main() {

  int N;
  cin >> N;

  vector<int> a(N+1);
  for (int i = 1; i <= N; i++) {
    cin >> a[i];
  }

  bool flg = true;
  int current = 1;
  int answer = 0;

  while (flg) {

    answer++;
    current = a[current];

    if (current == 2) {
      flg = false;
    }

    if (N < answer) {
      answer = -1;
      flg = false;
    }
  }

  cout << answer << endl;

}

Measured memory_bytes: 768
var
	a,b,c,d,e,f,i,j,k,l,ansa,ansb:Longint;
begin
	read(a,b,c,d,e,f);
	ansa:=100*a;
	for i:=0 to f div(100*a) do begin
		for j:=0 to (f-100*a*i)div(100*b)do begin
			for k:=0 to (f-100*(a*i+b*j))div c do begin
				for l:=0 to (f-100*(a*i+b*j)-c*k)div d do begin
					if((a*i+b*j)*e>=c*k+d*l)and(ansa*(c*k+d*l)>ansb*(100*(a*i+b*j)+c*k+d*l))then begin
						ansa:=100*(a*i+b*j)+c*k+d*l;
						ansb:=c*k+d*l;
					end;
				end;
			end;
		end;
	end;
	write(ansa);
	write(' ');
	writeln(ansb);
end.


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

signed main(){
	long long n,d,ans=0; cin>>n>>d;
	for(int i=0;i<n;i++){
		long long x,y; cin>>x>>y;
		if(x*x + y*y <= d*d){
			ans++;
		}
	}
	cout<<ans<<endl;
}

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

int main() {
  ios::sync_with_stdio(0); cin.tie(0);
  int n, k, s;
  cin >> n >> k >> s;
  int b = s == 1e9 ? 1 : 1e9;
  for (int i = 0; i < n; i++)
    cout << (i < k ? s : b) << ' ';
  cout << endl;
}


Measured memory_bytes: 1280
import java.util.Scanner;

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

		int A = sc.nextInt();
		int B = sc.nextInt();

		int ans = 0;
		int kt = 1;

		for (int i = 1; i <= 100; i++) {
			if (kt >= B) {
				break;
			} else {
				ans++;
				kt -= 1;
				kt += A;
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 22996
n = int(input())
A = list(input())

W = 0
E = A.count("E")
ans = n+1

for i in A:
    if i == "W":
        W += 1
    else:
        E -= 1
    if W + E < ans:
        ans = W + E
print(min(ans, A.count("E"), A.count("W")))

Measured memory_bytes: 64112
n = int(input())

nums = list(map(int, input().split()))
l = [int(x) for x in range(1, n + 1)]

remain = [0]
count = 0

for i in nums:
    if i == remain[-1] + 1:
        remain.append(i)
    else:
        count += 1

if nums == l:
    print(0)
elif (count > 0) and (count != n):
    print(count)
else:
    print(-1)

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

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

ll calc(ll n)
{
    int t = 0;
    while (n > 0)
    {
        t++;
        n /= 10;
    }
    return t;
}

int main()
{
    ll N;
    cin >> N;
    ll min = INF;
    for (ll i = 1; i * i <= N; ++i)
    {
        if (N % i != 0)
            continue;
        min = std::min(min, std::max(calc(i), calc(N / i)));
    }
    cout << min << endl;
    return 0;
}

Measured memory_bytes: 256
def prime_factorize(N,lis):
    a = []
    n = N
    while n % 2 == 0:
        lis[2] += 1
        n //= 2
    f = 3
    while f * f <= N:
        if n % f == 0:
            lis[f] += 1
            n //= f
        else:
            f += 2
    if n != 1:
        lis[n] += 1

N = int(input())
lis = [0] * 101
for i in range(1,N+1):
    prime_factorize(i,lis)
#print(lis)
lis.sort()
ans = 0
for i in range(101):
    for j in range(i+1,101):
        for k in range(j+1,101):
            if lis[i] >= 2 and lis[j] >= 4:
                ans += 1
            if lis[i] >= 4:
                ans += 2
for i in range(101):
    for j in range(i+1,101):
        if lis[i] >= 4 and lis[j] >= 14:
            ans += 1
            if lis[i] >= 14:
                ans += 1
        if lis[i] >= 2 and lis[j] >= 24:
            ans += 1
            if lis[i] >= 24:
                ans += 1
for i in range(101):
    if lis[i] >= 74:
        ans += 1
print(ans)


Measured memory_bytes: 66252
//#include <stdio.h>
#include <math.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <queue>
#include <map>
#include <utility>
#include <iomanip>

using namespace std;

#define ll long long

struct Data
{
    string s;
    ll p;
    ll num;
};

bool cmp(const Data &a, const Data &b)
{
    if (a.s == b.s)
    {
        return a.p > b.p;
    }

    return a.s < b.s;
}

void solve()
{
    ll N;
    cin >> N;
    vector<Data> SP(N);
    for (ll i = 0; i < N; i++)
    {
        string s;
        ll p;
        cin >> s >> p;

        SP[i] = {s, p, i + 1};
    }
    sort(SP.begin(), SP.end(), cmp);

    for (auto sp : SP)
    {
        cout << sp.num << endl;
    }

    return;
}

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


Measured memory_bytes: 256
import scala.io.StdIn.{readInt, readLine}
  
object Main extends App {
  val (_, list) = (readInt, readLine.split(" ").map(_.toInt))
  val (mod1, mod2, mod0) = ( list.count(_%3==1), list.count(_%3==2), list.count(_%3==0) )
  val (m1, m2, m0) = if(mod1>mod2) (mod1, mod2, mod0) else (mod2, mod1, mod0)
  val diff = m1-m2
  val count0 = m2 * 2 + (if(diff <= 3) diff else 3)
  val count = count0 + (if(count0==0) 1 else  mod0)
  println(count)
}


Measured memory_bytes: 88260
// by ul {{{
#include <bits/stdc++.h>
#include <unistd.h>
#define SZ(x) ((int)(x).size())
#define ALL(c) begin(c),end(c)
#define REP(i,n) for ( int i=0; i<(int)(n); i++ )
#define REP1(i,a,b) for ( int i=(int)(a); i<=(int)(b); i++ )
#define FOR(it,c) for ( auto it=(c).begin(); it!=(c).end(); it++ )
#define MP make_pair
#define PB push_back
using namespace std;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef long long LL;

void RI() {}

template<typename... T>
void RI( int& head, T&... tail ) {
    scanf("%d",&head);
    RI(tail...);
}

template<typename T>
void _dump( const char* s, T&& head ) { cerr<<s<<"="<<head<<endl; }

template<typename T, typename... Args>
void _dump( const char* s, T&& head, Args&&... tail ) {
    int c=0;
    while ( *s!=',' || c!=0 ) {
        if ( *s=='(' || *s=='[' || *s=='{' ) c++;
        if ( *s==')' || *s==']' || *s=='}' ) c--;
        cerr<<*s++;
    }
    cerr<<"="<<head<<", ";
    _dump(s+1,tail...);
}

#define dump(...) _dump(#__VA_ARGS__, __VA_ARGS__);

template<typename Iter>
ostream& _out( ostream &s, Iter b, Iter e ) {
    s<<"[";
    for ( auto it=b; it!=e; it++ ) s<<(it==b?"":" ")<<*it;
    s<<"]";
    return s;
}

template<typename A, typename B>
ostream& operator <<( ostream &s, const pair<A,B> &p ) { return s<<"("<<p.first<<","<<p.second<<")"; }
template<typename T>
ostream& operator <<( ostream &s, const vector<T> &c ) { return _out(s,ALL(c)); }
template<typename T>
ostream& operator <<( ostream &s, const set<T> &c ) { return _out(s,ALL(c)); }
template<typename A, typename B>
ostream& operator <<( ostream &s, const map<A,B> &c ) { return _out(s,ALL(c)); }
// }}}
string s;
void input() {
    cin >> s;
}

void solve() {
    
}

int main( int argc, char *argv[] ) {
    input();
    if(s == "SUN") {
        cout << 7 << endl;
    } else if(s == "SAT") {
        cout << 1 << endl;
    } else if(s == "MON") {
        cout << 6 << endl;
    } else if(s == "TUE") {
        cout << 5 << endl;
    } else if(s == "WED") {
        cout << 4 << endl;
    } else if(s == "THU") {
        cout << 3 << endl;
    } else if(s=="FRI") {
        cout << 2 << endl;
    }

    return 0;
}


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

ll pow(ll x,ll y,ll mod){
	ll ans=1;
	while(y>0){
		if(y&1){
			ans=ans*x%mod;
		}

		y=y>>1;
		x=x*x%mod;
	}

	return ans%mod;
}

int main(){
	ll n;
	cin>>n;
	//ll x=10,y=9,z=8;
	ll x=pow(10,n,mod);
	ll y=pow(9,n,mod);

	ll z = pow(8,n,mod);
	
	//cout<<x<<" "<<y<<" "<<z<<endl;
	ll ans = 0;
  	
  	ans = ((x-y-y+z)%mod+mod)%mod;
  
	cout<<ans<<endl;
}


Measured memory_bytes: 3576
#include<iostream>
using namespace std;
int main(){
int a,b,c,n,s=0;
cin>>a>>b>>c>>n;
for(int i=0;i<=a;i++)
for(int j=0;j<=b;j++)
for(int k=0;k<=c;k++)
if(i*500+j*100+k*50==n)
s++;
cout<<s;
}


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

int main() {
	
	int n, m;
	cin >> n >> m;
	
	string ans = "No";
	if(m == n) ans = "Yes";
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
class Program
    {
        class Node
        {
            public int id;
            public List<Node> link;
            public Node (int id)
            {
                this.id = id;
                link = new List<Node>();
            }
        }
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            Node[] nodes = new Node[n];
            for (int i=0; i<n; i++)
            {
                Node nn = new Node(i);
                nodes[i] = nn;
            }
            for (int i=0; i<n-1; i++)
            {
                string[] s = Console.ReadLine().Split(' ');
                int n1 = int.Parse(s[0]) - 1, n2 = int.Parse(s[1]) - 1;
                nodes[n1].link.Add(nodes[n2]);
                nodes[n2].link.Add(nodes[n1]);
            }
            Queue<Node> queue = new Queue<Node>();
            int[] checkList = new int[n];
            queue.Enqueue(nodes[0]);
            checkList[0] = -1;
            int farNode = -1;
            while(queue.Count > 0)
            {
                Node nn = queue.Dequeue();
                farNode = nn.id;
                foreach (Node nnn in nn.link)
                {
                    if (checkList[nnn.id] == 0)
                    {
                        checkList[nnn.id] = -1;
                        queue.Enqueue(nnn);
                    }
                }
            }
            queue.Enqueue(nodes[farNode]);
            checkList[farNode] = 1;
            while(queue.Count > 0)
            {
                Node nn = queue.Dequeue();
                farNode = nn.id;
                foreach (Node nnn in nn.link)
                {
                    if (checkList[nnn.id] == -1)
                    {
                        checkList[nnn.id] = checkList[nn.id] + 1;
                        queue.Enqueue(nnn);
                    }
                }
            }
            if (checkList[farNode] % 3 == 2) Console.WriteLine("Second");
            else Console.WriteLine("First");

            
        }
    }
    //mcs Main.cs
    //mono Main.exe

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

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

	vector<int> dp(n+1,0);
	dp[1]=0;
	dp[2]=abs(v[1]-v[2]);
	for(int i=3;i<=n;i++) dp[i]=min(dp[i-1]+abs(v[i-1]-v[i]),dp[i-2]+abs(v[i-2]-v[i]));

	cout<<dp[n];
	return 0;
}

Measured memory_bytes: 1024
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UncheckedIOException;
import java.util.StringTokenizer;

class Main{
	public static void main(String[] args) {
		SC sc=new SC(System.in);
		int N=sc.nextInt();
		int[] a=new int[N];
		for(int i=0; i<N; i++) {
			a[i]=sc.nextInt()-1;
		}
		int cnt=0;
		for(int i=0; i<N; i++) {
			if(a[a[i]]==i) {
				cnt++;
			}
		}
		pl(cnt/2);
	}
	public static void pl(Object o) {
		System.out.println(o);
	}
	public static void pl() {
		System.out.println();
	}
	public static void p(Object o) {
		System.out.print(o);
	}
	static class SC {
		private BufferedReader reader = null;
		private StringTokenizer tokenizer = null;
		public SC(InputStream in) {
			reader = new BufferedReader(new InputStreamReader(in));
		}
		public String next() {
			if (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
			}
			return tokenizer.nextToken();
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
		public double nextDouble() {
			return Double.parseDouble(next());
		}
		public String nextLine() {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new UncheckedIOException(e);
			}
		}
	}
}

Measured memory_bytes: 34644
#include <iostream>
#include <algorithm>
#include <vector>
#define INF 1e9+7
using namespace std;
typedef long long int ll;

int main() {

	//97以上122以下


	char w[11];
	cin >> w;
	int a = 0, c = 0;
	int cou = 0;
	int cou1 = 0;

	for (int i = 0; w[i] != '\0'; i++) {
		cou++;
	}

	if (w[0] == 'A') {
		a = 1;
	}

	for (int i = 0; w[i] != 0; i++) {
		if (w[i] == 'C'&&i >= 2 && i <= cou - 2) {
			c = 1;
		}
	}

	if (a != 1 || c != 1) {
		cout << "WA" << endl; 
		return 0;
	}

	for (int i = 0; i < cou; i++) {
		if ((int)w[i] >= 97 && 122 >= (int)w[i]) {
			cou1 += 1;
		}
	}

	if (cou1 + a + c == cou){
		cout << "AC" << endl;
	}
	else {
		cout << "WA" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <queue>
#include <cstring>
#include <fstream>

using namespace std;
using ll = long long;

ll dp[105][100005]; 
int weight[105];
int value[105];

int main()
{
	int n, w;
	cin >> n >> w;
	for(int i = 1; i <= n; i++)
		cin >> weight[i] >> value[i];
	for(int i = 1; i <= n; i++)
	{
		for(int j = 0; j <= w; j++)
		{
			dp[i][j] = max(dp[i][j], dp[i - 1][j]);
			if(j - weight[i] >= 0)
				dp[i][j] = max(dp[i][j], dp[i - 1][j - weight[i]] + value[i]);
		}
	}
	cout << dp[n][w] << endl;
	return 0;
}



Measured memory_bytes: 81724
using System;
using System.Collections.Generic;
using System.Text;

namespace AOJ
{
    class Program
    {
        static void Main(string[] args)
        {
            for (; ; )
            {
                var inputLine = Console.In.ReadLine();
                var inputs = inputLine.Split(new char[] { ' ', '\t', '　' });
                if (inputs.Length != 3)
                {
                    return;
                }

                var a = int.Parse(inputs[0]);
                var b = int.Parse(inputs[2]);
                var op = inputs[1];

                int result = 0; // dummy value.
                switch (op)
                {
                    case "+":
                        result = a + b;
                        break;
                    case "-":
                        result = a - b;
                        break;
                    case "*":
                        result = a * b;
                        break;
                    case "/":
                        result = a / b;
                        break;
                    case "?":
                        goto BREAK;
                }

                Console.WriteLine(result);
            }
        BREAK: ;
        }
    }
}


Measured memory_bytes: 15960
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll;


int main(void){
  int n,i;
  vector<int> ans;
  
  cin >> n;
  
  if (n==0){
    cout << 0 << endl;
    return 0;
  }
  
  int p1,p2;
  while (n!=0){
    if ((n-1)%4==0){
      p1=1;
      p2=0;
      n=(n-1)/4;
    }else if (n%4==0){
      p1=p2=0;
      n/=4;
    }else if ((n+1)%4==0){
      p1=p2=1;
      n=(n+1)/4;
    }else if ((n+2)%4==0){
      p1=0;
      p2=1;
      n=(n+2)/4;
    }
    ans.push_back(p1);
    ans.push_back(p2);
  }
  
  for (i=ans.size()-1;i>=0;i--){
    if (i==ans.size()-1 && ans[i]==0) continue;
    cout << ans[i];
  }
  cout << endl;
  
  return 0;
}

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

using namespace std;
#define DBG(x)                         \
    (void)(cout << "L" << __LINE__     \
                << ": " << #x << " = " \
                << (x) << '\n')
typedef long long ll;
const int INF = 0x3f3f3f3f;
const int maxn = 210000;
const int mod = 998244353;
ll power(ll a, ll b)
{
    ll ans = 1 % mod;
    while (b > 0)
    {
        if (b & 1)
        {
            ans = ans * a % mod;
        }
        a = a * a % mod;
        b >>= 1;
    }
    return ans;
}
ll fact[maxn], inv[maxn];
ll C(ll n, ll k)
{
    return ((((fact[n] * inv[k]) % mod) * inv[n - k]) % mod);
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setiosflags(ios::fixed) << setprecision(12);
    int n, m, k;
    cin >> n >> m >> k;
    fact[0] = inv[0] = 1;
    for (int i = 1; i <= n; ++i)
    {
        fact[i] = (fact[i - 1] * i) % mod;
        inv[i] = power(fact[i], mod - 2);
    }
    ll ans = 0;
    for (int i = 0; i <= k; i++)
    {
        ll cnt = 1LL * m * C(n - 1, i) % mod * power(m - 1, n - 1 - i) % mod;
        ans = (ans + cnt) % mod;
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 6724
import std.stdio, std.algorithm, std.string, std.conv, std.array, std.range, std.math;
int readint() { return readln.chomp.to!int; }
int[] readints() { return readln.split.to!(int[]); }
 
void main() {
    long a,b,c,k;
    readf("%d %d %d %d\n",&a,&b,&c,&k);
    writeln(k&1 ? b - a : a - b);
}

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

using namespace std;
using LL = long long;
using P = pair<int, int>;
using Tapris = tuple<int, int, int>;

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

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e15;
const int MOD = 1e9 + 7;

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

template <typename T>
class UnionFind {
    private:
        vector<int> parent;  // 親
        vector<int> rank;    // 木の深さ

        // 重み付きUnionFindでのみ利用
        vector<T> diffWeight; // 親ノードとの値の差
    public:
        UnionFind(int n);          // n要素で初期化
        int Find(int x);           // 木の根を返す
        void Unite(int x, int y);  // xとyの属する集合を併合
        bool Same(int x, int y);   // xとyが同じ集合に属するか否か
        
        // 重み付きUnionFindでのみ利用
        void Unite(int x, int y, T w);
        T Weight(int x);      // xの重みを返す
        T Diff(int x, int y); // xとyの差を返す
};

template <typename T>
UnionFind<T>::UnionFind(int n) : parent(n), rank(n), diffWeight(n, 0)
{
    for (int i = 0; i < n; i++) {
        parent[i] = i;
        rank[i] = 0;
    }
}

template <typename T>
int UnionFind<T>::Find(int x) {
    if (parent[x] == x) {
        return x;
    } else {
        int r = Find(parent[x]);
        diffWeight[x] += diffWeight[parent[x]];
        return parent[x] = r;
    }
}

template <typename T>
void UnionFind<T>::Unite(int x, int y) {
    x = Find(x);
    y = Find(y);
    if (x == y) return;

    if (rank[x] < rank[y]) {
        parent[x] = y;
    } else {
        parent[y] = x;
        if (rank[x] == rank[y]) rank[x]++;
    }
}

template <typename T>
bool UnionFind<T>::Same(int x, int y) { return Find(x) == Find(y); }

template <typename T>
void UnionFind<T>::Unite(int x, int y, T w){
    w += Weight(x); w -= Weight(y);
    x = Find(x); y = Find(y);
    if(x == y) return;

    if(rank[x] < rank[y]) swap(x, y), w = -w;

    if(rank[x] == rank[y]) rank[x]++;
    parent[y] = x;

    diffWeight[y] = w;
}

template <typename T>
T UnionFind<T>::Weight(int x){
    Find(x);
    return diffWeight[x];
}

template <typename T>
T UnionFind<T>::Diff(int x, int y){
    return Weight(y) - Weight(x);
}

/*************** using variables ***************/
int n, q;
/**********************************************/

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

    cin >> n >> q;
    UnionFind<int> uf(n);
    REP(i, q){
        int query;
        cin >> query;
        if(query == 0){
            int x, y, z;
            cin >> x >> y >> z;
            uf.Unite(x, y, z);
        }else{
            int x, y;
            cin >> x >> y;
            if(uf.Same(x, y)) cout << uf.Diff(x, y) << endl;
            else cout << '?' << endl;
        }
    }
}



Measured memory_bytes: 4160
a = int(input())
v = {}
v[a] = True
ans = 1
while True:
    ans += 1
    if a % 2 == 1:
        a = (a * 3) + 1
    else:
        a = (a//2)
    if v.get(a): 
        break
    else:
        v[a] = True
 
print(ans)


Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define taskname "A"
#define pb push_back
#define mp make_pair

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;
const int maxn = 2e5 + 5;

int n;
int a[maxn] , b[maxn];
int c[maxn] , d[maxn];

int main(){
    if(fopen(taskname".INP","r")){
        freopen(taskname".INP","r",stdin);
        freopen(taskname".OUT","w",stdout);
    }
    cin >> n;
    for(int i = 1 ; i <= n ; ++i){
        cin >> a[i];
    }
    for(int i = 1 ; i <= n ; ++i){
        cin >> b[i];
    }
    auto Solve = [&](int t){
        for(int i = 1 ; i <= n ; ++i){
            c[i] = a[i] % (t * 2);
            d[i] = b[i] % (t * 2);
        }
        sort(d + 1 , d + n + 1);
        ll res = 0;
        for(int i = 1 ; i <= n ; ++i){
            res += lower_bound(d + 1 , d + n + 1 , 2 * t - c[i]) -
             lower_bound(d + 1 , d + n + 1 , t - c[i]);
            res += lower_bound(d + 1 , d + n + 1 , 4 * t - c[i]) -
             lower_bound(d + 1 , d + n + 1 , 3 * t - c[i]);
        }
        return res & 1;
    };
    int res = 0;
    for(int i = 0 ; i < 29 ; ++i){
        if(Solve(1 << i))res += (1 << i);
    }
    cout << res;
}



Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
#define gcd(a,b) __gcd(a,b)
#define pb push_back
#define sevensins ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ll long long int
#define GO ll t; cin>>t; while(t--)
#define mod  1000000007
#define vect vector<long long int>
#define fore(p) for(auto& x:p)
#define bins binary_search
#define vecti vector<int>::iterator
#define bitout __builtin_popcount
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(), x.rend()
#define PY 3.141592653589793238
ll power(ll a,ll b){
    ll res = 1;
    while(b > 0)
    {
        if(b%2 == 11) res *= a;
        a *= a;
        b /= 2;
    }
    return res;
}
int main() 
{sevensins
    ll i,j,k,l,n;
    cout.precision(10);
    //GO
    {
        cin >> n >> k;
        
        vector<pair<ll,ll>> v;
        
        ll x, y;
        for(i=0;i<n;i++)
        {   
            cin >> x >> y;
            v.push_back({x,y});
        }
        
        ll sum = 0;
        
        vect dp(k+1,0);
        
        for(i = 0 ;i < n ;i++)
        {   
            for(j=k-v[i].first;j>=0;j--)
            {   
                dp[j+v[i].first]=max(dp[j+v[i].first],dp[j]+v[i].second);
            }  
        }
        
       fore(dp)
       {
           sum=max(sum,x);
           cerr<< x << " ";
       }
        
        cout << sum ;
    }
return 0;
}

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

int main() {
    long long a, b, c, d, gcc, ans=0;
    cin >> a >> b >> c >> d;
    gcc=c*d/ __gcd(c, d);
    ans = b-(a-1) - (b/c - (a-1)/c + b/d - (a-1)/d - (b/ gcc - (a-1)/ gcc));
    cout << ans;
}

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

typedef unsigned long long ll;
using namespace std;

#define NUMBER 1000000007
ll kaijo(int a){
    ll ans = 1;
    while(a != 1){
        ans *= a;
        ans = ans % NUMBER;
        a--;
    }
    return ans;
}

int main(){
    int n,m; scanf("%d %d",&n,&m);
    ll ans;
    
    if(abs(n-m) > 1)
        cout << "0" << endl;
    
    else{
        if(n == m)
            ans = kaijo(n) * kaijo(m) * 2;
        
        else
            ans = kaijo(n) * kaijo(m);
        
        cout << ans % NUMBER << endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip> // setprecision
#include <complex> // complex
#include <math.h> 
#include <climits> 
#include <assert.h>
#include <random>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod = 1'000'000'007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[8] = {1, 0, -1, 0,1,1,-1,-1};
const int dy[8] = {0, 1, 0, -1,1,-1,1,-1};
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; }
// ---------------------------------------------------------------------------

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N,K;
  cin >> N >> K;
  vector<int> A(N);
  ll sum = 0;
  for(int i=0; i<N; i++){
    cin >> A[i];
    sum += A[i];
  }
  auto suzu = [&](int d){
    vector<ll> rem(N);
    for(int i=0; i<N; i++){
      rem[i] = A[i]%d;
    }
    sort(rem.begin(),rem.end());
    vector<ll> S(N+1,0);
    for(int i=0; i<N; i++){
      S[i+1] = S[i] + rem[i];
    }
    vector<ll> suf(N+1,0);
    for(int i=0; i<N; i++){
      suf[i+1] = suf[i] + (d-rem[i]);
    }
    for(int i=0; i<N; i++){      
      if(max(S[i],suf[N]-suf[i]) <= K) return true;
    }
    return false;
  };
  ll ans = 0;
  for(ll i=1; i*i<=sum; i++){
    if(sum%i == 0){
      if(suzu(i)) chmax(ans,i);
      if(suzu(sum/i)) chmax(ans,sum/i);
    }
  }
  cout << ans << "\n";
  return 0;
}

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

ans = 10**10
for i in range(N):
  t = W[i]
  a = 0
  b = 0
  for j in range(N):
    if j <= i:
      a += W[j]
    else:
      b += W[j]
  ans = min(ans, abs(a - b))

print(ans)

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

int main() {
  int H = 0, W = 0;

  while (true) {
    cin >> H >> W;

    if (H == 0 && W == 0) {
      break;
    }

    for (int i = 0; i < W; i++) {
      cout << "#";
    }
    cout << endl;

    for (int i = 0; i < H - 2; i++) {
      cout << "#";
      for (int j = 0; j < W - 2; j++) {
        cout << ".";
      }
      cout << "#" << endl;
    }

    for (int i = 0; i < W; i++) {
      cout << "#";
    }
    cout << endl << endl;
  }
}



Measured memory_bytes: 3004
from collections import Counter

N = int(input())
A = list(map(int, input().split()))

count_max = 0
C = Counter(A)
for i in range(min(C.keys()), max(C.keys()) + 1):
    count = C.get(i-1, 0) + C.get(i, 0) + C.get(i+1, 0)
    count_max = max(count_max, count)
print(count_max)


Measured memory_bytes: 14564
// AOJ 1380 Medical Checkup
// 2018.2.6 bal4u
 
#include <stdio.h>
 
//#define getchar_unlocked()  getchar()
int in()
{
    int n = 0;
    int c = getchar_unlocked();
    do n = (n<<3)+(n<<1) + (c & 0xf), c = getchar_unlocked();
    while (c >= '0');
    return n;
}
 
int main()
{
    int n, t, h, p;
    long long a, b;
 
    n = in(), t = in();
    b = 0, p = 0;
    while (n--) {
        h = in();
        if (p < h) p = h;
		a = t+p-h - b;
		if (a < 0) puts("1");
		else printf("%d\n", 1+(int)(a/p));
        b += h;
    }
    return 0;
}


Measured memory_bytes: 2108
#include<iostream>

using namespace std;

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

	if (D == 25) {
		cout << "Christmas" << endl;
	}
	else if (D == 24) {
		cout << "Christmas Eve" << endl;
	}
	else if (D == 23) {
		cout << "Christmas Eve Eve" << endl;
	}
	else if (D == 22) {
		cout << "Christmas Eve Eve Eve" << endl;
	}
}




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

int main()
{
	int a,b,c,x,t=0;
	cin>>a>>b>>c>>x;
	for(int i=0;i<=a;i++)
		for(int j=0;j<=b;j++)
		{
			int m=(x-i*500-j*100)/50;
			if (m>=0 && m<=c)
				t++;
		}
	cout<<t<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#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 FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
typedef long long ll;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};
int gcd(int n,int m){
  int l;
  if(n<m){
    l=n;
    n=m;
    m=l;
  }
  while (m>0) {
    l=n%m;
    n=m;
    m=l;
  }
  return n;
}
int main(int argc, char const *argv[]) {
  int x,y;
  cin>>x>>y;
  cout<<gcd(x,y)<<endl;

  return 0;
}



Measured memory_bytes: 3120
#include<deque>
#include<list>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<cmath>
#include<cstdio>
using namespace std;
int main(){
  int i,j,k,l,m;
  int n;
  while(cin>>n,n){
    vector<vector<int> > a;
    for(i=0;i<n;++i)
      a.push_back(vector<int>(1,i+1));
    int p,q;
    while(cin>>p>>q,p||q){      
      for(i=0;i<(int)a.size();++i){
	for(j=0;j<(int)a[i].size();++j){
	  if(a[i][j]==p)
	    break;
	}
	if(j<(int)a[i].size())
	  break;
      }
      if(q){
	for(k=0;k<(int)a.size();++k){
	  for(l=0;l<(int)a[k].size();++l){
	    if(a[k][l]==q)
	      break;
	  }
	  if(l<(int)a[k].size())
	    break;
	}
	if(i==k){
	  if(j<l){
	    for(m=j+1;m<(int)a[i].size();++m)
	      a.push_back(vector<int>(1,a[i][m]));
	    a[i-j+l].push_back(a[i][j]);
	    if(j){
	      a[i].erase(a[i].begin()+j,a[i].end());
	    }else{
	      a.erase(a.begin()+i);
	    }
	  }
	}else{
	  if((int)a[i].size()-1!=j){
	    for(m=j+1;m<(int)a[i].size();++m)
	      a.push_back(vector<int>(1,a[i][m]));
	  }
	  a[k].push_back(a[i][j]);
	  if(j){
	    a[i].erase(a[i].begin()+j,a[i].end());
	  }else{
	    a.erase(a.begin()+i);
	  }
	}
      }else{
	if(j){
	  if((int)a[i].size()-1!=j){
	    for(m=j+1;m<(int)a[i].size();++m)
	      a.push_back(vector<int>(1,a[i][m]));
	  }
	  a.push_back(vector<int>(1,a[i][j]));
	  a[i].erase(a[i].begin()+j,a[i].end());
	}
      }
    }
    vector<int> b;
    for(i=0;i<(int)a.size();++i)
      b.push_back(a[i].size());
    sort(b.begin(),b.end());
    for(i=0;i<(int)b.size();++i)
      cout<<b[i]<<endl;
    cout<<"end"<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
def gcd(a,b):
    if b == 0:
        return a
    return gcd(b, a % b)


n, X = map(int,input().split())
x = list(map(int,input().split()))
x.append(X)
x.sort()
x = [x[i]-x[0] for i in range(n+1)]
del x[0]
g = x[0]
for i in range(1, n):
    g = gcd(g,x[i])
print(g)


Measured memory_bytes: 14224
L = list(map(str, input().split(' ')))
que = []
while len(L) != 0:
    if L[0] not in ('+', '-', '*'):
        que.append(int(L.pop(0)))
    else:
        if L[0] == '+':
            a = que[-2] + que[-1]
        elif L[0] == '-':
            a = que[-2] - que[-1]
        elif L[0] == '*':
            a = que[-2] * que[-1]
        L.pop(0)
        que.pop(-1)
        que.pop(-1)
        que.append(a)
print(que[0])


Measured memory_bytes: 5604
#include <bits/stdc++.h>
using namespace std;
int main () {
    int N, K;
    cin >> N >> K;
    int list[N];
    map<int, int> mp;
    for(int i = 0; i < N; i++) cin >> list[i];

    for(int i = 0; i<N; i++) {
        mp[list[i]]++;
    }

    int res = 0;
    int msize = mp.size();
    if(msize > K) {
        int sortlist[mp.size()];
        int index = 0;
        for(auto i : mp) {
            sortlist[index] = i.second;
            index++;
        }
        sort(sortlist, sortlist + mp.size());
        for(int i = 0; i< abs(K - msize); i++ ) {
            res += sortlist[i];
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 11136
#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
typedef long long LL;
typedef unsigned long long uLL;
typedef pair<int,int> pii;

const int maxn=300111;
int n,a[maxn];

bool check(int sum)
{
	int mn=0,pre=0;
	for(int i=1;i<=n;i++)
	{
		if(i%2==0&&pre-mn>=sum)mn=min(mn,pre-a[i]);
		if(i%2)pre+=a[i];
		else pre-=a[i];
	}
	if(pre-mn>=sum)return true;
	else return false;
}

int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",a+i);
	
	int s1=0,s2=0;
	for(int i=1;i<=n;i++)
	{
		if(i%2)s1+=a[i];
		else s2+=a[i];
	}
	if(n%2==0)
	{
		if(s1<s2)swap(s1,s2);
		printf("%d %d\n",s1,s2);
		return 0;
	}
	
	int lb=0,rb=1e9,mid;
	while(lb<rb-1)
	{
		mid=(lb+rb)>>1;
		if(check(mid))lb=mid;
		else rb=mid;
	}
	printf("%d %d\n",s2+lb,s1-lb);
	return 0;
}

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

#define range 100005
#define mod 1000000007
#define eps 1e-9
#define PI 3.14159265358979323846
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define ALL(V) V.begin(), V.end()
#define _ <<" "<<
#define int long long 

using namespace std;

typedef long long ll;
typedef vector <int> vi;
typedef vector<vi> vvi;
typedef pair <int, int> ii;
typedef pair<int, pair<int,int> > iii;
typedef vector<ii> vii;
typedef vector<iii> viii;

int nooD(int b)
{
	int count =0;
	while(b)
	{
		b /=10;
		count++;
	}
	return count;
}

signed main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	//freopen("test.txt","r",stdin);
	int n;
	cin>>n;
	int output=0;
	for(int i=1;i<=n;i++)
	{
		if(nooD(i)%2==1)
			output++;
	}
    cout<<output;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>

using namespace std;

int main(){
  int n,result;
  int i,a;

  cin >> n;
  result = 0;
  for ( i = 2; i>=0;i--){
    a = n / pow(10,i);
    n -= a*pow(10,i);
    if ( a == 1 ){
      result += 9 * pow(10,i);
    }
    else if(a == 9){
      result += 1 * pow(10,i);
    }
    else{
      result += a * pow(10,i);
    }
  }
  cout << result << 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;
using ll = long long;
using P = pair<int, int>;

int main()
{
    int m, n;
    cin >> m >> n;
    int aa[n];
    rep(i, n) cin >> aa[i];

    int cnt = 0;
    rep(i, n)
    {
        cnt += aa[i];
    }
    int res = m - cnt;

    if (res < 0)
    {
        res = -1;
    }
    cout << res << endl;

    return 0;
}


Measured memory_bytes: 3632