Problem:


Score : 200 points

Problem Statement

N Snukes called Snuke 1, Snuke 2, ..., Snuke N live in a town.

There are K kinds of snacks sold in this town, called Snack 1, Snack 2, ..., Snack K. The following d_i Snukes have Snack i: Snuke A_{i, 1}, A_{i, 2}, \cdots, A_{i, {d_i}}.

Takahashi will walk around this town and make mischief on the Snukes who have no snacks. How many Snukes will fall victim to Takahashi's mischief?

Constraints

All values in input are integers.

1 \leq N \leq 100

1 \leq K \leq 100

1 \leq d_i \leq N

1 \leq A_{i, 1} < \cdots < A_{i, d_i} \leq N

Input

Input is given from Standard Input in the following format:

N K
d_1
A_{1, 1} \cdots A_{1, d_1}
\vdots
d_K
A_{K, 1} \cdots A_{K, d_K}

Output

Print the answer.

Sample Input 1

3 2
2
1 3
1
3

Sample Output 1

1

Snuke 1 has Snack 1.

Snuke 2 has no snacks.

Snuke 3 has Snack 1 and 2.

Thus, there will be one victim: Snuke 2.

Sample Input 2

3 3
1
3
1
3
1
3

Sample Output 2

2



Sample input:
3 2
2
1 3
1
3


Sample output:
1

Submission status: Accepted

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

Submission status: Accepted

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: Accepted

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

d = [0 for i in range(k)]
a = [0 for i in range(k)]

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

l=[]
for c in range(len(a)):
    l.extend(a[c])
ls=list(set(l))
print(n-len(ls))

Submission status: Accepted

Solution code:
N, K = list(map(int, input().split(" ")))
length = {}
list1 = {}
for i in range(K):
    length[i] = int(input())
    list1[i] = list(map(int, input().split(" ")))
count = 0
List = []
for i in range(K):
    List.extend(list1[i])
Set = set(List)
print(N-len(Set))

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
d = []
A = []
setA = set(A)
ListN=[]
for i in range(1, N+1):
  ListN.append(i) 
setN = set(ListN) 

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

print(len(setA^setN))

Submission status: Accepted

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 q:
        ans[j - 1] = 1

print(ans.count(0))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N,K = map(int,input().split())
l =[]
for i in range(K):
    input()
    l.extend(list(map(str,input().split())))
count = 0
for i in range(1,N+1):
             if str(i) not in l:
                     count+=1
             else:
                 pass
print(count)

Submission status: Accepted

Solution code:
n,k=map(int,input().split())	
x=[list(map(int, input().split())) for i in range(2*k)]
ans=[range(1,n+1)]
num=[]
many=x[0:2*k:2]
cookie=x[1:2*k:2]
for y in range(len(cookie)):
    for z in range(len(cookie[y])):
        num.append(cookie[y][z])
Q=set(num)
W=list(Q)
print(n-len(W))

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
l = []
import collections
for i in range(k*2):
    if (i%2)!=0:
        a = list(map(int, input().split()))
        l.extend(a)
    else:
      b = int(input())

l = collections.Counter(l)

print(n-len(l))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
R = lambda: map(int, input().split())
n, k = R()
s = set()
for _ in range(k):
  R()
  s.update(R())
print(n - len(s))

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
# スペース区切りの整数の入力
N, K = map(int, input().split())
# すぬけ君リスト
l = [0] * N
# お菓子
i = 1
for i in range(1, K+1):
   di = int(input())
   Aidi = input().split()
   for sunuke_num in Aidi:
       l[int(sunuke_num) - 1] += i
# 出力
trick_num = 0
for sunuke_okasi in l:
    if sunuke_okasi == 0:
        trick_num += 1

print(trick_num)

Submission status: Accepted

Solution code:
import itertools

n,k = map(int,input().split())
d = [0]*k
A =[]
ans = 0

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

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

print(ans)

Submission status: Accepted

Solution code:
l = list(map(int,input().split()))
n = l[0]
l_all = list(range(1,n+1))
#print(ln)
k = l[1]

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

lh = []
for i in range(1,(k*2)+1):
  #print(i)
  if (i+1)%2 == 0:
    lh.extend(a[i])
    
#print(lh)
lnh = list((set(l_all) - set(lh)))
print( len(lnh) )

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
N,K = map(int,input().split())
N_set = set(range(N+1))
N_set = N_set - {0}
kari = []
for i in range(2*K):
  if i % 2 == 0:
    a = input()
    pass
  else:
    kari.append([int(k) for k in input().split()])
flatten = lambda x: [z for y in x for z in (flatten(y) if hasattr(y, '__iter__') and not isinstance(y, str) else (y,))]
kari = set(flatten(kari))
sa = N_set - kari
print(len(sa))

Submission status: Accepted

Solution code:
if __name__ == '__main__':
    N,K=input().split(" ")
    p=int(N)
    q=int(K)
    a=[0]*p
    judge=0
    for i in range(0,q):
        k=int(input())
        b=[int(t) for t in input().split()]
        for j in range(0,len(b)):
            a[b[j]-1]+=1
    for m in range(0,p):
        if a[m]==0:
            judge+=1
    print(judge)

Submission status: Accepted

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

N,K = map(int, input().split())
n_l = list(range(1, N+1))

while K > 0:
    i = int(input())
    j_l  = list(map(int, input().split()))
    for k in range(1, i+1):
        j = j_l[k-1]
        if j in n_l:
            n_l.remove(j)
    K -= 1

print(len(n_l))

Submission status: Accepted

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

s = {i: 0 for i in range(1, n+1)}
for i in range(k):
    d = int(input())
    a = list(map(str, input().split()))

    for kasi in a:
        s[int(kasi)] = s[int(kasi)] + 1

ans_list = list(s.values())
ans = ans_list.count(0)
print(ans)

Submission status: Accepted

Solution code:
N ,K = input().split()
list1=[]
for i in range(int(K)):
    new = input()
    list2= list(input().split())
    for  j in range(int(new)):
        list1.append(list2[j])
list1= set(list1)
length = len(list1)
print(int(N) - length)

Submission status: Accepted

Solution code:
import collections

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


num = collections.Counter(X)
print(N - len(num))

Submission status: Accepted

Solution code:
n,k = map(int,input().split())
a=list()
for i in range(1,k+1):
  d=input()
  a.extend(list(map(int,input().split())))
set(a)
cnt=0
for f in range(1,n+1):
  if not(f in a):     
      cnt=cnt+1

print(cnt)

Submission status: Accepted

Solution code:
import sys
import itertools
stdin = sys.stdin
ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))

N,K=nm()
A=[0 for i in range(N)]
for i in range(K):
    d=int(input())
    tmp=nl()
    for j in range(d):
        A[tmp[j]-1]+=1
c=0
for i in range(N):
        if(A[i]==0):
            c+=1

print(c)

Submission status: Accepted

Solution code:
from collections import Counter

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

c = Counter(l)
print(n-len(c))

Submission status: Accepted

Solution code:
import itertools

n, k = map(int, input().split())
d = [0]*k
a = []
for i in range(k):
    d[i] = int(input())
    sn = list(map(int, input().split()))
    a.append(sn)
res = itertools.chain(*a)
res = list(res)
res_s = list(set(res))
print(n - len(res_s))

Submission status: Accepted

Solution code:
i = list(map(int, input().split()))
n = i[0]
k = i[1]

lists = []
for j in range(k):
  d = int(input())
  a = list(map(int, input().split()))
  for b in range(d):
    lists.append(a[b])
    
    
c = len(set(lists))
print(n-c)

Submission status: Accepted

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

pp = []
for i in range(2*k):
    pp.append(list(input().split()))

p = pp[1::2]
s = 0
l = []

for i in range(k):
    q = p[i]
    l.extend(q)


ll = set(l)

print(n - len(ll))

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!

s = input().rstrip().split(' ')
trick = int(s[0])
sunuke = []

for i in range(int(s[1])):
  kind = str(input())
  has = input().rstrip().split(' ')
  
  for j in range(len(has)):
    sunuke.append(has[j])

sunuke = set(sunuke)


print(trick - len(sunuke))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, K = (int(i) for i in input().split(' '))
N = str(N)
listN = [str(n+1) for n in range(int(N))]
for i in range(K):
    d = int(input())
    A = input().split(' ')
    for j in A:
        if j in listN:
            listN.remove(j)
print(len(listN))

Submission status: Accepted

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

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

res = [ flatten for inner in a for flatten in inner ]

for j in range(0, len(res)):
    l[int(res[j])-1]+=1

cnt = 0
for k in range(0, len(l)):
    if(l[k]==0):
        cnt+=1

print(cnt)

Submission status: Accepted

Solution code:
N,K=map(int,input().split())
a=[]
for i in range(K):
    d=int(input())
    k=list(map(int,input().split()))
    a.append(k)
b=[]
for m in range(K):
    b+=a[m]
b=set(b)
ans=N-(len(b))
print(ans)

Submission status: Accepted

Solution code:
from sys import stdin

N,K=map(int,input().split())
A = []
for i in range(K):
    d=int(input())
    tmp = list(map(int, input().split())) 
    for j in range(d):
        if not tmp[j] in A:
            A.append(tmp[j])

print(N-len(A))

Submission status: Accepted

Solution code:
n,k = map(int,input().split())
a={i for i in range(1,n+1)}
b={0}
for _ in range(k):
    m=int(input())
    l=set(list(map(int,input().split())))
    b|=l
print(len(a-b))

Submission status: Accepted

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

for i in range(N):
  arr.append(i+1)

for j in range(K):
  S = input()
  d1 = input().split()
  for k in range(len(d1)):
    if int(d1[k]) in arr:
      arr.remove(int(d1[k]))

print(len(arr))

Submission status: Accepted

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

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

for i in range(1,N+1):
    for j in range(K):
        if A[j].count(i) == 0:
            flag += 1
    if flag == K:
        count += 1
        flag = 0
    else:
        flag = 0

print(count)

Submission status: Accepted

Solution code:
NK = list(map(int, input().split()))
N=NK[0]
K=NK[1]
sunukes = [i+1 for i in range(N)]
for i in range(K):
  d = int(input())
  A = map(int, input().split())
  for a in A:
    if a in sunukes:
      sunukes.remove(a)

print(len(sunukes))

Submission status: Accepted

Solution code:
N, K =list(map(int, input().split()))
okashi_list =[]
child_list = []
for i in range(K):
    okashi = input()
    okashi_list.append(okashi)
    child = list(map(int, input().split()))
    child_list.extend(child)
child_list = set(child_list)
D = list(range(1,N+1))
count = 0
for i in D:
    if i not in child_list:
        count = count + 1
print(count)

Submission status: Accepted

Solution code:
import collections
N,K=map(int,input().split())
sunuke=[]
for i in range(K):
    d=int(input())
    okashi=input().split()
    for i in range(d):
        sunuke.append(okashi[i])

have_okashi=collections.Counter(sunuke)
print(N-len(have_okashi))

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
ns=set()
for x in range(k):
    d=int(input())
    hl=list(input().split())
    for y in range(d):
        ns.add(hl[y])
have=len(ns)
trick=n-have
print(trick)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
NK = input().split()
d = []
boys = []
for k in range(int(NK[0])):
    boys.append(k+1)

for i in range(int(NK[1])):
    d.append(input())
    l = input().split()
    for item in l:
        if int(item) in boys:
            boys.remove(int(item))

print(len(boys))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,k = map(int,input().split())
d = []
a = []
u = set(range(1,n+1))
okashi = set()
for i in range(k):
    d.append(int(input()))
    a.append(list(map(int,input().split())))

for i in a:
    for j in i:
        okashi.add(j)

print(len(u-okashi))

Submission status: Accepted

Solution code:
x, y = list(map(int, input().split(' ')))
set1 = {a + 1 for a in range(x)}
for i in range(y):
    num = int(input())
    row = set(map(int, input().split(' ')))
    for v in row:
        set1.discard(v)

print(len(set1))

Submission status: Accepted

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


    print(a.count(0))

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
a = ""
b = []
for i in range(0,k):
    a = input()
    b += input().split()
c = set(b)
print(n - len(c))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
di = K * 2
l = []
for i in range (di):
    l.append(input().split())
l1 = []
x = 1
while x < di:
    for j in l[x]:
        l1.append(j)
    x += 2
l1 = set(l1)
print(N - len(l1))

Submission status: Accepted

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[a[j] - 1] += 1

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

print(res)

Submission status: Accepted

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

l = []
for i in range(K):
    s = input()
    l += list(map(int, input().split()))

print(N-len(set(l)))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
f=[True for i in range(n)]
for K in range(k):
    d=int(input())
    a=list(map(int,input().split()))
    for A in a:
        f[A-1]=False
        
print(sum(f))

Submission status: Accepted

Solution code:
N, K = (int(x) for x in input().split())
h = [[input().split() for i in range(2)] for _ in range(K)]
a = [0] * (N+1)
a[0] = 1
for i in range(0, K):
    for j in range(0, int(h[i][0][0])):
        a[int(h[i][1][j])] = 1
print(a.count(0))

Submission status: Accepted

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

print(lis.count(0))

Submission status: Accepted

Solution code:
def cal():
    snukes, snacks = input().split(" ")
    list1 = []
    for i in range(int(snacks)):
        num = int(input())
        str1 = input()
        list1.extend(str1.split(" "))

    count = 0

    for i in range(1, int(snukes) + 1):
        if str(i) not in list1:
            count += 1
    print(count)


cal()

Submission status: Accepted

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

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

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

print(ans)

Submission status: Accepted

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

d = []
l = []
i = 0

while i < 2*K:
  i += 1
  if i % 2 == 0:
    l.extend([int(x) for x in input().split()])
  else:
    d.append(int(input()))

L = list(set(l))
print(N - len(L))

Submission status: Accepted

Solution code:
n,k = input().split()
nlist = []
for i in range(int(k)):
    vain = int(input())
    if vain == 1:
        list = [input()]
    else :
        list= input().split()
    nlist.extend(list)
nlist = set(nlist)
c = len(nlist)
print(int(n)-int(c))

Submission status: Accepted

Solution code:

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

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

    for j in range(len(a)):
        l[a[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())
  Ak = list(input().split())
  for j in Ak:
    A[j] = 1

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

Submission status: Accepted

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

sunukeJudgeList = [0] * sunukeCount
for i in range(k):
    ninzu = int(input())
    sunukeNumberList = input().split()
    for p in range(len(sunukeNumberList)):
        sunukeJudgeList[(int(sunukeNumberList[p]) - 1)] = 1

list = []
for i in range(len(sunukeJudgeList)):
    if sunukeJudgeList[i] == 0:
        list.append(1)

print(len(list))

Submission status: Accepted

Solution code:
N,K = map(int,input().split())
prank = []
output = []
for i in range(K*2) :
    prank.append(input().split())
m = 1
while m < K*2 :
    for n in prank[m]:
        output.append(n)
    m += 2
print(N-len(set(output)))

Submission status: Accepted

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

def main():
    N, K = map(int, input().split())
    d = []
    A = []
    for i in range(K):
        d.append(int(input()))
        A.append(input().split())
    all_A = sum(A, [])
    all_A = [int(i) for i in all_A]
    M = [i for i in range(1, N + 1)]
    print(len(set(M) - set(all_A)))


main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,k = map(int, input().split())
di=[0]*k
Ap=[0]*n
for i in range(0,k):
    di[i] = int(input())
    A = list(map(int, input().split()))
    ai=0
    A.append(-100)
    for j in range(1,n+1):
        if A[ai]==j:
            ai=ai+1
            Ap[j-1]=1
num=0
for l in range(0,n):
    if Ap[l]==0:
        num=num+1
print(num)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

def main():
  N, M = map(int, input().split())
  sunukes = set(range(1, N+1))
  
  is_skip = True
  for i in range(M*2):
    d = list(map(int, input().split()))
    if is_skip:
      is_skip = False
      continue

    sunukes = sunukes - set(d)
	
    is_skip = True

  print(len(list(sunukes)))
  
  
if __name__ == '__main__':
  main()

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
c = 2 * k
ls = [input().split() for _ in range(c)]
i = 1
l = []
while i < c:
    for j in ls[i]:
        l.append(j)
    i += 2
print(n-len(set(l)))

Submission status: Accepted

Solution code:
n, k = map(int, input().split()) 
L = list(i for i in range(1,n+1))
for i in range(k):
  d = int(input())
  A = list(map(int, input().split()))
  for j in A:
    L = [0 if m == j else m for m in L]
  
print(n-L.count(0))

Submission status: Accepted

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

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

z = [0] * n

for x in range(n):
    z[x] = x + 1

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

print(len(z))

Submission status: Accepted

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

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

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

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

if __name__ == "__main__":
  main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

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

total = sum(ac)
ans = n - total

print(ans)

Submission status: Accepted

Solution code:
import itertools

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

list_1 = []

for i in range(K):
    x = input()
    list_2 = list(map(int,input().split()))
    list_1.append(list_2)

print(N-len(set(list(itertools.chain.from_iterable(list_1)))))

Submission status: Accepted

Solution code:
N_nin, K_ko = map(int, input().split())

index = [1 for i in range(N_nin)]

for i in range(K_ko):
    d = int(input())
    
    if (d != 1):
        A = list(map(int, input().split()))
        for a in A:
            temp = a - 1
            index[temp] = 0
    else:
        A = int(input()) - 1
        
        index[A] = 0
        

ans = sum(index)
print(ans)

Submission status: Accepted

Solution code:
N,K = map(int,input().split()) #intでインプット
li=[]
d=[]
counter=[0]*N
for i in range(K):
    d.append(input())
    li.append(list(map(int,input().split())))
    for j in li[i]:
        counter[j-1]+=1
print(len([i for i, x in enumerate(counter) if x == 0]))

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
# n,m = map(int,sys.stdin.readline().split())
# a = list(map(int,sys.stdin.readline().split()))
# a = [sys.stdin.readline() for _ in range(n)]
# s = sys.stdin.readline().rstrip()
# n = int(sys.stdin.readline())
import sys,bisect,math
sys.setrecursionlimit(15000)

N,K = map(int,sys.stdin.readline().split())
s = set(range(1,N+1))
for _ in range(K):
    d = int(sys.stdin.readline())
    a = set(map(int,sys.stdin.readline().split()))
    s = s-a
print(len(s))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import collections
N, K = map(int, input().split())
lists=[]
for i in range(K):
    d1=int(input())
    A1=list(map(str,input().split()))
    lists.append(A1)
a=[e for row in lists for e in row]
c = collections.Counter(a)
num=len(c)
print(N-num)

Submission status: Accepted

Solution code:
def flatten_2d(data):
    for block in data:
        for elem in block:
            yield elem

a,k = map(int,input().split())
listA=[]
cnt=0
for i in range(k):
    n = int(input())
    string_list=list(map(int,input().split()))
    listA.append(string_list)
dst=list(flatten_2d(listA))
for cou in range(1,a+1):

    if cou not in dst:
        cnt+=1

print(cnt)

Submission status: Accepted

Solution code:
n,k = map(int,input().split())
a = []
for i in range(k):
  d = int(input())
  if d == 1:
    tmp = int(input())
    a.append(tmp)
  else:
    b = [int(i) for i in input().split()]
    for item in b:
    	a.append(item)
result = 0
for i in range(n):
  if i+1 not in a:
    result += 1

print(result)

Submission status: Accepted

Solution code:
import itertools

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

l = []
k = []
for i in range(1, N+1):
    l.append(str(i))

for i in range(K):
    d = int(input())
    array = input().strip().split()
    k.append(array)
                
k = list(itertools.chain.from_iterable(k))

k = [x for x in set(k) if k.count(x) >= 1]

for i in range(len(k)):
    for j in range(len(l)):
        if k[i] == l[j]:
            l[j] = 0

cnt = 0

for i in l:
    if i == 0:
        cnt += 1

print(len(l) - cnt)

Submission status: Accepted

Solution code:
def c(n, a, cnt):
    for i in range(n):
        num = a.count(i+1)
        if num != 0:
            cnt[i] += 1

    return cnt

def solve():
    
    n, k = map(int, input().split())
    cnt = [0]*n
    for _ in range(k):
        d = int(input())
        a = list(map(int, input().split()))
        c(n, a, cnt)

    return cnt.count(0)




print(solve())

Submission status: Accepted

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

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

#print(sunuke)

for i in range(k):
  d = int(input())
  #print(d)
  A = list(map(int, input().split()))
  #print(A)
  for id, s in enumerate(sunuke):
    if s in A:
      sunuke[id] = 0
      #print(str(s) + "が0になったよ")
      #print(sunuke)

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

Submission status: Accepted

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

ans = []

for i in range(n):
    ans.append(i + 1)

b =[]

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

b = list(set(b))

for i in range(len(b)):
    ans.remove(b[i])

print(len(ans))

Submission status: Accepted

Solution code:
n, k= map(int, input().split())
num = list(range(1, n+1))
c = set()
num = set(num)
for i in range(k):
  a = input()
  b = set(list(map(int, input().split())))
  c = c.union(b)
num = list(num -c)
print(len(num))

Submission status: Accepted

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

Newlist = []
for i in range(K):
  Newlist.append(List[2*i+1])

Newlist2 = []
for i in range(K):
  for j in range(len(Newlist[i])):
    Newlist2.append(Newlist[i][j])


print(N-len(set(Newlist2)))

Submission status: Accepted

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

Submission status: Accepted

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

L = set(L)
print(N - len(L))

Submission status: Accepted

Solution code:
N, K = input().split()
P = [input().split() for i in range(2 * int(K))]
result = []
counter = 0
m = 0
for p in P:
    if m % 2 ==0:
        pass
    else:
        for i in p:
            result.append(int(i))
    m +=1

result =set(result)

for n in range(int(N)+1):
    if n ==0:
        pass
    elif n in result:
        pass
    else:
        counter +=1
print(str(counter))

Submission status: Accepted

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

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

ans = 0

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

print(ans)

Submission status: Accepted

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

print(len(ans))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import itertools
n,k=map(int,input().split())
List=[]
for i in range(k):
    s=input()
    List.append(list(map(int,input().split())))
List=list(itertools.chain.from_iterable(List))
cnt=0
for i in range(1,n+1):
    if i not in List:
        cnt+=1
print(cnt)

Submission status: Accepted

Solution code:
import itertools
N,K=map(int,input().split())
dlist=[list(map(int,input().split())) for i in range(2*K)]
alist=[]
num=0
for i in range(1,len(dlist),2):
  alist.append(dlist[i])
alist=list(itertools.chain.from_iterable(alist))
alist=set(alist)
ans=N-len(alist)
print(ans)

Submission status: Accepted

Solution code:
inputNumbers = input().split()
snuckNumber = int(inputNumbers[0])
snakeKinds = int(inputNumbers[1])
snuckDict = {}
for i in range(snakeKinds):
    temp = int(input())
    tempSnuckList = input().split()
    for item in tempSnuckList:
        snuckDict[item] = 1;

count = snuckNumber - len(snuckDict)
print(count)