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:
nk = input('')
n = int(nk.split(' ')[0])
k = int(nk.split(' ')[1])

sunukes = [0]*n
for i in range(k):
    d = int(input(''))
    a = input('').split(' ')
    for j in a:
        no = int(j)-1
        sunukes[no] = 1

cnt=0
for s in sunukes:
    if s == 0:
        cnt+=1
print(cnt)

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
A = [0 for i in range(n)]
for i in range(k):
    di = int(input())
    B = list(map(int, input().split()))
    for j in range(di):
        A[B[j] - 1] += 1

ans = 0
for i in range(n):
    if A[i] == 0:
        ans += 1
    else:
        pass
print(ans)

Submission status: Accepted

Solution code:
def main():
    N, K = map(int, input().split())
    d = []
    A = []
    for _ in range(K):
        d.append(int(input()))
        A.extend(list(map(int, input().split())))
    A = list(set(A))
    #print(A)
    result = [i+1 for i in range(N) if i+1 not in A]
    print(len(result))
    
if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

print(sum(sunuke_kun))

Submission status: Accepted

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

sunuke = [0 for i in range(n)]

for i in range(k):
    t = int(input())
    tl = map(int, input().split())
    for j in tl:
        sunuke[j-1] += 1

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

print(ans)

Submission status: Accepted

Solution code:
from collections import defaultdict

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

dict = defaultdict(lambda: 0)

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

print(N-len(dict))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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

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

print(okasi.count(0))

Submission status: Accepted

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

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

for i in range(K):
  d = int(input())
  LL = list(map(int, input().split()))
  for j in range( len(LL) ):
    L[ LL[j] ] += 1

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
import math
from collections import Counter
import itertools
import fractions
#from functools import reduce

# 入力を整数に変換して受け取る
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def MI1(): return map(int1, sys.stdin.readline().split())
# 入力全てを整数に変換したものの配列を受け取る
def LI(): return list(map(int, sys.stdin.readline().split()))
# 入力全てを整数に変換して1引いたものの配列を受け取る
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SR(): return sys.stdin.readline().rstrip()

ascii_lowercase = 'abcdefghijklmnopqrstuvwxyz'
ascii_uppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
ascii_uppercase2 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ'

# リストを改行区切りで出力する
p2D = lambda x: print(*x, sep="\n")
p2E = lambda x: print(''.join(x))
p2S = lambda x: print(*x, sep=" ")

# ###########################################
 
N,K=MI()
d=[0]*K
A=[0]*K

for i in range(K):
    d[i] = II()
    A[i] = LI()

s=set()
for a in A:
    for z in a:
        s.add(z)
ans=0
for i in range(1,N+1):
    if not i in s:
        ans+=1
print(ans)

Submission status: Accepted

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

print(t.count(0))

Submission status: Accepted

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

for i in range(k):
    d = int(input())
    l = list(map(int, input().split()))
    for x in l:
        ate.add(x)
# print(ate)
print(n - len(ate))

Submission status: Accepted

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

no_treat = [True] * (N + 1)

for _ in range(K):
    _ = input()
    A = list(map(int, input().split()))
    for a in A:
        no_treat[a] = False

ans = -1

for snuke in no_treat:
    if snuke:
        ans += 1

print(ans)

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10 ** 6)
# input = sys.stdin.readline    ####
int1 = lambda x: 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)]

INF = float('inf')

def solve():
    n, k = MI()
    S = [1] * n
    for i in range(k):
        d = II()
        A = LI1()
        for a in A:
            S[a] = 0
    # print(S)
    print(sum(S))



if __name__ == '__main__':
    solve()

Submission status: Accepted

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


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

list_sunuke = []

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

print(n-len(set(list_sunuke)))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, K = [int(x) for x in input().strip().split(" ")]
has_ = []
for _ in range(K):
    int(input().strip())
    has_ += [int(x) for x in input().strip().split(" ")]
print(N - len(set(has_)))

Submission status: Accepted

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

H = [0] * N

for i in range(K):
    input()
    for v in [int(t) for t in input().split()]:
        H[v - 1] += 1

print(H.count(0))

Submission status: Accepted

Solution code:
from collections import defaultdict
s = list(map(int,input().split()))
n=s[0]
k=s[1]
sunu={}
for i in range(1,n+1):
    sunu[i]=0
for i in range(k):
    s = list(map(int, input().split()))
    d=s[0]
    s = list(map(int, input().split()))
    for j in s:
        sunu[j]+=1
ans=0
for i in sunu:
    if sunu[i]==0:
        ans+=1
print(ans)

Submission status: Accepted

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

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
ans=0
for i in range(n):
  if S[i]==0:
    ans=ans+1
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import itertools
n,k=map(int,input().split())
a=[]
for i in range(k):
    d=int(input())
    l=list(map(int,input().split()))
    a.append(l)
a=list(itertools.chain.from_iterable(a))
print(n-len(set(a)))

Submission status: Accepted

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


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    # Failed to predict input format
    N, K = list(map(int, input().split()))
    d = {}
    result = {i: False for i in range(N)}
    for k in range(K):
        d = int(input())
        A = list(map(int, (input().split())))
        for a in A:
            result[a-1] = True
    count = 0
    for n in range(N):
        if result[n] == False:
            count += 1
    print(count)
    pass

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys
import math

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

#d=list()
#A=list()

sunuke=list()
for i in range(N):
    sunuke.append(0)

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

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

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

print(n)

Submission status: Accepted

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

Submission status: Accepted

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

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

print(N-sum(P))

Submission status: Accepted

Solution code:
from sys import stdin
import sys

# A, B, C, D = [int(x) for x in stdin.readline().rstrip().split()]
N, K = [int(x) for x in stdin.readline().rstrip().split()]
ans = [0 for i in range(N)]
for i in range(K):
    d = int(input())
    A = list(map(int, input().split()))
    for i in range(len(A)):
        ans[A[i]-1] += 1
cnt=0
for i in range(len(ans)):
    if ans[i] == 0:
        cnt += 1
print(cnt)

Submission status: Accepted

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

d = []
a = []

for i in range(k):
    temp = int(input())
    d.append(temp)

    t = list(map(int,input().split()))
    a.append(t)


a_set = set()
for i in a:
    for j in i:
        a_set.add(j)

print(n - len(a_set))

Submission status: Accepted

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

print(Ni.count(0))

Submission status: Accepted

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

for i in range(K):
    d = input()
    temp_ = list(map(int, input().split()))
    for i in range(len(temp_)):
        nlist.add(temp_[i])
N_ = len(nlist)
print(N - N_)

Submission status: Accepted

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

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

print(N-len(set(okashi)))

Submission status: Accepted

Solution code:
def main():
    n, k = map(int, input().split())
    d, A = [], []
    for _ in range(k):
        d.append(int(input()))
        l = list(map(lambda x:int(x) - 1, input().split()))
        A.append(l)

    ans = solve(n, k, d, A)
    print(ans)


def solve(n, k, d, A):
    sunuke = [False for _ in range(n)]
    for l in A:
        for i in l:
            sunuke[i] = True
    ans = [1 for i in sunuke if i == False]
    return sum(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

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

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

ans = 0
for okashi in list_:
    if okashi == 0:
        ans += 1

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

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

print(count)

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
snuke = [0 for _ in range(n)]
for i in range(k):
    how = int(input())
    snack = list(map(int, input().split()))
    for j in snack:
        snuke[j - 1] = 1

print(n - sum(snuke))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
inp_ls = input().split(" ")
n,k = [int(e) for e in inp_ls[:2]]

sunuke = [1 for _ in range(n)]
for i in range(k):
	d = int(input())
	a_ls = [int(e) for e in input().split(" ")[:d]]
	for a in a_ls:
		sunuke[a-1] = 0

print(sum(sunuke))

Submission status: Accepted

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

ans=[0]*n
for i in range(k):
    for j in range(len(a[i])):
        if ans[a[i][j]-1]==0:
            ans[a[i][j] - 1]=1
cnt=0
for i in range(n):
    if ans[i]==0:
        cnt+=1

print(cnt)

Submission status: Accepted

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

for i in range(k):
    d = map(int, input())
    ds = map(int, input().split())
    for j in ds:
        have[j-1] = True

count = 0
for i in range(n):
    if not have[i]:
        count += 1

print(count)

Submission status: Accepted

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

dA = [[int(input()), list(map(int, input().split()))] for i in range(K)]

sunulist = [1] * N

for i in range(K):
    di = dA[i][0]
    for j in range(di):
        m = dA[i][1][j]
        sunulist[m - 1] = 0

print(sum(sunulist))

Submission status: Accepted

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

Submission status: Accepted

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

b=[]
for t in a:
  for tt in t:
    b.append(tt)

a = set(b)
n = 0

for i in range(1, N+1):
  if i not in a:
    n += 1

print(n)

Submission status: Accepted

Solution code:
import numpy as np

x = input().split()

n = int(x[0])
k = int(x[1])
ds = []
bool_array = [0]*n

for num in range(k):
  di = int(input())
  ajs_input = input().split(' ')
  for j in range(di):
     bool_array[int(ajs_input[j])-1] = 1
      
print(n - np.array(bool_array).sum())

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())
  s = input().split(" ")
  for j in s:
    if int(j) in l:
      l.remove(int(j))
print(len(l))

Submission status: Accepted

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

for _ in range(K):
    d = int(input())
    dr = map(int,input().split())
    for it in dr:
        a[it]+=1

print(len(list(filter(lambda x:x==0,a)))-1)

Submission status: Accepted

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

print(a.count(0))

Submission status: Accepted

Solution code:
def main():
    N, K = map(int, input().split())
    A = [0 for a in range(N)]

    for i in range(K):
        d = int(input())
        O = [int(a) for a in input().split()]

        for j in range(d):
            A[O[j]-1] += 1
    cnt = 0
    for i in range(N):
        if A[i] == 0:
            cnt += 1

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

Submission status: Accepted

Solution code:
import itertools

n,k = map(int, input().split())
lis = []
for i in range(k):
  d = input()
  a = list(map(int, input().split()))
  lis.append(a)
aa = set(list(itertools.chain.from_iterable(lis)))
print(n-len(aa))

Submission status: Accepted

Solution code:
# abc166 B

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

for i in range(k):
    ld.append(int(input()))
    la.append(list(map(int, input().split())))

ln = [1] * (n+1)

ln[0] = 0

for a in la:
    for s in a:
        ln[s] = 0

print(sum(ln))

Submission status: Accepted

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

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

for i in range(K):
    input()
    li = list(map(int, input().split()))
    for j in li:
        N_li[j-1] = 1

print(N - sum(N_li))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:

def resolve():
    N, K = map(int, input().split())

    BL = [False]*N
    for _ in range(K):
        d = int(input())
        for i in input().split():
            i = int(i)-1
            BL[int(i)] = True

    print(sum([1 for x in BL if x==False]))

if __name__ == "__main__":
    resolve()

Submission status: Accepted

Solution code:
# python3

#===============================================================================
from collections import defaultdict, Counter
from functools import lru_cache
from heapq import heappush, heappop
from math import gcd, floor, ceil
from sys import stdin, stdout

def ilist():
    return [int(x) for x in stdin.readline().strip().split(" ")]
def iint():
    return int(stdin.readline().strip())
def istr():
    return stdin.readline().strip()
##==============================================================================


def solve():
    pass


if __name__ == '__main__':
    N, K = ilist()
    di = [0] * (N + 1)
    for _ in range(K):
        d = iint()
        A = ilist()
        for i in range(d):
            di[A[i]] = 1
    print(N - sum(di))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

N, K =  [int(i) for i in input().split()]

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

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
a = [0 for _ in range(n)]
for _ in range(k):
    _ = input()
    d_i = list(map(int, input().split()))
    for a_j in d_i:
        a[a_j-1] += 1

print(a.count(0))

Submission status: Accepted

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

def main():
    n, k = map(int, input().split())

    li = []

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

        li += a_li

    print(n - len(set(li)))

if __name__ == '__main__':
    main()

Submission status: Accepted

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

d = {}
for i in range(1, k+1):
    _ = input()
    A = map(int, input().split(" "))
    for a in A:
        tmp = d.get(a, [])
        tmp.append(i)
        d[a] = tmp

ans = 0
for i in range(1, n+1):
    if i not in d:
        ans = ans + 1

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n, d = map(int, input().split())
res_list = [0] * n
for i in range(d):
  input()
  s_list = list(map(int, input().split()))
  for val in s_list:
    res_list[val-1] += 1
res = 0
for r in res_list:
  if r == 0:
    res += 1
print(res)

Submission status: Accepted

Solution code:
N,K=map(int,input().split())
cnt=[0]*N
for _ in range(K):
    d=input()
    As=list(map(int,input().split()))
    for A in As:
        cnt[A-1]+=1
ans=0
for e in cnt:
    if e==0:
        ans+=1
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
have = [False] * n
for i in range(k):
    _ = int(input())
    a = list(map(int, input().split()))
    for a_elem in a:
        have[a_elem - 1] = True
print(sum([not h for h in have]))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

N, K = map(int, sys.stdin.readline().rstrip().split())

counter = [0] * N

for k in range(K):
    d = int(sys.stdin.readline().rstrip())
    A = list(map(int, sys.stdin.readline().rstrip().split()))
    for a in A:
        counter[a - 1] += 1

print(counter.count(0))

Submission status: Accepted

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

print(N - len(set(ans)))

Submission status: Accepted

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

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

ans = 0
for item in snukes_snacks:
	if len(item) == 0:
		ans += 1
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def B():
    N, K = map(int, input().split())
    snukes = set([i for i in range(1, N+1)])
    seen = set()
    for i in range(K):
        d = int(input())
        seen = seen.union(set([int(n) for n in input().split()])) 
    print(len(snukes.difference(seen)))
        
B()

Submission status: Accepted

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

Submission status: Accepted

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

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

cnt = 0
for row in A:
    if not any(row):
        cnt += 1

print(cnt)

Submission status: Accepted

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

import itertools


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

print(count)

Submission status: Accepted

Solution code:
from collections import Counter
N, K = map(int, input().split())
result = []
for _ in range(K):
    d = input()
    A = list(map(int, input().split()))
    result += A
A = Counter(result)
print(len([i for i in range(1, N+1) if i not in A]))

Submission status: Accepted

Solution code:
N ,K =map(int,input().split())
num =[]
for i in range(K):
    d_n =int(input())
    A_n = list(map(int,input().split()))
    for i in range(d_n):
        num.append(A_n[i])

print(N -len(set(num)))

Submission status: Accepted

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

print(ans.count(0))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
ls = [list(map(int, input().split())) for _ in range(2 * k)]

d = []
a = []

for i in range(2 * k):
    if i % 2 == 0:
        d.append(ls[i])
    elif i % 2 == 1:
        a.append(ls[i])


cnt = [0] * n

for j in range(k):
    for ajd in a[j]:
        cnt[ajd - 1] += 1

print(cnt.count(0))

Submission status: Accepted

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

Submission status: Accepted

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

h = {}

for i in range(K):
    tmp = int(input())
    for j in map(int, input().split()):
        if j in h:
            h[j] += 1
        else:
            h[j] = 1

print(N - len(h.keys()))

Submission status: Accepted

Solution code:
[n, k] = [int(s) for s in input().split()]
a = [0 for _ in range(n)]
for _ in range(k):
    input()
    for n in [int(s) for s in input().split()]:
        a[n-1] = 1
print(len([1 for b in a if b == 0]))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
foods = [[] for _ in range(N)]
for _ in range(K):
    d = int(input())
    food = list(map(int, input().split()))
    for human in food:
        foods[human - 1].append(d)

count = 0
for food in foods:
    if len(food) == 0:
        count += 1

print(count)

Submission status: Accepted

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

for _ in range(K):
    d=int(input())
    A=list(map(int,input().split()))
    for i in range(d):
        p[A[i]-1]=0
print(sum(p))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,k = map(int,input().split())
ans = {}
for i in range(k):
    di=int(input())	
    li = list(map(int,input().split()))
    for l in li:
        ans[str(l)] = "0"
count = 0
for i in range(1,n+1):
    if str(i) not in ans.keys():
        count += 1
print(count)

Submission status: Accepted

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

sunuke = [0] * n
for i in range(k):
    for j in A[i]:
        sunuke[j - 1] += 1

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