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:
import sys
input = sys.stdin.readline

def main():
    N, K = map(int, input().split())
    have = [False] * N
    ans = N
    for k in range(K):
        d = int(input())
        A = list(map(int, input().split()))
        for a in A:
            if not have[a-1]:
                ans -= 1
            have[a-1] = True
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

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 = list(map(int, input().split()))
    for ai in a:
        snuke[ai-1] = 0
print(sum(snuke))

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

b = [False] * n
for lst in A:
    for i in lst:
        b[i - 1] = True

print(n - sum(b))

Submission status: Accepted

Solution code:

import glob
import numpy as np

# 問題ごとのディレクトリのトップからの相対パス
REL_PATH = 'ABC\\166\\B'

# テスト用ファイル置き場のトップ
TOP_PATH = 'C:\\AtCoder'

class Common:

    problem = []
    index = 0

    def __init__(self, rel_path):
        self.rel_path = rel_path

    def initialize(self, path):
        file = open(path)
        self.problem = file.readlines()
        self.index = 0
        return

    def input_data(self):
        try:
            IS_TEST
            self.index += 1
            return self.problem[self.index-1]
        except NameError:
            return input()

    def resolve(self):
        pass

    def exec_resolve(self):
        try:
            IS_TEST
            for path in glob.glob(TOP_PATH + '\\' + self.rel_path + '/*.txt'):
                print("Test: " + path)
                self.initialize(path)
                self.resolve()
                print("\n\n")
        except NameError:
            self.resolve()


class B(Common):

    def resolve(self):

        N, K = map(int, self.input_data().split())

        snack = np.zeros((N+1, K+1), dtype = int)

        for i in range(K):
            d = int(self.input_data())
            tmp = list(map(int, self.input_data().split()))
            for t in tmp:
                snack[t][i+1] = 1

        count = 0
        for i in range(1, N+1):
            if np.sum(snack[i,1:]) == 0:
                count += 1

        print(str(count))


solver = B(REL_PATH)
solver.exec_resolve()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
def main():
    N,K=tuple(map(int,sys.stdin.readline().split()))
    C=[0 for _ in [0]*N]
    for _ in [0]*K:
        d=int(sys.stdin.readline())
        A=list(map(lambda x:int(x)-1,sys.stdin.readline().split()))
        for a in A:C[a]+=1
    print(C.count(0))
if __name__=='__main__':main()

Submission status: Accepted

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

sunuke = [0] * N
for i in range(K):
    _ = input()
    kasi_moti = map(int, input().split())
    for j in kasi_moti:
        sunuke[j - 1] = 1

count = 0
for k in sunuke:
    if k == 0:
        count += 1
print(count)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,k=[int(x) for x in input().split()]
ok=[]
for i in range(k):
  d_i=int(input())
  a_i=[int(x) for x in input().split()]
  for a in a_i:
    ok.append(a)

bad=[]
for i in range(1,n+1):
  if i not in ok:
    bad.append(i)

print(len(bad))

Submission status: Accepted

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

#print("d = {}".format(d))
#print("a = {}".format(a))
#print("chk = {}".format(chk))

ret = 0
for i in chk:
    if i == 0:
        ret += 1

print("{}".format(ret))

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
num_snack = []
#initiliaze number of snack each people has
for people in range(N):
  num_snack.append(0)
  
#count number of snack each people has
for i in range(K):
  num_people = map(int, input())
  has_snack = list(map(int,input().split()))
  for people in has_snack:
    num_snack[people-1] += 1

#count number of people that doesnt has snack
no_snack = 0
for snacks in num_snack:
  if (snacks == 0):
    no_snack += 1
print(no_snack)

Submission status: Accepted

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

for k in range(K):
    k=int(input())
    listA=list(map(int,input().split()))
    for j in listA:
        while True:
            try:
                nusuke.remove(j)
            except ValueError:
                break
print(len(nusuke))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N,K = map(int,input().split())
res = [False] * (N+1)
res[0] = True

for _ in range(K):
    d = int(input())
    A = list(map(int,input().split(" ")))
    for id,value in enumerate(A):
        res[A[id]] = True

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

Submission status: Accepted

Solution code:
line = input().split()
line2 = []
zenin = int(line[0])
snack = int(line[1])

for i in range(zenin):
  line2.append(i+1)

for i in range(snack):
  person = int(input())
  line3 = input().split()
 
  for i in range(person):
    if int(line3[i]) in line2:
      line2.remove(int(line3[i]))
      
print(len(line2))

Submission status: Accepted

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

ans=0

for i in range(K):
    _d=int(input())
    _a=list(input().split())
    for _ in _a:
        L[int(_)]+=1

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

Submission status: Accepted

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

Submission status: Accepted

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

    for i in range(K):
        d = int(input())
        a = map(int, input().split())
        for j in a:
            ans.append(j)

    count = 0
    for i in range(1, N + 1):
        if not i in ans:
            count += 1

    print(count)
    return

main()

Submission status: Accepted

Solution code:
import numpy as np
N, K = map(int,input().split())


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

count = 0


for i in range(1,N+1):

  if not i in A:
    count += 1

print(count)

Submission status: Accepted

Solution code:
#inport
import sys
import numpy as np
from collections import deque


#input
N,K = [int(x) for x in sys.stdin.readline().split()]
snu = np.zeros(N)

for _ in range(K):
    d = [int(x) for x in sys.stdin.readline().split()] 
    a = [int(x) for x in sys.stdin.readline().split()]
    n = np.size(a)
    for i in range(n):
        snu[a[i]-1] = snu[a[i]-1]+1

ju = np.count_nonzero(snu)
print(N-ju)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
A = [[]] * K
d = [0] * K
for i in range(2 * K):
    if i % 2:
        A[i // 2] = list(map(int, input().split()))
    else:
        d[i // 2] = int(input())
print(N - len(set([flatten for inner in A for flatten in inner])))

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

A = sum(A, [])
A = list(set(A))

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:

def main():
    N, K = map(int,input().split(' '))
    snuke = [0] * (N+1)
    for _ in range(K):
        d = input()
        A = list(map(int,input().split(' ')))
        for j in A:
            snuke[j] = 1
    
    print(N-sum(snuke))
    
    
if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
N,K = list(map(int,input().split()))
d=[]
e=[]
f=[]
for i in range(N):
	f.append(-1)
count=0
for i in range(K):
	d.append(0)
	e.append([]*N)
	d[i]= int(input())
	e[i]=list(map(int,input().split()))


for i in range(K):
	for j in range(d[i]):

			f[e[i][j]-1] = 1
		


for i in range(N):
	if f[i] == -1:
		count +=1
print(count)

Submission status: Accepted

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




if __name__ == '__main__':
    solve()

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
sunuke= []
for i in range(K):
    d = int(input())
    a = list(map(int, input().split()))
    for j in range(d):
        if a[j] not in sunuke:
            sunuke.append(a[j])
print(N - len(sunuke))

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 i in a:
    s.add(i)
print(n-len(s))

Submission status: Accepted

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

Submission status: Accepted

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

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

a=set()

for _ in range(K):
  X=int(input())
  Y=list(map(int,input().split()))
  for b in Y:
    a.add(b)
print(N-len(a))

Submission status: Accepted

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


s= set()

for _ in range(K):
    d = int(input())
    A = map(int, input().split())
    b = set(A)
    s = s | b
    
print(N -len(s))

Submission status: Accepted

Solution code:
n,k = map(int,input().split())
human = [0]*n
for i in range(k*2):
  if i % 2 == 0:
    num = map(int,input())
  else:
    list1=list(map(int, input().split()))
    for i in list1:
      human[i - 1] = 1

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

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
lst=[_ for _ in range(1,n+1)]
for i in range(k):
  x=int(input())
  a=list(map(int,input().split()))
  b=set(a)
  for j in b:
    if j in lst:
      lst.remove(j)
print(len(lst))

Submission status: Accepted

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

print(sunuke.count(0))

Submission status: Accepted

Solution code:
import numpy as np
N,K = (int(x) for x in input().split())
Sweet = np.zeros(N,dtype=bool)
for T in range(0,K):
    Di    = int(input())
    DiWho = [int(x) for x in input().split()]
    for TT in range(0,Di):
        Sweet[DiWho[TT]-1] = True
print(N-sum(Sweet))

Submission status: Accepted

Solution code:
N,K = list(map(int, input().split()))
D = []
S = set()
for i in range(K):
  D.append(int(input()))
  A = list(map(int, input().split()))
  for a in A:
    S.add(a)
    
print(N - len(S))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from __future__ import annotations

from dataclasses import dataclass, field
from typing import List, Optional, Generator


@dataclass
class Sweet:
    id: int


@dataclass
class User:
    id: int
    sweets: List[Sweet] = field(default_factory=list)

    def has_no_sweets(self) -> bool:
        return len(self.sweets) == 0

    def register_sweet(self, sweet: Sweet) -> None:
        self.sweets.append(sweet)


@dataclass(frozen=True)
class Users:
    values: List[User] = field(default_factory=list)

    @classmethod
    def create(cls, num_people: int) -> Users:
        users = [User(id=i) for i in range(1, num_people + 1)]

        return Users(users)

    def find_by_id(self, user_id: int) -> Optional[User]:
        return self.values[user_id - 1]

    def count_users_have_no_sweets(self) -> int:
        return sum([user.has_no_sweets() for user in self.values])


@dataclass
class DistributePlan:
    """どのお菓子をどのユーザに配布するか情報"""
    sweet_id: int
    user_ids: List[int] = field(default_factory=list)


@dataclass
class DistributePlans:
    num_people: int
    values: List[DistributePlan] = field(default_factory=list)

    @classmethod
    def create(cls, num_people, sweet_ids, distribution_plans) -> DistributePlans:
        plans = []

        for sweet_id, distribution_plan in zip(sweet_ids, distribution_plans):
            distribution_plan = DistributePlan(sweet_id, distribution_plan)
            plans.append(distribution_plan)

        return DistributePlans(num_people, plans)

    def gen(self) -> Generator:
        for plan in self.values:
            for user_id in plan.user_ids:
                yield plan.sweet_id, user_id

    def distribute(self) -> Users:
        users = Users.create(self.num_people)

        for sweet_id, user_id in self.gen():
            user = users.find_by_id(user_id)
            user.register_sweet(Sweet(id=sweet_id))

        return users


def actual(n, k, sweet_ids, distribution_user_ids):
    plans = DistributePlans.create(n, sweet_ids, distribution_user_ids)

    users = plans.distribute()

    return users.count_users_have_no_sweets()


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

sweet_ids = []
distribution_user_ids = []

for k_i in range(1, k + 1):
    d_i = int(input())
    a_i = list(map(int, input().split()))

    sweet_ids.append(d_i)
    distribution_user_ids.append(a_i)

print(actual(n, k, sweet_ids, distribution_user_ids))

Submission status: Accepted

Solution code:
N, K = list(map(int, input().split()))
haves = [False for _ in range(N)]
 
def judge_Flag(flags, num):
    As = list(map(int, input().split()))
    for i in range(num):
        flags[As[i] - 1] = True
        
for _ in range(K):
    people_num = int(input())
    judge_Flag(haves, people_num)
print(haves.count(False))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
#import cython

def main():
    read = lambda: sys.stdin.readline().rstrip()

    N, K = map(int,read().split())
    cnt = [0]*N
    #N: cython.longlong = 0
    for _ in range(K):
        d = int(read())
        A = list(map(int,read().split()))
        for num in A:
            cnt[num-1] += 1
    
    print(cnt.count(0))


 
if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import itertools

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

B = []

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

B = itertools.chain.from_iterable(B)
B = set(B)
print(N - len(B))

Submission status: Accepted

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

for j in range(k):
  d = int(input())
  a = map(int, input().split())
  for k in a:
    check[k-1] = True

print(check.count(False))

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
people = [False for i in range(n)]
for i in range(k):
    input()
    a = map(int, input().split())
    for j in a:
        people[j-1] = True
print(people.count(False))

Submission status: Accepted

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

d = [0] * k
a = [0] * k
sunuke = [0] * n

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

print(sunuke.count(0))

Submission status: Accepted

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

print(sum(people))

Submission status: Accepted

Solution code:
import numpy as np
n, k = map(int, input().split())

L = []
for i in range(k):
    d = input()
    l = list(map(int, input().split()))
    L.extend(l)

print(n - len(np.unique(L)))

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

s = 0
for i in range(1, n + 1):
    tf = False
    for j in range(k):
        if i in a[j]:
            tf = True
            break
    if tf == False:
        s += 1

print(s)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
(N, K) = [int(n) for n in input().split()]
C = [1 for _ in range(N)]
for _ in range(K):
    d = int(input())
    A = [int(n) - 1 for n in input().split()]
    for a in A:
        C[a] = 0

print(sum(C))

Submission status: Accepted

Solution code:
person,okasi = map(int,input().split())
have = []
ans = 0

for i in range(okasi):
    a = int(input())
    b = input().split()
    for j in range(a):
        have.append(int(b[j]))
#print(have)
for k in range(person):
    if k+1 in have:
        ans = ans
    else:
        ans = ans + 1
    #print(ans)
print(ans)

Submission status: Accepted

Solution code:
N,K = [int(x) for x in input().split()]
P = dict([(i,True) for i in range(1,N+1)])
for k in range(K):
    d = input()
    for p in [int(x) for x in input().split()]:
        P[p] = False
print(sum(list(P.values())))

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
i=0
d=[]
a=[]
while i<k:
    d.append(int(input()))
    a.extend(list(map(int,input().split())))
    i+=1
i=1
count=0
while True:
    if((i in a)!=True):
        count+=1
    i+=1
    if(i>n):
        break

print(count)

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
# テーブルをまず作成。0で初期化3人いるとする
t = [0] * N
for _ in range(K):
    d = int(input())
    # 1と3がお菓子持ってるリストAとする
    A = list(map(int, input().split()))
    # A全員aにぶち込んでガガガってやる
    for a in A:
        #お菓子を持っている子のindexを+1
        t[a-1] += 1
print(t.count(0))

Submission status: Accepted

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

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

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


diff = set(ans) - set(A)

print(len(diff))

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
a=[0]*n
for i in range(k):
    input()
    b=list(map(int,input().split()))
    for j in b:
        a[j-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()))

having_okashi = [False] * N

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

print(N-sum(having_okashi))

Submission status: Accepted

Solution code:
def main():
    n, k = map(int, input().split())
    nl = list(range(1, n+1))
    al = list()
    for i in range(k):
        d = int(input())
        a = list(map(int, input().split()))
        al.extend(a)
    trick = list(set(nl) ^ set(al))
    print(len(trick))

if __name__ == '__main__':
    main()

Submission status: Accepted

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

for i in range(K):
    d = int(input())
    A = [int(s) for s in input().split()]
    for a in A:
        sunuke[a-1] += 1

print(sunuke.count(0))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
x=input()
x0=x.split()
n=int(x0[0])
k=int(x0[1])
l=list()
z=0
for i in range(k):
    d=input()
    x=input()
    x0=x.split()
    l.extend(x0)
for p in range(n):
    c=str(p+1) in l
    if c==False:
        z=z+1
print(z)

Submission status: Accepted

Solution code:
A,B=map(int,input().split())
R=list(range(1,A+1))
for i in range(2*B):
  L=list(map(int,input().split()))
  if i%2==1:
    for j in range(len(L)):
      if L[j] in R:
        R.pop(R.index(L[j]))
  if R==list():
    break
print(len(R))

Submission status: Accepted

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

Submission status: Accepted

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

for m in range(0, k):
  d = int(input())
  li = [int(i) for i in input().split()]
  lis = lis + li
  
for s in range(1, n+1):
  if s in lis:
    count += 0
  else:
    count += 1

print(count)

Submission status: Accepted

Solution code:
import sys 

count = 0
list_ = []
N = 0

for i in sys.stdin:
    if count == 0:
        N = int(i.split()[0])
        count += 1
    else:
        list1 = []
        count += 1
        if count%2 == 0:
            pass
        else:
            list1 = list(map(int, i.split()))
            for j in list1:
                list_.append(j)

lista = list(set(list_))
x = 0
for k in range(1, N+1):
    if not(k in lista):
        x += 1
print(x)

Submission status: Accepted

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

people = []

for i in range(K):
  _ = input()
  a = list(map(int, input().split()))
  people += a
  
print(N - len(set(people)))

Submission status: Accepted

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

Submission status: Accepted

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

print(A.count(0))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def check(human):
    sum = 0
    for i in human:
        if(i == 0):
            sum += 1
    return sum

def resolve():
    data = [int(i) for i in input().split()]
    
    human = [0 for i in range(data[0])]
    sweet = data[1]
    
    for i in range(sweet):
        mem = int(input())
        have = [int(j) for j in input().split()]
        
        for k in have:
            human[k-1] += 1
    
    print(check(human))
resolve()

Submission status: Accepted

Solution code:
import itertools

N, K = map(int, input().split())
U = [list(input().split()) for i in range(2 * K)]

People = []

for i in range(2 * K):
    if i % 2 == 1:
        People.append(U[i])

for i in range(1, N + 1):
    if str(i) in list(itertools.chain.from_iterable(People)):
        N -= 1

print(N)

Submission status: Accepted

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

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

ans = 0

for i in range(n):
    if (i+1) not in safe:
        ans += 1
        
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#ABC166-B

N, K = map(int, input().split())
d = []
a = []

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

child = list(range(N))
x = [0]*N

for j in child:
    for c in range(K):
        if j+1 in a[c]:
            x[j] += 1

count = 0

for h in child:
    if x[h] == 0:
        count += 1

print(count)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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())))
flag = [False]*N
for i in A:
    for j in i:
        flag[j-1] = True
print(N - sum(flag))

Submission status: Accepted

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

print(len([1 for i in n_k if i==0]))

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)
import bisect
import numpy as np
import math
from collections import deque
from collections import defaultdict
from math import gcd

N, K = map(int, input().split())
snuke = defaultdict(int)
for _ in range(K):
    d = int(input())
    A = list(map(int, input().split()))
    for n in A:
        snuke[n] += 1

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    N, K = map(int, input().split())
    A_have = [0]*N
    num = N

    for k in range(0, K):
        d = int(input())
        A = map(int, input().split())
        for a in A:
            if A_have[a-1] == 0:
                A_have[a-1] = 1
                num -= 1
    print(num)
                    
if __name__ == '__main__':
    main()

Submission status: Accepted

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

for i in range(k):
  d = int(input())
  a += list(input().split())

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