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
import numpy as np
from math import ceil as C, floor as F, sqrt
from collections import defaultdict as D, Counter as CNT
from functools import reduce as R
 
ALP = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
alp = 'abcdefghijklmnopqrstuvwxyz'
def _X(): return sys.stdin.readline().rstrip().split(' ')
def _S(ss): return tuple(ss) if len(ss) > 1 else ss[0]
def S(): return _S(_X())
def Ss(): return list(S())
def _I(ss): return tuple([int(s) for s in ss]) if isinstance(ss, tuple) else int(ss)
def I(): return _I(S())
def _Is(ss): return list(ss) if isinstance(ss, tuple) else [ss]
def Is(): return _Is(I())

n, k = I()
ans = [0] * n
for _ in range(k):
  x = I()
  ys = Is()
  for y in ys:
    ans[y-1] += 1

print(len([a for a in ans if a == 0]))

Submission status: Accepted

Solution code:
from sys import stdin,stdout
# n=int(stdin.readline())
n,k=list(map(int,stdin.readline().split()))
s=set()
for _ in range(k):
    x=input()
    for v in map(int,stdin.readline().split()):
        s.add(v)
ans=0
for i in range(1,n+1):
    if i not in s:ans+=1
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n, k = map(int,input().split())
lst = [0 for i in range(n)]
for i in range(k):
  x = int(input())
  lst2 = list(map(int,input().split()))
  for j in range(x):
    if (lst[lst2[j] - 1] == 0):
      lst[lst2[j] - 1] = 1
ans = 0
for i in range(n):
  if (lst[i] == 0):
    ans = ans + 1
print(ans)

Submission status: Accepted

Solution code:
n,k = map(int, input().split())
b = list(range(1,n+1))
a = []
for i in range(k):
    d = int(input())
    a += list(map(int, input().split()))
a = list(set(a))
num = 0
for h in b:
    if h not in a:
        num += 1
print(num)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, K = map(eval, input().split())
candy = []

for i in range(K):
    input()
    candy.append(list(map(eval, input().split())))

result = 0

for i in range(1, N+1):
    for j in range(K):
        if i in candy[j]:
            break
    else:
        result += 1

print(result)

Submission status: Accepted

Solution code:
N, K = map(int,input().split())
d = 0
A = []
ans = 0
for i in range (K):
    d = int(input())
    A.append(input().split())
for i in range(1,N+1):
    for j in range(len(A)):
        if str(i) in A[j]:
            break
        if j == len(A)-1:
            ans += 1
print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import itertools

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

A = list(itertools.chain.from_iterable(A))
ans = 0
for i in range(1, N + 1):
    if i in A:
        continue
    else:
        ans += 1

print(ans)

Submission status: Accepted

Solution code:
def main(n, k):
    no_sweet = [x + 1 for x in range(n)]
    for _ in range(k):
        input()
        for v in map(int, input().split()):
            if v in no_sweet:
                no_sweet.remove(v)
    print(len(no_sweet))


if __name__ == "__main__":
    n, k = map(int, input().split())
    main(n, k)

Submission status: Accepted

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

people = []
 
for i in range(K):
  _ = input()
  a = list(map(int, input().split()))
  people += a
  
print(N - len(set(people)))

Submission status: Accepted

Solution code:
n,k = map(int,input().split())
a = [0]*n
for i in range(k):
    d = int(input())
    ai = list(map(int,input().split()))
    for j in ai:
        a[j-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())
lista=[]
for i in range(K):
    d=input()
    A=list(map(int,input().split()))
    lista.extend(A)
print(N-len(list(set(lista))))

Submission status: Accepted

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

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

    for e in a:
        t[e-1] += 1
ans = 0
l = [i for i in t if i == 0]
# print(l)
print(len(l))

Submission status: Accepted

Solution code:
import numpy as np
n, k = [int(i) for i in input().split()]

A = []
check = np.ones(n)
for i in range(k):
  d = int(input())
  A = [int(i) for i in input().split()]
  for j in A:
    check[j-1] = 0
print(int(check.sum()))

Submission status: Accepted

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

Submission status: Accepted

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

alis = sum(a, [])

alis = list(set(alis))

for i in range(len(alis)):
  lis.remove(alis[i])
print(len(lis))

Submission status: Accepted

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

check = [False]*(N+1)

for k in range(K):
    for sunuke in A[k]:
        if check[sunuke] == False:
            check[sunuke] = True
itazura = 0
for n in range(1, N+1):
    if check[n] == False:
        itazura += 1
print(itazura)

Submission status: Accepted

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

d_list = []
A_list = []

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

person = [0 for i in range(N)]

for i in range(K):
    for j in range(d_list[i]):
        person[A_list[i][j]-1] += 1

print(person.count(0))

Submission status: Accepted

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

ans = n - len(set(As))
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

num = len(set(a))
print(n-num)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,k = map(int, input().split())
setn = {x for x in range(1,n+1)}
setd = set()
for i in range(k):
  d = int(input())
  setd |= set(map(int, input().split()))
print(len(setn - setd))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
L = []
for i in range(k):
  a = int(input())
  b = list(map(int, input().split()))
  for j in range(a):
    L.append(b[j])
l = list(set(L))
print(n - len(l))

Submission status: Accepted

Solution code:
a, b = map(int, input().split())
oks = [0]*a
for i in range(b):
  d = int(input())
  snk = list(map(int, input().split()))
  for j in range(d):
    oks[snk[j]-1] += 1

print(oks.count(0))

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:
        l.append(j)
ans = 0
for i in range(n):
    if i + 1 not in l:
        ans += 1
print(ans)

Submission status: Accepted

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

print(have.count(False))

Submission status: Accepted

Solution code:
n,k=list(map(int, input("").split()))
d=[]
a=[]
t=[]
for i in range(k):
    d.append(int(input()))
    a.append(list(map(int, input("").split())))
for i in range(n):
    t.append(True)
for i in range(k):
    for j in a[i]:
        if t[j-1]:
            t[j-1]=False
out=0
for i in t:
    if i:
        out+=1
print(out)

Submission status: Accepted

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

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

print(sum(sunuke))

Submission status: Accepted

Solution code:
N,K = map(int,input().split())
li = []
count = 0
for i in range(K):
    d = int(input())
    a = list(map(int,input().split()))
    for j in range(d):
        li.append(a[j])

for i in range(N):
    if i+1 not in li:
        count += 1

print(count)

Submission status: Accepted

Solution code:
# Trick or Treat

N, K = map(int, input().split())
count = [0] * N
for _ in range(K):
    d = int(input())
    treat = list(map(int, input().split()))
    for val in treat:
        count[val-1] += 1

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
ans = set()
for i in range(k):
    d = input()
    a = set(map(int, input().split()))
    ans = ans | a  # 和集合をとる

print(n - len(ans))

Submission status: Accepted

Solution code:
list_K = []
N,K = map(int,input().split())
for i in range(K):
    d = int(input())
    A = [int(j) for j in input().split()]
    for k in range(d):
        list_K.append(A[k])
list_K0 = list(set(list_K))
list_K0.sort()
list_N = list(range(1,N+1))
set_NK = set(list_N)-set(list_K0)
print(len(set_NK))

Submission status: Accepted

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

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 = [0] * N
for i in range(K):
    for j in range(d[i]):
        count[A[i][j]-1] += 1

ans = count.count(0)
print(ans)

Submission status: Accepted

Solution code:
from collections import defaultdict

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

d = {i: [] for i in range(1, N+1)}
for _ in range(K):
    candy = int(input())
    for i in map(int, input().split()):
        d[i].append(candy)

print(list(d.values()).count([]))

Submission status: Accepted

Solution code:
def Qb():
    n, k = map(int, input().split())
    ans = set()
    for v in range(k):
        d = int(input())
        ns = [int(v) for v in input().split()]
        for N in ns:
            ans.add(N)
    print(n - len(ans))


if __name__ == '__main__':
    Qb()

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
def main():
    n, k = map(int, input().split())
    
    a = []
    for i in range(k):
        d = int(input())
        tmp_a = list(map(int, input().split()))
        a.extend(tmp_a)
    ans = len(set(range(1, n+1)) - set(a))
    print(ans)
    
main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# Trick or Treat
N, K = map(int,input().split())
sweets = [0]*N
for _ in range(K):
    d = int(input())
    A = list(map(int,input().split()))
    for a in A:
        sweets[a-1] += 1
ans = sum([e == 0 for e in sweets])
print(ans)

Submission status: Accepted

Solution code:
def solve():
    N,K = [int(i) for i in input().split()]
    ans = set([i for i in range(1, N+1)])
    for i in range(K):
        d = int(input())
        target = set([int(j) for j in input().split()])
        ans -= target
    print(len(ans))

if __name__ == "__main__":
    solve()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

for _ in range(k):
  d = input()
  hv_lst = list(map(int, input().split()))
  for i in hv_lst:
    lst[i-1] = 0
print(lst.count(1))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import numpy as np
def main():
  n, k  = list(map(int,(input().split())))
  a = np.array([])
  for i in range(k):
    d  = int(input())
    ak = list(map(int,(input().split())))
    a = np.append(a,ak)
    #print(ak,a)

  a = set(a)
  ans = n - len(a)
  print(ans)
  
  
  
  
if __name__ == '__main__':
  main()

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
A=[0]+[1]*n
for i in range(k):
    _=input()
    Q=list(map(int,input().split()))
    for i in Q:
        A[i]=0

print(sum(A))

Submission status: Accepted

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

candy_set = set()
for i in range(k):
    d = int(input())
    snuke = list(map(int,input().split()))
    for s in snuke:
        candy_set.add(s)

count = 0
for i in range(n):
    if not i+1 in candy_set:
        count+=1
print(count)

Submission status: Accepted

Solution code:
ini = lambda : int(input())
inm = lambda : map(int,input().split())
inl = lambda : list(map(int,input().split()))
gcd = lambda x,y : gcd(y,x%y) if x%y else y
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])
    if arr==[]:
        arr.append([n, 1])
    return arr
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    divisors.sort()
    return divisors

n,k = inm()
s = [0] * n
for i in range(k):
    d = ini()
    a = inl()
    for b in a:
        s[b-1] += 1
ans = sum(s[i] == 0 for i in range(n))
print(ans)

Submission status: Accepted

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

    for kk in range(k):
        kn = int(input())
        s = list(map(int,input().strip().split()))
        for kk in range(kn):
            nn[s[kk] - 1] += 1
    
    c = 0
    for ni in nn:
        if ni == 0:
            c += 1
    
    print(c)
    return 

main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n, k = (int(i) for i in input().split())
used = [0 for i in range(n)]
for i in range(k):
    val = int(input())
    a = [int(j) for j in input().split()]
    for aa in a:
        used[aa - 1] = 1
cnt = 0
for i in used:
    cnt += i == 0
print(cnt)

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 j in a:
      cnt[j-1] += 1
print(cnt.count(0))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N,K = map(int,input().split())
list1 ={i for i in range(1,N+1)}
list2 = set()
for i in range(K):
  NN = int(input())
  MM = map(int,input().split())
  for j in MM:
    list2.add(j)

ans = list1 -list2
print(len(ans))

Submission status: Accepted

Solution code:
N,K=map(int,input().split())
A=[]
B=[]
C=[]
D=[]
for i in range(2*K):
    A.append(list(map(int,input().split())))
for i in range(K):
    B.append(A[2*i-1])
for i in range(K):
    for j in range(len(B[i])):
        C.append(B[i][j])
for i in range(1,N+1):
    if i not in C:
        D.append(i)
print(len(D))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def resolve():
    N, K = map(int, input().split())
    candy_counter = [0] * N

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

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

if __name__ == "__main__":
    resolve()

Submission status: Accepted

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

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

ans = N - sum(sunuke)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

hold = set()
for i in range(len(A)):
    hold = hold | set(A[i])

print(N - len(hold))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

answer = [1] * N

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

	for j in tmp:
		answer[j-1] = 0

print(sum(answer))

Submission status: Accepted

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

for i in range(k):
    d = int(input())
    a = [int(s) for s in input().split()]
    for j in range(d):
        sum[a[j] - 1] += 1       

print(sum.count(0))

Submission status: Accepted

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

snack_maps = []

for _ in range(num_kinds_snack):
    num_snukes_has_snack_i = int(input())
    has_snack_list = list(map(int, input().split()))

    snack_maps.append(has_snack_list)

snukes_has_snacks = [False] * num_snukes

for has_snack_list in snack_maps:
    for i in has_snack_list:
        snukes_has_snacks[i - 1] = True

num_victims = len([snuke for snuke in snukes_has_snacks if not snuke])

print(num_victims)

Submission status: Accepted

Solution code:
N, K = [int(i) for i in input().split(' ')]
s = [True] * N

for i in range(K):
    d = input()
    for j in input().split(' '):
        s[int(j) - 1] = False
print(len([i for i in s if i]))

Submission status: Accepted

Solution code:
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
def main():
    n, k = map(int, input().split())
    sunuke = [0] * n
    for _ in range(k):
        d = int(input())
        a = tuple(map(int, input().split()))
        for ae in a:
            sunuke[ae-1] += 1

    r = sunuke.count(0)
    print(r)

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())
    b=list(map(int,input().split()))
    for j in range(d):
        a[b[j]-1]+=1
print(a.count(0))

Submission status: Accepted

Solution code:
n,k = map(int,input().split())
sunuke = []
for _ in range(k):
    d = input()
    tmp = [int(s) for s in input().split()]
    for i in range(len(tmp)):
        sunuke.append(tmp[i])

print(n - len(set(sunuke)))

Submission status: Accepted

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

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

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

Submission status: Accepted

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

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

print(N-len(A))

Submission status: Accepted

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

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

print(s.count(0))

Submission status: Accepted

Solution code:
def readinput():
    n,k=map(int,input().split())
    okashi=[]
    for _ in range(k):
        d=int(input())
        l=list(map(int,input().split()))
        okashi.append(l)
    return n,k,okashi

def main(n,k,okashi):
    sunuke=[0]*(n+1)
    for l in okashi:
        for su in l:
            sunuke[su]+=1
    count=0
    for i in range(n):
        if sunuke[i+1]==0:
            count+=1
    return count

if __name__=='__main__':
    n,k,okashi=readinput()
    ans=main(n,k,okashi)
    print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# ABC166
# B Trick or Treat
N, K = map(int, input().split())
A = [list(map(int, input().split())) for i in range(K*2)]
D = list(A[::2])
del A[::2]
A = sum(A, [])
a = set(A)
OP = [n +1 for n in range(N)]
op = set(OP)
an = op - a
print(len(list(an)))

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
def main():
    import sys

    input = sys.stdin.readline

    N, K = map(int, input().split())
    res = [False for _ in range(N)]
    for _ in range(K):
        _ = int(input())
        A = [int(x) for x in input().split()]
        for i in A:
            res[i - 1] = True
    print(res.count(False))



if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n, k = list(map(int, input().split()))
kl = [[] for _ in range(k)]
for i in range(k):
    a = int(input())
    d = list(map(int, input().split()))
    kl[i].append(d)
f1 = set(sum(sum(kl, []), []))
r = set(i for i in range(1, n + 1))
print(len(r - f1))

Submission status: Accepted

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

D=[]
A=[]
C=[]
for i in range(k):
    D.append(int(input()))
    A.append(list(map(int,input().split())))
for i in range(1,n+1):
    C.append(int(i))

for i in range(k):
    for a in A[i]:
        if C.count(a)!=0:
            C.remove(a)
        
print( len(C) )

Submission status: Accepted

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

ans_=[0]*N

for k in range(0,2*K,2):
    k_ = int(input())
    A = list(map(int,input().split()))
    for a in A:
        ans_[a-1]+=1
        
ans=0
for a in ans_:
    if a == 0:
        ans+=1
        
print(ans)

Submission status: Accepted

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

num = []
    
for i in range(n):
    cnt = 0
    for j in range(k):
        if i+1 in a[j]:
            cnt += 1
    if cnt == 0:
        num.append(i)
print(len(num))

Submission status: Accepted

Solution code:
word = list(map(int,input().split()))
dlist = [0]*word[1]
Alist = [0]*word[1]
for i in range(word[1]):
    dlist[i] = int(input())
    Alist[i] = list(map(int,input().split()))

ninzu = [0]*word[0]
for j in range(word[1]):
    for k in range(dlist[j]):
        ninzu[Alist[j][k]-1] += 1
        
print(ninzu.count(0))

Submission status: Accepted

Solution code:
N, K = list(map(lambda n: int(n), input().split(" ")))
A = []
for i in range(K):
  d = int(input())
  for x in list(map(lambda m: int(m), input().split(" "))):
  	A.append(x)
print(N - len(set(A)))

Submission status: Accepted

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

ans = have.count(False)
print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import math
def facts(n):
    ans = []
    for  i in range(1, int(math.sqrt(n)+1)):
        if(n%i==0):
            ans.append(i)
            ans.append(n//i)
    ans = sorted(ans)
    return ans


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

Submission status: Accepted

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

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

print(n-len(A))

Submission status: Accepted

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

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

ans = 0
for i in range(n):
    if i+1 not in A:
        ans += 1
print(ans)

Submission status: Accepted

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

for k in nusuke:
  if k == 0:
    ans += 1

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
sub = {(i+1):"Trick" for i in range(N)}
for i in range(K):
  d = int(input())
  prepare = map(int, input().split())
  for j in prepare:
    sub[j] = "Treat"
ans = 0
for v in sub.values():
  if v == "Trick":
    ans += 1
print(ans)