Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
from collections import deque

n, q = map(int, input().split())
# 隣接リストを作成
adj = [[] for i in range(n)]
for i in range(n-1):
    a, b = map(int, input().split())
    adj[a-1].append(b-1)
    adj[b-1].append(a-1)

queries = [0 for i in range(n)]
for i in range(q):
    p, x = map(int, input().split())
    queries[p-1] += x

ans = [0 for i in range(n)]

# スタックによるdfs(位置, 上からの加算, 親の位置)
st = deque([(0,0,-1)])
# stが空になるまで操作
while st:
    l = st.pop()
    ans[l[0]] = l[1] + queries[l[0]]
    for v in adj[l[0]]:
        if v != l[2]:
            st.append((v, ans[l[0], l[0]]))
print(*ans)

Fixed submission:
from collections import deque

n, q = map(int, input().split())
# 隣接リストを作成
adj = [[] for i in range(n)]
for i in range(n-1):
    a, b = map(int, input().split())
    adj[a-1].append(b-1)
    adj[b-1].append(a-1)

queries = [0 for i in range(n)]
for i in range(q):
    p, x = map(int, input().split())
    queries[p-1] += x

ans = [0 for i in range(n)]

# スタックによるdfs(位置, 上からの加算, 親の位置)
st = deque([(0,0,-1)])
# stが空になるまで操作
while st:
    l = st.pop()
    ans[l[0]] = l[1] + queries[l[0]]
    for v in adj[l[0]]:
        if v != l[2]:
            st.append((v, ans[l[0]], l[0]))
print(*ans)
Buggy python submission (verdict: Runtime Error):
a, b c = map(int, input().split())
print(min(a, b+c))

Fixed submission:
a, b, c = map(int, input().split())
print(max(0, c-(a-b)))
Buggy python submission (verdict: Time Limit Exceeded):
import sys
s = input()[::-1]
mod = 10**9 + 7
dp = [0 for i in range(13)]

if s[0] == '?':
    for i in range(10):
        dp[i] += 1
else:
    dp[int(s[0])] += 1

if len(s) == 1:
    print(dp[5])
    sys.exit()

for i, x in enumerate(s[1:], start=1):
    nextdp = [0 for j in range(13)]
    if x != '?':
        a = int(x) * pow(10, i, 13)
        for k in range(13):
            nextdp[(k + a)%13] += dp[k]%mod
            nextdp[(k + a)%13] %= mod
    else:
        for y in range(10):
            a = y * pow(10, i, 13)
            for k in range(13):
                nextdp[(k + a)%13] += dp[k]%mod
                nextdp[(k + a)%13] %= mod
    dp = nextdp
print(dp[5])

Fixed submission:
import sys
s = input()[::-1]
mod = 10**9 + 7
dp = [0 for i in range(13)]

if s[0] == '?':
    for i in range(10):
        dp[i] += 1
else:
    dp[int(s[0])] += 1

if len(s) == 1:
    print(dp[5])
    sys.exit()

for i, x in enumerate(s[1:], start=1):
    nextdp = [0 for j in range(13)]
    if x != '?':
        a = int(x) * pow(10, i, 13)
        for k in range(13):
            nextdp[(k + a)%13] += dp[k]%mod
            nextdp[(k + a)%13] %= mod
    else:
        for y in range(10):
            a = y * pow(10, i, 13)
            for k in range(13):
                nextdp[(k + a)%13] += dp[k]%mod
                nextdp[(k + a)%13] %= mod
    dp = nextdp
print(dp[5])
Buggy python submission (verdict: Runtime Error):
L, R= map(int, input().split())
ans = []
for i in range(L, R):
    for j in range(i+1, R+1):
        if (i*j)%2019 == 0:
            print(0)
            sys.exit()
        else:
            ans.append((i*j)%2019)
print(min(ans))

Fixed submission:
import sys
L, R= map(int, input().split())
ans = []
for i in range(L, R):
    for j in range(i+1, R+1):
        if (i*j)%2019 == 0:
            print(0)
            sys.exit()
        else:
            ans.append((i*j)%2019)
print(min(ans))

Buggy python submission (verdict: Time Limit Exceeded):
L, R= map(int, input().split())
ans = []
for i in range(L, R):
    for j in range(i+1, R+1):
        ans.append((i*j)%2019)
print(min(ans))

Fixed submission:
import sys
L, R= map(int, input().split())
ans = []
for i in range(L, R):
    for j in range(i+1, R+1):
        if (i*j)%2019 == 0:
            print(0)
            sys.exit()
        else:
            ans.append((i*j)%2019)
print(min(ans))

Buggy python submission (verdict: Runtime Error):
L, R= map(int, input().split())
L, R = L%2019, R%2019
ans = []
for i in range(L, R):
    for j in range(i+1, R+1):
        ans.append((i*j)%2019)
print(min(ans))

Fixed submission:
import sys
L, R= map(int, input().split())
ans = []
for i in range(L, R):
    for j in range(i+1, R+1):
        if (i*j)%2019 == 0:
            print(0)
            sys.exit()
        else:
            ans.append((i*j)%2019)
print(min(ans))
Buggy python submission (verdict: Time Limit Exceeded):
from copy import deepcopy
N = int(input())
A = [int(i) for i in input().split()]
B = deepcopy(A)
num = sum(A)
for i in B:
    A.append(i)
ans = []
if N%4 == 1:
    for i in range(N):
        a = 0
        for j in range(int(N/2)):
            a += 2*A[2+2*j+i]
        ans.append(num-a)
    b = [ans[-1]] + ans[:-1]
else:
    for i in range(N):
        a = 0
        for j in range(int(N/2)):
            a += 2*A[1+2*j+i]
        ans.append(num-a)
    b = ans
print(*b)


Fixed submission:
N = int(input())
A = [int(i) for i in input().split()]
num = sum(A)
ans = []
a = 0
for j in range(int(N/2)):
    a += 2*A[1+2*j]
ans.append(num-a)
a = num-a
for i in range(N-1):
    a = 2*A[i] - a
    ans.append(a)
print(*ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = [int(i) for i in input().split()]
A.sort()
a = A[0]
b = A[-1]
if N == 2:
    print(A[1]-A[0])
    print(A[1],A[0])
    sys.exit()
ans = []
for x in A[1:-1]:
    if x <= 0:
        ans.append([b, x])
        b = b - x
    else:
        ans.append([a, x])
        a = a - x
ans.append([b,a])
M = b-a
print(M)
for x in ans:
    print(x[0], x[1])


Fixed submission:
import sys
N = int(input())
A = [int(i) for i in input().split()]
A.sort()
a = A[0]
b = A[-1]
if N == 2:
    print(A[1]-A[0])
    print(A[1],A[0])
    sys.exit()
ans = []
for x in A[1:-1]:
    if x <= 0:
        ans.append([b, x])
        b = b - x
    else:
        ans.append([a, x])
        a = a - x
ans.append([b,a])
M = b-a
print(M)
for x in ans:
    print(x[0], x[1])
Buggy python submission (verdict: Runtime Error):
A, P = map(int, input().split())
print((3*A+P)//2)Ｖ

Fixed submission:
A, P = map(int, input().split())
print((3*A+P)//2)
Buggy python submission (verdict: Runtime Error):
from itertools import product
N, M = map(int, input().split())
denkyu = []
for i in range(M):
    denkyu.append([int(j) for j in input().split()])
p = [int(i) for i in input().split()]
ls = [0, 1]
ans = 0
for x in product(ls, repeat=N):
    num = 0
    for denkyu_, j in enumerate(denkyu):
        judge_light_on = 0
        for s, i in enumerate(denkyu_):
            if i != 0 and x[s-1] == 1:
                judge_light_on += 1
        if judge_light_on%2 == p[j]:
            num += 1
    if num == 0 or num == M:
        ans += 1
print(ans)

Fixed submission:
from itertools import product
N, M = map(int, input().split())
denkyu = []
for i in range(M):
    denkyu.append([int(j) for j in input().split()])
p = [int(i) for i in input().split()]
ls = [0, 1]
ans = 0
for x in product(ls, repeat=N):
    num = 0
    for j, denkyu_ in enumerate(denkyu):
        num_light_on = 0
        for i, s in enumerate(denkyu_):
            if i != 0 and x[s-1] == 1:
                num_light_on += 1
        if num_light_on%2 == p[j]:
            num += 1
    if num == M:
        ans += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())
V = [int(i) for i in input().split()]
ans = 0
for M in range(K+1):
    for m in range(M+1):
        ls = []
        cur1 = 0
        for i, x in enumerate(V):
            if i < m:
                ls.append(x)
                cur += 1
        cur2 = 0
        for i, x in enumerate(V[::-1]):
            if i < min(M-m, N-cur1):
                ls.append(x)
                cur2 += 1
        ls.sort()
        s = sum(ls)
        for i, x in enumerate(ls):
            if i < K-(cur1+cur2):
                s -= x
        ans = max(ans, s)
print(ans)

Fixed submission:
N, K = map(int, input().split())
V = [int(i) for i in input().split()]
ans = 0
for M in range(K+1):
    for m in range(M+1):
        ls = []
        for i, x in enumerate(V):
            if i < m:
                ls.append(x)
        for i, x in enumerate(V[::-1]):
            if i < min(M-m, N-m):
                ls.append(x)
        ls.sort()
        s = sum(ls)
        for i, x in enumerate(ls):
            if i < K-M and x < 0:
                s -= x
        ans = max(ans, s)
print(ans)
Buggy python submission (verdict: Runtime Error):
from collections import defaultdict
N, M = map(int, input().split())
A = [int(i) for i in input().split()]

dic = defaultdict(int)
for i in range(M):
    b, c = map(int, input().split())
    dic[c] += b
for x in A:
    dic[x] += 1
dic = sorted(dic.items(), key=lambda x:x[0], reverse=True)
cur = 0
ans = 0
for x, y in dic.items():
    cur += y
    if cur > len(A):
        print(ans + x*(y - (cur - len(A)))
        sys.exit()
    else:
        ans += x*y

Fixed submission:
from collections import defaultdict
import sys
N, M = map(int, input().split())
A = [int(i) for i in input().split()]

dic = defaultdict(int)
for i in range(M):
    b, c = map(int, input().split())
    dic[c] += b
for x in A:
    dic[x] += 1
dic = sorted(dic.items(), key=lambda x:x[0], reverse=True)
cur = 0
ans = 0
for x, y in dic:
    cur += y
    if cur > len(A):
        print(ans + x*(y - (cur - len(A))))
        sys.exit()
    else:
        ans += x*y
Buggy python submission (verdict: Time Limit Exceeded):
N, Q = map(int, input().split())
S = input()

ans = []
for i in range(N):
    ans.append(S[:i+1].count('AC'))

for _ in range(Q):
    l, r = map(int, input().split())
    if l == 1:
        print(ans[r-1])
    else:
        b = ans[r-1]-ans[l-2]
        if S[l-1] != 'C' and S[r-1] != 'A':
            print(b)
        elif S[l-1] == 'C' and S[l-2] == 'A':
            print(b-1)


Fixed submission:
N, Q = map(int, input().split())
S = input()

ans = [0]
num = 0
for x, y in zip(S[:-1], S[1:]):
    if x == 'A' and y == 'C':
        num += 1
        ans.append(num)
    else:
        ans.append(num)

for _ in range(Q):
    l, r = map(int, input().split())
    if l == 1:
        print(ans[r-1])
    else:
        b = ans[r-1]-ans[l-2]
        if S[l-1] == 'C' and S[l-2] == 'A':
            print(b-1)
        else:
            print(b)

Buggy python submission (verdict: Time Limit Exceeded):
N, Q = map(int, input().split())
S = input()
for _ in range(Q):
    l, r = map(int, input().split())
    print(S[l-1:r].count('AC'))


Fixed submission:
N, Q = map(int, input().split())
S = input()

ans = [0]
num = 0
for x, y in zip(S[:-1], S[1:]):
    if x == 'A' and y == 'C':
        num += 1
        ans.append(num)
    else:
        ans.append(num)

for _ in range(Q):
    l, r = map(int, input().split())
    if l == 1:
        print(ans[r-1])
    else:
        b = ans[r-1]-ans[l-2]
        if S[l-1] == 'C' and S[l-2] == 'A':
            print(b-1)
        else:
            print(b)
Buggy python submission (verdict: Runtime Error):
A, B = map(int, input().split())
import sys
b = format(B, 'b')
num = len(b)

cnt1 = [0]*num
for i in range(1, num):
    if (B+1)%(2**(i+1)) <= 2**i:
        continue
    else:
        if (B+1)%2 == 1:
            cnt1[i] = 1
if B % 4 == 1 or B % 4 == 2:
    cnt[0] = 1

c = ''
if A == 0:
    for i in range(num):
        if cnt1[i] == 0:
            c = '0' + c
        else:
            c = '1' + c
    print(int(c, 2))
    sys.exit()

if A == B:
    print(0)
    sys.exit()

cnt2 = [0]*num
for i in range(1, num):
    if A%(2**(i+1)) <= 2**i:
        continue
    else:
        if A%2 == 1:
            cnt2[i] = 1
if (A-1) % 4 == 1 or (A-1) % 4 == 2:
    cnt2[0] = 1

for i in range(num):
    if cnt1[i] == cnt2[i]:
        c = '0' + c
    else:
        c = '1' + c
print(int(c, 2))

Fixed submission:
import sys
A, B = map(int, input().split())

b = format(B, 'b')
num = len(b)
cnt1 = [0]*num
for i in range(1, num):
    if (B+1)%(2**(i+1)) <= 2**i:
        continue
    else:
        if (B+1)%2 == 1:
            cnt1[i] = 1
if B % 4 == 1 or B % 4 == 2:
    cnt1[0] = 1

c = ''
if A == 0:
    for i in range(num):
        if cnt1[i] == 0:
            c = '0' + c
        else:
            c = '1' + c
    print(int(c, 2))
    sys.exit()

cnt2 = [0]*num
for i in range(1, num):
    if A%(2**(i+1)) <= 2**i:
        continue
    else:
        if A%2 == 1:
            cnt2[i] = 1
if (A-1) % 4 == 1 or (A-1) % 4 == 2:
    cnt2[0] = 1

for i in range(num):
    if cnt1[i] == cnt2[i]:
        c = '0' + c
    else:
        c = '1' + c
print(int(c, 2))

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

b = format(B, 'b')
num = len(b)

cnt1 = [0]*num
for i in range(1, num):
    if (B+1)%(2**(i+1)) <= 2**i:
        continue
    else:
        if (B+1)%2 == 1:
            cnt1[i] = 1
if B % 4 == 1 or B % 4 == 2:
    cnt[0] = 1

c = ''
if A == 0:
    for i in range(num):
        if cnt1[i] == 0:
            c = '0' + c
        else:
            c = '1' + c
    print(int(c, 2))
    exit()

cnt2 = [0]*num
for i in range(1, num):
    if A%(2**(i+1)) <= 2**i:
        continue
    else:
        if A%2 == 1:
            cnt2[i] = 1
if (A-1) % 4 == 1 or (A-1) % 4 == 2:
    cnt2[0] = 1

for i in range(num):
    if cnt1[i] == cnt2[i]:
        c = '0' + c
    else:
        c = '1' + c
print(int(c, 2))

Fixed submission:
import sys
A, B = map(int, input().split())

b = format(B, 'b')
num = len(b)
cnt1 = [0]*num
for i in range(1, num):
    if (B+1)%(2**(i+1)) <= 2**i:
        continue
    else:
        if (B+1)%2 == 1:
            cnt1[i] = 1
if B % 4 == 1 or B % 4 == 2:
    cnt1[0] = 1

c = ''
if A == 0:
    for i in range(num):
        if cnt1[i] == 0:
            c = '0' + c
        else:
            c = '1' + c
    print(int(c, 2))
    sys.exit()

cnt2 = [0]*num
for i in range(1, num):
    if A%(2**(i+1)) <= 2**i:
        continue
    else:
        if A%2 == 1:
            cnt2[i] = 1
if (A-1) % 4 == 1 or (A-1) % 4 == 2:
    cnt2[0] = 1

for i in range(num):
    if cnt1[i] == cnt2[i]:
        c = '0' + c
    else:
        c = '1' + c
print(int(c, 2))
Buggy python submission (verdict: Runtime Error):
A, B, K = map(int, input().split())

ans = []

for i in range(1, max(A, B)):
    if A%i == 0 and B%i == 0:
        ans.append(i)
ans.reverse()
print(ans[K-1])

Fixed submission:
A, B, K = map(int, input().split())

ans = []

for i in range(1, min(A, B)+1):
    if A%i == 0 and B%i == 0:
        ans.append(i)
ans.sort(reverse=True)
print(ans[K-1])

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

ans = []

for i in range(1, max(A, B)):
    if A%i == 0 and B%i == 0:
        ans.append(i)
print(ans[K-1])

Fixed submission:
A, B, K = map(int, input().split())

ans = []

for i in range(1, min(A, B)+1):
    if A%i == 0 and B%i == 0:
        ans.append(i)
ans.sort(reverse=True)
print(ans[K-1])
Buggy python submission (verdict: Runtime Error):
N = int(input())
x = [0]*N
u = [0]*N
for i in range(N):
    x[i], u[i] = [int(i) for i in input().split()]

ans = 0
for i in range(N):
    if u[i] == 'JPY':
        ans += x[i]
    else:
        ans += x[i]*380000
print(ans)

Fixed submission:
N = int(input())
x = [0]*N
u = [0]*N
for i in range(N):
    x[i], u[i] = input().split()
y = list(map(float, x))

ans = 0
for i in range(N):
    if u[i] == 'JPY':
        ans += y[i]
    else:
        ans += y[i]*380000
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
h = [int(i) for i in input().split()]

dp = [float('inf')]*N
dp[0] = 0

for i in range(N):
    for j in range(1, K+1):
        if i+j < N:
            dp[i+j] = min(dp[i+j], dp[i] + abs(h[i]-h[i+j]))
print(dp[N-1])

Fixed submission:
N, K = map(int, input().split())
h = [int(i) for i in input().split()]

dp = [float('inf')]*N
dp[0] = 0

for i in range(N):
    for j in range(1, K+1):
        if i+j < N:
            dp[i+j] = min(dp[i+j], dp[i] + abs(h[i]-h[i+j]))
print(dp[N-1])
Buggy python submission (verdict: Time Limit Exceeded):
N, W = [int(i) for i in input().split()]
w, v = [0]*N, [0]*N
for i in range(N):
    w[i], v[i] = [int(i) for i in input().split()]

dp = [[-float('inf')]*(W+1) for i in range(N+1)]
for i in range(W+1):
    dp[0][i] = 0

for i in range(1, N+1):
    for j in range(W+1):
        if j >= w[i-1]:
            dp[i][j] = max(dp[i-1][j], dp[i-1][j-w[i-1]] + v[i-1])
        else:
            dp[i][j] = dp[i-1][j]
print(dp[N][W])

Fixed submission:
N, W = [int(i) for i in input().split()]
w, v = [0]*N, [0]*N
for i in range(N):
    w[i], v[i] = [int(i) for i in input().split()]

dp = [[-float('inf')]*(W+1) for i in range(N+1)]
for i in range(W+1):
    dp[0][i] = 0

for i in range(1, N+1):
    for j in range(W+1):
        if j >= w[i-1]:
            dp[i][j] = max(dp[i-1][j], dp[i-1][j-w[i-1]] + v[i-1])
        else:
            dp[i][j] = dp[i-1][j]
print(dp[N][W])
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = int(input())
B = int(input())
if N == 1:
  print('Hello World')
else:
  print(A+B)

Fixed submission:
import sys
N = int(input())
if N == 1:
  print('Hello World')
  sys.exit()
A = int(input())
B = int(input())
print(A+B)
Buggy python submission (verdict: Runtime Error):
import bisect
import sys
N, M = map(int, input().split())
ls = []
for i in range(1, int(M**(1/2))+1):
    if M%i == 0:
        ls.append(i)
ans = []
for x in ls:
    ans.append(x)
    ans.append(M//x)
print(ans[bisect.bisect_left(ans, N)])

Fixed submission:
import sys
N, M = map(int, input().split())
ls = []
for i in range(2, int(M**(1/2))+1):
    if M%i == 0:
        ls.append(i)
if N == 1:
    print(M)
    sys.exit()
ans = 1
for x in ls:
    if x >= N:
        ans = max(ans, M//x)
        continue
    if M//x >= N:
        ans = max(ans, x)
print(ans)
Buggy python submission (verdict: Runtime Error):
import sys
n = int(input())
w = []
for i in range(n):
  word = input()
  if word in w:
    print('No')
    sys.exit()
cur = w[0][-1]
for x in w[1:]:
  if cur != x[0]:
    print('No')
    sys.exit()
  cur = x[-1]
print('Yes')

Fixed submission:
import sys
n = int(input())
w = []
for i in range(n):
  word = input()
  if word in w:
    print('No')
    sys.exit()
  w.append(word)
cur = w[0][-1]
for x in w[1:]:
  if cur != x[0]:
    print('No')
    sys.exit()
  cur = x[-1]
print('Yes')
Buggy python submission (verdict: Runtime Error):
n = int(input())
ans = 0
for num in range(1, n):
    if num%2 == 1:
        continue
    ls = []
    for i in range(num+1):
        if num%i == 0:
            ls.append(i)
    if len(ls) == 8:
        ans += 1
print(ans)

Fixed submission:
N = int(input())
ans = 0
for i in range(1, N+1):
  num = 0
  if i%2 == 1:
    for j in range(1, i+1):
      if i%j == 0:
        num += 1
    if num == 8:
      ans += 1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
from itertools import accumulate

N, M =[int(i) for i in input().split()]
A = [int(i) for i in input().split()]

A.insert(0, 0)
a = list(accumulate(A))
ans = 0

for i in range(0, N):
    for j in range(i+1, N+1):
        if (a[j] - a[i])%M == 0:
            ans += 1
print(ans) 

Fixed submission:
from itertools import accumulate, combinations
from collections import Counter
import math

N, M =[int(i) for i in input().split()]
A = [int(i) for i in input().split()]

A.insert(0, 0)
a = list(accumulate(A))
for i in range(N+1):
    a[i] = a[i]%M

b = Counter(a)
m = b.most_common()
ans = 0

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

for x in m:
    if x[1] >= 2:
        ans += combinations_count(x[1], 2)
print(ans)
Buggy python submission (verdict: Runtime Error):
N = input()
for i in N:
  ans += int(i)
print(ans)


Fixed submission:
N = input()
ans = 0
for i in N:
  ans += int(i)
print('Yes' if int(N)%ans == 0 else 'No')
Buggy python submission (verdict: Runtime Error):
実装無理
import math
N, K = map(int, input().split())
A = [int(i) for i in input().split()]
ind = A.index(1)
if (ind%(K-1) + (N-ind-1)%(K-1)) <= K-1:
    print(math.floor(ind/(K-1)) + math.floor((N-ind-1)/(K-1))+1)
else:
    print(math.ceil(ind/(K-1)) + math.ceil((N-ind-1)/(K-1)))

Fixed submission:
import math
N, K = map(int, input().split())
A = [int(i) for i in input().split()]
ind = A.index(1)
print(math.ceil((ind + (N-ind-1))/(K-1)))

Buggy python submission (verdict: Runtime Error):
実装無理
import math
N, K = map(int, input().split())
A = [int(i) for i in input().split()]
ind = A.index(1)
if (ind%(K-1) + (N-ind-1)%(K-1))%(K-1) == 0:
    print(math.floor(ind/(K-1)) + math.floor((N-ind-1)/(K-1))+1)
else:
    print(math.ceil(ind/(K-1)) + math.ceil((N-ind-1)/(K-1)))

Fixed submission:
import math
N, K = map(int, input().split())
A = [int(i) for i in input().split()]
ind = A.index(1)
print(math.ceil((ind + (N-ind-1))/(K-1)))
Buggy python submission (verdict: Runtime Error):
A, B = map(int input().split())
if max(A, B) > 8:
    print(':(')
else:
    print('Yay!')

Fixed submission:
A, B = map(int, input().split())
if max(A, B) > 8:
    print(':(')
else:
    print('Yay!')
Buggy python submission (verdict: Runtime Error):
N = int(input())
S = input().strip()
ans= []

for i in range(1, N-1):
    a = S[:i]
    b = S[i+1:]
    for j in a:
        num = 0
        if j in b:
            num += 1
        ans.append(num)
print(max(ans))



Fixed submission:
n = int(input())
s = input()

ans = 0
for i in range(1, n):
    cur = 0
    a = set(s[:i])
    b = set(s[i:])
    for A in a:
        if A in b:
            cur += 1
    ans = max(ans, cur)
print(ans)
Buggy python submission (verdict: Runtime Error):
a, b, c, d = [int(i) for i in input().split()]

if abs(a-c) <= d:
    print('Yes')
elif abs(a-b) <= d and abs()-c) <= d:
    print('Yes')
else:
    print('No')

Fixed submission:
a, b, c, d = [int(i) for i in input().split()]

if abs(a-c) <= d:
    print('Yes')
elif abs(a-b) <= d and abs(b-c) <= d:
    print('Yes')
else:
    print('No')

Buggy python submission (verdict: Runtime Error):
a, b c, d = [int(i) for i in input().split()]

if (a-c) <= d:
    print('Yes')
elif (a-b) <= d and (b-c) <= d:
    print('Yes')
else:
    print('No')

Fixed submission:
a, b, c, d = [int(i) for i in input().split()]

if abs(a-c) <= d:
    print('Yes')
elif abs(a-b) <= d and abs(b-c) <= d:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Time Limit Exceeded):
import bisect
N = int(input())
X = [int(i) for i in input().split()]
ans = []
for i in range(N):
    num = X.pop(i)
    a = X[:]
    a.sort()
    ans.append(a[(N-1)//2])
    X.insert(i, num)
print(*ans, sep='\n')

Fixed submission:
N = int(input())
X = [int(i) for i in input().split()]
a = X[:]
a.sort()
l = a[N//2-1]
r = a[N//2]
if l == r:
    for i in range(N):
        print(l)
else:
    for i in range(N):
        if X[i] <= l:
            print(r)
        elif X[i] >= r:
            print(l)
Buggy python submission (verdict: Time Limit Exceeded):
N = input()
A = [int(i) for i in input().split()]

for i in range(len(A)):
    B = A[:i] + A[i+1:]
    B.append(0)
    B = [0] + B
    ans = 0
    for x, y in zip(B[:-1], B[1:]):
        ans += abs(x-y)
    print(ans)



Fixed submission:
N = int(input())
A = [int(i) for i in input().split()]

B = [0] + A + [0]
ans = 0
for x, y in zip(B[:-1], B[1:]):
    ans += abs(x-y)
for i in range(N):
    print(ans - abs(B[i+1]-B[i]) - abs(B[i+2]-B[i+1]) + abs(B[i+2]-B[i]))
Buggy python submission (verdict: Runtime Error):
A, B = map(int, input().split())
ans = 0
for x in range(A, B+1):
    if str(x) == str(x).reverse():
        ans += 1
print(ans)

Fixed submission:
A, B = map(int, input().split())
ans = 0
for x in range(A, B+1):
    if str(x) == str(x)[::-1]:
        ans += 1
print(ans)