akhauriyash/Code-Regression huggingface dataset:
//Hey u r far away to know this
#include <bits/stdc++.h>
using namespace std;
#define     ff                  first
#define     pb                  push_back
#define     ss                  second
#define     ll                  long long
#define     MAX                 5000
#define     mpi                 map<int, int>
#define     mpll                map<ll, ll>
#define     pll                 pair<ll, ll>
#define     plld                pair<ll, double>
#define     SKILLER             ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define     vi                  std::vector<int>
#define     vll                 std::vector<ll>
#define     vs                  std::vector<string>
#define     vvi                 std::vector<std::vector<int>>
#define     vvll                std::vector<std::vector<ll>>
#define     all(v)              v.begin(), v.end()
#define     allr(v)              v.rbegin(), v.rend()
#define     loop(i, a, b)     for(int i = a; i < b; i++)
#define       debug(x)         cout << x <<" " <<"\n";
#define       debug1(x, y)     cout << x << " " << y  << "\n";
#define       debug2(x, y, z)     cout << x << " " << y << " " << z<<"\n";
#define       int             ll
const   int N = 1e6+5, Mod = 1e9 + 7;
int32_t main(){
        SKILLER;
       
        int a, b, c; cin >> a >> b >> c;
        int k; cin >> k;
        int op = 0;
        while(b <= a and b != 0)
        {
            b *= 2;
            op++;
        }
        while(c <= b and c != 0){
            c *= 2;
            op++;
        }
        if(op <= k and c > b and b > a)
            cout << "Yes";
        else cout << "No";
        return 0;
}

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


int main() {
  ll N;
  cin >> N;
  vector<ll> T(N);
  vector<ll> A(N);
  vector<ll> t(N);
  vector<ll> a(N);
  
  for(ll i = 0;i<N;i++){
    cin >> T[i];
    cin >> A[i];
    }
    t[0] = T[0];
    a[0] = A[0];
  for(ll i = 0;i<N-1;i++){
    ll k = max((t[i]+T[i+1]-1)/T[i+1],(a[i]+A[i+1]-1)/A[i+1]);
    t[i+1] = k*T[i+1];
    a[i+1] = k*A[i+1];
  }

    cout << t[N-1] + a[N-1] << endl;

}

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

using namespace std;

typedef long long int64;

int main()
{
  int N;
  cin >> N;
  int64 latte, malta;
  cin >> latte >> malta;
  for(int i = 1; i < N; i++) {
    int T, A;
    cin >> T >> A;
    int64 sweep = max((malta + A - 1) / A, (latte + T - 1) / T);
    latte = sweep * T;
    malta = sweep * A;
  }
  cout << latte + malta << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
	int N, M;
	cin >> N >> M;

	int likeCounter[M] = {0};

	for (int i = 0; i < N; i++){
		int K;
		cin >> K;

		for (int j = 0; j < K; j++){
			int A;
			cin >> A;
			A--;

			likeCounter[A]++;
		}
	}

	int ans = 0;
	for (int i = 0; i < M; i++){
		if(likeCounter[i] == N){
			ans++;
		}
	}

	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
/*
A0647:set
 */
#include <stdio.h>
#include <stdlib.h>

int n,k,a[100001];

int comp( const void * a , const void * b ) {

  if( *( int * )a > *( int * )b ) {
    return 1;
  }
  else
  if( *( int * )a == *( int * )b ) {
    return 0;
  }
  return -1;
}


int main()
{
  int i,prev;
  int ret;
  scanf("%d",&n);

  for(i=0;i<n;i++)
    {
      scanf("%d",&a[i]);
    }
  qsort(a,n,sizeof(int),comp);
  prev=a[0];
  for(i=1,ret=1;i<n;i++)
  {
    if(a[i]!=prev)
      ret++;
    prev=a[i];
  }
  printf("%d\n",ret);
  return(0);
}



Measured memory_bytes: 2384
def fold(x,m):
    y = 0
    for _ in range(m):
        y |= x&1
        y <<= 1
        x >>= 1
    return x|y

lmi = lambda: list(map(int, input().split()))

h,w = lmi()
a = [lmi() for _ in range(2*h)]
g = [[abs(a[i][j] - a[i+h][j]) for j in range(w)] for i in range(h)]
m = 12801
mask = (1<<m) - 1

dp = [0]*(w+1)
dp[0] = 1
for i in range(h):
  for j in range(w):
    cur,par = g[i][j],dp[j]|dp[j-1]
    dp[j] = par<<cur&mask|fold(par,cur)
for i in range(m):
  if dp[-2]&(1<<i):
    print(i)
    break

Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
	/* code */
	ll n;
	cin>>n;
	int flag=0;
  	ll sum=0;
	for(int i=1;i<=n;i++)
    {
      if(i%5!=0 && i%3!=0)
      {	
        sum+=i;
        
      }
    }
  	cout<<sum<<endl;
	return 0;
}

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

int main(){
    string s;
    cin >> s;
    bool f1 = false, f2 = false;
    REP(i, s.size()){
        if(s[i] == 'C') f1 = true;
        if(s[i] == 'F') if(f1) f2 = true;        
    }
    if(f1 and f2) cout << "Yes" << endl;
    else cout << "No" << endl; 

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <utility>
#include <queue>
#include <cassert>
#include <map>
#define maxn 200005

using namespace std;
typedef long long ll;
const int LEN = 100000;

struct fastio{
  int it,len;
  char s[100005];
  fastio(){
	  it = len = 0;
  }
  char get(){
    if(it < len) return s[it++];
    len = fread(s,1,100000,stdin);
    it = 0;
    return len ? s[it++] : EOF;
  }
  void put(char c){
    if(it == LEN) fwrite(s,1,LEN,stdout), it = 0;
    s[it++] = c;
  }
  void flush(){
    fwrite(s,1,it,stdout);
  }
}buff,bufo;
inline int getint(){
  char c; int res = 0, sig = 1;
  for(c = buff.get();c < '0' || c > '9';c = buff.get()) if(c == '-') sig = -1;
  for(;c >= '0' && c <= '9';c = buff.get()) res = res * 10 + (c - '0');
  return sig * res;
}
inline void putint(int x,char c){
  if(x == 0) bufo.put('0');
  if(x < 0) bufo.put('-'), x = -x;
  char s[15]; int k = 0;
  while(x){
    s[++k] = x % 10 + '0';
    x /= 10;
  }
  for(;k >= 1;k--) bufo.put(s[k]);
  bufo.put(c);
}

int n,a[maxn];
map <int,int> cur;
typedef map<int,int>::iterator Ite;
bool check(int x){
  if(x == 1){
    for(int i = 1;i < n;i++) if(a[i + 1] <= a[i]) return false;
    return true;
  }
  cur.clear();
  for(int i = 1;i <= n;i++){
    if(a[i] <= a[i - 1]){
      if(!cur.empty()){
        Ite it = cur.end();
        vector <Ite> vec;
        for(it--;it != cur.begin() && (it -> first) > a[i];it--) vec.push_back(it);
        for(int j = 0;j < (int)vec.size();j++) cur.erase(vec[j]);
        if(cur.begin() -> first > a[i]) cur.erase(cur.begin());
      }
      int tmp = a[i];
      while(tmp && cur.find(tmp) != cur.end() && cur[tmp] == x - 1){
        cur[tmp] = 0;
        tmp--;
      }
      if(!tmp) return false;
      if(cur.find(tmp) != cur.end()) cur[tmp]++;
      else cur[tmp] = 1;
    }
  }
  return true;
}
int main(){
  n = getint();
  for(int i = 1;i <= n;i++) a[i] = getint();
  int lb = 1, rb = n;
  while(lb < rb){
    int mid = (lb + rb) >> 1;
    if(check(mid)) rb = mid;
    else lb = mid + 1;
  }
  printf("%d\n",lb);
  return 0;
}


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

const long long mod=1000000007ll;
const int BS=19;

void bitadd(int *bit,int i,int v)
{
  int p=i+1;
  while(p<1<<BS){
    bit[p]+=v;
    p+=p&-p;
  }
}

int bitsum(int *bit,int i)
{
  int p=i+1,ret=0;
  while(p>0){
    ret+=bit[p];
    p-=p&-p;
  }
  return ret;
}


int main()
{
  int n;
  scanf("%d",&n);
  static int P[500010];
  static bool B[500010]={0};
  int L=0;
  for(int i=0;i<n;i++){
    scanf("%d",P+i);
    if(P[i]==0){
      L++;
    }
    else{
      B[P[i]]=1;
    }
  }
  static int A[500010];
  A[n]=0;
  for(int i=n-1;i>0;i--){
    A[i]=A[i+1]+!B[i+1];
  }
  static int A2[500010];
  A2[1]=0;
  for(int i=2;i<=n;i++){
    A2[i]=A2[i-1]+B[i-1];
  }
  static long long F[500010];
  F[0]=1ll;
  for(int i=1;i<=n;i++){
    F[i]=F[i-1]*i%mod;
  }
  static int bit[1<<19]={0};
  long long ans=0ll;
  long long S0=0ll,S1=0ll;
  for(int i=1;i<=n;i++){
    if(!B[i]){
      S0+=A[i];
    }
    else{
      S1+=A[i];
    }
  }
  int K=0;
  for(int i=0;i<n;i++){
    //printf("%lld %lld\n",S0,S1);
    if(P[i]==0){
      ans+=S0%mod*(L-K-1)%mod*(L>=2?F[L-2]:0ll)%mod*F[n-i-1]%mod;
      ans%=mod;
      ans+=S1%mod*F[L-1]%mod*F[n-i-1]%mod;
      ans%=mod;
      K++;
    }
    else{
      int k=bitsum(bit,P[i]-1);
      ans+=(long long)(A2[P[i]]-k)*F[L]%mod*F[n-i-1]%mod;
      ans%=mod;
      ans+=(long long)(P[i]-1-A2[P[i]])*(L-K)%mod*(L>=1?F[L-1]:0)%mod*F[n-i-1]%mod;
      ans%=mod;
      S1-=A[P[i]];
      bitadd(bit,P[i],1);
    }
    //printf("%lld\n",ans);
  }
  ans+=F[L];
  ans%=mod;
  printf("%lld\n",ans);
  return 0;
}


Measured memory_bytes: 12416
n=int(input())
l=list(map(int,input().split()))
d={}
for i in range(n):
  d[i]=0
for i in l:
  d[i]+=1
b=True
if n%2==1:
  if d[0]!=1:
    b=False
  for i in range(1,n//2+1):
    if d[i*2]!=2:
      b=False
else:
  for i in range(n//2):
    if d[i*2+1]!=2:
      b=False
if b:
  print((2**(n//2))%(10**9+7))
else:
  print(0)


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

using namespace std;

#define gc getchar_unlocked
#define foi(i,n) for(int i=0;i<n;i++)
#define Foi(i,k,n) for(int i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define fol(i,n) for(ll i=0;i<n;i++)
#define Fol(i,k,n) for(ll i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define si(x)   scanf("%d",&x)
#define sl(x)   scanf("%lld",&x)
#define ss(s)   scanf("%s",s)
#define pi(x)   printf("%d\n",x)
#define pl(x)   printf("%lld\n",x)
#define ps(s)   printf("%s\n",s)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
typedef pair<int, int>  pii;
typedef pair<ll, ll>    pl;
typedef vector<int>     vi;
typedef vector<ll>      vl;
typedef vector<pii>     vpii;
typedef vector<pl>      vpl;
typedef vector<vi>      vvi;
typedef vector<vl>      vvl;
int mpow(int base, int exp); 
void ipgraph(int m);
void dfs(int u, int par);
const int mod = 1000000007;
const int N = 3e5, M = N;
//=======================

vi g[N];
int a[N];

int mpow(int base, int exp) {
    base %= mod;
    int result = 1;
    while (exp > 0) {
    if (exp & 1) result = ((ll)result * base) % mod;
    base = ((ll)base * base) % mod;
    exp >>= 1;
    }
    return result;
}

void ipgraph(int n, int m){
    int i, u, v;
    while(m--){
        cin>>u>>v;
        g[u-1].pb(v-1);
        g[v-1].pb(u-1);
    }
}

void dfs(int u, int par){
    for(int v:g[u]){
        if (v == par) continue;
        dfs(v, u);
    }
}


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    unsigned ll n;
    cin>>n;
    string s="";
    while(n)
    {
        n-=1;
        int t = n%26;
        n/=26;
        s+=char('a'+(t));
    }   
    reverse(all(s));
    cout<<s;
    return 0;
}

Measured memory_bytes: 10684
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include<numeric>
#include<bitset>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const ll inf = 1LL<<60;

ll n,k;
int main(){
    cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	//cout << fixed << setprecision(15);
    cin>>n>>k;
    ll a[n];
    REP(i,n){
        cin >> a[i];
    }
    ll ans = inf;
    for(ll bit=0; bit < (1<<n); bit++){
        ll now = 0;
        ll max_l = 0;
        if(bitset<64>(bit).count() == k && (bit & 1)){
            REP(i,n){
                if(bit & (1<<i)){
                    if(max_l >= a[i]){
                        now += max_l+1 - a[i];
                        max_l = max_l+1;
                    }
                    else{
                        max_l = a[i];
                    }
                }
                else{
                    if(max_l < a[i]){
                        max_l = a[i];
                    }
                }
            }
            ans = min(ans,now);
        }
    }

    cout << ans << endl;
}

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

using namespace std;

int main(void) {
    int N;
    cin >> N;
    double ans = 0.0;
    for(int i=0; i<N; i++) {
        double x;
        string u;
        cin >> x >> u;
        if(u == "JPY") {
            ans += x;
        } else {
            ans += x * 380000.0;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<map>
using namespace std;
typedef pair<int, int> P;

struct SegTree {
    vector<long long> value;
    int M;

    SegTree(int n, int x = 0) {
        M = 1;
        while(M < n) M *= 2;
        value = vector<long long>(M * 2 - 1, x);
    }

    void clear(int x = 0) {
        for(int i = 0; i < M * 2 - 1; i++) value[i] = x;
    }

    void add(int p, long long x, int k = 0, int l = 0, int r = -1) {
        if(r == -1) r = M;

        if(r - l == 1) value[k] += x;    
        else {
            int m = (l + r) / 2;
            if(p < m) add(p, x, k * 2 + 1, l, m);
            else add(p, x, k * 2 + 2, m, r);

            value[k] = value[k * 2 + 1] + value[k * 2 + 2];
        }
    }

    long long sum(int a, int b, int k = 0, int l = 0, int r = -1) {
        if(r == -1) r = M;

        if(a <= l && r <= b) return value[k];
        else {
            int m = (l + r) / 2;
            long long s = 0;
            if (a < m) s += sum(a, b, k * 2 + 1, l, m);
            if (m < b) s += sum(a, b, k * 2 + 2, m, r);
            return s;
        }
    }
};

vector<int> compress(vector<int> x) {
    vector<int> axis(x);

    sort(axis.begin(), axis.end());

    for(int i = 0; i < x.size(); i++) {
        x[i] = lower_bound(axis.begin(), axis.end(), x[i]) - axis.begin();
    }

    return x;
}

const int MOD = 998244353;

P p[200000];
vector<int> x;
vector<int> y;

long long LU[200000];
long long LD[200000];
long long RU[200000];
long long RD[200000];

long long pow[200001];

int main() {
    int n, i;
    scanf("%d", &n);

    x = vector<int>(n);
    y = vector<int>(n);
    for(int i = 0; i < n; i++) {
        scanf("%d %d", &x[i], &y[i]);
    }    

    x = compress(x);
    y = compress(y);
    for(int i = 0; i < n; i++) p[i] = P(x[i], y[i]);

    sort(p, p + n);
    SegTree seg = SegTree(n);
    for(int i = 0; i < n; i++) {
        int y = p[i].second;
        LU[i] = seg.sum(0, y);
        LD[i] = seg.sum(y, n);
        seg.add(y, 1);
    }

    seg.clear();
    for(int i = n - 1; i >= 0; i--) {
        int y = p[i].second;
        RU[i] = seg.sum(0, y);
        RD[i] = seg.sum(y, n);
        seg.add(y, 1);
    }

    pow[0] = 0;
    for(int i = 1; i <= n; i++) pow[i] = (pow[i - 1] * 2 + 1) % MOD;

    long long ans = (n * pow[n]) % MOD;
    for(int i = 0; i < n; i++) {
        ans -= pow[LU[i] + RU[i]] + pow[RU[i] + RD[i]]
                + pow[RD[i] + LD[i]] + pow[LD[i] + LU[i]];
        ans += pow[LU[i]] + pow[RU[i]] + pow[RD[i]] + pow[LD[i]];
        ans %= MOD;
    }

    printf("%lld\n", (ans + MOD) % MOD);
    return 0;
}

Measured memory_bytes: 16092
#include<iostream>
#include<iomanip>
using namespace std; int main(){
    int a, b, d, r;
    double f;

    cin >> a >> b;

    d = a / b;
    r = a % b;
    f = double(a*100000)/double(b)/double(100000);

    //cout << d << " " << r << " " << f << endl;
    cout << a/b << " " << a%b << " ";
    cout<< fixed <<setprecision(10)<<double(a)/double(b) << endl;

    return 0;
}





Measured memory_bytes: 3276
N = int(input())
a_lis = list(map(int, input().split()))

ans = 1
if 0 in a_lis:
    ans = 0
    
else:
    for i in a_lis:
        ans *= i
        if ans > pow(10, 18):
            ans = -1
            break
        
print(ans)

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

using namespace std;

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

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

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

int main() {
    int N;
    cin >> N;
    for (int i = 0; i < N; i++) {
        int x;
        cin >> x;
        if (x % 2) continue;
        if (x % 3 != 0 && x % 5 != 0) {
            cout << "DENIED" << endl;
            return 0;
        }
    }
    cout << "APPROVED" << endl;
    return 0;
}


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

using usize = ::std::size_t;
using u64 = ::std::int_least64_t;
static constexpr u64 Inf = ::std::numeric_limits<u64>::max() / 2;

u64 N, D, X, Y;

int main(int argc, char *argv[])
{
    
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin >> N >> D;
    u64 cnt = 0;
    while (N--) {
        cin >> X >> Y;
        if (X*X + Y*Y <= D * D) {
            cnt++;
        }
    }
    
    cout << cnt << endl;
    
    return 0;
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
#define x first
#define y second
#define pb push_back
#define eb emplace_back
#define all(a) (a).begin(),(a).end()
#define SZ(a) (int)(a).size()
#define FOR(i, a, b) for(int i=(a); i<=(b); ++i)
#define iFOR(i, a, b) for(int i=(a); i>=(b); --i)
#define make_unique(a) sort(all((a))), (a).resize(unique(all((a)))-(a).begin())

using namespace std;

typedef pair<int,int> PII;
typedef long long LL;
typedef unsigned long long UL; // ULLONG_MAX, %llu
typedef unsigned int UI; //UINT_MAX %u
typedef double DD;
typedef long double LD;
typedef pair<LL,LL> PLL;
typedef pair<DD,DD> PDD;
typedef vector<int> VI;
typedef vector<LL> VL;

const int N = 200005;
vector<LL> A, B;
int main(){
    int n, m;
    LL k;
    scanf("%d %d %lld",&n,&m,&k);
    A.resize(n); B.resize(m);
    FOR(i, 0, n-1) scanf("%lld",&A[i]);
    FOR(i, 0, m-1) scanf("%lld",&B[i]);
    int ans = 0;
    FOR(i, 1, n-1) A[i] += A[i-1];
    FOR(i, 1, m-1) B[i] += B[i-1];
    ans = max((int)(upper_bound(all(A), k)-A.begin()), ans);
    ans = max((int)(upper_bound(all(B), k)-B.begin()), ans);
    FOR(i, 0, n-1){
        if(A[i] > k) break;
        int idx = upper_bound(all(B), k-A[i])-B.begin();
        ans = max(i+1+idx, ans);
    }
    printf("%d",ans);
	return 0;
}
/*
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 */


Measured memory_bytes: 6460
N,A,B,C = map(int,input().split())
l = [int(input()) for i in range(N)]
INF = 10**9

def dfs(cur,a,b,c):
    if cur == N:
        return abs(a-A)+abs(b-B)+abs(c-C)-30 if min(a, b, c) > 0 else INF
    ret0 = dfs(cur+1,a,b,c)
    ret1 = dfs(cur+1,a+l[cur],b,c)+10
    ret2 = dfs(cur+1,a,b+l[cur],c)+10
    ret3 = dfs(cur+1,a,b,c+l[cur])+10
    return min(ret0,ret1,ret2,ret3)

print(dfs(0,0,0,0))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pll = pair<ll,ll>;
using vpii = vector<pii>;
using vpli = vector<pli>;
using vpll = vector<pll>;

#define rep(i, n) for(int i=0;i<(int)n;i++)
#define rep2(i, s, n) for(int i=(s);i<(int)n;i++)
int INF=1e9+7;

int main() {
  long double A,B;
  cin >> A >> B;
  
  cout << (ll)(A*B) << endl;
}

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

int main() {
  int N;
  cin >> N;
  
  for( N < 1; N--;) {
    string c;
    cin >> c;
    
    if(c == "Y") {
      cout << "Four" << endl;
      break;
    }

    if(N == 0){
      cout << "Three" << endl;
      break;
    }
  }
}
  


Measured memory_bytes: 256
#include <bits/stdc++.h>
// iostream is too mainstream
#include <cstdio>
// bitch please
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <cmath>
#include <iomanip>
#include <time.h>
#define dibs reserve
#define OVER9000 1234567890
#define ALL_THE(CAKE,LIE) for(auto LIE =CAKE.begin(); LIE != CAKE.end(); LIE++)
#define tisic 47
#define soclose 1e-8
#define chocolate win
// so much chocolate
#define patkan 9
#define ff first
#define ss second
#define abs(x) ((x < 0)?-(x):x)
#define uint unsigned int
#define dbl long double
#define pi 3.14159265358979323846
using namespace std;
// mylittledoge

#ifdef DONLINE_JUDGE
	// palindromic tree is better than splay tree!
	#define lld I64d
#endif

int main() {
	cin.sync_with_stdio(0);
	cin.tie(0);
	cout << fixed << setprecision(10);
	int N;
	cin >> N;
	vector< pair<int,int> > A(N);
	for(int i =0; i < N; i++) {
		cin >> A[i].ff;
		A[i].ss =i;}
	sort(begin(A),end(A));
	int ans =0;
	for(int i =0; i < N; i++) if((A[i].ss-i)%2 != 0) ans++;
	cout << ans/2 << "\n";
	return 0;}

// look at my code
// my code is amazing


Measured memory_bytes: 1024
#include <stdio.h>
#include <math.h>
#define SUM(a,b) ((a)+(b))
#define MAX(a,b) ((a>b)? (a):(b))
int main(void){
    int i,j,n;double x[100],y[100],m;
    scanf("%d",&n);
    for(i=0;i<n;i++){scanf("%lf",&x[i]);}
    for(i=0;i<n;i++){scanf("%lf",&y[i]);}
    for(double j=1.0;j<=3.0;j=j+1.0,m=0){
        for(i=0;i<n;i++){m=SUM(m,pow(fabs(x[i]-y[i]),j));};m=pow(m,1.0/j); 
        printf("%lf\n",m);
    }
    m=0;for(i=0;i<n;i++){m=MAX(m,fabs(x[i]-y[i]));};printf("%lf\n",m);
    return 0;
}


Measured memory_bytes: 2108
#include <stdio.h>

int max(int *array) {
	int i, max;
	max = array[0];
	for (i = 1; i < 3; i++) {
		if (array[i] > max) { max = array[i]; }
	}
	return max;
}

int main(void) {
	int A, B, V[3];
	scanf("%d %d", &A, &B);
	V[0] = A + B;
	V[1] = A - B;
	V[2] = A * B;
	
	printf("%d\n", max(V));
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using ll = long long;
using P = pair<int, int>;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

signed main() {
    int h,w,k;
    cin >> h >> w >> k;
    string s[h];
    rep(i, h) {
        cin >> s[i];
    }
    int ans = INF;
    for (int bit = 0; bit < 1 << (h - 1); bit++) {
        int cnt = __builtin_popcount(bit);
        bool d[h - 1] = {};
        rep(i, h - 1) {
            if(bit & 1 << i){
                d[i] = true;
            }
        }
        bool flag = false;
        int sum = 0;
        int mx = 0;
        int cntw[cnt + 1] = {};
        int pre = -1;
        rep(i, w) {
            int now = 0;
            rep(j, h) {
                if(s[j][i] == '1'){
                    cntw[now]++;
                    mx = max(mx, cntw[now]);
                }
                if(d[j] == true){
                    now++;
                }
            }
            if(mx > k){
                if(i == pre){
                    flag = true;
                    break;
                }
                mx = 0;
                sum++;
                fill(cntw, cntw + cnt + 1, 0);
                pre = i;
                i--;
            }
        }
        if (flag) continue;
        ans = min(ans, sum + cnt);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int a,b;
    cin >> a >> b;
    if(a <= 0 && 0 <= b){
        cout << "Zero" << endl;
    }else if(a <= -2){
        if(abs(b-a)%2){
            cout << "Positive" << endl;
        }else{
            cout << "Negative" << endl;
        }
    }else{
        cout << "Positive" << endl;
    }

    return 0;
}

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

class P
{
    static void Main()
    {
        string s = Console.ReadLine();
        char[] c = { 'a', 'e', 'i', 'o', 'u' };
        Console.WriteLine(s.Where(x => !c.Contains(x)).Count() == 0 ? "vowel" : "consonant");
    }
}

Measured memory_bytes: 11348
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;

int main(){
  ll n,ma=1e17;cin>>n;
  for(int i=0;i<5;i++){
    ll a;cin>>a;
    if(ma>a)ma=a;
  }
  cout<<4+(n+ma-1)/ma<<endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define pi pair<int, int>
#define pll pair<ll, ll>
#define f first
#define s second
#define pb push_back
#define mp make_pair
#ifdef LOCAL
template <class T> ostream &operator<<(ostream &str, const vector<T> &vec) {
  str << '[';
  for (auto it = vec.begin(); it != vec.end(); it++) {
    if (it != vec.begin())
      str << ", ";
    str << *it;
  }
  str << ']';
  return str;
}
#define var(x) "[" << #x << ": " << x << "] "
#define dbg cerr << "  line " << __LINE__ << ": "
#else
#define var(x) 0
struct dbg_cls {
  template <class T> dbg_cls &operator<<(const T &oth) { return *this; }
} dbg;
#endif
using ll = long long;
int main(int argc, char **argv) {
  ios::sync_with_stdio(false), cin.tie(0);
  auto solve = [&]() {
    ll h1, m1, h2, m2, k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;

    ll total = (h2 - h1) * 60ll + m2 - m1;
    cout << max(0ll, total - k) << '\n';
  };
  int t;
  t = 1;
  while (t--)
    solve();
  return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;

int main(){
    int n, k; cin >> n >> k;
    long double acc=0.0;
    for (int i=1;i<=n;i++){
        long double front_num=0.0;
        if (i >= k){
            acc += 1.0;
        } else {
            long double val = i;
            while (true){
                val *= 2.0;
                front_num++;
                if (val >= k){
                    break;
                }
            }
            acc += pow(1.0/2.0, front_num);
        }
    }
    cout << setprecision(15) << (1.0 / (long double)(n)) * acc << endl;
}

Measured memory_bytes: 384
#include <iostream>

using namespace std;
int main(int argc, char *argv[]) {
	char a, b;
	while(cin >> a >> b) {
		int ans = 0;
		if(a == 'H')
			cout << b << endl;
		else {
			if(b == 'H')
				cout << "D" << endl;
			else {
				cout << "H" << endl;
			}
		}
	}
}

Measured memory_bytes: 256
# C - Folia
import sys
readline = sys.stdin.readline

N = int(readline())
A = list(int(x) for x in readline().split())

# 上から順に取りうる頂点数を数えていく

leaf = sum(A) # 葉の残り数
tmp = 1 # 葉を除く頂点数
ans = 0 
for a in A:
    # その深さの葉の数が頂点数より多ければNG
    if tmp < a:
        ans = -1
        break
    # その深さまでで見た時、残りの葉の数と頂点数は一致（葉の数に合わせる）
    ans += min(tmp, leaf) 
    # その深さで使った葉の数を、葉の残り数と葉を除く頂点数からそれぞれ引いておく
    leaf -= a 
    tmp -= a 
    # 次の階層の頂点数の最大数は、葉を除く頂点数*2である
    tmp *= 2

print(ans)

Measured memory_bytes: 20004
#include <cstdio> 
#include <iostream>
#include <algorithm>
using namespace std;

int n,k;
int a[200005];
int main()
{
	int i;
	cin>>n>>k;
	for(i=1;i<=n;i++)
		cin>>a[i];
	for(i=k+1;i<=n;i++)
		if(a[i]>a[i-k]) cout<<"Yes"<<endl;
		else cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 4408
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pb push_back
#define f(i,x,n) for(int i=x;i<n;i++)
#define all(c) c.begin(),c.end()
#define int ll
using ll = long long;
using pii = pair<int,int>;
const int MOD = 1e9+7, N = 1e5 + 10; 

int32_t main(){
   ios::sync_with_stdio(false);
   cin.tie(NULL);
   int a,b;
   cin >> a  >> b;
   int ans = max(0ll,a-2*b);
   cout << ans << '\n';
   return 0;
} 

Measured memory_bytes: 256
macro_rules! scan {
    () => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().to_string()
        }
    };
    (;;$n:expr) => {
        (0..$n).map(|_| scan!()).collect::<Vec<_>>()
    };
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty;;$n:expr) => {
        (0..$n).map(|_| scan!($t;;)).collect::<Vec<_>>()
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    scan!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    scan!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let (a, b, c, d, e, f) = scan!(i64, i64, i64, i64, i64, i64);
    let n = (f + 100 * a - 1) / (100 * a);
    let m = (f + 100 * b - 1) / (100 * b);
    let o = (f + c - 1) / c;
    let p = (f + c - 1) / d;

    let mut ans = (0, 0);
    for i in 0..n {
        for j in 0..m {
            for k in 0..o {
                for l in 0..p {
                    let water = i * 100 * a + j * 100 * b;
                    let suger = k * c + l * d;
                    if water + suger > f {
                        break;
                    }
                    if suger * 100 <= e * water {
                        if ans.1 * (suger + water) <= suger * (ans.0 + ans.1) {
                            ans.0 = water;
                            ans.1 = suger;
                        }
                    }
                }
            }
        }
    }
    println!("{} {}", ans.0 + ans.1, ans.1)
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
int main(){
    map<string,int> mp;
    int n,m;
    cin>>n;
    string s[n];
    for(int i=0;i<n;i++) {
        cin>>s[i];
        mp[s[i]]++;
    }
    cin>>m;
    string t[m];
    for(int i=0;i<m;i++){
        cin>>t[i];
        mp[t[i]]--;
    }
    int value=0;
    for( map<string ,int>::const_iterator it = mp.begin(); it != mp.end(); ++it ){

      value = max(value,it->second);
    }
    cout<<value<<endl;
return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cassert>
#include<math.h>
#include<complex>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<unordered_map>
#include<functional>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=2e18;
const ll MOD=1e9+7;

string N,M;
int main(){
    cin>>N>>M;
	if(N==M.substr(0,N.length())){
		cout<<"Yes";
	}
	else{
		cout<<"No";
	}

    return 0;
}

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


#define long long long int

using namespace std;

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


int main() {
    std::ios_base::sync_with_stdio(false);
    
    int n;
    cin >> n;
    cout << n * n;
    
    return 0;
}

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

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define TO_STRING(VariableName) # VariableName
#define LOG(x) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" ";
#define LOGE if(DEBUG)cout<<endl;

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


int main(){

	lli N,Y;
	cin>>N>>Y;

	REP(x,0,N+1){
		REP(y,0,N-x+1){
			lli z = N-x-y;
			if(z<0)continue;
			if(10000*x+5000*y+1000*z == Y){
				cout<<x<<" "<<y<<" "<<z<<endl;
				return 0;
			}
		}
	}

	cout<<"-1 -1 -1"<<endl;


    return 0;
}


Measured memory_bytes: 3592
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define mp make_pair
#define pb push_back
#define x first
#define y second
#define forn(i,a,n) for(int i=a;i<n;i++)
#define foreach(i,c) for(__typeof(c.begin())i=(c.begin());i!=(c).end();i++)
#define pii pair<int,int>
#define vi vector<int>
#define ll long long
#define sz(s) s.size()
#define all(s) s.begin(),s.end()
#define zero(x) memset(x,0,sizeof(x))
#define vii vector<pair<int,int> >;
#define mpis map<int,string>
#define mpii map<int,int>
#define mpsi map<string,int>
#define re return
using namespace std;
string s;
int n,k;
int main(){
	cin>>n>>k>>s;
	int c=1;
	for(int i=1;i<n;i++){
		if(s[i]==s[i-1])
		continue;
		c++;
	}
	while(c>1&&k>0){
		k--;
		if(c>2)
		c-=2;
		else
		c--;
	}
	cout<<n-c;
	re 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>
#include<map>
#include<unordered_map>

using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
using P=pair<int,int>;
using lint=long long;
using ll=long long;
const lint inf=1e18+7;
const int MOD=1000000007;
unordered_map<int,int> memo;
void solve(int n){
  int res=0;
  rep1(i,101){
    for(int j=i;j<=101;++j){
      auto it=memo.find((i+j)*(i+j)-(i*i+j*j+i*j-n)*4);
      if(it!=memo.end()){
        int r=it->second;
        if(r-i-j>=1&&(r-i-j)%2==0){
          if(j==i)++res;
          else res+=2;
        }
      }
    }
  }
  cout<<res<<"\n";
}
signed main(){
  int n;cin>>n;
  rep(i,n+5){
    memo[i*i]=i;
  }
  rep1(i,n){
    solve(i);
  }
  return 0;
}


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

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

  int product = a[0];
  for(int i=1; i<n; i++) {
    product = product^a[i];
  }

  for(int i=0; i<n-1; i++) {
    cout<<(product^a[i])<<' ';
  }
  cout<<(product^a[n-1])<<endl;

  return 0;
}

Measured memory_bytes: 4396
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Practice
{
    class Program
    {
        private static int ReadAndParseInt()
        {
            return int.Parse(Console.ReadLine());
        }
        private static int[] ReadAndParseIntArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
        }
        private static long ReadAndParseLong()
        {
            return long.Parse(Console.ReadLine());
        }
        private static long[] ReadAndParseLongArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
        }
        static void Main(string[] args)
        {
            SolveA(args);
            //SolveB(args);
            //SolveC(args);
            //SolveD(args);


        }
        private const long MOD = 1000000007;
        static void SolveA(string[] args)
        {
            var nm = ReadAndParseIntArr();
            long n = nm[0];
            long m = nm[1];

            if( n == 1 && m == 1)
            {
                Console.WriteLine(1);

            }
            else if ( n >= 3 &&  m >= 3)
            {
                Console.WriteLine((n - 2) * (m - 2));
            }
            else if( n >= 2 && m >= 2)
            {
                long ans = n * m;
                Console.WriteLine(0);
            }
            else
            {
                Console.WriteLine(n * m - 2);
            }
        }
    }
}

Measured memory_bytes: 11092
import itertools

N = int(input())
table = [[0] * N for i in range(N)]
points = []
A = [i for i in range(N)]
ans = 0
count = 0

for i in range(N):
    x, y = map(int, input().split())
    points.append((x, y))

for i in range(N):
    for j in range(N):
        dist = ((points[j][0]-points[i][0])**2 + (points[j][1]-points[i][1])**2)**(1/2)
        table[i][j] = dist
        table[j][i] = dist

for p in itertools.permutations(A,N):
    tmp = 0
    for k in range(N-1):
        tmp += table[p[k]][p[k+1]]
    ans += tmp
    count += 1
print(ans/count)


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

int main(){
	double ln,rn;
	int la=0,ra=0,lb=0,rb=0,lc=0,rc=0,ld=0,rd=0;
	while(cin >> ln >> rn){
		if(ln >= 1.1) la++;
		else if(ln >= 0.6) lb++;
		else if(ln >= 0.2) lc++;
		else ld++;
		if(rn >= 1.1) ra++;
		else if(rn >= 0.6) rb++;
		else if(rn >= 0.2) rc++;
		else rd++;
	}
	cout << la << " " << ra << endl;
	cout << lb << " " << rb << endl;
	cout << lc << " " << rc << endl;
	cout << ld << " " << rd << endl;
	return 0;
}

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(obj) (obj).begin(), (obj).end()
#define bit(n) (1LL << (n))

typedef long long ll;

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

const long long INF = 1LL << 60;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n,d; cin>>n>>d;
  int res = 0;
  
  rep(i,n) {
    ll x,y; cin>>x>>y;
    ll sum = x*x + y*y;
    double dis = pow(sum, 0.5);
    if (dis<=d) {
      ++res;
    }
  }
  
  cout<<res;
  return 0;
}

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

const long long INF = 1LL << 60;

int main() {
    int N, W;
    cin >> N >> W;
    long long w[N], v[N];
    for (int i = 0; i < N; i++) {
        cin >> w[i] >> v[i];
    }

    //dp[i][sum_v]を，i-1番目まででsum_vを越さないように
    //品物を選んだ時の重さの最小値と定義する。
    long long dp[N+1][100001];
    
    //初期化
    for (int i = 0; i <= N; i++) {
        for (int j = 0; j <= 100000; j++) {
            dp[i][j] = INF;
        }
    }

    for (int i = 0; i <= N; i++) {
        dp[i][0] = 0;
    }

    for (int i = 0; i < N; i++) {
        for (int j = 1; j <= 100000; j++) {
            if (j - v[i] >= 0) dp[i+1][j] = min(dp[i+1][j], dp[i][j-v[i]] + w[i]);
            dp[i+1][j] = min(dp[i+1][j], dp[i][j]);
        }
    }

    long long ans = 0;
    for (int i = 0; i <= 100000; i++) {
        if (dp[N][i] <= W) ans = i;
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 79104
function Puzzle(){
   var obj={};
   var arrA="123,234,345,456,567,678,789,111,222,333,444,555,666,777,888,999".split(",");
   var arrB="11,22,33,44,55,66,77,88,99".split(",");
   var i,j,k,l,m;
   for(i=0;i<16;i++)for(j=0;j<16;j++)for(k=0;k<16;k++)for(l=0;l<16;l++)for(m=0;m<9;m++){
      var str=arrA[i]+arrA[j]+arrA[k]+arrA[l]+arrB[m];
      str=str.split("").map(Number).sort(function(a,b){return a-b;}).join("");
      obj[str]=true;
   }
   return obj;
}
var P=Puzzle();
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.trim()).split("\n");
while(true){
   if(Arr.length==0)break;
   var str=Arr.shift();
   var ans=[];
   for(var i=1;i<=9;i++){
      var arr=str.split("").map(Number);
      arr.push(i);
      arr.sort(function(a,b){return a-b;});
      var v=arr.join("");
      if(/(.)\1\1\1\1/.test(v))continue;
      if(P.hasOwnProperty(v))ans.push(i);
   }
   console.log((ans.length==0)?"0":ans.join(" "));
}

Measured memory_bytes: 50052
n, m = map(int, input().split(' '))

flag = [0 for i in range(n)]
wa_count = [0 for i in range(n)]
count_ac = 0
count_wa = 0

for i in range(m):
    p, s = map(str, input().split(' '))
    p = int(p)
    if s == 'AC':
        if not flag[p-1]: # first AC
            count_ac += 1
            flag[p-1] = 1
            count_wa += wa_count[p-1]
    else: # WA
        if not flag[p-1]:
            wa_count[p-1] += 1

print('{} {}'.format(count_ac, count_wa))


Measured memory_bytes: 4760
#include <cstdio> 
#include <cstdlib> 
#include <cmath> 
#include <cstring> 
#include <climits> 
#include <cfloat> 
#include <map> 
#include <utility> 
#include <set> 
#include <iostream> 
#include <memory> 
#include <string> 
#include <vector> 
#include <algorithm> 
#include <functional> 
#include <sstream> 
#include <complex> 
#include <stack> 
#include <queue> 
#include <numeric>
#include <cassert>

#define FOR(i, min, max) for (int i = (min); i < (max); ++i) 
#define FORE(i, min, max) for (int i = (min); i <= (max); ++i) 
#define REP(i, n) for (int i = 0; i < (n); ++i) 
#define REPV(vec, i) for (int i = 0; i < (int)(vec.size()); ++i) 
#define FOR_EACH(vec, it) for (typeof((vec).begin()) it = (vec).begin(); it != (vec).end(); ++it)

using namespace std; 
static const double EPS = 1e-12; 
typedef long long ll; 

int main(void)
{
    int N, K;
    cin >> N >> K;
    vector<bool> have(N, false);
    int ret = N;
    REP(k, K) {
        int d;
        cin >> d;
        REP(i, d) {
            int a;
            cin >> a;
            if (!have[a-1])
                ret--;
            have[a-1] = true;
        }
    }
    cout << ret << endl;
    
    return 0;
}


Measured memory_bytes: 3604
#include <cstdio>

const int N = 1e5+10;

int n,p;
int pa[N+1];

int find(int x){
    while(x != pa[x])
        x = pa[x];
    return x;
}


int main(){
    while(scanf("%d%d",&n,&p) == 2){
        if(!n && !p) break;
        pa[1] = 1;
        for(int i=2; i<=n; i++)
            scanf("%d",&pa[i]);

        long long sum = 0;
        for(int i=1; i<=p; i++){
            char s[2];
            int x;
            scanf("%s%d",s,&x);
            if(s[0] == 'M')
                pa[x] = x;
            else
                sum += find(x);
        }
        printf("%lld\n",sum);
    }
}

Measured memory_bytes: 2952
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <algorithm>
#include <random>
#include <chrono>
#include <iomanip>
#define lint unsigned long long int
#define FOR(x, to) for(int x=0; x<(int)(to); x++)
#define DUMP(ar) for(auto itd=begin(ar); itd != end(ar); itd++) cout << "["s << itd - begin(ar) << "]:"s << *itd << endl
#define DUMPL(ar) for(auto itd=begin(ar); itd != end(ar); itd++) { cout << *itd; if(end(ar)-itd > 1) cout << ' '; } cout << endl
#define COUT(x) cout << (x) << endl
#define VCIN(ar) for(auto &vcin: (ar)) cin >> vcin
#define ALL(ar) ar.begin(), ar.end()
#define LOOPD(i) cout << "ループ["s << i << "]回目---------------"s << endl
using namespace std;
// lint:64ビット 10^19

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

    char n;
    cin >> n;
    COUT((char)(n+1));

    return 0;
}

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

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

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16
#define mod 1000000007

ll N,M,K;
ll fac[1000010],finv[1000010];

ll mod_pow(ll a,ll n){
  ll res=1;
  while(n>0){
    if(n&1)res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}
ll comb(ll n,ll r){
  if(n<0||r<0||n<r)return 0;
  return (fac[n]*finv[r]%mod)*finv[n-r]%mod;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  fac[0]=1;
  rep(i,1000001)fac[i+1]=fac[i]*(i+1)%mod;
  rep(i,1000001)finv[i]=mod_pow(fac[i],mod-2);

  cin>>N>>M>>K;
  
  ll res=0;
  ll k3=1;
  repl(i,N,N+M+K+1){
    ll R=i-N;
    ll k1=comb(i-1,N-1);
    ll k2=mod_pow(3,N+M+K-i);
    (res+=(k1*k2%mod)*k3%mod)%=mod;
    k3=(k3+k3)%mod;
    if(R>=K){
      k3=(k3-comb(R,R-K)+mod)%mod;
    }
    if(R>=M){
      k3=(k3-comb(R,M)+mod)%mod;
    }
  }
  cout<<res<<endl;

  return 0;
}


Measured memory_bytes: 15872
a, b, c, d, e, f = map(int, input().split())

L = []
for i in range(f//a//100+1):
    for j in range(f//b//100+1):
        if 0 < 100*(a*i+b*j) < f and 100*(a*i+b*j) not in L:
            L.append(100*(a*i+b*j))
            
W = 1
S = 0
for w in L:
    s = 0
    for j in range(w//c+1):
        for k in range(w//d+1):
            if (c*j+d*k)*100 <= e*w and c*j+d*k+w <= f:
                s = max(s, c*j+d*k)
    if S*(w+s) < s*(W+S):
        S = s
        W = w
    
if W >= 100:
    print(S+W, S)
else:
    print(100*a, 0)

Measured memory_bytes: 42092
def gcd(a,b):
    if b == 0:
        return a
    else:
        return gcd(b,a%b)

n,x = map(int,input().split())
lstx = [int(i) for i in input().split()]

g = abs(lstx[0]-x)
for i in range(1,n): g = gcd(g,abs(lstx[i]-x))

print(g)


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

template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void POSS(T condition){ if(condition) cout << "POSSIBLE" << endl; else cout << "IMPOSSIBLE" << endl; }
template<class T> inline void Poss(T condition){ if(condition) cout << "Possible" << endl; else cout << "Impossible" << endl; }
template<class T> inline void First(T condition){ if(condition) cout << "First" << endl; else cout << "Second" << endl; }
int character_count(string text, char character){ int ans = 0; for(int i = 0; i < text.size(); i++){ ans += (text[i] == character); } return ans; }
long power(long base, long exponent, long module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ long root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position move_pattern[4] = {{-1, 0}, {0, 1}, {1, 0}, {0, -1}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++){ ans += to_string(*i) + " "; } ans.pop_back(); cout << ans << endl; }
template<class T> T gcd(T a, T b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }} template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
#define mod long(1e9 + 7)
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl(long(n))

int main(){
    long H, W;
    int N;
    cin >> H >> W >> N;
    map<pair<long, long>, long> space;
    for(int i = 0; i < N; i++){
        long a, b;
        cin >> a >> b;
        for(int j = -1; j <= 1; j++){
            for(int k = -1; k <= 1; k++){
                space[{a + j, b + k}]++;
            }
        }
    }
    vector<long> ans(9, 0);
    long zero = (H - 2) * (W - 2);
    for(auto i: space){
        if(i.first.first >= 2 && i.first.first <= H - 1 && i.first.second >= 2 && i.first.second <= W - 1){
            ans[i.second - 1]++;
            zero--;
        }
    }
    cout << zero << endl;
    for(int i = 0; i < 9; i++){
        cout << ans[i] << endl;
    }
}


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

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

	int size, ANS = 0;
	size = S.size();

	if (S.at(0) == '0') {
		for (int i = 1; i < size; i += 2) {
			if (S.at(i) == '0') {
				S.at(i) = '1';
				ANS++;
			}
		}
		for (int i = 2; i < size; i += 2) {
			if (S.at(i) == '1') {
				S.at(i) = '0';
				ANS++;
			}
		}
	}
	else if (S.at(0) == '1') {
		for (int i = 1; i < size; i += 2) {
			if (S.at(i) == '1') {
				S.at(i) = '0';
				ANS++;
			}
		}
		for (int i = 2; i < size; i += 2) {
			if (S.at(i) == '0') {
				S.at(i) = '1';
				ANS++;
			}
		}
	}
	cout << ANS << endl;
}

Measured memory_bytes: 512
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,a,b) for(int i =(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define REPm(i,n) for(int i=(n)-1;i>=0;i--)
#define REP1(i,n) for(int i=1;i<=(n);i++)
#define mp make_pair
typedef long long ll;
int main(){
    int A,B;
    cin >> A >> B;
    if(A == B) cout << "Draw" << endl;
    else if(A == 1 || (B != 1 && A > B)) cout << "Alice" << endl;
    else cout << "Bob" << endl;
    return 0;
}


Measured memory_bytes: 384