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())
s=[]
for i in range(K):
    d=int(input())
    a=list(map(int, input().split()))
    for j in range(len(a)):
        s+=[a[j]]
s=set(s)
#print(s)
s=list(s)
#print(s)
s.sort()
#print(s)
print(N-len(s))

Submission status: Accepted

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

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

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

c = 0
for i in d:
    if d[i] == 0:
        c += 1
        
print(c)

Submission status: Accepted

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

d = []
a = []

for i in range(k):
    di = int(input())
    ai = list(map(int, input().split()))
    d.append(di)
    a.append(ai)
dic = {}
for al in a:
    for aln in al:
        if aln not in dic:
            dic[aln] = aln    
print(n-len(dic))

Submission status: Accepted

Solution code:
N,K=[int(i) for i in input().split(" ")]
sunuke=[i for i in range(1,N+1)]
for i in range(K):
    d=[int(input())]
    A=[int(i) for i in input().split(" ")]
    for a in A:
        for i in range(len(sunuke)):
            if sunuke[i]==a:
                del sunuke[i]
                break
print(len(sunuke))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

d=[0]*K
A=[[0]*K]*100
sunuke=[0]*N
count=N

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

print(count)

Submission status: Accepted

Solution code:
N, K = map(int,input().split())
ans = set(range(1,N+1))
for i in range(K):
    d = input()
    tmp = set(map(int,input().split()))
    ans = ans - tmp


print(len(ans))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a=input().split()
N=int(a[0])
K=int(a[1])

d=[]
A=[]
for i in range(K):
    d.append(int(input()))
    A.append([int(x) for x in input().split()])
ans=0
for i in range(1,N+1):
    index=0
    for j in range(K):
        if (i in A[j])==False:
            index+=1
    if index==K:
        ans+=1

print(ans)

Submission status: Accepted

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

okashi = set(list(range(1, n+1)))

for i in range(k):
    d = int(input())
    A = set(map(int, input().split()))
    okashi = okashi - A 
    
print(len(okashi))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import numpy as np
N,K = map(int,input().split())
datas = np.zeros(N)
for i in range(K):
    n = int(input())
    A = list(map(int,input().split()))
    for a in A:
        datas[a-1] += 1
print(np.count_nonzero(datas == 0))

Submission status: Accepted

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

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

print(sunuke.count(1))

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
d_list = []
A_list = []
for i in range(K):
    d_list.append(int(input()))
    A_list += list(map(int, input().split()))

A_list = list(set(A_list))
ans = 0
for A in range(1, N + 1):
    if A not in A_list:
        ans += 1

print(ans)

Submission status: Accepted

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

sunukes = [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):
    sunukes[a[j]-1] = 1

r=0
for sunuke in sunukes:
  if sunuke == 0:
    r+=1

print(r)

Submission status: Accepted

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

for _ in range(k):
    _ = int(input())
    for a in input().split():
        if a in s:
            continue
        else:
            s.add(a)

print(n - len(s))

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

answer_list = [0]*N

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

Submission status: Accepted

Solution code:
N,K = map(int, input().split())
S = [list(map(int, input().split())) for _ in range(K*2)]
T = [True for _ in range(N)]
for i in range(len(S)):
  if i%2 == 1:
    for s in S[i]:
      T[s-1] = False
      
print(sum(T))

Submission status: Accepted

Solution code:
def main():
    n, k = map(int, input().split())
    i = 0
    s = []
    for _ in range(k):
        d = int(input())
        v = map(int, input().split())
        s += list(v)

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


if __name__ == '__main__':
    main()

Submission status: Accepted

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

def main():
    n, k = map(int, input().split())
    okashi = set()
    for i in range(k):
        d = int(input())
        okashi |= set(list(map(int, input().split())))
    print(n - len(okashi))
    
if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

ans=[1]*n

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

Submission status: Accepted

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

c = []
for i in range(N):
    c.append(0)


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

print(c.count(0))

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
d_a = [input() for _ in range(2 * K)]
length = len(d_a)
people = []
answer = []
for i in range(length):
    if i % 2 == 1:
        people.append(d_a[i])

for data in people:
    if len(data) > 1:
        data = data.split()
        for d in data:
            if d not in answer:
                answer.append(d)
    else:
        if data not in answer:
            answer.append(data)

print(N - len(answer))

Submission status: Accepted

Solution code:
import sys
import math
import bisect

def main():
    n, k = map(int, input().split())
    s = set()
    for i in range(1, n + 1):
        s.add(i)
    for i in range(k):
        d = int(input())
        for a in list(map(int, input().split())):
            if a in s:
                s.remove(a)
    print(len(s))

if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
banlist = [False]*N
for k in range(K):
    D = int(input())
    l = list(input().split())
    for i in l:
        if banlist[int(i)-1] == False:
            banlist[int(i)-1] = True
print(banlist.count(False))

Submission status: Accepted

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

for ll in l:
    a = ll[1]
    for sunuke in a:
        treat.append(sunuke)

print(N-len(set(treat)))

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
heh = set()
for x in range(1, n + 1):
    heh.add(x)
for _ in range(k):
     d = int(input())
     heh.difference_update(set(list(map(int, input().split()))))
print(len(heh))

Submission status: Accepted

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

for i in range(k):
  d = int(input())
  m = input().split()
  m_int = [int(s) for s in m]
#  print(d)
#  print(m_int)
  
  for j in range(d):
    s[m_int[j]-1] = 1

for k in range(n):
  if s[k] == 0:
    ans += 1

print(ans)

Submission status: Accepted

Solution code:
N,K=map(int,input().split())
d = [0]*K
A = [[]]*K
ps=[1]*N
for i in range(K):
    d[i] = int(input())
    A[i] = input().split()
    for j in range(len(A[i])):
        A[i][j] = int(A[i][j])


for i in range(K):
    for j in range(d[i]):
        ps[A[i][j]-1]=0

print(sum(ps))

Submission status: Accepted

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

import itertools
d = s[0::2]
a = s[1::2]
a = list(set(list(itertools.chain.from_iterable(a))))

res = []
for i in range(1, n+1):
        if i not in a:
            res.append(i)

print(len(res))

Submission status: Accepted

Solution code:
import math
 
def readInt():
	return int(input())
 
def readInts():
	return list(map(int, input().split()))
 
def readChar():
	return input()

def readChars():
	return input().split()
 
n,k = readInts()
d = []
a = []

for i in range(k):
	d.append(readInt())
	a.append(readInts())

su = [0]*(n+1)

for i in range(1,k+1):
	for j in range(len(a[i-1])):
		su[a[i-1][j]]+=1
print(su.count(0)-1)

Submission status: Accepted

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

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

for i in range(n):
    kashi.append(False)

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

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

print(count)

Submission status: Accepted

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

data = [0] * n

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

    for j, val in enumerate(people):
        tar = val - 1
        data[tar] += 1

ans = 0

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

Submission status: Accepted

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

candy_list = []

for i in range(K):
  d = int(input())
  A = [int(x) for x in input().split()]
  candy_list.append(A)
  
member_list = [0] * N

for k in range(K):
  target_candy = candy_list[k]
  
  for n in target_candy:
    member_list[n-1] += 1

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

print(ans)

Submission status: Accepted

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

sunukes = set()

for i in range(k):
    d = int(input())
    li = input().split()
    for j in range(d):
        sunukes.add(li[j])

print(n - len(sunukes))

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()))
import collections
c=collections.Counter(a)
print(n-len(c))

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 range(d):
        l[a[j]-1] = 0
ans = sum(l)
print(ans)

Submission status: Accepted

Solution code:
n,k = map(int,input().split())
l = list((range(1,n+1)))

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

print (len(l))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
n, k = map(int, input().split())
result = []
for i in range(k):
    okashi = int(input())
    hito = list(map(int, input().split()))
    for j in range(len(hito)):
        if (hito[j] not in result):
            result.append(hito[j])

print(n - len(result))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n, k = list(map(int, input().split(" ")))
t = [0 for i in range(n)]
for i in range(k):
    _ = input()
    for idx in map(int, input().split(" ")):
        t[idx - 1] += 1
print(len(list(filter(lambda x: x == 0, t))))

Submission status: Accepted

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

c = ['1']*n

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

d = c.count('1')

print(d)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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())))
    
ans = [0 for i in range(N)]
for A_k in A:
    for i in A_k:
        ans[i-1] += 1
    
print(ans.count(0))

Submission status: Accepted

Solution code:
"""
>>> main(3, 2, [[2, [1, 3]], [1, [3]]])
1
"""


def main(n: int, k: int, d_a: list):
    snuke = [[] for _ in range(n)]

    for d, a in d_a:
        for _a in a:
            snuke[_a - 1].append(d)

    ans = 0
    for s in snuke:
        if len(s) == 0:
            ans += 1

    print(ans)


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

    d_a = [[int(input()), list(map(int, input().split()))] for _ in range(k)]

    main(n, k, d_a)

Submission status: Accepted

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

li = [0]*N

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

print(li.count(0))

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
N,K = list(map(int , input().split()))
D = []
A= []
for i in range(K):
    d = int(input())
    y = list(map(int, input().split()))
    D.append(d)
    A.extend(y)
S = []
for j in range (N):
    k = A.count((j+1))
    if k == 0:
        S.append(j+1)
print(len(S))

Submission status: Accepted

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

print(sum(tmp))

Submission status: Accepted

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

Submission status: Accepted

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

have = np.ones(N)
for i in range(K):
    d = int(input())
    snack = np.array(list(map(int, input().split())))
    have[snack-1] = 0

# print(have)
print(int(sum(have)))

Submission status: Accepted

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

for i in range(k):
    for j in range(d[i]):
        s[a[i][j] - 1] += 1
        
print(s.count(0))

Submission status: Accepted

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

arr = [0 for i in range(n+1)]
arr[0] = 1

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

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

Submission status: Accepted

Solution code:
n, k = (int(x) for x in input().split())

li = []
for i in range(n):
    li.append(0)

for i in range(k):
    d = int(input())
    a = input().split(" ")
    for num in a:
        li[int(num) - 1] = 1

cnt = 0
for i in li:
    if i == 0:
        cnt += 1

print(cnt)

Submission status: Accepted

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

all_set = set(list(range(1, n+1)))
food_set = set()
for _ in range(k):
    t = input()
    lst = list(map(int, input().split()))
    for num in lst:
        food_set.add(num)
print(len(all_set - food_set))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
sn = [i for i in range(1, n+1)]
sn = set(sn)
l = []
for i in range(k):
    d = int(input())
    mini_l = list(map(int, input().split()))
    l.extend(mini_l)

l = set(l)
ans = len(sn - l)
print(ans)

Submission status: Accepted

Solution code:
# AtCoder Beginner Contest 166: B (2020/05/03)
N, K = map(int, input().split())
A = [0 for i in range(N)]
for j in range(K):
    d = int(input())
    l = input().split()
    for i in range(d):
        A[int(l[i])-1] = A[int(l[i])-1] + 1
ans = 0
for i in range(N):
    if A[i] == 0:
        ans = ans + 1
print(ans)

Submission status: Accepted

Solution code:
from collections import defaultdict
from math import gcd
import time
import sys
from collections import Counter
import itertools
import math
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
start = time.time()
N, K = map(int, input().split(' '))
sunuke = []
for i in range(K):
    d = input()
    sunuke.extend(input().split(' '))


sunuke = set(sunuke)
print(N-len(sunuke))

Submission status: Accepted

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

A = [False]*(N+1)
for i in range(K):
    dk = int(input())
    ad = list(map(int,input().split()))
    for a in ad:
        A[a] = True

count = 0
for a in A[1:]:
    if not a:
       count += 1 

print(count)

Submission status: Accepted

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

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

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

print(len(s))

Submission status: Accepted

Solution code:
date0=input().rstrip().split(" ")
N=int(date0[0])
K=int(date0[1])
list0=[]
for i in range(N):
    list0.append(0)
for j in range(K):
    d=int(input())
    date=input().rstrip().split(" ")
    k=0
    for k in range(d):
        list0[int(date[k])-1]=1
print(list0.count(0))

Submission status: Accepted

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

a = set(sum(a, []))
cnt = 0
for i in range(n):
    if i+1 not in a:
        cnt += 1

print(cnt)

Submission status: Accepted

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

Submission status: Accepted

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

A = set()

for i in range(K):
    d = int(input())
    B = [int(x) for x in input().split()]
    A = A | set(B)

print(N - len(A))

Submission status: Accepted

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

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

Submission status: Accepted

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

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

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

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

print(ans)

Submission status: Accepted

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

a=[]
b=[0]*K
d=[0]*K

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

  
dic = {}

for i in a:
  for j in i:
    dic[j] = 1

#print(dic)
print(N-len(dic))

Submission status: Accepted

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

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

c = collections.Counter(A)

print(N-len(c))

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
people = set()
for _ in range(k):
    _ = input()
    people = people | {int(i) for i in input().split()}

print(n - len(people))

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
cnt = [0]*N
for i in range(K):
    d = int(input())
    A = list(map(lambda x : int(x)-1, input().split()))
    for a in A:
        cnt[a] += 1
ans = 0
for c in cnt:
    if c == 0:
        ans += 1
print(ans)

Submission status: Accepted

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

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

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

print(people.count(0))

Submission status: Accepted

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

for i in range(K):
	for j in A[i]:
		test[j-1] =1
print(N-sum(test))

Submission status: Accepted

Solution code:
N, K = map(int, input().split())			# "5 7" -> ["5", "7"] -> 5, 7 => N=5,K=7

X=[0]*N

for k in range(K):
	d = int(input())
	A =        list( map(int, input().split()) )	# 1 2 3 4 5 ...
	for a in A:
		X[a-1]+=1

print( X.count(0) )

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
by_sweets = {}
for _ in range(k):
    d = int(input())
    a_list = list(map(int, input().split()))
    for a in a_list:
        by_sweets.setdefault(a, 0)
        by_sweets[a] += 1


print(n - len(by_sweets))

Submission status: Accepted

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

g = [1 for _ in range(n)]
for ai in a:
  for aii in ai:
    aii -= 1
    g[aii] = 0
print(sum(g))

Submission status: Accepted

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

    print(N - len(Sunuke))

if __name__ == "__main__":
    main()
    pass

Submission status: Accepted

Solution code:
#input
N, K = map(int, input().split())
B = {i:0 for i in range(N)}

for i in range(K):
    d = int(input())
    A = list(map(int, input().split()))
    for a in A:
        B[a-1] += 1
#output
answer = 0
for j in B.values():
    if j == 0:
        answer += 1

print(answer)

Submission status: Accepted

Solution code:
k = list(map(int, input().split()))
listA=[]
while True:
    try:
        listA.append(list(map(int,input().split())))
    except:
        break;
l = []
m = 0
for i in listA:
  if m % 2 == 1:
    l.append(i)
  m += 1
flat = sum(l, [])
import collections
c = collections.Counter(flat)

print(k[0] - len(c))

Submission status: Accepted

Solution code:


def solve():
    hm = {}
    for i in a:
        if not str(i) in hm:
            hm[str(i)] = 1
    print(n - len(hm))
    return



n, k = [int(s) for s in input().split(" ")]
d = []
a = []
for i in range(k):
    d.append(int(input()))
    a.extend([int(s) for s in input().split(" ")])
solve()

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
ans=0
for i in snuke:
    if i==0:
        ans+=1
print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
'''
.append(要素) リストに要素を追加
.extend(リスト) リストを連結する
.insert(場所,要素) 指定した場所に要素追加
del 配列名[場所]
-1で末尾で末尾から一つ前

sort()
sorted(reverse=true)

配列の初期化
配列名=[a]*n+[b]*m

Decimal()
'''

from sys import stdin
from itertools import accumulate, dropwhile, takewhile, groupby
import bisect
import copy
import math
from functools import reduce
from operator import mul
from collections import Counter
import itertools
import fractions

t = stdin.readline().rstrip().split()
n = int(t[0])
k = int(t[1])
res = []
for el in range(k):
    tt = int(stdin.readline().rstrip())
    person = [int(s) for s in stdin.readline().rstrip().split()]
    for el3 in person:
        res.append(el3)
count = 0
for el in range(1, n + 1):
    if not (el in res):
        count += 1
print(count)

Submission status: Accepted

Solution code:
N,K = map(int,input().split())
A = [list(map(int,input().split())) for i in range(K*2)]
A_ = [A[i] for i in range(len(A)) if i%2 == 1]
# print(A_)
sunuke = [0]*N
# print(sunuke)
for i in range(K):
    kasi = A_[i]
    for j in range(len(kasi)):
        s = kasi[j]-1
        if sunuke[s] == 0:
            sunuke[s] = 1
print(N-sum(sunuke))

Submission status: Accepted

Solution code:

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

l = []
for i in range(k):
    k = int(input())
    l += map(int,input().split())

x = len(set(l))
print(n - x)

Submission status: Accepted

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

d = {}

for i in range(m):
    input()
    L = list(map(int,input().split()))
    #print(L)
    for j in L:
        d[j] = j

#print(d)
print(n - len(d))

Submission status: Accepted

Solution code:
from sets import Set

N, K = map(int, raw_input().split())
snukes = Set()
for k in range(K):
	raw_input()
	snukes.update(Set(map(int, raw_input().split())))
print N - len(snukes)

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

flat_list = [s for a in A for s in a]
set_a = set(flat_list)
ans = 0

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

print(ans)

Submission status: Accepted

Solution code:
import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush, nlargest, nsmallest
from math import ceil, floor, gcd, fabs, factorial, fmod, sqrt, inf, log
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
# sys.setrecursionlimit(pow(10, 6))
# sys.stdin = open("input.txt", "r")
# sys.stdout = open("output.txt", "w")
mod = pow(10, 9) + 7
mod2 = 998244353
def data(): return sys.stdin.readline().strip()
def out(*var, end="\n"): sys.stdout.write(" ".join(map(str, var))+end)
def l(): return list(sp())
def sl(): return list(ssp())
def sp(): return map(int, data().split())
def ssp(): return map(str, data().split())
def l1d(n, val=0): return [val for i in range(n)]
def l2d(n, m, val=0): return [l1d(n, val) for j in range(m)]


n, k = sp()
graph = dd(set)
for i in range(k):
    d = int(data())
    arr = l()
    for j in arr:
        graph[j].add(i+1)
answer = 0
for i in range(1, n+1):
    if len(graph[i]) == 0:
        answer += 1
out(answer)