Buggy python submission (verdict: Runtime Error):
from collections import defaultdict
N, M = map(int, input().split())
A = list(map(int, input().split()))

ans = 0
hash = defaultdict(int())
i = 0
for a in A:
    i = (i+a) % M
    hash[i] += 1
for h in list(hash.keys()):
    ans += hash[h] * (hash[h]-1) // 2

print(ans)

Fixed submission:
from collections import defaultdict
N, M = map(int, input().split())
A = list(map(int, input().split()))

ans = 0
hash = defaultdict(int)
hash[0] = 1
i = 0
for a in A:
    i = (i+a) % M
    hash[i] += 1
for h in list(hash.keys()):
    ans += hash[h] * (hash[h]-1) // 2

print(ans)

Buggy python submission (verdict: Runtime Error):
from collections import defaultdict
N, M = map(int, input().split())
A = list(map(int, input().split()))

ans = 0
hash = defaultdict(int())
i = 0
for a in A:
    i = (i+a) % M
    hash[i] += 1
for h in list(hash.keys()):
    ans += hash[h] * (hash[h]-1) // 2

print(ans)

Fixed submission:
from collections import defaultdict
N, M = map(int, input().split())
A = list(map(int, input().split()))

ans = 0
hash = defaultdict(int)
hash[0] = 1
i = 0
for a in A:
    i = (i+a) % M
    hash[i] += 1
for h in list(hash.keys()):
    ans += hash[h] * (hash[h]-1) // 2

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
A = list(map(int, input().split()))

ans = 0
hash = {}
hash[0] = 1
i = 0
for a in A:
    i = (i+a) % M
    if i in list(hash.keys()):
        hash[i] += 1
    else:
        hash[i] = 1
for h in list(hash.keys()):
    ans += hash[h] * (hash[h]-1) // 2

print(ans)

Fixed submission:
from collections import defaultdict
N, M = map(int, input().split())
A = list(map(int, input().split()))

ans = 0
hash = defaultdict(int)
hash[0] = 1
i = 0
for a in A:
    i = (i+a) % M
    hash[i] += 1
for h in list(hash.keys()):
    ans += hash[h] * (hash[h]-1) // 2

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
A = list(map(int, input().split()))

ans = 0
hash = {}
hash[0] = 1
i = 0
for a in A:
    i = (i+a) % M
    if i in list(hash.keys()):
        hash[i] += 1
    else:
        hash[i] = 1
for h in list(hash.keys()):
    ans += hash[h] * (hash[h]-1) // 2

print(ans)

Fixed submission:
from collections import defaultdict
N, M = map(int, input().split())
A = list(map(int, input().split()))

ans = 0
hash = defaultdict(int)
hash[0] = 1
i = 0
for a in A:
    i = (i+a) % M
    hash[i] += 1
for h in list(hash.keys()):
    ans += hash[h] * (hash[h]-1) // 2

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
A = list(map(int, input().split()))

from itertools import accumulate
Cumsum = list(accumulate(A))
counter = 0
for l in range(0, N):
    for r in range(l, N):
        if l == r:
            if A[l] % M == 0:
                counter += 1
        elif l != r and l == 0:
            if Cumsum[r] % M == 0:
                counter += 1
        elif l != r and l >= 1:
            if (Cumsum[r] - Cumsum[l-1]) % M == 0:
                counter += 1


print(counter)

Fixed submission:
from collections import defaultdict
N, M = map(int, input().split())
A = list(map(int, input().split()))

ans = 0
hash = defaultdict(int)
hash[0] = 1
i = 0
for a in A:
    i = (i+a) % M
    hash[i] += 1
for h in list(hash.keys()):
    ans += hash[h] * (hash[h]-1) // 2

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
A = list(map(int, input().split()))

from itertools import accumulate
Cumsum = list(accumulate(A))
counter = 0
for l in range(0, N):
    for r in range(l, N):
        if l == r:
            if A[l] % M == 0:
                counter += 1
        elif l != r and l == 0:
            if Cumsum[r] % M == 0:
                counter += 1
        elif l != r and l >= 1:
            if (Cumsum[r] - Cumsum[l-1]) % M == 0:
                counter += 1


print(counter)

Fixed submission:
from collections import defaultdict
N, M = map(int, input().split())
A = list(map(int, input().split()))

ans = 0
hash = defaultdict(int)
hash[0] = 1
i = 0
for a in A:
    i = (i+a) % M
    hash[i] += 1
for h in list(hash.keys()):
    ans += hash[h] * (hash[h]-1) // 2

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
A = list(map(int, input().split()))

import numpy as np
Cumsum = np.cumsum(A)
counter = 0
for l in range(0, N):
    for r in range(l, N):
        if l == r:
            if A[l] % M == 0:
                counter += 1
        elif l != r and l == 0:
            if Cumsum[r] % M == 0:
                counter += 1
        elif l != r and l >= 1:
            if (Cumsum[r] - Cumsum[l-1]) % M == 0:
                counter += 1


print(counter)

Fixed submission:
from collections import defaultdict
N, M = map(int, input().split())
A = list(map(int, input().split()))

ans = 0
hash = defaultdict(int)
hash[0] = 1
i = 0
for a in A:
    i = (i+a) % M
    hash[i] += 1
for h in list(hash.keys()):
    ans += hash[h] * (hash[h]-1) // 2

print(ans)

Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
A = list(map(int, input().split()))

import numpy as np
Cumsum = np.cumsum(A)
counter = 0
for l in range(0, N):
    for r in range(l, N):
        if l == r:
            if A[l] % M == 0:
                counter += 1
        elif l != r and l == 0:
            if Cumsum[r] % M == 0:
                counter += 1
        elif l != r and l >= 1:
            if (Cumsum[r] - Cumsum[l-1]) % M == 0:
                counter += 1


print(counter)

Fixed submission:
from collections import defaultdict
N, M = map(int, input().split())
A = list(map(int, input().split()))

ans = 0
hash = defaultdict(int)
hash[0] = 1
i = 0
for a in A:
    i = (i+a) % M
    hash[i] += 1
for h in list(hash.keys()):
    ans += hash[h] * (hash[h]-1) // 2

print(ans)