forked from mustafagundogdu80/Python_VIT
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhackerRank.py
More file actions
47 lines (37 loc) · 1.46 KB
/
hackerRank.py
File metadata and controls
47 lines (37 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#https://www.hackerrank.com/challenges/alphabet-rangoli/problem
# def print_rangoli(size):
# # your code goes here
# letter_list = [chr(i) for i in range(96 +size, 96,-1)]
# list_print = []
# if size > 1 :
# for i in range(0,size):
# str_print =""
# if i == 0:
# str_print = letter_list[0]
# else:
# for j in range(0,i):
# str_print += letter_list[j]+"-"
# str_print = str_print+letter_list[i]+str_print[::-1]
# if i != size-1:
# list_print.insert(0,str_print)
# print(str_print.center(((size-1)*4+1),"-"))
# for i in list_print:
# print(i.center(((size-1)*4+1),"-"))
# elif size == 1:
# print("a")
"""---------------------------------------------------"""
# # https://www.hackerrank.com/challenges/swap-case/problem
# def swap_case(s):
# return s.
# if __name__ == '__main__':
# s = input()
# result = swap_case(s)
# print(result)
"""---------------------------------------------------"""
# https://www.hackerrank.com/challenges/maximize-it/problem?isFullScreen=true
from itertools import product
k, m = map(int, input().split())
lists = [list(map(int, input().split()))[1:] for _ in range(k)]
max_mod_sum = max(sum(x**2 for x in combination) % m for combination in product(*lists))
print(max_mod_sum)
"""---------------------------------------------------"""