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 i in range(d):
        s.append(a[i])
        
t = sorted(s)
a = len(t)
x = n

for i in range(n):
    for k in range(a):
        if i + 1 == t[k]:
            x -= 1
            break
        elif i + 1 < t[k]:
            break
        
print(x)

Submission status: Accepted

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

table = [0] * N
for _ in range(K):
  num = int(input())
  have_list = list(map(int, input().split()))
  for child in have_list:
    table[child-1] += 1

print(str(table.count(0)))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

#print(C)
print(C.count(0)-1)

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
from collections import Counter
import itertools
n, k = map(int, input().split())
d = []
sunuke = []
for i in range(k):
    d.append(int(input()))
    sunuke.append(list(map(int, input().split())))

new = list(itertools.chain.from_iterable(sunuke))

c = Counter(new)

print(n - len(c))

Submission status: Accepted

Solution code:
n,k=map(int,input().split());s={*range(1,-~n)}
for _ in range(k):
 input();s-={*map(int,input().split())}
print(len(s))

Submission status: Accepted

Solution code:
n,k=map(int,input().split());s=set(range(1,-~n))
for _ in range(k):
 input();s-=set(map(int,input().split()))
print(len(s))

Submission status: Accepted

Solution code:
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):
  sunuke[a[j]-1]+=1
  
ninnzuu=0

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

Submission status: Accepted

Solution code:
# 166 B
N, K = list(map(int, input().split()))
A = []
for i in range(K):
    d = int(input())
    a = []
    if d > 1:
        a = list(map(int, input().split()))
        A.extend(a)
    else:
        A.append(int(input()))
        
print(N - len(set(A)))

Submission status: Accepted

Solution code:
# coding=utf-8

if __name__ == '__main__':
    N, K = map(int, input().split())

    sunuke = [0] * N
    #print(sunuke)

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

        for j in range(D):
            sunuke[li[j] - 1] += 1
            #print(sunuke)

    print(sunuke.count(0))

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

# お菓子を持っている人を数える。すると持っていない人間は、Nから持っている人の数を引いたもの
l = [0]*N
for i in range(K):
  for j in range(D[i]):
    l[A[i][j]-1] = 1

print(N - sum(l))

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

# 各人ごとに、持っているお菓子の個数を数え、個数0の人数を出力する
l = [0]*N
for i in range(K):
  for j in range(D[i]):
    l[A[i][j]-1] +=1

print(l.count(0))

Submission status: Accepted

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

has_snack = [False]*N

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

print(sum([1 for h in has_snack if h == False]))

Submission status: Accepted

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

treat = [0] * N

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

print(treat.count(0))

Submission status: Accepted

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

for i in range(k):
    d=int(input())
    A+=list(map(int,input().split()))
    list(set(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 = map(int, input().split())
d = [0] * K
A = [] 
for i in range(K):
	d[i] = int(input())
	A += list(map(int, input().split()))
answer = N -len(list(set(A)))

print(answer)

Submission status: Accepted

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

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

for members in A:
    for member in members:
        sunuke[member - 1] = 1

print(N - sum(sunuke))

Submission status: Accepted

Solution code:
N,K = map(int,input().split())
d = [0 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()))
su_list = [i for i in range(1,N+1)]
for i in range(K):
    for j in range(d[i]):
        if A[i][j] in su_list:
            su_list.remove(A[i][j])        
print(len(su_list))

Submission status: Accepted

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

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 a in A:
    L[a-1] = 0
print(sum(L))

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 = set()
ans = 0
for i in range(K) :
    for j in range(len(A[i])) :
        a.add(A[i][j])

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
n,k = map(int, input().split())
s=[[0] * k for i in range(n)]
for i in range(k):
  input()
  l=list(map(int, input().split()))
  for j in range(len(l)):
    s[l[j]-1][i]=1

r=0
for i in range(n):
  if sum(s[i])==0:
    r=r+1
print(r)

Submission status: Accepted

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

for _ in range(k):
    d = int(input())
    A = list(map(int, input().split()))
    for a in A:
        have[a-1] = True

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

print(ans)

Submission status: Accepted

Solution code:
n,k = [int(x) for x in input().split()]
d = []
a = []
for i in range(k):
  d.append(int(input()))
  a.append([int(x) for x in input().split()])
#print(a)
ans = [0] * (n + 1)
for i in range(k):
  for j in range(d[i]):
    #print(a[i][j])
    ans[a[i][j]] += 1
c = 0
for i in range(1,n + 1):
  if ans[i] == 0:
    c += 1
print(c)

Submission status: Accepted

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

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

AAA = list(set(AAA))

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

a = AAA + AA
ANS = len([i for i in list(set(a)) if a.count(i) == 1])

print(ANS)

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
count = [0] * n
for _ in range(k):
    kosu = int(input())
    pos = list(map(int, input().split()))
    for i in pos:
        count[i-1] +=1
ans = [True if i == 0 else False for i in count]
print(sum(ans))

Submission status: Accepted

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

Submission status: Accepted

Solution code:

def main():
    n, k = map(int, input().split(" "))
    s =set()
    for i in range(k):
        _ = input()
        a = list(map(int, input().split(" ")))
        for j in range(len(a)):
            s.add(a[j])
    print(n - len(s))

if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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

l = []
for _ in range(k):
  d = int(input())
  a = list(map(int,input().split()))
  l.extend(a)
  l = list(set(l))

print(n - len(l))

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,k = map(int,input().split())
temp = [False for i in range(n)]
for i in range(k):
    x = int(input())
    y = list(map(int,input().split()))
    for j in y:
        if not temp[j-1]:
            temp[j-1] = True

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

Submission status: Accepted

Solution code:
N ,K = map(int ,input().split())
num = set()
for i in range(K):
    d = input()
    num.update(int(x) for x in input().split())

sum = 0
for k in num:
    sum += 1
print(N-sum)

Submission status: Accepted

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

for i in range(int(k)):
    num = int(input())
    sweet = input().split()
    for j in range(num):
        sw = int(sweet[j])
        l.append(sw)

l = list(set(l))

ass = len(l)

ans = n - ass

print(ans)

Submission status: Accepted

Solution code:
a,b=map(int,input().split())
e=[]
for _ in range(b):
  c=int(input())
  d=list(map(int,input().split()))
  for i in d:
    e.append(i)

f=set(e)
print(a-len(f))

Submission status: Accepted

Solution code:
a,b=map(int,input().split())
e=[]
for _ in range(b):
    c=int(input())
    d=list(map(int,input().split()))
    for i in d:
        e.append(i)

f=set(e)
print(a-len(f))

Submission status: Accepted

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

li = []
for i in range(k) :
  gomi = input()
  [li.append(int(j)) for j in input().split()]
st = set(li)
  
print(n - len(st))

Submission status: Accepted

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

li = []
for i in range(k) :
  gomi = input()
  [li.append(int(j)) for j in input().split()]
st = set(li)
  
ans = 0
for i in people :
  if not i in st :
    ans += 1
print(ans)

Submission status: Accepted

Solution code:
if __name__ == '__main__':
    N, K = map(int, input().split())
    have_snack = []
    for i in range(K):
        n = int(input())
        have_snack.extend(list(map(int, input().split())))
    ans = N - len(set(have_snack))
    print(ans)

Submission status: Accepted

Solution code:
import itertools
n,k = map(int, input().split())
di = [0] * k
Ai_di = []
for i in range(k):
    di[i] = int(input())
    Ai_di.append(list(map(int, input().split())))
ans_set = set(list(itertools.chain.from_iterable(Ai_di)))
print(n - len(ans_set))

Submission status: Accepted

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

Submission status: Accepted

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

    for a in A:
        cnts[a-1] += 1
cnt = 0
for c in cnts:
    if c == 0:
        cnt += 1
print(cnt)

Submission status: Accepted

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

for i in range(1,n+1):
    if i not in l:
        cnt+=1

print(cnt)

Submission status: Accepted

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

m = [0]*n

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

print(m.count(0))

Submission status: Accepted

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

d=[]
a=[]

for i in range(k):
  p=int(input())
  d.append(p)
  q=list(map(int,input().split()))
  a.append(q)

c=list(itertools.chain.from_iterable(a))
c.sort()

c_set=set(c)
c=list(c_set)

print(n-len(c))

Submission status: Accepted

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

for _ in range(K):
    d = int(input())
    A = map(int, input().split())
    for x in A:
        S[x-1] = True

print(sum(1 for x in S if not x))

Submission status: Accepted

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

for i in range(k):
  d = int(input())
  p = list(map(int,input().split()))
  for j in p:
    list1.append(j)
    
count = 0
for m in range(1,n+1):
  if m not in list1:
    count += 1
    
print(count)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
from itertools import chain
# import numpy as np
# from itertools import combinations as comb
# from bisect import bisect_left, bisect_right, insort_left, insort_right
# from collections import Counter


def solve(N, A):
    sunukes = [1 for _ in range(N)]
    for a in A:
        for i in a:
            sunukes[i-1] = 0
    return sum(sunukes)

def main():
    N, K = map(int, input().split())
    A = []
    for k in range(K):
        _ = int(input())
        A.append(list(map(int, input().split())))

    answer = solve(N, A)



    print(answer)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

for k in range(K):
    d = int(input())
    S = list(map(int, input().split()))
    for s in S:
        okasi[s - 1] = 0

print(sum(okasi))

Submission status: Accepted

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

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

Submission status: Accepted

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

S = [0] * N

for _ in range(K):
    snack = int(input())
    snukes = [int(v) for v in input().split()]
    for snuke in snukes:
        S[snuke-1] = 1

print(sum(x == 0 for x in S))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    nk = [int(_x) for _x in input().split()]
    N = nk[0]
    K = nk[1]

    snuke = [True]*N

    for i in range(K):
        input()
        aa = [int(_x) for _x in input().split()]
        for a in aa:
            snuke[a-1] = False
    print(sum(snuke))


main()

Submission status: Accepted

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

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

print(sum([1 if x == 0 else 0 for x in xs]))

Submission status: Accepted

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

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

Submission status: Accepted

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

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

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

    print(ans)

main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n, k = [int(i) for i in input().split()]
cnt = n
cnt_ = [0] * n
for _ in range(k):
  d = int(input())
  a = [int(i) for i in input().split()]
  for j in a:
    if cnt_[j - 1] == 0:
      cnt -= 1
      cnt_[j - 1] = 1
print(cnt)

Submission status: Accepted

Solution code:
from collections import defaultdict

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

d = defaultdict(int)

for i in range(K):
    _ = int(input())
    A = [int(x) - 1 for x in input().split()]
    for j in range(len(A)):
        d[A[j]] += 1

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

Submission status: Accepted

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

A = set()

for _ in range(K):
    input()
    A |= set(input().split())

print(N - len(A))

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
sunuke_set = set(i for i in range(1, n + 1))

for i in range(k):
    d = int(input())
    sunuke_tuple = tuple(map(int, input().split()))
    for sunuke in sunuke_tuple:
        sunuke_set.discard(sunuke)

print(len(sunuke_set))

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
sunuke_set = set(i for i in range(1, n + 1))

for i in range(k):
    d = int(input())
    sunuke_list = list(map(int, input().split()))
    for sunuke in sunuke_list:
        sunuke_set.discard(sunuke)

print(len(sunuke_set))

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

l = [1]*N
for i in range(K):
  for j in range(d[i]):
    l[A[i][j]-1] = 0
    
print(sum(l))

Submission status: Accepted

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

sunuke = [0]*(N+1)
for i in range(K):
  okashi_category = input()
  #print (okashi_category)
  if okashi_category ==1:
    sunuke[input()]=1
  else:
    sunukelist = list(map(int,input().split()))
    for j in range(len(sunukelist)):
      #print(sunukelist[j])
      sunuke[sunukelist[j]]=1

print (N-sum(sunuke))

Submission status: Accepted

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

for i in range(1,K+1):
  d=int(input())
  A=list(map(int,input().split()))
#  print(A)
  for j in A:
#    print(j)
    if S[j]==1:
      S[j]=0
      
Ans=sum(S)
print(Ans)

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
n_list = []
a_int_all = []
for i_n in range(1, n + 1):
    n_list.append(i_n)
for i in range(0, k):
    d_k = input()
    a_int_k = list(map(int, input().split()))
    a_int_all.extend(a_int_k)
n_only = set(a_int_all)
ans = n - len(n_only)
print(ans)

Submission status: Accepted

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

l=set()

for i in range(k):
    input()
    l = l | set(map(int,input().split()))

print(n-len(l))

Submission status: Accepted

Solution code:
def resolve():
    N, K = list(map(int, input().split()))
    snacks = [0 for _ in range(N)]
    for i in range(K):
        d = int(input())
        A = list(map(int, input().split()))
        for a in A:
            snacks[a-1] += 1
    cnt = 0
    for s in snacks:
        if s == 0:
            cnt += 1
    print(cnt)

if '__main__' == __name__:
    resolve()

Submission status: Accepted

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

judge = [True] * n
for i in range(k):
    j = int(input())
    A = list(map(int,input().split()))
    for a in A:
        judge[a-1] = False

print(judge.count(True))

Submission status: Accepted

Solution code:
import numpy as np
N, K = map(int,input().split())
B = []
C = np.zeros(N)
e = 0
for i in range(K):
  d = int(input())
  A = list(map(int,input().split()))
  for j in range(1, N + 1):
    B.append(A.count(j))
  for k in range(N):
    C[k] += B[k] 
  B = []
for l in range(N):
  if C[l] == 0:
    e += 1
print(e)

Submission status: Accepted

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

# すぬけ君は全員お菓子を持っていないと仮定する
list_snuke = [str(i) for i in range(1, n + 1)]

# お菓子をもっているすぬけ君の番号を削除
# appendではなくリスト内包表記で書きたい
for i in range(0, k):
     d = int(input())
     a = [s for s in input().split()]
     for j in range(0, d):
         if a[j] in list_snuke:
             list_snuke.remove(a[j])

# お菓子をもっていないすぬけ君の人数を出力
print(len(list_snuke))

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
d = [0]*K
A = []
for i in range(K):
    d[i] = int(input())
    A.append(list(map(int, input().split())))
ans = 0
for i in range(1,N+1):
    got = False
    for j in A:
        for k in j:
            if i == k:
                got = True
    if not got:
        ans += 1
print(ans)

Submission status: Accepted

Solution code:
def main():
    n, k = map(int, input().split())
    d_lst = [0 for _ in range(k)]
    a_lst = [0 for _ in range(k)]

    for i in range(k):
        d_lst[i] = int(input())
        a_lst[i] = list(map(int, input().split()))

    snuke_lst = [0 for _ in range(n)]

    for i in range(k):
        for a in a_lst[i]:
            snuke_lst[a - 1] = 1

    ans = n - sum(snuke_lst)

    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

flag = [0] * n
for i in range(int(len(okashi) / 2)):
    i = 2 * i + 1
    for j in okashi[i]:
        flag[j-1] = 1
count = 0
for i in flag:
    if i == 0:
        count += 1

print(count)

Submission status: Accepted

Solution code:
#B
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)
A_all=[]
for i in A:
    for j in i:
        A_all.append(j)
A_set=list(set(A_all))
print(N-len(A_set))

Submission status: Accepted

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

for i in range(k): 
    d=int(input()) 
    a=list(map(int,input().split())) 
    for j in range(d): 
        if a[j] in data: 
            data.remove(a[j]) 
        else: 
            pass 
print(len(data))

Submission status: Accepted

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

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

Q = list(set(num))
print(n-len(Q))

Submission status: Accepted

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

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

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

print(ans)

Submission status: Accepted

Solution code:
n = input()
n = n.split()
k = int(n[1])
n = int(n[0])
c = [0]
for f in range(n-1):
  c.append(0)
for b in range(k):
  d = int(input())
  a = input()
  a = a.split()
  for e in range(d):
    c[int(a[e])-1] = 1
h = 0
for g in range(n):
  if c[g] == 0:
    h = h + 1
print(h)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
L=[list(map(int, input().split())) for i in range(2*k)]
X=[]
for i in range(1,2*k,2):
  X.extend(L[i])
x=0
print(n-len(set(X)))

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
S = [i+1 for i in range(N)]
H = [0 for i in range(N)]
for i in range(K):
    d = int(input())
    A = list(map(int, input().split()))
    for j in A:
        for k in S:
            if j==k:
                H[k-1] += 1

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N,M=list(map(int,input().split()))
si=[0]*N
ans=0
for i in range(M):
    S=int(input())
    who=list(map(int,input().split()))
    for k in range(S):
        si[who[k]-1]+=1
for h in range(N):
  if si[h]==0:
    ans+=1
print(ans)

Submission status: Accepted

Solution code:
# coding: UTF-8
import sys
import numpy as np



n,k = map(int, input().split())
ansList = [False for _ in range(n+1)]

for _ in range(k):
	input()
	tmpList = list(map(int, input().split()))
	for person in tmpList:
		ansList[person] = True

print(ansList.count(False) - 1)

Submission status: Accepted

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

while k>0:
    d = int(input())
    b = input().split()
    for e in b:
        a[int(e)-1] = False
    k-=1
print(sum(a))

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N,K = list(map(int, input('').split(' ')))
D = set()
for i in range(K):
  input('')
  D |= set(map(int, input('').split(' ')))
print(N-len(D))

Submission status: Accepted

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

Submission status: Accepted

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

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

for i in range(len(S)):
    if S[i]==0:
        b+=1
print(b)

Submission status: Accepted

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

for i in range(K):
    d.append(int(input()))
    holders = list(map(int, input().split()))
    for holder in holders:
        have.append(holder)
print(N - len(set(have)))

Submission status: Accepted

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

for i in range(K):
    d.append(int(input()))
    holders = list(map(int, input().split()))
    for holder in holders:
        if holder not in have:
            have.append(holder)
print(N - len(have))

Submission status: Accepted

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

Submission status: Accepted

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

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

sets = set(lists)
ans = n - len(sets)
print(ans)

Submission status: Accepted

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

import sys

input = iter(sys.stdin.read().splitlines()).__next__


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

S = set(list(range(1, N+1)))
for k in range(K):
   d = int(input())
   A = list(map(int, input().split()))
   for x in A:
      if x in S:
         S.remove(x)

print(len(S))

Submission status: Accepted

Solution code:
r=input().split()
N=int(r[0])
K=int(r[1])
d=[input().split() for i in range(2*K)]
d_2=[]
d_ans=[0]*N
for i in range(2*K):
    d_pre=[int(s) for s in d[i]]
    d_2.append(d_pre)
for i in range(2*K):
    if i%2==0:
        for j in range(d_2[i][0]):
            d_ans[d_2[i+1][j]-1]=1
print(d_ans.count(0))

Submission status: Accepted

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

Submission status: Accepted

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

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

count = 0
for i in range(1,N +1,1):
	if okasi[i] != 1:
		count = count + 1
print(count)

Submission status: Accepted

Solution code:
import math
import numpy as np
import sys
import os
from operator import mul

sys.setrecursionlimit(10**7)

def _S(): return sys.stdin.readline().rstrip()
def I(): return int(_S())
def LS(): return list(_S().split())
def LI(): return list(map(int,LS()))

if os.getenv("LOCAL"):
    inputFile = basename_without_ext = os.path.splitext(os.path.basename(__file__))[0]+'.txt'
    sys.stdin = open(inputFile, "r")
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353    

N,K = LI()
s = set()
for i in range(K):
    _ = I()
    s.update(LI())

print(N-len(s))