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

S=[0]*(N+1)
for i in range(N):
    S[i+1]=(A[i]+S[i])%M


def tr(k):
    return k*(k-1)//2


countlist=dict()
check=set()


for i in range(1,N+1):
    countlist[S[i]]=countlist.get(S[i],0)+1
    check=check|{S[i]}
    
    





ANS=int(countlist.get(0,0))



for i in check:
    ANS+=tr(int(countlist[i]))



print(ANS)



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

S=[0]*(N+1)
for i in range(N):
    S[i+1]=(A[i]+S[i])%M


def tr(k):
    return k*(k-1)//2


countlist=dict()
check=set()


for i in range(1,N+1):
    countlist[S[i]]=countlist.get(S[i],0)+1

    
    


ANS=countlist.get(0,0)

for i in countlist.keys():
    ANS+=tr(countlist[i])



print(ANS)

Buggy python submission (verdict: Runtime Error):

import numpy as np

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




S=[0]*(N+1)
for i in range(N):
    S[i+1]=(A[i]+S[i])%M


def tr(k):
    return k*(k-1)//2


countlist=np.zeros(M)
check=set()


for i in range(1,N+1):
    countlist[S[i]]+=1
    check=check|{S[i]}
    
    





ANS=int(countlist[0])



for i in check:
    ANS+=tr(int(countlist[i]))



print(ANS)






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

S=[0]*(N+1)
for i in range(N):
    S[i+1]=(A[i]+S[i])%M


def tr(k):
    return k*(k-1)//2


countlist=dict()
check=set()


for i in range(1,N+1):
    countlist[S[i]]=countlist.get(S[i],0)+1

    
    


ANS=countlist.get(0,0)

for i in countlist.keys():
    ANS+=tr(countlist[i])



print(ANS)

Buggy python submission (verdict: Runtime Error):
import time
import numpy as np

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

time1=time.time()


S=[0]*(N+1)
for i in range(N):
    S[i+1]=(A[i]+S[i])%M


def tr(k):
    return k*(k-1)//2

time2=time.time()
countlist=np.zeros(M)
check=set()

time3=time.time()

for i in range(1,N+1):
    countlist[S[i]]+=1
    check=check|{S[i]}
    
    

time4=time.time()



ANS=countlist[0]

for i in check:
    ANS+=tr(countlist[i])



print(int(ANS))






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

S=[0]*(N+1)
for i in range(N):
    S[i+1]=(A[i]+S[i])%M


def tr(k):
    return k*(k-1)//2


countlist=dict()
check=set()


for i in range(1,N+1):
    countlist[S[i]]=countlist.get(S[i],0)+1

    
    


ANS=countlist.get(0,0)

for i in countlist.keys():
    ANS+=tr(countlist[i])



print(ANS)

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



countlist=[]
S=[0]*(N+1)
for i in range(N):
    S[i+1]=(A[i]+S[i])%M


def tr(k):
    return k*(k-1)//2


countlist=[0 for i in range(M)]
check=set()


for i in range(1,N+1):
    countlist[S[i]]+=1
    check=check|{S[i]}
    
    





ANS=countlist[0]

for i in check:
    ANS+=tr(countlist[i])

print(ANS)


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

S=[0]*(N+1)
for i in range(N):
    S[i+1]=(A[i]+S[i])%M


def tr(k):
    return k*(k-1)//2


countlist=dict()
check=set()


for i in range(1,N+1):
    countlist[S[i]]=countlist.get(S[i],0)+1

    
    


ANS=countlist.get(0,0)

for i in countlist.keys():
    ANS+=tr(countlist[i])



print(ANS)