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 = [0]*N
result = 0
for i in range(K):
    d = int(input())
    for j in map(int, input().split()):
        S[j-1] += 1

print(S.count(0))

Submission status: Accepted

Solution code:

def resolve():
    import sys
    input = sys.stdin.readline
    n, k = list(map(int, input().split()))

    has = set()

    for i in range(k):
        d = input().rstrip()
        x = list(map(int, input().split()))
        for a in x:
            has.add(a)

    count = 0
    for i in range(n):
        if i +1 not in has:
            count += 1
    print(count)

# x = list(map(int, input().split()))

if __name__ == "__main__":
    resolve()

Submission status: Accepted

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

  s = set()

  for k in range(K):
    d = int(input())
    A = input().split()
    for i in range(d):
      s.add(A[i])
  
  print(N - len(s))



if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
nList = [0 for _ in range(n)]
for i in range(k):
    d = int(input())
    aList = list(map(int, input().split()))
    for j in aList:
        nList[j-1] += 1
cnt = 0
for i in nList:
    if i == 0:
        cnt += 1
print(cnt)

Submission status: Accepted

Solution code:
from collections import defaultdict as dd
n, k = map(int, input().split())
dic = dd(lambda: [])
for i in range(k):
    d = int(input())
    A = list(map(int, input().split()))
    for a in A:
        dic[a].append(i)

#print(dic)

counter = 0
for i in range(1, n+1):
    if len(dic[i]) == 0:
        counter += 1
print(counter)

Submission status: Accepted

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

Submission status: Accepted

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

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

print(ans.count(0))

Submission status: Accepted

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

for i in range(K):
    for j in range(d[i]):
        Sunuke[A[i][j]-1]+=1

ans = 0
for i in range(len(Sunuke)):
    if Sunuke[i] == 0:
        ans+=1

print(ans)

Submission status: Accepted

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

count = [0 for _ in range(N)]

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


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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:

import heapq
from collections import defaultdict, deque
from math import ceil, factorial, gcd
from itertools import accumulate, permutations
import sys
import bisect


sys.setrecursionlimit(10 ** 7)
INF = float("inf")
MOD = 10 ** 9 + 7

si = lambda: input().strip()
ii = lambda: int(input())
mii = lambda: map(int, input().split())
msi = lambda: map(str, input().split())
lmii = lambda: list(map(int, input().split()))
lmsi = lambda: list(map(str, input().split()))
smii = lambda: sorted(map(int, input().split()))


# ----------

N, K = mii()
snuke = set()
for i in range(K):
    d = ii()
    A = lmii()
    for a in A:
        snuke.add(a)
ans = 0
for i in range(1, N+1):
    if i not in snuke:
        ans += 1
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

print(sunu.count(0) - 1)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

x=[0]*n

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

Submission status: Accepted

Solution code:
N, K = tuple(int(c) for c in input().split(' '))
d = []
have = set()
for _ in range(K):
    d.append(int(input()))
    A = [int(c) for c in input().split(' ')]
    for a in A:
        have.add(a)

print(N - len(have))

Submission status: Accepted

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

for i in range(k):
    d = int(input())
    ls2 = list(map(int, input().split()))
    for j in range(d):
        if ls2[j] in ls:
            ls.remove(ls2[j])

print(len(ls))

Submission status: Accepted

Solution code:
mNK = map(int, input().split())
lNK = list(mNK)

lSnk = [1 for i in range(lNK[0])]

for i in range(lNK[1]):
    d = int(input())
    mSwt = map(int, input().split())
    lSwt = list(mSwt)
    for s in lSwt:
        lSnk[s - 1] = 0

ans = sum(lSnk)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

ans = 0
for su in sunuke:
    if su == 0:
        ans += 1

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

L = []
for count in range(N):
    L.append(0)

for count in range(K):
    d = int(input())
    Alist = list(map(int,input().split()))
    for count2 in range(len(Alist)):
        L[Alist[count2]-1] = 1

ans = 0
for count in range(N):
    if L[count] == 0:
        ans = ans + 1

print(ans)

Submission status: Accepted

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

hoge = [0] * N

for a in A:
    for v in a:
        hoge[v-1] += 1

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

print(ans)

Submission status: Accepted

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

sweets = []

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

print(N - len(set(sweets)))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding: utf-8

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

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

print(inv.count(0))

Submission status: Accepted

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

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

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

print(ans)

Submission status: Accepted

Solution code:
n, k = (int(each) for each in input().split())
snuke = set(range(1, n+1))
for d in range(k):
    d = int(input())
    l = set([int(each) for each in input().split()])
    snuke -= l

print(len(snuke))

Submission status: Accepted

Solution code:
N,K = map(int,input().split())
ans = [] * (N+1)
for _ in range(K):
    d = int(input())
    A = map(str,input().split())
    for a in A:
        ans.append(a)
print(N - len(list(set(ans))))

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:

import math
from collections import Counter
n,k=map(int,input().split())
di={}
for i in range(k):
	d=int(input())
	l=[int(x) for x in input().split()]
	for j in l:
		if j not in di:
			di[j]=1
		else:
			di[j]+=1
c=0
for i in range(1,n+1):
	if i not in di:
		c+=1
print(c)

Submission status: Accepted

Solution code:
N,K =map(int,input().split())
D = []
A = []
for _ in range(K):
    D.append(int(input()))
    A.append(list(map(int,input().split())))
    
sunuke = [0]*N
for i in range(K):
    for j in range(D[i]):
        sunuke[A[i][j]-1] += 1
answer = sunuke.count(0)
print(answer)

Submission status: Accepted

Solution code:
n,k = map(int,input().split())
List = [False for i in range(n)]
for i in range(k):
    d = int(input())
    tmp = [int(i) for i in input().split()]
    for i in tmp:
        List[i-1] = True
ans = 0
for i in range(n):
    if List[i]==False:
        ans += 1
print(ans)

Submission status: Accepted

Solution code:
# Code for B - Trick or Treat
# Use input() to fetch data from STDIN
[n, k] = map(int, input().split())
d = [0 for x in range(k)]
a = [[] for x in range(k)]

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

org = set([x + 1 for x in range(n)])
uniq = set()
for s in a:
    uniq = uniq | s

print(len(org - uniq))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, K = list(map(int, input().split()))
cnt = {i: 0 for i in range(1, N+1)}
for _ in range(K):
    d = int(input())
    A = list(map(int, input().split()))
    for a in A:
        cnt[a] += 1
res = len([k for k, v in cnt.items() if v == 0])
print(res)

Submission status: Accepted

Solution code:
n,k = map(int, input().split())
nums = [0] * n
for _ in range(k):
    d = int(input())
    A = map(int, input().split())
    for a in A:
        nums[a-1] += 1
ans = 0
for num in nums:
    if num == 0:
        ans += 1
print(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])
  
print(n-len(ans))

Submission status: Accepted

Solution code:
def Main(N, K, d, A):
    se = set()
    for a in A:
        se.update(a)
    return N - len(se)
        
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())))
    print(Main(N, K, d, A))

if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

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

print(cnt)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

for i in range(k):
  a = input()
  bs = input().split()
  for b in bs:
    s.add(b)

print(n - len(s))

Submission status: Accepted

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

d = set()
for i in range(K):
  d_n = int(input())
  A = list(map(int, input().split()))
  d = d | set(A)

print(N - len(d))

Submission status: Accepted

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

Submission status: Accepted

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

for i in range(k):
  no = int(input())
  a = list(map(int, input().split()))
  for j in a:
    #print(j-1)
    ans[j-1] = 1
tmp = 0
for i in ans:
  if(i==0):tmp+=1
print(tmp)

Submission status: Accepted

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

Submission status: Accepted

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

count = 0
for i in range(n):
    if i + 1 in set(lst):
        count += 1

print(n - count)

Submission status: Accepted

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

print(n - len(t))

Submission status: Accepted

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

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())))
n_list=[]
for i in range(1,n+1):
    n_list.append(i)
count=[1]*n
for i in range(len(a)):
    for j in range(len(a[i])):
        count[a[i][j]-1]=0
sum=0
for l in count:
    sum+=l
print(sum)

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
s = set()
for _ in range(K):
    input()
    for i in map(int, input().split()):
        s.add(i)
print(N - len(s))

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
item=[0 for _ in range(n)] 
for i in range(k):
    i_d=int(input())
    a_i=list(map(int,input().split()))
    for j in a_i:
        item[j-1]=1
counter=0
for i in range(n):
    if item[i-1]==0:
        counter+=1
print(counter)

Submission status: Accepted

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

counts = []
datas = []
for i in range(k):
    counts.append(int(input()))
    datas.append(input().split(' '))
    datas[i] = [int(x) for x in datas[i]]

s = set()
for i in range(n):
    s.add(i+1)

for d in datas:
    ss = set(d)
    s -= ss

print(len(s))

Submission status: Accepted

Solution code:
N, K = list(map(int, input().split()))
all_n = set(range(1, N+1))
for i in range(K):
    d = int(input())
    As = set(map(int, input().split()))
    all_n = all_n - As
print(len(all_n))

Submission status: Accepted

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

for k in range(K):
    d = int(input()) 
    kasi = list(map(int, input().split()))
    
    for j in kasi:
        sunuke_list[j-1] = True

print(N-sum(sunuke_list))

Submission status: Accepted

Solution code:
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate, product, combinations_with_replacement
import sys
import bisect
import string
import math
import time


def I(): return int(input())


def S(): return input()


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


def MS(): return map(str, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


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


def debug(table, *args):
    ret = []
    for name, val in table.items():
        if val in args:
            ret.append('{}: {}'.format(name, val))
    print(' | '.join(ret), file=sys.stderr)


yn = {False: 'No', True: 'Yes'}
YN = {False: 'NO', True: 'YES'}
MOD = 10**9+7
inf = float('inf')
IINF = 10**10
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']

show_flg = False
# show_flg = True


def main():
    N, K = MI()
    d = []
    A = [None for i in range(K)]
    AD = [set() for i in range(N)]

    for i in range(K):
        d = I()
        A[i] = LI()

    for i in range(K):
        for k in A[i]:
            AD[k-1].add(i+1)

    ans = 0
    for i in range(len(AD)):
        if len(AD[i]) == 0:
            ans += 1

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding: utf-8
N, K = map(int, input().split())
a = []
for i in range(K):
    d = int(input())
    a += list(map(int, input().split()))
a = set(a)
b = set(i for i in range(1, N+1))

print(len(a ^ b))

Submission status: Accepted

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

dlist = []
alist = []

for i in range(k):
  dlist.append(int(input()))
  alist += (list(map(int,input().split())))

ans = len(set(range(1,n+1)) - set(alist))

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

    for j in range(len(tmp)):
        if L[tmp[j] - 1] == 0:
            L[tmp[j] - 1] = 1

print(L.count(0))

Submission status: Accepted

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

Submission status: Accepted

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

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

print(c.count(0))

Submission status: Accepted

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

treat_l = [0 for i in range(N)]

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

	for j in range(in_dk):
		treat_l[in_t_list[j]-1] += 1

# おかし0の数を出力
cnt = 0
for i in treat_l:
	if(i == 0):
		cnt += 1
print(cnt)

Submission status: Accepted

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

N,K=(int(x) for x in input().rstrip('\n').split())
snuke=set()
for i in range(K):
  d = int(input().rstrip('\n'))
  snuke = snuke | set((int(x) for x in input().rstrip('\n').split()))
print(N-len(snuke))

Submission status: Accepted

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

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

Submission status: Accepted

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

l = [list(map(int,input().split())) for i in range(k*2)]

a = [[] for i in range(n)]

for i in range(0,k*2,2):
    n = l[i]
    for j in l[i+1]:
        a[j-1].append(i+1)


cnt = 0

for i in a:
    if len(i) == 0:
        cnt += 1

print(cnt)

Submission status: Accepted

Solution code:
N, K = [int(el) for el in input().split()]
snukes = set(range(1, N + 1))
snacks = set()
for _ in range(K):
    _ = input()
    arr = [int(el) for el in input().split()]
    snacks.update(arr)
print(N - len(snukes.intersection(snacks)))

Submission status: Accepted

Solution code:
# coding=UTF-8
from collections import deque
from operator import itemgetter
from bisect import bisect_left, bisect
import itertools
import sys
import math
import numpy as np
import time
sys.setrecursionlimit(10**6)
input = sys.stdin.readline


def main():
    n, k = map(int, input().split())
    snack = [0]*n
    for i in range(k):
        d = int(input())
        a = [int(x) for x in input().split()]
        for j in range(d):

            snack[a[j] - 1] += 1
    print(snack.count(0))


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

for _ in range(K):
    input()
    for i in input().split():
        nusuke_with_treats.add(int(i))

print(len(nusuke - nusuke_with_treats))

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,k = map(int,input().split())
sunuke = [0]*n
for i in range(k):
    dum = input()
    sunuke_list = list(map(int,input().split()))
    for i in sunuke_list:
        sunuke[i-1] = 1
count = 0
for i in range(n):
    if sunuke[i] != 1:
        count += 1
print(count)

Submission status: Accepted

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

Submission status: Accepted

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

d = list(set(d))
print(n-len(d))

Submission status: Accepted

Solution code:
N,K = list(map(int,input().split()))
cnt = 0
a = [True for i in range(N)]
for i in range(K):
    b = input()
    c = list(map(int,input().split()))
    for j in c:
        a[j-1] = False
for i in range(len(a)):
    if a[i]:
        cnt+=1
print(cnt)

Submission status: Accepted

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

li=[list(map(int,input().split())) for i in range(k*2)]
ans=[]
for j in range(1,len(li),2):
    ans+= li[j]
ans = set(ans)

print(n-len(ans))

Submission status: Accepted

Solution code:
if __name__ == "__main__":
    # 入力パターン．
    # 先に要素数Nが与えられて，その数読み込むパターン
    ### N
    ### x_1, y_1
    ### ...
    ### x_N, y_N
    N, K = map(int, input().split())
    s = set()
    for k in range(K):
        d = int(input())
        line = list(map(int, input().rstrip().split(' ')))
        for l in line:
            s.add(l)
    print(N-len(s))

Submission status: Accepted

Solution code:
import sys
from io import StringIO
import unittest


def resolve():
    n, k = map(int, input().split())

    ans = []

    for i in range(2 * k):
        if i % 2 == 1:
            tmp = list(map(int, input().split()))
            ans.append(tmp)
        else:
            hoge = input()

    ans = [i for a in ans for i in a]
    print(n - len(set(ans)))


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例_1(self):
        input = """3 2
2
1 3
1
3"""
        output = """1"""
        self.assertIO(input, output)
    def test_入力例_2(self):
        input = """3 3
1
3
1
3
1
3"""
        output = """2"""
        self.assertIO(input, output)

if __name__ == "__main__":
    # unittest.main()
    resolve()

Submission status: Accepted

Solution code:
n,k = map(int,input().split())
dic = {}
for i in range(1,n+1):
    dic[i] = 0
for j in range(1,k+1):
    d = int(input())
    lis1 = list(map(int,input().split()))
    for i in lis1:
        dic[i] += 1
lis = [i for i in dic.values()]

print(lis.count(0))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
nums=[0 for _ in range(n)]
for _ in range(k):
  input()
  aas=list(map(int,input().split()))
  for aa in aas:
    nums[aa-1]+=1
print(sum(num==0 for num in nums))

Submission status: Accepted

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

Submission status: Accepted

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

A = set()

for _ in range(k):
  d = int(input())
  A |= set(input().split())
  
print(n-len(A))

Submission status: Accepted

Solution code:
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 a:
        l[j-1] += 1

print(l.count(0))

Submission status: Accepted

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

Submission status: Accepted

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

ANS = [False] * N

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

print(ANS.count(False))

Submission status: Accepted

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

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 i in range(d):
        s[a[i] - 1] += 1
print(s.count(0))

Submission status: Accepted

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

def main():
# 整数の入力
    
    s = [int(x) for x in input().split(' ')]
    n = s[0]
    k = s[1]

    # 文字列の入力
    
    id_list = []
    for i in range(k):
        d = int(input())
        s = [int(x) for x in input().split(' ')]
        id_list.extend(s)
    l = list(set(id_list))
    # 出力
    print(n - len(l))

if __name__ == '__main__':
    main()

Submission status: Accepted

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

print(l.count(0))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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



def main():
    # Failed to predict input format
    N, K = map(int, input().split())
    #print(N, K)
    s = set()
    for k in range(K):
        d = int(input())
        for Ai in map(int, input().split()):
            s.add(Ai)
    print(N - len(s))

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
li = []
ansli = []
for i in range(K):
    d = int(input())
    li.extend(list(map(int, input().split())))
for i in range(1, N+1):
    if i not in li:
        ansli.append(i)
print(len(ansli))

Submission status: Accepted

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