akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
 
using namespace std;
 
   const int d[7][7] =
        {
            { 8,  9,  3,  4,  5,  0,  1},
            { 9, 10,  4,  5,  6,  1,  2},
            {12, 13,  7,  8,  9,  3,  4},
            {13, 14,  8,  9, 10,  4,  5},
            {14, 15,  9, 10, 11,  5,  6},
            {16, 17, 12, 13, 14,  8,  9},
            {17, 18, 13, 14, 15,  9, 10}
        };
 

inline int change_pixel(int v, string &str)
{
    int nv = v;

    for (int i = 0; i < 7; i++) {
        int bit = 0;
        nv &= ~(1 << d[i][3]);
        for (int j = 0; j < 7; j++) {
            bit |= (v >> d[i][j] & 1) ? (1<<j) : 0;
        }        
        nv |= (1 << d[i][3])*(str[bit] - '0');
    }
    return nv;
}
 
bool is_idempotent(string &str)
{
    for (int i = 0; i < (1<<19); i++) {
        int before = i, after;
        before = change_pixel(before, str);
        after  = change_pixel(before, str);
        if ((before >> 9 & 1) != (after >> 9 & 1)) {
            return false;
        }
    }
    return true;
}
 
int main()
{
    string str;
    while (cin >> str, str != "#") {
        cout << (is_idempotent(str) ? "yes" : "no") << endl;
    }
    return 0;
}

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

int main() {
  int n;
  cin >> n;
    
  long long p = 1;
  long long d = pow(10, 9.0)+7;
  
//  cout << d << endl;
  
  for(int i=0; i<n; i++){
    p = p * (i+1) % d;
  }
  
  cout << p << endl;
  return 0;
}



Measured memory_bytes: 256
use std::io::stdin;




fn insertion_sort(array:&mut Vec<i32>){
  //println!("{:?}",array);
  print_array(array.to_vec());
  for i in 1 .. array.len(){
    //①位置決定
    let mut insertpos:usize=114514;
    for j in (0..i).rev(){
        if array[j]<array[i]{
          insertpos=j+1;
          break;
        }
        if j==0{
          insertpos=0;
        }
    }
    //②挿入
    for j in (insertpos..i).rev()
    {
      array.swap(j,j+1);
    }
    print_array(array.to_vec());
  }
  //print_array(array.to_vec());
}

fn bubble_sort(array:&mut Vec<i32>)->i32
{
  let mut swap_times=0;
  let mut swapped=true;
  while swapped{
  swapped=false;
  for j in (1..array.len()).rev(){
    if array[j]<array[j-1]
    {
      array.swap(j,j-1);
      //print_array(array.to_vec());
      swap_times+=1;
      swapped=true;
    }
  }
}
  swap_times
}
fn selection_sort(array:&mut Vec<i32>)->i32{
  let mut swap_cnt=0;
  for i in 0..array.len(){
    let mut current_min=1145141919;
    let mut current_min_pos=array.len()-1;
    for j in i..array.len()
    {
      if current_min>array[j]{
        current_min_pos=j;
        current_min=array[j]
      }
    }
    if current_min_pos!=i {
      array.swap(i,current_min_pos);
      swap_cnt+=1;
    }
    //print_array(array.to_vec());
  }
  swap_cnt
}
fn main() {
  //入力を受け取ってi32に変換
  let n:i32 = readline().parse().unwrap();
  //println!("{}",n);
  //let mut array=vec![5,4,3,2,1];
  let mut array=readline_as_vec();
  //insertion_sort(&mut array);
  //let swap_occured=bubble_sort(&mut array);
  let swap_occured=selection_sort(&mut array);
  print_array(array);
  println!("{:?}",swap_occured);
}

fn print_array(array:Vec<i32>){
  let mut array_content=String::new();
  for a in array{
    array_content += &a.to_string();
    array_content += " ";
  }
  println!("{}",array_content.to_string().trim_right());
}
fn readline()->String
{
  let mut s = String::new();
  stdin().read_line(&mut s).unwrap();
  //改行コードの削除
  s.trim_right().to_owned()
}

fn readline_as_vec()->Vec<i32>
{
  let mut s = String::new();
  stdin().read_line(&mut s).unwrap();
  //改行コードの削除
  s=s.trim_right().to_owned();
  let mut read_vec:Vec<i32>=Vec::new();
  //空白で分割
  for chr in s.split_whitespace(){
    read_vec.push(chr.parse::<i32>().unwrap());
  }
  read_vec
}


Measured memory_bytes: 5036
/*
 ╔═══╦═══╦═══╗
 ║╔═╗║╔══╩╗╔╗║
 ║║░║║╚══╗║║║║
 ║║░║║╔══╝║║║║
 ║╚═╝║╚══╦╝╚╝║
 ╚══╗╠═══╩═══╝
 ░░░╚╝░░░░░░░░
 */

#include <bits/stdc++.h>
#define ll					long long
#define MOD					1000000007
#define MAX					1e9
#define MIN                 -1e9
#define PI					acos(-1.0)
#define vi					vector<int>
#define vii					vector<vi>
#define vll					vector<ll>
#define mid(s,e)			(s+(e-s)/2)
#define clz(n)				__builtin_clzll(n))

using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
template<typename T>
void printVec(const T &v, char sep=' ') {for (auto &i: v) cout << i << sep;}
template<typename T>
void printVecPair(const T &v, char sep=' ') {for (auto &i: v) cout << i.first <<" " << i.second<< sep;}


#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

int main() {
	ios::sync_with_stdio(false);
 	cin.tie(0);
	int n,w;
	cin>>n>>w;
	vector<ll> dp(w+1,0);
	while(n--) {
			int a,b;
			cin>>a>>b;
			for(int i=w;i>=0;i--) {
					if(i-a >=0) {
							dp[i] = max(dp[i], dp[i-a] + b);
					}
			}
			
	}
	cout<<dp[w];
	
	return 0;
}





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

int main(){
    ll x,a,b;
    cin>>x>>a>>b;
    if (b<=a)
    {
        /* code */
        cout<<"delicious"<<endl;
    }
    else if (b-a<=x)
    {
        /* code */
        cout<<"safe"<<endl;
    }
    else
    {
        cout<<"dangerous"<<endl;
    }
    
    

    
    }


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

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MOD 1000000007

typedef long long ll;
typedef pair<ll, ll> p;

vector<ll> enumeration(ll n){
  vector<ll> result;
  for (ll i = 1; i*i <= n; i++) {
    if(n % i == 0){
      result.push_back(i);
      result.push_back(n / i);
    }
  }
  sort(ALL(result));
  return result;
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n;
  cin >> n;
  if(n == 1){
    cout << 0 << endl;
    return 0;
  }
  vector<ll> yakusu = enumeration(n);
  ll res = 0;
  yakusu.erase(yakusu.begin());
  for(auto a : yakusu){
    if(n % (a-1) == n / (a-1)) res += a-1;
  }
  cout << res << endl;

}


Measured memory_bytes: 384
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
	int N; cin >> N;
	int a[N + 1];
	rep(i, N) cin >> a[i + 1];
	int tmp = 1;
	rep(i, N) {
		tmp = a[tmp];
		if (tmp == 2) {
			cout << i + 1 << endl;
			return 0;
		}
	}
	cout << -1 << endl;


    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int H, W;
  cin >> H >> W;
  for (int i = 0; i < W + 2; i++) {
    cout << "#";
  }
  cout << endl;
  for (int i = 0; i < H; i++) {
    cout << "#";
    for (int j = 0; j < W; j++) {
      vector<char> vec(W);
      cin >> vec.at(j);
      cout << vec.at(j);
    }
    cout << "#" << endl;
  }
  for (int i = 0; i < W + 2; i++) {
    cout << "#";
  }
  cout << endl;
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

#define DBG 0

int N=50;
int K=250;
int A[50][50];

int cnt;

int q(int y1,int x1,int y2,int x2){
    if((y2-y1)*(x2-x1)==0)return 0;

    if(DBG){
        int res=0;
        for(int y=y1;y<y2;y++)for(int x=x1;x<x2;x++)res+=A[y][x];
        return res;
    }

    else{
        cout<<"? "<<y1<<" "<<x1<<" "<<y2-1<<" "<<x2-1<<endl;
        int p;cin>>p;
        return p;
    }
}


vector<int>lis[2555];
int dfs(int y1,int x1,int y2,int x2,int p){
    if(y1==y2)return 0;
    if(x1==x2)return 0;

    if((y2-y1)*(x2-x1)==p){
        for(int y=y1;y<y2;y++)for(int x=x1;x<x2;x++)A[y][x]=1;
        return 0;
    }

    if(p==0)return 0;
    int y3=(y1+y2)/2;
    int x3=(x1+x2)/2;

    int pl=q(y1,x1,y2,x3);
    int pu=q(y1,x1,y3,x2);

    int p11,p12,p21,p22;

    int cnt=2;

    if(pl==0){
        p11=p21=0;
        p12=pu;
        p22=p-pu;
    }
    else if(pl==p){
        p12=p22=0;
        p11=pu;
        p21=p-pu;
    }
    else if(pu==0){
        p11=p12=0;
        p21=pl;
        p22=p-pl;
    }
    else if(pu==p){
        p21=p22=0;
        p11=pl;
        p12=p-pl;
    }
    else{
        p11=q(y1,x1,y3,x3);
        p12=pu-p11;
        p21=pl-p11;
        p22=p-p11-p12-p21;
        cnt++;
    }

    cnt+=dfs(y1,x1,y3,x3,p11);
    cnt+=dfs(y1,x3,y3,x2,p12);
    cnt+=dfs(y3,x1,y2,x3,p21);
    cnt+=dfs(y3,x3,y2,x2,p22);

    lis[(y2-y1)*(x2-x1)].pb(cnt);
    return cnt;
}

signed main(){
    if(DBG){
        vector<pint>v;
        rep(i,N)rep(j,N)v.pb({i,j});
        srand((unsigned)time(NULL));
        random_shuffle(all(v));

        for(int i=0;i<K;i++){
            A[v[i].fi][v[i].se]=1;
        }
        int sum=0;
        const int B=8;
        for(int i=0;i<(N+B-1)/B;i++){
            for(int j=0;j<(N+B-1)/B;j++){
                int p=q(i*B,j*B,min(N,(i+1)*B),min(N,(j+1)*B));
                sum++;
                sum+=dfs(i*B,j*B,min(N,(i+1)*B),min(N,(j+1)*B),p);
            }
        }
        int cnt=0;
        rep(i,N)rep(j,N)cnt+=A[i][j];
        cout<<cnt<<endl;
        cout<<sum<<endl;

        cout<<dfs(0,0,N,N,K)<<endl;
    }

    else{
        int tmp;
        cin>>tmp;cin>>tmp;cin>>tmp;
        int mod;cin>>mod;

        const int B=8;
        for(int i=0;i<(N+B-1)/B;i++){
            for(int j=0;j<(N+B-1)/B;j++){
                int p=q(i*B,j*B,min(N,(i+1)*B),min(N,(j+1)*B));
                dfs(i*B,j*B,min(N,(i+1)*B),min(N,(j+1)*B),p);
            }
        }

        int p=1;
        int res=0;
        rep(i,N)rep(j,N){
            res=(res+p*A[i][j])%mod;
            p=p*2%mod;
        }

        cout<<"! "<<res<<endl;
    }
    return 0;
}


Measured memory_bytes: 844
#include <iostream>

using namespace std;

int main() {
  string str;
  cin >> str;
  int len = str.size();
  bool check1 = false;
  bool check2 = false;
  for (int i=0; i<len; i++) {
    if (str[i] == 'C') {
      check1 = true;
    }else if(str[i] == 'F' && check1) {
      check2 = true;
    }
    if (check2){
      break;
    }
  }
  if (check2) {
    cout << "Yes" << endl;
  }else {
    cout << "No" << endl;
  }

  return 0;
}

Measured memory_bytes: 256
//                                               KEEP GRINDING
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 

using namespace std;
using namespace __gnu_pbds; 

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>   new_data_set;

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); 

#define int long long
#define ld long double
#define MOD 1000000007
#define mod 998244353
#define precise(i) fixed << setprecision(10) << i
#define f(i,a,b) for(int i=a;i<b;++i)

#define endl '\n'
#define debug cout<<"\n========================================\n"<<endl;
#define err1(a) cout<<#a<<" "<<a<<endl;
#define err2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl;
#define err3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl;
#define err4(a,b,c,d) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<" "<<#d<<" "<<d<<endl;

#define all(a) a.begin(),a.end()
#define show(a) for(auto xyz:a)cout<<xyz<<" ";cout<<endl;
#define mx(a) *max_element(a)
#define mn(a) *min_element(a) 
#define LB lower_bound  //THIS GIVES THE ITR TO THE ELEMENT IN RANGE [SI,EI) THAT IS >= OUR VALUE 
#define UB upper_bound  //THIS GIVES THE ITR TO THE ELEMENT IN RANGE [SI,EI) THAT IS > OUR VALUE 

#define fr first
#define sc second

#define MAXN 500000
#define INF 9223372036854775807
signed main(){
    fastio
    string s;
    cin>>s;
    cout<<s[0]<<s[1]<<s[2];
}

Measured memory_bytes: 3612
n,a,b = map(int,input().split())
s = input()
count = 0
rank = 1

for i in range(len(s)):
    tmp = s[i]
    if tmp == 'a':
        if count < a + b:
            print("Yes")
            count += 1
        else:
            print("No")
    elif tmp == 'b':
        if count < a + b and rank <= b:
            print("Yes")
            count += 1
            rank += 1
        else:
            print("No")
    else:
        print("No")


Measured memory_bytes: 4016
// ?????¬???????????¬??????

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define int long long int

template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}

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

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
constexpr ll INF = 1001001001001001LL;
constexpr ll MOD = 1000000007LL;

// ??¨????????¢ (??¬??????????????\??????????????¢)
int dp[1010][1010];
int editDistance(string s, string t) {
    int n = s.length(), m = t.length();
    rep(i,0,n) dp[i+1][0] = i+1;
    rep(i,0,m) dp[0][i+1] = i+1;

    rep(i,0,n) rep(j,0,m) {
        int cost = (s[i] != t[j]);
        dp[i+1][j+1] = min(dp[i+1][j] + 1, 
                       min(dp[i][j+1] + 1, dp[i][j] + cost));
    }
    return dp[n][m];
}

signed main() {
    string s, t; cin >> s >> t;
    cout << editDistance(s, t) << endl;
    return 0;
}

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

using namespace std;

#define ALL(x) (x).begin(), (x).end()
#define ALLTRUE(xs) all_of(ALL(xs),[](bool x){return x;})
#define AND(x,y,z) set_intersection((x).begin(),(x).end(),(y).begin(),(y).end(),inserter((z),(z).end()))
#define ANYTRUE(xs) any_of(ALL(xs),[](bool x){return x;})
#define CONCAT(x,y) (x).insert((x).end(),(y).begin(),(y).end())
#define DUMP(xs) for (auto x:xs) cout<<x<<' ';cout<<endl
#define FOR(i,a,b) for (int i=(int)(a);i<(int)(b);++i)
#define OR(x,y,z) set_union((x).begin(),(x).end(),(y).begin(),(y).end(),inserter((z),(z).end()))
#define OUT(x) cout<<x<<endl
#define REP(i,n) FOR(i,0,n)

typedef long long ll;
typedef pair<ll, ll> P;

const int MOD = 1000000007;
const int MAX = 700000;
ll fac[MAX], finv[MAX], inv[MAX];

void init() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  FOR(i,2,MAX) {
    fac[i] = fac[i-1]*i%MOD;
    inv[i] = MOD - inv[MOD%i]*(MOD/i)%MOD;
    finv[i] = finv[i-1]*inv[i]%MOD;
  }
}

int main() {
  init();
  // パスカルの三角形の斜番
  ll X,Y;cin>>X>>Y;
  // X軸よりに点を対称移動
  if (X<Y) swap(X,Y);
  // 最もX軸に近いところまで移動させる
  int k = 0;
  while (Y*2>X) {
    X++;Y--;
    k++;
  }

  // 対象外
  if (Y*2!=X) {
    OUT(0);
    return 0;
  }
  int n = X/2;
  
  // あとはC(n,k)のcomb
  OUT(fac[n]*(finv[k]*finv[n-k]%MOD)%MOD);

  return 0;
}

Measured memory_bytes: 16640
/*
Keep clam  Believe youself
*/
#include<cstdio>
#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
#include<queue>
#include<map>
#include<vector>
#include<stack>
#include<set>
#include<cmath>
#define Xiaobo main
#define DEBUG(x) cerr<<#x<<": "<<(x)<<endl
using namespace std;
const int maxn=2e5+7;
const int mod=1e9+7;
const double eps=1e-15;
const double pi=acos(-1);
const int INF=0x3f3f3f3f;
typedef long long ll;
ll read(){ll c = getchar(),Nig = 1,x = 0;while(!isdigit(c) && c!='-')c = getchar();if(c == '-')Nig = -1,c = getchar();while(isdigit(c))x = ((x<<1) + (x<<3)) + (c^'0'),c = getchar();return Nig*x;}
ll gcd(ll a,ll b){ return b==0?a:gcd(b,a%b);}
//别急 dp找状态 问题看看本身的规律 贪心找方法
int a[maxn];
vector<int>b[maxn];
int Xiaobo()
{
	int n;
	cin>>n;
	for(int i=1;i<=n;i++) {
		scanf("%d",&a[i]);
		b[a[i]].push_back(i);
	} 
	int ans=0;
	int j;
	if(!b[1].size()) cout<<-1<<'\n';
	else {
		j=*b[1].begin();
		ans=1;
		for(int i=2;;i++) {
			if(!b[i].size()) break;
			int k=lower_bound(b[i].begin(),b[i].end(),j+1)-b[i].begin();
		//	cout<<k<<'\n';
			if(k>=b[i].size()) break;
			ans++,j=b[i][k];
 		}
		//cout<<j<<'\n';
		cout<<n-ans<<'\n';
	}
	return 0;
}

Measured memory_bytes: 11904
#define MYDEBUG
//
#include <bits/stdc++.h>
#ifdef MYDEBUG
#define dbp(x) cout<<#x<<": "<<x<<endl
#define dbp2(x,y) cout<<#x<<","<<#y<<": "<<x<<","<<y<<endl
#define dbp3(x,y,z) cout<<#x<<","<<#y<<","<<#z<<": "<<x<<","<<y<<","<<z<<endl
#define dbp4(w,x,y,z) cout<<#w<<","<<#x<<","<<#y<<","<<#z<<": "<<w<<","<<x<<","<<y<<","<<z<<endl
#define ifcin(x) std::ifstream cin(x)
#else
#define dbp(x)
#define dbp2(x,y)
#define dbp3(x,y,z)
#define dbp4(w,x,y,z)
#define ifcin(x)
#endif
#define ll long long
#define all(x) x.begin(), x.end()
#define rep(i, from, to) for(int i=from; i<to; ++i)
#define REP(i, from, to) for(int i=from; i<=to; ++i)
using namespace std;
template<typename T>
ostream& operator<<(ostream& out, const vector<T>& v) {
  out << "[";
  size_t last = v.size() - 1;
  for (size_t i = 0; i < v.size(); ++i) {
    out << v[i];
    if (i != last) {
      out << ",";
    }
  }
  out << "]";
  return out;
}
template<typename T>
ostream& operator<<(ostream& out, const vector<vector<T> >& v) {
  for (size_t i = 0; i < v.size(); ++i) {
    out << v[i] << endl;
  }
  return out;
}
template<typename T1, typename T2>
ostream& operator<<(ostream& out, const pair<T1, T2>& p) {
  out << "{" << p.first << "," << p.second << "}";
  return out;
}

int searchKey(int a[], int size, int x) {
  int L = 0, R = size; //[L, R): lower bound
  while (R - L > 1) {
    int C = L + (R - L) / 2;
    if (x < a[C]) {
      R = C;
    } else if (x == a[C]) {
      return C;
    } else {
      L = C;
    }
  }
  if (a[L] == x) {
    return L;
  }
  return (-L) - 1;
}

int n, q, S[100000];

void solve() {
  scanf("%d", &n);
  rep(i,0,n)
  {
    scanf("%d", &S[i]);
  }
  scanf("%d", &q);
  int sum = 0, key;
  rep(i,0,q)
  {
    scanf("%d", &key);
    if (searchKey(S, n, key) >= 0) {
      sum++;
    }
  }
  printf("%d\n", sum);
}
int main() {
  solve();
  return 0;
}



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

using namespace std;

const int MAXN = 3500;

long long dp[MAXN][MAXN];
long long arr[MAXN];

long long solve(int l, int r)
{
    long long &cur = dp[l][r];
    if (~cur)
        return cur;
    if (l == r)
        return cur = arr[l];
    return cur = max(-solve(l, r-1) + arr[r], -solve(l+1, r) + arr[l]);
}

int main()
{
    memset(dp, -1, sizeof dp);
    int n;
    scanf("%i", &n);
    for (int x = 1; x <= n; x++)
        scanf("%lli", &arr[x]);
    printf("%lli\n", solve(1, n));
}


Measured memory_bytes: 96128
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
#define tr(container, it) \
        for (auto it = container.begin(); it != container.end(); it++)
#define scontains(c, x) ((c).find(x) != (c).end())   //O(log n)
#define contains(c, x) (find((c).begin(),(c).end(),x) != (c).end()) //O(n)
#define pll pair<ll,ll>
#define pii pair<int,int>
#define mll map<ll,ll>
#define intv(x, a, b)((x)>=a && (x)<=b)
#define  rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define  _for(i, end) for (__typeof(end) i = 0; i < (end); i += 1)
#define all(x) (x).begin(),(x).end()
//#define len(array)  (sizeof(array)/sizeof((array)[0]))
#define what_is(x) cerr << #x << " is " << x << endl;
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#define mod(x, m) ((((x) % (m)) + (m)) % (m))
const double PI = 2 * acos(.0);
const int INF = 0x3f3f3f3f;
const ll LLINF = 1000000000000000005LL;;
const ll MOD = (ll) (1e9) + 7;
void _mod(ll &x){x = mod(x, MOD);}
//const ll MOD = (ll) 998244353 ;
const double EPS = 1e-10;

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    std::fill((T *) array, (T *) (array + N), val);
}


//#define int ll

class CStones {
public:
        int N;
        string s;
        array<int, 202020> A;
void solve(std::istream& cin, std::ostream& cout) {
    fill(all(A),0);
    cin >> N >> s;
    _for(i,N)A[i+1] = A[i] + (s[i] == '#');
    int mi = 22202020;
    _for(i,N+1){
        mi = min(mi, A[i] + (N-i - (A[N] - A[i])));
    }
    cout << mi << endl;
}
};


#undef int
int main() {
	CStones solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 1412
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

const int N=1e6+5;

string s, reqd="keyence";

int32_t main()
{
	IOS;
	cin>>s;	
	while(s.size() && reqd.size() && s.back()==reqd.back())
	{
		s.pop_back();
		reqd.pop_back();
	}
	reverse(s.begin(), s.end());
	reverse(reqd.begin(), reqd.end());
	while(s.size() && reqd.size() && s.back()==reqd.back())
	{
		s.pop_back();
		reqd.pop_back();
	}
	if(reqd.size()==0)
		cout<<"YES";
	else
		cout<<"NO";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long int ll;
typedef unsigned long long int ull;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> o_set; 

#define     int                 ll
#define     pb                  push_back
#define     mp                  make_pair
#define     xx                  first
#define     yy                  second    
#define     all(a)              a.begin(),a.end()
#define     vi                  vector<int>
#define     vpi                 vector<pii>
#define     pii                 pair<int, int>
#define     present(DT, val)    (DT.find(val) != DT.end()) //for set and map
#define     cpresent(DT, val)   (find(all(DT),val) != DT.end()) //vectors
#define     input               "/home/pollution/Desktop/WorkSpace/C++/Files/input.txt"
#define     output              "/home/pollution/Desktop/WorkSpace/C++/Files/output1.txt"
#define     error               "/home/pollution/Desktop/WorkSpace/C++/Files/error.txt"
#define     IO()                ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define     INF                 2e18
#define     MOD                 1000000007
#define     clr(x)              memset(x, 0, sizeof(x))
#define     init(x, a)          memset(x, a, sizeof(x))
#define     out(a)              for (auto i: a) cout<<i<<' '; cout<<'\n'
#define     cpy(a,b)            memcpy(a,b,sizeof(b))
#define     is(a)               to_string(a)
#define     ci(a,c)             a-c
#define     db(i)               cout<<"point :"<<i<<'\n';
#define     setd(val,n)         cout<<fixed<<setprecision(n)<<val<<'\n'

int pwr(int b){
	return b*b*b*b*b;
}

void solve(){
    int x; cin>>x;
    for(int i = -1000; i < 1001; ++i){
    	for(int j = -1000; j < 1001; ++j){
    		if(pwr(i)-pwr(j)==x){
    			cout<<i<<' '<<j<<'\n';
    			return;
    		}
    	}
    }
    cout<<"0 0\n";
}

signed main() { 
    IO();
    
    int t=1;
    // cin>>t;
    while(t--) solve();
    return 0; 
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
//#define int long long
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 


signed main(){
  int n,h;cin>>n>>h;
  int maxa = 0, b[100000];
  rep(i,n){
    int a;cin>>a>>b[i];
    maxa = max(maxa, a);
  }
  sort(b, b+n);
  auto itr = upper_bound(b,b+n,maxa);
  int ans = 0;
  for(auto i = b+n-1;i >= itr;i--){
    ans++;
    h -= (*i);
    if(h <= 0){
      cout << ans << endl;
      return 0;
    }
  }
  cout << ans + (h%maxa ? h/maxa+1 : h/maxa) << endl;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int N;
  cin>>N;
  vector<vector<int>> A(N+1,vector<int>(3,0));
  for(int i=1;i<=N;i++){
    vector<int> B(3);
    for(int &j:B)cin>>j;
    for(int j=0;j<3;j++)
      A[i][j]=max(A[i-1][(j+1)%3],A[i-1][(j+2)%3])+B[j];
  }
  cout<<max({A[N][0],A[N][1],A[N][2]})<<endl;
}

Measured memory_bytes: 8788
#pragma GCC optimize("O3", "unroll-loops")
//#pragma GCC target("avx2")
#include <bits/stdc++.h>
#include <stdio.h>

using namespace std;
#define ull unsigned long long
#define si short int
#define ll long long
#define piii pair<pair<int, int>, int>
#define piiii pair<pair<int, int>, pair<int, int>>

/*-----------------------------------------------------MATH------------------------------------------------*/
inline ll gcd(ll a, ll b) {
    while (b) {
        a %= b;
        swap(a, b);
    }
    return a;
}

inline ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

inline int pwm(ll xx, ll pow, int MD) {
    if (pow < 0) { pow = pow % (MD - 1) + MD - 1; }
    ll mlt = 1;
    while (pow) {
        if (pow & 1) {
            mlt *= xx;
            mlt %= MD;
        }
        xx *= xx;
        pow >>= 1;
        xx %= MD;
    }
    return (int) mlt;
}

inline ll gcdex(ll a, ll b, ll &x, ll &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    ll xx, yy;
    ll gc = gcdex(b, a % b, yy, xx);
    x = xx;
    y = yy - (a / b) * xx;
    return gc;
}

inline int inv(ll r, int _mod) { return pwm(r % _mod, _mod - 2, _mod); }

inline int64_t hilbertOrder(int x, int y, int pow, int rotate) {
    if (pow == 0) {
        return 0;
    }
    int hpow = 1 << (pow-1);
    int seg = (x < hpow) ? (
            (y < hpow) ? 0 : 3
    ) : (
                      (y < hpow) ? 1 : 2
              );
    seg = (seg + rotate) & 3;
    const int rotateDelta[4] = {3, 0, 0, 1};
    int nx = x & (x ^ hpow), ny = y & (y ^ hpow);
    int nrot = (rotate + rotateDelta[seg]) & 3;
    int64_t subSquareSize = int64_t(1) << (2*pow - 2);
    int64_t ans = seg * subSquareSize;
    int64_t add = hilbertOrder(nx, ny, pow-1, nrot);
    ans += (seg == 1 || seg == 2) ? add : (subSquareSize - add - 1);
    return ans;
}
/*-----------------------------------------------------MATH------------------------------------------------*/
vector<int> arr(1e6+1, 0);
vector<int> now(1e4+1, 0);
ll mod=1e9+7;
void solve() {
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        int a;
        cin>>a;
        now[i]=a;
        for(int j=2;j*j<=a;j++){
            int deg=0;
            while(a%j==0) {
                a/=j;
                deg++;
            }
            arr[j]=max(arr[j],deg);
        }
        if(a!=1){
            arr[a]=max(arr[a], 1);
        }
    }
    ll lcmm=1;
    for(int i=2;i<1e6+1;i++){
        ll summ=pwm(i,arr[i], mod);
        lcmm*=summ;
        lcmm%=mod;
    }
    ll ans=0;
    for(int i=0;i<n;i++){
        ll now1=inv(now[i],mod);
        ans+=now1;
        ans%=mod;
    }
    ans*=lcmm;
    cout<<(ans%mod+mod)%mod;
}

int main() {
    /*ios::sync_with_stdio(false);
    cin.tie(nullptr);*/
    //freopen("C:\\Users\\Maximus\\CLionProjects\\Codeforces\\BestTeam\\output.txt", "r", stdin);
    //freopen("C:\\Users\\Maximus\\CLionProjects\\Codeforces\\BestTeam\\output.txt", "w", stdout);
    unsigned int beg_time = clock();

    int n = 1;
    for (int i = 0; i < n; i++) solve();


    unsigned int end_time = clock();
    //cout<<endl<<endl<<end_time-beg_time;

    return 0;
}

Measured memory_bytes: 4224
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<math.h>
using namespace std;

int main(){
	double r;
	cin >> r;
	cout.setf(ios::fixed, ios::floatfield);
	cout << M_PI * r * r << " " << 2 * M_PI * r << endl;

}

Measured memory_bytes: 1288
#include <stdio.h>
#include <stdlib.h>
int f(const void *a,const void *b){
  return *(int*)b-*(int*)a;
}
int main(){
  int N,K;
  int H[200002];
  scanf("%d %d",&N,&K);
  for(int i=0;i<N;i++)
    scanf("%d",H+i);
  qsort(H,N,sizeof(int),f);
  long long int ans=0LL;
  for(int i=K;i<N;i++)
    ans+=(long long int)H[i];
  printf("%lld\n",ans);
  return 0;
}

Measured memory_bytes: 3100
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define NUM 2000

ll N,K;
ll nCm[NUM][NUM];

int main(){

	scanf("%lld %lld",&N,&K);

	//コンビネーションを求める
	nCm[0][0] = 1;
	for(ll n = 1; n <= N+K-1; n++) {
		for (int m = 0; m <= N; m++) {
			if(m > 0){
				nCm[n][m] = nCm[n-1][m]+nCm[n-1][m-1];
			}else{ //m == 0
				nCm[n][m] = 1;
			}
			nCm[n][m] %= MOD;
		}
	}

	printf("%lld\n",nCm[N+K-1][N]);

	return 0;
}




Measured memory_bytes: 26688
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<queue>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
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; }
typedef pair<int, int>P;
const int INF = 1e8;

signed main() {
	int N, K;
	cin >> N >> K;
	int num = 1;
	rep(i, N) {
		if (num * 2 < num + K)num *= 2;
		else num += K;
	}
	cout << num;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
void iosbase(void);
typedef  long long int     ll;
typedef  vector<int>       vi;
typedef  pair<int, int>     pii;
#define  int               ll
#define  pb                push_back
#define  mp                make_pair
#define  si(x)             (int)x.size()
#define  F                 first
#define  S                 second
#define  all(x)            x.begin(),x.end()
#define  minv(m,n)         *min_element(m,n)
#define  maxv(m,n)         *max_element(m,n)
#define  mem(a,x)          memset(a,x,sizeof(a))
#define  deb(x)            cout<<"> "<<#x<<" : "<<x<<endl
#define  rep(i,n)          for(int i=0;i<n;i++)
#define  prs(x,y)          fixed<<setprecision(y)<<x
#define  w(x)              int x;cin>>x; while(x--)
#define  show(a)           for(auto x:a){cout<<x<<" ";}cout<<endl;
#define   N  (int)1e5+5

int32_t main()
{
  iosbase();
  int n;
  cin >> n;
  int a[n];
  rep( i , n)cin >> a[i];
  int ans = 0;
  for (int i = 0 ; i < n ; i++)
  {
    if ( (i + 1) % 2 == 1  and a[i] % 2 == 1)
      ans++;
  }
  cout << ans << endl;


}


void iosbase(void) {
  ios::sync_with_stdio(false);
  cin.tie(nullptr); cout.tie(nullptr);
#ifndef ONLINE_JUDGE
  freopen("in.txt", "r", stdin);
//freopen("out.txt","w",stdout);
#endif
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i = 0;i<((ll)(n));i++)
#define reg(i,a,b) for(ll i = ((ll)(a));i<=((ll)(b));i++)
#define irep(i,n) for(ll i = ((ll)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(ll i = ((ll)(b));i>=((ll)(a));i--)
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T = int> void print(vector<T> v){for(auto a:v)cout<<a<<" ";cout<<endl;}

/*
*/

ll n,k,d[200010][60],ans=1;

int main(void){
	cin>>n>>k;
	reg(i,1,n)cin>>d[i][0];
	reg(j,1,59){
		reg(i,1,n){
			d[i][j] = d[d[i][j-1]][j-1];
		}
	}
	irep(j,60){
		if(k >= (1LL<<j)){
			ans = d[ans][j];
			k -= (1LL<<j);
		}
	}
	cout<<ans<<endl;
	return 0;
}

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

int main() {
	int n;

	scanf("%d", &n);

	int mx = 0, tot = 0;
	for (int i = 0;i < n;++i) {
		int u;

		scanf("%d", &u);

		mx = std::max(mx, u);
		tot += u;
	}

	printf("%s", mx < tot - mx ? "Yes" : "No");

	return 0;
}

Measured memory_bytes: 256
package main

import (
  "fmt"
)

func main() {
  var (
    s   string
    ans int
  )
  fmt.Scan(&s)
  for i := 0; i < len(s); i++ {
    if s[i] == '1' {
      ans++
    }
  }
  fmt.Println(ans)
}

Measured memory_bytes: 512
fun main(args: Array<String>) {
    val (N, Y) = readLine()!!.split(" ").map { it.toInt() }
    for (x in 0..N) {
        for (y in 0..(N - x)) {
            val z = N - x - y
            val total = 10000 * x + 5000 * y + 1000 * z
            if (Y == total) {
                print("$x $y $z")
                return
            }
        }
    }
    print("-1 -1 -1")
}


Measured memory_bytes: 36488
#define FNAME ""

#include <bits/stdc++.h>

#define hash padjf9srpi
#define y0 sdkfaslhagaklsldk
#define y1 aasdfasdfasdf
#define yn askfhwqriuperikldjk
#define j1 assdgsdgasghsf
#define tm sdfjahlfasfh
#define lr asgasgash
#define pb push_back
#define mp make_pair
#define forn(i, n) for (int i = 0; i < (n); i++)
#define fornr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define forab(i, a, b) for (int i = (a); i < (b); i++)
#define gcd __gcd
#define all(a) (a).begin(), (a).end()
 
#ifdef _WIN32
    #define I64 "%I64d"
#else
    #define I64 "%lld"
#endif

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair <int, int> pii;                                                                                                                                                                                      
typedef vector <int> vi;

template <class T> T sqr(const T &a) {return a * a;}


int main()
{
#ifdef LOCAL
    freopen(FNAME".in", "r", stdin);
    freopen(FNAME".out", "w", stdout);
#endif

    LL a, b, c;
    scanf("%lld%lld%lld", &a, &b, &c);
    if (a % 2 == 0 || b % 2 == 0 || c % 2 == 0)
        puts("0");
    else
        printf("%lld\n", min(min(b * c, a * b), a * c));
}



Measured memory_bytes: 764
n,a,b=map(int,input().split())
ans=0
def test(n):
    l=[]
    for i in range(4,-1,-1):
        l.append(n//(10**i))
        if n//(10**i)!=0:
            n=n%(10**i)
    return sum(l)
for i in range(1,n+1):
    if a<= test(i) <= b:
        ans+=i
print(ans)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
int main(){
  
  int N,D;
  cin>>N>>D;
  int count = 0;
  int Dsum;
  
  for(int i=1;;i++){
    Dsum=(2*D+1)*i;
    count++;
    if(Dsum>=N){
      break;
    }
  }
  
  cout<<count<<endl;
  
  return 0;
  
}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<string.h>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<deque>
using namespace std;

int main(){
	int a,b;
	cin >> a >> b;
	
	if(a+b >= 10){
		cout << "error" << endl;
	}else{
		cout << a+b << endl;
	}
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main(){
    int a,b,h,m;
    
    cin >> a >> b >> h >> m;
    long double theta_h = 2*M_PI/(12*60)*(60*h+m);
    long double theta_m = 2*M_PI/60*(60*h+m);
    long double answer = sqrt(a*a + b*b - 2*a*b*cos(theta_h - theta_m));
    cout<<fixed<<setprecision(12)<<answer;
}

Measured memory_bytes: 4156
//#include <bits/stdc++.h>
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <climits>
#include <iomanip>
#include <stack>
#include <bitset>

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define ROF(i, j, k) for(int i = (int)(j); i >= (int)(k); --i)
#define FORLL(i, n, m) for(long long i = n; i < (long long)(m); i++)
#define SORT(v, n) sort(v, v+n)
#define REVERSE(v) reverse((v).begin(), (v).end())

using namespace std;
using ll = long long;
const ll MOD=1000000007LL;
typedef pair<int, int> P;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }

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(a>b){a=b;return 1;}return 0;}

map<char, int> mp;

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

  int n, a, b;
  string s;

  cin >> s;



  REP(i, s.size()){
    mp[s[i]]++;
  }
  int cnt = 0;
  for(auto &e: mp) {
    if(e.second == 2) cnt++;
  }
  if(cnt == 2) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const ll inf =1LL << 62;
const ll mod=1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b,const ll &mod) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b,const ll &mod) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b,const ll &mod) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b,const ll &mod) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
random_device rd;
mt19937 mt(rd());
uniform_int_distribution<int> dice(1,6);
uniform_real_distribution<double> score(0.0,10.0);

int n, m;
vector<vi> G;

vi used;
int dfs(int v, int r){
    used[v] = r;

    int ret = 1;
    for(auto& nv : G[v]){
        if(used[nv]) continue;
        ret += dfs(nv, r);
    }
    return ret;
}

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

    cin >> n >> m;
    G = vector<vi>(n);
    rep(loop, m){
        int a, b; cin >> a >> b; a--, b--;
        G[a].emplace_back(b);
        G[b].emplace_back(a);
    }

    used = vi(n);
    int sum1 = dfs(0, 1);
    int sum2 = dfs(1, 2);
    int rest = n - sum1 - sum2;

    rep(v, n){
        if(not used[v]){
            if(sum1 > sum2){
                used[v] = 1;
                sum1++;
            }
            else {
                used[v] = 2;
                sum2++;
            }
        }
    }
    ll res = 0;
    rep(v, n){
        if(not used[v]) continue;
        if(used[v] == 1){
            sum1--;
            int diff = sum1;
            for(auto& u : G[v]){
                if(used[u] == 1 and u > v) diff--;
            }
            res += diff;
        }
        else if(used[v] == 2){
            sum2--;
            int diff = sum2;
            for(auto& u : G[v]){
                if(used[u] == 2 and u > v) diff--;
            }
            res += diff;
        }
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 10880
import java.util.*;

public class Main{
    public static void main(String[]args){
        Scanner sc=new Scanner(System.in);
        String s=sc.next();
        int w=0;
        int e=0;
        int n=0;
        int k=0;
        for(int i=0;i<s.length();i++){
              if(s.charAt(i)=='W')  w++;
              if(s.charAt(i)=='E')  e++;
              if(s.charAt(i)=='S')  k++;
              if(s.charAt(i)=='N')  n++;
}
if(w==0  && e!=0) System.out.println("No");
else if(e==0  && w!=0) System.out.println("No"); 

else if(k==0  && n!=0) System.out.println("No"); 

else if(n==0  && k!=0) System.out.println("No"); 

else System.out.println("Yes");
    }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
vector<vector<pair<int, int>>> g(100001);
int col[1000010];
pair<int, int> tmp;

int main() {
  int n,m;
  cin >> n >>m;
  //priority_queue<int> pq;
  priority_queue< int, vector<int>, greater<int> > pq;
  int a;
  for(int i = 0;i<n;i++){
    cin >>a;
    pq.push(a);
  }

  vector<pair<int, int>> l;
  int b,c;

  for(int i = 0;i<m;i++){
    cin >> b >> c;
    l.push_back({c,b});
    //cout << b << " " << c << endl;
    //cout << l.size() << endl;
  }
  //cout << l[0].second;
  sort(l.begin(), l.end(),greater<pair<int,int> >());
  long long co =0;
  
  for(int i = 0;i<m;i++){
    //cout << l[i].first << " " << l[i].second << endl;
    for(int j =0;j<l[i].second;j++){
      if(l[i].first > pq.top()){
        pq.pop();
        pq.push(l[i].first);
      }else{
        break;
      }
    }
    co += l[i].second;
    if(co > n){
      break;
    }
  }
  
  long long res =0;
  while (!pq.empty()) {
    res += pq.top();
    //cout << pq.top() << endl;
    pq.pop();
  }
  cout << res << endl;
}


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

int main(){
  int N,a,cnt,max;
  max = 0;
  cnt = 0;
  cin >> N;
  vector <int> moti;
  for(int i = 0;i<N;i++){
   	cin >> a;
    moti.push_back(a);
  }
  sort(moti.begin(),moti.end());
    for(int i = 0;i < moti.size();i++){
    	if(max < moti.at(i)){
        	max = moti.at(i);
          	cnt++;
        }
    }
  cout << cnt <<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include <cmath>
#define MOD 1e9+7
using namespace std;
typedef long long ll;

int main(){

int k,s;

cin >> k >> s;

int sum = 0;

for(int x = 0; x<=k; x++){
 for(int y = 0; y<=k; y++){
if(s-(x+y) <= k && s >= x+y) sum++;
 }
}

cout << sum << endl;

return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
char s[150],key[150]="AKIHABARA";
int cek;
int main(){
	//printf("a");
	scanf("%s",s);
	int c=strlen(key);
	int d=strlen(s);
	int cur=0;
	cek=1;
	if(d>c){
		cek=0;
	}else{
		for(int i=0;i<c;i++,cur++){
			if(cur==d){
				cur--;
			}
		//	printf("%c %c\n",key[i],s[cur]);
			if(key[i]!=s[cur]&&key[i]=='A'&&i==c-1){
				if(key[i-1]!=s[cur]){
					cek=0;
					break;
				}
				i++;
			}else if(key[i]!=s[cur]&&key[i]=='A'){
			//	puts("1");
				if(key[i+1]!=s[cur]){
					cek=0;
					break;
				}
				i++;
			}else if(key[i]!=s[cur]&&key[i]!='A'){
				cek=0;
				break;
			}
		}
	}
	if(cek==0){
		printf("NO\n");
	}else{
		printf("YES\n");
	}
return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n, a, b, x[100005];
long long ans;
int main() {
    scanf("%d%d%d", &n, &a, &b);
    for (int i = 0; i < n; i++)
        scanf("%d", &x[i]);
    for (int i = 1; i < n; i++)
        ans += min((long long)a * (x[i] - x[i-1]), (long long)b);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define repp(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ppb pop_back()
#define ALL(a) (a).begin(),(a).end()

using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;

int main(){
    ll h,w; cin >> h >> w;
    if(h%3==0||w%3==0){
        cout << 0 << endl;
        return 0;
    }
    ll ans=1e10;
    for(ll i=1;i<h;i++){
        ll a=i*w;
        ll b=(h-i)*(w/2);
        ll c=(h-i)*(w-w/2);
        ll x=max(a,max(b,c));
        ll y=min(a,min(b,c));
        chmin(ans,x-y);
        ll d=(h-i)/2;
        b=w*d;
        c=w*(h-i-d);
        x=max(a,max(b,c));
        y=min(a,min(b,c));
        chmin(ans,x-y);
    }
    for(ll i=1;i<w;i++){
        ll a=i*h;
        ll b=(w-i)*(h/2);
        ll c=(w-i)*(h-h/2);
        ll x=max(a,max(b,c));
        ll y=min(a,min(b,c));
        chmin(ans,x-y);
        ll d=(w-i)/2;
        b=h*d;
        c=h*(w-i-d);
        x=max(a,max(b,c));
        y=min(a,min(b,c));
        chmin(ans,x-y);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <bitset>
#include <stack>
#include <deque>
#include <set>
#include <unordered_set>
#include <list>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <climits>
#include <ctime>
#include <random>
#define speed ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ll long long
#define eps 1e-9
#define inf 0x3f3f3f3f
#define mod 1000000007
using namespace std;

int main() {
	speed;
	int d, t, s;
	cin >> d >> t >> s;
	if (t * s >= d)
		cout << "Yes";
	else
		cout << "No";
}

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

using namespace std;

const int INF = 1e9 + 5;
int main(){
	int H, n;
	cin >> H >> n;
	vector<int> dp(H+1,INF);
	dp[0] = 0;
	while(n--){
	   int value,cost;
	   cin >> value >> cost;
	   for(int i = 0; i <=H; i++){
			int j = min(H,i + value);
			dp[j] = min(dp[j], dp[i]+cost);
			/*
			for(int x = 0 ; x < dp.size(); x++){
					cout << "index : "<<x<< ", dp[x] : " << dp[x] << " ,";
			}
			cout << endl;
			*/
	   }
	   //cout << endl;
	}

	cout << dp[H] << endl;
	return 0;
}



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

int main(){
    char x, y;
    cin >> x >> y;
    if(x < y) cout << '<' << endl;
    else if(x == y) cout << '=' << endl;
    else cout << '>' << endl;
    return 0;
}

Measured memory_bytes: 3644