Problem:


Score : 200 points

Problem Statement

N Snukes called Snuke 1, Snuke 2, ..., Snuke N live in a town.

There are K kinds of snacks sold in this town, called Snack 1, Snack 2, ..., Snack K. The following d_i Snukes have Snack i: Snuke A_{i, 1}, A_{i, 2}, \cdots, A_{i, {d_i}}.

Takahashi will walk around this town and make mischief on the Snukes who have no snacks. How many Snukes will fall victim to Takahashi's mischief?

Constraints

All values in input are integers.

1 \leq N \leq 100

1 \leq K \leq 100

1 \leq d_i \leq N

1 \leq A_{i, 1} < \cdots < A_{i, d_i} \leq N

Input

Input is given from Standard Input in the following format:

N K
d_1
A_{1, 1} \cdots A_{1, d_1}
\vdots
d_K
A_{K, 1} \cdots A_{K, d_K}

Output

Print the answer.

Sample Input 1

3 2
2
1 3
1
3

Sample Output 1

1

Snuke 1 has Snack 1.

Snuke 2 has no snacks.

Snuke 3 has Snack 1 and 2.

Thus, there will be one victim: Snuke 2.

Sample Input 2

3 3
1
3
1
3
1
3

Sample Output 2

2



Sample input:
3 2
2
1 3
1
3


Sample output:
1

Submission status: Accepted

Solution code:
# 初期入力
import sys
from collections import Counter
input = sys.stdin.readline
N,K = (int(x) for x in input().split())
d=[-1]*K
#A=[[0]for i in range(K)]
A=[] #菓子持ってる人
#hito_kasi ={i:set for i in range(K)}
for i in range(K):
    d[i] = int(input())
    A.extend(list(map(int, input().split())))
    
#
hito_kasi   =Counter(A)
hito_all    =set(i for i in range(1,N+1))
kasi_motteru= set(hito_kasi.keys())
ans         =hito_all - kasi_motteru
print(len(ans))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,k=[int(s) for s in input().split(' ')]
gl=[]
c=0
for _ in range(k):
    z=input()
    for s in input().split(' '):
         gl.append(int(s))

for sn in range(1,n+1):
    if sn in gl:
        continue
    else:
        c+=1
print(c)

Submission status: Accepted

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

for i in range(1, N + 1):
  num.append(i)

for i in range(K):
  d = int(input())
  drops = list(map(int,input().split()))
  for k in drops:
    if k in num:
      num.remove(k)

print(len(num))

Submission status: Accepted

Solution code:
# coding: utf-8
a,b = map(int, input().split())
count=[0]*a
for i in range(b):
    n = int(input())
    num_list = list(map(int, input().split())) 
    for j in num_list:
       count[j-1]+=1
c=0

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

Submission status: Accepted

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

member = set([])

for j in range(k):
    d = int(input())
    member = member.union(set(list(map(int,input().split()))))

print(n-len(member))

Submission status: Accepted

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

Submission status: Accepted

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

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

p = list(set(p))

total = len(l) - len(p)
print(total)

Submission status: Accepted

Solution code:
nk = list(map(int, input().split()))
dic={}
for i in range(1,nk[0]+1):
    dic[str(i)]=0


for i in range(nk[1]):
    d=int(input())
    a = list(map(int, input().split()))
    for j in range(len(a)):
        dic[str(a[j])]=1

keys= [k for k, v in dic.items() if v == 0]
print(len(keys))

Submission status: Accepted

Solution code:
N,K=map(int,input().split())
d=[0]*K
A=[0 for _ in range(K)]
S=set([i+1 for i in range(N)])
for i in range(K):
  d[i]=int(input())
  A[i]=list(map(int,input().split()))
  for p in A[i]:
    if p in S:
      S.remove(p)
      
#print(S)
print(len(S))

Submission status: Accepted

Solution code:
def main():
    N, K = map(int, input().split())
    A = [0] * (N+1)
    A[0] = 1
    for _ in range(K):
        D = int(input())
        AD = list(map(int, input().split()))   # 数字が一つの時、mapできない
        for i in AD: A[i] = 1

    sum = 0
    for j in A:
        if j == 0: sum += 1

    print(sum)

main()

Submission status: Accepted

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

Aset = set()
Alist = list()
ans = 0

for count in range(2 * K):
    if count % 2 != 0:
        Alist.extend(dA[count])

Aset = set(Alist)
ans = N - len(Aset)
print(ans)

Submission status: Accepted

Solution code:

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

    dic = {}
    for i in range(N):
        dic[i+1] = 0
        
    for i in range(K):
        dk = int(input())
        Ak = list(map(int, input().split()))
        for a in Ak:
            if a in dic:
                del dic[a]
    print(len(dic))

solve()

Submission status: Accepted

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

Submission status: Accepted

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

sunuke_list = [0]*N

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

print(sunuke_list.count(0))

Submission status: Accepted

Solution code:
import numpy as np

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

A = sum(A, [])
ans = N - len(np.unique(A))
print(ans)

Submission status: Accepted

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

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

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

#print(dic)
ans = 0
for k,v in dic.items():
    if v == 0:
        ans += 1
print(ans)

Submission status: Accepted

Solution code:
import sys

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

Input = []
while True:
    try:
        d = int(input())
        i = list(map(int, input().split()))
        Input += i
        #print(d,i)
    except Exception as e:
        break

#count=0
# for i in n:
#     if i not in Input:
#         count+=1

N=[]
for i in range(n):
    N.append(i+1)
    #print(N)

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

Submission status: Accepted

Solution code:
inputlist = list(map(int, input().split()))
snum = inputlist[0]
kindofsweets = inputlist[1]
setofkind = []
for i in range(kindofsweets):
    input()
    setofkind += (list(map(int, input().split())))
counter = 0
for i in range(snum):
    if i + 1 not in setofkind:
        counter += 1
print(counter)

Submission status: Accepted

Solution code:
O=list(map(int, input().split()))
N = O[0]
K = O[1]
L = []
for i in range(N):
    L.append(1)
    

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

sumx = 0

for i in range(N):
    sumx+=L[i]
    
print(sumx)

Submission status: Accepted

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

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

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

print(ans)

Submission status: Accepted

Solution code:
N,K = map(int,input().split())
c = 0
listA = []
for k in range(1,K+1):
    d = int(input())
    listA += list(map(int,input().split()))
    
for n in range(1,N+1):
    if n not in listA:
        c += 1
print(c)

Submission status: Accepted

Solution code:
temp=input().split(" ")
N=int(temp[0])
K=int(temp[1])
sum=0
snucklist=[]
for i in range(1,K+1):
    d=int(input())
    templist=input().split(" ")
    for j in range(0,d):
        if int(templist[j]) not in snucklist:
            snucklist.append(int(templist[j]))
for t in range(1,N+1):
    if t not in snucklist:
        sum=sum+1
print(sum)

Submission status: Accepted

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

for j in range(NK[1]):
    d[j-1]=int(input())
    A_in=list(map(int,input().split()))
    A_list.append(A_in)

N_list=list(range(1,NK[0]+1))
A_sort=[]
for A in A_list:
    for a in A:
        A_sort.append(a)
print(NK[0]-len(set(A_sort)))

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

a=[]
for i in range(len(A)):
  for j in range(len(A[i])):
    if not(A[i][j] in a):
      a.append(A[i][j])
#     print("A[i][j]=",A[i][j])
# print(a)

print(n-len(a))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
def main():
    N,K = map(int,input().split())
    ans = []
    for i in range(K):
        tmp = []
        S = int(input())
        tmp = list(map(int, input().split()))
        ans.extend(tmp)
        #print(tmp,ans)
    print(N-(len(set(ans))))

if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

Submission status: Accepted

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

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

# calc
okashi = [0 for _ in range(n)]
for i in range(k):
    for j in range(d[i]):
        okashi[A[i][j]-1] += 1
ans = 0 
for i in range(len(okashi)):
    if okashi[i] == 0:
        ans += 1
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import bisect
import copy
import heapq
import sys
import itertools
import math
import queue
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
mod = 10 ** 9 + 7

def read_values(): return map(int, input().split())
def read_index(): return map(lambda x: int(x) - 1, input().split())
def read_list(): return list(read_values())
def read_lists(N): return [read_list() for n in range(N)]
def init_dp1(init, N): return [init for _ in range(N)]
def init_dp2(init, N, M): return [[init for _ in range(M)] for _ in range(N)]


class V:
    def __init__(self, f, v=None):
        self.f = f
        self.v = v
 
    def __str__(self):
        return str(self.v)
 
    def ud(self, n):
        if n is None:
            return

        if self.v is None:
            self.v = n
            return
        self.v = self.f(self.v, n) 


def main():
    N, K = read_values()
    S = set(i for i in range(N))

    for _ in range(K):
        input()
        A = tuple(read_index())
        for a in A:
            if a in S:
                S.remove(a)
    
    print(len(S))


if __name__ == "__main__":
    main()

Submission status: Accepted

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

arr = []

for i in range(int(K)):
    input()
    arr.append(list(input().split()))


snuk = [0] * int(N)

for di in arr:
    for i in di:
        snuk[int(i)-1] = 1


num = 0


for i in snuk:
    if i == 0:
        num = num+1

print(num)

Submission status: Accepted

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

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


count = 0
li = []
for i in range(K):
    for a in A[i]:
        if not a in li:
            count += 1
            li.append(a)

print(N - count)

Submission status: Accepted

Solution code:

N, K =(int(i) for i in input().split())
table = [False for _ in range(N)]
for _ in range(K):
  di = int(input())
  a = list(map(int,input().split()))
  for i in a:
    table[i-1] = True

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

Submission status: Accepted

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

for j in range(k):
  for l in range(D[j]):
    a[A[j][l]-1] += 1

print(a.count(0))

Submission status: Accepted

Solution code:
N, K = map(int,input().split())
s = {}
for j in range(K):
  d = int(input())
  A = list(map(int,input().split()))
  for i in A:
    s[i] = True
    
print(N - len(s))

Submission status: Accepted

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

for _ in range(k):
    d.append(int(input()))
    a += input().split()

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

Submission status: Accepted

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

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

t = 0
for i in range(1,n+1):
    if i in a_list:
        t += 1
print(n-t)

Submission status: Accepted

Solution code:
import itertools
n_people, n_food = map(int, input().split(" "))
d_list = []
A_list = []
for i in range(n_food):
    d = int(input())
    A = [int(_) for _ in input().split(" ")]
    d_list.append(d)
    A_list.append(A)
    
print(n_people - len(set(itertools.chain.from_iterable(A_list))))

Submission status: Accepted

Solution code:
N,K=map(int,input().split())
dlist=[]
Alist=[]
myset1=set([])

for i in range(K):
    d=int(input())
    dlist.append(d)
    templist=list(map(int,input().split()))
    for j in range(len(templist)):
        Alist.append(templist[j])
    
    
    
myset1=set(Alist)    
#print(dlist)
#print(Alist)
#print(myset1)


print(N-len(myset1))

Submission status: Accepted

Solution code:
n,k = (int(i) for i in input().split())
d = 0
a = []
c = set( [i for i in range(1,n+1)])
for i in range(k):
	d = int(input())
	a.extend(int(i) for i in (input().split()))

b = set(a)
d = c-b
print(len(d))

""""
n,m = (int(i) for i in input().split())
h = [int(i) for i in input().split()]
ab =[]
for i in range(m):
	ab.append(list(map(int,input().split())))
	"""

Submission status: Accepted

Solution code:
x = input().split()
n = int(x[0])
k = int(x[1])*2
s = [input().split() for i in range(k)]
l = []
for i in range(0, k):
  if i%2 != 0:
    for j in range(1, n+1):
      if (str(j) in s[i]) == True:
        l.append(j)
        pass
count = 0
for i in range(1, n+1):
  if (i in l) == False:
    count += 1
print(count)

Submission status: Accepted

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

d = []
t = ()

for _ in range(K):
    d.append(int(input()))
    a = list(map(int, input().split()))
    t = t + tuple(a)

nums_unique = list(set(t))

print(N - len(nums_unique))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
cnt = N
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:
            cnt -= 1
        snuke[a[j] - 1] += 1
print(cnt)

Submission status: Accepted

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

N,K=map(int,input().split())
d=[0]*K
A=[]
B=set()
for i in range(K):
    d[i]=int(input())
    A.append(list(map(int,input().split())))
    for j in A[i]:
        B.add(j)

print(N-len(B))

Submission status: Accepted

Solution code:

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

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


sunuke=[0]*N
for j in range(K):

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

print(sunuke.count(0))

Submission status: Accepted

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

treated = (list(range(1, N+1)))

for i in range(K):
  tt = list(set(list(range(1, N+1))) - set(l[2*i+1]))
  treated = list(set(treated) & set(tt))

print(len(treated))

Submission status: Accepted

Solution code:
def main():
    N, K = map(int, input().split())
    s_sunuke = set()
    d = [-1] * K
    A = [None] * K
    for i in range(1, K + 1):
        d[i-1] = int(input())
        s_sunuke = s_sunuke | set([int(x) for x in input().split()])
    
    print(N - len(s_sunuke))




if __name__ == "__main__":
    main()

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
li = []
for x in range(k*2):
    li.append(input().split())
li2 = []
i = 1
while i < k*2:
    for j in li[i]:
        li2.append(j)
    i += 2
li2 = set(li2)
print(n - len(li2))

Submission status: Accepted

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

Submission status: Accepted

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

for m in range(1, n + 1):
	if m not in A:
		count += 1

print(count)

Submission status: Accepted

Solution code:
n,k = map(int, input().split())
#print(n)
l = []
for i in range(0,2*k): 
  #print('i:',i)
  A = list(map(int, input().split()))
  if i % 2 != 0:
    l.extend(A)
#print(l)
ans = n - int(len(set(l)))
print(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

print(len([i for i,x in enumerate(S) if x==0]))

Submission status: Accepted

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

result = list(range(1,N+1))

for i in range(K):
  d = int(input())
  A_list = list(map(int,input().split()))
  for j in range(len(A_list)):
    if(A_list[j] in result):
      result.remove(A_list[j])

print(len(result))

Submission status: Accepted

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

set_all = set()
for i in range(k):
    input()
    set_all = set_all.union(set(list(map(int, input().split()))))
print(n - len(set_all))

Submission status: Accepted

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

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

for i in range(1,k+1):
  for j in range(len(ai[i-1])):
    if ai[i-1][j-1] in s:
      s.remove(ai[i-1][j-1])
    
print(len(s))

Submission status: Accepted

Solution code:
import math
import collections
#X=int(input())
N,K=map(int,input().split())
# S=[[]for i in range(Q)]
# for i in range(Q):
#     a=list(map(int,input().split()))
#     S[i]=a
# ans=0
# print()
ans=0
b=list()
for i in range(K):
    X = int(input())
    a = list(map(int, input().split()))
    b+=a
for i in range(1,N+1):
    if not i in b:
        ans+=1
print(ans)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
# スペース区切りの整数の入力
N, K = map(int, input().split())
# 文字列の入力
#s = input()
#開業されたN個要素を受け付ける
list=[]
for i in range(K):
    #print(i)
    d=int(input())
    #list.append(list(map(int, input().split())))
    tmp_list = input().split()
    map(int, tmp_list)
    list.append(tmp_list)

#print(list)

ans=0

for i in range(N):
    #print(i+1)
    flg=0
    for j in range(K):
        #print(list[j])
        if str(i+1) in list[j]:
            #print("flg")
            flg = 1
    if flg == 0:
        ans=ans+1

print(ans)

Submission status: Accepted

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

lis = [0] * n

for i in range(k):
    num = int(input())
    dos = list(map(int, input().split()))
    for k in range(num):
        lis[dos[k]-1] += 1

count =0
for p in range(n):
    if lis[p] == 0:
        count += 1
        
print(count)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import numpy as np

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

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

z = np.ones(N)
for i in range(K):
  for j in range(d[i]):
    z[A[i][j]-1] = 0

print(int(z.sum()))

Submission status: Accepted

Solution code:
def main():
    N, K = map(int, input().split())
    children_with_sweets = set()
    for i in range(K):
        d = int(input())
        a = set(map(int, input().split()))
        children_with_sweets = children_with_sweets | a        

    print(N - len(children_with_sweets))

main()

Submission status: Accepted

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

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

for i in range(K):
    d=int(input())
    a=list(map(int,input().split()))
    b=set(sunuke_list)-set(a)
    sunuke_list=list(b)
    
print(len(sunuke_list))

Submission status: Accepted

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

Submission status: Accepted

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

snakes = [[] for i in xrange(n + 1)]

for i in xrange(k):
    s = int(raw_input())
    ns = map(int, raw_input().split())

    for num in ns:
        snakes[num].append(s)

tot = 0
for i in xrange(1, n + 1):
    if not snakes[i]:
        tot += 1
print tot

Submission status: Accepted

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

Submission status: Accepted

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

def RD(): return sys.stdin.read()
def II(): return int(input())
def MI(): return map(int,input().split())
def LI(): return list(map(int,input().split()))
def TI(): return tuple(map(int,input().split()))
def RN(N): return [input().strip() for i in range(N)]


def main():
    N, K = MI()
    d = [0]*K
    A = [0]*K
    for i in range(K):
        d[i] = II()
        A[i] = LI()
    Alist = []
    for i in range(K):
        for j in range(d[i]):
            Alist.append(A[i][j])
    print(N-len(set(Alist)))


if __name__ == "__main__":
	main()

Submission status: Accepted

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

Submission status: Accepted

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

NA = [0] * N

for c in range(M):
    d =  int(input())
    A = input().split()

    for b in A:
        NA[int(b)-1] = 1

ANS = 0

for d in NA:
    if d == 0:
        ANS += 1

print(ANS)

Submission status: Accepted

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

li = []

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

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

Submission status: Accepted

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

ans = [0]*(N+1)

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

res = len(ans)-1-sum(ans)
print(res)

Submission status: Accepted

Solution code:
l=[]

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

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

j=list(range(1,N+1))

a=len(set(l))
b=len(set(j))
print(b-a)

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
list_all=list(range(1,n+1))
for i in range(k):
    num=int(input())
    List=list(map(int,input().split()))
    for j in List:
        if j in list_all:
            list_all.remove(j)

print(len(list_all))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
user_have_sweets = []
for i in range(K):
    __sweets_number = input()
    li = list(map(int, input().split()))
    user_have_sweets.extend(li)

counta = 0
for i in range(1, N+1):
    if i in user_have_sweets:
        pass
    else:
        counta += 1

print(counta)

Submission status: Accepted

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

print(list_A.count(1))

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

print(N - len(set(sum(a,[]))))

Submission status: Accepted

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

Submission status: Accepted

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

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

print(mask.count(False))

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(d):
        L[A[j]-1]+=1
ans=L.count(0)
print(ans)

Submission status: Accepted

Solution code:
import collections
N, K = map(int,input().split())
A_list = []
d_sum = 0
for i in range(K):
  d = int(input())
  d_sum += d
  A = list(map(int,input().split()))
  A_list.extend(A)

c = collections.Counter(A_list)

print(N-len(c))

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
N, K = list(map(int, input().split()))
data = [input().split() for _ in range(K*2)]
all_list = list(range(1,N+1))
have = []
for i in range(0,K):

    have.extend(data[1+2*i])

int_have = [int(n) for n in have]
sethave = list(set(int_have))

ans = list(set(all_list) - set(sethave))
print(len(ans))

Submission status: Accepted

Solution code:
if __name__=='__main__':
    n,k = map(int,input().split())
    have_okasi = [False for i in range(n)]
    for i in range(k):
        d = int(input())
        a = [int(x) for x in input().split()]
        for j in range(d):
            have_okasi[a[j]-1] = True
    print(have_okasi.count(False))

Submission status: Accepted

Solution code:
import sys
from random import choice,randint
inp=sys.stdin.readline
out=sys.stdout.write
flsh=sys.stdout.flush
 
sys.setrecursionlimit(10**9)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]
 
def MI(): return map(int, inp().strip().split())
def LI(): return list(map(int, inp().strip().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines().strip()]
def LI_(): return [int(x)-1 for x in inp().strip().split()]
def LF(): return [float(x) for x in inp().strip().split()]
def LS(): return inp().strip().split()
def I(): return int(inp().strip())
def F(): return float(inp().strip())
def S(): return inp().strip()
def pf(s): return out(s+'\n')
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)

def main():
    n,k=MI()
    dc = dict()
    for i in range(k):
        d = I()
        a = LI()
        for i in range(len(a)):
            if a[i] not in dc:
                dc[a[i]]=1
            else:
                dc[a[i]]+=1
    c=0
    for i in range(1,n+1):
        if i not in dc:
            c+=1
    print(c)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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

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

for i in range(K):
    d = int(input())
    A = [int(_) for _ in input().split()]
    
    for a in A:
        if (a in N_list) == True:
            N_list.remove(a)

print(len(N_list))

Submission status: Accepted

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

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

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


##########
if __name__ == "__main__":
    b()

Submission status: Accepted

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

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


for j in range(1,N+1):
  if AA.count(j) == 0:
    ans += 1

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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


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

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
sunuke = [False for _ in range(N)]
for k in range(K):
    _ = input()
    h = list(map(int, input().split()))
    for i in h:
        sunuke[i-1] = True
print(len([_ for s in sunuke if not s]))