Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
# 
import math
import sys
import itertools
import numpy as np

# なんこか入力
n,m = map(int, input().split())

# 空白区切りの数列をリストに代入
a = [int(i) for i in input().split()]
b = [0]*(n)
c1 = [0]
c2 = [0]
bb=0
c2[0]=1
for i in range(0,n) :
    bb = ( bb+a[i] ) % m
    if bb == 0:
        c2[0] += 1
    else:
        if bb in c1:
            c2[c1.index(bb)] += 1
        else:
            c1.append(bb)
            c2.append(1)
    
    
answer = 0
#print(c1)
#print(c2)
for i in range(0,len(c2)):
    cc = c2[i]
    if cc > 1:
        answer +=  (cc * (cc-1) // 2 )

print(answer)



Fixed submission:
# -*- coding: utf-8 -*-
# 
import math
import sys
import itertools
import numpy as np

# なんこか入力
n,m = map(int, input().split())

# 空白区切りの数列をリストに代入
a = [int(i) for i in input().split()]
b = [0]*(n)
c ={0:1}
bb=0
for i in range(0,n) :
    bb = ( bb+a[i] ) % m
    c[bb] = c.get(bb,0) + 1
    
    
answer = 0
#print(c)

for i,j in c.items():
    if j > 1:
        answer +=  (j * (j-1) // 2 )

print(answer)

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
# 
import math
import sys
import itertools
import numpy as np

# なんこか入力
n,m = map(int, input().split())

# 空白区切りの数列をリストに代入
a = [int(i) for i in input().split()]
b = [0]*(n)
c1 = [0]
c2 = [0]
bb=0
c2[0]=1
for i in range(0,n) :
    bb = ( bb+a[i] ) % m
    if bb == 0:
        c2[0] += 1
    else:
        if bb in c1:
            c2[c1.index(bb)] += 1
        else:
            c1.append(bb)
            c2.append(1)
    
    
answer = 0
#print(c1)
#print(c2)
for i in range(0,len(c2)):
    if c2[i] > 1:
        answer +=  (c2[i] * (c2[i]-1) // 2 )

print(answer)



Fixed submission:
# -*- coding: utf-8 -*-
# 
import math
import sys
import itertools
import numpy as np

# なんこか入力
n,m = map(int, input().split())

# 空白区切りの数列をリストに代入
a = [int(i) for i in input().split()]
b = [0]*(n)
c ={0:1}
bb=0
for i in range(0,n) :
    bb = ( bb+a[i] ) % m
    c[bb] = c.get(bb,0) + 1
    
    
answer = 0
#print(c)

for i,j in c.items():
    if j > 1:
        answer +=  (j * (j-1) // 2 )

print(answer)

Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
# 
import math
import sys
import itertools
import numpy as np

# なんこか入力
n,m = map(int, input().split())

# 空白区切りの数列をリストに代入
a = [int(i) for i in input().split()]
b = [0]*(n)
c = [0]*(m)
bb=0
c[0]=1
for i in range(0,n) :
    bb = ( bb+a[i] ) % m
    c[bb] += 1
    
    
answer = 0
#print(c)
for i in range(0,m):
    if c[i] > 1:
        answer +=  (c[i] * (c[i]-1) // 2 )

print(answer)



Fixed submission:
# -*- coding: utf-8 -*-
# 
import math
import sys
import itertools
import numpy as np

# なんこか入力
n,m = map(int, input().split())

# 空白区切りの数列をリストに代入
a = [int(i) for i in input().split()]
b = [0]*(n)
c ={0:1}
bb=0
for i in range(0,n) :
    bb = ( bb+a[i] ) % m
    c[bb] = c.get(bb,0) + 1
    
    
answer = 0
#print(c)

for i,j in c.items():
    if j > 1:
        answer +=  (j * (j-1) // 2 )

print(answer)

Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
# 
import math
import sys
import itertools
import numpy as np

# なんこか入力
n,m = map(int, input().split())

# 空白区切りの数列をリストに代入
a = [int(i) for i in input().split()]
b = [0]*(n)
c = [0]*(m)
bb=0
c[0]=1
for i in range(0,n) :
    bb = ( bb+a[i] ) % m
    c[bb] += 1
    
    
answer = 0
print(c)
for i in range(0,m):
    if c[i] > 1:
        answer +=  (c[i] * (c[i]-1) // 2 )

print(answer)



Fixed submission:
# -*- coding: utf-8 -*-
# 
import math
import sys
import itertools
import numpy as np

# なんこか入力
n,m = map(int, input().split())

# 空白区切りの数列をリストに代入
a = [int(i) for i in input().split()]
b = [0]*(n)
c ={0:1}
bb=0
for i in range(0,n) :
    bb = ( bb+a[i] ) % m
    c[bb] = c.get(bb,0) + 1
    
    
answer = 0
#print(c)

for i,j in c.items():
    if j > 1:
        answer +=  (j * (j-1) // 2 )

print(answer)

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
# 
import math
import sys
import itertools
import numpy as np

# なんこか入力
n,m = map(int, input().split())

# 空白区切りの数列をリストに代入
a = [int(i) for i in input().split()]
b = [0]*(n+1)
bb=0

for i in range(0,n) :
    b[i+1] = bb = ( bb+a[i] ) % m
    
answer = 0
for r in range(1,n+1) :
    for l in range(0,r) :
        if (b[r] - b[l] ) == 0:
            answer += 1

print(answer)



Fixed submission:
# -*- coding: utf-8 -*-
# 
import math
import sys
import itertools
import numpy as np

# なんこか入力
n,m = map(int, input().split())

# 空白区切りの数列をリストに代入
a = [int(i) for i in input().split()]
b = [0]*(n)
c ={0:1}
bb=0
for i in range(0,n) :
    bb = ( bb+a[i] ) % m
    c[bb] = c.get(bb,0) + 1
    
    
answer = 0
#print(c)

for i,j in c.items():
    if j > 1:
        answer +=  (j * (j-1) // 2 )

print(answer)

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
# 
import math
import sys
import itertools
import numpy as np

# なんこか入力
n,m = map(int, input().split())

# 空白区切りの数列をリストに代入
a = [int(i) for i in input().split()]
b = [0]*(n+1)
bb=0

for i in range(0,n) :
    b[i+1] = bb = ( bb+a[i] ) % m
    
answer = 0
for r in range(1,n+1) :
    for l in range(0,r) :
        if (b[r] - b[l] ) % m == 0:
            answer += 1

print(answer)


Fixed submission:
# -*- coding: utf-8 -*-
# 
import math
import sys
import itertools
import numpy as np

# なんこか入力
n,m = map(int, input().split())

# 空白区切りの数列をリストに代入
a = [int(i) for i in input().split()]
b = [0]*(n)
c ={0:1}
bb=0
for i in range(0,n) :
    bb = ( bb+a[i] ) % m
    c[bb] = c.get(bb,0) + 1
    
    
answer = 0
#print(c)

for i,j in c.items():
    if j > 1:
        answer +=  (j * (j-1) // 2 )

print(answer)