Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())
a=list(map(int, input().split()))
s=[0]*(n+1)
for i in range(1, n+1):
    s[i]=s[i-1]+a[i-1]
dic={}
for i in range(n+1):
    tmp=s[i]%m
    if tmp in dic.keys():
        dic[tmp]+=1
    else:
        dic[tmp]=1
ans=0
for i in dic.values():
    ans+=i*(i-1)//2
print(ans)
n, m = map(int, input().split())
a=list(map(int, input().split()))
s=[0]*(n+1)
for i in range(1, n+1):
    s[i]=s[i-1]+a[i-1]
dic={}
for i in range(n+1):
    tmp=s[i]%m
    if tmp in dic.keys():
        dic[tmp]+=1
    else:
        dic[tmp]=1
ans=0
for i in dic.values():
    ans+=i*(i-1)//2
print(ans)

Fixed submission:
def main():
    n, m = map(int, input().split())
    a=list(map(int, input().split()))
    s=[0]*(n+1)
    for i in range(1, n+1):
        s[i]=s[i-1]+a[i-1]
    dic={}
    for i in range(n+1):
        tmp=s[i]%m
        if tmp in dic.keys():
            dic[tmp]+=1
        else:
            dic[tmp]=1
    ans=0
    for i in dic.values():
        ans+=i*(i-1)//2
    print(ans)
if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    n, m = map(int, input().split())
    a=list(map(int, input().split()))
    s=[0]*(n+1)
    for i in range(1, n+1):
        s[i]=s[i-1]+a[i-1]
    dic={}
    for i in range(n+1):
        tmp=s[i]%m
        if tmp in dic.keys():
            dic[tmp]+=1
        else:
            dic[tmp]=1
    ans=0
    for i in dic.values():
        ans+=i*(i-1)//2
    print(ans)
if __name__ == '__main__':
    main()

Fixed submission:
def main():
    n, m = map(int, input().split())
    a=list(map(int, input().split()))
    s=[0]*(n+1)
    for i in range(1, n+1):
        s[i]=s[i-1]+a[i-1]
    dic={}
    for i in range(n+1):
        tmp=s[i]%m
        if tmp in dic.keys():
            dic[tmp]+=1
        else:
            dic[tmp]=1
    ans=0
    for i in dic.values():
        ans+=i*(i-1)//2
    print(ans)
if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    n, m = map(int, input().split())
    a=list(map(int, input().split()))
    s=[0]*(n+1)
    for i in range(1, n+1):
        s[i]=s[i-1]+a[i-1]
    dic={}
    for i in range(n+1):
        tmp=s[i]%m
        if tmp in dic.keys():
            dic[tmp]+=1
        else:
            dic[tmp]=1
    ans=0
    for i in dic.values():
        ans+=i*(i-1)//2
    print(ans)
if __name__ == '__main__':
    main()

Fixed submission:
def main():
    n, m = map(int, input().split())
    a=list(map(int, input().split()))
    s=[0]*(n+1)
    for i in range(1, n+1):
        s[i]=s[i-1]+a[i-1]
    dic={}
    for i in range(n+1):
        tmp=s[i]%m
        if tmp in dic.keys():
            dic[tmp]+=1
        else:
            dic[tmp]=1
    ans=0
    for i in dic.values():
        ans+=i*(i-1)//2
    print(ans)
if __name__ == '__main__':
    main()

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(1, n+1):
    s[i]=s[i-1]+a[i-1]
dic={}
for i in range(n+1):
    tmp=s[i]%m
    if tmp in dic.keys():
        dic[tmp]+=1
    else:
        dic[tmp]=1
ans=0
for i in dic.values():
    ans+=i*(i-1)//2
print(ans)

Fixed submission:
def main():
    n, m = map(int, input().split())
    a=list(map(int, input().split()))
    s=[0]*(n+1)
    for i in range(1, n+1):
        s[i]=s[i-1]+a[i-1]
    dic={}
    for i in range(n+1):
        tmp=s[i]%m
        if tmp in dic.keys():
            dic[tmp]+=1
        else:
            dic[tmp]=1
    ans=0
    for i in dic.values():
        ans+=i*(i-1)//2
    print(ans)
if __name__ == '__main__':
    main()