akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 1e18
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define pb push_back
#define ff first
#define ss second
#define vll vector<ll>
#define pii pair<ll,ll>
#define sz(v) (v).size()
#define srt(v) sort(v.begin(),v.end())
#define ull unsigned long long
#define tell(a) cout<<a<<" "
#define el cout<<endl
#define rev(v) reverse(v.begin(),v.end())
#define rep(i,a,n) for(int i=a;i<n;i++)
#define ld long double
#define mem(a,b) memset(a,b,sizeof(a) )
#define M 1000000007

ll power(ll x, ll y, ll p){ll res = 1;x = x % p;while (y > 0){   if (y & 1)res = (res*x) % p;y = y>>1;
x = (x*x) % p;}return res;}



int main()
{
	IOS;
	int n;
	cin>>n;
	ll a[n];
	ll ans=0;
	ll b[n];
	rep(i,0,n){
	cin>>a[i];
	ans=ans^a[i];
	}
	rep(i,0,n)
	{
		b[i]=ans^a[i];
	}
	rep(i,0,n)
	cout<<b[i]<<" ";
}



Measured memory_bytes: 6740
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#include <cmath>
#include <queue>
#include <tuple>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <random>
#include <set>
#include <stack>

//#include <bits/stdc++.h>
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i,i0,n) for(int (i)=(i0);(i)<(n);(i)++)
#define FORR(i,i0,n) for(int (i)=(n)-1; (i)>=(i0);(i)--)
#define SORT(x) sort(x.begin(),x.end())
#define SORTR(x) sort(x.begin(),x.end(),greater<int>())
#define rn return
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#include <time.h>
typedef std::pair<int,int> pii;
using namespace std;
using ll = long long;
#define PI 3.14159265358979323846264338327950L
const int mod =  998244353;



map<int,int> prime(int n ){
    map<int,int> ret;
    while(n%2 == 0){
        n/=2;
        ret[2]++;
    }
    for(int i = 3; i*i <= n; i = i + 2){
        while(n%i == 0){
            n/=i;
            ret[i]++;
        }
    }
    if (n>2) ret[n]++;
    return ret;
}

bool ok;

void dfs(vector<int>& ps, vector<int>& pw, int i, int v,map<int,int>& seen){
    if (i == pw.size()){
        if (v==1) return;
        ok |= seen[v];
        //cout << v << endl;
        return;
    }
    for(int j = 0; j <= pw[i]; j++){
        dfs(ps,pw,i+1,v*pow(ps[i],j),seen);
    }
}

bool check(map<int,int>& p, map<int,int>& seen){
    ok = false;
    vector<int> ps,pw;
    for(auto e:p){
        ps.push_back(e.first);
        pw.push_back(e.second);
    }
    dfs(ps,pw,0,1,seen);
    return ok;
}

void solveD(){
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    SORT(a);
    if (a[0] == a[n-1]){
        cout << 0;
        return;
    }
    int ans = 0;
    map<int,int> seen;
    
    for(int i = 0; i < n; i++){
        auto p = prime(a[i]);
        
        if (check(p,seen)) ans++;
        seen[a[i]] = 1;
    }
    
    cout << n - ans;
}

void solveC(){
    int x,n;
    cin >> x >> n;
    map<int,int> seen;
    rep(i,n){
        int p;
        cin >> p;
        seen[p] = 1;
    }
    int diff = 1001001001;
    int ans = 0;
    for(int i = -1000; i <= 1000; i++){
        if (seen[i]) continue;
        if (abs(i-x) < diff){
            diff = abs(i-x);
            ans = i;
        }
    }
    cout << ans;
}


void solveB(){
    int x,y;
    cin >> x >> y;
    if (y%2==1){
        cout << "No";
        return;
    }
    int b = y-2*x;
    b/=2;
    int a = x - b;
    
    if (a>=0 && b>=0){
        cout <<"Yes";
        return;
    }
    cout << "No";
}

void solveA(){
    rep(i,5){
        int x;
        cin >> x;
        if (x==0){
            cout << i+1;
            return;
        }
    }
}

int main(){
    int T;
    T = 1;
    while(T--){
        solveC();
        cout << endl;
    }
}


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

int a[1000];
int n, k;
set<int > factors;

bool check(int num){

    vector<int > rem;

    for(int i=0;i<n;i++){
        rem.push_back(a[i]%num);
        // cout<<a[i]%num<<" ";
    }
    // cout<<endl;
    
    sort(rem.begin(), rem.end());
    int ans = 0;

    int i = 0, j = n-1;
    while(i < j){
        // cout<<i<<" "<<j<<endl;
        if(rem[i] == 0) i++;
        else if(rem[j] == 0) j--;
        else{
            int temp = min(rem[i], (num - rem[j])%num);
            rem[i] -= temp;
            rem[j] = (rem[j] + temp)%num;
            ans += temp;
        }
    }
    if(ans <= k) return true;
    return false;
}

int32_t main()
{
    cin>>n>>k;

    int sum = 0;
    for(int i=0;i<n;i++) cin>>a[i], sum += a[i];
    
    int ans  = 0;

    int sq_num = sqrt(sum);

    for(int i=1;i<=sqrt(sum) + 1;i++){
        if(sum%i == 0){
            factors.insert(i);
            factors.insert(sum/i);
        }
    }

    for(auto itr : factors){
        if(check(itr)) ans = itr;
    }
 
	cout<<ans<<endl;
	return 0;
}

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

class Program {
    static void Main (string[] args) {
        var input = INP();

        CWL(input[0].Substring(0,3));
    }

    static string[] INP () {
        return Console.ReadLine().Split(' ');
    }

    static void CWL (string value) {
        Console.WriteLine(value);
    }

    static void CWL (int value) {
        Console.WriteLine(value);
    }

    static void CWL (long value) {
        Console.WriteLine(value);
    }

    static void CWL (float value) {
        Console.WriteLine(value);
    }

    static void CWL (double value) {
        Console.WriteLine(value);
    }

    static int TOI (string str) {
        return int.Parse(str);
    }

    static long TOL (string str) {
        return long.Parse(str);
    }

    static float TOF (string str) {
        return float.Parse(str);
    }

    static double TOD (string str) {
        return double.Parse(str);
    }

    /*static void Main (string[] args) {
        var input = INP();
        var input2 = INP();
        var input3 = INP();

        CWL("dummy");
    }*/
}


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

int main()
{
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
    int n;
    cin>>n;
    vector<int> h(n);
    for(int i=0;i<n;i++)
    cin>>h[i];
    int dp[n+1];
    dp[0]=dp[1]=0;
    dp[2]=abs(h[1]-h[0]);
    for(int i=3;i<=n;i++){
        dp[i]=min(dp[i-1]+abs(h[i-1]-h[i-2]),dp[i-2]+abs(h[i-1]-h[i-3]));
    }
    cout<<dp[n];
	return 0;
}

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

using namespace std;

typedef long long tint;

int main(){
	tint a,b,k; cin >> a >> b >> k;
	a-=k;
	if(a < 0){
		b+=a;
		a=0;
	}
	if(b <0) b = 0;
	cout << a << ' ' << b << endl;
}



Measured memory_bytes: 256
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
#pragma GCC optimize("inline")
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <bitset>
#include <cmath>
#define ll long long
#define intinf 0x7f7f7f7f
#define llinf 0x7f7f7f7f7f7f7f7f
#define rep(a,b,c) for(int a=b;a<=c;a++)
#define ALL(x) for(int i=head[x];i;i=e[i].u)
#define pii pair<int,int> 
#define mp make_pair
#define fi first
#define se second
using std::map;
using std::set;
using std::vector;
using std::bitset;
using std::sqrt;
using std::pair;
const int maxn=1e6+5;
int n,s[maxn],f[maxn],ans,now;
struct robot {
	int x,l,s;
}a[maxn];
inline bool cmp(robot a,robot b) {
	return a.s<b.s;
}
int main() {
	scanf("%d",&n);
	rep(i,1,n) scanf("%d %d",&a[i].x,&a[i].l),a[i].s=a[i].x+a[i].l;
	std::sort(a+1,a+n+1,cmp);
    now=-intinf;
    rep(i,1,n) {
        if(now<=a[i].x-a[i].l) ans++,now=a[i].s;
    }
	printf("%d",ans);
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define mod 1000000007
#define pb push_back
#define ff first 
#define ss second  
typedef pair<ll,ll> pp;
bool com(pp x,pp y){
    return x.ff<y.ff;
} 
ll power(ll a,ll b){
    ll res=1;
    while(b){
        if(b&1){
            res=(a*res)%10;
        }
        a=(a*a);
        b/=2;
    }
    return res;
} 
void solve(){
    int x,y;
    cin>>x>>y;
    if(y%2||y>4*x||2*x>y){
        puts("No");
        return;
    }
    else{
        puts("Yes");
    }
}
int main() {
	// your code goes here
	//isprime();
	//prime(); 
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	//int t;
	//cin>>t;
	//while(t--) 
	    solve();
	return 0; 
	
}


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

char message[100] = {} ;
int maxvalue = 0 ;
char flag = 0;
int i = 0 , j = 0 ;
int main(){
  	std::cin >> maxvalue ;
  for(i = 0 ;  i < maxvalue ; i++ ){
	std::cin >> message[i] ;
 	}
  std::cin >> flag;
  if(flag != 0){
    flag = 1 ;
  	}
  for(j = 0 ;  j < i ; j++ ){
    if(message[j]){
  	std::cout << message[j] ;
    	}
    }
  if(flag == 1){
  	std::cout << "..." << std::endl;
    }
  std::cout << std::endl;
  }

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const long long INF = 1LL<<60;

ll GCD(ll x,ll y){
    if(y == 0) return x;
    else return GCD(y,x%y);
}

ll LCM(ll a,ll b){
    return a / GCD(a,b) * b;
}

const int MOD = 1000000007;


//void warshall_floyd(int n){
//    for(int k=0;k<n;k++){
//        for(int i=0;i<n;i++){
//            for(int j=0;j<n;j++){
//                d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
//            }
//        }
//    }
//}
//ll calc_digit(ll N) {
//    ll res = 0;
//    while (N) {
//        ++res;
//        N /= 10;
//    }
//    return res;
//}
//ll sum_digit(ll N) {
//    ll res = 0;
//    while (N) {
//        res += N % 10;
//        N /= 10;
//    }
//    return res;
//}

int main() {
    int n; cin >> n;
    vector<pair<int,int>> v;
    for(int i = 0;i < n;i++){
        int x,y; cin >> x >> y;
        v.push_back(make_pair(y,x));
    }
    sort(v.begin(),v.end());
    string ans = "Yes";
    ll sum = 0;
    for(int i = 0;i < n;i++){
        sum+=v[i].second;
        if(sum > v[i].first){
            ans = "No";
            break;
        }
    }
    cout << ans;
}




Measured memory_bytes: 5276
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1LL << 60;
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)

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

	int N;
	cin >> N;
	vector<string>S(N);
	for (int i = 0; i < N; i++)cin >> S[i];
	
	int ans = 0;
	for (int b = 0; b < N; b++) {
		int cnt = 0;
		vector<vector<char>>temp(N,vector<char>(N));
		for (int i = 0; i < N; i++)for (int j = 0; j < N; j++)temp[i][j] = S[i][(j+b)%N];
		for (int i = 0; i < N; i++)for (int j = 0; j < N; j++)if (temp[i][j] == temp[j][i])cnt++;
		if (cnt == N * N)ans += N;
	}
	puts(ans);

	return 0;
}

Measured memory_bytes: 512
using System; 
using System.Text; 
using System.Collections.Generic;
using System.Linq; 
using E = System.Linq.Enumerable; 

class Program {
     static long waru = 1000000007;
     static void Main(string[] args) {
     //入力を受け取る
     var NM  = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
     var N   = NM[0];
     var M   = NM[1];
     var SA  = Math.Abs(N-M);
     var ans = 0L;
     
     if(SA == 0){
        ans = 2*kaijo(N)*kaijo(M);
     }else if(SA == 1){
         ans = kaijo(N)*kaijo(M);
     }else{
         
     }
     
     Console.WriteLine(ans%waru);
     }
     
     static long kaijo(long num){
         long res =1;
         var count = 0;
        // Console.WriteLine(res);
         while(num != 1){
             res *= (num%waru);
             num--;
             res = res%waru;
         }
         
         return res%waru;
    　}
}
     
     
     
     
     


Measured memory_bytes: 13396
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<ios>//左右揃え
#include<iomanip>//setwで幅指定

using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define MOD 1000000007LL

int main(void) {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n - 1) {
        int b;
        cin >> b;
        a[b - 1]++;
    }
    rep(i, n) {
        cout << a[i] << endl;
    }
}

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

int main(){
  string s;
  cin>>s;
  
  if (s=="a" || s=="i" || s=="e" || s=="u" || s=="o"){
    cout<<"vowel"<<endl;
  }
  
  else{
    cout<<"consonant"<<endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin>>N;
  vector <int> vec(N);
  for (int i=0;i<N;i++){
    cin>>vec.at(i);
  }
  int count;
  count=1;
  for (int i=0;i<N;i++){
    int x;
    x=vec.at(0);
    if (vec.at(0)==2){
      cout<<count<<endl;
      break;
    }
    else{
      vec.at(0)=vec.at(x-1);
      count++;
    }
  }
  if(count==N+1)
    cout<<-1<<endl;
}
  
    
  

Measured memory_bytes: 768
#include<iostream>
#include<string>
#include<math.h>

using namespace std;

int main(){
  string s;
  cin >> s;
  int count = 0;
  for(int i=0; i<3; i++){
  if(s[i]=='1')++count;
  }
  cout << count;

return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define vi   vector<int>
#define vvi  vector<vi >
#define vvvi vector<vvi >
#define pii  pair<int,int>
#define INF  (int)1e9
#define MOD  (int)1e9+7
typedef long long llong;
using namespace std;

int main(){
	int n,m;
	cin>>n>>m;
	
	vvi v(m+1);
	REP(i,n){
		int a,b;
		cin>>a>>b;
		if(m-a>=0) v[m-a].push_back(b);
	}
	
	int ans=0;
	priority_queue<int> q;
	for(int i=m;i>=0;--i){
		REP(j,v[i].size()) q.push(v[i][j]);
		if(q.size()){
			ans+=q.top();
			q.pop();
		}
	}
	
	cout<<ans<<endl;
}//解答解説参考.

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

using namespace std;

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

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

#define N 100

char mp[N][N+1];

void calc(int a, int b){
  bool swapped = a<b;
  if(swapped)swap(a,b);
  // white is greater than black
  REP(i,N)REP(j,N)mp[i][j] = '.';
  REP(i,N)mp[i][0] = '#';
  int cnt = 1;
  REP(i,N)FOR(j,2,N)if(i%2==1 && j%2==0)mp[i][j] = '#', cnt++;
  REP(i,N)FOR(j,1,N-1)if(i%2==1 && j%2==1 && cnt>b)mp[i][j] = '#', cnt--;
  cnt = 1;
  REP(i,N)FOR(j,2,N)if(i%2==0 && j%2==0 && cnt<a)mp[i][j]='#', cnt++;

  if(swapped)REP(i,N)REP(j,N)mp[i][j] = mp[i][j]=='.' ? '#' : '.';
}

bool used[N][N];
int ddd[] = {1,0,-1,0,1};
void dfs(int i,int j){
  used[i][j] = true;
  REP(d,4){
    int ni = i + ddd[d];
    int nj = j + ddd[d+1];
    if(ni<0 || nj<0 || ni>=N || nj>=N)continue;
    if(used[ni][nj])continue;
    if(mp[ni][nj] != mp[i][j])continue;
    dfs(ni,nj);
  }
}

int main(){
  if(false){
    FOR(a,1,501){
      DEBUG(a);
      FOR(b,1,501){
        calc(a,b);
        REP(i,N)REP(j,N)used[i][j] = false;
        int aa = 0, bb = 0;
        REP(i,N)REP(j,N)if(!used[i][j]){
          if(mp[i][j]=='.')aa++;
          else bb++;
          dfs(i,j);
        }
        if(aa!=a || bb!=b){
          puts("ERROR!!!");
          DEBUG(a);
          DEBUG(aa);
          DEBUG(b);
          DEBUG(bb);
          REP(i,N)puts(mp[i]);
          return 0;
        }
      }
    }
  }else{
    int a,b;
    cin>>a>>b;
    calc(a,b);
    printf("%d %d\n",N,N);
    REP(i,N)puts(mp[i]);
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <string>
#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>

using namespace std;

// ---------------------
// repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

// debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

// ---------------------
#define INF 922337203685477580
#define IINF (1<<21)
typedef long long ll;

int main() {
  while (1) {
    int m, n;
    cin >> m >> n;
    if (m == 0 && n == 0) break;

    // int furui[9000000];
    // bool furui[4000000];
    vector<bool> furui(7368792, true);
    // REP(i, 4000000 * 2) {
    //   furui[i] = true;
    // }

    int base = m;
    for (int trial = 0; trial < n; trial++) {
      for (int t = 1; t * base < 7368792; t++) {
        furui[base * t] = false;
      }
      while (furui[base] == false) base++;
    }

    FOR(i, m, 7368792) {
      if (furui[i] == true) {
        cout << i << endl;
        break;
      }
    }
  }

  return 0;
}

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

int main(){
  long long  N;
  cin>>N;
  vector<long long> a(N),b(N);
  for(long long i=0;i<N;i++) cin>>a[i]>>b[i];
 
  using P = pair<long long,long long>;
  vector<P> vp;
  for(long long i=0;i<N;i++) vp.emplace_back(a[i]+b[i],i);
 
  sort(vp.rbegin(),vp.rend());
  long long ans=0;
  for(long long i=0;i<N;i++){
    if(i%2==0) ans+=a[vp[i].second];
    else ans-=b[vp[i].second];
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 4980
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

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

    if(t.substr(0,(int)s.size()) == s)yn;
    return 0;
}




Measured memory_bytes: 3624
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

bool used[202020];
int main(){
    multiset<ll> st;
    int n;
    cin>>n;
    int a[n];
    rep(i,n){
        cin>>a[i];
        st.insert(a[i]);
    }
    sort(a,a+n);
    reverse(a,a+n);
    int ans=0;
    rep(i,n){
        if(!st.count(a[i]))continue;
        auto itr=st.lower_bound(a[i]);
        st.erase(itr);
        ll c=1;
        while(c<=a[i])c*=2;
        ll x = c-a[i];
        itr = st.lower_bound(x);
        if(*itr==x){
            ++ans;
            st.erase(itr);
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 10496
#define _USE_MATH_DEFINES

#include <cmath>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <limits>
#include <cstring>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <bitset>

using namespace std;

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

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

class edge {
public:
    int from, to;
    ll cost;

    edge(int t, ll c) : from(-1), to(t), cost(c) {}

    edge(int f, int t, ll c) : from(f), to(t), cost(c) {}

    bool operator<(const edge &e) const {
        return cost < e.cost;
    }

    bool operator>(const edge &e) const {
        return cost > e.cost;
    }
};

const int Maxn = 100010;
const ll INF = (ll) 1e10;

vector<edge> g[Maxn];
ll dist[Maxn];

int n, m;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> m;
    for (int i = 0; i < m; ++i) {
        int l, r;
        ll d;
        cin >> l >> r >> d;
        l--, r--;
        g[l].emplace_back(r, d);
        g[r].emplace_back(l, -d);
    }
    fill(dist, dist + n, INF);
    for (int i = 0; i < n; ++i) {
        if (dist[i] == INF) {
            queue<int> que;
            que.push(i);
            dist[i] = 0;
            while (!que.empty()) {
                int p = que.front();
                que.pop();
                for(auto &v : g[p]){
                    if (dist[v.to] == INF){
                        dist[v.to] = dist[p] + v.cost;
                        que.push(v.to);
                    }else if (dist[v.to] != dist[p] + v.cost){
                        cout << "No" << endl;
                        return 0;
                    }
                }
            }
        }
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 13824
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> P;
typedef vector<vector<int>> Matrix;
static const int INF = 2000000000;



int main(){
  int x, a, b;
  cin >> x >> a >> b;
  int A = abs(x - a), B = abs(x - b);
  if (A > B) cout << "B\n";
  else cout << "A\n";
}

Measured memory_bytes: 256
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.io.PrintWriter;
import java.util.HashMap;
import java.util.Map;
import java.util.StringTokenizer;

public class Main {

	FastScanner in;
	PrintWriter out;

	void solve() {
		long a = in.nextLong();
		long b = in.nextLong();
		long gcd = gcd(a, b);

		out.println(getPrimeFactors(gcd).size() + 1);
	}

	long gcd(long a, long b) {
		if (b > a)
			return gcd(b, a);
		if (a % b == 0)
			return b;

		return gcd(b, a % b);
	}

	Map<Long, Integer> getPrimeFactors(long n) {
		Map<Long, Integer> primeFactors = new HashMap<>();
		long c = n;
		for (long i = 2; i * i <= n && c > 1; i++) {
			int count = 0;
			while (c % i == 0) {
				count++;
				c /= i;
			}
			if (count > 0) {
				primeFactors.put(i, count);
			}
		}
		if (c > 1) {
			primeFactors.put(c, 1);
		}
		return primeFactors;
	}

	void run() {
		try {
			in = new FastScanner(new File("Main.in"));
			out = new PrintWriter(new File("Main.out"));

			solve();

			out.close();
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		}
	}

	void runIO() {

		in = new FastScanner(System.in);
		out = new PrintWriter(System.out);

		solve();

		out.close();
	}

	class FastScanner {
		BufferedReader br;
		StringTokenizer st;

		public FastScanner(File f) {
			try {
				br = new BufferedReader(new FileReader(f));
			} catch (FileNotFoundException e) {
				e.printStackTrace();
			}
		}

		public FastScanner(InputStream f) {
			br = new BufferedReader(new InputStreamReader(f));
		}

		String next() {
			while (st == null || !st.hasMoreTokens()) {
				String s = null;
				try {
					s = br.readLine();
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (s == null)
					return null;
				st = new StringTokenizer(s);
			}
			return st.nextToken();
		}

		boolean hasMoreTokens() {
			while (st == null || !st.hasMoreTokens()) {
				String s = null;
				try {
					s = br.readLine();
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (s == null)
					return false;
				st = new StringTokenizer(s);
			}
			return true;
		}

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

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

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

	public static void main(String[] args) {
		new Main().runIO();
	}
}


Measured memory_bytes: 22996
#include <iostream> // cin, cout, cerr
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota
#include <cstdio> // printf, scanf
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <iomanip> // cout<<setprecision(n)
#include <functional> // function<void(int)>
#include <cmath>
#include <cassert>
#include <bitset>

#ifdef DEBUG
#include "debug.hpp"
#else
#define debug(...)
#endif

#define int long long // at least int64 > 9*10^18
#define EL '\n'
#define rep(i,n) for(int i = 0; i < (n); i++)
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()
/* libraries */

// ceil of a/b
inline int ceil(int a, int b) { return (a+b-1)/b; }



signed main() {
	int h,w;
	std::cin >> h >> w;
	if(h==1 || w==1) {
		print(1);
		return 0;
	}
	int sum = ((h/2)*2 * ((w/2)*2))/2;
	if(h%2) sum+=ceil(w,2);
	if(w%2) sum+=ceil(h,2);
	if(h%2==1 && w%2==1) sum--;
	print(sum);

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
int n,k;
cin>>n>>k;
int a[n];
for(int i=0;i<n;i++)
{
cin>>a[i];
}
int dp[k+1]={};
for(int i=0;i<=k;i++)
{
for(int o=0;o<n;o++)
{
if( i-a[o]>=0 && dp[i-a[o]]==0)
{
dp[i]=1;
}
}
}
cout<<((dp[k]==1) ? "First" : "Second")<<endl;
}


Measured memory_bytes: 640
#include <stdio.h>

int n; // データーセット数
int main(){
  int i;
  scanf("%d", &n);
  for(i = 0; i < n; i++){
    int y, m, d; // 入力で与えられる日付(y年m月d日)
    int answer = 0; // ミレニアム記念日までの日数
    scanf("%d %d %d", &y, &m, &d);
    while(y != 1000){ // ミレニアム記念日に到達するまで次の日に進める．
      int month; // y年m月は何日あるか
      if(y % 3 == 0 || m % 2 == 1){
        month = 20;
      }else{
        month = 19;
      }
      if(d < month){
        d = d + 1;
      }else if(m < 10){
        d = 1;
        m = m + 1;
      }else{
        d = 1;
        m = 1;
        y = y + 1;
      }
      answer++;
    }
    printf("%d\n", answer);
  }
  return 0;
}

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

int main() {
  int n,m;
  cin>>n>>m;
  char a[n][n],b[m][m];
  
  for(int i=0;i<n;i++)
    for(int j=0;j<n;j++)
      cin>>a[i][j];
  for(int i=0;i<m;i++)
    for(int j=0;j<m;j++)
      cin>>b[i][j];

  bool exist=false;

  for(int i=0;i<n-m+1;i++){
    for(int t=0;t<n-m+1;t++){
      bool ans=true;
      for(int j=0;j<m;j++){
        for(int k=0;k<m;k++){
          if(a[i+j][t+k]!=b[j][k])
            ans=false;
        }
      }
        if(ans) exist=true;
    }
  }

  
  if(exist)
    cout<<"Yes";
  else cout<<"No";
        
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}


signed main() {
    int N, M;
    cin >> N >> M;
    V(P) ab(N), cd(M);
    rep(i, N) {
        cin >> ab[i].fi >> ab[i].se;
    }
    rep(i, M) {
        cin >> cd[i].fi >> cd[i].se;
    }

    vi res(N);
    rep(i, N) {
        int temp = 1e18;
        int mi = -1;
        rep(j, M) {
            if(abs(ab[i].fi-cd[j].fi)+abs(ab[i].se-cd[j].se) < temp) {
                mi = j + 1;
                temp = abs(ab[i].fi-cd[j].fi)+abs(ab[i].se-cd[j].se);
            }
        }
        res[i] = mi;
    }

    rep(i, N) cout << res[i] << endl;
    
    return 0;
}

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

using namespace std;
using LL = long long;
using P = pair<int, int>;

#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e19;
const int MOD = 1e9 + 7;

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

    int h, w, hh, ww;
    cin >> h >> w >> hh >> ww;

    cout << (h - hh) * (w - ww) << endl;

}

Measured memory_bytes: 256
# coding: utf-8

# https://atcoder.jp/contests/abc086/tasks/arc089_a
# 12:38-12:53


def main():
    N = int(input())
    t, x, y = [None] * N, [None] * N, [None] * N
    for i in range(N):
        t[i], x[i], y[i] = map(int, input().split())

    for i in range(N):
        if i == 0:
            root = abs(x[i]) + abs(y[i])
            if root > t[i] or (t[i] - root) % 2 > 0:
                return "No"

            continue

        root = abs(x[i] - x[i-1]) + abs(y[i] - y[i-1])
        if root > t[i] - t[i-1] or (t[i] - t[i-1] - root) % 2 > 0:
            return "No"

    return "Yes"


print(main())


Measured memory_bytes: 11636
#include<stdio.h>
#include<limits.h>

#define MAX 2000000000

typedef struct{

  int x;

  char c;

}card;

int Partition(int, int);
void Quicksort(int, int);
void merge(int, int, int,card[]);
void mergeSort(int, int, card[]);

card B[100000];

int main(){

  int i, p, n;

  char c;

  card C[100000];

  scanf("%d%c", &n, &c);
 
  for(i=0;i<n;i++){

    scanf("%c%d%c", &C[i].c, &C[i].x, &c);

    B[i] = C[i];

  }
 
  p = 0;

  mergeSort(0, n, C);

  Quicksort(0, n-1);

  for(i = 0; i < n; i++){

    if(C[i].c != B[i].c){

      printf("Not stable\n");

      break;
    }

    if(i == (n - 1))
      printf("Stable\n");

  }
 
  for(i=0;i<n;i++){

    printf("%c %d\n", B[i].c, B[i].x);

    }
 
  return 0;

}

 
int Partition(int p, int r){

  card tmp;

  int x, i, j;

  x = B[r].x;

  i = p - 1;

  for(j = p; j < r; j++){

    if (B[j].x <= x){

      i++;

      tmp = B[i];

      B[i] = B[j];
      
      B[j] = tmp;
      
    }
    
  }
 
  tmp = B[i + 1];
  
  B[i + 1] = B[r];
  
  B[r] = tmp;

  return (i + 1);

}
 
void Quicksort(int p, int r){

  int q;

  if(p < r){

     q = Partition(p, r);

     Quicksort(p, q-1);

     Quicksort(q+1, r);

  }
  
}
 
void merge(int left,int mid,int right,card A[]){

  int i, j, k;

  int n1 = mid - left;

  int n2 = right - mid;

  card L[100001],R[100001];
 
  for(i = 0;i<n1;i++){

    L[i] = A[left + i];

  }
 
  for(i = 0; i < n2; i++){
    
    R[i]=A[mid+i];

  }
   
  L[n1].x = MAX;
  
  R[n2].x = MAX;
  
  i = 0;

  j = 0;

  for(k = left; k < right; k++){

    if(L[i].x <= R[j].x)
      A[k]=L[i++];
    else
      A[k]=R[j++];

  }
   
}

void mergeSort(int left, int right, card A[]){
  
  if((left + 1) < right){

    int mid = (left + right) / 2;
    
    mergeSort(left, mid, A);
    
    mergeSort(mid, right, A);
    
    merge(left, mid, right, A);
  
  }

}

Measured memory_bytes: 2956
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, a, b) for(int i = a, i##_len = (b); i < i##_len; ++i)

int main()
{
    int N;
    string S;
    cin >> N >> S;
    REP(i, 0, S.size()) S[i] = (char)((int)(S[i] - 'A' + N)%26 + 'A');
    cout << S << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair <int,int> PAIR;
const int N = 1e4+5;
const int M = 1e4;
const int INF = 0x3f3f3f3f;

struct node{
	int A,B,C,D;
} p[55];
int n,m,q,ans,a[15];

inline int cal(){
	int res = 0;
	for(int i = 1;i <= q;++i){
		if(a[p[i].B] - a[p[i].A] == p[i].C)
			res += p[i].D;
	}
	return res;
}

inline void dfs(int now,int st){
	if(now > n){
		ans = max(ans,cal());
		return ;
	}
	
	for(int i = st;i <= m;++i){
		a[now] = i;
		dfs(now+1,i);
	}
	return ;
}

int main() {
	scanf("%d%d%d",&n,&m,&q);
	for(int i = 1;i <= q;++i)
		scanf("%d%d%d%d",&p[i].A,&p[i].B,&p[i].C,&p[i].D);
	
	ans = 0;
	dfs(1,1);
	printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 3792
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define showmap(is, js, x) {rep(i, is){rep(j, js){cout << x[i][j] << " ";}cout << endl;}}
#define show(x) {for(auto i: x){cout << i << " ";} cout<<endl;}
#define showm(m) {for(auto i: m){cout << m.x << " ";} cout<<endl;}
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> llP;
ll gcd(int x, int y){ return y?gcd(y, x%y):x;}
ll lcm(ll x, ll y){ return (x*y)/gcd(x,y);}


int main()
{
    int n;
    cin >> n;
    if (n >= 30) cout << "Yes" << endl;
    else cout << "No" << endl;

}



Measured memory_bytes: 3624
N,K=map(int,input().split())
mod=10**9+7
Sum=0
for i in range(K,N+2):
    Min=i*(i-1)/2
    Max=N*(N+1)/2-(N-i)*(N-i+1)/2
    Dif=(Max-Min+1)%mod
    Sum=(Sum+int(Dif))%mod
    
print(Sum)

Measured memory_bytes: 67824
n=int(input())
dp=[0 for i in range(n+1)]
dp[0]=1
x=(n-1)**2
dp[1]=n
pref=dp[1]
mod=10**9+7
x%=mod
for i in range(2,n+1):
    dp[i]+=x+pref-dp[i-2]+(n-i+2)
    pref+=dp[i]
    pref%=mod
    dp[i]%=mod
        
print(dp[-1])
    

Measured memory_bytes: 114160
#include<stdio.h>
int main(){
  int a,b;
  char op[101];
  scanf("%d" "%s" "%d",&a,op,&b);
  if(op[0] == '+'){
    printf("%d\n",a+b);
  }else{
    printf("%d\n",a-b);
  }
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll a[200009];
ll b[200009];
ll tree[800009];
void upd(int node,int l,int r,int k,ll val){
	if(l == r){
		tree[node] = val;
		return;
	}
	if(k <= (l+r)/2) 
		upd(node*2,l,(l+r)/2,k,val);
	else 
		upd(node*2+1,(l+r)/2+1,r,k,val);
	tree[node] = max(tree[node*2],tree[node*2+1]);
}
ll query(int node,int l,int r,int s,int e){
	if(s <= l && e >= r)
		return tree[node];
	if(s <= (l+r)/2 && e >= (l+r)/2+1){
		return max(query(node*2,l,(l+r)/2,s,e),query(node*2+1,(l+r)/2+1,r,s,e));
	}
	if(s <= (l+r)/2) 
		return query(node*2,l,(l+r)/2,s,e);
	return query(node*2+1,(l+r)/2+1,r,s,e);
}
int main(){
	int n; cin>>n;
	for(int i=0;i<n;i++)
		cin>>a[i];
	for(int i=0;i<n;i++) 
		cin>>b[i];
	for(int i=0;i<n;i++){
		ll id = a[i],val = b[i];
		ll x = query(1,0,n,0,id-1);
		upd(1,0,n,id,x+val);
	}
	cout<<tree[1]<<endl;
}

Measured memory_bytes: 9600
#include <iostream>
#include<bits/stdc++.h>
 using namespace std;
  
 int main()
 {
      int a,b;
      while(cin>>a>>b){
          if((a*b)%2==0) cout<<"Even"<<endl;
          else cout<<"Odd"<<endl;
     }
     return 0;
 }

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

#define PI 3.14159265359
/*
*/

int main() {
	int N,M;
	cin >> N >> M;
	vector<int> A(M);
	rep (i,M) {
		cin >> A[i];
	}
	int count = 0;
	rep (i,M) {
		count += A[i];
	}
	if (count > N) cout << -1 << endl;
	else cout << N - count << endl;

}


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

using namespace std;

void search(int n) {
	int *a, *b;
	bool *unused;
	a = new int[n];//??????
	b = new int[n];//?????£???
	unused = new bool[n];
	int Num = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i] >> b[i];
		Num += a[i];
		unused[i] = true;
	}

	for (int i = 0; i < n; i++) {
		int max = 0;
		int maxNum = 0;
		int maxVal = 0;
		for (int j = 0; j < n; j++) {
			if (unused[j]) {
				if (max < b[j]) {
					max = b[j];
					maxNum = j;
					maxVal = a[j];
				}
			}
		}
		if (b[maxNum] < Num) {
			cout << "No" << endl;
			return;
		}
		unused[maxNum] = false;
		Num -= maxVal;
	}
	cout << "Yes" << endl;

	return;
}

int main() {
	vector<int> n;
	int a;
	int i = 0;
	for (;;) {
		cin >> a;
		n.push_back(a);
		if (n[i] == 0)
			break;
		search(n[i]);
		i++;
	}

	return 0;
}

Measured memory_bytes: 3084
#include<iostream>
#include<string>
#include<vector>
#include<algorithm> 
#include<functional> 
#include<cassert>
#include<numeric> // std::accumulate(vec.begin(),vec.end(),0) sum of element
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<queue>
#include<map>
#include<set>


using namespace std;


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


#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define all(c) c.begin(),c.end()
#define show(x) cout << #x << " = " << x << endl

#define fi first
#define se second
#define pb push_back



#define DEBUG


// void print_vector(const std::vector<int> &t);
// void unique_vector(std:: vector<int> &t);

template <class X>
void print_vector(const std::vector<X> &t);
template <class X>
void unique_vector(std:: vector<X> &t);


int w, h;

vector<int> xl={-1, 0, 1, 0};
vector<int> yl={0, 1, 0, -1};

int main(){

  vi ans;
  while(true){
    cin >> w >> h;
    if(w == 0 && h == 0) break;
    vector<vector<char>> f(h, vector<char>(w));
    queue<P> ser;
    for(int i = 0; i < h; i++){
      for(int j = 0; j < w; j++) {
	cin >> f[i][j];
	if(f[i][j] == '@')
	  ser.push(make_pair(i, j));
      }
    }
    int c = 0;
    while(!ser.empty()){
      P t = ser.front();
      ser.pop();
      int y = t.fi, x = t.se;
      // show(x); show(y);
      if(f[y][x] == '@') f[y][x] = '#';
      for(int i = 0; i < 4; i++) {
	int dx = x+xl[i], dy=y+yl[i];
	// cout << dx << ' ' << dy << endl;
	// show(dx); show(dy);
	if(dy < 0 || dy >= h || dx < 0 || dx >= w || f[dy][dx] == '#')
	  continue;
	
	if(f[dy][dx] == '.'){
	  c++;
	  ser.push(make_pair(dy, dx));
	  f[dy][dx] = '#';
	}
      }	
      // for(int i = 0; i < h; i++) {
      // 	for(int j = 0; j < w; j++) {
      // 	  cout << f[i][j] << ' ';
      // 	}
      // 	cout << endl;
      // }
      // cout << endl;
    }
    ans.pb(c+1);
  }
  for(auto &i : ans) cout << i << endl;
}

template <class X>
void unique_vector(std::vector<X> &t)
{
  std::sort(t.begin(), t.end());
  t.erase( std::unique(t.begin(), t.end()), t.end() );
}

template <class X>
void print_vector(const std::vector<X> &t){
  for(auto itr=t.begin(); itr != t.end(); itr++){
    std::cout << *itr;
    if(itr != t.end()-1) std::cout << ' ';
  }
  std::cout << std::endl;
}

Measured memory_bytes: 3104
import java.util.*;

class Main{

	static int mod=1000000007;

	public static void main(String[] $){
		System.err.println();
		Scanner s=new Scanner(System.in);

		int n=s.nextInt(),k=s.nextInt();

		ArrayList<HashSet<Integer>> g=new ArrayList<>();

		for(int i=0;i<n;++i){
			g.add(new HashSet<>(1));
		}
		for(int i=0;i<n-1;++i){
			int a=s.nextInt()-1,b=s.nextInt()-1;
			g.get(a).add(b);
			g.get(b).add(a);
		}

		//System.err.println(g);
		long r=f(0,k,g,0,-1);
		System.out.println(r*k%mod);
		System.err.println(r);
	}

	private static long f(int i,int k,ArrayList<HashSet<Integer>> g,int brother,int parent){
		HashSet<Integer> h=g.get(i);
		long r=1;

		//child pattern
		{
			int c=k-(parent==-1?1:2);
			int child=h.size()-(parent==-1?0:1);
			for(int l=0;l<child;++l){
				r*=c-l;
				r%=mod;
			}
		}

		//reduction
		for(int j:h){
			if(j==parent)
				continue;
			HashSet<Integer> h2=g.get(j);
			r*=f(j,k,g,h.size(),i);
			r%=mod;
		}
		return r;
	}
}


Measured memory_bytes: 126976
#include <unordered_set>
#include <iostream>
#include <vector>

int getRemainingNumber(const std::vector<int> &numbers) {
  std::unordered_set<int> remaining_numbers;
  for (const auto &number : numbers) {
    auto it = remaining_numbers.find(number);
    if (it == remaining_numbers.end()) {    
      remaining_numbers.insert(number);
    } else {
      remaining_numbers.erase(number);   
    }
  }
  return static_cast<int>(remaining_numbers.size());
}

int main() {
  int n;
  std::cin >> n;
  std::vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    std::cin >> a[i];
  }
  std::cout << getRemainingNumber(a) << std::endl;
  return 0;
}


Measured memory_bytes: 4772
// Problem : F - Distributing Integers
// Contest : AtCoder Beginner Contest 160
// URL : https://atcoder.jp/contests/abc160/tasks/abc160_f
// Memory Limit : 1024 MB
// Time Limit : 3000 ms
// Powered by CP Editor (https://github.com/coder3101/cp-editor)

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

#ifdef LOCAL
#define DEBUG(...) cerr << #__VA_ARGS__ << ": ", debug(__VA_ARGS__);
#else
#define DEBUG(...)
#endif

template<typename T, typename S> ostream& operator << (ostream &os, const pair<T, S> &p) {return os << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator << (ostream &os, const vector<T> &v) {os << "["; for (int i=0; i<(int)v.size(); i++) {if (i) os << ", "; os << v[i];} return os << "]";}
void debug() {cerr << "\n";} template<typename T, typename... Args> void debug(T x, Args... args) {cerr << x << "; "; debug(args...);}

#define MOD 1000000007

int inverse(long long a) {
    int ret = 1, b = MOD - 2;
    while (b > 0) {
        if (b & 1)
            ret = (ret * a) % MOD;
        a = (a * a) % MOD;
        b >>= 1;
    }
    return ret;
}

int dp[200000], sub[200000], fact[200000], inv[200000], ret[200000];
vector<int> adj[200000];

void dfsDP(int u, int p) {
    sub[u] = 1;
    for (int v : adj[u])
        if (v != p) {
            dfsDP(v, u);
            sub[u] += sub[v];
        }
    
    dp[u] = fact[sub[u]-1];
    for (int v : adj[u])
        if (v != p)
            dp[u] = (long long) dp[u] * dp[v] % MOD * inv[sub[v]] % MOD;
}

void dfsReroot(int u, int p) {
    ret[u] = dp[u];
    for (int v : adj[u])
        if (v != p) {
            dp[u] = (long long) dp[u] * inv[sub[u]-1] % MOD * inverse(dp[v]) % MOD * fact[sub[v]] % MOD;
            sub[u] -= sub[v];
            dp[u] = (long long) dp[u] * fact[sub[u]-1] % MOD;
            dp[v] = (long long) dp[v] * inv[sub[v]-1] % MOD;
            sub[v] += sub[u];
            dp[v] = (long long) dp[v] * fact[sub[v]-1] % MOD * dp[u] % MOD * inv[sub[u]] % MOD;
            
            dfsReroot(v, u);
            
            dp[v] = (long long) dp[v] * inv[sub[v]-1] % MOD * inverse(dp[u]) % MOD * fact[sub[u]] % MOD;
            sub[v] -= sub[u];
            dp[v] = (long long) dp[v] * fact[sub[v]-1] % MOD;
            dp[u] = (long long) dp[u] * inv[sub[u]-1] % MOD;
            sub[u] += sub[v];
            dp[u] = (long long) dp[u] * fact[sub[u]-1] % MOD * dp[v] % MOD * inv[sub[v]] % MOD;
        }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    
    int n;
    cin >> n;
    for (int i=0; i<n-1; i++) {
        int a, b;
        cin >> a >> b;
        adj[a-1].push_back(b-1);
        adj[b-1].push_back(a-1);
    }
    
    fact[0] = inv[0] = 1;
    for (int i=1; i<n; i++) {
        fact[i] = (long long) fact[i-1] * i % MOD;
        inv[i] = inverse(fact[i]);
    }
    
    dfsDP(0, -1);
    dfsReroot(0, -1);
    
    for (int i=0; i<n; i++)
        cout << ret[i] << "\n";

    return 0;
}


Measured memory_bytes: 17908
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#include <set>
#include <map>
#include <deque>
#include <cmath>
#include <queue>
#include <random>
#include <bitset>
#include <time.h>
#include <string>
#include <cstdio>
#include <vector>
#include <cstdlib>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
//++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++
//#define endl '\n'
#define mp make_pair
#define pbc push_back
#define pob pop_back()
#define empb emplace_back
#define sp system("pause")
#define queuel queue<long long>
#define all(x) (x).begin(),(x).end()
#define matrix vector<vector<ll>>
#define pin(p) cin >> p.first >> p.second;
#define rev(v) reverse(v.begin(),v.end());
#define mx(v) max_element(v.begin(), v.end());
#define mn(v) min_element(v.begin(), v.end());
#define sout(s, c) for(auto i : s) cout << i << c;
#define pout(p) cout << p.first << " " << p.second;
#define er(v, l, r) erase(v.begin() + l, v.begin() + r);
#define vin(v) for(ll i = 0; i < v.size(); ++i) cin >> v[i];
#define vout(v, c) for(int i = 0; i < v.size(); ++i) cout << v[i] << c;
#define pushi(v, a) for(int i = 0; i < a.size(); ++i) v.push_back(a[i]);
#define sin(s, n) for(int i = 0; i < n; ++i){int a; cin >> a; s.insert(a);}
#define fastio() ios_base::sync_with_stdio(0);cout.tie(0);cin.tie(0);srand(time(NULL));
//++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++
using namespace std;
//++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
//++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++
const ll INF = 1000LL * 1000 * 1000 * 1000 * 1000 * 1000;
const int inf = 1000 * 1000 * 1000;
const ld PI = acos(-1.0);
const ll mod1 = inf + 7;
const ll mod2 = inf + 9;
const int MAXN = 500001;
const ld EPS = 1e-9;
int hp = 179;

signed main()
{
	fastio();
	int n;
	cin >> n;
	if (n > 999)
	{
		cout << "ABD";
	}
	else
	{
		cout << "ABC";
	}
	sp;
}

Measured memory_bytes: 504
//satyaki3794
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define MOD (1000000007LL)
#define LEFT(n) (2*(n))
#define RIGHT(n) (2*(n)+1)
 
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
 
ll pwr(ll base, ll p, ll mod=MOD){
ll ans = 1;while(p){if(p&1)ans=(ans*base)%mod;base=(base*base)%mod;p/=2;}return ans;
}
 
 
ll gcd(ll a, ll b){
    if(b == 0)  return a;
    return gcd(b, a%b);
}


const int N = 200002;
int n, arr[N], cnt[N], balls[N];


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

	int q;
	scanf("%d%d", &n, &q);
	for(int i=1;i<=n;i++){
		int a;
		scanf("%d", &a);
		balls[i] = a;
		cnt[a]++;
	}
    
	for(int i=1;i<=n;i++){
		arr[max(0, i-cnt[i]+1)]++;
		arr[i+1]--;
	}

	int uncovered = 0;
	for(int i=1;i<=n;i++){
		arr[i] += arr[i-1];
		uncovered += (arr[i] == 0);
	}

// cout<<uncovered<<endl;
// for(int i=1;i<=n;i++)	cout<<arr[i]<<" ";cout<<endl;

// q=1;
	while(q--){
	
		int a, b;
		scanf("%d%d", &a, &b);

		if(balls[a] == b){
			printf("%d\n", uncovered);
			continue;
		}


		int z = a;
		a = balls[a];

		if(a-cnt[a]+1 > 0){
			arr[a-cnt[a]+1]--;
			if(arr[a-cnt[a]+1] == 0)	uncovered++;
		}
// cout<<ans<<endl;
		if(b-cnt[b] > 0){
			arr[b-cnt[b]]++;
			if(arr[b-cnt[b]] == 1)	uncovered--;
		}

		balls[z] = b;
		cnt[a]--;	cnt[b]++;

// for(int i=1;i<=n;i++)	cout<<balls[i]<<" ";cout<<endl;
// for(int i=1;i<=n;i++)	cout<<cnt[i]<<" ";cout<<endl;

		printf("%d\n", uncovered);
	}

    return 0;
}






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

int main() {
    long N, K;
    cin>>N>>K;
    long ans = 0;
    for(long b=K+1;b<=N;++b){
        ans += N/b*(b-K);
        if((N%b)-(K-1) > 0) ans += (N%b) - (K-1);
    }
    if(K==0)ans -= N-K;
    cout<<ans<<endl;
}


Measured memory_bytes: 256