You are viewing a single comment's thread. Return to all comments →
import itertools n, m = map(int, input().split()) l=[] for _ in range(n): l.append(set(list(map(int, input().split()))[1:])) combinations = list(itertools.product(*l)) big_num = 0 for i in range(len(combinations)): big_num = max(sum([x**2 for x in combinations[i]])%m ,big_num) print(big_num)
Seems like cookies are disabled on this browser, please enable them to open this website
Maximize It!
You are viewing a single comment's thread. Return to all comments →