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

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

ans = [0] * m

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

print(ans.count(n))

Submission status: Wrong Answer

Solution code:
n,m = map(int ,input().split())
l=[list(map(int ,input().split())) for x in range(n)]
cnt=0
ans=0
if n==1:
    print(l[0][0])
    exit()
    
for i in range(n):
    del(l[i][0])

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
k = [list(map(int, input().split())) for _ in range(n)]
lst = []
lst2 = []
cnt = 0

for i in range(n):
    for j in range(k[i][0]):
        lst.append(k[i][j])

for i in range(n):
    lst2.append(k[i][0])

for i in range(sum(lst2)):
    if lst.count(i) == n:
        cnt += 1

print(cnt)

Submission status: Wrong Answer

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

lst = list(range(1, m+1))

for _ in range(n):
  a = list(map(int, input().split()))[1:]
  for i in lst:
    if i not in a:
      lst.pop(lst.index(i))
print(len(lst))

Submission status: Wrong Answer

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(m):
  for j in range(n):
    if i not in k[j][1:]:
      break
    elif j == n-1:
      ans += 1
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

s1 = set()
for i in range(m):
  s1.add(i+1)  
s2 = set()

for i in range(n):
  b = list(map(int, input().split()))
  for j in range(b[0]):
    if b[j+1] in s1:
      s2.add(b[j])
  s1 = s2
  s2 = set()

print(len(s1))

Submission status: Wrong Answer

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(a[i][0]):
        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: Wrong Answer

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
        
a = [i for i in dd if i == n]
print(len(a))

Submission status: Wrong Answer

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 == M]))

Submission status: Wrong Answer

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
    print(res)
    for i in range(n):
        res &= set(likes[i][1:])
        print(res)
    
    print(len(res))

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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, *likes = [line.rstrip() for line in sys.stdin.readlines()]
    n, m = [int(x) for x in nm.split()]
    menu = set(str(i) for i in 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: Wrong Answer

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].pop(K[i][0])

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

Submission status: Wrong Answer

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

K = [list(map(int, input().split())) for row in range(N)]

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

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

Submission status: Wrong Answer

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
    print(l)
print(l)
l = list(map(lambda x: x//n, l))
print(sum(l))

Submission status: Wrong Answer

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(m):
    if flat.count(i) == n:
        point += 1
print(point)

Submission status: Wrong Answer

Solution code:
from sys import stdin, exit
from math import factorial
input = stdin.readline
lmi = lambda: list(map(int, input().split()))
mi = lambda: map(int, input().split())
si = lambda: input().strip('\n')
ssi = lambda: input().strip('\n').split()

n, m = mi()
foods = [0 for i in range(m+1)]
for i in range(n):
    arr = lmi()
    for j in arr[1:]:
        foods[j] += 1
cnt= 0
print(foods)
for i in range(1, m+1):
    if foods[i] == n:
        cnt += 1
print(cnt)

Submission status: Wrong Answer

Solution code:
from sys import stdin, exit
from math import factorial
input = stdin.readline
lmi = lambda: list(map(int, input().split()))
mi = lambda: map(int, input().split())
si = lambda: input().strip('\n')
ssi = lambda: input().strip('\n').split()

n, m = mi()
foods = [0 for i in range(m+1)]
for i in range(n):
    arr = lmi()
    for j in arr:
        foods[j] += 1
cnt= 0
for i in range(1, m+1):
    if foods[i] == n:
        cnt += 1
print(cnt)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# ABC118B - Foods Loved by Everyone
from collections import defaultdict


def main():
    N, M = map(int, input().split())
    cnt = defaultdict(int)
    for _ in range(N):
        _, *A = map(int, input().split())
        for a in A:
            cnt[a] += 1
    ans = sum(i == N for i in cnt.values())


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
# ABC118B - Foods Loved by Everyone
from collections import defaultdict


def main():
    N, M = map(int, input().split())
    cnt = defaultdict(int)
    for _ in range(N):
        _, *A = map(int, input().split())
        for a in A:
            cnt[a] += 1
    ans = sum(i == M for i in cnt.values())
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def main():
    N,M =  map(int, input().split())
    dish_list = []
    for i in range(N):
        K =  [int(s) for s in input().split()]
        K.pop(0)
        if i == 0:
            dish_list = K
            continue
        for dish in dish_list:
            new_dish_list = []
            if dish in K:
                new_dish_list.append(dish)
        dish_list = new_dish_list
    print(len(dish_list))


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
def main():
    N,M =  map(int, input().split())
    dish_list = []
    for i in range(N):
        K =  [int(s) for s in input().split()]
        if i == 0:
            dish_list = K
            continue
        for dish in dish_list:
            new_dish_list = []
            if dish in K:
                new_dish_list.append(dish)
        dish_list = new_dish_list
    print(len(dish_list))


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
k_list = []
a_list = []
for _ in range(n):
    k, *a = map(int, input().split())
    k_list.append(k)
    a_list.append(a)
    
ans = [0]*m
for i in range(m):
    for j in range(len(k_list)):
        if i in a_list[j]:
            ans[i-1] += 1
if max(ans) == n:
    print(ans.count(n))
else:
    print(0)

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
a=[]
ans=0
for i in range(n):
    ii=0
    for j in map(int,input().split()):
        if ii > 0:
        	a.append(j)
        ii+=1
#print(a)
 
for k in range(m):
    if a.count(k) == n:
        ans+=1
print(ans)

Submission status: Wrong Answer

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

for k in range(m):
    if a.count(k) == m:
        ans+=1
print(ans)

Submission status: Wrong Answer

Solution code:
N,M = [int(i) for i in input().split()]
_,*K1 = [int(i) for i in input().split()]
N=N-1
for i in range(N):
    _,*K=[int(i) for i in input().split()]
    for j in K1:
        if j not in K:K1.remove(j)
print(len(K1))

Submission status: Wrong Answer

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

A = []
for i in range(N):
    for j in range(1,K[i][0] + 1):
        temp = K[i][j]
        A.append(temp)
ans = 0
for i in range(1,31):
    if A.count(i) == N:
        ans +=1
    elif N == 1:
        ans = K[0][0]
print(ans)

Submission status: Wrong Answer

Solution code:

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

A = []
for i in range(N):
    for j in range(1,K[i][0] + 1):
        temp = K[i][j]
        A.append(temp)
ans = 0
for i in range(1,N+1):
    if A.count(i) == N:
        ans +=1
    elif N == 1:
        ans = K[0][0]
print(ans)

Submission status: Wrong Answer

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

A = []
for i in range(N):
    for j in range(1,K[i][0] + 1):
        temp = K[i][j]
        A.append(temp)
ans = 0
for i in range(1,30):
    if A.count(i) == N:
        ans +=1
    elif N == 1:
        ans = K[0][0]
print(ans)

Submission status: Wrong Answer

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

A = []
for i in range(N):
    for j in range(1,K[i][0] + 1):
        temp = K[i][j]
        A.append(temp)

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

Submission status: Wrong Answer

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

A = []
for i in range(N):
    for j in range(1,K[i][0] + 1):
        temp = K[i][j]
        A.append(temp)
        #print(A)
ans = 0
i
for i in range(1, N + 1):
    #print(A.count(i))
    if A.count(i) == N:
        ans +=1
    if N == 1:
        ans = K[0][0]
print(ans)

Submission status: Wrong Answer

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

A = []
for i in range(N):
    for j in range(1,K[i][0] + 1):
        temp = K[i][j]
        A.append(temp)
        #print(A)
ans = 0
for i in range(1, N + 1):
    #print(A.count(i))
    if A.count(i) == N:
        ans +=1
print(ans)

Submission status: Wrong Answer

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

list_like = []
menu = {}

for i in range(m):
  menu[i+1] = 0

for i in range(n):
  list_like = list(map(int, input().split()))
  k = list_like[0]
  like = list_like[1:k]
  for j in range(k):
      menu[list_like[j]] += 1
      
sum = 0
for i in range(m):
  if menu[i+1] == n:
    sum += 1

print(sum)

Submission status: Wrong Answer

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

if n == 1:
    print(ka[0][0])
    exit()

counter = [0] * m
for x in ka:
    for a in x[1:]:
        counter[a - 1] += 1
ans = 0
for i in range(m):
    if i == n:
        ans += 1
print(ans)

Submission status: Wrong Answer

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

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


print(sum([1 for k in pref if k == n]))

Submission status: Wrong Answer

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

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

ans = 0
for p in pref:
    if p == n:
        ans += 1

print(ans)

Submission status: Wrong Answer

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

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

ans = 0
for p in pref:
    if p == n:
        ans += 1

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N,M=map(int,input().split())
List=[]
for i in range(N):
  List.append(list(map(int,input().split())))
List_K=[]
List_A=[]
for j in range(N):
  List_K.append(List[j][0])
  List_A.append(List[j][1:])
count=0
for k in range(M):
  count1=0
  for l in range(N):
    if k in List_A[l]:
      count1+=1
  if count1==N:
    count+=1
print(count)

Submission status: Wrong Answer

Solution code:
n ,m = list(map(int,input().split()))
A = []
for i in range(n):
    k,*a = list(map(int,input().split()))
    A.append(a)
count = 0     
for j in range(n):
    result = set(A[0]) & set(A[j])
print(len(result))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
lis = []
for i in range(n):
  lis += input().split()[1:]
print(lis)
  
import collections as cl
dic = cl.Counter(lis)
counter = 0
for num in dic.values():
  if num == n:
    counter += 1
print(counter)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

food =[0]*(m+1)

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

print(food.count(n))

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
a = list(map(int, input().split()))[1:]
for i in range(n - 1):
  foods = list(map(int, input().split()))[1:]
  for food in a:
    if not food in foods:
      a.remove(food)
print(len(a))

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
el = list(range(M))
for _ in range(N):
    A = [int(x) for x in input().split()[1:]]
    for i, f in enumerate(el):
        if f not in A:
            el[i] = -1
print(len([x for x in el if x >= 1]))

Submission status: Wrong Answer

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())
    Ans=S&set(A)
print(len(Ans))

Submission status: Wrong Answer

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

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

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

print(len(ans))

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
L = [list(map(int, input().split())) for _ in range(N)]
ALL = sum(list(map(lambda x: x[1:], L)), [])
print(list(map(lambda x: ALL.count(x), ALL)).count(N))

Submission status: Wrong Answer

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

counter=collections.defaultdict(int)
for _ in range(N):
  text = list(input().split())
  for x in text[1:]:
    counter[x]+=1
ans=0
for _ in counter:
  if counter[x]== N:
    ans+=1
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

for i in kx[0]:
  for j in range(1,n):
    if i in kx[j]:
      c1 += 1
  if c1 == n-1:
    c2 += 1
  c1 = 0

print(c2)

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
like = []
for i in range(n):
    *k, = map(int,input().split())
    k = k[1:]
    if i==0:
        for j in k:
            like.append(j)
    else:
        for j in like:
            if j not in k:
                like.remove(j)
print(len(like))

Submission status: Wrong Answer

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())
print(len(S))

Submission status: Wrong Answer

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

ans=inputs[0][1:]

for inp in inputs[1:]:
  for tmp in ans:
    if tmp not in inp[1:]:
      ans.remove(tmp)
print(len(ans))

Submission status: Wrong Answer

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

ans=inputs[0][1:]
for inp in inputs[0:]:
  for i in ans:
    if i not in inp[1:]:
      ans.remove(i)
      
print(len(ans))

Submission status: Wrong Answer

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

ans=inputs[0][1:]
for inp in inputs[1:]:
  for i in ans:
    if i not in inp[1:]:
      ans.remove(i)
      
print(len(ans))

Submission status: Wrong Answer

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

print(len(s))

#I refered the answer...

Submission status: Wrong Answer

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

food=[]

for i in range(n):
    food.append(list(map(int,input().split())))

for i in food:
    del i[0]
#print(food)

if n==1:
    print(len(food[0]))

else:

    ans=0
    for i in range(1,m):
        cnt=0
        for sfood in food:
            if i in sfood:
                cnt+=1

        if cnt==n:
            ans+=1
    print(ans)

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
count=0
s=[[0 for i in range(n)] for i in range(m)]
print(s)
for j in range(n):
  L=list(map(int,input().split()))

  for i in range(1,L[0]+1):
    s[L[i]-1][j]=1
print(s)
for i in range(m):
  if s[i]==[1]*n:
    count+=1

print(count)

Submission status: Wrong Answer

Solution code:
import collections

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

arr=[]
for _ in range(n):
  k,*a=list(map(int,input().split()))
  arr.extend(a)
  
c = collections.Counter(a)

cnt=0
for c_ in c.most_common():
  if n == c_[1]:
    cnt+=1
print(cnt)

Submission status: Wrong Answer

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

ans = 0
i_list = []

for i in range(N):
	tmp_list = list(map(int,input().split()))
	i_list.extend(tmp_list[1:])
	print(i_list)

for i in range(1,M+1):
  if i_list.count(i) == N:
    ans += 1

print(ans)

Submission status: Wrong Answer

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

ans = 0
i_list = []

for i in range(N):
	tmp_list = list(map(int,input().split()))
	i_list.extend(tmp_list[1:])

for i in range(M):
  if i_list.count(i) == N:
    ans += 1

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N,M=map(int,input().split())
Set=set(range(1,M+1))
for i in range(N):
  Set=Set and set(map(int,input().split()))
print(len(Set))

Submission status: Wrong Answer

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

a = set(str(x) for x in range(1,M+1))
for i in range(N):
  li = list(input().split())
  a = a & set(li[1:])

print (' '.join(a))

Submission status: Wrong Answer

Solution code:
"""
# 標準入力取得
## 文字列
 = sys.stdin.readline().rstrip()
 = list(sys.stdin.readline().rstrip())

## 数値
 = int(sys.stdin.readline())
 = map(int, sys.stdin.readline().split())
 = list(map(int, sys.stdin.readline().split()))
 = [list(map(int,list(sys.stdin.readline().split()))) for i in range(h)]  # 二次元配列入力　二次元マップみたいな入力のとき

# 0埋め, 小数点出力桁指定時のときの出力
a = 100
b = 0.987654321
print("{0:06d}-{1:6f}".format(a,b))
000100-0.987654

# 文字列をリストに格納
char_list = list("abcd") # ["a","b","c","d"]
"""

import math
import sys
import itertools
import queue
from fractions import gcd

def lcm(a, b):
    return a * b // gcd(a, b)

mod = 1000000007

if __name__ == "__main__":
    n,m = map(int, sys.stdin.readline().split())
    l= [list(map(int,list(sys.stdin.readline().split()))) for i in range(n)]
    c=0
    if n ==1:
        print(l[0][0])
    else:
        for i in range(1,5):
            flag = 0
            for j in range(n):
                if i not in l[j][1:]:
                    flag = 1
            if flag == 0:
                c+=1
        print(c)

Submission status: Wrong Answer

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

cnt = 0
for i in range(1, m+1):
    flag = True
    for j in range(len(a)):
        if not i in a[j]:
            flag = False
    if flag:
        cnt += 1

print(cnt - 1)

Submission status: Wrong Answer

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

dic = {}
for i in range(n):
    for j in range(1, k[i][0]+1):
        if k[i][j] in dic:
            dic[k[i][j]] += 1
        else:
            dic[k[i][j]] = 1

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

Submission status: Wrong Answer

Solution code:
n,m = map(int, input().split())
count = 0
for i in range(n):
  k, *aaa = list(map(int, input().split()))
  if i == 0:
    mmm = aaa
  for j in mmm:
    if not j in aaa:
      mmm.remove(j)
print(len(mmm))

Submission status: Wrong Answer

Solution code:
n,m = map(int, input().split())
count = 0
mmm = [i for i in range(1,m+1)]
for i in range(n):
  k, *aaa = list(map(int, input().split()))
  for j in mmm:
    if not j in aaa:
      mmm.remove(j)
print(len(mmm))

Submission status: Wrong Answer

Solution code:
N,M = map(int,input().split())
List = []
for i in range(N):
  L = list(map(int,input().split()))
  L.pop(0)
  List.append(L)
ans = 0
for i in range(M):
  judge = 0
  for j in range(N):
    if (i in List):
      judge += 1
    if (judge != j):
      break
  if(judge==N):
    ans += 1
print(ans)

Submission status: Wrong Answer

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

print(sum)

Submission status: Wrong Answer

Solution code:


def main():
    A,B = map(int,input().split())
    
    originalList = set(list(map(int,input().split()))[1:])
    print(originalList)
    for i in range(A-1):
        list1=set(list(map(int,input().split()))[1:])
        print(list1)
        print(type(list1))
        originalList = originalList & list1
        print(originalList)
        print(type(originalList))

    print(len(originalList))










if __name__== "__main__":
    main()

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
A0 = list(map(int, input().split()))
A0.pop(0)
for i in range(N-1):
    A = list(map(int, input().split()))
    for j in A0:        
        if j not in A[1:]:
            A0.remove(j)

print(len(A0))

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
A0 = list(map(int, input().split()))
A0.pop(0)
for i in range(N-1):
    A = list(map(int, input().split()))
    for j in A0:
        
        if j not in A[1:]:
            A0.remove(j)
            print(A0)

print(len(A0))

Submission status: Wrong Answer

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

for i in range(N-1):
    A = list(map(int, input().split()))
    for j in A0[1:]:
        if j not in A[1:]:
            A0.remove(j)

print(len(A0[1:]))

Submission status: Wrong Answer

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

for i in range(N-1):
    A = list(map(int, input().split()))
    for j in A0[1:]:
        if j not in A[1:]:
            A0.remove(j)
            print(A0)

print(len(A0[1:]))

Submission status: Wrong Answer

Solution code:
import collections as co
n,m=map(int,input().split())
l=[]
for i in range(n):
    j,*k=map(int,input().split())
    l.extend(k)
for p,q in co.Counter(l).items():
    if q==n:print(p)

Submission status: Wrong Answer

Solution code:
import sys
import math
from collections import deque

sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def solve(N, M, inputs):
    likes = [string_to_int(i) for i in inputs]
    everyone_likes = {n for n in range(0, M)}

    for l in likes:
        for i, f in enumerate(l):
            if i == 0:
                continue
            if f in everyone_likes:
                everyone_likes.remove(f)
    return len(everyone_likes)

    return likes


def string_to_int(string):
    return list(map(lambda x: int(x), string.split()))


if __name__ == "__main__":
    [N, M] = string_to_int(input())
    ret = solve(N, M, inputs(N))
    print(ret)

Submission status: Wrong Answer

Solution code:
import sys
import math
from collections import deque

sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def solve(N, M, inputs):
    likes = [string_to_int(i) for i in inputs]
    everyone_likes = {n for n in range(0, M)}

    for l in likes:
        for f in l:
            if f in everyone_likes:
                everyone_likes.remove(f)
    return len(everyone_likes)

    return likes


def string_to_int(string):
    return list(map(lambda x: int(x), string.split()))


if __name__ == "__main__":
    [N, M] = string_to_int(input())
    ret = solve(N, M, inputs(N))
    print(ret)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

mcount = [0]*m
for mi in range(m):
  for ai in a:
    if mi in ai:
      mcount[mi] += 1
print(mcount.count(n))

Submission status: Wrong Answer

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

lst = []
for i in range(N):
    lst.append(input().split())
    del(lst[i][0])

res = lst[0]
for i in range(len(lst)):
    for j in res:
        if (j in lst[i]) == False:
             del(res[res.index(j)])
print(len(res))