Skip to content

Instantly share code, notes, and snippets.

@abidkhan484
Last active December 5, 2017 17:02
Show Gist options
  • Select an option

  • Save abidkhan484/8f843d8da39eed986109b5f1435bbd90 to your computer and use it in GitHub Desktop.

Select an option

Save abidkhan484/8f843d8da39eed986109b5f1435bbd90 to your computer and use it in GitHub Desktop.
# the problem is not solved yet
from itertools import product
k, m = map(int, input().split())
li = []
for _ in range(k):
pagli = list(map(int, input().split()))
pagli.pop(0)
li.append(pagli)
maxim = -1
li = list(product(*li))
l = len(li[0])
for i in range(len(li)):
total = 0
for p in range(l):
total += (li[i][p]**2)
total = total % m
if total > maxim:
maxim = total
print(maxim)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment