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:
# ABC166 B
n,k = map(int, input().split())
# お菓子を持っているすぬけ君かを判断する配列d 1ならもってる 0はもってない
d = [0] * n
# お菓子iを持っているのはどのすぬけ君か？
for i in range(k):
    # お菓子iを持っている人数m人
    m = int(input())
    # お菓子iを持っているすぬけ君のリスト
    a = list(map(int, input().split()))
    for j in a:
        # すぬけ君a[j]は少なくとも一つ以上のお菓子を持っている
        d[j-1] = 1 
        
#いたずらされる人数ans人
ans = 0
for i in range(n):
    if d[i] == 0:
        ans += 1

print(ans)

Submission status: Accepted

Solution code:
# ABC166 B
n,k = map(int, input().split())
# お菓子を持っているすぬけ君かを判断する配列d 1ならもってる 0はもってない
d = [0] * n
# お菓子iを持っているのはどのすぬけ君か？
for i in range(k):
    # お菓子iを持っている人数m人
    m = int(input())
    # お菓子iを持っているすぬけ君のリスト
    a = list(map(int, input().split()))
    for j in range(m):
        # すぬけ君a[j]は少なくとも一つ以上のお菓子を持っている
        d[a[j]-1] = 1 
        
#いたずらされる人数ans人
ans = 0
for i in range(n):
    if d[i] == 0:
        ans += 1

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

lista = []
for i in range(N):
  lista.append(i+1)
for i in range(K):
  d = int(input())
  a = list(map(int, input().split()))
  for j in range(len(a)):
    if a[j] in lista:
      lista.remove(a[j])

print(len(lista))

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
l = []
for i in range(K):
  d = int(input())
  A = list(map(int, input().split()))
  for j in A:
    if l.count(j) == 0:
      l.append(j)
print(N - len(l))

Submission status: Accepted

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

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

Submission status: Accepted

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

sunuke = [i for i in range(1,n+1)]

while k > 0:
    d = int(input())
    a = list(map(int,input().split()))
    for i in range(len(a)):
        if a[i] in sunuke:
            sunuke.remove(a[i])
    k -= 1

print(len(sunuke))

Submission status: Accepted

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

C = [0 for _ in range(N)]
ct = N
for i in range(K):
  d = input()
  A = list(map(int, input().split()))
  for a in A:
    if C[a-1] == 0:
      C[a-1] += 1
      ct -= 1

print(ct)

Submission status: Accepted

Solution code:
N,K = map(int,input().split())
from collections import defaultdict
dic = defaultdict(int)
for _ in range(K):
    d = int(input())
    A = list(map(int,input().split()))
    for a in A:
        dic[a] = 1
print(N-len(dic))

Submission status: Accepted

Solution code:
import numpy as np
n,k=map(int,input().split())

d=[]
a=[]
sunuke=np.zeros(n)

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

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
res = set()
for _ in range(K):
    input()
    for a in map(int, input().split()):
        res.add(a)

print(N - len(res))

Submission status: Accepted

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

for k in range(K):
  input()
  S|=set(input().split())

print(N-len(S))

Submission status: Accepted

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

print(cld.count(0)-1)

Submission status: Accepted

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

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

print(ans.count(1))

Submission status: Accepted

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

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

print(ans.count(1))

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
N, K = map(int, input().split())
A = [[] for _ in range(K)]
a = list()

sunuke = [None] * N
for i in range(K):
  d = int(input())
  a = map(int, input().split())
  for t in a:
    sunuke[t-1] = 1

print(sunuke.count(None))

Submission status: Accepted

Solution code:
N,K=map(int,input().split())
d=[] 
A=[] 
A_union=[]
U=[i for i in range(1,N+1)]

for i in range(K): 
    d.append(int(input())) 
    A.append(list(map(int,input().split()))) 
for j in range(K): 
    A_union+=A[j] 
print(len(set(U)-set(A_union)))

Submission status: Accepted

Solution code:
def resolve():
    N, K = list(map(int, input().split()))
    uni = set()

    for _ in range(K):
        d = int(input())
        A = list(map(int, input().split()))
        uni = uni.union(set(A))
    print(N - len(uni))
    return

resolve()

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
m = [True]*n

for i in range(k):
    d = int(input())
    a = (list(map(int, input().split())))
    for j in a:
        m[j-1] = False
        
ans = [i for i in range(n) if m[i]]
print(len(ans))

Submission status: Accepted

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

Submission status: Accepted

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

def main():
    N, K = map(int, input().split())
    people = set([])
    for _ in range(K):
        d = input()
        A = set(input().split())
        people |= A
    print(N - len(people))


if __name__ == '__main__':
    main()

Submission status: Accepted

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

s = [t for t in range(1,N+1)]
for i in range(K):
    d = int(input())
    A = list(map(int,input().split()))
    for i in range(len(A)):
        if A[i] in s:
            s.remove(A[i])
print(len(s))

Submission status: Accepted

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

t = 0
for i in range(1,n+1):
    if a.count(i) == 0:
        t += 1

print(t)

Submission status: Accepted

Solution code:

n,k = list(map(int,input().split()))
sunuke = [i for i in range(1,n+1)]

while k > 0:
    d = int(input())
    a = list(map(int,input().split()))
    for i in range(len(a)):
        if a[i] in sunuke:
            sunuke.remove(a[i])
    k -= 1

print(len(sunuke))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N,K=map(int,input().split())
treat=set()
for i in range(1,K+1):
    d=int(input())
    A=list(map(int,input().split()))
    for i in A:
        treat.add(i)
result=0
for i in range(1,N+1):
    if not (i in treat) :
         result+=1
print(result)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
a = [0] * n

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

print(a.count(0))

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
a = [0] * n

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

print(a.count(0))

Submission status: Accepted

Solution code:
def main():
    N, K = map(int, input().split(' '))
    d = [0] * N
    total = 0
    for i in range(K):
        A = input()
        B = list(map(int, input().split(' ')))
        for j in B:
            d[j - 1] = 1
    for j in range(N):
        if d[j] == 0:
            total += 1
    print(total)
main()

Submission status: Accepted

Solution code:
n,k = map(int,input().split())
has = [False] * n

for i in range(k):
    d = int(input())
    a = list(map(int,input().split()))
    for hasperson in a:
        has[hasperson - 1] = True
print(has.count(False))

Submission status: Accepted

Solution code:

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

ni = [0]*n

while k > 0:
    d = int(input())
    a = list(map(int,input().split()))
    k -= 1
    for i in a:
        ni[i-1] = 1

print(ni.count(0))

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
ls = []
for i in range(n):
    ls.append(1)
for i in range(k):
    input()
    ts = map(int, input().split(' '))
    for t in ts:
        ls[t-1] = 0
print(sum(ls))

Submission status: Accepted

Solution code:
def main():
    n, k = map(int, input().split())
    snack = set()
    for _ in range(k):
        input()
        a = set(list(map(int, input().split())))
        snack |= a
    print(n-len(snack))
        

if __name__ == "__main__":
    main()

Submission status: Accepted

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

has_snck = {}
for i in range(1, n + 1):
    has_snck[i] = False
for ai in a:
    for aij in ai:
        has_snck[aij] = True

ans = 0
for snk in has_snck.keys():
    if not has_snck[snk]:
        ans += 1
print(ans)

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())
nnin = []
for m in range(1,n+1):
    nnin.append(m)
for b in range(k):
    d  = int(input())
    a = list(map(int,input().split()))
    for s in a:
        if s in nnin:
            nnin.remove(s)
print(len(nnin))

Submission status: Accepted

Solution code:
N,K = map(int, input().split())
t = set()
for i in range(K):
  d = int(input())
  t |= set(map(int, input().split()))
print(N-len(t))

Submission status: Accepted

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

r = set()
for i in range(K):
  d = int(input())
  r |= set(map(int,input().split()))
print(N-len(r))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
def Ii():return int(sys.stdin.buffer.readline())
def Mi():return map(int,sys.stdin.buffer.readline().split())
def Li():return list(map(int,sys.stdin.buffer.readline().split()))
 
n,k = Mi()
b = [1]*(n+1)
for i in range(k):
  d = Ii()
  a = Li()
  for j in a:
    b[j] = 0
    
print(sum(b)-1)

Submission status: Accepted

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

for _ in range(K):
    D = int(input())
    A = list(map(int, input().split()))
    for d in range(D):
        if ans[A[d]-1] == None:
            ans[A[d]-1] = True

print(ans.count(None))

Submission status: Accepted

Solution code:
N,K = map(int,input().split())
people = []
for i in range(K):
    di = int(input())
    Aij = list(map(int,input().split()))
    for A in Aij:
        if A not in people:
            people.append(A)
print(N-len(people))

Submission status: Accepted

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

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

cnt = 0
for i in range(len(lst)):
    if lst[i] == 0:
        cnt += 1

print(cnt)

Submission status: Accepted

Solution code:
N, K = map(int,input().split())
A = []
for _ in range(K):
    d = input()
    A += list(map(int, input().split()))


#集合にして、重複を除き、数を引く
print(N - len(set(A)))

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
i = 1
lstA = []
while (i < K + 1):
  lstd = list(map(int, input().split()))
  lstA0 = list(map(int, input().split()))
  for a in lstA0:
    lstA.append(a)
  i += 1
 
j = 1
lst2 = []
while(j < N + 1):
  if(j not in lstA):
    lst2.append(j)
  j += 1
 
print(len(lst2))

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
i = 1
lstA = []
while (i < K + 1):
  lstd = list(map(int, input().split()))
  lstA0 = list(map(int, input().split()))
  for a in lstA0:
    lstA.append(a)
  i += 1

j = 1
lst2 = []
while(j < N + 1):
  if(j not in lstA):
    lst2.append(j)
  j += 1

print(len(lst2))

Submission status: Accepted

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

for i in range(K):
    input()
    have = list(map(int,input().split()))
    for d in have:
        sunuke[d-1] = 1
    #print(sunuke)
print(sunuke.count(0))

Submission status: Accepted

Solution code:
n,k = map(int,input().split())
no_okashi_set = set(range(1,n+1))
for _ in range(k):
    input()
    no_okashi_set -= set(map(int,input().split()))
    
print(len(no_okashi_set))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

all_A = []

for _1 in A:
    for _2 in _1:
        all_A.append(_2)

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

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
sunuke = [0 for _ in range(N)]
for _ in range(K):
    d = int(input())
    As = list(map(int, input().split()))
    for a in As:
        sunuke[a-1] = 1
print(sunuke.count(0))

Submission status: Accepted

Solution code:
N, K = map(int,input().split())
S = set(range(1,N+1))
for _ in range(K):
    input()
    A = set(map(int,input().split()))
    S -= A

print(len(S))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import collections

N, K = map(int, input().split())
cnt = []
for _ in range(K):
    d = map(int, input())
    A = list(map(int, input().split()))
    cnt.extend(A)

num = collections.Counter(cnt)
print(N - len(num))

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
d=[]
A=[]

for i in range(k):
    d=d+[int(input())]
    A=A+[list(map(int,input().split()))]
ans=0


for i in range(n):
    ans+=1
    key=0
    for j in range(k):
        for l in range(d[j]):
            if i+1==A[j][l]:
                ans-=1
                key=1
            if key==1:
                break
        if key==1:
            break

print(ans)

Submission status: Accepted

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

cnt = [0]*n

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

ans = 0

for c in cnt:
    if c == 0:
        ans += 1


print(ans)

Submission status: Accepted

Solution code:
n,k = map(int,raw_input().split(' '))
h = set([])
for _ in range(k):
	di = int(raw_input())
	for ii in map(int, raw_input().split(' ')):
		h.add(ii)
print n - len(h)

Submission status: Accepted

Solution code:
N = list(map(int, input().split()))
S = [0 for i in range(N[0])]
for i in range(N[1]):
    d = int(input())
    A = list(map(int, input().split()))
    for k in range(d):
        S[A[k]-1] += 1

out = 0
for i in range(N[0]):
    if S[i] == 0:
        out += 1

print(out)

Submission status: Accepted

Solution code:
import sys

def trick_or_treat(in_):
    n, k = map(int, in_.readline().split())
    
    snacks = set()
    for _ in range(k):
        d = int(in_.readline())
        snacks.update(map(int, in_.readline().split()))

    snaks = frozenset(range(1, n + 1))
    no_snacks = snaks - snacks
    return len(no_snacks)


def main():
    answer = trick_or_treat(sys.stdin.buffer)
    print(answer)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

    for j in range(N):
        cnt.append(0)
    
    for i in range(K):
        d = int(input())
        A = list(map(int, input().split()))
        for k in range(len(A)):
            num = A[k]
            cnt[num - 1] = cnt[num - 1] + 1
    
    print(cnt.count(0))
main()

Submission status: Accepted

Solution code:
N, K = list(map(int, input().split()))
chi = [0] * (N + 1)
A = []
for _ in range(K):
    d = int(input())
    a = list(map(int, input().split()))
    A.append(a)

for i in range(len(A)):
    for j in range(len(A[i])):
        chi[A[i][j]] = 1
print(chi.count(0)-1)

Submission status: Accepted

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

ans = [False] * (n)

for _ in range(k):
    d = int(input())
    a = list(map(int, input().split()))
    for i in a:
        ans[i - 1] = True

print(ans.count(False))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

    list_i = [0]*N

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

    cnt = 0
    for judge in list_i:
        if judge == 0:
            cnt += 1

    return cnt

print(main())

Submission status: Accepted

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

dp = [0]*n

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

print(dp.count(0))

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()))
    for i in A:
        s.add(i)
print(N-len(s))

Submission status: Accepted

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

child = [0]*N

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

ans = 0
for i in child:
    if i == 0:
        ans += 1

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

ans = 0
#print(judge)
for i in range(N):
	if judge[i] == 1:
		ans+=1
print(ans)

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10 ** 9)
# input = sys.stdin.readline    ####
def int1(x): return int(x) - 1
def II(): return int(input())
def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())
def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def MS(): return input().split()
def LS(): return list(input())
def LLS(rows_number): return [LS() for _ in range(rows_number)]
def printlist(lst, k=' '): print(k.join(list(map(str, lst))))
INF = float('inf')
# from math import ceil, floor, log2
# from collections import deque
# from itertools import combinations as comb, combinations_with_replacement as comb_w, accumulate, product, permutations
# from heapq import heapify, heappop, heappush
# import numpy as np    # cumsum
# from bisect import bisect_left, bisect_right

def solve():
    N, K = MI()
    snuke = [0] * N
    for i in range(K):
        d = II()
        for s in LI1():
            snuke[s] += 1

    ans = 0
    for s in snuke:
        if s == 0:
            ans += 1
    print(ans)


if __name__ == '__main__':
    solve()

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
table = [[int(i) for i in input().split()] for _ in range(K * 2)]

ans_list = []
sunuke_set = set(list(range(1, N + 1)))

for i in range(1, K * 2 + 1, 2):
    ans_list += table[i]

ans_set = set(ans_list)

print(len(sunuke_set - ans_set))

Submission status: Accepted

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

alis = set(range(1 , n + 1))

for i in range(k):
    d = int(input())
    a = set(map(int,input().split()))
    alis = alis - a

print(len(alis))

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 j in a:
		s[j-1]=0
print(len([i for i in s if i>0]))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#すぬけ君N人，お菓子K種類
N, K = map(int, input().split())

#下はansに人数分の”1”の要素を作成している
ans = [1]*N
#print(ans)

#K種類のお菓子が誰に渡っているかを入力するfor文
for i in range(K):
    #お菓子iの個数d
    d = int(input())
    for j in list(map(int, input().split())):
        #ansの要素のうちjに含まれる（つまりお菓子iを持っている人間を1→0に変換する）
        #ただし配列は0,1...と数えるが，ここで入力されるのは1,2...という正の整数のため-1する
        ans[j-1] = 0

print(ans.count(1))

Submission status: Accepted

Solution code:
from collections import Counter

n, k = map(int, input().split())
b = []

for j in range(k):
  d = int(input())
  a = list(map(int, input().split()))
  for f in a:
    b.append(f)
print(n - len(Counter(b)))

Submission status: Accepted

Solution code:
#166B
#Trick or Treat

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    import sys
    read = sys.stdin.buffer.read
    readline = sys.stdin.buffer.readline
    readlines = sys.stdin.buffer.readlines
    sys.setrecursionlimit(10 ** 7)

    n, k = map(int, readline().split())
    memo = set()
    cnt = 0
    for _ in range(k):
        d = int(readline())
        memo |= set(map(int, readline().split()))
    for i in range(1, n + 1):
        if i not in memo:
            cnt += 1
    print(cnt)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

records = []
for i in range(K):
    d = input()
    records.extend([int(_) for _ in input().split()])

records = list(set(records))
print(N-len(records))

Submission status: Accepted

Solution code:
from sys import stdin
data = stdin.readlines()

n = int(data[0].split()[0])
k = int(data[0].split()[1])

l = []

for i in range(1,k+1):
    num = int(data[2*i-1].split()[0])
    for j in range(0,num):
        l.append(int(data[2*i].split()[j]))

counter = 0
for i in range(1,n+1):
    if not i in l:
        counter += 1
print(counter)

Submission status: Accepted

Solution code:
from collections import defaultdict as dd
from collections import deque
import bisect
import heapq

def ri():
    return int(input())

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


def solve():
    n, k = rl()
    snacks = set()
    for i in range(k):
        d = ri()
        for s in rl():
            snacks.add(s)
    print (n - len(snacks))






mode = 's'

if mode == 'T':
    t = ri()
    for i in range(t):
        solve()
else:
    solve()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
n_list = [0 for i in range(N)]
for i in range(K):
    di = int(input())
    A = list(map(int, input().split()))
    for j in A:
        n_list[j - 1] = 1

print(n_list.count(0))

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
S = set()
for k in range(K):
    D = int(input())
    A = list(map(int, input().split()))
    for a in A:
        S.add(a)
print(N - len(S))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,k= map(int,input().split())
kasi = {}
for i in range(k):
    _=int(input())
    for c in list(map(int,input().split())):kasi[c]=kasi.get(c,[])+[i]
print(sum([1 if not i in kasi.keys() else 0 for i in range(1,n+1)]))

Submission status: Accepted

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

di ={}
for i in range(1, n+1):
  di[i] = 0

for i in range(k):
  d = int(input())
  l = list(map(int, input().split()))
  for ii in range(d):
    no = l[ii]
    di[no] +=1

ans = 0
for i in di.values():
  if i == 0:
    ans += 1

print(ans)

Submission status: Accepted

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

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

set_a = set(set_a)
print(n - len(set_a))

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
lst = []
for i in range(K):
    d = int(input())
    A = list(map(int, input().split()))
    for char in A:
        if char not in lst:
            lst.append(char)
count = 0
for i in range(1, N+1):
    if i not in lst:
        count += 1
print(count)

Submission status: Accepted

Solution code:
n, k = map(int,input().split())
c = [0]*n

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

print(c.count(0))

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
A = set()
for i in range(K):
    _ = input()
    for j in input().split():
        A.add(int(j))
print(N-len(A))

Submission status: Accepted

Solution code:
def main():
    n, k = map(int, input().split())
    sunuke = set()
    for _ in range(k):
        input()
        sunuke |= set(map(int, input().split()))
    print(len(set(range(1, n+1))-sunuke))

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
# B - Trick or Treat
# https://atcoder.jp/contests/abc166/tasks/abc166_b
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

c = 0
for i in snk:
    if i == 0:
        c += 1
print(c)

Submission status: Accepted

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

answer=[0]*(N+5)
for k in range(K):
    D=int(input())
    A=list(map(int,input().split()))
    for a in A:
        answer[a]=1

for a in answer:
    N-=a
print(N)

Submission status: Accepted

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

memo = []
for i in range(k):
  d = int(input())
  a = [int(num) for num in input().split()]
  for j in a:
    memo.append(j)
  
memo = set(memo)
print(n-len(memo))

Submission status: Accepted

Solution code:
n,k = map(int, input().split())
okashi = [0]*n

for i in range(k*2):
  a = list(map(int, input().split()))
  if i % 2 == 1:
    for j in range(len(a)):
      okashi[a[j]-1] = 1
      
print(okashi.count(0))

Submission status: Accepted

Solution code:
N,K = map(int, input().split())
a = set()
for i in range(K):
  gomi = input()
  b = set(map(int,input().split()))
  a |= b
print(N - len(a))

Submission status: Accepted

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

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

print(N - len(a))

Submission status: Accepted

Solution code:
N,K = map(int, input().split())
a = set()
for i in range(K*2):
  b= set(map(int,input().split()))
  if i % 2 == 0:
    continue
  a|= b
print(N - len(a))

Submission status: Accepted

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

for i in range(k):
    d=int(input())
    a=list(map(int,input().split()))
    for j in a:
        if j in n:
            n.remove(j)
    
print(len(n))