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:
#!/usr/bin/env python3
# vim: set fileencoding=utf-8

# pylint: disable=unused-import, invalid-name, missing-docstring, bad-continuation


"""Module docstring
"""

import functools
import heapq
import itertools
import logging
import math
import random
import string
import sys
from argparse import ArgumentParser
from collections import defaultdict, deque
from copy import deepcopy
from typing import Dict, List, Optional, Set, Tuple


def solve(values: List[int], nb: int) -> int:
    for _v in values:
        pass
    return nb


def do_job():
    "Do the work"
    LOG.debug("Start working")
    # first line is number of test cases
    N, K = map(int, input().split())
    snukes = [0] * N
    for _ in range(K):
        snack_nb = int(input())
        snuke_ids = list(map(int, input().split()))
        assert len(snuke_ids) == snack_nb
        for s in snuke_ids:
            snukes[s % N] += s
    # values = []
    # for _ in range(N):
    #     values.append(input().split())
    result = snukes.count(0)
    LOG.debug((snukes))
    print(result)


def print_output(testcase: int, result) -> None:
    "Formats and print result"
    if result is None:
        result = "IMPOSSIBLE"
    print("Case #{}: {}".format(testcase + 1, result))
    # 6 digits float precision {:.6f} (6 is the default value)
    # print("Case #{}: {:f}".format(testcase + 1, result))


def configure_log() -> None:
    "Configure the log output"
    log_formatter = logging.Formatter("%(lineno)d - " "%(message)s")
    handler = logging.StreamHandler(sys.stdout)
    handler.setFormatter(log_formatter)
    LOG.addHandler(handler)


LOG = None
# for interactive call: do not add multiple times the handler
if not LOG:
    LOG = logging.getLogger("template")
    configure_log()


def main(argv=None):
    "Program wrapper."
    if argv is None:
        argv = sys.argv[1:]
    parser = ArgumentParser()
    parser.add_argument(
        "-v",
        "--verbose",
        dest="verbose",
        action="store_true",
        default=False,
        help="run as verbose mode",
    )
    args = parser.parse_args(argv)
    if args.verbose:
        LOG.setLevel(logging.DEBUG)
    do_job()
    return 0


if __name__ == "__main__":
    import doctest

    doctest.testmod()
    sys.exit(main())


class memoized:
    """Decorator that caches a function's return value each time it is called.
    If called later with the same arguments, the cached value is returned, and
    not re-evaluated.
    """

    def __init__(self, func):
        self.func = func
        self.cache = {}

    def __call__(self, *args):
        try:
            return self.cache[args]
        except KeyError:
            value = self.func(*args)
            self.cache[args] = value
            return value
        except TypeError:
            # uncachable -- for instance, passing a list as an argument.
            # Better to not cache than to blow up entirely.
            return self.func(*args)

    def __repr__(self):
        """Return the function's docstring."""
        return self.func.__doc__

    def __get__(self, obj, objtype):
        """Support instance methods."""
        return functools.partial(self.__call__, obj)

Submission status: Accepted

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

Submission status: Accepted

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

sunuke = [0]*(n+1)

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

cnt = 0

for k in range(1, n+1):
    if sunuke[k] == 0:
        cnt += 1

print(cnt)

Submission status: Accepted

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

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

print(n - len(set(v)))

Submission status: Accepted

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

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

for i in range(n):
    if ((i+1) in res) == False:
        c += 1

print(c)

Submission status: Accepted

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

result = {i: 0 for i in range(1, N+1)}
for i in range(1, K+1):
    index = i*2 - 1
    for k in Ad_list[index]:
        result[k] += 1

print(len({k for k, v in result.items() if v == 0}))

Submission status: Accepted

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

Submission status: Accepted

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

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

ans = [0]*N
for i in range(K):
    for j in A[i]:
        ans[j-1] += 1

print(ans.count(0))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N,K = map(int,input().split())
sunuke_list=[str(i) for i in range(1,N+1)]
for i in range(K):
  d=int(input())
  kasi_list = list(map(str,input().split()))
  for j in kasi_list:
    try:
	    sunuke_list.remove(j)
    except:
      pass
    

print(len(sunuke_list))

Submission status: Accepted

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

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

    cnt = [1 for _ in range(n)]
    for i in range(k):
        for b in a[i]:
            cnt[b-1] = 0

    print(sum(cnt))

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
# import math
# from collections import Counter

# N = int(input()) # 1行, 単数
# arg = list(map(int, input().split())) # 1行, 配列
# D = Counter(arg) # 出現数カウント

# print('Yes')
# print('No')
# print()


arg = list(map(int, input().split())) # 1行, 配列

N = arg[0]
K = arg[1]
S = range(1,N+1)
l = []

for i in range(K):
  D = int(input()) # 1行, 単数
  A = list(map(int, input().split())) # 1行, 配列
  for j in A:
    l.append(j)


AM = list(set(S) - set(l))

print(len(AM))

Submission status: Accepted

Solution code:
n,m = map(int,input().split())
#L = list(map(int,input().split()))
L = []
s = set()
for i in range(m):
    li = []
    d = int(input())
    e = list(map(int,input().split()))
    li.append(e)
        #s.add(e)
    L.append(*li)
#print(L,s)
for i in range(m):
    for j in range(len(L[i])):
        s.add(L[i][j])
#print(s)
print(n-len(s))

Submission status: Accepted

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

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

result = 0 
A_all = list(itertools.chain.from_iterable(A_all))
for i in range(1, N + 1):
  if A_all.count(i) == 0:
    result += 1
      
print(result)

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

ml=[]
for ai in a:
    ml.extend(ai)

ml = set(ml)

print(n-len(ml))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,k = map(int,input().split())
a = []
for i in range(k):
    d = int(input())
    f = input().split()
    #fはlen(f)=dの配列
    a.append(f)
b = []
for i in range(len(a)):
    for j in range(len(a[i])):
        b.append(int(a[i][j]))
c =set(b)

d = {i for i in range(1,n+1)}

print(len(d-c))

Submission status: Accepted

Solution code:
import math

def main():
    n, k = map(int, input().split())
    sunuke = [False] * n
    for i in range(k):
        d = int(input())
        A = map(int, input().split())
        for a in A:
            sunuke[a-1] = True

    print(sunuke.count(False))

main()

Submission status: Accepted

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

for L in l:
    if(L == 0):c += 1
print(c)

Submission status: Accepted

Solution code:
N,K = map(int,input().split())
OkashiList = []
KesuList = []
for _ in range(K):
        d = int(input())
        li = list(map(int,input().split()))
        OkashiList.append(li)
for i in OkashiList:
    for j in i:
        if j in KesuList:
            pass
        else:
            KesuList.append(j)
ans = N - len(KesuList)
print(ans)

Submission status: Accepted

Solution code:
import sys

lines = sys.stdin.readlines()

X = lines[0].split(' ')
N = int(X[0])
K = int(X[1])

S =[]
for i in range(N):
    S.append(0)


for j in range(K):
    d = int(lines[2*j +1])
    A = lines[2*j +2].split(' ')
    for k in range(d):
        S[int(A[k])-1] +=1

P = 0
for i in range(N):
    if S[i] == 0:
        P += 1

print(P)

Submission status: Accepted

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

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

for i in range(N):
    if l[i]==0:
        sum += 1

print(sum)

Submission status: Accepted

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

check_list = 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 check_list:
      check_list.remove(j)
print(len(check_list))

Submission status: Accepted

Solution code:
#b
n, k = map(int, input().split())
dn = []
dls = []

for i in range(k):
    dn.append(int(input()))
    dls.append(list(map(int, input().split())))

print(n-len(set(sum(dls,[]))))

Submission status: Accepted

Solution code:
n, k = list(map(int, input().split()))
# d_list = []
# a_matrix = []
is_sunuke_have_sweets_list = [False for _ in range(n)]
for i in range(k):
    d = int(input())
    a_list = list(map(int, input().split()))

    for a in a_list:
        is_sunuke_have_sweets_list[a-1] = True

    # d_list.append(d)
    # a_matrix.append(a_list)

print(is_sunuke_have_sweets_list.count(False))

Submission status: Accepted

Solution code:
import sys, math
import bisect, heapq
import collections

sys.setrecursionlimit(10 ** 6)

input = sys.stdin.readline

gets = lambda: input().rstrip()
getn = lambda: int(input())
getmul = lambda: (int(i) for i in input().split())
getlist = lambda: [int(i) for i in input().split()]

n, k = getmul()
snukes = [1 for _ in range(n + 1)]
for _ in range(k):
    d = getn()
    A = getlist()
    for snuke in A:
        snukes[snuke] = 0

print(sum(snukes) - 1)

Submission status: Accepted

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

for i in range(K):
    d = int(input())
    A = list(map(int,input().split()))
    for j in A:
        sunuke[j-1] = True
        
for person in sunuke:
    if not person:
        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()))
    line = map(int,input().split())
    A.extend(line)

B = set(A)
sunuke = len(B)
print(N-sunuke)

Submission status: Accepted

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

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

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

print(N_list.count(0))

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
ans = [0]*n
for i in range(n): ans[i] = set()
for i in range(k):
    input()
    *a, = map(int, input().split())
    for j in a: ans[j-1].add(i+1)
print(sum(len(i)==0 for i in ans))

Submission status: Accepted

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

have = 0
d = set()
for _ in range(k):
    have += int(input())
    tmp = [int(i) for i in input().split()]
    for t in tmp:
        d.add(t)

print(n-len(d))

Submission status: Accepted

Solution code:
import sys
import numpy as np

n,k=map(int,sys.stdin.readline().split())
ans=[0]*n
cnt=0
for i in range(k):
    d=int(sys.stdin.readline())
    a=sys.stdin.readline().split()
    for j in a:
        ans[int(j)-1]=1
for i in range(n):
    if ans[i]==0:
        cnt+=1
print(cnt)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import numpy as np

N, K = map(int,input().split())
d_list = []
A_list = []
sunuke = np.ones(N)

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

    for j in range(d):
        sunuke[A_list[j]-1] -= 1

nokori = sunuke[sunuke > 0]
print(len(nokori))

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def S(): return input().rstrip()
def LS(): return S().split()
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float("INF")

#solve
def solve():
    n, k = LI()
    ans = [1] * n
    for _ in range(k):
        d = II()
        a = LI_()
        for ai in a:
            ans[ai] = 0
    print(sum(ans))
    return


#main
if __name__ == '__main__':
    solve()

Submission status: Accepted

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

for k in range(K):
    d_i = int(input())
    holder_list = [int(x) for x in input().split(" ")]

    for hi in holder_list:
        A[hi-1] += 1

count_non_holder = 0
for a in A:
    if a == 0:
        count_non_holder += 1

print(count_non_holder)

Submission status: Accepted

Solution code:
def io():
    return map(int,input().split())
def op():
    return list(map(int,input().split()))
n,k=io()
s=set()
c=0
for _ in range(k):
    d=int(input())
    s.update(op())
for i in range(1,n+1):
    if i not in s:
        c+=1
print(c)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

sunuke = [False] * N

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

print(len(list(filter(lambda x:not x, sunuke))))

Submission status: Accepted

Solution code:
import numpy as np
n,k = [int(j) for j in input().split()]
r = np.full(n,False)
for i in range(k):
    d = int(input())
    a = [int(j) - 1 for j in input().split()]
    for j in a:
        r[j] = True
print(n - len(r[r]))

Submission status: Accepted

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

max_n = 0
result = set()
for i in range(K):
    d = int(input())
    A = list(map(int, input().split()))
    for j in A:
        result.add(j)

print(N - len(result))

Submission status: Accepted

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

an = []
for i in a_l:
  for j in i:
    if j not in an:
      an.append(j)
print(n - len(an))

Submission status: Accepted

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

D = []
A = set()
for i in range(K):
    d = int(input())
    a = set(map(int, input().split()))
    A = A.union(a)
print(N - len(A))

Submission status: Accepted

Solution code:
"""
ある街に、N 人のすぬけ君(すぬけ君 1 、すぬけ君 2 、 ...、 すぬけ君 N)が住んでいます。
この街には、 K種類のお菓子(お菓子 1 、 お菓子 2 、....、お菓子 K )が売られています。
お菓子 i を持っているのは、すぬけ君 Ai,1,Ai,2,⋯,Ai,di の計 di人です。
高橋君は今からこの街を回り、お菓子を 1つも持っていないすぬけ君にいたずらをします。
このとき、何人のすぬけ君がいたずらを受けるでしょうか。
制約

    入力は全て整数
    1≤N≤100

1≤K≤100
1≤di≤N
1≤Ai,1<⋯<Ai,di≤N
"""
n,k=map(int,input().split())
a=[[] for ii in range(k)]
d=[0]*k
r=[1]*n
for ii in range(k):
  d[ii]=int(input())
  a[ii]=[]*d[ii]
  a[ii][:]=map(int,input().split())
  for jj in range(d[ii]):
    r[a[ii][jj]-1]=0
print(sum(r))

Submission status: Accepted

Solution code:
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))

from collections import defaultdict
from sys import exit
import math


def main():
    n, m= getList()
    snu = [0 for _ in range(n)]

    for _ in range(m):
        a = getN()
        nums = getList()
        for num in nums:
            snu[num-1] += 1
    ans = 0
    for sn in snu:
        if sn == 0:
            ans += 1

    print(ans)
if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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

l=[]

for x in range(k):
    for y in a[2*x+1]:
        l.append(y)
print(n-len(set(l)))

Submission status: Accepted

Solution code:
N,K = map(int, input().split())
AD = []
D = []
A = []
for i in range(K):
    D_temp = input()
    A_temp = input().split()
    AD.append([[D_temp],[A_temp]])
    D.append(D_temp)
    for i2 in A_temp:
        A.append(i2)
print(N - len(set(A)))

Submission status: Accepted

Solution code:
input_line = input().split(" ")
N, K = list(map(int, input_line))
A_i = []
for i in range(K):
	d_i = int(input())
	A_i = A_i + list(map(int, input().split(" ")))

A_i = set(A_i)
print(N - len(A_i))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
l1=input().split(" ")
n=int(l1[0])
k=int(l1[1])
list=[range(n)]
kashi=[]
for i in range(k):
  tmp=input()
  num=input().split(" ")
  for j in num:
    kashi.append(j)
kashi=set(kashi)
print(n-len(kashi))

Submission status: Accepted

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

Submission status: Accepted

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

snack_cnt = set()

for _ in range(K):
    d = int(input())
    array = [int(i) for i in input().split()]
    for p in array:
        snack_cnt.add(p)

print(N - len(snack_cnt))

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
hashmap=dict()
for _ in range(k):
  d=int(input())
  arr=[int(p) for p in input().split()]
  for key in arr:
    hashmap[key]=d
count=0
for i in range(1,n+1):
  if hashmap.get(i)==None:
    count+=1
print(count)

Submission status: Accepted

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

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    N,K=MI()
    used=[0]*N
    for i in range(K):
        d=I()
        A=LI()
        for j in range(d):
            used[A[j]-1]=1
            
    print(N-sum(used))
        
    

main()

Submission status: Accepted

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

have = set()

for i in range(k):
    d = int(input())
    astr = input()
    ai = astr.split(' ')
    for a in ai:
        have.add(int(a))

print(n-len(have))

Submission status: Accepted

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

print(Okashi.count(0))

Submission status: Accepted

Solution code:
import numpy as np

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

mat = np.array([[False] * N for i in range(K)])

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

mat = mat.T

ans = 0
for i in range(N):
    flg = False
    for j in range(K):
        if mat[i][j]:
            flg = True

    if not flg:
        ans += 1

print(ans)

Submission status: Accepted

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

for k in range(K):
    d = int(input())
    A = list(map(int, input().split()))
    for a in A:
        result[a-1] = 1
    A.clear()

ans = 0

for r in result:
    if r == 0:
        ans += 1

print(ans)

Submission status: Accepted

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

for i in range(k):
  d = int(input())
  if d == 1:
    ans_list.append(int(input()))
  else:
    ans_list[len(ans_list):len(ans_list)] = map(int, input().split())

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

Submission status: Accepted

Solution code:
n, k = [int(i) for i in input().split(' ')]
counts = [0 for i in range(n)]
ans = 0
for i in range(k):
  input()
  for owner in [int(o) for o in input().split(' ')]:
    counts[owner - 1] = 1
for i in range(n):
  if counts[i] == 0:
    ans += 1 
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import numpy as np

N, K = map(int, input().split())
# N, K = 3, 2
di = np.zeros((K), dtype='int64')
Ai = np.ones((N),  dtype='int8')

for i in range(K):
    di[i] = int(input())
    Sunuke = map(int, input().split())
    for s in Sunuke:
        Ai[int(s)-1] = 0
        
print (Ai.sum())

Submission status: Accepted

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

for i in range(k):
    d = int(input())
    lis = list(map(int, input().split()))
    for m in lis:
        ans[m-1] = 0

print(sum(ans))

Submission status: Accepted

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

Submission status: Accepted

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

ARR = []

for i in range(K):
    num = int(input())
    ele = list(map(int,input().split()))
    ARR.append({"num": num, "ele": ele})

def calculate(n, k, arr):
    result = {}
    for i in range(1, n + 1):
        result.__setitem__(i, False)

    for ar in arr:
        for sr in ar["ele"]:
            result.__setitem__(sr,True)
    tt = 0

    for index,res in result.items():
        if res == False:
            tt = tt + 1

    print(tt)


calculate(N, K, ARR)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline
N,K = [int(i) for i in readline().split()]
d = []
A = []
for _ in range(K):
  d.append(int(input()))
  A.append([int(i) for i in readline().split()])

concat_A = []
for a in A:
  concat_A += a
concat_A = set(concat_A)
print(N-len(concat_A))

Submission status: Accepted

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

l = [True]
for _ in range(n):
    l.append(False)
    
for _ in range(k):
    d = int(input())
    al = map(int, input().split())
    for a in al:
        if l[a] == False:
            l[a] = True
    
count = 0
for v in l:
    if v == False:
        count += 1
        
print(count)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!python3

# input
N, K = list(map(int, input().split()))
D = [None] * K
A = []
for i in range(K):
    D[i] = int(input())
    A.append(list(map(int, input().split())))


def main():
    s = {i for i in range(1, N + 1)}
    for l in A:
        for a in l:
            if a in s:
                s.remove(a)

    ans = len(s)
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

count = 0
for num in ans:
    if num == 0:
        count+=1

print(count)

Submission status: Accepted

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

sunuke = []
for n in range(int(N)):
  sunuke.append([])
for k in range(int(K)):
  people = input()
  no = input().split()
  for i in no:
    sunuke[int(i)-1].append(int(K))
target = []
for i in range(int(N)):
  if len(sunuke[i]) == 0:
    target.append(i)
print(len(target))

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
a = []
res = []
for k in range(K):
    d = input()
    for l in list(map(int, input().split())):
        a.append(int(l))
for i in range(1, N + 1):
    if a.count(i) == 0:
        res.append(i)
print(len(res))

Submission status: Accepted

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

su = [0] * n

for i in range(k):
    d=int(input())
    tmp=list(map(int, input().split())) 
#   print(d,tmp)

    for j in range(d):
#       print(tmp[j])
        su[tmp[j]-1] = su[tmp[j]-1] + 1

print(su.count(0))

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

x = list(range(1, n+1))
for i in range(k):
    for b in a[i]:
        if b in x:
            x.remove(b)
print(len(x))

Submission status: Accepted

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

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

ans = 0
for i in range(n) :
    check = 1
    for j in range(k) :
        if s[j][i] == 1 :
            check = 0
            break
    if check == 1 :
        ans += 1

print(ans)

Submission status: Accepted

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

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

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


resolve()

Submission status: Accepted

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

  for i in input_line:
    data[i-1] += 1

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

print(result)

Submission status: Accepted

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


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

cnt = 0
for i in sunuke:
    if not i:
        cnt += 1
print(cnt)

Submission status: Accepted

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

for i in range(k):
  lenc = int(input())
  candy = input().split()
  for c in range(lenc):
    #print(candy[c])
    lst[int(candy[c])-1] += 1
#
#print(lst)
for i in lst:
  if i == 0:
    ans += 1
#

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

a = {}
for i in range(n):
    a[i] = 0
    
for i in range(k):
    d = int(input())
    tmp  = list(map(int, input().split()))
    for t in tmp:
        a[t-1] = 1

print(len([k for k, v in a.items() if v == 0]))

Submission status: Accepted

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

print(N - len(set(sum(ans, []))))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
lst = []
for i in range(K):
    input()
    lst.append(list(map(int, input().split())))
res = [0 for i in range(N)]
for l in lst:
    for i in l:
        res[i-1] += 1
res1 = 0
for i in res:
    if i == 0:
        res1 += 1
print(res1)