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

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define rep(i, n) repd(i, 0, n)

using namespace std;

using ll = long long;
using ul = unsigned long long;
using ld = long double;
ll mod = 1000000007;

bool judge(vector<ll> &a, ll k, ll len) {
    ll total = 0;
    ll n = a.size();
    rep(i, n) { total += (a[i] + len - 1) / len; }
    return total <= n + k;
}

int main() {
    ll n, k;
    cin >> n >> k;
    vector<ll> a(n);
    rep(i, n) { cin >> a[i]; }

    ll l = 0, r = mod;
    while (r - l > 1) {
        ll mid = (l + r) / 2;
        if (judge(a, k, mid)) {
            r = mid;
        } else {
            l = mid;
        }
    }

    cout << r << endl;

    return 0;
}



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

using namespace std;

const int N = 200 * 1000 + 17;
const int MOD = 1000 * 1000 * 1000 + 7;

int n;
string s;

bool read() {
    if (!(cin >> s))
        return false;

    return true;
}

void solve() {
    n = s.size();
    auto ans = 0ll;
    auto cnt = 0;

    for (int i = 0; i < n; ++i)
        if (s[i] == 'B')
            ++cnt;
        else
            ans += cnt;

    cout << ans << endl;
}

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

    while (read())
        solve();

    return 0;
}



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

int main() {
  ll n;
  cin >> n;
  vector<int> a(n), b(n), c(n);
  rep(i, n) cin >> a[i];
  rep(i, n) cin >> b[i];
  rep(i, n) cin >> c[i];

  sort(a.begin(), a.end());
  sort(c.begin(), c.end());

  ll ans = 0;
  rep(i, n) {
    int j = lower_bound(a.begin(), a.end(), b[i]) - a.begin();
    int k = upper_bound(c.begin(), c.end(), b[i]) - c.begin();
    ans += j * (n - k);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4576
#include<iostream>
#include<stdio.h>
using namespace std;

int main() {
	int H,a[250],i;
	cin>>H;
	
	for (i = 1;i <= H;i++)cin>>a[i];
	
	for (i = 1;i <= H;i++) {
		if (i / 2 == 0) {
			printf("node %d: key = %d, left key = %d, right key = %d, \n", i,a[i], a[2 * i], a[2 * i + 1]);
		}
		else if (2 * i > H) {
			printf("node %d: key = %d, parent key = %d, \n",i,a[i],a[i/2]);
		}
		else if (2 * i + 1>H) {
			printf("node %d: key = %d, parent key = %d, left key = %d, \n", i, a[i], a[i / 2], a[2 * i]);
		}
		else {
			printf("node %d: key = %d, parent key = %d, left key = %d, right key = %d, \n", i, a[i], a[i / 2], a[2 * i], a[2 * i + 1]);
		}
	}
	return 0;
}


Measured memory_bytes: 3208
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <numeric>
#include <queue>
#include <numeric>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <map>
#include <functional>
#include <limits>
#include <set>
#include <stack>
#include <cctype>
#define rep(i,a,b) for((i)=a;i<(int)(b);i++)

#define AAA (1000000007) 


using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pairII;


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 powD(ll a, ll b) {
	ll ans = 1;
	a %= AAA;
	for (int i = 0; i < b; i++)
	{
		ans *= a;
		ans %= AAA;
	}
	return ans;
}



int main() {
	string S, T;
	cin >> S >> T;
	int i;
	int ans = 0;
	rep(i, 0, S.size()) {
		if (S[i] != T[i])
			ans++;

	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 3880
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <sstream>
#include <numeric>
#include <set>
#include <map>
//#include <bits/stdc++.h>

#define rep(i, j) for(int i = 0; i < j; i++)
#define all(i) i.begin(), i.end()
#define ll long long
#define bl bool
#define nn printf("\n");
#define mod 1000000007

using namespace std;

int Str2Num(string s)
{
	stringstream ss;
	ss << s;
	int num;
	ss >> num;
	return num;
}
string Num2Str(int num)
{
	stringstream ss;
	ss << num;
	return ss.str();
}
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);

	int n; cin >> n;
	rep(i, n)
	{
		string tar; cin >> tar;
		int ans = 0;
		while (1)
		{
			int tmp = 0;
			if ((int)tar.size() == 1) { break; }
			rep(i, (int)tar.size() - 1)
			{
				string sp1, sp2;
				sp1 = accumulate(tar.begin(), tar.begin() + i + 1, string());
				sp2 = accumulate(tar.begin() + i + 1 , tar.end(), string());
				tmp = max(tmp, (Str2Num(sp1) * Str2Num(sp2)));
			}
			tar = Num2Str(tmp);
			ans++;
		}
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 3352
n=int(input())
a=list(input().split())
o=[]
e=[]
if n==1:
    print(a[0])
elif n%2==0:
    for i in range(1,n,2):
        e.append(a[i])
    for i in range(0,n,2):
        o.append(a[i])
    e.reverse()
    print(" ".join(e)+" "+" ".join(o))
else:
    x=a[0]
    for i in range(1,n,2):
        e.append(a[i])
    for i in range(2,n,2):
        o.append(a[i])
    o.reverse()
    print(" ".join(o)+" "+x+" "+" ".join(e))


Measured memory_bytes: 117464
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
constexpr int di[] = { 0, 1, 0, -1 }, dj[] = { 1, 0, -1, 0 };
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define sortr(v) sort((v).rbegin(), (v).rend())
#define all(v) (v).begin(), (v).end()
#define MAX 2000001
#define vmax 10000
constexpr ll inf = 1000000000000;
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/

int main() {
    int n,k;
    int m;
    cin>>n>>k;
    int x=0,cnt=0;
    int a[n];
    rep(i,n) cin>>a[i];
    rep(i,n){
        if(i==0){
            x+=k;
            cnt++;
        }else{
            x+=k-1;
            cnt++;
        }
        if(x>=n){
            cout<<cnt<<endl;
            return 0;
        }
    }

    return 0;
}












Measured memory_bytes: 640
import java.util.Scanner;

public class Main {
    void run() {
        Scanner scan = new Scanner(System.in);
        int a = scan.nextInt();
        int b = scan.nextInt();
        int c = scan.nextInt();
        int x = scan.nextInt();
        int ans = 0;
        for (int i = 0; i <= a; i++) {
            for (int j = 0; j <= b; j++) {
                for (int k = 0; k <= c; k++) {
                    if ((500  * i) + (100 * j) + (50 * k) == x)
                        ans++;
                }
            }
        }
        System.out.println(ans);
    }
    public static void main(String[] args) {
        new Main().run();
    }
}


Measured memory_bytes: 23124
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
    ll n;
    cin>>n;
    vector<ll> b(n-1);
    for(ll i=0;i<n-1;i++)cin>>b[i];
    ll ans=0;
 	reverse(b.begin(),b.end());
    ans+=b[n-2]+b[0];
    for(ll i=0;i<n-2;i++){
        ll a;
        a=(b[i]<b[i+1])?b[i]:b[i+1];
        ans+=a;
    }
    cout<<ans<<endl;
}

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

typedef long long ll;
#define Inf 1 << 20
#define MInf -(1 << 20)
 
#define REP(n) for(int i = 0;i < (int)(n);i++)
#define rep(i,n) for(int i = 0;i < (int)(n);i++)
#define Rep(i,n,m) for(int i = (int)(n); i < (int)(m);i++)
#define rrep(i,n) for(int i = (int)(n - 1); i > -1;i--)
#define RRep(i,n,m) for(int i = (int)(n - 1); i > (int)(m);i--)
#define trav(a, x) for(auto& a : x)
 
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V))
#define REVERSE(V) reverse(ALL(V))
#define RSORT(V) SORT(V);REVERSE(V)
 
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define yes(n) cout << ((n) ? "yes" : "no") << endl;


int main()
{
    int N = 0;
    cin >> N;
    ll count = 0;
    vector<int> v(N);
    rep(i,N)
    {
        cin >> v.at(i);
    }
    bool is = true;
    while(is)
    {
        rep(i,N)
        {
            if(v[i] % 2 != 0)
            {
                is = false;
            }
            v[i] = v[i] / 2;
        }
        count++;
    }
    cout << count - 1<< endl;
}

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

int main(){
    int sum;
    
    for(int i=1; i<10; i++){
        for(int j=1; j<10; j++){
            sum = i * j;
            cout << i << "x" << j << "=" << sum << endl;
        }
    }

    return 0;
}

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

// region template
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define trav(a, x) for (auto &a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;

ll gcd(ll a, ll b) { return __gcd(a, b); }

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

typedef unsigned long long ull;
typedef long double ld;
ull mod_mul(ull a, ull b, ull M) {
    ll ret = a * b - M * ull(ld(a) * ld(b) / ld(M));
    return ret + M * (ret < 0) - M * (ret >= (ll)M);
}
ull mod_pow(ull b, ull e, ull mod) {
    ull ans = 1;
    for (; e; b = mod_mul(b, b, mod), e /= 2)
        if (e & 1) ans = mod_mul(ans, b, mod);
    return ans;
}

const ll mod = 1000000007;
struct Mod {
    ll x;
    Mod(ll xx) : x(xx) {}
    Mod operator+(Mod b) { return Mod((x + b.x) % mod); }
    Mod operator-(Mod b) { return Mod((x - b.x) % mod); }
    Mod operator*(Mod b) { return Mod((x * b.x) % mod); }
    Mod operator/(Mod b) { return *this * invert(b); }
    Mod invert(Mod a) {
        ll x, y, g = euclid(a.x, mod, x, y);
        assert(g == 1); return Mod((x + mod) % mod);
    }
    Mod operator^(ll e) {
        if (!e) return Mod(1);
        Mod r = *this ^ (e / 2); r = r * r;
        return e & 1 ? *this * r : r;
    }
};
// endregion

ll tri(ll i) {return i*(i+1)*(i+2)/6;}
int dp[1000005], dp2[1000005];

int main() {
    rep(i, 0, 1000005) dp[i] = dp2[i] = i;
    for (int i = 1; tri(i) < 1000005; i++) {
        if (tri(i) % 2 == 1) {
            for (int j = 0; j + tri(i) < 1000005; j++)
                dp2[j + tri(i)] = min(dp2[j + tri(i)], dp2[j] + 1);
        }
        for (int j = 0; j + tri(i) < 1000005; j++)
            dp[j + tri(i)] = min(dp[j + tri(i)], dp[j] + 1);
    }
    for (;;) {
        int n; cin >> n; if (!n) break;
        cout << dp[n] << " " << dp2[n] << endl;
    }
}


Measured memory_bytes: 10872
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<climits>
#include<set>
#include<utility>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD=1e9+7;

int main(){
	
	int n, a[100000], k;
	cin >> n >> k;
	for(int i=0; i<n; i++){
		cin >> a[i];
	}
	n--, k--;
	if(n%k==0){
		cout << n/k << endl;
	} else {
		cout << n/k+1 << endl;
	}

	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
bool SecondCompare(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second<b.second;
}
 
bool SecondCompareDes(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second>b.second;
}
string s, ans;
int main(){
    cin >> s;
  ans += "2018";
    for(int i = 4;i < s.length(); i++){
      ans += s[i];
    }
  cout << ans << endl;
}

Measured memory_bytes: 256
#![allow(unused_imports, unused_variables, dead_code)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;
use std::io::Write;

trait InputValue {
    fn parse(s: &str) -> Self;
}

fn read<T: InputValue>() -> T {
    let mut buf = String::new();
    let _ = stdin().read_line(&mut buf);
    T::parse(&buf.trim())
}

fn readnc<T: InputValue>() -> Vec<T> {
    let mut vec = vec![];
    let line: String = read();
    for token in line.split_whitespace() {
        vec.push(T::parse(token));
    }
    vec
}

fn readn<T: InputValue>(n: usize) -> Vec<T> {
    let mut vec = vec![];
    for _ in 0..n {
        vec.push(read());
    }
    vec
}

macro_rules! parse_single_value {
    ($($t:ty),*) => {
        $(
            impl InputValue for $t {
                fn parse(s: &str) -> $t { s.parse().unwrap() }
            }
        )*
	}
}
parse_single_value!(i32, i64, f32, f64, usize, String);

macro_rules! parse_tuple {
	($($t:ident),*) => {
		impl<$($t),*> InputValue for ($($t),*) where $($t: InputValue),* {
			fn parse(s: &str) -> ($($t),*) {
				let mut tokens = s.split_whitespace();
				let t = ($($t::parse(tokens.next().unwrap())),*);
				t
			}
		}
	}
}
parse_tuple!(A, B);
parse_tuple!(A, B, C);

// ===

fn main() {
    let (n, l): (usize, i64) = read();
    let a: Vec<i64> = readnc();

    let mut lol: usize = n+1;
    for i in 0..n-1 {
        if a[i] + a[i+1] >= l {
            lol = i;
            break;
        }
    }

    let out = stdout();
    let mut out = BufWriter::new(out.lock());

    if lol >= n {
        writeln!(out, "Impossible");
    } else {
        writeln!(out, "Possible");
        for i in 0..lol {
            writeln!(out, "{}", i+1);
        }
        for i in (lol+1..n-1).rev() {
            writeln!(out, "{}", i+1);
        }
        writeln!(out, "{}", lol+1);
    }
}

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

int const INF = 1024102410;
int N;


int main() {
  std::cin >> N;
  
  std::vector<int> a(N);
  for(int i = 0; i < N; ++i) std::cin >> a[i];
  
  std::vector<std::vector<int>> G(N);
  for(int i = 0; i < N-1; ++i) {
    int u, v; std::cin >> u >> v; --u; --v;
    G[u].push_back(v);
    G[v].push_back(u);
  }
  
  std::vector<int> dp(N, INF), ans(N);
  auto dfs = [&](auto &&f, int v, int p)->void {
    auto pos = std::lower_bound(dp.begin(), dp.end(), a[v]);
    auto val = *pos;
    *pos = a[v];
    ans[v] = std::lower_bound(dp.begin(), dp.end(), INF) - dp.begin();
    for(auto c: G[v]) if(c != p) f(f, c, v);
    *pos = val;
  };
  
  dfs(dfs, 0, -1);
  for(auto v: ans) std::cout << v << "\n";
  return 0;
}


Measured memory_bytes: 30880
a=int(input())
b=[sorted(input()) for j in range(a)]
c=[[0for i in range(26)] for j in range(a)]
for i in range(a):
  for j in range(10):
    c[i][ord(b[i][j])-97]+=1
sum=0
d=1
c.sort()
for i in range(a-1):
  if c[i]==c[i+1]:
    d+=1
  else:
    sum+=d*(d-1)//2
    d=1
  if i==a-2:
    sum+=d*(d-1)//2
    
print(sum)

Measured memory_bytes: 61504
#include<bits/stdc++.h>
#define ull unsigned long long
#define ll long long
#define db double
#define ldb long double
#define vi vector<int>
#define vull vector<ull>
#define vll vector<ll>
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define si set<int>
#define sll set<ll>
#define ins insert
#define vpp vector<pair<int,int>>
#define mp make_pair
#define ft first
#define sc second
using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
    ll n,k;
    cin>>n>>k;
    ll a[n];
    rep(i,n){
    	cin>>a[i];	
	}
	ll sum=0;
	sort(a,a+n,greater<ll>());
	ll ans=0;
    for(int i=0;i<n;i++){
    	sum+=a[i];
    	if(sum<k)
    	ans++;
    	else{
    	ans=0;
		sum-=a[i];	
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    string s1,s2,s3;
    cin>>s1>>s2>>s3;
    char c1=toupper(s1.at(0));
    char c2=toupper(s2.at(0));
    char c3=toupper(s3.at(0));
    cout<<c1<<c2<<c3<<endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	static int r = 0;
	static int w;
	static int h;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (true) {
			w = sc.nextInt();
			h = sc.nextInt();
			if (w == 0 && h == 0)
				break;
			r = 0;
			int x = 0;
			int y = 0;
			String fs;
			int[][] fi = new int[h][w];
			int[][] l = new int[h][w];
			for (int i = 0; i < h; i++)
				for (int j = 0; j < w; j++)
					l[i][j] = 0;
			for (int i = 0; i < h; i++) {
				fs = sc.next();
				for (int j = 0; j < w; j++) {
					if (fs.charAt(j) == '.')
						fi[i][j] = 1;
					if (fs.charAt(j) == '#')
						fi[i][j] = 0;
					if (fs.charAt(j) == '@') {
						fi[i][j] = 1;
						x = i;
						y = j;
					}
				}
			}
			loop(x, y, fi, l);
			System.out.println(r);
		}
		sc.close();
	}

	public static void loop(int x, int y, int[][] fi, int[][] l) {
		r++;
		l[x][y] = 1;
		if (x > 0)
			if (fi[x - 1][y] != 0 && l[x - 1][y] == 0)
				loop(x - 1, y, fi, l);
		if (x < h - 1)
			if (fi[x + 1][y] != 0 && l[x + 1][y] == 0)
				loop(x + 1, y, fi, l);
		if (y > 0)
			if (fi[x][y - 1] != 0 && l[x][y - 1] == 0)
				loop(x, y - 1, fi, l);
		if (y < w - 1)
			if (fi[x][y + 1] != 0 && l[x][y + 1] == 0)
				loop(x, y + 1, fi, l);
	}
}

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

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 1000000000000000000LL
#define MOD 1000000007
#define writeln(n) cout<<n<<endl
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
//vector<tuple<long long, long long, long long>>vec;

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

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

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


int main()
{
    llong h,w;
    cin>>h>>w;
    llong ans=INF;
    if(h%3==0||w%3==0)ans=0;
    else{
        ans=min(h,w);
        llong t=h/2;
        for(llong i=1;i<=w-1;i++){
            llong a=t*(w-i);
            llong b=(h-t)*(w-i);
            llong c=h*i;
            ans=min(ans,max({a,b,c})-min({a,b,c}));
        }
        t=w/2;
        for(llong i=1;i<=h-1;i++){
            llong a=t*(h-i);
            llong b=(w-t)*(h-i);
            llong c=w*i;
            ans=min(ans,max({a,b,c})-min({a,b,c}));
        }
    }
    cout<<ans<<endl;

}

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

int main() {
  int A, B, C, D, L, R;
  cin >> A >> B >> C >> D;
  L = A + B;
  R = C + D;
  
  if (L>R) {
    cout << "Left" << endl;
  }
  else if (L<R) {
    cout << "Right" << endl;
  }
  else {
    cout << "Balanced" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define INF 9223372036854775807
ll dp[20001];
int main(void){
	ll n,m,k,a[20001],i,j,min,max,temp;
	cin>>n>>m>>k;
	for(i=1;i<=n;i++) cin>>a[i];
//	for(i=1;i<=n;i++) cout<<a[i]<<endl;
	for(i=0;i<=n;i++) dp[i]=INF;
	dp[0]=0;
	for(i=0;i<n;i++){
		min=INF; max=-1;
		for(j=1;j<=m;j++){
			if(i+j<=n){
//				cout<<'A'<<endl;
				if(min>a[i+j]) min=a[i+j];
				if(max<a[i+j]) max=a[i+j];
				temp=dp[i]+k+j*(max-min);
				if(dp[i+j]>temp) dp[i+j]=temp;
			}
		}
	}
/*	cout<<endl;
	for(i=0;i<=n;i++) cout<<dp[i]<<endl;
	cout<<endl;*/
	cout<<dp[n]<<endl;
	return 0;
}

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

int ra[9];

void put(int r) {
  if (r >= 1 && r <= 399) {
    ra[0] |= 1;
    return;
  }
  if (r >= 400 && r <= 799) {
    ra[1] |= 1;
    return;
  }
  if (r >= 800 && r <= 1199) {
    ra[2] |= 1;
    return;
  }
  if (r >= 1200 && r <= 1599) {
    ra[3] |= 1;
    return;
  }
  if (r >= 1600 && r <= 1999) {
    ra[4] |= 1;
    return;
  }
  if (r >= 2000 && r <= 2399) {
    ra[5] |= 1;
    return;
  }
  if (r >= 2400 && r <= 2799) {
    ra[6] |= 1;
    return;
  }
  if (r >= 2800 && r <= 3199) {
    ra[7] |= 1;
    return;
  }
  ra[8] += 1;
}

int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    put(x);
  }
  
  int ansmin = 0, ansmax = 0;
  for (int i = 0; i < 8; i++) {
    ansmin += ra[i];
    ansmax += ra[i];
  }
  if (ra[8] != 0) {
    ansmax += ra[8];
  }
  cout << max(1, ansmin) << " " << ansmax << endl;
  return 0;
}


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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >>n;
  int max = 1;
  for(int i = 10*10*10*10*10; i > 1 ; i /= 10){
    if(n/i > 0) {max=i;break;}
  }
  int ans;
  if(max == 10*10*10*10*10) {
    ans = 90909;
    for(int i = 0; 1; i++){
      if(n < 1000000+i) break;
      else ans++;
    }
  }
  else if(max == 10*10*10*10 || max == 10*10*10) {
    ans = 909;
    for(int i = 0; 1; i++){
      if(n < 10000+i) break;
      else ans++;
    }
  }
  else if(max == 10*10 || max == 10) {
    ans = 9;
    for(int i = 0; 1; i++){
      if(n < 100+i) break;
      else ans++;
    }
  }
  else {
    ans = 0;
    for(int i = 1; 1; i++){
      if(n < i) break;
      else ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 888
#include<bits/stdc++.h>                
using namespace std;
int N;
string A, B, C;
int answer;
int main(void){
	cin >> N >> A >> B >> C;
	for(int i = 0; i < N; i++){
		if(A[i] == B[i] && B[i] == C[i] && C[i] == A[i]){
		} else if(A[i] == B[i] || B[i] == C[i] || C[i] == A[i]) answer+=1;
		else answer+=2;
	}
	cout << answer << endl;
}


 
 
 
 


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#define REP(i, n) for(int i=0;i<n;++i)

typedef long long ll;
using namespace std;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, m;
    cin >> n >> m;
    pair<int, int> p = {};
    vector<int> l = {};
    vector<int> r = {};
    ll res = 0;
    vector<int> s = {};
    vector<int> g = {};
    REP(i, m){
        ll x, y;
        cin >> x >> y;
        s.push_back(x);
        g.push_back(y);
    }

    sort(s.begin(), s.end(), greater<int>());
    sort(g.begin(), g.end());

    ll ans = 0;
    if(g[0]-s[0]>=0){
        ans = g[0]-s[0]+1;
    } else {
        ans = 0;
    }

    cout << ans << "\n";

    return 0;
}

Measured memory_bytes: 1276
#include <bits/stdc++.h>
#define pb push_back
#define sz(a) int(a.size())
#define re return
#define all(a) a.begin(),a.end()
#define int long long
using namespace std;
signed main()
{
	int a,b,c;
	cin>>a>>b>>c;
	cout<<c<<' '<<a<<' '<<b;
	re 0;
}

Measured memory_bytes: 256
N,M=map(int,input().split())
MOD=10**9+7

if abs(N-M)>1:
    print(0)
    exit()

fn=1
for n in range(2,min(N,M)+1):
    fn=fn*n%MOD
fx=fn

ans=1
if N==M:
    ans*=2
else:
    fx=fx*max(N,M)%MOD
print(ans*fn*fx%MOD)


Measured memory_bytes: 39024
N, Y = gets.split.map(&:to_i)
if Y > N * 10000 || Y < N * 1000
    puts '-1 -1 -1'
    exit
end
(0..N).each do |x|
    (0..(N-x)).each do |y|
        z = (N - x - y)
        if Y == x * 10000 + y * 5000 + z * 1000
            puts [x, y, z].join(' ')
            exit
        end
    end
end
puts '-1 -1 -1'

Measured memory_bytes: 1788
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

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

const ll mod=1e9+7;

int main()
{
    ll n,k;
    cin >> n >> k;
    vector<ll> a(n);
    rep(i,n){
        cin >> a[i];
    }
    vector<vector<ll>> dp(n+1,vector<ll>(k+2)); //0~k+1
    dp[0][0]=1;
    for(ll i=1;i<=n;i++){
        for(ll j=0;j<=k;j++){
            dp[i][j]+=dp[i-1][j];
            dp[i][j]%=mod;
            if(j+a[i-1]<=k){
                dp[i][j+a[i-1]+1]-=dp[i-1][j];
                dp[i][j+a[i-1]+1]+=mod;
                dp[i][j+a[i-1]+1]%=mod;
            }
            else{
                dp[i][k+1]-=dp[i-1][j];
                dp[i][k+1]+=mod;
                dp[i][k+1]%=mod;
            }
        }
        for(ll j=0;j<=k;j++){
            dp[i][j+1]+=dp[i][j];
            dp[i][j+1]%=mod;
        }
    }
    cout << dp[n][k] << endl;
    return 0;
} 

Measured memory_bytes: 80256
def main():
    n = int(input())
    a = [list(map(int, input().split())) for _ in range(n)]
    dp = [[] * 3] * n
    dp[0] = a[0]
    for i in range(1, n):
        dp[i] = [0, 0, 0]
        dp[i][0] = max(dp[i - 1][1] + a[i][0], dp[i - 1][2] + a[i][0])
        dp[i][1] = max(dp[i - 1][0] + a[i][1], dp[i - 1][2] + a[i][1])
        dp[i][2] = max(dp[i - 1][0] + a[i][2], dp[i - 1][1] + a[i][2])
    print(max(dp[n - 1]))

if __name__ == '__main__':
    main()


Measured memory_bytes: 47180
x1, y1, x2, y2 = map(int, input().split())
 
x4 = x1 - (y2 - y1)
y4 = y1 + (x2 - x1)
 
x3 = x4 - (y1 - y4)
y3 = y4 + (x1 - x4)
 
print(x3, y3, x4, y4)

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

int main(){
  int n;
  cin >> n;
  int a[n];
  int c = 0, d = 0;
  rep(i, n){
    cin >> a[i];
    if(a[i] % 4 == 0) c++;
    if(a[i] % 2) d++;
  }
  if(c + d == n)  cout << (c + 1 >= d ? "Yes" : "No") << endl; 
  else cout << (c >= d ? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 640
#define fn auto
#include <iostream>
#include <stdio.h>
#include <vector>
#include <math.h>
#include <algorithm>
#include <string>
using namespace std;

void newline() {cout << endl;}
template <typename T> void display(T input){cout << input;}
template <typename T> void put(T input){display(input); newline();}
void iput(int input) {put(input);}

fn main() -> int {
  int n;
  cin >> n;
  cout << (n >= 1200 ? "ARC" : "ABC") << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
using i64 = int64_t;
using f80 = __float80;
static const int dy[4] = {0,1,0,-1}, dx[4] = {1,0,-1,0};
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
#define _overload3(_1,_2,_3,name,...) name
#define repi(i,start,end) for(i64 i=(start);i<(end);++i)
#define _rep(i,n) repi(i,0,n)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,start,end) for(i64 i=(start);i>end;--i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define v(T) vector<T>
#define vv(T) v(v(T))
typedef v(i64) vi;
typedef v(vi) vvi;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream &operator<<(ostream &os, const vector< T > &v){
  rep(i,v.size()) os << v[i] << (i + 1 != v.size() ? " " : "");
  return os;
}
template<typename T> istream &operator>>(istream &is, vector< T > &v){
  for(T &in : v) is >> in;
  return is;
}

void Main()
{
  i64 N, A, B;
  cin >> N >> A >> B;
  cout << min(A * N, B) << "\n";
}

int main()
{
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
  int d,h,i;

  while(EOF!=scanf("%d",&d)){

  h=0;

  for(i=0;i<600/d;i++){
    h += d*i*d*i;
  }

  printf("%d\n", h*d);

}

  return 0;
}

Measured memory_bytes: 596
/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>
#include <random>
#include <cstring>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
#include <stack>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type ---------- */
using ll = long long;
#define int ll
#define P pair<ll, ll>

/* ---------- Constants  */
const double PI = 3.141592653589793238462643383279;
const ll MOD = 1e9 + 7;
const int INF = 1LL << 55;

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */
signed main() {
    int N;
    cin >> N;
    vector<int> S(N + 1, 0);
    int ret = INF;
    for (int i = 0; i < N; i++) {
        S[i+1] = S[i];
        int w;
        cin >> w;
        S[i+1] += w;
    }

    for (int i = 1; i <= N; i++) {
        ret = min(ret, abs(S[N] - S[i] - S[i]));
    }

    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan0
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/














string S, T;
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> S >> T;

	if (S == T.substr(0, S.length())) cout << "Yes" << endl;
	else cout << "No" << endl;
}







Measured memory_bytes: 3656
local n = io.read("*n", "*l")
local map = {}
for i = 1, n do
  local str = io.read()
  local t = {}
  for i = 1, 10 do
    table.insert(t, str:sub(i, i))
    table.sort(t)
  end
  local sorted = table.concat(t)
  if not map[sorted] then map[sorted] = 1
  else map[sorted] = map[sorted] + 1
  end
end
local ret = 0
for k, v in pairs(map) do
  ret = ret + (v * (v - 1)) // 2
end
print(ret)


Measured memory_bytes: 20708
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
	int x;
	cin >> x;
	if (x < 1200) {
		cout << "ABC" << endl;
	}
	else {
		cout << "ARC" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 9)
# input = sys.stdin.readline    ####
def int1(x): return int(x) - 1
def II(): return int(input())
def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())
def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def MS(): return input().split()
def LS(): return list(input())
def LLS(rows_number): return [LS() for _ in range(rows_number)]
def printlist(lst, k=' '): print(k.join(list(map(str, lst))))
INF = float('inf')
# from math import ceil, floor, log2
# from collections import deque, defaultdict
# from itertools import combinations as comb, combinations_with_replacement as comb_w, accumulate, product, permutations
# from heapq import heapify, heappop, heappush
# import numpy as np    # cumsum
# from bisect import bisect_left, bisect_right

def solve():
    N = II()
    Z = []
    for i in range(N):
        x, y = MI()
        Z.append((x-y, x+y))
    # print(Z)
    minx = miny = INF
    maxx = maxy = -INF
    for z in Z:
        minx = min(minx, z[0])
        maxx = max(maxx, z[0])
        miny = min(miny, z[1])
        maxy = max(maxy, z[1])
    print(max(maxx-minx, maxy-miny))
if __name__ == '__main__':
    solve()



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



int main()
{
	vector<int> v;
	for (int i = 0; i < 5; i++){
		int n;
		cin >> n;
		v.push_back(n);
	}
	sort(v.begin(), v.end());
	for (int i = 4; i > 0; i--){
		cout << v[i]<<" ";
	}
	cout << v[0] << endl;
	return 0;
}

Measured memory_bytes: 1216
#include <stdio.h>
#include <string.h>

int main(){
    char input[1500];
    int i;

    while(1){
        fgets(input, sizeof(input), stdin);
        if(input[0] == '0') break;
        input[strlen(input) - 1] = '\0';
        int sum_of_digit = 0;
        for(i=0; input[i]!='\0'; i++){
            sum_of_digit += input[i] - '0';
        }
        printf("%d\n", sum_of_digit);
    }
}



Measured memory_bytes: 2044
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include <time.h>
typedef long long ll;
typedef long double ld;
#define INF (1LL<<60)
#define MOD1 1000000007
/*swap 交換*/
void swap(ll *a, ll *b){ll c;c=*b;*b=*a;*a=c;}
/*2つのうち大きい数を返す*/
ll max2(ll a,ll b){return a>=b?a:b;}
/*2つのうち小さい数を返す*/
ll min2(ll a,ll b){return a>=b?b:a;}
/*絶対値*/
ll ABS(ll a){return a>=0?a:(-a);}
typedef struct{
    ll aa;
    ll bb;
}frequent;
// 小大
int compare(const void *a, const void *b){
    return *(ll *)a>*(ll *)b?1:*(ll *)a<*(ll *)b?-1:0;}

int main(void){
    ll n,k,s,i;
    scanf("%lld%lld%lld",&n,&k,&s);
    for(i=0;i<n;i++){
        if(i<k){
            printf("%lld ",s);
        }else{
            if(s==1000000000){
                printf("3 ");
            }else{
                printf("1000000000 ");
            }
        }
    }
    printf("\n");
    return 0;
}

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

int main() {
  int n, cnt = 0, res;
  int xx, yy, zz;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cnt = 0;
    for (int x = 1; x <= 100; x++) {
      xx = x * x;
      if (xx >= i) break;
      for (int y = 1; y <= 100; y++) {
        yy = y * y;
        if (xx + yy >= i) break;
        for (int z = 1; z <= 100; z++) {
          zz = z * z;
          if (xx + yy + zz >= i) break;
          res = xx + yy + zz + x * y + y * z + z * x;
          if (res > i) break;
          if (res == i) cnt++;
        }
      }
    }
    cout << cnt << endl;
  }
}

Measured memory_bytes: 3520
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;

int main(){
	int n;
	cin >> n;
	
	vector<int> h(n);
	for(int i = 0; i < n; ++i){
		cin >> h[i];
	}
	sort(h.begin(), h.end(), greater<int>());

	long long ans = 1;
	for(int i = 0; i < n; ++i){
		ans += max(0, h[i] - i / 4);
	}
	
	cout << ans << endl;
}

Measured memory_bytes: 1208
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <complex>
#include <iterator>
#include <array>
#include <memory>
#include <stack>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
typedef pair<ll,ll>pll;
int main(){
    bool flag=false;
    int tiya,rize,tino; cin>>tiya>>rize>>tino;
    ll gotiusa=0;
    rep(i,10000000){
        gotiusa+=tiya;
        if(gotiusa%rize==tino)flag=true;
    }
    cout<<(flag ? "YES":"NO")<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#define int long long
using namespace std;
const int N=1e5+2;
pair<int,pair<int,int> > ar[N];
pair<int,int> wow[N];
int sum[N];
signed main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n,x,i,j,k,l=0,val,val1,max1;
	int lef=0,rig=0,mid;
	cin>>n>>x;
	for(i=1;i<=n;i++){
		cin>>ar[i].first>>ar[i].second.first>>ar[i].second.second;
		rig+=ar[i].first;
		l+=-ar[i].first*ar[i].second.first;
		wow[i].first=ar[i].first*(ar[i].second.first-ar[i].second.second)+x*ar[i].second.second;
		wow[i].second=i;
	}
	sort(wow+1,wow+1+n,[&](pair<int,int> cac,pair<int,int> cac1){
		return cac.first>cac1.first;
	});
	for(i=1;i<=n;i++){
		sum[i]=sum[i-1]+wow[i].first;
	}
	while(rig>lef){
		mid=(lef+rig)/2;
		val=mid/x;
		val1=mid%x;
		max1=sum[val];
		for(i=1;i<=n;i++){
			j=wow[i].second;
			if(i<=val){
				if(val1>ar[j].first){
max1=max(max1,sum[val+1]-wow[i].first+ar[j].first*(ar[j].second.first-ar[j].second.second)+val1*ar[j].second.second);
				}
				else{
					max1=max(max1,sum[val+1]-wow[i].first+val1*ar[j].second.first);
				}
			}
			else{
				if(val1>ar[j].first){
				max1=max(max1,sum[val]+ar[j].first*(ar[j].second.first-ar[j].second.second)+val1*ar[j].second.second);
				}
				else{
					max1=max(max1,sum[val]+val1*ar[j].second.first);
				}
			}
		}
		if(max1+l>=0){
			rig=mid;
		}
		else{
			lef=mid+1;
		}
	}
	cout<<rig;
}

Measured memory_bytes: 4992
#include<time.h>
#include<stdio.h>
#include<unistd.h>
#include<string.h>
#include<stdlib.h>
#include<stdint.h>
#include<stdarg.h>
#include<tgmath.h>
#include<assert.h>
#include<iso646.h>
#include<stdbool.h>

//fast(?) Input
#define buf_sz 1<<24
char buf[buf_sz];
unsigned int nextint(){
	static int idx = 0, sz;
	if(idx == 0)sz = read(0, buf, buf_sz);
	unsigned int res = 0;
	while(idx<sz && buf[idx]<'0' || '9'<buf[idx])idx++;
	while(idx<sz && '0'<=buf[idx] && buf[idx]<='9'){
		res *= 10;
		res += buf[idx++] - '0';
	}if(idx>=sz)exit(1);
	return res;
}

int d[] = {[0 ... 1<<17] -1};
int find(int x){
	if(d[x] < 0) return x;
	return d[x] = find(d[x]);
}
bool unite(int x, int y){
	x = find(x); y = find(y);
	if(x == y)return false;
	if(d[x] > d[y]){
		int tmp = x;
		x = y;
		y = tmp;
	}
	d[x] += d[y];
	d[y] = x;
	return true;
}
bool same(int x, int y){return find(x) == find(y);}
int size(int x){return -d[find(x)];}

int main(){
	int N = nextint() - 1;
	int M = nextint();
	for(int i=0;i<M;i++)N -= unite(nextint(), nextint());
	printf("%d\n", N);
	return 0;
}

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

int main()
{
	int a = 0;
	int b = 0;
	int val = 0;
	scanf("%d %d", &a, &b);

	if ((b%a) == 0) {
		val = a + b;
	} else {
		val = b -a;
	}
	printf("%d",val);
	return 0;
}


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

using namespace std;
using ll = long long;

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

    int n, q;
    cin >> n;
    vector<int> s(n);
    for(int i = 0; i < n; ++i) cin >> s[i];
    cin >> q;
    int t, ans = 0;
    for(int i = 0; i < q; ++i) {
        cin >> t;
        for(int j: s) {
            if(t == j) {
                ans++;
                break;
            }
        }
    }

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

    return 0;
}


Measured memory_bytes: 3224
#include <stdio.h>
#include <string.h>

int main()
{
	char S[4];
	
	scanf("%s",&S);
	if(!strcmp(S,"abc") || !strcmp(S,"acb") || !strcmp(S,"bac") || !strcmp(S,"bca") || !strcmp(S,"cab") || !strcmp(S,"cba")) printf("Yes\n");
	else printf("No\n");
	
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp>
//#include <functional> // for less
//using namespace __gnu_pbds;
using namespace std;
typedef long long  L;

#define max_(x, y) (((x) > (y)) ? (x) : (y))
#define min_(x, y) (((x) < (y)) ? (x) : (y))
#define ___ ios_base::sync_with_stdio(false);cin.tie(NULL);
#define Mx 200001
#define inf 1e15
const L MOD = 1e9+7;
const double pi = 2 * acos (0.0);

/*------------------------------Graph Moves----------------------------*/
//const int fx[]={+1,-1,+0,+0};
//const int fy[]={+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
/*---------------------------------------------------------------------*/


//typedef tree<L,null_type,less<L>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

L a1,a2,a3,b1,b2,b3,c,c1,c2,c3,d,d1,d2,d3,d4,d5,e1,e2,e3,f,h,k,l,m,n,m1,m2,n1,n2,o,p,p1,p2,p3,p4,q,q1,q2,q3,q4,r,s,t,
u,v,x,y,z,sum,mx=-inf,mn=inf,flg,flg1,flg2,id1,id2,id3,id4,lim;

//double rat;
L A[Mx+5],B[Mx+5];


void solve(){
    c=0;
    for(L i=1;i<=n;i++){
        printf("%lld\n",A[i]);
    }
}
int main()
{
    memset(A,0,sizeof(A));
    scanf("%lld",&n);
    for(L i=2;i<=n;i++){
        scanf("%lld",&d);
        A[d]++;
    }
    solve();
    return 0;
}
/// empty() lld I64d push_back() top() pop() insert() upper_bound() lower_bound() memset() max() min() scanf continue


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

using namespace std;

int main(void)
{
	string s; cin>>s;
	int len = s.size();
	string t;
	string dm = "dream";
	string dr = "dreamer";
	string es = "erase";
	string er = "eraser";
	
	for(int i = len-1; i >= 0; i--){
		if(i >= 6 && s[i] == 'r' && s[i-1] == 'e' && s[i-2] == 'm' && s[i-3] == 'a' && s[i-4] == 'e' && s[i-5] == 'r' && s[i-6] == 'd'){
			i -= 6;
		}
		else if(i >= 5 && s[i] == 'r' && s[i-1] == 'e' && s[i-2] == 's' && s[i-3] == 'a' && s[i-4] == 'r' && s[i-5] == 'e'){
			i -= 5;
		}
		else if(i >= 4 && s[i] == 'm' && s[i-1] == 'a' && s[i-2] == 'e' && s[i-3] == 'r' && s[i-4] == 'd'){
			i -= 4;
		}
		else if(i >= 4 && s[i] == 'e' && s[i-1] == 's' && s[i-2] == 'a' && s[i-3] == 'r' && s[i-4] == 'e'){
			i -= 4;
		}
		else{
			cout<<"NO"<<endl;
			return 0;
		}
	}
	t = es+dm;
	//cout<<t<<endl;
	cout<<"YES"<<endl;
	return 0;
}



Measured memory_bytes: 512
const [first, ...strs] = require('fs').readFileSync('/dev/stdin', 'utf8').toString().split('\n');
const [N, M] = first.split(' ').map(x => parseInt(x));

let arr1 = new Array(N);
let arr2 = new Array(N);

for (const str of strs) {
	const x = str.split(' ').map(x => parseInt(x));
	if (x[0] === 1) {
		arr1[x[1] - 1] = true;
	} else if (x[1] === N) {
		arr2[x[0] - 1] = true;
	}
}

console.log(arr1.some((x, i) => x && arr2[i]) ? 'POSSIBLE' : 'IMPOSSIBLE');

Measured memory_bytes: 42392
N,M = map(int, input().split())
a = []
b = []
c = []
d = []
#入力
for i in range(N):
    A,B = map(int, input().split())
    a.append(A)
    b.append(B)
for i in range(M):
    C,D = map(int, input().split())
    c.append(C)
    d.append(D)

res_min = [10**9]*N #各人の最小距離
res = [0]*N #出力する答え

#全探索
for i in range(N):
    for j in range(M):
        temp = abs(a[i]-c[j]) + abs(b[i]-d[j])
        if res_min[i] > temp:
            res_min[i] = temp
            res[i] = j+1
for i in range(N):
    print(res[i])

Measured memory_bytes: 39408
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef std::pair<int,int> pair2;
typedef std::pair<int,pair2> pair3;
const ll INF = 1LL<<60;

int main(){
int a,b,d;
  cin>>a>>b;
  cin>>d;
int ans;
  
  ans=b/d-(a-1)/d;

  
  cout<<ans<<endl;
  
  
}


Measured memory_bytes: 3580
from collections import Counter

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

ans = sum(a)
q = int(input())
for i in range(q):
    b, c = map(int, input().split())
    ans += (c - b) * ac[b]
    ac[c] += ac[b]
    ac[b] = 0
    print(ans)


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

int main() {
  
  int a,b,c;
  cin >> a >> b >> c;
  
  if(c-b <= 0) cout << "delicious" << endl;
  else if(c-b <= a) cout << "safe" << endl;
  else cout << "dangerous" << endl;
  
}


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

typedef vector<int> vi;
typedef pair<int, int> pi;

const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;

#define pb push_back
#define mp make_pair

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REP2(i, b, e) for (int i = (b); i <= (int)(e); i++)
#define DEBUG(x) cout << #x << ": " << (x) << endl
#define DEBUGA(a) cout << #a << ": "; for (const auto& v: (a)) cout << v << endl

signed main() {
    int N;
    cin >> N;
    vi H(N);
    REP(i, N) cin >> H[i];

    int M = 0;
    bool can = true;
    REP(i, N) {
        if (H[i] > M) M = H[i];
        if (M - H[i] >= 2) {
            can = false;
            break;
        }
    }
    cout << (can ? "Yes" : "No") << endl;

    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>

using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, s, n) for (int i = (s); i <= (n); i++)

int main()
{
	int N, v, j;
	cin >> N;
	vector<int> A(N);
	rep(i, N) cin >> A[i];

	rep(i, N - 1) cout << A[i] << " ";
	cout << A[N - 1] << endl;

	rep1(i, 1, N - 1) {
		v = A[i];
		j = i - 1;
		while (j >= 0 && A[j] > v) {
			A[j + 1] = A[j];
			j--;
		}
		A[j + 1] = v;

		rep(i, N - 1) cout << A[i] << " ";
		cout << A[N - 1] << endl;
	}

	return 0;
}



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

#define EACH(i,a) for (auto&& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define debug(x) cout << #x << ": " << x << endl
using ll = long long;

//#define int ll

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

signed main(void) {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n, a;
    cin >> n >> a;

    if(n%500<=a) printf("Yes\n");
    else printf("No\n");
    
    return 0;
    
}





Measured memory_bytes: 256
n = int(input())
L = list(map(int,input().split()))

q = int(input())

A = {}
a = 0
for i in L:
    a += i
    if i in A:
        A[i] = A[i] +1
    else:
        A[i] = 1

#print(A)
#print(a)
for i in range(q):
    b,c = map(int,input().split())
    #print(L2)
    if b in A:
        a = a - A[b]*b
        a = a + A[b]*c
        
        if c in A:
            A[c] = A[c] + A[b]
        else:
            A[c] = A[b]
        A.pop(b)
    print(a)    
    
    


Measured memory_bytes: 20744
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;i<(n);i++)
#define REP(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define INF INT_MAX
#define MOD 1000000007
#define fcout cout << fixed << setprecision(15)
#define int long long
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)?"YES":"NO")
#define sec second
#define fir first
typedef long long ll;
typedef pair<int, int> P;
typedef priority_queue<int> pque;
typedef vector<int> Vec;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a/gcd(a,b)*b;};
int mod(int a,int b){return (a+b-1)/b;};
template<typename A, size_t N, typename T>
void Fill(A(&array)[N],const T &val){std::fill((T*)array,(T*)(array+N),val);}
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;};
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;};



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

	int n;
	cin >> n;
	int sum[200000] = {};
	int a[n];
	rep(i, n) {
		cin >> a[i];
		sum[a[i]]++;
	}

	int all = 0;
	rep(i, 200000) {
		all += sum[i] * (sum[i] - 1) / 2;
	}

	//cout << all << endl;
	//rep(i, 10) cout << sum[i] << endl;
	rep(i, n) {
		cout << all - sum[a[i]] * (sum[a[i]] - 1) / 2 + (sum[a[i]] - 1) * (sum[a[i]] - 2) / 2 << endl;;
	}
	return 0;
}

Measured memory_bytes: 5760