Problem:


Score : 200 points

Problem Statement

N Snukes called Snuke 1, Snuke 2, ..., Snuke N live in a town.

There are K kinds of snacks sold in this town, called Snack 1, Snack 2, ..., Snack K. The following d_i Snukes have Snack i: Snuke A_{i, 1}, A_{i, 2}, \cdots, A_{i, {d_i}}.

Takahashi will walk around this town and make mischief on the Snukes who have no snacks. How many Snukes will fall victim to Takahashi's mischief?

Constraints

All values in input are integers.

1 \leq N \leq 100

1 \leq K \leq 100

1 \leq d_i \leq N

1 \leq A_{i, 1} < \cdots < A_{i, d_i} \leq N

Input

Input is given from Standard Input in the following format:

N K
d_1
A_{1, 1} \cdots A_{1, d_1}
\vdots
d_K
A_{K, 1} \cdots A_{K, d_K}

Output

Print the answer.

Sample Input 1

3 2
2
1 3
1
3

Sample Output 1

1

Snuke 1 has Snack 1.

Snuke 2 has no snacks.

Snuke 3 has Snack 1 and 2.

Thus, there will be one victim: Snuke 2.

Sample Input 2

3 3
1
3
1
3
1
3

Sample Output 2

2



Sample input:
3 2
2
1 3
1
3


Sample output:
1

Submission status: Accepted

Solution code:
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

def main():
    N,K = map(int, readline().split())

    D = [0] * N
    for i in range(K):
        d = int(readline())
        A = [int(i) for i in readline().split()]
        for a in A:
            D[a-1] += 1
    
    ans = 0
    for i in D:
        if i == 0:
            ans += 1
    
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
N,K = map(int,input().split())
snk = [0 for i in range(N)]

for i in range(K):
  d = int(input())
  A = list(map(int,input().split()))
  for x in A:
    snk[x-1] += 1

ans = 0
for x in snk:
  if(x == 0): 
    ans += 1
print(ans)

Submission status: Accepted

Solution code:
n,k = map(int,input().split())
ans = [i for i in range(1,n+1)]
for i in range(k):
    d = int(input())
    a = list(map(int,input().split()))
    for j in a:
        if j in ans:
            ans.remove(j)
print(len(ans))

Submission status: Accepted

Solution code:
def resolve():
    n, k = map(int, input().split())
    sunuke = [0]*n
    man = []
    for i in range(k):
        d = int(input())
        a = list(map(int, input().split()))
        for j in a:
            if sunuke[j-1] == 0:
                sunuke[j-1] = 1
    print(n-sum(sunuke))

resolve()

Submission status: Accepted

Solution code:
n, k = map(int,input().split())

person = [0 for i in range(n)]
for i in range(k):
    input()
    a = list(map(int,input().split()))
    for j in a:
        person[j-1] +=1

answer = len([person[i] for i in range(n) if person[i]==0])

print(answer)

Submission status: Accepted

Solution code:
n,k = map(int, input().split())
a = [0] * n
for i in range(k):
  d = int(input())
  b = list(map(int, input().split()))
  for j in range(len(b)):
    a[b[j]-1] = 1
res = 0
for i in range(n):
  if a[i] == 0:
    res += 1
print(res)

Submission status: Accepted

Solution code:
n,k = map(int,input().split())

a = [-1 for _ in range(n)]
for i in range(k):
	d = int(input())
	A = list(map(int,input().split()))
	for j in range(d):
		a[A[j]-1] += 1

ans = 0
for i in range(n):
	if a[i] == -1:
		ans += 1

print(ans)

Submission status: Accepted

Solution code:
import sys
int1 = lambda x: int(x) - 1
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

N, K = map(int, readline().split())

checked = [0] * N
for _ in range(K):
    d = int(readline())
    A = list(map(int1, readline().split()))
    for a in A:
        checked[a] += 1

cnt = sum([c == 0 for c in checked])
print(cnt)

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
n = [0 for i in range(n)]

for i in range(k):
  d = int(input())
  oyatu = list(map(int, input().split()))
  for i in oyatu:
    n[i-1]+=1
  
  
count = 0
for i in n:
  if i == 0:
    count+=1
print(count)

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
sunuke=[0]*n
for i in range(k):
    d=int(input())
    a=list(map(int,input().split()))
    for j in range(len(a)):
        sunuke[a[j]-1]+=1
print(sunuke.count(0))

Submission status: Accepted

Solution code:
def main():
    n,k = map(int,input().split())
    sunukes = [0] * n
    for i in range(k):
        d = int(input())
        lst = list(map(int,input().split()))
        for j in lst:
            sunukes[j-1] += 1

    print(sunukes.count(0))



if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
def main():
    N, K = map(int, input().split())

    sunuke = {i:0 for i in range(N)}

    for i in range(K):
        d = int(input())
        a = list(map(int, input().split()))  # 整数のリスト
        for j in a:
            sunuke[j-1] += 1

    answer = 0

    for i in range(N):
        if sunuke[i] == 0:
            answer += 1

    print(answer)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n,k = map(int, input().split())

sunuke = [0]*n

for i in range(k):
    d = int(input())
    c = list(map(int, input().split()))

    for candidate in c:
        sunuke[candidate-1] = 1

print(sunuke.count(0))

Submission status: Accepted

Solution code:
N, K = map(int, input().split())

snuke = [False] * N
for i in range(K):
    d = int(input())
    a = list(map(int, input().split()))
    for j in range(d):
        snuke[a[j] - 1] = True

ans = 0
for i in range(N):
    if not snuke[i]:
        ans += 1

print(ans)

Submission status: Accepted

Solution code:
## coding: UTF-8
N,K = map(int,input().split())

d = []
A = []
for i in range(K):
    d.append(int(input()))
    A.append(list(map(int,input().split()))) 
#print(d)
#print(A)

have_not = [0] + [1] * N
for i in range(K):
    for j in range(len(A[i])):
        #print(A[i][j])
        have_not[A[i][j]] = 0

#print(have_not)
print(sum(have_not))

Submission status: Accepted

Solution code:
from collections import Counter
N, K = map(int, input().split())
l = [0]*N
for i in range(K):
    d = int(input())
    tmp = list(map(int, input().split()))
    for j in tmp:
        l[j-1] += 1

c = Counter(l)
print(c[0])

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
s = set(range(1, n+1))
for _ in range(k):
    d = input()
    for i in map(int, input().split()):
        s.discard(i)
print(len(s))

Submission status: Accepted

Solution code:
inpl = lambda: list(map(int,input().split()))
N, K = inpl()
B = set()
for _ in range(K):
    d = int(input())
    A = set(inpl())
    B |= A
print(N - len(B))

Submission status: Accepted

Solution code:
from sys import stdin

def main():

    input = stdin.readline

    N,K = map(int,input().split())

    ans = []

    for _ in range(K):
        tmp = input()
        ans.extend(list(map(int,input().split())))
    
    ans_num = N-len(set(ans))

    print(ans_num)

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
n,k=map(int,input().split())

A=[0]*n
for i in range(k):
    d=int(input())
    a=list(map(int,input().split()))
    for i in range(d):
        A[a[i]-1]+=1
print(A.count(0))

Submission status: Accepted

Solution code:
import sys
readline = sys.stdin.readline

N, K = map(int, readline().split())

D = []
A = []
for i in range(K):
    D.append(int(readline()))
    A.append(list(map(int, readline().split())))

import itertools

a = set(itertools.chain.from_iterable(A))
print(N - len(a))

Submission status: Accepted

Solution code:
# coding: utf-8

N, K = map(int,input().split())
L = [0] * (N+1)
for i in range(K):
    d = int(input())
    A = list(map(int,input().split()))
    for i in range(d):
        L[A[i]] = 1

ans = 0
for i in L:
    if i == 0:
        ans += 1
ans -= 1
print(ans)

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
box = set()
for i in range(K):
    temp = int(input())
    temp2 = set(map(int, input().split()))
    for j in temp2:
        box.add(j)

ans = 0
for i in range(1, N+1):
    if i not in box:
        ans += 1
print(ans)

Submission status: Accepted

Solution code:
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10 ** 6)
#from collections import defaultdict
#d = defaultdict(int)
#import fractions
#import math
#import collections
#from collections import deque
#from bisect import bisect_left
#from bisect import insort_left
#N = int(input())
#A = list(map(int,input().split()))
#S = list(input())
#S.remove("\n")
#N,M = map(int,input().split())
#S,T = map(str,input().split())
#A = [int(input()) for _ in range(N)]
#S = [input() for _ in range(N)]
#A = [list(map(int,input().split())) for _ in range(N)]
#import itertools
#import heapq
#import numpy as np
dd = {}
N,K = map(int,input().split())
for _ in range(K):
    d = int(input())
    A = list(map(int,input().split()))
    for j in A:
        if j not in dd.keys():
            dd[j] = 1
print(N-len(dd))

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
a=[0]*n
for i in range(k):
    d=int(input())
    aa=list(map(int,input().split()))
    for j in aa:
        a[j-1]=d
ans=0
for i in a:
    if i == 0:
        ans+=1

print(ans)

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
sunukes = set()
for i in range(1, n + 1):
    sunukes.add(i)

for _ in range(k):
    d = int(input())
    for i in list(map(int, input().split())):
        sunukes.discard(i)

print(len(sunukes))

Submission status: Accepted

Solution code:
N,K = [int(v) for v in input().split()]

have = [0 for _ in range(N)]
for _ in range(K):
    d = int(input())
    a = [int(v) for v in input().split()]
    for v in a:
        have[v-1] += 1

ans = 0
for v in have:
    if v == 0: ans+=1
print(ans)

Submission status: Accepted

Solution code:
n,k = map(int,input().split(" "))
sunuke = [0]*n
for i in range(k):
  d = int(input())
  a = list(map(int,input().split(" ")))
  for a_i in a:
    sunuke[a_i-1] += 1
sum_sunuke = 0
for sunuke_i in sunuke:
  if sunuke_i == 0:
    sum_sunuke += 1
print(sum_sunuke)

Submission status: Accepted

Solution code:
#!/bin/bash
''':'
docker run --rm -it -v $(cd $(dirname $0) && pwd):/vo:ro pypy:3-2.4.0 \
   /bin/bash -c "pypy3 /vo/$(basename $0) < /vo/input.txt"
exit $?
'''
import sys


def _i(): return int(sys.stdin.readline().strip())


def _ia(): return map(int, sys.stdin.readline().strip().split())


def main():
    n, k = _ia()
    ans = set()
    for _ in range(k):
        _ = _i()
        ans |= set(_ia())
    return n - len(ans)


if __name__ == "__main__":
    print(main())

Submission status: Accepted

Solution code:
n, k = map(int, input().split())

trick = [1] * n
for _ in range(k):
   d = int(input())
   a = list(map(int, input().split()))
   for i in range(d):
      trick[a[i]-1] = 0

print(sum(trick))

Submission status: Accepted

Solution code:
N,K = map(int,input().split())
S = [1]*N
for i in range(K):
    d = int(input())
    A = list(map(int,input().split()))
    for a in A:
        if S[a-1] == 1:
            S[a-1] = 0
print(sum(S))

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline


def main():
    N, K = map(int, input().split())
    sunuke = [0] * N
    for _ in range(K):
        d = int(input())
        A = map(int, input().split())
        for a in A:
            sunuke[a-1] += 1

    print(len([s for s in sunuke if s == 0]))


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n,k=map(int,input().split())

l=[0]*n

for i in range(k):
    d=int(input())
    a_list=list(map(int,input().split()))
    for a in a_list:
        l[a-1]+=1

cnt=0
for ll in l:
    if 0==ll:
        cnt+=1

print(cnt)

Submission status: Accepted

Solution code:
n,k = map(int, input().split())
d = []
a_s = []
for _ in range(k):
    d.append(int(input().strip()))
    a = list(map(int, input().split()))
    a_s += a
a_s = set(a_s)
count = 0
for i in range(1, n + 1):
    if i not in a_s:
        count += 1
print(count)

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
a = [0] * n
for i in range(k):
    dk = int(input())
    ak = list(map(int, input().split()))
    for j in range(dk):
        a[ak[j] - 1] = 1
print(n - sum(a))

Submission status: Accepted

Solution code:
n,k= map(int, input().split())
# s = input()

# n,m,q = map(int, input().split())
# abcd = [map(int, input().split())for _ in range(q)]

# a = list(map(int, input().split()))

count = [0]*n

for i in range(k):
    d = int(input())
    a = list(map(int, input().split()))
    for j in a:
        count[j-1]+=1

ans = 0
for i in count :
    if i == 0:
        ans+=1
print(ans)

Submission status: Accepted

Solution code:
n, k = map(int, input().split())

a = [0]*n

for i in range(k):
  d = int(input())
  okasi = list(map(int, input().split()))
  for o in okasi:
    a[o-1] += 1
    
ans = 0
for i in range(n):
  if a[i] ==0 :
    ans += 1
print(ans)

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
ds = []
As = []
for i in range(K):
    ds.append(int(input()))
    As.extend(list(map(int, input().split())))

all_sunuke = set(range(1, N+1))
some = set(As)
print(len(all_sunuke - some))

Submission status: Accepted

Solution code:
# coding:utf-8
n, k = map(int, input().split())
sunuke = [0] * n

for i in range(k):
    d = int(input())
    a = list(map(int, input().split()))
    for person in a:
        sunuke[person - 1] += 1

print(sunuke.count(0))

Submission status: Accepted

Solution code:
N,K=map(int,input().split())

check=[0]*N

for _ in range(K):
    d=int(input())
    A=list(map(int,input().split()))
    for a in A:
        check[a-1]+=1

ans=0
for c in check:
    if c==0:
        ans+=1
print(ans)

Submission status: Accepted

Solution code:
N, K = map(int,input().split())
counts = [0 for i in range(N)]

for i in range(K):
    d = int(input())
    A = list(map(int,input().split()))
    for a in A:
        counts[a-1] += 1
    
print(counts.count(0))

Submission status: Accepted

Solution code:
n,k = map(int, input().split())
d = []
a = []
for _ in range(k):
    d1 = int(input())
    A = list(map(int, input().split()))
    d.append(d1)
    a.append(A)
ans = [0] * n
for s in a:
    for v in s:
        ans[v-1] = 1
print(ans.count(0))

Submission status: Accepted

Solution code:
#!python3.8
# -*- coding: utf-8 -*-
# abc166/abc166_b
import sys

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [i2s() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def main():
    N, K = i2nn()
    sunuke = [1] * N
    for _ in range(K):
        i2s()
        for A in i2nn():
            sunuke[A - 1] = 0
    print(sum(sunuke))
    return

main()

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
sunuke=set(range(1,n+1,1))
for i in range(k):
    d=int(input())
    okashi=set(map(int,input().split()))
    sunuke-=okashi
print(len(sunuke))

Submission status: Accepted

Solution code:
#!/usr/bin/env python
import os
import sys
from io import BytesIO, IOBase


def main():
    n,k=map(int,input().split())
    a=[True]*n
    for _ in range(k):
        _=input()
        for x in map(int,input().split()):
            a[x-1]=False
    print(sum(a))
# region fastio

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
s = [0] * (N+1)
s[0] = 1
for i in range(K):
  d = int(input())
  A = list(map(int, input().split()))
  for j in range(d):
    s[A[j]] += 1
ans = 0
for i in range(N+1):
  if(s[i] == 0):
    ans += 1
print(ans)

Submission status: Accepted

Solution code:
N, K = map(int, input().split())

As_has_okashi = [False for i in range(N)]

for _ in range(K):
    d = int(input())
    As = list(map(int, input().split()))
    for i in range(d):
        As_has_okashi[As[i]-1] = True

count = 0
for i in range(N):
    if As_has_okashi[i] == False:
        count += 1

print(count)

Submission status: Accepted

Solution code:
N, K = map(int, input().split())

ans = 0
lis = [0]*N
for _ in range(K):
    d = int(input())
    Ns = list(map(int, input().split()))
    for j in range(d):
        lis[Ns[j]-1] = 1

print(N-sum(lis))

Submission status: Accepted

Solution code:
N,K=map(int,input().split())
ans=[]
for i in range(K):
    d=int(input())
    ans+=list((map(int,input().split())))
print(N-len(list(set(ans))))

Submission status: Accepted

Solution code:
import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy

N, K = map(int, input().split())

s = set()
for i in range(K):
    d = int(input())
    s |= set(map(int, input().split()))

print(N - len(s))

Submission status: Accepted

Solution code:
N,K = list(map(int, input().split()))

sunukes = [False] * N

for i in range(K):
    d = int(input())
    As = list(map(int, input().split()))

    for a in As:
        sunukes[a-1] = True    

cnt = 0
for v in sunukes:
    if not v:
        cnt += 1

print(cnt)

Submission status: Accepted

Solution code:
# import sys
# import math #sqrt,gcd,pi
# import decimal
# import queue # queue
# import bisect
# import heapq # priolity-queue
# import time
# from itertools import product,permutations,\
#     combinations,combinations_with_replacement
# 重複あり順列、順列、組み合わせ、重複あり組み合わせ
# import collections # deque
# from operator import itemgetter,mul
# from fractions import Fraction
# from functools import reduce

mod = int(1e9+7)
INF = 1<<29
lINF = 1<<35

def readInt():
    return list(map(int,input().split()))

def main():
    n,k = readInt()
    poss = set()
    for i in range(k):
        d = int(input())
        a = readInt()
        for x in a:
            poss.add(x)
    ans = 0
    for i in range(1,n+1):
        if i not in poss:
            ans += 1
    print(ans)
    return

if __name__=='__main__':
    main()

Submission status: Accepted

Solution code:
N,K = map(int, input().split())
ans = [1]*N

for i in range(K):
    d = int(input())
    A = list(map(int,input().split()))
    for x in A:
        ans[x-1] = 0

print(sum(ans))

Submission status: Accepted

Solution code:
n,k = map(int,input().split())
nn = [0]*n
for _ in range(k):
    d = int(input())
    a = [int(i) for i in input().split()]
    for j in a:
        nn[j-1] += 1
c=0
for i in nn:
   if i==0:
       c+=1
print(c)

Submission status: Accepted

Solution code:
N, K = list(map(int, input().split()))
treated = set()
for i in range(K):
    _ = input()
    
    treated = treated | (set(list(map(int, input().split()))))
print(len([x for x in range(N) if not x+1 in treated]))

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 7)

from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
from collections import deque, defaultdict
from itertools import combinations, permutations, combinations_with_replacement
from itertools import accumulate
from math import ceil, sqrt, pi

MOD = 10 ** 9 + 7
INF = 10 ** 18
#
N, K = map(int, input().split())

cnt = [0] * (N + 1)
for i in range(2 * K):
    q = input()
    if i % 2:
        lst = list(map(int, q.split()))
        for l in lst:
            cnt[l] = 1
    
ans = 0        
for i in range(1, N + 1):
    if cnt[i] == 0:
        ans += 1
#print(cnt)
print(ans)

Submission status: Accepted

Solution code:
import math

n, k = map(int, input().split())

p = [0] * n

for _ in range(k):
    d = int(input())
    a = list(map(int, input().split()))
    for m in a:
        p[m-1] += 1

ans = 0

for l in p:
    if l == 0:
        ans += 1

print(ans)

Submission status: Accepted

Solution code:

def main():
    n, k = map(int, input().split())
    x = [0]*n
    count = 0
    for i in range(k):
        d = int(input())
        a = list(map(int, input().split()))
        for j in a:
            x[j-1] += 1
    for i in x:
        if i == 0:
            count += 1
    print(count)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N,K = (int(x) for x in input().split())
pos = set()
for i in range(K):
    d = int(input())
    A = list(map(int, input().split()))
    for a in A:
        pos.add(a)
print(N-len(pos))

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
res = set()

for i in range(K):
    d = int(input())
    A = list(map(int, input().split()))
    for p in A:
        res.add(p)

print(N-len(res))

Submission status: Accepted

Solution code:
# B - Trick or Treat

N, K = map(int, input().split())
H = [0] * N

for i in range(K):
    d = int(input())
    A = list(int(x) for x in input().split())
    for j in A:
        H[j-1] += 1

print(H.count(0))

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Sun May  3 20:55:32 2020

@author: Kanaru Sato
"""

n,k = list(map(int, input().split()))
dic = {}
for i in range(k):
    d = int(input())
    l = list(map(int, input().split()))
    for j in range(d):
        if l[j] not in dic:
            dic[l[j]] = 1
        
count = 0
for i in range(1,n+1):
    if i not in dic:
        count += 1
print(count)

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
snk = [0] * n
for i in range(k):
    d = int(input())
    a = list(map(int, input().split()))
    for i in range(d):
        snk[a[i] - 1] += 1
print(snk.count(0))

Submission status: Accepted

Solution code:
N,K = map(int,input().split())

l = [0 for i in range(N)]
for i in range(K):
    d = int(input())
    A = list(map(int,input().split()))
    for j in A:
        l[j-1] += 1

cnt = 0
for i in l:
    if i == 0:
        cnt += 1

print(cnt)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
n, k = map(int, input().split())
ans = []
for _ in range(k):
    d = int(input())
    a = list(map(int, input().split()))
    ans.extend(a)
print(n - len(set(ans)))

Submission status: Accepted

Solution code:
def main():
    n, k = map(int, input().split())
    d = list()
    a = list()
    for i in range(k):
        d.append(int(input()))
        a.append(list(map(int, input().split())))

    kids = [0]*n

    for aa in a:
        for aaa in aa:
            kids[aaa-1] = 1

    print(n-sum(kids))


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
ans = [1]*N
for i in range(K):
    d = int(input())
    okashi = [int(num) for num in input().split()]
    
    for j in range(d):
        ans[okashi[j]-1] = 0

print(sum(ans))

Submission status: Accepted

Solution code:
n, k = map(int, input().split())

s = set()
for i in range(k):
  d = input()
  a = map(int, input().split())
  for x in a:
    s.add(x)
    
print(n-len(s))

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
t=[0]*n
for i in range(k):
    d=int(input())
    l=list(map(int,input().split()))
    for j in range(len(l)):
        t[l[j]-1]+=1

print(t.count(0))

Submission status: Accepted

Solution code:
n,k = map(int, input().split())
friends = [0]*n
for _ in range(k):
    d = int(input())
    a = list(map(int,input().split()))
    for i in a:
        friends[i-1] = 1
ans = friends.count(0)
print(ans)

Submission status: Accepted

Solution code:
N, K = map(int, input().split())

ans = [True for _ in range(N)]

for _ in range(K):
    d = int(input())
    okasi = list(map(int, input().split()))
    for o in okasi:
        ans[o-1] = False

print(sum(ans))

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
s = set(range(1, n+1))
for i in range(k):
    d = int(input())
    for a in map(int, input().split()):
        s.discard(a)
print(len(s))

Submission status: Accepted

Solution code:
if __name__ == '__main__':
    n, k = map(int, input().split())
    count = 0
    list = []
    for i in range(k):
        b = int(input())
        c = [int(i) for i in input().split()]
        list.extend(c)
    setList = set(list)
    print(n - len(setList))

Submission status: Accepted

Solution code:
#!/usr/bin/python3
# -*- coding: utf-8 -*-
n, k = map(int, input().split())
kun_list = [1] * n
for i in range(0, k):
    d = int(input())
    a_list = list(map(int, input().split()))
    for a in a_list:
        kun_list[a-1] = 0
print(sum(kun_list))

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
itazura = [1]*n
for _ in range(k):
    d = int(input())
    l = list(map(int, input().split()))
    for i in range(len(l)):
        itazura[l[i]-1] = 0
print(sum(itazura))

Submission status: Accepted

Solution code:
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections

n,k = map(int,input().split())
A = []
D = []
p = [0 for i in range(n)]
for i in range(k):
    d = int(input())
    a = list(map(int,input().split()))
    for j in range(len(a)):
        p[a[j]-1]+=1
cnt = 0
for i in range(len(p)):
    if p[i] == 0:
        cnt+=1
print(cnt)

Submission status: Accepted

Solution code:
import math
import collections

def main():
    N, K = map(int, input().split())
    ans = {}

    for k in range(K):
        d = int(input())
        A = list(map(int, input().split()))
        for a in A:
            ans[a] = 1
    print(N - len(ans))

    return 0

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N, K = [int(i) for i in input().split()]
a=[False]*N
for _ in range(K):
    input()
    A = [int(i) for i in input().split()]
    for i in A:
        i -= 1
        a[i] = True
print(a.count(False))

Submission status: Accepted

Solution code:
#!/usr/bin/env python3


def solve(n, k, info):
    all_set = set(range(1, n + 1))
    sub_set = set()
    for _, bs in info:
        sub_set.update(bs)
    rest_set = all_set - sub_set
    return len(rest_set)


def main():
    n, k = (int(z) for z in input().split())
    info = []
    for _ in range(k):
        d = int(input())
        bs = [int(z) for z in input().split()]
        info.append((d, bs))
    print(solve(n, k, info))


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
NK = list(map(int, input().split()))

s = set()
for i in range(NK[1]):
    d = int(input())
    A = list(map(int, input().split()))
    for j in range(d):
        s.add(A[j])

print(NK[0] - len(s))

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
l = [0] * 101
for i in range(k):
    d = int(input())
    t = list(map(int, input().split()))
    for j in t:
        l[j] = 1
ans = 0
for i in range(1, n + 1):
    if l[i] == 0: ans -= -1
print(ans)

Submission status: Accepted

Solution code:
n, k = map(int,input().split())
nums = []
for i in range(k):
    d = int(input())
    a = list(map(int,input().split()))
    nums += a
ans = n - len(set(nums))
print(ans)

Submission status: Accepted

Solution code:
# coding: utf-8


def main():
    N, K = map(int, input().split())
    d = [None] * K
    A = [None] * K

    for i in range(K):
        d[i] = int(input())
        A[i] = list(map(int, input().split()))
        A[i] = [x-1 for x in A[i]]
    
    have = [0] * N
    for a in A:
        for x in a:
            have[x] += 1
    
    ans = 0
    for i in range(N):
        if have[i] == 0:
            ans += 1
    
    return ans


print(main())

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
#%%code
def resolve():
    N,K=pin()
    a=[0]*N
    for k in range(K):
        d=int(input())
        A=list(pin())
        #print(A)
        for n in range(d):
            a[A[n]-1]+=1
    cnt=0
    for aa in a:
        if aa==0:cnt+=1
    print(cnt)
#%%submit!
resolve()

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
s = set()
for i in range(k):
    d = int(input())
    a = list(map(int, input().split()))
    s |= set(a)
print(n - len(s))

Submission status: Accepted

Solution code:
n,k = map(int, input().split())
d = []
a = []
for i in range(k):
    d.append(int(input()))
    a.append(list(map(int, input().split())))

count = []
for i in range(k):
    for j in range(len(a[i])):
        count.append(a[i][j])

count = set(count)

print(n-len(count))

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
A = []

for i in range(K):
    d = int(input())
    A.append(list(map(int, input().split())))

s = set()
for i in range(K):
    for a in A[i]:
        s.add(a)

# print(s)
print(N - len(s))

Submission status: Accepted

Solution code:
N, K = [int(i) for i in input().split()]
d=[]
A=[]
for i in range(K):
    d.append(int(input()))
    A.extend([int(i) for i in input().split()])

A=set(A)
print(N-len(A))

Submission status: Accepted

Solution code:
n, k = map(int, input().split())

tmp = [0]*n
for i in range(k):
    d = int(input())
    a = list(map(int, input().split()))

    for j in a:
        tmp[j-1] += 1

ans = 0
for j in range(n):
    if tmp[j] == 0:
        ans += 1

print(ans)

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
have=[False]*n
for i in range(k):
    d=int(input())
    a=list(map(int,input().split()))
    for j in a:
        have[j-1]=True
print(have.count(False))

Submission status: Accepted

Solution code:

N,K = map(int,input().split())

lis = [True] * N

for i in range(K):

    d = int(input())

    A = list(map(int,input().split()))

    for j in A:
        lis[j-1] = False

ans = 0
for i in range(N):

    if lis[i]:
        ans += 1
print (ans)

Submission status: Accepted

Solution code:
N, K = map(int, input().split())

all_sunuke = list(range(1, N+1))

have_sunuke = []

for i in range(K):
    d = int(input())
    A = list(map(int, input().split()))
    have_sunuke += A

print(len(list(set(all_sunuke)-set(have_sunuke))))