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())
li = [True] * n
for i in range(k):
    d = int(input())
    a_list = list(map(int, input().split()))
    for a in a_list:
        li[a - 1] = False
print(sum(li))

Submission status: Accepted

Solution code:
Row = list(map(int, input().split()))
#print(Row)

List = [list(map(int, input().split())) for i in range(Row[1]*2)]
#print(List)
sunuke = [0]*Row[0]

for i in range(1, len(List), 2):
  #print(List[i])
  for j in List[i]:
    sunuke[j-1] += 1
#print(sunuke)
count = 0
for i in range(len(sunuke)):
     if( sunuke[i] == 0):
               count+=1
print(count)

Submission status: Accepted

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

for i in range(k):
  d.append(int(input()))
  for i in input().split():
    a.append(int(i))

ans = 0

for i in sunuke:
  if i not in a:
    ans += 1

print(ans)

Submission status: Accepted

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

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

ans = set(range(1,N+1))
for i in range(K):
  d = int(readline())
  ans -= set(map(int,readline().split()))
  
print(len(ans))

Submission status: Accepted

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

# print(A)

for i in range(k):
    di = int(input())
    Ai = list(map(int, input().split()))

    for j in range(di):
        A[Ai[j] - 1] += 1

# print(A)

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

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

print(N_array.count(0))

Submission status: Accepted

Solution code:
N,K = (int(x) for x in input().split())
all = set(map(lambda a: a+1,range(N)))
for i in range(K):
	d = input()
	Ai = set(int(x) for x in input().split())
	all -= Ai
	
print(len(all))

Submission status: Accepted

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

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

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

Submission status: Accepted

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

ans = 0
for i in range(1, N+1):
    num = 0
    for j in range(K):
        for k in range(D[j]):
            if A[j][k] == i:
                num = 1
    if num == 0:
        ans += 1
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from sys import stdin, stdout
rl = lambda: stdin.readline()
rll = lambda: stdin.readline().split()

def main():
	n, k = (int(x) for x in rll())
	exclude = set()
	for _ in range(k):
		d = int(rl())
		for snuke in (int(x) for x in rll()):
			exclude.add(snuke)
	ans = n - len(exclude)
	stdout.write(str(ans));stdout.write("\n")
	stdout.close()

if __name__ == "__main__":
	main()

Submission status: Accepted

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

print(n-sum(l))

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
list = []
for p in range(k):
  d = int(input())
  k_list = [int(x) for x in input().split()]
  m = len(k_list)
  for q in k_list:
    if not q in list:
      list.append(q)
l = len(list)
print(n - l)

Submission status: Accepted

Solution code:
N, K = list(map(int, input().split()))
okashi = [False] * N
for i in range(K):
    d = int(input())
    a = list(map(int, input().split()))
    for ai in a:
        okashi[ai-1] = True

ans = okashi.count(False)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,k = map(int,input().split())
a = set([i+1 for i in range(n)])
b = set()
for i in range(k):
  d = input()
  b |= set(map(int,input().split()))
print(len(a^b))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N,K=input().split()
def delete(a,n):
  j=len(a)
  for i in range(j):
    n=[l for l in n if l!=int(a[i])]
    
  return n

def get(y):
  first=[]
  for i in range(y):
    first.append(i+1)
    
  return first

answer=get(int(N))
for i in range(int(K)):
  v=input()
  b=input().split()
  answer=delete(b,answer)
  
print(len(answer))

Submission status: Accepted

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

workList = [1] * n

for i in range(k):
    input()
    *inList, = map(int, input().split())
    for di in inList:
        workList[int(di)-1] = 0

print(sum(workList))

Submission status: Accepted

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

workList = [1] * n

for i in range(k):
    di = int(input())
    inList = input().split()
    for di in inList:
        workList[int(di)-1] = 0


print(sum(workList))

Submission status: Accepted

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

O = [0]*N

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

Submission status: Accepted

Solution code:
def input_map_int():
    return map(int,input().split())

n,k=input_map_int()

flag=[True]*n

for i in range(k):
    d=int(input())
    a=list(input_map_int())
    for j in a:
        flag[j-1]=False

print(flag.count(True))

Submission status: Accepted

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

M = [0] * N

for i in range(K) :
    C = int(input())
    L = list(map(int,input().split()))
    for j in range(C) :
        M[L[j] - 1] += 1
R = 0
for i in range(N) :
    if M[i] == 0 :
        R += 1

print(R)

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
X = [True for i in range(n)]
for j in range(k):
    input()
    *A, = map(int, input().split())
    for a in A:
        X[a - 1] = False
print(len([x for x in X if x]))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from sys import stdin
N, K = [int(_) for _ in stdin.readline().rstrip().split()]
D = []
A = []
for i in range(K):
  d = int(stdin.readline().rstrip())
  D.append(d)
  a = [int(_) for _ in stdin.readline().rstrip().split()]
  for _a in a:
    A.append(_a)
A = set(A)
print(N-len(list(A)))

Submission status: Accepted

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

snuke = [0] * N

# K 回ループ
for i in range(K):
    d = int(input()) # A の要素数

    # A をリストとして受け取る
    A = list(map(int, input().split()))

    for j in range(d):
        snuke[A[j] - 1] = 1

ans = 0

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

print(ans)

Submission status: Accepted

Solution code:

n,k=map(int,input().split())
l=[]
n_l=[]
for i in range(1,n+1):
    n_l.append(i)
#print(n_l)
for i in range(k):
    d = int(input())
    a = list(map(int,input().split()))
    for a_j in a:
        l.append(a_j)
l=list(set(l))    
#print(l)
ans=len(list(set(n_l)-set(l)))
print(ans)

Submission status: Accepted

Solution code:
init=input().split()
num=int(init[0])
snacks=int(init[1])
check=[]
 
for i in range(snacks):
  sNum=int(input())
  if sNum>1:
    whos=input().split()
    for j in range(sNum):
      check.append(whos[j])
  else:
    who=input()
    check.append(who)
   
count=0
for i in range(1,num+1):
  if str(i) not in check:
    count=count+1
print(count)

Submission status: Accepted

Solution code:
def l(): return [int(a) for a in input().split(" ")] 
ka = l()
lis = [a + 1 for a in range(ka[0])]
for a in range(ka[1]):
  input()
  q = l()
  for b in q:
    if b in lis:
      lis.pop(lis.index(b))
print(len(lis))

Submission status: Accepted

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

for k in range(K):
    D[k] = int(input())
    A[k] = list(map(int, input().split()))

snuke = [0] * N

for k in range(K):
    for d in range(D[k]):
        snuke[A[k][d] - 1] += 1

ans = snuke.count(0)

print(ans)

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

nusuke = [1 for _ in range(N)]

for kids in A:
    for kid in kids:
        nusuke[kid-1] = 0

itazura = nusuke.count(1)
print(itazura)

Submission status: Accepted

Solution code:
#B 
N, K = map(int, input().split())
nonset = []
for i in range(K):
    _ = input()
    arr = list(map(int, input().split()))
    nonset.extend(arr)
print(N - len(set(nonset)))

Submission status: Accepted

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

flag = [True]*N
for k in range(K):
  tmp = input()
  for i in list(map(int,input().split())):
        flag[i-1] = False
 
print(sum(1 for x in flag if x==True))

Submission status: Accepted

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

print(my_list.count(0))

Submission status: Accepted

Solution code:
import sys
import math
n, k = map(int, input().split())
ans=[False]*n
for i in range(k):
    tmp = int(input())
    li = list(map(int, input().split()))
    for j in li:
        if (ans[j - 1] == False):
            ans[j - 1] = True
cnt = 0
for i in ans:
    if not i:
        cnt += 1
print(cnt)

Submission status: Accepted

Solution code:
def q2():
    N, K = (int(i) for i in input().split())
    ans = [True]*N

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

    print(ans.count(True))


if __name__ == '__main__':
    q2()

Submission status: Accepted

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

for _ in range(K):
    d=int(input())
    A_lis=list(map(int,input().split()))
    
    for i in A_lis:
        if i in A: A.remove(i)
print(len(A))

Submission status: Accepted

Solution code:
n,k = map(int,input().split())
list = []
for i in range(k):
    d = input()
    list.append(input().split())
cnt = 0
for i in range(n):
    a = str(i + 1)
    flg = False
    for l2 in list:
        if a in l2:
            flg = True
            break
    if not flg:
        cnt += 1

print(cnt)

Submission status: Accepted

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

h = set()
for d in range(K):
    _ = input()
    for a in map(int, input().split()):
        h.add(a)

result = set(range(1, N + 1)) - h
print(len(result))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

check = []
for a in A:
    check = list(set(check + a))

print(N - len(check))

Submission status: Accepted

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

for i in range(k):
    d=int(input())
    a=set(list(map(int,input().split())))
    ans=ans - a
print(len(ans))

Submission status: Accepted

Solution code:
SUNUKE,KASHI  =list(map(int, input().split()))
havings = [1 for _ in range(SUNUKE)]

for k in range(KASHI):
    num_sunuke=int(input())
    having_sunuke = list(map(int, input().split()))
    for i in having_sunuke:
        havings[i-1] = 0


print(sum(havings))

Submission status: Accepted

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

for turn in range(K):
  nn = int(input())
  li = list(map(int,input().split()))
  for num in li:
    lis[num-1] = 1

print (lis.count(0))

Submission status: Accepted

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

print(n-len(A))

Submission status: Accepted

Solution code:
from sys import setrecursionlimit, exit
setrecursionlimit(1000000000)

def main():
    n, k = map(int, input().split())
    have = set()
    for _ in range(k):
        input()
        for i in map(int, input().split()):
            have.add(i)
    print(n - len(have))

main()

Submission status: Accepted

Solution code:
import sys
input=sys.stdin.readline
n,k=map(int,input().split())
res=[]
for i in range(k):
    d=int(input())
    arr=list(map(int,input().split()))
    [res.append(x) for x in arr if x not in res]
print(n-len(res))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
nums = [int(e) for e in input().split()]
N = nums[0]
K = nums[1]

list0 = []
for i in range(0, 2*K):
  val = [int(e) for e in input().split()]
  if i%2 == 1:
      list0.extend(val)

num = N - len(list(set(list0)))

print(num)

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
F = [1 for _ in range(N)]
for _ in range(K):
    d = int(input())
    for a in map(int, input().split()):
        F[a - 1] = 0
print(sum(F))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding:utf-8 -*-
import numpy as np
N, K = [int(i) for i in input().split()]
# print("N:{}, K:{}".format(N, K))

cnt = np.zeros([1, N], dtype=int)
# print(cnt.shape)

## 繰り返しの回数はお菓子の種類に依存
for i in range(K):
    
    ## お菓子の種類dとそのお菓子dを持っている人の番号A
    d = int(input())
    A = [int(i) for i in input().split()]
    # print("d:{}, A:{}".format(d, A))
    
    ## お菓子dを持っている人の番号に値を代入
    for j in range(0, len(A)):
        cnt[0][A[j]-1] = 1
        
        # print("A[j]:{}".format(A[j]-1))
    
    
# print(cnt == 0)
print(np.count_nonzero(cnt == 0))

Submission status: Accepted

Solution code:
N,K=map(int,input().split())
A=[]
for _ in range(K):
    d=int(input())
    A.append(list(map(int,input().split()))) #Aのリストをflattenしたい
print(N-len(set(sum(A,[])))) #[]にAの要素を積んでいくやりかた。なるほどなぁ

Submission status: Accepted

Solution code:

val = input().split(" ")
N = int(val[0])
K = int(val[1])

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

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

for i in range(0, K):
    num_of_holder = int(input())
    holder_set = set([int(i) for i in input().split(" ")])

    not_have = initial - holder_set

    nhave = nhave & not_have

print(len(nhave))

Submission status: Accepted

Solution code:
s = set()
n,k = map(int,input().split())
for i in range(k):
  d_1 = int(input())
  a_i = map(int,input().split())
  A_i = list(a_i)
  for hito in A_i:
    s.add(hito)
print(n-len(s))

Submission status: Accepted

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

for i in range(K):
  d = int(input())
  indexs = [int(i) - 1 for i in input().split()]
  for index in indexs:
    sunukes[index] = 0
print(sum(sunukes))

Submission status: Accepted

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

#お菓子を持っていない人のリスト
#初期値は全員
not_hoyu_list=[x+1 for x in range(N)]

#お菓子の種類Kでループ
for i in range(K):
    num_d=int(input())
    hoyulist=list(map(int,input().split()))

    for j in hoyulist:
        if j in not_hoyu_list:
            not_hoyu_list.remove(j)

print(len(not_hoyu_list))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
n = []
for i in range(N):
  n.append(1)
for j in range(K):
  di = int(input())
  l = input().split()
  for k in range(di):
    if n[int(l[k])-1] == 1:
      n[int(l[k])-1] = 0
r = 0
for i in range(N):
  r += n[i]
print(r)

Submission status: Accepted

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

for _ in range(k):
  d = int(input())
  a += [int(m) for m in input().split()]

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

Submission status: Accepted

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

for i in range(k):
    treat_count = input()
    give_treat = list(map(int, input().split()))
    for j in give_treat:
        sunuke_list[j - 1] += 1

print(len([ i for i in sunuke_list if i == 0 ]))

Submission status: Accepted

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

Submission status: Accepted

Solution code:

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

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

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

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
a = set()
for i in range(k):
    di = int(input())
    ai = list(map(int,input().split()))
    for j in ai:
        a.add(j)

print(n-len(a))

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

    s=int(input())
    list1.extend(list(map(int,input().split())))


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

Submission status: Accepted

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

N, K = (int(_) for _ in input().split())

ret = [1] * N
for k in range(K):
    d = input()
    A = (int(_) - 1 for _ in input().split())
    for a in A:
        ret[a] = 0
print(sum(ret))

Submission status: Accepted

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

indexs = []
for i in range(len(L)):
    if i%2 != 0:
        indexs.append(L[i])

uniq_list = []
for li in indexs:
    for e in li:
        if e not in uniq_list:
            uniq_list.append(e)

print(N - len(uniq_list))

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
sunuke={i for i in range(1,n+1)}
for i in range(k):
    d=int(input())
    a=set(map(int,input().split()))
    sunuke=sunuke-a
print(len(sunuke))

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
sunuke = [1] * N
for i in range(K):
  di = int(input())
  ai = map(int, input().split())
  for j in ai:
    sunuke[j - 1] = 0
print(sum(sunuke))

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
used = [False]*(N+1)
for _ in range(K):
    _ = int(input())
    for i in map(int, input().split()):
        used[i] = True
print(N-sum(used))

Submission status: Accepted

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

Submission status: Accepted

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

from fractions import gcd
from collections import Counter, deque, defaultdict
from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge
from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort
from itertools import accumulate, product, permutations, combinations, combinations_with_replacement

N, K = [int(_) for _ in input().split()]
A = [[int(_) for _ in input().split()] for i in range(K+K)]
A = [A[i] for i in range(K+K) if i % 2 == 1]
a = []
for i in A:
    a += i
print(N - len(list(set(a))))

Submission status: Accepted

Solution code:
n,k = map(int,input().split())
master = []
count = 0
for num in range(k):
    d = input()
    sunuke = list(map(int,input().split()))
    master+=sunuke

print(n-len(set(master)))

Submission status: Accepted

Solution code:
h = [int(x) for x in input().split(' ')]
n = h[0]
k = h[1]

result = 0

l = {}
for i in range(n):
  l[i+1] = False

for i in range(k):
  num = input()
  has = [int(x) for x in input().split(' ')]
  for mem in has:
    l[mem] = True

for mem in l.values():
  if not mem:
    result += 1

print(result)

Submission status: Accepted

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

snukes = [0] * N

for i in range(K):
    d = int(input())
    arr = list(input().split())
    for j in range(d):
        snukes[int(arr[j]) - 1] += 1

non_zero_values = 0
for i in range(N):
    if snukes[i] == 0:
        non_zero_values += 1

print(non_zero_values)

Submission status: Accepted

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

havent = [0] + [1] * N

for i in range(K):
    d = int(input())
    a = list(map(int,input().split()))
    for e in  a:
        havent[e] = 0
print(sum(havent))

Submission status: Accepted

Solution code:
N,K=map(int,input().split())
hoge={}
for j in range(K):
    input()
    [hoge.update({int(j)-1:1}) for j in input().split()]
print(sum([not j in hoge for j in range(N)]))

Submission status: Accepted

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

snacklist = [0]*n

for num in range(0, k):
    d = input()

    boylist = list(map(int, input().split()))

    for bl in boylist:
        snacklist[bl-1] += 1


count = 0

for sl in snacklist:
    if sl == 0:
        count += 1

print(count)

Submission status: Accepted

Solution code:
temp = input().split(" ")
N = int(temp[0])
K = int(temp[1])

kashi = []
for i in range(K):
    input()
    temp = input().split(" ")
    kashi.extend(temp)

ans = 0
for i in range(N):
    if str(i+1) not in kashi:
        ans += 1

print(ans)

Submission status: Accepted

Solution code:
N,K=map(int,input().split())
hoge=[0 for j in range(N)]
for j in range(K):
    input()
    for i in input().split():
        hoge[int(i)-1]+=1
print(sum([j==0 for j in hoge]))

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools


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


def input_int_list_with_length(length=None):
    if length == None:
        length = int(input())
    return list(map(int, input().split()))[:length]


def list_uniq_count(l):
    return len(set(l))


def solve(N: int, K: int):
    l = []
    for _ in range(K):
        l += input_int_list_with_length()
    print(N-list_uniq_count(l))


def main():
    solve(*input_int_list())


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
#!usr/bin/env python3
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop
from itertools import permutations
import sys
import math
import bisect

def LI(): return [int(x) for x in sys.stdin.readline().split()]


def I(): return int(sys.stdin.readline())


def LS(): return [list(x) for x in sys.stdin.readline().split()]


def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res


def IR(n):
    return [I() for i in range(n)]


def LIR(n):
    return [LI() for i in range(n)]


def SR(n):
    return [S() for i in range(n)]


def LSR(n):
    return [LS() for i in range(n)]


sys.setrecursionlimit(1000000)
mod = 1000000007


def solve():
    n, k = LI()
    flag_list = [False] * n
    for _ in range(k):
        d = I()
        a = LI()
        for i in range(d):
            flag_list[a[i]-1] = True
    print(flag_list.count(False))
    
    return


if __name__ == "__main__":
    solve()

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools


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


def input_int_list_with_length(length=None):
    if length == None:
        length = int(input())
    return list(map(int, input().split()))[:length]


def solve(N: int, K: int):
    l = []
    for _ in range(K):
        l += input_int_list_with_length()
    print(N-len(set(l)))


def main():
    solve(*input_int_list())


if __name__ == '__main__':
    main()

Submission status: Accepted

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

li_n = list(range(1 , n + 1))
for _ in range(k):
    d = int(input())
    li_a = list(map(int, input().split()))
    for a in li_a:
        if a in li_n:
            li_n.remove(a)
print(len(li_n))

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

N, K = map(int, input().split())
d = [0]*K

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

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

#print("{}".format(C))
print("{}".format(count))

Submission status: Accepted

Solution code:
if __name__ == "__main__":
  str_N_K = input()
  
  list_N_K = str_N_K.split(' ')
  N = int(list_N_K[0])
  K = int(list_N_K[1])
  
  list_person = [0] * N
  
  for _ in range(K):
    d = int(input())
    str_persons = input()
    if (" " in str_persons):
      list_str_persons = str_persons.split(" ")
    else:
      list_str_persons = [str_persons]
      
    for str_person in list_str_persons:
      int_person = int(str_person)
      list_person[int_person-1] += 1
  
  output = 0
  for person in list_person:
    if person == 0:
      output += 1
      
  print(output)

Submission status: Accepted

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

N, K = map(int, input().split())
d = []
A = [[]] * K
sunuke = [0] * N

for k in range(K):
	d.append(int(input()))
	A[k] = map(int, input().split())
	for a in A[k]:
		sunuke[a-1] += 1

print(sunuke.count(0))

Submission status: Accepted

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

t = [0]*n

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
line1 = input().split()
n = int(line1[0])
k = int(line1[1])
list1 = []
for i in range(k):
  d = input()
  lst = input().split()
  list1 += lst

set1 = set(list1)
nothing = set(str(i+1) for i in range(n)) - set1
print(len(nothing))

Submission status: Accepted

Solution code:
person, snack = map(int, input().split(" "))

persons = {i+1 for i in range(person)}

for i in range(snack):
    _ = int(input())
    for p in list(map(int, input().split(" "))):
        persons.discard(p)

print(len(persons))

Submission status: Accepted

Solution code:
# B - Trick or Treat

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

print(N - len(set(ls)))

Submission status: Accepted

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

Submission status: Accepted

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

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

print(cnt.count(0))

Submission status: Accepted

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