akhauriyash/Code-Regression huggingface dataset:
def exp(n, k, mod = nil)
	x = 1	
	r = n
	while k > 0
		x *= r if k & 1 == 1
		r *= r		
		if mod
			x %= mod
			r %= mod
		end
		k >>= 1
	end
	x
end

def gcd(m, n)
	if m < n 
		gcd(n, m)
	elsif n == 0
		m
	else
		gcd(n, m % n)
	end 
end

def fermat_test(n)
    a = 2 + rand(n - 2)
    return false if gcd(a, n) > 1
    return exp(a, n - 1, n) == 1
end

def prime?(n, k = 100)
    return (1..k).all? { fermat_test(n) }
end

n, c = gets.split.map(&:to_i)
if c < 0 and n == 1
    puts 11
else
    max = 10 ** n - 1
    min = 10 ** (n - 1)
    ans = nil
    c = (c < 0 ? '' : c.to_s)
    if c != ''
        max.downto(min) do |x|
            y = (x.to_s + c + x.to_s.reverse).to_i
            if prime?(y)
                ans = y
                break
            end
        end
    end
    puts ans || [max, max] * c
end




Measured memory_bytes: 6876
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;

const long double PI = acos(-1);
constexpr long double EPS = 1e-15;
constexpr int inf = 2e9;
constexpr ll INF = 2e18;
constexpr ll MOD = 1e9+7;
constexpr ll MOD1 = 998244353;
typedef pair<ll,ll> P;

//#define all(v) (v).begin(), (v).end()
#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
//#define mp make_pair

int main(){
  string s;
  cin >> s;
  int cnt = 0;
  for (int i = 0; i < sz(s) ; i++) {
    if (s[i] == '*') break;
    if (s[i] == '(') cnt++;
    else cnt--;
  }
  cout << cnt << endl;
  return 0;
}



Measured memory_bytes: 3208
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		int[][][] array = new int [4][3][10];
		Scanner scan = new Scanner(System.in);
		int number = scan.nextInt();
		for(int i = 0; i<number; i++){
			int building = scan.nextInt();
			int floor = scan.nextInt();
			int room_number = scan.nextInt();
			int change = scan.nextInt();

			array[building-1][floor-1][room_number-1] += change;

		}
		for(int j = 0; j<4; j++){
			for(int k = 0; k<3; k++){
				for(int l = 0; l<10; l++){
					System.out.print(" "+array[j][k][l]);
				}
				System.out.println();
			}
			if(j!=3){
				System.out.println("####################");
			}
		}
	}
}

Measured memory_bytes: 29580
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) begin(x), end(x)
#define chmax(x,y) x = max(x,y)
using namespace std;
typedef long long ll;
typedef pair <int,int> P;

int group[1005][1005];

const int MAX_V=10000005;
int V;
vector<pair<int,ll>> G[MAX_V];
ll d[MAX_V];

void dijkstra(int s){
  priority_queue<pair<ll,int>,vector<pair<ll,int>>,greater<pair<ll,int>>> que;
  rep(i,V) d[i]=1e18;
  d[s]=0;
  que.emplace(0,s);

  while (!que.empty()) {
    pair<ll,int> p=que.top(); que.pop();
    int v=p.second;
    if (d[v]<p.first) continue;
    for (auto e: G[v]) {
      if (d[e.first]>d[v]+e.second) {
	d[e.first]=d[v]+e.second;
	que.emplace(d[e.first],e.first);
      }
    }
  }
}

int main(){
  int h,w,ch,cw,dh,dw;
  cin>>h>>w>>ch>>cw>>dh>>dw;
  ch--,cw--,dh--,dw--;
  char s[1005][1005];
  rep(i,h) rep(j,w) cin>>s[i][j];

  int dx[4] = {1,0,-1,0};
  int dy[4] = {0,1,0,-1};
  int g_num=1;
  int s_g,g_g;
  rep(i,h) rep(j,w){
    if(group[i][j]!=0||s[i][j]=='#') continue;
    group[i][j]=g_num;
    queue<P> q;
    q.push({i,j});
    while(q.size()){
      auto p1=q.front(); q.pop();
      int y,x; tie(y,x)=p1;
      if(y==ch&&x==cw) s_g=g_num;
      if(y==dh&&x==dw) g_g=g_num;
      rep(i,4){
	int ny=y+dy[i],nx=x+dx[i];
	if(ny<0||nx<0||ny>=h||nx>=w) continue;
	if(s[ny][nx]=='.'&&group[ny][nx]==0){
	  group[ny][nx]=group[y][x];
	  q.push({ny,nx});
	}
      }
    }
    g_num++;
  }

  /*
  rep(i,h){
    rep(j,w){
      cout<<group[i][j]<<' ';
    }
    cout<<endl;
  }
  */

  vector<set<int>> e(g_num);
  rep(i,h) rep(j,w){
    if(group[i][j]==0) continue;
    for(int ny=i-2; ny<=i+2; ny++){
      for(int nx=j-2; nx<=j+2; nx++){
	if(ny<0||nx<0||ny>=h||nx>=w) continue;
	if(group[ny][nx]==0) continue;
	if(group[i][j]==group[ny][nx]) continue;
	e[group[i][j]].insert(group[ny][nx]);
      }
    }
  }

  rep(i,g_num){
    for(int x:e[i]){
      G[i].push_back({x,1});
    }
  }

  /*
  rep(i,g_num){
    for(auto p:G[i]){
      cout<<p.first<<' ';
    }
    cout<<endl;
  }
  */

  V=g_num+1;
  dijkstra(s_g);

  if(d[g_g]==1e18) cout<<-1<<endl;
  else cout<<d[g_g]<<endl;
  return 0;
}


Measured memory_bytes: 277172
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#include<cmath>


#define REP(i,n) for (int i = 0; (i) < (n); ++ (i))
#define FOR(i,n) for (int i = 1; (i) <= (n); ++ (i))
#define dump(x)  cout << #x << " = " << (x) << endl;
#define pb push_back
#define int long long
//#define lint long long

const int INF = 1e18;
const int MOD = 1e9+7;
//const lint LINF = 1e18;
const double eps = 0.000000001;//もとの値の10^(-16)まで

using namespace std;

//typedef pair<int, int> P;
//priority_queue< P, vector<P>, greater<P> > q;//ダイクストラの時、greaterで小さい順
int a[20];
int x[20][20];
int y[20][20];
int mypow(int _x, int _n){
	int ret = 1;
	while(0 < _n){
		if((_n % 2) == 0){
			_x *= _x;
			_n >>= 1;
		}
		else{
			ret *= _x;
			--_n;
		}
	}
	return ret;
}

signed main(){
  int n;
	cin >> n;
	REP(i,n){
		cin >> a[i];
		REP(j,a[i]){
			int x1;
			cin >> x1;
			x1 --;
			x[i][j] = x1;
			cin >> y[i][j];
		}
	}
	int ans = 0;
	REP(i,mypow(2,n)){
		int now = i;
		int now_hito[20];
		int f = 0;
		REP(j,n){
			//cout << "now=" << now << endl;
			now_hito[j] = now%2;
			now/=2;
		}
		REP(j,n){
			if(now_hito[j]==0) continue;
			REP(j2,a[j]){
				if(y[j][j2]!=now_hito[x[j][j2]]) f = 1;
			}
		}
		//cout << "i= "<< i << " " << f << endl;
		if(f==0){
			int an = 0;
			REP(kk,n){
				an += now_hito[kk];
			}
			ans = max(ans,an);
		}
	}
	cout << ans << endl;
  return 0;
}


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

const int log2_SIZE = 17;

using namespace std;

//多分他の問題にはそのまま使えない
vector<complex<double>> fft(vector<complex<double>> x){
  int n = x.size();
  
  if(n == 1) return x;
  
  
  vector<complex<double>> xe(n >> 1);
  vector<complex<double>> xo(n >> 1);
  
  for(int t = 0; t < n; t++){
    if(t & 1) xo[t >> 1] = x[t];
    else xe[t >> 1] = x[t];
  }
  
  vector<complex<double>> ye = fft(xe);
  vector<complex<double>> yo = fft(xo);
  
  vector<complex<double>> y(n);
  
  for(int k = 0; k < (n >> 1); k++){
    complex<double> w_k = polar(1.0, -2 * M_PI / (double)n * k);
    
    y[k] = ye[k] + w_k * yo[k];
    y[k + (n >> 1)] = ye[k] - w_k * yo[k];
  }
  
  return y;
}

vector<complex<double>> ifft(vector<complex<double>> y){
  int n = y.size();
  
  for(int k = 0; k < n; k++){
    y[k] = conj(y[k]) / (double)n;
  }
  
  vector<complex<double>> x = fft(y);
  
  for(int t = 0; t < n; t++){
    x[t] = conj(x[t]);
  }
  
  return x;
}

vector<complex<double>> conv(vector<complex<double>> x1, vector<complex<double>> x2){
  int n = x1.size() + x2.size();
  
  x1.resize(n);
  x2.resize(n);
  for(int t = n >> 1; t < n; t++){
    x1[t] = x2[t] = 0;
  }
  
  vector<complex<double>> y1 = fft(x1);
  vector<complex<double>> y2 = fft(x2);
  
  for(int k = 0; k < n; k++){
    y1[k] *= y2[k];
  }
  return ifft(y1);
}

int main(){
  int N;
  long long M;
  cin >> N >> M;
  vector<complex<double>> power((1 << log2_SIZE), 0);
  for(int i = 0; i < N; i++){
    int A;
    cin >> A;
    power[A] += 1;
  }
  
  vector<complex<double>> happy((1 << (log2_SIZE + 1)));
  happy = conv(power, power);
  long long happiness = 0;
  for(int i = (1 << (log2_SIZE + 1)) - 1; M > 0 && i >= 0; i--){
    happiness += i * min((long long)(happy[i].real() + 0.5), M);
    M -= int(happy[i].real() + 0.5);
  }
  
  cout << happiness << endl;
  
  return 0;
}

Measured memory_bytes: 47464
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int n, c[512] = {}, s[512] = {}, f[512] = {};
    cin >> n;
    for (int i = 1; i < n; i++) cin >> c[i] >> s[i] >> f[i];
    for (int i = 1; i <= n; i++) {
        int t = 0;
        for (int j = i; j < n; j++) {
            if (t < s[j]) t = s[j];
            else if (t % f[j]) t += f[j] - t % f[j];
            t += c[j];
        }
        cout << t << '\n';
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<iomanip>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1e9+7
#define LINF (long long)4e18



int main(){
   long long X,Y;
   cin >> X >> Y;
   vector<int> A;
   while(X <= Y){
       A.push_back(X);
       X *= 2;
   }
   int ans = A.size();
   cout << ans << endl;

}

Measured memory_bytes: 256
object Main extends App {
	val ab = scala.io.StdIn.readLine.split(" ").map(_.toInt)
	val s = scala.io.StdIn.readLine.toList

	var flag = true
	var temp1 = ab(0)
	var temp2 = ab(1)

	for(i<-s){
		if(i != '-' && flag) temp1 = temp1 - 1
		else if(i != '-' && ! flag) temp2 = temp2 - 1
		else flag = false
	}

	if(temp1 == 0 && temp2 == 0)  println("Yes")
	else println("No")

}


Measured memory_bytes: 27216
import java.io.*;
import java.util.*;

public class Main {
    public static void main(String[] args) throws IOException {
        InputReader in = new InputReader();
        PrintWriter out = new PrintWriter(System.out);
        int test_cases = 1;
        Solver s = new Solver();
        for (int i = 1; i <= test_cases; i++) {
            s.solve(i, in, out);
        }
        out.close();
    }
}

class Solver {
    void solve(int test_number, InputReader in, PrintWriter out) throws IOException {
        int n = in.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < a.length; i++) {
            a[i] = in.nextInt();
        }
        int sp = 0;
        boolean ok = false;
        for (int i = 0; i < n; i++) {
            if (a[i] == i + 1) {
                if (!ok) sp++;
                ok = !ok;
            } else ok = false;
        }
        out.println(sp);
    }
}


class InputReader {
    BufferedReader br;
    StringTokenizer st;

    public InputReader()
    {
        br = new BufferedReader(new
                InputStreamReader(System.in));
    }

    String next()
    {
        while (st == null || !st.hasMoreElements())
        {
            try
            {
                st = new StringTokenizer(br.readLine());
            }
            catch (IOException  e)
            {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    int nextInt()
    {
        return Integer.parseInt(next());
    }

    long nextLong()
    {
        return Long.parseLong(next());
    }

    double nextDouble()
    {
        return Double.parseDouble(next());
    }

    String nextLine()
    {
        String str = "";
        try
        {
            str = br.readLine();
        }
        catch (IOException e)
        {
            e.printStackTrace();
        }
        return str;
    }
}

Measured memory_bytes: 33176
#include "bits/stdc++.h"

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

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

struct Edge { int from; int to; long long weight; };
typedef std::vector<Edge> Edges;
typedef std::vector<Edges> Graph;
typedef std::pair<long long, int> P;

std::vector<long long> dijkstra(const Graph &g, int src) {
	std::vector<long long> d(g.size(), std::numeric_limits<long long>::max()/5);
	d[src] = 0;
	//vector<int> prev(g.size());
	std::priority_queue<P, std::vector<P>, std::greater<P>> q;
	q.push({ 0, src });
	while (!q.empty()) {
		auto p = q.top(); q.pop();
		int v = p.second;
		if (p.first > d[v]) continue;
		for (int i = 0; i < g[v].size(); ++i) {
			Edge e = g[v][i];
			if (d[e.to] > d[v] + e.weight) {
				d[e.to] = d[v] + e.weight;
				q.push({ d[e.to],e.to });
				//prev[e.to] = v;
			}
		}
	}
	return d;
}
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, m, s, a, b;
	while (cin >> n >> m >> s >> a >> b, n) {
		s--; a--; b--;
		Graph g(n), rg(n);
		REP(i, m) {
			int a, b, c;
			cin >> a >> b >> c;
			a--; b--;
			g[a].push_back(Edge{ a,b,c });
			rg[b].push_back(Edge{ b,a,c });
		}
		vl d = dijkstra(g, s), da = dijkstra(rg, a), db = dijkstra(rg, b);
		ll ans = INF * INF;
		REP(i, n) {
			chmin(ans, d[i] + da[i] + db[i]);
		}
		cout << ans << endl;
	}
}


Measured memory_bytes: 3108
n=int(input())
h=list(map(int,input().split()))
D=[10**0 for i in range(n)]

for i in range(n):
    if i==0:
        D[i]=0
    elif i==1:
        D[i]=abs(h[1]-h[0])  
    else:
        D[i]=min(D[i-1]+abs(h[i]-h[i-1]),D[i-2]+abs(h[i]-h[i-2]))
print(D[n-1])

Measured memory_bytes: 52904
import java.util.Scanner;

class Main {
	private static final char ALPHABET_SIZE = 'z' - 'a' + 1;

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

		char[] s = sc.next().toCharArray();
		char[] t = sc.next().toCharArray();

		int[] repS = new int[ALPHABET_SIZE];
		int[] repT = new int[ALPHABET_SIZE];
		for(int i = 0; i < ALPHABET_SIZE; i++) {
			repS[i] = -1;
			repT[i] = -1;
		}

		boolean judge = true;
		for(int i = 0; i < s.length; i++) {
			int si = s[i] - 'a';
			int ti = t[i] - 'a';

			if(repS[si] < 0) {
				repS[si] = ti;
			}
			else {
				if(repS[si] != ti) {
					judge = false;
					break;
				}
			}

			if(repT[ti] < 0) {
				repT[ti] = si;
			}
			else {
				if(repT[ti] != si) {
					judge = false;
					break;
				}
			}
		}

		if(judge) {
			System.out.println("Yes");
		}
		else {
			System.out.println("No");
		}
	}
}


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

using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0;i<(int)(n);i++)

int main(){
    ll x,y,z;
    cin >> x >> y >> z;
    if(x<y&&y<z) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3116
A,B,Q,*I=`dd`.split.map &:to_i
F=1e15
s=[-F]+I[0,A]+[F]
t=[-F]+I[A,B]+[F]
I[-Q,Q].map{|x|
	p s[s.bsearch_index{|y|y>x}-1,2].map{|s|
		t[t.bsearch_index{|y|y>x}-1,2].map{|t|
			[(s-x).abs,(t-x).abs].min+(t-s).abs
		}.min
	}.min
}

Measured memory_bytes: 40956
//code by lynmisakura.wish to be accepted!
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;

int n,m;
vector<int> g[100010];
int used[100010];

vector<int> p_a;
void dfs_1(int x){
    used[x]++;
    p_a.push_back(x);
    for(int i : g[x]){
        // bool check = true;
        if(!used[i]){
            // check = false;
//            cout << i << " " << x << endl;
            dfs_1(i);
            break;
        }
    }
    return;
}
vector<int> p_b;
void dfs_2(int x){
    used[x]++;
    p_b.push_back(x);
    for(int i : g[x]){
        // bool check = true;
        if(!used[i]){
            // check = false;
            dfs_2(i);
            break;
        }
    }
    return;
}

int main(void){
    scanf("%d %d",&n,&m);
    int s,t;
    for (int i = 0; i < m; ++i)
    {
        int a,b;scanf("%d %d",&a,&b);a--,b--;
        if(!i)s=a,t=b;
        g[a].push_back(b);
        g[b].push_back(a);
    }
//    for(auto i : g[1])cout << i << " ";cout << endl;
    used[s]++,used[t]++;
    dfs_1(s);
    dfs_2(t);
    cout << p_a.size() + p_b.size() << endl;
    reverse(p_a.begin(),p_a.end());
    for(auto i : p_a)cout << i+1 << " ";
    for(auto i : p_b)cout << i+1 << " ";
    cout << endl;
}

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

using lli = long long int;

template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

template <class T>ostream &operator<<(ostream &o,const pair<T, T>&p)
{o<<"("<<p.first<<", "<<p.second<<")";return o;}

int main(void){
    lli n, k;
    cin >> n >> k; 
    vector<lli> h(n);
    for(auto& i : h) cin >> i;
    lli c = 0;
    for(auto i : h){
        if(i >= k) c++;
    }
    cout << c << endl;
    return 0;
}


Measured memory_bytes: 1024
///IN THE NAME OF ALLAH
    #include<bits/stdc++.h>
    using namespace std;
    vector<long long>Vec,Primes;
    map<long long,bool>mp;
    int main(){
     int n,m;
     cin >> n >> m;
     if(n==m || n%m==0)
        cout<<-1;
     else cout<<n;
    }


Measured memory_bytes: 256
N,Q = map(int,input().split())
S = '_'+input()+'_'
td = [input().split() for _ in range(Q)]
R = N+1
L = 0
for i in range(Q-1,-1,-1):
    t,d = td[i]
    if t == S[R-1] and d == 'R':
        R -= 1
    elif t == S[R] and d == 'L':
        R += 1
    if t == S[L+1] and d == 'L':
        L += 1
    elif t == S[L] and d == 'R':
        L -= 1
print(max(0,R-L-1))

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

using namespace std;

const int maxn = 2e5+5;

map<string,int> mps;

int main(){
	int n;
	scanf("%d",&n);
	int maxn=-1;
	string s;
	for(int i=0;i<n;i++){
		cin>>s;
		mps[s]++;
		if(mps[s]>maxn){
			maxn=mps[s];
		}
	}
	for(auto a:mps){
		if(a.second==maxn){
			cout<<a.first<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 25216
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(){
	int n,m;
	scanf("%d",&n);
	int t[n];
	for(int i=0;i<n;i++){
		scanf("%d",&t[i]);
	}
	scanf("%d",&m);
	int p,x;
	for(int i=0;i<m;i++){
		int tempo=0;
		scanf("%d %d",&p,&x);
	for(int j=0;j<n;j++){
			if(j+1==p)
				tempo+=x;
			else
				tempo+=t[j];
		}
		printf("%d\n",tempo);
	}

	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define PII pair<int, int>
#define PLL pair<LL, LL>
#define VI vector<int>
#define VPII vector<PII>
#define LL long long
#define LD long double
#define f first
#define s second
#define MP make_pair
#define PB push_back
#define pb pop_back
#define ALL(c) (c).begin(), (c).end()
#define SIZ(c) (int)(c).size()
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, b, e) for(int i = (b); i <= (int)(e); ++i)
#define FORD(i, b, e) for(int i = (b); i >= (int)(e); --i)

#define Sim template<class n
Sim, class s> ostream & operator << (ostream &p, pair<n, s> x)
{return p << "<" << x.f << ", " << x.s << ">";}
Sim> auto operator << (ostream &p, n y) -> 
typename enable_if<!is_same<n, string>::value, decltype(y.begin(), p)>::type 
{int o = 0; p << "{"; for(auto c: y) {if(o++) p << ", "; p << c;} return p << "}";}
void dor() {cerr << endl;}
Sim, class...s> void dor(n p, s...y) {cerr << p << " "; dor(y...);}
Sim, class s> void mini(n &p, s y) {if(p>y) p = y;}
Sim, class s> void maxi(n &p, s y) {if(p<y) p = y;}
#ifdef DEB
#define debug(...) dor(__FUNCTION__, ":", __LINE__, ": ", __VA_ARGS__)
#else
#define debug(...)
#endif 

#define I(x) #x " = ", (x), " "
#define A(a, i) #a "[" #i " = ", i, "] = ", a[i], " "
const int M = 1024;

int n;
int T[M];
map<pair<PII, PII>, LL> mapa;

LL go(PII l, PII r)
{
	if (mapa.count(MP(l, r)))
	{
		return mapa[MP(l, r)];
	}
	if (l.f + 1 == r.f)
	{
		return mapa[MP(l, r)] = 0;
	}
	LL tmp = 1e18;
	FOR(i, l.f + 1, r.f - 1)
	{
		int sum = l.s + r.s;
		mini(tmp, go(l, MP(i, sum)) + go(MP(i, sum), r) + (LL)T[i] * sum);
	}
	return mapa[MP(l, r)] = tmp;
}

int main()
{
	//ios_base::sync_with_stdio(0);
	//cin.tie(NULL);
	scanf("%d", &n);
	FOR(i, 1, n)
	{
		scanf("%d", T + i);
	}
	printf("%lld\n", go(MP(1, 1), MP(n, 1)) + T[1] + T[n]);
	return 0;
}



Measured memory_bytes: 32896
#include<stdio.h>

#define MAX 100

int main()
{
  int i, j, n, u, k, v, M[MAX+1][MAX+1];

  scanf("%d", &n);

  for( i=1; i<=n; i++ )
    {
      for( j=1; j<=n; j++ )
	{
	  M[i][j] = 0;
	}
    }


  for( i=0; i<n; i++ )
    {
      scanf("%d%d", &u, &k);

      for( j=0; j<k; j++ )
	{
	  scanf("%d", &v);
	  M[u][v] = 1;
	}
    }

  for( i=1; i<=n; i++ )
    {
      for( j=1; j<=n; j++ )
	{
	  printf("%d", M[i][j]);
	  if( j == n ) break;
	  printf(" ");
	}
      printf("\n");
    }

  return 0;
}



Measured memory_bytes: 2112
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define i_7 (ll)(1E9+7)
#define i_5 (ll)(1E9+5)
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    else return c+i_7;
}
typedef pair<int,int> i_i;
typedef pair<ll,ll> l_l;
ll inf=(ll)1E12;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll * pos,ll val){*pos=max(*pos,val);}//Max(&dp[i][j],dp[i-1][j]);
void Min(ll * pos,ll val){*pos=min(*pos,val);}
void Add(ll * pos,ll val){*pos=mod(*pos+val);}
const long double EPS=1E-8;
////////////////////////////////////////




int main(){
    ll n;cin>>n;
    ll a[n];rep(i,0,n-1)cin>>a[i];
    ll dp[n];rep(i,0,n-1)dp[i]=inf;
    dp[0]=0;
    rep(i,1,n-1){
        dp[i]=(dp[i-1]+abs(a[i]-a[i-1]));
        if(i>=2)Min(&dp[i],dp[i-2]+abs(a[i]-a[i-2]));
    }
    cout<<dp[n-1]<<endl;
    
    return 0;
}




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

const int maxN = 3e5 + 10;

int n;
int a[maxN];
long long low[maxN], high[maxN];

void Enter() {
    scanf("%d", &n);
    for (int i = 1; i <= 3 * n; ++i) scanf("%d", &a[i]);
}

void getHigh() {
    priority_queue <int, vector <int>, greater <int> > q;
    for (int i = 1; i <= n; ++i) {
        q.push(a[i]);
        high[n] += a[i];
    }
    for (int i = n + 1; i <= 3 * n; ++i) {
        if (q.top() < a[i]) {
            high[i] = high[i - 1] + a[i] - q.top();
            q.pop(); q.push(a[i]);
        } else
            high[i] = high[i - 1];
    }
}

void getLow() {
    priority_queue <int> q;
    for (int i = 3 * n; i > 2 * n; --i) {
        low[i] = low[i + 1] + a[i];
        q.push(a[i]);
    }
    for (int i = 2 * n; i > 0; --i) {
        if (q.top() > a[i]) {
            low[i] = low[i + 1] - q.top() + a[i];
            q.pop(); q.push(a[i]);
        } else
            low[i] = low[i + 1];
    }
}

void Init() {
    getLow();
    getHigh();
}

void Process() {
    long long ans = -1e18;
    for (int i = n; i <= 2 * n; ++i)
        ans = max(ans, high[i] - low[i + 1]);
    printf("%lld\n", ans);
}

int main() {
//    freopen("input.in", "r", stdin);
 //   freopen("output.out", "w", stdout);

    Enter();
    Init();
    Process();

    return 0;
}


Measured memory_bytes: 6260
#include <bits/stdc++.h>
#include <functional>
#include <iostream>
#define ALL(v) v.begin(), v.end()
#define MAX 510000
#define rrep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define dcout cout<<fixed<<setprecision(15);

using namespace std;
typedef long long int  ll;
typedef pair<ll, ll> P;

constexpr int MOD = 1e9 + 7;
constexpr ll inf = 1LL << 60;

//lcm//
ll gcd(ll x, ll y) {
	if (x == 0) return y;
	return gcd(y%x, x);
}
ll lcm(ll x, ll y) { return x * y / gcd(x, y); }

//a^n mod p//
ll modpow(ll a, ll n, ll p) {
  if (n == 1) return a % p;
  if (n % 2 == 1) return (a * modpow(a, n - 1, p)) % p;
  ll t = modpow(a, n / 2, p);
  return (t * t) % p;
}

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

//Cmonp//
ll fac[MAX], finv[MAX], inv[MAX];
// 
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 
ll COM(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

//LARGE n
ll com(ll n,ll m){
    if(n<m || n<=0 ||m<0){
		return 0;
	}
	if( m==0 || n==m){
		return 1;
	}
	ll k=1;
	for(ll i=1;i<=m;i++){
       k*=(n-i+1); 
	   k%=MOD;
	   k*=modinv(i,MOD);
	   k%=MOD;
	}
	return k;
}

//radP
ll rad(ll u, ll p){
ll cnt=0;
	while(u%p==0){
		u/=p;
		cnt++;
	}
	return cnt;
}


////////////////////////////////////////////////////////////////////


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

ll h[n+1];
rep(i,n){
	cin>>h[i];
}

vector<ll> vec[n+1]{};
rep(i,m){
	ll a,b;
	cin>>a>>b;
	vec[a].push_back(b);
	vec[b].push_back(a);
}

ll ans=0;
rep(i, n){
	ll cn=1;
for(int j=0;j<vec[i].size();j++){
	if(h[i]<=h[vec[i][j]]){
		cn=0;
		break;
	}
}
if(cn) ans++;
}

cout<<ans<<endl;
return 0;



}






Measured memory_bytes: 10236
using System;
using System.Linq;
using CompLib.Util;

public class Program
{
    int N;
    int[] A;

    bool[,,] F;
    double[,,] Memo;

    public void Solve()
    {
        var sc = new Scanner();
        N = sc.NextInt();
        A = sc.IntArray();

        int[] cnt = new int[4];
        for (int i = 0; i < N; i++)
        {
            cnt[A[i]]++;
        }

        F = new bool[N + 1, N + 1, N + 1];
        Memo = new double[N + 1, N + 1, N + 1];

        Console.WriteLine(Go(cnt[1], cnt[2], cnt[3]));
    }

    double Go(int cnt1, int cnt2, int cnt3)
    {
        ref double ans = ref Memo[cnt1, cnt2, cnt3];
        if (F[cnt1, cnt2, cnt3]) return ans;
        if (cnt1 == 0 && cnt2 == 0 && cnt3 == 0) return 0;
        int sum = cnt1 + cnt2 + cnt3;
        double p = (double)N / sum;
        if (cnt1 > 0)
        {
            ans += (Go(cnt1 - 1, cnt2, cnt3) + p) * cnt1 / sum;
        }

        if (cnt2 > 0)
        {
            ans += (Go(cnt1 + 1, cnt2 - 1, cnt3) + p) * cnt2 / sum;
        }

        if (cnt3 > 0)
        {
            ans += (Go(cnt1, cnt2 + 1, cnt3 - 1) + p) * cnt3 / sum;
        }
        F[cnt1, cnt2, cnt3] = true;
        return ans;
    }

    public static void Main(string[] args) => new Program().Solve();
    // public static void Main(string[] args) => new Thread(new Program().Solve, 1 << 27).Start();
}

namespace CompLib.Util
{
    using System;
    using System.Linq;

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            if (_index >= _line.Length)
            {
                string s;
                do
                {
                    s = Console.ReadLine();
                } while (s.Length == 0);

                _line = s.Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public string ReadLine()
        {
            _index = _line.Length;
            return Console.ReadLine();
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            string s = Console.ReadLine();
            _line = s.Length == 0 ? new string[0] : s.Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}


Measured memory_bytes: 150700
#include<bits/stdc++.h>
using namespace std;
struct happiness{
 int a,b,c;
};
int maxHappi(happiness arr[],int n){
 int dp[n+1][4]={0};
 dp[1][1] = arr[1].a;
 dp[1][2] = arr[1].b;
 dp[1][3] = arr[1].c;
 for(int i=2;i<=n;i++){
    dp[i][1] = arr[i].a + max(dp[i-1][2],dp[i-1][3]);
    dp[i][2] = arr[i].b + max(dp[i-1][1],dp[i-1][3]);
    dp[i][3] = arr[i].c + max(dp[i-1][1],dp[i-1][2]);
 }
 return max(dp[n][1],max(dp[n][2],dp[n][3]));
}
int main(){
 int n;
 cin>>n;
 happiness arr[n+1];
 for(int i=1;i<=n;i++){
    int a1,b1,c1;
    cin>>a1>>b1>>c1;
    arr[i].a = a1;
    arr[i].b = b1;
    arr[i].c = c1;
 }
 cout<<maxHappi(arr,n);
}


Measured memory_bytes: 2944
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;

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

void resolve() {
    string s;
    cin >> s;
    if ((s[0] == s[1] || s[2] == s[3]) && s[1] == s[2]) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define ull unsigned long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define _h cout<<"here"<<endl;
#define fill(a,v) memset(a,v,sizeof(a));
#define all(v) v.begin(),v.end()
#define rep(i,n) for(int i=0;i<n;i+=1)
#define prd(a,n) rep(i,n) cout<<a[i]<<" \n"[i==n-1];// printf("%s\n"," " );
#define ff first
#define ss second
#define pu push_back
const int inf = 1e9+10;
const ll INF = 2e18+10;
const int Mod = 1e9+7;
const int MAXN = 1000010;
const int N=3e3+10;
const int M=210;
const int M1=1e9+7;
const int M2=1e9+9;
const int base=131;
ll dp[N][N][4];
ll val[N][N];
int main()
{
  ios::sync_with_stdio(0), cin.tie(0); cout.tie(0);
  // freopen("input.txt","r",stdin);
  // freopen("output.txt","w",stdout);
  int r,c,k;
  cin>>r>>c>>k;
  for(int i=1;i<=k;i++)
  {
    int x,y,v;
    cin>>x>>y>>v;
    val[x][y]=v;
  }
  for(int i=1;i<=r;i++)
  {
    for(int j=1;j<=c;j++)
    {
      ll top=0;
      for(int k=0;k<4;k++)
      {
        top=max(top,dp[i-1][j][k]);
        dp[i][j][k]=max(dp[i][j][k],dp[i][j-1][k]);
      }
      dp[i][j][0]=max(top,dp[i][j][0]);
      if(val[i][j]>0)
      {
        dp[i][j][1]=max(dp[i][j][1],top+val[i][j]);
        for(int k=1;k<4;k++)
        {
          dp[i][j][k]=max(dp[i][j][k],val[i][j]+dp[i][j-1][k-1]);
        }
      }
    }
  }
  ll ans=0;
  for(int k=0;k<4;k++)
  {
    ans=max(ans,dp[r][c][k]);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 356252
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

int main() {
    ll n, k;
    cin >> n >> k;

    vl d(k);
    rep(i, k) {
        cin >> d[i];
    }

    for(ll x = n; ; x++) {
        string s = to_string(x);
        ll ok = 1;
        rep(i, s.size()) {
            ll a = s[i] - '0';
            rep(j, k) {
                if(a == d[j]) {
                    ok = 0;
                    break;
                }
            }
            if(!ok) {
                break;
            }
        }
        if(ok) {
            out(x);
            re0;
        }
    }

    re0;
}

Measured memory_bytes: 256
l = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

k = int(input()) - 1

print(l[k])

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

int main() {
  int N;
  cin>>N;
  vector<int64_t>p(N+1);
  for(int i=0;i<N;i++){
    int64_t a;
    cin>>a;
    if(i==0){
      p.at(i)=a;
    }
    else{
    p.at(i)=p.at(i-1)+a;
    }
  }
  p.at(N)=0;
  sort(p.begin(), p.end());
  int64_t Z=0,a=1;
  for(int i=1;i<=N;i++){
    if(p.at(i)==p.at(i-1)){
      a++;
    }
    else{
      Z+=a*(a-1)/2;
        a=1;
    }
  }
  Z+=a*(a-1)/2;
  cout<<Z<<endl;
}

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

using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() //sortなどの引数を省略したい
#define SIZE(x) ll(x.size()) //sizeをsize_tからllに直しておく
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB emplace_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define Umap unordered_map
#define Uset unordered_set

int main(){
    ll n, m;
    cin >> n >> m;
    vector<ll> a(n), b(n);
    REP(i, n) cin >> a[i] >> b[i];
    vector<vector<ll>> score(MAXR+1);
    priority_queue<ll> score_all;
    REP(i, n) score[a[i]].PB(b[i]);
    ll ans = 0;
    REP(i, m){
        while(!score[i+1].empty()){
            score_all.push(score[i+1].back());
            score[i+1].pop_back();
        }
        if(score_all.empty()) continue;
        ans += score_all.top();
        score_all.pop();
    }
    cout << ans;
    return 0;
}

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

int main() {
  int x, y, z;
  cin >> x >> y >> z;

  printf("%d %d %d", z, x, y);
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
double ans=0;
int fact(int n){
    int f=1;
    for(int i=1;i<=n;i++)
        f=f*i;
    return f;
}
void per(string s,int l,int r,vector<pair<double,double>> v){
    //cout<<v[0].first<<" "<<v[0].second;
    if(l==r){
        for(int i=1;i<s.length();i++){
            int temp=s[i]-'1';
            int temp1=s[i-1]-'1';
            ans+=sqrt(pow((v[temp].first-v[temp1].first),2) + pow((v[temp].second-v[temp1].second),2));
        }
    }
    else
	{ 
		for (int i = l; i <= r; i++) 
		{ 
			swap(s[l], s[i]); 
			per(s, l+1, r,v); 
			swap(s[l], s[i]); 
		} 
	} 
}

int main()
{
    int n;
    cin>>n;
    vector<pair<double,double>> v(n);
    string s="12345678";
    s.resize(n);
    for(int i=0;i<n;i++){
        int x,y;
        cin>>x>>y;
        v[i].first=x;
        v[i].second=y;
    }
    per(s,0,n-1,v);
    cout<<setprecision(12)<<ans/fact(n);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
 
using namespace std;
using namespace __gnu_pbds;

#define debug(s) cout << #s << " = " << s << endl
#define all(v) (v).begin(), (v).end()
#define mem(a,val) memset(a, val, sizeof a)
 
#define PI acos(-1.0)
#define ff first
#define ss second
typedef long long ll;

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

int main() {
  int a, b, h, m;
  scanf("%d %d %d %d", &a, &b, &h, &m);
  double angh = (h * 60 + m) * .5;
  double angm = m * 6;
  double ang = fabs(angh - angm) * PI/ 180.;
  double cc = a*a + b*b - 2*a*b*cos(ang);  
  double c = sqrt(cc);
  printf("%.15lf\n", c);
}


Measured memory_bytes: 4192
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define ALL(a) a.begin(), a.end()
ll dx[4] = { 0, 1, 0, -1 };
ll dy[4] = { 1, 0, -1, 0 };
const ll INF = 1e14;
const ll MOD = 1e9 + 7;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    // input
    ll n;
    cin >> n;
    vector<ll> a(n + 1), b(n);
    ll sum = 0; // Aの合計
    rep(i, n + 1)
    {
        cin >> a[i];
        sum += a[i];
    }
    rep(i, n)
    {
        cin >> b[i];
    }
    // output
    ll sub = 0;
    // Aからできるだけ引く
    for (int i = 0; i < n; i++) {
        if (a[i] - b[i] < 0) {
            b[i] -= a[i];
            a[i] = 0;
            if (a[i + 1] - b[i] < 0) {
                b[i] -= a[i + 1];
                a[i + 1] = 0;
            } else {
                a[i + 1] -= b[i];
                b[i] = 0;
            }
        } else {
            a[i] -= b[i];
            b[i] = 0;
        }
    }
    rep(i, n+1) {
        sub += a[i];
    }
    cout << sum - sub << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define all(v) (v).begin(), (v).end()
#define INF 1e9
#define pb push_back
using namespace std;
typedef long long ll;
using pii = pair<ll, ll>;

int main() {
    string S;
    cin >> S;
    if(S.find("7") == string::npos) {
        cout << "No" << endl;
    }else cout << "Yes" << endl;
    
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int d;
    scanf("%d",&d);
    if(d==24)
        printf("Christmas Eve\n");
    else if(d==23)
        printf("Christmas Eve Eve\n");
    else if(d==22)
        printf("Christmas Eve Eve Eve\n");
    else printf("Christmas\n");
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
int main()
{
    int R;
    cin >> R;

    cout << (2 * M_PI * R) << endl;

    return 0;    
}

Measured memory_bytes: 3772
// In the name of GOD
#include<bits/stdc++.h>
using namespace std;

#define debug(x) cout<<#x<<" :: "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n";

#define     IOS         ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define 	setprecn(x) cout<<fixed<<setprecision(x);
#define 	ll          long long int
#define 	pb          push_back
#define 	pll         pair<ll,ll>
#define 	vll         vector<ll>
#define 	ff          first
#define 	ss          second
#define 	all(a)      (a).begin(),(a).end()
#define 	sz(x)       (ll)x.size()
#define 	mod         1000000007
#define 	inf         10000000000000007
#define 	rep(i,n)    for(ll i=0;i<n;i++)
#define 	repe(i,a,b) for(ll i=a;i<b;i++)
#define 	lbnd        lower_bound
#define 	ubnd        upper_bound
#define 	bs          binary_search

ll power(ll a,ll b,ll m=mod)
{
	if(b==0)
		return 1;
	if(b==1)
		return a;
	ll c=power(a,b/2,m);
	if(b%2==0)
		return((c%m)*(c%m))%m;
	return ((((c%m)*(c%m))%m)*(a%m))%m;
}
/********************************************************/
//	d.erase(unique(all(d)), d.end());



int main()
{
	IOS;
	ll n,k,m,i,j,c=0,cs=0,t;
	t=1;

	// cin>>t;
	string s;
	while(t--)
	{
		cin>>n>>m;
		// n=s.length();
		ll a[m];
		// double q=n*6.28318530717958623200;
		// setprecn(20);
		rep(i,m) {cin>>j;c+=j;}
		if(c>n) c=-1;
		else c=n-c;
		cout<<c;

		
		cout<<"\n";
	}
	return 0;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
using LL = long long; using PII = pair<LL, LL>; using VI = vector<LL>; using VVI = vector<VI>;
using VB = vector<bool>; using VS = vector<string>; using VP = vector<PII>;
#define VV(T)        vector<vector<T>>
#define PB           push_back
#define MP           make_pair
#define SZ(a)        LL((a).size())
#define EACH(x, c)   for (auto x : (c))
#define ALL(c)       (c).begin(), (c).end()
#define REVERSE(c)   reverse(ALL(c))
#define SORT(c)      stable_sort(ALL(c))
#define RSORT(c)     stable_sort((c).rbegin(), (c).rend())
#define FOR(i, a, b) for (LL i = (a); i < (b); ++i)
#define REP(i, n)    FOR(i, 0, n)
#define $(x)         {cout << #x << " = " << (x) << endl;}

class UnionFind {
public:
    VI parent;
    UnionFind(LL N) : parent(N) {
        iota(ALL(parent), 0);   // 初期化(親==自分)
    }
    LL getRoot(LL x) {   // 根に到達するまで親を辿る
        if (parent[x] == x) return x;   // 根は親==自分
        return parent[x] = getRoot(parent[x]);   // 経路圧縮(辿った要素を全て根に直結させる)
    }
    bool inSameSet(LL x, LL y) {   // 根が同じなら同じ集合に属する
        return getRoot(x) == getRoot(y);
    }
    void unite(LL x, LL y) {   // 同値関係 x~y を追加(xが属する集合とyが属する集合をマージ)
        x = getRoot(x);
        y = getRoot(y);
        if (x == y) return;   // すでに同じ集合
        parent[x] = y;
    }
};


void solve(LL N, LL M, vector<LL> p, vector<LL> x, vector<LL> y){
    UnionFind uf(N + 1);   // N は要素数、1-indexの場合は N + 1 にする
    REP(i, M) {
        uf.unite(x[i], y[i]);   // マージ
    }
    map<LL, set<LL>> ccs;
    FOR(i, 1, N + 1) {   // 1-indexの場合は FOR(i, 1, N + 1) にする
        /* uf.getRoot(i) が i の属する集合の根 */
        ccs[uf.getRoot(i)].insert(i);
    }
    LL ans = 0;
    EACH(cc, ccs) {
        set<LL> values;
        EACH(m, cc.second) {
            values.insert(p[m - 1]);
        }
        LL count = 0;
        EACH(value, values) {
            if (cc.second.count(value) != 0) {
                count++;
            }
        }
        ans += count;
    }
    cout << ans << endl;
}

int main(){
    LL N;
    scanf("%lld",&N);
    LL M;
    scanf("%lld",&M);
    vector<LL> p(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&p[i]);
    }
    vector<LL> x(M);
    vector<LL> y(M);
    for(int i = 0 ; i < M ; i++){
        scanf("%lld",&x[i]);
        scanf("%lld",&y[i]);
    }
    solve(N, M, move(p), move(x), move(y));
    return 0;
}


Measured memory_bytes: 17408
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>
#include<stack>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<string> vstring;
typedef vector<pint> vpint;
typedef stringstream SS;

template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }

#define rep(i,n) for(int i=0;i<(n);++i)
#define repn(i,m,n) for(int i=(m);i<(n);++i)
#define repd(i,n) for(int i=(n)-1;i>=0;--i)
#define repnd(i,m,n) for(int i=(n)-1;i>=(m);--i)
#define rep0(i,n) for(i=0;i<(n);++i)
#define repn0(i,m,n) for(i=(m);i<(n);++i)
#define repd0(i,n) for(i=(n)-1;i>=0;--i)
#define repnd0(i,m,n) for(i=(n)-1;i>=(m);--i)
#define repc(i,n) for(int i=0;i<=(n);++i)
#define repcn(i,m,n) for(int i=(m);i<=(n);++i)
#define repcd(i,n) for(int i=(n);i>=0;--i)
#define repcnd(i,m,n) for(int i=(n);i>=(m);--i)
#define repc0(i,n) for(i=0;i<=(n);++i)
#define repcn0(i,m,n) for(i=(m);i<=(n);++i)
#define repcd0(i,n) for(i=(n);i>=0;--i)
#define repcnd0(i,m,n) for(i=(n);i>=(m);--i)
#define all(n) n.begin(),n.end()
#define sz(n) ((int)(n).size())
#define IL for(;;)
#define MP make_pair
#define PB push_back
#define X second
#define Y first
#define p_queue(n) priority_queue<n,vector<n>,greater<n> >
#define PUTLINE cout<<"LINE:"<<__LINE__<<endl;

const int INF = 2147483647/3;
const double EPS = 1e-10;
const double PI = acos(-1.0);

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



int main() {
	int n;
	IL{
		cin>>n;
		if(n==0)break;
		int p,d1,d2;
		int r,dis=0;
		rep(i,n){
			cin>>p>>d1>>d2;
			if(d1+d2>dis){
				r=p;
				dis=d1+d2;
			}
		}
		cout<<r<<" "<<dis<<endl;
	}
	return 0;
}

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

int main(){
    char S[16];
    cin >> S;
    int win=0;
    for(int i=0; i<15; i++){
        if (S[i]=='o') win++;
        else if (S[i]!='x'){
            win += 15-i;
            break;
        }
    }
    if (win >= 8) cout << "YES";
    else cout << "NO";
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string>
#include <tuple>
#include <vector>
#include <map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <cassert>
using namespace std;
#define LL long long
#define MP(a, b) make_pair(a, b)
#define MMP(a, b, c) make_pair(make_pair(a, b), c)
#define MAX 1000000000
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647
#define LL_MIN -9223372036854775808
#define LL_MAX 9223372036854775807
#define PI 3.14159265359

#include <boost/multiprecision/cpp_int.hpp>
namespace boost_multiprecision = boost::multiprecision;
#define CINT boost_multiprecision::cpp_int

int main(){
    iostream::sync_with_stdio(false);
    
    int N, K;
    cin >> N >> K;
    int wa = 1;
    int ans = 1;
    N--;
    int tmp = 1;
    while(N >= tmp){
        if((double)wa/tmp <= K){
            wa += tmp;
            N -= tmp;
            ans++;
        }
        else{
            if(tmp > 0) tmp++;
            else break;
        }
    }
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 3124
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#include <functional>
#include <queue>
#include <map>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
const int INF = 100000000;

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

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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<pll> vpl;
typedef vector<vll> vvll;

#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define yes cout<<"Yes"<<endl
#define YES cout<<"YES"<<endl
#define no cout<<"No"<<endl
#define NO cout<<"NO"<<endl
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

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

  ll n,m;
  cin>>n>>m;
  vpl p(m);
  REP(i,m)cin>>p[i].FI>>p[i].SE;

  sort(ALL(p));

  ll cnt=0;
  ll e=LLINF;
  ll ans=0;
  REP(i,m){
    if(e<=p[i].FI){
      ans++;
      e=p[i].SE;
    }
    else
      e=min(e,p[i].SE);
  }
  ans++;

  cout<<ans<<endl;
}



Measured memory_bytes: 4760