akhauriyash/Code-Regression huggingface dataset:
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};
#[allow(unused_imports)]
use std::iter::FromIterator;
mod util {
    use std::fmt::Debug;
    use std::io::{stdin, stdout, BufWriter, StdoutLock};
    use std::str::FromStr;
    #[allow(dead_code)]
    pub fn line() -> String {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.trim().to_string()
    }
    #[allow(dead_code)]
    pub fn chars() -> Vec<char> {
        line().chars().collect()
    }
    #[allow(dead_code)]
    pub fn gets<T: FromStr>() -> Vec<T>
    where
        <T as FromStr>::Err: Debug,
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.split_whitespace()
            .map(|t| t.parse().unwrap())
            .collect()
    }
    #[allow(dead_code)]
    pub fn with_bufwriter<F: FnOnce(BufWriter<StdoutLock>) -> ()>(f: F) {
        let out = stdout();
        let writer = BufWriter::new(out.lock());
        f(writer)
    }
}
#[allow(unused_macros)]
macro_rules ! get { ( [ $ t : ty ] ) => { { let mut line : String = String :: new ( ) ; stdin ( ) . read_line ( & mut line ) . unwrap ( ) ; line . split_whitespace ( ) . map ( | t | t . parse ::<$ t > ( ) . unwrap ( ) ) . collect ::< Vec < _ >> ( ) } } ; ( [ $ t : ty ] ; $ n : expr ) => { ( 0 ..$ n ) . map ( | _ | get ! ( [ $ t ] ) ) . collect ::< Vec < _ >> ( ) } ; ( $ t : ty ) => { { let mut line : String = String :: new ( ) ; stdin ( ) . read_line ( & mut line ) . unwrap ( ) ; line . trim ( ) . parse ::<$ t > ( ) . unwrap ( ) } } ; ( $ ( $ t : ty ) ,* ) => { { let mut line : String = String :: new ( ) ; stdin ( ) . read_line ( & mut line ) . unwrap ( ) ; let mut iter = line . split_whitespace ( ) ; ( $ ( iter . next ( ) . unwrap ( ) . parse ::<$ t > ( ) . unwrap ( ) , ) * ) } } ; ( $ t : ty ; $ n : expr ) => { ( 0 ..$ n ) . map ( | _ | get ! ( $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ ( $ t : ty ) ,*; $ n : expr ) => { ( 0 ..$ n ) . map ( | _ | get ! ( $ ( $ t ) ,* ) ) . collect ::< Vec < _ >> ( ) } ; }
#[allow(unused_macros)]
macro_rules ! debug { ( $ ( $ a : expr ) ,* ) => { eprintln ! ( concat ! ( $ ( stringify ! ( $ a ) , " = {:?}, " ) ,* ) , $ ( $ a ) ,* ) ; } }
const BIG_STACK_SIZE: bool = true;
#[allow(dead_code)]
fn main() {
    use std::thread;
    if BIG_STACK_SIZE {
        thread::Builder::new()
            .stack_size(32 * 1024 * 1024)
            .name("solve".into())
            .spawn(solve)
            .unwrap()
            .join()
            .unwrap();
    } else {
        solve();
    }
}

fn solve() {
    let n = get!(usize);
    let (t, a) = get!(f64, f64);
    let hs = get!([f64]);
    let mut min = std::f64::MAX;
    let mut mini:usize = 0;

    for i in 0..n {
        let tmp = (t - hs[i] * 0.006) - a;
        if tmp.abs() < min {
            min = tmp.abs();
            mini = i;
        }
    }

    println!("{}", mini + 1);
}


Measured memory_bytes: 8572
function main(lines) {
  const N = lines[0];
  const a = lines[1].split(' ').map(BigInt);

  if (a.includes(BigInt(0))) return console.log(0);
  let res = BigInt(1);
  for (let i = 0; i < N; i++) {
    res *= a[i];
    if (res > BigInt(10) ** BigInt(18)) {
      res = BigInt(-1);
      break;
    }
  }

  console.log(res.toString());
}


main( require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n") );



function splitN(s) {
  return s.split(' ').map(Number);
}

Measured memory_bytes: 43756
#include <iostream>
#include <algorithm>
#include <cmath>
#include <set>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define for(i, a, b) for(ll (i)=a;(i)<(b);++(i))
#define rep(i, n)    for(i, 0, n)
#define sz(x)        ((ll)(x).size())
#define inf          1<<25

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

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

ll memo[100];

ll calc(int n) {
    if (memo[n] != 0) return memo[n];
    memo[n] = calc(n-1) + calc(n-2);
    return memo[n];
}

int main() {
    int n;
    cin >> n;
    
    memo[0] = 2;
    memo[1] = 1;
    cout << calc(n) << endl;
    
    return 0;
}

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

ll powfive(int x){
    ll a=1;
    rep(i,x){
        a*=5;
    }
    return a;
}

int main(){
   ll n;cin>>n;
   if(n%2==1){
       cout<<0<<endl;
       return 0;
   }
   ll ans=0;
   for(int i=1;i<=27;++i){
       ans+=n/(2*powfive(i));
   }
   cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>

long long N;
int digits[20];
int szDigits;
int count;
bool isExist[4];

int main()
{
	scanf("%lld", &N);
	
	count = 0;
	szDigits = 0;
	long long curNum = 0;
	memset(digits, 0, sizeof(digits));
	
	while (curNum <= N)
	{
		isExist[1] = false;
		isExist[2] = false;
		isExist[3] = false;
		digits[0]++;
		int pDigits = 0;
		while (digits[pDigits] == 4)
		{
			digits[pDigits] = 1;
			pDigits++;
			digits[pDigits]++;
		}
		
		curNum = 0;
		for (int i = 10 ; i >= 0 ; i--)
		{
			isExist[digits[i]] = true;
			switch (digits[i])
			{
			case 1:	//3
				curNum = curNum * 10 + 3;
				break;
			case 2:	//5
				curNum = curNum * 10 + 5;
				break;
			case 3:	//7
				curNum = curNum * 10 + 7;
				break;
			}
		}
		
		if (curNum <= N && isExist[1] == true && isExist[2] == true && isExist[3] == true)
		{
//			printf("%d\n", curNum);
			count++;
		}
	}
	
	printf("%d\n", count);
		
	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
#include<stdlib.h>

#define MAX 20000

void push1( int x );
int pop1();
void push2( int x );
int pop2();
void push3( int x );
int pop3();

int top1=0,top2=0,top3=0;
int S1[MAX];
int S2[MAX];
int S3[MAX];

int main( void ){
	
	int i = 0;
	int j;
	char s[MAX];
	int total = 0;
	int ans = 0;
	
	scanf("%s",s);
	
	while( s[i]=='\\' || s[i]=='/' || s[i]=='_' ){
		
		if( s[i] == '\\' ){
			push1(i);
		}else if( ( s[i] == '/' ) && ( top1 != 0 ) ){
			j = pop1();
			total = i - j;
			ans += total;
			
			while( ( top2 != 0 ) && ( j <= S2[top2] ) ){
				
				pop2();
				total+=pop3();
			}
			
			push2(j);
			push3(total);
		}
		
		i++;
	}
	
	printf( "%d\n" , ans );
	printf( "%d" , top3 );
	
	for( i = 1; top3 != 0 ; i++ ){
		
		pop3();
		printf( " %d" , S3[i] );
		
	}
	
	printf( "\n" );
	
	return 0;
}

void push1( int x ){
	top1++;
	S1[top1] = x;
}

int pop1(){
	top1--;
	return S1[top1+1];
}
	
void push2( int x ){
	top2++;
	S2[top2] = x;
}

int pop2(){
	top2--;
	return S2[top2+1];	
}
	
void push3( int x ){
	top3++;
	S3[top3] = x;
}

int pop3(){
	top3--;
	return S3[top3+1];
}



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

int main() {
	int A, B, C, K;
	cin >> A >> B >> C;
	cin >> K;
	int i = 0;// 魔術を使う回数
	while (A >= B) {
		B *= 2;
		i++;
	}

	while (B >= C) {
		C *= 2;
		i++;
	}

	if (i <= K) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}

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

using namespace std;

typedef long long ll;
const ll maxS=1e6+5;
ll bit[maxS][64];
vector<ll> v;
bool flg[maxS];
void toBinary()
{
        for(int i=0;i<v.size();i++)
        {
                ll x=v[i];
                ll j=63;
                while(x>0)
                {
                        bit[i][j--]=x%2;
                        x/=2;
                }
        }
}
int main()
{
    
        ll n,k;
        cin>>n>>k;
        ll a[n+1],pre[n+1]={0};
        memset(bit,0,sizeof(bit));
        memset(flg,true,sizeof(flg));
        for(int i=1;i<=n;i++)
        {
                cin>>a[i];
                pre[i]=pre[i-1]+a[i];
        }
        for(int i=1;i<=n;i++)
        {
                for(int j=i;j<=n;j++)
                {
                        v.push_back(pre[j]-pre[i-1]);
                }
        }
        toBinary();
        ll ans=0;
        /*for(int i=0;i<v.size();i++)
        {
                cout<<v[i]<<" ";
                for(int j=0;j<=31;j++)
                        cout<<bit[i][j];
                cout<<endl;
        }*/
        for(int i=0;i<=63;i++)
        {
                ll cnt=0;
                for(int j=0;j<v.size();j++)
                {
                        if(bit[j][i]==1 && flg[j]==true) cnt++;
                }
                if(cnt>=k)
                {
                        for(int j=0;j<v.size();j++)
                        {
                                if(bit[j][i]==0) flg[j]=false;
                        }
                        ans+=(ll)pow(2,63-i);
                }
        }
        cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 507376
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <sstream>
#include <string>

#define rep(x,to) for(int x=0;x<to;x++)
#define rep2(x,from,to) for(int x=from;x<to;x++)

using namespace std;

void RepStr(string& str, const string& from, const string& to){
   string::size_type pos = 0;
 
  while(pos = str.find(from, pos), pos != string::npos) {
     str.replace(pos, from.length( ), to);
     pos += to.length();
   }
}


int main(void){

string bun,wk;
vector<string> bun2;
	getline(cin, bun );	

	stringstream buf(bun);
	while(buf >> wk){
		int i=0;
		bun2.push_back(wk);
	}	

	wk =bun;
	RepStr(wk,"apple","AAPLL");
	RepStr(wk,"peach","apple");
	RepStr(wk,"AAPLL","peach");
	cout << wk << endl;
	return 0;
	
	
}

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

typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;
#define MP make_pair
#define PB push_back
#define X first
#define Y second

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define ITER(it, a) for(__typeof(a.begin()) it = a.begin(); it != a.end(); ++it)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())
#define FILL(a, value) memset(a, value, sizeof(a))
#define debug(a) cerr << #a << " = " << a << endl;

const double PI = acos(-1.0);
const LL INF = 1e9;
const LL LINF = INF * INF;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//freopen("In.txt", "r", stdin);
	//freopen("Out.txt", "w", stdout);

	string s;
	cin >> s;
	
	string d[] = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
	int id = 0;
	FOR(i, 0, 7) if (d[i] == s) id = i;
	cout << 7 - id << endl;
	cerr << "Time elapsed: " << clock() / (double)CLOCKS_PER_SEC << endl;
	return 0;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
char a[1111][1111];
int x[8]= {1,1,0,-1,-1,-1,0,1};
int y[8]= {0,-1,-1,-1,0,1,1,1},n=0,m=0; 
int main() {
	cin>>n>>m;
	for(int i=1; i<=n; i++) {
		for(int j=1; j<=m; j++) {
			cin>>a[i][j];
		}
	}
	for(int i=1; i<=n; i++) {
		for(int j=1; j<=m; j++) {
			if(a[i][j]=='#') {
				cout<<'#';
			} else {
				int ans=0;
				for(int m=0; m<8; m++) {
					if(a[i][j]!='.') {
						continue;
					}
					if(a[i+x[m]][j+y[m]]=='#') {
						ans++;
					}
				}
				cout<<ans;
			}
		}
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	final boolean DEBUG = false;

	void run() {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		Tree tree = new Tree();
		for (int i = 0; i < n; i++) {
			String inst = scan.next();
			int key;

			switch(inst) {
			case "insert":
				key = scan.nextInt();
				if (DEBUG)
					System.out.println("insert: " + key);
				tree.insert(new Node(key));
				break;
			case "find":
				key = scan.nextInt();
				if (DEBUG)
					System.out.println("insert: " + key);
				System.out.println(tree.find(key) ? "yes" : "no");
				break;
			case "print":
				if (DEBUG)
					System.out.println("print");
				tree.print();
				break;
			}
		}
	}
	public static void main(String[] args) {
		new Main().run();
	}
}

class Tree {
	Node root;

	void insert(Node node) {
		Node parent = null;
		Node child = this.root;
		while (child != null) {
			parent = child;
			if (node.key < child.key) child = child.left;
			else					  child = child.right;
		}
		node.parent = parent;

		if(parent == null)		   		this.root    = node;
		else if (node.key < parent.key) parent.left  = node;
		else					   		parent.right = node;
	}

	boolean find(int key) {
		Node node = this.root;
		while (node != null) {
			if (key == node.key) return true;
			if (key < node.key) node = node.left;
			else 				node = node.right;
		}
		return false;
	}

	void print() {
		this.inorder(this.root);
		System.out.println();
		this.preorder(this.root);
		System.out.println();
	}

	void preorder(Node node) {
		if (node == null) return;
		System.out.print(" " + node.key);
		this.preorder(node.left);
		this.preorder(node.right);
	}
	void inorder(Node node) {
		if (node == null) return;
		this.inorder(node.left);
		System.out.print(" " + node.key);
		this.inorder(node.right);
	}
}

class Node {
	int key;
	Node parent, left, right;
	Node(int key) {
		this.key = key;
	}
}


Measured memory_bytes: 212440
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.TreeSet;

class Main {
	public static void main(String args[]) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		Solver solver = new Solver();
		solver.init();
		solver.readHead(in.readLine());
		for (; solver.hasNext();) {
			solver.readBody(in.readLine());
		}
		solver.solve();
	}
}

class Solver {
	int N;
	int cnt;

	public void init() {
		N = 0;
		cnt = 0;
	}

	String S;

	public void readHead(String str) {
		String[] strArr = str.split(" ");
		// N = Integer.parseInt(strArr[0]);
		// System.out.println(N);
		S = str;
	}

	public boolean hasNext() {
		// return cnt < N;
		return cnt < 1;
	}

	int K;

	public void readBody(String str) {
		// System.out.println(str);
		cnt++;
		K = Integer.parseInt(str);
	}

	public void solve() {
		// System.out.println(S + " " + K);
		SubStr = new TreeSet<String>();
		SubStrPos = new HashMap<String, ArrayList<Integer>>();
		for (int i = 0; i < S.length(); i++) {
			putSubStrPos(S.substring(i, i + 1), i);
		}
		for (int ord = 1; ord < K; ord++) {
			String subs = getOrdStr(ord);
			for (int p : SubStrPos.get(subs)) {
				if (p + subs.length() + 1 <= S.length())
					putSubStrPos(S.substring(p, p + subs.length() + 1), p);
			}
		}
		// for (String s : SubStr) {
		// System.out.print(s + ":");
		// for (int p : SubStrPos.get(s))
		// System.out.print(" " + p);
		// System.out.println();
		// }
		System.out.println(getOrdStr(K));
	}

	TreeSet<String> SubStr;
	HashMap<String, ArrayList<Integer>> SubStrPos;

	private String getOrdStr(int ord) {
		String ret = "";
		int i = 0;
		for (String s : SubStr) {
			if (i == (ord - 1)) {
				ret = s;
				break;
			}
			i++;
		}
		return ret;
	}

	private void putSubStrPos(String subStr, int pos) {
		SubStr.add(subStr);
		if (!SubStrPos.containsKey(subStr))
			SubStrPos.put(subStr, new ArrayList<Integer>());
		SubStrPos.get(subStr).add(pos);
	}
}


Measured memory_bytes: 21588
# -*- coding: utf-8 -*-

from scipy.misc import comb
import sys
sys.setrecursionlimit(1000000000)


class UnionFind:

    def __init__(self, n):
        # parent[x] < 0 means x is root and abs(parent[x]) == size[x]
        self.parent, self.depth = [-1] * (n + 1), [0] * (n + 1)

    def find(self, x):
        if self.parent[x] < 0:
            return x
        else:
            self.parent[x] = self.find(self.parent[x])
            return self.parent[x]

    def isSame(self, x, y):
        return self.find(x) == self.find(y)

    def unite(self, x, y):
        x, y = self.find(x), self.find(y)

        if self.depth[x] > self.depth[y]:
            self.parent[x] += self.parent[y]
            self.parent[y] = x
        else:
            self.parent[y] += self.parent[x]
            self.parent[x] = y
            if self.depth[x] == self.depth[y]:
                self.depth[y] += 1

    def count(self, x):
        return - self.parent[self.find(x)]


N, M = map(int, input().split())

AB = [tuple(map(int, input().split())) for _ in range(M)]
AB.reverse()

groups = UnionFind(N)
ans = [comb(N, 2, exact=True)]
for i in range(M):
    if groups.isSame(AB[i][0], AB[i][1]):
        ans.append(ans[-1])
    else:
        ans.append(ans[-1] - groups.count(AB[i][0]) * groups.count(AB[i][1]))
        groups.unite(AB[i][0], AB[i][1])

for i in range(M):
    print(ans[-(i + 2)])


Measured memory_bytes: 33696
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 7;
int n, m, cnt = 1, num, head[maxn], d[maxn], inq[maxn];
struct Node {int v, nxt, w;} G[maxn << 1];
void ins(int u, int v, int w) {G[cnt] = (Node) {v, head[u], w}; head[u] = cnt++;}
void spfa() {
	memset(d, 0x3f, sizeof d);
	queue<int> q;
	q.push(1); inq[1] = 1; d[1] = 0;
	while(!q.empty()) {
		int u = q.front(); q.pop(); inq[u] = 0;
		for (int i = head[u]; i; i = G[i].nxt) {
			int v = G[i].v; 
			if(d[v] > d[u] + G[i].w) {
				d[v] = d[u] + G[i].w;
				if(!inq[v]) {inq[v] = 1; q.push(v);}
			}
		}
	}
}
#define pii pair<int, int>
map<pii, int> p;
int get(pii a) {
	if(p.find(a) != p.end()) return p[a];
	else return p[a] = ++num;
}
int main() {
	scanf("%d%d", &n, &m); num = n;
	for (int i = 1, x, y, c; i <= m; ++i) {
		scanf("%d%d%d", &x, &y, &c);
		int r1 = get(make_pair(x, c)), r2 = get(make_pair(y, c));
		ins(x, r1, 1); ins(r1, x, 1);
		ins(y, r2, 1); ins(r2, y, 1);
		ins(r1, r2, 0); ins(r2, r1, 0);
	}
	spfa();
	if(d[n] > 2 * n) puts("-1");
	else printf("%d\n", d[n] / 2);
	return 0;
}

Measured memory_bytes: 52352
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
int N;
LL a[100001];
LL b[100001];
LL c[100001];
LL ch[100001];
int main(){
	cin>>N;

	map<LL,int>m;
	
	REP(i,N){
		cin>>a[i];
		m[a[i]]++;
	}
	int cc=0;
	for(auto it:m){
		b[cc]=it.first;
		c[cc]=it.second;
		cc++;
	}
	if(cc>4){
		cout<<"No"<<endl;
	}else{
		REP(i,cc){
			REP(j,cc){
				REP(k,cc){
					ch[k]=c[k];
				}
				LL now=b[i];
				LL now2=b[j];
				//cout<<now<<" "<<now2<<endl;
				ch[i]--;
				ch[j]--;
				REP(k,N-2){
					LL nxt=now^now2;
					REP(l,cc){
						if(nxt==b[l]){
							ch[l]--;
						}
					}
					now=now2;
					now2=nxt;
				}
				bool c=false;
				REP(k,cc){
					if(ch[k]!=0)c=true;
				}
				if(c==false){
					cout<<"Yes"<<endl;
					return 0;
				}
			}
		}
		cout<<"No"<<endl;
	}
	return 0;
}

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

int main()
{
	char s[4];
	cin>>s[0]>>s[1]>>s[2];
	
	int o=0;
	for(int i=0;i<3;i++) if(s[i]=='o') o++;
	
	cout<<700+o*100<<endl;
	
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<iomanip>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
typedef long long ll;

int main(){
    int H, W;
    cin >> H >> W;
    string C[H];
    rep(i,H) cin >> C[i];
    for(int i=0; i<H*2; i++){
        int tmp = i/2;
        cout << C[tmp] << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin.env python3

N,K = map(int,input().split())
queries = [list(map(int,input().split())) for _ in range(N)]

queries = sorted(queries,key=lambda x: x[0])

arrayLength = 0
for i in range(N):
  arrayLength += queries[i][1]
  if arrayLength >= K:
    print(queries[i][0])
    exit()
print(-1)


Measured memory_bytes: 29332
import java.util.*;

class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int d = sc.nextInt();
		if(d == 25){
			System.out.print("Christmas");
		}else if(d == 24){
			System.out.print("Christmas Eve");
		}else if(d == 23){
			System.out.print("Christmas Eve Eve");
		}else if(d == 22){
			System.out.print("Christmas Eve Eve Eve");
		}
	}
}


Measured memory_bytes: 22228
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e18;
const ll mod = 1000000007;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
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 ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (a < b) {
    ll tmp = a;
    a = b;
    b = tmp;
  }
  ll r = a%b;
  while(r != 0) {
    a = b;
    b = r;
    r = a%b;
  }
  return b;
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}

int main() {
  string s;
  ll n;
  cin >> s >> n;
  ll tmp = 0;
  rep(i, s.size()) {
    if (s.at(i) == '1') {
      tmp++;
    } else {
      break;
    }
  }
  if (tmp >= n) {
    cout << 1 << endl;
  } else {
    cout << s.at(tmp) << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
using namespace std;

long long cnt;
int l;
int A[1000000];
int n;
vector<int> G;

//間隔gを指定した挿入ソート
void insertionSort(int A[], int n, int g)
{
    for( int i = g; i < n; i++ ){
        int v = A[i];
        int j = i - g;
        while( j >= 0 && A[j] > v ){
            A[j + g] = A[j];
            j -= g;
            cnt++;
        }
        A[j + g] = v;
    }
}

void shellSort(int A[], int n)
{
    //数列 G = { 1, 4, 13, 40, 121, 364, 1093, ... } を生成
    for( int h = 1; ; ){
        if( h > n ) break;
        G.push_back(h);
        h = 3*h + 1;
    }

    for( int i = G.size()-1; i >= 0; i-- ){ //逆順に G[i] = g を指定
        insertionSort(A, n, G[i]);
    }
}

int main()
{
    cin >> n;
    //より速い入力scanf関数を使用
    for( int i = 0; i < n; i++ ) scanf("%d", &A[i]);
    cnt = 0;

    shellSort(A, n);

    cout << G.size() << endl;
    for( int i = G.size() - 1; i >= 0; i-- ){
        printf("%d", G[i]);
        if( i ) printf(" ");
    }
    printf("\n");
    //printf("%d\n", cnt); //本ではこちらだけれど，警告されるので以下を採用
    printf("%lld\n", cnt);
    for( int i = 0; i < n; i++ ) printf("%d\n", A[i]);
    return 0;
}

Measured memory_bytes: 5196
#include <iostream>

using namespace std;
#define maxN int(1e5+5)
int N, a[maxN],b[maxN],c[maxN],F[maxN][5];
int main()
{
    ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
    cin >> N ;
    for(int i = 1 ; i<= N ; i++)
        cin >> a[i] >> b[i] >> c[i];
    for(int i = 0 ; i<= N ; i++)
    {
        for(int j = 1 ; j<= 3; j++)
        {
            if(i==0)
                F[i][j] = 0 ;
            else
            {
                if(j==1)
                    F[i][j] = max(F[i-1][2],F[i-1][3]) + a[i];
                else if(j==2)
                    F[i][j] = max(F[i-1][1],F[i-1][3]) + b[i];
                else
                    F[i][j] = max(F[i-1][2],F[i-1][1]) + c[i];
            }
        }
    }
    cout << max(F[N][1],max(F[N][2],F[N][3]));
    return 0;
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
 
int main(){
	int a,b;
	cin>>a>>b;
    char s[a+b+1];
    for(int i=0;i<a+b+1;i++){
        cin>>s[i];
    }
    
    bool flag=false;
    if(s[a]=='-'){
            flag=true;
        }
    for(int i=0;i<a;i++){
        if(s[i]=='-'){
            flag=false;
        }
    }
    for(int i=a+1;i<a+b+1;i++){
        if(s[i]=='-'){
            flag=false;
        }
    }


    
    cout << (flag?"Yes":"No") << endl;

	return 0;
}

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

constexpr int LEN = 3005;
ll dp[LEN][LEN];
bool check[LEN][LEN];

ll calc_p(int l, int r, ll a[]){
    if(check[l][r]) return dp[l][r];
    check[l][r] = true;
    if(l == r) return dp[l][r] = a[l];
    return dp[l][r] = max<ll>(a[l] - calc_p(l+1, r, a), a[r] - calc_p(l, r-1, a));
}

int main(){
    memset(dp, 0, sizeof(dp));
    memset(check, 0, sizeof(check));
    int n; cin >> n;
    ll a[n]; rep(i, n) cin >> a[i];

    cout << calc_p(0, n-1, a) << endl;

    return 0;
}

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

int main()
{
	long i,N,temp,sum=0;
	vector<long> A;
	cin>>N;
	for(i=0;i<N;i++){
		cin>>temp;
		A.push_back(temp);
	}
	sort(A.begin(),A.end());
	cout<<A.at(N-1)-A.at(0);
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void){
    long i = 100000;
    long j,n;
    scanf("%ld",&n);
    for(j = n;j > 0;j--){
        i = i + i * 0.05;
        if(i % 1000 == 0){
        }
        else{
            i = i / 1000;
            i = i * 1000 + 1000;
        }
    }
    printf("%ld\n",i);
    return 0;
}

Measured memory_bytes: 1020
import std.stdio, std.conv, std.string, std.array, std.range, std.algorithm, std.container;
import std.math, std.random, std.bigint, std.datetime, std.format;
void main(string[] args){ if(args.length > 1) if(args[1] == "-debug") DEBUG = 1; solve(); }
void log()(){ writeln(""); } void log(T, A ...)(T t, lazy A a){ if(DEBUG) write(t, " "), log(a); } bool DEBUG = 0;
string read(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
T rtype(T)(){ return read.to!T; } alias rint = rtype!int, rlong = rtype!long, rreal = rtype!real;
T[] rtypes(T)(int n){ return n.iota.map!(i => rtype!T()).array; } alias rint = rtypes!int, rlong = rtypes!long, rreal = rtype!real;
// ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- //
void solve(){
	int n = rint, k = rint;
	string s = read;
	bool[] xs = s.map!(c => c == 'R').array;
	log("xs:", xs.map!(x => x? "R": "L").array.join(" "));
	
	long ans;
	long t;
	foreach(i; 0 .. n - 1){
		if(s[i] == s[i + 1]) ans += 1;
		else t += 1;
	}
	if(s[0] == 'R' || t % 2){ // 端が内向き→偶数番目をひっくり返す
		ans += min(k * 2, t);
	}
	else{ // 端が外向き→奇数番目をひっくり返す
		ans += min(k * 2, t);
	}
	
	ans.writeln;
	
}


Measured memory_bytes: 636
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int A = sc.nextInt();
		int B = sc.nextInt();
		String S = sc.next();

		int already = 0;
		int students_rank = 0;

		for (int i = 0; i < N; i++) {
			char c = S.charAt(i);
			if (c == 'a') {
				if (already < A + B) {
					already++;
//					students_rank++;
					System.out.println("Yes");
				} else {
//					students_rank++;
					System.out.println("No");
				}
			} else if (c == 'b') {
				students_rank++;
				if (students_rank <= B && already < A + B) {
					already++;
					System.out.println("Yes");
				}else{
					System.out.println("No");
				}
			}else{
				System.out.println("No");
			}
		}

	}

}


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

#define re(i,n) for(int i=0;i<n;i++)
#define m(a,b) a=min(a,b)

int main(){
    int n, m, a=1e9, c[1000], d[1000], dp[1002][1002];
    cin>>n>>m;
    re(i,m+1)
        re(j,n+1)
            dp[i][j]=1e9;
    dp[0][0]=0;
    re(i,n)cin>>d[i];
    re(i,m)cin>>c[i];
    re(i,m){
        re(j,n){
            m(dp[i+1][j+1],dp[i][j]+c[i]*d[j]);
            m(dp[i+1][j],dp[i][j]);
        }
    }
    re(i,m+1)
        m(a,dp[i][n]);
    cout<<a<<endl;
}

Measured memory_bytes: 5084
#include <algorithm>
#include <bitset>
#include <complex>
#include <cstdio>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;

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

typedef long long ll;

const int Inf = 100100100;
const double EPS = 1e-9;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    int tile;
    int i;
    int count0 = 0;
    int count1 = 0;
    cin >> s;
    int len = s.size();

    rep(i, len) {
      if (i % 2 == 0) {
        if (s[i] - '0' != 0)
          count0++;
      } else {
        if (s[i] - '0' != 1)
          count0++;
      }
    }

    rep(i, len) {
      if (i % 2 == 1) {
        if (s[i] - '0' != 0)
          count1++;
      } else {
        if (s[i] - '0' != 1)
          count1++;
      }
    }

    printf("%d\n", count0 > count1 ? count1 : count0);
    return 0;
}


Measured memory_bytes: 512
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF (LLONG_MAX - 1e5)
#define fcout cout << fixed << setprecision(10)

using namespace std;

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

    int N;
    cin >> N;
    vector<int> h(N);
    REP(i, N) cin >> h[i];

    int ans = 0;
    FOR(j, 1, 100) {
        bool ok = false;
        REP(i, N) {
            if (!ok && h[i] >= j) {
                ok = true;
                ans++;
                continue;
            }

            if (ok && h[i] < j) {
                ok = false;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


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

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

#define N 1000

int lcs(string X, string Y) {
  int m = X.size();
  int n = Y.size();
  int c[m + 1][n + 1];
  int maxlen = 0;
  X = ' ' + X;
  Y = ' ' + Y;
  c[0][0] = 0;
  FOR(i, 1, m + 1) c[i][0] = 0;
  FOR(j, 1, n + 1) c[0][j] = 0;

  FOR(i, 1, m + 1) {
    FOR(j, 1, n + 1) {
      if(X[i] == Y[j]) {
        c[i][j] = c[i - 1][j - 1] + 1;
      } else {
        c[i][j] = max(c[i - 1][j], c[i][j - 1]);
      }
      maxlen = max(maxlen, c[i][j]);
    }
  }

  return maxlen;
}

int main(void) {
  string X, Y;
  int n; cin >> n;
  REP(i, n) {
    cin >> X >> Y;
    cout << lcs(X, Y) << endl;
  }
  return 0;
}

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

using namespace std;

int main() {
    int A, B, C, D;
    int train = 0;
    int bus = 0;
    cin >> A >> B >> C >> D;
    if (A > B) {
        train = B;
    } else {
        train = A;
    }
    if (C > D) {
        bus = D;
    } else {
        bus = C;
    }

    cout << train + bus << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define len(s) (int)s.size()
#define pb push_back

template<class T> inline bool chmin(T &a, T b){
	if(a>b){a=b;return true;}
	return false;
}
template<class T> inline bool chmax(T &a, T b){
	if(a<b){a=b;return true;}
	return false;
}
constexpr int mod = 998244353;
constexpr int inf = 3e18;

int N,M,K;
int A[200005],B[200005];
signed main(){
	cin>>N>>M>>K;
	rep(i,N)cin>>A[i];
	rep(i,M)cin>>B[i];
	int ri=-1,sum=0;
	rep(i,M){
		if(sum+B[i]<=K){
			sum+=B[i];
			ri=i;
		}else break;
	}
	int ans=ri+1,sum2=0;
	rep(i,N){
		sum2+=A[i];
		if(sum2>K)break;
		while(sum+sum2>K&&ri>=0){
			sum-=B[ri];ri--;
		}
		chmax(ans,i+1+ri+1);
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 6716
n, a, b = gets.strip.split.map(&:to_i)

def digest_sum n
  sum = 0
  while n > 0 do
    sum += n % 10
    n/= 10
  end
  sum
end

ans = (1..n)
  .map { |i|  [i, digest_sum(i)] }
  .select { |d| a <= d[1] && d[1] <= b }
  .inject(0) { |sum, d| sum + d[0] }

puts ans

Measured memory_bytes: 3836
X = int(input())

Ureshisa = 0

# make as many 500 yen coin as possible
FiveHundredCoins = X//500
Ureshisa += 1000*FiveHundredCoins

# make the rest of the amount as many 5 yen coin as possible
X -= 500*FiveHundredCoins
FiveCoins = X//5
Ureshisa += 5*FiveCoins

print(Ureshisa)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define iter(it,a) for(auto it=a.begin();it!=a.end();it++)
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define endl '\n'
#define preturn(X) cout<<X<<endl; return 0
typedef long long ll;


int a[100000+1];

int main(){
    cin.tie(0);ios_base::sync_with_stdio(0);
	int n,m;
	cin>>n>>m;
	int x,y;
	rep(i,0,m){
		cin>>x>>y;
		a[x]++;
		a[y]++;
	}    
	rep(i,1,n+1){
		if(a[i]%2==1){
			preturn("NO");
		}
	}
	preturn("YES");
}

Measured memory_bytes: 640
//url:
//problem name: Brick Break

#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

int main() {
    int N;
    int K;
    cin >> N >> K;
    map<int,int> mp;
    set<int> st;
    ll ans = 0;
    REP(i,N) {
        int a; cin >> a;
        st.insert(a);
        if(mp.count(a)) mp[a]++;
        else mp[a] = 1;
    }
    vector<P> res;
    for(P p:mp) res.push_back(make_pair(p.second,p.first));
    sort(res.begin(),res.end());
    if(st.size() <= K) {
        cout << 0 << endl;
        return 0;
    }
    else {
        REP(i,st.size()-K) {
            ans += res[i].first;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 21112
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;


int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n;
    cin >> n;
    map<string, int> cnts;

    for (int i = 0; i < n; ++i) {
        string s;
        cin >> s;
        sort(s.begin(), s.end());
        cnts[s] += 1;
    }

    long long res = 0;
    for (auto& P : cnts) {
        long long n = P.second;
        res += n * (n - 1) / 2;
    }

    cout << res << "\n";

    return 0;
}

Measured memory_bytes: 11264
#include<stdio.h>

int main(void)

{

int W,H,x,y,r ;


scanf("%d",&W) ;

scanf("%d",&H) ;

scanf("%d",&x) ;

scanf("%d",&y) ;

scanf("%d",&r) ;

if(W>=x+r&&H>=y+r&&0<=x-r&&0<=y-r){

printf("Yes\n") ;

}

else{

printf("No\n") ;

}

return 0 ;

}
 

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


int main(void)
{
  int queue=0,a[10],n;  

  while(scanf("%d",&n)!=EOF){
    if(n==0){
      printf("%d\n",a[queue-1]);
      queue--;
    }
    else{
      a[queue++]=n;
    }
  }
  return 0;
}

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

int main() {
	vector<int> v; int n, q, c, x, y; cin >> n >> q;
	v.resize(n); fill(v.begin(), v.end(), 0);
	for (int i = 0; i < q; i++) {
		cin >> c >> x >> y;
		switch (c) {
		case 0:
			v[x - 1] += y; break;
		case 1:
			cout << accumulate(v.begin() + x - 1, v.begin() + y, 0) << endl;
			break;
		}
	}
	return 0;
}


Measured memory_bytes: 3124
s=input()
if s=="zyxwvutsrqponmlkjihgfedcba":
    print(-1)
    quit()
elif len(s)<26:
    d=set([i for i in range(26)])
    for i in s:
        d.remove(ord(i)-97)
    print(s+chr(min(d)+97))
else:
    d=[ord(s[-1])]
    for i in range(25):
        c=s[-2-i]
        if max(d)<ord(c):
            d.append(ord(c))
        else:
            print(s[:26-2-i]+chr(min([i for i in d if i>ord(c)])))
            break

Measured memory_bytes: 3064
def main():
    A, B, C = map(int, input().split())
    K = int(input())

    while K > 0 and A >= B:
        B *= 2
        K -= 1

    while K > 0 and B >= C:
        C *= 2
        K -= 1

    if A < B < C:
        print("Yes")
    else:
        print("No")

if __name__ == "__main__":
    main()

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

int main() {
  string S;
  cin >> S;
  int count0 = 0;
  int count1 = 0;
  for (char e : S) {
    if (e == '0') count0 += 1;
    if (e == '1') count1 += 1;
  }
  
  cout << 2 * min(count0, count1) << endl;
}

Measured memory_bytes: 512
//メモ再帰
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#define mkp make_pair
#define fi first
#define se second
#define pt(num) cout << num << "\n"
#define mCalc(a, s, b) (a)=((a)s(b)+MOD)%MOD
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define chmax(a, b) (a<b ? a=b : 0)
#define chmin(a, b) (a>b ? a=b : 0)
#define INF 1000000000000000000
#define MOD 1000000007LL
#define MAX 101010
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef map<ll, ll> Map;

ll N;
ll dp[MAX];

ll rec(ll n) {
    if(n==0) return 0;
    if(dp[n]!=-1) return dp[n];
    
    ll i;
    ll res=INF;
    for(i=1; i<=n; i*=6)
        res=min(res, rec(n-i)+1);
    
    for(i=1; i<=n; i*=9)
        res=min(res, rec(n-i)+1);
    
    
    return dp[n]=res;
}


int main(void) {;
    cin >> N;
    memset(dp, -1, sizeof(dp));
    
    pt(rec(N));
}



Measured memory_bytes: 5760
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    // TODO 自動生成されたメソッド・スタブ
    String[] week = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};

    Scanner sc = new Scanner(System.in);
    String s = sc.next();

    int ans = 0;
    for (int i = 0; i < week.length; i++) {
      if (s.equals(week[i])) {
        ans = 7 - i;
        break;
      }
    }

    System.out.println(ans);
  }
}


Measured memory_bytes: 19924
def LI():return list(map(int,input().split()))
def yes():return print("Yes")
def no():return print("No")
from collections import deque, defaultdict, Counter
# from heapq import heappop, heappush
# import math
# from decimal import Decimal

# def divisors(x):
#     ret=[]
#     for i in range(1,int(x**.5)+1):
#         if x%i==0:
#             ret.append(i)
#             if x//i==i:continue
#             ret.append(x//i)
#     return sorted(ret)

# print(divisors(64),2**6)            

# def prime_factor(n):
#     ass = []
#     for i in range(2,int(n**0.5)+1):
#         while n % i==0:
#             ass.append(i)
#             n = n//i
#     if n != 1:
#         ass.append(n)
#     return ass

# n=int(input())
# pf=prime_factor(n)
# pf=Counter(pf)
# # print(pf)

# def cng(x):
#     le=2*x
#     ret=-1
#     mi=int(le**0.5)
#     for i in range(mi-1,mi+10000):
#         # print((i+1)*(i+2),le,i*(i+1))
#         if (i+1)*(i+2)>le>=i*(i+1):
#             ret=i
#             # print((i+1)*(i+2),le,i*(i+1))
#             break
        
#     return ret

# mp=[]   
# for i in range(2*10**5):
#     mp.append(cng(i))
# # print(-1 in mp)

# ans=0
# for i in pf.values():
#     ans+=mp[i]
    
# print(ans)
# import numpy as np

n=int(input())
a=[]
b=[]
# ab=[]
for _ in range(n):
    c,d=LI()
    a.append(c)
    b.append(d)
    # ab.append((c,d))
    
a.sort()
b.sort()
# print(a,b)

if n%2==1:
    # 奇数
    t=(n+1)//2
    ans=b[t-1]-a[t-1]+1

else:
    l=n//2
    r=l+1
    
    aa=(a[l-1]+a[r-1])
    bb=(b[l-1]+b[r-1])
    ans=bb-aa+1
    
print(ans)

Measured memory_bytes: 104868
def m():  
    N = int(input())
    A = list(map(int, input().split()))
    times = 1
    c = 0

    for i in A: 
        if times <= 10**18 and c < N:
            times *= i
            c += 1   
    if times > 10 ** 18:
        times = -1
    if 0 in A:
        times = 0
    print(times)
m()

Measured memory_bytes: 21668
package main

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

const (
	initialBufSize = 100000
	maxBufSize     = 10000000
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wt = bufio.NewWriter(os.Stdout)
)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, initialBufSize), maxBufSize)
	defer wt.Flush()

	n := nextInt()
	a, b := make([]int, n), make([]int, n)
	for i := 0; i < n; i++ {
		a[i], b[i] = nextInt(), nextInt()
	}
	sort.Sort(sort.IntSlice(a))
	sort.Sort(sort.IntSlice(b))

	var ans int
	if n%2 == 1 {
		ca, cb := a[n/2], b[n/2]
		ans = cb - ca + 1
	} else {
		ca, cb := a[(n-1)/2]+a[n/2], b[(n-1)/2]+b[n/2]
		ans = cb - ca + 1
	}

	puts(ans)
}


Measured memory_bytes: 8892
N = int(input())
A = [list(map(int, input().split())) for _ in range(N)]

dp = [[0] * 3 for _ in range(N + 1)]
for i in range(N):
    for j in range(3):
        for k in range(3):
            if j != k:
                dp[i+1][k] = max(dp[i+1][k], dp[i][j] + A[i][k])
print(max(dp[N]))

Measured memory_bytes: 47344
#入力

N,M = map(int,input().split())

graph = [ ]
for _ in range(N+1):
    graph.append([])

for _ in range(M):
    a,b = map(int,input().split())
    graph[a].append(b)
    graph[b].append(a)

visited = []
for _ in range(N+1):
    visited.append(False)


def dfs(dep,cur):
    global N,visited,graph

    if dep == N:
        return 1

    ans = 0

    for dist in graph[cur]:
        if visited[dist] == False:
            visited[dist] = True
            ans += dfs(dep + 1,dist)
            visited[dist] = False
    return ans

visited[1] = True
print(dfs(1,1))


Measured memory_bytes: 9208
#include<bits/stdc++.h>
#include <cstdio>
using namespace std;
#define ll  long long
#define PB push_back
#define ld long double
#define ff first
#define ss second
# define st(v) (v).begin(),(v).end()
#define   pr pair<ll,ll>
const ll N = 1e5+4 , M=N,inf=(ll)1e9;
const ll mod=1e9+7;
ll fastAbs(ll n) { return (n ^ (n >> 31)) - (n >> 31); }
ll multiply(ll a, ll b){ return ((a % mod) * (b % mod)) % mod; }
ll add(ll a, ll b) {     return ((a % mod) + (b % mod)) % mod; }
ll sub(ll a, ll b) { return ((a%mod) - (b % mod)+ mod) % mod ; }
//map< pair<ll,ll> , ll > mp;
const ll dx[4] = {1,0,0,-1};
const ll dy[4] = {0,-1,1,0};
/////////////////////////////////////////////////////
const int nmax = 2e5 + 5 ;
vector < int > edge[nmax];
vector < int > dfs_order  ;
map < int , int > mp ;
int dfs( int x , int parent , int t  ){
    dfs_order.PB(x);
    int cnt = 1 ;
    for( auto child : edge[x]){
        if(child!=parent){
            cnt += dfs(child,x,t+1);
        }
    }
    mp[x] = cnt ;
    return cnt ;
}
/////////////////////////////////////////////////////
void solve( int y ){
    int n , q ;
    cin >> n >>  q ;
    for( int i = 0 ; i < n-1 ; i++){
        int u  , v ;
        cin >> u >> v ;
        edge[u].PB(v);
        edge[v].PB(u);
    }
    dfs(1,-1,0);
    vector < int > dfs_size(n);
    map < int , int > mp1 ;
    for( int i = 0 ; i < n ; i++){
        //cout << dfs_order[i] << " " << mp[dfs_order[i]] << "\n" ;
        mp1[dfs_order[i]] = i ;
    }
    vector < int > a(n+1,0);
    for(int i = 0 ; i < q ; i++){
        int node , val ;
        cin >> node >> val;
        int l = mp1[node];
        int r = l + mp[node];
        a[l]+=val;
        a[r]-=val;
    }
    for( int i = 1 ; i < n ; i++){
        a[i]+=a[i-1];
    }
    vector < int > ans(n) ;
    for( int i = 0 ; i < n ; i++){
        int node = dfs_order[i] -1 ;
        ans[node] = a[i] ;
    }
    for( int i = 0 ; i < n ; i++) cout << ans[i] << " " ;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll q=1;
    //cin >> q;
//    while(q--)
//        solve();
    for( int i = 1 ; i <= q ; i++) solve(i);
}


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

void call(int n){
  int i = 1;
 CHECK_NUM:
  int x = i;
  if ( x % 3 == 0 ){
    cout << " " << i;
    goto END_CHECK_NUM;
  }
 INCLUDE3:
  if ( x % 10 == 3 ){
    cout << " " << i;
    goto END_CHECK_NUM;
  }
  x /= 10;
  if ( x ) goto INCLUDE3;
 END_CHECK_NUM:
  if ( ++i <= n ) goto CHECK_NUM;

  cout << endl;
}

int main(){

  int n;
  cin >> n;
  call(n);
}

Measured memory_bytes: 1160
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
using namespace std;
#define ll long long
#define rep(i,l,r) for(ll i=(l);i<(r);i++)
int main(void){
    ll n,cnt=0;
    cin>>n;
    int p[n+1];
    rep(i,1,n+1)cin>>p[i];
    rep(i,1,n)if(p[i]==i){
        swap(p[i],p[i+1]);
        cnt++;
    }
    cnt+=(p[n]==n);
    cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
//using namespace __gnu_pbds;
typedef long long ll;
typedef pair<int, int> pi;
typedef vector<int> vi;
template <class Key, class Compare = less<Key>>
using Tree = __gnu_pbds::tree<Key, __gnu_pbds::null_type, Compare, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update>;





void Main() {
  int n;
  cin >> n;
  vi h(n), dp(n);
  for (int i = 0; i < n; ++i) {
    cin >> h[i];
  }
  dp[0] = 0;
  dp[1] = abs(h[0] - h[1]);
  for (int i = 2; i < n; ++i) {
    dp[i] = min(dp[i-2] + abs(h[i-2] - h[i]), dp[i-1] + abs(h[i-1] - h[i]));
  }
  cout << dp[n-1] << '\n';
}


int main() {
  ios::sync_with_stdio(false);
//  cin.tie(nullptr);
  #ifdef _DEBUG
//  freopen("in.txt", "r", stdin);
//  freopen("out.txt", "w", stdout);
  #endif
  Main();
  return 0;
}


Measured memory_bytes: 1024