Problem:


Score : 200 points

Problem Statement

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

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

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

Constraints

All values in input are integers.

1 \leq N \leq 100

1 \leq K \leq 100

1 \leq d_i \leq N

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

Input

Input is given from Standard Input in the following format:

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

Output

Print the answer.

Sample Input 1

3 2
2
1 3
1
3

Sample Output 1

1

Snuke 1 has Snack 1.

Snuke 2 has no snacks.

Snuke 3 has Snack 1 and 2.

Thus, there will be one victim: Snuke 2.

Sample Input 2

3 3
1
3
1
3
1
3

Sample Output 2

2



Sample input:
3 2
2
1 3
1
3


Sample output:
1

Submission status: Accepted

Solution code:
import logging

logging.basicConfig(level=logging.INFO, format="%(message)s")
#logging.disable(logging.CRITICAL)

def main():
    N, K = map(int, input().split())
    N_list = [1 for x in range(N)]
    s_list = [x for x in range(1, N)] 
    
    for i in range(K):
        di = int(input())
        A_i = list(map(int, input().split()))
        for j in A_i:
            N_list[j - 1] = 0

    print(N_list.count(1))
    
if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
Q = input().split(" ")
N = int(Q[0])
K = int(Q[1])
A = {}
ss = 0
for i in range (N):
  A[str(i +1)] = 0
for i in range(K):
  a = int(input())
  b = input().split(" ")
  for j in range(a):
    A[b[j]] = 1
    #print(b[j])

#print(A)

for v in A.values():
  #print(v)
  if v == 0:
    ss += 1
print(ss)

Submission status: Accepted

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

for i in range(K):
    _ = input()
    a = input().split()
    for j in a:
        snk[int(j)-1] = 0

print(sum(snk))

Submission status: Accepted

Solution code:
def main():
    n,k = (int(x) for x in input().split())
    ans = []
    for i in range(k):
        d = int(input())
        A = [int(x) for x in input().split()]
        ans += A
    ans = set(ans)
    print(n-len(ans))

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import itertools

def main():
  n, k = map(int, input().split())
  d_li = []
  a_li = []
  for i in range(k):
    d_li.append(int(input()))
    a_li.append(list(map(int, input().split())))

  res = itertools.chain(*a_li)
  res = list(res)
  print(n-len(list(set(res))))

if __name__ == '__main__':
  main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

l = [1] * N

for i in range(K):
  a=input()
  A = list(map(int, input().split()))
  for j in A:
    l[j-1]=0
print(sum(l))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
list_d_i = []
for i in range(K):
	d = int(input())
	list_d_i.extend(list(map(str, input().split())))

import collections as c

cnt_l = c.Counter(list_d_i)

print(N-len(cnt_l.keys()))

Submission status: Accepted

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

Submission status: Accepted

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

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

B = set(A)
print(a[0]-len(B))

Submission status: Accepted

Solution code:
from sys import stdin
import sys
import math

N, K = list(map(int, stdin.readline().rstrip().split()))

d = []
A = []
n = {}
for i in range(K):
    d.append(int(input()))
    #A.append(stdin.readline().rstrip().split())
    tmp = list(map(int, stdin.readline().rstrip().split()))
    A.append(tmp)
    for a in tmp:
        n[a] = 1

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

print(count)

Submission status: Accepted

Solution code:
N,K=map(int,input().split())
A=[]
for i in range(2*K):
  A.append(input().split())
B=list(A[1::2])
C=[]
for i in range(K):
  C+=B[i]
  
print(N-len(list(set(C))))

Submission status: Accepted

Solution code:
def main():

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

    print(l.count(0))

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
NK=list(map(int,input().split()))
a=[]
for _ in range(NK[1]):
    NUM=input()
    oyatsyumochi=list(map(int,input().split()))
    a.extend(oyatsyumochi)

have=set(a)

ans=NK[0]-len(have)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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


b=[int(i) for i in range(1,n+1)]


for i in range(k):
    d = int(input())
    a =[int(x) for x in input().split()]
           
    for j in (a):
        if j in b:
            b.remove(j)

print(len(b))

Submission status: Accepted

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

N = NK[0]
K = NK[1]

Ad = [list(map(int,input().split())) for l in range(K*2)]

A = []

for i in range(1,len(Ad)+1,2):
    A.extend(Ad[i])
    
set_A = set(A)

members = []

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

set_M = set(members)

print(len(set_M - set_A))

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
# ==B==
N, K = map(int, input().split())
acc = set()
for i in range(1, K+1):
	# loop for snack_i
	_ = int(input())
	for A in map(int, input().split()):
		acc.add(A)
print(N-len(acc))

Submission status: Accepted

Solution code:
import math as m

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

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

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

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

print(ans)

Submission status: Accepted

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

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


a=[]
for i in range(1,N+1):
    if i in s:
        pass
    else:
        a.append(i)

print(len(a))

Submission status: Accepted

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

ans = n

person = []
have = []

for i in range(k):
  person.append(int(input()))
  have.append(input().split())

import itertools
have = list(itertools.chain.from_iterable(have))
sunuke = (list(range(1, n+1)))

have = list(map(int, have))

for j in range(len(have)):
  if have[j] in sunuke:
    sunuke.remove(have[j])

print(len(sunuke))

Submission status: Accepted

Solution code:
from collections import Counter
N, K = map(int, input().split())
list=[]
for _ in range(1,K+1):
    d = int(input())
    S = input().split()
    list.extend(S)
num = Counter(list)
print(N-len(num))

Submission status: Accepted

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

Submission status: Accepted

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

for i in range(K):
  n=int(input())
  l=input().split()
  for j in range(n):
    k=int(l[j])
    list[k-1]=1
print(list.count(0))

Submission status: Accepted

Solution code:
ninzu,okashi=map(int,input().split())
okashimochi=[list(map(int,input().split())) for i in range(okashi*2)]
for i in range(0,okashi,1):
    del okashimochi[i]
okashininzu=sum(okashimochi,[])
print(ninzu-len(set(okashininzu)))

Submission status: Accepted

Solution code:
N,M=map(int,input().split())
i = 0
B_list = []
for i in range(M):
    d = int(input()) # nは入力回数
    A = list(map(int,input().split()))
    B_list = B_list + A
C = N - len(set(B_list))
print(C)

Submission status: Accepted

Solution code:
N,K = map(int,input().split())
D = []
A = []
for k in range(1,K+1):
    d = int(input())
    D.append(d)
    a = list(map(int, input().split()))
    for n in a:
        A.append(n)

for i in range(1,N+1):
    x = A.count(i)
    if x >= 2:
        for n in range(1,x):
            A.remove(i)

print(N - len(A))

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
A_dict = {i: [] for i in range(1, N + 1)}

sunuke_have_not_okashi = 0

okashi = 0
for _ in range(K):
    okashi += 1
    d = input()
    A = map(int, input().split())
    for a in A:
        A_dict[a].append(okashi)


for i in sorted(A_dict.items(), key=lambda x: len(x[1])):
    if i[1]:
        break
    sunuke_have_not_okashi += 1

print(sunuke_have_not_okashi)

Submission status: Accepted

Solution code:
n,k = map(int,input().split())
sunuke = list(range(1,n+1))
i = 0
kashi_sunuke = []
d = ''
while i < k:
  d = input()
  okashi = list(map(int,input().split()))
  kashi_sunuke += okashi
  i+=1

o = list(set(sunuke) - set(kashi_sunuke))
print(len(o))

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
x=[]
for i in range(k):
    hoge=int(input())
    c=[int(e) for e in input().split()]
    for j in range(hoge):
        x.append(c[j])
x=set(x)
print(n-len(x))

Submission status: Accepted

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

for i in range(k):
    d[i] = int(input())
    A[i] = [0]*d[i]
    A[i] = input().split(' ')
    for j in range(d[i]):
        A[i][j] = int(A[i][j])
N = []
for a in range(n):
    N.append(a+1)

def check(A,n,k):
    for i in range(k):
        for j in range(len(A[i])):
            if A[i][j] in N:
                N.remove(A[i][j])

check(A,n,k)
print(len(N))

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
lst=[0]*n
for i in range(k):
  d=int(input())
  #snackはお菓子を受け取る人のリスト
  snack=list(map(int,input().split()))
  for j in snack:
    lst[j-1]+=1
    
print(lst.count(0))

Submission status: Accepted

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

B = [0]*N

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

print(B.count(0))

Submission status: Accepted

Solution code:
s = input().split();
import sys;

n = int(s[0]);
k = int(s[1]);
count = [];
cnt = 0;
for i in range(n):
    count.append(False);

for i in range (k):
    d = int(input());
    num = list(map(int,input().split()));
    for i in range(d):
        count[num[i] - 1] = True;

for i in range(n):
    if(count[i] == False):
        cnt += 1;

print(cnt);

Submission status: Accepted

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

i = 0
dd = []
aa = []
for d in I:
	if (i % 2) == 0:
		dd.append(d)
	else:
		aa.append(d)
	i += 1
    
zz = [0 for i in range(N)]

for ii in aa:
    for i in ii:
        zz[i - 1] = 1
ans = 0
for i in zz:
    if (i == 0):
        ans += 1
print(ans)

Submission status: Accepted

Solution code:
import itertools

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 = list(itertools.chain.from_iterable(A))
A = list(set(A))
kotae = N - len(A)
print(kotae)

Submission status: Accepted

Solution code:
def d():
    s = input()
    count = 0
    for i in range(1, 60):
        ans = 2019 * i
        if '0' not in str(ans):
            count += 1
            print(i, ans)

    print(count)

def c():
    n = int(input())
    s = ['']*n
    for i in range(n):
        s[i] = input()
    s.sort()
    count = 1
    for i in range(1, n):
        if s[i - 1] != s[i]:
            count += 1
    print(count)

def b():
    n, k = map(int, input().split())
    check = [0] * n
    for i in range(k):
        input()
        for j in list(map(int, input().split())):
            check[j - 1] = 1
    print(check.count(0))
    


def a():
    s = input()
    if s == 'ABC':
        print('ARC')
    else:
        print('ABC')



b()

Submission status: Accepted

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

for i in range(k):
    snu|=set(nu[i])

print(n-len(snu))

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
list_sunuke = [0]*N #list初期化

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

Submission status: Accepted

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

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

l = []
for j in range (k):
    l.append(grid[0+2*j+1])

lis = list(itertools.chain.from_iterable(l))

count = 0
for m in range(n):
    if m+1 in lis:
        count = count +1
print(n - count)

Submission status: Accepted

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

d = []
A = []

count = []
ans = 0

for i in range(K*2):
  if i % 2 == 0:
    d.append(int(input()))
  else:
    tmp = list(map(int,input().split()))
    for j in range(1,N+1):
      if j in tmp:
        count.append(j)

for k in range(1,N+1):
  if k not in count:
    ans = ans + 1

print(ans)

Submission status: Accepted

Solution code:
import itertools

n, k = (int(x) for x in input().split())
okashi_count_list = []
okashi_snuke_list = []
l = [0] * n

for i in range(k * 2):

    if i % 2 == 0 :
        okashi_count_list.append(list(map(int,input().split())))
    else :
        okashi_snuke_list.append(list(map(int,input().split())))

# print(okashi_count_list)
# print(okashi_snuke_list)

# 1次元に変換
okashi_snuke_list = list(itertools.chain.from_iterable(okashi_snuke_list))
# 重複を削除
okashi_snuke_list = set(okashi_snuke_list)

l_n_str = [str(n) for n in okashi_snuke_list]

# print('lの長さ')
# print(len(l))

for e in l_n_str:
    # print(e)

    # print('l[e]')
    # print(l[int(e) - 1])

    l[int(e) - 1] = 1

count = 0

for e in l:
    if e == 0 :
        count = count + 1

print(count)

Submission status: Accepted

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

Submission status: Accepted

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

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

cnt = 0
for i in range(n):
    if (dl.count(i+1) == 0):
        cnt += 1

print(cnt)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import numpy as np

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

d = [0] * k
A = [0] * k

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

list = []
for i in range(k):
    for j in range(d[i]):
        list.append(A[i][j])

count = 0
for i in range(1, n+1):
    if not i in list:
        count += 1

print(count)

Submission status: Accepted

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

noTrick=[]

for ik in range(k):

    d =int(input())
    ad = list(map(int,input().split() ))
    for id in range(d):
        for iad in ad:
            noTrick.append(iad)
#   print("aaaa:",k,id,ad)

print( n -  len(set(noTrick)))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,k=map(int, input().split())
i=1
okashi_kazu=[]
okashi_hito=[]
okashi_hito2=[]
for i in range(1,2*k+1):
  if i%2==0:
    okashi_hito.extend(input().split())
  else:
    okashi_kazu.append(input().split())

okashi_hito2=set(okashi_hito)
print(n-len(okashi_hito2))

Submission status: Accepted

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

print(nlist.count(0))

Submission status: Accepted

Solution code:
from collections import Counter

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

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

lst = Counter(num for sublst in A for num in sublst)
allLst = [0] * N
for sunuke, cnt in sorted(lst.items(), key=lambda x: x[0]):
	allLst[sunuke - 1] = cnt

print(allLst.count(0))

Submission status: Accepted

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

array = []

s = 0
for i in range(k):
  d = int(input())
  array += list(map(int, input().strip().split()))

array = set(array)

for j in range(1,n+1):
  if j not in array:
    s += 1
print(s)

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

ans = 0

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

print(ans)

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
ml=[int(i) for i in range(1,n+1)]
while k>0:
    mm=int(input())
    ll=list(map(int,input().split()))
    result=list(set(ml)-set(ll))
    ml=result
    k-=1
print(len(ml))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

for i in range(K):
    d[i] = int(input())
    a = list(map(int, input().split()))
    for j in range(len(a)):
        A[a[j]-1][i] = 1
    
for i in range(N):
    if sum(A[i]) == 0:
        n += 1

print(n)

Submission status: Accepted

Solution code:
N, K=map(int, input().split())
set_okashi=set()
for i in range(K):
    d=int(input())
    list_d=[i for i in input().split()]
    for j in list_d:
        set_okashi.add(j)
print(N-len(set_okashi))

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
sunuke=[[]]*n
for i in range(k):
    d=int(input())
    lid=list(map(int, input().split()))
    for i2 in range(d):
        if d not in sunuke[lid[i2]-1]:
            sunuke[lid[i2]-1]=sunuke[lid[i2]-1] + [d]
ans=0
for item in sunuke:
    if item==[]:
        ans+=1
print(ans)

Submission status: Accepted

Solution code:
n,k = map(int,input().split())
l1 = list(range(1,n+1))
for i in range(k):
    d = input()
    l2 = list(map(int,input().split()))
    for num in l2:
        if num in l1:
        	l1.remove(num)
print(len(l1))

Submission status: Accepted

Solution code:
NK = input().split()
N = int(NK[0])
K = int(NK[1])
Moratta = []
 
for i in range(0, K):
    D = int(input())
    A = input().split()
    for j in A:
      if j in Moratta:
        continue
      else:
        Moratta.append(j)

sunuke_count = len(Moratta)
result = N-sunuke_count
print(result)

Submission status: Accepted

Solution code:
N, K = list(map(int,input().split()))
C = []
for _ in range(K):
  d = int(input())
  A = list(map(int,input().split()))
  for i in range(len(A)):
    C.append(A[i])
NC = []
for a in range(1,N+1):
  if a <= N and a not in C:
    NC.append(a)
print(len(NC))

Submission status: Accepted

Solution code:
nk = input().split()
NK =[int(x) for x in nk]
t = []
s = []
for i in range(1 ,NK[0]+1):
	s.append(i)
for i in range(1,NK[1]+1):
    d = int(input())
    A =  input().split()
    a = [int(x) for x in A]
    t += a
set_t = set(t)
set_s = set(s)
r = set_s - set_t
print(len(r))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
sunuke_list = [1] * N
for j in range(K):
  D = int(input())
  D_list = list(map(int, input().split()))
  for i in D_list:
    sunuke_list[i - 1] = 0
print(sum(sunuke_list))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import sys
import os
from collections import Counter

n,k = [int(p) for p in input().split()]

a = []
d = []
c = []
for i in range(k):
    d.append(int(input()))
    s = input()
    a.append([int(p) for p in s.split()])
    c.extend([int(p) for p in s.split()])

total = 0

for i in range(1,n+1):
    x = c.count(i)
    #print(i, x)
    if x == 0:
        total += 1

print(total)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N, K = map(int, readline().split())
lst = []
for _ in range(K):
    d = int(readline())
    lst += list(map(int, readline().split()))

x = N - len(set(lst))
print(x)

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
#2020-05-03
n, k = map(int, input().split())
lst = []
cou = 0
for i in range(k):
    a = int(input())
    lst = lst + input().split()
    set(lst)
for j in range(1, n+1):
    if str(j) not in lst:
        cou += 1
print(cou)

Submission status: Accepted

Solution code:
n,k = map(int,input().split())
ls = [0 for p in range(k)]
new = [0 for q in range(k)]
for i in range(k):
    ls[i] = int(input())
    new[i] = list(map(int,input().split()))
for l in range(1,k):
    new[0] = new[0] + new[l]
c = len(set(new[0]))
print(n-c)

Submission status: Accepted

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

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

for i in range(k):
    _ = input()
    bx = [ int(x) - 1 for x in input().split() ]

    for b in bx:
        have[b] += 1

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

Submission status: Accepted

Solution code:
import numpy as np
# coding: utf-8
# Your code here!
N, K = map(int, input().split())
#S = input()
Ai_list = []
 
for i in range(K):
    di = int(input())
    Ai_list += input().split()
 
#print(Ai_list)
print(N - len(set(Ai_list)))

Submission status: Accepted

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

D = []
E = []
for i in range(k):
    d = int(input())
    D.append(d)
    F = list(int(x) for x in input().split())
    E.append(F)

count = []
for i in E:
    for j in i:
        count.append(j)

number = set(count)

apple = list(number)

counter = 0
for i in range(1, n + 1):
    if i in apple:
        pass
    else:
        counter += 1

print(counter)

Submission status: Accepted

Solution code:
N,K=map(int,input().split())
D=[]
A=set()
for i in range(K):
	D.append(int(input()))
	A=A|set(map(int,input().split()))
length=len(A)
print(N-length)

Submission status: Accepted

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

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

for i in range(K):
    for j in range(d[i]):
            if A[i][j] in person:
                person.remove(A[i][j])

print(len(person))

Submission status: Accepted

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

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

C=[0]*N
for i in range(0,K*2,2):
  d=A[i][0]
  for j in range(d):
    C[A[i+1][j]-1]+=1
    
print(C.count(0))

Submission status: Accepted

Solution code:
# coding: utf-8
N, K = map(int, input().split(' '))

R = []
for i in range(N):
    R.append(i + 1)
    
for i in range(K):
    d = input()
    A = list(map(int, input().split(' ')))
    for j in range(len(A)):
        try:
            R.remove(A[j])
        except ValueError:
            pass

print(len(R))

Submission status: Accepted

Solution code:
N,K = map(int, input().split())
sunuke_list = [str(i+1) for i in range(N)]
d_list = []
A_list = []
t_list = []

for j in range(K):
  d_list.append(input())
  A_list.append(input().split())
  
t_list = list(set(sunuke_list) - set(A_list[0]))
for j in range(K-1):
  t_list = list(set(t_list) - set(A_list[j+1]))
  
print(len(t_list))

Submission status: Accepted

Solution code:
import numpy as np
n,k = map(int,input().split())
#li = []
#append = li.append
#for i in range(n):
#    append(i+1)
#print(li)
alist = []
for i in range(k):
    d = int(input())
    a = list(map(int,input().split()))
    for j in a:
        alist.append(j)

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

Submission status: Accepted

Solution code:
n, k = list(map(int, input().split()))
# a, b, c = list(map(int, input().split()))
a = []
for i in range(k*2):
    a.append(list(map(int, input().split())))

count = 0
have = [0]*n
for i in range(k*2):
    if i % 2 != 0:
        for j in range(len(a[i])):
            have[a[i][j]-1] += 1

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

Submission status: Accepted

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

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

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

for i in range(0, N):
    for j in range(0, len(A_row)):
        if check[i] == A_row[j]:
            check[i] = 'None'

for i in range(0, len(check)):
    if check[i] != 'None':
        count += 1
print(str(count))

Submission status: Accepted

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

Submission status: Accepted

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

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

print(N - len(mark.keys()))

Submission status: Accepted

Solution code:
# B - Trick or Treat
n,k = map((int),(input().split()))

sunuke = [0]*n

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

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

print(sum)

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
S = [input().split() for _ in range(K*2)]
new_list = []
for i in range(5):
    S.append([])
S.append([])
for i in range(1,len(S)-2,2):
    for j in S[i]:
        new_list.append(j)

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

Submission status: Accepted

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

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

c = collections.Counter(l)

print(N-len(c))

Submission status: Accepted

Solution code:
R = lambda: map(int, input().split())
n, k = R()
s = set()
for _ in range(k):
  input()
  s.update(R())
print(n - len(s))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
lis = input().split()
N = int(lis[0])
K = int(lis[1])
lis = list(range(N+1))

for i in range(K):
    d = int(input())
    A = input().split()
    #print("d=",d,"A=",A)
    for j in range(d):
        if int(A[j]) in lis:
            lis.remove(int(A[j]))

print(len(lis) - 1)

Submission status: Accepted

Solution code:
import numpy as np
N, K = map(int, input().split())
N_lis=np.zeros(N)
for i in range(K):
    d=int(input())
    sweet=np.array(list(map(int, input().split())))
    #print(sweet)
    sweet-=1
    for j in sweet:
        N_lis[j]+=1
#print(N_lis)
no_sweet=N_lis==0
#print(no_sweet)
print(no_sweet.sum())

Submission status: Accepted

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

Submission status: Accepted

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