Buggy python submission (verdict: Runtime Error):
# encoding: utf-8
N, M = list(map(int, input().split()))

d_sym = {}
sym = 0

# refresh

for A in map(int, input().split()):
    sym = (sym + A) % M
    if str(sym) in d_sym: d_sym[str(sym)] += 1
    else: d_sym[str(sym)] = 1

print(int(d_sym["0"] + sum([val * (val - 1) / 2 for val in d_sym.values()])))

Fixed submission:
# encoding: utf-8
N, M = list(map(int, input().split()))

d_sym = {}
sym = 0

# refresh

ans = 0
for A in map(int, input().split()):
    sym = (sym + A) % M
    #
    if sym == 0: ans += 1
    # 
    if str(sym) in d_sym.keys(): d_sym[str(sym)] += 1
    else: d_sym[str(sym)] = 1

print(int(ans + sum([val * (val - 1) / 2 for val in d_sym.values()])))

Buggy python submission (verdict: Time Limit Exceeded):
# encoding: utf-8
N, M = list(map(int, input().split()))

# TLE
# Amod = [A for A in map(lambda x: int(x) % M , input().split())]
# ans = 0
# for l in range(len(Amod)):
#     acm = 0
#     for r in range(l, len(Amod)):
#         acm = (acm + Amod[r]) % M
#         if acm == 0: ans += 1

# Asym = []

# sym = 0
# cnt_zero = 0
# for i, A in enumerate(map(int, input().split())):
#     sym = (sym + A) % M
#     if sym > 0: Asym.append(sym)
#     else: cnt_zero += 1
    
# ans = cnt_zero * (cnt_zero + 1)
# for sym in set(Asym):
#     Asym.remove(sym)

# for sym in set(Asym):
#     cnt = Asym.count(sym)
#     ans += cnt * (cnt + 1)
        
# print(int(ans / 2))

Acnt = [0 for i in range(M)]
sym = 0

for A in map(int, input().split()):
    sym = (sym + A) % M
    Acnt[sym] += 1

print(int(Acnt[0] + sum([Acnt.count(i) * i * (i - 1) for i in range(1 + max(Acnt))]) / 2))

Fixed submission:
# encoding: utf-8
N, M = list(map(int, input().split()))

d_sym = {}
sym = 0

# refresh

ans = 0
for A in map(int, input().split()):
    sym = (sym + A) % M
    #
    if sym == 0: ans += 1
    # 
    if str(sym) in d_sym.keys(): d_sym[str(sym)] += 1
    else: d_sym[str(sym)] = 1

print(int(ans + sum([val * (val - 1) / 2 for val in d_sym.values()])))

Buggy python submission (verdict: Time Limit Exceeded):
# encoding: utf-8
N, M = list(map(int, input().split()))

# TLE
# Amod = [A for A in map(lambda x: int(x) % M , input().split())]
# ans = 0
# for l in range(len(Amod)):
#     acm = 0
#     for r in range(l, len(Amod)):
#         acm = (acm + Amod[r]) % M
#         if acm == 0: ans += 1

Asym = []

sym = 0
cnt_zero = 0
for i, A in enumerate(map(int, input().split())):
    sym = (sym + A) % M
    if sym > 0: Asym.append(sym)
    else: cnt_zero += 1
    
ans = cnt_zero * (cnt_zero + 1)
for sym in set(Asym):
    Asym.remove(sym)

for sym in set(Asym):
    cnt = Asym.count(sym)
    ans += cnt * (cnt + 1)
        
print(int(ans / 2))

Fixed submission:
# encoding: utf-8
N, M = list(map(int, input().split()))

d_sym = {}
sym = 0

# refresh

ans = 0
for A in map(int, input().split()):
    sym = (sym + A) % M
    #
    if sym == 0: ans += 1
    # 
    if str(sym) in d_sym.keys(): d_sym[str(sym)] += 1
    else: d_sym[str(sym)] = 1

print(int(ans + sum([val * (val - 1) / 2 for val in d_sym.values()])))

Buggy python submission (verdict: Time Limit Exceeded):
# encoding: utf-8
N, M = list(map(int, input().split()))

# TLE
# Amod = [A for A in map(lambda x: int(x) % M , input().split())]
# ans = 0
# for l in range(len(Amod)):
#     acm = 0
#     for r in range(l, len(Amod)):
#         acm = (acm + Amod[r]) % M
#         if acm == 0: ans += 1

Asym = []

sym = 0
cnt_zero = 0
for i, A in enumerate(map(int, input().split())):
    sym = (sym + A) % M
    if sym > 0: Asym.append(sym)
    else: cnt_zero += 1
        
ans = cnt_zero * (cnt_zero + 1)
for sym in set(Asym):
    cnt = Asym.count(sym)
    ans += cnt * (cnt -  1)
        
print(int(ans / 2))

# Acnt = [0 for i in range(M)]
# sym = 0
# for A in map(int, input().split()):
#     sym = (sym + A) % M
#     Acnt[sym] += 1

# print(int(Acnt[0] + sum([cnt * (cnt - 1) for cnt in Acnt]) / 2))

Fixed submission:
# encoding: utf-8
N, M = list(map(int, input().split()))

d_sym = {}
sym = 0

# refresh

ans = 0
for A in map(int, input().split()):
    sym = (sym + A) % M
    #
    if sym == 0: ans += 1
    # 
    if str(sym) in d_sym.keys(): d_sym[str(sym)] += 1
    else: d_sym[str(sym)] = 1

print(int(ans + sum([val * (val - 1) / 2 for val in d_sym.values()])))

Buggy python submission (verdict: Time Limit Exceeded):
# encoding: utf-8
N, M = list(map(int, input().split()))

# TLE
# Amod = [A for A in map(lambda x: int(x) % M , input().split())]
# ans = 0
# for l in range(len(Amod)):
#     acm = 0
#     for r in range(l, len(Amod)):
#         acm = (acm + Amod[r]) % M
#         if acm == 0: ans += 1

if N < M:

    Asym = [0 for i in range(N)]
    sym = 0
    for i, A in enumerate(map(int, input().split())):
        sym = (sym + A) % M
        Asym[i] = sym
    
    ans = Asym.count(0)
    for sym in set(Asym):
        cnt = Asym.count(sym)
        ans +=  int(cnt * (cnt -  1) / 2)
    
    print(ans)

else:

    Acnt = [0 for i in range(M)]
    sym = 0
    for A in map(int, input().split()):
        sym = (sym + A) % M
        Acnt[sym] += 1

    print(int(Acnt[0] + sum([cnt * (cnt - 1) for cnt in Acnt]) / 2))

Fixed submission:
# encoding: utf-8
N, M = list(map(int, input().split()))

d_sym = {}
sym = 0

# refresh

ans = 0
for A in map(int, input().split()):
    sym = (sym + A) % M
    #
    if sym == 0: ans += 1
    # 
    if str(sym) in d_sym.keys(): d_sym[str(sym)] += 1
    else: d_sym[str(sym)] = 1

print(int(ans + sum([val * (val - 1) / 2 for val in d_sym.values()])))

Buggy python submission (verdict: Time Limit Exceeded):
# encoding: utf-8
N, M = list(map(int, input().split()))

# TLE
# Amod = [A for A in map(lambda x: int(x) % M , input().split())]
# ans = 0
# for l in range(len(Amod)):
#     acm = 0
#     for r in range(l, len(Amod)):
#         acm = (acm + Amod[r]) % M
#         if acm == 0: ans += 1
import array

Asym = array.array('I', [0 for i in range(N)])
sym = 0
for i, A in enumerate(map(int, input().split())):
    sym = (sym + A) % M
    Asym[i] = sym
    
ans = Asym.count(0)
for sym in set(Asym):
    cnt = Asym.count(sym)
    ans +=  int(cnt * (cnt -  1) / 2)
    
print(ans)

# print(int(Asym.count(0) + sum([Asym.count(sym) * (Asym.count(sym) - 1) for sym in set(Asym)]) / 2))

# Acnt = [0 for i in range(M)]
# sym = 0
# for A in map(int, input().split()):
#     sym = (sym + A) % M
#     Acnt[sym] += 1

# print(int(Acnt[0] + sum([cnt * (cnt - 1) for cnt in Acnt]) / 2))

Fixed submission:
# encoding: utf-8
N, M = list(map(int, input().split()))

d_sym = {}
sym = 0

# refresh

ans = 0
for A in map(int, input().split()):
    sym = (sym + A) % M
    #
    if sym == 0: ans += 1
    # 
    if str(sym) in d_sym.keys(): d_sym[str(sym)] += 1
    else: d_sym[str(sym)] = 1

print(int(ans + sum([val * (val - 1) / 2 for val in d_sym.values()])))

Buggy python submission (verdict: Time Limit Exceeded):
# encoding: utf-8
N, M = list(map(int, input().split()))

# TLE
# Amod = [A for A in map(lambda x: int(x) % M , input().split())]
# ans = 0
# for l in range(len(Amod)):
#     acm = 0
#     for r in range(l, len(Amod)):
#         acm = (acm + Amod[r]) % M
#         if acm == 0: ans += 1

Asym = [0 for i in range(N)]
sym = 0
for i, A in enumerate(map(int, input().split())):
    sym = (sym + A) % M
    Asym[i] += sym
    
# ans = Asym.count(0)
# for sym in set(Asym):
#     cnt = Asym.count(sym)
#     ans +=  int(cnt * (cnt -  1) / 2)
    
# print(ans)
print(int(Asym.count(0) + sum([Asym.count(sym) * (Asym.count(sym) - 1) for sym in set(Asym)]) / 2))

# Acnt = [0 for i in range(M)]
# sym = 0
# for A in map(int, input().split()):
#     sym = (sym + A) % M
#     Acnt[sym] += 1

# print(int(Acnt[0] + sum([cnt * (cnt - 1) for cnt in Acnt]) / 2))


Fixed submission:
# encoding: utf-8
N, M = list(map(int, input().split()))

d_sym = {}
sym = 0

# refresh

ans = 0
for A in map(int, input().split()):
    sym = (sym + A) % M
    #
    if sym == 0: ans += 1
    # 
    if str(sym) in d_sym.keys(): d_sym[str(sym)] += 1
    else: d_sym[str(sym)] = 1

print(int(ans + sum([val * (val - 1) / 2 for val in d_sym.values()])))

Buggy python submission (verdict: Time Limit Exceeded):
# encoding: utf-8
N, M = list(map(int, input().split()))

# TLE
# Amod = [A for A in map(lambda x: int(x) % M , input().split())]
# ans = 0
# for l in range(len(Amod)):
#     acm = 0
#     for r in range(l, len(Amod)):
#         acm = (acm + Amod[r]) % M
#         if acm == 0: ans += 1

Asym = [0 for i in range(N)]
sym = 0
for i, A in enumerate(map(int, input().split())):
    sym = (sym + A) % M
    Asym[i] += sym
    
ans = Asym.count(0)
for sym in set(Asym):
    cnt = Asym.count(sym)
    ans +=  int(cnt * (cnt -  1) / 2)

print(ans)

# Acnt = [0 for i in range(M)]
# sym = 0
# for A in map(int, input().split()):
#     sym = (sym + A) % M
#     Acnt[sym] += 1

# print(int(Acnt[0] + sum([cnt * (cnt - 1) for cnt in Acnt]) / 2))

Fixed submission:
# encoding: utf-8
N, M = list(map(int, input().split()))

d_sym = {}
sym = 0

# refresh

ans = 0
for A in map(int, input().split()):
    sym = (sym + A) % M
    #
    if sym == 0: ans += 1
    # 
    if str(sym) in d_sym.keys(): d_sym[str(sym)] += 1
    else: d_sym[str(sym)] = 1

print(int(ans + sum([val * (val - 1) / 2 for val in d_sym.values()])))

Buggy python submission (verdict: Time Limit Exceeded):
# encoding: utf-8
N, M = list(map(int, input().split()))

# TLE
# Amod = [A for A in map(lambda x: int(x) % M , input().split())]
# ans = 0
# for l in range(len(Amod)):
#     acm = 0
#     for r in range(l, len(Amod)):
#         acm = (acm + Amod[r]) % M
#         if acm == 0: ans += 1

# Asym = []
# sym = 0
# for A in map(int, input().split()):
#     sym = (sym + A) % M
#     Asym.append(sym)
# print(Asym)
    
# ans = Asym.count(0)
# for sym in set(Asym):
#     cnt = Asym.count(sym)
#     ans +=  int(cnt * (cnt -  1) / 2)

# print(ans)

Acnt = [0 for i in range(M)]
sym = 0
for A in map(int, input().split()):
    sym = (sym + A) % M
    Acnt[sym] += 1

print(int(Acnt[0] + sum([cnt * (cnt - 1) for cnt in Acnt]) / 2))


Fixed submission:
# encoding: utf-8
N, M = list(map(int, input().split()))

d_sym = {}
sym = 0

# refresh

ans = 0
for A in map(int, input().split()):
    sym = (sym + A) % M
    #
    if sym == 0: ans += 1
    # 
    if str(sym) in d_sym.keys(): d_sym[str(sym)] += 1
    else: d_sym[str(sym)] = 1

print(int(ans + sum([val * (val - 1) / 2 for val in d_sym.values()])))

Buggy python submission (verdict: Time Limit Exceeded):
# encoding: utf-8
N, M = list(map(int, input().split()))

# TLE
# Amod = [A for A in map(lambda x: int(x) % M , input().split())]
# ans = 0
# for l in range(len(Amod)):
#     acm = 0
#     for r in range(l, len(Amod)):
#         acm = (acm + Amod[r]) % M
#         if acm == 0: ans += 1

Asym = []
append = Asym.append
count = Asym.count

sym = 0
for A in map(int, input().split()):
    sym = (sym + A) % M
    append(sym)
# print(Asym)
    
ans = count(0)
for sym in set(Asym):
    cnt = count(sym)
    ans +=  int(cnt * (cnt -  1) / 2)

print(ans)


Fixed submission:
# encoding: utf-8
N, M = list(map(int, input().split()))

d_sym = {}
sym = 0

# refresh

ans = 0
for A in map(int, input().split()):
    sym = (sym + A) % M
    #
    if sym == 0: ans += 1
    # 
    if str(sym) in d_sym.keys(): d_sym[str(sym)] += 1
    else: d_sym[str(sym)] = 1

print(int(ans + sum([val * (val - 1) / 2 for val in d_sym.values()])))

Buggy python submission (verdict: Time Limit Exceeded):
# encoding: utf-8
N, M = list(map(int, input().split()))

# TLE
# Amod = [A for A in map(lambda x: int(x) % M , input().split())]
# ans = 0
# for l in range(len(Amod)):
#     acm = 0
#     for r in range(l, len(Amod)):
#         acm = (acm + Amod[r]) % M
#         if acm == 0: ans += 1

Asym = []
sym = 0
for A in map(int, input().split()):
    sym = (sym + A) % M
    Asym.append(sym)
# print(Asym)
    
ans = Asym.count(0)
for sym in set(Asym):
    cnt = Asym.count(sym)
    ans +=  int(cnt * (cnt -  1) / 2)

print(ans)


Fixed submission:
# encoding: utf-8
N, M = list(map(int, input().split()))

d_sym = {}
sym = 0

# refresh

ans = 0
for A in map(int, input().split()):
    sym = (sym + A) % M
    #
    if sym == 0: ans += 1
    # 
    if str(sym) in d_sym.keys(): d_sym[str(sym)] += 1
    else: d_sym[str(sym)] = 1

print(int(ans + sum([val * (val - 1) / 2 for val in d_sym.values()])))

Buggy python submission (verdict: Time Limit Exceeded):
# encoding: utf-8
N, M = list(map(int, input().split()))

# TLE
# Amod = [A for A in map(lambda x: int(x) % M , input().split())]
# ans = 0
# for l in range(len(Amod)):
#     acm = 0
#     for r in range(l, len(Amod)):
#         acm = (acm + Amod[r]) % M
#         if acm == 0: ans += 1

for i, A in enumerate(map(int, input().split())):
    if i == 0: Asym = [A % M]
    else: Asym.append((Asym[-1] + A) % M)
# print(Asym)
    
ans = Asym.count(0)
for sym in set(filter(lambda x: Asym.count(x) > 0, Asym)):
    # print(sym, Asym.count(sym), ans)
    cnt = Asym.count(sym)
    ans +=  int(cnt * (cnt -  1) / 2)

print(ans)


Fixed submission:
# encoding: utf-8
N, M = list(map(int, input().split()))

d_sym = {}
sym = 0

# refresh

ans = 0
for A in map(int, input().split()):
    sym = (sym + A) % M
    #
    if sym == 0: ans += 1
    # 
    if str(sym) in d_sym.keys(): d_sym[str(sym)] += 1
    else: d_sym[str(sym)] = 1

print(int(ans + sum([val * (val - 1) / 2 for val in d_sym.values()])))

Buggy python submission (verdict: Time Limit Exceeded):
# encoding: utf-8
N, M = list(map(int, input().split()))

# TLE
# Amod = [A for A in map(lambda x: int(x) % M , input().split())]
# ans = 0
# for l in range(len(Amod)):
#     acm = 0
#     for r in range(l, len(Amod)):
#         acm = (acm + Amod[r]) % M
#         if acm == 0: ans += 1

for i, A in enumerate(map(int, input().split())):
    if i == 0: Asym = [A % M]
    else: Asym.append((Asym[-1] + A) % M)
# print(Asym)
    
ans = Asym.count(0)
for sym in set(Asym):
    # print(sym, Asym.count(sym), ans)
    cnt = Asym.count(sym)
    ans +=  int(cnt * (cnt -  1) / 2)

print(ans)



Fixed submission:
# encoding: utf-8
N, M = list(map(int, input().split()))

d_sym = {}
sym = 0

# refresh

ans = 0
for A in map(int, input().split()):
    sym = (sym + A) % M
    #
    if sym == 0: ans += 1
    # 
    if str(sym) in d_sym.keys(): d_sym[str(sym)] += 1
    else: d_sym[str(sym)] = 1

print(int(ans + sum([val * (val - 1) / 2 for val in d_sym.values()])))

Buggy python submission (verdict: Time Limit Exceeded):
# encoding: utf-8
N, M = list(map(int, input().split()))

# TLE
Amod = [A for A in map(lambda x: int(x) % M , input().split())]
ans = 0
for l in range(len(Amod)):
    acm = 0
    for r in range(l, len(Amod)):
        acm = (acm + Amod[r]) % M
        if acm == 0: ans += 1

print(ans)

Fixed submission:
# encoding: utf-8
N, M = list(map(int, input().split()))

d_sym = {}
sym = 0

# refresh

ans = 0
for A in map(int, input().split()):
    sym = (sym + A) % M
    #
    if sym == 0: ans += 1
    # 
    if str(sym) in d_sym.keys(): d_sym[str(sym)] += 1
    else: d_sym[str(sym)] = 1

print(int(ans + sum([val * (val - 1) / 2 for val in d_sym.values()])))

Buggy python submission (verdict: Time Limit Exceeded):
# encoding: utf-8
N, M = list(map(int, input().split()))
Amod = [A for A in map(lambda x: int(x) % M ,filter(lambda x: int(x) > 0, input().split()))]

ans = 0
for l in range(len(Amod)):
    acm = 0
    for r in range(l, len(Amod)):
        acm = (acm + Amod[r]) % M
        if acm == 0: ans += 1

print(ans)

Fixed submission:
# encoding: utf-8
N, M = list(map(int, input().split()))

d_sym = {}
sym = 0

# refresh

ans = 0
for A in map(int, input().split()):
    sym = (sym + A) % M
    #
    if sym == 0: ans += 1
    # 
    if str(sym) in d_sym.keys(): d_sym[str(sym)] += 1
    else: d_sym[str(sym)] = 1

print(int(ans + sum([val * (val - 1) / 2 for val in d_sym.values()])))

Buggy python submission (verdict: Time Limit Exceeded):
# encoding: utf-8
N, M = list(map(int, input().split()))
Amod = [int(A) % M for A in filter(lambda x: int(x) > 0, input().split())]

ans = 0
for l in range(len(Amod)):
    acm = 0
    for r in range(l, len(Amod)):
        acm = (acm + Amod[r]) % M
        if acm == 0: ans += 1

print(ans)

Fixed submission:
# encoding: utf-8
N, M = list(map(int, input().split()))

d_sym = {}
sym = 0

# refresh

ans = 0
for A in map(int, input().split()):
    sym = (sym + A) % M
    #
    if sym == 0: ans += 1
    # 
    if str(sym) in d_sym.keys(): d_sym[str(sym)] += 1
    else: d_sym[str(sym)] = 1

print(int(ans + sum([val * (val - 1) / 2 for val in d_sym.values()])))

Buggy python submission (verdict: Time Limit Exceeded):
# encoding: utf-8
N, M = list(map(int, input().split()))
Amod = [int(A) % M for A in input().split()]

ans = 0
for l in range(N):
    acm = 0
    for r in range(l, N):
        acm = (acm + Amod[r]) % M
        if acm == 0: ans += 1

print(ans)

Fixed submission:
# encoding: utf-8
N, M = list(map(int, input().split()))

d_sym = {}
sym = 0

# refresh

ans = 0
for A in map(int, input().split()):
    sym = (sym + A) % M
    #
    if sym == 0: ans += 1
    # 
    if str(sym) in d_sym.keys(): d_sym[str(sym)] += 1
    else: d_sym[str(sym)] = 1

print(int(ans + sum([val * (val - 1) / 2 for val in d_sym.values()])))