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:

from sys import stderr

def debug(*args):
    print(*args, file=stderr)


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

n_sukuke_num, k_sweets_types_num = map(int, input().split())
ai_sweets_owners = [input_sweets_owners() for _ in range(k_sweets_types_num)]

# debug(ai_sweets_owners)
# for _ in range(k_sweets_types_num):
#     input()
#     ai_sweets_owners.append(list(map(int, input().split())))

sunuke_n_has = {}

for i, sweets_owners in enumerate(ai_sweets_owners):
    for sweets_owner in sweets_owners:
        sunuke_n_has[sweets_owner] = True

# debug(sunuke_n_has)

result = 0
for sunuke_i in range(1, n_sukuke_num+1):
    # debug(sunuke_i in sunuke_n_has)
    if not sunuke_i in sunuke_n_has:
        result += 1

print(result)

Submission status: Accepted

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

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

s = 0
for i in d:
  if i == 0:
    s += 1

print(s)

Submission status: Accepted

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

list = []

for a in A:
    for num in a:
        if num in list:
            continue
        list.append(num)

ans = N - len(list)

print(ans)

Submission status: Accepted

Solution code:
N , K = map(int,input().split())
d = [0]*K
A = [0]*K
for i in range(K):
  d[i] = int(input())
  A[i] = list(map(int,input().split()))
people = []
for i in range(K):
  for j in range(len(A[i])):
    people.append(A[i][j])
num = set(people)
print(N - len(num))

Submission status: Accepted

Solution code:
inputLine = input()
tempStr = inputLine.split(' ')

numPeople = int(tempStr[0])
numCandy = int(tempStr[1])

candyList = [0] * numPeople
for index in range(numCandy) :

		inputLine = input()
		inputLine = input()
		tempStr = inputLine.split(' ')

		for eachPeople in tempStr :
			candyList[int(eachPeople) - 1] += 1

finalAns = 0
for eachCandy in candyList :
	finalAns = finalAns + 1 if eachCandy == 0 else finalAns

print(finalAns)

Submission status: Accepted

Solution code:
line1=input("")
li1=line1.split()
numOfSnuke=eval(li1[0])
numOfSnack=eval(li1[1])
list=[];
num=0
count=1
for i in range(numOfSnuke):
  list.append(0)

while(count<=numOfSnack):
  snack = eval(input(""))
  line=input("")
  li=line.split()
  for item in li:
    list[eval(item)-1]+=1
  count+=1
for i in list:
  if i==0:
    num+=1
print(num)

Submission status: Accepted

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

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

print(pos.count(False))

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

tricked = [0] * n
for i in range(k):
    for j in range(d[i]):
        tricked[a[i][j]-1] = 1

print(n-sum(tricked))

Submission status: Accepted

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

all = set([i for i in range(1,N+1)])
nn = set()

for k_ in range(K):
  n = int(input())
  a = list(map(int,input().split()))
  nn |= set(a)
  
print(len(all-nn))

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())))
have_sweet = set(sum(A, []))
all_member = set([i for i in range(1, N+1)])
print(len(have_sweet ^ all_member))

Submission status: Accepted

Solution code:
# 190503 B
if __name__ == "__main__":
    N,K = list(map(int,input().split()))
    d = []
    A = [0] * N
    for i in range(K):
        tmpd = (int(input()))
        tmpa = (list(map(int,input().split())))
        for j in range(tmpd):
            A[tmpa[j]-1] =+ 1
    emptycnt = 0
    for i in range(N):
        if A[i] == 0:
            emptycnt = emptycnt + 1
    print(emptycnt)

Submission status: Accepted

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

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

for i in range(K):
    d=int(input())
    *x,=map(int,input().split())
    for j in range(len(x)):
        A[x[j]-1]+=1
    
print(len([x for x in A if x==0]))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
NK = [int(x) for x in input().split()]
d=[]
A=[]
x=[]
n=0
for i in range(NK[1]):
  d.append(int(input()))
  A.append([int(x) for x in input().split()])
for i in A:
  for j in i:
    for k in range(NK[0]):
      if j==k+1:
        x.append(j)
        
for i in range(NK[0]):
  if i+1 in x:
    n+=1
print(NK[0]-n)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N,K = map(int,input().split())
okashi=[0] * N
for i in range(K):
  x=input()
  y=input().split()
  for j in y:
    okashi[int(j)-1]=1
counter=0

for i in okashi:
  if i==0:
    counter=counter+1
print(counter)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
num_list = [int(i) for i in input().split()]
have_list = [list(map(int, input().split())) for i in range(num_list[1]*2)]
user_list = [have_list[i] for i in range(len(have_list)) if i % 2 != 0]

check_set = []
for i in user_list:
    check_set += i
check_set = set(check_set)

ans_num = num_list[0] - len(check_set)
print(ans_num)

Submission status: Accepted

Solution code:
N, K = [int(n) for n in input().split()]
have_players = set()
for i in range(0, K):
    di = int(input())
    [have_players.add(n) for n in input().split()]
ans = N - len(have_players)
print(ans)

Submission status: Accepted

Solution code:
s = []
j = 0
num = 0

n,k = map(int, input().split())
for i in range(k):
  d = int(input())
  s.extend(input().split())

s = list(set(s))
for j in range(n):
  p = str(j + 1)
  if p in s:
    num += 1

print(n - num)

Submission status: Accepted

Solution code:

n,k = map(int,input().split())
dlist = list(range(1,n+1))

d = []
for i in range(k):
    d.append(int(input()))
    a = list(map(int,input().split()))
    for j in range(len(a)):
        if a[j] in dlist:
            dlist.remove(a[j])
print(len(dlist))

Submission status: Accepted

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

J = []
for i in range(K):
    d = int(input())
    A = [int(g) for g in input().split()]
    J.extend(A)
    i = i + 1
    
j = collections.Counter(J)
ans = N - len(j)

print(ans)

Submission status: Accepted

Solution code:
people, snack = map(int, input().split())

have_list = [1 for _ in range(people)]

for i in range(snack):
  d = int(input())
  if d == 1:
    person = int(input())
    have_list[person-1] = 0
  else:
    for person in map(int, input().split()):
      have_list[person-1] = 0
      
print(sum(have_list))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N,K = map(int, input().split())
has = [False for i in range(N)]
for i in range(K):
    input()
    args = list(map(int, input().split()))
    for i in args:
        has[i-1] = True

res = 0
for i in has: 
    if i == False: 
        res += 1
print(res)

Submission status: Accepted

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

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

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

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import collections

N,K = map(int,input().split())
l = []
for i in range(K):
    d = int(input())
    for a in input().split():
        l.append(a)
print(N - len(collections.Counter(l)))

Submission status: Accepted

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

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

for _ in range(k):
    d = int(input())
    if d == 1:
        having_okasi.add(input())
    else:
        having_okasi |= (set(input().split()))

print(n - len(having_okasi))

Submission status: Accepted

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

list_A = [0]*N
ans = 0
d = []
A = []

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

list_A = [0]*N

for i in range(len(A)):
    for j in A[i]:
        list_A[j-1] += 1
        
for i in range(N):
    if list_A[i] == 0:
        ans += 1
        
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:

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

ans =[]

A = [0]*k
x = [0]*k

for j in range(k):
     x[j]= int(input())
     A[j] = [int(x) for x in input().split()]
     ans += A[j]



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

Submission status: Accepted

Solution code:
N,K = map(int,input().split())
Ds = []
players = set()
ans = 0
for i in range(K):
    Ds.append(int(input()))
    players |= set(input().split())
for i in range(N):
    if not str(i+1) in players:
        ans+=1
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,k=[int(x) for x in input().split()]
a=set()
for i in range(k):
    m=int(input())
    arr=[a.add(int(x)) for x in input().split()]
    
print(n-len(a))

Submission status: Accepted

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

for i in range(K):
    d = input()
    a=list(map(int, input().split()))
    for aa in a:
        if aa in A:
            A.remove(aa)

print(len(A))

Submission status: Accepted

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

l = [0]*n
for ai in a:
    buf = list(map(int,ai.split()))
    for b in buf:
        l[b-1]=1

total =0 
for ln in l:
    if ln == 0:
        total += 1
        
print(total)

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
res = {i for i in range(N)}
for _ in range(K):
    d = int(input())
    ll = list(map(int, input().split()))
    for l in ll:
        res -= {l-1}

print(len(res))

Submission status: Accepted

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

ans = 0
for i in range(1, n+1):
    if i not in lst:
        ans += 1
print(ans)

Submission status: Accepted

Solution code:
from sys import stdin
N, K = map(int, input().split())

data = [list(map(int, stdin.readline().rstrip().split())) for _ in range(N*2)]
sunuke = []
for i in data[1::2]:
  for j in i:
    if not j in sunuke:
      sunuke.append(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())
    snucks = list(map(int,input().split()))
    for i in snucks:
        s.add(i)
print(n-len(s))

Submission status: Accepted

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

k_lst = []
a_lst = []

for _ in range(k):
    k_lst.append(int(input()))
    a_lst.extend(list(map(int,input().split())))

ans = 0

for i in range(n):
    if (i+1) in a_lst:
        continue
    else:
        ans += 1 

print(ans)

Submission status: Accepted

Solution code:

import collections

[n,k] = list(map(int, input().strip().split()))

counts = collections.Counter()
for i in range(k):
	d = int(input().strip())
	
	arr = list(map(int, input().strip().split()))
	for num in arr:
		counts[num] += 1

ans = 0

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

Submission status: Accepted

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

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

sunuke = [0] * (n+1)

for i in range(k):
    tmp = d[i]
    for j in range(tmp):
        sunuke[a[i][j]] += 1

print(sunuke.count(0)-1)

Submission status: Accepted

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

people = []

for i in range(0, K):
  d = int(input())
  A = list(map(int, input().split(" ")))
  # print(d, A)
  for j in range(d):
    people.append(A[j])

# print(people)
print(N - len(set(people)))

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import numpy as np

n, k = map(int, input().split())
f = np.zeros(n)
for i in range(k):
    d = int(input())
    a = map(int, input().split())
    for ai in a:
        f[ai-1] += 1
print(np.count_nonzero(f==0))

Submission status: Accepted

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

lis=[]

for i in range(m):
    nb=int(input())
    lis2=list(map(int,input().split()))
    for j in range(nb):
        if lis2[j] not in lis:
            lis.append(lis2[j])


ans=n-len(lis)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

from sys import stdin


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

    okashi = [False] * n
    for a in A:
        for j in a:
            okashi[j - 1] = True
    print(okashi.count(False))
    pass


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(map(int,input().split()))
  for j in range(d):
    if A[j] not in a:
      a.append(A[j])
      
print(n-len(a))

Submission status: Accepted

Solution code:
import collections

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

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

m = len(list(c.keys()))

print(N-m)

Submission status: Accepted

Solution code:

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

okashi = [0 for _ in range(n)]
#print(okashi)
for i in range(k):
    d = int(input())
    lis = list(map(int,input().split()))
    for j in lis:
        okashi[j-1] = 1
        
#print(okashi)
print(okashi.count(0))

Submission status: Accepted

Solution code:
line = input().split(" ")
b = []
for i in range (int(line[1]) * 2):
  if i%2 == 0:
    a = input()
    continue
  a = input().split(" ")
  for j in a:
    b.append(j)
print(int(line[0]) - len(set(b)))

Submission status: Accepted

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

for i in range(k):
    d = int(input())
    get = list(map(int, input().split()))
    for j in range(d):
        A[get[j] - 1] = True

for i in range(len(A)):
    if not A[i]:
        count += 1

print(count)

Submission status: Accepted

Solution code:
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from functools import reduce


sys.setrecursionlimit(2147483647)
INF = 10 ** 13
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


n, k = LI()
B = [0] * n
for _ in range(k):
    d = I()
    A = LI()
    for a in A:
        B[a - 1] = 1

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

print(ans)

Submission status: Accepted

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

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

n = list(range(1,N+1))

itazura = set(A) ^ set(n)

print(len(itazura))

Submission status: Accepted

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

a = []

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



a = set(a)

print(len(set(range(1,n+1)) - a))

Submission status: Accepted

Solution code:
g = set()
lists = list(map(int, input().split())) #１行の入力をi[0],i[1]というように空白で分けてを取得し、iに値を入れる
for i in range(lists[1]):
    
    d = int(input())
    a = list(map(int, input().split())) #１行の入力をi[0],i[1]というように空白で分けてを取得し、iに値を入れる
    for j in range(d):
        g.add(a[j])

print(lists[0] - len(g))

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

ans = set(sum(a, []))
print(n-len(ans))

Submission status: Accepted

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

for i in range(K) :
  d = int(input())
  if d == 1 :
    ans.add(int(input()))
  else :
    A = list(map(int, input().split()))
    for j in A :
      ans.add(j)
      
print(N - len(ans))

Submission status: Accepted

Solution code:
d=[]
A=[]
Ans=[]

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

for n in range(K):
    d=int(input())
    S= list(map(int,input().split()))
    for s in S:
        A.append(s)

for n1 in range(1,N+1):
    if n1 not in A:
        Ans.append(n1)

print(len(Ans))

Submission status: Accepted

Solution code:
N, K = (int(x) for x in input().split())
d = []
for i in range(1,N+1):
  d.append(i)
#print(d)
#dset = set(d)
for i in range(K):
    di = int(input())
    A = [int(x) for x in input().split()]
      #Aset = set(A)
#    print(A)
    for a in A:
      if a in d:
      	d.remove(a)
print(len(d))

Submission status: Accepted

Solution code:
if __name__ == "__main__":
    N, K = map(int, input().split())
    member = set()
    for _ in range(K):
        trash = input()
        member |= set(map(int, input().split()))
    print(N-len(member))

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
s = set()
for _ in range(k):
    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())

hogelist = [0] * N

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

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

print(count)

Submission status: Accepted

Solution code:
import sys
from math import sqrt
from collections import Counter, defaultdict, deque

input = sys.stdin.readline
sys.setrecursionlimit(10 ** 6)


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


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


def LI():
    return list(MI())


def LIN(n: int):
    return [I() for _ in range(n)]


inf = float("inf")
mod = 10 ** 9 + 7


def main():
    n, k = MI()

    li = []
    for _ in range(k):
        _ = I()
        li.append(LI())

    child = list(range(1, n + 1))

    for l in li:
        for c in l:
            if c in child:
                child.remove(c)

    print(len(child))


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=A+list(map(int,input().split()))
k=len(set(A))

print (N-k)

Submission status: Accepted

Solution code:
import collections as col
N,K = map(int,input().split())
d_i = list()
sunuke_have = list()
for i in range(K):
    d_i = int(input())
    sunuke_have.append(list(map(int,input().split())))

sunuke_f = [0]*(N+1)
for i in range(K):
    for j in range(len(sunuke_have[i])):
        sunuke_f[sunuke_have[i][j]] +=1
# print(sunuke_f)
print(sunuke_f.count(0)-1)

Submission status: Accepted

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

snack_holder = set()
for d, a in da:
    snack_holder |= set(a)

print(n - len(snack_holder))

Submission status: Accepted

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

sunuke_tachi = list(range(1, N + 1))
for Ai in A:
    sunuke_tachi = list(set(sunuke_tachi) - set(Ai))

answer = len(sunuke_tachi)

print(answer)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import collections

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

d = []
a = []

for i in range(k):
    d_ = int(input())
    d.append(d_)
    a_ = list(map(int,input().split()))
    a = a + a_

c = collections.Counter(a)

# print(c)
# print(c.keys())
ans = 0
for i in range(n):
    if i+1 not in c.keys():
        ans += 1
print(ans)

Submission status: Accepted

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

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

#print(AA_list)

ihav_cnt = [0 for _ in range(N) ]
#print(ihav_cnt)

for d, A_list in enumerate(AA_list):
    for a, A in enumerate(A_list):
        ihav_cnt[A-1] = ihav_cnt[A-1]+1

# 0の人をカウント
cnt = 0
for ihav in ihav_cnt:
    if ihav == 0:
        cnt = cnt + 1

print(cnt)

Submission status: Accepted

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

for num in range(N):
    okashi_map[num+1] = 0

for _ in range(K):
    okashi = input()
    sunuke_list = list(map(int, input().split()))
    for sunuke in sunuke_list:
        okashi_map[sunuke] += 1

find_keys = [k for k, v in okashi_map.items() if v == 0]

print(len(find_keys))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
N, K = map(int, sys.stdin.readline().split())
d = []
A = []
for i in range(2 * K):
    if i % 2 == 0:
        d.append(int(input()))
    else:
        A.append(list(map(int, input().split())))
B = set(sum(A, []))
print(N - len(B))

Submission status: Accepted

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

for i in range(k):
    okashi = int(input())
    people = list(map(int, input().split()))
    for num in people:
        if num in l:
            l.remove(num)

print(len(l))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import defaultdict as dd
N,K=map(int,input().split())
res = [0]*N
for i in range(K):
    d = int(input())
    a = list(map(int,input().split()))
    for val in a:
        res[val-1]=1
print(N-sum(res))

Submission status: Accepted

Solution code:
import collections
N, K = map(int, input().split())
d = [0]*K
A = []
counter = 0
for i in range(K):
    d[i] = int(input())
    A.extend(list(map(int, input().split())))
l = collections.Counter(A)

counter = N - len(l)
print(counter)

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
l_d = []
l_A = []
for i in range(K):
  di = int(input())
  Ai = list(map(int, input().split()))
  l_d.append(di)
  l_A.append(Ai)

l = [0]*N
for i in range(len(l_A)):
  for j in l_A[i]:
    l[j-1] = 1

print(l.count(0))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/python3

#標準出力からの読み込み

input_1 = input()
n = int(input_1.split(" ")[0])
k = int(input_1.split(" ")[1])

input_array = []
for i in range(k):
    input()
    input_array.append(input().split(" "))

for i in range(len(input_array)):
    for j in range(len(input_array[i])):
        input_array[i][j] = int(input_array[i][j])

#判定ロジック
trick_list = []
for i in range(n):
    trick_list.append(i+1)

for i in range(len(input_array)):
    for j in range(len(input_array[i])):
        try:
            trick_list.remove(input_array[i][j])
        except:
            pass
            
print(len(trick_list))

Submission status: Accepted

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

ans = 0

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

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

print(str(ans))

Submission status: Accepted

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

for i in range(2*K):
  if(i%2==0):
    tmp = input()
    pass
  else:
    list_tmp = list(map(int, input().split()))
    for item in list_tmp:
      ans_list.append(item)

print(N - len(set(ans_list)))

Submission status: Accepted

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

Submission status: Accepted

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

import sys
sys.setrecursionlimit(10**7)
from pprint import pprint as pp
from pprint import pformat as pf

import math
#from sortedcontainers import SortedList, SortedDict, SortedSet # no in atcoder
import bisect


if __name__ == '__main__':
    any_haver = set()
    num_nusuke, num_treat_type = list(map(int, input().split()))
    for i in range(num_treat_type):
        _ = int(input())
        treat_haver = list(map(int, input().split()))
        for nusuke_id in treat_haver:
            any_haver.add(nusuke_id)
    # check
    count_not_have = 0
    for nusuke_id in range(1, num_nusuke + 1):
        #print('nusuke_id') # debug
        #print(nusuke_id) # debug
        if nusuke_id not in any_haver:
            count_not_have += 1
    #print('count_not_have') # debug
    #print(count_not_have) # debug
    print(count_not_have)



    #print('\33[32m' + 'end' + '\033[0m') # debug

Submission status: Accepted

Solution code:
inp = input()
inplist1 = inp.split()
people = int(inplist1[0])
kinds = int(inplist1[1])

inplist2 = [input() for i in range(kinds * 2)]

foodlist = []
roop = 0
for i in inplist2:
  if roop % 2 == 0 :
    roop += 1
    continue
  boys = i.split()
  for boy in boys:
    foodlist.append(boy)
  roop += 1

setlist = set(foodlist)
print(people -len(setlist))

Submission status: Accepted

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

sunuke = [i for i in range(1, N+1)]
sunuke = set(sunuke)

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

ans = len(sunuke - A)

print(ans)

Submission status: Accepted

Solution code:
n, k = [int(i) for i in input().split(" ")]
d = []
ans = [i for i in range(1, n + 1)]
for i in range(k):
    d.append(int(input()))
    A = [int(i) for i in input().split(" ")]
    for delete in A:
        if delete in ans:
            ans.remove(delete)
print(len(ans))

Submission status: Accepted

Solution code:
import math, sys
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from copy import deepcopy
from functools import lru_cache
from heapq import heapify, heappop, heappush
from itertools import accumulate, combinations, permutations
input = sys.stdin.readline
mod = 10**9 + 7
ns = lambda: input().strip()
ni = lambda: int(input().strip())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

def main():
    n, k = nm()
    d = []
    a = []
    for _ in range(k):
        temp1 = ni()
        d.append(temp1)
        temp2 = nl()
        a.append(temp2)
    
    ans = [0] * (n + 1)

    for arr in a:
        for value in arr:
            ans[value] += 1
    out = 0 
    for value in ans:
        if value == 0 :
            out += 1
    print(out - 1)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

for i in range(K):
    num = int(input())
    discard_num = [int(y) for y in input().split()]
    for j in range(len(discard_num)):
        s.discard(discard_num[j])

print(len(s))

Submission status: Accepted

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

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

count = 0
for i in range(N):
    if human[i] == 0:
        count += 1

print(count)