Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
def dsum(n):
    ret = 0
    while n > 0:
        ret += n % 10
        n //= 10
    return ret


def g(n):
    return n / dsum(n)

K = int(input())

res = []
base = 1
for i in range(15):
    for j in range(1, 150):
        res.append(base * (j + 1) - 1)
    base *= 10

res.sort()
res = list(set(res))

ans = []
print(res[:20])
for i, r in enumerate(res):
    flag = true
    for j in range(i + 1, len(res)):
        if g(r) > g(res[j]):
            flag = False
            break
    if flag:
        ans.append(r)

for k in range(K):
    print(ans[k])


Fixed submission:
K = int(input())


def dsum(n):
    return sum(list(map(int, str(n))))


def g(n):
    return n / dsum(n)

j = 1
order = 1
for i in range(K):
    print(j)
    if g(j + 10 ** (order - 1)) > g(j + 10 ** order):
        order += 1
    j += 10 ** (order - 1)
Buggy python submission (verdict: Runtime Error):
def calc(x, base):
    res = 0
    while x:
        x, m = divmod(x, base)
        res += m
    return res

ans = min(calc(i, 6) + calc(N - i, 9) for i in range(N + 1))

print(ans)

Fixed submission:
def calc(x, base):
    res = 0
    while x:
        x, m = divmod(x, base)
        res += m
    return res


def main():
    N = int(input())
    ans = min(calc(i, 6) + calc(N - i, 9) for i in range(N + 1))
    print(ans)


main()

Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(100000)

MAXN = 100001
memo = [-1] * MAXN


def rec_bank(n):
    ret = n
    if n == 0:
        return 0
    if memo[n] != -1:
        return memo[n]

    pow6 = 1
    while(pow6 <= n):
        ret = min(ret, rec_bank(n - pow6) + 1)
        pow6 *= 6
    pow9 = 1
    while(pow9 <= n):
        ret = min(ret, rec_bank(n - pow9) + 1)
        pow9 *= 9
    memo[n] = ret
    return ret


def main():
    N = int(input())
    print(rec_bank(N))

main()

Fixed submission:
def calc(x, base):
    res = 0
    while x:
        x, m = divmod(x, base)
        res += m
    return res


def main():
    N = int(input())
    ans = min(calc(i, 6) + calc(N - i, 9) for i in range(N + 1))
    print(ans)


main()
Buggy python submission (verdict: Runtime Error):
import itertools
import sys
input = sys.stdin.readline()


def main():
    N, C = map(int, input().split())
    D = [list(map(int, input().split())) for _ in range(C)]
    CC = [list(map(lambda x: int(x) - 1, input().split())) for _ in range(N)]

    cost = [[0 for _ in range(C)] for _ in range(3)]
    for c in range(C):
        for i in range(N):
            for j in range(N):
                cost[(i + j) % 3][c] += D[CC[i][j]][c]

    res = float("inf")
    color = [i for i in range(C)]
    for i, c in enumerate(list(itertools.permutations(color, 3))):
        tmp = 0
        for it in range(3):
            tmp += cost[it][c[it]]
        res = min(res, tmp)

    print(res)

main()

Fixed submission:
import itertools


def main():
    N, C = map(int, input().split())
    D = [list(map(int, input().split())) for _ in range(C)]
    CC = [list(map(lambda x: int(x) - 1, input().split())) for _ in range(N)]

    cost = [[0 for _ in range(C)] for _ in range(3)]
    for c in range(C):
        for i in range(N):
            for j in range(N):
                cost[(i + j) % 3][c] += D[CC[i][j]][c]

    res = float("inf")
    color = [i for i in range(C)]
    for i, c in enumerate(list(itertools.permutations(color, 3))):
        tmp = 0
        for it in range(3):
            tmp += cost[it][c[it]]
        res = min(res, tmp)

    print(res)

main()

Buggy python submission (verdict: Runtime Error):
import itertools
import sys
input = sys.input.readline()


def main():
    N, C = map(int, input().split())
    D = [list(map(int, input().split())) for _ in range(C)]
    CC = [list(map(lambda x: int(x) - 1, input().split())) for _ in range(N)]

    cost = [[0 for _ in range(C)] for _ in range(3)]
    for c in range(C):
        for i in range(N):
            for j in range(N):
                cost[(i + j) % 3][c] += D[CC[i][j]][c]

    res = float("inf")
    color = [i for i in range(C)]
    for i, c in enumerate(list(itertools.permutations(color, 3))):
        tmp = 0
        for it in range(3):
            tmp += cost[it][c[it]]
        res = min(res, tmp)

    print(res)

main()


Fixed submission:
import itertools


def main():
    N, C = map(int, input().split())
    D = [list(map(int, input().split())) for _ in range(C)]
    CC = [list(map(lambda x: int(x) - 1, input().split())) for _ in range(N)]

    cost = [[0 for _ in range(C)] for _ in range(3)]
    for c in range(C):
        for i in range(N):
            for j in range(N):
                cost[(i + j) % 3][c] += D[CC[i][j]][c]

    res = float("inf")
    color = [i for i in range(C)]
    for i, c in enumerate(list(itertools.permutations(color, 3))):
        tmp = 0
        for it in range(3):
            tmp += cost[it][c[it]]
        res = min(res, tmp)

    print(res)

main()
Buggy python submission (verdict: Runtime Error):
from math import factorial
N = int(input())
A = sorted(list(map(int, input().split())))
ret = []

pos = 1
maxn = 0
for i, a in enumerate(A):
    if a == 0:
        maxn = 1
        ans = (a, A[pos])
        continue
    minn = [abs(A[pos] / a - 2), (a, A[pos])]
    while pos < N:
        if minn[0] < abs(A[pos] / a - 2):
            break
        minn[0] = abs(A[pos] / a - 2)
        pos += 1
    if maxn < factorial(minn[1][1]) / factorial(minn[1][0]):
        maxn = factorial(minn[1][1]) / factorial(minn[1][0])
        ans = minn[1]
    if i == pos:
        pos += 1
    if pos >= N:
        break
print(ans[1], ans[0])


Fixed submission:
N = int(input())
A = sorted(list(map(int, input().split())))
y = A.pop(-1)
print(y, min(A, key=lambda x: abs(y - 2 * x)))
Buggy python submission (verdict: Time Limit Exceeded):
A, B, K = map(int, input().split())
for i in range(A, B + 1):
    if i - A < K or B - i < K:
        print(i)


Fixed submission:
A, B, K = map(int, input().split())
ret = range(A, B + 1)
for i in sorted(set(ret[:K]) | set(ret[-K:])):
    print(i)
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = [0] + list(map(int, input().split())) + [0]
cost = []
for i in range(N + 1):
    cost.append(abs(A[i + 1] - A[i]))
scost = sum(cost)
for i in range(N):
    print(S - cost[i] - cost[i + 1] + abs(A[i + 2] - A[i]))


Fixed submission:
N = int(input())
A = [0] + list(map(int, input().split())) + [0]
cost = []
for i in range(N + 1):
    cost.append(abs(A[i + 1] - A[i]))
scost = sum(cost)
for i in range(N):
    print(scost - cost[i] - cost[i + 1] + abs(A[i + 2] - A[i]))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list( map(int, input().split()) )

res = 0
pair = []
for i in range(N):
    if A[A[i] - 1] - 1 == i and sorted([i, A[i] - 1]) not in pair:
        res += 1
        pair.append([i, A[i] - 1])

print(res)


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

res = 0
for i in range(N):
    if A[A[i] - 1] - 1 == i:
        res += 1

print(res // 2)
Buggy python submission (verdict: Runtime Error):
#include <iostream>
#include <map>
#include <string>
using namespace std;

int main() {
  string w;
  cin >> w;

  map<char, int> count;
  for (auto s : w) {
    count[s] += 1;
  }
  for (auto itr = count.begin(); itr != count.end(); itr++) {
    if (itr->second % 2 == 1) {
      cout << "No" << endl;
      return 0;
    }
  }

  cout << "Yes" << endl;
  return 0;
}


Fixed submission:
import collections

w = input()
c = collections.Counter(w)
if all(i % 2 == 0 for i in c.values()):
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Time Limit Exceeded):
N, A = map(int, input().split())
# X = list(map(lambda x: int(x) - A, input().split()))
X = list(map(int, input().split()))
maxn = max(max(X), A)

dp = [[[0 for _ in range(maxn * N + 1)] for _ in range(N + 1)] for _ in range(N + 1)]
dp[0][0][0] = 1

for i in range(N):
    for j in range(i + 1):
        for k in range((i + 1) * maxn + 1):
            dp[i + 1][j][k] += dp[i][j][k]
            if k >= X[i]:
                dp[i + 1][j + 1][k] += dp[i][j][k - X[i]]

ans = 0
for j in range(1, N + 1):
    ans += dp[N][j][j * A]

print(ans)


Fixed submission:
N, A = map(int, input().split())
X = list(map(lambda x: int(x) - A, input().split()))
maxn = max(max(X), A)

dp = [[0 for _ in range(2 * N * maxn + 1)] for _ in range(N + 1)]
dp[0][N * maxn] = 1

for i in range(N):
    for k in range(2 * N * maxn + 1):
        dp[i + 1][k] = dp[i][k]
        if 0 <= k - X[i] <= 2 * N * maxn:
            dp[i + 1][k] += dp[i][k - X[i]]

print(dp[N][N * maxn] - 1)

Buggy python submission (verdict: Runtime Error):
N, A = map(int, input().split())
# X = list(map(lambda x: int(x) - A, input().split()))
X = list(map(int, input().split()))

dp = [[[0 for _ in range(max(X) * N + 1)] for _ in range(N + 1)] for _ in range(N + 1)]
dp[0][0][0] = 1

for i in range(N):
    for j in range(N):
        for k in range(max(X) * N + 1):
            dp[i + 1][j][k] += dp[i][j][k]
            if k >= X[i]:
                dp[i + 1][j + 1][k] += dp[i][j][k - X[i]]

ans = 0
for j in range(1, N + 1):
    ans += dp[N][j][j * A]

print(ans)


Fixed submission:
N, A = map(int, input().split())
X = list(map(lambda x: int(x) - A, input().split()))
maxn = max(max(X), A)

dp = [[0 for _ in range(2 * N * maxn + 1)] for _ in range(N + 1)]
dp[0][N * maxn] = 1

for i in range(N):
    for k in range(2 * N * maxn + 1):
        dp[i + 1][k] = dp[i][k]
        if 0 <= k - X[i] <= 2 * N * maxn:
            dp[i + 1][k] += dp[i][k - X[i]]

print(dp[N][N * maxn] - 1)
Buggy python submission (verdict: Runtime Error):
import math
const MOD = 1000000007


def comb(n, r):
    return math.factorial(n) // (math.factorial(r) * math.factorial(n - r))


def main():
    H, W, A, B = map(int, input().split())
    nr = 0
    for i in range(1, N - A + 1):
        nr = nr + comb(i - 1, B + i - 2) * comb(m - b - 1, m + n - b - i - 1) % MOD
    print(nr % MOD)

main()

Fixed submission:
import math
MOD = 10 ** 9 + 7
H, W, A, B = map(int, input().split())
maxf = H + W

f, invf = [1] * maxf, [1] * maxf

for i in range(1, maxf):
    f[i] = i * f[i - 1] % MOD
invf[maxf - 1] = pow(f[maxf - 1], MOD - 2, MOD)
for i in range(maxf - 1, 0, -1):
    invf[i - 1] = invf[i] * i % MOD

comb = lambda a, b: f[a + b] * invf[a] * invf[b] % MOD

ans = 0
for x in range(B, W):
    ans += comb(x, H - A - 1) * comb(W - 1 - x, A - 1) % MOD
print(ans % MOD)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
xl, yl = [], []
for _ in range(n):
    x, y = map(int, input().split())
    xl.append(x)
    yl.append(y)
xl_ = xl.copy()
yl_ = yl.copy()
xl_.sort()
yl_.sort()
xm = xl_[n//2-1]
ans = 0
for k in range(min(n, 1000)):
    ym = yl[k]
    ans1, ans2, ans3, ans4 = 0, 0, 0, 0
    for i in range(n):
        if xl[i] > xm:
            if yl[i] > ym:
                ans1 = max(ans1, abs(xl[i]-xm)+abs(yl[i]-ym))
            else:
                ans4 = max(ans4, abs(xl[i]-xm)+abs(yl[i]-ym))
        else:
            if yl[i] > ym:
                ans2 = max(ans2, abs(xl[i]-xm)+abs(yl[i]-ym))
            else:
                ans3 = max(ans3, abs(xl[i]-xm)+abs(yl[i]-ym))
ans = int(max(abs(ans1+ans3), abs(ans2+ans4)))

print(ans)





Fixed submission:
n = int(input())
xy = [list(map(int, input().split())) for _ in range(n)]
f0 = sorted([x+y for x, y in xy])
f1 = sorted([x-y for x, y in xy])
print(max(f0[-1]-f0[0], f1[-1]-f1[0]))
Buggy python submission (verdict: Runtime Error):
class UnionFind:
    def __init__(self, size):
        self.par = [-1] * size
        
    def find(self, x):
        if self.par[x] < 0:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def unite(self, x, y):
        x, y = self.find(x), self.find(y)
        if x == y: return False
        if self.par[x] > self.par[y]:
            x, y = y, x
        self.par[x] += self.par[y]
        self.par[y] = x
        return True

    def same(self, x, y):
        return self.find(x) == self.find(y)
    
    def size(self, x):
        return -self.par[self.find(x)]

N, Q = map(int, input().split())
uf = Unionfind(N)
for _ in range(Q):
    t, u, v = map(int, input().split())
    if t == 0:
        uf.unite(u, v)
    else:
        if uf.same(u, v):
            print(1)
        else:
            print(0)

Fixed submission:
def find(x):
    if par[x] < 0:
        return x
    else:
        par[x] = find(par[x])
        return par[x]

def unite(x, y):
    x, y = find(x), find(y)
    if x == y: return False
    if par[x] > par[y]:
        x, y = y, x
    par[x] += par[y]
    par[y] = x
    return True

N, Q = map(int, input().split())
par = [-1]*N
for _ in range(Q):
    t, u, v = map(int, input().split())
    if t == 0:
        unite(u, v)
    else:
        if find(u)==find(v):
            print(1)
        else:
            print(0)
Buggy python submission (verdict: Runtime Error):
import sys
n = int(input())
a = list(map(int, input().split()))

def prime_decomposition(n):
    i = 2
    table = []
    while i**2 <= n:
        while n % i == 0:
            n //= i
            table.append(i)
        i += 1
    if n > 1: table.append(n)
    return set(table)

pri_0 = prime_decomposition(a[0])
pri_1 = prime_decomposition(a[1])

if len(pri_0&pri_1):
    for i in range(2, n):
        res = prime_decomposition(a[i])
        ans &= res
        if not ans:
            print('setwise coprime')
            sys.exit()
    print('not coprime')

else:
    ans = pri_0 | pri_1
    for i in range(2, n):
        res = prime_decomposition(a[i])
        for i in res:
            if i in ans:
                print('setwise coprime')
                sys.exit()
        ans |= res
    print('pairwise coprime')

Fixed submission:
import sys
n = int(input())
a = list(map(int, input().split()))

def prime_decomposition(n):
    i = 2
    table = []
    while i**2 <= n:
        while n % i == 0:
            n //= i
            table.append(i)
        i += 1
    if n > 1: table.append(n)
    return set(table)

pri_0 = prime_decomposition(a[0])
pri_1 = prime_decomposition(a[1])
ans = pri_0&pri_1

if len(ans):
    for i in range(2, n):
        res = prime_decomposition(a[i])
        ans &= res
        if not ans:
            print('setwise coprime')
            sys.exit()
    print('not coprime')

else:
    ans = pri_0 | pri_1
    for i in range(2, n):
        res = prime_decomposition(a[i])
        for i in res:
            if i in ans:
                print('setwise coprime')
                sys.exit()
        ans |= res
    print('pairwise coprime')
Buggy python submission (verdict: Time Limit Exceeded):
R, C, K = map(int, input().split())
item = [[0]*C for _ in range(R)]
for _ in range(K):
    r, c, v = map(int, input().split())
    item[r-1][c-1] = v
dp = [[[0]*C for _ in range(R)] for _ in range(4)]

dp[1][0][0] = item[0][0]

for h in range(R):
    for w in range(C):
        for k in range(4):
            if h!=0:
                dp[0][h][w] = max(dp[0][h][w], dp[k][h-1][w])
                dp[1][h][w] = max(dp[1][h][w], dp[k][h-1][w]+item[h][w])
            if w!=0:
                dp[k][h][w] = max(dp[k][h][w], dp[k][h][w-1])
                if k==0: continue
                dp[k][h][w] = max(dp[k][h][w], dp[k-1][h][w-1]+item[h][w])
ans = []
for k in range(4):
    ans.append(dp[k][-1][-1])
print(max(ans))

Fixed submission:
R, C, K = map(int, input().split())
item = [[0]*C for _ in range(R)]
for _ in range(K):
    r, c, v = map(int, input().split())
    item[r-1][c-1] = v
dp = [[[0]*C for _ in range(R)] for _ in range(4)]
dp[1][0][0] = item[0][0]

for h in range(R):
    for w in range(C):
        if h!=0:
            dp[0][h][w] = max(dp[0][h][w], dp[0][h-1][w], dp[1][h-1][w],  dp[2][h-1][w],  dp[3][h-1][w])
            dp[1][h][w] = max(dp[1][h][w], dp[0][h-1][w]+item[h][w], dp[1][h-1][w]+item[h][w], dp[2][h-1][w]+item[h][w], dp[3][h-1][w]+item[h][w])
        if w!=0:
            dp[0][h][w] = max(dp[0][h][w], dp[0][h][w-1])
            dp[1][h][w] = max(dp[1][h][w], dp[1][h][w-1], dp[0][h][w-1]+item[h][w])
            dp[2][h][w] = max(dp[2][h][w], dp[2][h][w-1], dp[1][h][w-1]+item[h][w])
            dp[3][h][w] = max(dp[3][h][w], dp[3][h][w-1], dp[2][h][w-1]+item[h][w])
ans = []
for k in range(4):
    ans.append(dp[k][-1][-1])
print(max(ans))
Buggy python submission (verdict: Time Limit Exceeded):
k = int(input())
if k%2==0 or k%5==0:
    print(-1)
else:
    res = 7
    i = 1
    while True:
        if res%k==0:
            print(i)
        res *= 10
        res += 7
        res %= k
        i += 1

Fixed submission:
k = int(input())
a = 7
for i in range(1, 10**6):
    if a%k == 0:
        print(i)
        exit()
    a = (a*10+7)%k
print(-1)
Buggy python submission (verdict: Runtime Error):
n=int(open(0));print(sum(n//i*(n//i+1)*i//2for i in range(1,n+1)))

Fixed submission:
n=int(input());a=0;
for i in range(n): i+=1;y=n//i;a+=y*(y+1)//2*i
print(a)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
d = [0]*n
cnt = 0
a.sort()

while a:
    res = a.pop(0)
    cnt += 1
    
    i = 0
    flag = False
    while True:
        if i >= len(a): break
        if a[i]%res==0:
            if a[i] == res:
                flag = True
            a.pop(i)
            i -= 1
        i += 1
    if flag: cnt -= 1

print(cnt)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
cnt = 0
d = [0]*(10**6+1)
a.sort()
for i in range(n):
    if d[a[i]]: continue
    cnt += 1
    if i != n-1 and a[i] == a[i+1]:
        cnt -= 1
    res = a[i]
    while res <= 10**6:
        d[res] = 1
        res += a[i]
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
d = [0]*n
cnt = 0
a.sort()

while a:
    res = a.pop(0)
    cnt += 1
    
    i = 0
    flag = False
    while True:
        if i >= len(a): break
        if a[i]%res==0:
            if a[i] == res:
                flag = True
            a.pop(i)
            i -= 1
        i += 1
    if flag: cnt -= 1

print(cnt)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
cnt = 0
d = [0]*(10**6+1)
a.sort()
for i in range(n):
    if d[a[i]]: continue
    cnt += 1
    if i != n-1 and a[i] == a[i+1]:
        cnt -= 1
    res = a[i]
    while res <= 10**6:
        d[res] = 1
        res += a[i]
print(cnt)
Buggy python submission (verdict: Time Limit Exceeded):
from copy import deepcopy
import bisect
n, k = map(int, input().split())
a = list(map(int, input().split()))

for _ in range(k):
    b = [1] * n
    for i in range(n):
        for j in range(1, a[i]+1):
            if i-j >= 0: b[i-j] += 1
            if i+j < n: b[i+j] += 1
    a = deepcopy(b)
    
    if bisect.bisect_left(a, n) == 0: break
        
print(*a)

Fixed submission:
from copy import deepcopy
import bisect
n, k = map(int, input().split())
a = list(map(int, input().split()))

for _ in range(k):
    b = [0] * (n+1)
    for i in range(n):
        b[max(0, i-a[i])] += 1
        b[min(n, i+a[i]+1)] -= 1
    for i in range(n-1):
        b[i+1] += b[i]
    b.pop()
    a = deepcopy(b)
    
    if bisect.bisect_left(a, n) == 0: break
    
print(*a)
Buggy python submission (verdict: Time Limit Exceeded):
n, s = map(int, input().split())
a = list(map(int, input().split()))
dp = [[0]*(s+1) for _ in range(n+1)]
dp[0][0] = 1
mod = 998244353
for i in range(n):
    for j in range(s+1):
        dp[i+1][j] = dp[i][j]*2%mod
        if a[i]<=j: dp[i+1][j] = (dp[i+1][j]+dp[i][j-a[i]])%mod
        dp[i+1][j] %= mod
print(dp[n][s])

Fixed submission:
n, s = map(int, input().split())
a = list(map(int, input().split()))
dp = [[0]*(s+1) for _ in range(n+1)]
dp[0][0] = 1
mod = 998244353
for i in range(n):
    for j in range(s+1):
        dp[i+1][j] = dp[i][j]*2%mod
        if a[i]<=j: dp[i+1][j] = (dp[i+1][j]+dp[i][j-a[i]])%mod
        dp[i+1][j] %= mod
print(dp[n][s])

Buggy python submission (verdict: Time Limit Exceeded):
n, s = map(int, input().split())
a = list(map(int, input().split()))
dp = [[0]*(s+1) for _ in range(n+1)]
dp[0][0] = 1
mod = 998244353
for i in range(n):
    for j in range(s+1):
        dp[i+1][j] = dp[i][j]*2
        if a[i]<=j: dp[i+1][j] += dp[i][j-a[i]]
        dp[i+1][j] %= mod
print(dp[n][s])

Fixed submission:
n, s = map(int, input().split())
a = list(map(int, input().split()))
dp = [[0]*(s+1) for _ in range(n+1)]
dp[0][0] = 1
mod = 998244353
for i in range(n):
    for j in range(s+1):
        dp[i+1][j] = dp[i][j]*2%mod
        if a[i]<=j: dp[i+1][j] = (dp[i+1][j]+dp[i][j-a[i]])%mod
        dp[i+1][j] %= mod
print(dp[n][s])
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
ans = 0
for i in range(n-1):
    for j in range(a[i], n):
        if j-i == a[i]+a[j]:
            ans += 1
print(ans)

Fixed submission:
import bisect
n = int(input())
a = list(map(int, input().split()))
ans = 0
l_dp = []
r_dp = []
for i in range(n):
    l_dp.append(a[i]+i)
    r_dp.append(n-i-1-a[n-i-1])
r_dp.sort()
for i in l_dp:
    if i < 0 or i >= n: continue
    l_index = bisect.bisect_left(r_dp, i)
    r_index = bisect.bisect_right(r_dp, i)
    ans += r_index - l_index
print(ans)
Buggy python submission (verdict: Runtime Error):
s = input()
dp = [0]*(len(s)-3)
for i in range(4, len(s)):
    dp[i-3] = dp[i-4]
    for j in range(i-3):
        if not int(s[j:i+1])%2019: dp[i-3]+=1
print(dp[-1])

Fixed submission:
s = input()
counter = [0]*2019
counter[0] = 1
ans = 0
res, d = 0, 1
for i in range(len(s)-1, -1, -1):
    res = (res+int(s[i])*d)%2019
    counter[res] += 1
    d = d*10%2019
for count in counter:
    ans += count*(count-1)//2
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
for i in range(n):
    print(a.count(i+1))

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
ans = [0]*n
for i in a:
    ans[i-1] += 1
for i in ans:
    print(i)
Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())
mod = 10**9+7
mina = [0]*(n-k+2)
maxa = [0]*(n-k+2)
mina[0] = (k-1)*k//2
for i in range(k):
    maxa[0] += n-i
for i in range(1, n-k+2):
    mina[i] = mina[i-1]+i+k-1
    maxa[i] = maxa[i-1]+(n-k-i+1)
    if mina[i-k+1]>=mod and maxa[i-k+1]>=mod:
        mina[i-k+1] %= mod
        maxa[i-k+1] %= mod
ans = 0
for i in range(n-k+2):
    ans += maxa[i]-mina[i]+1
    ans %= mod
print(ans)

Fixed submission:
n, k = map(int, input().split())
mod = 10**9+7
mina = [0]*(n-k+2)
maxa = [0]*(n-k+2)
mina[0] = (k-1)*k//2
for i in range(k):
    maxa[0] += n-i
for i in range(1, n-k+2):
    mina[i] = mina[i-1]+i+k-1
    maxa[i] = maxa[i-1]+(n-k-i+1)
    if mina[i]>=mod and maxa[i]>=mod:
        mina[i] %= mod
        maxa[i] %= mod
ans = 0
for i in range(n-k+2):
    ans += maxa[i]-mina[i]+1
    ans %= mod
print(ans%mod)
Buggy python submission (verdict: Time Limit Exceeded):
n, k, c = map(int, input().split())
s = input()
left_dp = []
right_dp = []

i = 0
while len(left_dp)<k:
    if s[i] == "o":
        left_dp.append(i+1)
        i += c+1
    else: i += 1
        
i = n-1
while len(right_dp)<k:
    if s[i] == "o":
        right_dp.append(i+1)
        i -= c+1
    else: i -= 1

for i in left_dp:
    for j in right_dp:
        if i == j: 
            print(i)

Fixed submission:
n, k, c = map(int, input().split())
s = input()
left_dp = []
right_dp = []

i = 0
while len(left_dp)<k:
    if s[i] == "o":
        left_dp.append(i+1)
        i += c+1
    else: i += 1
        
i = n-1
while len(right_dp)<k:
    if s[i] == "o":
        right_dp.append(i+1)
        i -= c+1
    else: i -= 1

for i in range(k):
    if left_dp[i] == right_dp[k-i-1]:
        print(left_dp[i])