Problem:


Score : 200 points

Problem Statement

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

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

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

Constraints

All values in input are integers.

1 \leq N \leq 100

1 \leq K \leq 100

1 \leq d_i \leq N

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

Input

Input is given from Standard Input in the following format:

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

Output

Print the answer.

Sample Input 1

3 2
2
1 3
1
3

Sample Output 1

1

Snuke 1 has Snack 1.

Snuke 2 has no snacks.

Snuke 3 has Snack 1 and 2.

Thus, there will be one victim: Snuke 2.

Sample Input 2

3 3
1
3
1
3
1
3

Sample Output 2

2



Sample input:
3 2
2
1 3
1
3


Sample output:
1

Submission status: Accepted

Solution code:
n,k = map(int, input().split())
s = [ input() for i in range(k*2) ]
nl = [i for i in range(1,n+1)]
t = []
for i in range(1,k*2,2):
    l = []
    l = s[i].split()
    for j in range(len(l)):
        t.append(int(l[j]))
l = list(set(t))
for i in range(len(l)):
    nl.remove(l[i])
print(len(nl))

Submission status: Accepted

Solution code:
import sys

if __name__ == "__main__":
    line1 = sys.stdin.readline().strip()
    param1 = line1.split(" ")
    n = int(param1[0])
    k = int(param1[1])

    d = []
    A = set()

    for i in range(k):
        d_i = int(sys.stdin.readline().strip())
        A_i = [int(a) for a in sys.stdin.readline().strip().split(" ")]

        for a_i in A_i:
            A.add(a_i)
    
    print(len(set([i+1 for i in range(n)]) - A))

Submission status: Accepted

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

n_list=[]
for x in range(k):
  n_list=n_list+list[2*x+1].split()
  
n_list.sort()

s=1
for y in range(len(n_list)-1):
  if n_list[y]==n_list[y+1]:
    s=s
  else:
    s=s+1
print(n-s)

Submission status: Accepted

Solution code:
import itertools
N,K = map(int,input().split())
h =2*K
d = [input().split() for l in range(h)]
z=[]
t=[]
for a in range(h+1):
  if a%2==1:
    z.append(d[a])
s=list(itertools.chain.from_iterable(z))
o=set(s)

print(N-len(o))

Submission status: Accepted

Solution code:
def getN():
    return int(input())

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


def main():

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

    slist = [0] * N

    for i in range(K):
        d = getN()
        A = getIntList()
        for j in range(d):
            slist[A[j]-1] += 1
    
    print(slist.count(0))
    
    return

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:

hyo1 = input().split()
N = int((hyo1[0]))
K = int((hyo1[1]))
lis = []

for i in range (N):
    lis.append(i+1)
set_lis = set(lis)

for i in range(K):
    okasi = input()
    hito = list(map(int, input().split()))
    set_hito = set(hito)
    set_lis = (set_lis-set_hito)

print(len(set_lis))

Submission status: Accepted

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

t_1 = [n+1 for n in range(N)]

t_2 = []
t_3 = {}


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

    for a in A:
            
        t_2.append(int(a))

    t_3 = set(t_1) - set(t_2)
    
print(len(t_3))

Submission status: Accepted

Solution code:
s1, s2 = map(int, input().split())
A = set()

for i in range(s2):
    N = input()
    A |= set(map(int, input().split()))

print(s1 - len(A))

Submission status: Accepted

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

count = 0
p = []

for i in range(n):
    p.append(0)

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

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

print(count)

Submission status: Accepted

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

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

print(sum(all_sunuke))

Submission status: Accepted

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

sum_ita = 0
have = [0 for i in range(N)]

for i in range(K):
    d = int(input())
    nyu = list(map(int, input().split(" ")))
    for row in nyu:
        have[row - 1] += 1

print(have.count(0))

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
x=[]
for i in range(k):
  d=int(input())
  y=list(map(int,input().split()))
  for j in range(d):
    x.append(y[j])
z=set(x)
print(n-len(z))

Submission status: Accepted

Solution code:
n, k = map(int, input().split())  # x = 1, y = 2

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


bitl = 2**n - 1
for kashi in a:
    for i in kashi:
        bitl &= ~(1 << (i - 1))

print(bin(bitl).count("1"))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N,K = map(int,input().split())
lst = []
for i in range(K):
    d = int(input())
    sunuke = list(map(int,input().split()))
    n = 0
    while n < d:
        lst.append(sunuke[n])
        n += 1
moratta = len(set(lst))
print(N - moratta)

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
j = 0
count = 0
index = []
index2 = []
for i in range(1, K+1):
    d = int(input())
    index.append(input().split())
for i in range(len(index)):
    for j in index[i]:
        index2.append(j)
        index3 = set(index2)
print(N - len(index3))

Submission status: Accepted

Solution code:
N_setup_data = input().split()
N_sunuke_number = int(N_setup_data[0])
K_snack_number = int(N_setup_data[1]) - 1
K_snack_number = int(N_setup_data[1])
N_sunuke_pocket = [0] * N_sunuke_number


for j in range(K_snack_number):
	N_A_sunuke_pocket = [0] * (N_sunuke_number + 1)
	N_B_sunuke_pocket = [0] * (N_sunuke_number + 1)
	d = input()
	N_A_sunuke_pocket = input().split()
#	print(N_A_sunuke_pocket)
	for i in N_A_sunuke_pocket:
		N_B_sunuke_pocket[int(i) - 1] += 1
#	print(N_B_sunuke_pocket, i)
	j = 0

	for i in N_B_sunuke_pocket:
		if i != 0:
			N_sunuke_pocket[j] += 1
		j += 1
#		print(N_sunuke_pocket)
def calc_area():
	Out_Area = 0
	for i in N_sunuke_pocket:
		if i == 0:
			Out_Area += 1
	return Out_Area

print(calc_area())

Submission status: Accepted

Solution code:
import sys,bisect,string,math,time,functools,random
from heapq import heappush,heappop,heapify
from collections import deque,defaultdict,Counter
from itertools import permutations,combinations,groupby
def Golf():*a,=map(int,open(0))
def I():return int(input())
def S_():return input()
def IS():return input().split()
def LS():return [i for i in input().split()]
def LI():return [int(i) for i in input().split()]
def LI_():return [int(i)-1 for i in input().split()]
def NI(n):return [int(input()) for i in range(n)]
def NI_(n):return [int(input())-1 for i in range(n)]
def StoLI():return [ord(i)-97 for i in input()]
def ItoS(n):return chr(n+97)
def LtoS(ls):return ''.join([chr(i+97) for i in ls])
def GI(V,E,ls=None,Directed=False,index=1):
    org_inp=[];g=[[] for i in range(V)]
    FromStdin=True if ls==None else False
    for i in range(E):
        if FromStdin:
            inp=LI()
            a,b,c=(inp+[1])[:3]
            org_inp.append(inp)
        else:
            index=0
            a,b,c=(ls[i]+[1])[:3]
        if index==1:a-=1;b-=1
        aa=(a,c);bb=(b,c);g[a].append(bb)
        if not Directed:g[b].append(aa)
    return g,org_inp
def GGI(h,w,search=None,replacement_of_found='.',mp_def={'#':1,'.':0},boundary=1):
#h,w,g,sg=GGI(h,w,search=['S','G'],replacement_of_found='.',mp_def={'#':1,'.':0}) # sample usage
    mp=[boundary]*(w+2);found={}
    for i in range(h):
        s=input()
        for char in search:
            if char in s:
                found[char]=((i+1)*(w+2)+s.index(char)+1)
                mp_def[char]=mp_def[replacement_of_found]
        mp+=[boundary]+[mp_def[j] for j in s]+[boundary]
    mp+=[boundary]*(w+2)
    return h+2,w+2,mp,found
def TI(n):return GI(n,n-1)
def bit_combination(k,n=2):
    rt=[]
    for tb in range(n**k):
        s=[tb//(n**bt)%n for bt in range(k)];rt+=[s]
    return rt
def show(*inp,end='\n'):
    if show_flg:print(*inp,end=end)

YN=['YES','NO'];Yn=['Yes','No']
mo=10**9+7
inf=float('inf')
l_alp=string.ascii_lowercase
#sys.setrecursionlimit(10**7)
input=lambda: sys.stdin.readline().rstrip()

class Comb:
    def __init__(self,n,mo=10**9+7):
        self.fac=[0]*(n+1)
        self.inv=[1]*(n+1)
        self.fac[0]=1
        self.fact(n)
        for i in range(1,n+1):
            self.fac[i]=i*self.fac[i-1]%mo
            self.inv[n]*=i
            self.inv[n]%=mo
        self.inv[n]=pow(self.inv[n],mo-2,mo)
        for i in range(1,n):
            self.inv[n-i]=self.inv[n-i+1]*(n-i+1)%mo
        return
    
    def fact(self,n):
        return self.fac[n]
        
    def invf(self,n):
        return self.inv[n]

    def comb(self,x,y):
        if y<0 or y>x:
            return 0
        return self.fac[x]*self.inv[x-y]*self.inv[y]%mo

class Tree:
    def __init__(self,inp_size=None,init=True):
        if init:
            self.stdin(inp_size)
        return

    def stdin(self,inp_size=None):
        if inp_size==None:
            self.size=int(input())
        else:
            self.size=inp_size
        self.edges,_=GI(self.size,self.size-1)
        return
    
    def listin(self,ls):
        self.size=len(ls)+1
        self.edges,_=GI(self.size,self.size-1,ls)
        return

    def __str__(self):
        return  str(self.edges)

    def dfs(self,x,func=lambda prv,nx,dist:prv+dist,root_v=0):
        q=deque()
        q.append(x)
        v=[-1]*self.size
        v[x]=root_v
        while q:
            c=q.pop()
            for nb,d in self.edges[c]:
                if v[nb]==-1:
                    q.append(nb)
                    v[nb]=func(v[c],nb,d)
        return v

    def EulerTour(self,x,func=lambda prv,nx,dist:prv+dist,root_v=0):
        q=deque()
        q.append((-1,x))
        v=[None]*self.size
        v[x]=root_v
        et=[]
        while q:
            cb,ce=q.pop()
            et.append(ce)
            for nb,d in self.edges[ce]:
                if v[nb]==None:
                    q.append((nb,ce))
                    q.append((ce,nb))
                    v[nb]=func(v[ce],nb,d)
        vid=[[-1,-1]for i in range(self.size)]
        for i,j in enumerate(et):
            if vid[j][0]==-1:
                vid[j][0]=i
            else:
                vid[j][1]=i
        return v,et,vid
    
    def LCA_init(self,depth,et):
        self.st=SegTree(self.size*2-1,func=min,ide=inf)
        for i,j in enumerate(et):
            self.st.update(i,j)
        self.LCA_init_stat==True
        return
    
    def LCA(self,root,x,y):
        if self.LCA_init_stat==False:
            depth,et,vid=self.EulerTour(root)
            self.LCA_init(depth,et)
        return self.st.query(x,y+1)

show_flg=False
show_flg=True
ans=0

n,k=LI()
m=[1]*n
for i in range(k):
    d=I()
    a=LI_()
    for j in a:
        m[j]=0
        
ans=sum(m)
print(ans)

Submission status: Accepted

Solution code:
import itertools
n,m=map(int,input().split())
l=[input() for i in range(2*m)]
l=l[1::2]
a=[]
for j in l:
    a.append(j.split())
b=list(itertools.chain.from_iterable(a))
c=[int(j) for j in b]
d=list(set(c))
e=[]
for k in range(1,n+1):
    e.append(k)
print(len(e)-len(d))

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
count=0
l,p=[],[]
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:
			l.append(i)
for i in range(1,n+1):
	if i not in l:
		p.append(i)
print(len(p))

Submission status: Accepted

Solution code:
d=[];
A=[];
N,K=input().split();
N=int(N);
K=int(K);
for i in range(K):
  d.append(input())
  A.append(input().split());
count=0;
for i in range(N):#i君がおかしを持っているか確認
  flag=0;
  for j in range(K):
    if(str(i+1) in A[j]):#i君が種類kのお菓子を持ってるか。
      flag=1;
  if (flag == 0):
    count+=1;
print(count);

Submission status: Accepted

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

Submission status: Accepted

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

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

for i in range(K):
  _ = int(input())
  for okashi in map(int, input().split()):
    #print(sunuke)
    if okashi in sunuke:
      sunuke.remove(okashi)

print(len(sunuke))

Submission status: Accepted

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

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

ans = 0
for n in range(1, N+1):
    if n in l:
        pass
    else:
        ans += 1

print(ans)

Submission status: Accepted

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

temp_array = []

for _ in range(k):
  temp = input()
  [temp_array.append(i) for i in list(map(int, input().split())) if i != ""]

all_member = len(list(set(temp_array)))
print(n - all_member)

Submission status: Accepted

Solution code:
#n,k
n,k = (int(x) for x in input().split())

#wk=[[0] * n for i in range(k)]
#a=[]
wk=[]
cnt=0

while cnt<k:
    d=input()
    a = (int(x) for x in input().split())
    for i in a:
        wk.append(i)
    cnt+=1
#    print(cnt,wk)
wk=set(wk)
ans = n - len(wk)
print(ans)

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
j = 0
ls1 = []
ls2 = []

for i in range(1, K+1):
    d = int(input())
    ls1.append(input().split())
for i in range(len(ls1)):
    for j in ls1[i]:
        ls2.append(j)
        x = set(ls2)
print(N - len(x))

Submission status: Accepted

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

a = []
for _ in range(k):
    _ = int(input())
    a.append([int(j) for j in input().split(" ")])

a_set = set(sum(a, []))
n_set = {j+1 for j in range(n)}
print(len(n_set - a_set))

Submission status: Accepted

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

for i in range(k):
    d = int(input())
    b.append(input().split())
    # print(b)

    for j in range(d):
        b[i][j] = int(b[i][j])
        a[b[i][j] - 1] += 1
for i in range(n):
    if a[i] == 0:
        cnt += 1

print(cnt)

Submission status: Accepted

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

sunuke_set = set(range(1, N + 1))
for k in range(K):
    input()
    removed_sunuke_set = set(map(int, input().split()))
    for sunuke in removed_sunuke_set:
        if sunuke in sunuke_set:
            sunuke_set.remove(sunuke)
print(len(sunuke_set))

Submission status: Accepted

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

Submission status: Accepted

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

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

print(l.count(0))

Submission status: Accepted

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

b = []

for j in range(K):
    b.append(a[2*j +1])
b = list(itertools.chain.from_iterable(b))
b = set(b)
print(N-len(b))

Submission status: Accepted

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

Submission status: Accepted

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

import itertools
d_list=[]
a_list=[]
trick_list=[]
trick=0
sunu_list=[i for i in range(1,n+1)]

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

for sunu in a_list:
  trick_list=list(set(sunu_list)-set(sunu))
  sunu_list=trick_list


print(len(sunu_list))

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

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

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

k = n - sum(buf)
print(k)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
j = 0
ls1 = []
ls2 = []

for i in range(1, K+1):
    d = int(input())
    ls1.append(input().split())
for i in range(len(ls1)):
    for j in ls1[i]:
        ls2.append(j)
        x = set(ls2)
print(N - len(x))

Submission status: Accepted

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

d = {}
for i  in range(N):
    if i+1 not in d:
        d.setdefault(str(i+1) , 0)

while(K):
    tmp = input()
    data = input().split()

    for i in range(int(tmp)):
        if data[i] in d:
            d[data[i]]+=1
    
    K-=1

count = 0 
for k,v in d.items():
    if v == 0 :
        count+=1
print(count)

Submission status: Accepted

Solution code:


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

import itertools

#nk = [3, 2]
#a = [['2'], ['1', '3'], ['1'], ['3']]

#偶数参照
a_2 = a[1::2]

count = 0

aaa = list(itertools.chain.from_iterable(a_2))

for m in range(1, nk[0]+1):

    if not(str(m) in aaa):
        count += 1

print(count)

Submission status: Accepted

Solution code:
def start():
    n, k = input().split()
    n = int(n)
    k = int(k)
    bs = [0 for i in range(n)]
    for j in range(k):
        di = input()
        ds = input().split()
        for d in ds:
            d = int(d)
            bs[d - 1] += 1
    n = bs.count(0)
    print(n)


if __name__ == '__main__':
    start()

Submission status: Accepted

Solution code:
N,K=map(int,input().split())
res={0}
for i in range(K):
    d=int(input())
    if d==1:
        res|={int(input())}
    else:
        res|=set(map(int,input().split()))
res=[x for x in res if x!=0]
print(N-len(res))

Submission status: Accepted

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

ans = [1]*n

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

print(sum(ans))

Submission status: Accepted

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


print(n - len(set(list(itertools.chain.from_iterable(ans))))
      )

Submission status: Accepted

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

Submission status: Accepted

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

#N人がお菓子を持っているか持っていないかのリスト表
for i in range(N):
    N_LIST.append(0)

#仮におかしdiでその人が指名されたときもしリストでの値が0
#なら1にして１なら１のまま

for i in range(K):
    di = int(input())
    who_has_di_list = input().split()

    #who_has_di_listでdiを持っている人が分かる
    for i in range(len(who_has_di_list)):
        num = int(who_has_di_list[i])
        if N_LIST[num-1] == 0:
            N_LIST[num-1] = 1

#N_LISTにはお菓子を持ってる人は1、そうでない人は0となっている
ans = 0

for i in range(len(N_LIST)):
    ans += N_LIST[i]

Ans = len(N_LIST) - ans

print(Ans)

Submission status: Accepted

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

box=[]
for x in range(K):
    a=int(input())
    n=list(map(int,input().split()))
    box+=n
#print(box)
print(N-len(set(box)))

Submission status: Accepted

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

a = 0
for l in range(1, N+1):
    if l not in mylist:
        a = a + 1

print(a)

Submission status: Accepted

Solution code:
import collections
import itertools

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

sunuke_list = a[1::2]
sunuke_list2 = list(itertools.chain.from_iterable(sunuke_list))

ans = n - len(set(sunuke_list2))

print(ans)

Submission status: Accepted

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

count=0

c = [0] * (N+1)

for i in range(K):
    d = int(input())
    a = [int(d) for d in input().split()]
    for j in a:
        c[j] += 1

for i in c:
    if (i == 0):
        count+=1

print(count-1)

Submission status: Accepted

Solution code:
import itertools
n,k=map(int,input().split())
li=[input().split() for i in range(2*k)]
new=li[1::2]
count=0
a=list(itertools.chain.from_iterable(new))
print(n-len(set(a)))

Submission status: Accepted

Solution code:
import numpy as np
n,k=map(int, input().split())
l = []
for i in range (k):
    d = int(input())
    l.extend(list( map(int,input().split()) ))

print(n-np.unique(l).size)

Submission status: Accepted

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

sa = [0 for i in range(n)]
for i in range(k):
    input()
    for a in map(int, input().split(" ")):
        sa[a - 1] += 1
c = 0
for i in range(n):
    if sa[i] == 0:
        c += 1
print(c)

Submission status: Accepted

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


n = [0]*N

for k in range(K):
    d = int(input())
    a = [int(i_s) for i_s in input().split(" ")]
    for i in a:
        n[i-1] = 1

print(n.count(0))

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
i = 0
c = []
while i < k:
    d = int(input())
    b = list(map(int, input().split()))
    for j in b:
        if j not in c:
            c.append(j)
    i += 1
print(n - len(c))

Submission status: Accepted

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

okasi_nasi = set()
for i in range(int(K)*2):
    buf = input()
    if i % 2 == 1:
        if buf[0] != "":
            okasi_nasi = okasi_nasi | set(buf.split(" "))

print(int(N) - len(okasi_nasi))

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 i in range(d):
        A.append(a[i])

ans = len(list(set(A)))
print(N-ans)

Submission status: Accepted

Solution code:
import itertools

n, k = map(int, input().split())
a = []
sunuke = list(range(1, n + 1))

# 標準入力わからん
for i in range(k):
    d = int(input())
    a.append(map(int, input().split()))

a2 = list(itertools.chain.from_iterable(a))
result = set(sunuke) - set(a2)
print(len(result))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
from functools import reduce
#数値ひとつ
#I = int(input())
#数値空白区切りで欲しいとき
N, K = map(int, input().split())
#文字欲しいとき
#N = input()
#それをListにしたいとき
#list = list(N)
#数値を受け取る数が未定かつリストにしたいとき
#list = list(map(int, input().split()))
#受け取る文字列が未定かつリストにしたいとき(Iは回数)
#list = [input() for i in range(I)]
lista = []
for i in range(K):
    S = input()
    l = list(map(int, input().split()))
    lista.append(l)

lista = reduce(lambda a, b: a + b, lista)
lista = list(set(lista))
print(N - len(lista))

Submission status: Accepted

Solution code:
N, K = map(int,input().split())
LIST = []
for i in range(K): 
    d_i = int(input())
    # nest_list = [int(input()) for j in range(d_i)]
    nest_list = list(map(int,input().split())) 
    LIST.append(nest_list)

all_set = set(list(range(1, N+1)))
difference_set = all_set

for nest_list in LIST:
    nest_set = set(nest_list)
    difference_set = difference_set - nest_set 

print(len(difference_set))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
nk=input().split()
total=set(range(1,int(nk[0])+1))
mina=set()
for r in range(int(nk[1])):
    D=int(input())
    A=list(map(int,input().split()))
    mina=mina|set(A)
anser=total-mina
print(len(anser))

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
n=set(range(1,N+1))
d=[0]*K
A=[0]*K
Aset=set()

for i in range(K):
    d[i]=int(input())
    A[i]=list(map(int, input().split()))
    Aset.update(set(A[i]))
nA_dif=n-Aset
print(len(nA_dif))

Submission status: Accepted

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

havesnack = [0 for x in range(n + 1)]

for i in range(k):
    d = int(input())
    dlist = list(map(int, input().split()))
    for dl in dlist:
        havesnack[dl] = 1

count = 0

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

print(count)

Submission status: Accepted

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

flag = [False] * N
for _ in range(K):
    d = int(input())
    A = [int(i) - 1 for i in input().split()]
    for a in A:
        flag[a] = True

print(flag.count(False))

Submission status: Accepted

Solution code:
import sys
import collections
import itertools
#def input(): return sys.stdin.readline().strip()
#def INT(): return int(input())
#def MAP(): return map(int, input().split())
#def LIST(): return list(map(int, input().split()))

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

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

c = list(itertools.chain.from_iterable(A))
ans1 = collections.Counter(c)

print(n-len(ans1))

Submission status: Accepted

Solution code:
n,k= list(map(int, input().split()))
z=[0]*n
ans=0
for j in range(k):
    q=int(input())
    i = list(map(int, input().split())) 
    for h in range(len(i)):
        z[i[h]-1]+=1
for u in range(n):
    if z[u]==0:
        ans+=1
print(ans)

Submission status: Accepted

Solution code:
n,k=map(int, input().split())
ad=[list(map(int,input().split()))  for _ in range(k*2)]
d=[]
a=[]
ans=0
kashi=[1 for _ in range(n)]

for i in range(0,len(ad),2):
    d.append(ad[i])
for j in range(1,len(ad),2):
    a.append(ad[j])

for i in range(len(a)):
    for j in range(len(a[i])):
        kashi[a[i][j]-1]=0

ans=sum(kashi)
print(ans)

Submission status: Accepted

Solution code:
import numpy
N,K = map(int,input().split())
a= [input().split() for l in range(2*K)]
b=a[1::2]

k=[0]*N
for i in range(K) :
    for j in range(N):
        if (b[i].count(str(j+1))) > 0 :
            k[j]+=1

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

print(count)

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
lst1=list(map(lambda x: x+1,range(n)))
lst2=[]
for i in range(k):
    d = int(input())
    r = list(map(int,input().split()))
    lst2 = lst2 + r
lst2 = list(set(lst2))
for i in lst2:
    lst1.remove(i)
print(len(lst1))

Submission status: Accepted

Solution code:
population, kind = map(int,input().split())
lists = [0] * population
i = 0

while i <= kind -1:
  i += 1
  zaiko = int(input())
  j = 0
  posess = list(map(int,input().split()))
  while j <=  zaiko -1:
    lists[posess[j] - 1] = 1
    j += 1

k = 0
count = 0
while k <= population-1:
  if lists[k] == 0:
    count += 1
  k += 1

print(count)

Submission status: Accepted

Solution code:
#文字列の長さ len(測る文字)
#文字列の検索（何番目） List.index(検索する文字)


#A, B = [int(input()) for i in range(2)]
#A, B = [input() for i in range(2)]
N,K =map(int, input().split())
#N = int(input())
#S = input()

sum=0

#List = ['A','B','C','D','E']
#List=list(range(1))
List_A_all = list(range(3*K+1))
List_A_all =[]


#行列入力
for i in range(K):

    List_d = int(input())

    List_A = input().split()
    List_A_int= [int(s) for s in List_A]
    List_A_all.extend(List_A_int)

#print(List_A_all)

for t in range(N):
    if not t+1 in List_A_all:
        sum+=1


#print(List_d)
print(sum)


#1行のリスト作成
#for i in range(1):
#    X,Y,Z= map(int, input().split())
#    List=[X,Y,Z]

#List.sort()
#print(List[1])

#for i in range(3):
 #   sum += List[i][0]*List[i][1]*0.1

#print(int(sum))

#print(List.index(S)+1)

#salary = 0

#sum=0

#print(N)
#while sum!=N:

#    print(1)
#    sum+=1



#i=0からスタートなのに注意
#for i in range(N+1):
#    salary+= i*10000/N
#
#salary = int(salary)
#print(str(Y)+' '+str(X))

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())))
answer=N-len(set(itertools.chain.from_iterable(A)))
print(answer)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a = input().split()

n = int(a[0])
k = int(a[1])

ar = [0]*(2*k)
ss = [0]*n

for i in range(0,k*2):
  ar[i] = input().split()
  
for i in range(0,len(ar)):
  if(i%2==0):
    del ar[i][:]

for i in range(0,len(ar)):
  if(len(ar[i]) == 0):
    continue
  else:
    if(len(ar[i]) == 1):
      x = int(ar[i][0]) - 1
      ss[x] += 1 
    else:
      for j in range(0,len(ar[i])):
        x = int(ar[i][j]) - 1
        ss[x] += 1 

print(ss.count(0))

Submission status: Accepted

Solution code:
import collections
N , K= map(int, input().split())
c = 0
A =[]
for ia in range(K):
    d = int(input())
    A.extend(list(map(int, input().split())))

sa = collections.Counter(A)
sss = len(sa)
print(N-sss)

Submission status: Accepted

Solution code:
n,k=(int(x) for x in input().split())
hito = []
d = []
A = []
for i in range(1,n+1):
  hito.append(i)
for j in range(1,k+1):
  d = int(input())
  newa = input().split()
  for m in range(0,d):
    A = int(newa[m])
    if A in hito:
      hito.remove(A)
print(len(hito))

Submission status: Accepted

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

for i in range(K*2):
  A=list(map(int, input().split()))
  if i%2!=0:
    arr = arr+A
print(len(list(set(arr1) - set(arr))))