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())
res=set()
ans=0
for i in range(k):
    m=int(input())
    s=list(map(int,input().split()))
    for j in range(m):
        res.add(s[j]-1)
for i in range(n):
    if i not in res:
        ans=ans+1
print(ans)

Submission status: Accepted

Solution code:
import math

N, K = (int(x) for x in input().split())
itazura = [1] * N
total = 0
for i in range(K * 2):
    for x in input().split():
        if i % 2:
            itazura[int(x) - 1] = 0
print(sum(itazura))

Submission status: Accepted

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

sunuke = []
target = []

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


for i in range(1, N+1):
    if i not in sunuke:
        target.append(i)

print(len(target))

Submission status: Accepted

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

print(n - len(b))

Submission status: Accepted

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

Submission status: Accepted

Solution code:

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

    for k in range(K):
        D = int(input())
        d_list = [int(_) for _ in input().split()]
        
        for d in range(D):
            i = d_list[d]
            A[i-1] +=  1

    out = A.count(0)
    print(out)
main()

Submission status: Accepted

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

box = [0]
for i in range(k):
    box = box + a[(i*2 + 1)]
box.remove(0)

c = len(list(set(box)))
print(n - c)

Submission status: Accepted

Solution code:
il1 = [int(k) for k in input().split()]
N = il1[0]
K = il1[1]
A = [0] * (N+1)
A[0] = A[0] + 1
for i in range(K):
    d = int(input())
    tmp_A = [int(k) for k in input().split()]
    for a in tmp_A:
        A[a] = A[a] + 1

print(A.count(0))

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
DD = []
AA = []
for _ in range(K):
  d = int(input())
  DD.append(d)
  A = list(map(int, input().split()))
  a = len(A)
  for i in range(a):
    AA.append(A[i])
AAA = list(set(AA))
aaa = len(AAA)

print(N-aaa)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
n, k = map(int,input().split())
list_people = list(range(1,n+1))
for i in range(k):
    d = int(input())
    list_get = list(input().split())
    for j in range(d):
        if int(list_get[j]) in list_people:
            list_people.remove(int(list_get[j]))
print(len(list_people))

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
# coding: utf-8

def main():
    N, K = map(int, input().split())
    s = dict(zip(range(1, N + 1), [0] * N))
    for _ in range(K):
        _ = input()
        *A, = map(int, input().split())
        for a in A:
            s[a] += 1
    c = len(list(filter(lambda x: x == 0, s.values())))
    print(c)

if __name__ == "__main__":
    main()

Submission status: Accepted

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

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

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

print(cnt)

Submission status: Accepted

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

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

mans = [0 for _ in range(0, N)]
for ds in data:
    for d in ds:
        mans[d-1] = 1

print(len(list(filter(lambda x: x == 0, mans))))

Submission status: Accepted

Solution code:
num = input().split(" ")
people = int(num[0])
kind = int(num[1])
sunuke = []
for i in range(kind):
    have = int(input())
    a = input().split(" ")
    for j in range(have):
        sunuke.append(a[j])
print(people - len(set(sunuke)))

Submission status: Accepted

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

for i in range(K):
  key=input()
  v=input().split()
  v=list(map(int,v))
  
  for j in v:
    count[j-1]+=1

print(count.count(0))

Submission status: Accepted

Solution code:
def main():
  import sys
  input = sys.stdin.readline
  n, k = map(int, input().split())
  d =[]
  a =[]
  all = set(range(1,n+1))
  for i in range(k):
    d.append(int(input()))
    all -= set(map(int, input().split()))
  print(len(all))

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N, K = map(int,input().split())
d = []
A = []
for i in range(K):
  d.append(input())
  A.append(input().split())
count = ['No'] * N


for i in A:
  for j in range(int(d[A.index(i)])):
    for k in range(1, N + 1):
      if int(i[j]) == k:
        count[k-1] = 'OK'
 
print(N - count.count('OK'))

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
a=[]
for i in range(1,(1+(k*2))):
    if i%2==1:
        b=input()
        continue
    else:
        a+=input().split()
print(n-len(set(a)))

Submission status: Accepted

Solution code:
#n=int(input())
#n,m=list(map(int,input().split()))
#a=list(map(int,input().split()))
import math
import itertools
from collections import defaultdict
from collections import Counter
import numpy as np

import heapq


n,k=list(map(int,input().split()))
ans=[True for _ in range(n)]
for _ in range(k):
    c=input()
    a=list(map(int,input().split()))
    for each in a:
        ans[each-1]=False

print(sum(ans))

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
people = set(range(1, N+1))
for i in range(K):
    d = int(input())
    A = map(int, input().split())
    for a in A:
        people.discard(a)
print(len(people))

Submission status: Accepted

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

N = input_line[0]
K = input_line[1]
RESULT = []
count = 0

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


for i in range(N):
    if i + 1 not in RESULT:
        count += 1
print(count)

Submission status: Accepted

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

hoge = []

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

hoge = set(hoge)

print(N-len(hoge))

Submission status: Accepted

Solution code:
N,K=map(int,input().split())
l=list(range(1,N+1))
for i in range(K):
  d=input()
  a =input().split()
  A=list(a)
  AA=[int(n) for n in A]
  l=[i for i in l if i not in AA]
  
print(len(l))

Submission status: Accepted

Solution code:

N, K = [int(x) for x in input().split(" ")]
a = [0] * N
for i in range(K):
    _ = input()
    ls = [int(x)-1 for x in input().split(" ")]
    #print(ls)
    for j in ls:
        a[j] = 1
cnt = 0
for i in a:
    if i == 0:
        cnt += 1
print(cnt)

Submission status: Accepted

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

list = [0] * N

for i in range(1,len(a),2):
    for n in range(len(a[i])):
        x = int(a[i][n])
        list[(x-1)] = 1
        


print(list.count(0))

Submission status: Accepted

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

n, k = map(int, input().split())
a = np.zeros(n)

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

    for j in range(int(d)):
        a[int(temp.split(' ')[j]) - 1] = 1

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

print(count)

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

# print(n,k)
# print(d)
# print(a)

check = [False  for i in range(n)]
# print(check)
for i in range(k):
	for sunuke in a[i]:
		check[sunuke-1] = True

# print(check)
print(len([sunuke for sunuke in range(n) if check[sunuke]==False]))

Submission status: Accepted

Solution code:
N=list(map(int,input().split()))
data=[0]*(N[1]*2)
for n in range(N[1]*2):
    data[n]=list(map(int,input().split()))
sunuke=[0]*(N[0]+1)
sunuke[0]=1
for i in range(N[1]):
    for j in range(len(data[2*i-1])):
        sunuke[data[2*i-1][j]]+=1

ans=0
for k in range(len(sunuke)):
    if sunuke[k]==0:
        ans+=1

print(ans)

Submission status: Accepted

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

print(N - len(have))

Submission status: Accepted

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

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

print(a.count(0))

Submission status: Accepted

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

for i in range(K):
    AA=int(input())
    L=list(map(int,input().split()))
    for j in L:
        D.add(j)

print(N-len(D))

X=set()

Submission status: Accepted

Solution code:
N, K=map(int, input().split())
sunuke=[list(map(str, input().split())) for _ in range(2*K)]
merge=[]
ans=0
for i in range(K):
  merge+=sunuke[2*i+1]
for j in range(1, N+1):
  if str(j) not in merge:
    ans+=1
print(ans)

Submission status: Accepted

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

#print(ans)
l=set(ans)
#print(l)
print(N-len(l))

Submission status: Accepted

Solution code:
N, K = [int(x) for x in input().split()]
s = set()
for i in range(K):
    d = int(input())
    if d == 1:
        s.add(int(input()))
    else:
        for a in input().split():
            s.add(int(a))
ans = sum([a not in s for a in range(1, N+1)])
print(ans)

Submission status: Accepted

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

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

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

for i in range(K):
    for a in A:
        for j in a:
            rs.add(j)

for i in rs:
    s.remove(i)

print(len(s))

Submission status: Accepted

Solution code:

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

d=[0]*k
a=set()
for i in range(k):
    d[i]=int(input())
    if d[i]>1:
        ai=set(map(int,input().split()))
        a=a|ai
    else:
        a.add(int(input()))
    
print(n-len(a))

Submission status: Accepted

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

num = set()

for i in range(k):
  d = int(input())
  tmp = [int(x) for x in input().split()]
  for j in range(d):
    num.add(tmp[j])
  # print(num)

print(n- len(num))

Submission status: Accepted

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

    
print(s.count(0))

Submission status: Accepted

Solution code:
N, K = [int(i) for i in input().split()]
cnt = 0
sunuke_dict = {}
for i in range(1, N+1):
    sunuke_dict[i] = 0
    
while cnt < K:
    cnt += 1
    d = int(input())
    sunuke_list = [int(i) for i in input().split()]
    for sunuke in sunuke_list:
        sunuke_dict[sunuke] = 1

result = [key for key, value in sunuke_dict.items() if value == 0]
print(len(result))

Submission status: Accepted

Solution code:
N,K=input().split()
N=int(N)
K=int(K)
j=0
A=[]
for j in range(K):
    d=int(input())
    B=[int(x) for x in input().split()]
    k=0
    for k in range(d):
        A.append(B[k])
        k+=1
    A=list(set(A))
    j+=1
A=set(A)
a=len(A)
b=N-a
print(b)

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())))
ans=0
s=[]
for h in range(1,n+1):
    for i in range(k):
        for j in range(d[i]):
            if A[i][j] == h:
                if not h in s:
                    ans +=1
                    s.append(h)
    
print(n-ans)

Submission status: Accepted

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

peo=[]

for i in range(K):
    A=int(input())
    su=input().split()
    for k in range(A):
        peo.append(str(su[k]))

peo
print(N-len(set(peo)))

Submission status: Accepted

Solution code:
import itertools
n, k = map(int, input().split())
d = [0]*k
a = [0]*k
for i in range(k):
    d[i] = int(input())
    a[i] = list(map(int, input().split()))
a = list(set(list(itertools.chain.from_iterable(a))))
ans = 0
for i in range(1, n+1):
    if i in a:
        continue
    else:
        ans += 1

print(ans)

Submission status: Accepted

Solution code:
def main():
    n, k = map(int, input().split())
    cnt = [0]*101
    for _ in range(k):
        d = int(input())
        A_i = list(map(int, input().split()))
        for i in range(1, n+1):
            if i not in A_i:
                cnt[i] += 1
    res = 0
    for j in cnt:
        if j == k:
            res += 1
    print(res)

if __name__ == "__main__":
    main()

Submission status: Accepted

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

con = 0
ans = list(int() for _ in range(100000))
pre = 0


for _ in range(K):

    D = int(input())
    arr = list(map(int,input().split()))

    for j in range(D):

        ans[pre+j]=arr[j]

    pre += D

        
fin = (N+1) - len(set(ans))

print(fin)

Submission status: Accepted

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

A = [1 for i in range(N)]
d = [0 for i in range(K)]

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

print(sum(A))

Submission status: Accepted

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

Submission status: Accepted

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

#print(A)
num = A[1::2]
#print(num)
ans = []
for i in range(k):
    ans += num[i]

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

Submission status: Accepted

Solution code:
n , k = map(int ,input().split())
n_all_list = []
cnt = 1
n_cnt = 0
while cnt <= k :
    d_x = int(input())
    n_list = map(int,input().split())
    n_all_list.extend(n_list)
    cnt += 1

set(n_all_list)
n_all_dict = {}
for i in range(1,n + 1):
    n_all_dict[i] = ""

for x in n_all_list :
    n_all_dict[x] = "exsit"

for i in n_all_dict.values():
    if i == "":
        n_cnt += 1

print(n_cnt)

Submission status: Accepted

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

for i in range(k):
    d = int(input())
    okashi_list = list(map(int,input().split()))
    for j in range(d):
        having = okashi_list[j] - 1
        if not hash_list[having]:
            hash_list[having] = True

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

print(count)

Submission status: Accepted

Solution code:
from collections import defaultdict
import sys
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9 + 7
eps = 10**-7


def inp():
    return int(input())


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


N, K = inpl()
tmpl = [0] * N
for k in range(K):
    d = inp()
    aa = inpl()
    for a in aa:
        tmpl[a - 1] += 1

ans = 0
for t in tmpl:
    if t == 0:
        ans += 1
print(ans)

Submission status: Accepted

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

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

Alist = [e for row in A for e in row]
        
L = len(list(set(Alist)))
print(N-L)

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
li = []
for i in range(k):
    d = int(input())
    li.append([d, list(map(int, input().split()))])
c = 0
for i in range(1, n+1):
    for j in li:
        if i in j[1]:
            break
    else:
        c += 1
print(c)

Submission status: Accepted

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

taisho = set()
for j in range(K):
    d = int(input())
    A = [int(x) for x in input().split()]
    for k in range(d):
        if not A[k] in taisho:
            taisho.add(A[k])
cnt = 0
for i in range(N):
    if not i+1 in taisho:
        cnt += 1
print(cnt)

Submission status: Accepted

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

Submission status: Accepted

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

l = [e for row in l for e in row]
l = set(l)

cnt = 0
for i in range(n+1):
    for j in l:
        if i == j:
            cnt += 1

print(n-cnt)

Submission status: Accepted

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

hito = []
max = k*2
for i in range(k*2):
    a = list(map(int,input().split()))
    hito.append(a)

for i in range(k*2):
    if i % 2 == 1:
        h = hito[i]
        for j in h:
            A[j-1] += 1
ans = 0
for i in range(len(A)):
    if A[i] == 0:
        ans += 1
print(ans)

Submission status: Accepted

Solution code:
#! usr/bin python3

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

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

print(d.count(0))

Submission status: Accepted

Solution code:
# coding: utf-8
s = input().split()

n = int(s[0])
k = int(s[1])

treat = []

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

for i in range(k):    
    d = int(input())
    a = input().split()
    
    for j in range(d):
        treat[int(a[j]) - 1] = True
    
res = 0

for i in range(n):
    if not treat[i]:
        res += 1

print(res)

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
#print('N : ' + str(N))
#print('K : ' + str(K))
li = [0 for i in range(N)]

for i in range(0,K): 
  d = int(input())
 # print('')
 # print('d : ' + str(d))
  A = list(map(int, input().split()))
 # print('<A>')
  for j in A:
  #  print(j)
    li[j-1] = 1
sum = 0
#print(li)

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

Submission status: Accepted

Solution code:
N,K = map(int,input().split())
A = [1]*N
import collections
for i in range(K):
  d = int(input())
  check = input().split()
  for j in range(d):
    if A[int(check[j])-1] == 1:
      A[int(check[j])-1] = 0
c = collections.Counter(A)
print(c[1])

Submission status: Accepted

Solution code:
data = input().rstrip().split(" ")
people = int(data[0])
kind = int(data[1])
ans = [i+1 for i in range(people)]
for j in range(kind):
    empty = input()
    have = input().rstrip().split(" ")
    for k in have:
        if int(k) in ans:
            delete = ans.index(int(k))
            del ans[delete]
print(len(ans))

Submission status: Accepted

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

d = []
a = []
res = [0] * n

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

for aa in a:
    for aaa in aa:
        res[aaa - 1] += 1

count = 0

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

print(count)

Submission status: Accepted

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

Submission status: Accepted

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

for i in range(K):
    d = int(input())
    X = [int(i) for i in input().split()]
    A.extend(X)

for i in range(N):
    if A.count(i+1) == 0:
        cnt += 1
print(cnt)

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
b=list(range(1,n+1))
a=[]

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

a=list(set(a))

ans=0
for i in b:
	if not i in a:
		ans += 1

print(ans)

Submission status: Accepted

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

resolve()

Submission status: Accepted

Solution code:
n,k = map(int,input().split())
List = [list(map(int, input().split())) for i in range(2*k)]
List_a = []
for x in range(1,2*k,2):
    for i in List[x]:
        List_a.append(i)

List_a =set(List_a)
print(n-len(List_a))

Submission status: Accepted

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

lists = []
for i in range(k):
    d = input()
    a = input().split()
    lists.extend(a)

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

Submission status: Accepted

Solution code:
n,k = [int(ch) for ch in input().split()]
snuckList = []
for i in range(n):
    snuckList.append(i+1)
for i in range(k):
    cnt = int(input())
    snucks = [int(ch) for ch in input().split()]
    for snuck in snucks:
        if snuck in snuckList: 
            snuckList.remove(snuck)
print(len(snuckList))

Submission status: Accepted

Solution code:
N,K = list(map(int,input().split()))
all_sunuke = set([i for i in range(1,N+1)])
d = [] # お菓子iを持っている人数
A = [] # お菓子iを持っている人のID列
for i in range(K):
    d = int(input())
    A += list(map(int,input().split()))

setA = set(A)
sub = list(all_sunuke - setA)

print(len(sub))

Submission status: Accepted

Solution code:
import itertools
N, K = map(int, input().split())
i=0
dlist=[]
mlist=[]
while(i<K) :
  d = int(input())
  val = input().split()
  dlist.append(d)
  mlist.append(val)
  i+=1
res=0
list=list(itertools.chain.from_iterable(mlist))
if(N==1):
  if(list.count("1")==0):
    res+=1
else:
  j=1
  while(j<=N):
    if(list.count(str(j))==0):
      res+=1
    j+=1
print(res)

Submission status: Accepted

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

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

Submission status: Accepted

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

for _ in range(K):
    d = int(input())
    A = map(int, input().split())
    for a in A:
        earned[a] = earned[a] | 1
else:
    print("%d"%(N-sum(earned)))

Submission status: Accepted

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

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

Submission status: Accepted

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

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

print(count)

Submission status: Accepted

Solution code:
n_k = input().split(' ')

n = [0]*int(n_k[0])
k = int(n_k[1])

for k_ in range(k):
    d = int(input())
    l = input().split(' ')
    for d_ in range(d):
        n[int(l[d_])-1] += 1

count = 0
for i in n:
    if i == 0:
        count += 1

print(count)

Submission status: Accepted

Solution code:
n = list(map(int,input().split()))
m= []
mm= []
nuke = []
for x in range(n[1]):
    m.append(int(input()))
    mm.extend(list(map(int,input().split())))

for i in range(n[0]):
    nuke.append(i+1)

mn = list(set(mm))

for l in range(len(mn)):
    if mn[l] in nuke:
        nuke.remove(mn[l])

print(len(nuke))

Submission status: Accepted

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

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

Submission status: Accepted

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

flat=[flatten for inner in li for flatten in inner]


B=len(flat)


for k in range(N):
        if k+1 in flat:
            pass
        else:
            ans=ans+1
        
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
A = []
ans = [0 for i in range(n)]
an = 0
for i in range(k):
    d = int(input())
    AA = list(map(int, input().split()))
    A[len(A):len(A)] = AA
for num in A:
    ans[num-1] += 1
for n in ans:
  if n == 0:
    an += 1
print(an)

Submission status: Accepted

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

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

sulist = []

for j in range(M):
    K = int(input())
    P = [list(map(int,input().split()))]
    for i in sunuke:
      if i in P[0]:
        sulist.append(i)
print(N-len(set(sulist)))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def do():
    n,m=map(int,input().split())
    num=[]
    k=0
    for i in range(m):
        d=int(input())
        l=list(map(int,input().split()))
        num.extend(l)
    for i in range(1,n+1):
        if i not in num:
            k+=1
    return k


print(do())

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
n, k = map(int, input().split())
data = [list(map(int,input().split())) for i in range(k*2)]
d = data[0::2]
a = data[1::2]
a = ', '.join(map(str, a))
a = a.replace("[","")
a = a.replace("]","")
list_a = list(map(int, a.split(",")))
list_a = list(set(list_a))
ans = n - len(list_a)
print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import deque
import sys
input = sys.stdin.readline

N, K = map(int, input().split())
member_list = []
while input():
    arr = list(map(int, input().split()))
    #t5tygprint(arr)
    member_list.extend(arr)

print(N-len(set(sorted(member_list))))

Submission status: Accepted

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

A = []
for k in range(K):
    d = int(input())
    a = list(map(int, input().split()))
    for x in range(d):
        A.append(a[x])
    
A = list(set(A))
print(N - len(A))

Submission status: Accepted

Solution code:
import os

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

if __name__ == "__main__":
        main()

Submission status: Accepted

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

# okasi = k * [0]
sunuke = n * [0]
ans = 0

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

count = 0
N = 0
K = 0
Check = []

while True:

    try:
        S = input()
        count += 1
    except:
        print(N - sum(Check))
        break
	
    if count > 1 and count % 2 == 1:
      split = S.split()
      for i in range(len(split)):
        Check[int(split[i]) - 1] = True      
      
    if count == 1:
      split = S.split()
      N = int(split[0])
      K = int(split[1])
      for i in range(N):
        Check.append(False)

Submission status: Accepted

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

Submission status: Accepted

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

m = [False] * N

for a in A:
    for aa in a:
        m[aa - 1] = True

print(len([x for x in m if not x]))

Submission status: Accepted

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

np = [0] * n

for i in range(k):
    d = int(input())
    for x in input().split():
        np[int(x) - 1] += 1

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

Submission status: Accepted

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

#intの場合

L, R = map(int,input().split())
dell = set(range(1, L))
answer = set(range(1, L+1))

for x in range(R):
  intA = int(input())
  dell = list(map(int, input().split()))
  
  answer = answer.difference(dell)

print (len(answer))