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())
A=[]
for _ in range(K):
    input()
    A+=list(map(int, input().split()))
from collections import Counter
C=Counter(A)
print(N-sum(i in C for i in range(1,N+1)))

Submission status: Accepted

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

cnt = [0] * (n + 1)

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

ans = cnt[1:].count(0)
print(ans)

Submission status: Accepted

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

ans = 0
for num in lst:
    if num == 0:
        ans += 1
print(ans)

Submission status: Accepted

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

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

print(cnt)

Submission status: Accepted

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

snuke=[1 for i in range(n)]
for i in range(k):
    d=int(input())
    A=[int(i) for i in input().split()]
    for ele in A:
        snuke[ele-1]*=0
print(sum(snuke))

Submission status: Accepted

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


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    N, K = map(int, input().split())

    motteru = [False] * N

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

    print(motteru.count(False))


if __name__ == '__main__':
    main()

Submission status: Accepted

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

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

N, K = MAP()
S = set()
for i in range(K):
    INT()
    S |= set(LIST())
ans = N - len(S)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, K = MAP()
A = [True] * N
for i in range(K):
    d = INT()
    B = LIST()
    for b in B:
        A[b-1] = False
print(sum(A))

Submission status: Accepted

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

for i in range(K):
    d = int(input())
    A = set([int(i) for i in input().split()])
    S = S - (S & A)

print(len(S))

Submission status: Accepted

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

if __name__ == "__main__":
    main()

Submission status: Accepted

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


def main():
  N, K = map(int, input().split())
  counts = [0] * N

  for _ in range(K):
    input()
    for n in map(int, input().split()):
      counts[n - 1] = 1

  print(len([v for v in counts if v == 0]))


if __name__ == '__main__':
  main()

Submission status: Accepted

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

sunukes = [0] * N

for _ in range(K):
    di = int(input())
    Ai = list(map(int, input().split()))
    for item in Ai:
        sunukes[item-1] += 1

ans = 0

for i in sunukes:
    if i == 0:
        ans += 1

print(ans)

Submission status: Accepted

Solution code:
def main():
    N, K = (int(i) for i in input().split())
    F = [True]*N
    for _ in range(K):
        d = int(input())
        A = [int(i) for i in input().split()]
        for a in A:
            F[a-1] = False
            # いたずらうけない
    ans = 0
    for f in F:
        if f:
            ans += 1
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
a = set({})
for _ in range(k):
    p = int(input())
    f = [int(i) for i in input().split()]
    a = a | set(f)
print(n - len(a))

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
ans = [0] * (N+1)
for k in range(K):
    d = int(input())
    A = list(map(int, input().split()))
    for ai in A:
        ans[ai] = 1
print(N-sum(ans))

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 j in range(d):
    l[a[j]-1] += 1

print(l.count(0))

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
no = [True] * n
for _ in range(k):
    _ = input()
    a = map(int, input().split())
    for num in a:
        no[num-1] = False

print(sum(no))

Submission status: Accepted

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

Submission status: Accepted

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

n,k=LI()
dA=[]
ans=set([])
for i in range(k):
    d=int(input())
    for a in LI():
        ans.add(a)
print(n-len(ans))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
import math

from collections import defaultdict
from collections import deque
def load(vtype=int):
    return vtype(input().strip())
def load_list(seplator=" ", vtype=int):
    return [vtype(v) for v in input().strip().split(seplator)]
def exit():
    import sys
    sys.exit(0)
def perm_sub(li, used):
    if len(li) == len(used):
        return [deque()]
    k = []
    for i in range(len(li)):
        if i in used:
            continue
        used.add(i)
        sub_list = perm_sub(li, used)
        for sub in sub_list:
            sub.appendleft(li[i])
        k.extend(sub_list)
        used.discard(i)
    return k
def perm_li(li):
    return perm_sub(li, set())
def perm_n(n):
    return perm_sub(list(range(n)), set())
def join_i(li, sep=""):
    return sep.join([str(e) for e in li])
def li2n(li):
    n, base = 0, 1
    for i in range(len(li)-1, -1, -1):
        n += li[i] * base
        base *= 10
    return n
def sli2ili(li):
    return [int(s) for s in li] 
def prime_list(n):
    li = [i for i in range(2, n+1)]
    for i in range(len(li)):
        if li[i] >= int(math.sqrt(n)):
            break
        if li[i] == -1:
            continue
        for j in range(i+1, len(li)):
            if li[j] % li[i] == 0:
                li[j] = -1
    return [n for n in li if n != -1]
def gcd(a, b):
    a, b = max(a, b), min(a, b)
    while True:
        r = a % b
        if r == 0: return b
        a, b = b, r
def lcm(a, b):
    return int(a * b / gcd(a,b))
def all_subset(li):
    s = []
    n = len(li)
    for bit in range(0, (1<<(n+1))):
        ss = set()
        for i in range(0, n):
            if (bit & (1 << i)):
                ss.add(li[i])
        s.append(ss)
    return s
def factorial(n):
    if n == 1:
        return 1
    return n * factorial(n-1)
def mCn(m, n):
    def factorial_ntimes(m, n):
        r = 1
        while n:
            r *= m
            m -= 1
            n -= 1
        return r
    return int(factorial_ntimes(m, n) / factorial(n))

n, k = load_list()
d = defaultdict(int)
for i in range(k):
    load()
    A = load_list()
    for a in A:
        d[a] += 1

cnt = 0
for i in range(1, n+1):
    if d[i] == 0:
        cnt += 1
print(cnt)

Submission status: Accepted

Solution code:
import sys
from collections import defaultdict, Counter, deque
from itertools import accumulate, permutations, combinations
from operator import itemgetter
from bisect import bisect_left, bisect_right, bisect
from heapq import heappop, heappush
from fractions import gcd
from math import ceil, floor, sqrt, cos, sin, pi
from copy import deepcopy

# If you use recursive call, uncomment this code
#sys.setrecursionlimit(10**6)

def main():
    N,K = map(int, input().split())
    snukes = [0]*N
    for _ in range(K):
        d = int(input())
        A = list(map(int, input().split()))
        for a in A:
            snukes[a-1] += 1
    count = 0
    for snuke in snukes:
        if not snuke:
            count += 1
    print(count)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
n, k = map(int, input().split())
li = [0] * n
for i in range(k):
    d = int(input())
    a = list(map(int, input().split()))
    for x in a:
        li[x - 1] += 1
ans = sum(x == 0 for x in li)
print(ans)

Submission status: Accepted

Solution code:


def submit():
    n, k = map(int, input().split())
    treat = {i:False for i in range(1, n + 1)}
    
    for _ in range(k):
        d = int(input())
        a = list(map(int, input().split()))
        for s in a:
            treat[s] = True

    print(n - sum(treat.values()))


submit()

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
a=set()
for i in range(k):
    d=input()
    aaa=map(int,input().split())
    for aa in aaa:
        a.add(aa)

print(n-len(a))

Submission status: Accepted

Solution code:

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

Submission status: Accepted

Solution code:
import sys


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


sys.setrecursionlimit(20000000)


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


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
def main():

    from bisect import bisect_left as bl, bisect_right as br, insort
    import sys,heapq,math
    from collections import defaultdict as dd, deque
    def data(): return sys.stdin.readline().strip()
    def mdata(): return list(map(int, data().split()))
    out = sys.stdout.write
    # sys.setrecursionlimit(100000)
    INF = int(1e9)
    mod = int(1e9)+7

    n,k=mdata()
    l=[0]*n
    for i in range(k):
        d=int(data())
        s=mdata()
        for j in s:
            l[j-1]+=1
    cnt=0
    for i in l:
        if i==0:
            cnt+=1
    print(cnt)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

Submission status: Accepted

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

c = [0]*N
for i in range(2*K):
    if i%2 == 0:
        d = int(input())
    else:
        A = list(map(int,input().split()))
        for a in A:
            c[a-1]+=1
            
print(c.count(0))

Submission status: Accepted

Solution code:
n,k = map(int,input().split())
t = [0] * n
for _ in range(k):
    d = int(input())
    l = list(map(int,input().split()))
    for x in l:
        t[x-1] += 1
ans = 0
for x in t:
    if x == 0:
        ans += 1
print(ans)

Submission status: Accepted

Solution code:
import math
from functools import reduce
from collections import deque
import sys
sys.setrecursionlimit(10**7)

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

# スペース区切りの入力を読み込んで数値リストにして返します。
def get_nums_l():
    return [ int(s) for s in input().split(" ")]

# 改行区切りの入力をn行読み込んで数値リストにして返します。
def get_nums_n(n):
    return [ int(input()) for _ in range(n)]

# 改行またはスペース区切りの入力をすべて読み込んでイテレータを返します。
def get_all_int():
    return map(int, open(0).read().split())

def rangeI(it, l, r):
    for i, e in enumerate(it):
        if l <= i < r:
            yield e
        elif l >= r:
            break

def log(*args):
    print("DEBUG:", *args, file=sys.stderr)

INF = 999999999999999999999999
MOD = 10**9+7

n,k = get_nums_l()

check = [False] * (n+1)

for i in range(k):
    d = int(input())
    for a in get_nums_l():
        check[a] = True

ans = 0

for i,b in enumerate(check):
    if not b:
        ans += 1

print(ans-1)

Submission status: Accepted

Solution code:



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

print(snk.count(0))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from math import gcd

from math import factorial as f

from math import ceil,floor,sqrt


import bisect
import re
import heapq


from copy import deepcopy
import itertools

from sys import exit

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

yes = "Yes"
no = "No"

def main():
    n,k = mi()
    a = []
    for i in range(k):
        d = ii()
        atmp = li()
        a.append(atmp)

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

    for _ in range(k):
        for i in a[_]:
            ans[i] = 0
    print(sum(ans))


main()

Submission status: Accepted

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

cnt = 0
for sn in s:
    if not sn:
        cnt += 1

print(cnt)

Submission status: Accepted

Solution code:
if __name__ == '__main__':
    from sys import stdin
    # from collections import defaultdict
    import math
    input = stdin.readline

    # import random

    n, k = map(int, input().split())
    ans = set(range(1, n+1))
    for _ in range(k):
        d = int(input())
        aa = set(map(int, input().split()))
        ans = ans-aa
    print(len(ans))

Submission status: Accepted

Solution code:
from sys import stdin
def main():
    #入力
    readline=stdin.readline
    N,K=map(int,readline().split())
    flags=[False]*N
    for i in range(K):
        d=int(readline())
        A=list(map(int,readline().split()))
        for a in A:
            a-=1
            flags[a]=True

    res=0
    for i in range(N):
        if flags[i]==False:
            res+=1

    print(res)

if __name__=="__main__":
    main()

Submission status: Accepted

Solution code:
def solve():
    N, K = map(int,input().split())
    have = [False] * N
    for i in range(K):
        d = int(input())
        A = list(map(lambda x:int(x)-1, input().split()))
        for a in A:
            have[a] = True
    
    print(N - sum(have))
if __name__ == '__main__':
    solve()

Submission status: Accepted

Solution code:
def main():
    import sys
    sys.setrecursionlimit(10**6)
    input = sys.stdin.readline
    N, K = [int(x) for x in input().strip().split()]
    sunuke = [0] * N
    for k in range(K):
        input()
        for a in [int(x) for x in input().strip().split()]:
            sunuke[a-1] += 1
    
    cnt = 0
    for n in range(N):
        if sunuke[n] == 0:
            cnt += 1
    
    print(cnt)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
a=[0]*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
print(a.count(0))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from _collections import defaultdict
n,k=map(int,input().split())
X=defaultdict(int)
for i in range(k):
    d=int(input())
    A=list(map(int,input().split()))
    for a in A:
        X[a]+=1
print(n-len(X))

Submission status: Accepted

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

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

Submission status: Accepted

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

memo = [False]*N
for _ in range(K):
    d = input()
    A = map(int,input().split())
    for a in A:
        memo[a-1] = True

print(N-sum(memo))

Submission status: Accepted

Solution code:
N, K = [int(_) for _ in input().split()]
s = set([])
for _ in range(K):
    input()
    s |= set([int(_) for _ in input().split()])
print(len(set(range(1, N + 1)) - s))

Submission status: Accepted

Solution code:
def main():

    N, K = map(int, input().split())
    v = [0 for _ in range(N)]
    for _ in range(K):
        d = int(input())
        A = list(map(int, input().split()))
        for u in A:
            v[u-1] += 1
    ans = 0
    for i in range(N):
        if v[i] == 0: ans += 1
    return ans

if __name__ == '__main__':
    print(main())

Submission status: Accepted

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

print(memo.count(0))

Submission status: Accepted

Solution code:
ma = lambda :map(int,input().split())
ni = lambda:int(input())

n,k = ma()
sn = [0]*n
for i in range(k):
    d = ni()
    for a in ma():
        sn[a-1]=1
c = 0
for w in sn:
    if w==0:c+=1
print(c)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import math

def makelist(n, m):
    return [[0 for _ in range(m)] for _ in range(n)]

# n
# 
# s = input()

N, K = list(map(int, input().split()))
dp = [1]*(N+1)
dp[0] = 0
for i in range(K):
    d = int(input())
    A = list(map(int, input().split()))
    for e in A:
        dp[e] = 0

ans = sum(dp)
print(ans)

Submission status: Accepted

Solution code:
#MLE注意！0や1のケースに注意

def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    import math
    #from math import gcd

    #inf = 10**17
    #mod = 10**9 + 7

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

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N,K=map(int,input().split())
D=[]
N=[False for i in range(N)]
for i in range(K):
    a=input()
    A=list(map(int,input().split()))
    for i in range(len(A)):
        N[A[i]-1]=True
ans=0
for i in N:
    if not i:
        ans+=1
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    n,k = map(int,input().split())
    a = []
    for i in range(k):
        d = int(input())
        aa = list(map(int,input().split()))
        a.extend(aa)
    print(n-len(set(a)))
if __name__=='__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N,K=map(int, input().split())
C=[0]*(N+1)
for _ in range(K):
    d=int(input())
    *A,=map(int, input().split())
    for a in A:
        C[a]+=1
ans=0
for i in range(1,N+1):
    if C[i]==0: ans+=1
print(ans)

Submission status: Accepted

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
def main():
    n, k = LI()
    per = [False for i in range(n)]
    for i in range(k):
        d = I()
        a = LI_()
        for person in a:
            per[person] = True
    cnt = 0
    for i in range(n):
        if not per[i]:
            cnt += 1
    print(cnt)


main()

Submission status: Accepted

Solution code:
import sys
import math
import fractions
from collections import deque
from collections import defaultdict
sys.setrecursionlimit(10**7)

N, K = map(int, input().split())
snuke = [0] * N
for i in range(K):
    d = int(input())
    A = map(int, input().split())
    for a in A:
        a -= 1
        snuke[a] += 1

cnt = 0
for s in snuke:
    if s == 0:
        cnt += 1

print(cnt)

Submission status: Accepted

Solution code:
import sys
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))

n,k=MAP()
#d=INT()
a=[0 for i in range(n)]
for i in range(k):
    b=INT()
    b=LIST()
    for l in b:
        a[l-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())
u = [0]*n
for i in range(k):
    d=int(input())
    v = map(int,input().split())
    for a in v:
        u[a-1]+=1
c=0
for i in range(n):
    if u[i]==0:
        c+=1
print(c)

Submission status: Accepted

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


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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？

n,k=mii()

chk=[0]*n
for i in range(k):
    d=ii()
    arr=limii()
    for j in range(d):
        chk[arr[j]-1]=1

print(n-sum(chk))

Submission status: Accepted

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

st = set([])
for i in range(k):
    d = int(input())
    a[i] = list(map(int, input().split()))
    st.update(a[i])
print(n - len(st))

Submission status: Accepted

Solution code:
def main():
    N, K = map( int, input().split())
    ANS = [1]*N
    for _ in range(K):
        d = int( input())
        A = list( map( lambda x: int(x)-1, input().split()))
        for a in A:
            ANS[a] = 0
    print( sum(ANS))
if __name__ == '__main__':
    main()

Submission status: Accepted

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

treats = [False] * N
for _ in range(K):
	d = int(input())
	As = map(int, input().split())
	for A in As:
		treats[A - 1] = True

count = 0
for t in treats:
	if not t:
		count += 1

print(count)

Submission status: Accepted

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

dic = {}
for i in range(n):
    dic[i] = 0

for i in range(k):
    d = int(input())
    a = [int(i)-1 for i in input().split()]
    for j in a:
        dic[j] = 1
print(n-sum(dic.values()))

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
dic = {i: 0 for i in range(1, N+1)}
for _ in range(K):
  dt = int(input())
  A = list(map(int, input().split()))
  for a in A:
    dic[a] += 1

ans = 0
for k, v in dic.items():
  if v == 0:
    ans += 1

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n, k = map(int, readline().split())
aa = []
for i in range(k):
    d = int(readline())
    aa += list(map(int, readline().split()))
aa = set(list(aa))
cnt = 0
for i in range(1, n + 1):
    if i not in aa:
        cnt += 1
print(cnt)

Submission status: Accepted

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

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 a in A:
        a -= 1
        l[a] += 1
ans = 0
for i in range(N):
    if l[i]==0:
        ans += 1
print(ans)

Submission status: Accepted

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

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

print(n - len(A))

Submission status: Accepted

Solution code:
import bisect
import collections
import sys

sys.setrecursionlimit(100000)
input = sys.stdin.readline
ACMOD = 1000000007
INF = 1 << 62


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


def llmi(n):
    return [lmi() for _ in range(n)]

N,C = lmi()

x = { i for i in range(1,N+1)}
for _ in range(C):
    input()
    x = x - set(lmi())
print(len(x))

Submission status: Accepted

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