Problem:


Score : 200 points

Problem Statement

Katsusando loves omelette rice.

Besides, he loves crème brûlée, tenderloin steak and so on, and believes that these foods are all loved by everyone.

To prove that hypothesis, he conducted a survey on M kinds of foods and asked N people whether they like these foods or not.

The i-th person answered that he/she only likes the A_{i1}-th, A_{i2}-th, ..., A_{iK_i}-th food.

Find the number of the foods liked by all the N people.

Constraints

All values in input are integers.

1 \leq N, M \leq 30

1 \leq K_i \leq M

1 \leq A_{ij} \leq M

For each i (1 \leq i \leq N), A_{i1}, A_{i2}, ..., A_{iK_i} are distinct.

Constraints

Input is given from Standard Input in the following format:

N M
K_1 A_{11} A_{12} ... A_{1K_1}
K_2 A_{21} A_{22} ... A_{2K_2}
:
K_N A_{N1} A_{N2} ... A_{NK_N}

Output

Print the number of the foods liked by all the N people.

Sample Input 1

3 4
2 1 3
3 1 2 3
2 3 2

Sample Output 1

1

As only the third food is liked by all the three people, 1 should be printed.

Sample Input 2

5 5
4 2 3 4 5
4 1 3 4 5
4 1 2 4 5
4 1 2 3 5
4 1 2 3 4

Sample Output 2

0

Katsusando's hypothesis turned out to be wrong.

Sample Input 3

1 30
3 5 10 30

Sample Output 3

3



Sample input:
3 4
2 1 3
3 1 2 3
2 3 2


Sample output:
1

Submission status: Accepted

Solution code:
def solve():
    N, M = map(int, input().split())
    K = [0 for _ in range(N)]
    A = [[] for _ in range(N)]
    for i in range(N):
        K[i], *A[i] = map(int, input().split())
    
    ans = M
    for i in range(1, M+1):
        for j in range(N):
            if i not in A[j]:
                ans -= 1
                break
    print(ans)


if __name__ == '__main__':
    solve()

Submission status: Accepted

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

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


ans = 0
for x in range(1,m+1):

    if n == l.count(x):
        ans += 1

print(ans)

Submission status: Accepted

Solution code:
import collections

n, m = [int(i) for i in input().split()]
ka = []
counter = 0

for i in range(n):
    l = list(int(i) for i in input().split())
    for j in l[1:]:
        ka.append(j)
        
c = collections.Counter(ka).most_common()

for i in c:
    if i[1] == n:
        counter += 1
print(counter)

Submission status: Accepted

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

S = set(range(1, m + 1))

for i in range(n):
    K, *A = map(int , input().split())
    S = S & set(A)
    
print(len(S))

Submission status: Accepted

Solution code:
n, m = map(int, (input().split()))
s = set(range(1, m + 1))

for i in range(n):
    a = [int(i) for i in input().split()]
    s = s & set(a[1: a[0] + 1])

print(len(s))

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
li = []
for i in range(n):
    array = list(map(int, input().split()))
    array = array[1:]
    li.append(array)

shugou = set(li[0])
for i in range(n):
    shugou = shugou & set(li[i])

print(len(shugou))

Submission status: Accepted

Solution code:
import math


n, m = map(int, input().split())
l = [[int(i) for i in input().split()[1:]] for i in range(n)]
ans = set(l[0])
for i in l:
    ans = ans & set(i)
print(len(ans))

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
k=[]
a=[]
for i in range(n):
  b=list(map(int,input().split()))
  k.append(b[0])
  a.append(b[1:])
d={}
for i in range(n):
  for j in range(k[i]):
    if a[i][j] not in d:
      d[a[i][j]]=1
    else:
      d[a[i][j]]+=1
nd=list(d.values())
cnt=0
for i in range(len(nd)):
  if nd[i]==n:
    cnt+=1
print(cnt)

Submission status: Accepted

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

suki = []
for i in range(N):
  K[i].pop(0)
  K[i] = sorted(K[i])
  for j in range(1,M+1):
    if all(K[i].count(c) == 1 for c in [j]):
      continue
    else:
      suki.append(j)
print(M-len(set(suki)))

Submission status: Accepted

Solution code:
N,M = map(int,input().split())
An = []
for i in range(N):
  A = list(map(int,input().split()))
  An.extend(A[1:])
Ans = 0
for i in range(M):
  if An.count(i+1)==N:
    Ans += 1
print(Ans)

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
a = [list(map(int, input().split())) for i in range(n)]
ans = set(a[0][1:])
for i in range(1, n):
    ans = ans & set(a[i][1:])
print(len(ans))

Submission status: Accepted

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

for i in range(n):
    k, *args = map(int, input().split())
    for j in args:
        table[j] += 1

cnt = 0
for t in table:
    if t == n:
        cnt += 1

print(cnt)

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
ka = []
for i in range(n):
    ka.append(list(map(int, input().split())))

ans = set(range(1, m+1))
for i in ka:
    ans &= set(i[1:])
print(len(ans))

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(n)]
ans = [0]*m
num = 0

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

for k in range(m):
  num += ans[k]//n
  
print(num)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
List = [list(map(int, input().split())) for i in range(n)]

l = set(List[0][1:])
for i in range(n):
    l = l & set(List[i][1:])
print(len(l))

Submission status: Accepted

Solution code:
N,M = map(int,input().split())
nes = []
count = 0
for i in range(N) :
    li = list(map(int,input().split()))
    nes.append(li)
favorite = [0] * M
for i in range(N) :
    for j in range(1,nes[i][0]+1) :
        favorite[nes[i][j]-1] += 1
for i in range(M) :
    if favorite[i] == N :
        count+=1
print(count)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import sys
import itertools#これは色々使える組み込み関数みたいなやつ
import math#数学的計算はこれでいける。普通に0.5乗しても計算可能
#w=input()
N, M=input().split()
N=int(N)
M=int(M)
i=0
katu_list=[]
katu_sublist=[]
#センテンスを暗記するのではなく、まずinput()を書いて、膨らます感じで記述する。すると#思考の流れ通りに書ける。素晴らしい！
for i in range(M):
 katu_list.append(i+1)
#print(katu_list)
#for i in range(N)
food_list =  [list(map(int, input().split(" ")))for i in range(N)]
#x=[]
#y=[]
#t, x, y = [0]*(N+1), [0]*(N+1), [0]*(N+1)#N+1個の空のリストを作成(原点を入れて##るから一つ増える)
#delta_t=0
#delta_x=0
#delta_y=0
#l=0
#t[0],x[0],y[0]=[0, 0, 0]
#とりあえず入力までは完成した．
#for i in range(N):
# t[i+1], x[i+1], y[i+1] = map(int, input().split())
#child_i =  list(map(int, input().split()))
#w_len=len(w)
#w_list=list(w)
#print(len(w_list))
#print(w_list)
#child_il=sorted(child_i)
#print(child_il)#リストの右端のほうが大きい
i=0
j=0
k=0
l=0
for i in range(N):#N人の人に聞くところ
 #print(katu_sublist)
 #katu_list=katu_sublist   
 #M=len(katu_list)   
 for j in range(food_list[i][0]):
  for k in range(M):
   if food_list[i][j+1]==katu_list[k]:
     katu_sublist.append(katu_list[k])
     #print(katu_sublist)
   else:
       pass
#リストの中身を一旦空っぽにして再度作り上げる
 katu_list=[]
 for l in range(len(katu_sublist)):
   katu_list.append(katu_sublist[l])
 M=len(katu_list)
 katu_sublist=[]#空にしないと貯まるばかり
print(len(katu_list))

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
List = [list(map(int, input().split())) for i in range(n)]

ans = 0
count = 1
for j in range(1, len(List[0])):
    for i in range(1, n):
        if List[0][j] in List[i][1:]:
            count += 1
            if count == n:
                ans += 1
    count = 1
if n == 1:
    print(List[0][0])
else:
    print(ans)

Submission status: Accepted

Solution code:
def p_b():
    n, m = map(int, input().split())
    ans = set(range(1, m + 1))
    for _ in range(n):
        ans &= set(list(map(int, input().split()))[1:])
    print(len(ans))
    
p_b()

Submission status: Accepted

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

ret=set(range(1,m+1))

for i in range(n):
	tmp=list(map(int, input().split()))
	tmp = set(tmp[1:])
	ret = ret&tmp


print(len(ret))

Submission status: Accepted

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

l=[0]*m
for i in range(n):
    ka=list(map(int,input().split()))
    A=ka[1:]
    for a in A:
        l[a-1]+=1
ans=0
for i in l:
    if i==n:
        ans+=1
print(ans)

Submission status: Accepted

Solution code:
n,m = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(n)]
b = set(a[0][1:])
for i in range(1,n):
    b = b&set(a[i][1:])
print(len(b))

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
l=[list(map(int,input().split())) for _ in range(n)]
a=[x[1:] for x in l]
ans=[0]*m

for r in a:
  for c in r:
    ans[c-1]+=1
    
print(sum([x==n for x in ans]))

Submission status: Accepted

Solution code:
n,m = map(int,input().split())
k = [list(map(int,input().split())) for i in range(n)]
ans = 0
for i in range(1,m+1):
  for j in range(n):
    if i not in k[j][1:]:
      break
    elif j == n-1:
      ans += 1
print(ans)

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
food=set(range(1,m+1))
for i in range(n):
    k,*a=map(int,input().split())
    food &= set(a)
print(len(food))

Submission status: Accepted

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

import numpy as np

N, M = [int(x) for x in readline().rstrip().split()]
A = []
B = [0] * M
for _ in range(N):
    temp = [int(x) for x in readline().rstrip().split()]
    A.append(temp[1:])
for i in A:
    for j in i:
        B[j-1] += 1
B = np.array(B)
cnt = np.count_nonzero(B == N)
print(cnt)

Submission status: Accepted

Solution code:
N, M=list(map(int, input().split()))
K=[0*N]
Set=set(range(1, M+1))
for i in range(N):
    K, *A=map(int, input().split())
    Set=Set & set(A)
print(len(Set))

Submission status: Accepted

Solution code:
import collections
n,m = map(int,input().split())
h = []
for i in range(n):
  h[len(h):len(h)] = list(map(int,input().split()))[1:]
ans = 0
count = collections.Counter(h)
for v in count.values():
  if v == n:
    ans += 1
print(ans)

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
l=[list(map(int,input().split())) for i in range(n)]

#print(l)
dic={}
for i in range(1,m+1):
  dic[i]=0
ans=0
for i in range(n):
  k=l[i][0]
  templ=l[i][1:k+1]
  for a in templ:
    dic[a]=dic[a]+1
for v in dic.values():
  if v==n:
    ans+=1
print(ans)

Submission status: Accepted

Solution code:
N,M=map(int,input().split())
S=set(range(1,M+1))
for _ in range(N):
    K,*A=map(int,input().split())
    S&=set(A)
print(len(S))

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
lst = []
for i in range(n):
  tmplst = [int(i) for i in input().split()]
  tmp = 0
  for item in tmplst[1:]:
    tmp |= 1 << item
  lst.append(tmp)
ret = lst[0]
for item in lst[1:]:
  ret &= item
if ret:
  s = sum(map(int, bin(ret)[2:]))
  print(s)
else:
  print(0)

Submission status: Accepted

Solution code:
n,m = map(int, input().split())
s = set(range(1,m+1))
for i in range(n):
  k,*a= map(int,input().split())
  s &= set(a)
print(len(s))

Submission status: Accepted

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

all_set = set()
for i in range(N):
    A = list(map(int, input().split()))
    A.pop(0)
    if i == 0:
        all_set = set(A)
    else:
        all_set = all_set & set(A)

print(len(all_set))

Submission status: Accepted

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

a = []
for i in range(n):
    k = [int(j) for j in input().split()]
    a.append(k[1:])

ans = 0
for i in range(1,m+1):
    check = 0
    for j in a:
        if i not in j:
            check =1
            break
    if check == 0:
        ans += 1
print(ans)

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
l=[0]*(m+1)
for i in range(n):
    a=list(map(int,input().split()))
    for j in range(1,a[0]+1):
        l[a[j]]+=1
if max(l)==n:
    print(l.count(max(l)))
else:
    print(0)

Submission status: Accepted

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

ans = set(K[0][1:])
for li in K:
    ans = ans & set(li[1:])
print(len(list(ans)))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
cand=set(range(1,m+1)) #set型で候補の番号一覧
for _ in [0]*n:
    _,*A=map(int,input().split()) #最初のデータを飛ばして配列Aの中に数字を格納
    cand &= set(A) # 集合の共通部分をとる操作は&で行う.
print(len(cand))

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
ans = set([int(i) for i in input().split()][1:])
for i in range(1, N):
    next_ans = set([int(i) for i in input().split()][1:])
    ans = ans & next_ans
print(len(ans))

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
L=[list(map(int,input().split())) for _ in range(n)]
food=L[0][1:]
good=[]
for i in range(1,n):
    for j in range(len(food)):
        if food[j] in L[i][1:]:
            good.append(food[j]) 
    food = good
    good=[]
print(len(food))

Submission status: Accepted

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

t = [0] * M
for _ in range(N):
    K, *A = map(int, input().split())
    for a in A:
        t[a - 1] += 1
print(t.count(N))

Submission status: Accepted

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

ls_k = [0] * n
ls_a = [0] * n
st_ans = {_ for _ in range(1, m+1)} 

for i in range(n):
    ls_k[i] = ls_ka[i][0]
    ls_a[i] = ls_ka[i][1:]
    st_ans &= set(ls_a[i])

print(len(st_ans))

Submission status: Accepted

Solution code:
N,M = map(int,input().split())
array2 = [0 for i in range(M+1)]
for i in range(N):
  array = list(map(int,input().split()))
  array.pop(0)
  for j in array:
    array2[j] += 1
c = 0
for k in array2:
  if k == N:
    c += 1
print(c)

Submission status: Accepted

Solution code:
N,M=map(int, input().split())
k,*a=map(int, input().split())
s=set(a)

for i in range(N-1):
    k,*a=map(int, input().split())
    s=s&set(a)
    
print(len(s))

Submission status: Accepted

Solution code:
import itertools

N, M = map(int, input().split())
t = []
ans = 0
for i in range(N):
    t.append(list(map(int, input().split()))[1::])

t = list(itertools.chain.from_iterable(t))
for i in set(t):
    if t.count(i) == N:
        ans += 1
print(ans)

Submission status: Accepted

Solution code:
A,B = map(int,input().split())
count = 0
for _ in range(A):
  N = list(map(int, input().split()))
  N.pop(0)
  if count == 0:
    K1 = set(N)
    count += 1
  else:
    K2 = set(N)
    K1 = K1 & K2
print(len(K1))

Submission status: Accepted

Solution code:
NM = list(map(int,input().split()))
N=NM[0]
M=NM[1]
KA = [list(map(int,input().split())) for l in range(N)]
for i in range(N):
      KA[i].pop(0)

jandjplu1=set(KA[0])
for j in range(1,N):
    jandjplu1=jandjplu1 & set(KA[j-1]) & set(KA[j])

print(len(jandjplu1))

Submission status: Accepted

Solution code:
from functools import reduce

N,M = map(int,input().split())
list_aaa = [ list(map(int,input().split()))  for i in range(N)]

list_ccc =[]

for i in range(N):
    list_bbb =[]
    for j in range(1,list_aaa[i][0]+1):
        list_bbb.append(list_aaa[i][j])
    list_ccc.append(set(list_bbb))

print(len(reduce(lambda a,b: a.intersection(b),list_ccc)))

Submission status: Accepted

Solution code:
N,M=map(int,input().split())
c= [ 0 for _ in range(M)]
for i in range(N):
  A = list(map(int, input().split()))
  for j in range(A[0]):
    c[A[j+1]-1]+=1
ans=0
for i in range(M):
  if c[i] == N:
    ans += 1
print(ans)

Submission status: Accepted

Solution code:
import os, sys, re, math

N,M = list(map(int,input().split(' ')))

dic = {}

for _ in range(N):
    tmp = list(map(int,input().split(' ')))
    for i in range(1,len(tmp)):
        if tmp[i] in dic:
            dic[tmp[i]] += 1
        else:
            dic[tmp[i]] = 1

ret = 0
for v in dic.values():
    if v == N:
        ret += 1
print(ret)

Submission status: Accepted

Solution code:
#テストファイルで実行する時
import sys
if sys.platform =='ios':
    sys.stdin=open('input_file.txt')

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

#指定した場所のリストを削除
for i in range(n):
	del a[i][0]

#2次元のリストaを1次元のリストbに変換
b = sum(a,[])

c = list(set(b))
#print(c)

ans = 0
check = 0

for i in range(len(c)):
	check = b.count(c[i])
	if check == n:
		ans = ans + 1

print(ans)

Submission status: Accepted

Solution code:
import os, sys, re, math

(N, M) = [int(n) for n in input().split()]
favorites = [n + 1 for n in range(M)]
for i in range(N):
    d = [int(n) for n in input().split()]
    favorites = list(filter(lambda x: x in d[1:], favorites))

print (len(favorites))

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
As = []
ans = [0] * 31
for n in range(N):
    ka = list(map(int, input().split()))
    #a = ka[1:]
    for a in ka[1:]:
        ans[a] += 1

print(ans.count(N))

Submission status: Accepted

Solution code:
n, m = list(map(int, input().split()))
d = set(i for i in range(1, m + 1))
for ks in [list(map(int, input().split())) for _ in range(n)]:
    d &= set(ks[1:])
print(len(d))

Submission status: Accepted

Solution code:
from collections import defaultdict

nPeople, nKinds = map(int, input().split())
d = defaultdict(int)
for _ in range(nPeople):
    for kind in list(map(int, input().split()))[1:]:
        d[kind] += 1
print(sum([d[kind] == nPeople for kind in d.keys()]))

Submission status: Accepted

Solution code:
n, m = list(map(int, input().split(' ')))
d = {}
for i in range(n):
  l = list(map(int, input().split(' ')))
  for j in l[1:]:
    d[j] = d.get(j, 0) + 1
ans = 0
for key in d:
  if d[key] == n:
    ans += 1
print(ans)

Submission status: Accepted

Solution code:
N,M = map(int,input().split())
ans = set([str(m) for m in range(1,M+1)])
for n in range(N):
    A = input().split()
    A.pop(0)
    ans = ans & set(A)
print(len(ans))

Submission status: Accepted

Solution code:
from collections import Counter
from itertools import chain

N, M = map(int, input().split())
AK = [list(map(int,input().split())) for i in range(N)]
A = [ak[1:] for ak in AK]
A = list(chain.from_iterable(A))

print(list(Counter(A).values()).count(N))

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
k=[list(map(int,input().split())) for _ in range(n)]
for i in range(n):
    k[i].pop(0)
res = 0
for i in range(1,m+1):
    flag = 1
    for j in range(n):
        if not i in k[j]:
            flag = 0
            break
    res += flag

print(res)

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
k = []
a = []
for i in range(n) :
    data = list(map(int,input().split()))
    k += [data[0]]
    a += [data[1:]]
countdict = {i+1 : 0 for i in range(m)}
for i in range(n) :
    for j in range(1, m+1) :
        countdict[j] += a[i].count(j)
count = 0
for i in range(1, m + 1) :
    if countdict[i] == n :
        count += 1
print(count)

Submission status: Accepted

Solution code:
import sys
input=sys.stdin.readline
n,m=map(int,input().split())
dic={}
a=[list(map(int,input().split())) for i in range(n)]
for i in range(n):
    for j in range(1,a[i][0]+1):
        if a[i][j] in dic:
            dic[a[i][j]]+=1
        else:
            dic[a[i][j]]=1

cnt=0
for i in dic.values():
    if i==n:
        cnt+=1
print(cnt)

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
a=[]
for i in range(n):
    b=list(map(int,input().split()))
    a+=b[1:]
ans=0
for i in range(1,1+m):
    if n==a.count(i):
        ans+=1
print(ans)

Submission status: Accepted

Solution code:
from collections import defaultdict

n, m = map(int, input().split())
dd = defaultdict(int)

for i in range(n):
    tmp = list(map(int, input().split()))
    tmp.pop(0)
    for j in tmp:
        dd[j]+=1

#print(dd)

a = [k for k in dd.values() if k == n]
#print(a)
print(len(a))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import Counter
ctr = Counter()
N, M = map(int,input().split())
for _ in range(N):
  ctr.update(list(map(int,input().split()))[1:])
print(len([None for v in ctr.values() if v == N]))

Submission status: Accepted

Solution code:
# ABC 118: B – Foods Loved by Everyone
n, m = [int(s) for s in input().split()]

k = []
a = []

for _ in range(n):
    tmp = [int(s) for s in input().split()]
    k.append(tmp[0])
    a.append(tmp[1:])

foods = [0] * m

for i in range(n):
    for j in range(m):
        if j + 1 in a[i]:
            foods[j] += 1

print(foods.count(n))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(N)]
a = []
if N > 1:
  for i in range(N):
    a.append(A[i][1:])

  ans = 0
  for x in range(len(a[0])):
    for y in range(N - 1):
      if a[0][x] in a[y + 1]:
        if y + 1 == N - 1:
          ans += 1
      else:
        break
  print(ans)
else:
  print(A[0][0])

Submission status: Accepted

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

    array = []
    for i in range(n):
        if i == 0:
            array = set(list(map(int,input().split()))[1:])
        else:
            A = list(map(int,input().split()))
            k = A[0]
            A = set(A[1:])
            array = array & A
    print(len(array))


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N,M = map(int,input().split())
L = [0]*N
for i in range(N):
    L[i] = list(map(int,input().split()))
for i in range(N):
    del L[i][0]
L.sort() #第一要素でソート

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

Submission status: Accepted

Solution code:
n,m=map(int,input().split(" "))
s=[input().split() for i in range(n)]
d=[]
for j in s:
    j=j[1:]
    for k in j:
        d.append(k)
f=[]
for h in d:
    if d.count(h)==n:
        f.append(h)
print(len(set(f)))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
s=set(range(1,m+1))
for i in range(n):
    k,*a=list(map(int,input().split()))
    s&=set(a)
print(len(s))

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
s=set(range(1,m+1))
for i in range(n):
    k,*a=list(map(int,input().split()))
    s&=set(a)
print(len(s))

Submission status: Accepted

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

Submission status: Accepted

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

aL = []
for _ in range(n):
    kal = list(map(int,input().split()))
    al = kal[1:]
    aL.append(al)


tmp = aL[0]
for al in aL:
    tmp = set(al) & set(tmp)
    
print(len(tmp))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# 2019-11-12 15:53:47(JST)
import sys
# import collections
# import math
# from string import ascii_lowercase, ascii_uppercase, digits
# from bisect import bisect_left as bi_l, bisect_right as bi_r
# import itertools
# from functools import reduce
# import operator as op
# from scipy.misc import comb # float
# import numpy as np 

def main():
    nm, *lines = sys.stdin.readlines()
    n, m = [int(x) for x in nm.split()]
    likes = [[int(x) for x in line.split()] for line in lines]
    menu = set(range(1, m+1))
    res = menu
    for i in range(n):
        res &= set(likes[i][1:])
    
    print(len(res))

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
n,m=map(int, input().split())
a=[[int(i) for i in input().split()] for n in range(n)]
al=[]
for i in a:
    i=i[1:]
    al.append(i)
cnt=0
for i in range(m):
    if all(i+1 in j for j in al):
        cnt+=1
print(cnt)

Submission status: Accepted

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

for i in range(n):
  k,*a=map(int,input().split())
  tmp+=list(a)
ans=sum(tmp.count(i)==n for i in range(1,m+1))
print(ans)

Submission status: Accepted

Solution code:
# Hariom_Pandey
# 11.11.2019
N,M =map(int,input().split())
se = set(range(M+1))
for _ in range(N):
  A = [int(x) for x in input().split()]
  se &= set(A[1:])
print(len(se))

Submission status: Accepted

Solution code:
N,M = map(int,input().split())
dic = {}
for i in range(N):
    a = list(map(int,input().split()))
    a = a[1:]
    for j in a:
        if(j in dic):
            dic[j] += 1
        else:
            dic[j] = 1
ans = 0
for key,value in dic.items():
    if(value == N):
        ans += 1
print(ans)

Submission status: Accepted

Solution code:
n, m = [int(i) for i in input().split()]
ka = [[int(i) for i in input().split()] for _ in range(n)]
like = set(range(1, m + 1))
for ai in ka:
  like &= set(ai[1:])
print(len(like))

Submission status: Accepted

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

K = [list(map(int, input().split())) for row in range(N)]
if N == 1:
	print(K[0][0])
else:
	for i in range(N):
		K[i].remove(K[i][0])

	foods = set(K[0])
	i = 0
	while i < N:
		foods = foods.intersection(set(K[i]))
		if foods == {}:
			
			break
			exit()
		i += 1
	print(len(list(foods)))

Submission status: Accepted

Solution code:
import numpy as np
N, M = map(int, input().split())
tmp = np.array([1]*M)
for n in range(N):
  K_A = list(map(int,input().split()))
  # K = K_A[0]
  A = K_A[1:]
  tmp_n = np.array([0]*M)
  for a in A:
    tmp_n[a-1] = 1
  tmp = tmp*tmp_n
print(sum(tmp))

Submission status: Accepted

Solution code:
n,m = map(int,input().split())
likes = [0]*(m+1)
for _ in range(n):
    ka = list(map(int,input().split()))
    a = ka[1:]
    for like_idx in a:
        likes[like_idx] += 1

ans = 0
for num in likes:
    if num >=n:
        ans += 1
print(ans)

Submission status: Accepted

Solution code:
N,M=map(int,input().split())
A=[]
for i in range(N):
    a=list(map(int,input().split()))
    A.extend(a[1:])
    
U=0
for i in range(len(A)):
    if A.count(i)==N:
        U+=1
if N>1:
    print(U)
else:
    print(len(A))

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import numpy as np

N, M = map(int, input().split())
A =[]
for i in range(N):
  kk = list(map(int, input().split()))
  A.append(kk[1:])

count = np.zeros(M, dtype=int)
for i in range(N):
  for ind in A[i]:
    count[ind-1] += 1

sum = 0
for j in range(M):
  if(count[j] == N):
    sum += 1

print(sum)

Submission status: Accepted

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

def main():
    n,m=map(int,input().split())
    s = {i for i in range(1,m+1)}
    for _ in range(n):
        k,*aa=map(int,input().split())
        s&=set(aa)
    print(len(s))

main()

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
s = set(map(int, input().split()[1:]))
for i in range(n-1):
  t = set(map(int, input().split()[1:]))
  s &= t
print(len(s))

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
k,*b=map(int,input().split())
b=set(b)
for _ in range(n-1):
    k,*a=map(int,input().split())
    b=b&set(a)
print(len(b))

Submission status: Accepted

Solution code:
n,m = map(int, input().split())
tmp = []
for i in range(n):
    k, *a = map(int, input().split())
    tmp += list(a)
ans = sum(tmp.count(i)==n for i in range(1, m+1))
print(ans)

Submission status: Accepted

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

liked = set(range(1, M+1))
for _ in range(N):
  liked &= set(map(int, input().split()[1:]))
  
print(len(liked))

Submission status: Accepted

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

for val in range(n):
    tmp = list(map(int,input().split()))
    k = tmp[0]
    if val == 0:
        a_L = set(tmp[1:])
    else:
        a_L = set(tmp[1:]) & a_L

print(len(a_L))

Submission status: Accepted

Solution code:
n, m = map(int,input().split())
l = [0 for i in range(m)]
for i in range(n):
  s = list(map(int, input().split()))
  for j in range(1, s[0]+1):
    l[s[j]-1] += 1
l = list(map(lambda x: x//n, l))
print(sum(l))

Submission status: Accepted

Solution code:
N,M =map(int,input().split())
se = set(range(M+1))
for i in range(N):
  A = [int(x) for x in input().split()]
  se &= set(A[1:])
print(len(se))

Submission status: Accepted

Solution code:
n, m =map(int, input().split())
for i in range(n):
	a = list(map(int, input().split()))
	a.pop(0)
	if i == 0:
		b = set(a)
	b = set(a) & b
print (len(b))

Submission status: Accepted

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

k, *a = map(int, input().split())
sa = set(a)

for i in range(N - 1):
    k, *a = map(int, input().split())
    s = set(a)
    sa = s & sa

print(len(sa))

Submission status: Accepted

Solution code:
from sys import stdin

n,m = [int(x) for x in stdin.readline().rstrip().split()]
li = [list(map(int,stdin.readline().rstrip().split())) for _ in range(n)]

lin = []
for i in range(n):
    lin.append(li[i][1:])

flat = [flatten for inner in lin for flatten in inner]

flat.sort()
point = 0
for i in range(1,m+1):
    if flat.count(i) == n:
        point += 1
print(point)

Submission status: Accepted

Solution code:
N,M=map(int,input().split())
x = [list(map(int,input().split())) for _ in range(N)]

for i in range(N):
  x[i].pop(0)

t = set(x[0])
for i in range(1,N):
  t &=set(x[i])
print(len(list(t)))

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
k=[input().split() for i in range(n)]
a=set(k[0][1:])
for i in range(n):
    a=set(k[i][1:])&a
    
print(len(a))

Submission status: Accepted

Solution code:
N,M = map(int,input().split())
A = [list(map(int,input().split())) for i in range(N)]
K = []
for i in range(N):
    K.append(A[i].pop(0))
ans = A[0]
for j in range(1,N):
    ans = set(ans)&set(A[j])
print(len(ans))

Submission status: Accepted

Solution code:
N,M = [int(x) for x in input().split()]
FOODS=set(range(1,M+1))

for i in range(N):
    A=[int(x) for x in input().split()]
    FOODS = FOODS & set(A[1:])
ans=len(FOODS)
print(ans)

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
KA = [[int(i) for i in input().split()] for _ in range(N)]

ret = [0] * (M + 1)
for i in range(N) :
    for j in KA[i][1:] :
        ret[j] += 1
print(ret.count(N))