akhauriyash/Code-Regression huggingface dataset:
import static java.lang.Integer.*;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        for (;;) {
            char[] n = sc.next().toCharArray();
            if (n[0] == '0') {
                break;
            }
            System.out.println( "black blue lime aqua red fuchsia yellow white".split(" ") [parseInt("" + n[1] + n[2], 16) / 128 * 4 + parseInt("" + n[3] + n[4], 16) / 128 * 2 + parseInt("" + n[5] + n[6], 16) / 128]);
        }
    }
}


Measured memory_bytes: 32624
#include <stdio.h>

int
main(int argc, char *argv[])
{
  int n, m, x, a[100], p = 0;
  scanf("%d %d %d", &n, &m, &x);
  for(int i = 0; i < m; i++){
    scanf("%d", &a[i]);
    if(a[i] < x) p++;
  }
  
  if(p <= m - p) printf("%d\n", p);
  else printf("%d\n", m - p);
  
  return 0;
}
  

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
using Graph = vector<vector<int>>;

int main() {
    // 頂点数と辺数
    long long int N, M; cin >> N >> M;

    // グラフ入力受取 (ここでは無向グラフを想定)
    Graph G(N);
    for (long long int i = 0; i < M; ++i) {
        long long int a, b;
        cin >> a >> b;
        G[a - 1].push_back(b - 1);
        G[b - 1].push_back(a - 1);
    }

    // BFS のためのデータ構造
    vector<long long int> dist(N, -1); // 全頂点を「未訪問」に初期化
  	vector<long long int> parent(N, -100);
    queue<long long int> que;

    // 初期条件 (頂点 0 を初期ノードとする)
    dist[0] = 0;
    que.push(0); // 0 を橙色頂点にする

    // BFS 開始 (キューが空になるまで探索を行う)
    while (!que.empty()) {
        long long int v = que.front(); // キューから先頭頂点を取り出す
        que.pop();

        // v から辿れる頂点をすべて調べる
        for (long long int nv : G[v]) {
            if (dist[nv] != -1) continue; // すでに発見済みの頂点は探索しない

            // 新たな白色頂点 nv について距離情報を更新してキューに追加する
            dist[nv] = dist[v] + 1;
          	parent[nv] = v;
            que.push(nv);
        }
    }

  	bool flag = false;
    for (long long int i = 1; i < N; i++){
      	if (parent[i] == -100) flag = true;
    }
  
  	if (flag == true) cout << "No" << endl;
  	else{
      	cout << "Yes" << endl;
    	for (long long int v = 1; v < N; ++v) {
      		cout << parent[v] + 1 << endl;
    	}
    }
}

Measured memory_bytes: 11624
#include <iostream>

using namespace std;

int main() {
    int n;
    cin >> n;

    while (n--) {
        int Y, M, D;
        cin >> Y >> M >> D;

        int days = 0;
        for (int i = 1; i < Y; i++) {
            if (i % 3 == 0) { days += 200; }
            else { days += 195; }
        }
        for (int i = 1; i < M; i++) {
            if (Y % 3 != 0 && i % 2 == 0) { days += 19; }
            else { days += 20; }
        }
        days += D;

        cout << 196471 - days << endl;
    }
    return 0;
}


Measured memory_bytes: 3056
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll a,b,c,d;
    string s;
    set<string>ss;
    cin>>a;
    for(ll i=0;i<a;i++)
    {
        cin>>s;
        ss.insert(s);
    }
    cout<<ss.size()<<endl;
}




Measured memory_bytes: 19152
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll seive[(int)2e5];
int main()
{
    int t;
    cin >> t;
    ll sum = 0;
    for (int i = 0; i < t; i++)
    {
        ll k;
        cin >> k;
        sum += k;
        seive[k]++;
    }
    int k;
    cin >> k;
    while (k--)
    {
        ll a, b;
        cin >> a >> b;
        sum += ((ll)seive[a]*(b-a));
        seive[b] += seive[a];
        seive[a] = 0;
        cout << sum << '\n';
    }
}

Measured memory_bytes: 4336
#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second

int a[200009], cnt[1000009];

int main()
{
    int n, i, j;
    cin >> n;

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

    sort(a, a+n);

    for(i = 0; i < n; i++)
    {
        if(cnt[a[i]] != 0)
        {
            cnt[a[i]] = 2;
            continue;
        }

        for(j = 1; a[i] * j <= a[n-1]; j++)
            cnt[a[i] * j]++;
    }

    int ans = 0;
    for(i = 0; i < n; i++)
    {
        if(cnt[a[i]] == 1)
            ans++;
    }

    cout << ans;
}


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

int main() {
    int D, G;
    cin >> D >> G;
    int p[D], c[D], s[D];
    for (int i=0; i<D; i++) {
        cin >> p[i] >> c[i];
        s[i] = 100 * (i+1) * p[i] + c[i];
    }
    int ans = 100000;
    for (int bit=0; bit<pow(2, D); bit++) {
        int point = 0;
        int problem = 0;
        int nonbit = -1;
        for (int i=0; i<D; i++) {
            if (bit & (1 << i)) {
                point += s[i];
                problem += p[i];
            } else {
                nonbit = i;
            }
        }
        if (point >= G) {
            if (problem < ans) {
                ans = problem;
            }
        } else {
            if (nonbit == -1) continue;

            int diff = G - point;
            int diffp = int((diff-1) / ((nonbit+1)*100)) + 1;
            if (diffp < p[nonbit]) {
                problem += diffp;
                if (problem < ans) {
                    ans = problem;
                }
            }
        }
    }
    cout << ans << endl;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  deque<int> d;
  rep(i,n) {
    int p = lower_bound(d.begin(), d.end(), a[i]) - d.begin();
    if (p == 0) {
      d.push_front(a[i]);
    } else d[p-1] = a[i];
  }
  int ans = d.size();
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;

template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { os << '['; string sep = ""; for (const auto &x : v) os << sep << x, sep = ", "; return os << ']'; }
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }
template<typename A> ostream& operator<<(ostream &os, const set<A> &s) { os << '{'; string sep = ""; for (const auto &x : s) os << sep << x, sep = ", "; return os << '}'; }
template<typename A, typename B> ostream& operator<<(ostream &os, const map<A, B> &m) { os << '{'; string sep = ""; for (const auto &x : m) os << sep << x.first << " -> " << x.second, sep = ", "; return os << '}'; }

#ifdef MY_DEBUG_FLAG
void debug() { cerr << '\n'; }
template<typename Ini, typename... Fim> void debug(Ini I, Fim... F) { cerr << " " << I; debug(F...); }
#define db(...) cerr << "DEBUG (" << #__VA_ARGS__ << ") ==", debug(__VA_ARGS__)
#else
#define db(...)
#endif

#define pb push_back
#define eb emplace_back
#define ff first
#define ss second
#define fast ios_base::sync_with_stdio(false), cout.tie(nullptr), cin.tie(nullptr)
#define sz(a) ((int)(a).size())
#define rep(i,a,b) for(int i=(a); i<(b); i++)
#define dec(i,n,a) for(int i=(n); i>=(a); i--)
#define clr(a,v) memset(a, v, sizeof(a))
#define all(a) (a).begin(),(a).end()

constexpr int inf = 0x3f3f3f3f;
constexpr int maxn = 1e5 + 10;
constexpr int mod = 1000000007;

// int bit[30][30];
int pot[20][20];

// void upd(int x, int v, int k) {
// 	for(x++; x < 27; x += x&-x)
// 		bit[x][k] += v;
// }

// int query(int x, int k) {
// 	int ans = 0;
// 	for(x++; x > 0; x -= x&-x)
// 		ans += bit[x][k];
// 	return ans;
// }

int main() {
	fast;
	int n; cin >> n;
	ll ans = 0;
	rep(i,0,n) {
		string massa; cin >> massa;
		int t = sz(massa);

		int antes = 0, dec = 0;
		bool ok = 0;
		rep(j,0,t) {
			if(massa[j] == '.') ok = 1; 
			else if(ok) dec++;
			else antes++;
		}

		ll a = 0;

		rep(j,0,t)
			if(massa[j] != '.')
				a *= 10ll, a += massa[j] - '0';
		
		rep(j,dec,9) a *= 10ll;

		int p2 = 0, p5 = 0;
		while(a%2==0) a/=2ll, p2++;
		while(a%5==0) a/=5ll, p5++;

		p2 = min(p2, 18);
		p5 = min(p5, 18);

		rep(j,18-p2,19)
			rep(x, 18-p5, 19)
				ans += pot[j][x];
			// ans += query(18, j) - query(18-p5,j);

		pot[p2][p5]++;
		// upd(p5, 1, p2);
	}

	cout << ans << '\n';
}


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

int n, m;
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> m;
    cout << (n * (n - 1)) / 2 + (m * (m - 1)) / 2 << "\n";
    return 0;
}

Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std;
int main(){
int n;cin>>n;
vector<int> d(n);
for(int& i:d) cin>>i;
int ans=0,s=d[n-1];
for(int i=n-2;i>=0;i--){ans+=(d[i]*s); s+=d[i]; }
cout<<ans<<endl;
return 0;
} 

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

int a, b, c, x, d[3] = {500, 100, 50}, ans;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> a >> b >> c >> x;
	for(int i=0; i<=a; ++i)
		for(int j=0; j<=b; ++j)
			for(int k=0; k<=c; ++k)
				if(d[0]*i+d[1]*j+d[2]*k==x)
					++ans;
	cout << ans << endl;
}

Measured memory_bytes: 256
def main():
    # n = int(input())
    n, m = map(int, input().split())
    # v = list(map(int, input().split()))
    # s = input()
    h = [int(input()) for _ in range(n)]

    h.sort()

    temp = []
    for i in range(n-m+1):
        temp.append(h[i+m-1]-h[i])

    temp.sort()
    print(temp[0])


if __name__ == '__main__':
    main()


Measured memory_bytes: 87332
from collections import Counter

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

cnt = Counter(Xs)

nums = [0] * M
numSames = [0] * M
for key, num in cnt.items():
    k = key%M
    nums[k] += num
    numSames[k] += num//2

ans = 0
for k in range(M//2+1):
    k2 = M-k
    if k == 0 or k == k2:
        numPair = nums[k]//2
        ans += numPair
        nums[k] -= numPair*2
    else:
        numPair = min(nums[k], nums[k2])
        ans += numPair
        nums[k] -= numPair
        nums[k2] -= numPair

for k in range(M):
    ans += min(numSames[k], nums[k]//2)

print(ans)


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

int main()
{
    int n, q;
    cin >> n >> q;
    vector<vector<int>> A(n);
    repi(i, q, 0)
    {
        int op, t, x;
        cin >> op;
        if (op == 0)
        {
            cin >> t >> x;
            A[t].push_back(x);
        }
        else if (op == 1)
        {
            cin >> t;
            repi(i, A[t].size(), 0)
            {
                cout << A[t][i] << ((i + 1) % A[t].size() ? " " : "");
            }
            cout << endl;
        }
        else if (op == 2)
        {
            cin >> t;
            A[t].clear();
        }
    }
    return 0;
}


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

char s[310][310];
char t[310][310];
int main(void){
	int n;scanf("%d",&n);
	for(int i=0;i<n;i++)for(int j=0;j<n;j++)cin>>s[i][j];
	int a=0;
	for(int i=0;i<n;i++){
		//a=0,b=i
		for(int j=0;j<n;j++)for(int k=0;k<n;k++){
			t[j][k] = s[j][(k+i)%n];
		}
		bool check = true;
		for(int j=0;j<n;j++)for(int k=0;k<n;k++){
			if(!(t[j][k] == t[k][j]))check = false;
		}
		if(check)a++;
	}
	cout << n*a << endl;
	return 0;
}

Measured memory_bytes: 384
#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 N,M; cin>>N>>M;
    vector<set<int>> k(M);
    cin.ignore();
    rep(i,M){
        int s; cin>>s;
        rep(j,s){
            int t; cin>>t;
            k[i].insert(t-1);
        }
    }
    vector<int> p(M);
    rep(i,M) cin>>p[i];

    int ans=0;
    // switchの入れ方ビット探索
    for(int i=0; i< (1<<N);i++){
        bitset<10> bit(i);
        bool flg=true;
        // 各電球について
        for(int j=0;j<M ; j++){
            int sch = 0;
            // switchが入っていたら
            for(int a=0; a<N; a++){
                if(bit.test(a)){
                    if(k[j].count(a)){
                        sch++;
                    }
                }
            }
            if(sch%2!=p[j]){
                flg=false;
            }
        }
        if(flg) ans++;
    }
    cout << ans << endl;
    // for(int x:k[0]){
    //     cout << x << " ";
    // }cout << endl;
}


Measured memory_bytes: 3628
/**
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⡀⠀⠀⠀⠀⢀⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⣠⡖⠁⠀⠀⠀⠀⠀⠀⠈⢲⣄⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⣼⡏⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢹⣧⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⣸⣿⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⣿⣇⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⣿⣿⡇⠀⢀⣀⣤⣤⣤⣤⣀⡀⠀⢸⣿⣿⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⢻⣿⣿⣔⢿⡿⠟⠛⠛⠻⢿⡿⣢⣿⣿⡟⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⣀⣤⣶⣾⣿⣿⣿⣷⣤⣀⡀⢀⣀⣤⣾⣿⣿⣿⣷⣶⣤⡀⠀⠀⠀⠀
⠀⠀⢠⣾⣿⡿⠿⠿⠿⣿⣿⣿⣿⡿⠏⠻⢿⣿⣿⣿⣿⠿⠿⠿⢿⣿⣷⡀⠀⠀
⠀⢠⡿⠋⠁⠀⠀⢸⣿⡇⠉⠻⣿⠇⠀⠀⠸⣿⡿⠋⢰⣿⡇⠀⠀⠈⠙⢿⡄⠀
⠀⡿⠁⠀⠀⠀⠀⠘⣿⣷⡀⠀⠰⣿⣶⣶⣿⡎⠀⢀⣾⣿⠇⠀⠀⠀⠀⠈⢿⠀
⠀⡇⠀⠀⠀⠀⠀⠀⠹⣿⣷⣄⠀⣿⣿⣿⣿⠀⣠⣾⣿⠏⠀⠀⠀⠀⠀⠀⢸⠀
⠀⠁⠀⠀⠀⠀⠀⠀⠀⠈⠻⢿⢇⣿⣿⣿⣿⡸⣿⠟⠁⠀⠀⠀⠀⠀⠀⠀⠈⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣼⣿⣿⣿⣿⣧⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠐⢤⣀⣀⢀⣀⣠⣴⣿⣿⠿⠋⠙⠿⣿⣿⣦⣄⣀⠀⠀⣀⡠⠂⠀⠀⠀
⠀⠀⠀⠀⠀⠈⠉⠛⠛⠛⠛⠉⠀⠀⠀⠀⠀⠈⠉⠛⠛⠛⠛⠋⠁⠀⠀
 *    author:  Daredevil666
 *    institution: IIT Patna
**/
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define nl cout<<"\n";
#define ll long long int
#define REP(i,a,n) for(i=a;i<=n;i++)
#define F(i,a,b) for(i=a;i<b;i++)
#define RF(i,b,a) for(i=b;i>=a;i--)
#define IOS  ios::sync_with_stdio(false);cin.tie(0);
using namespace std;
const ll mod=1e9+7;
const ll MAXN=1000000;
ll i,j,mask,test;
int main()
{
IOS
/*#ifndef ONLINE_JUDGE
   freopen("input.txt","r",stdin);
   freopen("output.txt","w",stdout);
#endif // ONLINE_JUDGE*/
vector<ll> vis(MAXN+1),v(MAXN+1),prime(MAXN+1);
for(i=2;i*i<=MAXN;i++)
{
    for(j=i;j*i<=MAXN;j++)
    {
        vis[i*j]=1;
    }
}
set<ll> st;
F(i,2,MAXN+1)
{
    if(vis[i]==0)
    {
        st.insert(i);
    }
}
ll n;
cin>>n;
ll g=0;
F(i,0,n)
{
    ll x;
    cin>>x;
    g=__gcd(g,x);
    v[x]++;
}
for(auto x:st)
{
    for(i=x;i<=1e6;i+=x)
    {
        prime[x]+=v[i];
    }
}
ll f=1;
F(i,0,MAXN)
{
    if(prime[i]>1)
    {
        f=0;
        break;
    }
}
if(f==1)
{
    cout<<"pairwise coprime";
    return 0;
}
if(g==1)
{
    cout<<"setwise coprime";
    return 0;
}
cout<<"not coprime";
return 0;
}


Measured memory_bytes: 30328
//! 尺卂乃卂.卂ﾌ乇乇ㄒ
#include<bits/stdc++.h>
//#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
//Using namespace __gnu_pbds;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> Ordered_set;

#define ll              long long
#define int             long long
#define ld             long double
#define pb              push_back
#define pii             pair<int,int>
#define vi              vector<int>
#define vii             vector<vi>
#define vip            vector<pii>
#define mii             map<int,int>
#define mip             map<pair<int,int>,int>
#define mic             map<char,int> 
#define all(v)          v.begin(),v.end()  
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define lb(x)           (x&(-x))
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define w(x)            int x; cin>>x; while(x--)
#define itr(it,v)          for(auto it:v)
#define show(arr,n)     for(int i=0;i<n;i++) cout<<arr[i]<<" "; cout<<"\n";
#define fi(i,n)         for(int i=0;i<n;i++)
#define fir(i,k,n)       for(int i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ff               first 
#define ss               second
#define deb(x) cout << #x << "=" << x << endl
#define FIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define check(x) (x && cout<<"Yes\n")||(cout<<"No\n");
#define fin(s)          freopen(s,"r",stdin);  
#define fout(s)         freopen(s,"w",stdout);

const ld pi = 3.141592653589793238462643383279502884;
const int xd[]={-1,0,1,0};
const int yd[]={0,-1,0,1};
int XX[] = { -1, -1, -1, 0, 0, 1, 1, 1 };
int YY[] = { -1, 0,  1, -1, 1, -1, 0, 1 };

int expo(int a,int b,int m);
int mmi(int a,int m);
void ipgraph(int m);

const int N=5*(1e5)+10;
vii adj(N);
int a[N];

void  solve(){

}
int32_t main()
{
    FIO
    int n; cin>>n;
    mii m; int sum=0;
    fi(i,n) {
        cin>>a[i];
        m[a[i]]++;
        sum+=a[i];
    }
    int q; cin>>q;
    while(q--){
        int b,c; cin>>b>>c;
        if(m.find(b)!=m.end()){
            sum-=b*(m[b]);
            sum+=c*(m[b]);
            m[c]+=m[b];
            m.erase(b);
        }
        cout<<sum<<"\n";

    }
    return 0;

}

void ipgraph(int m){
    int i, u, v;
    while(m--){
          cin>>u>>v;
         u--, v--;
    adj[u].pb(v);
    adj[v].pb(u);
    }
}
int expo(int a,int b,int m){
    if(b==0) return 1;
    if(b==1) return a;
    int val=(expo(a,b/2,m)*expo(a,b/2,m))%m;
    if(b & 1) return (val*a)%m;
    else return val;
}
int mmi(int a,int m){
    return expo(a,m-2,m);
}

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

int main() {
	int N;
	cin >> N;
	set<char> S;
	for (int i = 0; i < N; i++) {
		char tmp;
		cin >> tmp;
		S.insert(tmp);
	}
	if (S.size() == 3) cout << "Three" << endl;
	else if (S.size() == 4) cout << "Four" << endl;
	return 0;
}

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

using namespace std;

int main(){
    int n, m, x;
    cin >> n >> m >> x;
    vector<int> precios(n);
    int ar[n][m];

    for(int i = 0; i < n; i++){
        cin >> precios[i];
        for(int j = 0; j < m; j++){
            cin >> ar[i][j];
        }
    }
    int mini = INT_MAX;
    for(int mask = 0; mask < (1<<n); mask++){
        int coste = 0;
        vector<int> algs(m);
        bool ok = true;
        for(int i = 0; i < n; i++){
            if((mask>>i) & 1){
                coste += precios[i];
                for(int j = 0; j < m; j++) algs[j] += ar[i][j];
            }
        }
        for(int k: algs){
            if(k < x)
                ok = false;
        }
        if(ok)
            mini = min(mini, coste);
    }
    cout << (mini == INT_MAX ? -1 : mini) << '\n';

}

Measured memory_bytes: 3596
#include <iostream>
#include <vector>
#include <cstring>
#include <algorithm> // sort

#define REP(i, n) for (long long i = 0; i < (n); i++) 
typedef long long ll;
static const ll MOD = 1000000007;
static const ll INF = 1000000000000000000LL;
using namespace std;

//AKIBA
//
int main(){
  string S;
  cin >> S;

  string akiba = "AKIHABARA";
  string res = "NO";

  if(S.size() < 5 || S .size() > akiba.size())
  {
    cout << res << endl;
    return 0;
  }

  //Aを取り除く、取り入れるのパターンを全網羅

  string akibas[16];
  ll cnt = 0;
  
  akibas[cnt++] = "KIHBR";
  akibas[cnt++] = "AKIHBR";
  akibas[cnt++] = "KIHABR";
  akibas[cnt++] = "KIHBAR";
  akibas[cnt++] = "KIHBRA";
  akibas[cnt++] = "AKIHABR";
  akibas[cnt++] = "AKIHBAR";
  akibas[cnt++] = "AKIHBRA";
  akibas[cnt++] = "KIHABAR";
  akibas[cnt++] = "KIHABRA";
  akibas[cnt++] = "KIHBARA";
  akibas[cnt++] = "AKIHABAR";
  akibas[cnt++] = "AKIHBARA";
  akibas[cnt++] = "AKIHABRA";
  akibas[cnt++] = "KIHABARA";
  akibas[cnt++] = "AKIHABARA";

  REP(i,16)
  {
    if(akibas[i] == S)
    {
      res = "YES";
    }
  }

  cout << res << endl;

  return 0;
}



Measured memory_bytes: 256
/*Lucky_Glass*/
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;

typedef long long ll;
const int N=3e6;
const ll MOD=998244353;

ll Efac[N+3],Einv[N+3];

ll QPow(ll Va,ll Vb){
	ll Rr=1;
	while(Vb){
		if(Vb&1) Rr=Va*Rr%MOD;
		Va=Va*Va%MOD;
		Vb>>=1;
	}
	return Rr;
}
void Process(){
	Efac[0]=1;for(int i=1;i<=N;i++) Efac[i]=Efac[i-1]*i%MOD;
	Einv[N]=QPow(Efac[N],MOD-2);for(int i=N-1;i>=0;i--) Einv[i]=Einv[i+1]*(i+1)%MOD;
}
ll fC(int Va,int Vb){return Efac[Vb]*Einv[Va]%MOD*Einv[Vb-Va]%MOD;}
int main(){
	Process();
	int n,m;scanf("%d%d",&n,&m);
	ll Vans=fC(n-1,3*m+n-1);
	Vans=(Vans-fC(n-1,m+n-2)*n%MOD+MOD)%MOD;
	for(int i=m+1;i<=n && i<=3*m;i++)
		if((3*m-i)%2==0){
			Vans=(Vans-fC(i,n)*fC(n-1,(3*m-i)/2+n-1)%MOD+MOD)%MOD;
		}
	printf("%lld\n",(Vans%MOD+MOD)%MOD);
	return 0;
}

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

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> X(M), Z(M - 1);
  for (int i = 0; i < M; i++) cin >> X[i];
  sort(X.begin(), X.end());
  for (int i = 0; i < M - 1; i++) Z[i] = X[i + 1] - X[i];
  sort(Z.begin(), Z.end());
  int ans = 0;
  for (int i = 0; i < M - N; i++) {
    ans += Z[i];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define FOR(i,a,b) for(int i=(a); i<=(b); i++) 
#define rep(i,n); for(int i = 0; i < (n); i++)
#define chmin(a,b) if((a)>(b)) (a)=(b); 
#define chmax(a,b) if((a)<(b)) (a)=(b);
#define vi vector<int>
#define all(v) (v).begin(),(v).end()
#define pb push_back
int gcd(int a,int b){/*a>=0,b>=0,￢(a=b=0)*/
  while(min(a,b)>0){if(a<b)swap(a,b);a%=b;}return max(a,b);
}
int dx[]={0,1,0,-1,1,-1,-1,1};
int dy[]={1,0,-1,0,1,1,-1,-1};
const int MOD = 1e9+7;
const int INF = 1e18+10;

/*----------------------------------------------*/
signed main(){
  int a,b,c;
  cin>>a>>b>>c;
  cout<<c<<" "<<a<<" "<<b<<endl;
  
  return 0;
}


Measured memory_bytes: 256
/*
  B - Unhappy Hacking (ABC Edit)
  Contest 043
  Rakesh Kumar --> 02/08/2020
 */

#include <bits/stdc++.h>

int main() {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(0); std::cout.tie(0);

    std::string s;
    std::getline(std::cin, s);
    std::string r = s;
    int i = 0;
    for (char c : s) {
        if (c == 'B')
            i = std::max(0, i - 1);
        else
            r[i++] = c;
    }

    std::cout << r.substr(0, i) << std::endl;

    return 0;
}


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

const int N = 4e5 + 10;

int a[N], L[N], R[N];

int main (void) {
	int n;
	scanf("%d", &n);
	for (int i = 1; i <= n; i ++) {
		scanf("%d", a + i);
	}
	sort(a + 1, a + n + 1);
	queue<int> q;
	q.push(a[n]);
	long long ans = 0;
	for (int i = n - 1; i >= 1; i --) {
		ans += q.front(); q.pop();
		q.push(a[i]);
		q.push(a[i]);
	}
	printf("%lld\n", ans);
}

Measured memory_bytes: 5224
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.StringTokenizer;


public class Main {



	static int mod = 998244353;
	static HashMap<String,Long> dp = new HashMap();
	public static long solve(String s) {
		if (s.length() == 0) return 1;
		if (s.length() == 1) {
			return s.charAt(0) == '1' ? 2 : 1;
		}
		if (dp.containsKey(s)) {
			return dp.get(s);
		}
		long ret = (s.charAt(0) == '1' ? 2 : 1) * (solve(s.substring(1,s.length())));
		ret %= mod;
		for (int i = 0 ; i < s.length(); ++i) {
			int lst = i + 1;
			int len = i + 1;
			StringBuilder cur = new StringBuilder(s.substring(0, lst));
			while (lst + len - 1 < s.length()) {
				for (int k = lst , p = 0; k <= lst + len - 1 ; ++k, ++p) {
					if (s.charAt(k) == '0') {
						cur.setCharAt(p, '0');
					}
				}

				lst += len;
				ret += (1L*solve(cur.toString()) * solve(s.substring(lst,s.length())))%mod;
				ret %= mod;

			}
		}
		dp.put(s, ret);
		return ret;

	}
	public static void main(String[]args) throws Throwable {
		Scanner sc = new Scanner(System.in);
		System.out.println(solve(sc.next()));
	}

	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s) {
			br = new BufferedReader(new InputStreamReader(s));
		}

		public Scanner(String s) throws FileNotFoundException {
			br = new BufferedReader(new FileReader(new File(s)));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public String nextLine() throws IOException {
			return br.readLine();
		}

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public boolean ready() throws IOException {
			return br.ready();
		}
	}
}

Measured memory_bytes: 158220
import java.util.*;
class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int a = sc.nextInt();
		int b = sc.nextInt();
		int o = 1; //初期タップ
		int ans = 0;
		while(o < b){
			--o;//ここで挿入に使うタップ-1をする
			o += a; //タップを増やす	
			++ans;
		}

		System.out.println(ans);
		
		}
	}

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

using namespace std;
#define NIL -1
#define ll long long
#define MAX 100
#define pb push_back

int main() {
	int n;
	cin >> n;
	int arr[n];
	for(int i=0; i<n; i++) cin >> arr[i];
	sort(arr, arr+n);
	int x = n/2;
	int ans = 0;
	ans = arr[x] - arr[x-1];
	cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4024
#include <vector>
#include <iostream>
#include <algorithm>
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];
	for (int i = 0; i < N; ++i) cin >> B[i];
	int ans = 0;
	for (int i = 0; i < 29; ++i) {
		vector<int> bs(2 * N);
		for (int j = 0; j < N; ++j) {
			bs[j] = B[j] % (2 << i);
			bs[j + N] = bs[j] + (2 << i);
		}
		sort(bs.begin(), bs.end());
		long long sum = 0;
		for (int j = 0; j < N; ++j) {
			int pl = lower_bound(bs.begin(), bs.end(), (2 << i) - (A[j] % (2 << i)) + (1 << i)) - bs.begin();
			int pr = lower_bound(bs.begin(), bs.end(), (2 << i) - (A[j] % (2 << i)) + (2 << i)) - bs.begin();
			sum += pr - pl;
		}
		if (sum % 2 == 1) {
			ans += 1 << i;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3428
#include <bits/stdc++.h>
#include <algorithm>  
#include <unordered_set>

#define ll long long

using namespace std;

int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	ll x, n;

	cin >> x >> n;

	vector<ll> d(n);

	set<ll> s;

	for (int i = 0; i < n; i++) {
		cin >> d[i];
		s.insert(d[i]);
	}

	for (ll i = 0; i <= x; i++) {

		if (s.find(x - i) == s.end()) {
			cout << x - i << endl;
			break;
		}
		else if (s.find(x + i) == s.end()) {
			cout << x + i << endl;
			break;
		}
	}





	return 0;
}

Measured memory_bytes: 3660
import java.io.*;
import java.util.*;

public class Main{
	
	static long mod=(long)1e9+7;
	
	public static void main(String[] args) throws IOException {
		Writer out=new Writer(System.out);
		Reader in=new Reader(System.in);
		int ts=1;
		
		outer: while(ts-->0) {	
			int a=in.nextInt(), b=in.nextInt(), c=in.nextInt(), k=in.nextInt();
			int sum=0;
			int temp;
			temp=Math.min(a,k);
			sum+=temp; k-=temp;
			temp=Math.min(b, k);
			k-=temp;
			temp=Math.min(c, k);
			sum-=temp; k-=temp;
			out.println(sum);
		}
		out.close();		
		
	}

	static boolean tri(int a, int b, int c) {
		if(c<a+b && c>abs(a-b)) return true;
		return false;
	}
	
	
/*********************************** UTILITY CODE BELOW **************************************/	
		
	static int abs(int a) {
		return a>0 ? a : -a;
	}
	
	static int max(int a, int b) {
		return a>b ? a : b;
	}
	
	static int pow(int n, int m) {
		if(m==0) return 1;
		int temp=pow(n,m/2);
		long res=(((long)temp*temp)%mod);
		if(m%2==0) return (int)res;
		return (int)((res*n)%mod);
	}
	
	static class Pair{
		int u, v;
		
		Pair(int u, int v){this.u=u; this.v=v;}
		
		static void sort(Pair [] coll) {		
			List<Pair> al=new ArrayList<>(Arrays.asList(coll));
			Collections.sort(al,new Comparator<Pair>() {
				public int compare(Pair p1, Pair p2) {
					return p1.u-p2.u;
				}	
			});
			for(int i=0; i<al.size(); i++) {
				coll[i]=al.get(i);
			}
		}
		
	}
	
	static void sort(int[] a) {
		ArrayList<Integer> list=new ArrayList<>();
		for (int i:a) list.add(i);
		Collections.sort(list);
		for (int i=0; i<a.length; i++) a[i]=list.get(i);
	}
	
	static void sort(long a[]) {
		ArrayList<Long> list=new ArrayList<>();
		for(long i: a) list.add(i);
		Collections.sort(list);
		for(int i=0; i<a.length; i++) a[i]=list.get(i);
	}
	
	static int [] array(int n, int value) {	
		int a[]=new int[n];
		for(int i=0; i<n; i++) a[i]=value;
		return a;
	}
	
	static class Reader{
		
		BufferedReader br;
		StringTokenizer to;
		
		Reader(InputStream stream){
			br=new BufferedReader(new InputStreamReader(stream));
			to=new StringTokenizer("");
		}
		
		String next() {
			while(!to.hasMoreTokens()) {
				try {
					to=new StringTokenizer(br.readLine());	
				}catch(IOException e) {}
				
			}
			return to.nextToken();
			
		}
		
		int nextInt() {
			return Integer.parseInt(next());
		}
		
		long nextLong() {
			return Long.parseLong(next());
		}
		
		int [] readArray(int n) {
			int a[]=new int[n];
			for(int i=0; i<n ;i++) a[i]=nextInt();
			return a;
		}
		long [] readLongArray(int n) {
			long a[]=new long[n];
			for(int i=0; i<n ;i++) a[i]=nextLong();
			return a;
		}
		
	}
	
	static class Writer extends PrintWriter{
		Writer(OutputStream stream){
			super(stream);
		}
		void println(int [] array) {
			for(int i=0; i<array.length; i++) {
				print(array[i]+" ");
			}
			println();
		}
		void println(long [] array) {
			for(int i=0; i<array.length; i++) {
				print(array[i]+" ");
			}
			println();
		}
	}
	
}

Measured memory_bytes: 32928
N=int(input())
List=list(input().split())
List=list(map(int,List))
List_sorted=sorted(List)

i=0
while i<len(List)-1:
    j=i+1
    ListTest=list(List)
    count=0
    while j<len(List):
        if ListTest==List_sorted:
            print('YES')
            quit()
        ListTest[i],ListTest[j]=ListTest[j],ListTest[i]
        if ListTest==List_sorted:
            print('YES')
            quit()
        else:
            ListTest=list(List)
        j+=1
    i+=1
print('NO')


Measured memory_bytes: 9076
S = input()
#N,A,B = map(int,input().split())
#X_list = list(map(int,input().split()))
#X1_list = [int(input()) for i in range(N)]
#X2_list = [list(map(int,input().split())) for i in range(N)]

for i in range(len(S)):
    if i % 2 == 0:
        if S[i] == 'R' or S[i] == 'U' or S[i] == 'D':
            continue
        else:
            print('No')
            exit(0)
    else:
        if S[i] == 'L' or S[i] == 'U' or S[i] == 'D':
            continue
        else:
            print('No')
            exit(0)
print('Yes')

Measured memory_bytes: 3060
#include "bits/stdc++.h"
using namespace std;
#define MODULO 1000000007
#define PI 3.14159265359
typedef long long int ll;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
     int n;
     cin>>n;
     int A[n];
     for(int i=0;i<n;++i)
     {
     	cin>>A[i];
	 }
	 int z=A[0];
	 for(int i=1;i<n;++i)
	 {
	 	z=z^A[i];
	 }
	 for(int i=0;i<n;++i)
	 {
	 	cout<<(z^A[i])<<" ";
	 }
	 cout<<endl;
    return 0;
}


Measured memory_bytes: 4364
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
#include <stack>
#include <cassert>
#include <functional>
#include <random>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<vvvl> vvvvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vvb> vvvb;
typedef vector<vvvb> vvvvb;
typedef vector<string> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef pair<ll, ll> PL;
typedef vector<PL> vpl;
typedef vector<vector<PL>> vvpl;
typedef vector<vvpl> vvvpl;
typedef pair<ll, PL> TL;
typedef vector<TL> vtl;
typedef vector<vtl> vvtl;
const int INF = 1001001001;
const ll LINF = 1e17;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define RFOR(i, a, b) for(ll i = (a); i > b; i--)
#define rep(i, n) for(ll i = 0; i < n; i++)
#define rrep(i, n) for(ll i = n-1; i > -1; i--)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back
#define epb emplace_back
#define ALL(X) (X).begin(),(X).end()

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    sort(ALL(vec));
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}

inline ll popcnt(ll x){return __builtin_popcountll((unsigned long long)x);};
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
//friend bool operator<(const stc& lhs, const stc& rhs){
//    return std::tie(lhs.l, lhs.r) < std::tie(rhs.l, rhs.r);
//}



int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    ll N; cin >> N;;
    vl A(N), B(N);
    ll eqcnt = 0;
    ll suma = 0;
    rep(i, N){
        cin >> A[i] >> B[i];
        if(A[i] == B[i]) eqcnt++;
        suma += A[i];
    }
    if(eqcnt == N){
        cout << 0 << endstr; return 0;
    }
    
    ll ans = 0;
    rep(i, N){
        if(A[i]>B[i]){
            chmax(ans, suma-(B[i]));
        }
    }
    cout << ans << endstr;
    return 0;
}


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

int main(){
    int s;
    cin>>s;
    vector<bool> check(1000000, false);
    int a = s;
    check[a-1] = true;
    for(int i=2;;i++){
        if(a%2 == 0) a = a/2;
        else a = 3*a+1;
        if(check[a-1]){
            cout << i << endl;
            return 0;
        }
        check[a-1] = true;
    }
}


Measured memory_bytes: 384
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N,M = MI()
    A=tuple((ST()) for _ in range(N))
    B=tuple((ST()) for _ in range(M))

    for i in range(N-M+1):
        for j in range(N-M+1):
            #check
            ok = True
            for k in range(M):
                if A[i+k][j:j+M] != B[k][:]:
                    ok=False

            if ok:
                print("Yes")
                exit()
    print("No")


if __name__ == '__main__':
    main()

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

#define ASC(vec) vec.begin(), vec.end()    // 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend() // 降順ソート 例：sort(DESC(vec));
#define rep(i, n) for (int i = 0; i < (n); i++)
#define Rep(i, n) for (int i = 1; i < n; i++)
#define REP(i, vec) for (auto i = vec.begin(); i != vec.end(); ++i)

const int       mod = 1000000007;
const int       inf = (1 << 21);
const long long INF = 1LL << 60;

using ll = long long;
using ii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vb = vector<bool>;
using vl = vector<ll>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvb = vector<vector<bool>>;
using vii = vector<pair<int, int>>;
using vll = vector<pair<ll, ll>>;

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; }
template<class T>
T GCD(T a, T b) { if (b == 0) return a; else return GCD(b, a % b); }
template<class T>
T LCM(T a, T b) { return a / GCD(a, b) * b; }

constexpr array<int, 9> dx = { 0, 1, 0, -1, -1, 1, 1, -1, 0 };
constexpr array<int, 9> dy = { 1, 0, -1, 0, 1, 1, -1, -1, 0 };

// ──────────────────────────────────────────────────────────────────

int main() {
	int n;
	cin >> n;

	ll r = 0;
	vi a(n);
	rep(i, n) cin >> a[i], r += a[i];

	ll l = 0, ans = INF;
	rep(i, n) {
		l += a[i];
		r -= a[i];

		ans = min(ans, abs(r - l));
	}
	cout << ans << endl;
}

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

using namespace std;

#define ll long long
#define vi vector<int>
#define pii pair<int, int>
#define vpii vector< pair<int, int> >
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

int N, cnt = 0;
bool isUsed[105]={};
vpii Red, Blue;

void print_Red(){
    cout << "Red" << endl;
    rep(i,N)
        printf("(%d,%d)\n", Red[i].first, Red[i].second);
}

void print_Blue(){
    cout << "Blue" << endl;
    rep(i,N)
        printf("(%d,%d)\n", Blue[i].first, Blue[i].second);
}

bool isOk(pii r, pii b){
    return r.first < b.first && r.second < b.second;
}

int calc_dist(pii r, pii b){
    return pow(b.first-r.first,2) + pow(b.second-r.second,2);
}

void solve(){
    for(int i = 0; i < N; i++){
        int min_id = -1, max_y = -1;
        for(int j = 0; j < N; j++){
            if(isOk(Red[j], Blue[i]) && !isUsed[j]){
                    int buff_y = Red[j].second;
                    if(buff_y >  max_y){
                        min_id = j;
                        max_y = buff_y;
                    }
                }
            }
        if(min_id != -1) isUsed[min_id] = true;
        }

    rep(i,N)
        if(isUsed[i]) cnt++;

    cout << cnt << endl;
}

int main(){
    cin >> N;
    int buff1, buff2;

    rep(i,N){
        cin >> buff1 >> buff2;
        Red.push_back(make_pair(buff1, buff2));
    }
    rep(i,N){
        cin >> buff1 >> buff2;
        Blue.push_back(make_pair(buff1, buff2));
    } 

    sort(Red.begin(), Red.end());
    sort(Blue.begin(), Blue.end());
    // print_Red();
    // print_Blue();

    solve();
}


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

const int A[] = { 0, 2, 5, 5, 4, 5, 6, 3, 7, 6 };

struct hugeint {
    int a[5005], len;
    void operator=(const hugeint x) {
        memcpy(a, x.a, sizeof(x.a));
        len = x.len;
    }
    hugeint operator+(const int x) {
        hugeint res = *this;
        res.len++;
        res.a[res.len] = x;
        return res;
    }
    bool operator<(const hugeint x) const {
        int i;
        if (len ^ x.len)
            return len < x.len;
        for (i = len; i; i--)
            if (a[i] ^ x.a[i])
                return a[i] < x.a[i];
        return false;
    }
};

bool c[10];
int n, m;
hugeint f[10005];

void writeln(hugeint x) {
    int i;
    for (i = x.len; i; i--)
        putchar(x.a[i] | 48);
    putchar('\n');
}

int main() {

    int i, j, x;

    scanf("%d %d", &n, &m);
    for (i = 1; i <= m; i++) {
        scanf("%d", &x);
        c[x] = true;
    }
    for (i = 1; i <= n; i++) {
        for (j = 1; j <= 9; j++) {
            if (c[j] and i >= A[j] and (f[i - A[j]].len or i == A[j])) {
                f[i] = std::max(f[i], f[i - A[j]] + j);
            }
        }
    }
    writeln(f[n]);
    return 0;
}

Measured memory_bytes: 195840
import itertools
n=int(input())
x=[0]*n
y=[0]*n
for i in range(n):
    x[i],y[i] = map(int,input().split())
num=[i for i in range(n)]
def dist(i,j):
    return ((x[i]-x[j])**2 + (y[i]-y[j])**2)**0.5
ans=0
s=0
for perm in list(itertools.permutations(num)):
    for i in range(n-1):
        ans+=dist(perm[i],perm[i+1])
    s+=1     
print(ans/s)
        



Measured memory_bytes: 46448
using System;

class Program
{
	static void Main()
	{
		string[] D = Console.ReadLine().Split(' ');
		int a = int.Parse(D[0]), b = int.Parse(D[1]), c = int.Parse(D[2]);
		int k = 0;
		for (int i = a; i <= b; i++)
		{
			if (c % i == 0)
			{
				k++;
			}
		}
		Console.WriteLine(k);
	}
}

Measured memory_bytes: 7628
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
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; }
  
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/

const ll mod = 1000000007;

ll dp[110][10];

int main(){
    int H, W, K; cin >> H >> W >> K;
    dp[0][0] = 1;

    for(int i=0; i<H; i++){
        for(int j=0; j<W; j++){
            if(dp[i][j] == 0) continue;
            for(int bit=0; bit<1<<(W-1); bit++){
                bool ok = true;
                for(int k=0; k<W-2; k++) if(bit&1<<k && bit&1<<(k+1)) ok = false;
                if(!ok) continue;

                if(j != 0 && bit&1<<(j-1)) { dp[i+1][j-1] += dp[i][j]; dp[i+1][j-1] %= mod; }
                else if(j != W-1 and bit&1<<j) { dp[i+1][j+1] += dp[i][j]; dp[i+1][j+1] %= mod; }
                else {dp[i+1][j] += dp[i][j]; dp[i+1][j] %= mod; }
            }
        }
    }


    cout << dp[H][K-1] << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main ()
{
	string s;
	ll a, b, c;
    cin>>a>>b>>c;
    ll o = c % b;
    for (ll i = a; i < 100000; i += a)
    {
        if(i%b == o)
        {
            cout<<"YES"<<endl;
            return 0;
        }
    }
    cout<<"NO"<<endl;
    return 0;
}

Measured memory_bytes: 3584
n, k = map(int, input().split())
H = [int(input()) for _ in range(n)]
H = sorted(H, reverse=True)

ans = 10**9
for i in range(n-k+1):
    dh = H[i] - H[i+k-1]
    ans = min(ans, H[i] - H[i+k-1])
print(ans)

Measured memory_bytes: 81828
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);		
		String s = sc.next();
        String t = sc.next();
        int ans = t.length();
        for(int i=0;i<=s.length()-t.length();i++){int count = t.length();
                                         for(int j=0;j<t.length();j++){if(s.charAt(i+j)==t.charAt(j)){count--;}                              
                                                                      }
                            ans=Math.min(ans,count);
                                        }        
		System.out.println(ans);
	}
}

Measured memory_bytes: 35536
#include <bits/stdc++.h>
 
#define N 200010 
 
using namespace std;
 
typedef long long ll;
 
char *p1, *p2, buf[100000];
 
#define nc() (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 100000, stdin), p1 == p2) ? EOF : *p1 ++ )
 
int rd() {
    int x = 0, f = 1;
    char c = nc();
    while (c < 48) {
        if (c == '-')
            f = -1;
        c = nc();
    }
    while (c > 47) {
        x = (((x << 2) + x) << 1) + (c ^ 48), c = nc();
    }
    return x * f;
}
 
ll bin[40];
 
map <ll, int> MP;
 
ll a[N];
 
int main() {
    bin[0] = 1;
    for (int i = 1; i <= 35; i ++ ) {
        bin[i] = bin[i - 1] << 1;
    }
    int n = rd();
    for (int i = 1; i <= n; i ++ ) {
        a[i] = rd();
        MP[a[i]] ++ ;
    }
    sort(a + 1, a + n + 1);
 
    int ans = 0;
    for (int i = n; i; i -- ) {
        if (MP[a[i]] > 0) {
            MP[a[i]] -- ;
            for (int j = 32; j; j -- ) {
                if (bin[j] - a[i] <= a[i] && bin[j] > a[i]) {
                    ll re = bin[j] - a[i];
                    if (MP.count(re) && MP[re] > 0) {
                        MP[re] -- ;
                        ans ++ ;
                        break;
                    }
                }
            }
        }
    }
 
    cout << ans << endl ;
    return 0;
}

Measured memory_bytes: 14464
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
ans = 0
for i in range(n):
    ans += b[i]
for i in range(n-1):
    if a[i + 1] == a[i] + 1:
        ans += c[a[i]-1]
print(ans)

Measured memory_bytes: 3064
n, m, x = map(int, input().split())
C = []
A = []
for i in range(n):
  t = list(map(int, input().split()))
  C.append(t[0])
  A.append(t[1:])
  
result = -1
for i in range(1 << n):
  t = [0] * m
  c = 0
  for j in range(n):
    if (i >> j) & 1 == 0:
      continue
    c += C[j]
    for k in range(m):
      t[k] += A[j][k]
  if all(z >= x for z in t):
    if result == -1:
      result = c
    else:
      result = min(result, c)
print(result)
  

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

int main() {
    int n, k;
    cin >> n >> k;
    ll ans = k;
    rep(i, n-1) ans *= (k-1);
    cout << ans << endl;
    return 0;
}

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

int main(){
	int n;
	cin >> n;
	vector<int> a(n+10);
	long long s = 0;
	for (int i = 1; i <= n; i++){
	       	cin >> a[i];
		s += a[i];
	}

	vector<long long> x(n+10);
	x[1] = s;
	for (int i = 2; i <= n-1; i += 2) x[1] -= 2*a[i];
	cout << x[1] << ' ';
	for (int i= 2; i <= n; i++){
		x[i] = 2*a[i-1] - x[i-1];
		cout << x[i] << ' ';
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 4464
#include<iostream>
#include<algorithm>
#include<math.h>
#include<queue>
#include<vector>
#include<climits>
#include<map>
#include<string>
#include<functional>
#include<iomanip>

using namespace std;
typedef long long ll;

ll V, E, s, t, w;

typedef int Weight;
struct Edge {  //src:辺の始点,dst:辺の終点,weight:辺の重さ
	int src, dst;
	Weight weight;
	Edge(int src, int dst, Weight weight) :
		src(src), dst(dst), weight(weight) { }
};
bool operator < (const Edge &e, const Edge &f) {
	return e.weight != f.weight ? e.weight > f.weight : //辺は重さが重いものを"小さい"と定義する
	e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

//引数 g:隣接リスト,r:最小全域木の始点
//戻値 total:最小全域木の重み,T:最小全域木の辺集合
pair<Weight, Edges> prim(const Graph &g, int r = 0) {
	int n = g.size();
	Edges T;
	Weight total = 0;
	vector<bool> visited(n);
	priority_queue<Edge> Q;
	Q.push(Edge(-1, r, 0));    //始め、-1とrを結ぶ辺があると考える
	while (!Q.empty()) {
		Edge e = Q.top(); Q.pop();
		if (visited[e.dst]) continue;
		T.push_back(e);
		total += e.weight;
		visited[e.dst] = true;
		for (auto f = g[e.dst].begin(); f != g[e.dst].end(); ++f)if (!visited[f->dst]) Q.push(*f);
	}
	return pair<Weight, Edges>(total, T);
}

int main() {
	cin >> V >> E;
	Graph g(V);
	for (int i = 0; i < E; i++) {
		cin >> s >> t >> w;
		g[s].push_back(Edge(s, t, w));
		g[t].push_back(Edge(t, s, w));
	}
	cout << prim(g).first << endl;
	return 0;
}


Measured memory_bytes: 8616
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define dunk(a) cout << (a) << "\n"
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	vector<int> t(n);
	rep(i, n) cin >> t[i];
	int m;
	cin >> m;
	vector<int> p(m), x(m);
	vector<int> h(m);
	rep(i, m) {
		cin >> p[i] >> x[i];
		p[i]--;
		h[i] = t[p[i]] - x[i];
	}
	ll sum = 0;
	rep(i, n) sum += t[i];
	rep(i, m) {
		dunk(sum - h[i]);
	}
	return 0;
}


Measured memory_bytes: 256