Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
trans = [int(input()) for _ in range(5)]

people = [n, 0, 0, 0, 0, 0]
cnt = 0

while people[5] < n:
    for i in reversed(range(0, len(trans))):
        if people[i] >= trans[i]:
            people[i] -= trans[i]
            people[i+1] += trans[i]
        else:
            people[i + 1] += people[i]
            people[i] = 0
    cnt += 1
print(cnt)
    


Fixed submission:
import math
n = int(input())
trans = [int(input()) for _ in range(5)]

min_trans = min(trans)
print(math.ceil(n/min_trans) + 4)
Buggy python submission (verdict: Time Limit Exceeded):
import itertools


x, y, z, k = list(map(int, input().split()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
AB = [a + b for (a, b) in list(itertools.product(A, B))]
AB.sort(reverse=True)
ABC = [ab + c for (ab, c) in list(itertools.product(AB[:k], C))]
ABC.sort(reverse=True)

for i in range(k):
    print(ABC[i])


Fixed submission:
import itertools


x, y, z, k = list(map(int, input().split()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
AB = [a + b for (a, b) in list(itertools.product(A, B))]
AB.sort(reverse=True)
ABC = [ab + c for (ab, c) in list(itertools.product(AB[:k], C))]
ABC.sort(reverse=True)

for i in range(k):
    print(ABC[i])

Buggy python submission (verdict: Time Limit Exceeded):
x, y, z, k = list(map(int, input().split()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

ab = []
for i in range(len(a)):
    for j in range(len(b)):
        ab.append(a[i] + b[j])

ab = sorted(ab, reverse=True)
ab = ab[:k]
abc = []
for i in range(len(ab)):
    for j in range(len(c)):
        abc.append(ab[i] + c[j])

abc = sorted(abc, reverse=True)
for i in range(k):
    print(abc[i])




Fixed submission:
import itertools


x, y, z, k = list(map(int, input().split()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
AB = [a + b for (a, b) in list(itertools.product(A, B))]
AB.sort(reverse=True)
ABC = [ab + c for (ab, c) in list(itertools.product(AB[:k], C))]
ABC.sort(reverse=True)

for i in range(k):
    print(ABC[i])
Buggy python submission (verdict: Runtime Error):
n, q = map(int, input().split())
s = input()
q_l = [tuple(map(int, input().split())) for _ in range(q)]

accum_sum = [0] * (len(s)+1)

for i in range(len(s)):
    if s[i] == "A" and s[i+1] == "C":
        accum_sum[i+1] = accum_sum[i] + 1
    else:
        accum_sum[i+1] = accum_sum[i]

for l, r in q_l:
    print(accum_sum[r-1]-accum_sum[l-1])





Fixed submission:
n, q = list(map(int, input().split()))
s = input()
ran = [list(map(int, input().split())) for i in range(q) ]

table = [0] * n
for i in range(1, n):
    if s[i] == "C" and s[i-1] == "A":
        table[i] = table[i - 1] + 1
    else:
        table[i] = table[i - 1]

for l, r in ran:
    print(table[r-1]  - table[l - 1] )
Buggy python submission (verdict: Runtime Error):
a, b, k = list(map(int, input().split()))

ans_l = []
for num in range(min(a, b)):
  if a % num == 0 and b % num == 0:
    ans_l.append(num)

sorted(ans_l)

print(ans_l[-k])

Fixed submission:
a, b, k = list(map(int, input().split()))
 
ans_l = []
for num in range(1, min(a, b) + 1):
  if a % num == 0 and b % num == 0:
    ans_l.append(num)


print(ans_l[-k])
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
h = list(map(int, input().split()))

if k >= n:
    print(h[-1]-h[0])
    exit()
dp = [0] * n
dp[0] = 0
for i in range(1, k):
    dp[i] = abs(h[0]-h[i])

for i in range(k, len(dp)):
    dp[i] = min(abs(h[i]-h[i-j])+dp[i-j] for j in range(1, k+1))
print(dp[-1])



Fixed submission:
n, k = map(int, input().split())
h = list(map(int, input().split()))

if k >= n:
    print(h[-1]-h[0])
    exit()
dp = [0] * n
dp[0] = 0
for i in range(1, k):
    dp[i] = abs(h[0]-h[i])

for i in range(k, len(dp)):
    dp[i] = min(abs(h[i]-h[i-j])+dp[i-j] for j in range(1, k+1))
print(dp[-1])
Buggy python submission (verdict: Runtime Error):
h, w = map(int, input().split())
field = [input() for _ in range(h)]
MOD = 10 ** 9 + 7

dp = [[0] * w for _ in range(h)]
dp[0][0] = 1

for i in range(1, w):
    if field[0][i] == ".":
        dp[0][i] = dp[0][i-1] 

for i in range(1, h):
    if field[i][0] == ".":
        dp[i][0] = dp[i-1][0]

for row in range(1, h):
    for col in range(1, w):
        if field[i][j] == ".":
            dp[i][j] = dp[i-1][j] + dp[i][j-1]
print(dp[-1][-1])



Fixed submission:
h, w = map(int, input().split())
field = [input() for _ in range(h)]
MOD = 10 ** 9 + 7

dp = [[0] * w for _ in range(h)]
dp[0][0] = 1

for i in range(1, w):
    if field[0][i] == ".":
        dp[0][i] = dp[0][i-1] 

for i in range(1, h):
    if field[i][0] == ".":
        dp[i][0] = dp[i-1][0]

for row in range(1, h):
    for col in range(1, w):
        if field[row][col] == ".":
            dp[row][col] = (dp[row-1][col] + dp[row][col-1]) % MOD
print(dp[-1][-1])
Buggy python submission (verdict: Runtime Error):
age = int(input())

if age == 1:
    print("Hello World")
    exit(1)
else:
    a = int(input())
    b = int(input())
    print(a+b)
    


Fixed submission:
age = int(input())

if age == 1:
    print("Hello World")
else:
    a = int(input())
    b = int(input())
    print(a+b)
Buggy python submission (verdict: Runtime Error):
import sys


n = int(input())

for i in range(100):
    for j in range(100):
        if i * 4 + j * 7 == n:
            print("Yes")
            sys.exit(1)
print("No")




Fixed submission:
import sys


n = int(input())

for i in range(100):
    for j in range(100):
        if i * 4 + j * 7 == n:
            print("Yes")
            sys.exit()
print("No")
Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque


h, w = map(int, input().split())
field = [list(input()) for _ in range(h)]
INF = float("inf")
directions = [(1, 0), (-1, 0), (0, 1), (0, -1)]

done = [[0] * w for _ in range(h)]
done[0][0] = 1

que = deque([(0, 0)])

dist = 0 
flag = False
while que:
    dist += 1

    for i in range(len(que)):
        x, y = que.popleft()
        if x == w-1 and y == h-1:
            flag = True
        for dx, dy in directions:
            nx = x + dx
            ny = y + dy
            if 0 <= nx < w and 0 <= ny < h and done[ny][nx] == 0 and field[ny][nx] == ".":
                que.append((nx, ny))
                done[ny][nx] == 1
    if flag:
        break

if not flag:
    print(-1)
    exit()

white_num = 0
for i in range(h):
    for j in range(w):
        if field[i][j] == ".":
            white_num += 1
print(white_num-dist)





Fixed submission:
from collections import deque


h, w = map(int, input().split())
field = [list(input()) for _ in range(h)]
directions = [(-1, 0), (1, 0), (0, -1), (0, 1)]
nokoshi = 1
que = deque([(0, 0)])
done = [[False] * w for _ in range(h)]

white_num = 0
for i in range(h):
    for j in range(w):
        if field[i][j] == ".":
            white_num += 1

while que:
    for i in range(len(que)):
        y, x = que.popleft()

        if y == h - 1 and x == w - 1:
            print(white_num - nokoshi)
            exit()

        if y < 0 or y >= h or x < 0 or x >= w or field[y][x] == "#" or done[y][x] is True:
            continue
        done[y][x] = True

        for dy, dx in directions:
            que.append((y+dy, x+dx))

    nokoshi += 1
print(-1)
Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())
snuke = [0] * N
for n in range(N-1):
    snack = int(input())
    d_snuke = map(int, input().split())
    for d in d_snuke:
        snuke[d-1] = snack
c = 0
for n in range(N-1):
    if snuke[n] == 0:
        c += 1
print(c)


Fixed submission:
N, K = map(int, input().split())
snuke = [0] * N
for n in range(K):
    snack = int(input())
    d_snuke = map(int, input().split())
    for d in d_snuke:
        snuke[d-1] = snack
c = 0
for n in range(N):
    if snuke[n] == 0:
        c += 1
print(c)

Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())
snuke = [0] * N
for n in range(N-1):
    snack = int(input())
    d_snuke = map(int, input().split())
    for d in d_snuke:
        snuke[d-1] = snack
c = 0
for n in range(N):
    if snuke[n] == 0:
        c += 1
print(c)

Fixed submission:
N, K = map(int, input().split())
snuke = [0] * N
for n in range(K):
    snack = int(input())
    d_snuke = map(int, input().split())
    for d in d_snuke:
        snuke[d-1] = snack
c = 0
for n in range(N):
    if snuke[n] == 0:
        c += 1
print(c)

Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())
snuke = [0] * N
for n in range(N-1):
    snack = int(input())
    A = str(input())
    snuke[snack-1] = 1
c = 0
for n in range(N):
    if snuke[n] == 0:
        c += 1
print(c)

Fixed submission:
N, K = map(int, input().split())
snuke = [0] * N
for n in range(K):
    snack = int(input())
    d_snuke = map(int, input().split())
    for d in d_snuke:
        snuke[d-1] = snack
c = 0
for n in range(N):
    if snuke[n] == 0:
        c += 1
print(c)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
found = 0
for n in range(N):
    for i in range(n+1, N):
        if (i-n) == A[n] + A[i]:
            found += 1
print(found)

Fixed submission:
from collections import defaultdict
N = int(input())
A = list(map(int, input().split()))
found = 0
dt = defaultdict(int)
for n in range(N):
    found += dt[n - A[n]]
    dt[n + A[n]] += 1
print(found)
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

my_input = lambda : map(int, input().split(" "))

N, M = my_input()
dist = 100 * 1000 * np.ones([N, N])

edges = []
for i in range(M):
    a, b, c = my_input()
    dist[a-1][b-1] = c
    dist[b-1][a-1] = c
    edges.append((a, b, c))

for k in range(N):
    for i in range(N):
        for j in range(N):
            dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j])

print(len([e for e in edges if e[2] != dist[e[0]-1][e[1]-1]]))

Fixed submission:
import numpy as np
from scipy.sparse.csgraph import dijkstra

my_input = lambda : map(int, input().split(" "))

N, M = my_input()
dist = 100 * 1000 * (np.ones([N, N]) - np.eye(N)).astype(int)

edges = []
for i in range(M):
    a, b, c = my_input()
    dist[a-1][b-1] = c
    dist[b-1][a-1] = c
    edges.append((a, b, c))

dist = dijkstra(dist, directed=False)
print(len([e for e in edges if e[2] != dist[e[0]-1][e[1]-1]]))
Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter

S = input()
mods = [0]
num, ten = 0, 1
for n in S[::-1]:
    num += int(n) * ten
    num %= 2019
    mods.append(num)
    ten *= 10

counter = Counter(mods)
ret = 0
for v in counter.values():
    ret += v * (v - 1) // 2
print(ret)

Fixed submission:
from collections import Counter

S = input()
mods = [0]
num, ten = 0, 1
for n in S[::-1]:
    num += int(n) * ten
    num %= 2019
    mods.append(num)
    ten *= 10
    ten %= 2019

counter = Counter(mods)
ret = 0
for v in counter.values():
    ret += v * (v - 1) // 2
print(ret)

Buggy python submission (verdict: Time Limit Exceeded):
S = input()
counter = {0: 1}
num, ten = 0, 1
for n in S[::-1]:
    num += int(n) * ten
    mod = num % 2019
    if mod in counter:
        counter[mod] += 1
    else:
        counter[mod] = 1
    ten *= 10

ret = 0
for v in counter.values():
    ret += v * (v - 1) // 2
print(ret)

Fixed submission:
from collections import Counter

S = input()
mods = [0]
num, ten = 0, 1
for n in S[::-1]:
    num += int(n) * ten
    num %= 2019
    mods.append(num)
    ten *= 10
    ten %= 2019

counter = Counter(mods)
ret = 0
for v in counter.values():
    ret += v * (v - 1) // 2
print(ret)

Buggy python submission (verdict: Time Limit Exceeded):
S = input()
ret = 0
counter = {0: 1}
for i in range(len(S)):
    mod = int(S[-i:]) % 2019
    if mod in counter:
        counter[mod] += 1
    else:
        counter[mod] = 1

for k, v in counter.items():
    ret += v * (v - 1) // 2

print(ret)

Fixed submission:
from collections import Counter

S = input()
mods = [0]
num, ten = 0, 1
for n in S[::-1]:
    num += int(n) * ten
    num %= 2019
    mods.append(num)
    ten *= 10
    ten %= 2019

counter = Counter(mods)
ret = 0
for v in counter.values():
    ret += v * (v - 1) // 2
print(ret)

Buggy python submission (verdict: Time Limit Exceeded):
S = input()
ret = 0
counter = {0: 1}
for i in range(len(S)):
    mod = int(S[-i:]) % 2019
    if mod in counter:
        counter[mod] += 1
    else:
        counter[mod] = 1
for k, v in counter.items():
    ret += v * (v - 1) // 2

print(ret)

Fixed submission:
from collections import Counter

S = input()
mods = [0]
num, ten = 0, 1
for n in S[::-1]:
    num += int(n) * ten
    num %= 2019
    mods.append(num)
    ten *= 10
    ten %= 2019

counter = Counter(mods)
ret = 0
for v in counter.values():
    ret += v * (v - 1) // 2
print(ret)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
import collections

N = int(input())
S = [ch for ch in input()]
counter = collections.Counter(S)
if len(counter.keys()) != 3:
    print(0)
    sys.exit()
total = 1
for k, v in counter.items():
    total *= v

for i in range(len(S)):
    l, r = i - 1, i + 1
    while 0 <= l and r < len(S):
        if len(set([S[i], S[l], S[r]])) == 3:
            total -= 1
        l -= 1
        r += 1
print(total)

Fixed submission:
import sys
import collections

N = int(input())
S = [ch for ch in input()]
counter = collections.Counter(S)
if len(counter.keys()) != 3:
    print(0)
    sys.exit()
total = 1
for k, v in counter.items():
    total *= v

for i in range(len(S)):
    l, r = i - 1, i + 1
    while 0 <= l and r < len(S):
        if len(set([S[i], S[l], S[r]])) == 3:
            total -= 1
        l -= 1
        r += 1
print(total)

Buggy python submission (verdict: Runtime Error):
import sys
import collections

N = int(input())
S = [ch for ch in input()]
counter = collections.Counter(S)
if len(counter.keys()) != 3:
    print(0)
    eys.exit()
total = 1
for k, v in counter.items():
    total *= v

for i in range(len(S)):
    l, r = i - 1, i + 1
    while 0 <= l and r < len(S):
        if len(set([S[i], S[l], S[r]])) == 3:
            total -= 1
        l -= 1
        r += 1
print(total)

Fixed submission:
import sys
import collections

N = int(input())
S = [ch for ch in input()]
counter = collections.Counter(S)
if len(counter.keys()) != 3:
    print(0)
    sys.exit()
total = 1
for k, v in counter.items():
    total *= v

for i in range(len(S)):
    l, r = i - 1, i + 1
    while 0 <= l and r < len(S):
        if len(set([S[i], S[l], S[r]])) == 3:
            total -= 1
        l -= 1
        r += 1
print(total)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
import collections

N = int(input())
S = [ch for ch in input()]
RGB = [0, 0, 0]
for ch in S:
    if ch == "R":
        RGB[0] += 1
    elif ch == "G":
        RGB[1] += 1
    else:
        RGB[2] += 1
total = 1
for count in RGB:
    if count == 0:
        print(0)
        sys.exit()
    total *= count

for i in range(len(S)):
    l, r = i - 1, i + 1
    while 0 <= l and r < len(S):
        if len(set([S[i], S[l], S[r]])) == 3:
            total -= 1
        l -= 1
        r += 1
print(total)

Fixed submission:
import sys
import collections

N = int(input())
S = [ch for ch in input()]
counter = collections.Counter(S)
if len(counter.keys()) != 3:
    print(0)
    sys.exit()
total = 1
for k, v in counter.items():
    total *= v

for i in range(len(S)):
    l, r = i - 1, i + 1
    while 0 <= l and r < len(S):
        if len(set([S[i], S[l], S[r]])) == 3:
            total -= 1
        l -= 1
        r += 1
print(total)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque

N, X, Y = map(int, input().split())
X, Y = X - 1, Y - 1
ans = [0] * N
for sv in range(N):
    dist = [float("inf")] * N
    q = deque([sv])

    def push(v, d):
        if dist[v] != float("inf"):
            return
        dist[v] = d
        q.append(v)

    push(sv, 0)
    while len(q):
        v = q.popleft()
        d = dist[v]
        if v - 1 >= 0:
            push(v - 1, d + 1)
        if v + 1 < N:
            push(v + 1, d + 1)
        if v == X:
            push(Y, d + 1)
        if v == Y:
            push(X, d + 1)
    for i in range(N):
        ans[dist[i]] += 1
for i in range(1, N):
    print(ans[i] // 2)

Fixed submission:
from collections import defaultdict

N, X, Y = map(int, input().split())
X, Y = X - 1, Y - 1
dist_to_cnt = defaultdict(int)
for i in range(N):
    for j in range(i, N):
        dist = min(j - i, abs(i - X) + 1 + abs(Y - j))
        dist_to_cnt[dist] += 1
for i in range(1, N):
    print(dist_to_cnt[i])

Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque

N, X, Y = map(int, input().split())
X, Y = X - 1, Y - 1
ans = [0] * N
for sv in range(N):
    dist = [float("inf")] * N
    q = deque([sv])

    def push(v, d):
        if dist[v] != float("inf"):
            return
        dist[v] = d
        q.append(v)

    push(sv, 0)
    while len(q):
        v = q.popleft()
        d = dist[v]
        if v - 1 >= 0:
            push(v - 1, d + 1)
        if v + 1 < N:
            push(v + 1, d + 1)
        if v == X:
            push(Y, d + 1)
        if v == Y:
            push(X, d + 1)
    for i in range(N):
        ans[dist[i]] += 1
for i in range(N):
    ans[i] //= 2
for i in range(1, N):
    print(ans[i])

Fixed submission:
from collections import defaultdict

N, X, Y = map(int, input().split())
X, Y = X - 1, Y - 1
dist_to_cnt = defaultdict(int)
for i in range(N):
    for j in range(i, N):
        dist = min(j - i, abs(i - X) + 1 + abs(Y - j))
        dist_to_cnt[dist] += 1
for i in range(1, N):
    print(dist_to_cnt[i])
Buggy python submission (verdict: Time Limit Exceeded):
import bisect 
N = int(input())
max_keys = []
max_cnt = 1
c = {}
for _ in range(N):
    s = input()
    if s in set(c.keys()):
        c[s] += 1
    else:
        c[s] = 1

    if max_cnt == c[s]:
        bisect.insort(max_keys, s)
    elif max_cnt < c[s]:
        max_keys = [s]
        max_cnt = c[s]

for x in max_keys:
    print(x)

Fixed submission:
import collections
N = int(input())
S = [input() for _ in range(N)]
C = collections.Counter(S)
max_cnt = C.most_common()[0][1]
tmp = sorted([k for k,v in C.items() if v == max_cnt])
for ans in tmp:
    print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
max_keys = []
max_cnt = 1
c = {}
for _ in range(N):
    s = input()
    if s in set(c.keys()):
        c[s] += 1
    else:
        c[s] = 1

    if max_cnt == c[s]:
        max_keys.append(s)
    elif max_cnt < c[s]:
        max_keys = [s]
        max_cnt = c[s]

for x in sorted(max_keys):
    print(x)

Fixed submission:
import collections
N = int(input())
S = [input() for _ in range(N)]
C = collections.Counter(S)
max_cnt = C.most_common()[0][1]
tmp = sorted([k for k,v in C.items() if v == max_cnt])
for ans in tmp:
    print(ans)
Buggy python submission (verdict: Runtime Error):
# 解き直し
H, N = map(int, input().split())
A_to_minB = {}
max_A = -1
for i in range(N):
    a, b = map(int, input().split())
    max_A = max(max_A, a)
    if a not in set(A_to_minB.keys()):
        A_to_minB[a] = b
    else:
        A_to_minB[a] = min(A_to_minB[a], b)
dp = [float("inf")] * (H + max_A)
dp[0] = 0
for i in range(1, H+N):
    tmp = [dp[i-a]+b for a, b in A_to_minB.items() if a<=i]
    if tmp:
        dp[i] = min(tmp)
print(min(dp[H:H+max_A]))

Fixed submission:
# 解き直し
H, N = map(int, input().split())
A_to_minB = {}
max_A = -1
for i in range(N):
    a, b = map(int, input().split())
    max_A = max(max_A, a)
    if a not in set(A_to_minB.keys()):
        A_to_minB[a] = b
    else:
        A_to_minB[a] = min(A_to_minB[a], b)
dp = [float("inf")] * (H + max_A)
dp[0] = 0
for i in range(1, H+max_A):
    tmp = [dp[i-a]+b for a, b in A_to_minB.items() if a<=i]
    if tmp:
        dp[i] = min(tmp)
print(min(dp[H:H+max_A]))
Buggy python submission (verdict: Runtime Error):
N, K, S = map(int, input().split())
ans = [str(S)] * K + [str(S//(N-K)+1)] * (N-K)
print(' '.join(ans))

Fixed submission:
N, K, S = map(int, input().split())
ans = [S] * K 
if S != 10**9:
    ans += [S+1] * (N-K)
else:
    ans += [1] * (N-K)
print(' '.join([str(x) for x in ans]))

Buggy python submission (verdict: Runtime Error):
N, K, S = map(int, input().split())
ans = [S] * K + [S//(N-K)+1] * (N-K)
print(ans)

Fixed submission:
N, K, S = map(int, input().split())
ans = [S] * K 
if S != 10**9:
    ans += [S+1] * (N-K)
else:
    ans += [1] * (N-K)
print(' '.join([str(x) for x in ans]))
Buggy python submission (verdict: Runtime Error):
import math
A, B = map(int, input().split(' '))
print(int((A * B) / math.gcd(A, B)))

Fixed submission:
import fractions
A, B = map(int, input().split(' '))
gcd = fractions.gcd(A, B)
print((A * B) // gcd)

Buggy python submission (verdict: Runtime Error):
import math
A, B = map(int, input().split(' '))
print((A * B) // math.gcd(A, B))

Fixed submission:
import fractions
A, B = map(int, input().split(' '))
gcd = fractions.gcd(A, B)
print((A * B) // gcd)
Buggy python submission (verdict: Runtime Error):
 A, B, C = map(int, input().split())

if A + B + C >= 22:
    print('bust')
else:
    print('win')

Fixed submission:
 
A, B, C = map(int, input().split())
val = A + B + C
if val >= 22:
    print('bust')
else:
    print('win')
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = input()
anss = []
for i in range(1000):
    str_i = str(i).zfill(3)
    idx = 0
    ans = ""
    for j in range(N):
        if S[j] == str_i[idx]:
            if idx == 2:
                ans += str_i[idx]
                anss.append(ans)
                break
            else:
                ans += str_i[idx]
                idx += 1
print(len(set(anss)))

Fixed submission:
N = int(input())
S = input()
anss = []
for i in range(1000):
    str_i = str(i).zfill(3)
    idx1 = S.find(str_i[0], 0)
    idx2 = S.find(str_i[1], idx1 + 1)
    idx3 = S.find(str_i[2], idx2 + 1)
    if idx1 != -1 and idx2 != -1 and idx3 != -1:
        anss.append(str_i)

print(len(set(anss)))
Buggy python submission (verdict: Runtime Error):
import numpy as np
 
H, W = map(int, input().split())
S = np.array([list(input()) for _ in range(H)]) == '.'

#上下左右方向に塗られるマスの数を格納する配列
up = np.zeros((H, W), dtype=int)
down = np.zeros((H, W), dtype=int)
left = np.zeros((H, W), dtype=int)
right = np.zeros((H, W), dtype=int)

for i in range(H):
    up[i] = (up[i-1] + 1) * S[i]
    down[-i-1] = (down[-i] + 1) * S[-i-1]
 
for i in range(W):
    left[:, i] = (left[:, i-1] + 1) * S[:, i]
    right[:, -i-1] = (right[:, -i] + 1) * S[:, -i-1]

print(np.max(up+down+left+right) - 3)

Fixed submission:
import numpy as np
 
H, W = map(int, input().split())
S = np.array([list(input()) for _ in range(H)]) == '.'

#上下左右方向に塗られるマスの数を格納する配列
up = np.zeros((H, W), dtype=int)
down = np.zeros((H, W), dtype=int)
left = np.zeros((H, W), dtype=int)
right = np.zeros((H, W), dtype=int)

for i in range(H):
    up[i] = (up[i-1] + 1) * S[i]
    down[-i-1] = (down[-i] + 1) * S[-i-1]
 
for i in range(W):
    left[:, i] = (left[:, i-1] + 1) * S[:, i]
    right[:, -i-1] = (right[:, -i] + 1) * S[:, -i-1]

print(np.max(up+down+left+right) - 3)