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())
ans = {i+1 : 0 for i in range(n)}
for i in range(k):
    d = int(input())
    a = [int(x) for x in input().split()]
    for i in a:
        ans[i] += 1
print(len([i for i in ans.values() if i == 0]))

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

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

print(ans)

Submission status: Accepted

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

print(n-len(set(A)))

Submission status: Accepted

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

b = [False for _ in range(n)]

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

for bb in b:
    if(bb == False):
        ans += 1
        
print(ans)

Submission status: Accepted

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

A = [0] * n

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

Submission status: Accepted

Solution code:
n,k = map(int,input().split())
li1 = []
li2 = [0]*n
for i in range(n):
    li2[i] = i+1
for i in range(k):
    a = input()
    b = [int(j) for j in input().split()]
    for j in range(len(b)):
        li1.append(b[j])
print(len(set(li1) ^ set(li2)))

Submission status: Accepted

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

lst = [0] * N

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

print(lst.count(0))

Submission status: Accepted

Solution code:
a = 1;
treat = 0;
n, k = map(int, input().split());

data = [input().split() for l in range(2*k)]


while a <= n:
    b = 0;
    d = 0;
    
    while b < k:
        search = int(data[2*b][0]);
        c = 0;
        
        while c < search:
            x = int(data[2*b+1][c]);
            if x == a :
                d = d + 1;
            c = c + 1
            
        b = b + 1;
        
    if d == 0:
        treat = treat + 1;
        
    a = a + 1;

print(treat);

Submission status: Accepted

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

Submission status: Accepted

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


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    n, k = map(int, input().split())
    aset = set()
    for _ in range(k):
        d = int(input())
        a = set(map(int, input().split()))
        aset = aset.union(a)
    print(n - len(aset))


if __name__ == "__main__":
    main()

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()])
loop = 0
count = 0
for i in range(N):
	bool = 0
	for j in range(K):
		for k in range(d[j]):
			if A[j][k] == i+1:
				bool = 1
#			print([i,j,k,bool])
	if bool == 0:
		count = count + 1
print(count)

Submission status: Accepted

Solution code:
def main():
    N,K = [int(x) for x in input().split()]
    snack_sunuke = []
    for a in range(K):
        di = int(input())
        for i in [int(x) for x in input().split()]:
            snack_sunuke.append(i)
    print(N - len(set(snack_sunuke)))

if __name__ == '__main__':
    main()

Submission status: Accepted

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

sunuke = set()
for i in range(K):
  d = int(input())
  A = set(map(int, input().split()))
  sunuke = sunuke | A
ans = N - len(sunuke)
print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
has_snack = set()
for i in range(K):
    d = int(input())
    A = list(map(int, input().split()))
    for a in A:
        has_snack.add(a)
ans = 0
for i in range(1, N + 1):
    if i not in has_snack:
        ans += 1
        
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

xs = [0] * N
for rs in A:
    for r in rs:
        xs[r - 1] += 1

result = sum(x == 0 for x in xs)

print(result)

Submission status: Accepted

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

for i in range(K):
	d = int(input())
	A = list(map(int,input().split()))
	for i in range(d):
		X[A[i]-1] = True
		
print(X.count(False))

Submission status: Accepted

Solution code:
import numpy as np
n, k = input().split(" ")

A = np.zeros((int(k), int(n)))
for i in range(int(k)):
    _ = input()
    for j in input().split(" "):
        A[i-1,int(j)-1] = 1
print(np.sum((np.sum(A, axis=0) == 0)))

Submission status: Accepted

Solution code:
a,b = map(int,input().split())
ans_li = [0 for x in range(a)]

for i in range(b):
  d = int(input())
  l = list(map(int, input().split()))
  for ll in l:
      ans_li[ll-1] += 1
print(ans_li.count(0))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
li=[]
for i in range(k):
  d=int(input())
  l=input().split()
  for j in range(d):
    if l[j] not in li:
      li.append(l[j])
print(n-len(li))

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
ans=[0]*n #0がn個ある配列(すぬけ君の配列)

for i in range(k): #k種類のお菓子を順に見て行く
    d=int(input())  #参照しなくていい数
    a=list(map(int,input().split()))
    for j in a:    #そのお菓子を持っていれば配列の要素を1にする
        ans[j-1]=1 #すぬけ君0はいないので配列の番値は-1にならない

print(n-sum(ans)) #(全集合)-(お菓子を持っている人)
                  #n-(0+1+1+1+0+0+...)

Submission status: Accepted

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

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
li = []
for i in range(k):
  d = int(input())
  sunuke = input().split()
  for j in range(d):
    if int(sunuke[j]) not in li:
      li.append(int(sunuke[j]))
print(str(n - len(li)))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
S = []
for i in range(K):
    d = input()
    for j in input().split():
        if j not in S:
            S.append(j)

print(N - len(S))

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!

N, K = map(int, input().split())
dummy, ans = 0, 0
array, sarray = [], []
for i in range(K):
    dummy = int(input())
    array += list(map(int, input().split()))
sarray = set(array)

for j in range(1, N + 1):
    if j in sarray:
        pass
    else:
        ans += 1
print(ans)

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())))
    
aa=[0]*N
counts=0

#リストaの中からk番目のリストを取り出す（k自体もリスト）
for k in a:
    for j in k:
        aa[j-1]+=1
        
for x in aa:
    if x==0:
        counts+=1

print(counts)

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())))
    
aa=[0]*N
counts=0

for k in a:
    for j in k:
        aa[j-1]+=1
        
for x in aa:
    if x==0:
        counts+=1

print(counts)

Submission status: Accepted

Solution code:
N,K = map(int,input().split())
D = []
A = []
for k in range(K):
    D.append(int(input()))
    A.append([int(i) for i in input().split()])
P = [True for i in range(N)]
for a in A:
    for aa in a:
        P[aa-1] = False
print(sum(P))

Submission status: Accepted

Solution code:
n,k = map(int,input().split())
a = list(input() for nesya in range(2*k))
t = 1
b =[]
for hoge in a:
  if t%2 == 0:
    b += list(hoge.split())
  t += 1
c = set(b)
ans = n - len(c)
print(ans)

Submission status: Accepted

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

snuke = [0]*N
for AA in A:
    for a in AA:
        snuke[a-1]+=1

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

Submission status: Accepted

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

for i in range(k):
  dummy = int(input())
  ans = map(int, input().split())
  list.extend(ans)

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
se = set()
for i in range(K):
    d = int(input())
    A = list(map(int, input().split()))
    for a in A:
        se.add(a-1)
ans = 0
for i in range(N):
    if not i in se:
        ans += 1
print(ans)

Submission status: Accepted

Solution code:
import numpy

N, K = map(int,input().split()) 
P = [list(map(int, input().split())) for i in range(2 * K)]
flatten = lambda x: [z for y in x for z in (flatten(y) if hasattr(y, '__iter__') else (y,))]

print(N - len(set(flatten(P[1::2]))))

Submission status: Accepted

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

print(n - len(set(count)))

Submission status: Accepted

Solution code:
# B

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

sunuke = [1] * N

for i in range(K):
    di = int(input())
    tmp = map(int, input().split())
    for t in tmp:
        sunuke[t-1] = 0
print(sum(sunuke))

Submission status: Accepted

Solution code:
# B

inp = input().split(' ')
N, K = int(inp[0]), int(inp[1])

sunuke = [1] * N

for i in range(K):
    di = int(input())
    tmp = map(int, input().split())
    for t in tmp:
        sunuke[t-1] = 0
print(sum(sunuke))

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 a in A:
        sunuke[a-1] += 1

print(sunuke.count(0))

Submission status: Accepted

Solution code:
n,k=[int(i) for i in input().split()]
arr=[0 for i in range(n+1)]
ans=n
for i in range(k):
  d=int(input())
  s=[int(i) for i in input().split()]
  for i in s:
    if arr[i]==0:
      arr[i]=1
      ans-=1
print(ans)

Submission status: Accepted

Solution code:
def resolve():
	n, k = map(int, input().split())
	s = [False]*n
	for i in range(k):
		input()
		for j in list(map(int, input().split())):
			s[j-1] = True
	print(s.count(False))
resolve()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
def main():
    # 人数N,おかし種類K
    num_list = list(map(int, input().split()))
    N = num_list[0]
    K = num_list[1]

    # 全員登録したリストを用意しておく
    list1 = [int(s) for s in range(1,N+1,1)]

    for _ in range(K):
        # おかしiを持ってる人数
        d = int(input())
        # おかしiを持ってる人リスト
        listA = list(map(int, input().split()))

        for i in listA:
            # お菓子持ってる人を見つけたら除去
            if i in list1: list1.remove(i)

    print(len(list1))

main()

Submission status: Accepted

Solution code:
N, K = [int(n) for n in input().split(' ')]
dic = {}
for i in range(1, N+1):
  dic[i] = 0
for i in range(K):
  d = int(input())
  A = [int(n) for n in input().split(' ')]
  for j in A:
    dic[j] += 1

ans = 0

for i in dic.keys():
  if dic[i] == 0:
    ans += 1

print(ans)

Submission status: Accepted

Solution code:
def B():
    n, k = list(map(int, input().split()))
    a = []
    for i in range(2*k):
        ipt = input()
        if i%2==1:
            a += list(map(int, ipt.split()))
    a = set(a)
    res = set(range(1, n+1)) - a 
    print(len(res))
B()

Submission status: Accepted

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

dic={}

for i in range(k):
    d=int(input())
    al=list(map(int,input().split()))
    for a in al:
        dic[a]=True
ans=0
for i in range(1,n+1):
    if dic.get(i,0)==0:
        ans+=1
print(ans)

Submission status: Accepted

Solution code:
import numpy as np

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

cnt = np.array(list([0]*n))

for _ in range(k):
    d = int(input())
    a = np.array(list(map(int, input().split())))
    for i in a:
        cnt[i-1] += 1

print(np.count_nonzero(cnt==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())))
s = [0] * n
for ai in a:
    for i in range(len(ai)):
        s[ai[i] - 1] += 1
ans = 0
for si in s:
    if si == 0:
        ans += 1
print(ans)

Submission status: Accepted

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

for i in range(K):
    _ = input()
    
    A = set(map(int, input().split()))
    
    x |= A
    
print(N-len(x))

Submission status: Accepted

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

ans = set()
for _ in range(K):
    input()
    s = set(map(int, input().split()))
    ans |= s

print(N-len(ans))

Submission status: Accepted

Solution code:
whatMan = []

N, K = input().split()
for i in range(int(K)):
    input()
    whatMan.extend(input().split())
print(int(N) - len(set(whatMan)))

Submission status: Accepted

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

Submission status: Accepted

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

	d.append(int(input()))
	a.extend(list(map(int,input().split())))
x=0    
for s in range(1,n+1):
	if s not in a:
		x+=1
        
print(x)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
N,K=map(int, input().split())
kosu = []
for i in range(N):
  kosu.append(0)
for i in range(K):
  d = int(input())
  A=list(map(int, input().split()))
  for t in range(d):
    kosu[A[t]-1] += 1
print(len([1 for x in kosu if x==0]))

Submission status: Accepted

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

import collections
import itertools

# print(*data)
data = list(itertools.chain.from_iterable(data))
# print(*data)
data = list(set(data))
# print(*data)
print(n - len(data))

# l = ['a', 'a', 'a', 'a', 'b', 'c', 'c']
# c = collections.Counter(l)
# print(c)
# Counter({'a': 4, 'c': 2, 'b': 1})

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
#ANSlist = [1]*(N)
ANSlist = []
ANS = 0

for i in range(K):
    I = input() #
    S = input().split()
    #print(ANSlist)
    for j in range(len(S)):
        if S[j] != " ":
            #ANSlist[int(S[j])-1] = 0
            if not S[j] in ANSlist:
                ANSlist.append(S[j])
                
            


'''for i in range(len(ANSlist)):
    if ANSlist[i] != 0:
        ANS += 1'''
ANS = N - len(ANSlist)
print(ANS)

Submission status: Accepted

Solution code:
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    import itertools
    n,k=map(int, input().split())
    sunukel=[False]*n
    for i in range(k):
        d=int(input())
        l=list(map(int, input().split()))
        for j in l:
            if sunukel[j-1]==False:
                sunukel[j-1]=True
    print(n-sum(sunukel))
resolve()

Submission status: Accepted

Solution code:
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    import itertools
    n,k=map(int, input().split())
    sunukel=[0]*n
    for i in range(k):
        d=int(input())
        l=list(map(int, input().split()))
        for j in l:
            sunukel[j-1]+=1
    print(sunukel.count(0))
resolve()

Submission status: Accepted

Solution code:
N,K=[int(s) for s in input().split()]
snuke=[0 for _ in range(N)]
for i in range(K):
  a=int(input())
  ls=[int(s) for s in input().split()]
  for e in ls:
    snuke[e-1]+=1
ans=0
for e in snuke:
  if e==0:
    ans+=1
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

arr=[]
arr1=[]
for i in range(1, N+1):
  arr1.append(i)

for i in range(K):
  d=input()
  A=list(map(int, input().split()))
  arr = arr+A
print(len(set(arr1) - set(arr)))

Submission status: Accepted

Solution code:
import sys
     
n, k = map(int, sys.stdin.readline().split())
     
snukes = [1] * n
     
for _ in range(k):
  n = int(sys.stdin.readline())
  nums = list(map(int, sys.stdin.readline().split()))
  for num in nums:
    snukes[num - 1] = 0

print(sum(snukes))

Submission status: Accepted

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

ans = [L for L in Su if len(L) == 0]
ans = len(ans)
print(ans)

Submission status: Accepted

Solution code:
def solve():
    n,k=map(int,input().split())
    A=[0 for i in range(n)]
    for i in range(k):
        d=int(input())
        di=list(map(int,input().split()))
        for ele in di:
            A[ele-1]+=1
    count=0
    for i in range(n):
        if(A[i]==0):
            count+=1
    print(count)
solve()

Submission status: Accepted

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

okashi = {}
for i in range(k):
    d = int(input())
    a_list = input().split()
    for a in a_list:
        if not a in okashi:
            okashi[a] = True

print(n - len(okashi))

Submission status: Accepted

Solution code:
def main():
    n, k = list(map(int, input().split()))
    sunukes = [0] * n
    for _ in range(k):
        d_tmp = int(input())
        aList = list(map(int, input().split()))
        for a in aList:
            sunukes[a-1] += 1
    print(sunukes.count(0))


if __name__ == '__main__':
    main()

Submission status: Accepted

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

ans = []

for i in range(k*2):
  x = input().split()
  if 1 == i % 2:
    for j in range(len(x)):
      if int(x[j]) not in ans:
        ans.append(int(x[j]))

print(n - len(ans))

Submission status: Accepted

Solution code:
N,K = map(int, input().split())
A = []
for i in range(0,K):
    d = int(input())
    array = list(map(int, input().strip().split()))
    A.extend(array)
ans = sorted(set(A), key=A.index)
print(N-len(ans))

Submission status: Accepted

Solution code:
import numpy as np
N, K = map(int, input().split())
judge = np.zeros(N)
for k in range(K):
  d = int(input())
  A = input().split()
  for i in range(d):
    judge[int(A[i])-1] += 1
print(np.sum(judge==0))

Submission status: Accepted

Solution code:
# B - Trick or Treat

n, k = map(int, input().split())
safe = set()  # お菓子を持っているすぬけ
for i in range(k):
    d = int(input())
    a = list(map(int, input().split()))
    assert len(a) == d
    safe.update(a)

print(n - len(safe))

Submission status: Accepted

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

sun_lst = [0] * n
for i in range(k):
    d = d_lst[i]
    a = a_lst[i]

    for j in range(d):
        sun = a[j]
        sun_lst[sun-1] = 1

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

print(ans)

Submission status: Accepted

Solution code:
a,b = map(int,input().split())
aaa = [list(map(int,input().split())) for i in range(b*2)]

c = set()
e = set([i for i in range(1,a+1)])
for i in range(1,len(aaa),2):
  for k in aaa[i]:
     e.discard(k)

print(len(e))

Submission status: Accepted

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

si = [1]*n
di = [0]*k
ai = [0]*k
#di[0] = int(input())
#ai = [int(j) for j in input().split()]

for l in range(k):
    #print(l)
    d = int(input())
    di[l] = d
    a = [int(m) for m in input().split()]
    #ai[l] = a
    for o in range(len(a)):
        if (si[a[o-1]-1] == 1):
            si[a[o-1]-1] = 0

print(sum(si))

Submission status: Accepted

Solution code:
a,b = map(int,input().split())
aaa = [list(map(int,input().split())) for i in range(b*2)]

c = set()
e = set()
for i in range(1,len(aaa),2):
  for k in aaa[i]:
     c.add(k)
    
print(a - len(c))

Submission status: Accepted

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

Submission status: Accepted

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

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

have_sunuke = []

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

print(len(set(all_sunuke) - set(have_sunuke)))

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
i = 0
a = list()
d = 0
while i<k:
    d += int(input())
    a += (map(int, input().split()))
    i += 1
i=0

b = [0]*n
while i<d:
    b[a[i]-1]=1
    i+=1

i=0
ans = 0
while i<n:
    if b[i] ==0:
        ans += 1
    i+=1

print(ans)

Submission status: Accepted

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

nukes = set()
for i in range(K):
    int_snacks = int(input())
    
    nukes.update(list(map(int,input().split())))
    # print(nukes)

print(str(N-len(nukes)))

Submission status: Accepted

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

Submission status: Accepted

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

O=[1]*N
for i in range(K):
  d=int(input())
  for j in map(int,input().split()):
    O[~-j]=0
print(sum(O))

Submission status: Accepted

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

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

print(N - len(X))

Submission status: Accepted

Solution code:
#n, m, q = map(int, input().split())
#List = list(map(int, input().split()))

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

print(sunuke.count(0))

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

Submission status: Accepted

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

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 a:
        sunuke[j-1]+=1

print(sunuke.count(0))

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
lists=[]
for _ in range(k):
  d=int(input())
  lis=list(map(int,input().split()))
  lists.append(lis)
ans=[0]*n
for list in lists:
  for i in range(len(list)):
    ans[list[i]-1]+=1
count=0
for h in ans:
  if h==0:
    count+=1
print(count)

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()))
    for i in range(d):
        l.append(a[i])

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# B - Trick or Treat

n, k = map(int, input().split())
safe = set()  # お菓子を持っているすぬけ
for i in range(k):
    d = int(input())
    a = list(map(int, input().split()))
    assert len(a) == d
    safe.update(a)

x = sum(1 for s in range(1, n+1) if s not in safe)
print(x)

Submission status: Accepted

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

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

for i in range(K):
    di = int(input())
    tmp = [int(t)-1 for t in input().split()] # int(t)-1 することでインデックス調整
    for t in tmp:
        sunuke[t] = 0
print(sum(sunuke))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N_nin, K_ko = map(int, input().split())

sunuke = []

for i in range(K_ko):
    d = int(input())
    
    A = list(map(int, input().split()))
    
    for a in A:
        sunuke.append(a)


ans = N_nin - len(set(sunuke))

print(ans)

Submission status: Accepted

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

# B - Trick or Treat
n, k = map(int, input().split())
sunukes = [0] * (n + 1)

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

ans = 0

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
p = [0]*n
for _ in range(k):
    _ = input()
    items = list(map(int, input().split()))
    items = [x-1 for x in items]
    for i in items:
        p[i] += 1

print(p.count(0))

Submission status: Accepted

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

import itertools

n, k =map(int, input().split())
A = []
for i in range(k):
    d = int(input())
    A.append(list(map(int, input().split())))
A = list(itertools.chain.from_iterable(A))
print(n-len(set(A)))

Submission status: Accepted

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

print(y.count(0))

Submission status: Accepted

Solution code:
set_have = set()
N, K = input().split()
for _ in range(int(K)):
  temp = input()
  lis = input().split()
  for m in lis:
    set_have.add(m)
print(int(N) - len(set_have))

Submission status: Accepted

Solution code:
n,k = map(int , input().split())
a = []
from collections import defaultdict as dd
dc = dd(lambda : 0)
for i in range(k):
  d = int(input())
  a = list(map(int , input().split()))
  for i in a:
    dc[i] += 1
cnt = 0
for i in range(1 , n + 1):
  if dc[i] == 0:
    cnt += 1
print(cnt)

Submission status: Accepted

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

    for j in e:
        a.append(j)

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

Submission status: Accepted

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