akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<int> cnt(3, 0);
    for(int i=0; i<n; ++i){
        int a;
        cin >> a;
        for(int j=2; ; --j){
            if(a % (1<<j) == 0){
                ++ cnt[j];
                break;
            }
        }
    }

    if(cnt[1] > 0)
        ++ cnt[0];
    if(cnt[0] - 1 <= cnt[2])
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return 0;
}


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

#define REP(i, n ,N) for(ll i = (n); i < (N); i++)
#define p(s) cout<<(s)<<endl
#define p2(a, b) cout<<(a)<<" "<<(b)<<endl
using namespace std;
typedef long long ll;
ll mod = 1e9+7;
ll inf = 1e18;


ll N, K;
ll h[100010];
ll dp[100010];
int main(){
	cin >> N >> K;
	REP(i,0,N){
		cin >> h[i];
	}
	REP(i,0,N){
		dp[i]=inf;
	}
	dp[0]=0;
	REP(i,0,N){
		REP(j,i+1,i+K+1){
			dp[j] = min(dp[j], dp[i] + abs(h[i] - h[j]));
		}
	}
	p(dp[N-1]);
	return 0;
}

Measured memory_bytes: 1792
import sys

def solve():
      input = sys.stdin.readline
      N = int(input())
      count = N - 1
      for i in range(2, N):
            b = 1
            while i * b < N:
                  count += 1
                  b += 1
      print(count)

      return 0

if __name__ == "__main__":
      solve() 

Measured memory_bytes: 9160
#include <iostream>
#include <string>
#include <vector>
#include <map>
using namespace std;
int main(){
	string s;
	int n;
	for(;cin>>n,n;){
		int i=0,ma=0;
		bool f=false;
		map<string,int>votes;
		votes[""]=0;
		for(;i<n;){
			i++;
			cin>>s;
			if(f)continue;
			votes[s]+=1;
			if(ma<votes[s])ma=votes[s];
			char c;
			if(c=[&]()->char{
				char c_=0;
				for(auto &e:votes){
					if(e.second==ma){
						if(c_)return 0;
						c_=e.first[0];
					}else{
						if(e.second+n-i>=ma)return 0;
					}
				}
				return c_;
			}()){
				cout<<c<<' '<<i<<endl;
				f=true;
			}
		}
		if(!f)cout<<"TIE"<<endl;
	}
}

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

int main() {
	//code
	int a,b,c,d,e;
	cin>>a>>b>>c>>d>>e;
	
	if(a == 0)
	cout<<1<<endl;
	else if(b == 0)
	cout<<2<<endl;
	else if(c == 0)
	cout<<3<<endl;
	else if(d == 0)
	cout<<4<<endl;
	else
	cout<<5<<endl;
	return 0;
}

Measured memory_bytes: 3592
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
#include <stack>
#include <iomanip>
#include <limits>
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 FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
using Graph=vector<vector<int>>;

using edge= struct{int to;ll cost;};


template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}

typedef priority_queue<ll> PQ_HIGH;
typedef priority_queue<ll,VL,greater<ll>> PQ_LOW;//昇順

//A 65
//a 97
//pairの比較関数(昇順)
bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}
//降順
bool compare_by_b_high(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second > b.second;
    }else{
        return a.first < b.first;
    }
}

int main(){
  string s;cin>>s;
  deque<char> data;
  for(int i=0;i<s.length();i++){
    if(s[i]=='0'){
      data.push_back('0');
    }else if(s[i]=='1'){
      data.push_back('1');
    }else{
      if(!data.empty()){
        data.pop_back();
      }
    }
  }
  while(!data.empty()){
    cout<<data.front();
    data.pop_front();
  }
  cout<<endl;
}


Measured memory_bytes: 256
///usr/bin/g++ -O2 $0 -o ${0%.cpp} && echo "----------" && ./${0%.cpp}; exit;
#include <bits/stdc++.h>
using namespace std;

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

const int N = 2e5 + 10; 
int n, a[N], c[21];

bool can(int x) {  
    for(int i = 0; i < 20; ++i) 
        if((x >> i & 1) && c[i]) return 0; 
    return 1; 
}
void add(int x, int d) {
    for(int i = 0; i < 20; ++i) 
        if(x >> i & 1) c[i] = d; 
}

int main(int argc, char const *argv[]) {
    scanf("%d", &n); 
    for(int i = 1; i <= n; i++) 
        scanf("%d", &a[i]);
    ll ans = 0; 
    for(int l = 1, r = 1; l <= n; ++l) {
        while(r <= n && can(a[r])) 
            add(a[r++], 1); 
        ans += r - l; 
        add(a[l], 0);
    }
    printf("%lld\n", ans); 
}

Measured memory_bytes: 1024
def merge(A, left, mid, right):
    global cnt
    inf = 100000000001
    n1, n2 = mid - left, right - mid
    L, R = A[left:left+n1]+[inf], A[mid:mid+n2]+[inf]
    i = j = 0
    for k in range(left, right):
        if L[i] <= R[j]:
            A[k] = L[i]
            i += 1
        else:
            A[k] = R[j]
            j += 1
        cnt += 1

def mergeSort(A, left, right):
    if left+1 < right:
        mid = (left + right) // 2
        mergeSort(A, left, mid)
        mergeSort(A, mid, right)
        merge(A, left, mid, right)

cnt = 0
n = int(input())
A = list(map(int, input().strip().split()))
mergeSort(A, 0, n)
print(*A)
print(cnt)

Measured memory_bytes: 63688
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

use std::iter::Iterator;

fn main() {

    input!{
        k: usize,
        n: usize,
        a: [i32; n],
    }

    let mut vec = Vec::new();
    for i in 1..n + 1 {
        if i == n {
            vec.push(k as i32 - a[i-1]+a[0]);
        }else{
            vec.push(a[i] - a[i-1]);
        }
    }

    let sum = vec.iter().fold(0, |sum, a| sum + a);

    let maxkyori = sum - vec.iter().max().unwrap();

    println!("{}", maxkyori)

}


Measured memory_bytes: 6524
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
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; }
const ll INF=1LL<<60;
const int inf=1<<30;
const int mod=1e9+7;
const int MOD=998244353;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;cin >> n;
    set<ll> st;
    vector<ll> v;
    for(ll i=2;i*i<=n;i++){
        if(n%i==0){
            v.push_back(i);
            if(i*i!=n){
                v.push_back(n/i);
            }
        }
    }
    v.push_back(n);
    for(ll x:v){
        ll num=n;
        while(num%x==0){
            num/=x;
        }
        if(num%x==1){
            st.insert(x);
        }
    }
    n--;
    for(ll i=2;i*i<=n;i++){
        if(n%i==0){
            st.insert(i);
            if(i*i!=n){
                st.insert(n/i);
            }
        }
    }
    if(n!=1){
        st.insert(n);
    }
    cout << st.size() << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
#define P(x) cout << (x) << endl
#define p(x) cout << (x)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define vv(type, c, m, n, i) vector<vector<type>> c(m, vector<type>(n, i));
#define rep(i,a,n) for(int i=(a), i##_len=(n); i<i##_len; ++i)
#define rrep(i,a,n) for(int i=(a), i##_len=(n); i>i##_len; --i)
#define len(x) ((int)(x).size())
#define mp make_pair
#define eb emplace_back
typedef long long ll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
constexpr int MAX = 101;
constexpr int INF = 1<<21;
enum Color { WHITE = 0, GRAY, BLACK };
int n;
vv(int, M, MAX, MAX, INF);
inline int prim() {
	vi d(MAX, INF), t(MAX, -1), color(MAX, WHITE);
	d[0] = 0;
	int minv, u;
	while(true) {
		minv = INF;
		u = -1;
		rep(i, 0, n) {
			if(minv > d[i] && color[i] != BLACK) {
				u = i;
				minv = d[i];
			}
		}
		if(u == -1) break;
		color[u] = BLACK;
		rep(v, 0, n) {
			if(color[v] != BLACK && M[u][v] != INF && d[v] > M[u][v]) {
				d[v] = M[u][v];
				t[v] = u;
				color[v] = GRAY;
			}
		}
	}
	int sum = 0;
	rep(i, 0, n) {
		if(t[i] != -1) sum += M[i][t[i]];
	}
	return sum;
}
int main() {
	cin >> n;
	int e;
	rep(i, 0, n) {
		rep(j, 0, n) {
			cin >> e;
			if(e != -1) M[i][j] = e;
		}
	}
	P(prim());
	return 0;
}

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

int a, b, c;

bool check(){
    if(a % 2 == 1 || b % 2 == 1 || c  % 2 == 1){
        return true;
    }else return false;
}


void calc(){
    int tmp_a, tmp_b, tmp_c;
    tmp_a = a;
    tmp_b = b;
    tmp_c = c;
    a = (tmp_b + tmp_c) / 2;
    b = (tmp_a + tmp_c) / 2;
    c = (tmp_a + tmp_b) / 2;
    return ;
}


void solve(){
    int count = 0;
    while(1){
        if( check() ){
            cout << count << '\n';
            return ;
        }
        calc();
        count++;
    }
    return ;
}


int main(){
    cin >> a >> b >> c;
    if(a == b && b == c && a % 2 == 0){
        cout << -1 << '\n';
        return 0;
    }
    if( ( a + b + c) % 2 == 1){
        cout << 0 << '\n';
        return 0;
    }
    solve();
    return 0;
}

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

int main()
{
    long long int a;
    string s;
    cin >> a;
    cin >> s;
    if(a<3200)
    {
        cout << "red" << endl;
    }
    else if(a>=3200)
    {
        cout << s << endl;
    }
}


Measured memory_bytes: 256
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {
    
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int n = sc.nextInt();
		int k = sc.nextInt();
		String s = sc.next();
		
		// 計算
		int result = 0;
		char pre = '1';
		int cntOne = 0;
		int cntZero = 0;
		ArrayList<Integer> list = new ArrayList<Integer>();
		for(int i = 0; i < n; i++){
		    char c = s.charAt(i);
		    if(pre == '1' && c == '1'){
		        cntOne++;
		    }else if(pre == '1' && c == '0'){
		        list.add(cntOne);
		        cntZero = 1;
		        cntOne = 0;
		        pre = '0';
		    }else if(pre == '0' && c == '0'){
		        cntZero++;
		    }else if(pre == '0' && c == '1'){
		        list.add(cntZero);
		        cntOne = 1;
		        cntZero = 0;
		        pre = '1';
		    }
		}
		if(pre == '0'){
		    list.add(cntZero);
		    list.add(0);
		}else{
		    list.add(cntOne);
		}
		//System.out.println(list.toString());
		
		int loop = min(list.size(), 2*k + 1);
		int temp = 0;
		for(int i = 0; i < loop; i++){
		    temp += list.get(i);
		}
		result = temp;
		for(int i = loop; i < list.size(); i = i + 2){
		    temp += list.get(i);
		    temp += list.get(i + 1);
		    temp -= list.get(i - loop);
		    temp -= list.get(i + 1 - loop);
		    result = max(result, temp);
		}
		
		// 出力
		System.out.println(result);
        
	}
}

Measured memory_bytes: 26524
#include<bits/stdc++.h>
using namespace std;
    long long int n=0,x=0,a[100005]={0},ans=0;
int main(){
    cin>>n>>x;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        int c=a[i]+a[i-1];
        if(i>0 && c>x){

                int v=c-x;
                ans+=v;
                a[i]-=v;
            }
        }
    cout<<ans<<endl;
    return 0;
}


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

using namespace std;

#define int long long

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

#define pb push_back
#define VDEL(v, n) v.erase(v.begin() + (n))
#define ALL(v) v.begin(), v.end()

#define INTMAX 2147483647
#define INF 200000000
#define TINT(str) atoi(str.c_str())
#define TSTR(num) to_string(num)

using ll = long long;
using PII = pair<int, int>;
using VI = vector<int>;
using VII = vector<vector<int>>;

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

int k[100][100];
int ans = 0;

void saiki(int x, int y, int d)
{
    if(x < 0 || y < 0) return;
    if(k[x][y] == 0) return;

    ans = max(ans, d);

    k[x][y] = 0;
    REP(i, 4)
    {
        saiki(x + dx[i], y + dy[i], d + 1);
    }
    k[x][y] = 1;
    return;
}

signed main()
{
    while(true)
    {
        REP(i, 100)
        {
            memset(k[i], 0, 100 * sizeof(int));
        }
        ans = 0;

        int m,n;
        cin >> m >> n;
        if(m == 0 && n == 0) break;
        REP(i, n)
        {
            REP(h, m)
            {
                cin >> k[i][h];
            }
        }
        REP(i, n)
        {
            REP(h, m)
            {
                if(k[i][h] == 1)
                {
                    saiki(i, h, 1);
                }
            }
        }
        cout << ans << endl;
    }
    return 0;
}



Measured memory_bytes: 3164
use std::cmp;

fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let n: usize = sc.read();
    let a: Vec<Vec<char>> = (0..n).map(|_| sc.chars()).collect::<Vec<_>>();

    if a.iter().all(|row| row.iter().all(|&c| c == '.')) {
        println!("-1");
        return;
    }

    let mut ans = n * n;
    for row_id in 0..n {
        let white = a[row_id].iter().filter(|&&c| c == '.').count();
        let white_columns = (0..n)
            .filter(|&column_id| (0..n).any(|row_id| a[row_id][column_id] == '.'))
            .count();
        if a.iter().any(|row| row[row_id] == '#') {
            ans = cmp::min(ans, white + white_columns);
        } else {
            ans = cmp::min(ans, white + white_columns + 1);
        }
    }
    println!("{}", ans);
}

pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n')
            .take_while(|&b| b != b' ' && b != b'\n')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 4476
import java.util.Scanner;

class fibonacci{
    private int num;
    private int n1 = 1;
    private int n2 = 1;
    private int temp = 1;
    
    public fibonacci(int num){
	this.num = num;
    }
    
    public int cal(int num){
	for (int i=1; i<num; i++){
	    temp = n1 + n2;
	    n1 = n2;
	    n2 = temp;
	}
	return temp;
    }
}

public class Main{
    public static void main(String[] args){
	Scanner scan = new Scanner(System.in);
	int n = scan.nextInt();
	fibonacci f = new fibonacci(n);
	System.out.println(f.cal(n));
    }
}



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

int main() {
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  if(a>b){
    if(c>=d){
      cout << b+d << endl;
    }
    else if(c<d){
      cout << b+c << endl;
    }
  }
  else if(a<b){
    if(c>=d){
      cout << a+d << endl;
    }
    else if(c<d){
      cout << a+c << endl;
    }
  }
  else if(a=b){
        if(c>=d){
      cout << a+d << endl;
    }
    else if(c<d){
      cout << a+c << endl;
    }
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
#define all(v) v.begin(), v.end()
#define repi(i, n, init) for (ll i = init; i < (n); i++)
#define repd(i, n, init) for (ll i = (n); i >= init; i--)
#define repm(i, m) for (auto i = m.begin(); i != m.end(); i++)
#define repb(bit, n, init) for (ll bit = init; bit < (1 << n); ++bit)

int main()
{
    int n, k;
    cin >> n >> k;
    ll ans = 0;
    ll st = 0;
    ll fin = 0;
    if (n + 1 == k)
    {
        cout << 1 << endl;
    }
    else
    {
        repi(j, k, 0)
        {
            st += j;
        }
        repd(j, n, n - k + 1)
        {
            fin += j;
        }
        ans += (fin - st + 1) % MOD;
        // cout << st << " " << fin << endl;

        repi(i, n + 1, k + 1)
        {
            st += i - 1;
            fin += (n - i + 1);
            // cout << st << " " << fin << endl;
            ans += (fin - st + 1) % MOD;
        }
        cout << (ans + 1) % MOD << endl;
    }
    return 0;
}

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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;


int main() {
    li x;
    cin >> x;
    cout << "Christmas";
    rep(i, 25 - x) {
        cout << " Eve";
    }
    cout << endl;
    return 0;
}

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

using namespace std;
#define SZ(x) (x).size()
#define ALL(x) (x).begin(),(x).end()
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef pair<int,int> PII;
#define MP make_pair

struct Edge{
  int to, cost;
  Edge(int to_, int cost_) : to(to_), cost(cost_){
  }
};
typedef vector<vector<Edge>> Graph;


class UnionFind{
private:
  vector<int> par, rank;
public:
  UnionFind(int n){
	par.assign(n, 0);
	rank.assign(n, 0);
	for(int i=0;i<n;++i)
	  par[i] = i;
  }

  //find root of x
  int find(int x){
	if(par[x] == x)
	  return x;
	return (par[x] = find(par[x]));
  }

  void unite(int x, int y){
	x = find(x);
	y = find(y);
	if(x == y) return;

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

  bool same(int x, int y){
	return find(x) == find(y);
  }
};

const int INF = 1e9;

void dfs(int u, VI& dist, Graph& G){
  for(auto& e: G[u]){
	if(dist[e.to] == INF){
	  dist[e.to] = dist[u] + e.cost;
	  dfs(e.to, dist, G);
	}
  }
}

int main(){
  int N, M;
  while(cin>>N>>M,N&&M){
	VI kind;
	vector<PII> query;
	Graph G(N);
	UnionFind after(N), tmp(N);
	for(int i=0;i<M;++i){
	  char c; cin >> c;
	  if(c == '!'){
		int a, b, c;
		cin >> a >> b >> c;
		--a, --b;
		kind.push_back(0);
		query.push_back(MP(a,b));
		G[a].emplace_back(b,c);
		G[b].emplace_back(a,-c);
		after.unite(a, b);
	  }
	  else{
		int a, b; cin >> a >> b;
		--a, --b;
		kind.push_back(1);
		query.push_back(MP(a,b));
	  }
	}

	VI dist(N, INF);
	for(int i=0;i<N;++i){
	  if(dist[i] == INF){
		int rt = after.find(i);
		dist[rt] = 0;
		dfs(rt, dist, G);
	  }
	}

	for(int i=0;i<SZ(query);++i){
	  if(kind[i]){
		int a = query[i].first;
		int b = query[i].second;
		int u = tmp.find(a);
		if(u != tmp.find(b)){
		  cout << "UNKNOWN" << endl;
		}
		else{
		  cout << dist[b] - dist[a] << endl;
		}
	  }
	  else{
		tmp.unite(query[i].first, query[i].second);
	  }
	}
  }
  
  return 0;
}

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

using namespace std;
typedef long long ll;

#define MOD (long long)(1e9+7)
#define INF (1LL<<60)
#define rep(i,n) for(ll i = 0; i < (n); i++)
#define rep1(i,n) for(ll i = 1; 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;
}


// 最大公約数
ll gcd(ll a, ll b)
{
  if(b == 0) return a;
  return gcd(b, a % b);
}

// mod m におけるa の逆元
ll modinv(ll a, ll m) {
  ll b = m, u = 1, v = 0;
  while (b) {
    ll t = a / b;
    a -= t * b; swap(a, b);
    u -= t * v; swap(u, v);
  }
  u %= m;
  if (u < 0) u += m;
  return u;
}

// 素因数分解
vector<pair<ll, ll>> prim;
void pf(ll n)
{
  ll s = sqrt(n);
  ll r = 0;
  for(ll i = 2; i <= s; i++) {
    if((n % i) == 0) {
      r = 0;
      do {
	r++;
	n = n / i;
      } while((n % i) == 0);
      prim.push_back({i, r});
    }
  }
  if(n > s) {
    prim.push_back({n, 1});
  }
}

void solve()
{
  ll X; cin >> X;
  ll a = X / 500;
  X %= 500;
  ll b = X / 5;
  ll ans = a* 1000 + b * 5;

  cout << ans << endl;
}


int main(void)
{
  // ll t; cin >> t; rep(i, t)
  solve();
}


Measured memory_bytes: 3644
def mod n, i, m=3
  (n + i) % m
end

MOD = 10000
n, k = gets.split.map(&:to_i)

h = Hash.new(-1)
k.times{ 
  a, b = gets.split.map{|x| x.to_i.pred}
  h[a] = b
}

dp = Array.new(n.succ).map{Array.new(3).map{Array.new(3, 0)}}
if h[0] != -1
  dp[0][h[0]][1] = 1
else
  3.times { |j|
    dp[0][j][1] = 1
  }
end

n.pred.times { |i|
  if h[i.succ] != -1
    for j_  in (1..2)
      for k  in (1..2)
        dp[i.succ][h[i.succ]][1] += dp[i][mod(h[i.succ], j_)][k] % MOD
      end     
    end     
    dp[i.succ][h[i.succ]][2] += dp[i][h[i.succ]][1] % MOD
  else
    3.times { |j|
      for j_  in (1..2)
        for k  in (1..2)
          dp[i.succ][j][1] += dp[i][mod(j, j_)][k] % MOD
        end     
      end     
      dp[i.succ][j][2] += dp[i][j][1] % MOD
    }
  end
}
p dp[n.pred].map{|arr| arr.inject :+}.inject(:+) % MOD

Measured memory_bytes: 8736
#include<iostream>
using namespace std;
int n,a,b,ans=1e9,sum;
main()
{
	cin>>n;
	for(a=1;a<n;a++)
	{
		b=n-a;
		sum=0;
		int i=1;
		while(a>=i)
		{
			sum+=a/i%10;
			i*=10;
		}
		i=1;
		while(b>=i)
		{
			sum+=b/i%10;
			i*=10;
		}
		ans=ans<sum?ans:sum;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
using ll = long long;
const ll MOD = 1e9+7; ll LLINF = 1LL << 60; int INF = INT_MAX;

//

int main(){
      int h,w; cin>>h>>w;
      vector<vector<char>> s(h+2,vector<char>(w+2,'.'));
      rep(i,1,h+1)rep(j,1,w+1) cin>>s[i][j];
      bool ok=true;
      rep(i,1,h+1){
            rep(j,1,w+1){
                  if(s[i][j]=='#' && s[i][j+1]!='#' && s[i+1][j]!='#' && s[i-1][j]!='#' && s[i][j-1]!='#') ok=false;
            }
      }
      if(ok) cout<<"Yes"<<endl;
      else cout<<"No"<<endl;
}

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

constexpr int64_t INF = 1'010'000'000'000'000'017LL;
constexpr int64_t MOD = 1'000'000'007LL;
constexpr double EPS = 1e-12;
constexpr double PI = 3.14159265358979323846;

#define FOR(i, start, end) for(int64_t i=start; i<end; i++)
#define REP(i, n) FOR(i, 0, n)

// 最大公約数gcd
// 最小公倍数lcm=m*n/gcd
uint64_t gcd(uint64_t m, uint64_t n) {
  uint64_t temp;
  while (m % n != 0){
    temp = n;
    n = m % n;
    m = temp;
  }
  return n;
}

uint64_t lcm(uint64_t m, uint64_t n) {
  return (m*n)/gcd(m,n);
}

signed main() {
  uint64_t n, r;
  cin >> n >> r;
  
  uint64_t k;
  
  if (n<10) {
    cout << r + 100*(10-n) << endl;
  }
  else {
    cout << r << endl;
  }
  return 0;
}

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

using namespace std;

typedef long long LL;

#define MAX_W 100005
#define MAX_H 100005

LL W, H;
LL P[MAX_W], Q[MAX_H];

void input()
{
  cin >> W >> H;

  for (size_t i = 0; i < W; i++) {
    scanf("%lld", &P[i]);
  }
  for (size_t i = 0; i < H; i++) {
    scanf("%lld", &Q[i]);
  }
}

LL sumQ[MAX_H];
LL calcQ(int l, int r)
{
  return sumQ[r] - sumQ[l];
}

int main()
{
  input();

  sort(Q, Q+H);
  for (size_t i = 0; i < H; i++) {
    sumQ[i+1] = sumQ[i] + Q[i];
  }

  LL ans = 0;
  int n;
  for (size_t i = 0; i < W; i++) {
    int num = upper_bound(Q, Q+H, P[i]) - Q;
    ans += P[i] * (H-num+1) + calcQ(0, num);
    //cerr << P[i] << " " << num << " " << ans << endl;
    n = num;
  }

  ans += calcQ(0, H);
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 2688
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fi first
#define se second
#define pb push_back
#define pr pair<int,int>
#define mod 1000000007
#define endl "\n"
int a[55],b[55],c[55],d[55],n,m,q,ans=0,ar[11];

int power(int a,int b,int m=mod)
{
	if(b==0)	return 1;
	if(b==1)	return a;
	int res=power(a,b/2,m);
	res=(res*res)%m;
	if(b&1)	res=(res*a)%m;
	return res;
}
int modinv(int a,int m=mod){ return power(a,m-2,m);}
int add(int a,int b,int m=mod){	return (a+b)%m;}
int sub(int a,int b,int m=mod){	return (a-b+m)%m;}
int mul(int a,int b,int m=mod){	return (a*b)%m;}

void func()
{
	int val=0;
	for(int i=0;i<q;i++)
	{
		if(ar[b[i]]-ar[a[i]]==c[i])
			val+=d[i];
	}
	ans=max(ans,val);
}

void fun(int idx,int j)
{
	if(idx==n)
	{
		func();
		return;
	}
	for(int i=j;i<=m;i++)
	{
		ar[idx]=i;
		fun(idx+1,i);
	}
}

void solve()
{
	cin>>n>>m>>q;
	int i;
	for(i=0;i<q;i++)
	{
		cin>>a[i]>>b[i]>>c[i]>>d[i];
		a[i]--;b[i]--;
	}
	fun(0,1);
	cout<<ans<<endl;
}

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

Measured memory_bytes: 3676
void main()
{
    long h, w;
    rdVals(h, w);
    long[][] a = h.rdMat;

    Edge[] list;
    long limit = h * w - 1;
    Grid now;
    bool to = true;
    foreach (i; 0 .. limit)
    {
        Grid nxt = now;
        if (nxt.x == 0 && !to) ++nxt.y, to = true;
        else if (nxt.x == w - 1 && to) ++nxt.y, to = false;
        else nxt.x += (to ? 1 : -1);

        if (a[now.y][now.x] & 1)
        {
            --a[now.y][now.x];
            ++a[nxt.y][nxt.x];
            list ~= Edge(now, nxt);
        }

        now = nxt;
    }

    list.length.writeln;
    foreach (l; list)
    {
        writeln(l.from.y + 1, " ", l.from.x + 1, " ", l.to.y + 1, " ", l.to.x + 1);
    }
}

struct Grid
{
    long y, x;
}

struct Edge
{
    Grid from, to;
}

enum long mod = 10^^9 + 7;
enum long inf = 1L << 60;
enum double eps = 1.0e-9;

T rdElem(T = long)()
if (!is(T == struct))
{
    return readln.chomp.to!T;
}

alias rdStr = rdElem!string;
alias rdDchar = rdElem!(dchar[]);

T rdElem(T)()
if (is(T == struct))
{
    T result;
    string[] input = rdRow!string;
    assert(T.tupleof.length == input.length);
    foreach (i, ref x; result.tupleof)
    {
        x = input[i].to!(typeof(x));
    }
    return result;
}

T[] rdRow(T = long)()
{
    return readln.split.to!(T[]);
}

T[] rdCol(T = long)(long col)
{
    return iota(col).map!(x => rdElem!T).array;
}

T[][] rdMat(T = long)(long col)
{
    return iota(col).map!(x => rdRow!T).array;
}

void rdVals(T...)(ref T data)
{
    string[] input = rdRow!string;
    assert(data.length == input.length);
    foreach (i, ref x; data)
    {
        x = input[i].to!(typeof(x));
    }
}

void wrMat(T = long)(T[][] mat)
{
    foreach (row; mat)
    {
        foreach (j, compo; row)
        {
            compo.write;
            if (j == row.length - 1) writeln;
            else " ".write;
        }
    }
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.mathspecial;
import std.traits;
import std.container;
import std.functional;
import std.typecons;
import std.ascii;
import std.uni;
import core.bitop;

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin >> s;
  for (auto& c : s) {
    if (c == '7') {
      cout << "Yes\n";
      return 0;
    }
  }  
  cout << "No\n";
  return 0;
}

Measured memory_bytes: 3652
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

class LowestCommonAncestor
{
private:
    vector<vector<int> > to; // ??????????????°
    vector<int> depth;       // ??????????????±???
    int climb(int curr, int dist)
    {
        int i = 0;
        while(dist > 0){
            if(dist % 2 == 1)
                curr = to[curr][i];
            dist /= 2;
            ++ i;
        }
        return curr;
    }
public:
    LowestCommonAncestor(const vector<vector<int> >& edges, int root)
    {
        int n = edges.size();
        to.assign(n, vector<int>());
        depth.resize(n);

        queue<pair<int, int> > q;
        q.push(make_pair(root, -1));

        int cnt = 0;
        while(!q.empty()){
            int m = q.size();
            while(--m >= 0){
                int curr, prev;
                tie(curr, prev) = q.front();
                q.pop();

                depth[curr] = cnt;
                if(prev != -1){
                    to[curr].push_back(prev);
                    int j = prev;
                    for(unsigned k=0; k<to[j].size(); ++k){
                        j = to[j][k];
                        to[curr].push_back(j);
                    }
                }

                for(int next : edges[curr]){
                    if(next != prev)
                        q.push(make_pair(next, curr));
                }
            }
            ++ cnt;
        }
    }
    // 2??????????????????????°???±????\?????????????
    int getAncestor(int a, int b)
    {
        int diff = depth[a] - depth[b];
        if(diff < 0)
            b = climb(b, -diff);
        else
            a = climb(a, diff);
        if(a == b)
            return a;

        for(int i=to[a].size()-1; i>=0; --i){
            if(i < (int)to[a].size() && to[a][i] != to[b][i]){
                a = to[a][i];
                b = to[b][i];
            }
        }
        return to[a][0];
    }
    // ??????????????±????????????
    int getDepth(int a)
    {
        return depth[a];
    }
    // 2???????????????????????¢?????????
    int getDist(int a, int b)
    {
        int c = getAncestor(a, b);
        return getDepth(a) + getDepth(b) - getDepth(c) * 2;
    }
};

int main()
{
    int n;
    cin >> n;
    vector<vector<int> > edges(n);
    for(int i=0; i<n; ++i){
        int k;
        cin >> k;
        while(--k >= 0){
            int j;
            cin >> j;
            edges[i].push_back(j);
            edges[j].push_back(i);
        }
    }

    LowestCommonAncestor lca(edges, 0);

    int q;
    cin >> q;
    while(--q >= 0){
        int u, v;
        cin >> u >> v;
        cout << lca.getAncestor(u, v) << endl;
    }

    return 0;
}

Measured memory_bytes: 20876
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <random>
#include <iomanip>
#include <unordered_set>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<pair<ll,ll> > vpll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<vc> vvc;
typedef vector<vs> vvs;
typedef vector<vll> vvll;
typedef map<int,int> mii;
typedef set<int> si;
#define rep(i,n) for(ll i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define arep(i,v) for(auto i : v)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STLL(s) strtoll(s.c_str(), NULL, 10)
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define fi first
#define se second
constexpr int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
template <class T> inline void dump(T &v){irep(i, v){cout<<*i<<((i==--v.end())?'\n':' ');}}
inline string getline(){string s; getline(cin,s); return s;}
inline void yn(const bool b){b?fin("yes"):fin("no");}
inline void Yn(const bool b){b?fin("Yes"):fin("No");}
inline void YN(const bool b){b?fin("YES"):fin("NO");}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
constexpr ll LLINF = 1LL<<60;
constexpr ll MOD = 1000000007;
constexpr ld EPS = 1e-11;


int main() {
    
    int n;
    cin>>n;
    vi v(n);
    rep(i,n)cin>>v[i];
    int q;
    cin>>q;
    rep(_,q){
        int x;
        cin>>x;
        int t=distance(v.begin(),lower_bound(all(v),x));
        fin(t);
    }
}


Measured memory_bytes: 3116
x1, y1, x2, y2 = map(int, raw_input().split())

dx = x2 - x1
dy = y2 - y1

x3 = x2 - dy
y3 = y2 + dx
x4 = x3 - dx
y4 = y3 - dy

print str(x3) + ' ' + str(y3) + ' ' + str(x4) + ' ' + str(y4)

Measured memory_bytes: 2568
#include <bits/stdc++.h>
#define INF 1000000007
#define rep(i, N) for(ll i = 0; i < N; i++)
#define rep2(i, j, k) for(ll i = j; i < k; i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define print(x) cout << x << "\n"
#define print2(x, y) cout << x << " " << y << "\n"
#define printv(vec) rep(lp, vec.size()) cout << vec[lp] << " "; print(""); 
#define show(x) cerr << #x << " = " << x << "\n";
#define ALL(v) v.begin(), v.end()
#define SUM(v) accumulate(ALL(v), 0)
#define MAX(v) *max_element(ALL(v))
#define MIN(v) *min_element(ALL(v))
#define SORT(v) sort(ALL(v))
#define REV(v) reverse(ALL(v))
#define pb(x) emplace_back(x)
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
typedef long long ll;
using namespace std;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vs = vector<string>;

const int mod = INF;
class mint {
public:
	ll x;
	mint(ll x = 0) : x((x % mod + mod) % mod) {}
	mint operator-() const { 
		return mint(-x);
	}
	mint& operator+=(const mint& a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint& a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const  mint& a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint& a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint& a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint& a) const {
		mint res(*this);
		return res *= a;
	}
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}
	mint inv() const {
		return pow(mod - 2);
	}
	mint& operator/=(const mint& a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint& a) const {
		mint res(*this);
		return res /= a;
	}
	friend ostream& operator<<(ostream& os, const mint& m){
		os << m.x;
		return os;
	}
};

ll modpow(ll x, ll n, ll p = INF) {
	if (n == 0) return 1 % p;
	if (n % 2 == 0) return modpow(x * x % p, n / 2, p);
	else return x * modpow(x, n - 1, p) % p;
}

ll extgcd(ll a, ll b, ll &x, ll &y){
	if(b == 0){
		x = 1;
		y = 0;
		return a;
	}
	ll gcd = extgcd(b, a % b, x, y);
	ll oldX = x;
	x = y;
	y = oldX - a / b * y;
	return gcd;
}

void Main(){
	
	int N;
	cin >> N;
	vector<int> v(N);
	for(int i = 0; i < N; i++) cin >> v[i];
	
	ll sum = 0;
	for(int i = 0; i < N; i++) sum += v[i];
	
	int ans = sum;
	if(!(ans % 10)) ans = 0;
	
	for(int i = 0; i < N; i++){
		int tmp = sum - v[i];
		if(!(tmp % 10)) tmp = 0;
		ans = max(ans, tmp);
	}
	
	print(ans);
	
}

int main(){
	
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	ll t = 1;
	//cin >> t;
	rep(i, t) Main();
	return 0;
	
}





Measured memory_bytes: 3604
#include <stdio.h>

int A[1000000], n;

int BinarySearch(int);

int main(){
  int i, q, k, sum = 0;

  scanf("%d", &n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }

  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&k);
    if(BinarySearch(k)) sum++;
  }

  printf("%d\n",sum);
  
  return 0;
}

int BinarySearch(int key){
  int left = 0;
  int right = n;
  int mid;

  while(left < right){
    mid = (left + right)/2;
    if(key == A[mid]) return 1;
    if(key > A[mid]) left = mid + 1;
    else if(key < A[mid]) right = mid;
  }
  return 0;
}



Measured memory_bytes: 2088
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, m, n) for (int i = m; i < n; ++i)
#define FORR(i, m, n) for (int i = m; i >= n; --i)
#define ALL(v) (v).begin(),(v).end()
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; }
const ll INF=1LL<<60;
const int inf=(1<<30)-1;
const int mod=1e9+7;
int dx[8]={1,0,-1,0,-1,-1,1,1};
int dy[8]={0,1,0,-1,-1,1,-1,1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,k;cin >> n >> k;
    vector<int> p(n);
    REP(i,n){
        cin >> p[i];
    }
    sort(ALL(p));
    int ans=0;
    REP(i,k){
        ans+=p[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
#define mod 1000000007
using namespace std;
typedef long long ll;
ll n,a,b,res;
ll fact[200005],inv[200005];

inline ll read(){
    ll s=0,w=1;
    char ch=getchar();
    
    while(ch<'0' || ch>'9'){
        if(ch=='-')
            w=-w;
        ch=getchar();
    }
    while(ch>='0' && ch<='9'){
        s=(((s*10ll)%mod)+(ch-'0'))%mod;
        ch=getchar();
    }
    return s;
}

ll power(ll a,ll b){
    a%=mod;
    b%=mod;
    ll ans=1%mod;
    for(;b;b>>=1){
        if(b&1){
            ans=ans*a%mod;
        }
        a=a*a%mod;
    }
    return ans;
}

ll calc(ll n,ll m){
    ll a1=1,a2=1;
    for(int i=n;i>=n-m+1;i--){
        a1=a1*i%mod;
    }
    for(int i=2;i<=m;i++){
        a2=a2*i%mod;
    }
    return a1*power(a2,mod-2)%mod;
}

int main(){
    n=read();
    a=read();
    b=read();
    res=(power(2LL,n)-1-calc(n,a)%mod-calc(n,b)%mod+mod+mod)%mod;
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<iomanip>
#include<ctime>
#include<set>
#include<map>
#include<queue>
#include<stack>
#define sqr(x) ((x)*(x))
#define fz1(i,n) for ((i)=1;(i)<=(n);(i)++)
#define fd1(i,n) for ((i)=(n);(i)>=1;(i)--)
#define fz0g(i,n) for ((i)=0;(i)<=(n);(i)++)
#define fd0g(i,n) for ((i)=(n);(i)>=0;(i)--)
#define fz0k(i,n) for ((i)=0;(i)<(n);(i)++)
#define fd0k(i,n) for ((i)=(long long)((n)-1);(i)>=0;(i)--)
#define fz(i,x,y) for ((i)=(x);(i)<=(y);(i)++)
#define fd(i,y,x) for ((i)=(y);(i)>=(x);(i)--)
#define fzin fz1(i,n)
#define fzim fz1(i,m)
#define fzjn fz1(j,n)
#define fzjm fz1(j,m)
#define ff(c,itr) for (__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
#define rdst(st,len){static char ss[len];scanf(" %s",ss);(st)=ss;}
#define inc(x,y) {x+=(y);if(x>=mod)x-=mod;}
#define dec(x,y) {x-=(y);if(x<0)x+=mod;}
#define spln(i,n) (i==n?'\n':' ')
using namespace std;
long long n,k,i,j,a[100005],b[100005],l[100005],r[100005],dp[100005],tag[800005],sum;
vector<long long> all;
void upd(long long x,long long y)
{
	tag[x]=y;
}
void pushdo(long long x)
{
	if(tag[x]){
		upd(x+x,tag[x]);
		upd(x+x+1,tag[x]);
		tag[x]=0;
	}
}
void update(long long x,long long l,long long r,long long ql,long long qr,long long c)
{
	if(ql>qr)return;
	if(ql<=l&&r<=qr){
		upd(x,c);
		return;
	}
	long long mid=(l+r)/2;
	pushdo(x);
	if(ql<=mid) update(x+x,l,mid,ql,qr,c);
	if(qr>mid) update(x+x+1,mid+1,r,ql,qr,c);
}
long long query(long long x,long long l,long long r,long long y)
{
	if(l==r) return tag[x];
	long long mid=(l+r)/2;
	pushdo(x);
	if(y<=mid) return query(x+x,l,mid,y); else return query(x+x+1,mid+1,r,y);
}
long long fwd(long long x,long long y)
{
	return (all[y-1]+k-all[x-1])%k;
}
int main()
{
	scanf("%lld%lld",&n,&k);
	fz1(i,n){
		scanf("%lld%lld",&a[i],&b[i]);
		if(b[i]==1&&a[i]+a[i]>k){
			puts("-1");
			return 0;
		}
		sum+=a[i];
		a[i]=a[i]+a[i-1];a[i]%=k;
	}
	fz1(i,n){
		if(b[i]==1){
			l[i]=2*(k-a[i-1])%k;
			r[i]=2*(k-a[i])%k;
		}
		else{
			l[i]=0;
			r[i]=k-1;
		}
		all.push_back(l[i]);
		all.push_back(r[i]);
	}
	sort(all.begin(),all.end());
	all.resize(unique(all.begin(),all.end())-all.begin());
	fz1(i,n){
		l[i]=upper_bound(all.begin(),all.end(),l[i])-all.begin();
		r[i]=upper_bound(all.begin(),all.end(),r[i])-all.begin();
	}
	fd1(i,n){
		long long lst=query(1,1,all.size(),l[i]);
		if(!lst){
			dp[i]=0;
		}
		else{
			dp[i]=dp[lst]+fwd(l[i],l[lst]);
		}
		if(r[i]<l[i]){
			update(1,1,all.size(),r[i]+1,l[i]-1,i);
		}
		else{
			update(1,1,all.size(),1,l[i]-1,i);
			update(1,1,all.size(),r[i]+1,all.size(),i);
		}
	}
	long long ans=dp[1];
	fz1(i,all.size()){
		long long lst=query(1,1,all.size(),i);
		if(!lst) ans=0; else ans=min(ans,dp[lst]+fwd(i,l[lst]));
	}
	cout<<ans+sum*2<<endl;
	return 0;
}

Measured memory_bytes: 10096
use std::io;


fn main() {
    let (n, q) = {
        let i = read::<usize>();
        (i[0], i[1])
    };
    let s = read_one::<String>()
        .chars()
        .collect::<Vec<char>>();

    let mut cnt = vec![0; n];

    for i in 1..n {
        if s[i - 1] == 'A' && s[i] == 'C' { cnt[i] += 1; }
        cnt[i] += cnt[i - 1];
    }

    for _ in 0..q {
        let (l, r) = {
            let i = read::<usize>();
            (i[0] - 1, i[1] - 1)
        };
        println!("{}", cnt[r] - cnt[l])
    }
}


#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
std::str::FromStr,
T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
std::str::FromStr,
T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

Measured memory_bytes: 4860
#include<iostream>
#include<cstdio>
#include<queue>
#include<algorithm>
using namespace std;
int n;
char a[1000010],b[1000010];
int main(){
	scanf("%d",&n);
	scanf("%s",a+1);
	scanf("%s",b+1);
	bool flag=1;
	for(int i=1;i<=n;++i)if(a[i]!=b[i])flag=0;
	if(flag){
		cout<<0;
		return 0;
	}
	queue<int> q;
	int pos=n,ans=0;
	for(int i=n;i>=1;--i){
		if(b[i]==b[i-1])continue;
		pos=min(pos,i);
		while(pos&&a[pos]!=b[i])pos--;
		if(!pos){
			cout<<-1;
			return 0;
		}
		while(!q.empty()){
			if(q.front()-q.size()>=i)q.pop();
			else break;
		}
		q.push(pos);
		if(i!=pos)ans=max(ans,(int)q.size());
	}
	cout<<ans+1;
}

Measured memory_bytes: 6272
#include<iostream>
#include<cstdio>
#include<cstdlib>
#define ll long long
#define N 310
using namespace std;
ll C[N][N],mod;
ll f[N][N],g[N][N];
ll ksm(ll a,ll b=mod-2)
{
	ll ans=1;
	for(;b;b>>=1)
	{
		if(b&1) ans=ans*a%mod;
		a=a*a%mod;
	}
	return ans;
}
int main()
{
	int n,m;
	scanf("%d%d%lld",&n,&m,&mod);
	C[0][0]=1;
	for(int i=1;i<=n;i++)
	{
		C[i][0]=1;
		for(int j=1;j<=i;j++)
			C[i][j]=(C[i-1][j-1]+C[i-1][j])%mod;
	}
	for(int i=0;i<=m;i++)
	{
		f[1][i]=1;
		g[1][i]=m-i+1;
	}
	for(int i=2;i<=n+1;i++)
	{
		for(int j=0;j<=m;j++)
			for(int k=1;k<i;k++)
				f[i][j]=(f[i][j]+f[i-k][j]*g[k][j+1]%mod*C[i-2][k-1])%mod;
		for(int j=m;j>=0;j--)
			g[i][j]=(f[i][j]+g[i][j+1])%mod;
    }
    printf("%lld",f[n+1][0]);
	return 0;
}


Measured memory_bytes: 2432
#include<math.h>
#include<limits.h>
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<sstream>
#include<list>
#include<queue>
#include<algorithm>
#include<functional>
#include<map>
#include<set>
#include<utility>
#include<initializer_list>
#include<tuple>
#include<regex>
using namespace std;
#define ull unsigned long long
#define ll long long
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define all(t) t.begin(), t.end()
#define mat(type, row, col, init) vector<vector<type>>(row, vector<type>(col, init));
int que(int i) {
	// arg: 0-indexed
	static char q[10];
	static char sv = 'V', sm = 'M', sf = 'F';
	printf("%d\n", i);
	fflush(stdout);
	scanf("%s", q);
	if (q[0] == sv) {
		cout << i << endl;
		exit(0);
	}
	else if (q[0] == sm) return 0;
	else if (q[0] == sf) return 1;
}

int main() {
	int n;
	cin >> n;
	vector<int>a(n, 0);
	int base = que(0);
	int midv;
	int lb = 0, ub = n;
	while (ub - lb >= 1) {
		int mid = (lb + ub) / 2;
		midv = que(mid);
		int expect = (mid % 2 == 0 ? base : !base);
		if (expect ==midv) {
			lb = mid;
		}
		else {
			ub = mid;
		}
	


	}

	return 0;
}





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

int cmp(const int *a,const int *b){

return *a > *b ? -1 : *a < *b ? 1 : 0 ;
}
//qsort(pa,n,sizeof(int),(int(*)(const void* ,const void*))cmp);

int main(void){

  int a,b;
  scanf("%d%d",&a,&b);
  int ans;
  ans=6-(a+b);
  printf("%d",ans);


  return 0;
}


Measured memory_bytes: 128