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:
def main():
    input1 = input().split()
    N = int(input1[0])
    K = int(input1[1])
    d = [0]*K
    count = [0]*N
    for i in range(K):
        input2 = input()
        d[i] = int(input2)
        input3 = input().split()
        for j in range(d[i]):
            count[(int(input3[j]))-1] += 1

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

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
N,K = map(int,input().split())
A =[]
B =[]
count = 0
for _ in range(K):
  d = int(input())
  B = list(map(int,input().split()))
  A += B
set(A)

for i in range(1,N+1):
  if not i in list(A):
    count += 1
print(count)

Submission status: Accepted

Solution code:

def main():
  n, k = map(int, input().split(" "))

  arr = [0] * n

  for _ in range(k):
    input()
    for a in map(int, input().split(" ")):
      arr[a - 1] += 1

  print(len(tuple(filter(lambda count: count == 0, arr))))


main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N,K = map(int, input().split())
A=[]
d=[0 for i in range(K)]
recode={}
for i in range(K):
    d[i]=int(input())
    a=list(map(int, input().split()))
    A.append(a)
for i in range(K):
    for j in range(d[i]):
        recode[A[i][j]]=1
count=0
for i in range(1,N+1):
    if i in recode.keys():
        continue
    else:
        count+=1
print(count)

Submission status: Accepted

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

Submission status: Accepted

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

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

answer=0
for i in range(1,n+1):
  t=0
  for j in range(k):
    if i in a[j]:
      t=1
  if t==0:
    answer+=1

print(answer)

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())
    R = list(map(int,input().split()))
    A.extend(R)
A = set(A)
print(N - len(A) + 1)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
# 標準入力の取得
N, K = list(map(int, input().split()))
d = []
A = []
for k in range(K):
    d.append(int(input()))
    A.append(list(map(int, input().split())))

# 求解処理
persons = set()
for A_i in A:
    for A_ij in A_i:
        persons.add(A_ij)

result = N - len(persons)

# 結果出力
print(result)

Submission status: Accepted

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

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



sum=0
for i in range(n):
    sum+=ans[i]
print(sum)

Submission status: Accepted

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

for i in range(len(A)):
  for j in range(len(A[i])):
    if A[i][j] in s2:
      s2.remove(A[i][j])

print(len(s2))

Submission status: Accepted

Solution code:

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

snu = [ False for i in range(n)]
count=0

for _ in range(k):
  d = int(input())
  snukes = [ int(x) for x in input().split()]
  for elem in snukes:
    if(not snu[elem-1]):
      snu[elem-1]=True
      count+=1
      
print(n-count)

Submission status: Accepted

Solution code:
a, b = map(int, input().split())
lis = [0]*a
for i in range(b):
    p = int(input())
    t = map(int, input().split())
    for j in t:
        lis[j-1] = 1
for i in lis:
    a-=i
print(a)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import itertools
import sys
import numpy as np
input = lambda: sys.stdin.readline().strip()

def main():
    N,K = map(int,input().split())
    itadura = list()
    sunuke_list = [i for i in range(1,N+1)]
    A = list()
    for _ in range(N):
        d = input()
        A.append(map(int,input().split()))
    for ls in A:
        for j in ls:
            itadura.append(j)
    ans = set(sunuke_list) - set(itadura)
    print(len(ans))




main()

Submission status: Accepted

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

sunuke = set()
for _ in range(K):
    _ = input()
    A = input().split()
    for a in A:
        sunuke.add(a)

print(N - len(sunuke))

Submission status: Accepted

Solution code:

n,k = map(lambda x: int(x), input().split())

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


def set_sum(list):
    n = len(list)
    for i in range(n):
        list[i] = set(list[i])
    result = set()
    for i in range(n):
        result = result | list[i]
    return result



print(n - len(set_sum(a)))

Submission status: Accepted

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

snuke = [0 for i in range(N)]

for i in range(K):
    number = int(input())
    menber = [int(x) for x in input().split()]
    for j in range(number):
        snuke[menber[j]-1] += 1

cnt = 0    
for k in range(N):
    if snuke[k] == 0 :
        cnt += 1

print(cnt)

Submission status: Accepted

Solution code:
n, k = list(map(int, input().split()))
b = {i for i in range(1, n+1)}
a = []
for i in range(k):
    d = int(input())
    z = list(map(int, input().split()))
    for l in z:
        a.append(l)
a_ = set(a)
print(len(b-a_))

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

print(su.count(0))

Submission status: Accepted

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

A=[]
B=[]
for i in range(2*K):
    get=list(map(int,(input().split())))
    if i%2==1:
        A.append(get)
for i in range(len(A)):
    for j in range(len(A[i])):
        B.append(A[i][j])
cnt=0
for i in range(1,N+1):
    if i not in B:
        cnt+=1
        
print(str(cnt))

Submission status: Accepted

Solution code:
N,K = map(int,input().split())
unchecked = set((range(1,N+1)))
#print(unchecked)
checked = set()

for i in range(K):
  d = int(input())
  A = set(map(int,input().split()))
  checked = A | checked

#print(checked)
unchecked -= checked
print(len(unchecked))

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
d={}
for i in range(1,n+1):
	d[i]=0
while k:
	k-=1
	x=int(input())
	l=list(map(int,input().split()))
	for i in l:
		d[i]+=1
	
c=0
for i in d:
	if d[i]==0:
		c+=1
print(c)

Submission status: Accepted

Solution code:
import math
import itertools
cnt = 0
n,k = map(int,input().split())
t = []
for i in range(1,n+1):
    t.append(i)
#print(t)
for i in range(k):
    n = int(input())
    a = list(map(int,input().split()))
    for i in range(len(a)):
        if a[i] in t:
            t.remove(a[i])
        
print(len(t))

Submission status: Accepted

Solution code:
import numpy as np

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

x = np.array([1 for i in range(N)])
for i in range(0, K*2):
	if i % 2 == 0:
		d = int(input())
	else:
		member = np.array(list(map(int, input().split())))
		for j in range(d):
			x[member-1] = 0

print(np.sum(x == 1))

Submission status: Accepted

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

print(N - len(s))

Submission status: Accepted

Solution code:

N, K = map(int, input().split())
okasi = [False for _ in range(N)]

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

print(N - sum(okasi))

Submission status: Accepted

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

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

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

print(count)

Submission status: Accepted

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

count = 0
for i in x:
  if i == 0: count+=1
    
print(count)

Submission status: Accepted

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

if __name__ =='__main__':
    main()

Submission status: Accepted

Solution code:
#B問題
N, K = map(int, input().split())
Result = [True] * N
Count = 0
for i in range(K):
    d = int(input())
    A = input().split()
    for j in range(len(A)):
        Result[int(A[j])-1] = False

Count = Result.count(True)
print(Count)

Submission status: Accepted

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

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

count = 0
for i in range(N):
	if not (i+1) in A: count += 1

print(count)

Submission status: Accepted

Solution code:
N, K = map(int,input().split())
sweet = [list(map(int,input().split())) for s in range(K*2)]
tmp = []
for index,s in enumerate(sweet):
	if index % 2 != 0:
		if len(s) >= 2:
			for ss in s:
				tmp.append(ss)
		else:
			tmp.append(*s)
print(N - len(set(tmp)))

Submission status: Accepted

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

lis_d = [];
lis_A = [];

for i in range(k):
    d = int(input());
    A = list(map(int, input().split()));
    lis_d.append(d);
    lis_A.append(A);

all_A = []
for a in lis_A:
    all_A += a;

all_A = set(all_A)

all_num = set(range(1, n + 1));

ans = len(list(all_num - all_A));
print(ans)

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
seta=set()
for i in range(k):
    d=int(input())
    l=[int(i) for i in input().split()]
    for j in l:
        seta.add(j)

print(n-len(set(seta)))

Submission status: Accepted

Solution code:
N,K=map(int,input().split())#n人k種類
hito=[num for num in range(1,N+1)]
for i in range(K):
  d=int(input())#何人持ってるか
  A=list(map(int,input().split()))#2,3
  for a in A:
    if a in hito:
      hito.remove(a)
print(len(hito))

Submission status: Accepted

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


def main():
    n, k = input_list()
    a = set()
    c = k*2
    for i in range(c):
        num = input()
        d = input_list()
        for v in d:
            a.add(v)
    print(n-len(a))


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


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, K = [int(i) for i in input().split()]
sunuke = [False] * N

for i in range(K):
    d = int(input())
    target_list = list(input().split())
    for k in target_list:
        sunuke[int(k)-1] = True
    
#print("**")
print(N-sum(sunuke))

Submission status: Accepted

Solution code:
n,k = map(int,input().split())
ans=[]
s=[list(map(int, input().split())) for _ in range(0,2*k)]
for i in s[1::2]:
    for j in i:
        ans.append(j)
print(n-len((set(ans))))

Submission status: Accepted

Solution code:
import queue
import copy
import math
from collections import deque
import bisect
from decimal import Decimal

# そのまま入力文字列の入力
n, k = map(int, input().split())

s = set()

# 空白区切りの数値をリスト化
for i in range(0, 2 * k):
    if i % 2 == 0:
        d = int(input())
        continue
    l = input().split()
    for v in l:
        s.add(v)

print(n-len(s))

Submission status: Accepted

Solution code:

def main():
    N,K = map(int, input().split())
    cnt = 0
    sunuke = [0]*(N+1)

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

    
    cnt = sunuke.count(0) - 1

    print(cnt)




if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import itertools
N, K = map(int, input().split())
all_sunuke = []
for _ in range(K):
    d = int(input())
    *A, = map(int, input().split())
    all_sunuke.append(tuple(A))
all_sunuke = list(itertools.chain.from_iterable(all_sunuke))
print(N - len(set(all_sunuke)))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
import math

N, K = list(map(int, input().split()))
ALL = []

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

print(N - len(set(ALL)))

Submission status: Accepted

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

print(len([i for i in ans if i%2==0]))

Submission status: Accepted

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

for i in range(m):
    l = int(input())
    ll = list(map(int,input().split()))

    for ii in range(l):
        ls.append(ll[ii])

ls = set(ls)

c = 0
for i in range(1,n+1):
    if not i in ls:
        c+=1

print(c)

Submission status: Accepted

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

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

for i in range(len(d)):
    if i % 2 == 0:
        continue
    else:
        for j in range(len(d[i])):
            if d[i][j] in s:
                s.remove(d[i][j])
      
            
print(len(s))

Submission status: Accepted

Solution code:
def main():
    N, K = map(int, input().split())
    D = []
    A = []
    for i in range(K):
        d = int(input())
        Ai = [int(x) for x in input().split()]
        A = A + Ai
    A_ = set(A)
    n = N - len(A_)
    print(n)
main()

Submission status: Accepted

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

for i in range(K):
    C=A[i]
    for j in C:
        o[j-1]=1
c=0
for i in o:
    if i==0:
        c+=1

print(c)

Submission status: Accepted

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

cnt = [0 for i in range(n)]
for i in range(k):
    d  = int(input())
    A  = list(map(int, input().split()))
    
    # print("A:", A)
    for j in A:
        # print(cnt)
        cnt[j-1] += 1

ans = 0
for p in cnt:
    if p == 0:
        ans += 1

print(ans)

Submission status: Accepted

Solution code:
import numpy as np

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

A = np.zeros(N, dtype=int)

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

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

Submission status: Accepted

Solution code:
N,K= map(int,input().split())
rich_boy = set()
all_boy = set([n for n in range(1,N+1)])
for k in range(K):
    d = input()
    A = set(map(int,input().split()))
    rich_boy=rich_boy.union(A)
print(len(all_boy-rich_boy))

Submission status: Accepted

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

Submission status: Accepted

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

ans=[0]*N

#print(ans)

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

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

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

n = 0
for sunu in sunuke:
    if sunu == 0:
        n += 1
print(n)

Submission status: Accepted

Solution code:
n,k = map(int,input(). split())
allist = []
for i in range(k):
  d = input()
  a = input().split(" ")
  linta = [int(n) for n in a]
  allist.extend(linta)
alist = set(allist)
kotae = n-len(alist)
print(kotae)

Submission status: Accepted

Solution code:
arr_1 = input().split(" ")

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

okashimochi=list()

for num in range(0,k):
    input()
    child = list(input().split(" "))
    okashimochi.extend(child)

result = list(set(okashimochi))
print(n-len(result))

Submission status: Accepted

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

for i in range(K):
  a = input()
  case = case + list(map(int, input().split()))
  
cases = set(case)
print(N-len(cases))

Submission status: Accepted

Solution code:
import numpy as np
n, k = map(int, input().split())
sunuke = np.zeros(n, dtype=int)

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

print(sunuke.shape[0] - np.count_nonzero(sunuke))

Submission status: Accepted

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

for i in range(k):
    num = int(input())
    a = map(int, input().rstrip().split())
    for j in a:
        a_set.add(j)

print(n-len(a_set))

Submission status: Accepted

Solution code:
from sys import stdin

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

A_list = [0 for i in range(N)]

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

count = 0
for i in range(N):
  if A_list[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.extend(list(map(int, input().split())))

N = []    
for i in range(1, n+1):
    N.append(i)
# print(A,N)
print(len(set(A)^set(N)))

Submission status: Accepted

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

li = []

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

newli = set(li)

count = 0

for j in range(1, n+1):
  if j in newli:
    count = count
  else:
    count = count + 1

print(count)

Submission status: Accepted

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

check = []

for i in range(1, k+1):
  check.extend(d[i*2-1])

print(n-len(set(check)))

Submission status: Accepted

Solution code:
def readInt():
    return list(map(int,input().split()))
    
n,k = readInt()
ans = 0
nusuke = [0 for i in range(n)]
for i in range(k):
    d = int(input())
    a = readInt()
    for i in range(d):
        a[i] -= 1
    # print(a)
    for j in a:
        nusuke[j] += 1
# print(nusuke)
for m in nusuke:
    if m==0:
        ans += 1
print(ans)

Submission status: Accepted

Solution code:
from collections import defaultdict

import sys
sys.setrecursionlimit(10**6)
ii = lambda: int(input())
mis = lambda: map(int,input().split())
lmis = lambda: list(mis())
INF = float('inf')

def main():
    n,k=mis()
    nlis=[0 for _ in range(n+1)]
    for _ in range(k):
        d=ii()
        a=input().split()
        for i in range(d):
            x=int(a[i])
            nlis[x]+=1
    cnt=0
    for i in range(1,n+1):
        if nlis[i]==0: cnt+=1
    print(cnt)



if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
n,k = map(int,input().split())
lis = [[int(p) for p in input().split()] for _ in range(2*k)]
people = [0]*n

for i in range(k):
  
  for j in range(lis[2*i][0]):
    print()
    num = lis[2*i+1][j]
    people[num-1] = 1

count = 0
for i in people:
  if i == 0:
    count += 1
    
print(count)

Submission status: Accepted

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

sunu = [0 for i in range(N+1)]
ans = N


for a in A:
    for j in a:
        if sunu[j] == 0:
            ans -= 1
            sunu[j] += 1

print(ans)

Submission status: Accepted

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

def main():
    n, k = map(int, input().split())
    used = set()
    for _ in range(k):
        d = int(input())
        a = list(map(int, input().split()))
        used |= set(a)
    ans = n - len(used)
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#coding: utf-8
N, K = map(int, input().split())
snukes = set([i+1 for i in range(N)])
d = []
for k in range(K):
    input()
    for a in map(int, input().split()):
        if a in snukes:
            snukes.remove(a)
print(len(snukes))

Submission status: Accepted

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


B=[0 for i in range(N)]

for j in A:
  for k in j:
    B[k-1]+=1
C=B.count(0)

print(C)

Submission status: Accepted

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

for i in range(k):
    tmp = int(input())
    tmp2 = list(input().split())
    d.append(tmp)
    A.append(tmp2)
    
for i in range(k):
    for j in range(d[i]):
        if A[i][j] not in cnt:
            cnt.append(A[i][j])

ans = n - len(cnt)
print(ans)

Submission status: Accepted

Solution code:
# coding: utf-8

s = list(map(int, input().split(" ")))

snk = s[0]
oks = s[1]

v = []
for i in range(oks) :
    num = int(input())
    x = list(map(int, input().split(" ")))
    for j in range(num) :
        v.append(x[j])

ans = snk - len(set(v))

print(ans)

Submission status: Accepted

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

c=[]
b=[list(map(int, input().split())) for i in range(2*k)]

for i in range(1,2*k,2):
  for j in range(len(b[i])):
    c.append(b[i][j]) 

d=set(c)
print(n-len(d))

Submission status: Accepted

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

print(ans)

Submission status: Accepted

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

for i in range(K):
    X = int(input())
    arr = list(map(int, input().split()))
    for j in range(len(arr)):
        morata[arr[j]-1] = 1

print(morata.count(0))

Submission status: Accepted

Solution code:
import itertools

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

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

grid2 = []

for j in range(K):
    grid2.append(grid[j*2+1])

grid2 = list(itertools.chain.from_iterable(grid2))

for k in range(1, N+1):
    if k in grid2:
        pass
    else:
        X += 1

print(X)

Submission status: Accepted

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

N_list=list(range(1,N+1))
ans=N
for i in range(K):
    d=int(input())
    A=list(map(int,input().split()))
    for j in A:
        if j in N_list:
            ans=ans-1
            N_list.remove(j)
    

print(len(N_list))

Submission status: Accepted

Solution code:
N, K = [eval(v) for v in input().strip().split(" ")]
Snuke = [0] * N
for i in range(K):
    d = eval(input())
    A = [eval(v) for v in input().strip().split(" ")]
    for a in A:
        Snuke[a-1] += 1

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

Submission status: Accepted

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

d = []
A = []
for i in range(K):
    _d = int(input())
    d.append(_d)
    _a = [int(x) for x in input().split()]
    A.append(_a)

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

for a in A:
    for _a in a:
        if _a in res:
            res.remove(_a)
print(len(res))

Submission status: Accepted

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

def resolve():
    import itertools
    n,k=map(int, input().split())
    l=[list(map(int,input().split())) for i in range(2*k)]
    newl=l[1::2]
    newl=itertools.chain(*newl)
    print(n-len(set(newl)))
resolve()

Submission status: Accepted

Solution code:
n, k = map(int, input().split(" "))
d = []
A_list = []
for ki in range(k):
    d = int(input())
    A = map(int, input().split(" "))
    A_list.extend(A)

ari = len(set(A_list))
print(n - ari)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
import itertools


# 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 = [int(x) for x in input().split()]
    d = []
    A = []
    for i in range(K):
        d.append(input())
        A.append(input().split())
    a = list(set(itertools.chain.from_iterable([list(set(x)) for x in A])))
    print(N - len(a))
    return

if __name__ == '__main__':
    main()

Submission status: Accepted

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

n = []
for i in range(K * 2):
    _in = input().split()
    if i % 2 != 0:
        n = n + _in

print(N - len(set(n)))

Submission status: Accepted

Solution code:
# Trick or Treat
import numpy
N, K = map(int, input().split())

sweets = [0] * N

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

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

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
nlst = [0]*n
total = 0
for i in range(k):
    d = int(input())
    List = [int(i) for i in input().split()]
    for num in List:
        nlst[num-1] += 1
for ans in nlst:
    if ans == 0:
        total += 1
print(total)

Submission status: Accepted

Solution code:
#整数の入力
N,K = map(int, input().split())

d_list = []
A_list_list = []
for i in range(K):
  #整数の入力
  d = int(input())
  d_list.append(d)
  #スペース区切りの整数の入力リスト
  A_list = list(map(int, input().split()))
  #print(A_list)
  A_list_list.extend(A_list)
#print(A_list)
counter = 0
for i in range(N):
  if((i+1 in A_list_list) ==True):
    counter = counter
  else:
    counter = counter + 1
print(counter)

Submission status: Accepted

Solution code:
import sys
import itertools
if sys.platform =='ios':
    sys.stdin=open('input_file.txt')
    
    
n,k=map(int,input().split())

l=[0]*n

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

Submission status: Accepted

Solution code:
if __name__ == '__main__':
    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(sunuke.count(False))

Submission status: Accepted

Solution code:
def resolve():
    '''
    code here
    '''
    N, K = [int(item) for item in input().split()]
    
    data = [input() for _ in range(2*K)]

    sunuke = [0 for _ in range(N)]

    for i in range(K):
        d = data[i*2]
        okashi = data[i*2 + 1].split()
        for j in okashi:
            sunuke[int(j)-1] += 1


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

    print(cnt)

if __name__ == "__main__":
    resolve()

Submission status: Accepted

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

for i in A:
    for j in i:
        B.append(j)
print(N-len(set(B)))

Submission status: Accepted

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

print(x.count(0))

Submission status: Accepted

Solution code:
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

n,k = mi()
aa = [[]for _ in range(k)]
for i in range(k):
    d = ii()
    aa[i] = li()

dp = [0]*(n+1)
dp[0] = 1
for i in range(k):
    for l in aa[i]:
        dp[l] = 1
ans = 0
for i in range(n+1):
    if dp[i] == 0:
        ans += 1
print(ans)

Submission status: Accepted

Solution code:
input_NK = input().split(' ')
N = int(input_NK[0])
K = int(input_NK[1])
rest = [i + 1 for i in range(N)]

for i in range(K):
  di = int(input())
  input_Ai = input().split(' ')
  for j in range(len(input_Ai)):
    if rest.count(int(input_Ai[j])) != 0:
      rest.remove(int(input_Ai[j]))
    
print(len(rest))

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
n, k = map(int, input().split())

sunuke_list = [False for i in range(n)]

for i in range(k):
    d = int(input())
    has_sunuke_list = input().split()
    for k in has_sunuke_list:
        sunuke_list[int(k)-1] = True

print(sunuke_list.count(False))