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,K = map(int,input().split())
K_A = []
for i in range(N):
	K_A.append(list(map(int,input().split())))

l = []

for i in range(N):
	del K_A[i][0]
	for j in range(len(K_A[i])):
		l.append(K_A[i][j])
		
count = 0

for i in range(K+1):
	print(l.count(i),i)
	if l.count(i) == N:
		count  += 1

print(count)

Submission status: Wrong Answer

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

l = []

for i in range(N):
	del K_A[i][0]
	for j in range(len(K_A[i])):
		l.append(K_A[i][j])
		
count = 0

for i in range(K):
	if l.count(i) == N:
		count  += 1

print(count)

Submission status: Wrong Answer

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

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

n, m = reads()
a = set(reads()[1:])
for _ in range(n - 1):
  a &= set(input().split()[1:])
print(len(a))

Submission status: Wrong Answer

Solution code:
N,M = map(int,input().split())
Likes = [True] * M
count = [0] * M
for n in range(N):
    KA = list(map(int,input().split()))[1:]
    for nn in range(M):
        count[nn] += 1
        if not nn in KA :
            Likes[nn] = False
for i,j in enumerate(count):
    if i == 0:
        Likes[i] = False
print(Likes.count(True))

Submission status: Wrong Answer

Solution code:
N,M = map(int,input().split())
Likes = [True] * M
for n in range(N):
    KA = list(map(int,input().split()))[1:]
    for nn in range(M):
        if not nn in KA :
            Likes[nn] = False
print(Likes.count(True))

Submission status: Wrong Answer

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

for i in range(n):
    o = list(map(int, input().split()))
    for j, x in enumerate(o):
        if j != 0:
            res[i][x - 1] = True

ans = 0
res = list(zip(*res))

for i, x in enumerate(res):
    print(x)
    if all(x):
        ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np

n,m=list(map(int,input().split()))
t=np.zeros(m)
for i in range(n):
  tmp=list(map(int,input().split()))  
  for j in range(tmp[0]):
    t[tmp[j+1]-1] += 1
  
maxIndex = [i for i, x in enumerate(t) if x == max(t)]
print(len(maxIndex))

Submission status: Wrong Answer

Solution code:
print(8)

Submission status: Wrong Answer

Solution code:
print(7)

Submission status: Wrong Answer

Solution code:
print(6)

Submission status: Wrong Answer

Solution code:
print(10)

Submission status: Wrong Answer

Solution code:
print(30)

Submission status: Wrong Answer

Solution code:
print(5)

Submission status: Wrong Answer

Solution code:
print(4)

Submission status: Wrong Answer

Solution code:
print(3)

Submission status: Wrong Answer

Solution code:
print(2)

Submission status: Wrong Answer

Solution code:
print(1)

Submission status: Wrong Answer

Solution code:
print(0)

Submission status: Wrong Answer

Solution code:
import random
print(random.randint(0,30))

Submission status: Wrong Answer

Solution code:
import random
print(random.randint(1,30))

Submission status: Wrong Answer

Solution code:
N,M = map(int,input().split())
kind = [0]
for res in range (0,M):
    kind.append(0)
for x in range (0,N):
    like = map(int,input().split())
    like = list(like)
    for i in range (0,len(like)):
        kind[like[i]] += 1
print(kind.count(N))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
nm = [int(i) for i in input().split()]

tmp = [int(i) for i in input().split()]
tmp2 = tmp[1:]
list = set(tmp2)
for i in range(1,nm[0]):
  tmp = [int(i) for i in input().split()]
  tmp2 = tmp[1:]
  list = set(tmp2) and list 
print(len(list))

Submission status: Wrong Answer

Solution code:
N,M=[int(i) for i in input().split()]
total_list=[]
for i in range(N):
    total_list.append([int(i) for i in input().split()])
total_set=set()
for i in total_list:
    for j,num in enumerate(i):
        if j!=0:
            total_set.add(num)
print(len(total_set))

Submission status: Wrong Answer

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

count = 0
for y in S:
  if y == N:
    count+=1
print(count)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
N ,M = map(int,input().split(" "))
ans =input().split(" ")
del ans[0]
for i in range(N-1):
    x = input().split(" ")
    del x[0]
    #print(x)
    for i in ans:
        if i not in x:
            ans.remove(i)
print(len(ans))
#print(ans)

Submission status: Wrong Answer

Solution code:
import sys
import collections

N = int(sys.stdin.readline().strip().split()[0])
print("N=",N)

new = []
for i in range(N):
  tmp = sys.stdin.readline().strip().split()
  for j in range(len(tmp)-1):
    new.append(tmp[j+1])

print("new len:, ",len(new))
    
c = collections.Counter(new)


cnt = 0
for i in range(len(c.most_common())):
  if int(c.most_common()[i][1]) == N:
    cnt += 1
  else:
    break
    
print(cnt)

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
print(len(set.intersection(*[set(input().split())for _ in[0]*n]))-1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
nb_people, nb_foods = [int(x) for x in input().split()]
like_count = {}
for _ in range(nb_people):
    _, *liked = [int(x) for x in input().split()]
    for i in liked:
        like_count[i] = like_count.get(i, 0) + 1
    cnt = 0
    for x in like_count.values():
        if x == nb_people:
            cnt += 1
    print(cnt)

Submission status: Wrong Answer

Solution code:
n,m = map(int, input().split())
if n == 1:
    print(input().split()[0])
else:
    kdict = {i:0 for i in range(1,m+1)}
    for _ in range(n):
        for i in map(int, set(input().split()[1:])):
            kdict[i] += 1
    print(sum([i for i in kdict.items() if i == n]))

Submission status: Wrong Answer

Solution code:
n,m = map(int, input().split())
if n == 1:
    print(input().split()[0])
else:
    kdict = {i:0 for i in range(1,m+1)}
    for _ in range(n):
        for i in map(int, input().split()[1:]):
            kdict[i] += 1
    print(sum([i for i in kdict.items() if i == n]))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import collections

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

l = []
for j in range(N):
    for i in range(len(a[j])-1):
        l.append(a[j][i+1])


c = collections.Counter(l)
cc=c.most_common()[0]

for i in range(len(cc)):
    if cc[i] == N:
        print(len(cc))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
#coding: utf-8

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

List = []
all_and = []
for i in range(N):
    l = list(map(int, input().split()))
    del l[0]
    List.append(l)
    all_and = set(all_and) & set(List[i])

all_and_list = list(all_and)
print(len(all_and_list))

Submission status: Wrong Answer

Solution code:
#coding: utf-8

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

List = []
all_and = []
for i in range(N):
    l = list(map(int, input().split()))
    #print(l)
    del l[0]
    #print(l)
    List.append(l)
    #print(List[i])
    #print(List)
    #print( )

    all_and = set(all_and) & set(List[i])

all_and_list = list(all_and)
#print(all_and)
#print(all_and_list)
print(len(all_and_list))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

ans = 0


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


print(ans)

Submission status: Wrong Answer

Solution code:
import sys
import collections
input_lines = sys.stdin.readlines()

N = input_lines[0].strip()[0]
N = N.strip()
N = int(N)

new = []
for i in range(1,len(input_lines)):
  tmp = input_lines[i].strip()
  tmp = tmp.split()
  for j in range(len(tmp)-1):
	  new.append(tmp[j+1])
      
c = collections.Counter(new)


cnt = 0
for k in range(len(c.most_common())):
  if int(c.most_common()[k][1]) == N:
    cnt += 1
  else:
    break
    
print(cnt)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import collections

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

l = []
for j in range(N):
    for i in range(len(a[j])-1):
        l.append(a[j][i+1])


c = collections.Counter(l)
cc=c.most_common()[0]

if cc[1] == N:
    print(1)

Submission status: Wrong Answer

Solution code:
import sys
import collections
input_lines = sys.stdin.readlines()

N = input_lines[0].strip()[0]
N = N.strip()
N = int(N)

new = []
for i in range(1,len(input_lines)):
  tmp = input_lines[i].strip()
  tmp = tmp.split()
  for j in range(len(tmp)-1):
	  new.append(tmp[j+1])
      
c = collections.Counter(new)


cnt = 0
for i in range(len(c.most_common())):
  if int(c.most_common()[i][1]) == N:
    cnt += 1
  else:
    break
    
print(cnt)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,m = map(int, input().split())
if n == 1:
    print(input().split()[0])
else:
    ans = 0
    for _ in range(n):
        if len(input().split()) == n + 1:
            ans += 1
    print(ans)

Submission status: Wrong Answer

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

b = [x[1:] for x in a ]

c = []
for j in range(1,31):
    for k in range(n):
        if j in b[k]:
            c.append(j)

d = [x for x in set(c) if c.count(x) == n]

Submission status: Wrong Answer

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

b = [x[1:] for x in a ]

c = []
for j in range(30):
    for k in range(n):
        if j in b[k]:
            c.append(j)

d = [x for x in set(c) if c.count(x) == n]
print(len(d))

Submission status: Wrong Answer

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

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

a = {}
for i in list:
    for j in i[1:]:
        if j in a:
            a[j] = a[j] + 1
        else:
            a[j] = 1

cnt = 0
for x in a:
    if x == n[0]:
        cnt += 1

print(cnt)

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
a = [list(map(int, input().split())) for i in range(n)]
result = [0 for i in range(m)]
for mindex in range(0,m):
    for nindex in range(0,n):
        for kindex in range(1,a[nindex][0]+1):
            if a[nindex][kindex] == mindex+1:
                result[mindex]+=1
            else:
                pass
                

print(result.count(n+1))

Submission status: Wrong Answer

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

a_li =[]
for i in range(n):
    li = input().split()
    del li[0]
    a_li += li

count_li =[]
for o in range(m):
    x = a_li.count(str(o))
    count_li.append(int(x))
    
print(count_li.count(n))

Submission status: Wrong Answer

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

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

a = {}
for i in list:
    for j in i[1:]:
        a[j] = a.get(j, 0) + 1

cnt = 0
for x in a:
    if x == n[0]:
        print('同じ')
        cnt += 1

print(cnt)

Submission status: Wrong Answer

Solution code:
N = list(map(int, input().split()))
array = list(map(int, input().split()))
array.remove(array[0])
dainyu = []
for i in range(0, N[0]-1):
    data = list(map(int, input().split()))
    dainyu = []
    for loop in range(1, data[0]-1):
        if (array.count(data[loop]) != 0) :
            dainyu.append(data[loop])
    array = dainyu
print(len(array))

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import numpy


def main():
  n, m = list(map(int, input().split()))
  a = numpy.ones(m)

  for _ in range(n):
    b = numpy.zeros(m)
    b[list(map(lambda x: int(x) - 1, input().split()))[1:]] = 1
    a *= b

  print(a)
  print(int(numpy.sum(a)))


if __name__ == '__main__':
  main()

Submission status: Wrong Answer

Solution code:
import numpy as np
n, m = map(int, input().split())
A = []
for _ in range(n):
  __ = input().split()
  A.append(np.array(__, dtype=int))
ans = []
for i in range(m):
  ans.append(i+1)
for a in A:
  for i in ans:
    if not i in a[1:]:
      ans.remove(i)
print(len(ans))

Submission status: Wrong Answer

Solution code:
N, M = (int(x) for x in input().split())
KA = [[int(x) for x in l] for l in [input().split() for i in range(N)]]
[x.pop(0) for x in KA]
x = []
for s in KA:
  x.extend(s)
c = 0
for i in range(1, M + 1):
  print(x.count(i))
  c = c + (1 if x.count(i) == N else 0)
print(c)

Submission status: Wrong Answer

Solution code:
import numpy as np
n, m = map(int, input().split())
A = []
for _ in range(n):
  __ = input().split()
  A.append(np.array(__, dtype=int))
ans = []
for i in range(m):
  ans.append(i)
for a in A:
  for i in ans:
    if not i in a[1:]:
      ans.remove(i)
print(len(ans))

Submission status: Wrong Answer

Solution code:
import sys
import collections
input_lines = sys.stdin.readlines()

N = input_lines[0].strip()[0]
N = N.strip()
N = int(N)

new = []
for i in range(1,len(input_lines)):
  tmp = input_lines[i].strip()
  tmp = tmp.split()
  for j in range(len(tmp)-1):
	  new.append(tmp[j+1])
      
c = collections.Counter(new)


cnt = 0
for i in range(len(c.most_common())):
  if int(c.most_common()[i][1]) == N:
    cnt += 1
    
print(cnt)

Submission status: Wrong Answer

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

I = [True]*(M)

for j in range(1,M):
    for ki in range(N):
        if not (j in A[ki]):
            I[j-1] = False

print(I.count(True))

Submission status: Wrong Answer

Solution code:
import sys
import collections
input_lines = sys.stdin.readlines()

N = input_lines[0].strip()[0]
N = N.strip()
N = int(N)

new = []
for i in range(1,len(input_lines)):
  tmp = input_lines[i].strip()
  tmp = tmp.split()
  for j in range(len(tmp)-1):
	  new.append(tmp[j+1])
      
c = collections.Counter(new)


cnt = 0
for i in range(len(c.most_common())):
  print("i=",i,",",c.most_common()[i][1])
  if int(c.most_common()[i][1]) == N:
    print("hit")
    cnt += 1
    
print(cnt)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

a_li =[]
for i in range(n):
    li = input().split()
    del li[0]
    a_li += li

count_li =[]
for o in range(m):
    x = a_li.count(str(o))
    count_li.append(int(x))
    
print(count_li.count(count_li == n))

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
l=[]
for i in range(n):
    a=len(l)
    l.append(map(str,input().split()))
    b=len(l)-a
    l.pop(-b)
s=[]
i=0
while i<m:
    i+=1
    i=str(i)
    s.append(l.count(i))
    i=int(i)
print(s.count(m))

Submission status: Wrong Answer

Solution code:
n, k = [int(i) for i in input().split()]
lines = [set(input().split()[1:]) for i in range(n)]
diff = set()
for line in lines:
  diff = diff&line
print(len(diff))

Submission status: Wrong Answer

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

tabe = []

for i in range(1,M+1):
    tabe.append(int(i))

count = 0

KACOUNT = []

for i in range(N):
    for j in range(len(KA[i])):
        KACOUNT.append(KA[i][j])

for i in tabe:
    if KACOUNT.count(i) < N:
        count += 1

print(M-1-count)

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
listA=[]
while True:
    try:
        listA.append(list(map(int,input().split())))

    except:
        break;
x = 0
for j in range(1,listA[0][0]+1):
    for i in range(1,n):
        listB = []
        for k in range(1,listA[i][0]+1):
          listB.append(listA[i][k])
          if listA[0][j] not in listB:
            break
    else:
    	x += 1
print(x)

Submission status: Wrong Answer

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

product = set(i for i in range(1, m+1))
for i in range(0, n):
	As = set(input().split()[1:])
	product &= As
	
print(len(product))

Submission status: Wrong Answer

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

dic = {}
for i in range(0,n):
    k = list(map(int,input().split()))
    for j in range(1,len(k)):
        if k[j] in dic:
            dic[k[j]] += 1
        else:
            dic[k[j]] = 1
        
res = 0
for key,value in dic.items():
    if value == n:
        res+=1
res

Submission status: Wrong Answer

Solution code:
sasaoka = input().split()
N = int(sasaoka[0])
M = int(sasaoka[1])
a = []
for _ in range(N):
    a.append(list(map(int, input().split())))
nokolist = []
lst = a[0]
nokolist = lst[1:]
for i in range(N-1):
    lst = a[i+1]
    list = lst[1:]
    for j in nokolist:
        if j in list:
          c =2
        else:
          nokolist.remove(j)
print(len(nokolist))

Submission status: Wrong Answer

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

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


for i in range(n):
    a= [int(j) for j in input().split()]
    a.pop(0)
    a=set(a)
    s=s and a

print(len(s))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

for i in range(int(N)):
    hito[i] = list(map(int, hito[i]))

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

hikaku = np.arange(1,int(M)+1)
for i in range(int(N)):
    hikaku = list(set(hikaku) & set(hito[i]))
    print(hikaku)

print(hikaku)
print(len(hikaku))

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
listA=[]
while True:
    try:
        listA.append(list(map(int,input().split())))

    except:
        break;
x = 0
for j in range(1,listA[0][0]+1):
    for i in range(1,n):
        if listA[0][j] not in listA[i] or listA[0][j] == listA[i][0]:
            break
    else:
    	x += 1
print(x)

Submission status: Wrong Answer

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

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


for i in range(n):
    a= [int(j) for j in input().split()]
    a.pop(0)
    a=set(a)
    s=s and a

print(len(s))

Submission status: Wrong Answer

Solution code:
a = list(map(int, input().split()))
likefood = []
result = 0

for i in range(a[0]):
    b = list(map(int, input().split()))
    for k in range(b[0]):
        likefood.append(k+1)

for i in range(a[1]):
    if likefood.count(i+1) == a[0]:
        result += 1

print(result)

Submission status: Wrong Answer

Solution code:
N = list(map(int, input().split()))
array = list(map(int, input().split())) #最初の列データを入れる
array.remove(array[0])
dainyu = []
for i in range(0, N[0]-1):
    data = list(map(int, input().split()))
    for loop in range(1, data[0]-1):
        dainyu = []
        if (array.count(data[loop]) != 0) :
            dainyu.append(data[loop])
    array = dainyu
print(len(array))

Submission status: Wrong Answer

Solution code:
from sys import stdin


def count_samples_of_like_same_food(samples_and_like_foods):
    all_samples_count = len(samples_and_like_foods)
    like_foods_num_dict = {}
    for like_foods in samples_and_like_foods:
        like_foods_set = tuple(set(like_foods))
        #print(like_foods_set)
        for like_food in like_foods_set:
            if like_food not in like_foods_num_dict:
                like_foods_num_dict[like_food] = 1
            else:
                like_foods_num_dict[like_food] += 1

    same_like_food_samples_count = 0
    for key, value in like_foods_num_dict.items():
        if value == all_samples_count:
            same_like_food_samples_count += 1
    return same_like_food_samples_count


def main():
    input_line_list = stdin.readlines()[1:]
    #print(input_line_list)
    samples_and_like_foods = [like_foods_string.split() for like_foods_string in input_line_list]
    #print(samples_and_like_foods)
    print(count_samples_of_like_same_food(samples_and_like_foods))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N,M=map(int,input().split())
data = [input().split() for i in range(N)] 
# print(len(data))
result=[]
for j in range(N):
    result=result+data[j][1:]
# print(result)
result=[int(s) for s in result]
ans=[x for x in result if result.count(x) == N]
print(len(ans))

Submission status: Wrong Answer

Solution code:
#!/usr/bin/python3

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

candidates = [i + 1 for i in range(N)]

for k in range(N):
    A = [i for i in map(int, input().split())]
    _M = A.pop(0)
    for index, cand in enumerate(candidates):
        if cand not in A:
            del candidates[index]

print(len(candidates))

Submission status: Wrong Answer

Solution code:
from operator import add

n, m = map(int, input().split())
li = []
for i in range(n):
    li.append(list(map(int, input().split())))
    del li[i][0]
li = sum(li, [])

count = 0
for num in li:
    if n == li.count(num):
        count += 1
print(count)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

ka=[]
for i in range(n):
    atmp=list(input().split())
    ka.append(atmp)


like=ka[0][1::]
ans=len(like)

if n>1:
    for i in range(1,n):
        liketmp=ka[i][1::]
        for k in range(0,len(like)):
             if like[k] not in liketmp:
                 if ans>0:
                     ans-=1
                     if ans==0:
                         break

print(ans)

Submission status: Wrong Answer

Solution code:
N,M=map(int,input().split())
data = [input().split() for i in range(N)] 
# print(len(data))
result=[]
for j in range(N):
    result=result+data[j][1:]
# print(result)
ans=[x for x in result if result.count(x) == N]
print(len(ans))

Submission status: Wrong Answer

Solution code:
a = list(map(int, input().split()))
likefood = []
result = 0

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

for i in range(a[1]):
    if likefood.count(i) == a[0]:
        result += 1

print(result)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import numpy as np
N, M = map(int, input().split())
a = np.zeros((N,M))
for i in range(N):
    K = list(map(int, input().split())) 
    for j in K[1:]:
        a[i][j-1] = 1
b = a.sum(axis=1)
print(len(np.where(b==N)[0]))

Submission status: Wrong Answer

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

ka=[]
for i in range(n):
    atmp=list(input().split())
    ka.append(atmp)


like=ka[0][1::]
ans=len(like)

if n>1:
    for i in range(1,n):
        liketmp=ka[i][1::]
        for j in range(0,len(liketmp)-1):
            if liketmp[j] not in like:
                if ans>0:
                    ans-=1
                    if ans==0:
                        break

        for k in range(0,len(like)):
             if like[k] not in liketmp:
                 if ans>0:
                     ans-=1
                     if ans==0:
                         break

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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


set_list = []

for i in e:
    set_list.append(set(i[1:]))


ok= set()
for i in set_list:
    for i2 in set_list:
        if i == i2:
            continue
        if len(ok) >=1:
            ok = list(i2.intersection(ok))
        else:
            ok = list(i.intersection(i2))
    break

if N == 1:
    print(e[0][0])
else:
    print(len(ok))

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
List = list(range(1,M))
anser = []
def judge(N,M,List,anser):
  for i in range(N):
    L = list(map(int, input().split()))
    anser.extend(L)
    anser = list(set(anser))
    print(anser)
  print(len(anser))
judge(N,M,List,anser)

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
List = list(range(1,M))
anser = []
def judge(N,M,List,anser):
  for i in range(N):
    L = list(map(int, input().split()))
    anser.extend(L)
    anser = list(set(anser))
    print(anser)
  print(M - len(anser))
judge(N,M,List,anser)

Submission status: Wrong Answer

Solution code:
from sys import stdin


def count_samples_of_like_same_food(samples_and_like_foods):
    all_samples_count = len(samples_and_like_foods)
    like_foods_num_dict = {}
    for like_foods in samples_and_like_foods:
        like_foods_set = tuple(set(like_foods))
        #print(like_foods_set)
        for like_food in like_foods_set:
            if like_food not in like_foods_num_dict:
                like_foods_num_dict[like_food] = 1
            else:
                like_foods_num_dict[like_food] += 1

    same_like_food_samples_count = 0
    for key, value in like_foods_num_dict.items():
        if value == all_samples_count:
            same_like_food_samples_count += 1
    return same_like_food_samples_count


def main():
    input_line_list = stdin.readlines()
    samples_and_like_foods = [like_foods_string.split() for like_foods_string in input_line_list]
    #print(samples_and_like_foods)
    print(count_samples_of_like_same_food(samples_and_like_foods))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
for i in range(n):
    if i==0:
        a0=list(map(int,input().split()))	
        b0=a0[1:]
    else:
        a=list(map(int,input().split()))
        b=a[1:]
        for j in b0:
            if not j in b:
                b0.remove(j)
print(len(b0))