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:
#!/usr/bin/env python3

def main():
    n, m = map(int, input().split())
    k, *a = map(int, input().split())
    ans = set(a)
    for i in range(n - 1):
        k, *a = map(int, input().split())
        ans = ans & set(a)
    print(len(ans))


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
n,m = map(int,input().split())
data = [0]*n
for i in range(n):
    data[i] = input().split()
ans = 0
if n == 1:
    print(len(data[0]) - 1)
else:
    for i in range(1,int(data[0][0]) + 1):
        bool = True
        for j in range(1,n):
            if data[0][i] not in data[j][1:]:
                bool = False
        if bool:
            ans += 1
    print(ans)

Submission status: Accepted

Solution code:
import math
import collections
from sys import exit
from itertools import product

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

n,m = mi()
ka = [li() for _ in range(n)]

food = [0]*m
for i in range(n):
    for j in range(1,ka[i][0]+1,1):
        food[ka[i][j]-1] += 1
print(food.count(n))

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
l=[0]*m
for i in range(n):
    s=list(map(int,input().split()))
    for j in range(1,len(s)):
        l[s[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 i in range(n)]
count=0
for i in range(1,m+1):
  check=True
  for j in range(n):
    if i not in a[j][1:]:
      check=False
  if check:
    count+=1
print(count)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n, m = [int(i) for i in input().split()]
list_a = [[s for s in input().split()] for i in range(0, n)]
list_ans = [str(s) for s in range(1, m + 1)]
for i in range(0, n):
    for j in range(0, m):
        if list_ans[j] not in list_a[i][1:]:
            list_ans[j] = '0'
print(len([s for s in list_ans if s != '0']))

Submission status: Accepted

Solution code:
N,M = map(int,input().split())
d = {i:0 for i in range(1,M+1)}

for _ in range(N):
  L = list(map(int,input().split()))[1:]
  for i in L:
    d[i] += 1
    
cnt = sum([1 for k,v in d.items() if v == N])
print(cnt)

Submission status: Accepted

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

Submission status: Accepted

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

N = a[0]
M = a[1]

ctr = [0 for i in range(M)]


for i in range(N):
    b =  list(map(int,input().split()))

    for j in range(b[0]):
        for k in range(M):
            if b[j+1] == k+1:
                ctr[k] += 1

flag = [N == ctr[j] for j in range(M)]
print(sum(flag))

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 = [int(x) for x in input().split()]
Like = [0 for _ in range(M+1)]
for i in range(N):
  KA = [int(x) for x in input().split()]
  for j in range(1, KA[0]+1):
    Like[KA[j]] += 1
ans = 0
for i in range(M+1):
  if(Like[i]==N):
    ans += 1
print(ans)

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
l = []
for i in range(N):
  l.append(list(map(int, input().split())))
  
ans = [0] * (M+1)
for i in range(N):
  n = l[i]
  for j in range(1, n[0]+1):
    ans[n[j]] += 1
    
cnt = 0
for i in range(M+1):
  if ans[i] == N:
    cnt += 1
print(cnt)

Submission status: Accepted

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

ans = [0]*(M+1)
for i in range(N):
	for j in range(l[i][0]):
		ans[(l[i][j+1])] += 1

print(ans.count(N))

Submission status: Accepted

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

K, *result = map(int, input().split())
result = set(result)
for _ in range(N-1):
    K, *A = map(int, input().split())
    A = set(A)
    result = result & A
    
print(len(result))

Submission status: Accepted

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

ab = [list(map(int, input().split())) for _ in range(n)]

dp = [0]*m

for i in range(n):
    for j in range(ab[i][0]):
        k = ab[i][j+1]
        dp[k-1] +=1
        
print(dp.count(n))

Submission status: Accepted

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

for i in range(n):
    tmp = input().split()
    tmp.pop(0)
    k += tmp

for i in range(m):
    if k.count(str(i+1)) == n:
        cnt += 1

print(cnt)

Submission status: Accepted

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

Submission status: Accepted

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

for i in range(n):
    a = list(map(int, input().split()))
    for j in range(1, a[0]+1):
        c[a[j]-1] += 1
print(c.count(n))

Submission status: Accepted

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

Submission status: Accepted

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

s = set(list(map(int, input().split()))[1:])
for _ in range(n-1):
    s &= set(list(map(int, input().split()))[1:])

print(len(s))

Submission status: Accepted

Solution code:
from collections import Counter


def mapt(fn, *args):
    return tuple(map(fn, *args))


def Input():
    return mapt(int, input().split(" "))


def main():
    n, m = Input()
    data = [Input()[1:] for _ in range(n)]
    d = Counter(num for row in data for num in row)
    print(sum(value == n for value in d.values()))


main()

Submission status: Accepted

Solution code:
import itertools

N, M = map(int, input().split())
L = []
res, cnt = 0, 1

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

L = list(itertools.chain.from_iterable(L))
L.sort()
L.append(100)

for i in range(len(L)-1):
    if L[i] == L[i+1]:
        cnt += 1
    else:
        if cnt == N:
            res += 1
        cnt = 1
    

print(res)

Submission status: Accepted

Solution code:
#-*-coding:utf-8-*-
import sys
input=sys.stdin.readline

def main():
    interview=[]
    n,m = map(int,input().split())
    interview=[list(map(int,input().split())) for _ in range(n)]
    set_data={}

    for data in interview:
        if len(set_data)==0:
            set_data  = set(data[1:])
        else:
            set_data=set_data & set(data[1:])
    print(len(set_data))


if __name__=="__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

flg = [0] * (m+1)
for i in range(n):
  for j in range(1,ka[i][0]+1):
    food = ka[i][j]
    flg[food] += 1

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

Submission status: Accepted

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

ans = {}
for a in k_a:
    for i in a[1:]:
        if i in ans.keys():
            ans[i] += 1
        else:
            ans[i] = 1
print(sum([ 1 for i,v in ans.items() if v == n ]))

Submission status: Accepted

Solution code:
import sys
import copy
import math
import itertools
import numpy as np
l = [int(c) for c in input().split()]
N = l[0]
M = l[1]
KA = [list(map(int,input().split())) for c in range(N)]

F = [0]*M

for i in range(N):
    for j in range(1,KA[i][0]+1):
        F[KA[i][j]-1]+=1
print(F.count(N))

Submission status: Accepted

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

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

cnt=0

for k in l:
  if l.count(k)==n:
    cnt+=1

print(cnt//n)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

n, m = map(int, input().split())
fav = set(range(1, m+1))
for _ in range(n):
    a = set(list(map(int, input().split()))[1:])
    fav = fav.intersection(a)

print(len(fav))

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
A = []
for _ in range(N):
    KA = list(map(int, input().split()))
    A.append(KA[1:])
ans = [0]*M
for a in A:
    for i in a:
        ans[i-1] += 1
print(ans.count(N))

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
Ans = list(map(int, input().split()))
Ans = Ans[1:]
Ans = set(Ans)

for _ in range(N-1):
    A = list(map(int, input().split()))
    A = set(A[1:])
    Ans = Ans & A
print(len(Ans))

Submission status: Accepted

Solution code:
def resolve():
    N, M = list(map(int, input().split(" ")))
    loved = [0 for _ in range(M)]
    for i in range(N):
        _, *a = list(map(int, input().split(" ")))
        for food in a:
            loved[food-1] += 1
    print(len(list(filter(lambda x: x == N, loved))))
    

if '__main__' == __name__:
    resolve()

Submission status: Accepted

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

n, m = map(int, readline().split())
ka = []
ans = set(str(i+1) for i in range(m))

for _ in range(n):
    ka = input().split()
    ans = ans & set(ka[1:])
    
print(len(ans))

Submission status: Accepted

Solution code:
N,M=map(int,input().split())
b=[]
s=[0]*M
for i in range(N):
    a=list(map(int,input().split()))
    del a[0]
    a.sort()
    b.append(a)
for i in range(N):
    for j in range(len(b[i])):
        s[b[i][j]-1]+=1
print(s.count(N))

Submission status: Accepted

Solution code:
from collections import defaultdict
N, M = map(int, input().split())
dict = defaultdict(int)
for _ in range(N):
    line = list(map(int, input().split()))
    K = line[0]
    A = line[1:]
    for a in A:
        dict[a] += 1
ans = 0
for k, v in dict.items():
    if v == N:
        ans += 1
print(ans)

Submission status: Accepted

Solution code:
N,M=map(int,input().split())
ka=[[int(x) for x in input().split()] for _ in range(N)]
K=list()
A=list()
for i in range(N):
  K.append(ka[i][0])
  A.append(ka[i][1:])
ans=[0]*(M+1)
for i in range(N):
  for j in range(K[i]):
    ans[A[i][j]]+=1
cnt=0
for i in range(M+1):
  if ans[i]==N:
    cnt+=1
print(cnt)

Submission status: Accepted

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

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:
def main():
    n, m = map(int, input().split())
    food_list = [0] * m

    for _ in range(n):
        a_list = list(map(int, input().split()))
        for i in range(1, a_list[0] + 1):
            food_list[a_list[i] - 1] += 1

    cnt = 0
    for food in food_list:
        if food == n:
            cnt += 1
    print(cnt)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N , M = map(int,input().split())
con = 0
like = 0
List = []
for i in range(1,N+1):
  L = list(map(int,input().split()))
  for a in range(L[0]):
    b = L[a + 1]
    List.append(b)
for j in range(1,M + 1):
  con = 0
  for k in List:
    if k == j:
      con += 1
  if con == N:
    like += 1   
print(like)

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())
like = [0] * m

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

print(sum(i==n for i in like))

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
s = set(range(1, 1+m))
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())
data=[0]*m
for i in range(n):
  a=list(map(int,input().split()))
  for j in range(1,a[0]+1):
    data[a[j]-1]+=1
print(data.count(n))

Submission status: Accepted

Solution code:
N,M = map(int,input().split())
foods = [0]*M
 
for i in range(N):
  KA = list(map(int,input().split()))
  
  for a in KA[1:]:
    foods[a-1] += 1
  
cnt = 0
for j in foods:
  if j == N:
    cnt += 1
    
print(cnt)

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())
response_list = []
for _ in range(n):
    response = list(map(int, input().split()))
    response.pop(0)
    response_list.append(response)

cnt_list = [0]*m
for list in response_list:
    for i in list:
        cnt_list[i-1] += 1

ans = 0
for j in cnt_list:
    if j == n:
        ans += 1

print(ans)

Submission status: Accepted

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

for _ in range(n):
    al = list(map(int, input().split()))
    arr = al[1:]
    for a in arr:
        like[a-1] += 1

print(like.count(n))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

s = 0
for i in range(1,m+1):
    s |= 1 << i


for i in range(n):
    a = map(int, input().split())
    a = list(a)
    t = 0
    for j in range(1, len(a)):
        t |= 1 << a[j]
    s &= t


ans = 0
for i in range(1,m+1):
    if (s & (1<<i)) != 0:
        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):
  l = list(map(int, input().split()))
  l.remove(l[0])
  s = set(l)
  S = S & s
print(len(S))

Submission status: Accepted

Solution code:
from collections import Counter

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

lis=[]
cnt=0
for i in range(n):
  l=list(map(int,input().split()))
  lis+=l[1:]
  
d=Counter(lis)
for i in d.values():
  if i==n:
    cnt+=1
    
print(cnt)

Submission status: Accepted

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

Submission status: Accepted

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

for i in range(N):
  KA = list(map(int,input().split()))
  
  for a in KA[1:]:
    foods[a-1] += 1
  
cnt = 0
for j in foods:
  if j == N:
    cnt += 1
    
print(cnt)

Submission status: Accepted

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

Submission status: Accepted

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

cnt = [0]*m
for ka in KA:
  for a in ka[1:]:
    cnt[a-1] += 1

ans = 0
for i in cnt:
  if i == n:
    ans += 1
print(ans)

Submission status: Accepted

Solution code:
import numpy as np
n,m = map(int,input().split())
k = np.zeros(n,dtype=int)
a = np.zeros((n,m),dtype=int)
for i in range(n):
    p = list(map(int, input().split()))
    k[i] = p[0]
    for j in range(1,len(p)):
        a[i][j-1] = p[j]
ans = np.zeros(n+m,dtype=int)
for i in range(n):
    for j in range(m):
        if a[i][j] != 0:
            s = a[i][j]-1
            ans[s] += 1
an = 0
for i in range(n+m):
    if ans[i] == n:
        an += 1
print(an)

Submission status: Accepted

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

for i in range(N):
 
  A = list(map(int, input().split()))
  B = set(A[1:])
 
  S = S & B
print(len(S))

Submission status: Accepted

Solution code:
N,M=map(int,input().split())
h={i for i in range(1,M+1)}
for _ in range(N):
  a=list(map(int,input().split()))
  a=set(a[1:])
  h&=a
print(len(h))

Submission status: Accepted

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

for _ in range(N):
    items = list(map(int,input().split()))
    for i in range(1,len(items)):
        like[items[i]-1] += 1

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

print(ans)

Submission status: Accepted

Solution code:
n,m = map(int,input().split())
L = [i for i in range(1,m+1)]
for j in range(n):
    l = list(map(int,input().split()))
    del l[0]
    L = set(l) & set(L)
print(len(L))

Submission status: Accepted

Solution code:
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    N, M = map(int, readline().split())
    cnt = [0] * (M + 1)

    for _ in range(N):
        K, *A = list(map(int, readline().split()))
        for x in A:
            cnt[x] += 1

    print(cnt.count(N))


if __name__ == '__main__':
    main()

Submission status: Accepted

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

menu = [i for i in range(1,m+1)]
cnt = [0]*m
a = []

for i in range(n):
    ka = list(map(int,input().split()))
    ka.pop(0)
    a.append(ka)
    
for i in menu:
    for j in a:
        if i in j:
            cnt[i-1] += 1
            
print(cnt.count(n))

Submission status: Accepted

Solution code:
n,m = map(int, input().split())
c = set(i+1 for i in range(m))
for j in range(n):
  l = list(map(int, input().split()))
  l.remove(l[0])
  c = c&set(l)
print(len(c))

Submission status: Accepted

Solution code:
n,m = map(int,input().split())
like = set(range(1,m+1))
for _ in range(n):
    a = list(map(int,input().split()))
    like = like & set(a[1:])

print(len(like))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N,M = map(int,input().split())
foods = [0]*(M+1)
for i in range(N):
  line = list(map(int,input().split()))
  for j in range(1,line[0]+1):
    foods[line[j]]+=1
print(foods.count(N))

Submission status: Accepted

Solution code:
import sys

input = sys.stdin.readline


def main():
    N, M = map(int, input().split())
    ans = [0]*(M+1)
    for _ in range(N):
        food = list(map(int, input().split()))
        K = food[0]
        for i in range(1, K + 1):
            ans[food[i]] += 1
    print(ans.count(N))


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import collections
a,b=map(int,input().split())
c=[list(map(int,input().split())) for i in range(a)]
result=[]
for i in range(a):
    n=c[i][1:]
    result+=n
ans=collections.Counter(result)
ans1,ans2=zip(*ans.most_common())
ans2=list(ans2)
print(ans2.count(a))

Submission status: Accepted

Solution code:
N,M = map(int,input().split())
ls = [0]*(M+1)
for i in range(N):
    ls1 = list(map(int,input().split()))
    a = ls1.pop(0)
    for j in range(a):
        ls[ls1[j]] += 1
print(ls.count(N))

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
l=[0]*(m+1)
for u in range(n):
    d=list(map(int,input().split()))
    for i in range(1,d[0]+1):
        l[d[i]]+=1
c=0
for i in range(1,m+1):
    if(l[i]==n):
        c=c+1
print(c)

Submission status: Accepted

Solution code:
def resolve():
    '''
    code here
    '''
    N, M = [int(item) for item in input().split()]
    As = [[int(item) for item in input().split()] for _ in range(N)]

    memo = [0 for _ in range(M+1)]

    for k, *items in As:
        for item in items:
            memo[item] += 1
    res = 0
    for item in memo:
        if item == N:
            res += 1

    print(res)


if __name__ == "__main__":
    resolve()

Submission status: Accepted

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

Submission status: Accepted

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

fond = [0]*(M+1)

for i in A:
    for j in i[1:]:
        fond[j] += 1
        
print(fond.count(N))

Submission status: Accepted

Solution code:
N,M = map(int,input().split())
foods = [0] * (M+1)
for i in range(N):
    line = list(map(int,input().split()))
    for j in range(1,line[0]+1):
        foods[line[j]] += 1
print(foods.count(N))

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
import sys

n,m=map(int,input().split())
ans=[0]*(m+1)
output=0

for i in range(n):
    k=list(map(int,input().split()))
    for j in range(1,len(k)):
        ans[k[j]]+=1

for i in ans:
    if i==n:
        output+=1

print(output)

Submission status: Accepted

Solution code:
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, M = map(int, readline().split())
    vec = [0] * M
    for _ in range(N):
        K, *A = map(int, readline().split())
        for a in A:
            vec[a - 1] += 1

    ans = 0
    for i, v in enumerate(vec, 1):
        if v == N:
            ans += 1

    print(ans)
    return


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import numpy as np

n, m = map(int, input().split())
res = np.ones(m, dtype=np.int8)
for _ in range(n):
    a_like = np.zeros_like(res)
    for a in map(lambda x: int(x)-1, input()[2:].split()):
        a_like[a] = 1
    res *= a_like
print(np.count_nonzero(res))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
a=[0 for _ in range(m)]
for x in range(n):
  e=list(map(int,input().split()))
  e.remove(e[0])
  for p in e:
    a[p-1]+=1
    
print(a.count(n))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
import collections
lines = [s.rstrip("\n") for s in sys.stdin.readlines()]
n, m = [int(num) for num in lines.pop(0).split(" ")]
def iter_a_set():
    for line in lines:
        fs = [int(num) for num in line.split(" ")]
        k = fs.pop(0)
        yield set(fs)
foods = set(range(1, m + 1))
for a_set in iter_a_set():
    foods &= a_set
print(len(foods))

Submission status: Accepted

Solution code:
from collections import Counter
n,m = map(int, input().split())
ka = []
for i in range(n):
    ka1 = list(map(int, input().split()))
    ka += ka1[1:]
ka = Counter(ka).most_common()
num = 0
for h in range(len(ka)):
    if ka[h][1] == n:
        num += 1
    else:
        break
print(num)

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
c = []
ans = 0
for i in range(N):
    tmp = list(map(int, input().split()))
    c.extend(tmp[1:])
cnt = [0 for i in range(M)]
for i in range(len(c)):
    tmp2 = c[i]-1
    cnt[tmp2] += 1

for i in range(M):
    if cnt[i] == N:
        ans += 1

print(ans)

Submission status: Accepted

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

ans_dict = {}

for i in range(N):
    for j in range(1, favorites[i][0] + 1):
        food = favorites[i][j]
        if food in ans_dict:
            ans_dict[food] += 1
        else:
            ans_dict[food] = 1

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

print(count)

Submission status: Accepted

Solution code:
#import numpy as np

n,m=map(int,input().split())
a=[]
k=[]
for _ in range(n):
    b=list(map(int,input().split()))
    k.append(b[0])
    a.append(b[1:])
#print(k)
#print(a[1][0])

#c=np.zeros(m)
c=[0]*m
for i in range(n):
    for j in range(k[i]):
        d=a[i][j]
#        print(d)
        c[d-1]+=1

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

Submission status: Accepted

Solution code:
N,M=map(int,input().split())
KA=[]
A=[]
a=0
for i in range(N):
    KA.append(list(map(int,input().split())))
for i in range(N):
    KA[i].remove(KA[i][0])
for i in range(N):
    for j in range(len(KA[i])):
        A.append(KA[i][j])
for i in range(1,M+1):
    if N==A.count(i):
        a+=1
print(a)

Submission status: Accepted

Solution code:
import numpy as np

n,m=map(int,input().split())
a=[]
k=[]
for _ in range(n):
    b=list(map(int,input().split()))
    k.append(b[0])
    a.append(b[1:])
#print(k)
#print(a[1][0])

c=np.zeros(m)
for i in range(n):
    for j in range(k[i]):
        d=a[i][j]
#        print(d)
        c[d-1]+=1

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

Submission status: Accepted

Solution code:
import numpy as np
N,M = map(int,input().split())
A = [[int(i) for i in input().split()] for _ in range(N)]

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

Submission status: Accepted

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

Submission status: Accepted

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

like = [True] * (m+1)

for i in range(n):
    ka = list(map(int, input().split()))
    for j in range(1, m+1):
        if j not in ka[1:]:
            like[j] = False

print(like[1:].count(True))

Submission status: Accepted

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

for s in range(m):
    if n==a[s]:
        ans+=1
print(ans)

Submission status: Accepted

Solution code:
n,m=map(int, input().split())
alist=[0]*(m+1)
for i in range(n):
  blist=list(map(int, input().split()))
  for j in range(blist[0]):
    alist[blist[j+1]]+=1
cnt=0
for i in range(m+1):
  if alist[i]==n:
    cnt+=1
print(cnt)

Submission status: Accepted

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

cnt = [0]*m

for i in range(n):
    survey = list(map(int, input().split()))
    k = survey[0]
    for j in range(1,k+1):
        favorite = survey[j]
        cnt[favorite - 1] += 1

print(cnt.count(n))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N,M=map(int,(input().split()))
k=list(map(int,input().split()))[1:]
for i in range(N-1):
  A=list(map(int,input().split()))[1:]
  l=[]
  for j in k:
    if j in A:
      l.append(j)
  k=l
print(len(k))

Submission status: Accepted

Solution code:
n,m = map(int, input().split())
l = [i for i in range(1,m+1)]
l2 = []
for _ in range(n):
    k = list(map(int, input().split()))
    del k[0]
    for i in range(len(l)):
        if l[i] not in k:
            l2.append(l[i])
l2 = list(set(l2))
print(len(l)-len(l2))

Submission status: Accepted

Solution code:
n,m = map(int,input().split())
ans = ['Yes'] * m
for i in range(n):
    k = list(map(int,input().split()))
    k.pop(0)
    for i in range(m):
        if not i + 1 in k:
            ans[i] = 'No'
print(ans.count('Yes'))

Submission status: Accepted

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