akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include <iostream>
#include <complex>
#include <algorithm>
#include <vector>
#include <stack>
#include <string>
#include <queue>
#include <cmath>
#include <math.h>
#include <numeric>
#include <list>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <climits>
#include <set>
#include <memory.h>
#include <memory>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cassert>
#include <map>
#include <cassert>
#include <time.h>
#include <ctime>

using namespace std;

typedef complex<double> xy_t;
typedef pair<xy_t, xy_t> line;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int , P> PP;
typedef pair<int, string> Ps;
typedef vector<int> vec;
typedef vector<vec> mat;
const int INF = 1 << 30;
const double EPS = 1e-9;
const double PI = 3.1415926535897932384626433832795;
const int CLK = CLOCKS_PER_SEC;

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

int main(){
	double la[2], lo[2];
	while(cin >> la[0] >> lo[0] >> la[1] >> lo[1] && (abs(la[0] + 1) > EPS 
		|| abs(la[1] + 1) > EPS || abs(lo[0] + 1) > EPS || abs(lo[1] + 1) > EPS)){

	
		double x[2], y[2], z[2];
		rep(i, 2){
			la[i] *= (M_PI) / 180.0;
			lo[i] *= (M_PI) / 180.0;
		}
		rep(i, 2){
			z[i] = sin(la[i]);
			y[i] = cos(la[i]) * sin(lo[i]);
			x[i] = cos(la[i]) * cos(lo[i]);
		}
		double dis = sqrt((x[0]-x[1])*(x[0]-x[1])+(y[0]-y[1])*(y[0]-y[1])+(z[0]-z[1])*(z[0]-z[1]));
		double theta = asin(dis/2);
		double res = theta * 2;
		cout << (int)(res * 6378.1 + 0.5) << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <climits>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <set>
#include <map>
#include <deque>
#include <queue>
#define px first
#define py second
#define fi first
#define se second
#define LD long double

//#define DEBUG
#ifdef DEBUG
#include "Debug.h"
#endif // DEBUG

using namespace std;

const int INF = INT_MAX;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    int p = -1;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    int cnt = INF;
    for (int i = 0; i <= n - k; i++) {
        if (a[i] < 0 && a[i + k - 1] > 0) {
            cnt = min(cnt, abs(a[i] * 2) + a[i + k - 1]);
            cnt = min(cnt, abs(a[i]) + 2 * a[i + k - 1]);
        }else if (a[i] < 0 && a[i + k - 1] < 0) {
            cnt = min(cnt, abs(a[i]));
        }else {
            cnt = min(cnt, a[i + k - 1]);
        }
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 640
import sys,math
def prime(n):
    a = [0] * (n+1)
    for i in range(2, n+1):
        isPrime = a[i] == 0
        a[i] = a[i-1] + isPrime * 1
        if isPrime:
            r = slice(i*2, n+1, i)
            a[r] =[1 for x in a[r]]
    return a
prime = prime(999999)
for i in sys.stdin:
    print(prime[int(i)])


Measured memory_bytes: 50216
using System;
using System.Linq;
using System.Collections.Generic;

namespace PANASONIC2020
{
    class B
    {
        static void Main(string[] args)
        {
            var a = Console.ReadLine().Split().Select(long.Parse).ToArray();
            var H = a[0];
            var W = a[1];

            if (H == 1 || W == 1) { Console.WriteLine(1); return; }

            long res = (long)Math.Ceiling((double)(H * W) / 2);

            Console.WriteLine(res);
        }
    }
}


Measured memory_bytes: 13268
/**********************************************
 *Author*        :jxf378440404
 *Created Time*  : 2018/9/29 19:59:46

*********************************************/

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
using namespace std;
typedef long long LL;
const int MaxN = 1e5;
const int Inf = 1 << 30;

int main()
{
	int n,a,b,c;
	while(~scanf("%d",&n)){
		for(int i = n;i <= 999;i++){
			if(i == 111 || i == 222 || i == 333|| i == 444|| i == 999){
				printf("%d\n",i);
				break;
			}
			else if(i == 555 || i == 666 || i == 777 || i == 888){
				printf("%d\n",i);
				break;
			}
		}
	}
    return 0;
}

Measured memory_bytes: 128
void solve();

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

//////////////////////////////////////////////////
//////////////////////////////////////////////////
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
using namespace std;

int N, M, P;
class edge {
public:
	int a, b, c;
};
vector<edge> Edges;
vector<int> dp;

void solve() {
	cin >> N >> M >> P;
	Edges.resize(M);
	for (int m = 0; m < M; m++) {
		cin >> Edges[m].a >> Edges[m].b >> Edges[m].c;
		Edges[m].a--; Edges[m].b--;
		Edges[m].c = P - Edges[m].c;
	}
	dp.resize(N, INT_MAX);
	dp[0] = 0;
	for (int time = 0;time < N; time++) {
		for (auto itr = Edges.begin(); itr != Edges.end(); itr++) {
			if (dp[itr->a] == INT_MAX)continue;
			if (dp[itr->b] > dp[itr->a] + itr->c) {
				dp[itr->b] = dp[itr->a] + itr->c;
			}
		}
	}
	vector<bool> negcheck;
	negcheck.resize(N,false);
	for (int time = 0; time < N; time++) {
		for (auto itr = Edges.begin(); itr != Edges.end(); itr++) {
			if (dp[itr->a] == INT_MAX)continue;
			if (dp[itr->b] > dp[itr->a] + itr->c) {
				dp[itr->b] = dp[itr->a] + itr->c;
				negcheck[itr->b] = true;
			}
          if(negcheck[itr->a])negcheck[itr->b] = true;
		}
	}
	if (negcheck[N - 1])cout << -1 << endl;
	else if (dp[N - 1] >= 0)cout << 0 << endl;
	else cout << -dp[N - 1] << endl;
	return;
}

Measured memory_bytes: 256
#define TEST_MODE true

#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, a, b) for (int i = (a); i < (int)(b); ++i)
#define rrep(i, n) for (int i = (n)-1; i >= 0; --i)
#define rrep2(i, a, b) for (int i = (a)-1; i >= (int)b; --i)
#define range(i, a, b, c) for (int i = a;             \
                                   c > 0 ? i < b : i > b; \
                                   i += c)
#define chmax(a, b) (a = (a) < (b) ? (b) : (a))
#define chmin(a, b) (a = (a) > (b) ? (b) : (a))
using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define all(a) begin(a), end(a)
#define ifnot(a) if (not(a))
#define int long long

#ifdef LOCAL_ENV

#if TEST_MODE == true
const bool test = true;
#define dump(x) cerr << #x << " = " << (x)
#define dumpl(x) dump(x) << endl
#else
const bool test = false;
#define dump(x) 
#define dumpl(x)
#endif

#else
const bool test = false;
#define dump(x) 
#define dumpl(x)
#endif

int dx[] = { 1, 0, -1, 0 };
int dy[] = { 0, 1, 0, -1 };
const int INF = (int)1 << 60;
const ll INFL = (ll)1 << 60;
ll mod_n = (int)1e9 + 7;
const double eps = 1e-10;
typedef long double Real;
// return -1, 0, 1
int sgn(const Real &r) { return (r > eps) - (r < -eps); }
int sgn(const Real &a, const Real &b) { return sgn(a - b); }

//.....................
const int MAX = (int)2e5 + 5;

vector<string> split(const string &str, char sep)
{
	vector<string> v;
	stringstream ss(str);
	string buffer;
	while (getline(ss, buffer, sep))
	{
		v.push_back(buffer);
	}
	return v;
}

template <class InputIterator>
int sum(InputIterator begin, InputIterator end)
{
	return accumulate(begin, end, 0ll);
}

template<typename T>
T gcd(T a, T b)
{
	T c;
	while (a != 0) {
		c = a; a = b%a;  b = c;
	}
	return b;
}

template<typename T>
T bit_count(T N) {
	T cnt = 0;
	while (N) {
		if (N & 1) cnt++;
		N >>= 1;
	}
	return cnt;
}

struct Point {
	int y, x;
	bool operator < (const Point& r) {
		if (x < r.x) return true;
		else return false;
	}
};

class Solver {
public:
	int N;

	void solve() {
		cin >> N;

		string s;
		int v = N;
		rep(i, 50) {
			if (v == 0) break;
			int d = (int)1;
			dumpl(d);
			int a = abs(v) % (d << (i + 1));
			if (a == 0) {
				s = "0" + s;
				continue;
			}
			int b = d << i;
			int c = b * (i % 2 == 0 ? 1 : -1);
			s = "1" + s;
			v -= c;
			
			dumpl(c);
			dumpl(v);
		}
		if (s == "") s = "0";
		cout << s << endl;
	}
};

signed main()
{
	srand((unsigned int)time(NULL));
	cout << fixed << setprecision(20);
	auto ptr = new Solver();
	ptr->solve();
	delete ptr;
	//while (true) {
	//	if (cin.eof() == true) break;
	//	auto ptr = new Solver();
	//	ptr->solve();
	//	delete ptr;
	//}
	return 0;
}

Measured memory_bytes: 256
integer,dimension(3)::x!３つの成分を持つ配列としてxを宣言
read*,x!なんかこれで勝手に読み込んでくれる
if (maxval(x)*2==sum(x)) then!maxval(x)は配列xの最大値,sum(x)は配列xの合計値
	print"(A)","Yes"
else
	print"(A)","No"
endif
end

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast", "unroll-loops")
#define ll long long 
#define pii pair<int, int>
#define ull unsigned ll
#define f first
#define s second
#define FOR(i,a,b) for (int i=(a); i<(b); i++)
#define REP(i,n) for (int i=0; i<(n); i++)
#define RREP(i,n) for (int i=(n-1); i>=0; i--)
#define ALL(x) x.begin(),x.end()
#define SZ(x) x.size()
#define SQ(x) (x)*(x)
#define MNTO(a,b) a = min(a,(__typeof__(a))(b))
#define MXTO(a,b) a = max(a,(__typeof__(a))(b))
#define pb push_back
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define debug(x) cerr<<#x<<" is "<<x<<endl
using namespace std;

// #define int ll

const int iinf = 1<<29;
const ll inf = 1ll<<60;
const ll mod = 1e9+7;


void GG(){cout<<"No\n"; exit(0);}

ll mpow(ll a, ll n){ // a^n % mod
    ll re=1;
    while (n>0){
        if (n&1) re = re*a %mod;
        a = a*a %mod;
        n>>=1;
    }
    return re;
}

ll inv (ll b){
    if (b==1) return b;
    return (mod-mod/b) * inv(mod%b) % mod;
}

const int maxn = 1e5+5;

vector<ll> p;
ll pos[maxn];

bool done[maxn];

main(){
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    ll n; cin>>n;
    vector<ll> x(n); REP(i,n) cin>>x[i];
    ll m, k; cin>>m>>k;
    vector<ll> v(m);
    vector<ll> d;
    REP(i,m){
        cin>>v[i];
    }
    REP(i,n){
        if (i) d.pb(x[i] - x[i-1]);
    }
    // k%=2;
    k--;
    REP(i,n-1) p.pb(i);
    REP(i,m){
        swap(p[v[i]-2], p[v[i]-1]);
    }
    REP(i,n-1){
        if (done[i]) continue;
        vector<ll> tmp;
        ll at = i; 
        tmp.pb(at); at = p[at];
        while (at != i){
            tmp.pb(at); at = p[at];
        }
        ll j = tmp.size(); ll df = k%j;
        REP(h,j){
            pos[tmp[h]] = tmp[(h+df+1)%j];
            done[tmp[h]]=1;
        }
    }

    ll at = x[0];
    REP(i,n){
        cout<<at<<'\n';
        if (i!=n-1) at += d[pos[i]];
    }
} 

Measured memory_bytes: 5476
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <sstream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>

#define rep(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define all(v) (v).begin(), (v).end()
#define rev(s) (s).rbegin(), (s).rend()
#define MP make_pair
#define X first
#define Y second

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;

int op(int lhs, int rhs, int ope){
	if(ope == 0) return lhs+rhs;
	if(ope == 1) return lhs-rhs;
	if(ope == 2) return lhs*rhs;
}

int calc(int a, int b, int c, int d, int o1, int o2, int o3){
	if( op(op(op(a, b, o1), c, o2), d, o3) == 10) return 0; // 1->2->3
	if( op(op(a, op(b, c, o2), o1), d, o3) == 10) return 1; // 2->1->3
//	if(	op(a, op(op(b, c, o2), d, o3), o1) == 10) return 2; // 2->3->1
//	if(	op(a, op(b, op(c, d, o3), o2), o1) == 10) return 3; // 3->2->1
	if(	op(op(a, b, o1), op(c, d, o3), o2) == 10) return 4; // 1->3->2 (== 3->1->2)
	return -1;
}

void output(int a, int b, int c, int d, int o1, int o2, int o3, int type){
	string ope = "+-*";
	if(type == 0) printf("(((%d %c %d) %c %d) %c %d)\n", a, ope[o1], b, ope[o2], c, ope[o3], d);
	if(type == 1) printf("((%d %c (%d %c %d)) %c %d)\n", a, ope[o1], b, ope[o2], c, ope[o3], d);
	if(type == 2) printf("(%d %c ((%d %c %d) %c %d))\n", a, ope[o1], b, ope[o2], c, ope[o3], d);
	if(type == 3) printf("(%d %c (%d %c (%d %c %d)))\n", a, ope[o1], b, ope[o2], c, ope[o3], d);
	if(type == 4) printf("((%d %c %d) %c (%d %c %d))\n", a, ope[o1], b, ope[o2], c, ope[o3], d);
}

bool solve(int a, int b, int c, int d){
	rep(o1, 3) rep(o2, 3) rep(o3, 3){
		int res = calc(a, b, c, d, o1, o2, o3);
		if(res != -1){
			output(a, b, c, d, o1, o2, o3, res);
			return true;
		}
	}
	return false;
}

int main(){
	vi a(4);
	while(1){
		rep(i, 4) cin >> a[i];
		if(!a[0]) break;
		sort(all(a));
		bool ok;
		do{
			ok = solve(a[0], a[1], a[2], a[3]);
		}while(!ok && next_permutation(all(a)));
		if(!ok) cout << "0" << endl;
	}

	return 0;
}

Measured memory_bytes: 1248
#include <iostream>
#define mxn 100010
#define inf 10001
using namespace std;

int ar[mxn], dp[mxn];

int solve(int n, int k) {
    if(n == 1) return 0;
    if(n < 1) return inf;
    if(dp[n] != -1) return dp[n];
    int ans = (1 << 30);
    for(int i=1; i<=k; ++i) ans = min(ans, solve(n-i, k) + abs(ar[n] - ar[n - i]));
    return dp[n] = ans;
}

int main() {
    int n, k; cin >> n >> k;
    fill(dp, dp+mxn, -1);
    for(int i=1; i<=n; ++i) cin >> ar[i];
    cout << solve(n, k);
    return 0;
}

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

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

    int n, m;
    cin >> n >> m;
    vector<int> A(n), B(n);
    for(int i = 0; i < n; i++){
        cin >> A[i] >> B[i];
    }
    vector<int> C(m), D(m);
    for(int i = 0; i < m; i++){
        cin >> C[i] >> D[i];
    }

    for(int i = 0; i < n; i++){
        int mini = 1e9, p;
        for(int j = 0; j < m; j++){
            int cost = abs(A[i] - C[j]) + abs(B[i] - D[j]);
            if(mini > cost){
                p = j + 1;
                mini = cost;
            }
        }
        cout << p << endl; 
    }

    return 0;
}

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

#define REP(i, n) for(int i = 0;i < n;i++)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define ALL(a) (a).begin(), (a).end()

using namespace std;

int main()
{
    int A, B; cin >> A >> B;

    bool ok = (A % 3 == 0) || (B % 3 == 0) || ((A + B) % 3 == 0);

    cout << (ok?"Possible":"Impossible") << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
       int t;
       int ct=0;
       cin>>t;
       int a[t],b[t];
       for(int i=0;i<t;i++){
            cin>>a[i]>>b[i];
       }
        for(int i=0;i<t;i++){
               if(a[i]==b[i]) {ct++;
                if(ct==3) break;
               }
                else
                    ct=0;
        }
       if(ct==3) cout<<"Yes"<<endl;
       else
        cout<<"No"<<endl;
}


Measured memory_bytes: 3624
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let  s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

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

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

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

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

fn main() {
    ipt_1_2_c();
}

fn ipt_1_2_c(){
    input!{
        v: [i32; 3]
    }
    let mut v = v;
    v.sort();
    println!("{} {} {}", v[0], v[1], v[2]);
}


Measured memory_bytes: 5036
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>

#define FOR(i, a, b) for (int i = (a); i < int(b); ++i)
#define RFOR(i, a, b) for (int i = (b)-1; i >= int(a); --i)
#define REP(i, n) FOR(i, 0, n)
#define REP1(i, n) FOR(i, 1, int(n) + 1)
#define RREP(i, n) RFOR(i, 0, n)
#define RREP1(i, n) RFOR(i, 1, int(n) + 1)
#define ALL(c) begin(c), end(c)

int _ = (
#ifndef LOCAL
    std::cin.tie(nullptr), std::ios::sync_with_stdio(false),
#endif
    std::cout.precision(10), std::cout.setf(std::ios::fixed));

using ll = long long;
using ull = unsigned long long;
using ld = long double;
template <typename T> using vec = std::vector<T>;
using namespace std;

int main() {
  int A, B;
  cin >> A >> B;
  REP1(i, 1009) {
    const int x = static_cast<int>(floor(i * 0.08));
    const int y = static_cast<int>(floor(i * 0.1));
    if (x == A && y == B) {
      cout << i << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}


Measured memory_bytes: 3600
#include<bits/stdc++.h>
#define For(i,x,y) for (register int i=(x);i<=(y);i++)
#define FOR(i,x,y) for (register int i=(x);i<(y);i++)
#define Dow(i,x,y) for (register int i=(x);i>=(y);i--)
#define Debug(v) for (auto i:v) printf("%lld ",i);puts("")
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define ep emplace_back
#define siz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define fil(a,b) memset((a),(b),sizeof(a))
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pa;
typedef pair<ll,ll> PA;
typedef vector<int> poly;
inline ll read(){
    ll x=0,f=1;char c=getchar();
    while ((c<'0'||c>'9')&&(c!='-')) c=getchar();
    if (c=='-') f=-1,c=getchar();
    while (c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
    return x*f;
}

const int N = 2e5+10;
int n;
ll pre[N];

int main(){
	n=read();
	For(i,1,n) pre[i]=pre[i-1]+read();
	ll ans=1e18;
	For(i,1,n-1){
		ll x=pre[i],y=pre[n]-pre[i];
		ans=min(ans,abs(x-y));
	}
	printf("%lld\n",ans);
}

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

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for (int &i : a)
    cin >> i;
  int sum = 0;
  sort(a.begin(), a.end(), greater<int>());
  for (int i = 0; i < k; i++) {
    sum += a[i];
  }
  cout << sum << endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		String str = in.next();
		String a = str.substring(2, 3);
		String b = str.substring(3, 4);
		String c = str.substring(4, 5);
		String d = str.substring(5, 6);
		if(a.equals(b) && c.equals(d)) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 22996
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQG = priority_queue<T, vector<T>, greater<T> >;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) {return a < b && (a = b, true);}
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) {return a > b && (a = b, true);}
template<typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &p) { return is >> p.first >> p.second;}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) { return os << p.first << ' ' << p.second;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vi a(n);
    rep(i, n) cin >> a[i];

    int x = 0;
    rep(i, n) {
        x ^= a[i];
        int num = __builtin_ctz(a[i]);
        a[i] = (1<<num+1)-1;
    }
    sort(rall(a));

    int cnt = 0;
    rep(i, n) {
        if(__builtin_clz(a[i]) == __builtin_clz(x) and x) {
            cnt++;
            x ^= a[i];
        }
    }
    if(x) cout << -1 << endl;
    else cout << cnt << endl;
}

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

int main() {
  int a[51];
  int n,c=0;
  cin>>n;
  for(int i=0; i<n; i++) {
	int x; cin >> x;
	x--;
    if(x!=i) c++;
  }
  if(c>2) cout << "NO" << endl;
  else cout << "YES" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <queue>
#include <map>
using namespace std;
typedef long long ll;
const int INF = 1<<30; 
const int MOD = 1e9 + 7;
const int dy[] = {1, 0, -1, 0};
const int dx[] = {0, 1, 0, -1};
const int MAX_N = 110;
const int MAX_W = 100100;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, W;
    cin >> N >> W;
    ll v[N + 1], w[N + 1];
    for(int i = 0; i < N; i++) cin >> v[i] >> w[i];
    ll dp[N + 1][W + 1] = {};
    for(int i = 0; i < N; i++)
    {
        for(int j = 0; j <= W; j++)
        {
            if(j - w[i] < 0) 
            {
                dp[i + 1][j] = dp[i][j];
            }
            else 
            {
                dp[i + 1][j] = max(dp[i][j], dp[i + 1][j - w[i]] + v[i]);
            }
        }
    }
    cout << dp[N][W] << endl;
    return 0;
}




Measured memory_bytes: 11088
/* ALDS1_4_A: Linear Search */
/* 20181115 AOJ */

#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>

#define N 100001
#define Q 50000

int binarySearch(int *A, int n, int key);

int main(void){
	int n, S[N], q, T[Q], i = 0, j = 0, C = 0;

	scanf("%d", &n);
	while(i < n){
		scanf("%d", &S[i++]);
	}

	scanf("%d", &q);
	i = 0;
	while(i < q){
		scanf("%d", &T[i]);
		if(binarySearch(S, n, T[i++])) C++;
	}

	printf("%d\n", C);

	return 0;
}

int binarySearch(int *A, int n, int key){
	int i = 0, low, high, mid;
	
	low = 0;
	high = n;
	while(low < high){
		mid = (low + high) / 2;
		if(A[mid] == key){
			return 1;
		}else if(A[mid] > key){
			high = mid;
		}else{
			low = mid + 1;
		}
	}

	return 0;
}


Measured memory_bytes: 2284
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;

int main()
{
	int N;
	cin >> N;
	vector<long long> A(N);

	long long T = 0;
	for (auto &x : A) {
		cin >> x;
		T += x;
	}

	long long ans = T;
	long long acc = 0;
	for (int i = 0; i + 1 < N; ++i) {
		acc += A[i];
		ans = min(ans, abs(acc - (T - acc)));
	}
	cout << ans << endl;
}

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

int main(){
    int N,K;cin>>N>>K;
    vector<long long> V(N);
    for(int i = 0; i < N ; i++){
        cin >> V[i];
    }
    long long res = 0;
    for(int a = 0 ; a <= min(K,N) ; a++){
        for(int b = 0 ; a+b <= min(K,N) ; b++){
            vector<long long> v;
            long long sum = 0;
            for(int i = 0 ; i < a ; i++){
                v.push_back(V[i]);
                sum += V[i];
            }
            for(int j = 0 ; j < b ; j++){
                v.push_back(V[N-1-j]);
                sum += V[N-1-j];
            }

            sort(v.begin(),v.end());
            for(int i = 0 ; i < min(K-a-b,(int)v.size()) ; i++){
                if(v[i] < 0) sum -= v[i];
            }
            res = max(res,sum);
        }
       
    }
    cout << res << endl;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <functional>
#include <numeric>
#include <iostream>
#include <string>
#include <time.h>
#include <bitset>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }

int N, P[212345];

int main() {

	cin >> N;
	rep(i, N) cin >> P[i];

	int min = P[0];
	int ans = 0;

	rep(i, N) {
		if (min >= P[i]) {
			ans++;
			min = P[i];
		}
	}


	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1024
/*-- ILSH  --*/
#include "bits/stdc++.h"
using namespace std;
typedef long long int ll;
#define pb push_back 
#define pop pop_back
#define mp make_pair
#define vii vector < int >
#define vll vector < ll > 
#define pii pair < int , int >
#define pll pair < ll , ll >
#define vpi vector < pii >
#define vpl vector < pll >
#define fi first
#define se second 
#define sz size 
#define len length 

const ll mod = 1e9+7;
const ll inf=1e18+1e17;
//const ll mod = 998244353;

ll modInverse(ll a,ll m){ll m0=m;ll y=0,x=1;if(m == 1)return 0;while(a> 1){ll q=a/m;ll t=m;m=a%m,a=t;t=y;y=x-q*y;x=t;}if(x<0)x+=m0;return x;}  
ll powm(ll a,ll b){a=a%mod;ll res=1;while(b){if(b&1)res=(res*a)%mod;a=(a*a)%mod;b>>=1;}return (res%mod);}

const ll N=2e5+6;


void solve(){
	ll s,w;
	cin>>s>>w;
	if ( w>=s)
		cout<<"unsafe\n";
	else
		cout<<"safe\n";

}


int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
//	#ifndef ONLINE_JUDGE
	//  freopen ("INPUT.txt" , "r" , stdin);
	  //freopen ("OUTPUT.txt", "w" , stdout);
//	#endif	
    ll t=1;
	//cin>>t;
    for (int i=1;i<=t;i++){
    //	cout<<"Case #"<<i<<": ";
    	solve();
 	}
}





Measured memory_bytes: 3652
#include<iostream>
using namespace std;
 
int dp[2][2001][3001];
const int mod = 100000;
int main(){
  int n,m,s;
  while(cin>>n>>m>>s){
    if(n==0)break;
    n *= n;

    for(int j=0;j<=m;j++)
      for(int k=0;k<=s;k++)
	dp[0][j][k]=0;

    dp[0][0][0]=1;    
    for(int i=0;i<=n;i++){
      int now=i&1;
      int next=now^1;

      for(int j=0;j<=m;j++)
	for(int k=0;k<=s;k++)
	  dp[next][j][k]=0;
     
      for(int j=0;j<m;j++){
	for(int k=0;k<=s;k++){
	  if(dp[now][j][k]==0)continue;
	  (dp[now][j+1][k]+=dp[now][j][k]) %= mod;
	  if(k+j+1<= s)(dp[next][j+1][k+j+1]+=dp[now][j][k]) %= mod;
	  //cout << dp[now][j+1][k] << " " ;
	}
	//cout << endl;
      }
      //cout << endl;
    }
    cout << dp[n&1][m][s] << endl;
  }
  return 0;
}

Measured memory_bytes: 48060
N = int(input())
A = list(map(int, input().split()))

R = A[:]
for i in range(N - 1, -1, -1):
    R[i] = R[i + 1] + A[i]
B = 1
ans = B
for i in range(1, N + 1):
    M = 2 * B - A[i]
    if M < 0:
        ans = -1
        break
    B = min(M, max(0, R[i] - A[i]))
    ans += A[i] + B

print(ans if A[0] == 0 or A[0] == 1 and len(A) == 1 else -1)


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

int main(void)
{
    double w;
    
    while (cin >> w) {
        if (w <= 48) {
            cout << "light fly";
        } else if (w > 48 && w <= 51) {
            cout << "fly";
        } else if (w > 51 && w <= 54) {
            cout << "bantam";
        } else if (w > 54 && w <= 57) {
            cout << "feather";
        } else if (w > 57 && w <= 60) {
            cout << "light";
        } else if (w > 60 && w <= 64) {
            cout << "light welter";
        } else if (w > 64 && w <= 69) {
            cout << "welter";
        } else if (w > 69 && w <= 75) {
            cout << "light middle";
        } else if (w > 75 && w <= 81) {
            cout << "middle";
        } else if (w > 81 && w <= 91) {
            cout << "light heavy";
        } else if (w > 91) {
            cout << "heavy";
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 3132
#include "bits/stdc++.h"
using namespace std;
 
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);

    long long x , k , d;
    cin >> x >> k >>d;

    x=abs(x);
    if(x/d>=k){
        cout<<x-k*d<<endl;
    }
    else{
        long long  ans=x%d;
        long long  f=k-x/d;
        if(f&1)ans=abs((d-ans));
        cout<<ans<<endl;
    }
}



Measured memory_bytes: 3636
#include<stdio.h>
int main(){
  int a,b,key=0;
  scanf("%d %d",&a,&b);

  if(a >= b){
    key = a%b;

    while(key != 0){
      a = b;
      b = key;
      key = a%b;
    }
    printf("%d\n",b);
  }

  else{
    key = b%a;
    
    while(key != 0){
      b = a;
      a = key;
      key = b%a;
    }
    printf("%d\n",a);
  }

  return 0;
}

Measured memory_bytes: 592
import sys
reader = (s.rstrip() for s in sys.stdin)
input = reader.__next__

n,k = map(int, input().split())
a = list(map(int, input().split()))

plus = minus = zero = 0
ps = []
ms = []
for i in a:
    if i == 0:
        zero += 1
    elif i > 0:
        plus += 1
        ps.append(i)
    else:
        minus += 1
        ms.append(-i)

ps.sort()
ms.sort()

def check(m):
    if m == 0:
        return plus*minus + zero*(zero-1)//2 + zero*(plus+minus) >= k
    elif m > 0:
        tmp = plus*minus + zero*(zero-1)//2 + zero*(plus+minus)
        for l in [ps, ms]:
            X = len(l)
            cur = X-1
            for i in range(X):
                while cur >= 0 and l[i]*l[cur] > m:
                    cur -= 1
                if cur <= i:
                    break
                tmp += cur-i
        return tmp >= k
    else:
        tmp = 0
        cur = 0
        for i in reversed(range(plus)):
            while cur < minus and ms[cur]*ps[i] < -m:
                cur += 1
            tmp += minus-cur
        return tmp >= k

left = -10**20
right = 10**20

while right-left>1:
    mid = (right+left)//2
    if check(mid):
        right = mid
    else:
        left = mid

print(right)

Measured memory_bytes: 97228
/*input
2
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl
#define debug cout << "hi" << endl

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

const int MOD = 1e9 + 7;
const int INF32 = 1<<30;
const ll INF64 = 1LL<<60;

ll gcd(ll a, ll b)
{
	return (!b ? a : gcd(b, a % b));
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll k, ans = 0; cin >> k;
    for(ll i = 1; i <= k; i++) for(ll j = 1; j <= k; j++) for(ll l = 1; l <= k; l++) ans += gcd(i, gcd(j, l));
    cout << ans;

    return 0;
}

Measured memory_bytes: 3640
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int H, W;
		boolean sharp = false;

		while (true) {
			H = scanner.nextInt();
			W = scanner.nextInt();

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

			for (int i = 0; i < H; i++) {
				if (i % 2 == 0)
					sharp = false;
				else
					sharp = true;

				for (int i2 = 0; i2 < W; i2++) {
					System.out.print((sharp = !sharp) ? "#" : ".");
				}

				System.out.println();
			}

			System.out.println();
		}
	}
}

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

int main() {
  int A,B,C;
  cin >> A >> B >> C;
  int S = 0;
  S = A + B + C;
  
  if (S >= 22){
    cout << "bust" <<endl;
  }
  else {
    cout << "win" <<endl;
  }
}


Measured memory_bytes: 256
import java.util.*;

class Main {
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in)) {
            int a = Integer.parseInt(sc.next());
            if (a % 2 == 0) {
                System.out.println("Even");
                return;
            }

            int b = Integer.parseInt(sc.next());
            if (b % 2 == 0) {
                System.out.println("Even");
                return;
            }

            System.out.println("Odd");
            return;
        } catch (NumberFormatException e) {
            e.printStackTrace();
        }
    }
}

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

int main() {
	int a[10];
	for(int i=0;i<10;i++)
	cin>>a[i];
	for(int j=0;j<10;j++)
	{for(int i=0;i<10-1;i++)
	{
		if(a[i]<a[i+1])
		{
			int temp;
			temp=a[i];
			a[i]=a[i+1];
			a[i+1]=temp;
		}
	}}
	for(int i=0;i<3;i++)
	cout<<a[i]<<endl;
	return 0;
}


Measured memory_bytes: 3104
#pragma gcc optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V)) //小さい方からソート
#define REV(V) reverse(ALL(V)) //リバース
#define RSORT(V) SORT(V);REV(V) //大きい方からソート
#define NPN(V) next_permutation(ALL(V)) //順列
#define pb(n) push_back(n)
#define endl '\n'
#define Endl '\n'
#define DUMP(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define Yay(n) cout << ((n) ? "Yay!": ":(") << endl
#define RAPID cin.tie(0);ios::sync_with_stdio(false)
#define VSUM(V) accumulate(ALL(V), 0)
#define MID(a,b,c) (a) < (b) && (b) < (c)
#define MIDe(a,b,c) (a) <= (b) && (b) <= (c)
#define IN(n) cin >> n
#define IN2(a,b) cin >> a >> b
#define IN3(a,b,c) cin >> a >> b >> c 
#define IN4(a,b,c,d) cin >> a >> b >> c >> d
#define VIN(V) for(int i = 0; i < (V).size(); i++) {cin >> (V).at(i);}
#define OUT(n) cout << n << endl
#define VOUT(V) REP(i, (V).size()) {cout << (V)[i] << endl;}
#define VOUT2(V) REP(i, (V).size()) {cout << (V)[i] << " ";} cout<<endl;

// 型マクロ定義
#define int long long
#define P pair<ll,ll>
#define Vi vector<ll>
#define Vd vector<double>
#define Vs vector<string>
#define Vc vector<char>
#define M map<ll,ll>
#define S set<ll>
#define PQ priority_queue<ll>
#define PQG priority_queue<ll,V,greater<ll>
//

const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int gcd(int a,int b){return b != 0 ? gcd(b, a % b) : a;} //最大公約数
int lcm(int a, int b){return a * b / gcd(a, b);}
string toStrUp(string str){char diff = 'A'-'a';REP(i,str.size()) str[i] += diff;return str;}
string gCh(string str, int key){return str.substr(key,1);}

signed main() {
  RAPID;
  // デフォルト変数定義
  int n=0,m=0,a=0,b=0,c=1,d=0,x=0,y=0,z=0;
  string s="",t="";
  //

  // ここから
  IN(n);
  Vi A(n);
  VIN(A)
  RSORT(A);
  REP(i,n){
  	if(i%2==0) x+=A[i];
    else y+=A[i];
  }
  OUT(x-y);
}


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

int main() {
  int a,b,c,d; cin >> a >> b >> c >> d;
  if(abs(a-b) <= d && abs(b-c) <= d){
    cout << "Yes";
  }
  else if(abs(a-c) <= d){
    cout << "Yes";
  }
  else{
    cout << "No";
  }
}

Measured memory_bytes: 3640
n = int(input())
w = list(map(int, input().split()))

s1 = 0
s2 = sum(w)

res = abs(s2-s1)

for i in range(n):
  s1 += w[i]
  s2 -= w[i]
  r = abs(s2-s1)
  if r < res:
    res = r
    
print(res)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
#define int  long long
const int MOD = 1e9 + 7;

void solve(){
	cout << fixed;
	cout << setprecision(10);
  	int n;
  	cin >> n;
  	double num = ceil(n / 2.0);
  	double den = n;
  	double ret = num / den;
  	cout << ret << endl;
}

int32_t main(){
     ios_base::sync_with_stdio(false);
     cin.tie(nullptr);
     solve();	
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define forn(i, a, n) for(int i = a; i < n; ++i)
#define pb push_back
#define mp make_pair
//#define f first
//#define sex second

#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stack>
#include <set>
#include <ostream>
#include <queue>
#include <functional>
#include <sstream>
#include <map>

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
#pragma comment(linker, "/STACK:228228000")
const ll mod = 9982443530;

ll n, k, res;
ll a[1001][4];

void fun(ll f, ll s, ll t)
{
	vector<pll> d;
	ll ret = 0;
	ll cof = 0, cos = 0, cot = 0;
	forn(i, 0, n)
	{
		pll c;
		c.first = a[i][0]*f + a[i][1]*s + a[i][2]*t;
		c.second = i;
		d.push_back(c);
	}
	sort(d.begin(), d.end());
	forn(i, 0, k)
	{
		ret += d[d.size() - 1 - i].first;
		cof += a[d[d.size() - 1 - i].second][0];
		cos += a[d[d.size() - 1 - i].second][1];
		cot += a[d[d.size() - 1 - i].second][2];
	}
	if (cof*f >= 0 && cos*s >= 0 && cot*t >= 0)
		res = max(res, ret);
}

int main()
{
	/*

	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif
	*/


	cin >> n >> k;
	forn(i, 0, n)
	{
		cin >> a[i][0];
		cin >> a[i][1];
		cin >> a[i][2];
	}
	
	fun(1, 1, 1);
	fun(1, 1, -1);
	fun(1, -1, 1);
	fun(1, -1, -1);
	fun(-1, 1, 1);
	fun(-1, 1, -1);
	fun(-1, -1, 1);
	fun(-1, -1, -1);

	cout << res;
	return 0;
}


Measured memory_bytes: 256
def Binary_Search(A,x):
    L=0
    R=len(A)
    while R-L>1:
        C=(R+L-1)//2
        
        if A[C]<=x:
            L=C+1
        else:
            R=C+1
    return L
        
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))

A.sort()
A.append(A[-1]+1)
B.sort()
C.sort()
C=[0]+C
C=[-c for c in C[::-1]]

S=0
for b in B:
    S+=Binary_Search(A,b-1)*Binary_Search(C,-(b+1))
print(S)


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

using namespace std;

typedef long long ll;

#define sz(x) ((int)(x).size())
#define in(x) int x;cin>>x
#define inn(x, y) int x,y;cin>>x>>y
#define innn(x, y, z) int x,y,z;cin>>x>>y>>z
#define bit(n) (1<<(n))

#define out(x) cout<<(x)<<endl;
#define outt(x,y) cout<<(x)<<" "<<(y)<<endl;
#define err(x) cerr<<(x)<<endl;
#define errr(x,y) cerr<<(x)<<" "<<(y)<<endl;
#define errrr(x,y,z) cerr<<(x)<<" "<<(y)<<" "<<(z)<<endl;

#define rep(i,n) for (int i=0;i<(n);i++)
#define repp(i,n) for (int i=1;i<=(n);i++)
#define reppp(j, i, n) for (int j=i+1; j<n; j++)

#define lim5 200010
#define lim9 1000000010

#define deg(rad) (((rad)/2/M_PI)*360)
#define mid(min, max) ((min + max) / 2)

int main() {
	string s;
	cin >> s;
	out(s == "ABC" ? "ARC" : "ABC");
    return 0;
}


Measured memory_bytes: 3628
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < n; i++)

using namespace std;

void solve() {
  long T, A, B;
  cin >> T >> A >> B;
  cout << min(A*T, B) << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


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


int main()
{
    int num,i,sum=0;
    scanf("%d",&num);

    string str;
    stringstream ss;

        ss<<num;
        ss>>str;
        int len = str.size();

    int c=0;

    for(int j=0; j<len; j++)
     {
        if(str[j]=='0')
            c++;

         sum = sum + (str[j]-'0');
     }

     //printf("%d\n",c);

    if(c==len-1 && len!=1)
        printf("10\n");

    else
    printf("%d\n",sum);

    return 0;
}


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

int main(){
	int N;cin>>N;
  	int A,B;cin>>B;int minv=B,maxv=B;
  	for(int i=1;i<N;++i){
    	cin>>A;
      	minv=min(A,minv);
      	maxv=max(A,maxv);
    }
	cout<<maxv-minv<<endl;
  	return 0;
}

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

int Binary_Search(int S[], int key, int n) {
  int left = 0;
  int right = n;
  int mid;

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

  return 0;
}

int main() {
  int result = 0;
  int n, q, key;
  int S[100000];

  cin >> n;
  for (int i = 0; i < n; i++)
    cin >> S[i];

  cin >> q;
  for (int i = 0; i < q; i++) {
    cin >> key;
    result += Binary_Search(S, key, n);
  }

  cout << result << endl;

  return 0;
}



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

int main() {
    int k, a, b;
    cin >> k >> a >> b;
    bool judge = false;
    for (int i = a; i <= b; i++) {
        if (i % k == 0) {
            judge = true;
            break;
        }
    }
    if (judge) {
        cout << "OK" << endl;
    } else {
        cout << "NG" << endl;
    }
    return 0;
}

Measured memory_bytes: 3636
#include<iostream>
#include<cstdio>
#include<cstring>
#include<climits>
#include<cassert>
#include<cmath>
#include<cstdlib>
#include<complex>
#include<algorithm>
#include<vector>
#include<deque>
#include<queue>
#include<map>
#include<set>
#include<sstream>
#include<bitset>

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

using namespace std;

typedef long long ll;
#define IINF INT_MAX
#define LLINF LLONG_MAX

int main(){
  string s,t;
  cin >> s >> t;
  vector<int> a,b;
  int ptr = 0;
  rep(i,(int)s.size()) {
    if( s[i] == t[ptr] ) {
      a.push_back(i);
      ++ptr;
      if( ptr >= (int)t.size() ) break;
    }
  }
  if( ptr < (int)t.size() ) { puts("no"); return 0; }
  ptr = (int)t.size()-1;
  for(int i=(int)s.size();i>=0;--i) {
    if( s[i] == t[ptr] ) {
      b.push_back(i);
      --ptr;
      if( ptr < 0 ) break;
    }
  }
  reverse(b.begin(),b.end());
  puts((a==b)?"yes":"no");
  return 0;
}

Measured memory_bytes: 8940
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
using ll = long long;
using ull = unsigned long long; 
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
//constexpr long long MOD = 998244353LL;
template<class T, class U> inline bool chmax(T &a, U b) { if (a < b) { a = b; return true;} return false; }
template<class T, class U> inline bool chmin(T &a, U b) { if (a > b) { a = b; return true;} return false; }
void print() { cerr << "\n"; }
template <class T, class... Args>
void print(const T &x, const Args &... args) {
    cerr << x << " ";
    print(args...);
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int X,Y,Z; cin >> X >> Y >> Z;
    int N = X+Y+Z;
    vector<tuple<int, int, int>> arr(N);
    rep(i,N) {
        int a,b,c; cin >> a >> b >> c;
        arr[i] = make_tuple(b-c,c,a);
    }

    sort(all(arr)); reverse(all(arr));
    vector<ll> AB(X+1);
    priority_queue<int> pq;
    rep(i,Y) {
        int a,b,c;
        tie(b,c,a) = arr[i];
        b += c;
        pq.emplace(a-b);
        AB[0] += b;
    }
    rep(i,X) {
        int a,b,c;
        tie(b,c,a) = arr[Y+i];
        b += c;
        pq.emplace(a-b);
        AB[i+1] = AB[i] + b + pq.top(); pq.pop();
    }
    
    reverse(all(arr));
    vector<ll> AC(X+1);
    priority_queue<int> rs;
    rep(i,Z) {
        int a,b,c;
        tie(b,c,a) = arr[i];
        b += c;
        rs.emplace(a-c);
        AC[0] += c;
    }
    rep(i,X) {
        int a,b,c;
        tie(b,c,a) = arr[Z+i];
        b += c;
        rs.emplace(a-c);
        AC[i+1] = AC[i] + c + rs.top(); rs.pop();
    }
    reverse(all(AC));
    ll ans = 0;
    rep(i,X+1) {
        //print(AB[i],AC[i]);
        chmax(ans,AB[i]+AC[i]);
    }

    cout << ans << ln;
}


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

using ll = long long;
using ull = unsigned long long;

const double PI = acos(-1);
const int inf = 2e9;
const long long INF = 2e18;
const long long MOD = 1e9+7;

#define sx(s) (s).size()
#define pb push_back
#define fi first
#define se second
#define REP(i,n) for (int i = 0; i < n; i++)
#define ALL(a) begin(a),end(a)

int main(void) {
    ll N,K;
    cin >> N >> K;
    vector<int> A(N);
    REP(i,N) cin >> A[i];
    ll ans = 0;
    REP(i,N) {
        REP(j,N) {
            if (i==j) continue;
            if (A[i] > A[j]) {
                if (i < j) {
                    ll temp = K*(K+1)/2;
                    temp %= MOD;
                    ans += temp;
                    ans %= MOD;
                }
                else {
                    ll temp = (K-1)*K/2;
                    temp %= MOD;
                    ans += temp;
                    ans %= MOD;
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC106
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int ans = 0;
            if (n < 105) { }
            else if (n < 135) { ans = 1; }
            else if (n < 165) { ans = 2; }
            else if (n < 189) { ans = 3; }
            else if (n < 195) { ans = 4; }
            else { ans = 5; }
            Console.WriteLine(ans);
        }
    }
}


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

int main() {
    string s;
    cin >> s;
    s[1] = 'B'+'R'-s[1];
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define SZ(X) ((int)(X).size())
#define endl "\n";
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	int n,ans=0;
	cin>>n;
	for (int i = 1; i <= n; ++i)
	{
		if(SZ(to_string(i))%2!=0){
			ans++;
		}
	}
   cout<<ans; 	
   return 0;
}


Measured memory_bytes: 3688
import java.util.Arrays;
import java.util.Scanner;

public class Main {

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

		int N = sc.nextInt();
		int K = sc.nextInt();

		int[] balls = new int[N + 1];

		for (int i = 0; i < N; i++) {
			balls[sc.nextInt()]++;
		}

		int rewrite = balls.length - K;
		if (rewrite <= 0) {
			System.out.println(0);
			return;
		}
		Arrays.parallelSort(balls);
		int sum = 0;
		for (int i = 0; i < rewrite; i++) {
			sum += balls[i];
		}

		System.out.println(sum);

	}
}


Measured memory_bytes: 85544
#coding: utf-8
# n,k = int(input())
# list = list(map(int,input().split()))
# strings = list(map(str, [input() for i in range(amount)]))

a,b = map(int,input().split())
l=0

if a >= 10 or b >= 10:
    l = -1
else:
    l = a*b

print(l)


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

bool check(int* books, int width, int m,int n);

int main(void){
  int m,n;
  while(1){
    cin>>m>>n;
    if(m==0 and n==0)break;
    int books[n];
    for(int i=0;i<n;i++){
      cin>>books[i];
    }
    int min=0;
    int max=1500000;
    int mid;
    while(max-min>5){
      mid=(min+max)/2;
      if(check(books,mid,m,n)){
        max=mid;
      }
      else{
        min=mid;
      }
    }
    int retval;
    for(int i=max;i>=min;i--){
      if(check(books,i,m,n)){
        retval=i;
      }
    }
    cout<<retval<<endl;
  }
  return 0;
}


bool check(int* books, int width, int m, int n){
  int row=1;
  int w=0;
  for(int i=0;i<n;i++){
    if(books[i]>width)return false;
    if(w+books[i]<=width){
      w+=books[i];
    }
    else{
      row+=1;
      w=books[i];
    }
  }
  return row<=m;
}



Measured memory_bytes: 3040
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0;i < n;i++)
#define rev(i, n) for(int i = n;i >= 0;i--)
#define Rep(i, m, n) for(int i = m;i < n;i++)
#define repeatrev(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define itn int

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
typedef priority_queue<int> Pr;

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a, b;
    cin >> a >> b;
    if(a >= 13) cout << b << endl;
    else if(a >= 6) cout << b / 2 << endl;
    else cout << 0 << endl;

}

Measured memory_bytes: 256