akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>  // g++ -std=c++14 -o a a.cpp

using namespace std;

typedef pair<int, int> P;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define repto(i, n) for(int i = 0; i <= (n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end()) // ユニークなvectorにする。連続した値を除去して切り出す。
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007
#define DEBUG(x) cout << #x << ": " << x << endl;

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

int main() {
  int D, L;
  cin >> D >> L;
  cout << ((D / L) + (D % L)) << endl;
}



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

int main()
{
    /*A
    string s;
    cin>>s;
    if(s=="AAA" || s=="BBB")
    {
        cout<<"No"<<endl;
    }
    else
    {
        cout<<"Yes"<<endl;
    }
    */
   /*B
    ll n,a,b;
    cin>>n>>a>>b;
    ll count=0;
    if(a==0)
    {
       cout<<0<<endl;
       return 0;
    }
    else if(n%(a+b)==0)
    {
        count = (n/(a+b))*a;
        cout<<count<<endl;
        return 0;
    }
    else
    {
        if(n%(a+b)<=a)
        {
            count=(n/(a+b))*a+n%(a+b);
            cout<<count<<endl;
            return 0;
        }
        else
        {
            count =  (n/(a+b))*a+a;
            cout<<count<<endl;
            return 0;
        }
    }

    cout<<count<<endl;
    */
    /*C
    int a,b;
    cin>>a>>b;

    for(int i=1;i<=1009;i++)
    {
        if(int(i*0.08)==a && int(i*0.1)==b)
        {
            cout<<i<<endl;
            return 0;
        }
    }
    cout<<-1<<endl;
    */
    string s;
    cin>>s;
    ll q;
    cin>>q;
    string t;
    for(ll i=0;i<q;i++)
    {
        int u,f;
        cin>>u;
        if(u==1)
        {
            swap(s,t);
        }
        else
        {
            cin>>f;
            char c;
            cin>>c;
            if(f==1)
            {
                t+=c;
            }
            else
            {
                s+=c;
            }
        }
    }

    reverse(t.begin(),t.end());
    t += s;

    cout<<t<<endl;
    return 0;
}

Measured memory_bytes: 1128
/*Function Template*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pint;
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;
}

void runlength(string s,vector<pair<char,ll>> &p){
  ll x=1;
  if(s.size()==1){
    p.push_back(pair<char,ll>(s[0],1));
  }
  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));
      }
    }
  }
}




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

vector<pint> prime_factorize(ll n){
  vector<pint> ans;
  for(ll p=2;p<=sqrt(n);p++){
    if(n%p!=0) continue;
    ll cnt=0;
    while(n%p==0){
      n/=p;
      cnt++;
    }
    ans.push_back(make_pair(p,cnt));
  }
  if(n!=1) ans.push_back(make_pair(n,1));
  return ans;
}

/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
int main() {
  IOS;
  while(1){
    ll n,q;
    cin>>n>>q;
    if(n==0 && q==0) return 0;
    ll ans[101];
    rep(i,101) ans[i]=0;
    rep(i,n){
      ll tmp;cin>>tmp;
      rep(j,tmp){
        ll a;cin>>a;
        ans[a]++;
      }
    }
    ll cnt=102;
    rep(i,101) if(ans[i]>=q){
      if(ans[i]==q) chmin(cnt,i);
      else cnt=i;
      q=ans[i];
    }
    if(cnt==102) cout<<0<<endl;
    else cout<<cnt<<endl;
  }
}


Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
const int N=16;
int n;
vector<int>v[N][2];
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        int x;scanf("%d",&x);
        for(int j=1;j<=x;j++)
        {
            int y,z;scanf("%d%d",&z,&y);
            v[i][y].push_back(z);
        }
    }
    int ans=0;
    for(int i=0;i<1<<n;i++)
    {
        bool flag=true;
        for(int j=1;j<=n;j++)
        {
            bool f=true;
            for(int k=0;k<v[j][0].size();k++)
                if(1<<(v[j][0][k]-1)&i) f=false;
            for(int k=0;k<v[j][1].size();k++)
                if(!((1<<v[j][1][k]-1)&i)) f=false;
            if(f&&(!(1<<(j-1)&i))) flag=false;
            if(!f&&(1<<(j-1)&i)) flag=false;
        }
        if(flag) ans=max(ans,__builtin_popcount(i));
    }
    printf("%d\n",ans);
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

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

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

void calc(ll x, ll c, VL &ans){
    int n = ans.size();
    VL s(n + 1);
    REP(i,x){
        s[i + 1]++;
        s[i + 2]++;
        s[i + c/2 + 2]--;
        s[i + (c-1)/2 + 2]--;
    }
    REP(i,n) s[i + 1] += s[i];
    REP(i,n) ans[i] += s[i];
}

int main(void){
    ll n, x, y;
    cin >> n >> x >> y;
    x--;
    y--;
    ll c = y - x + 1;
    y = n - y - 1;
    VL ans(n);
    FOR(x,1,(c-1)/2) ans[x] = c;
    if (c % 2 == 0) ans[c / 2] = c / 2;
    calc(x, c, ans);
    calc(y, c, ans);
    ll s = x + y + 2;
    FOR(k,1,s-1) ans[k] += s - k;
    REP(k,s){
        ans[abs(k - x)]--;
        ans[abs(k - y)]--;
    }
    ans[1]++;
    FOR(k,1,n-1) printf("%lld\n", ans[k]);
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <vector>

using namespace std;

int main() {
  uint32_t N, X, *L;
  cin >> N >> X;
  L = new uint32_t[N + 1];
  uint32_t tmp;
  L[0] = 0;
  for (uint32_t i = 0; i < N; ++i) {
    cin >> tmp;
    L[i + 1] = L[i] + tmp;
  }
  uint32_t res = 0;
  for (uint32_t i = 0; i < N + 1; ++i) {
    if (L[i] <= X) ++res;
  }

  cout << res << endl;

  return 0;
}


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

#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define RFOR(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define LL long long
#define INF INT_MAX/3

const double EPS = 1e-14;
const double PI  = acos(-1.0);


int main(){
  int n; cin >> n;
  int march[5] = {0};
  REP (i, n) {
    string s;
    cin >> s;
    if (s[0] == 'M') march[0]++;
    else if (s[0] == 'A') march[1]++;
    else if (s[0] == 'R') march[2]++;
    else if (s[0] == 'C') march[3]++;
    else if (s[0] == 'H') march[4]++;
  }

  LL ans = 0;
  REP (i, (1<<5)) {
    LL sum = 0;
    if (__builtin_popcount(i) == 3) {
      sum = 1;
      REP (j, 5) {
        if ((i>>j) % 2 == 1) {
          sum *= march[4 - j];
        }
      }
    }
    ans += sum;
  }

  printf("%lld\n", ans);
}


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

int main () {
  int N,c;
  cin >> N;
  
  for(int a=0; a<26; a++) {
    for(int b=0; b<15; b++) {
      if(N==4*a+7*b) {
        c++;
      }
    }
  }
  if(c>=1) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
H = int(input())
count = 0
N = 1
while True:
  if H == 1:
    count += N
    print(count)
    break
  else:
    if H % 2 == 0:
      H = H//2
      count += N
      N *= 2
    else:
      H = (H-1) // 2
      count += N
      N *= 2


Measured memory_bytes: 2940
s = input()[::-1]
N = len(s)
idx = 0
ls = ['maerd', 'remaerd', 'esare', 'resare']
while 1:
    tmp = idx
    if s[idx:idx+5] in ls:
        idx += 5
    elif s[idx:idx+6] in ls:
        idx += 6
    elif s[idx:idx+7] in ls:
        idx += 7
    
    if idx == N:
        print('YES')
        break
    if tmp == idx:
        print('NO')
        break



Measured memory_bytes: 3188
using System;

namespace _0019
{
    class Program
    {
        static void Main(string[] args)
        {
            int a = int.Parse(Console.ReadLine());
            long y = 1;
            for(int i = 1; i <= a; i++)
            {
                y = y * i;
            }
            Console.WriteLine(y);
        }
    }
}

Measured memory_bytes: 9000
import sys
from collections import namedtuple
from heapq import heappop, heappush

Edge = namedtuple('Edage', 'to cost')
P = namedtuple('P', 'cost u')

N = int(input())

G = [[] for _ in range(N)]

for u in range(N):
  args = [int(x) for x in input().split()]
  #　不要な値を捨てる 
  args.pop(0)
  args.pop(0)

  while args:
    to = args.pop(0)
    cost = args.pop(0)
    G[u].append(Edge(to, cost))

costs = [sys.maxsize] * N
costs[0] = 0

q = [P(0, 0)]

while q:
  cost, u = heappop(q) 

  for v, c in G[u]:
    if costs[u] + c < costs[v]:
      costs[v] = costs[u] + c
      heappush(q, P(costs[v], v))

for i in range(N):
  print(i, costs[i])



Measured memory_bytes: 6552
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>
#include<iomanip>

using namespace std;
typedef long long ll;

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

	map<int, int> x;
	for (int i = 0; i < N; i++) x[a[i]]++;
	int ans = 0;
	for (auto p: x) {
		int x1 = p.first;
		int x2 = p.second;
		if (x2 < x1) ans += x2;
		else ans += x2 - x1;
	}
	cout << ans << endl;
}


Measured memory_bytes: 8076
//20200815A
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String s=sc.nextLine();
		if(s.equals("SSS")){
			System.out.println(0);
		}
		if(s.equals("RSS")){
			System.out.println(1);
		}
		if(s.equals("SRS")){
			System.out.println(1);
		}
		if(s.equals("SSR")){
			System.out.println(1);
		}
		if(s.equals("RRS")){
			System.out.println(2);
		}
		if(s.equals("SRR")){
			System.out.println(2);
		}
		if(s.equals("RSR")){
			System.out.println(1);
		}
		if(s.equals("RRR")){
			System.out.println(3);
		}
	}
}

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

int main() {
  int H, W;
  cin >> H >> W;
  string edge;
  for (int i = 0; i < W+2; i++) {
    edge += "#";
  }
  cout << edge << endl;
  for (int j = 0; j < H; j++) {
    string r;
    cin >> r;
    string R = "#";
    for (int k =0; k < W; k++) {
      R += r.at(k);
    }
    R += "#";
    cout << R << endl;
  }
  cout << edge <<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define all(v) v.begin(),v.end()
using namespace std;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    long long n,k,q,a,p[100005]={};
    cin>>n>>k>>q;
    for(int i=0;i<q;i++){
        cin>>a;
        p[a]++;
    }
    for(int i=1;i<=n;i++){
        if(q-p[i]>=k){
            cout<<"No"<<endl;
        }
        else{
            cout<<"Yes"<<endl;
        }
    }
    return(0);
}

Measured memory_bytes: 4400
N=int(input())
A=[]
B=[]
for i in range(N):
  a,b=map(int,input().split())
  A.append(a)
  B.append(b)
A.sort()
B.sort()

if N%2==1:
  Amed=A[N//2]
  Bmed=B[N//2]
  print(Bmed-Amed+1)
else:
  Amed=(A[N//2]+A[N//2-1])/2
  Bmed=(B[N//2]+B[N//2-1])/2
  print(round((Bmed-Amed)*2+1))

Measured memory_bytes: 25408
import sys
sys.setrecursionlimit(10**6)
# input = sys.stdin.readline
ii = lambda: int(input())
mis = lambda: map(int,input().split())
lmis = lambda: list(mis())
INF = float('inf')

def main():
    a=lmis()
    print('bust' if sum(a)>21 else 'win')


if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
n=int(input())
a=list(map(int,input().split()))
ans=float('inf')
b=[a[0]]
for i in range(1,n):
    b.append(b[i-1]+a[i])
#print(b)
for i in range(n-1):
    c=abs(b[-1]-2*b[i])
    if c<=ans:
        ans=c
        #print(ans)
print(ans)


Measured memory_bytes: 100816
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.stream.Stream;

public class Main{
    public static void main(String[] args)throws IOException{
        BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
        String[] array = input.readLine().split(" ");
        int[] array1 = Stream.of(array).mapToInt(Integer::parseInt).toArray();
        int disx = Math.abs(array1[2] - array1[0]);
        int disy = Math.abs(array1[3] - array1[1]);
        String ans = "";
        StringBuffer sb = new StringBuffer(ans);
        for(int i=0;i<disy;i++){
            sb.append("U");
        }
        for(int i=0;i<disx;i++){
            sb.append("R");
        }
        for(int i=0;i<disy;i++){
            sb.append("D");
        }
        for(int i=0;i<disx;i++){
            sb.append("L");
        }
        sb.append("LU");
        for(int i=0;i<disy;i++){
            sb.append("U");
        }
        for(int i=0;i<disx;i++){
            sb.append("R");
        }
        sb.append("RDRD");
        for(int i=0;i<disy;i++){
            sb.append("D");
        }
        for(int i=0;i<disx;i++){
            sb.append("L");
        }
        sb.append("LU");
        
        System.out.println(new String(sb));

    }

}

Measured memory_bytes: 26708
#include <iostream>
#include <cstring>
#include <queue>
#include <algorithm>
using namespace std;
int n,c;
string mp[11];
int visited[101][101],flg;
int cnt;

void saiki(int x,int y,char num){
  //cout << x << " "<<y<<" : "<<mp[y][x]<<endl;
 
  visited[y][x] = 1;

  for(int i=-1;i<=1;i++)
    for(int j=-1;j<=1;j++){
      if(i==0&&j==0)continue;
      int f=0;
      if(i==0)f=j;
      int nx = x+j+f;
      int ny = y+i;     

      if(nx<0||ny<0||ny>=n||nx>=(int)mp[ny].size())continue;
      
      if(mp[ny][nx]== num && visited[ny][nx]==0)cnt++,saiki(nx,ny,num);
      if(mp[ny][nx]== '0')flg=0;
    }
  
}

int check(){
  //for(int i=0;i<n;i++)cout << mp[i]<<endl;
  memset(visited,0,sizeof(visited));
  int res=0;
  for(int i=0;i<n;i++)
    for(int j=0;j<mp[i].size();j++)
      if('1'<=mp[i][j]&&mp[i][j]<='9' && visited[i][j]==0){
	flg=1;
	if(mp[i][j] == c+'0')flg=-1;
	cnt=1;
	saiki(j,i,mp[i][j]);
	//	cout <<"flg="<< flg<<endl;
	res+=cnt*flg;
      }
  return res;
}

int main() {
  
  while(1){
    cin >> n >> c;
    if(n==0 && c==0) break;
    string a;
    for(int i=0;i<n;i++) mp[i].clear();
    for(int i=0;i<n;i++){
      for(int j=0;j<n-i-1;j++)mp[i]+=" ";
      for(int j=0;j<=i;j++) mp[i]+=" ",cin >> a ,mp[i]+=a;
    }

    int ans = -1000000;
    for(int i=0;i<n;i++)
      for(int j=0;j<mp[i].size();j++)
	if(mp[i][j]=='0')mp[i][j]=c+'0',ans = max(ans,check()),mp[i][j]='0';
      
    cout <<ans <<endl;
				    

  }
  return 0;

}

Measured memory_bytes: 1260
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
#include <map>
using namespace std;
//cout <<  << endl;
typedef long long int ll;
typedef long double ld;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1LL << 60;
#define MOD 1000000007
#define MAX_V 100010
#define MAX_N 1000100
bool x[MAX_N];
ll num[MAX_N];
ll fibl[MAX_N]={0};
 
ll fib(ll a){
    if (fibl[a]!=0)return fibl[a];
    if (a==0){
        return 0;
    }else if (a==1){
        return 1;
    }
    return fibl[a]=fib(a-1)+fib(a-2);
}
 
ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    return p;
}
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.second < secondElof.second;
}

ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}

ll junnretu(ll n){
    ll ans=1;
    for (ll i=1;i<=n;i++){
        ans*=i;
    }
    return ans;
}

map<ll,ll> prime_factor(ll n){
    map<ll,ll> mp;
    for(ll i=2; i*i<=n; i++){
        while(n % i == 0){
            mp[i]++;
            n /= i;
        }
    }
    if(n != 1) mp[n] = 1;
    return mp;
}

ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

int main(){
    ll a,b,c;
    cin >> a >> b >> c;
    if (c>=a && c<=b){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}




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


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



Measured memory_bytes: 3600
memo = {(0,1):False, (1, 1): False}
def solve(p):
    x,y = p
    if x > y:
        x,y = y,x
    if (x, y) in memo:
        return memo[(x,y)]
    if x < 2 and y < 2:
        return False
    hand = []
    for i in range(2, x+1, 2):
        hand.append((x-i, y+i//2))
    for i in range(2, y+1, 2):
        hand.append((x+i//2, y-i))
    if all(map(solve, hand)):
        memo[(x,y)] = False
    else:
        memo[(x,y)] = True    
    return memo[(x,y)]

def solve2(p):
    x,y = p
    if x > y:
        x,y = y,x
    return not (-1 <= y-x <= 1)



if __name__ == '__main__':
    X,Y = map(int, input().split())
    # print('Alice' if solve((X, Y)) else 'Brown')
    print('Alice' if solve2((X, Y)) else 'Brown')
    # N = 100
    # a = [['Alice' if solve((i, j)) else 'Brown' for j in range(N)] for i in range(N)]
    # for i in range(N):
    #     print('\t'.join(a[i]))
    # for i in range(N):
    #     for j in range(N):
    #         if solve((i, j)) != solve2((i, j)):
    #             print(i,j)
            # print(i,j,'Alice' if solve((i, j)) else 'Brown')
    

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <utility>
#include <unordered_map>
#include <vector>
#include <string>


std::string S, T;

int main()
{
	using std::cin;
	using std::cout;
	using std::endl;
	cin >> S >> T;

	std::unordered_map<char, char> graph;
	for (size_t i = 0; i < S.size(); ++i)
	{
		if (graph.count(S[i]) == 0) {
			graph[S[i]] = T[i];
		}
		else {
			if (graph[S[i]] != T[i]) {
				cout << "No" << endl;
				return 0;
			}
		}
	}

	bool used[256] = {};
	for (auto& i : graph) {
		if (used[i.second]) {
			cout << "No" << endl;
			return 0;
		}
		used[i.second] = true;
	}
	cout << "Yes" << endl;
	

	/*
	if (graph.size() < ('z' - 'a' + 1)) {
		cout << "Yes" << endl;
		return 0;
	}
	bool used[256] = {};
	for (char i = 'a'; i <= 'z'; i++)
	{
		if (used[i]) {
			continue;
		}
		used[i] = true;
		char next = graph[i];
		while (next != i) {
			if(used[next]){
				cout << "No" << endl;
				return 0;
			}
			used[next] = true;
			next = graph[next];
		}
	}
	cout << "Yes" << endl;
	*/
}


//D解けないが（険しい）
#if 0
//ICPC練習の為にライブラリ使わずに自分で書くか...
constexpr int64_t MOD = 1000000000 + 7;
int64_t mpow(int64_t b, int32_t p)
{
	int64_t res = 1;
	int64_t mul = b;
	while (p > 0)
	{
		if (p & 1) {
			res *= mul;
			res %= MOD;
		}
		mul *= mul;
		mul %= MOD;
		p >>= 1;
	}
	return res;
}

int64_t fact[100];
int64_t fact_rev[100];

int64_t N, M;
std::unordered_map<int32_t, int32_t> num;

int main()
{
	using std::cin;
	using std::cout;
	using std::endl;
	cin >> N >>M;

	fact[0] = fact_rev[0] = 1;
	for (int32_t i = 1; i < 100; i++)
	{
		fact[i] = i * fact[i - 1]; fact[i] %= MOD;
		fact_rev[i] = mpow(fact[i], MOD - 2);
	}

	int32_t total = 0;
	for (int32_t i = 2; i <= M; i++)
	{
		if (M%i == 0) {
			++num[i];
			++total;
			M /= i;
		}
	}

	int64_t res = 1;
	res *= fact[N - 1 + total]; res %= MOD;
	res *= fact_rev[N - 1]; res %= MOD;
	for (auto& i : num) {
		res *= fact_rev[i.second]; res %= MOD;
	}
	cout << res << endl;
}
#endif

Measured memory_bytes: 1020
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll n,a,b;
    cin>>n>>a>>b;
    if(a==0)
    {
        cout<<0<<endl;
    }
    else if(b==0)
    {
        cout<<n<<endl;
    }
    else
    {
        if(n%(a+b)==0)
        {
            cout<<n/(a+b)*a<<endl;
        }
        else
        {
            ll x=n%(a+b);
            if(x>=a)
            {
                cout<<(n/(a+b)*a)+a<<endl;
            }
            else
            {
                cout<<(n/(a+b)*a)+x<<endl;
            }
        }
    }



    return 0;
}


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

int main(){
  int a,b,c;
  int tmp;

  cin >> a >> b >> c;

  if(a > b){
    tmp = a;
    a = b;
    b = tmp;
  }

  if(b > c){
    tmp = b;
    b = c;
    c = tmp;
  }

  if(a > b){
    tmp = a;
    a = b;
    b = tmp;
  }

  cout << a << " " << b << " " << c << endl;
  
  return 0;
}

Measured memory_bytes: 3076
import java.util.*;

public class Main 
{
	public static void main(String[] args) 
	{
		Scanner stdIn = new Scanner(System.in);
		int d, t;
		double x = 0, y = 0;
		double angle = 90;
		while(true)
		{
			String[] s = stdIn.next().split(",");
			d = Integer.parseInt(s[0]);
			t = Integer.parseInt(s[1]);
			if(d == 0 && t == 0)
			{
				break;
			}
			x += d * Math.cos(angle / 180 * Math.PI);
			y += d * Math.sin(angle / 180 * Math.PI);
			angle -= t;
		}
		System.out.printf("%d\n%d\n", (int)x, (int)y);
	}
}

Measured memory_bytes: 11000
#include <iostream>
#include <fstream>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#include <random>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<29;
const ll INF=1ll<<52;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const vi emp;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,-0};
const int DX[8]={-1,-1,-1,0,1,1,1,0},DY[8]={1,0,-1,-1,-1,0,1,1};

int n;
vl a;

bool f(int x){
	ll sum=0;
	for(int i=0;i<=x;i++) sum+=a[i];
	x++;
	for(int i=0;i<n;i++){
		auto it=upper_bound(a.begin(),a.end(),sum*2);
		if(it==a.end()) return 1;
		for(int j=x;j<it-a.begin();j++) sum+=a[j];
		x=it-a.begin();
	}
	return 0;
}

int main(){
	cin>>n;
	a=vl(n);
	for(int i=0;i<n;i++) cin>>a[i];
	sort(a.begin(),a.end());
	int s=-1,t=n-1;
	while(t-s>1){
		int m=(s+t)/2;
		if(f(m)) t=m;
		else s=m;
	}
	cout<<n-t<<endl;
}

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

char C[36][3];
char Cb[36][3];
char Cs[36][3];
int Ib[36];
int Is[36];
int N;

bool is_stable(char c[][3], int ind[]){
    char num='1';
    for (int i=1; i<N; i++) {
        if (c[i][1] == num) {
            if (ind[i-1] > ind[i]) {
                return false;
            }
        }
        num = c[i][1];
    }
    return true;
}

void print_cards(char c[][3]){
    for (int i=0; i<N; i++) {
        printf("%s", c[i]);
        putchar(i<N-1 ? ' ' : '\n');
    }
}

int main()
{
    scanf("%d", &N);
    for (int i=0; i<N; i++) {
        scanf("%s", C[i]);
        strcpy(Cb[i], C[i]);
        strcpy(Cs[i], C[i]);
        Ib[i] = Is[i] = i;
    }
    
    for (int i=0; i<N; i++) {
        for (int j=N-1; j>i; j--) {
            if (Cb[j-1][1] > Cb[j][1]) {
                char temp[3];
                strcpy(temp, Cb[j-1]);
                strcpy(Cb[j-1], Cb[j]);
                strcpy(Cb[j], temp);
                int tempi = Ib[j];
                Ib[j] = Ib[j-1];
                Ib[j-1] = tempi;
            }
        }
    }
    print_cards(Cb);
    puts(is_stable(Cb, Ib)?"Stable":"Not stable");
    
    for (int i=0; i<N; i++) {
        int minj = i;
        for (int j=i; j<N; j++) {
            if (Cs[j][1] < Cs[minj][1]) {
                minj = j;
            }
        }
        char temp[3];
        strcpy(temp, Cs[minj]);
        strcpy(Cs[minj], Cs[i]);
        strcpy(Cs[i], temp);
        int tempi = Is[minj];
        Is[minj] = Is[i];
        Is[i] = tempi;
    }
    print_cards(Cs);
    puts(is_stable(Cs, Is)?"Stable":"Not stable");
}

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

const int INF = 1e9;

int main() {

	ll A[3];
	rep(i, 3) cin >> A[i];

	sort(A,A+3);

	rep(i, 3) {
		if (A[i] % 2 == 0) {
			cout << 0 << endl;
			return 0;
		}
	}

	cout << A[0] * A[1] << endl;

	return 0;
}

Measured memory_bytes: 256
import math
x, y = map(int, input().split())
mod = 10**9 +7
if (2*x-y)%3 != 0 or (2*y-x)%3 != 0 or (2*x-y)<0 or (2*y-x)<0:
    print(0)
else:
    b = (2*x-y)//3
    a = x - 2*b
    c = min(a, b)
    s = 1
    t = 1
    for i in range(c):
        s = s*(a+b-i)%mod
        t = t*(c-i)%mod
    print(s*pow(t, mod-2, mod)%mod)

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

using namespace std;

#define FOR(i,a,b) for(int i = (a); i <= (b); ++i)
#define FORD(i,a,b) for(int i = (a); i >= (b); --i)
#define RI(i,n) FOR(i,1,(n))
#define REP(i,n) FOR(i,0,(n)-1)
#define mini(a,b) a=min(a,b)
#define maxi(a,b) a=max(a,b)
#define mp make_pair
#define pb push_back
#define st first
#define nd second
#define sz(w) (int) w.size()
typedef vector<int> vi;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

const ll inf = 1e18 + 7;
const int maxN = 5e4 + 5;

string s;
int ans = 0;

int main() {
	ios_base::sync_with_stdio(0);
	cin >> s;
	REP(i, sz(s) - 1) {
		if (s[i] == s[i + 1]) {
			cout << i + 1 << " " << i + 2 << endl;
			return 0;
		}
	}
	REP(i, sz(s) - 2) {
		string tmp = s.substr(i, 3);
		sort(tmp.begin(), tmp.end());
		if (tmp[0] == tmp[1] || tmp[1] == tmp[2]) {
			cout << i + 1 << " " << i + 3 << endl;
			return 0;
		}
	}
	cout << -1 << " " << -1 << endl;
	return 0;
}


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

int main(){
  int x;cin>>x;
  if(x <= 599)
    cout << 8 << endl;
  else if(x <= 799)
    cout << 7 << endl;
  else if(x <= 999)
    cout << 6 << endl;
  else if(x <= 1199)
    cout << 5 << endl;
  else if(x <= 1399)
    cout << 4 << endl;
  else if(x<=1599)
    cout << 3 << endl;
  else if(x <= 1799)
    cout << 2 << endl;
  else cout << 1 << endl;
}

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

int main(){
	int n; cin>>n;
	int p[n]; for (int i = 0; i < n; ++i) cin>>p[i];
	vector<int> dp(n+1,0); for (int i = 0; i < n; ++i) dp[p[i]]=dp[p[i]-1]+1;
	int ans=0;for (int i = 1; i <= n; ++i) ans=max(ans,dp[i]);
	cout<<n-ans<<endl;
	return 0;
}

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

int main() {
	int N;
  cin >> N;
  vector<int>vec(N,0);
  for(int i=0;i<N-1;i++){
    int k;
    cin >> k;
    vec.at(k-1)++;
  }
  for(int j=0;j<N;j++){
    cout << vec.at(j) <<endl;
  }
}




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

#define pb push_back
#define eb emplace_back
#define ff first
#define ss second
#define endl '\n'
#define boost ios::sync_with_stdio(false) ; cin.tie(NULL); cout.tie(NULL);
typedef long long li;
const int INF = 1e9 + 12;
#define int long long
const int N = 1e5 + 10;
int dp[N];
signed main(){

	int n;
	cin>>n;
	int a[n];

	for(int i = 0 ; i < n ; ++i)
		cin>>a[i];
	fill(dp,dp+n,INF);
	dp[0] = 0;
	for(int i = 0 ; i < n ; ++i){

		for(int j : {i+1,i+2})
			if(j < n)
				dp[j] = min(dp[j] , dp[i] + abs(a[i]-a[j]));
	}

	cout<<dp[n-1]<<endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

#define            ll              long long
#define            pb              push_back
#define            mp              make_pair
#define            loop(i,a,n)     for(int i=a;i<=n;++i)
#define            clr(x)          memset(x,0,sizeof x)
#define            min3(a,b,c)     min(a,min(b,c))
#define            max3(a,b,c)     max(a,max(b,c))
#define            min4(a,b,c,d)   min(a,min(b,min(c,d)))
#define            max4(a,b,c,d)   max(a,max(b,max(c,d)))
#define            fast            ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define            pii             pair<int,int>
#define            pll             pair<ll,ll>
#define            pli             pair<ll,int>
#define            pil             pair<int,ll>
#define            FF              first
#define            SS              second
#define            PI              acos(-1.0)
#define            bug             cout<<"ok"<<endl;

using namespace std;
using namespace __gnu_pbds;

typedef tree<int , null_type,less<int>,
       rb_tree_tag, tree_order_statistics_node_update> anik;

const int MOD = 1e9 + 7;
const ll MX= 1e9;
const ll INF = 1e9;
vector<int>adj[200009];
bool visited[200009];
int n,m;
bool dfs(int s)
{    visited[s]=true;
    for(int i=0;i<adj[s].size();i++)
    {
        if(visited[adj[s][i]]==false)
        {
            int p=adj[s][i];
            for(int j=0;j<adj[p].size();++j)
                if(adj[p][j]==n)return 1;
        }
    }
    return 0;
}

main()
{
   cin>>n>>m;

   for(int i=0;i<m;++i)
   {
       int x,y;
       cin>>x>>y;
       adj[x].pb(y);
       adj[y].pb(x);
   }
   bool ok=dfs(1);
   if(ok==1)cout<<"POSSIBLE"<<endl;
   else
    cout<<"IMPOSSIBLE"<<endl;
}



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


int main(int argc, char *argv[], char *envp[]){

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

	// cal
	int KAI = 0;
	for(int i=0; i<N; ++i){
		for(int j=i+1; j<N; ++j){
			KAI = KAI + A[i] * A[j];
		}
	}

	cout << KAI << endl;

	return 0;
}


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

using namespace std;
int main(){
	int masu[9000],n,m,iti,f;
	while(cin>>n>>m){
		if(n==0){
			break;
		}
		iti=f=1;
		for(int i=1;i<=n+m;i++){
			cin>>masu[i];
			if(i>n){
				iti+=masu[i];
				iti+=masu[iti];
				if(iti>=n&&f==1){
					printf("%d\n",i-n);
					f=0;
				}
			}
		}
	}
}

Measured memory_bytes: 0
n, k = gets.split.map(&:to_i)
h = gets.split.map(&:to_i)
(k - 1).times { h << 0 }
dp = Array.new(n - 1 + k) { Float::INFINITY }
dp[0] = 0

0.upto(n - 2) do |i|
  (k + 1).times do |j|
    dp[i + j] = [dp[i] + (h[i] - h[i + j]).abs, dp[i + j]].min
  end
end

puts dp[n - 1]


Measured memory_bytes: 21060
/**   Created by: Marcos Portales
          Codeforces User: marcosportales
          Country: Cuba
          Copyright                    */
#include<bits/stdc++.h>
using namespace std;
/// Pragmas:
#pragma GCC optimize("Ofast","unroll-loops","omit-frame-pointer","inline") //Optimization flags
#pragma GCC option("arch=native","tune=native","no-zero-upper") //Enable AVX
#pragma GCC target("avx2") //Enable AVX
/// Macros:
#define int long long
#define f first
#define s second
#define db(x) cerr << #x << ": " << (x) << '\n';
#define pb push_back
#define lb lower_bound
#define up upper_bound
#define all(x) x.begin() , x.end()
#define rall(x) x.rbegin() , x.rend()
#define enl '\n'
#define vi vector<int>
#define sz(a) int((a).size())
#define rep(i,n) for(int i=0;i<(n);i++)
#define repi(i,n) for(int i=(1);i<=(n);i++)
typedef pair<int,int> ii;
typedef long double ld;
typedef unsigned long long ull;
/// Constraints:
const int maxn = 200005;
const int mod = 1000000007;
const ld eps = 1e-9;
const int inf = ((1ll<<31ll)-1ll);
const int INF = 2000000000000000000ll;
const ld pi = acos(-1);
/// Prime Numbers:
// 2, 173, 179, 181, 197, 311, 331, 737, 1009, 2011, 2027, 3079, 4001, 10037, 10079, 20011, 20089;
// 100003, 100019, 100043, 200003, 200017, 1000003, 1000033, 1000037, 1000081;
// 2000003, 2000029, 2000039, 1000000007, 1000000021, 2000000099;
/// Functions:
#define lg2(x) 31 - __builtin_clz(x)
#define lgx(x,b) ( log(x) / log(b) )
/// Red-Black Tree Test.insert(x)late ---------------------------------
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//typedef tree < long long ,  null_type ,  less<long long> ,  rb_tree_tag ,  tree_order_statistics_node_update > ordered_set;
/// Quick Pow------------------------------------------------
int qpow(int b,int e){
    if( !e ) return 1;
    if( e & 1 ) return qpow(b,e-1) * b % mod;
    int pwur = qpow(b,e>>1);
    return (pwur * pwur) % mod;
}
int modinv(int x){
    return qpow(x,mod-2);
}

/// My Code -------------------------------------------------

int32_t main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout.setf(ios::fixed); cout.precision(0);
    srand(time(NULL));
    //freopen("a.in","r",stdin);
    //freopen("a.in","w",stdout);
    int n,m;
    cin>>n>>m;
    int i=n,ans=0;
    for(i=n;i<=m;i+=i)
        ans++;
    cout<<ans<<enl;
    return 0;
}


Measured memory_bytes: 3652
def warshall_floyd(v_count: int, matrix: list) -> list:
    """ ワーシャルフロイド
    v_count: 頂点数
    matrix: 隣接行列(到達不能はfloat("inf"))
    """
    for i in range(v_count):
        for j, c2 in enumerate(row[i] for row in matrix):
            for k, (c1, c3) in enumerate(zip(matrix[j], matrix[i])):
                if c1 > c2+c3:
                    matrix[j][k] = c2+c3
    return matrix


n = int(input())
g = [[] for _ in range(n)]
m = [list(map(int, input())) for _ in range(n)]
for i, row in enumerate(m):
    for j, c in enumerate(row):
        if c == 1:
            g[i].append(j)
        elif i != j:
            m[i][j] = 10000000000
d = [-1] * n
d[0] = 0
s = [0]
while s:
    p = s.pop()
    for node in g[p]:
        if d[node] == -1:
            s.append(node)
            d[node] = d[p] ^ 1
        elif d[node] == d[p]:
            print(-1)
            exit(0)
ans = 0
warshall_floyd(n, m)
for row in m:
    ans = max(ans, max(row))
print(ans + 1)


Measured memory_bytes: 42732
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<long long> vll, vLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int l,n;
    cin >> l >> n;
    ll x[n];
    ll sum[n+1];
    sum[0]=0;
    REP(i,n){
        cin >> x[i];
        sum[i+1]=sum[i]+x[i];
    }
    ll ans =0;
    REP(i,n){
        ll cur = x[i];
        int k = min(i,n-i-1);
        cur += 2*(sum[i]-sum[i-k]);
        if(n-i-1>k) k++;
        cur += 2*((ll)k*l-(sum[i+1+k]-sum[i+1]));
        ans=max(ans,cur);
    }
    REP(i,n){
        ll cur = l-x[i];
        ll k = min(n-1-i,i);
        cur += 2*((ll)l*k-(sum[i+1+k]-sum[i+1]));
        if(i>k) k++;
        cur += 2*(sum[i]-sum[i-k]);
        ans = max(ans,cur);
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

typedef long long ll;

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

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

int main(void) {
    int A, B;
    cin >> A >> B;

    int ans;
    if (A >= 13) {
        ans = B;
    } else if (A >= 6 && A <= 12) {
        ans = B / 2;
    } else {
        ans = 0;
    }

    cout << ans << endl;

    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 = sc.nextInt();
		int k = sc.nextInt();

		int[] array = new int[n];

		for(int i = 0; i < n; i++) {
			array[i] = 0;
		}

		for(int i = 0; i < k; i++) {
			int d = sc.nextInt();
			for(int j = 0; j < d; j++) {
				int a = sc.nextInt();
				array[a - 1] = 1;
			}
		}

		int ans = 0;

		for(int i = 0; i < n; i++) {
			if(array[i] == 0) {
				ans++;
			}
		}

		System.out.println(ans);

		sc.close();

	}

}


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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long int

using namespace __gnu_pbds;

typedef tree<pair<ll,pair<ll,ll> >, null_type, less<pair<ll,pair<ll,ll> > >, rb_tree_tag, tree_order_statistics_node_update>ordered_set;


#define me BOSS
#define bug() cout<<"AIkahne aise"<<endl
#define PI acos(-1)
#define mod 1000000007
/* Precode Start Here *\


power of 2 less than or equal to N

ll largest_power(ll N)
{
    //changing all right side bits to 1.
    N = N (N>>1);
    N = N| (N>>2);
    N = N| (N>>4);
    N = N| (N>>8);


//as now the number is 2 * x-1, where x is required answer, so adding 1 and dividing it by
 2.
            return (N+1)>>1;

}


     Sieve
void sieve()
{
    for(ll i=3; i<=2000; i+=2)
    {
        for(ll j=i*i; j<=4000000; j+=i)
            A[j]=1;
    }
    v.push_back(2);
    for(ll i=3; i<=4000000; i+=2)
        if(A[i]==0)
            v.push_back(i);
}

     Power Function Modulo P

ll modPow(ll a, ll x, ll p) {
    //calculates a^x mod p in logarithmic time.
    long res = 1;
    while(x > 0) {
        if( x % 2 != 0) {
            res = (res * a) % p;
        }
        a = (a * a) % p;
        x /= 2;
    }
    return res;
}


   factorial

ll fact(ll n)
{
    ll ans=1;
    for(ll i=1;i<=n;i++)
    {
        ans=(ans*i)%mod;
    }
    return ans;
}
     Calculating nCr using Fermats law Theorem

ll modInverse(ll a, ll p) {
    //calculates the modular multiplicative of a mod m.
    //(assuming p is prime).
    return modPow(a, p-2, p);
}


ll modBinomial(ll n, ll k, ll p) {
// calculates C(n,k) mod p (assuming p is prime).

    ll numerator = 1; // n * (n-1) * ... * (n-k+1)
    for (ll i=0; i<k; i++) {
        numerator = (numerator * (n-i) ) % p;
    }

    ll denominator = 1; // k!
    for (ll i=1; i<=k; i++) {
        denominator = (denominator * i) % p;
    }

    // numerator / denominator mod p.
    return ( numerator* modInverse(denominator,p) ) % p;
}
     num of divisor and euler totient

ll phi[1000001],mark[1000001],divi[1000001];;
void divisorPhi(ll n)
{
    for(int i=1;i<=n;i++)
        phi[i]=i;
    for(int i=2;i<=n;i++)
    {
        if(!mark[i])
        {
            for(int j=i;j<=n;j+=i)
            {
                mark[j]=1;
                phi[j]*=(1-1/(double)i);
            }
        }
    }
    for(ll i=1;i<=n;i++)
    {
        for(ll j=i;j<=n;j+=i)
            divi[j]++;
    }
}




/* Precode Ends */
ll A[5000001],B[5000001];
vector<ll>v;
map<ll,ll>myMap;
set<ll>mySet;
vector<pair<ll,ll> >vp;
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);

 char ch;
 cin>>ch;
 cout<<(char)(ch+1)<<endl;;
return 0;
}



Measured memory_bytes: 256
n = int(input())
S = [100] * 26
alphabet = 'abcdefghijklmnopqrstuvwxyz'
alpha_list = list(alphabet)

for i in range(n):
    s = input()
    for i in range(26):
        c = s.count(alpha_list[i])
        S[i] = min(S[i], c)

ans = ''

for i in range(26):
    for j in range(S[i]):
        ans += alpha_list[i]

print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>

using namespace std;
using ll =long long;
#define rep(i,n) ;for( int i =0; i < n ; i ++)
bool is_int_lround(double x){
  return std::lround(x)==x;
}
int ketasuu(int x){
  int n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}
ll gcd11(ll x, ll y){
  long long a= max(x,y), b=min(x,y), c=a%b;
  while( c!=0){
    a =b;
    b =c;
    c = a%b;
  }
  return b;
}

int abs(int x, int y){
  if(x>=y){
    return x-y;
  }
  else if(y>x){
    return y-x;
  }
}
int fiv(int n){
  if(n==0){
    return 0;
  }
  else if(n==1){
    return 1;
  }
  return fiv(n-1)+fiv(n-2);
}
int main(){
  int n,k;
  cin>>n>>k;
  vector<int> a(n);
  rep(i,n){
    cin>>a[i];
    
  }
  int ba;
  for(int i=0;i<n;i++){
    if(a[i]==1) ba=i;
    break;
  }
  int ans =10000000;
  for(int l=0;l<k && ba-l>=0 ;l++){
    ans=min( ans,       (ba-l+k-2)/(k-1) +max((n-ba-k+l+k-2)/(k-1) ,0)           );
  }
  cout<<ans+1<<endl;
}



Measured memory_bytes: 640
L1=list(map(int,input().split()))
L2=list(map(int,input().split()))
L3=list(map(int,input().split()))
L=L1+L2+L3
ansL=[0]*9

n=int(input())

for i in range(n):
    p=int(input())
    if p in L:
        tmp=L.index(p)
        ansL[tmp]=1


if ansL[0]+ansL[1]+ansL[2]==3 or ansL[3]+ansL[4]+ansL[5]==3 or ansL[6]+ansL[7]+ansL[8]==3 or ansL[0]+ansL[3]+ansL[6]==3 or ansL[1]+ansL[4]+ansL[7]==3 or ansL[2]+ansL[5]+ansL[8]==3 or ansL[0]+ansL[4]+ansL[8]==3 or ansL[2]+ansL[4]+ansL[6]==3:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
// memo  fixed  setprecision(20);
using vvll = vector<vector<ll>>;
ll mod =1e9+7;
/*"itob" int to "N"base */           template<typename TypeInt> string itob(const TypeInt v, int base){static const char table[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";string ret;static numeric_limits<TypeInt> t;TypeInt n = v;if (t.is_signed) {if (v < 0) n *= -1;}while (n >= base) {ret += table[n%base];n /= base;}ret += table[n];if (t.is_signed) {if (v < 0 && base == 10) ret += '-';}reverse(ret.begin(), ret.end());return ret;}
/*"chmin" a = MAX*/                  template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
/*"chmax" a = MIN*/                  template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
/*"ctoi"  char to int*/              int ctoi(char c) {return c-'0';}
/*"gcd"   MAX Euclidean */           ll gcd(ll a,ll b){if(b==0)return a; return gcd(b,a%b);}
    /*"lcm"   MIN*/                      ll lcm(ll a,ll b){ll g = gcd(a,b);return a/g*b;}
/*"primecheck"If prime,return true.*/bool primecheck(ll n){if(n < 2) return false;else{for(int i = 2; i * i <= n; i++){if(n % i == 0) return false;}return true;}}
string  reverserange(string s,ll a,ll b){reverse(s.begin()+a-1,s.begin()+b); return s;}
ll modpow(ll a,ll n, ll mod){ll res = 1;while(n>0){if (n%2==1){res = res * a % mod;}a = a * a % mod;n/=2;}return res;}
int main() {
    int a,b;
    cin >> a >>b;
    ll ans = a*b;
    cout<<ans<<endl;
}
    



Measured memory_bytes: 3632
s = input()
n = len(s)
ans = 0
 
for i in range(2**(n-1)):
    l = list(s)
    for j in reversed(range(1, n)): 
        if (1<<(j-1)) & i > 0:
            l = l[:j] + ['+'] + l[j:] # strにインサートはない
    ans += eval(''.join(l))
 
print(ans)

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

int main(int argc, const char * argv[]) {
    int N, A, B;
    
    cin >> N >> A >> B;
    
    if (N * A > B) {
        cout << B << endl;
    } else {
        cout << N * A << endl;
    }
    
    return 0;
}

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

int main()
{
int a,b,c;
cin >> a >> b >> c;
cout << min({a,b,c}) << " " << min({max(a,b),max(a,c),max(b,c)}) << " " << max({a,b,c}) << endl;
}




Measured memory_bytes: 3052
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cassert>
#include <functional>
#include <string>
using namespace std;

int main(){
  int X, Y, Z; cin >> X >> Y >> Z;
  cout << (X - Z) / (Y + Z) << endl;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
N = int(input())

ans = 0

for i in range(1, N + 1):
    count = 0
    if i % 2 == 1:
        for j in range(1, i + 1):
            if i % j == 0:
                count += 1
        if count == 8:
            ans += 1

print(ans)


Measured memory_bytes: 2940