akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"

// Begin Header {{{
using namespace std;

#ifndef DEBUG
#define dump(...)
#endif

#define all(x) x.begin(), x.end()
#define rep(i, n) for (intmax_t i = 0, i##_limit = (n); i < i##_limit; ++i)
#define reps(i, b, e) for (intmax_t i = (b), i##_limit = (e); i <= i##_limit; ++i)
#define repr(i, b, e) for (intmax_t i = (b), i##_limit = (e); i >= i##_limit; --i)
#define var(Type, ...) Type __VA_ARGS__; input(__VA_ARGS__)

constexpr size_t    operator""_zu(unsigned long long value) { return value; };
constexpr intmax_t  operator""_jd(unsigned long long value) { return value; };
constexpr uintmax_t operator""_ju(unsigned long long value) { return value; };

constexpr int INF = 0x3f3f3f3f;
constexpr intmax_t LINF = 0x3f3f3f3f3f3f3f3f_jd;

template <class T, class Compare = less<>>
using MaxHeap = priority_queue<T, vector<T>, Compare>;
template <class T, class Compare = greater<>>
using MinHeap = priority_queue<T, vector<T>, Compare>;

inline void input() {}
template <class Head, class... Tail>
inline void input(Head&& head, Tail&&... tail) {
    cin >> head;
    input(forward<Tail>(tail)...);
}

template <class T>
inline istream& operator>>(istream &is, vector<T> &vec) {
    for (auto &e: vec) {
        is >> e;
    }
    return is;
}

inline void output() { cout << "\n"; }
template <class Head, class... Tail>
inline void output(Head&& head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail)) {
        cout << " ";
    }
    output(forward<Tail>(tail)...);
}

template <class T>
inline ostream& operator<<(ostream &os, const vector<T> &vec) {
    static constexpr const char *delim[] = {" ", ""};
    for (const auto &e: vec) {
        os << e << delim[&e == &vec.back()];
    }
    return os;
}

template <class T>
inline vector<T> makeVector(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto makeVector(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(makeVector<T>(initValue, args...))>(sz, makeVector<T>(initValue, args...));
}

template <class Func>
class FixPoint : Func {
public:
    explicit constexpr FixPoint(Func&& f) noexcept : Func(forward<Func>(f)) {}

    template <class... Args>
    constexpr decltype(auto) operator()(Args&&... args) const {
        return Func::operator()(*this, std::forward<Args>(args)...);
    }
};

template <class Func>
static inline constexpr decltype(auto) makeFixPoint(Func&& f) noexcept {
    return FixPoint<Func>{forward<Func>(f)};
}

template <class T>
inline bool chmax(T &a, const T &b) noexcept {
    return b > a && (a = b, true);
}

template <class T>
inline bool chmin(T &a, const T &b) noexcept {
    return b < a && (a = b, true);
}

template <class T>
inline T diff(const T &a, const T &b) noexcept {
    return a < b ? b - a : a - b;
}
// End Header }}}

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

    var(string, s, t);

    rep(i, s.size()) {
        const char tmp = s.back();
        s.pop_back();
        s = tmp + s;
        if (s == t) {
            return output("Yes"), 0;
        }
    }

    output("No");

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;


public class Main {

	public static void main(String[] args)  {

		Scanner sc = new Scanner(System.in);
		int n =  Integer.parseInt(sc.next());		
		int k =  Integer.parseInt(sc.next());		
		boolean[] have = new boolean[n];
		
		for(int i = 0 ; i < k ; i++) {
			int cnt = Integer.parseInt(sc.next());
			for(int j = 0; j < cnt ; j++) {
				have[Integer.parseInt(sc.next())-1] = true;
			}
		}
		
		int ans = 0;
		for(int i = 0 ; i < n ; i++) {
			if(!have[i]) {
				ans++;
			}
		}
		
		System.out.println(ans);
		
	}
}



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

int main() {
	int N;
	bool flag = false;
	cin >> N;
	for(;N>-5;N=N-4){
		if(N%7==0)
			flag=true;
	}
	if (flag)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
// Millennium
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1179&lang=jp
#include <iostream>
using namespace std;
int Millennium(int y, int m, int d) {
    int t = 0;
    // 1000??´1???1??\?????§?????\????¨????
    // ?\???°??????20??\?????¶??°??????19??\
    // 3??§?????????????????´????????¨???20??\
    // 182 9 5 ??§??¨??????
    while(y < 1000){
        t++;
        // 3??´??§???????????????????????????
        if(y % 3 == 0){
            // ??¨????????????20??\?????¨
            if(d == 20){
                d = 1;
                m++;
            }else{
                d++;
            }
        }else{
            // 3??´??§????????????????????¨???
            if(m % 2 == 0){
                // ??¶??°???
                if(d == 19){
                    d = 1;
                    m++;
                }else{
                    d++;
                }
            }else{
                // ?\???°???
                if(d == 20){
                    d = 1;
                    m++;
                }else{
                    d++;
                }
            }
        }
        if(m == 11){
            m = 1;
            y++;
        }
    }
    return t;
}
int main() {
    int n, y, m, d;
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> y >> m >> d;
        cout << Millennium(y, m, d) << endl;
    }
    return 0;
}

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pb push_back
#define int long long
#pragma GCC optimize("O3,Ofast,no-stack-protector,unroll-loops,fast-math")
const int maxn=2e3+7;
const int mod=1e9+7;
/*Almost copy pasted part :)*/

int32_t main(){
    double a,b;
    cin>>a>>b;
    double l=(double)(1/0.08)*a;
    double r=(double)(1/0.08)*(a+1)-1;
    double ll=10*(b);
    double rr=10*(b+1)-1;
    double lft=max(l,ll);
    double rht=min(r,rr);
    if(ceil(lft)<=rht){
        int ans=ceil(lft);
        cout<<ans<<endl;
    }
    else{
        cout<<-1<<endl;
    }
}

Measured memory_bytes: 256
fun main(args:Array<String>) {
  val n = readLine()!!.toInt()
  val aas = readLine()!!.split(" ").map { it.toInt() }.toMutableList()
  aas.add(0, 0)
  aas.add(n+1, 0)
  
  var sum = 0
  (0..n).map { 
    sum += Math.abs(aas[it+1] - aas[it])
  }
  (1..n).map {
    println( sum - Math.abs(aas[it-1] -  aas[it]) - Math.abs(aas[it] - aas[it+1]) + Math.abs(aas[it-1] - aas[it+1]) ) 
  }
}

Measured memory_bytes: 56252
#include <bits/stdc++.h>
#include <iostream>
typedef long long ll;
#define rep(i,a,b) for(ll i =a ;i <= b;i++)
#define per(i,a,b) for(ll i =a ;i >= b;i--)
using namespace std;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;


int main(int argc, char const *argv[])
{
	//ifstream cin("input.txt");
	int n,m;
	cin>>n>>m;
	ll sum =0;
	ll x;
	rep(i, 0 ,m-1)
	{
		cin>>x;
		sum += x;
	}
	if(sum > n)
		cout<<-1;
	else
		cout<<n-sum;
	
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
 
typedef pair<int, int> p;
 
int main() {
	cin.tie(0);
    ios::sync_with_stdio(false);

    vector<string> s(3);
    vector<int> p(3);

    for(int i = 0; i < 3; i++) cin >> s[i];

    int t = 0;

    while(true) {
        if(p[t] == s[t].length()) {
            cout << char('A' + t) << endl;
            return 0;
        }
        int x = s[t][p[t]] - 'a';
        p[t]++;
        t = x;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
using namespace std;
typedef long long ll;

int main(){

    string s; cin >> s;
    int n = s.size();

    int rcnt = 0;
    int lcnt = 0;
    vector<pair<int, int>> v;
    vector<pair<int, int>> vans;
    for(int i=0; i<n; i++){
        if(s[i] == 'R'){
            // cout << 'R';
            rcnt++;
        }
        else{
            // cout << 'L';
            lcnt++;
            if(i == n-1 || s[i+1] == 'R'){
                v.push_back(make_pair(rcnt, lcnt));
                rcnt = 0;
                lcnt = 0;
            }
        }
    }




    for(int i=0; i<v.size(); i++){
        int sum = v[i].first + v[i].second;
        if( sum % 2 == 0){
            vans.push_back(make_pair(sum/2, sum/2));
        }
        else{
            if(v[i].first % 2 == 1){
                vans.push_back(make_pair(sum/2 + 1, sum/2));
            }
            else{
                vans.push_back(make_pair(sum/2, sum/2 + 1));
            }
        }
    }

    // for(int i=0; i<vans.size(); i++){
    //     cout << vans[i].first << " " << vans[i].second << endl;

    // }

    int index = 0;
    for(int i=0; i<n; i++){
        if(s[i] == 'R' && s[i+1] == 'L'){
             cout << vans[index].first << " " << vans[index].second << " ";
            index++;
            i++;
        }
        else{
            if(i != n-1) cout << 0 << " ";
            else cout << 0;
        }
    }

    return 0;
}

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

using namespace std;

using i64 = int64_t;

const i64 MOD = 1e9+7;

const i64 INF = 1e18+7;


signed main(){
    int n, a, b;
    cin >> n >> a >> b;
    string s;
    cin >> s;
    int x = 0, y = 0;
    for(auto& c : s){
        if(c == 'a' && x < a + b){
            cout << "Yes" << endl;
            ++x;
        }
        else if(c == 'b' && x < a + b && y < b){
            cout << "Yes" << endl;
            ++x, ++y;
        }
        else
            cout << "No" << endl;
    }
}


Measured memory_bytes: 896
/* Generated by powerful Codeforces Tool
 * You can download the binary file in here https://github.com/xalanq/cf-tool (win, osx, linux)
 * Author: step_by_step
 * Time: 2020-03-19 17:35:03
**/

//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")
  
#include <iostream>
#include <stdlib.h>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <assert.h>
#include <memory.h>
#include <time.h>
#include <bitset>

#define uint unsigned int
#define ll long long
#define ull unsigned long long
#define ld long double
#define rep(i, l, r) for (int i = (l); i < (r); i++)
#define repb(i, r, l) for (int i = (r); i > (l); i--)
#define sz(a) (int)a.size()
#define fi first
#define se second
#define mp(a, b) make_pair(a, b)
#define rank qwertyuio
#define next dfghjk
#define prev fhsgfhjf
#define plus fsghsf
#define minus ytryr
  
using namespace std;
  
inline bool setmin(int &x, int y) { return (y < x) ? x = y, 1 : 0; }
inline bool setmax(int &x, int y) { return (y > x) ? x = y, 1 : 0; }
inline bool setmin(ll &x, ll y) { return (y < x) ? x = y, 1 : 0; }
inline bool setmax(ll &x, ll y) { return (y > x) ? x = y, 1 : 0; }
  
const int N = 100000;
const int inf = (int)1e9 + 1;
const ll big = (ll)1e18 + 1;
const int P = 239;
const int P1 = 31;
const int P2 = 57;
const int MOD = (int)1e9 + 7;
const int MOD1 = (int)1e9 + 9;
const int MOD2 = 998244353;
const ld eps = 1e-9;
const double pi = atan2(0, -1);
const int ABC = 26;

int main()
{
    //freopen("circus.in", "r", stdin);
    //freopen("circus.out", "w", stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.precision(20);
    cout << fixed;
    //ll TL = 10.95 * CLOCKS_PER_SEC;
    //clock_t time = clock();
    int n;
    cin >> n;
    int a[n + 1];
    rep(i, 0, n + 1) {
        cin >> a[i];
    }
    if (a[0] > 1) {
        cout << -1 << "\n";
        return 0;
    }
    ll max_free[n + 1];
    max_free[0] = 1 - a[0];
    rep(i, 0, n) {
        max_free[i + 1] = min(big, max_free[i] * 2);
        if (max_free[i + 1] < a[i + 1]) {
            cout << -1 << "\n";
            return 0;
        }
        max_free[i + 1] -= a[i + 1];
    }
    ll tot = 0;
    repb(i, n, -1) {
        setmin(max_free[i], tot);
        tot = a[i] + max_free[i];
    }
    ll ans = 0;
    rep(i, 0, n + 1) {
        ans += a[i] + max_free[i];
    }
    cout << (ans > 0 ? ans : -1) << "\n";
    return 0;
}



Measured memory_bytes: 4784
/*~~~~~~~~~~~~~~~~~ K++ code ~~~~~~~~~~~~~~~~~~~
in(n, t)
kluster<int ,int> klst <<
for(i, n){
    int p, q ;
    cin >> p >> q ;
    push(klst, (q, p))
}
sort(klst, 1)
for(i, n){
    if(klst[i][0]<=t) out(klst[i][1]); return 0
}
out("TLE")
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/

#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <algorithm>
#include <functional>
#include <deque>
#include <cctype>
#include <ctime>
#include <cstdlib>
#include <iomanip>
using namespace std;

struct struct_0_ {;
    int m_0;
    int m_1;
};
bool comp_klst_(const struct_0_& a, const struct_0_& b){;
    if(a.m_0 != b.m_0){;
        return (a.m_0 < b.m_0);
    };
    if(a.m_1 != b.m_1){;
        return (a.m_1 < b.m_1);
    };
    return (1);
};
bool comp_klst_0_(const struct_0_& a, const struct_0_& b){;
    return (a.m_0 < b.m_0);
};
bool comp_klst_1_(const struct_0_& a, const struct_0_& b){;
    return (a.m_1 < b.m_1);
};
;;;
;
int main(){
  ;;;
    int n, t;
    cin >> n >> t;
    ;
    vector<struct_0_> klst;;
    for(int i = 0; i <  n; ++i){;;;;
        int p, q ;;
        cin >> p >> q ;;
        klst.push_back({q, p});
    ;};;;
    sort(klst.begin(), klst.end(), comp_klst_1_);;
    for(int i = 0; i <  n; ++i){;;;;
        if(klst[i].m_0<=t) {;;cout << (klst[i].m_1) << endl;; return (0);;};
    ;};;;
    cout << ("TLE") << endl;;
    ;
}

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

using namespace std;

#define nl '\n'
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define pb push_back

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

const int N = (int)2e5 + 123;
const int K = 500;
const int maxn = (int)2e9;
const int mod = 100000007;
const ll inf = 1ll * 1e18 + 123;

int n;
ll w;
pair<ll, int> p[111];
ll a[100111];
int main(){

   ios_base :: sync_with_stdio(0), cin.tie(0), cout.tie(0);

    #ifdef LOCAL
        freopen("in.txt", "r", stdin);
    #endif

    cin >> n >> w;
    for(int i = 1; i <= n; ++i){
        cin >> p[i].F >> p[i].S;
    }
    for(int i = 0; i <= 100011; ++i) a[i] = -1;
    int sum = 0;
    a[0] = 0;
    sort(p + 1, p + n + 1);
    int ans = 0;
    for(int i = 1; i <= n; ++i){
        sum += p[i].S;
        for(int j = sum; j >= p[i].S; --j){
            if(a[j - p[i].S] != -1){
                ll newW = a[j - p[i].S] + p[i].F;
                if(newW <= w){
                    ans = max(ans, j);
                }
                if(a[j] == -1 || a[j] > newW){
                    a[j] = newW;
                }
            }
        }
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}
#ifdef __LOCAL
#define debug(x) cerr << __LINE__ << ": " << #x << " = " << x << endl
#define debugArray(x, n)                           \
  cerr << __LINE__ << ": " << #x << " = {";        \
  for (long long hoge = 0; (hoge) < (n); ++(hoge)) \
    cerr << ((hoge) ? "," : "") << x[hoge];        \
  cerr << "}" << endl
#else
#define debug(x) (void(0))
#define debugArray(x, n) (void(0))
#endif

template <int mod>
struct ModInt {
  int x;
  ModInt() : x(0) {}
  ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod)) {}
  ModInt &operator+=(const ModInt &p) {
    if ((x += p.x) >= mod) x -= mod;
    return *this;
  }
  ModInt &operator-=(const ModInt &p) {
    if ((x += mod - p.x) >= mod) x -= mod;
    return *this;
  }
  ModInt &operator*=(const ModInt &p) {
    x = (int)(1LL * x * p.x % mod);
    return *this;
  }
  ModInt &operator/=(const ModInt &p) { return *this *= p.inverse(); }
  ModInt operator-() const { return ModInt() - *this; }
  ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }
  ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }
  ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }
  ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }
  bool operator==(const ModInt &p) const { return x == p.x; }
  bool operator!=(const ModInt &p) const { return x != p.x; }
  ModInt inverse() const {
    int a = x, b = mod, u = 1, v = 0, t;
    while (b) t = a / b, swap(a -= t * b, b), swap(u -= t * v, v);
    return ModInt(u);
  }
  ModInt pow(int64_t e) const {
    ModInt ret(1);
    for (ModInt b = *this; e; e >>= 1, b *= b)
      if (e & 1) ret *= b;
    return ret;
  }
  friend ostream &operator<<(ostream &os, const ModInt &p) { return os << p.x; }
  friend istream &operator>>(istream &is, ModInt &a) {
    int64_t t;
    is >> t;
    a = ModInt<mod>(t);
    return (is);
  }
  static int modulo() { return mod; }
  int get() const { return x; }
};

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  using Mint = ModInt<int(1e9 + 7)>;
  int N;
  cin >> N;
  long long x[N + 1];
  x[0] = 0;
  for (int i = 1; i <= N; i++) cin >> x[i];
  Mint ans = 1;
  int rem = 0;
  for (int i = 1; i <= N; i++) {
    if (2 * rem == x[i])
      ans *= (rem + 1);
    else
      rem++;
  }
  while (rem) ans *= rem--;
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 4424
while True:
  a,b = map(int,input().split())
  if (a,b) == (0,0):
    break
  x = max(a,b)
  y = min(a,b)
  c = 0
  while y != 0:
    x %= y
    x,y = y,x
    c += 1
  print(x,c)


Measured memory_bytes: 5608
#include <iostream>
using ll = long long ;
int main()
{
  ll K,A,B;
  std::cin>>K>>A>>B;
  if(K<=A){return std::cout<<1<<std::endl,0;}
  if(A<=B){return std::cout<<-1<<std::endl,0;}
  const ll ans = (K-B-1)/(A-B)*2LL+1LL;
  std::cout<<ans <<std::endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define ri(x) scanf("%d",&(x))
#define ri2(x,y) scanf("%d %d",&(x),&(y))
#define ri3(x,y,z) scanf("%d %d %d",&(x),&(y),&(z))
#define rll(x) scanf("%lld",&(x))
#define rll2(x,y) scanf("%lld %lld",&(x),&(y))
#define rll3(x,y,z) scanf("%lld %lld %lld",&(x),&(y),&(z))
#define gc(x) ((x) = getchar())
using namespace::std;

const long double PI = acos(-1);
const long long MOD = 1000000000 +7;

typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<ll,pll> tll;
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<ll> vll;
typedef vector<pll> vpll;
typedef vector<tll> vtll;
typedef vector<string> vs;
typedef set<int> si;
typedef set<ii> sii;
typedef set<iii> siii;

ll gcd(ll a, ll b){ return b==0?a:gcd(b,a%b);}

ll add(ll a, ll b, ll m = MOD){
	if(a >= m) a %= m;
	if(b >= m) b %= m;
	if(a < 0) a += m;
	if(b < 0) b += m;
	ll res = a+b;
	if(res >= m or res <= -m) res %= m;
	if(res < 0) res += m;
	return res;
}

ll mul(ll a, ll b, ll m = MOD){
	if(a >= m) a %= m;
	if(b >= m) b %= m;
	if(a < 0) a += m;
	if(b < 0) b += m;
	ll res = a*b;
	if(res >= m or res <= -m) res %= m;
	if(res < 0) res += m;
	return res;
}

ll pow_mod(ll a, ll b, ll m = MOD){
	ll res = 1LL;
	a = a%m;
	while(b){
		if(b&1) res = mul(res,a,m);
		b >>= 1;
		a = mul(a,a,m);
	}
	return res;
}

ll fastexp(ll a, ll b){
	ll res = 1LL;
	while(b){
		if(b&1) res = res*a;
		b >>= 1;
		a *= a;
	}
	return res;
}

int gcdExtendido(int a, int b, int *x, int *y){
	if(a == 0){
		*x = 0;
		*y = 1;
		return b;
	}
	int x1, y1;
	int gcd = gcdExtendido(b%a,a,&x1,&y1);
	
	*x = y1-(b/a)*x1;
	*y = x1;
	return gcd;
}

int modInverso(int a, int m){
	int x, y;
	int g = gcdExtendido(a,m,&x,&y);
	if(g!=1) return -1;
	else return (x%m + m)%m;
}

/****************************************
*************P*L*A*N*T*I*L*L*A************
*****************************************/

const int N = 100+5;
const int SUMV = 100000+5;
const long long inf = 1LL<<60;

int n;
int C;
int w[N];
int v[N];
long long memo[N][SUMV];

int main(){
	ri2(n,C);
	int S = 0;
	for(int i=1; i<=n; i++){
		ri2(w[i],v[i]);
		S += v[i];
	}
	memo[0][0] = 0;
	for(int i=1; i<=S; i++) memo[0][i] = inf;
	for(int i=1; i<=n; i++){
		for(int val = 0; val <= S; val++){
			memo[i][val] = memo[i-1][val];
			if(val >= v[i]){
				memo[i][val] = min(memo[i][val], memo[i-1][val - v[i]] + w[i]);
			}
		}
	}
	int ans = 0;
	for(int val = 1; val <= S; val++){
		if(memo[n][val] <= C) ans = val;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 80256
#include <iostream>
using namespace std;
int main(){
    int x;
    cin>>x;
    while(x){
        int y=x%10;
        if(y==7){
            cout<<"Yes"<<endl;
            return 0;
        }
        x/=10;
    }
    cout<<"No"<<endl;
    return 0;
}

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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s,t;
    cin >> s >> t;
    if (t.substr(0,s.length())==s) cout << "Yes\n";
    else cout << "No\n";
    return 0;
}

Measured memory_bytes: 3636
#include <iostream>
using namespace std;
typedef long long ll;

int main()
{
    ll n, a, b;
    cin >> n >> a >> b;
    if((a + b) % 2 == 0) cout << (b - a) / 2 << endl;
    else cout << min(min(b - 1, n - a), min((a + b - 1) / 2, (n * 2 - a - b + 1) / 2)) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=21,M=N*N,mod=1e9+7;
int n,m,up,sum[1<<20],e[1<<20],f[N],x[M],y[M],mp[N],bit[1<<20];
int Bit(int x){return x==0||bit[x]?bit[x]:bit[x]=__builtin_popcount(x);}
int getf(int x){return f[x]==x?x:f[x]=getf(f[x]);}
ll p[M],invp[M],dp[1<<20],si[1<<20],len[1<<20];
ll Dp()
{
    dp[up-1]=0;si[up-1]=1;
    for(int i=up-1;i>=1;i--)
    {
        for(int j=1;j<=n;j++)
            if(i>>j-1&1)
        {
            int st=i^(1<<j-1);
            int n=len[i],a=sum[i]-sum[st];
            len[st]=n+a+1;
            ll c=si[i]*p[n+a]%mod*invp[n]%mod;
            ll s=dp[i]*p[n+a+1]%mod*invp[n+1]%mod;
            s=(s+c*(Bit((up-1)^st)));
            (dp[st]+=s)%=mod;
            (si[st]+=c)%=mod;
        }
    }
    return dp[0];
}
int main()
{
    p[0]=p[1]=invp[0]=invp[1]=1;
    for(int i=2;i<M;i++) p[i]=p[i-1]*i%mod,invp[i]=(mod-mod/i)*invp[mod%i]%mod;
    for(int i=2;i<M;i++) invp[i]=invp[i-1]*invp[i]%mod;
    scanf("%d%d",&n,&m);
    for(int i=1;i<=m;i++)
    {
        scanf("%d%d",&x[i],&y[i]);
        mp[x[i]]|=1<<y[i]-1;
        mp[y[i]]|=1<<x[i]-1;
    }
    up=1<<n;
    for(int i=1;i<up;i++)
    {
        for(int j=1;j<=n;j++)
            if(i>>j-1&1)
            {
                e[i]=e[i^(1<<j-1)]+Bit(i&mp[j]);
                break;
            }
    }
    for(int i=1;i<up;i++)
        e[i]-=Bit(i)-1;
    up=1<<n-1;
    int st[N];
    for(int i=1;i<up;i++)
    {
        for(int j=1;j<=n;j++) f[j]=j;
        for(int j=1;j<n;j++)
            if(i>>j-1&1)
            f[getf(x[j])]=getf(y[j]);
        memset(st,0,sizeof(st));
        for(int j=1;j<=n;j++)
            st[getf(j)]|=1<<j-1;
        for(int j=1;j<=n;j++)
            if(f[j]==j)
            sum[i]+=e[st[j]];
    }
    printf("%lld\n",Dp());
}


Measured memory_bytes: 30976
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define ll long long
#define ld long double
#define zeros(x) x^(x-1)&x
#define pii pair<ll,ll>
#define cd complex<double>
#define dbg(x) cerr<<#x<<": "<<x<<endl;ll
#define Nmax 400005
#define OFF 100001
#define MOD 1000000007
using namespace std;

ll n, a, b, x[Nmax], y[Nmax], v[Nmax];
vector<pii> hx, hy;

void add(ll x[], int pos, int val){
    for (pos++;pos < Nmax; pos += zeros(pos)) x[pos] = (x[pos] + val + MOD) % MOD;
}

int query(ll x[], int pos){
    int ans = 0;
    for (pos++;pos > 0; pos -= zeros(pos)) ans = (ans + x[pos]) % MOD;
    return ans;
}

void _clear(ll x[], vector<pii> &hx){
    for (auto it : hx){
        add(x, it.first, -it.second);
    }
    hx.clear();
}

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

    add(x, 0, 1); hx.push_back({0, 1});
    add(y, 0, 1); hy.push_back({0, 1});
    int lstx = 0, lsty = 0;
    for (int i=2;i<=n;i++){
        while (lstx < i && v[i] - v[lstx+1] >= b) lstx++;
        while (lsty < i && v[i] - v[lsty+1] >= a) lsty++;
        int aux1 = query(x, lstx);
        int aux2 = query(y, lsty);
        if (v[i] - v[i-1] < a) _clear(x, hx);
        if (v[i] - v[i-1] < b) _clear(y, hy);
        add(x, i-1, aux2); hx.push_back({i-1,aux2});
//        add(x, i, getVal(x, i-1));
        add(y, i-1, aux1); hy.push_back({i-1,aux1});
//        add(y, i, getVal(y, i-1));
    }
    cout << (query(x, n) + query(y, n)) % MOD<< '\n';
    return 0;
}


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

#define REP(i,num) for(int i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	string S=in<string>();
	int N=S.size();
	reverse(ALL(S));

	int start = 0;
	while(start<N){
		if(S.substr(start,5)=="maerd" || S.substr(start,5)=="esare"){
			start+=5;
		}
		else if(S.substr(start,6)=="resare"){
			start+=6;
		}
		else if(S.substr(start,7)=="remaerd"){
			start+=7;
		}
		else{
			out("NO");
			return 0;
		}
	}
	
	out("YES");
	return 0;
}


Measured memory_bytes: 512
/*author : Yashvardhan
Sunday, April 19, 2020
7:49 PM
*/

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

using ll = long long;

#define int ll
#define pb push_back
#define vi vector<int>
#define pi pair<int,int>
#define vpi vector<pi>
#define ff first
#define ss second
#define mp make_pair
#define endl '\n'
#define all(a) a.begin(), a.end()
#define initialise(a, x) memset(a, x, sizeof(a))
#define rev(Y) reverse(all(Y))

#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS

#ifdef __APPLE__
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){cerr << name << " : " << arg1 << endl;}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');
	cerr.write(names, comma - names) << " : " << arg1 << "  ";
	__f(comma + 1, args...);}
#else
#define debug(...)
#endif

template <typename T> ostream& operator << (ostream& os,const vector<T>& v){for(int i=0;i<v.size();++i) os<<v[i]<<" ";return os;} 
template <typename T> ostream& operator << (ostream& os,const set<T>& v){for(auto it:v) os<<it<<" ";return os;} 
template <typename T, typename S> ostream& operator << (ostream& os, const pair<T,S>& v) {os<<v.ff<<" "<<v.ss;return os;}

const int mod = 1e9 + 7;
const int inf = 2e18;
const int ninf = -2e18;

int takemod(int a){return ((a%mod)+mod)%mod;}

int pow(int a, int b, int m)
{
	int ans = 1;
	a %= m;
	while (b)
	{
		if (b & 1)
			ans = (ans * a) % m;
		b /= 2;
		a = (a * a) % m;
	}
	return ans;
}

int modinv(int a){return takemod( pow( takemod(a), mod-2,mod ) );}

const int N = 2e3 + 5;
vpi arr;
int dp[N][N];

signed main()
{

	ios_base::sync_with_stdio(false);
	cin.tie(0);

	#ifdef __APPLE__
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
		freopen("error.txt","w",stderr);
	#endif

	time_t t1, t2;
	t1 = clock();
	
	int n;
	cin >> n;

	arr.resize(n);
	for(int i = 0; i < n; i++){
		int x;
		cin >> x;
		arr[i] = {x, i};
	} 

	sort(arr.rbegin(), arr.rend());
	initialise(dp,-1);

	dp[0][1] = arr[0].ff * abs((n - 1) - arr[0].ss);
	dp[1][0] = arr[0].ff * abs(arr[0].ss);

	for(int i = 2; i <= n; i++){
		for(int j = 0; j <= i; j++){
			int k = i - j;
			if(j) dp[j][k] = max(dp[j][k], dp[j - 1][k] + arr[i - 1].ff * abs(arr[i - 1].ss - (j - 1)));
			if(k) dp[j][k] = max(dp[j][k], dp[j][k - 1] + arr[i - 1].ff * abs((n - 1) - k + 1 - arr[i - 1].ss));
		}
	}

	int ans = 0;
	for(int j = 0; j <= n; j++){
		ans = max(ans, dp[j][n - j]);
	}

	cout << ans << endl;
	

	t2 = clock();
	cerr << endl << t2-t1 << endl;
	
	return 0;
}



Measured memory_bytes: 35084
n, m, k = list(map(int, input().split()))
MOD = 10 ** 9 + 7

t = 0
pre = [0]
for i in range(1, max(n, m) + 1):
    t += i
    pre.append(t)


def calc_base(n, m, pre):
    base = 0
    for i in range(n // 2):
        base = base + (pre[i] + pre[n - i - 1]) * 2 % MOD
    if n % 2 == 1:
        i = n // 2
        base = (base + pre[i] * 2) % MOD
    return base * m * m % MOD


bi = calc_base(n, m, pre)
bj = calc_base(m, n, pre)


def prepare(n, MOD):
    f = 1
    for m in range(1, n + 1):
        f *= m
        f %= MOD
    fn = f

    inv = pow(f, MOD - 2, MOD)
    invs = [1] * (n + 1)
    invs[n] = inv
    for m in range(n, 1, -1):
        inv *= m
        inv %= MOD
        invs[m - 1] = inv

    return fn, invs


nm = n * m - 2
f, inv = prepare(nm, MOD)
print((bi + bj) * f * inv[k - 2] % MOD * inv[nm - k + 2] * inv[2] % MOD)


Measured memory_bytes: 20116
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int main() {
    int n, k;
    cin >> n >> k;
    ll now = k, ans = 0;
    while(now <= n){
        ans++;
        now *= k;
    }
    cout << ans + 1 << endl;
}


Measured memory_bytes: 256
/* Karen {{{
  ___  ____
 |_  ||_  _|
   | |_/ /    ,--.   _ .--.  .---.  _ .--.
   |  __'.   `'_\ : [ `/'`\]/ /__\\[ `.-. |
  _| |  \ \_ // | |, | |    | \__., | | | |
 |____||____|\'-;__/[___]    '.__.'[___||__]
}}} */
// include {{{
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cmath>
#include <math.h>
#include <string>
#include <vector>
#include <complex>
#include <iostream>
#include <algorithm>

using namespace std;

// }}}
/* cpp template {{{*/


#define endl '\n'

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

typedef double D;      // 座標値の型。doubleかlong doubleを想定
typedef long long ll;
typedef long double lb;
typedef complex<D> P;  // Point
typedef pair<P, P> L;  // Line
typedef vector<P> VP;
typedef vector<int> vi;
typedef vector<vector<int> > vii;
typedef pair<int, int> pii;
typedef pair<int, string> pis;
typedef pair<string, int> psi;

inline bool inside(int y, int x, int H, int W){return (y >= 0 && x >= 0 && y < H && x < W);}
inline int in() {int x; std::cin >> x; return x;}

template <typename T>
void print(std::vector<T>& v, char c = ' ') {
  REP(i, v.size()) {
    if (i != 0) std::cout << c;
    std::cout << v[i];
  }
  std::cout << endl;
}
template <typename T>
void print(T x) {
  std::cout << x << '\n';
}

/* 定数 */
const ll MOD = 1e9 + 7;
const ll INF = 1e9 + 9;
const D EPS  = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1};
const int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};


/* }}} */

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

  ll N = in(), L = in();
  ll a[100000];
  int ca[100000];
  int ans = -1;

  REP(i, N){
    a[i] = in();
  }

  REP(i, N - 1){
    if (a[i] + a[i + 1] >= L){
      ans = i;
      break;
    }
  }

  if (ans == -1){
    cout << "Impossible" << endl;
    return 0;
  }

  cout << "Possible" << endl;

  for (int i = 1; i <= ans; i++){
    cout << i << endl;
  }
  for (int i = N - 1; i > ans; i--){
    cout << i << endl;
  }


  /*
  ll N = in(), L = in();
  ll a[100000];
  int ca[100000];
  int s = 0, l = N - 1;
  REP(i, N){
    a[i] = in();
  }

  REP(i, N - 1){
    if ((l - s == 1) && (a[l] + a[s] < L)){
      cout << "Impossible" << endl;
      break;
    }
    if (a[s] < a[l]){
      ca[i] = ++s;
    }
    else {
      ca[i] = l--;
    }
    if (l == s) {
      cout << "Possible" << endl;
      for (int j = 0; j < N - 1; j++){
        cout << ca[j] << endl;
      }
    }
  }
  */
  return (0);
}



Measured memory_bytes: 1664
#include <stdio.h>
#include <stdlib.h>
#define MAX 10
int main()
{
		int N;
		float f,S = 0;
		char str[3];
		
		scanf("%i",&N);
		float vetorf[MAX];
		
	
		for(int i = 0; i < N; i++)
		{
			scanf("%f %s",&f, str);
			
			if (str[0] == 'B')
			{
				f *= 380000;
			}
			vetorf[i] = f;

		}
		for (int i = 0; i < N;i++)
		{
			S += vetorf[i];	
		}
		printf("%f", S);
		
		return 0;
		
	

}

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

// @@ !! LIM()

int main(/* int argc, char *argv[] */) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  ll n, a, b; cin >> n >> a >> b;
  if ((b - a) % 2 == 0) {
    cout << (b - a) / 2 << endl;
  }else {
    ll z = min(a - 1, n - b);
    cout << z + 1 + (b - a - 1) / 2 << endl;
  }

  return 0;
}



Measured memory_bytes: 3620
#include<bits/stdc++.h> 
using namespace std; 
int main() { 
int x;
scanf("%d", &x) ; 
int a1,a2 ; 
a1=x%10;
a2=(x/100) %10 ; 
if (a1==a2) 
printf("Yes") ;
else
printf("No");

return 0;

}


Measured memory_bytes: 256
/*input
100000 100000 1
50000 50000
*/
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ii pair<int, int>
#define vi vector<int>
#define pb emplace_back
#define sz(x) (int)x.size()
#define all(v) v.begin(), v.end()
#define rep(i, j, k) for(i=j; i<k; i++)
#define sep(i, j, k) for(i=j; i>k; i--)
#define x first
#define y second
const int inf = 1e9+7;
const int N = 2e5+5;
int n, k, h;
int A[N], dp[N];
int in[N], f[N];
inline int fpow(int n, int k, int p = inf) {int r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n % p; n = n * n % p;} return r;}
inline int inv(int a, int p = inf) {return fpow(a, p - 2, p);}
inline int cc(int a, int b){ if(a<b || b<0) return 0; return f[a]*in[b]%inf*in[a-b]%inf; }
void fac(){ int i; f[0] = 1; rep(i, 1, N) f[i] = f[i-1]*i%inf; in[N-1] = inv(f[N-1]); sep(i, N-1, 0) in[i-1] = i*in[i]%inf; }

signed main()
{
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	int i, j, a, b, x, y;
	cin>>a>>b>>n; 
	n+=2;
	std::vector<ii> v(n);
	rep(i, 1, n-1) cin>>v[i].x>>v[i].y;
	v[0].x = 1; v[0].y = 1;
	v[n-1].x = a; v[n-1].y = b;
	sort(all(v));
	fac();
	rep(i, 1, n){
		dp[i] = cc(v[i].x+v[i].y-2, v[i].x-1);
		rep(j, 0, i)
			if(v[j].y <= v[i].y)
				dp[i] -= dp[j]*cc(v[i].x+v[i].y-v[j].x-v[j].y, v[i].x-v[j].x)%inf;
		dp[i]%= inf;
	}
	dp[n-1]+=inf;
	cout<<dp[n-1]%inf;
}

Measured memory_bytes: 4352
#include <stdio.h>
#include <stdlib.h>

int ordena(const void *a, const void *b){
  return (*(int *)a)- (*(int *)b);
}

int vezes[200000];  //vezes que cada numero de a[i] apareceu;

int main (){

  int n,k,c=0,a;

  scanf("%d%d", &n,&k);

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

  qsort(vezes,n,sizeof(int), ordena);

  for(int i=0; i<n-k; i++)
    c+=vezes[i];

  printf("%d\n", c);


  return 0;
}


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

#define repr(i,a,b) for (int i=a; i<b; i++)
#define rep(i,n) for (int i=0; i<  n; i++)
 
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; }
 
const long long INF = 1LL << 60;
#define PI 3.14159265359 
bool dp[100100];

template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
    vector.erase(vector.begin() + index);
}
 

int main () {
    int N;
    cin >> N;
    vector<int> A(N);
    vector<bool>kazu(1000100,true);
    
    rep(i,N){
        cin >> A[i];
    }

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

    rep(i,N-1){
        while(A[i]== A[i+1] && i+1 <= N-1){
            kazu[A[i]] = false ;
            i++;
        }

        for(int j = 2; A[i]*j <= 1000100 ;j++){
            kazu[ A[i]*j] = false;
            }
        }
    
    
    int ans = 0;
    rep(i,N){
        if(kazu[A[i]] )ans +=1;
    }

    cout << ans << endl;

}




Measured memory_bytes: 4016
let rec for_fold a b v f = if a > b then v else for_fold (a+1) b (f a v) f
let ans =
  Scanf.scanf "%d %d" @@ fun l r ->
  if r - l >= 5000 then 0 else
  for_fold l     r max_int @@ fun i a ->
  for_fold (i+1) r a       @@ fun j a -> min a (i * j mod 2019)
let () = Printf.printf "%d\n" ans


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

int main(){
  int a,b,c,d,e,f,i,j,k,l,s=0,w=100;
  cin>>a>>b>>c>>d>>e>>f;a*=100;b*=100;
  for(i=0;i*a<=f;i++)
  for(j=0;i*a+j*b<=f;j++)
  for(k=0;i*a+j*b+k*c<=f;k++)
  for(l=0;i*a+j*b+k*c+l*d<=f;l++){
    int wa=i*a+j*b,su=k*c+l*d;
    if((i||j)&&(su*(100+e)<=e*(wa+su)&&s*(wa+su)<=su*(w+s))){
      w=wa;
      s=su;
    } 
  }
  cout<<w+s<<" "<<s;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define modulo K
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 1000000005

int main(){
	
	int N,K;
	cin>>N>>K;
	
	vector<long long> A(N);
	for(int i=0;i<N;i++){
		cin>>A[i];
		A[i]%=K;
	}
	
	vector<long long> S(N+1,0);
	for(int i=1;i<=N;i++){
		S[i] += S[i-1];
		S[i] += A[i-1];
		S[i] %= K;
	}
	
	map<long long,long long> mp;
	long long ans = 0;
	
	for(int i=0;i<=N;i++){
		if(i-K>=0)mp[mod(i-K-S[i-K])]--;
		ans += mp[mod(i-S[i])];
		mp[mod(i-S[i])]++;
	}
	
	cout<<ans<<endl;
	
	return 0;
}


Measured memory_bytes: 15872
#define _USE_MATH_DEFINES
#include  <iostream>
#include  <algorithm>
#include  <climits>
#include  <vector>
#include  <string>
#include  <cstring>
#include  <stack>
#include  <queue>
#include  <cmath>
#include  <iomanip>
#include  <set>
#include  <map>
#include  <new>

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

using ll = long long;
using Vii = vector<vector<int> >;
using Gjudge = vector<vector<bool>>;
using Vi = vector<int>;
using Vl = vector<ll>;
using Vs = vector<string>;
using Vb = vector<bool>;
using the = pair<int, int>;

const int Mod = static_cast<int>(1e9 + 7);
const int INF = INT_MAX;
const int dx[4] = { -1,0,1,0 };
const int dy[4] = { 0,1,0,-1 };

int main()
{
	int n, k;
	cin >> n >> k;
	int d, v;
	Vi A(n, 0);
	rep(i, k) {
		cin >> d;
		rep(j, d) {
			cin >> v;
			v--;
			A[v]++;
		}
	}
	int ans = 0;
	rep(i, n) {
		if (A[i] == 0)  ans++;
	}
	cout << ans << endl;
}


Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;


int main() {
  int n;
  cin >> n;
  string temp;
  
  vector<string> s;
  for (int i=0; i<n; i++) {
    cin >> temp;
    s.push_back(temp);
  }
  
  int p=0, q=0, r=0, m=0, ans=0;
  for (int i=0; i<n; i++) {
    for(int j=0; j<s[i].length()-1; j++) {
      if(s[i][j]=='A' && s[i][j+1]=='B') m++;
    }
    
    if(s[i][0]=='B') {
      if(s[i][s[i].length()-1]=='A') p++;
      else q ++;
    } else {
      if(s[i][s[i].length()-1]=='A') r ++;
    }
  }
  
  if(p>0) {
    ans += p-1;
    if(q>0) {
      ans++;
      q--;
    }
    if(r>0) {
      ans++;
      r--;
    }
  }
  ans += min(q,r);
  
  cout << ans+m <<endl;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(x) (x).begin(),(x).end()

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

const int INF = 1001001001;
const vector<int> di = {-1,  0, 1, 0};
const vector<int> dj = { 0, -1, 0, 1};

void chmin(int &a, int b) { if (a > b) a = b; }

ll GCD(ll a, ll b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}
ll LCM(ll a, ll b) { return a * b / GCD(a, b); }

struct UnionFind {
    vector<int> d; // d[a]=bのとき、「aの親がbである」ということを表す。

    UnionFind(int n=0): d(n, -1) {} // 全て根であるとみなす。d[x]==-1のとき、そのノードは根である。

    int find(int x) {
        if (d[x] < 0) return x; // 今の頂点が根ならその値を返す
        return d[x] = find(d[x]); // 経路縮約（メモ化）
    }

    bool unite(int x, int y) { // Minimum Spanning Treeのためにboolを返す実装にしている。
        int rx = find(x);
        int ry = find(y);

        if (rx == ry) return false;
        if (d[rx] > d[ry]) swap(rx, ry); // マイナスサイズなので不等号が逆。xのサイズの方が大きいようにする。
        d[rx] += d[ry]; // 連結成分のサイズを管理するためのコード
        d[ry] = rx; // xにyをくっつける。yの値をxの根とする。
        return true;
    }

    bool same(int x, int y) { return find(x) == find(y); }
    int size(int x) { return -d[find(x)]; }
};


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

    vector<int> P(N);
    rep(i, N) cin >> P.at(i);

    UnionFind tree(N);

    rep(i, M) {
        int x, y;
        cin >> x >> y;
        x--, y--;
        tree.unite(x, y);
    }

    int ans = 0;
    rep(i, N) if (tree.same(i, P.at(i)-1)) ans++;

    cout << ans << endl;
}


Measured memory_bytes: 1152
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define MAX 1000000007
using namespace std;
ll comb[2010][2010];

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

	rep(i,2005)rep(j,2005)comb[i][j]=0;
	comb[1][0]=1;
	comb[1][1]=1;
	for(int i=2;i<2002;i++){
		comb[i][0]=1;
		comb[i][i]=1;	
		for(int j=1;j<i;j++){
			comb[i][j] = (comb[i-1][j]+comb[i-1][j-1])%MAX;
		}
	}

	if(n==k){
		cout<<1<<endl;
		rep(i,k-1)cout<<0<<endl;
		return 0;
	}
	rep(i,k){
		if(n-k<i)cout<<0<<endl;
		/*cout<<k-1<<"C"<<i+1<<"="<<comb[n-1][i+1]<<endl;
		cout<<n-k-1<<"C"<<i<<"="<<comb[n-k-1][i]<<endl;
		cout<<n-k-1<<"C"<<i+1<<"="<<comb[n-k-1][i+1]<<endl;
		cout<<n-k-1<<"C"<<i+2<<"="<<comb[n-k-1][i+2]<<endl;*/
		else cout<<(comb[k-1][i]*comb[n-k+1][i+1])%MAX<<endl;
	}
	return 0;
}


Measured memory_bytes: 31744
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
int main() {
  ll a, b, n;
  cin >> a >> b >> n;
  ll ans=0;
  if(b-1<=n) cout << a*(b-1)/b << endl;
  else {
    cout << a*n/b << endl;
  }
}


Measured memory_bytes: 3620
#include<stdio.h>
int main()
{
	int n,h[20],c=1,t,i;

	scanf("%d",&n);
	for(i=0;i<n;i++)
		scanf("%d",&h[i]);
	t=h[0];
	for(i=1;i<n;i++)
		if(t<=h[i]){
			c++;
			if(t<h[i])
				t=h[i];
		}
	printf("%d",c);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#define pi 3.14159265358979323846264338327950



int main() {
	long long N, A, B, d; std::cin >> N >> A >> B;
	std::cout << ((N / (A + B)) * A) + std::min(A, N % (A + B)) << std::endl;

	return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
#define rep(i, l, r) for(int i = l; i <= r; ++i)
const int N = 2000 + 5;
const int M = 20000 + 5;
const int inf = 1000000000;
struct Modify{
    int x, y;
}up[M];
int n, m, ans, Max, a[N * 3], b[N], f[N], S[N], L[N][N], dp[N][N];
int read(){
    char c; int x = 0, f = 1;
    c = getchar();
    while(c > '9' || c < '0'){ if(c == '-') f = -1; c = getchar();}
    while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
    return x * f;
}
int chkmax(int &a, int b){
    return a = max(a, b);
}
int main(){
    n = read();
    rep(i, 1, n * 3) a[i] = read();
    rep(i, 1, n - 1){
        int Fi = 2 + (i - 1) * 3;
        if((a[Fi + 1] == a[Fi + 2]) && (a[Fi + 2] == a[Fi + 3])) ++ans, f[i] = 1;
    }
    rep(i, 1, n) rep(j, 1, n) dp[i][j] = L[i][j] = S[i] = -inf;
    L[a[1]][a[2]] = L[a[2]][a[1]] = dp[a[1]][a[2]] = dp[a[2]][a[1]] = S[a[1]] = S[a[2]] = 0;
    rep(i, 1, n - 1){
        if(f[i]) continue;
        int Fi = 2 + (i - 1) * 3; m = 0;
        dp[a[Fi + 2]][a[Fi + 1]] = chkmax(dp[a[Fi + 1]][a[Fi + 2]], max(Max, L[a[Fi + 3]][a[Fi + 3]] + 1));
        dp[a[Fi + 3]][a[Fi + 1]] = chkmax(dp[a[Fi + 1]][a[Fi + 3]], max(Max, L[a[Fi + 2]][a[Fi + 2]] + 1));
        dp[a[Fi + 3]][a[Fi + 2]] = chkmax(dp[a[Fi + 2]][a[Fi + 3]], max(Max, L[a[Fi + 1]][a[Fi + 1]] + 1));
        up[++m].x = a[Fi + 1], up[m].y = a[Fi + 2];
        up[++m].x = a[Fi + 1], up[m].y = a[Fi + 3];
        up[++m].x = a[Fi + 2], up[m].y = a[Fi + 3];
        int A, B, C; b[1] = a[Fi + 1], b[2] = a[Fi + 2], b[3] = a[Fi + 3];
        sort(b + 1, b + 3 + 1), A = b[1], B = b[2], C = b[3];
        if(B == C) swap(A, C);
        rep(j, 1, n) if(S[j] >= 0){
            up[++m].x = j, up[m].y = A, up[++m].x = j, up[m].y = B, up[++m].x = j, up[m].y = C;
            dp[A][j] = chkmax(dp[j][A], S[j]);
            dp[B][j] = chkmax(dp[j][B], S[j]);
            dp[C][j] = chkmax(dp[j][C], S[j]);
        }
        if(A == B){
            rep(j, 1, n) if(L[j][A] >= 0){
                up[++m].x = j, up[m].y = C;
                dp[j][C] = chkmax(dp[C][j], L[j][A] + 1);
            }
        }
        rep(j, 1, m){
            int x = up[j].x, y = up[j].y;
            L[x][y] = L[y][x] = dp[x][y];
            Max = max(Max, dp[x][y]), S[x] = max(S[x], dp[x][y]), S[y] = max(S[y], dp[x][y]);
        }
    }
    printf("%d", max(Max, dp[a[n * 3]][a[n * 3]] + 1) + ans);
    return 0;
}

Measured memory_bytes: 35160
#include<bits/stdc++.h>
using namespace std;
int main()
{
    stack<int> st;
    string x;
    while(cin>>x)
    {
	if(x=="+" || x=="-" || x=="*")
        {
	    int a = st.top(); st.pop();
	    int b = st.top(); st.pop();
            if(x=="+") { st.push(b + a); }
	    if(x=="-") { st.push(b - a);  }
	    if(x=="*") { st.push(b * a);  }
        }
        else { st.push(stoi(x)); }
    }
	cout<<st.top()<<endl;
    return 0;
}



Measured memory_bytes: 3216
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define rrep(i,n) for(int (i) = (n) - 1; (i) >= 0; --(i)) //Reversi rep
#define nfor(i,a,b) for(int (i) = (a); (i) < (b); ++(i)) //Natural for
#define rfor(i,a,b) for(int (i) = (b) - 1; (i) >= (a); --(i)) //Reversi for
#define ll long long
#define mod (1000000007)
#define YES cout << "YES" << endl;
#define Yes cout << "Yes" << endl;
#define yes cout << "yes" << endl;
#define NO cout << "NO" << endl;
#define No cout << "No" << endl;
#define no cout << "no" << endl;

int asc(const void *a, const void *b) {
    return *(int *)a - *(int *)b;
}

int desc(const void *a, const void *b) {
    return *(int *)b - *(int *)a;
}

int main()
{
    int r,d,x;
    cin >> r >> d >> x;
    rep(i, 10){
        x = r * x - d;
        cout << x << endl;
    }
    return 0;
}


Measured memory_bytes: 256