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:
a, b = map(int, input().split())
c = [0] * b
for i in range(a):
    d = list(map(int, input().split()))
    for j in range(1, d[0]+1):
        c[d[j]-1] += 1
e = 0
print(c)
for i in range(b):
    if c[i] == a:
        e += 1
print(e)

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
erase = []
for i in range(N):
    a = list(map(int, input().split())) #a = [2,1,3] -> a = [3,1,2,3]
    
    if i == 0:
        food = a[1:] #food = [1] -> food = [1,3]

    for j in range(len(food)): 
        if food[j] not in a[1:]:
            erase.append(j)
print(len(food)-len(erase))

Submission status: Wrong Answer

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

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

print(len(ans))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

na3 = []

for i4 in range(n1):
    na3.append([int(j) for j in input().split()])

na5 = [0] * (n2 + 1)

for i6 in range(n1):
    for i7 in range(na3[i6][0] + 1):
        if i7 != 0:
            na5[na3[i6][i7]] += 1

r8 = 0
for i9 in range(n2):
    if na5[i9] == n1:
        r8 += 1

print(r8)

Submission status: Wrong Answer

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

for i in range(N):
    A.append([int(m) for m in input().split()])
    A[i].pop(0)
cnt =0
for i in range(M):
    flag = 1
    for k in range(N):
        if i not in A[k]:
            flag = 0
    if flag == 1:
        cnt += 1
        

print(cnt)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

sum = 0
for i in range(m):
    if food[i] == n:
        sum += 1

print(sum)

Submission status: Wrong Answer

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

sum = 0
for i in range(m):
    if food[i] == n:
        sum += 1

print(sum)

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
ka = []
for i in range(n):
    ka.append(list(map(int, input().split())))
ok = 0
for j in range(1, 30):
    for i in range(n):
        row = ka[i][1:]
        flag = (j in row)
        if not flag:
            break
    if flag:
        ok += 1
print(ok)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import collections

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

lst2 = list()
for i in range(0, len(lst)):
    for j in range(1, len(lst[i])):
        lst2.append(lst[i][j])

c = collections.Counter(lst2)

ans_cnt = 0
for moji, cnt in c.items():
    if cnt == 3:
        ans_cnt+=1

print(ans_cnt)

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
k,*a=input().split()
for i in range(n-1):
    if a==[]:
        break
    k,*b=input().split()
    for j in a:
        if j not in b:
            a.remove(j)
print(len(a))

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
k,*a=input().split()
for i in range(n-1):
    k,*b=input().split()
    for j in a:
        if j not in b:
            a.remove(j)
print(len(a))

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
k,*a=map(int,input().split())
for i in range(n-1):
    k,*b=map(int,input().split())
    for j in a:
        if j not in b:
            a.remove(j)
print(len(a))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import collections

N,M = map(int,input().split())
A = [list(map(int,input().split())) for i in range(N)]
favorite = []
count = 0

for i in range(1,A[0][0]+1):
    favorite.append(i)
for j in range(1,N):
    for k in range(1, A[j][0]+1):
        if A[j][k] in favorite:
            favorite.append(A[j][k])

a = collections.Counter(favorite)
for key,value in a.items():
    if value == N:
        count += 1
print(count)

Submission status: Wrong Answer

Solution code:
n, m= map(int, input().split())
ka = [input() for i in range(n)]
common = {i for i in range(1,m+1)}
for k in ka:
    tmp = k.split()
    tmp = set(tmp[1:])
    common = common.intersection(tmp)

print(len(common))

Submission status: Wrong Answer

Solution code:
n, m= map(int, input().split())
ka = [input() for i in range(n)]
common = {i for i in range(1,m+1)}
for k in ka:
    tmp = [int(i) for i in k.split()]
    tmp = set(tmp)
    common = common.intersection(tmp)

print(len(common))

Submission status: Wrong Answer

Solution code:
n, m= map(int, input().split())
ka = [input() for i in range(n)]
common = {i for i in range(1,m+1)}
for k in ka:
    tmp = {int(i) for i in k[1:].split()}
    common = common.intersection(tmp)

print(len(common))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N,M=map(int,input().split())
L=[]
for i in range(N):
  a=list(map(int,input().split()))
  for b in a:
    L.append(b)
mas=list(range(1, M+1))
print(len(set(mas)-set(L)))

Submission status: Wrong Answer

Solution code:
#!/usr/bin/python
# coding: UTF-8
n,m = map(int,input().split())

res = [0 for _ in range(m)]

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

print(sum([res[i]==m for i in range(m)]))

Submission status: Wrong Answer

Solution code:
#!/usr/bin/python
# coding: UTF-8
n,m = map(int,input().split())

res = [0 for _ in range(m)]

for i in range(n):
  res_tmp = [0 for _ in range(m)]
  for j in list(map(int,input().split()))[1:]:
    res[j-1] += 1
  print(res)

print(sum([res[i]==n for i in range(m)]))

Submission status: Wrong Answer

Solution code:
#!/usr/bin/python
# coding: UTF-8
n,m = map(int,input().split())

res = [1 for _ in range(m)]

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

print(m-sum(res))

Submission status: Wrong Answer

Solution code:
#!/usr/bin/python
# coding: UTF-8
import numpy as np

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

res = np.array([1 for _ in range(m)])
print(res)

res_init = np.array([-1 for _ in range(m)])
print(res_init)

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

print(sum(res))

Submission status: Wrong Answer

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

res = [1 for _ in range(m)]

for i in range(n):
  res_tmp = res
  for j in list(map(int,input().split()))[1:]:
    res_tmp[j-1] = 0
  res = [res[k]*res_tmp[k] for k in range(m)]

print(sum(res))

Submission status: Wrong Answer

Solution code:
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]
v=[]

x=0
for i in range(1,31):
    for j in range(n):
        v.append(a[j].count(i))

for i in range(0,31,n):
    if v[i:i+n].count(1)==n:
        x+=1

  
print(x)

Submission status: Wrong Answer

Solution code:
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]
v=[]

x=0
for i in range(31):
    for j in range(n):
        v.append(a[j].count(i))

for i in range(0,31,n):
    if v[i:i+n].count(1)==n:
        x+=1

  
print(x)

Submission status: Wrong Answer

Solution code:
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]
print(a)
v=[]

x=0
for i in range(31):
    for j in range(n):
        v.append(a[j].count(i))
print(v)
for i in range(0,31,n):
    print(v[i:i+n])
    if v[i:i+n].count(1)==n:
        x+=1

  
print(x)

Submission status: Wrong Answer

Solution code:
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]
v=[]

x=0
for i in range(30):
    for j in range(n):
        v.append(a[j].count(i))

for i in range(0,30,n):
    if v[i:i+n].count(1)==n:
        x+=1

  
print(x)

Submission status: Wrong Answer

Solution code:
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]
v=[]

x=0
for i in range(30):
    for j in range(n):
        v.append(a[j].count(i))

for i in range(0,30,n):
    if v[i:i+3].count(1)==n:
        x+=1

  
print(x)

Submission status: Wrong Answer

Solution code:
import sys
from collections import deque
input = sys.stdin.readline

N, M = map(int, input().split())
A = deque()
ans = [[0]*M for i in range(N)]
choose = [i for i in range(1, M+1)]
for _ in range(N):
    A.append(list(map(int, input().split())))

if N == 1:
    print(len(A[0])-1)
    exit()

for i in range(N):
    for j in range(1, len(A[i])):
        if A[i][j] in choose:
            choose.remove(A[i][j])
print(len(choose))

Submission status: Wrong Answer

Solution code:
#118
import collections
N, M = map(int, input().split())
A = [[] for _ in range(N)]
for i in range(N):
    A[i] = list(map(int, input().split()))
All = []
count = 0
for v in A:
    v.pop(v[0])
    
for v in A:
    for _v in v:
        All.append(_v)
_All= collections.Counter(All)
#All = set(All)
for v in _All:
    if _All[v] == N:
        count += 1
print(count)

Submission status: Wrong Answer

Solution code:
import sys
from collections import deque
input = sys.stdin.readline

N, M = map(int, input().split())
A = deque()
ans = set()
for _ in range(N):
    A.append(list(map(int, input().split())))

for i in range(N):
    for j in range(1,M+1):
        if j in A[i]:
            ans.add(j)
            
print(M - len(ans))

Submission status: Wrong Answer

Solution code:
import collections
N, M = map(int, input().split())
A = [[] for _ in range(N)]
for i in range(N):
    A[i] = list(map(int, input().split()))
All = []
count = 0
for v in A:
    v.pop(v[0])
for v in A:
    for _v in v:
        All.append(_v)
_All= collections.Counter(All)
All = set(All)
for v in All:
    if _All[v] == N:
        count += 1
print(count)

Submission status: Wrong Answer

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

ans = 0

if N == 1:
    print(len(K[0])-1)

else:
    for i in range(N):
        cnt = 0
        for j in range(int(K[i][0])):
            if str(i+1) in K[i][1:]:
                cnt += 1
        if cnt == N:
            ans += 1         
    print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

l = []
for i in range(N):
  K, *A = map(int, input().split())
  for k in range(K):
    l.append(A[k])

print(len(set(l)))

Submission status: Wrong Answer

Solution code:
n,m = map(int, input().split())
k = [list(map(int, input().split())) for i in range(n)]
result = 0
answer = 0
for i in range(1,m + 1):
    for j in range(n):
        K = k[j]
        for v in range(1,K[0] + 1):
            if K[v] == i:
                result += 1
    if result == n:
        answer += 1
print(answer)

Submission status: Wrong Answer

Solution code:
import sys


def input():
    return sys.stdin.readline()[:-1]

# N = int(input())
# A = [int(x) for x in input().split()]
# a, b, c = map(int, input().split())
# name1 = str(input())
# alph = {"A": 1, "B": 2, "C": 3, "D": 4, "E": 5}
# b = list(map(lambda x: math.ceil(x/10)*10, a))


n, m = map(int, input().split())
con = []
for i in range(n):
    k = [int(x) for x in input().split()]
    for j in range(1, k[0]+1):
        con.append(k[j])
ans = 0
print(con)
for i in range(m):
    if con.count(i+1) == n:
        ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
N,M = map(int, input().split())
line_list = []
for i in range(N):
    tmp_list = list(map(int, input().split()))
    tmp_list.pop(0)
    line_list.append(tmp_list)

candidate_list = []
for i in range(N):
    line_param = line_list[i]
    if i == 0:
        candidate_list = line_param
    else:
        for param in candidate_list:
            if param not in line_param:
                candidate_list.remove(param)
#    print("Loop{} List{}".format(i, candidate_list))
print(len(candidate_list))

Submission status: Wrong Answer

Solution code:
import numpy as np
N, M = map(int,input().split())
K = list(list(map(int,input()[1:].split()) for i in range(N)))
like = [[0]*M for i in range(N)]
for _ in range(N):
    for i in K[_]:
        like[_][i-1] = 1
like = np.array(like)
for i in range(N-1):
    like[i+1,:] = np.minimum(like[i,:],like[i+1,:] )
print(np.sum(like[N-1,:]))

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
data = []
for i in range(N):
    data.append(list(map(int, input().split())))
#print(data)
counter2 = 0
for i in range(1, M + 1):
    counter1 = 0
    for ans in data:
        num = ans[0]
        if i in ans[1 : num + 1]:
            counter1 += 1
            print("{} {}".format(i, counter1))
        else:
            counter1 = 0
            break
    if counter1 == N:
        counter2 += 1
print(counter2)

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
data = []
for i in range(N):
    data.append(list(map(int, input().split())))
#print(data)
counter1 = 0
counter2 = 0
for i in range(1, M + 1):
    for ans in data:
        num = ans[0]
        #print(ans[1 : num + 1])
        if i in ans[1 : num + 1]:
            counter1 += 1
        else:
            counter1 = 0
            break
    if counter1 == N:
        #print(i)
        counter2 += 1
print(counter2)

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
data = []
for i in range(N):
    data.append(list(map(int, input().split())))
#print(data)
counter1 = 0
counter2 = 0
for i in range(1, M + 1):
    for ans in data:
        num = ans[0]
        #print(ans[1 : num + 1])
        if i in ans[1 : num + 1]:
            counter1 += 1
        else:
            counter1 = 0
            break
    if counter1 == N:
        print(i)
        counter2 += 1
print(counter2)

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
data = []
for i in range(N):
    data.append(list(map(int, input().split())))
#print(data)
counter1 = 0
counter2 = 0
for i in range(1, M + 1):
    for ans in data:
        num = ans[0]
        if i in ans[1 : num + 1]:
            counter1 += 1
        else:
            counter1 = 0
            break
    if counter1 == N:
        counter2 += 1
print(counter2)

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
A = [[int(a) for a in input().split()] for i in range(n)]
B = []
for i, j in enumerate(A):
    if i == 0:
        B = j[1:]
    else:
        B = list(set(j[1:]) & set(B))
print(B)

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
nakami=[]
for i in range(n):
  ilist= list(map(int,input().split()))
  for j in range(1,ilist[0]+1):
    nakami.append(ilist[j])

import collections
c=collections.Counter(nakami)

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

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
import sys
ans = 0
lst = []
kari = []
for i in range(N):
    if i == 0:
        lst += list(map(int, input().split()))
        lst = lst[1:]
        print (lst)
    else:
        if lst == []:
            print (0)
            sys.exit()
        else:      
            kari = list(map(int, input().split()))
#            print ('kari ', kari)
            sakujo = []
            for j in lst:
                if j in kari[1:]:
                    pass
                else:
                    sakujo += [j]
#                    lst.remove(j) #ループの途中でlstから削除すると場所がずれる
#                    print (j)
            for k in sakujo:
                lst.remove(k)

#        print ('lst ', lst)
        if lst == []:
            print (0)
            sys.exit()

#print (lst)
ans = len(lst)
print (ans)

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
import sys
ans = 0
lst = []
kari = []
for i in range(N):
    if i == 0:
        lst += list(map(int, input().split()))
        lst = lst[1:]
    else:
        if lst == []:
            print (0)
            sys.exit()
        else:      
            kari = list(map(int, input().split()))
            for j in lst:
                if j in kari[1:]:
                    pass
                else:
                    lst.remove(j)

#print (lst)
ans = len(lst)
print (ans)

Submission status: Wrong Answer

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

ans = 0
lst = []
kari = []
for i in range(N):
    if i == 0:
        lst += list(map(int, input().split()))
        lst = lst[1:]
    else:
        if lst == []:
            print (0)
            break
        else:      
            kari = list(map(int, input().split()))
            for j in lst:
                if j in kari[1:]:
                    pass
                else:
                    lst.remove(j)

#print (lst)
ans = len(lst)
print (ans)

Submission status: Wrong Answer

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

ans = 0
lst = []
kari = []
for i in range(N):
    if i == 0:
        lst += list(map(int, input().split()))
        lst = lst[1:]
    else:
        if lst == []:
            print (0)
        else:      
            kari = list(map(int, input().split()))
            for j in lst:
                if j in kari[1:]:
                    pass
                else:
                    lst.remove(j)

#print (lst)
ans = len(lst)
print (ans)

Submission status: Wrong Answer

Solution code:
N,M=list(map(int,input().split()))
Key=[]
cnt=0
a=0
    
if N==1:
    a=input().split()
    print(len(a)-1)

else:    
    
    for i in range(N):
        tmp=input().split()
        for j in range(int(tmp[0])):
            Key.append(int(tmp[j+1]))
    
    for i in range(1,N+1):
        if Key.count(i)==N:
            cnt+=1
    
    print(cnt)

Submission status: Wrong Answer

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

def solve():
    N, M = list(map(int, input().split()))

    A = list(map(int, input().split()))
    candidates = A[1:]

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

        for food in candidates:
            if food in A:
                pass
            else:
                candidates.remove(food)
    
    print(len(candidates))




if __name__ == "__main__":
    solve()

Submission status: Wrong Answer

Solution code:
from sys import stdin
import itertools
from collections import Counter

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

c = []
for _ in range(N):
  a = [int(x) for x in stdin.readline().rstrip().split()][1:]
  
  if N==1:
    print(len(a));exit()
  else:
    c.append(a)
    merged = list(itertools.chain.from_iterable(c))

k = Counter(merged).most_common()[0][1] 

print(int(k/N))

Submission status: Wrong Answer

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

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

food_count = [0] * m

for p in k:
    for i in range(1, len(p)):
        food_count[p[i]-1] += 1

print(food_count)
count = 0
for f in food_count:
    if f == n:
        count += 1

print(count)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
from sys import stdin
import sys
N,M = map(int,stdin.readline().rstrip().split())
if N == 0:
    print(1)
    sys.exit()
list = [ set(stdin.readline().rstrip().split()[1:5]) for _ in range(0,N)]
print(list)
fav = list[0]
for i in range(1,N):
    fav = fav.intersection(list[i])
print(len(fav))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N,M = map(int,input().split())
tmp = []
for i in range(N):
    tmp1 = []
    K = list(map(int,input().split()))
    for j in range(1,K[0]+1):
        if i <= 0:
            tmp1.append(K[j])
        elif K[j] in tmp:
            tmp1.append(K[j])
        tmp = tmp1
        
print(len(tmp))

Submission status: Wrong Answer

Solution code:
N,M = map(int,input().split())
tmp = []
for i in range(N):
    tmp1 = []
    K = list(map(int,input().split()))
    for j in range(1,K[0]+1):
        if i <= 1:
            tmp1.append(K[j])
        elif K[j] in tmp:
            tmp1.append(K[j])
        tmp = tmp1
print(len(tmp))

Submission status: Wrong Answer

Solution code:
# ABC118B - Foods Loved by Everyone
n, m = list(map(int, input().rstrip().split()))
lst = [list(map(int, input().rstrip().split())) for _ in range(n)]
data = [0] * m
count = 0
for i in range(n):
    for j in range(m):
        if j in lst[i]:
            data[j] += 1

for k in range(m):
    if data[k] == n:
        count += 1
        
print(count)

Submission status: Wrong Answer

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

ansLst = []
for i in range(1, len(kLst[0])):
    ansLst.append(kLst[0][i])

for i in range(N):
    del kLst[i][0]

for i in range(1, N):
    if len(ansLst) == 0:
        break
    for j in ansLst:
        if kLst[i].count(j) == 0:
            ansLst.remove(j)
print(len(ansLst))

Submission status: Wrong Answer

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

ansLst = []
for i in range(1, len(kLst[0])):
    ansLst.append(kLst[0][i])

for i in range(N):
    del kLst[i][0]

for i in range(1, N):
    for j in ansLst:
        if kLst[i].count(j) == 0:
            ansLst.remove(j)
print(len(ansLst))

Submission status: Wrong Answer

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

foods = list(range(1, M+1))

for i in range(N):
    fav_food = list(map(int, input().split()))
    fav_food = fav_food[1:]
    for food in foods:
        if food not in fav_food:
            foods.remove(food)

print(len(foods))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

bag = {m+1: 0 for m in range(M)}

for n in range(N):
    all_list = list(map(int, input().split()))
    K = all_list[0]
    A = all_list[1:]
    for k in range(K):
        bag[A[k]] *= 1

count = sum(bag.values())

print(count)

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
truely_loved_food = {x for x in range(m)}
for i in range(n):
    li = list(map(int, input().split()))
    k=li[0]
    loved_food = set(li[1:])
    truely_loved_food = truely_loved_food & loved_food
print(len(truely_loved_food))

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
truely_loved_food = {x for x in range(m)}
for i in range(n):
    li = list(map(int, input().split()))
    k=li[0]
    loved_food = set(li[1:])
    truely_loved_food = truely_loved_food & loved_food
print(len(loved_food))

Submission status: Wrong Answer

Solution code:
import sys
from collections import Counter

N, M = map(int, input().split())
KA = ''
for i in range(N):
    KA += input()[1:].replace(' ', '')
c = Counter(KA)

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

print(ans)

Submission status: Wrong Answer

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

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

print(len(common))

Submission status: Wrong Answer

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

def hantei(x):
  for j in range(N):
    if x not in List[j][1:]:
      return(0)
  return(1)

ans = 0
for i in range(M):
  ans = ans + hantei(i)
print(ans)

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
lis = [[int(x) for x in input().split()] for _ in range(N)]
ans = 0
for item in range(1, M + 1):
  for i in lis[1:]:
    if not item in i:
      break
  else:
    ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
lis = [[int(x) for x in input().split()] for _ in range(N)]
ans = 0
for item in range(1, M + 1):
  for i in lis:
    if not item in i:
      break
  else:
    ans += 1
print(ans)

Submission status: Wrong Answer

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

count1 = 0
for i in range(M+1):
    count2 = 0
    for j in range(N):
        if i in K[j][1:M]:
            count2 += 1
    if count2 == N:
        count1 += 1
print(count1)

Submission status: Wrong Answer

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

count1 = 0
for i in range(M):
    count2 = 0
    for j in range(N):
        if i in K[j][1:M]:
            count2 += 1
    if count2 == N:
        count1 += 1
print(count1)

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
L = list()
ans = list()
for i in range(N):
  l = [int(_) for _ in input().split()]
  for j in range(l[0]):
    ans.append(l[j+1])
  l = L.copy()
cnt = 0
num = 0
s = -1
ans.sort()
for k in ans:
  if s == k:
    cnt += 1
    if cnt == N:
      num += 1
      cnt = 0
  else:
    cnt = 1
    s = k
print(num)

Submission status: Wrong Answer

Solution code:
K = [None]*30
A = [None]*30
Ms = [0]*31
def main():
    N, M = map(int, input().split())
    for i in range(N):
        K[i], *A[i], = map(int, input().split())
    for i in A:
        if i == None:
            break
        for j in i:
            print(j)
            Ms[j] += 1
    print(Ms.count(N))

main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,m = map(int, input().split())
number_list = []
for _ in range(n):
	KA = input().split()
	number_list.extend(KA[1:])
	# print(number_list)
count = 0
for i in range(n + 1):
	if number_list.count(str(i)) == n:
		count += 1

print(count)

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
list1=[]
for i in range(n):
  l=list(map(int,input().split()))
  del l[0]
  list1.append(l)
c=0
for i in range(m):
  b=True
  for j in range(n):
    if i in list1[j]:
      pass
    else:
      b=False
  if b:
    c+=1
print(c)

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
l=[list(map(int,input().split())) for i in range(n)]
c=0
for i in range(m):
  b=True
  for j in range(n):
    if i in l[j]:
      pass
    else:
      b=False
  if b:
    c+=1
print(c)

Submission status: Wrong Answer

Solution code:
N,M = map(int,input().split())
list_a = [0]*M
for i in range(N):
    k = input().split()
    for K in range(1,int(k[0])):
        list_a[int(k[K])-1] += 1

print(list_a.count(N))