akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define int long long
#define INT int
#define MOD 1000000007

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()
#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
template <typename T>
void print(T x)
{
    std::cout << x << '\n';
}
typedef long long ll;

int n;
vector<int> a;

signed main()
{
    cin >> n;
    a.resize(n);
    map<int, int> L, R;

    rep(i, n)
    {
        cin >> a[i];
        L[i + a[i]]++;
        R[i - a[i]]++;
    }

    int ans = 0;

    for (auto t : L)
    {
        int temp = t.second * R[t.first];
        ans += temp;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 39124
N = int(input())
A = list(map(int,input().split()))
OKlist = [0]*(10**6+100)
A.sort()
for i in range(len(A)-1):
    if A[i] == A[i+1] and OKlist[A[i]] == 0:
        OKlist[A[i]] += 2
        for j in range(1,10**6+10):
            if A[i]*j > 10**6:
                break
            else:
                OKlist[A[i]*j] += 1
    elif OKlist[A[i]] == 0:
        for j in range(1,10**6+10):
            if A[i]*j > 10**6:
                break
            else:
                OKlist[A[i]*j] += 1
    else:
        OKlist[A[i]] += 1
OKlist[max(A)] += 1
cnt = 0
for i in A:
    if OKlist[i] == 1:
        cnt += 1
        
        
print(cnt)

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

int main(){
    int n;
    double d;
    cin >> n >> d;
    vector<double> x(n);
    vector<double> y(n);
    for(int i=0; i<n; i++){
        cin >> x.at(i) >> y.at(i);
    }

    int count = 0;
    d = d*d;
    for(int i=0; i<n; i++){
        if(x.at(i) * x.at(i) + y.at(i) * y.at(i) <= d){
            count++;
        }
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 6480
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
#include <functional>
#include <cassert>

#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 62;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll conbinationMemo[100][100];

void cmemoInit(){
    rep(i, 100){
        rep(j, 100){
            conbinationMemo[i][j] = -1;
        }
    }
}
 
ll nCr(ll n, ll r){
    if(conbinationMemo[n][r] != -1) return conbinationMemo[n][r];
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return conbinationMemo[n][r] = (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
//-----------------------ここから-----------
int main(void){
    ll n;
    cin >> n;
    vector<bool> prime(1001001, false);
 
    for(ll i = 0; i <= 1001000; i++){
        prime[i] = true;
    }
 
    vector<ll> p;
 
    for(ll i = 2; i <= 1001000; i++){
        if(prime[i]){
            for(ll j = 2 * i; j <= 1001000; j += i){
                prime[j] = false;
            }
            p.push_back(i);
        }
    }
    vector<ll> li;
    for(ll i = 0; i < p.size(); i++){
        ll now = p[i];
        while(now <= (ll)1e13){
            li.push_back(now);
            now *= p[i];
        }
    }
 
    bool np = true;
 
    for(ll i = 2; i * i <= n; i++){
        if(n % i == 0){
            np = false;
        }
    }
    ll plus = 0;
    if(n > 1001000){
        if(np){
            cout << 1 << endl;
            return 0;
        }
    }
    sort(all(li));
    ll ans = 0;
    ll num = n;
    for(ll i = 0; i < li.size(); i++){
        if(num % li[i] == 0){
            num /= li[i];
            ans++; 
        }
    }

    if(num > 1001000){
        ans++;
    }
 
    cout << ans << endl;
}


Measured memory_bytes: 6108
#include <stdio.h>
#include <string.h>
int min(int a, int b)
{
    if (a > b){
        return (b);
    }
    return (a);
}

int switch_color(int *ball, int check, int col, int n, int *top, int *bottom)
{
    int i, j;
    
    *top = check;
    i = check - 1;
    while (i >= 0 && ball[i] == col){
        *top = i;
        i--;
    }
    
    *bottom = check;
    i = check + 1;
    while (i < n && ball[i] == col){
        *bottom = i;
        i++;
    }
    return(*bottom - *top + 1);
}

int chain(int *temp, int start, int end, int n)
{
    int i, j, k;
    int temp_2[30001];
    
    i = 0;
    while (i != n && n >= 0){
        for (j = 1; j <= 3; j++){
            if (temp[i] == j && switch_color(temp, i, j, n, &start, &end) >= 4){
                memset(temp_2, -1, sizeof(temp_2));
                n -= (end - start + 1);
                for (k = 0; k < n; k++){
                    if (k < start){
                        temp_2[k] = temp[k];
                    }
                    else {
                        temp_2[k] = temp[(end - start + 1) + k];
                    }
                }
                for (k = 0; k < n; k++){
                    temp[k] = temp_2[k];
                }
                i = 0;
            }
        }
        i++;
    }
    if (n < 0){
        return (0);
    }
    return (n);
}

int count(int check, int n, int *ball)
{
    int i, j;
    int top, bottom;
    int ans, comp;
    int temp[30001];
    
    ans = 100000;
    for (i = 1; i <= 3; i++){
        if (ball[check] != i){
            if (switch_color(ball, check, i, n, &top, &bottom) >= 4){
                ans = n - (bottom - top + 1);
                memset(temp, -1, sizeof(temp));
                for (j = 0; j < ans; j++){
                    if (j < top){
                        temp[j] = ball[j];
                    }
                    else {
                        temp[j] = ball[(bottom - top + 1) + j];
                    }
                }
                comp = 100000;
                if (temp[top - 1] == temp[top]){
                    comp = chain(temp, top, bottom, ans);
                }
                ans = min(comp, ans);
                if (ans == 0){
                    break;
                }
            }
            if (ans == 0){
                break;
            }
        }
    }
    if (ans == 100000){
        return (n);
    }
    return (ans);
}

int main(void)
{
    int ball[30001];
    int n;
    int i;
    int ans;
    
    while (1){
        scanf("%d", &n);
        
        if (n == 0){
            break;
        }
        
        memset(ball, -1, sizeof(ball));
        for (i = 0; i < n; i++){
            scanf("%d", &ball[i]);
        }
        
        ans = 100000;
        for (i = 0; i < n; i++){
            if (i == 0 || i == n - 1 || !(ball[i] == ball[i - 1] && ball[i] == ball[i + 1])){
                ans = min(ans, count(i, n, ball));
                if (ans == 0){
                    break;
                }
            }
        }
        
        printf("%d\n", ans);
    }
    
    return (0);
}

Measured memory_bytes: 756
#include <cstdio>
#include <algorithm>
#include <vector>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)

int main() {
	while(true) {
		int n, m;
		scanf(" %d %d", &n, &m);
		if(n == 0 && m == 0) break;
		vector<int> v(n + m + 1);
		v[0] = 0;
		rep(i, n + m) {
			scanf(" %d", &v[i + 1]);
		}
		sort(v.begin(), v.end());
		int ans = 0;
		for(int i = 1; i <= n + m; i++) {
			ans = max(v[i] - v[i - 1], ans);
		}
		printf("%d\n", ans);
	}
	return 0;
}

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

int main(){
  int a, b, c, cnt=3;
  cin >> a >> b >> c;
  if (a == b) cnt--;
  if (b == c) cnt--;
  if (a == c) cnt--;
  if (cnt == 0) cnt = 1;
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef long long ll;
string str, t;
ll a[210000], res;
int main(void){
    // Your code here!
    cin >> str;
    ll len = str.length(), xcou = 0;
    for (ll i = 0; i < len; i++) {
        if (str[i] == 'x') {
            xcou++;
        } else {
            a[t.length()] = xcou;
            xcou = 0;
            t += str[i];
        }
    }
    a[t.length()] = xcou;
    for (ll i = 0; i <= t.length(); i++) {
        res += abs(a[i] - a[t.length() - i]);
    }
    ll ans = 0;
    for (ll i = 0; i < t.length(); i++) {
        if (t[i] != t[t.length() - i - 1]) ans++;
    }
    if (ans) cout << -1 << endl;
    else cout << res / 2 << endl;
}


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

#define ran 101101

int n, m;
int h[ran];
bool f[ran];

int main() {
	scanf("%d%d", &n, &m);
	for(int i=1;i<=n;i++) {
		scanf("%d", &h[i]);
		f[i] = true;
	}
	for(int i=0;i<m;i++) {
		int x, y;
		scanf("%d%d", &x, &y);
		if(h[x]<=h[y]) f[x] = false;
		if(h[x]>=h[y]) f[y] = false;
	}
	int ans = 0;
	for(int i=1;i<=n;i++)
		ans += f[i];
	printf("%d\n", ans);
	
	return 0;
}

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

int main(){
  int n; cin >> n;
  vector<int> a(n), b(n);
  for(int i = 0; i < n; i++){
    cin >> a[i] >> b[i];
  }
  sort(a.begin(), a.end());
  sort(b.begin(), b.end());
  if(n % 2 == 0){
    cout << (b[n/2] + b[n/2-1]) - (a[n/2] + a[n/2-1]) + 1 << endl;
  }
  else{
    cout << b[n/2] - a[n/2] + 1 << endl;
  }
}

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

int main(){
    int H, W, N;
    cin >> H >> W >> N;
    vector<pair<int, int>> ob;
    for (int i = 0; i < N; i++) {
        int X, Y;
        cin >> X >> Y;
        ob.push_back({X, Y});
    }
    sort(ob.begin(), ob.end());
    int t = 0;
    for (int i = 0; i < N; i++) {
        int X, Y;
        X = ob[i].first;
        Y = ob[i].second;
        if (X-Y < t)continue;
        else if (X-Y == t) t++;
        else if (X-Y > t) {
            cout << X-1 << endl;
            return 0;
        }
    }
    cout << H << endl;
    return 0;
}


Measured memory_bytes: 2420
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;

#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define RREP(i,n) for(int (i)=(int)(n)-1;i>=0;i--)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
typedef long long ll;
typedef unsigned long long ull;

template <class T> int LIS(vector<T> &a) {
    T INF = numeric_limits<T>::max() / 2;
    vector<T> res(a.size()+1,INF);
    for (int i = 0; i < a.size(); i++) {
        *(lower_bound(res.begin(),res.end(),a[i])) = a[i];
    }
    for (int i = 0; i < a.size(); i++) {
        if (res[i] == INF) return i;
    }
    return (int) a.size();
}

vector<long long> LIS(vector<long long>& v) {
    int N = (int) v.size();
    long long INF = numeric_limits<long long>::max() / 2;
    vector<long long> dp(N,INF), id(N);
    for (int i = 0; i < v.size(); i++) {
        id[i] = lower_bound(dp.begin(),dp.end(),v[i]) - dp.begin();
        dp[id[i]] = v[i];
    }
    long long nl = *max_element(id.begin(),id.end());
    vector<long long> ret(nl+1);
    for (int i = 0; i < N; i++) {
        if (id[N-1-i] == nl) ret[nl--] = v[N-1-i];
    }
    return ret;
}

int main() {

	int n; cin >> n;
	vector < int > a(n);
	REP(i,n) cin >> a[i];

	sort(a.begin(), a.end());
	cout << LIS < int > (a) << endl;

	return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
O = list(input())[: -1]
E = list(input())[: -1]
res = [""] * (len(O) + len(E))
for i in range(len(res)):
  if i % 2: res[i] = E[i // 2]
  else: res[i] = O[i // 2]
print("".join(res))

Measured memory_bytes: 38384
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string.h>
#include <vector>
#include <map>
#include <math.h>

using namespace std;

#define pb push_back
#define mp make_pair
#define ll long long
#define ull unsigned ll
#define db double
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define PII pair<int, int>

const int N=105;
int n,m;
int X1[N],Y1[N],X2[N],Z2[N];

db width(int* x,int *y,int n,db xx) {
    db lb=INF,ub=-INF;
    for (int i=0;i<n;i++) {
        db xx1=x[i],yy1=y[i],xx2=x[(i+1)%n],yy2=y[(i+1)%n];
        if ((xx1-xx)*(xx2-xx)<=0&&xx1!=xx2) {
            db yy=yy1+(yy2-yy1)*(xx-xx1)/(xx2-xx1);
            lb=min(lb,yy);
            ub=max(ub,yy);
        }
    }
    return max(0.0,ub-lb);
}

int main()
{
    while (true) {
        scanf("%d%d",&m,&n);
        if (m==0&&n==0) break;
        for (int i=0;i<m;i++) { scanf("%d%d",X1+i,Y1+i); }
        for (int i=0;i<n;i++) { scanf("%d%d",X2+i,Z2+i); }
        int mn1=*min_element(X1,X1+m),mx1=*max_element(X1,X1+m);
        int mn2=*min_element(X2,X2+n),mx2=*max_element(X2,X2+n);
        vector<int> xs;
        for (int i=0;i<m;i++) xs.pb(X1[i]);
        for (int i=0;i<n;i++) xs.pb(X2[i]);
        sort(xs.begin(),xs.end());
        db ans=0.0;
        for (int i=0;i+1<xs.size();i++) {
            db a=xs[i],b=xs[i+1],c=(a+b)/2;
            if (mn1<=c&&c<=mx1&&mn2<=c&&c<=mx2) {
                db fa=width(X1,Y1,m,a)*width(X2,Z2,n,a);
                db fb=width(X1,Y1,m,b)*width(X2,Z2,n,b);
                db fc=width(X1,Y1,m,c)*width(X2,Z2,n,c);
                ans+=(b-a)/6*(fa+4*fc+fb);
            }
        }
        printf("%.10lf\n",ans);
    }
}


Measured memory_bytes: 3096
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = a; i < n; i++)
#define Repr(i, n, a) for (int i = n; i >= a; i--)
#define rep(i, n) Rep(i, 0, n)
#define repr(i, n) Repr(i, n, 0)
#define all(a) a.begin(), a.end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;

int a[100010][50];

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

    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    int ans = 0;
    repr(I, 40)
    {
        int num = 0;
        repr(i, 40)
        {
            if (i >= I && k & (1LL << i))
            {
                num += 1LL << i;
                continue;
            }
            int cnt = 0;
            rep(j, n) if (a[j] & (1LL << i)) cnt++;
            if (cnt < n - cnt)
            {
                int tmp = num + (1LL << i);
                if (tmp <= k)
                    num = tmp;
            }
        }
        int tmp = 0;
        rep(i, n) tmp += a[i] ^ num;
        ans = max(ans, tmp);
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include<stdio.h>//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_7_A
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#include<set>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
struct Node{
	int p,l,r;//親、左の子、右の子
};
Node T[100001];
int N,depth[100001],height[100001];
void setdepth(int u,int d){
	depth[u]=d;
	if(T[u].l!=-1) setdepth(T[u].l,d+1);
	if(T[u].r!=-1) setdepth(T[u].r,d+1);
}
int setheight(int u){
	int h1=0,h2=0;
	if(T[u].l!=-1) h1=setheight(T[u].l)+1;
	if(T[u].r!=-1) h2=setheight(T[u].r)+1;
	height[u]=max(h1,h2);
	return height[u];
}
int getsibling(int u){//uの兄弟を返す
	if(T[u].p==-1) return -1;
	if(T[T[u].p].l!=u&&T[T[u].p].l!=-1) return T[T[u].p].l;
	if(T[T[u].p].r!=u&&T[T[u].p].r!=-1) return T[T[u].p].r;
	return -1;
}
void print(int u){
	int degree=0;
	if(T[u].l!=-1) degree++;
	if(T[u].r!=-1) degree++;
	printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, ",u,T[u].p,getsibling(u),degree,depth[u],height[u]);
	if(T[u].p==-1) prin("root");
	else if(T[u].l==-1&&T[u].r==-1) prin("leaf");
	else prin("internal node");
}
int main(){
	scan(N);
	rep(i,N) T[i].p=T[i].l=T[i].r=-1;
	rep(i,N){
		int v,l,r;
		scan(v>>l>>r);
		T[v].l=l,T[v].r=r;
		if(l!=-1) T[l].p=v;
		if(r!=-1) T[r].p=v;
	}
	int root;
	rep(i,N) if(T[i].p==-1) root=i;
	setdepth(root,0);//再帰的に深さを求める
	setheight(root);//再帰的に高さを求める
	rep(i,N) print(i);
	return 0;
}



Measured memory_bytes: 3212
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
constexpr int MOD=1000000007;
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(lint (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(lint (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
#define fi first
#define se second
typedef long long lint;
int dx[8]={1,1,0,-1,-1,-1,0,1};
int dy[8]={0,1,1,1,0,-1,-1,-1};
const int MAX_N=2e5+5;

lint powmod(lint a,lint b){
  return b?powmod(a*a%MOD,b/2)*(b%2?a:1)%MOD:1;
}

int main(void){
    string S;
    cin >> S;
    int N=S.length();
    lint p[N+10]={};
    p[0]=1;
    rep(i,N+5) p[i+1]=(p[i]*10)%2019;
    lint sum[N]={};
    lint cnt[2050]={};
    lint ans=0;
    lint base=0;
    sum[0]=S[N-1]-'0';
    cnt[sum[0]]++;
    for(int i=1;i<N;i++){
        sum[i]=(sum[i-1]+p[i]*(S[N-1-i]-'0'))%2019;
        cnt[sum[i]]++;
    }
    for(int i=0;i<N;i++){
        ans+=cnt[base];
        lint minus=(p[i]*(S[N-1-i]-'0'))%2019;
        base=(base+minus+2019)%2019;
        cnt[sum[i]]--;
    }
    cout << ans << endl;
}

Measured memory_bytes: 6880
#include<stdio.h>
int main(void){
  
  	int d=0;
  	int n=0;
  	
  	scanf("%d %d",&d,&n);
if((n>=1)&&(n<100)){
   switch(d){
      case 0:
        printf("%d",n);break;
      case 1:
        printf("%d",n);printf("00");break;
      case 2:
         printf("%d",n);printf("0000");break;
    }
}
if(n==100){   switch(d){
      case 0:
        printf("101");break;
      case 1:
        printf("10100");break;
      case 2:
         printf("1010000");break;
    }}
}


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

int main(){
  int N,L;
  cin >> N;
  cin >> L;
  vector<string> S (N);
  for (int i = 0;i< N;i++)
    cin >> S.at(i);
  sort (S.begin(),S.end());
  string answer = "";
  for (string x : S)
    answer += x;
  cout << answer << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
 
int main(){
    int sum = 0;
    char ch;
 
    while(true)
    {
        while((ch = getchar()) != '\n'){
            sum += ch - '0';
        }
        if(sum == 0)
            break;
        else{
            printf("%d\n",sum);
            sum = 0;
        }
    }
}


Measured memory_bytes: 2708
#include<stdio.h>
 
int S[1000000];
int T[1000000];
int Sc;
int Tc;
int c;
int i,j;
 
int binarySearch(int);
int main(){
 
 
  scanf("%d",&Sc);
 
  for(c = 0 ; c < Sc ; c++){
    scanf("%d",&S[c]);
  }
 
  scanf("%d",&Tc);
 
  for(c = 0 ; c < Tc ; c++){
    scanf("%d",&T[c]);
  }
  c = 0;
 
  for(i = 0 ; i < Tc ; i++){
  if(binarySearch(T[i]) == 1)c++;
  }
 
  printf("%d\n",c);
  return 0;
}
 
int binarySearch(int key){
  int left;
  int right;
  int mid;
 
  left = 0;
  right = Sc;
  while(left < right){
    mid = (left + right)/2;
    if(S[mid] == key)return 1;
    else if(key < S[mid])right = mid;
    else left = mid + 1;
  }
  return 0;
}

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

int main(){
	int n;
  	cin>>n;
  	vector<double>num(n);
  	for(int i=0;i<n;i++){
    	cin>>num[i];
    }
  	double x=1;
  	for(int i=0;i<n;i++){
    	x=x*num[i];
    }
  	double y=0;
  	for(int i=0;i<n;i++){
    	y=(x/num[i])+y;
    }
  	double z=x/y;
  	cout << fixed << setprecision(5);
  	cout<<z<<endl; 
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
  int n,q,i,right=0,mid=0,left=0,count=0;
  scanf("%d",&n);
  int S[n];
  for(i =0 ; i<n ;i++){
    scanf("%d",&S[i]);
  }
  scanf("%d",&q);
  int T[q];
  for(i =0 ; i<q ;i++){
    scanf("%d",&T[i]);
  }

  for(i = 0 ;i<q;i++){
    left = 0;
    right = n;
    while(left <right){
      mid = (left +right)/2;
      if(S[mid] ==T[i]){
	count++;
	break;
      }
      else if(T[i] < S[mid]){
	right =mid;
    }
      else left =mid+1;
    }
  }
    printf("%d\n",count);
    return 0;
  }



Measured memory_bytes: 2320
def calculate_angle(h, m):
    hour_hand = 360.0 * m / 60.0
    minute_hand = 360.0 * (h * 60.0 + m) / (12.0 * 60.0)

    if abs(hour_hand - minute_hand) > 180:
        angle = 360.0 - abs(hour_hand - minute_hand)
    else:
        angle = abs(hour_hand - minute_hand)

    return angle

for i in range(int(raw_input())):
    h, m = map(int, raw_input().split(':'))
    h = h % 12

    angle = calculate_angle(h, m)
    if angle < 30:
        print "alert"
    elif angle < 90:
        print "warning"
    else:
        print "safe"

Measured memory_bytes: 4256
#include <iostream>
#include <math.h>
//#include <numeric>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;
#define n_max 100000

#define rep(i, a, n) for(int i = a; i < n; i++)
#define rep2(i, a, n) for(int i = a; i <= n; i++)
#define rrep(i, a, n) for(int i = a; i > n; i--)
#define rrep2(i, a, n) for(int i = a; i >= n; i--)
#define lrep(i, a, n) for(long int i = a; i < n; i++)
#define in(a) cin >> a
#define out(a) cout << a << endl

int main()
{
    int N;
    double ans;

    cin >> N;
    vector<int> a(N);

    rep(i, 0, N) {
        cin >> a[i]; 
    }

    sort(a.begin(), a.end());
    
    ans = (a[0] + a[1]) / pow(2, N-1);

    //rrep(i, N-2, 0) {
    rep(i, 2, N) {
        //cout << a[i] << endl;
        ans += (a[i] / pow(2, N-i)); 
        //ans = (pow(2, i)); 
        //cout << "i " << i << " ans" << ans << endl;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int k,n;
	cin >> k >> n;
	if(n == 2){
		int a,b;
		cin >> a >> b;
		cout << min(abs(a - b), k - abs(a - b));
		exit(0);
	}
	int t = -1;
	int ans = -(int)1e9;
	int f;
	for(int i = 1;i <= n;i++){
			int a;
			cin >> a;
		if(t != -1){
			ans = max(ans, a - t);
		}else{
			f = a;
		}
		t = a;
	}
	ans = max(ans, k - t + f);
	cout << k - ans;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
using namespace std;
int main()
{
  long int n;
  cin>>n;
  long int a[n],b[n]={};
  for(int i=0;i<n;i++)
  {
    cin>>a[i];
    b[a[i]-1]=i+1;
  }
  for(int i=0;i<n;i++)
  {
    cout<<b[i]<<" ";
  }
}
  

Measured memory_bytes: 2432
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    long H = sc.nextLong();
    int N = sc.nextInt();
    long sum = 0;
    for(int i=0;i<N;i++){
      sum=sum+sc.nextLong();
    }
    if(H>sum){
      System.out.println("No");
      return;
    }else{
      System.out.println("Yes");
    }
  }
  

  
}

Measured memory_bytes: 46924
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <unordered_map>
#include <unordered_set>
#include <map>
#include <set>
using namespace std;

typedef pair<long long, long long> pll;
long long M=1000000007;
int main(int argc, char const *argv[]) {
  long long n,d;cin>>n>>d;
  vector<long long> x(n);
  for(int i=0;i<n;++i)cin>>x[i];
  vector<long long> ds(n+1);
  ds[0]=d;
  for(int i=0;i<n;++i){
    // if(ds[i]*2>x[i]){
    //   ds[i+1]=abs(ds[i]-x[i]);
    // }
    ds[i+1]=min(ds[i],abs(ds[i]-x[i]));
    // cout<<ds[i+1]<<endl;
  }
  vector<bool> res(n);
  long long b=1;
  for(int i=n-1;i>-1;--i){
    res[i]=(b<=ds[i]);
    if(x[i]<2*b)b+=x[i];
    // cout<<b<<endl;
  }
  int q;cin>>q;
  for(int i=0;i<q;++i){
    long long tmp;cin>>tmp;
    if(res[tmp-1])cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
  }
  return 0;
}


Measured memory_bytes: 10240
n, m = [int(i) for i in input().split()]

mn = 0
mx = n

for i in range(m):
    tmp = [int(i) for i in input().split()]
    mn = max(tmp[0], mn)
    mx = min(tmp[1], mx)

print(mx - mn + 1 if mx >= mn else 0)

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

using namespace std;
//DP用
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;
}
const long long INF = 1LL << 60;

int count(int i,int c) {
    if(i % c == 0) {
        return i/c;
    }else {
        return i/c+1;
    }
}

int main() {
    int n,c,k;
    cin >> n >> c >> k;
    int t[n];
    for(int i = 0; i < n; i++){
        cin >> t[i];
    }
    sort(t,t+n);
    int bus = 0;
    for(int i = 0; i < n;){
        int time = t[i] + k;
        for(int j = 1; j <= c && t[i] <= time; j++) {
            i++;
        }
        bus++;
    }
    cout << bus;
    return 0;
}


Measured memory_bytes: 640
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    def dfs(x):
        s = 0
        for y in v[x]:
            if d[y]:
                d[y] = 0
                e_[y] = dfs(y)
            s += e[y]
        p = 0
        if v[x]:
            res = s/len(v[x])
            res += 1
            p = e[x] = res
        if len(v[x]) > 1:
            ns = s-max([e[y] for y in v[x]])
            p = 1+ns/(len(v[x])-1)
        return p

    def dfs2(x):
        if not v_[x]:
            return
        s = 0
        for y in v_[x]:
            if d[y]:
                d[y] = 0
                dfs2(y)
            s += p[y]/len(v[y])
        p[x] = s

    n,m = LI()
    v = [[] for i in range(n)]
    v_ = [[] for i in range(n)]
    for i in range(m):
        a,b = LI()
        a -= 1
        b -= 1
        v[a].append(b)
        v_[b].append(a)
    e = [0]*n
    d = [1]*n
    d[0] = 0
    e_ = [0]*n
    e_[0] = dfs(0)
    p = [0]*n
    p[0] = 1
    d = [1]*n
    d[n-1] = 0
    dfs2(n-1)
    res = e[0]
    print(res+min(list(map(lambda x:x[0]*(x[2]-x[1]), zip(p,e,e_)))))
    return

#Solve
if __name__ == "__main__":
    solve()


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

using namespace std;

#define INF (1 << 30)
#define INFL (1LL << 62)
#define MOD7 1000000007
#define MOD9 1000000009
#define EPS 1e-10

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

int main() {
    ll a, b, c;
    cin >> a >> b >> c;
    if (c - a - b < 0)
        cout << "No" << endl;
    else if (4 * a * b < (c - a - b) * (c - a - b))
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return 0;
}

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

int main() {
	string S;
	cin >> S;
	int N = S.size();
	for (int i = 0;i < N - 1;++i) {
		S.pop_back();
		if (S.size() % 2 == 0 && S.substr(0, S.size() / 2) == S.substr(S.size() / 2, S.size() / 2)) {
			break;
		}
	}
	cout << S.size() << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
int n,q,ans;
int main(){
	cin>>n;
    int S[n];
    for(int i=0;i<n;i++){
    	cin>>S[i];
	}
	cin>>q;
	int T[q];
	for(int i=0;i<q;i++){
		cin>>T[i];
	}
	for(int i=0;i<n;i++){
		for(int j=0;j<q;j++){
			if(S[i]==T[j]){
				ans++;
				T[j]=-1236824;
			}
		}
	}
	cout<<ans<<endl;
	return 0;
} 


Measured memory_bytes: 3140
#!/usr/bin/env python3
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import collections
from decimal import Decimal # 10進数で考慮できる

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

d = collections.deque()
def LI(): return list(map(int, sys.stdin.readline().split()))

A,B,C,D = LI()

while True:
    C -= B
    if C <= 0:
        print("Yes")
        sys.exit()
    A -= D
    if A <= 0:
        print("No") 
        sys.exit()

Measured memory_bytes: 10852
input()
S = input()
runlength = []
begin, end = 0, 0
for i in range(len(S) - 1):
    if S[i] != S[i + 1]:
        end = i + 1
        runlength.append(S[begin:end])
        begin = i + 1
runlength.append(S[begin : len(S)])
print(len(runlength))


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

#define lint long long
#define P pair<int, int>
#define LLP pair<long long, long long>
#define REP(i, x, n) for(int i = (x), i##_len = (int)(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = (int)(n) ; i < i##_len ; ++i)
#define repr(i, n) for(int i = (int)(n) - 1 ; i >= 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())

const int IINF = 1e9 + 10;
const long long LLINF = (long long)1e18 + 10;
const long long MOD = (long long)1e9 + 7;
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};
const double EPS = 1e-8;

int n, m;
vector<int> w;
int maxi;

bool check(int mid){
    if(maxi > mid){
        return false;
    }
    int cnt = 1, sum = 0;
    rep(i, n){
        if(sum + w[i] <= mid){
            sum += w[i];
        }else{
            ++cnt;
            sum = w[i];
        }
    }
    return cnt <= m;
}

int meguru_search(int ok, int ng){
    while(abs(ok - ng) > 1){
        int mid = (ok + ng) / 2;
        if(check(mid)){
            ok = mid;
        }else{
            ng = mid;
        }
    }
    return ok;
}

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

    while(cin >> m >> n, m){

        w.resize(n);
        int sum = 0;
        maxi = 0;
        rep(i, n){
            cin >> w[i];
            sum += w[i];
            maxi = max(maxi, w[i]);
        }

        int ans = meguru_search(sum, 0);
        cout << ans << endl;

    }

    return 0;
}


Measured memory_bytes: 3028
#include <bits//stdc++.h>
using namespace std;
#define rep(i,n,k) for(int i=n;i<k;i++)
#define int long long
#define P make_pair
#define F first
#define S second
signed main(void){
    int n,m,ans,p,q;
    ans=0;
    string s,t,u;
    cin>>n;
    map<int,int> num;
    rep(i,0,n){
        cin>>m;
        if(num.find(m)==num.end())
        num[m]=1;
        else{
            cout<<"NO"<<endl;
            return 0;
        }
    }
    cout<<"YES"<<endl;
    return 0;


}

Measured memory_bytes: 12800
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = (1<<30)-1;
const ll INF = (1LL<<60)-1;
const ld EPS = 1e-10;
template<typename T> bool chmax(T &x, const T &y) {return (x < y)? (x = y, true) : false;};
template<typename T> bool chmin(T &x, const T &y) {return (x > y)? (x = y, true) : false;};

int main(){
    int N;
    cin >> N;
    int A[N], B[N];
    rep(i, N) cin >> A[i];
    rep(i, N) cin >> B[i];
    int memo[51][51];
    rep(i, 51) rep(j, 51){
        if(i == j) {memo[i][j] = 0; continue;}
        memo[i][j] = inf;
        rep2(k, 1, i){
            if(i%k == j || i%k > 2*j){
                memo[i][j] = k;
                break;
            }
        }
    }
    bool pote[N][51];
    fill(pote[0], pote[N], false);
    ll ans = 0;
    rep(i, N) pote[i][A[i]] = true;
    while(true){
        int update = 0;
        rep(i, N){
            int tmp = inf;
            rep(j, 51){
                if(pote[i][j]) chmin(tmp, memo[j][B[i]]);
            }
            chmax(update, tmp);
        }
        if(update == 0) break;
        if(update == inf) {cout << -1 << endl; return 0;}
        ans |= 1LL<<update;
        rep(i, N){
            rep(j, 51) if(pote[i][j]) pote[i][j%update] = true;
        }
    }
    cout << ans << endl;
}

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

int main(){
    int n,x;
    int ans=0;
    scanf("%d %d",&n,&x);
    vector<int> l(n);
    vector<int> d(n+1);
    for(int i=0;i<n;i++) scanf("%d",&l[i]);
    for(int i=1;i<n+2;i++){
        if(i==1) d[i]=0;
        else d[i]=d[i-1]+l[i-2];

        if(d[i]<=x) ans++;
    }
    printf("%d\n",ans);
}

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

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back

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

int main(){
	string s;
	cin>>s;

	for (int i = 0; i < s.size(); ++i){
		if(i%2==0){
			if(s[i]!='R'&&s[i]!='U'&&s[i]!='D'){
				cout<<"No"<<endl;
				return 0;
			}
		}else{
			if(s[i]!='L'&&s[i]!='U'&&s[i]!='D'){
				cout<<"No"<<endl;
				return 0;
			}
		}
	}

	cout<<"Yes"<<endl;

	return 0;
}


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

int main() {
  string s;
  cin >> s;
  char a,b;
  a = s.at(0);
  int x=0,y=0;
  for(int i=0;i<4;i++){
    if(a == s.at(i)){
      x++;
    }
    else {
      b = s.at(i);
      for(int j=0;j<4;j++){
        if(b == s.at(j)){
          y++;
        }
      }
    }
  }
  
  if(x == 2 && y == 4){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}


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

int main(){
  int N;
  cin>>N;
  int a[N+1];
  int i,j;
  long long sum=0;
  for(i=1;i<=N;i++){
	cin>>a[i];
	a[i]-=i;
	sum+=a[i];
  }
  sort(a+1,a+N+1);
  long long b=a[(N+1)/2];
  long long ans=0;
  for(i=1;i<=N;i++){
	ans+=abs(a[i]-b);
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 1024
N=int(input())

for n in range(1,3501):
    for h in range(1,3501):
        up,down=N*n*h,4*h*n-N*(h+n)
        if down!=0:
            if up%down==0 and up//down>0:
                print(h,n,(N*n*h)//(4*n*h-N*(h+n)))
                exit()

Measured memory_bytes: 40556
import sys

h, w = map(int, sys.stdin.readline().split())

def main():
    if w == 1 or h == 1:
        return 1
        
    res = h // 2 * w
    if h & 1:
        res += (w + 2 - 1) // 2
    return res

if __name__ == "__main__":
    ans = main()
    print(ans)

Measured memory_bytes: 3060
import java.util.Scanner;

class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int x = sc.nextInt();
        System.out.println( a<=x&&a+b>=x?"YES":"NO" );
    }
}


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

xor = 0
for a in A[2:]:
    xor ^= a

n = A[0] + A[1] - xor
if n < 0 or n%2:
    print(-1)
    quit()

n //= 2
a = b = 0
digit = [1]
d = []
count = 0    
while n or xor:
    n0 = n & 1; xor0 = xor & 1
    if n0:
        if xor0:
            print(-1)
            quit()
        else:
            a += digit[-1]
            b += digit[-1]
    else:
        if xor0:
            b += digit[-1]
            d.append(count)

    digit.append(digit[-1] * 2)
    count += 1
    n >>= 1; xor >>= 1

if a > A[0]:
    print(-1)
    quit()

while d:
    c = d.pop()
    if a + digit[c] <= A[0]:
        a += digit[c]; b -= digit[c]

if a:
    print(A[0] - a)
else:
    print(-1)

Measured memory_bytes: 9172
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  long long n;
  cin >> n;
  vector<long long> a(3*n);
  
  for(long long i = 0; i < 3*n; i++) {cin >> a[i];}
        sort(a.begin(),a.end());
 
        long long ans = 0;
        int cnt = 0;
        for(long long i = 3*n-2; i >= 0; i -= 2){
                if(cnt == n) break;
                ans += a[i];
                cnt++;
        }
        cout << ans << endl;
        return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
#define ALL(v) (v).begin(), (v).end()

int main() {
  vector<int> dish_time(5);
  int sum_time = 0;
  for (int i = 0; i < 5; ++i) {
    cin >> dish_time.at(i);
    sum_time += (dish_time.at(i) + 9) / 10 * 10;
  }
 
  int min_time = 0;
  for (int i = 0; i < 5; ++i) {
    min_time = max(min_time, ((dish_time.at(i) + 9) / 10 * 10) - dish_time.at(i));
  }
 
  cout << sum_time - min_time << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
 
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		
		boolean isPossible = true;
		for (int i = 0; i < n; i++) {
			int abs = sc.nextInt();
			a[abs]++;
			
			if (n % 2 == abs % 2 || a[abs] >= 3) {
				isPossible = false;
				break;
			}
		}
		
		long ans = 1;
		for (int i = (n % 2) ^ 1; i < n && isPossible; i += 2) {
			if (i == 0 && a[i] != 1 || (i > 0 && a[i] != 2)) {
				isPossible = false;
				break;
			}
			
			if (i > 0) {
				ans = mlt(ans, 2);
			}
		}
		
		if (!isPossible) ans = 0;
		
		System.out.println(ans);
		
		sc.close();
	}
	
	public static long mlt(long a, long b) {
		final long MOD = 1_000_000_007;
		return ((a % MOD) * (b % MOD)) % MOD;
	}
}



Measured memory_bytes: 49616
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;

int main() {
	long long int n;
	cin >> n;
	vector<long long int> a(n);
	vector<long long int> b(n);

	for (long long int i = 0; i < n; i++) {
		cin >> a[i] >> b[i];
	}

	long long int ans = 0;
	bool h = true;
	for (long long int i = 0; i < n; i++) {
		ans += a[i];
		if (a[i] <= b[i]) {
			b[i] -= a[i];
			a[i] = 0;
		}
		if (a[i] != b[i]) {
			h = false;
		}
	}
	long long int MIN = 1000000010LL;
	for (long long int i = 0; i < n; i++) {
		if (a[i] > 0) {
			MIN = min(MIN, b[i]);
		}
	}

	if (h) {
		cout << 0 << endl;
	}
	else {
		cout << ans - MIN << endl;
	}
	return 0;
}

Measured memory_bytes: 640
#include<stdio.h>
int main(){
  int n,q,i,ans=0,j,flag=0,m,l,r;
  scanf("%d",&n);
  int s[n];
  for(i=0;i<n;i++){
  scanf("%d",&s[i]);

  }
  scanf("%d",&q);
  int t[q];
   for(i=0;i<q;i++){
  scanf("%d",&t[i]);
  }
  
 
   for(i=0;i<q;i++){
   l=0;
   r=n;
    m=(l+r)/2;
     while(l<r){
      
       if(s[m]>t[i]){
	 r=m;
	 m=(l+r)/2;
       }
       else if(s[m]==t[i]){
	 ans+=1;
	 break;
       }
       else{
	 l=m+1;
	 m=(l+r)/2;
       }
       
     }
   }

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

  return 0;
}



Measured memory_bytes: 2380
#include <algorithm>
#include <string.h>
#include <iostream>
#include <stdio.h>
using namespace std;
const char sp = ' ';
const long long N = 2e5 + 10;
const long long INF = 2e18;
long long n;
long long k, a[N], L, R;

int main() {
	cin >> n >> k;
	for (long long i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a, a + n);
	L = -INF;
	R = INF;
	while (L + 1 != R) {
		long long Mid = (L + R) / 2;
		long long cnt = 0;
		for (long long i = 0; i < n; i++) {
			if (a[i] < 0) {
				long long l, r;
				l = i;
				r = n;
				while (l + 1 != r) {
					long long mid = (l + r) / 2;
					if (a[i] * a[mid] <= Mid) {
						r = mid;
					}
					else {
						l = mid;
					}
				}
				cnt += n - r;
			}
			else {
				long long l, r;
				l = i;
				r = n;
				while (l + 1 != r) {
					long long mid = (l + r) / 2;
					if (a[i] * a[mid] <= Mid) {
						l = mid;
					}
					else {
						r = mid;
					}
				}
				cnt += l - i;
			}
		}
		if (cnt < k)L = Mid;
		else R = Mid;
	}
	cout << R << endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define BE(x) (x).begin(), (x).end()

int main() {
    string s;
    cin >> s;
    int a = 0, b = 0, c = 0;
    int ss = s.size();
    for (int i = 0; i < ss; i++) {
        if (s[i] == 'a') a++;
        else if (s[i] == 'b') b++;
        else c++;
    }
    int n = max({abs(a-b), abs(b-c), abs(c-a)});
    if (n < 2) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 3708
var
  ch:char;
  n,i,max,k:longint;
begin
  readln(n);
  max:=0;k:=0;
  for i:=1 to n do
   begin
     read(ch);
     if ch='I' then k:=k+1;
     if ch='D' then k:=k-1;
     if k>max then max:=k;
   end;
  writeln(max);
end.

Measured memory_bytes: 128
#include<iostream>

using namespace std;

int main() {
  int N;
  cin >> N;
  
  bool OK =false;
  
  for(int c=0;c<=(N/4); c++) {
    for(int d=0; d<=(N/7); d++) {
      int total= 4*c + 7*d;
      if (total == N) OK = true;
    }
  }
  
  if(OK == false) cout << "No" << endl;
  else cout << "Yes" << endl;
}
 


Measured memory_bytes: 3592
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define PF push_front
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double
#define pii pair<int,int>
#define pll pair<LL,LL>
#define vi vector<int>
#define vl vector<LL>
#define vii vector<vi>
#define vll vector<vl>

const double pi = 3.14159265358979323846264;
const int mod=1000000007;

int main(){
	int a;
    cin>>a;
    cout<<1-a;

}


Measured memory_bytes: 3588
#include<stdio.h>

int main(void)
{
	char hoge;
	scanf("%c",&hoge);
	
	if(hoge == 'A'){
		printf("T\n");
	}
	
	else if(hoge == 'T'){
		printf("A\n");
	}
	
	else if(hoge == 'C'){
		printf("G\n");
	}
	
	else if(hoge == 'G'){
		printf("C\n");
	}
	
	return 0;
}

Measured memory_bytes: 128
# https://atcoder.jp/contests/abc063/tasks/arc075_b
import sys
import itertools
from collections import Counter
from collections import defaultdict
from collections import deque
import bisect
from heapq import heappush, heappop
import math
sys.setrecursionlimit(12345678)


def can_delete(ml, t, a, b):
    for i in range(len(ml)):
        ml[i] -= (b * t)

    count = 0
    for m in ml:
        if m > 0:
            count += math.ceil(m/(a-b))

    return t >= count


def main():
    n, a, b = map(int, input().split())
    monsters = []
    for _ in range(n):
        monsters.append(int(input()))

    l = 0
    r = 10**9
    while l < r:
        m = (l + r) // 2
        if can_delete(monsters[:], m, a, b):
            r = m
        else:
            l = m + 1

    print(r)


if __name__ == '__main__':
    main()


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

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    int n;
    cin >> n;
    bool found = false;
    while(n > 0){
        int digit = n % 10;
        n = n / 10;
        if(digit == 7){
            found = true;
            break;
        }
    }
    cout << (found ? "Yes" : "No");
}

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

mod = 10**9 + 7

S = [0]*61

for i in range(N):
    tmpA = A[i]
    now = 0
    while tmpA != 0:
        if tmpA%2 == 1:
            S[now] += 1
        tmpA //= 2
        now += 1
ans = 0
for i in range(61):
    ans += pow(2,i,mod)*S[i]*(N-S[i])
    ans %= mod
print(ans)

Measured memory_bytes: 122808
#include<bits/stdc++.h>
using namespace std;
#define chmax(a,b) if(a<b)a=b
#define pb push_back
const int N=3011;

string s1,s2;
string ans;
int dp[N][N];

int main()
{
	
	cin>>s1>>s2;
	s1+='('; s2+=')';
	for(int i=0;i<s1.size();i++)
	for(int j=0;j<s2.size();j++)
	{
		chmax(dp[i+1][j],dp[i][j]);
		chmax(dp[i][j+1],dp[i][j]);
		if(s1[i]==s2[j]) chmax(dp[i+1][j+1],dp[i][j]+1);
	}
	int i=s1.size()-1;
	int j=s2.size()-1;
	while(i && j)
		if(dp[i][j]==dp[i-1][j]) i--;
		else if(dp[i][j]==dp[i][j-1]) j--;
		else i--,j--,ans.pb(s1[i]);
	reverse(ans.begin(),ans.end());
	cout<<ans<<'\n';
	
	return 0;
}

Measured memory_bytes: 35584
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include<functional>
#include<numeric>
#include<queue>
#include<stack>
#include<map>
#include<unordered_map>
#include<set>
#include<bitset>
#include<random>

#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define rep(i,n) FOR(i,0LL,n)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define rrep(i,n) RFOR(i,0LL,n)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define COUNT(a,y,x) upper_bound(all(a), y) - lower_bound(all(a), x)
#define UNIQUE(a) sort(all(a)); a.erase(unique(all(a)), a.end())
#define pb push_back
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;
typedef map<ll, ll> MAP;
const ll inf = 2222222222222222222LL;
const ll mod = 1000000007LL;

ll n = 0, m = 0, ans = 0, tmp = 0, ma = -inf, mi = inf;
string s;
bool ok;
ll dx[9] = { 0,1,-1,0,0,1,1,-1,-1 }, dy[9] = { 0,0,0,1,-1,1,-1,1,-1 };
#define endl '\n'
#pragma endregion
#define MAX 222222





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


  ll x, y, z;
  cin >> x >> y >> z >> m;
  vll a(x), b(y), c(z), v;
  rep(i, x) cin >> a[i];
  rep(i, y) cin >> b[i];
  rep(i, z) cin >> c[i];
  sort(rall(a)); sort(rall(b)); sort(rall(c));
  rep(i, a.size()) rep(j, b.size()) rep(k, c.size()) {
    if (i*j*k > 3000) break;
    tmp = a[i] + b[j] + c[k];
    v.pb(tmp);
  }
  sort(rall(v));
  rall(v);
  rep(i, m) cout << v[i] << endl;



  return 0;
}


Measured memory_bytes: 35176