akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef long double ld;
//typedef tree<int,null_type,less<int >,rb_tree_tag,tree_order_statistics_node_update>indexed_set;
template<class T1, class T2>
ostream &operator <<(ostream &os, pair<T1,T2>&p);
template <class T>
ostream &operator <<(ostream &os, vector<T>&v);
template <class T>
ostream &operator <<(ostream &os, set<T>&v);
template <class T1, class T2>
ostream &operator <<(ostream &os, map<T1,T2>&v);
#ifndef ONLINE_JUDGE
#define debug(a) cout<<#a<<" --> "<<(a)<<"\n";
#define debug2(a) cout<<#a<<" --> "<<(a)<<" ";
#define HERE cout<<"here - "<<__LINE__<<"\n";
#else
#define debug(a)
#define debug2(a)
#define HERE
#endif
const ll mod = 998244353  ;
const int N = 1e5+2;


void TEST_CASES(int cas)
{
    vector<int>a(5);
    int ans = -1;
    for(int i=0;i<5;i++)
    {
        scanf("%d",&a[i]);
        if(a[i]==0)
            ans = i+1;
    }
    printf("%d\n",ans);


}


/*

*/

int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int t=1,cas=0;
    //scanf("%d",&t);
    while(t--)
    {
        TEST_CASES(++cas);
    }

    return 0;
}



//os.order_of_key(v): returns how many elements strictly less than v
//os.find_by_order()

template<class T1, class T2>
ostream &operator <<(ostream &os, pair<T1,T2>&p)
{
    os<<"{"<<p.first<<", "<<p.second<<"} ";
    return os;
}
template <class T>
ostream &operator <<(ostream &os, vector<T>&v)
{
    os<<"[ ";
    for(int i=0; i<v.size(); i++)
    {
        os<<v[i]<<" " ;
    }
    os<<" ]";
    return os;
}

template <class T>
ostream &operator <<(ostream &os, set<T>&v)
{
    os<<"[ ";
    for(T i:v)
    {
        os<<i<<" ";
    }
    os<<" ]";
    return os;
}
template <class T1, class T2>
ostream &operator <<(ostream &os, map<T1,T2>&v)
{
    for(auto i:v)
    {
        os<<"Key : "<<i.first<<" , Value : "<<i.second<<endl;
    }
    return os;
}


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

using namespace std;

#define fori(x) for (int i = 0; i < x; ++i)
#define forj(x) for (int j = 0; j < x; ++j)

typedef long long ll;

const int INF = 2e9 + 5;
const int alength=100100;

int main() {
	int n;map<int,int> a;
	cin>>n;
	fori(n){
		int hoge;
		cin>>hoge;
		a[hoge]=i;
	}
	for(auto x:a){
		cout<<x.second+1<<" ";
	}
}

Measured memory_bytes: 8284
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int a, b;
  cin >> a >> b;
  if(a <= 8 && b <= 8) cout << "Yay!" << endl;
  else cout << ":(" << endl;
  return 0;
}

Measured memory_bytes: 3588
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
typedef vector<vector<P>> vvP;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e6;
const ll MAX_N = 1e9;



int main() {
    ll n, m;
    cin >> n >> m;

    vl a(n);
    rep(i, n) {
        cin >> a[i];
    }
    sort(rall(a));
    
    // 判定問題「xを買うことができるか？」を二分探索で解く
    ll left = 0;
    ll right = INF;
    while(right - left > 1) {
        ll mid = (left + right)/2;
        ll x = mid;
        ll u = 0;
        ll j = n-1;
        rep(i, n) {
            while(j >= 0 && a[i] + a[j] < x) {
                j--;
            }
            u += j+1;
        }
        if(u >= m) {
            left = mid;
        }
        else {
            right = mid;
        }
    }

    vl rui(n+1);
    rep(i, n) {
        rui[i+1] = rui[i] + a[i];
    }

    ll c = 0;
    ll ans = 0;
    ll j = n-1;
    rep(i, n) {
        while(j >= 0 && a[i] + a[j] < left) {
            j--;
        }
        ans += (j+1)*a[i] + rui[j+1];
        c += j+1;
    }

    ans -= (c - m)*left;

    out(ans);
    re0;
}

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

int main() {
  int n, k;
  cin >> n >> k;
  priority_queue <int> pq;
  
  for (int i = 0; i < n; i++) {
    int64_t h;
    cin >> h;
    pq.push(h);
  }
  
  for (int i = 0; i < k; i++) {
    pq.pop();
    if (pq.empty()) {
      break;
    }
  }
  
  int64_t ans = 0;
  while (!pq.empty()) {
    ans += pq.top();
    pq.pop();
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 1400
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
using namespace std;
#define rep(i,n) for(i=0;i<n;i++)
#define repl(k,n) for(k=0;k<n;++k)

int main() {
	long long N,D;
	int count=0;
	cin >> N >> D;
	vector<long long> X(N);
	vector<long long> Y(N);
	int i;
	rep(i, N) {
		cin >> X[i] >> Y[i];
		if ((X[i] * X[i] + Y[i] * Y[i]) <= (D*D))count=count+1;
	}
	cout << count;
	return 0;
}

Measured memory_bytes: 6344
import sys
import heapq
input = sys.stdin.readline

def solve():
    N, M = map(int, input().split())
    jobs = [[] for _ in range(M)]
    for i in range(N):
        a, b = map(int, input().split())
        if a - 1 < M:
            jobs[a-1].append(-b)
    
    ans = 0
    hq = []
    for i in range(M):
        for job in jobs[i]:
            heapq.heappush(hq, job)
        if len(hq) > 0:
            ans += -heapq.heappop(hq)
    
    print(ans)

if __name__ == '__main__':
    solve()

Measured memory_bytes: 17604
#include <bits/stdc++.h>
#include <vector>
using namespace std;
int x, y;
int main(){
	while(cin >> x >> y){
		if(x == 0 && y == 0){
			break;
		}
		if(x < y){
			cout << x << " " << y << endl;
		}
		else{
			cout << y << " " << x << endl;
		}
	}
	return 0;
}

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

const ll MAX = 1000000007;


vector<ll> dp(100000 + 1);

// ll rec(ll i) {
//   if(dp[i] == -1) return 0;
//   else if (dp[i]) return dp[i];
//   else {
//     dp[i] = (rec(i-1) + rec(i-2)) % MAX;
//     return dp[i];
//   }
// }

void solve() {
  ll n, m;
  cin >> n >> m;
  dp.resize(n+1);

  vector<bool> broken(n+1);
  rep(i, m) {
    int a;
    cin >> a;
    broken[a] = true;
  }
  
  dp[0] = 1;
  dp[1] = 1;
  if(broken[1]) dp[1] = 0;
  
  for(int i = 2; i <= n; i++) {
    if(broken[i]) dp[i] = 0;
    else dp[i] = (dp[i-1] + dp[i-2]) % MAX;
  }
  cout << dp[n] << endl;
}

int main() {
  solve();
  return 0;
}

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

int main(void){
  int n;
  int a=0,b=0,o=0,ab=0;
  char bl[3];
  while(scanf("%d,%s",&n,bl)!=EOF){
    //printf("%d\n",n);
    //printf("%s\n",bl);
    if(strcmp(bl,"A")==0){
      a++;
    }else if(strcmp(bl,"B")==0){
      b++;
    }else if(strcmp(bl,"O")==0){
      o++;
    }else if(strcmp(bl,"AB")==0){
      ab++;
    }
  }
  printf("%d\n",a);
  printf("%d\n",b);
  printf("%d\n",ab);
  printf("%d\n",o);
  return 0;
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
using namespace std;
int n, i;
pair<int, int> a[100000];
int main()
{
	cin>>n;
	for(i=0; i<n; i++)
	{
		cin>>a[i].first;
		a[i].second=(i+1);
	}
	sort(a, a+n);
	for(i=0; i<n; i++)
	{
		cout<<a[i].second<<' ';
	}
	return 0;
}


Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int k,a[5];
  for(int i=0;i<5;i++) cin>>a[i];
  cin>>k;
  sort(a,a+5);
  for(int i=0;i<=3;i++)
  {
    for(int j=i+1;j<=4;j++)
    {
      if(a[j]-a[i]>k) {cout<<":(";return 0;}
    }
  }
  cout<<"Yay!";
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cstdlib>
#include<queue>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)

int main(){
    int n;
    cin >> n;
    double a[n];
    rep(i, n) cin >> a[i];
    double ans = 0;
    rep(i, n) ans += 1/ a[i];
    cout << 1 / ans << endl;
}


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

using namespace std;
#define rep(i, n) for(int i = 0 ; i < (int)(n) ; i++)
typedef long long ll;
typedef long double Double;

#ifndef INPUTS_DIR
#define INPUTS_DIR "./"
#endif


ll solve(vector<ll> x, ll C, vector<ll> v) {
    vector<ll> maximumCost;
    maximumCost.push_back(0);
    {
        ll sm = 0;
        for (int i = x.size() - 1; i >= 0; i--) {
            sm += v[i];
            maximumCost.push_back(sm - (C - x[i]) * 2);
        }
    }
    for (int i = 1; i < maximumCost.size(); i++) {
        maximumCost[i] = max(maximumCost[i], maximumCost[i - 1]);
    }


    ll sum = 0;
    ll ans = maximumCost[x.size()];
    for (int i = 0; i < x.size(); i++) {
        sum += v[i];
        ans = max(ans, sum - x[i] + maximumCost[x.size() - i - 1]);
    }
    return ans;
}


void solve(ll N, ll C, vector<ll> x, vector<ll> v) {
    ll ans1 = solve(x, C, v);
    reverse(x.begin(), x.end());
    reverse(v.begin(), v.end());
    for (auto &&i : x)
        i = C - i;
    ll ans2 = solve(x, C, v);
    cout << max(ans1, ans2) << endl;
}


void main_(istream &cin) {
    ll N;
    ll C;
    cin >> N;
    vector<ll> v(N - 1 + 1);
    vector<ll> x(N - 1 + 1);
    cin >> C;
    for (int i = 0; i <= N - 1; i++) {
        cin >> x[i];
        cin >> v[i];
    }
    solve(N, C, x, v);
}

int main() {
#ifdef INTELLIJ
    ifstream ifs(string(INPUTS_DIR) + "in_1.txt");
    if (ifs.is_open()) {
        main_(ifs);
        ifs.close();
    } else {
        cerr << "Error: no input." << endl;
    }
#else
    ios::sync_with_stdio(false);
    cin.tie(0);
    main_(cin);
#endif
}





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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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; }

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

const int INF = 1e9;

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin>>N;
    vi a(N),b(N);
    rep(i,N) cin>>a[i];
    rep(i,N) cin>>b[i];
    int ans=INF;
    rep(S,1<<N){
        vector<pi> vec;
        int sum=0;
        rep(i,N){
            if(S>>i&1) vec.pb({b[i],0});
            else vec.pb({a[i],0});
        }
        // cerr<<"Before: ";
        // rep(i,N) cerr<<vec[i].fi<<" "; cerr<<endl;

        vi indices(N);
        rep(i,N) indices[i]=i;
        bool upd=true;
        while(upd){
            upd=false;
            rep(i,N-1)if(vec[i].fi>vec[i+1].fi){
                swap(vec[i],vec[i+1]);
                swap(indices[i],indices[i+1]);
                vec[i].se++; vec[i+1].se++;
                sum++;
                upd=true;
            }
        }
        rep(i,N) vec[i].se%=2;
        // cerr<<"After: ";
        // rep(i,N) cerr<<"("<<vec[i].fi<<","<<vec[i].se<<") "; cerr<<endl;
        // cerr<<"Mid: "<<sum<<endl;
        vector<vi> row(51);
        rep(i,N){
            if ((S>>indices[i]&1)==vec[i].se)
                row[vec[i].fi].pb(0);
            else
                row[vec[i].fi].pb(1);
        }
        for(auto r:row){
            vi even;
            int R = r.size();
            rep(i,R){
                if (i%2==r[i]) even.pb(i);
            }
            int E = even.size();
            if (E!=(R+1)/2){
                sum=INF;
                break;
            }
            rep(i,E){
                sum+=abs(i*2-even[i]);
            }
        }
        // cerr<<"Result: "<<(sum==INF?-1:sum)<<endl;
        chmin(ans,sum);
    }
    cout<<(ans==INF?-1:ans)<<endl;
    return 0;
}


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<string> vs;
typedef pair<int, int> P;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

void YN(bool flg){if(flg) cout << "YES" << endl; else cout << "NO" << endl;}
void Yn(bool flg){if(flg) cout << "Yes" << endl; else cout << "No" << endl;}
void yn(bool flg){if(flg) cout << "yes" << endl; else cout << "no" << endl;}

int main()
{
    ll a;
    double b;
    cin >> a >> b;
    ll nb = (b+0.005)*100;
    cout << a * nb / 100 << endl;

    return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
#include <string.h>
#include <ctype.h>
#include <math.h>
#include <float.h>
#include <iomanip>
#include <iostream>
using namespace std;

int digitsSum(int x){
    int ans=0;
    while(1){
        ans+=x%10;
        x/=10;
        if(x<1){
            break;
        }
    }
    return ans;
}

int main(){

    int N,K,l[60]={},ans=0;
    cin >>N>>K;

    for(int i=0;i<N;i++){
        cin >> l[i];
    }

    sort(l,l+N,greater<int>());

    for(int i=0;i<K;i++){
        ans+=l[i];
    }

    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 256
S = str(input())

ans = [0 for i in range(len(S))]
RL_index = 0
R_count = 0
L_count = 0
for i in range(0,len(S)):
  if i != 0:
    if S[i-1] == "R" and S[i] == "L":
      RL_index = i-1
    if S[i-1] == "L" and S[i] == "R":
      if (R_count + L_count)%2 == 0:
        ans[RL_index] = (R_count + L_count)//2
        ans[RL_index+1] = (R_count + L_count)//2
      else:
        if R_count > L_count and R_count %2 == 0:
          ans[RL_index] = (R_count + L_count)//2
          ans[RL_index+1] = (R_count + L_count)//2 + 1
        elif R_count > L_count and R_count %2 == 1:
          ans[RL_index] = (R_count + L_count)//2 + 1
          ans[RL_index+1] = (R_count + L_count)//2
        elif L_count > R_count and L_count %2 ==0:
          ans[RL_index] = (R_count + L_count)//2 + 1
          ans[RL_index+1] = (R_count + L_count)//2
        else:
          ans[RL_index] = (R_count + L_count)//2
          ans[RL_index+1] = (R_count + L_count)//2 + 1
      R_count = 0
      L_count = 0

  if S[i] == "R":
    R_count += 1
  if S[i] == "L":
    L_count += 1

if (R_count + L_count)%2 == 0:
  ans[RL_index] = (R_count + L_count)//2
  ans[RL_index+1] = (R_count + L_count)//2
else:
  if R_count > L_count and R_count %2 == 0:
    ans[RL_index] = (R_count + L_count)//2
    ans[RL_index+1] = (R_count + L_count)//2 + 1
  elif R_count > L_count and R_count %2 == 1:
    ans[RL_index] = (R_count + L_count)//2 + 1
    ans[RL_index+1] = (R_count + L_count)//2
  elif L_count > R_count and L_count %2 ==0:
    ans[RL_index] = (R_count + L_count)//2 + 1
    ans[RL_index+1] = (R_count + L_count)//2
  else:
    ans[RL_index] = (R_count + L_count)//2
    ans[RL_index+1] = (R_count + L_count)//2 + 1

print(' '.join(map(str, ans)))


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

int main() {
  ll n;
  cin >> n;
  vector<ll>a(n+1);
  for(int i=0; i<n+1; i++) cin >> a[i];
  
  if(n==0 && a[0]==1){
    cout << 1 << endl;
    return 0;
  }
  if(a[0]>0){
    cout << -1 << endl;
    return 0;
  }
  vector<ll>mae(n+1),usiro(n+1);
  mae[0]=1;
  usiro[n]=a[n];
  for(int i=1; i<n+1; i++){
    mae[i]=(mae[i-1]-a[i-1])*2;
    if(mae[i]>10e16) mae[i]=10e16;
    if(mae[i]<a[i]){
      cout << -1 << endl;
      return 0;
    }
  }
  
  if(mae[n]>usiro[n]) mae[n]=usiro[n];
  for(int i=n-1; i>=0; i--){
    usiro[i]=usiro[i+1]+a[i];
    if(mae[i]>usiro[i]) mae[i]=usiro[i];
    //cout << usiro[i] << endl;
  }
  
  ll sum=0;
  for(int i=0; i<n+1; i++){
    sum+=mae[i];
  }
  cout << sum << endl;
}


Measured memory_bytes: 5636
use std::io::*;

fn read<T: std::str::FromStr>() -> T {
    let stdin = stdin();
    let mut buf = String::new();
	stdin.lock().read_line(&mut buf);
	buf.trim().parse().ok().unwrap()
}

fn main() {
    let n = read::<usize>();
    println!("{}",if n % 2 == 0 { n } else { 2*n });
}


Measured memory_bytes: 4352
#include <stdio.h>
int main() {
	int n;
	scanf("%d", &n);
	for (int i = 0; i <= n / 7; i++) {
		if ((n - 7 * i) % 4 == 0) {
			printf("Yes\n");
			return 0;
		}
	}
	printf("No\n");
	return 0;
}

Measured memory_bytes: 128
N, M = map(int, input().split())

def main():
    sub = [0] * N
    pen = [0] * N
    for _ in range(M):
        p, s = input().split()
        if s == 'AC':
            sub[int(p)-1] += 1
        else:
            if sub[int(p)-1] == 0:
                pen[int(p)-1] += 1

    ac = len([s for s in sub if s > 0])
    pen = sum([p for i, p in enumerate(pen) if sub[i] > 0])
    print(ac, pen)

if __name__ == '__main__':
    main()

Measured memory_bytes: 5528
/*
integer and notation in decimal
ABC 080 B
*/

#include <stdio.h>
  int N;
  int main (void)
  {
    scanf("%d",&N);
    int t=N,c=0;
    /*cにtを10で割った余りを加算し，商を代入するのを
    tが0になるまで繰り返す*/
    while(t>0)c += t%10, t /= 10;
      if(N%c==0) puts("Yes");
      else puts("No");
    return 0;
  }


Measured memory_bytes: 128
stairs = []

loop do
  n = gets.to_i
  break if n.zero?

  stairs << n
end

stairs.each do |n|
  dp = Array.new(n + 1, 0)
  dp[0] = 1
  dp[1] = 1

  (2..n).each do |i|
    dp[i] += dp[i - 1] + dp[i - 2]
    dp[i] += dp[i - 3] if i > 2
  end

  day = (dp[n] / 10.0).ceil
  year = (day / 365.0).ceil
  p year
end



Measured memory_bytes: 6880
#include <bits/stdc++.h>
#define pq priority_queue
using namespace std;
constexpr long long gcd(long long a, long long b){return b ? gcd(b, a % b) : a;}
constexpr long long lcm(long long a, long long b){return a / gcd(a, b) * b;}
constexpr int INF = 1e9, MOD = INF + 7, around[] = {0, 1, 1, -1, -1, 0, -1, 1, 0, 0};
constexpr int mod_pow(long long x, long long n, const int mod){long long ret=1;while(n){if(n&1)(ret*=x)%=mod;(x*=x)%=mod;n>>=1;}return ret;}
template<int n> struct Prime{bool arr[n+1];constexpr bool operator[](int k){return arr[k];}constexpr Prime():arr(){for(int i=2;i<n;i++){arr[i]=true;for(int j=2;j*j<=i;j++){if(!(i%j))arr[i]=false;}}}};
template<int n> struct Factorial{long long arr[n+1],ary[n+1];constexpr Factorial():arr(),ary(){arr[0]=1;ary[0]=1;for(int i=0;i<n;i++){arr[i+1]=arr[i]*(i+1)%MOD;ary[i+1]=mod_pow(arr[i+1],MOD-2,MOD);}}};
constexpr Factorial<1010> fact; constexpr Prime<10> prime;
constexpr long long comb(int a, int b){if(a < b) return 0LL;if(!a or !b) return 1LL; long long pos = fact.arr[a], pot = fact.ary[a - b], por = fact.ary[b]; return pos * pot % MOD * por % MOD;}
template<int n> struct Bernoulli{long long arr[n+1];constexpr Bernoulli():arr(){arr[0]=1;for(int i=1;i<=n;i++){long long sum=0;for(int j=0;j<i;j++){(sum+=comb(i+1,j)*arr[j]%MOD)%=MOD;}arr[i]=(MOD-mod_pow(i+1,MOD-2,MOD))%MOD*sum%MOD;}}};
constexpr int vx[] = {1, 0, -1, 0}, vy[] = {0, 1, 0, -1};
constexpr long double PI = abs(acos(-1));
constexpr int sqrtN = 512, logN = 32;
constexpr long long LINF=1e18;

int main(){
	int n; cin >> n;
	int li[100010] = {};
	for(int i = 0; i < n; i++){
		int a; cin >> a;
		
		li[a - 1]++;
	}

	int a = 0, b = 0;
	for(int i = 0; i < 100000; i++){
		if(li[i] == 0) continue;
		
		if(li[i] % 2) a++;
		else b++;
	}
	b -= b % 2;
	
	cout << a + b << endl;
	return 0;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
#include <cstdlib>
#include <cmath>
#define rep(i,n) for (long long i=0; i < (n); ++i)
#define rep2(i,n,m) for(long long i=n;i<=m;i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
const ll INF=1e18 ;
inline void chmax(ll& a,ll b){a=max(a,b);}
inline void chmin(ll& a,ll b){a=min(a,b);}

int main(){
 int n,x;
 cin>> n>>x ;
 vector<int> A(n) ;
 rep(i,n) cin>> A[i] ;
 sort(A.begin(),A.end()) ;
 int ans=0 ;
 rep(i,n){
   if(A[i]>x){
     break ;
   }
   
   x-=A[i] ;
  ans++ ;
 }
  if(x>0&&ans==n) 
  cout <<n-1<<endl;
   else
   cout<<ans<<endl; 
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <map> // pair
using namespace std;
int main(){
    string S;
    cin>>S;
    int ans=700;
    for(int i=0;i<3;i++){
      if(S.at(i)=='o')ans+=100;
    }
    cout<<ans<<endl;
  }


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int j,i,f,e=1,d=1,N,M,s=0,h,g;
    scanf("%d%d",&N,&M);
    h=N;
    for(i=h;i>N-2;i--)
    {
        d=i*d;
    }
    g=M;
    for(j=g;j>M-2;j--)
    {
        e=j*e;
    }
            f=(e+d)/2;
    printf("%d",f);
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
typedef int64_t llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define ld PRId64


int main(){
    string s,t;
    cin >> s >> t;
    if(s[0]==t[2] and s[1]==t[1] and s[2]==t[0]) cout << "YES" << endl;
    else cout <<"NO" << endl;
}

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

using ll=int64_t;
#define int ll

#define FOR(i,a,b) for(int i=int(a);i<int(b);i++)
#define REP(i,b) FOR(i,0,b)
#define MP make_pair
#define PB push_back
#define ALL(x) x.begin(),x.end()
#ifdef MAROON_LOCAL
#define cerr (cerr<<"-- line "<<__LINE__<<" -- ")
#else
class CerrDummy{}cerrDummy;
template<class T>
CerrDummy& operator<<(CerrDummy&cd,const T&){
	return cd;
}
using charTDummy=char;
using traitsDummy=char_traits<charTDummy>;
CerrDummy& operator<<(CerrDummy&cd,basic_ostream<charTDummy,traitsDummy>&(basic_ostream<charTDummy,traitsDummy>&)){
	return cd;
}
#define cerr cerrDummy
#endif
#define REACH cerr<<"reached"<<endl
#define DMP(x) cerr<<#x<<":"<<x<<endl
#define ZERO(x) memset(x,0,sizeof(x))
#define ONE(x) memset(x,-1,sizeof(x))

using pi=pair<int,int>;
using vi=vector<int>;
using ld=long double;

template<class T,class U>
ostream& operator<<(ostream& os,const pair<T,U>& p){
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator <<(ostream& os,const vector<T>& v){
	os<<"[";
	REP(i,(int)v.size()){
		if(i)os<<",";
		os<<v[i];
	}
	os<<"]";
	return os;
}

ll read(){
	ll i;
	scanf("%" SCNd64,&i);
	return i;
}

void printSpace(){
	printf(" ");
}

void printEoln(){
	printf("\n");
}

void print(ll x,int suc=1){
	printf("%" PRId64,x);
	if(suc==1)
		printEoln();
	if(suc==2)
		printSpace();
}

string readString(){
	static char buf[3341000];
	scanf("%s",buf);
	return string(buf);
}

char* readCharArray(){
	static char buf[3341000];
	static int bufUsed=0;
	char* ret=buf+bufUsed;
	scanf("%s",ret);
	bufUsed+=strlen(ret)+1;
	return ret;
}

template<class T,class U>
void chmax(T& a,U b){
	if(a<b)
		a=b;
}

template<class T,class U>
void chmin(T& a,U b){
	if(b<a)
		a=b;
}

template<class T>
T Sq(const T& t){
	return t*t;
}

#define CAPITAL
void Yes(bool ex=true){
	#ifdef CAPITAL
	cout<<"YES"<<endl;
	#else
	cout<<"Yes"<<endl;
	#endif
	if(ex)exit(0);
}
void No(bool ex=true){
	#ifdef CAPITAL
	cout<<"NO"<<endl;
	#else
	cout<<"No"<<endl;
	#endif
	if(ex)exit(0);
}

const ll infLL=LLONG_MAX/3;

#ifdef int
const int inf=infLL;
#else
const int inf=INT_MAX/2-100;
#endif

signed main(){
	int n=read(),m=read(),col=read();
	vi l(col);REP(i,col)l[i]=read();
	vector<pi> vc;
	REP(i,n){
		int c=read()-1,v=read();
		vc.PB(pi(v,c));
	}
	sort(ALL(vc),greater<pi>());
	int ans=0;
	REP(i,n){
		int v=vc[i].first,c=vc[i].second;
		if(m&&l[c]){
			m--;
			l[c]--;
			ans+=v;
		}
	}
	print(ans);
}



Measured memory_bytes: 5632
#include<stdio.h>
int main(){
	int i,A,B,C,a,b,c;
	scanf("%d%d%d",&A,&B,&C);
	for(i=0;i<10000;i++){
		if(A%2==1||B%2==1||C%2==1)break;
		a=B/2+C/2;
		b=A/2+C/2;
		c=A/2+B/2;
		A=a;
		B=b;
		C=c;
	}
	if(i==10000)printf("-1\n");
	else printf("%d\n",i);
}

Measured memory_bytes: 128
n = int(input())
ls = list(map(int, input().split()))

count = 0
for i in range(n):
    for j in range(i+1, n):
        for k in range(j+1, n):
            li = ls[i]
            lj = ls[j]
            lk = ls[k]

            if li != lj and lj != lk and lk != li and li + lj > lk and lj + lk > li and lk + li > lj:
                count += 1

print(count)



Measured memory_bytes: 9184
#include<stdio.h>

int selectionSort(int *a, int N)
{
	int swap = 0;
	for (int i = 0; i < N; i++)
	{
		int min = i;
		for (int j = i + 1; j < N; j++)
		{
			if (a[j] < a[min])
				min = j;
		}
		if (min != i)
		{
			int t = a[min];
			a[min] = a[i];
			a[i] = t;
			swap++;
		}
	}
	return swap;
}

void print(int *a, int N)
{
	for (int i = 0; i < N; i++)
	{
		if (i)
			printf(" ");
		printf("%d", a[i]);
	}
}

int main()
{
	int N;
	int a[101];
	scanf("%d", &N);
	for (int i = 0; i < N; i++)
		scanf("%d", &a[i]);
	int sw = selectionSort(a, N);
	print(a, N);
	printf("\n%d\n", sw);
}


Measured memory_bytes: 2088
use std::fmt::Debug;
use std::str::FromStr;

#[allow(dead_code)]
#[allow(deprecated)]
fn read_line_from_stdin() -> String {
    let mut buffer = String::new();
    std::io::stdin().read_line(&mut buffer).unwrap();
    buffer.trim_right().to_owned()
}

#[allow(dead_code)]
#[allow(deprecated)]
fn parse_line_to_single<T>() -> T
where
    T: FromStr,
    T::Err: Debug,
{
    let mut buffer = String::new();
    std::io::stdin().read_line(&mut buffer).unwrap();
    T::from_str(buffer.trim_right()).unwrap()
}

#[allow(dead_code)]
#[allow(deprecated)]
fn parse_line_to_multiple<T>() -> Vec<T>
where
    T: FromStr,
    T::Err: Debug,
{
    let mut buffer = String::new();
    std::io::stdin().read_line(&mut buffer).unwrap();
    buffer
        .trim_right()
        .split_whitespace()
        .flat_map(|s| T::from_str(s))
        .collect()
}

macro_rules! parse_line {
    [$( $x:tt : $t:ty ),+] => {
        //declare variables
        $( let $x: $t; )+
        {
            use std::str::FromStr;
            // read
            let mut buf = String::new();
            std::io::stdin().read_line(&mut buf).unwrap();
            #[allow(deprecated)]
            let mut splits = buf.trim_right().split_whitespace();
            // assign each variable
            $(
                $x = splits.next().and_then(|s| <$t>::from_str(s).ok()).unwrap();
            )+
            // all strs should be used for assignment
            assert!(splits.next().is_none());
        }
    };
}

use std::collections::HashSet;

fn main() {
    parse_line![_town_count: usize, desired_move_count: usize];

    let transporters = parse_line_to_multiple::<usize>();

    let mut current_town = 1;
    let mut move_histories = vec![];
    let mut visited_towns = HashSet::new();

    loop {
        if move_histories.len() == desired_move_count {
            println!("{}", current_town);
            break;
        }
        if visited_towns.contains(&current_town) {
            let remaining_movement = desired_move_count - move_histories.len();

            let first_loop_index = move_histories
                .iter()
                .enumerate()
                .find(|(i, h)| **h == current_town)
                .map(|(i, _)| i)
                .unwrap();

            let loop_length = move_histories.len() - first_loop_index;
            let index_diff = remaining_movement % loop_length;
            let final_town = move_histories[first_loop_index + index_diff];
            println!("{}", final_town);
            break;
        }
        move_histories.push(current_town);
        visited_towns.insert(current_town);
        let town_index = current_town - 1;
        current_town = transporters[town_index];
    }
}


Measured memory_bytes: 8304
#include<bits/stdc++.h>
#include <math.h>
#include <cmath>
#include <limits>
#include <iostream>
#include <assert.h>

#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
typedef pair<ll,Pi> P1i;
const ll INF=10000000000000000001;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};
struct pos{
	int x,y,sx,sy,total;
};
int a[100001];
ll dp[100001]={};
int	d[100001]={};
int main(){

	int n,m;
	cin>>n>>m;
	rep(i,m){
		cin>>a[i];
		d[a[i]]=1;
	}

	dp[1]=1;
	dp[2]=1;
	for(int i=1; i<n+1; i++){
		if(d[i]==1)continue;
		dp[i+1]+=dp[i];
		dp[i+2]+=dp[i];
		dp[i+1]%=i197;
		dp[i+2]%=i197;
	}
	cout<<dp[n]<<endl;
	return 0;

}




Measured memory_bytes: 1664
import java.io.PrintStream;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    static final Scanner     sc = new Scanner(System.in);
    static final PrintStream so = System.out;

    public static void main(String[] args) {
        int N = nint();
        int[] d = nints(N);
        Arrays.sort(d);
        
        int a = d[N/2 - 1];
        int b = d[N/2];
        so.println(b-a);
    }

    private static long nlong() {
        return sc.nextLong();
    }

    private static int nint() {
        return sc.nextInt();
    }

    private static String nstr() {
        return sc.next();
    }

    private static char[] nsToChars() {
        return sc.next().toCharArray();
    }

    private static long[] nlongs(int n) {
        return nlongs(n, 0, 0);
    }

    private static int[] nints(int n) {
        return nints(n, 0, 0);
    }

    private static int[] nints(int n, int padL, int padR) {
        int[] a = new int[padL + n + padR];
        for (int i = 0; i < n; i++)
            a[padL + i] = nint();
        return a;
    }

    private static long[] nlongs(int n, int padL, int padR) {
        long[] a = new long[padL + n + padR];
        for (int i = 0; i < n; i++)
            a[padL + i] = nlong();
        return a;
    }

    private static String[] nstrs(int n) {
        String[] a = new String[n];
        for (int i = 0; i < n; i++)
            a[i] = nstr();
        return a;
    }

    private static char[][] nsToChars2D(int h, int w) {
        return nsToChars2D(h, w, 0);
    }

    private static char[][] nsToChars2D(int h, int w, int pad) {
        char[][] a2 = new char[h + pad * 2][w + pad * 2];
        for (int i = 0; i < h; i++)
            System.arraycopy(nsToChars(), 0, a2[pad + i], pad, w);
        return a2;
    }
}


Measured memory_bytes: 50956
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
#include<vector>
#include<queue>
using namespace std;
typedef long long LL;
const int N=200005;
char ss[N];
int n;
queue<int> q;
bool check (int x)
{
	if (x<=0) return false;
	if (x>n-2) return false;
	if (ss[x]=='A'&&ss[x+1]=='B'&&ss[x+2]=='C') return 	true;
	return false;
}
char b[N];
int top;
int main()
{
	scanf("%s",ss+1);n=strlen(ss+1);
	for (int u=1;u<=n;u++)
	{
		b[++top]=ss[u];
		if (top>1&&b[top]=='C'&&b[top-1]=='B') 	{top-=2;b[++top]='D';}
	}
	int l=1,r;
	LL ans=0;
	while (l<n)
	{
		if (b[l]=='B'||b[l]=='C') {l++;continue;}
		r=l;while (r+1<=n&&(b[r+1]=='A'||b[r+1]=='D')) r++;
		int cnt=0;
		for (int u=r;u>=l;u--)
		{
			if (b[u]=='D') cnt++;
			else ans=ans+cnt;
		}
		l=r+1;
	}
	/*for (int u=1;u<=n-2;u++)	if (check(u))	q.push(u);
	
	int ans=0;
	while (!q.empty())
	{
		int x=q.front();q.pop();
		//printf("%d\n",x);
		ans++;
		ss[x]='B';ss[x+1]='C';ss[x+2]='A';
		if (check(x+2)) q.push(x+2);
		if (check(x-1)) q.push(x-1);
	}*/
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 640
# 入力
N = int(input())
x, u = zip(*((float(t[0]), t[1]) for t in (input().split() for _ in range(N))))

# 定義通り計算
ans = sum(
    t[0] if t[1] == 'JPY' else
    380000 * t[0] for t in zip(x, u)
)

# 出力
print(ans)


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

const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;

ll ppow(ll a,ll b){
	a%=MOD;
	ll res=1;
	while(b){
		if(b&1)res=(res*a)%MOD;
		a=(a*a)%MOD;
		b>>=1;
	}
	return res;
}
ll c[300000];
int main(){
	int n;cin>>n;
	rep(i,n)scanf("%lld",&c[i]);
	sort(c,c+n,greater<>());
	ll t=ppow(2,MOD-2);
	ll ans=0;
	rep(i,n){
		(ans+=c[i]*t%MOD*(t%MOD*i%MOD+1))%=MOD;
	}
	cout<<ans*(ppow(2,n)*ppow(2,n)%MOD)%MOD<<endl;
}

Measured memory_bytes: 1792
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = 1; i < (int)(n); i++) 
#define dunk(n) cout << n << endl
#define all(a) (a).begin(),(a).end()
typedef pair<int,int> P;
typedef long long ll;

int main() {
    double n;
    cin >> n;
    vector<double> x(n);
    rep(i,n) cin >> x[i];
    double gat = 0;
    rep(i,n) gat += x[i];
    gat = gat/n;
    gat += 0.5;
    int p = (int)gat;
    int ans = 0;
    rep(i,n){
        ans += (x[i]-p)*(x[i]-p);
    }
    dunk(ans);
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include <math.h>
using namespace std;
int main(){

	int N;
	double ave=0;
	cin>>N;
	double a[100]={0};
	for(int i=0;i<N;i++){
		cin>>a[i];
		ave+=a[i];
	}
	ave/=N;
	double y=fabs(a[0]-ave);
	int any=0;
	for(int i=1;i<N;i++){
		double x=fabs(a[i]-ave);
		if(x<y){	
			y=x;
			any=i;
		}
	}
	cout<<any<<endl;
	
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#define rep(i,a,b) for(int (i)=(a);i<(b);i++)
#define INF 1000000000
#define MAX_N 150005
using namespace std;

int L[100005];

int main(){
    int n,a[100005];
    cin>>n;
    rep(i,0,n)cin>>a[i];
    
    L[0]=a[0];
    int length=1;
    for(int i=1;i<n;i++){
        if(L[length-1]<a[i]){
            L[length++]=a[i];
        }else{
            int right=length-1,left=0;
            int mid=0;
            while(left<=right){
                mid=(right+left)/2;
                if(L[mid]>a[i]){
                    if(mid==0||L[mid-1]<a[i])L[mid]=a[i];
                }
                if(L[mid]<a[i])left=mid+1;
                else right=mid-1;
            }
        }
    }
    cout<<length<<endl;
    
}

Measured memory_bytes: 3848
import java.util.*;

/**
 * Created by Santa.
 */
public class Main {

    static int N;
    static int M;
    static int A;
    static long B;
    static long C;
    static int[][] map;
    static int min = 9999999;
    static int[] moto = new int[3];

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        N = scanner.nextInt();

        int sum = -N;

        for (int i = 0; i < N; i++) {
            int a = scanner.nextInt();
            sum += a;
        }

        System.out.println(sum);



    }




}



Measured memory_bytes: 26832
#include<stdio.h>

int main(void){
    int n[3], i, j, k, tmp;

    scanf("%d %d %d", &n[0], &n[1], &n[2]);
    for(i = 0; i < 2; i++){
        for(j = 2; j > 0; j--){
            if(n[j-1] > n[j]){
                tmp = n[j-1];
                n[j-1] = n[j];
                n[j] = tmp;
            }
        }
    }
    for(k = 0; k < 3; k++){
        if(k == 2){
            printf("%d\n", n[k]);
            break;
        }
        printf("%d ", n[k]);
    }
    return 0;
}


Measured memory_bytes: 2140
function Main(input) {
    var tmp = input.split("\n");
    var num = parseInt(tmp[0]);
    var ary = tmp[1].split(" ");
    
    for(var n=0; n<num; n++){
        ary[n] = BigInt(ary[n]);
    }
    
    var count = BigInt(1);
    var flg = 0;
    
    if(ary.includes(BigInt(0))){
        console.log("0");
    }else{
        for(var i=0; i<num; i++){
            count = count * ary[i];
            if(count>BigInt(Math.pow(10,18))){
                flg = 1;
                console.log(-1);
                break;
            }
        }
        if(flg===0){
            console.log(String(count));
        }
    }
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 43996
#include<bits/stdc++.h>
using namespace std;
#define res register int
#define ll long long
//#define cccgift
//#define getchar()(p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
//char buf[1<<21],*p1=buf,*p2=buf;
template<typename T>
inline void read(T &x)
{
    static char ch;bool f=1;
    for(x=0,ch=getchar();!isdigit(ch);ch=getchar()) if(ch=='-') f=0;
    for(;isdigit(ch);x=(x<<1)+(x<<3)+(ch^48),ch=getchar());x=f?x:-x;
}
template<typename T>
void print(T x)
{
    if (x<0) x=-x,putchar('-');
    if (x>9) print(x/10);
    putchar(x%10+48);
}
template<typename T>
inline void print(T x,char ap) {print(x);if (ap) putchar(ap);}
template<typename T>
inline void chkmax(T &x,const T &y) {x=x<y?y:x;}
template<typename T>
inline void chkmin(T &x,const T &y) {x=x<y?x:y;}
int n,m,L,q,x,y,z;
ll f[301][301];
int main()
{
	cin>>n>>m>>L,memset(f,0x3f,sizeof(f));
	for(res i=1;i<=n;++i) f[i][i]=0;
	for(res i=1;i<=m;++i) read(x),read(y),read(z),f[x][y]=f[y][x]=min(f[x][y],(ll)z);
	for(res k=1;k<=n;++k)
	  for(res i=1;i<=n;++i)
	    for(res j=1;j<=n;++j) chkmin(f[i][j],f[i][k]+f[k][j]);
	for(res i=1;i<=n;++i)
	  for(res j=1;j<=n;++j) if(f[i][j]<=L) f[i][j]=1;else f[i][j]=1e18;
	for(res k=1;k<=n;++k)
	  for(res i=1;i<=n;++i)
	    for(res j=1;j<=n;++j) chkmin(f[i][j],f[i][k]+f[k][j]);
	cin>>q;
	while(q--) {
		cin>>x>>y;
		if(f[x][y]>=1e18) cout<<-1<<'\n';
		else cout<<f[x][y]-1<<'\n';
	}
	return 0;
}
/* stuff you should look for
    * int overflow, array bounds
    * special cases (n=1?), set tle
    * do something instead of nothing and stay organized
*/ 

Measured memory_bytes: 1280
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#define f first
#define s second
#define x first
#define y second
using namespace std;

typedef pair<int,int>pii;

void func(char dir, int dist, set<pii>&gems, pii &current){
  if(dir == 'E' || dir == 'W'){
    for(int i=0;i<dist;i++){
      current.x += (dir=='E'?1:-1);
      gems.erase(current);
    }
  }
  else{
    for(int i=0;i<dist;i++){
      current.y += (dir=='N'?1:-1);
      gems.erase(current);
    }
  }
}

int main(void){
  int n,m;

  while(cin >> n, n){
    set<pii>gems;
    for(int i=0;i<n;i++){
      int a,b;
      cin >> a >> b;
      gems.insert(pii(a,b));
    }
    cin >> m;
    pii curr=pii(10,10);
    for(int i=0;i<m;i++){
      char dir;
      int dist;
      cin >> dir >> dist;
      func(dir,dist,gems,curr);
    }
    cout << (gems.size()==0?"Yes":"No") << endl;
  }
  return 0;
}

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

long long N;
string S;
int P;

long long solve() {
    /*
	if (P == 2 || P == 5) {
        long long res = 0;
        for (int i = 0; i < N; ++i) if ((S[N-i-1]-'0') % P == 0) res += N-i;
        return res;
    }
	*/
    vector<long long> val(P, 0);
    long long tenfactor = 1;
    long long cur = 0;
    val[cur]++;
    for (int i = 0; i < N; ++i) {
        cur = (cur + (S[N-i-1]-'0') * tenfactor) % P;
        tenfactor = (tenfactor * 10) % P;
        val[cur]++;
    }
    long long res = 0;
    for (int p = 0; p < P; ++p) res += val[p] * (val[p] - 1) / 2;
    return res;
}

int main() {
    cin >> S;
	N=S.size();
	P=2019;
    cout << solve() << endl;
}

Measured memory_bytes: 3668
def func(li, a):
  i = 1
  while a//i > 0:
    if i == 1:
        li.append(1 - (a-1) // 2 % 2)
    elif ((a - i + 1) // i) % 2 == 0 and (a - i + 1) % 2 == 1:
      li.append(1)
    else:
      li.append(0)
    i *= 2

def bi_to_int(li):
    ans = 0
    i = 1
    for x in li:
        ans += x * i
        i *= 2
    
    return ans
    
a, b = map(int, input().split())

bit_a = []
bit_b = []

func(bit_a, a-1)
func(bit_b, b)

print(bi_to_int(bit_a) ^ bi_to_int(bit_b))

Measured memory_bytes: 3064
#include <iostream>
using namespace std;
int main(){
  int n,c;
  cin >> n;
  if(n==1) {
    cout <<1<<endl;
    return 0;
  }
  int a[7]={2,4,8,16,32,64,128};
  for(int i=6;i>=0;i--){
      if(n>=a[i]) {
        c=i;
        break;
      }
  }
  cout << a[c]<<endl;
}


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

int main() {
  long long X;
  cin >> X;
  long long a,b;
  for (long long i =-1000;i<1000;i++){
    for(long long j =-1000;j<1000;j++){
      if((i*i*i*i*i-j*j*j*j*j)==X){
        a=i;
        b=j;
      }
    }
  }
  cout << a << " " << b <<endl;
      
}
    
    


Measured memory_bytes: 3636
import numpy as np
#基本入力
D = int(input())
c =list(map(int,input().split()))
s = []
for i in range(D):
        s.append(list(map(int,input().split())))
t = []
for i in range(D):
    t.append(int(input()))
        
#基本入力完了
#得点計算
c = np.array(c)
last_day = np.array([0]*26)
day_pulse = np.array([1]*26)
s = np.array(s)
t = np.array(t)
manzoku = 0
for day in range(1,D+1):
    contest_number = t[day-1] #開催するコンテスト種類
    manzoku += s[day-1,contest_number-1] #開催したコンテストによる満足度上昇
    last_day += day_pulse #経過日数の計算
    last_day[contest_number -1 ] = 0 #開催したコンテスト種類の経過日数を0に
    manzoku -= sum(c*last_day) #開催していないコンテストによる満足度の減少
    print(manzoku)


Measured memory_bytes: 27480
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>


using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD (ll)1000000007
#define P pair<ll, ll>

ll n, a, b, s[110000];
bool solve(ll index) { //条件判定
	ll cnt = 0;
	REP(i, n) {
		ll now = max(0ll, s[i] - b * index);
		cnt += (now + a - b - 1) / (a - b);
	}
	if (cnt <= index)return true;
	else return false;
}

ll nibutan() { //めぐる式

	ll ng = -1; //最大値ならs.size()
	ll ok = (ll)1e9 + 1000; // 最大値なら0

	while (abs(ok - ng) > 1) {
		ll mid = (ok + ng) / 2;

		if (solve(mid)) ok = mid;
		else ng = mid;
	}
	return ok; //満たさない最大ならng
}

int main() {
	cin >> n >> a >> b;
	REP(i, n) {
		cin >> s[i];
	}
	cout << nibutan() << endl;
}	


Measured memory_bytes: 1024
N=int(input())
ls=[int(s) for s in input().split()]
dic={}
for e in ls:
  if (e in dic):
    dic[e]+=1
  else:
    dic[e]=1
ans=0
for k,v in dic.items():
  if k<=v:
    ans+=v-k
  else:
    ans+=v
print(ans)

Measured memory_bytes: 18168
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
int main(){
  string s,t;
  cin>>s>>t;
  int a,b;
  cin>>a>>b;
  string u;
  cin>>u;
  
  if(u==s)cout<<a-1<<" "<<b<<endl;
  else if(u==t)cout<<a<<" "<<b-1<<endl;
  else cout<<a<<" "<<b<<endl; 



}


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

typedef long long ll;

#define PB push_back
#define MP make_pair

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
    ll n; cin >> n;
    unordered_map<ll, ll> mp;
    ll cumsum = 0;
    for (ll i = 0; i < n; ++i) {
        ll ai; cin >> ai;
        mp[ai]++;
        cumsum += ai;
    }
    ll q; cin >> q;
    for (ll i = 0; i < q; ++i) {
        ll b, c; cin >> b >> c;
        ll cnt = mp[b];
        cumsum -= cnt * b;
        cumsum += cnt * c;
        mp[b] = 0;
        mp[c] += cnt;
        cout << cumsum << "\n";
    }
}

/* stuff you should look for
	* int overflow, array bounds
	* special cases (n=1?)
	* do smth instead of nothing and stay organized
	* print new lines
*/

Measured memory_bytes: 7096
#include <iostream>
#include <string>

using namespace std;

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

	if (n.length() % 2 == 1) {
		cout << "No" << endl;
		return 0;
	}
	for (int i = 0; i < n.length(); i++) {
		if (i % 2 == 1) {
			if (n[i] != 'i') {
				cout << "No" << endl;
				return 0;
			}
		}
		else {
			if (n[i] != 'h') {
				cout << "No" << endl;
				return 0;
			}
		}
	}
	cout << "Yes" << endl;
	
	return 0;
}

Measured memory_bytes: 256
def solve2():
    N = raw_input()
    K = int(raw_input())
    L = len(N)
    digN = [int(d) for d in N]
    dp = [[[0 for k in range(2)] for j in range(K+1)] for i in range(L+1)]
    dp[0][0][0] = 1
    for i in range(L):
        for j in range(K+1):
            for k in range(2):
                for d in range(10):
                    ni = i + 1
                    nj = j
                    nk = k
                    if d != 0:
                        nj += 1
                    if nj > K:
                        continue
                    if k == 0:
                        if d > digN[i]:
                            continue
                        if d < digN[i]:
                            nk = 1
                    dp[ni][nj][nk] += dp[i][j][k]
    print dp[L][K][0] + dp[L][K][1]

if __name__ == '__main__':
    solve2()


Measured memory_bytes: 32364
import sys

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

IN=lambda : map(int, input().split())
mod=1000000007

#+++++

def main():
	a = int(input())
	al=[]
	for i in range(a):
		b = int(input())
		al.append(b)
		
	opened_list=set()
	st=0
	opened_list.add(st)
	count=0
	while st != 1:
		st = al[st]-1
		count+=1
		if st in opened_list:
			return -1
		opened_list.add(st)
			
	return count
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

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

typedef long long ll;
typedef long double ld;
typedef vector<vector<int>> Graph;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
#define pi 3.14159265359
#define inf 2147483647
#define INF 9223372036854775807
#define mod 1000000007
#define mod2 998244353

int main() {
    string S; cin >> S;
    for(int i = 0; i < S.size(); i = i + 2) {
        cout << S[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 3724
N = int(input())
K = int(input())
dp = [[[0]*2 for _ in range(4)] for _ in range(105)]
# dp[i][j][k]:上からi桁まで決めて0でない数字をj個用いた数字で
# k = 0の時Nと一致,k=1の時N未満が確定
# 求める答えはdp[len(str(N))][K][0] + dp[len(str(N))][K][1]
# k=0からk=1の遷移が不可逆

dp[0][0][0] = 1
length = len(str(N))
for i in range(length):
    for j in range(4):
        for k in range(2):
            next_digit = int(str(N)[i])
            for d in range(10):
                ni = i+1
                nj = j
                nk = k
                if d != 0:
                    nj += 1
                if nj > K:
                    continue
                if k == 0:
                    if next_digit < d:
                        continue
                    if next_digit > d:
                        nk = 1
                dp[ni][nj][nk] += dp[i][j][k]
ans = dp[length][K][0] + dp[length][K][1]
print(ans)


Measured memory_bytes: 3064