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())
A = [None]*k
for i in range(k):
    d = int(input())
    A[i] = list(map(int, input().split()))

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

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

Submission status: Accepted

Solution code:
if __name__ == '__main__':
    [n,k] = [int(i) for i in input().split()]
    m = dict()
    for i in range(1,n+1,1):
        m[i] = []
    for i in range(1,k+1,1):
        d = input()
        for j in input().split():
            m[int(j)].append(i) 

    count = 0
    for i in m.keys():
        if len(m[i]) == 0:
            count+=1
    print(count)

Submission status: Accepted

Solution code:
n,_,*t=''.join([*open(0)][::2]).split()
print(int(n)-len({*t}))

Submission status: Accepted

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

d = []
A = []
for _ in range(K):
  d.append(int(input()))
  A.extend([int(j) for j in input().split()])
  
print(N-len(set(A)))

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
arr = [False for i in range(n + 1)]
count = 0
for i in range(k):
    d = int(input())
    darr = list(map(int, input().split()))
    for j in darr:
        arr[j] = True
for i in range(len(arr)):
    if arr[i] == False:
        count+=1
print(count - 1)

Submission status: Accepted

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

lst = [0] * N #お菓子の数を格納するリスト

for i in range(K):
    d = input() #今回は使用しない
    A = list(map(int, input().split()))
    for a in A:
        lst[a-1] += 1 #indexを合わせてお菓子の数をカウントする。

print(lst.count(0))

Submission status: Accepted

Solution code:
x,*l=open(0)
print(int(x.split()[0])-len({*''.join(l[1::2]).split()}))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
(n,_),*t=[t.split()for t in open(0)][::2]
print(int(n)-len(set(sum(t,[]))))

Submission status: Accepted

Solution code:
import collections
N,K = map(int, input().split())
myMap = collections.defaultdict(int)
for i in range(K):
    input()
    withSnack =  list(map(int, input().split(" ")))
    for j in withSnack:
        myMap[j] += 1
for d in myMap.keys():
    N -= 1
print(N)

Submission status: Accepted

Solution code:
import sys
input = lambda:sys.stdin.readline().strip()
n,k = map(int,input().split())
vis = [False]*n
for i in range(k):
    d = int(input())
    a = list(map(int,input().split()))
    for i in a:
        vis[i-1]=True
ans = vis.count(False)
print(ans)

Submission status: Accepted

Solution code:
# B - Trick or Treat
def main():
    N, K = map(int, input().split())
    has_snacks = set()
    for _ in range(K):
        _ = input()
        has_snacks |= set(map(int, input().split()))
    print(N - len(has_snacks))


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**6)

n,k=map(int,input().split())
ans = [0]*n
for _ in range(k):
    d=int(input())
    a=list(map(int,input().split()))
    for x in a:
        ans[x-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())
A = [0] * N

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

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

print(count)

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()))
    for j in A:
        if j not in a:
            a.append(j)

ans = 0

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

print(ans)

Submission status: Accepted

Solution code:
import numpy as np

N,K=map(int,input().split())
L=[]
for i in range(K):
  d=int(input())
  A=np.array(list((map(int,input().split()))))
  A=np.unique(A)
  for a in A:
    if not(a in L):
      L.append(a)
print(N-len(L))

Submission status: Accepted

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

Submission status: Accepted

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

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

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

print(ans)

Submission status: Accepted

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

if __name__ == "__main__":
    solve()

Submission status: Accepted

Solution code:
import collections

dic = collections.defaultdict(int)

N, K = map(int, input().strip().split())
for i in range(K):
  di = map(int, input().strip())
  A = map(int, input().strip().split())
  for j in A:
    dic[j] += 1

ans = 0
for i in range(1, N+1):
  if dic.get(i) is None:
    ans += 1

print(ans)

Submission status: Accepted

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

member = list(range(1, n+1))

for i in range(0,k):
    a = int(input())
    if a == 1:
        b = int(input())
        if b in member:
            member.remove(b)
        else:
            pass
    else:
        b = list(map(int, input().split()))
        for j in range(0,a):
            if b[j] in member:
                member.remove(b[j])
            else:
                pass

print(len(member))

Submission status: Accepted

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

snuke = [0]*N

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

Submission status: Accepted

Solution code:
#import math
#S=input()
#int(input())
N,K=map(int,input().split())
#H = list(map(int,input().split()))
#AB=[list(map(int,input().split())) for _ in range(M)]
l = []
for _ in range(K):
    d = int(input())
    A = list(map(int,input().split()))
    l += A
print(N - len(set(l)))

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

snuke = [] # お菓子を持っていないなら0
for i in range(n):
    snuke.append(0) # snukeは0がn個入っているリスト

for i in range(k):
    d = int(input())
    a = list(map(int,input().split()))
    for j in range(d):
        a[j] -= 1 # a[j]番目だけど、0から始める添え字に直すので1引いておく
        if snuke[a[j]] == 0:
            snuke[a[j]] = 1
            n -= 1 # a[j]番目のすぬけくんが初めてお菓子を貰うならnから1引く

print(n)

Submission status: Accepted

Solution code:
import numpy as np

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

A=[]
l=[]
for _ in range(K):
    d = map(int, input())
    l=list(map(int,input().split()))
    A.append(l)
#print(A)
a=np.zeros((N, K))
for i in range (len(A)):
    for j in range(len(A[i])):
        a[A[i][j]-1][i]=1
#print(a)
print(np.count_nonzero(np.all(a==0, axis=1)))

Submission status: Accepted

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

ans = 0
l = []

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

for j in range(1,n+1):
    if j not in l:
        ans += 1

print(ans)

Submission status: Accepted

Solution code:
N, K = input().strip().split(" ")
N = int(N)
K = int(K)
checkbox = [False for i in range(N)]
for k in range(K):
    input()
    seq = input().strip().split(" ")
    for j in seq:
        checkbox[int(j)-1] = True
print(checkbox.count(False))

Submission status: Accepted

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

for i in range(0,NK[1]):
  d = int(input())
  table  = list(map(int, input().split()))
  for j in range(1,NK[0]+1):
    if table.count(j) != 0:
      ans[j-1] = 1
print(NK[0]-sum(ans))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def run():
  N, K = map(int, input().split())
  C = [0] * N
  counter = 0
  for i in range(K):
    d = int(input())
    A = list(map(int, input().split()))
    
    for j in range(d):
      C[A[j]-1] += 1
  
  for i in range(N):
    if C[i]==0:
      counter+=1
    else:
      pass
  print(counter)

if __name__ == "__main__":
  run()

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()))
    ans += a
print(n-len(set(ans)))

Submission status: Accepted

Solution code:
total, kinds = map(int, input().split())

l = [False]*total

for i in range(kinds):
    non = input()
    people = list(map(int, input().split()))
    for j in range(len(people)) :
        l[people[j]-1] = True
    
print(l.count(False))

Submission status: Accepted

Solution code:
# coding: utf-8


def solve(*args: str) -> str:
    n, k = map(int, args[0].split())

    T = set()
    for A in args[2::2]:
        T |= set(map(int, A.split()))

    return str(n-len(T))


if __name__ == "__main__":
    print(solve(*(open(0).read().splitlines())))

Submission status: Accepted

Solution code:
import numpy as np

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

p = np.zeros(n)


for i in range(k):
  input()
  l = np.array(list(map(int, input().split())))
  p[l-1] += 1

print(len(np.where(p==0)[0]))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

L = []
"""
while True:
    l = input()
    if l == "":
        break
    else:
        L.append(list(map(int,l.split())))
        print(L)
"""
N,K = list(map(int,input().split()))

#print(N,K)

for a in range(2 * K):
    n = list(map(int,input().split()))
    L.append(n)

#print("End",L)

Num = list(range(1, N + 1, 1))
#print(Num)
new_L = L[1::2]
#print(new_L)

new_LL = sum(new_L, [])
for n in new_LL:
    if n in Num:
        Num.remove(n)

print(len(Num))

Submission status: Accepted

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


C = [0 for i in range(N+1)]
for i in range(K):
    d.append(input())  #Kこの文字列を読み込み　行列

    A = list(map(int, input().split())) #一行ずつ処理


    for v in A:
        C[v-1] = 1


print(N-sum(C))

Submission status: Accepted

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

Submission status: Accepted

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

print(sum(a))

Submission status: Accepted

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

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

for k in range(K):
  _ = input()
  sunukekun = input().split(' ')
  for kun in sunukekun:
    if kun in sunukekuns:
      sunukekuns.remove(kun)

print(len(sunukekuns))

Submission status: Accepted

Solution code:
from sys import stdin, setrecursionlimit

setrecursionlimit(10 ** 9)


def input():
    return stdin.readline().strip()


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

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

ans = N - len(s)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N,K=map(int,input().split())
A=[list(map(int,input().split())) for i in range(K*2)]
count=0
a=0
for i in range(K):
    del A[i]
a_list=[]
for i in range(K):
    for j in range(len(A[i])):
        a_list.append(A[i][j])
for i in range(1,N+1):
    #print(i,count)
    #print(i in a_list)
    if (i in a_list)==True:
        count+=1
#print(N,count)
print(N-count)

Submission status: Accepted

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

# setについての詳細:
# https://docs.python.org/ja/3/library/stdtypes.html#set-types-set-frozenset

has_snack = set()  # 1つ以上のお菓子を持っているすぬけ君を入れておくset
for i in range(K):
    d = int(input())  # d を読む（使わないけど）
    A = set(map(int, input().split()))  # A を set として読む
    has_snack |= A  # has_snackとの和集合を求め、それをhas_snackに代入

# len(has_snack) でhas_snackの要素数を求め、総数 N から引く
print(N-len(has_snack))

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
has_snack = [False]*N
# has_snack: 1つ以上のお菓子を持っているかどうか
# has_snack[i] = True なら、すぬけ君i+1は1つ以上のお菓子を持っている

for i in range(K):
    d = int(input())  # d を読む (使わないけど)
    A = list(map(int, input().split()))  # A を読む
    for v in A:  # A の各要素 v について、
        has_snack[v-1] = True  # すぬけ君vは1つ以上のお菓子を持っている

# sum(has_snack) で1つ以上のお菓子を持っているすぬけ君の人数を求める
# ↑ 暗黙に、Trueは1、Falseは0に変換される
# 求めたいのは1つも持っていないすぬけ君の人数なので、総数Nから引く
print(N - sum(has_snack))

Submission status: Accepted

Solution code:
a,b = map(int,input().split())
lis = [0]*a
for i in range(b):
  c = int(input())
  d = input().split()
  
  for l in range(c):
    lis[int(d[l])-1] += 1
    
count = 0
for i in range(a):
  if(lis[i] == 0):
    count += 1

print(count)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
n, k = map(int, input().split())
d = []
a = []

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

check = [False] * n

for i in range(k):
    for j in a[i]:
        check[j-1] = True

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

print(ans)
# thx for https://qiita.com/taxfree_python/items/491269d25cb7bcd9965b

Submission status: Accepted

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

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

print(snuke.count(0))

Submission status: Accepted

Solution code:
s = []
n, k = map(int, input().split())
for i in range(n):
    s.append(0)
for i in range(k):
    m = int(input())
    na = list(map(int, input().split()))
    for j in na:
        s[j - 1] = 1
         
print(s.count(0))

Submission status: Accepted

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

Submission status: Accepted

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

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

print(check.count(0))

Submission status: Accepted

Solution code:
n,k = input().split()
n = int(n)
k = int(k)
s = set()
for _ in range(k):
  m = int(input())
  l = list(map(int, input().split()))
  for item in l:
    s.add(item)

print(n-len(s))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n, k = [int(x) for x in input().split()]
s = set()
for _ in range(k):
    d = int(input())
    s |= set(int(x) for x in input().split())
print(sum(1 for i in range(1, n + 1) if i not in s))

Submission status: Accepted

Solution code:
import time
startTimeProblem=time.time()

import fileinput, sys, itertools, functools
from math import *
from bisect import *
from heapq import *
from collections import *

def lcm(a, b):  
    return (a*b)/gcd(a, b)

class InputHelper:
    def __init__(self):
        self.myinput = fileinput.input()

    def isLocal(self):
        return not fileinput.isstdin()

    def int(self):
        return int(self.myinput.readline().rstrip())

    def ints(self):
        return [int(_) for _ in self.myinput.readline().rstrip().split()]

    def str(self):
        return self.myinput.readline().rstrip()

    def strs(self):
        return [_ for _ in self.myinput.readline().rstrip().split()]

class OutputHelper:
    def int(self, a):
        print(a)    

    def ints(self, a):  
        print(" ".join([str(_) for _ in a]))
    
    def intsNL(self, a):
        for _ in a:
            print(_)
    
    def str(self, s):
        print(s)

    def strs(self, s):
        print(" ".join([_ for _ in s]))

    def strsNL(self, s):
        for st in s:
            print(st)

class ListNode:
    def __init__(self, val):
        self.val = val
        self.next = None
        self.prev = None

In = InputHelper()
Out = OutputHelper()

######################################

N, K = In.ints()

has = [0]*(N+1)
for i in range(K):
    d = In.int()

    for snuke in In.ints():
        has[snuke]+=1

ans = 0

for h in has:
    if h==0:
        ans+=1

Out.int(ans-1)
 
######################################

if len(sys.argv)>2 and sys.argv[2]=="TIMEIT":
    fin = (time.time()-startTimeProblem)*1000
    print("{:.2f}".format(fin) + "ms")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,k = map(int,input().split())
e=[]
for i in range(k):
  s= int(input())
  l=list(map(int,input().split()))
  e=e+l
r=set(e)
print(n-len(r))

Submission status: Accepted

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

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

print(N-len(has_snack))

Submission status: Accepted

Solution code:
N,K = map(int,input().split())
s = [input() for i in range(K*2)]
l = []
c = 0
k = 0
m = 0
f = []
# スペース区切りの整数の入力
num = []
for i in range(K*2):
  if i%2==1:
    for m in range(int(s[i-1])):
      num.append(s[i].split()[m])
for j in range(1,N+1):
  f.append(num.count(str(j)))
print(f.count(0))

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
d = [0] * k
sunuke = {}
for i in range(n):
    sunuke.setdefault(str(i), 0)
    #print(sunuke)

for i in range(k):
    d[i] = int(input())
    A = list(map(int,input().split()))
    #print(d[i],A)
    for j in range(d[i]):
        sunuke[str(A[j]-1)] += 1

ans = list(sunuke.values()).count(0)

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
num_sunuke, num_okashi_kind = map(int, input().split())
sunuke = [0] * (num_sunuke+1)

ans = 0
for idx_okashi_kind in range(1, num_okashi_kind+1) :
    num_have_okashi = int(input())
    idx_sunuke_with_okashi = map(int,input().split())

    for i in range(1, num_have_okashi+1) :
        for j in idx_sunuke_with_okashi :
            sunuke[j] = 1

for s in sunuke :
    if s == 1 :
        ans = ans + 1

print(num_sunuke - ans)

Submission status: Accepted

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

Submission status: Accepted

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

A = [-1] * n

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

ans = 0

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

print(ans)

Submission status: Accepted

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

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

print(N-sum(has_snack))

Submission status: Accepted

Solution code:
import sys

def solve():
    input = sys.stdin.readline
    N, K = map(int, input().split())
    Count = [0] * N
    for k in range(K):
        d = int(input())
        A = [int(a) - 1 for a in input().split()]
        for a in A: Count[a] += 1
    print(Count.count(0))

    return 0

if __name__ == "__main__":
    solve()

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 a in A:
    ans[a-1] += 1
cnt = 0
for a in ans:
  if a == 0:
    cnt += 1
print(cnt)

Submission status: Accepted

Solution code:
import itertools
import math
import string
import collections
from collections import Counter
from collections import deque
import sys
sys.setrecursionlimit(2*10**5)
INF = 2**60


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


def nCr(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor


# coordinates
dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]

n, k = map(int, input().split())
check = [0]*(n)
for _ in range(k):
    d = int(input())
    a = readints()
    # print(d)
    # print(a)
    for i in range(d):
        check[a[i]-1] = a[i]
cnt = 0
for i in range(len(check)):
    if check[i] == 0:
        cnt += 1
print(cnt)

Submission status: Accepted

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

sunuke = []

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

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

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
numlist = []
for i in range(K*2):
    numlist.append(list(map(int,input().split())))
anslist=[]

i=0
while i<K*2:
    if not i%2==0:
        anslist.extend(numlist[i])
    i+=1
    
ans=0
j=0
while j<N:
    check=j+1
    if check not in anslist:
        ans+=1
    j+=1
    
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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


sunuke =[0] * n
for i in range(k):
    #print("d[i]",d[i])
    for j in range(int(d[i])):
        temp = a[i][j] -1 
        sunuke[temp] += 1

#print(sunuke)
print(sunuke.count(0))

Submission status: Accepted

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

s = set()

#K種類ループ
for i in range(K):
  d = int(input())
  ad = list(map(int,input().split()))
  for a in range(d):
    s.add(ad[a])

print(N - len(s))

Submission status: Accepted

Solution code:
N,K = map(int, input().split())
p = []
for s in range(1,N+1):
    p.append(s)
for i in range(K):
    d = int(input())
    A = [int(x) for x in input().split()]
    B = len(A)
    for i in range(B):
        if A[i] in p:
            p.remove(A[i])
ans = len(p)
print(ans)

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
s = [0 for i in range(n)]
for z in range(k):
	hoge = input()
	l = list(map(int, input().split()))
	for i in l:
		s[i-1] += 1

def fuga(x): return x==0

print(len(list((filter(fuga, s)))))

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
AA=set([])
for i in range(k):
  d=int(input())
  A=list(map(int,input().split()))
  AA=AA|set(A)#|は「パイプ」和集合
print(n-len(AA))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, K = [int(i) for i in input().split()]
count = [0]*N

for _ in range(K):
  d = int(input())
  for v in input().split():
    j = int(v) - 1
    count[j] += 1
sunsuke = 0 
for i in count:
  if i == 0:
    sunsuke += 1
print(sunsuke)

Submission status: Accepted

Solution code:
s = []
j = 0
num = 0

n,k = map(int, input().split())
for i in range(k):
  d = int(input())
  s.extend(input().split())

s = list(set(s))
print(n - len(s))

Submission status: Accepted

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

for i in range(1,n + 1):
  num.append(i)
  
for j in range(k):
  rm_tg = s[2*j+1].split()
  for m in range(int(s[2*j])):
    for sin in num:
      if sin == int(rm_tg[m]):
        num.remove(int(rm_tg[m]))

        
print(len(num))

Submission status: Accepted

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

Submission status: Accepted

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

for _ in range(k):
    d = int(input())
    t = list(map(int, input().split()))
    for i in range(len(t)):
        s.add(t[i])


print(n - len(s))

Submission status: Accepted

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

for _ in range(k):
    d = int(input())
    t = list(map(int, input().split()))
    for i in range(len(t)):
        s.append(t[i])

l = set(s)

print(n - len(l))

Submission status: Accepted

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

n, k = map(int, readline().split())
aa = []
for i in range(k):
    readline()
    aa += list(map(int, readline().split()))
cnt = 0
for i in range(1, n + 1):
    if i not in aa:
        cnt += 1
print(cnt)

Submission status: Accepted

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

sunuke = 0
for i in range(1,N+1):
    if i in okashi_sunuke:
        sunuke +=1

print(N-sunuke)

Submission status: Accepted

Solution code:
import numpy as np
N,K = list(map(int, input().split()))

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


res = []
for i in range(1,N+1):
    if not np.any(i in A):
        res.append(i)

print(len(res))

Submission status: Accepted

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

Submission status: Accepted

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

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

print(result.count(0))

Submission status: Accepted

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

Submission status: Accepted

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


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

print(cnt.count(0))

Submission status: Accepted

Solution code:
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)))

Submission status: Accepted

Solution code:
import sys
import math
from collections import defaultdict
from bisect import bisect_left, bisect_right

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def LI(): return list(map(int, input().split()))
def LIR(row,col):
    if row <= 0:
        return [[] for _ in range(col)]
    elif col == 1:
        return [I() for _ in range(row)]
    else:
        read_all = [LI() for _ in range(row)]
        return map(list, zip(*read_all))

#################

N,K = LI()
X = [False]*N
for i in range(K):
    d = I()
    a = LI()
    for a0 in a:
        X[a0-1] = True

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

print(ans)

Submission status: Accepted

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

for i in range (k):
    d=int(input())
    list_temp=list(map(int,input().split()))
    for j in list_temp:
        list_1[j-1]+=1
#print(list_1)

print(list_1.count(0))

Submission status: Accepted

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

Submission status: Accepted

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

d = [0]*n

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


print(d.count(0))

Submission status: Accepted

Solution code:
import numpy as np
n, k = map(int, input().split())
a = np.zeros(n + 1)
a[0] = 1
for i in range(k):
    d = int(input())
    a[np.array(list(map(int, input().split())))] += 1
print(np.count_nonzero(a == 0))