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())
s=[]
for i in range(n):
  s.append(0)


for i in range(k):
  d=int(input())
 
  List=list(map(int,input().split()))
  for i in range(d):
    s[List[i]-1]=1
print(n-sum(s))

Submission status: Accepted

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

print(a.count(0))

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
group = set()
for _ in range(k):
  no = input()
  okashi = list(map(int, input().split()))
  for i in okashi:
  	group.add(i)
print(n - len(group))

Submission status: Accepted

Solution code:
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.buffer.readline().split()]
def I(): return int(sys.stdin.buffer.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()
    d = [0]*n
    for _ in range(k):
        LI()
        a = LI()
        for i in a:
            d[i-1] = 1
    print(n-sum(d))
    return

#Solve
if __name__ == "__main__":
    solve()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import defaultdict as dc
n,k = map(int,input().split())
DICT = dc(lambda:0)
for i in range(k):
    d = int(input())
    l = list(map(int,input().split()))

    for i in range(d):
        DICT[l[i]]+=1
ans = 0
for i in range(1,n+1):
    if DICT[i] == 0:
        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())))

okashi = [0] * N

for l in range(K):
    for i in A[l]:
        okashi[i-1] += 1

count = 0
for i in okashi:
    if i == 0:
        count += 1

print(count)

Submission status: Accepted

Solution code:
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    n, k = list(map(int, readline().split()))

    snuke = [False] * n

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

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

if __name__ == '__main__':
    main()

Submission status: Accepted

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

for i in range(K):
  d = int(input())
  A = list(map(int, input().split()))
  for p in A:
    L[p - 1] = 1
  
print(L.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 a in A:
        t[a - 1] += 1
print(t.count(0))

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
ans = list(range(1,n+1))
num_list = []
for i in range(2*k) :
    num_list.append(list(map(int, input().split())))

for i in range(0,k) :
    del num_list[i]

for value in num_list :
    for values in value :
        if values in ans :
            ans.remove(values)

print(len(ans))

Submission status: Accepted

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

for i in range(k):
	d = int(input())
	s.update([int(x) for x in input().split()])

ans = 0

for x in range(1,n+1):
	if x not in s:
		ans += 1

print(ans)

Submission status: Accepted

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

for i in range(0, K):
  input()
  shuger = map(int, input().split())
  for n in shuger:
    member[int(n)-1]=0
print(member.count(1))

Submission status: Accepted

Solution code:
import itertools
N, K = map(int, input().split())
d_list = []
A = []
a_set = set()
al_set = {i for i in range(1, N+1)}
for i in range(K):
    d_list.append(int(input()))
    A.append(list(map(int, input().split())))
for i in itertools.chain.from_iterable(A):
    a_set.add(i)
print(len(al_set - a_set))

Submission status: Accepted

Solution code:
n, k = [int(i) for i in input().split()]
list_ = [False for _ in range(n)]
for _ in range(k):
  d = int(input())
  a = [int(i) for i in input().split()]
  for i in a:
    list_[i-1] = True
count = 0
for i in list_:
  if not i:
    count += 1
print(count)

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())
A = []
d = []
for i in range(K):
    d.append(int(input()))
    A.append(list(map(int, input().split())))

count = 0
flag = 0
for i in range(N):
    flag = 0
    for j in range(K):
        if (i+1 in A[j]) is True:
            flag = 1
            break
    if flag == 0:
        count += 1
print(count)

Submission status: Accepted

Solution code:
(a,b) = input().split()
a = int (a)
a = a + 1
b = int (b)
list_a = set(range(1,a,1))
for i in range(b):
    c = input()
    d = input().split()
    d = set(map(int,d))
    list_a = list_a-d
print(len(list_a))

Submission status: Accepted

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

N,K = list(map(int, input().rstrip().split()))
#-----

sunuke_dic = {}

for i in range(1,K+1):
    d = int(input().strip())
    A_list = list(map(int, input().rstrip().split()))
    
    for a in A_list:
        sunuke_dic.setdefault(a,[])
        sunuke_dic[a].append(i)


cnt = 0
for i in range(1,N+1):
    if i not in sunuke_dic:
        cnt += 1


print(cnt)

Submission status: Accepted

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

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

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

print(str(ans))

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
q = set([])
for _ in range(K):
    d = int(input())
    tmp = list(map(int, input().split()))
    for i in range(d):
        q.add(tmp[i])

ans = N - len(q)

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

# from collections import deque

def linput(_t=int):
    return list(map(_t, input().split()))

def gcd(n,m):
    while m: n,m = m, n%m
    return n

def lcm(n,m): return n*m//gcd(n,m)

def main():
    # N = int(input())
    N,K = linput()
    # vH = linput()
    # vE = [linput() for _ in [0,]*M]

    # vH = [0,] + vH
    vV = [0,] + [0,]*N

    # res = 0
    # for s in S.split("-"):
    #     res = max(res, len(s))

    for i in range(K):
        X = int(input())
        vL = linput()
        for j in vL:
            vV[j] = 1
        
    res = N - sum(vV)


    # res = 0
    print(res)

    # print(("No","Yes")[res%2])


main()

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7 # 998244353
input=lambda:sys.stdin.readline().rstrip()
def resolve():
    n, k = map(int,input().split())
    have = [False] * n
    for _ in range(k):
        input()
        for a in map(int,input().split()):
            have[a - 1] = True
    print(n - sum(have))
resolve()

Submission status: Accepted

Solution code:
def main():
    import sys
    N,K=list(map(int,sys.stdin.readline().split()))
    st=set()
    for i in range(K):
        d=int(sys.stdin.readline())
        A=list(map(int,sys.stdin.readline().split()))
        st=st|set(A)
    print(N-len(st))
    
main()

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
ql = [tuple(map(int, input().split())) for i in range(2*m)]
a = ql[1::2]
b = []
for x in a:
    b += x
ans = n - len(set(b))
print(ans)

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
cnt = [0] * N
for _ in range(K):
    _ = int(input())
    for a in map(int, input().split()):
        cnt[a - 1] += 1

print(cnt.count(0))

Submission status: Accepted

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

count = [0] * N

for _ in range(K):
    d = int(input())
    for v in input().split():
        j = int(v) - 1
        count[j] += 1

sunuke = 0
for i in count:
    if i == 0:
        sunuke += 1

print(sunuke)

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


def read_tuple(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


def read_col(H):
    '''
    H is number of rows
    A列、B列が与えられるようなとき
    ex1)A,B=read_col(H)    ex2) A,=read_col(H) #一列の場合
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return tuple(map(list, zip(*ret)))


def read_matrix(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return ret
    # return [list(map(int, read().split())) for _ in range(H)] # 内包表記はpypyでは遅いため


MOD = 10**9 + 7
INF = 2**31  # 2147483648 > 10**9
# default import
from collections import defaultdict, Counter, deque
from operator import itemgetter
from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right  # , insort_left, insort_right
from math import gcd

N, K = read_ints()
is_okasi = [False] * N  # お菓子を持ってるスヌケ
for _ in range(K):
    read()
    A = read_ints()
    for a in A:
        is_okasi[a - 1] = True
# print(is_okasi)
print(N - sum(is_okasi))

Submission status: Accepted

Solution code:
a,b=input().split()
c=int(a)
d=int(b)
e=[]
for i in range(c):
    e.append(i+1)
for j in range(d):
    f=int(input())
    g=input().split()
    h=[int(s) for s in g]
    for n in range(len(h)):
        if h[n] in e:
            e.remove(h[n])
print(len(e))

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(300000)

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LMI(): return list(map(int, sys.stdin.readline().split()))
MOD = 10 ** 9 + 7
INF = float('inf')


N, K = MI()
s = set()
for i in range(K):
    I()
    for a in LMI():
        s.add(a)

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=map(int,input().split())
ans={k:0 for k in range(1,N+1)}
for i in range(1,K+1):
    d=int(input())
    l=list(map(int,input().split()))
    for item in l:
        ans[item]=ans[item]+1 
count=0
for i in ans:
    if ans[i]==0:
        count+=1
print(count)

Submission status: Accepted

Solution code:
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.buffer.readline().split()]
def I(): return int(sys.stdin.buffer.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 = map(int,input().split())
    count = [0]*N
    
    for i in range(K):
      d = int(input())
      A = list(map(int,input().split()))

      for s in range(d):
        a = A[s]
        count[a-1] += 1

    print(count.count(0))
    return

#Solve
if __name__ == "__main__":
    solve()

Submission status: Accepted

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

import fractions
import copy
import bisect
import math
import numpy as np
import itertools
from itertools import combinations_with_replacement
#import math#数学的計算はこれでいける。普通に0.5乗しても計算可能
#w=input()
from operator import itemgetter
from sys import stdin
#input = sys.stdin.readline#こっちの方が入力が早いが使える時に使っていこう
from operator import mul
from functools import reduce
from collections import Counter
import collections
#from collections import deque

#input = stdin.readline


j=0
k=0
n=3
r=1
a=[0]
#n=int(input())
#r=int(input())
#print(M)
#A=int(input())
#B=int(input())
#print(N)
"1行1つの整数を入力を取得し、整数と取得する"


#number_list=list(map(int, input().split(" ")))#数字の時
#print(number_list)
"12 21 332 とか入力する時に使う"
"1行に複数の整数の入力を取得し、整数として扱う"

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
#メモ
for i in number_list:#こっちの方がrage使うより早いらしい
    print(number_list[i-1])#

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

'''
x=[]
y=[]
for i in range(N):
    x1, y1=[int(i) for i in input().split()]
    x.append(x1)
    y.append(y1)
print(x)
print(y)
"複数行に2数値を入力する形式 x座標とy座標を入力するイメージ"
'''

'''
mixlist=[]
for i in range(N):
    a,b=input().split()
    mixlist.append((int(a),b))
print(mixlist)
"複数行にintとstrを複合して入力するやつ，今回はリスト一つで処理している"
'''

'''
#array=[input().split()for i in range(N)]
#print(type(array[0][0]))
#print(array)
"正方行列にstr型の値を入力"
'''

#brray=[list(map(int, input().split(" ")))for i in range(N)]
#print(type(brray[0][0]))
#print(brray)
'''
入力
1 2
4 5
7 8
出力結果
[[1, 2], [4, 5], [7, 8]]
'''
"列数に関して自由度の高いint型の値を入力するタイプの行列"
#以下に別解を記載
#N, M = [int(i) for i in input().split()]
'''
table = [[int(i) for i in input().split()] for m in range(m)]

print(type(N))
print(N)
print(type(M))
print(M)

print(type(table))
print(table)
'''




#s=input()
#a=[int(i) for i in s]
#print(a[0])
#print([a])
#単数値．桁ごとに分割したい．入力と出力は以下の通り
#イメージとして1桁ごとにリストに値を入れているかんじ
#intを取ると文字列分解に使える
'''
入力
1234
出力
1
[[1, 2, 3, 4]]
'''




'''
word_list= input().split(" ")
print(word_list[0])
"連続文字列の入力"
"qw er ty とかの入力に使う"
"入力すると空白で区切ったところでlistの番号が与えられる"
'''



'''
A, B, C=stdin.readline().rstrip().split()#str style 何個でもいけることが多い
print(A)
"リストではなく独立したstr型を入れるなら以下のやり方でOK"
'''


#a= stdin.readline().rstrip()
#print(a.upper())
"aという変数に入っているものを大文字にして出力"


#a,b=map(int, input().split())  #int style 複数数値入力　「A B」みたいなスペース空いた入力のとき

#なんかうまく入力されるけど
#a=[[int(i) for i in 1.strip()]for 1 in sys.stdin]
#a = [[int(c) for c in l.strip()] for l in sys.stdin]]
#print(a)
#複数行の数値を入力して正方行列を作成


##############################################################################################
##############################################################################################
#under this line explains example calculation

'''
コンビネーションの組み合わせの中身を出力する形式
for i in itertools.combinations(brray, 2)
combinationsをpermutationsにすれば順列になる
今回なら(abc133B)
入力
1 2
5 5
-2 8
出力
[[1, 2], [5, 5], [-2, 8]]
もちろん一次元リストでも使えるし
何よりiもリストのように使えるので便利
'''

#nCr combination
'''
def cmb(n,r):
    #When n < r , this function isn't valid
    r= min(n-r,r)
    #print(n,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n-r, -1))
    #flochart mul(n,n-1)=x
    #next     mul(x,n-2)........(n-r+1,n-r)
    #mul read a,b and returns a*b

    under = reduce(mul, range(1, r+1))
    #print(over, under)
    #reduce is applied mul(1,2)=2
    #next   mul(2,3)=6
    #next   mul(6,4)=4.........last(r!,r+1)=r+1!

    return over // under
    #// is integer divide
    #calc example 5C2
    #over=5*4*3
    #under=3*2*1
a = cmb(n, r)
#print(a)
'''

'''
import itertools
from itertools import combinations_with_replacement

combinationについて
以下の違いを意識しよう
combinations() p, r 長さrのタプル列、ソートされた順で重複なし

combinations_with_replacement() p, r 長さrのタプル列、ソートされた順で重複あり


使用例 　　　　　　　　　　　                  出力　　
combinations('ABCD', 2)　　　　　　　　　　　　AB AC AD BC BD CD

combinations_with_replacement('ABCD', 2)　　 AA AB AC AD BB BC BD CC CD DD
'''



'''
#集計
#example
#a=[2,2,2,3,4,3,1,2,1,3,1,2,1,2,2,1,2,1]
#a=Counter(a)
for i in a.most_common(n):print(i)
#most_common()メソッドは、出現回数が多い要素順にCounterオブジェクトを並び替えます。
#引数にint型の数字nを設定した場合は、出現回数が高い上位ｎ個の要素を返します。
#何も設定しなければ、コンテナ型にあるすべての要素を出現回数の順番に並び替えたタプル型オブジェクトを返します。
#out put
#(2, 8)
 #(1, 6)
#(3, 3)
#(4, 1)
'''


#二部探索(binary search)
#A = [1, 2, 3, 3, 3, 4, 4, 6, 6, 6, 6]
#print(A)
#index = bisect.bisect_left(A, 5) # 7 最も左(前)の挿入箇所が返ってきている
#A.insert(index, 5)
#print(index)
#print(A)
'''
bisect.bisect_left(a, x, lo=0, h=len(a))
引数
a: ソート済みリスト
x: 挿入したい値
lo: 探索範囲の下限
hi: 探索範囲の上限
(lo, hiはスライスと同様の指定方法)
bisect_leftはソートされたリストaに対して順序を保ったままxを挿入できる箇所を探索します。leftが示す通り、aにすでにxが存在している場合は、挿入箇所は既存のxよりも左側になります。また、lo, hiを指定することで探索範囲を絞り込むことも可能です。デフォルトはaの全体が探索対象です。
'''





########################################################################
########################################################################
#b2=a[:]  #1次元のときはコピーはこれで良い
#print(b2)

#a= [[0]*3 for i in range(5)] #2次元配列はこう準備、[[0]*3]*5だとだめ
#b3=copy.deepcopy(a)  #2次元配列はこうコピーする
#print(b3)

def main():


    j=0
    k=0
    #n=int(input())
    #r=int(input())

    N,K=map(int, input().split(" "))
    d_lis=[]

    k_lis=[[] for i in range(K)]
    #print(k_lis)
    c_lis=[]
    pp=0
    d_lis=[]
    "1行1つの整数を入力を取得し、整数と取得する"
    for i in range(N):
        c_lis.append(i+1)

    for i in range(K):
        d_lis.append(int(input()))
        k_lis[i]=list(map(int, input().split(" ")))
    #    for j in range(len(number_list)):
    #        #c_lis.remove(t_lis[j])
    #        print(number_list[j])
    #        pp=int(number_list[j])
    #        c_lis.apped(pp)
        number_list=[]
    #brray=[list(map(int, input().split(" ")))for i in range(N)]

    #print(len(c_lis))
        #k_lis[i].append(map(int, input().split(" ")))
    #brray=[list(map(int, input().split(" ")))for i in range(N)]
    #print(type(brray[0][0]))
    #print(brray)
    #number_list=list(map(int, input().split(" ")))#数字の時
    #print(k_lis)
    "12 21 332 とか入力する時に使う"
    "1行に複数の整数の入力を取得し、整数として扱う"
    #for i in range(N):
    #    c_lis.append(i+1)
    #ss=0
    #ss=collections.Counter(t_lis)
    #print(t_lis)#mapオブジェクトが入っとる
    #print(collections.Counter(t_lis))
    ss=collections.Counter(tuple(itertools.chain.from_iterable(k_lis)))
    #print(k_lis)#mapオブジェクトが入っとる
    #print(collections.Counter(t_lis))
    #l = ['a', 'a', 'a', 'a', 'b', 'c', 'c']
    #c = collections.Counter(l)
    #print("ss", len(ss))
    #print("aaaa",len(c))
    #ss=len(set(t_lis))
    print(N-len(ss))
    #s=input()
    #a=[int(i) for i in s]#int取るとstrでも行ける
    #print(a)
    '''
    入力
    1234
    出力
    [1, 2, 3, 4]
    '''



if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import itertools
N, K = map(int, input().split())
d = [0]*K
a = [0]*K

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

menber = list(range(1, N+1))
have_list = list(set(itertools.chain.from_iterable(a)))

res = len(menber) - len(have_list)
print(res)

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
lst = []
tmp = []
count = 0
for i in range(k):
    d = int(input())
    a = input().split()
    lst.append(a)
for i in range(k):
    tmp.extend(lst[i])
for j in range(1, n+1):
        if str(j) not in tmp:
            count +=1
print(count)

Submission status: Accepted

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

print(snukes.count(0))

Submission status: Accepted

Solution code:
n, k = [int(i) for i in input().split()]
ds = []
As = []
for i in range(k):
    ds.append(int(input()))
    As += [int(j) for j in input().split()]
 
 
print(n-len(set(As)))

Submission status: Accepted

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

A = []
for i in range(K):
    a = int(input())
    b = list(map(int, input().split()))
    for n in b:
        if n not in A:
            A.append(n)
count = 0

for i in A:
    count += 1

print(N - count)

Submission status: Accepted

Solution code:
count = 0 #お菓子を持っていない人数
N, K = map(int, input().split()) #N,Kの入力
#print(N, K)

array = [0] * N #要素が0のN人分の要素を持つ配列を用意
#print(array)

for b in range(1,K+1): #K個のお菓子分繰り返す
    a = int(input()) #お菓子bを計何人持っているか
    i = list(map(int, input().split())) #お菓子を持っている人の番号
    #print(i[0])
    for c in range(a):
        #print(a, array[i[c]])
        array[i[c]-1] = 1


for k in range(N):
    if array[k] == 0:
        count += 1
#print(array)
print(count)

Submission status: Accepted

Solution code:
#list全要素にadd 1
def add_list(LIST):
    return LIST +1
####################################
def flatten(nested_list):
    """2重のリストをフラットにする関数"""
    return [e for inner_list in nested_list for e in inner_list]
####################################

N, K = (int(x) for x in input().split())
List_1 = []
List_2 = []
for  i in range(K):
    List_1.append([int(input())])
    List_2.append([int(y) for y in input().split()])

men = list(range(N))
men_add = list(map(lambda z: z + 1, men))

flatten_list = flatten(List_2)

#人のlistの中から、お菓子を持っている人を削除。listに値がないとエラーになるので、例外処理も追加
for j in range(len(set(flatten_list))):
    try:
        men_add.remove(j+1)
    except ValueError:
        pass

print(len(men_add))

Submission status: Accepted

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

for i in range(len(d)):
    if len(a[i]) == 0:
        count[a[i]-1] = True
    else:
        for j in range(len(a[i])):
            count[a[i][j]-1] = True

print(count.count(None))

Submission status: Accepted

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

snukes_arr = [0 for i in range(no_snukes)]


for i in range(types_snacks):
    snack = int(input())
    snukes_who_have = list(map(int, input().split()))
    for s in snukes_who_have:
        snukes_arr[s-1] += 1

dead_boy = 0

for i in range(len(snukes_arr)):
    if snukes_arr[i] == 0:
        dead_boy += 1

print(dead_boy)

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
sunuke=[0]*n
cnt=0
for i in range(k):
	num=int(input())
	a=list(map(int,input().split()))
	#print(i,a)
	for i in a:
		sunuke[i-1]+=1
#print(sunuke)
for i in range(n):
	if sunuke[i]==0:
		cnt+=1
print(cnt)

Submission status: Accepted

Solution code:
n,k = (int(x) for x in input().split())
a_list=[]
for i in range(k):
    d=int(input())
    a=list(map(int, input().strip().split()))
    a_list.extend(a)
#print(a_list)
count=0

for i in range(1,n+1):
    if i in a_list:
        pass
    else:
        count+=1
print(count)

Submission status: Accepted

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

        

print(len(set(a)-set(l)))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
A_list  =[]
import numpy as np
nuske = np.zeros(n)

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

p =0

for i in range(len(nuske)):
    if nuske[i] ==0:
        p+=1

print(p)

Submission status: Accepted

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

num_list = []
d = []
for i in range(N):
  try:
      d.append(list(map(int,input().split())))
      num_list.append(list(map(int,input().split())))
  except EOFError:
    pass
  
#those who has snack
snack = set(sum(num_list, []))

ppl = []
for i in range(N):
    ppl.append(N)
    N -= 1
    
nsnack = set(ppl) - snack
nosnack = list(nsnack)

print(len(nosnack))

Submission status: Accepted

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

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

cnt = 0                    
for q in N:
    if q != 0:
        cnt += 1
print(cnt)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    n, k = map(int, input().split())
    sunuke = {}

    for i in range(1, k + 1):
        d = int(input())
        for a in input().split():
            if a in sunuke.keys():
                sunuke[a] += str(i)
            else:
                sunuke[a] = str(i)

    kind_of_sunuke = sunuke.keys()
    count = 0
    for j in range(1, n + 1):
        if str(j) not in kind_of_sunuke:
            count += 1
    print(count)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import collections
N,K=map(int,input().split())
a=[]
d=[]
while K>0:
  K=K-1
  d.append(int(input()))
  b=list(map(int,input().split()))
  a.extend(b)
e=collections.Counter(a)
print(N-len(e))

Submission status: Accepted

Solution code:
# coding: utf-8

N, K = [int(i) for i in input().split()]
snk = [0 for _ in range(N)]
for i in range(K):
    d = int(input())
    a_d = [int(i) for i in input().split()]
    for a in a_d:
        snk[a-1] += 1
print(snk.count(0))

Submission status: Accepted

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


d=[]
a=[]
for i in range(K):
  d.append(input())
  a.extend(map(int,input().split()))

n=[]
for j in range(N):
  n.append(j+1)
  
cnt=0
for j in range(N):
  if a.count(j+1)==0:
    cnt=cnt+1
print(cnt)

Submission status: Accepted

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

have = set()

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

print(n-len(have))

Submission status: Accepted

Solution code:
# coding: utf-8

############################

n,k = map(int,input().split())
s = {i+1 for i in range(n)}

for _ in range(k):
    d = int(input())
    a_set = set(map(int,input().split()))

    s -= a_set

print(len(s))

Submission status: Accepted

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

ans = {}
for i in range(0, K):
  input()
  A_hpge_strlist = input().split(' ')
  for A_hoge_str in A_hpge_strlist:
    ans[int(A_hoge_str)] = 0
print(N - len(ans.keys()))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N,K=map(int,input().split())
a=[list(map(int,input().split()))for i in range(2*K)]
sunuke=[]
for i in range(2*K):
    if i%2==1:
        d=sum(a[i-1])
        for n in range(d):
            sunuke.append(a[i][n])
sunuke=set(sunuke)
print(N-len(sunuke))

Submission status: Accepted

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

print(d.count(0))

Submission status: Accepted

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

Submission status: Accepted

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

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

print(counter)

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
kashi = [0] * n
cnt = 0
M = 0
for s in range(k):
	i=int(input())
	li=list(map(int,input().split()))
	if i > 0:
		for m in li:
			kashi[m-1] +=1

for i in kashi:
	if i == 0:
		cnt += 1

print(cnt)

Submission status: Accepted

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

for k in range(K):
    d=int(input())
    have_k=map(int,input().split())
    for h in have_k:
        a[k][h-1]=1

an=[0]*N
for k in range(K):
  for n in range(N):
    an[n] = an[n]+a[k][n]

result=0
for i in an:
  if i == 0:
    result+=1

print(result)

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
li = []
for i in range(k):
    d = int(input())
    li.append([d, list(map(int, input().split()))])
c = 0
for i in range(1, n+1):
    for j in li:
        if i in j[1]:
            break
    else:
        c += 1
print(c)

Submission status: Accepted

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

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

d1 = list(map(int,d))
a1 = list(map(int,a))

ct = 0

for j in range(1,n+1):
  if a1.count(j)==0:
    ct +=1
print(ct)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N,K = map(int,input().split())
data = []
nolist = list(range(1,N+1))
for i in range(K):
  number = int(input())
  data = input().split()
  for j in range(number):
    nolist[int(data[j])-1] = 0
try:
  for i in range(N):
  	nolist.remove(0)
except:
  pass
print(len(nolist))