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,raw_input().split())
dic = {}
for a in range(k):
  x = raw_input()
  x = map(int,raw_input().split())
  for z in x:
    dic[z] = 1
x = [1]*(n+1)
x[0] = 0
for a in dic:
  x[a] = 0
print x.count(1)

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

Okashi = []
for i in range(k):
    for j in range(len(A[i])):
        Okashi.append(A[i][j])
c = collections.Counter(Okashi)

print(n-len(c))

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

okashi=set()
for a in A:
    for b in a:
        okashi.add(b)

print(n-len(okashi))

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
S=[0]*n
for _ in range(k):
    input()
    A=tuple(map(int,input().split()))
    for a in A:
        S[a-1]+=1
ans=0
for s in S:
    if s==0:
        ans+=1
print(ans)

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
treat = list(range(1, n+1))

for i in range(k):
  d = int(input())
  a = list(map(int, input().split()))
  for j in a:
    if j in treat:
      treat.remove(j)
print(len(treat))

Submission status: Accepted

Solution code:
N, K = [int(s) for s in input().split()]
h = []
for _ in range(K):
    d = input()
    h = h + [int(s) for s in input().split()]

print(sum([True for x in range(1, N + 1) if not (x in set(h))]))

Submission status: Accepted

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

import sys


def input():
    return sys.stdin.readline()


def resolve():
    n, k = map(int, input().split())
    d_list = []
    a_list = []
    for i in range(k):
        d_list.append(int(input()))
        a_list.append(list(map(int, input().split())))

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

    for a in a_list:
        for sunuke_no in a:
            try:
                remain_list.remove(sunuke_no)
            except:
                pass

    print(len(remain_list))



if __name__ == "__main__":
    resolve()

Submission status: Accepted

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

k = input().split(" ")

num_sunuke = int(k[0])
kind = int(k[1])

counter = [False for i in range(num_sunuke)]

for i in range(kind):
    d = int(input())
    a = input().split(" ")
    for j in range(d):
        counter[int(a[j])-1] = True
        
print(counter.count(False))

Submission status: Accepted

Solution code:
import sys
stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)

def LI(): return list(map(int, stdin.readline().split()))
def LS(): return list(stdin.readline())

import itertools
n, k = LI()
s = []
for i in range(k):
    d = int(input())
    a = LI()
    s.append(a)
s = list(itertools.chain.from_iterable(s))
ans = 0
for i in range(1, n+1):
    if i not in s:
        ans += 1
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n, k = map(int, input().split(" "))
snukes = [0] * n
result = 0
for i in range(0, k):
    number_temp = input()
    snakes_temp = list(map(int, input().split(" ")))
    for n in snakes_temp:
        snukes[n-1]+=1
for i in snukes:
    if i==0:
        result+=1
print(result)

Submission status: Accepted

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

l=[n for n in range(1,N+1)]
for n in range(K):
    d=int(input())
    A=list(map(int,input().strip().split()))
    for n in range(d):
        if A[n] in l:
            l.remove(A[n])

print(len(l))

Submission status: Accepted

Solution code:
import numpy as np
N,K = map(int,input().split())
numberList = np.array(range(1,N+1)).tolist()
for d in range(1,K+1):
    num = input()
    array = list(map(int, input().strip().split()))
    for i in array:
        if i in numberList:
            numberList.remove(i)
print(len(numberList))

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

ans = [i for i in range(1,n+1)]
for i in a:
    for j in i:
        if j in ans:
            ans.remove(j)

print(len(ans))

Submission status: Accepted

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

d = []
All = set()

for k in range(K):
    d.append(int(input()))
    X = list(map(int,input().split()))
    All = All | set(X)

print(N-len(All))

Submission status: Accepted

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

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

print(N-len(s))

Submission status: Accepted

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

#辞書として全部のすぬけ君確認する
zisyo = {} 
zisyo = set(zisyo)

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

print(N-len(zisyo))

Submission status: Accepted

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

for i in range(N):
    a.append(False)

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

c=0
for i in a:
  if i==False:
    c = c + 1
print(c)

Submission status: Accepted

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

sunuke = []
list_sunuke=[]
for i in range(K):
    d = int(input())
    
    sunuke.append(input().split())

for i in sunuke:
    for j in i:
        list_sunuke.append(j)

set_sunuke = set(list_sunuke)
print(N-len(set_sunuke))

Submission status: Accepted

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

Submission status: Accepted

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

import sys
# import math
# from string import ascii_lowercase, ascii_upper_case, ascii_letters, digits, hexdigits
# import re                                    # re.compile(pattern) => ptn obj; p.search(s), p.match(s), p.finditer(s) => match obj; p.sub(after, s)
# from operator import itemgetter              # itemgetter(1), itemgetter('key')
# from collections import deque                # deque class. deque(L): dq.append(x), dq.appendleft(x), dq.pop(), dq.popleft(), dq.rotate()
# from collections import defaultdict          # subclass of dict. defaultdict(facroty)
# from collections import Counter              # subclass of dict. Counter(iter): c.elements(), c.most_common(n), c.subtract(iter)
# from heapq import heapify, heappush, heappop # built-in list. heapify(L) changes list in-place to min-heap in O(n), heappush(heapL, x) and heappop(heapL) in O(lgn).
# from heapq import nlargest, nsmallest        # nlargest(n, iter[, key]) returns k-largest-list in O(n+klgn).
# from itertools import count, cycle, repeat   # count(start[,step]), cycle(iter), repeat(elm[,n])
# from itertools import groupby                # [(k, list(g)) for k, g in groupby('000112')] returns [('0',['0','0','0']), ('1',['1','1']), ('2',['2'])]
# from itertools import starmap                # starmap(pow, [[2,5], [3,2]]) returns [32, 9]
# from itertools import product, permutations  # product(iter, repeat=n), permutations(iter[,r])
# from itertools import combinations, combinations_with_replacement
# from itertools import accumulate             # accumulate(iter[, f])
# from functools import reduce                 # reduce(f, iter[, init])
# from functools import lru_cache              # @lrucache ...arguments of functions should be able to be keys of dict (e.g. list is not allowed)
# from bisect import bisect_left, bisect_right # bisect_left(a, x, lo=0, hi=len(a)) returns i such that all(val<x for val in a[lo:i]) and all(val>-=x for val in a[i:hi]).
# from copy import deepcopy                    # to copy multi-dimentional matrix without reference
# from fractions import gcd                    # for Python 3.4 (previous contest @AtCoder)


def main():
    mod = 1000000007                # 10^9+7
    inf = float('inf')              # sys.float_info.max = 1.79...e+308
    # inf = 2 ** 64 - 1               # (for fast JIT compile in PyPy) 1.84...e+19
    sys.setrecursionlimit(10**6)    # 1000 -> 1000000
    def input(): return sys.stdin.readline().rstrip()
    def ii():    return int(input())
    def mi():    return map(int, input().split())
    def mi_0():  return map(lambda x: int(x)-1, input().split())
    def lmi():   return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    def li():    return list(input())
    
    
    n, k = mi()
    member = set()
    for _ in range(k):
        d = ii()
        L = lmi_0()
        for person in L:
            member.add(person)
    cnt = 0
    for i in range(n):
        if i not in member:
            cnt += 1
    print(cnt)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

lis = []
for n in range(K):
    d = int(input())
    lis.append(list(map(int, input().split())))

ans_lis = []
for v in lis:
    for sunuke_num in v:
        ans_lis.append(sunuke_num)

print(N-len(set(ans_lis)))

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())))
nusuke = [i+1 for i in range(N)]
N_nusuke = [0 for i in range(N)]
for a in A:
    for i in range(len(a)):
        N_nusuke[a[i]-1] += 1
print(N_nusuke.count(0))

Submission status: Accepted

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

d_list = []
a_list = []

for i in range(k):
  d_list.append(int(input()))
  a_list.append([int(x) for x in input().split()])
  
lis = {i:0 for i in range(1,n+1)}

for a in a_list:
  for a2 in a:
    lis[a2] += 1

print(list(lis.values()).count(0))

Submission status: Accepted

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

# 各人がもっているお菓子の個数を足しこんでいく
item_num_list = [0 for i in range(N)]
for i in range(K):
    d = int(input())
    Aid = map(int, input().split())
    for a in Aid:
        item_num_list[a - 1] += 1

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

Submission status: Accepted

Solution code:
from sys import stdin
input=lambda : stdin.readline().strip()
from math import ceil,sqrt,factorial,gcd
n,k=map(int,input().split())
s=set()
for i in range(k):
	a=int(input())
	l=list(map(int,input().split()))
	for j in  l:
		s.add(j)
print(n-len(s))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# region
import sys

DEBUG = True if (len(sys.argv) > 1 and sys.argv[1] == "DEBUG") else False


def dp(value):
    if DEBUG:
        print(value)
    return


def input_text(split=" "):
    # 入力
    result = []
    while True:
        try:
            row = list(
                map(lambda x: int(x) if x.isdecimal() else x, input().split(split))
            )
            result.append(row)
        except EOFError:
            break
    return result


# endregion
it = input_text()

n = it[0][0]
row = len(it)

s = set()
i = 1
while row >= i * 2:
    s = s | (set(it[i * 2]))
    i += 1

print(n - len(s))

Submission status: Accepted

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

Submission status: Accepted

Solution code:


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

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

Submission status: Accepted

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

def judge_Flag(flags):
    As = list(map(int, input().split()))
    for A in As:
        flags[A - 1] = True

for _ in range(K):
    people_num = int(input())
    judge_Flag(haves)
print(haves.count(False))

Submission status: Accepted

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

for zzz in range(k):
    for i in a[zzz]:
        if i in ans:
            pass
        else:
            ans.append(i)

print(n-len(ans))

Submission status: Accepted

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

for k in range(K):
    d_i = int(input())
    # for i in range(d_i):
    l = list(map(int, input().split()))
    for i in l:
        N_list[i-1] += 1

print(N_list.count(0))

Submission status: Accepted

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

for i in range(K):
    d = int(input())
    A = list(map(int, input().split()))
    for k in range(d):
        sunuke_num = A[k]
        possess[sunuke_num - 1] = 1

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

print(count)

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
sum_list = []
for i in range(K):
  d = int(input())
  own_list = list(map(int, input().split()))
  sum_list += own_list
count = 0
# print(sum_list)
for i in range(1, N+1):
  if i not in sum_list:
    count += 1
print(count)

Submission status: Accepted

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

treat_list = set()

for i in range(K):
    a = int(input())
    Line = [int(s) for s in input().split()]
    for x in Line:
        treat_list.add(x)
        # print(treat_list)
print(N - len(treat_list))

Submission status: Accepted

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

s=[0]*n

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

print(s.count(0))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N,K=map(int,input().split())
A=[]
sunuke=[False]*N
ds=[]
ans=0
for k in range(K):
    d=int(input())
    ds.append(d)
    a=list(map(int,input().split()))
    A.append(a)

for i in range(K):
    for j in range(ds[i]):
        sunuke[A[i][j]-1]=True


for i in range(N):
    if sunuke[i]==False:
        ans+=1
print(ans)

Submission status: Accepted

Solution code:
# coding:utf-8

import sys
import math
import time
#import numpy as np
import collections
from collections import deque
from collections import Counter
import queue
import copy
import bisect
import heapq
import itertools


#sys.setrecursionlimit(10**7)
#N, Q = map(int, input().split())
#G = [list(input()) for i in range(H)]
#INF = V * 10001
#A = [int(i) for i in input().split()]
#AB = [list(map(int, input().split())) for _ in range(K)]


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

print(Human.count(0))

Submission status: Accepted

Solution code:
N, K = map(int, input().split(' '))
# print('recv', N,K)
d = []
A = []
for n in range(K):
    d.append(int(input()))
    # print('recv', d[-1])

    if d[-1] > 1:
        A.append(list(map(int, input().split(' '))))
        # print('recv', A[-1])
    else:
        A.append([int(input())])
        # print('recv', A[-1])

itazurasareru = [0] * N

for k in range(K):
    # print(k)
    cnt = d[k]
    a = A[k]
    # print(a)
    for i in range(cnt):
        # print(i)
        itazurasareru[a[i]-1] += 1

print(sum([ 1 for sunuke in itazurasareru if sunuke == 0 ]))

Submission status: Accepted

Solution code:
import sys
#sys.exit()
#sorted( ,reverse=True)
#N = int(input())
N,K = map(int, input().split())
A = []
for i in range(K):
    d = int(input())
    B = list(map(int, input().split()))
        
    A += B 
   #print(B)
   #print(A)    

#A = [int(input()) for _ in range(N)]

cnt = N
for i in range(1,N+1):
    if i in A:
        cnt -= 1



#print(N)
#print(S,T)
#print(A)
#print('Yes')
#print('No')
print(cnt)

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
S=[]
for i in range(2*K):
    a = input().split()
    if i%2 ==1:
        S.extend(a)

print(N-len(set(S)))

Submission status: Accepted

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

for i in range(K):
    d=int(input())
    A=[int(x) for x in input().split()]
    for j in range(d):
        SET.append(A[j-1])
SET=set(SET)    
print(N-len(SET))

Submission status: Accepted

Solution code:
n,k = map(int,input().split())
N = list(range(1,n+1))
A = set()
count = 0
for i in range(k):
  d = int(input())
  Ad = list(map(int,input().split()))
  for j in range(d):
    A.add(Ad[j])

for i in range(n):
  if N[i] in A:
    count += 1

print(n-count)

Submission status: Accepted

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

snuke_list = [0]*N
for i in range(K):
  snuke_sayisi = int(input())
  snukes = list(map(int, input().split()))
  for snuke in snukes:
    snuke_list[snuke-1] += 1
ans = 0
for i in snuke_list:
  if i == 0:
    ans += 1
print(ans)

Submission status: Accepted

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

person = set(range(1,n+1))
for i in range(k):
    d = int(input())
    a = list(map(int,input().split()))
    for j in range(d):
        if a[j] in person:
            person.discard(a[j])

print(len(person))

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

listn = []
for i in range(n):
    listn.append(i+1)

for i in range(len(a)):
    a_ex = a[i]
    for j in range(len(a_ex)):
        if (a_ex[j] in listn):
            listn.remove(a_ex[j])

print(len(listn))

Submission status: Accepted

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

for v in range(k):
    d_ = int(input())
    d__ = input()
    d_l = list(map(int, d__.split(" ")))
    for v in range(d_):
        m = d_l[v]
        L[m-1] += 1
print(L.count(0))

Submission status: Accepted

Solution code:
N,K=map(int,input().split())
l=[0]*N
count=0
for i in range(K):
    d=int(input())
    A=list(map(int,input().split()))
    for index ,m in enumerate(A):
        l[m-1]+=1
for i in range(N):
    if l[i]==0:
        count+=1
print(count)

Submission status: Accepted

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

flag=1
ans=0
for i in range(n):
    for j in a:
        if str(i+1) in j:
            flag=0
    if flag==1:
        ans+=1
    flag=1
print(ans)

Submission status: Accepted

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

cnt = 0
ans = []
for a in A:
  for i in a:
    if i not in ans:
      ans.append(i)
print(n-len(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())))

sunuke = [0] * (N+1)

for k in A:
  for a in k:
    sunuke[a] += 1

print(sunuke.count(0)-1)

Submission status: Accepted

Solution code:
import collections

n,k = map(int,input().split())
listA=[] #appendのために宣言が必要
while True:
    try:
        listA.append(list(map(int,input().split())))

    except:
        break;
        #または、quit(),os.exit()をして止める。

listB=[] 

for i in range(k):
  listB+=listA[2*i+1]
  
c = collections.Counter(listB)  
print(n-len(c))

Submission status: Accepted

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

x = list()
for i in range(k):
  d = int(input())
  y = list(map(int,input().split()))
  x += y 
    
x = sorted(x)
cnt = 0
for i in range(n):
  if i+1 in x:
    cnt +=1
    
print(n-cnt)

Submission status: Accepted

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

has_n = []

for i in range(k):
    d = int(input())
    a = input()
    tmp = a.split()
    has_n.extend(tmp)
has_n = set(has_n)
print(n - len(has_n))

Submission status: Accepted

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

Submission status: Accepted

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

print(N-len(have_snack))

Submission status: Accepted

Solution code:
n, k = map(int,input().split())
sets = set(range(1, n + 1))
for i in range(k):
    d = int(input())
    li = list(map(int,input().split()))
    for j in li:
        if j in sets:
            sets.discard(j)

print(len(sets))

Submission status: Accepted

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

# 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():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()

    N = int(next(tokens))  # type: str
    K = int(next(tokens))  # type: str
    # print(N, K)
    g = set()
    for _ in range(K):
        d = int(next(tokens))
        g = g | set([int(next(tokens)) for i in range(d)])

    print(N - len(g))    

    return


if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
N, K = [int(n) for n in input().split()]
o = {}
for i in range(1, N+1):
    o[i] = False
for j in range(K):
    d = int(input())
    for k in [int(n) for n in input().split()]:
        o[k] = True
print(list(o.values()).count(False))

Submission status: Accepted

Solution code:
N, K = map(int, input().split())  #数字
A = [list(map(int, input().split())) for i in range(K*2)]  #数字、複数行複数列

cou = []
for i in range(len(A)):
    if (i+1) % 2 == 0:
#        print(i)
        for j in A[i]:
#            print(j)
            cou.append(j)   

#print(cou)
print(N - len(set(cou)))

Submission status: Accepted

Solution code:
NK = input().split()  #N 人のすぬけ君 K 種類のお菓子
N = int(NK[0])
K = int(NK[1])

L = [] #お菓子を持っている人番号のリスト

for i in range(K):
  d = int(input())
  A = input().split()
  for k in range(d):
    if not int(A[k]) in L:
      L.append(int(A[k]))


solution = N - len(L)
print(solution)

Submission status: Accepted

Solution code:
N,K = map(int,input().split())
number_of = [0]*N
for i in range(K):
  d = int(input())
  who_has = [int(x) for x in input().split()]
  for j in range(d):
    number_of[who_has[j]-1]+=1
print(number_of.count(0))

Submission status: Accepted

Solution code:
(N,K) = map(int,input().split())
man_list = []
for i in range(K):
    D = int(input())
    man_ele = list(map(int,input().split()))
    for j in man_ele:
        man_list.append(j)

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

Submission status: Accepted

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

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

s = set()

for i in range(k):
    d = int(input())
    a = list(map(int, input().split()))
    for a_i in a:
        s.add(a_i)

print(n-len(s))

Submission status: Accepted

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

l =[]
okashi = set(l)

for i in range(k):
  d = int(input())
  A = list(map(int, input().split()))
  for a in A:
    okashi.add(a)

print(n - len(okashi))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,k=list(map(int, input().split()))
dic={}
for i in range(k):
  j=int(input())
  l=list(map(int, input().split()))
  for a in l:
    if a not in dic:
      dic[a]=True
x=len(list(dic.keys()))
print(n-x)

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
treat = []
for i in range(K):
    d = int(input())
    snack = input().split()
    for l in snack:
        if l not in treat:
            treat.append(l)
print(N-len(treat))

Submission status: Accepted

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

#print(Alist)
import itertools
Alist=list(itertools.chain.from_iterable(Alist))
#print(Alist)
Alist=list(set(Alist))
#print(Alist)
print(N-len(Alist))

Submission status: Accepted

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

for i in range(K):
    d = int(input())
    #print(d)

    A_d = list(map(int, input().split()))
    for i in A_d:
        N_i[i-1] = 1
        




print(N_i.count(0))

Submission status: Accepted

Solution code:
import collections
n,k=map(int,input().split())
a=[]
for i in range(0,k):
  d_i=int(input())
  a_i=list(map(int,input().split()))
  a=a+a_i
a=collections.Counter(a)
print(n-len(a))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

#intl = [1,1,1,2,2,2,2,2,2,2,3,3,3,3,4,4,4]
#print(ints[1]) # 3

n, k = map(int, input().replace("\n","").split())

snuke =  [0] * n
# print(snuke)

havelist = []

for i in range(k):
    d = int(input())
    a = list(map(int, input().replace("\n","").split()))

    havelist.extend(a)

have = len(list(set(havelist)))
print(n-have)

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
X = [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):
    X[A[j]-1] += 1

print(X.count(0))

Submission status: Accepted

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

set_i = set()

for i in range(k):
  d = input()
  s = map(int,input().split())
  for s_ in s:
    set_i.add(s_)

print(n-len(set_i))

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 i in range(len(a)):
        if a[i] not in b:
            b.append(a[i])
#print(b)
print(n-len(b))

Submission status: Accepted

Solution code:
n, k = [int(i) for i in input().split(' ')]
a, d = [], []
for i in range(2*k):
  if (i%2)==0:
    d.append(int(input()))
  else:
    a.extend([int(j) for j in input().split(' ')])

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

Submission status: Accepted

Solution code:
import collections

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

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


c = collections.Counter(A)

print(N - len(c))

Submission status: Accepted

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

import sys
import math


debug = False

def log(text):
    if debug:
        print(text)

def parse_input(lines_as_string = None):

    global debug
    lines = []
    if lines_as_string is None:
        debug = False
        # for line in sys.stdin:
        #     lines.append(line)
        lines.append(input())
        (n, k) = [int(e) for e in lines[0].split(' ')]
        for i in range(2*k):
            lines.append(input())
    else:
        debug = True
        lines = [e for e in lines_as_string.split("\n")][1:-1]
        (n, k) = [int(e) for e in lines[0].split(' ')]

    d = [] 
    a = []
    for i in range(1, 2*k+1):
        if i % 2 == 1:
           d.append(int(lines[i]))
        else:
           a.append([int(e) for e in lines[i].split(' ')])

    return (n, k, d, a)


def solve(n, k, d, a):


    candy_a = set() 
    for i in range(k):
        for e in a[i]:
            candy_a.add(e)

    result = n - len(candy_a)

    return result
    


def main():
    # 出力
    result = solve(*parse_input())
    if isinstance(result, list):
        for r in result:
            print("%s" % r, sep='')
    else:
        print("%s" % result, sep='')

if __name__ == '__main__':

    main()

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
x = []

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

for i in range(n):
    x.append(0)

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

    for sweet in sweets:
        x[sweet-1] = 1

print(x.count(0))

Submission status: Accepted

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

# = [int(input()) for i in range(N)]
# = [list(map(int, input().split())) for i in range(N)]
d = []
A = []
count = []

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

for i in range(K):
    for j in range(d[i]):
        count.append(A[i][j])

answer = list(set(count))

print(N - len(answer))

Submission status: Accepted

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

p = [0]*N
for i in range(K):
    n = int(input())
    ks = [int(j) for j in input().split()]
    # print(ks)
    for k in ks:
        p[k-1] = 1
print(p.count(0))

Submission status: Accepted

Solution code:
line = input()
n, k = line.split(" ")
n, k = int(n), int(k)
kashi_list = []

for i in range(k):
    d = int(input())
    line = input()
    temp = line.split(" ")
    for t in temp:
        kashi_list.append(t)

print(n - len(set(kashi_list)))