akhauriyash/Code-Regression huggingface dataset:
//#include <math.h>
#include <bits/stdc++.h>
using namespace std;

int main(void){
    // 自分の得意な言語で
    // Let's チャレンジ！！
    int S,W;
    cin >> S >> W;
 
    if(S>W)
    cout << "safe"<< endl;
    else
    cout << "unsafe"<< endl;
        
    return 0;
}


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



int main() {
	

	double L;
	cin >> L;

	double V;

	
	V = (L / 3)*(L / 3)*(L / 3);

	
	
	printf("%lf", V);


	return 0;
}




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

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef priority_queue<int> PQ_DESC;
typedef priority_queue<int, vector<int>, greater<int>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define SORT_ASC(c) sort(ALL(c))
#define SORT_DESC(c) sort(ALL(c), greater<typeof(*((c).begin()))>())
#define SIZE(a) int((a).size())

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

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int LARGE_INT = 1e9+100;
const int INF = 2e9+100;
const LL INF_LL = (LL)INF * 300 * 300;
const int MOD = 1e9+7;

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

LL modpow(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 modinv(LL a) {
    LL b = MOD, u = 1, v = 0;
    while (b) {
        LL t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= MOD;
    if (u < 0) u += MOD;
    return u;
}

LL moddev(LL a, LL b){
	return a * modinv(b) % MOD;
}

void Main()
{
    int n; cin >> n;

    vector<pair<LL,LL>> x(n);
    REP(i,n){
        LL p,l; cin>>p>>l;
        x[i].first = p+l;
        x[i].second = p-l;
        //cin >> x[i].first >> x[i].second;
    }
    SORT_ASC(x);

    LL now = -1*LARGE_INT;
    int result = 0;

    REP(i,n){
        if(x[i].second >= now){
            result ++;
            now = x[i].first;
        }
        //cerr << i << " " << now << endl;
    }

    cout << result << endl;

	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
    return 0;
}

Measured memory_bytes: 1792
#include<algorithm>
#include<bitset>
#include<climits>
#include<cmath>
#include<cstdlib>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<time.h>
#include<tuple>
#include<utility>
#include<vector>

using namespace std;
long gcd(long x, long y) { if (x > y) { return gcd(y, x); } long r; while (y != 0) { r = x % y; x = y; y = r; } return x; }
long lcm(long x, long y) { return (x / gcd(x, y) * y); }

int main() {

	string S; cin >> S;
	long K; cin >> K;
	string DS = S + S;
    string TS = S + S + S;
	S = '.' + S;
	S = S + '.';
	DS = '.' + DS;
	DS = DS + '.';
    TS = '.' + TS;
    TS = TS + '.';

	long snum = 0, dsnum = 0, tsnum = 0;
    long count = 0;
	for (int i = 0; i < (long)S.length(); i++) {
        while(S[i] == S[i + 1]) {i++; count++;}
		snum += (count + 1) / 2;
        count = 0;
	}

	for (int i = 0; i < (long)DS.length(); i++) {
        while(DS[i] == DS[i + 1]) {i++; count++;}
		dsnum += (count + 1) / 2;
        count = 0;
	}
    
    for (int i = 0; i < (long)TS.length(); i++) {
        while(TS[i] == TS[i + 1]) {i++; count++;}
		tsnum += (count + 1) / 2;
        count = 0;
	}
    long ts = tsnum - snum;
    long ds = dsnum - snum;
    cout << ((K - 1) / 2) * ts + ((K - 1) % 2) * ds + snum << endl;
}

Measured memory_bytes: 256
#[warn(unused_imports)]
use proconio::{
   fastout, input,
   marker::{Bytes, Chars, Isize1, Usize1},
};

#[fastout]
fn main() {
   input! {
      mut x: i64
   }
   let mut b = -200;
   let mut a = -200;
   loop {
      let c = f5(b) - f5(a);
      if c == x {
         println!("{} {}", b, a);
         break;
      } else if c < x {
         b += 1;
      } else {
         a += 1;
      }
   }
}

fn f5(x: i64) -> i64 { x * x * x * x * x }


Measured memory_bytes: 2144
code = input()
n = int(input())

for i in range(n):
    lst = list(input().split())
    a = int(lst[1])
    b = int(lst[2])

    if lst[0] == 'replace':
        t1 = code[0:a]
        t2 = code[a:b+1]
        t3 = code[b+1:len(code)]
        code = t1 + lst[3] + t3

    elif lst[0] == 'reverse':
        s = code[a:b+1]
        ss = ''.join(list(reversed(s)))
        t1 = code[0:a]
        t2 = code[a:b+1]
        t3 = code[b+1:len(code)]
        code = t1 + ss + t3

    elif lst[0] == 'print':
        print(code[a:b+1])


Measured memory_bytes: 5616
#include <iostream>

using namespace std;

int K[8], u;

void check(int x) {
  if (x >= 1 && x <= 399) {
    K[0] = 1;
  }
  if (x >= 400 && x <= 799) {
    K[1] = 1;
  }
  if (x >= 800 && x <= 1199) {
    K[2] = 1;
  }
  if (x >= 1200 && x <= 1599) {
    K[3] = 1;
  }
  if (x >= 1600 && x <= 1999) {
    K[4] = 1;
  }
  if (x >= 2000 && x <= 2399) {
    K[5] = 1;
  }
  if (x >= 2400 && x <= 2799) {
    K[6] = 1;
  }
  if (x >= 2800 && x <= 3199) {
    K[7] = 1;
  }
  if (x >= 3200) {
    u++;
  }
}

int main() {
  int n;
  cin >> n;
  while (n--) {
    int x;
    cin >> x;
    check(x);
  }
  int ans_1 = 0;
  for (int i = 0; i < 8; i++) {
    ans_1 += K[i];
  }
  cout << max(1, ans_1) << ' ' << ans_1 + u << endl;
  return 0;
}


Measured memory_bytes: 256
/*Function Template*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int MAX = 510000;
const int MOD = 1000000007;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define Rep(i, n) for(ll i = 1; i < (n); i++)
#define ALL(a)  (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll fac[MAX], finv[MAX], inv[MAX];


template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }

}
ll Len(ll n) {
  ll s=0;
  while(n!=0) s++, n/=10;
  return s;
}


ll Sint(ll n) {
  ll m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(ll i=s-1;i>=0;i--) m+=n/((ll)pow(10,i))-(n/((ll)pow(10,i+1)))*10;
  return m;
}


ll Svec(vector<ll> v){
  ll n=0;
  for(ll i=0;i<v.size();i++) n+=v[i];
  return n;
}


ll GCD(ll a,ll b) {
  return b ? GCD(b,a%b) : a;
}


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


ll Factorial(ll n){
  ll m=1;
  while(n>=1) m*=n,n--;
  return m;
}

vector<pair<char,ll>> runlength(string s,vector<pair<char,ll>> p){
  ll x=1;
  if(s.size()==1){
    p.push_back(pair<char,ll>(s[0],1));
    return p;
  }
  for(ll i=0;i<s.size()-1;i++){
    if(s[i]==s[i+1]){
      x++;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[i],x));
      }
    }else{
      p.push_back(pair<char,ll>(s[i],x));
      x=1;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[s.size()-1],x));
      }
    }
  }
  return p;
}


ll COM(ll n,ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

const int MAX_N=100010;
vector<bool> sieve_of_eratosthenes(){
  vector<bool> isPrime(MAX_N+1,true);
  for(int i=2;i<=MAX_N;i++){
    if(isPrime[i]){
      for(int j=2*i;j<=MAX_N;j+=i){
        isPrime[j]=false;
      }
    }
  }
  return isPrime;
}



/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
int main() {
  IOS;
  ll n;
  cin>>n;
  vector<ll> a(n),b(n);
  rep(i,n) cin>>a[i]>>b[i];
  ll ans=0,tmp=b[0];
  rep(i,n){
    if(tmp>b[i]){
      tmp=b[i];
      ans=i;
    }
  }
  cout<<a[ans]+b[ans]<<endl;
}

Measured memory_bytes: 1792
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author dyominov
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ATrapezoids solver = new ATrapezoids();
        solver.solve(1, in, out);
        out.close();
    }

    static class ATrapezoids {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int a = in.nextInt();
            int b = in.nextInt();
            int h = in.nextInt();
            out.println((a + b) * (h / 2));
        }

    }

    static class InputReader implements AutoCloseable {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

        public void close() {
        }

    }
}



Measured memory_bytes: 22612
#include <iostream>

const int N_MAX = 1e5 + 5;

using namespace std;

int A[N_MAX];
int l_gcd[N_MAX];
int r_gcd[N_MAX];

int euclidean_gcd(int a, int b) {
    if (a < b) return euclidean_gcd(b, a);
    int r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

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

    l_gcd[0] = A[0];
    for (int i = 1; i < N - 1; i++) {
        l_gcd[i] = euclidean_gcd(l_gcd[i - 1], A[i]);
    }

    r_gcd[N - 1] = A[N - 1];
    for (int i = N - 2; i >= 0; i--) {
        r_gcd[i] = euclidean_gcd(r_gcd[i + 1], A[i]);
    }

    int ans = 0;
    for (int i = 0; i < N; i++) {
        if (i == 0) {
            ans = max(ans, r_gcd[1]);
        } else if (i == N - 1) {
            ans = max(ans, l_gcd[N - 2]);
        } else {
            ans = max(ans, euclidean_gcd(l_gcd[i - 1], r_gcd[i + 1]));
        }
    }

    cout << ans << endl;
}

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

using namespace std;
typedef long long ll;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int x;
    cin >> x;
    if(x>=30) cout << "Yes\n";
    else cout << "No\n";
    return 0;
}


Measured memory_bytes: 3604
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
typedef long long ll;

int main(){
    int n, q;
    ll k;
    cin >> n >> k >> q;

    vector<int> a(q), ans(n, 0);
    for(int i=0;i<q;i++){
        cin >> a[i];
        ans[a[i]-1]++;
    }

    for(int i=0; i<n; i++){
        if(k + ans[i] - q > 0){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
# define INF 0x3f3f3f3f

#define MOD 1000000007
#define ll long long
#define mp make_pair
#define pb push_back
#define pp popo_back
#define nl printf("\n");
#define sf scanf
#define pf printf
#define rep(i,n) for(ll i=0;i<n;i++)
#define vint vector<int> 
#define  tc int t;scanf("%d",&t);while(t--) 



int main()
{
    int n,m;
    cin>>n>>m;
    ll a[n][2],b[m][2];
    rep(i,n)
        cin>>a[i][0]>>a[i][1];
    rep(i,m)
        cin>>b[i][0]>>b[i][1];
    ll g,h;
    ll j;
    rep(i,n)
    {
        g=0;
        ll x=a[i][0],y=a[i][1];
        ll min=INF;
        for(j=0;j<m;j++)
        {
            if(abs(x-b[j][0])+abs(y-b[j][1])<min)
            {
                min=abs(x-b[j][0])+abs(y-b[j][1]);
                g=j;
            }
        }
        cout<<g+1;
        nl;
    }
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
 
int main(){
  int i,n,x;
  i=1;
  cin>>n;
  while(i<=n){
    x=i;
    if(x%3==0){
      cout<<" "<<i;
    }else {
      for(x=i;x;x/=10){
	if (x%10==3){
	  cout<<" "<<i;
	  break;
	}
      }
    }
    i++;
  }
  cout<<endl;
}

Measured memory_bytes: 3100
n = int(input())
sum = 0
nums = dict()
for num in input().split():
	sum += int(num)
	nums[num] = nums.get(num, 0) + 1
q = int(input())
for v in range(q):
	bi, ci = [vi for vi in input().split()]
	count = nums.get(bi, 0)
	change = (int(ci) - int(bi)) * count
	sum += change
	print(sum)
	if count != 0:
		nums[bi] = 0
	nums[ci] = nums.get(ci, 0) + count
	


Measured memory_bytes: 20292
#include <cstdio>
#include <cctype>
#include <utility>
#include <vector>
#include <complex>
#include <algorithm>
using namespace std;

#define gcu getchar_unlocked
#define pcu putchar_unlocked
#define _T template <typename T>
#define _HT template <typename H, typename... T>
#define _il inline
#define _in _il int in
#define _sc _il bool scan
_T T in(int c){T n=0;bool m=false;while(isspace(c)){c=gcu();}if(c=='-')m=true,c=gcu();
	do{n=10*n+(c-'0'),c=gcu();}while(c>='0'&&c<='9');return m?-n:n;}
_in() {return in<int>(gcu());}
_T T scan(T &n){int c=gcu();return c==EOF?false:(n=in<T>(c),true);}
_sc(char &c){c=gcu();gcu();return c!=EOF;}
#ifdef _GLIBCXX_STRING
_sc(string &s){int c;s="";
	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=c;}}
#endif
_HT _sc(H &h, T&&... t){return scan(h)&&scan(t...);}
#define _vo _il void out
#define _vl _il void outl
_vo(bool b) {pcu('0'+b);}
_vo(const char *s){while(*s)pcu(*s++);}
_vo(char c){pcu(c);}
#ifdef _GLIBCXX_STRING
_vo(string s){for(char c:s)pcu(c);}
#endif
_T _vo(T n){static char buf[20];char *p=buf;
	if(n<0)pcu('-'),n*=-1;if(!n)*p++='0';else while(n)*p++=n%10+'0',n/=10;
	while (p!=buf)pcu(*--p);}
_vl(){out('\n');}
#ifdef _GLIBCXX_VECTOR
_T _vo(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);outl();}
#endif
_HT _vo(H&& h, T&&... t){out(h);out(move(t)...);}
template <typename... T> _vl(T&&... t){out(move(t)...);outl();}

using C = complex<int>;
using V = vector<C>;

V read () {
	V v(in());
	C c = {in(), in()};
	v[0] = {0, 0};
	for_each(v.begin() + 1, v.end(), [&](auto &x) {x = C{in(), in()} - c;});
	return move(v);
}

int main() {
	for (int n; (n = in());) {
		V a = read(), b;
		vector<V> v(8);
		auto rot = [&a](auto b, auto e) {
			for_each (b, e, [&a](auto &x) {
					  x = a;
					  for_each(a.begin() + 1, a.end(), [](auto &x) {x *= C{0, 1};});});
		};
		rot(v.begin(), v.begin() + 4);
		reverse(a.begin(), a.end());
		C c = a[0];
		for_each(a.begin(), a.end(), [=](auto &x) {x -= c;});
		rot(v.begin() + 4, v.end());
		for (int i = 1; i <= n; i++) {
			b = read();
			if(find(v.begin(), v.end(), b) != v.end())
				outl(i);
		}
		outl("+++++");
	}
}


Measured memory_bytes: 2436
import math
import operator as op
from functools import reduce

def ncr(n, r):
    r = min(r, n-r)
    numer = reduce(op.mul, range(n, n-r, -1), 1)
    denom = reduce(op.mul, range(1, r+1), 1)
    return numer / denom
"""
int(input())
map(int,input().split())
list(map(int,input().split()))
"""


            
       

t=1
for term in range(1,t+1):
    n,m=map(int,input().split())
    A=list(map(int,input().split()))
    s=sum(A)
    if(n>=s):
        print(n-s)
    else:
        print(-1)

Measured memory_bytes: 10264
n,m=[int(i) for i in input().split()]
new_n=min(n,m)
new_m=max(n,m)
mod=10**9+7
def ans(n,m):

    if n==m:
        return 2*kaijyou(n,mod)*kaijyou(m,mod)
    elif m-n==1:
        return kaijyou(n,mod)*kaijyou(m,mod)
    else:
        return 0


def kaijyou(n,mod):
    ans=1
    for i in range(1,n+1):
        ans*=i
        ans=ans%mod
    return ans
print(ans(new_n,new_m)%mod)

Measured memory_bytes: 9212
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second

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

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const double EPS = 1e-8;

template<typename T> T chmax(T& a, const T& b){return a = (a > b ? a : b);}
template<typename T> T chmin(T& a, const T& b){return a = (a < b ? a : b);}

int main(){
    int n, k;
    cin >> n >> k;
    vl a(n);
    rep(i, n) cin >> a[i];
    ll ans = 1e18;
    rep(mask, 1 << n) if(__builtin_popcount(mask) >= k) {
        ll tmp = 0;
        ll pre = 0;
        rep(i, n) {
            if(mask&(1<<i)) {
                if(pre >= a[i]) {
                    tmp += pre - a[i]+1;
                    pre++;
                }
            }
            chmax(pre, a[i]);
        }
        // cout << bitset<8>(mask) << " " << tmp << " " << pre<< endl;
        chmin(ans, tmp);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstring>
#include <iostream>
#include <cassert>
#include <queue>
#include <map>
#include <string>
#include <tuple>
using namespace std;

char a[9];
typedef tuple<string, int> T;
int d[4] = {1, -1, 4, -4};
map<string, int> sol;

int bfs(string state) {
    if (sol.find(state) != sol.end()) {
        return sol[state];
    }
    else {
        auto Q = queue<T>();
        sol["01234567"] = 0;
        Q.push(make_tuple("01234567", 0));

        string s;
        int x, t;
        while (!Q.empty()) {
            tie(s, t) = Q.front(); Q.pop();
            x = s.find('0');
            for (int i = 0; i < 4; ++i) {
                int xx = x + d[i];
                if (d[i] ==  1 && x == 3) continue;
                if (d[i] == -1 && x == 4) continue;
                if (0 <= xx && xx < 8) {
                    swap(s[x], s[xx]);
                    if (sol.find(s) == sol.end()) {
                        sol[s] = t+1;
                        Q.push(make_tuple(string(s), t + 1));
                    }
                    swap(s[x], s[xx]);
                }
            }
        }
        return sol[state];
    }
}

int main() {
    while (cin >> a[0]) {
        for (int i=1; i<8; ++i) cin >> a[i];
        string s = string(a);
        cout << bfs(s) << endl;
    }
    return 0;
}



Measured memory_bytes: 5440
#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++)
#define ALL(v) v.begin(), v.end()
#define downque(que)  priority_queue<ll> que;
#define upque(que) priority_queue<ll, vector<int>, greater<int>> que;
typedef long long ll;
typedef vector<vector<int> > Matrix;
const int MOD = 1e9+7;


int main(){
  int n,m; cin>>n>>m;
  int res=0;

  Matrix s(m);
  REP(i,m){//入力
  int k; cin>>k;
  REP(j,k){
    int a; cin>>a;
    s[i].push_back(a-1);
  }
  }
  vector<int> p(m);
  REP(i,m)cin>>p[i];

  /*REP(i,m){
    REP(j,s[i].size())cout<<"電球"<<i<<"につながってるスイッチ"<<s[i][j]<<endl;
  }*/

  for(int bit = 0; bit < (1<<n); ++bit){
   bool flag=1;
    REP(i,m){
      int sum=0;
      REP(j,s[i].size()){
         if(bit&(1<<s[i][j]))sum++;
        }
        if(sum%2!=p[i])flag=0;
    }//repi
    if(flag)res++;
  }

  cout<<res<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#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 = 1e16;
const double pi = acos(-1);

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

    vl d(3);
    rep(i, 3) {
        cin >> d[i];
    }

    vector<P> p(n+1);
    rep(i, n) {
        string s;
        cin >> s;
        if(s == "AB") {
            p[i] = make_pair(0, 1);
        }
        else if(s == "AC") {
            p[i] = make_pair(0, 2);
        } 
        else if(s == "BC") {
            p[i] = make_pair(1, 2);
        } 
    }
    p[n] = make_pair(0, 1);

    vector<char> ans;
    auto add = [&](ll a, ll b) {
        d[a]++;
        d[b]--;
        char c = 'A' + a;
        ans.pb(c);
    };

    rep(i, n) {
        ll a = p[i].first;
        ll b = p[i].second;
        if(d[a] == 0 && d[b] == 0) {
            out("No");
            re0;
        }
        if(d[a] == 0) {
            add(a, b);
        }
        else if(d[b] == 0) {
            add(b, a);
        }
        else {
            ll na = p[i+1].first;
            ll nb = p[i+1].second;
            if(a == na || a == nb) {
                add(a, b);
            }
            else {
                add(b, a);
            }
        }
    }

    out("Yes");
    for(auto c : ans) {
        out(c);
    }

    re0;
}

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

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

Measured memory_bytes: 3604
S = str(input())
T = str(input())
char = []
flag = True
for i in range(len(S)):
    if S[i] != T[i]:
        if (S[i] not in char) and (T[i] not in char):
            table = str.maketrans({S[i]:T[i], T[i]:S[i]})
            S = S.translate(table)
            char.append(T[i])
        else:
            flag = False
            break
    else:
        char.append(T[i])
# print(S)
if flag:
    print('Yes')
else:
    print('No')

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

int main() {
    int a,b,c,k,d,e;
    cin >> a >> b >> c >> k;
    d=max(a,max(b,c));
    e=d;
    for(int i=0;i<k;i++){
        d*=2;
    }
    cout << a+b+c-e+d << endl;
}

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

using namespace std;

typedef long long ll;

int main(){
	int d;
	cin >> d;
	if(d == 22)cout << "Christmas Eve Eve Eve" << endl;
	else if(d == 23)cout << "Christmas Eve Eve" << endl;
	else if(d == 24)cout << "Christmas Eve" << endl;
	else if(d == 25)cout << "Christmas" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
#define abs(x) ((x)>0)?(x):(-(x))

int main(void)
{
	int S_1 = 0, S_2 = 0;
	int N, W[100];
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> W[i];
		S_1 += W[i];
	}
	int diff = S_1;
	for (int i = 0; i < N; i++) {
		S_1 -= W[i];
		S_2 += W[i];
		int tmp = abs(S_1 - S_2);
		if (diff > tmp)diff = tmp;
		else break;
	}
	cout << diff << endl;

	return 0;
}

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

int main() {
  int n;
  cin >> n;
  ll A = 1;
  bool overflow = false;
  for (int i = 0; i < n; i++) {
    ll a;
    cin >> a;
    if (a == 0) {
      cout << 0 << endl;
      return 0;
    }

    if (overflow) continue;

    double da, dA;
    da = (double)a;
    dA = (double)A;
    if (da * dA >= 2.0 * 1e18) {
      overflow = true;
      continue;
    }

    A *= a;
    if (A > (ll)1e18) overflow = true;
  }

  if (overflow) cout << -1 << endl;
  else cout << A << endl;

  return 0;
}

Measured memory_bytes: 3652
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int q = sc.nextInt();
		for(int k = 0; k < q; k++) {
			String x = sc.next();
			String y = sc.next();
			int s = x.length();
			int t = y.length();
			int[][] dp = new int[s + 1][t + 1];
			for(int i = 1; i <= s; i++) {
				for(int j = 1; j <= t; j++) {
					if(x.charAt(i - 1) == y.charAt(j - 1)) {
						dp[i][j] = dp[i - 1][j - 1] + 1;
					}else {
						dp[i][j] = Math.max(dp[i - 1][j], dp[i][j - 1]);
					}
				}
			}
			System.out.println(dp[s][t]);
		}
	}
}




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

/* define const */

/* finish defineing const */

int m, n;
string a[60];
string b[60];

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

    bool f = true;
    for (int i = 0; i <= n - m; i++)
    {
        for (int j = 0; j <= n - m; j++)
        {
            f = true;
            for (int k = 0; k < m; k++)
            {
                for (int l = 0; l < m; l++)
                {
                    if (a[i + k][j + l] != b[k][l])
                    {
                        f = false;
                    }
                }
            }
            if (f == true)
            {
                goto L;
            }
        }
    }

L:
    if (f)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
N, K = map(int, input().split())
ans = 0
point = 0

for i in range(N):
  point = i+1
  t_ans = 1/N
  while point >= 1 and point <= K-1:
    point = point * 2
    t_ans = t_ans / 2
  ans += t_ans

print(ans)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize ("Ofast")
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
using namespace __gnu_pbds;
using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<long long,long long> ii; 	
typedef complex<long double> com;

const ll mod = 1e9+7;
const ld PI = 3.14159265358979323846;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll k;
	cin >> k;
    string s;
	cin >> s;
	if (s.size() <= k) cout << s << endl;
	else cout << s.substr(0,k) + "..." << endl;
} 

Measured memory_bytes: 3616
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18


int main() {
	LL n; cin >> n;
	vector<LL> a(n+1);

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

	vector<vector<LL>> dp(n+10, vector<LL>(2));
	dp[0][0] = 0;
	dp[0][1] = -INF2;

	for (int i = 1; i < n; i++) {
		dp[i][0] = max(dp[i - 1][0] + a[i], dp[i - 1][1] - a[i]);
		dp[i][1] = max(dp[i - 1][0] - a[i], dp[i - 1][1] + a[i]);
	}

	cout << max(dp[n-1][0]+a[n], dp[n-1][1]-a[n]) << endl;
	
	return 0;
}

Measured memory_bytes: 6528
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
const double PI = acos(-1);
const double EPS = 1e-15;
long long INF=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd_(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}
 
class UnionFind {
    public:
    //各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。
    vector<int> Parent;
    
    //クラスを作るときは、Parentの値を全て-1にする。
    //以下のようにすると全てバラバラの頂点として解釈できる。
    UnionFind(int N) {
        Parent = vector<int>(N, -1);
    }
    
    //Aがどのグループに属しているか調べる
    int root(int A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
    
    //自分のいるグループの頂点数を調べる
    int size(int A) {
        return -Parent[root(A)];//先祖をrootで取っておきたい。
    }
    
    //AとBをくっ付ける
    bool connect(int A, int B) {
        //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        if (A == B) {
            //すでにくっついてるからくっ付けない
            return false;
        }
        
        //大きい方(A)に小さいほう(B)をくっ付けたい
        //大小が逆だったらAとBをひっくり返す。
        if (size(A) < size(B)) swap(A, B);
        
        //Aのサイズを更新する
        Parent[A] += Parent[B];
        //Bの親をAに変更する
        Parent[B] = A;
        
        return true;
    }
};

int main(){
  
  int n;
  cin>>n;
  vector<int> v(n);
  REP(i,n){
    cin>>v[i];
  }
  sort(v.begin(),v.end());
  double ans;
  REP(i,n){
    if(i==0){
      ans = (double)v[i];
    }else{
      ans = (ans + (double)v[i])/2.0;
    }
  }
  cout << fixed << setprecision(6) << ans << endl;
  return 0;
}

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

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

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

  vector<char> winner(k + 1);
  for (int i = 0; i <= k; i++) {
    if (i < *min_element(a.begin(), a.end())) {
      winner[i] = 's';
    } else if (find (a.begin(), a.end(), i) != a.end()) {
      winner[i] = 'f';
    } else {
      bool found = false;
      for (int j = 0; j < a.size(); j++) {
        if (a[j] < i) {
          if (winner[i - a[j]] == 's') {
            found = true;
            break;
          }
        } else {
          break;
        }
      }
      if (found)
        winner[i] = 'f';
      else
        winner[i] = 's';
    }
  }

  if (winner[k] == 'f')
    cout << "First \n";
  else
    cout << "Second \n";
  return 0;
}

Measured memory_bytes: 384
def main():
    N,K,S = [int(n) for n in input().split()]
    if S == 1:
        A = []
        for i in range(K):
            A.append("1")
        for i in range(N-K):
            A.append("10")
        print(" ".join(A))
        return
    if K==1:
        A = []
        A.append(str(S))
        for i in range(N-1):
            A.append(str(S-1))
        print(" ".join(A))
        return

    if S == 2:
        A = []
        for i in range(K):
            A.append("2")
        for i in range(N-K):
            A.append("10")
        print(" ".join(A))
        return
    # A = []
    # for i in range(N+1):
    #     A.append(S*i)
    # K = N-K
    # for i in range(1,N+1,2):
    #     # print(i)
    #     if K == 1:
    #         A[-1]-=1
    #         break
    #     if K == 0:
    #         break
    #     A[i]-=1
    #     K-=2
    B = []
    for i in range(K):
        B.append(str(S))
    for i in range(N-K):
        B.append(str(S-1))

    print(" ".join(B))
main()

Measured memory_bytes: 53488
#include<bits/stdc++.h>
#define LiangJiaJun main
#define ll long long
using namespace std;
ll x,sum,maxn;
int n;
int LiangJiaJun(){
    cin>>n;
    sum=0;
    maxn=0;
    for(int i=1;i<=n;i++){
        cin>>x;sum+=x;
        maxn=max(maxn,x);
    }
    cout<<sum-maxn/2<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<sstream>
#include<vector>
#include<iterator>
#include<algorithm>
#include<bitset>
using namespace std;

int main(void)
{
	long long N, K;
	cin >> N >> K;

	vector<long long> A(N);
	for(int i=0; i<N; i++)
		cin >> A[i];

	const int length = 50;
	vector<long long> cnt(length, 0);
	for(int i=0; i<N; i++){
		bitset<length> bit(A[i]);
		for(int j=0; j<length; j++)
			cnt[j] += bit[j];
	}

	reverse(cnt.begin(), cnt.end());

	long long ans = 0;
	long long k = 0;
	for(int i=0; i<length; i++){
		bool bit;
		int count;
		if(cnt[i] > N-cnt[i]){
			bit = 0;
			count = cnt[i];
		}
		else{
			bit = 1;
			count = N - cnt[i];
		}
		int shift = length - i - 1;
		long long n = (long long)bit << shift;
		long long value = (long long)1 << shift;
		if(k+n <= K)
			k += n;
		else
			count = N - count;

		ans += value * count;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
using namespace std;
int main(void){
  int a[3];
  for(int i = 0; 3 > i; i++) cin >> a[i];
  if(a[0] == a[1] && a[0] != a[2]){
    cout << "Open" << endl;
  } else {
    cout << "Close" << endl;
  }
}


Measured memory_bytes: 3044
#pragma region
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <iomanip>
#include <cstdint>
#include <cstdlib>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()
#pragma endregion


int main()
{
	int n, k; cin >> n >> k;
	vector<ll> a(n), b(n);
	rep(i, n)cin >> a[i] >> b[i];
	ll res = 0;
	ll tmp = 0;
	rep(i, n)
	{
		if ((k | a[i]) == k)
		{
			tmp += b[i];
		}
	}
	res = tmp;
	rep(i, 31)
	{
		if (k < (1 << i))break;
		if (!(k&(1 << i)))continue;
		int mask = 0;
		rep(j, i)mask += 1 << j;
		int c = 0;
		rep(j, 31)if (i != j) c += 1 << j;
		c &= k;
		c |= mask;
		tmp = 0;
		rep(i, n)if ((c | a[i]) == c)tmp += b[i];
		res = max(res, tmp);
	}
	cout << res << endl;
}

Measured memory_bytes: 1920
import copy

def bubbleSort(A, N):
    count = 0
    for i in range(1, N):
        for j in reversed(range(i, N)):
            if A[j][1] < A[j-1][1]:
                A[j], A[j-1] = A[j-1], A[j]
                count += 1

def selectionSort(A, N):
    count = 0
    for i in range(N):
        min = i
        for j in range(i, N):
            if A[j][1] < A[min][1]:
                min = j
        if min != i:
            A[i], A[min] = A[min], A[i]
            count += 1

def prArr(A, N):
    for i in range(N):
        if i != 0:
            print(" ", end = "")
        print(A[i], end = "")
    print()

N = int(input())
A = [i for i in input().split()]
B = copy.deepcopy(A)

bubbleSort(A, N)
selectionSort(B, N)

prArr(A, N)
print("Stable")
prArr(B, N)
print("Stable" if A == B else "Not stable")



Measured memory_bytes: 6348
n, m = map(int,input().split())
h = list(map(int,input().split()))

ab = [list(map(int,input().split())) for i in range(m)]
l = [[] for i in range(n)]



for i in range(m):
    if h[ab[i][0]-1] > h[ab[i][1]-1]:
        l[ab[i][0]-1].append(1)
        l[ab[i][1]-1].append(0)
    
    elif h[ab[i][1]-1] > h[ab[i][0]-1]:
        l[ab[i][0]-1].append(0)
        l[ab[i][1]-1].append(1)
    else:
        l[ab[i][0]-1].append(0)
        l[ab[i][1]-1].append(0)
        

cnt = 0

for i in l:
    if len(i) == i.count(1) or len(i) == 0:
        cnt += 1
        
print(cnt)
    

Measured memory_bytes: 41484
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <deque>
#include <set>
#include <iomanip>
#include <utility>
#define ll long long
#define ld long double
using namespace std;

ll mod=1000000007;
ll gcd(ll a, ll b){
	if(a%b) return gcd(b, a%b);
	else return b;
}
ll modpow(ll a, ll b, ll m){
    ll res=1, p=0, now=a;
    b %= (m-1);
    for(int i=0; b>p; ++i){
        if(b&((ll) 1<<i)){
            res=(res*now)%m;
            p |= ((ll) 1<<i);
        }
        now=(now*now)%mod;
    }
    return res;
}
ll modinv(ll a, ll m){
    return modpow(a, m-2, m);
}
ll moddiv(ll a, ll b, ll m){
    return (a*modinv(b, m))%m;
}

int main() {
	ll H, W, T;
	cin >> H >> W >> T;
	ll gh=gcd(H, T), gw=gcd(W, T);
	ll mh=H/gh, mw=W/gw;
	ll ans=(modpow(2, mh, mod)+modpow(2, mw, mod)-1)%mod;
	ll x=gcd(mh, mw);
	ans=(ans+modpow(2, x, mod)+mod-2)%mod;
	ans=modpow(ans, gh*gw, mod);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std ;
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define rep(i,a,b) for(int i=a; i<=b; i++)
#define per(i,b,a) for(int i=b; i>=a; i--)
#define sz(v) (int)v.size()
#define len(s) (int)s.length()
#define all(v) v.begin(), v.end()
#define pb push_back
#define fi first
#define se second
typedef pair<int, int> pi ;
typedef vector<pair<int,int> > vpi ;
typedef vector<int> vi ;
typedef long long ll ;
typedef double db ;
typedef long double ldb ;
const int mod = 1e9 + 7;
const int cmod = 998244353 ;
const int inf = 2e9 + 5;
const db cpi = 3.14159265358 ;
ll powmod(ll a, ll b) { ll ret = 1 ; while(b) { if(b&1) ret = (ret*a)%mod ;  a = (a*a)%mod ; b >>= 1 ; }  return ret ; }
const int maxn = 3e5 + 5 ;
int n, m ;
int p[maxn] ;
struct DSU
{
    int par[maxn], csz[maxn] ;
    void init()
    {
        rep(i,0,n-1)
        {
            par[i] = i ;
            csz[i] = 1 ;
        }
    }
    int root(int v)
    {
        return par[v] == v ? v : par[v] = root(par[v]) ;
    }
    void join(int u, int v)
    {
        u = root(u) ;
        v = root(v) ;
        if(u == v) return ;
        if(csz[u] < csz[v]) swap(u, v) ;
        csz[u] += csz[v] ;
        par[v] = u ;
    }
};
DSU uf ;
int pos[maxn] ;
int main()
{
    ios::sync_with_stdio(false) ;
    cin.tie(NULL) ;
    cin >> n >> m ;
    rep(i,0,n-1)
    {
        cin >> p[i] ;
        p[i]-- ;
        pos[p[i]] = i ;
    }
    uf.init() ;
    while(m--)
    {
        int u, v ;
        cin >> u >> v ;
        u-- ;
        v-- ;
        uf.join(u,v) ;
    }
    int res = 0 ;
    rep(i,0,n-1)
    {
        if(uf.root(pos[i]) == uf.root(i)) res++ ;
    }
    cout << res << "\n" ;
    return 0 ;
}


Measured memory_bytes: 3072
/*
 * a.cpp
 *
 *  Created on: 2019/06/08
 *      Author: MEIP-users
 */




#include <bits/stdc++.h>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1e9+10)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))


int main() {
	int n, k;
	cin >> n >> k;
	vector<int> v(n, 1);
	rep(i, k){
		int d;
		cin >> d;
		rep(j, d){
			int a;
			cin >> a;
			v.at(a-1) = 0;
		}
	}
	int ans;
	rep(i, n){
		if(v.at(i)==1){
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>

using namespace std;
#define vsort(v) sort(v.begin(), v.end());
#define vsort_reverse(v) sort(v.begin(), v.end(), greater<int>());
#define bsearch(v, n) binary_search(v.begin(), v.end(), n)
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);

	int N, M, X;
	cin >> N >> M >> X;
	vector<int> A;
	for(int i = 0;i < M; i++) {
		int x;
		cin >> x;
		A.push_back(x);
	}
	int cost1 = 0;
	int cost2 = 0;
	
	vsort(A);
	for(int i = X; i < N; i++) {
		if(bsearch(A, i)) cost1 += 1;
	}
	
	for(int i = X; i > 0; i--) {
		if(bsearch(A, i)) cost2 += 1;
	}

	int rslt = min(cost1, cost2);
	cout << rslt << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
	int n,x;
	cin>>n>>x;
	int a[n];
	int i,j;
	for(i=0; i<n; i++)
		cin>>a[i];
	sort(a,a+n);
	int count=0;
	for(i=0; i<n; i++)
	{
		if(x>=a[i]&&i!=n-1)
		{
			x-=a[i];
			count++;
		}
		else if(x<a[i])
			break;
		else
		{
			if(x==a[i]) count++;
		}
	}
	cout<<count;
}

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

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

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

#define MAX 100005
#define INF 1001001001

int main(int, char**)
{
  int n; cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];

  int m; cin >> m;
  vector<int> b(m);
  rep(i,m) cin >> b[i];

  vector<int> ans;
  set_difference(a.begin(), a.end(),
  b.begin(), b.end(),
  inserter(ans, ans.end()));

  for (auto a : ans) cout << a << endl;

  return 0;
}



Measured memory_bytes: 5492
import queue
N, M = map(int, input().split())
q=queue.Queue()
room=[['' for i in range(0)] for j in range(N+1)]
checkRoom=[0 for j in range(N+1)]
for i in range(M):
    A, B = map(int, input().split())
    room[A].append(B)
    room[B].append(A)
q.put(1)
while not q.empty():
    checkI=q.get()
    for j in range(len(room[checkI])):
        if checkRoom[room[checkI][j]]==0:
            q.put(room[checkI][j])
            checkRoom[room[checkI][j]]=checkI
print("Yes")
for i in range(2,N+1):
    print(checkRoom[i])

Measured memory_bytes: 34312
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb(x) push_back(x)
#define all(x) x.begin(), x.end()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = 1e9;
const ll INF = 1e18;
const ld EPS = 1e-10;

int main(){
    ll X;
    cin >> X;
    ll now = 100;
    int n = 0;
    while(now < X){
        now += (now/100);
        n++;
    }
    cout << n << endl;
}

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

int main(){
	int a,b,c;
	int ans;
	
	string cunning="77675";
	
	for(int i=0;i<104;i++){
		cin>>a>>b;c=a+b;
		//-----test-----
		if(i<cunning.size()){
			cout<<cunning[i]<<endl;
			continue;
		}
		//--------------
		ans=1;
		while(10<=c){
			c/=10;
			ans++;
		}
		cout<<ans<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 1204
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n; cin >> n;
  vector<string> S(n);
  vector<int> P(n);
  vector<int> id(n);
  rep(i, n) {
    cin >> S[i] >> P[i];
    id[i] = i;
  }
  sort(all(id), [&](int i, int j) {
      if(S[i] == S[j]) return P[i] > P[j];
      return S[i] < S[j];
    });
  rep(i, n) cout << id[i]+1 << "\n";
  return 0;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  int h=0;
  int w=0;
  for(int i=0;i<s.size();i++){
    if(s[i]=='N'){
      h++;
      break;
    }
  }
  for(int i=0;i<s.size();i++){
    if(s[i]=='W'){
      w++;
      break;
    }
  }for(int i=0;i<s.size();i++){
    if(s[i]=='S'){
      h++;
      break;
    }
  }for(int i=0;i<s.size();i++){
    if(s[i]=='E'){
      w++;
      break;
    }
  }
  if(h%2==0&&w%2==0){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>

using namespace std;
int n,m,k;


int main()
{
    cin>>n>>m>>k;
    vector<int>a(n+1,0);
    vector<int>b(m+1,0);
    long long sum=0;
    for(int i=1;i<=n;++i)
    {
        cin>>a[i];
    }
    for(int i=1;i<=m;++i)
    {
        cin>>b[i];
        sum+=b[i];
    }
    int ans=0;
    int bi=m;
    for(int i=0;i<=n;++i)
    {
        sum+=a[i];
        while(sum>k&&bi>=0) sum-=b[bi--];
        if(sum>k)
            break;
        ans=max(ans,bi+i);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 4764
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,x,y;
  cin>>n>>x>>y;
  x--;
  y--;
  int a[n] = {0};
  for(int i = 0;i<n;i++)
  {
      for(int j = i+1;j<n;j++)
      {
          int e,f,g;
          e = j-i;
          f = max(x-i,i-x);
          f++;
          f+=max(y-j,j-y);
          g = min(e,f);
          a[g]++;
      }
  }
  for(int i = 1;i<n;i++)
  {
      cout<<a[i]<<"\n";
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  int n;
  cin>>n;
  if(n==111)cout<<999;
  if(n==119)cout<<991;
  if(n==191)cout<<919;
  if(n==911)cout<<199;
  if(n==199)cout<<911;
  if(n==919)cout<<191;
  if(n==991)cout<<119;
  if(n==999)cout<<111;
  cout<<endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <vector>
#include <map>
#include <iostream>
#include <string>
#include <math.h>

typedef long long ll;

using namespace std;

int main()
{
	int a;
	int b;

	cin >> a;
	cin >> b;

	int count=0;

	for (int i = 4; i <= a; i++)
	{
		for (int j = 20; j <= b; j++)
		{
			if ( (j % 10) >=2 && i == (j / 10) * (j % 10))
			{
				count++;
			}
		}
	}

	cout << count;

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<set>
#include<iomanip>
#define rep(i, a, n) for(int i = a; i < n; i++)
using namespace std;
int main(){
  int a, b, c;
  cin >> a >> b >> c;
  a = a - b;
  int d;
  d = a % c;
  cout << d << "\n";
}

Measured memory_bytes: 3520
import math
def pri(n):
    l =[True] * n
    l[0] = l[1] = False
    for i in range(2,n):
        if l[i]:
            for j in range(i*2, n, i):
                l[j] = False
    return l
n=105000
s=pri(n)
l=[i for i in range(n) if s[i]]
while True:
    n = int(input())
    if n == 0: break
    print(sum(l[:n]))

Measured memory_bytes: 8024