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: Wrong Answer

Solution code:
n,k=map(int,input().split())
d = int(input())
while True:
    try:
        listA=list(map(int,input().split()))
        #listA<-[1,2,2,3,1]
        #ここに逐次処理を書けばいいと思う。
    except:
        break;
print(n-d)

Submission status: Wrong Answer

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

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

print(N - max_n)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:

n,k = map(int,input().split())
l = [0]*n

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

    for j in range(len(a)):
        l[j-1] += 1

print(l.count(0))

Submission status: Wrong Answer

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

nusuke = [0] * N
res = 0

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

for value in nusuke:
  if(value == 0):
    res += 1

print(res)

Submission status: Wrong Answer

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

dic = {}
for i in range(K):
    d = int(input())
    A = list(map(int, input().split()))
    for a in A:
        if not a in dic:
            dic[a] = 1

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

Submission status: Wrong Answer

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

lis = [0] * n

for i in range(k):
    num = int(input())
    dos = list(map(int, input().split()))
    for k in range(num):
        lis[k] += 1

count =0
for p in range(n):
    if lis[p] == 0:
        count += 1
        
print(count)

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
s = 0
for _ in range(K):
    d = int(input())
    A = input()
    if d > s: s = d
print(N - s)

Submission status: Wrong Answer

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

for i in range(k):
    d = int(input())
    l = list(map(int, input().split()))
    for x in l:
        ate.add(x)
print(ate)
print(n - len(ate))

Submission status: Wrong Answer

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

A.sort()
A = set(A)
count = 0
for i in range(1,K+1):
    if i in A:
        pass
    else:
        count += 1
print(count)

Submission status: Wrong Answer

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())))
print(li)
for i in range(1, N+1):
    if i not in li:
        ansli.append(i)
print(len(ansli))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
nk = input().split()
n = int(nk[0])
k = nk[1]
d = int(input())
print(n-d)

Submission status: Wrong Answer

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

snucks = set(i for i in range(1, k + 1))

for snack in range(1, k + 1):
    d = int(input())

    for snuck in map(int, input().split()):
        if snuck in snucks:
            snucks.remove(snuck)

print(len(snucks))

Submission status: Wrong Answer

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

sunuke = set(range(1, K+1))
for i in range(K):
    _ = input()
    As = [int(n) for n in input().split()]
    for A in As:
        if A in sunuke:
            sunuke.remove(A)

print(len(sunuke))

Submission status: Wrong Answer

Solution code:
N, K = list(map(int, input().split()))
a_set = set()
for k in range(K):
    d = int(input())
    A = list(map(int, input().split()))
    a_set |= set(A)

people = set(range(1, N)) - a_set

print(len(people))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

for i in range(1, k*2+1):
  if i%2==1:
    pass
  else:
    for s_i in map(int, input().split()):
      ss.add(s_i)
print(len([s for s in range(1, n+1) if s not in ss]))

Submission status: Wrong Answer

Solution code:
from sys import stdin
input=lambda : stdin.readline().strip()
from math import ceil,sqrt,factorial,gcd
n,k=map(int,input().split())
s=set()
for i in range(k):
	a=int(input())
	l=list(map(int,input().split()))
	if len(l)>0:
		s.add(a)
print(n-len(s))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:


n, k = map(int, input().split())
count = {i: [] for i in range(n)}
for i in range(k):
    input()
    a = list(map(int, input().split()))
    for ii in a:
        count[ii-1].append(i)
sum(len(item)==0 for item in count.values())

Submission status: Wrong Answer

Solution code:
a, b = map(int, input().split())
c = int(input())
print(a-c)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

d=int(input())
print(N-d)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from sys import stdin
input=lambda : stdin.readline().strip()
from math import ceil,sqrt,factorial,gcd
n,k=map(int,input().split())
s=set()
for i in range(k):
	a=int(input())
	s.add(a)
	l=list(map(int,input().split()))
print(n-len(s))

Submission status: Wrong Answer

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

a = []

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

ans = n - len(a)

print(ans)

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
N,K=map(int,input().split())
Hash=defaultdict(lambda:0)
for i in range(K):
    x=int(input())
    Hash[x]=1
    L=list(map(int,input().split()))
count=0
for i in range(1,N+1):
    if Hash[i]==0:
        count+=1
print(count)

Submission status: Wrong Answer

Solution code:
N, K = [int(x) for x in input().split()]
s = set()
for i in range(K):
    d = int(input())
    for a in map(int, input().split()):
        s.add(a)
ans = sum([a not in s for a in range(1, K+1)])
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

print(sunu.count(0))

Submission status: Wrong Answer

Solution code:
n, k = map(int, input().split())
s = set()
for _ in range(k):
    d = int(input())
    a = tuple(map(int, input().split()))
    for _a in a:
        s.add(a)

print(n - len(s))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n, k = map(int, input().split())
ls = list(range(1, n+1))
for i in range(k):
  d = int(input())
  tmp = list(map(int, input().split()))
  for p in ls:
    if p in tmp:
      ls.remove(p)
print(len(ls))

Submission status: Wrong Answer

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

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

print(ans.count(0))

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
klis = [1 for i in range(N)]
for i in range(K):
  l = int(input())
  for j in input():
    if j == ' ':
      continue
    else:
      klis[int(j)-1] = 0
  
print(sum(klis))

Submission status: Wrong Answer

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

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:

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

ans = n-d

print(ans)

Submission status: Wrong Answer

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

n,k = mi()
aa = [[]for _ in range(k)]
for i in range(k):
    d = ii()
    aa[i] = li()

dp = [0]*(n+1)
dp[0] = 1
for i in range(k):
    for l in aa[i]:
        dp[l] = 1
ans = 0
for i in range(n):
    if dp[i] == 0:
        ans += 1
print(ans)

Submission status: Wrong Answer

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):
    if i not in snuke:
        ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.buffer.readline().split()]
def I(): return int(sys.stdin.buffer.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
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)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n,k = LI()
    d = [0]*n
    for _ in range(k):
        input()
        a = LI()
        for i in a:
            d[i-1] = 1
    print(n-sum(d))
    return

#Solve
if __name__ == "__main__":
    solve()

Submission status: Wrong Answer

Solution code:
S = input()



if S == "ABC":
    print("ARC")
else:
    print("ABC")

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

N, K = map(int, input().split())
S = np.array([])
for i in range(K):
    d = input()
    for j in input().split():
        S = np.append(S, [j])

print(N - np.unique(S).size)  # np.unique(np.array).sizeユニークな要素の個数

Submission status: Time Limit Exceeded

Solution code:
n, k = map(int, input().split())
i = 0
a = list()
d = 0
while i<k:
    d += int(input())
    a += (map(int, input().split()))
    i += 1
i=0

while i<d:
    x = d-1
    while x > i:
        if a[x] < a[x-1]:
            c = a[x]
            a[x] = a[x-1]
            a[x-1] = c
        x -= 1
    i+=1

i=0
ans = a[0] - 1
while i<d-1:
    if a[i+1] - a[i]>1:
        ans += a[i+1] - a[i] -1
    i+=1
if a[d-1] != n:
    ans += n - a[d-1]

print(ans)

Submission status: Accepted

Solution code:
a,b = map(int,input().split())
w = []
t = {}
for i in range(b):
    c = int(input())
    s = list(map(int,input().split()))
    w +=s
t = set(w)
print(a-len(t))

Submission status: Accepted

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

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

print(sum(P))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
s = set()
for _ in range(k):
    tmp = int(input())
    arr = list(map(int, input().split()))

    for a in arr:
        s.add(a)

print(n - len(s))

Submission status: Accepted

Solution code:
#ABC166
n,k=map(int,input().split())
cnt=[0]*(n+1)
for j in range(k):
  tmp = int(input())
  arr=list(map(int,input().split()))
  for val in arr:
    cnt[val]+=1
ans=0
for i in range(1,n+1):
  if cnt[i]==0:
    ans+=1
print(ans)

Submission status: Accepted

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

s = set()
for _ in range(k):
  _ = int(input())
  arr = list(map(int, input().split()))
  for a in arr:
    s.add(a)
print(n-len(s))

Submission status: Accepted

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

s = [i for i in range(1,n+1)]
for _ in range(k):
  d = int(input())
  arr = list(map(int, input().split()))
  for a in arr:
    if a in s:
	    s.remove(a)
print(len(s))

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
count = 0
num_people = []
num_people_snacks = []
for i in range(1, N + 1):
    num_people.append(i)

while K > count:
    d = int(input())
    A = list(map(int, input().split()))
    for k in A:
        num_people_snacks.append(k)
    count += 1

ans = 0
for j in range(N):
    if num_people[j] not in num_people_snacks:
        ans += 1
        
print(ans)

Submission status: Accepted

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

for i in range(K):
    d = int(input())
    if d > 0:
        a = list(map(int, input().split()))
        for v in a:
            x[v] += 1

# print(a)

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

print(c)

Submission status: Accepted

Solution code:
import sys
from collections import deque, defaultdict, Counter
from itertools import accumulate, product, permutations, combinations
from operator import itemgetter
from bisect import bisect_left, bisect_right
from heapq import heappop, heappush
from math import ceil, floor, sqrt, gcd, inf
from copy import deepcopy
import numpy as np
import scipy as sp

INF = inf
MOD = 1000000007

n, k = [int(i) for i in input().split()]
d = []
A = []
for i in range(k):
    d.append(int(input()))
    A.append([int(i) for i in input().split()])

tmp = [True for i in range(n + 1)]
res = 0

for i in range(k):
    for j in range(d[i]):
        tmp[A[i][j]] = False
for i in range(1, n + 1):
    if tmp[i]:
        res += 1

print(res)

Submission status: Accepted

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

sunuke = [1] * N

for i in range(K):
    di = int(input())
    tmp = map(int, input().split())
    for j in tmp:
        sunuke[j-1] = 0
print(sum(sunuke))

Submission status: Accepted

Solution code:
import math
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(map(int, input().split()))
def i_row(N): return [int(input()) for _ in range(N)]
def i_row_list(N): return [list(map(int, input().split())) for _ in range(N)]

mnum,snum=i_map()
snholder=set()
for i in range(snum):
    d=i_input()
    ls=i_list()
    snholder=snholder | set(ls)
print(mnum-len(snholder))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

candy = [0 for i in range(N)]
for i in range(K):
  for j in range(d[i]):
    candy[A[i][j]-1] += 1
print(candy.count(0))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, K = (int(x) for x in input().split())
listN = [1] * N
# N is population / K is candy
for i in range(K):
    d = int(input())
    tmp = map(int, input().split())
    for j in tmp:
        listN[j-1] = 0
print(sum(listN))

Submission status: Accepted

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

sunuke = [1] * n

for i in range(k):
    d = int(input())
    oka = map(int,input().split())
    for j in oka:
        sunuke[j-1] = 0
        
print(sum(sunuke))

Submission status: Accepted

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

s = {i:0 for i in range(n+1)} 

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

cnt = -1

for i in s:
  if s[i] == 0:
    cnt +=1

print(cnt)

Submission status: Accepted

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

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

s[0] += 1
print(s.count(0))

Submission status: Accepted

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

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

dst = [1] * N

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

    for j in range(d):
        dst[A[j]-1] = 0

print(sum(dst))

Submission status: Accepted

Solution code:
import itertools

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=list(itertools.chain.from_iterable(A))

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

Submission status: Accepted

Solution code:
N,K=map(int,input().split())
ans=list()
for i in range(K):
  D=int(input())
  L=list(map(int,input().split()))
  ans+=L
  ans=list(set(ans))
print(N-len(ans))

Submission status: Accepted

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

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

ans = [0]*100

for i in range(k):
    for j in range(d[i]):
        ans[a[i][j]-1] = 1

print(n-sum(ans))

Submission status: Accepted

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

Submission status: Accepted

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

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

print(sunuke.count(0))

Submission status: Accepted

Solution code:
def main() -> None:
    n, k = map(int, input().split())

    check = [0] * n
    for _ in range(k):
        _ = input()
        having = tuple(map(int, input().split()))
        for idx in having:
            check[idx-1] += 1
    print(check.count(0))
    return


if __name__ == '__main__':
    main()

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
for i in range(K):
    for j in range(d[i]):
        sunuke[A[i][j] - 1] += 1

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

print(ans)

Submission status: Accepted

Solution code:
#N人　K種類のお菓子
[N, K] = [int(i) for i in input().split()]

okasi = [0]*N #i番目の人が持っているお菓子の中で、種類番号が多いものに更新する

#お菓子K種類渡す
for k in range(K):
    num = int(input()) #お菓子の番号
    have = [int(i) for i in input().split()]
    for snuke in have:
        okasi[snuke-1] = num

#お菓子持ってない人を探す
print(okasi.count(0))

Submission status: Accepted

Solution code:
if __name__ == '__main__':

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

    A = [0] * n

    for _ in range(k):
        m = int(input())
        B = list(map(int,input().split()))
        for b in B:
            A[b-1] += 1
    print(A.count(0))

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
sunukes = [0 for k in range(N)]
for k in range(K):
  d = int(input())
  A = list(map(int, input().split()))
  for a in A:
    sunukes[a-1] += 1
  assert len(A) == d
print(len([k for k in sunukes if k == 0]))

Submission status: Accepted

Solution code:
N,K=list(map(int, input().split()))
A=[0]*(N+1)
for _ in range(K):
  k=int(input())
  a=list(map(int, input().split()))
  for i in a:
    A[i]+=1
c=0
for i in range(1,N+1):
  c+=not A[i]
print(c)

Submission status: Accepted

Solution code:
import numpy as np
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 j in a:
        l[j-1] = 1

print(l.count(0))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
snukes = []
for _ in range(k):
    okashi = int(input())
    snukes += [int(v) for v in input().split()]
target = 1
cnt = 0
l = list(set(snukes))
s = [int(v) for v in range(1, n + 1)]

for p in s:
    if p not in l:
        cnt += 1
print(cnt)

Submission status: Accepted

Solution code:
def N():
    return int(input())
def L():
    return list(map(int,input().split()))
def NL(n):
    return [list(map(int,input().split())) for i in range(n)]
mod = pow(10,9)+7
#import numpy
n,k = L()
l = [1]*n
for i in range(k):
    d = N()
    a = L()
    for j in a:
        l[j-1] = 0
print(l.count(1))

Submission status: Accepted

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

for i in range(k):
    d = int(input())
    l+=map(int,input().split())
print(n-int(len(set(l))))

Submission status: Accepted

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

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

Submission status: Accepted

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

l = list(itertools.chain.from_iterable(l))
l = [int(i) for i in l]

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

sunukes = [0 for i in range(n)]

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

    for j in range(d):
        sunukes[aa[j] - 1] += 1

count = sum(1 for sunuke in sunukes if sunuke == 0)

print(count)

Submission status: Accepted

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

print(n - len(a))

Submission status: Accepted

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

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

ans = 0
for k in range(len(sunuke)):
    if sunuke[k] == 0:
        ans +=1
print(ans)

Submission status: Accepted

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

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())))
cnt=[0 for i in range(N)]
for i in range(K):
    for a in A[i]:
        cnt[a-1]+=1
print(cnt.count(0))

Submission status: Accepted

Solution code:
from collections import Counter

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

has_sweet = [False] * N

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

c = Counter(has_sweet)
print(c[False])

Submission status: Accepted

Solution code:
N,K=map(int,input().split())
A=[]
people=list(range(1,N+1,1))
for idx in range(K):
    d=int(input())
    X=list((map(int,input().split())))
    for i in range(len(X)):
        A.append(X[i])
ans =[i for i in people if not i in A]
print(len(ans))

Submission status: Accepted

Solution code:
N,K=map(int,input().split())
s = set(range(1, N+1))
for i in range(K):
    d = int(input())
    A = list(map(int,input().split()))
    for x in A:
        try:
            s.remove(x)
        except:
            pass
print(len(s))

Submission status: Accepted

Solution code:
import sys

input=sys.stdin.buffer.readline


#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return sys.stdin.read()


def II(): return int(input())


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


def MF(): return map(float,input().split())


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


def LF(): return list(map(float,input().split()))


def TI(): return tuple(map(int,input().split()))


# rstrip().decode('utf-8')
import numpy as np

def main():
	n,k=MI()
	s=set()
	for _ in range(k):
		d=II()
		A=set(LI())
		s|=(A)
	print(n-len(s))
	
	









if __name__=="__main__":
	main()

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
A = []
A_dup = []
cnt = 0

for i in range(k):
    input()
    # A.append(list(map(int, input().split())))
    A_dup += list(map(int, input().split()))
A_eldup = list(set(A_dup))

for i in range(1, n+1):
    if i not in A_eldup:
        cnt += 1
print(cnt)

Submission status: Accepted

Solution code:
import sys
def input(): return sys.stdin.readline().rstrip()

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

d = []
A = []

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

vec = [0] * N

for a in A:
    for i in a:
        i -= 1
        vec[i] += 1

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

print(ans)

Submission status: Accepted

Solution code:
from collections import defaultdict
n, k = map(int, input().split())
m = defaultdict(int)

for _ in range(k):
  input()
  for x in input().split():
    m[int(x)] += 1

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

Submission status: Accepted

Solution code:
import sys

input = sys.stdin.readline
N, K = map(int, input().split())
cnt = [0]*N
for _ in range(K):
    d = int(input())
    for a in list(map(int, input().split())):
        a -= 1
        cnt[a] += 1

ans = 0
for c in cnt:
    ans += c == 0
print(ans)