Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())
A = (map(lambda s: int(s) % K, input().split()))

counts = [0] * K
counts2 = [0] * K

cumAm1 = [1] 
for i, Ai in enumerate(A):
    cumAm1.append((-1 + cumAm1[-1] + Ai) % K)

for i in range(N + 1):
    if i >= K:
        counts[cumAm1[i - K]] -= 1

    cur = cumAm1[i]
    counts2[cur] += counts[cur]

    counts[cur] += 1

print(sum(counts2))


Fixed submission:
from collections import Counter

N, K = map(int, input().split())
A = list(map(lambda s: int(s) % K, input().split()))

cumAm1 = [1] + A
for i in range(1, N + 1):
    cumAm1[i] = (-1 + cumAm1[i - 1] + cumAm1[i]) % K

counts = Counter()
ans = 0
for i in range(N + 1):

    if i >= K:
        counts[cumAm1[i - K]] -= 1

    cur = cumAm1[i]
    ans += counts[cur]

    counts[cur] += 1

print(ans)

Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())
A = list(map(lambda s: int(s) % K, input().split()))

cumAm1 = [1] + A
for i in range(1, N + 1):
    cumAm1[i] = (-1 + cumAm1[i - 1] + cumAm1[i]) % K

counts = [0] * K
counts2 = [0] * K
for i in range(N + 1):

    if i >= K:
        counts[cumAm1[i - K]] -= 1

    cur = cumAm1[i]
    counts2[cur] += counts[cur]

    counts[cur] += 1

print(sum(counts2))


Fixed submission:
from collections import Counter

N, K = map(int, input().split())
A = list(map(lambda s: int(s) % K, input().split()))

cumAm1 = [1] + A
for i in range(1, N + 1):
    cumAm1[i] = (-1 + cumAm1[i - 1] + cumAm1[i]) % K

counts = Counter()
ans = 0
for i in range(N + 1):

    if i >= K:
        counts[cumAm1[i - K]] -= 1

    cur = cumAm1[i]
    ans += counts[cur]

    counts[cur] += 1

print(ans)

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

cumAm1 = [1] + A
for i in range(1, N + 1):
    cumAm1[i] = (-1 + cumAm1[i - 1] + cumAm1[i]) % K

counts = [0] * K
counts2 = [0] * K
for i in range(N + 1):

    if i >= K:
        counts[cumAm1[i - K]] -= 1

    cur = cumAm1[i]
    counts2[cur] += counts[cur]

    counts[cur] += 1

print(sum(counts2))

Fixed submission:
from collections import Counter

N, K = map(int, input().split())
A = list(map(lambda s: int(s) % K, input().split()))

cumAm1 = [1] + A
for i in range(1, N + 1):
    cumAm1[i] = (-1 + cumAm1[i - 1] + cumAm1[i]) % K

counts = Counter()
ans = 0
for i in range(N + 1):

    if i >= K:
        counts[cumAm1[i - K]] -= 1

    cur = cumAm1[i]
    ans += counts[cur]

    counts[cur] += 1

print(ans)

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

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

# N = 2 * 10 ** 5
# A = [10 ** 9 for i in range(N)]


cumAm1 = np.cumsum(np.array([1] + A) % K - 1) % K

counts = [0] * K
counts2 = [0] * K
for i in range(N + 1):

    if i >= K:
        counts[cumAm1[i - K]] -= 1

    cur = cumAm1[i]
    counts2[cur] += counts[cur]

    counts[cur] += 1

print(sum(counts2))


Fixed submission:
from collections import Counter

N, K = map(int, input().split())
A = list(map(lambda s: int(s) % K, input().split()))

cumAm1 = [1] + A
for i in range(1, N + 1):
    cumAm1[i] = (-1 + cumAm1[i - 1] + cumAm1[i]) % K

counts = Counter()
ans = 0
for i in range(N + 1):

    if i >= K:
        counts[cumAm1[i - K]] -= 1

    cur = cumAm1[i]
    ans += counts[cur]

    counts[cur] += 1

print(ans)

Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())
A = list(map(int, input().split()))
import numpy as np

cumAm1 = np.cumsum(np.array([1] + A) - 1)
cumAm1 %= K

counts = np.zeros(K, dtype=int)
counts2 = np.zeros(K, dtype=int)
for i in range(N + 1):

    if i >= K:
        counts[cumAm1[i - K]] -= 1

    counts2[cumAm1[i]] += counts[cumAm1[i]]

    counts[cumAm1[i]] += 1

print(counts2.sum())


Fixed submission:
from collections import Counter

N, K = map(int, input().split())
A = list(map(lambda s: int(s) % K, input().split()))

cumAm1 = [1] + A
for i in range(1, N + 1):
    cumAm1[i] = (-1 + cumAm1[i - 1] + cumAm1[i]) % K

counts = Counter()
ans = 0
for i in range(N + 1):

    if i >= K:
        counts[cumAm1[i - K]] -= 1

    cur = cumAm1[i]
    ans += counts[cur]

    counts[cur] += 1

print(ans)