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:
N,K = map(int,input().split())

sunuke = []
ans = 0

for i in range(N):
    sunuke.append([])

for i in range(1,K+1):
    input()
    for j in map(int,input().split()):
        sunuke[j-1].append(i)

for i in sunuke:
    if len(i) == 0:
        ans += 1

print(ans)

Submission status: Accepted

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

ans = set([i+1 for i in range(n)])

for i in range(k):
    d.append(int(input()))
    ans.difference_update(set(map(int, input().split())))

print(len(ans))

Submission status: Accepted

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

snuke = [False] * N

for _ in range(K):
  input()  # d は不要
  for s in input().split():
    snuke[int(s) - 1] = True
    
print(N - sum(snuke))

Submission status: Accepted

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

alls = set(i + 1 for i in range(n))
done = set()

for _ in range(k):
  input()
  for i in list(map(int, input().split())):
    done.add(i)
print(len(alls - done))

Submission status: Accepted

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

a = []
d = []
for i in range(k):
  d.append(input())
  a+=(map(int,input().split()))
set_a = set(a)
count = 0
for i in range(1,n+1):
  if i in set_a:
    continue
  else:
    count+=1
print(count)

Submission status: Accepted

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

N, K = list(map(int, input().split()))
s_list = []

for _ in range(K):
    _ = input()
    a_list = list(map(int, input().split()))
    s_list.append(a_list)

s_list = set(itertools.chain.from_iterable(s_list))
ans = N - len(s_list)

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

for i in range(k):
    d = int(input())
    a = input().split()
    for k in range(len(a)):
        b.append(a[k])

print(n - len(set(b)))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
snukes = input().split(" ")
n = int(snukes[0])
k = int(snukes[1])

village = [0] * n
for i in range(k):
    numOwners = int(input())
    candyOwners = input().split(" ")
    for j in range(numOwners):
        village[int(candyOwners[j])-1] += i+1

print(village.count(0))

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
d=[list(map(int, input().split())) for i in range(m*2)]

s=[]
for i in range(1,m*2,2):
  s.extend(d[i])
s=list(set(s))

print(n-len(s))

Submission status: Accepted

Solution code:
# n,kに代入
n,k = map(int, input().split())
n_list = []
tmp = []

for i in range(n):
    n_list.append(i + 1)

for i in range(k):
#     d:お菓子の個数
    d = int(input())
#     tmp:お菓子が配られる人
    a = input().split()
    for j in range(len(a)):
        if int(a[j]) in n_list:
            n_list.remove(int(a[j]))

print(len(n_list))

Submission status: Accepted

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

Submission status: Accepted

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

#k種類のお菓子
for i in range(k):
  d[i] = int(input())
  a = list(map(int,input().split()))
  for i in a:
  	sunuke[i-1] += 1
  
print(sunuke.count(0))

Submission status: Accepted

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

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

print(sunuke.count(0))

Submission status: Accepted

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

for i in range(n+1):
  if s.count(i) == 0:
    ans += 1
    
print(ans-1)

Submission status: Accepted

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

total_set = {0}
for i in range(K):
    d = int(input())
    A_set = set(map(int, input().split()))
    total_set = total_set | A_set

sunuke_set = {i for i in range(N+1)}

answer_set = sunuke_set - total_set
print(len(answer_set))

Submission status: Accepted

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

Submission status: Accepted

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

A = list()
treat = {}
for i in range(K):
    d = int(input())
    A = list(map(int,input().split()))
    for a in A:
        if a in treat.keys():
            treat[a] += 1
        else:
            treat[a] = 1

counter = 0
for j in range(1,N+1):
    if not(j in treat.keys()):
        counter += 1

print(counter)

Submission status: Accepted

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

Submission status: Accepted

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

snuke = {}
for i in range(N):
    snuke[i] = 0

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

    for j in range(d):
        snuke[A[j]-1] += 1

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

print(ans)

Submission status: Accepted

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

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

print(N-sum(does_have))

Submission status: Accepted

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

# すぬけ君の人数分要素のリストを作る
Sunuke_List = [0] * N

# お菓子iを持っているすぬけ君を取得してリストに格納
for i in range(K):
    d_i = int(input())
    A_i = list(map(int, input().split()))
    for j in range(d_i):
        Sunuke_List[A_i[j]-1] = Sunuke_List[A_i[j]-1] + 1

# お菓子が0このすぬけ君の人数を出力
print(Sunuke_List.count(0))

Submission status: Accepted

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

        have[j-1]+=1

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

Submission status: Accepted

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

Submission status: Accepted

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

ans = {i + 1 for i in range(N)}
for i in range(K):
    d = int(input())
    A = map(int, input().split())
    for a in A:
        ans.discard(a)

print(len(ans))

Submission status: Accepted

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

Submission status: Accepted

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

print(sum(p))

Submission status: Accepted

Solution code:
n,k = map(int, input().split())
a = set()
for i in [0]*k:
    _ = input()
    a = a | set([*map(int, input().split())])
print(n - len(a))

Submission status: Accepted

Solution code:
(n,k),*p = [[*map(int, i.split())] for i in open(0)]
a = sum([p[2*i+1] for i in range(k)],[])
print(n - len(set(a)))

Submission status: Accepted

Solution code:
N, K = map(int, input().split(' '))
input_lists = [input() for _ in range(K*2)]
sweets = []*K
counts = [0]*(N+1)
counts[0] = -1
for i in range(0, len(input_lists), 2):
    tmp = []
    tmp.append(int(input_lists[i]))
    tmp.append(list(map(int, input_lists[i+1].split(' '))))
    sweets.append(tmp)
for sweet in sweets:
    for n in sweet[1]:
        # print(counts[n])
        counts[n] += 1

print(sum(count == 0 for count in counts))

Submission status: Accepted

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

sweet=[0 for i in range(N+1)]

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

for i in range(len(d)):
    for j in range(d[i]):
        sweet[A[i][j]]+=1

num=0
for i in range(1,len(sweet)):
    if sweet[i]==0:
        num+=1
print(num)

Submission status: Accepted

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


def main():
    n, k = map(int, readline().rstrip().split())
    nList = [0] * n
    for _ in range(k):
        d = int(readline().rstrip())
        aList = map(int, readline().rstrip().split())
        for a in aList:
            nList[a - 1] += 1
    print(nList.count(0))


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
def main():
    N, K = map(int, input().split())
    ans = [1] * N
    for i in range(K):
        input()
        A = map(int, input().split())
        for Ai in A:
            ans[Ai - 1] = 0
    print(sum(ans))
    return


main()

Submission status: Accepted

Solution code:
import sys
INF = 10**9
sys.setrecursionlimit(INF)


def main():
    n, k, *da = map(int, open(0).read().split())

    is_have_list = set()

    for _ in range(k):
        d = da.pop(0)
        for _ in range(d):
            is_have_list.add(da.pop(0))

    ans = n - len(is_have_list)
    print(ans)
    return(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
a_set = set()
for _ in range(k):
    input()
    a = set(map(int, input().split()))
    a_set = a_set | a

n_set = set()
for i in range(1,n+1):
    n_set.add(i)

ans = n_set - a_set

print(len(ans))

Submission status: Accepted

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

all = list(range(1, n + 1))
kashi = []

for i in range(k):
    x = input()
    kashi.extend(list(map(int, input().split())))
    
diff = set(all) - set(kashi)

print(len(diff))

Submission status: Accepted

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

for _ in range(k):
    d = int(input())
    l = list(map(int,input().split()))
    for i in l:
        if i in humans:
            humans.remove(i)
print(len(humans))

Submission status: Accepted

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

AList = []
emptyList = []

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

for i in AList:
    for j in range(1, N+1):
        if j in i:
            emptyList.append(j)

print(N-len(list(set(emptyList))))

Submission status: Accepted

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

m = [0] * n

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

Submission status: Accepted

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

check=[0]*N
 
for i in range(K):
  d=int(input())
  a=[int(K) - 1 for K in input().split()]
  for j in a:
    check[j]+=1

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

print(count)

Submission status: Accepted

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

ans=[0]*n

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

ansint=0


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


print(ansint)

Submission status: Accepted

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

Submission status: Accepted

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

d=[]
syozi=[]
syozi_flag=[0]*N

for _ in range(K):
    d.append(int(input()))
    inp=list(map(int,input().split()))
    syozi.append(inp)

for i in range(K):
    for syozisya in syozi[i]:
        if syozi_flag[syozisya-1]==0:
            syozi_flag[syozisya-1]=1

ans = sum(j==0 for j in syozi_flag)

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, K = (int(x) for x in input().split())

S = [s for s in range(1, N+1)]
dS = []

for i in range(K):
    d = int(input())
    A = list(map(int, input().split()))
    for j in A:
        if j in S:
            S.remove(j)
    
print(len(S))

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
Have = [1]*N
A = []
for k in range(K):
	d = int(input())
	tmp = map(int, input().split())
	for s in tmp:
		if Have[s-1] == 1:
			Have[s-1] = 0

print(sum(Have))

Submission status: Accepted

Solution code:
n,k = list(map(int, input().split()))
from collections import defaultdict
children = set([])
for i in range(k):
    _ = int(input())
    for j in list(map(int, input().split())):
        children.add(j)
print(n-len(children))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
Bs = [False]*N
for i in range(K):
  d = int(input())
  As = list(map(int, input().split()))
  for A in As:
    A = A-1
    Bs[A] = True
r = Bs.count(False)
print(r)

Submission status: Accepted

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

for d in data:
    for i in range(d[0]):
        if d[1][i] in person:
            person.remove(d[1][i])
        if person == []:
            print("0", end="")
            exit()
print(len(person), end="")

Submission status: Accepted

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

ans = [0]*N
for i in A:
    for j in i:
        ans[j-1]+=1

print(ans.count(0))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N,K=map(int,input().split())
snukes=list()
for i in range(K):
    d=input()
    snukes.append(list(map(int,input().split())))


gotsnacks=[]

for i in snukes:
    for j in i:
        if j not in gotsnacks:
            gotsnacks.append(j)

print(N-len(gotsnacks))

Submission status: Accepted

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

Submission status: Accepted

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

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

ans = set(allsunuke)- set(sunukes)

print(len(ans))

Submission status: Accepted

Solution code:
import itertools

num_of_sunuke, num_of_sweetstypes = map(int, input().split())

num_of_havingsweetssunuke= []
havingsweetssunukes = []

for _ in range(num_of_sweetstypes):
    num_of_havingsweetssunuke.append(int(input()))
    havingsweetssunukes.append(list(map(int, input().split())))

set_all = set(range(1, num_of_sunuke + 1))
set_havingsweets = set(itertools.chain.from_iterable(havingsweetssunukes))

print(len(set_all - set_havingsweets))

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
i = 0
children = set()
while(i < k):
    input()
    children = children | set(map(int, input().split()))
    i += 1
print(n - len(children))

Submission status: Accepted

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

ans = [0] * n

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

Submission status: Accepted

Solution code:
import numpy as np
N, K = map(int, input().split())
snuke = np.zeros(N, dtype=int)
for n in range(K):
    snack = int(input())
    d_snuke = map(int, input().split())
    for d in d_snuke:
        snuke[d-1] = snack
print(N-np.count_nonzero(snuke, axis=0))

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
snuke = [0] * N
for n in range(K):
    snack = int(input())
    d_snuke = map(int, input().split())
    for d in d_snuke:
        snuke[d-1] = snack
c = 0
for n in range(N):
    if snuke[n] == 0:
        c += 1
print(c)

Submission status: Accepted

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

result = [False] * N

for i in range(K):
    d = int(input())
    A = list(map(int, input().split()))
    for a in range(len(A)):
        result[A[a] - 1] = True

print(result.count(False))

Submission status: Accepted

Solution code:
import math
import bisect
from queue import Queue
from collections import deque

n, k= [int(i) for i in input().split()]

count = []
for i in range(n+1):
    count.append(0)

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

print(n-sum(count))

Submission status: Accepted

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

print(t.count(0))

Submission status: Accepted

Solution code:
import itertools
N,K=map(int,input().split())
A=[]
for i in range(K*2):
    a=list(map(int,input().split()))
    if i%2==1:
        A.append(a)
x=list(itertools.chain.from_iterable(A))
print(N-len(set(x)))

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
A = []
for _ in range(K):
    D = int(input())
    A.append(list(map(int, input().split())))
treated_people = len(set(sum(A, [])))
tricked_people = N - treated_people

print(tricked_people)

Submission status: Accepted

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

have_number=[]
have_who=[]

for i in range(K):
    i = input().split()
    j = input().split()
    have_number.append(i)
    have_who.append(j)

    #人
list1=[]
for k in range(1,N+1):
    list1.append(k)
list1

#持っている人の番号
t_have_who=sum(have_who,[])
for c in range(0,len(t_have_who)):
    t_have_who[c]=int(t_have_who[c])
t_have_who  

#人と持っている人の番号の非重複
list1=set(list1)
t_have_who =set( t_have_who )
diff = list1 ^ t_have_who  

print(len(diff))

Submission status: Accepted

Solution code:
N,K = map(int,input().split())
P = [0] * N
for i in range(K):
    a = int(input())
    b = list(map(int,input().split()))
    for j in range(a):
      P[b[j]-1] = 1 
m = 0   
for i in range(N):
    if P[i] == 0:
        m += 1
print(m)

Submission status: Accepted

Solution code:
N,K = map(int,input().split())
P = [0 for i in range(N)]
for i in range(K):
    a = int(input())
    b = list(map(int,input().split()))
    for j in range(a):
      P[b[j]-1] = 1 
m = 0   
for i in range(N):
    if P[i] == 0:
        m += 1
print(m)

Submission status: Accepted

Solution code:
N,K = map(int,input().split())
P = [0 for i in range(N)]
for i in range(K):
    a = int(input())
    b = list(map(int,input().split()))
    for j in range(a):
        P[b[j]-1] = 1
m = 0   
for i in range(N):
    if P[i] == 0:
        m += 1
print(m)

Submission status: Accepted

Solution code:
N,K = map(int,input().split())
P = [0 for i in range(N)]
for i in range(K):
    a = int(input())
    b = list(map(int,input().split()))
    for j in range(a):
        P[b[j]-1] = 1
m = 0
for i in range(N):
    if P[i]==0:
        m+=1
print(m)

Submission status: Accepted

Solution code:
n,k = map(int,input().split())
su = [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):
        su[a[j]-1] = 1
count = 0
for i in range(n):
    if su[i]==0:
        count+=1
print(count)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N,K=map(int,input().split())
P= [list(map(int,input().split())) for i in range(2*K)]
count=0
Q=[]
for t in range(1,2*K,2):
    Q.append(P[t])

R=[]
for u in range(0,len(Q)):
    for s in range(0,len(Q[u])):
        R.append(Q[u][s])

for j in range(1,N+1):
    if j not in R:
        count=count+1
    else:
        count=count
print(count)

Submission status: Accepted

Solution code:
N, K = map(int,input().split())
counts = [0]*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())
su = [True for i in range(n)]
for i in range(k):
    d = int(input())
    a = list(map(int,input().split()))
    for j in range(d):
        su[a[j]-1] = False
count = 0
for i in range(n):
    if su[i]:
        count+=1
print(count)

Submission status: Accepted

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

(N, K) = map(lambda x: int(x), input().split(' '))
AL = [False for i in range(int(N))]
#print(AL)

for i in range(K):
    d = int(input())
    A = [i for i in map(lambda x: int(x) -1, input().split(' '))]
    for i in A:
        AL[i] = True
#print(AL)
print(len([1 for x in AL if x==False]))

Submission status: Accepted

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

member = [0]*n

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

print(member.count(0))

Submission status: Accepted

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

m = [0] * N

for i in range(K):
  d = int(input())
  s = [int(x) for x in input().split()]
  for j in range(d):
    m[s[j] - 1] += 1
    
print(m.count(0))

Submission status: Accepted

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

member = [0]*n

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

print(member.count(0))

Submission status: Accepted

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


print(len([i for i in a if i < 1]) - 1)

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
cnt=[0]*(n+1) #i人目の人が所持しているお菓子の数を数える
for _ in range(k): #それぞれのお菓子について、そのお菓子を買った人のお菓子の所持数を1増やす
 tmp=int(input())
 arr=list(map(int,input().split()))
 for val in arr:
   cnt[val]+=1
ans=0
for i in range(1,n+1):
 if cnt[i]==0: #すべてのお菓子を見終えたあと、1つもお菓子を持っていない人の数が答え
   ans+=1
print(ans)

Submission status: Accepted

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

while k != 0:
    k = k - 1
    d = int(input())
    a = map(int,input().split())
    for num in a:
        list[num] = 1
        
print(list.count(0) - 1)

Submission status: Accepted

Solution code:
def input_int():
    return map(int, input().split())
def one_int():
    return int(input())
def one_str():
    return input()
def many_int():
    return list(map(int, input().split()))

# N すぬけ君人数
# K お菓子種類
N, K = input_int()

output = []
for i in range(K):
    # [2]
    a = many_int()
    # [1, 2]
    b = many_int()
    output += b
    
print(N - len(set(output)))

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
SUNUKE = {n+1:0 for n in range(N)}

def skip():
  input()

def okashi():
  okashi_list = map(int, input().split())
  for i in okashi_list:
    SUNUKE[i] += 1

for i in range(K):
  skip()  # お菓子の種類は無視
  okashi()
  
print(len([k for k, v in SUNUKE.items() if v == 0]))

Submission status: Accepted

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

Submission status: Accepted

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

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())))
    
s = set([i for i in range(1, N+1)])
ss =  set()
for i in a:
    ss = ss | set(i)
print(len(s - ss))

Submission status: Accepted

Solution code:
def input_int():
    return map(int, input().split())

def one_int():
    return int(input())

def one_str():
    return input()

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

N, K = input_int()

sunukes = [i+1 for i in range(N) ]

lis = []
for i in range(K):
    _ = one_int()
    temp = many_int()
    lis += temp

treats = set(sunukes)-set(lis)

print(len(treats))

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:
        if tmp[j-1] == 0:
            tmp[j-1] = 1

print(N - sum(tmp))

Submission status: Accepted

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

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

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

print(sum(count))

Submission status: Accepted

Solution code:
N,K = map(int,input().split())
L = 0
s = set() 
for i in range(K):
  d = int(input())
  A = [ int(x) for x in input().split() ]
  for j in range(d):
    s.add(A[j]) 
print(N-len(s))

Submission status: Accepted

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

x = N - len(set(lst))
print(x)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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())))

lis = []

for i in A:
    for j in i:
        if j in lis:
            continue
        else:
            lis.append(j)
print(N-len(lis))

Submission status: Accepted

Solution code:
N=input("")
N=N.split(" ")
Sunuke_num=int(N[0])
Treat_num=int(N[1])

ans_list=[]
for i in range(Sunuke_num):
    ans_list.append(False)

for i in range(Treat_num):
    s=input("")
    q=input("")
    q=q.split(" ")
    for r in range(int(s)):
        ans_list[int(q[r])-1]=True

print(ans_list.count(False))

Submission status: Accepted

Solution code:
n, k = 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())

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

S=[]
for i in range(K):
    S+=A[i]

s=set(S)

total=0
for i in range(1,N+1):
    if (i in s)==False:
        total+=1
print(total)

Submission status: Accepted

Solution code:
# unihernandez22
# https://atcoder.jp/contests/abc166/tasks/abc166_b
# implemtation
n, k = map(int, input().split())
 
snucks = [0]*n
 
for _ in range(k):
    input()
    for i in map(int, input().split()):
        snucks[i-1] = 1;
 
print(snucks.count(0))

Submission status: Accepted

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

snucks = [0]*n

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

print(snucks.count(0))

Submission status: Accepted

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

d=[]
U=set(range(1,N+1))
X=set()

for i in range(K):
    d.append(int(input()))

    S=map(int,input().split())
    for s in S:
        X.add(s)

print(len(U-X))

Submission status: Accepted

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