Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
import copy

n, q = map(int, input().split())
s = input()

cnt = [0]
for i in range(n):
    if s[i] == 'A' and s[i+1] == 'C':
        cnt.append(cnt[-1] + 1)
    else:
        cnt.append(cnt[-1])

for i in range(q):
    l, r = map(int, input().split())
    print(cnt[r-1] - cnt[l-1])

Fixed submission:
import copy

n, q = map(int, input().split())
s = input()

cnt = [0]
for i in range(n-1):
    if s[i] == 'A' and s[i+1] == 'C':
        cnt.append(cnt[-1] + 1)
    else:
        cnt.append(cnt[-1])

for i in range(q):
    l, r = map(int, input().split())
    print(cnt[r-1] - cnt[l-1])

Buggy python submission (verdict: Time Limit Exceeded):
n, q = map(int, input().split())
s = input()

flg = [False]*(n-1)
for i in range(n-1):
    if s[i] == 'A' and s[i+1] == 'C':
        flg[i] = True
        
for i in range(q):
    l, r = map(int, input().split())
    print(sum(flg[l-1:r-1]))

Fixed submission:
import copy

n, q = map(int, input().split())
s = input()

cnt = [0]
for i in range(n-1):
    if s[i] == 'A' and s[i+1] == 'C':
        cnt.append(cnt[-1] + 1)
    else:
        cnt.append(cnt[-1])

for i in range(q):
    l, r = map(int, input().split())
    print(cnt[r-1] - cnt[l-1])
Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int,input().split())
ab = []
for i in range(n):
    ab.append(list(map(int,input().split())))

ab = sorted(ab, key=lambda x:(x[0], x[1]))

cost = 0
while m > 0:
    a, b = ab.pop(0)
    if b > m:
        cost += m * a
        m = 0
    else:
        cost += b * a
        m -= b
print(cost)

Fixed submission:
n, m = map(int,input().split())
ab = []
for i in range(n):
    ab.append(list(map(int,input().split())))

ab = sorted(ab, key=lambda x:(x[0], x[1]))

cost = 0
while m > 0:
    a, b = ab.pop(0)
    if b > m:
        cost += m * a
        m = 0
    else:
        cost += b * a
        m -= b
print(cost)
Buggy python submission (verdict: Runtime Error):
import copy
import numpy as np

n = int(input())
v = list(map(int,input().split()))
a = v[0::2] 
b = v[1::2]

cnta = np.zeros(10**5+1, dtype=int)
cntb = np.zeros(10**5+1, dtype=int)
for i in range(n//2):
    ca, cb = a[i], b[i]
    cnta[ca] += 1
    cntb[cb] += 1
print(a, cnta[:5])
print(b, cntb[:5])
la = np.zeros((2,2), dtype=int)
lb = np.zeros((2,2), dtype=int)
for i in range(2):
    ia = cnta.argmax()
    ib = cntb.argmax()
    la[i][0], la[i][1] = ia, cnta[ia]
    lb[i][0], lb[i][1] = ib, cntb[ib]
    cnta[ia] = -1
    cntb[ib] = -1
print(la)
print(lb)
if la[0][0] != lb[0][0]:
    ans = n//2 - la[0][1] + n//2 - lb[0][1]
elif la[0][1] > lb[0][1]:
    ans = min(n//2 - la[0][1] + n//2 - lb[1][1], n//2 - la[1][1] + n//2 - lb[0][1])
print(ans)

Fixed submission:
import copy
import numpy as np

n = int(input())
v = list(map(int,input().split()))
a = v[0::2] 
b = v[1::2]

cnta = np.zeros(10**5+1, dtype=int)
cntb = np.zeros(10**5+1, dtype=int)
for i in range(n//2):
    ca, cb = a[i], b[i]
    cnta[ca] += 1
    cntb[cb] += 1

la = np.zeros((2,2), dtype=int)
lb = np.zeros((2,2), dtype=int)
for i in range(2):
    ia = cnta.argmax()
    ib = cntb.argmax()
    la[i][0], la[i][1] = ia, cnta[ia]
    lb[i][0], lb[i][1] = ib, cntb[ib]
    cnta[ia] = 0
    cntb[ib] = 0

if la[0][0] != lb[0][0]:
    ans = n//2 - la[0][1] + n//2 - lb[0][1]
else:
    ans = min(n//2 - la[0][1] + n//2 - lb[1][1], n//2 - la[1][1] + n//2 - lb[0][1])
print(ans)
Buggy python submission (verdict: Runtime Error):
n, k = map(int,input().split())
a = [int(i) for i in input().split()]

if n == k:
    cnt == 1
else:
    cnt = (n - k) // (k-1) + 2
print(cnt)

Fixed submission:
n, k = map(int,input().split())
a = [int(i) for i in input().split()]

if n == k:
    cnt = 1
else:
    cnt = (n - 2) // (k-1) + 1
print(cnt)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()
ans = 10**6
for i in range(n):
    a, b = s[:i], s[i+1:]
    ans = min(ans, a.count('W') + b.count('E'))
print(ans)

Fixed submission:
n = int(input())
s = input()
e_l, e_sum = [], 0
w_l, w_sum = [], 0
for i in range(n):
    if s[i] == 'E':
        e_sum += 1
    else:
        w_sum += 1
    e_l.append(e_sum)
    w_l.append(w_sum)
for i in range(n):
    if i == 0:
        ans = e_l[n-1] - e_l[0]
    elif i == n:
        ans = max(ans, w_l[n-2])
    else:
        ans = min(ans, e_l[n-1] - e_l[i] + w_l[i-1])
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()
ans = 10**6
for i in range(n):
    a, b = s[:i], s[i+1:]
    ans = min(ans, a.count('W') + b.count('E'))
print(ans)

Fixed submission:
n = int(input())
s = input()
e_l, e_sum = [], 0
w_l, w_sum = [], 0
for i in range(n):
    if s[i] == 'E':
        e_sum += 1
    else:
        w_sum += 1
    e_l.append(e_sum)
    w_l.append(w_sum)
for i in range(n):
    if i == 0:
        ans = e_l[n-1] - e_l[0]
    elif i == n:
        ans = max(ans, w_l[n-2])
    else:
        ans = min(ans, e_l[n-1] - e_l[i] + w_l[i-1])
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
k = int(input())
 
sl = [s]
for i in range(len(s)):
    for j in range(i+1, len(s)+1):
        ss = s[i:j]
        sl.append(ss)
sl = sorted(list(set(sl)))
print(sl[k-1])

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

sl = [s]
for i in range(len(s)):
    for j in range(i+1, len(s)+1):
        if j - i > k:
            break
        ss = s[i:j]
        sl.append(ss)
sl = sorted(list(set(sl)))
print(sl[k-1])

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
k = int(input())

sl = [s]
for i in range(len(s)):
    for j in range(i+1, len(s)+1):
        ss = s[i:j]
        sl.append(ss)
sl = sorted(list(set(sl)))
print(sl[k-1])

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

sl = [s]
for i in range(len(s)):
    for j in range(i+1, len(s)+1):
        if j - i > k:
            break
        ss = s[i:j]
        sl.append(ss)
sl = sorted(list(set(sl)))
print(sl[k-1])
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
x = [int(i) for i in input().split()]

for i in range(n):
    y = x[:i] + x[i+1:]
    y.sort()
    print(y[n//2-1])


Fixed submission:
n = int(input())
x = [int(i) for i in input().split()]
y = sorted(x)
a , b = y[n//2-1], y[n//2]
for i in x:
    if i > a:
        print(a)
    else:
        print(b)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
x = [int(i) for i in input().split()]

for i in range(n):
    y = x[:i] + x[i+1:]
    y.sort()
    print(y[n//2-1])

Fixed submission:
n = int(input())
x = [int(i) for i in input().split()]
y = sorted(x)
a , b = y[n//2-1], y[n//2]
for i in x:
    if i > a:
        print(a)
    else:
        print(b)
Buggy python submission (verdict: Runtime Error):
from queue import Queue
import itertools
import numpy as np
 
R, C = map(int, input().split())
sy, sx = 1, 1
gy, gx = R, C
 
field = [["#"] * (C + 2)] + \
        [list("#" + input() + "#") for i in range(R)] + \
        [["#"] * (C + 2)]
dxy = [(0,1), (0,-1), (1,0), (-1,0)]
flg = False
cnt = 0
 
field_1d = list(itertools.chain.from_iterable(field))
field01 = [1 if i == '.' else 0 for i in field_1d]
dot_num = np.array(field01).sum()
 
q = Queue()
q.put([sy, sx])
field[sy][sx] = 0
 
while flg == False:
    yx = q.get()
    cnt = field[yx[0]][yx[1]]
    for dy, dx in dxy:
        y_n, x_n = yx[0] + dy, yx[1] + dx
        if y_n == gy and x_n == gx:
            field[y_n][x_n] = cnt + 1
            flg = True
            print(dot_num - (cnt+2))
        if field[y_n][x_n] == '#':
            continue
        if field[y_n][x_n] == '.':
            q.put([y_n, x_n])
            field[y_n][x_n] = cnt + 1
if flg == False:
    print(-1)

Fixed submission:
n = int(input())
a = int(input())
if n % 500 <= a:
    print('Yes')
else:
    print('No')

Buggy python submission (verdict: Runtime Error):
from queue import Queue
import itertools
import numpy as np

R, C = map(int, input().split())
sy, sx = 1, 1
gy, gx = R, C

field = [["#"] * (C + 2)] + \
        [list("#" + input() + "#") for i in range(R)] + \
        [["#"] * (C + 2)]
dxy = [(0,1), (0,-1), (1,0), (-1,0)]
flg = False
cnt = 0

field_1d = list(itertools.chain.from_iterable(field))
field01 = [1 if i == '.' else 0 for i in field_1d]
dot_num = np.array(field01).sum()

q = Queue()
q.put([sy, sx])
field[sy][sx] = 0

while flg == False:
    yx = q.get()
    cnt = field[yx[0]][yx[1]]
    for dy, dx in dxy:
        y_n, x_n = yx[0] + dy, yx[1] + dx
        if y_n == gy and x_n == gx:
            field[y_n][x_n] = cnt + 1
            flg = True
            print(dot_num - (cnt+2))
            break
        if field[y_n][x_n] == '#':
            continue
        if field[y_n][x_n] == '.':
            q.put([y_n, x_n])
            field[y_n][x_n] = cnt + 1
    if flg:
        print('------')
        break
if flg == False:
    print(-1)

Fixed submission:
n = int(input())
a = int(input())
if n % 500 <= a:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Time Limit Exceeded):
n, h = map(int,input().split())
a = []
b = []
for i in range(n):
    ca, cb = map(int,input().split())
    a.append(ca)
    b.append(cb)

a.sort(reverse=True)
b.sort(reverse=True)
cnt = 0
while h > 0:
    if b and b[0] > a[0]:
        h -= b.pop(0)
        cnt += 1
    else:
        cnt += h//a[0]
        h -= a[0] * (h//a[0])
        if h > 0:
            h -= a[0]
            cnt += 1
print(cnt)

Fixed submission:
n, h = map(int,input().split())
a = []
b = []
for i in range(n):
    ca, cb = map(int,input().split())
    a.append(ca)
    b.append(cb)

amax = max(a)
b.sort(reverse=True)
cnt = 0
while h > 0:
    if b and b[0] > amax:
        h -= b.pop(0)
        cnt += 1
    else:
        cnt += h//amax
        h -= amax * (h//amax)
        if h > 0:
            h -= amax
            cnt += 1
print(cnt)

Buggy python submission (verdict: Runtime Error):
n, h = map(int,input().split())
a = []
b = []
for i in range(n):
    ca, cb = map(int,input().split())
    a.append(ca)
    b.append(cb)

a.sort(reverse=True)
b.sort(reverse=True)
cnt = 0
while h > 0:
    if b[0] > a[0]:
        h -= b.pop(0)
        cnt += 1
    else:
        cnt += h//a[0]
        h -= a[0] * h//a[0]
        if h > 0:
            h -= a[0]
            cnt += 1
print(cnt)

Fixed submission:
n, h = map(int,input().split())
a = []
b = []
for i in range(n):
    ca, cb = map(int,input().split())
    a.append(ca)
    b.append(cb)

amax = max(a)
b.sort(reverse=True)
cnt = 0
while h > 0:
    if b and b[0] > amax:
        h -= b.pop(0)
        cnt += 1
    else:
        cnt += h//amax
        h -= amax * (h//amax)
        if h > 0:
            h -= amax
            cnt += 1
print(cnt)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
csf = [list(map(int,input().split())) for i in range(n-1)]
t = [[0] * n for i in range(n)]
for i in range(n-1):
    cc, cs, cf = csf[i][0], csf[i][1], csf[i][2]
    t[i][i] = cs
    for j in range(1+i):
        cs = csf[i][1]
        while t[j][i] > cs:
            cs += cf
        t[j][i+1] = cs + cc 
for i in range(n):
    print(t[i][n-1])

Fixed submission:
n = int(input())
csf = [list(map(int,input().split())) for i in range(n-1)]
t = [[0] * n for i in range(n)]
for i in range(n-1):
    cc, cs, cf = csf[i][0], csf[i][1], csf[i][2]
    t[i][i] = cs
    for j in range(1+i):
        cs = csf[i][1]
        while t[j][i] > cs:
            cs += cf
        t[j][i+1] = cs + cc 
for i in range(n):
    print(t[i][n-1])
Buggy python submission (verdict: Runtime Error):
s = list(input())
t = list(input())

s.sort()
t.sort(reverse=True)

flg = True
for i in range(len(s)):
    if ord(s[i]) > ord(t[i]):
        flg = False
        break
    if ord(s[i]) < ord(t[i]):
        break
        
print('Yes') if flg else print('No')
        

Fixed submission:
s = list(input())
t = list(input())

s.sort()
t.sort(reverse=True)

flg = False
for i in range(len(s)):
    if i >= len(t):
        break
    if ord(s[i]) > ord(t[i]):
        break
    if ord(s[i]) < ord(t[i]):
        flg = True
        break
    if i == len(s)-1 and i < len(t)-1:
        flg = True
        break
        
print('Yes') if flg else print('No')
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
s = set(a)

ans = 0
for i in s:
    c = a.count(i)
    if c < i:
        ans += c
    elif c >= i:
        ans += c - i
print(ans)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
s = set(a)

d = {}
for i in s:
    d[i] = 0
for i in a:
    d[i] += 1

ans = 0
for i in d:
    c = d[i]
    if c < i:
        ans += c
    elif c >= i:
        ans += c - i
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson
from scipy.sparse import csr_matrix

n = int(input())
a = [list(map(int,input().split())) for i in range(n)]

arr = np.array(a)
csr = csr_matrix(arr)
f = floyd_warshall(csr)

if np.sum(arr == f) != n**2:
    print(-1)
    exit()
total = np.sum(arr) // 2
for i in range(n-1):
    for j in range(i+1,n):
        for x in range(n):
            if x == i or x == j:
                continue
            if a[i][j] == a[i][x] + a[j][x]:
                total -= a[i][j]
print(total)

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

total = 0
for i in range(n-1):
    for j in range(i+1,n):
        flg = True
        for x in range(n):
            if x == i or x == j:
                continue
            if a[i][j] > a[i][x] + a[j][x]:
                print(-1)
                exit()
            elif a[i][j] == a[i][x] + a[j][x]:
                flg = False
                break
        if flg:
            total += a[i][j]
            
print(total)
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))

cnt = [0]*10**5+5
for i in a:
    cnt[i] += 1

ans = 0
for i in range(1, 10**5+3):
    ans = max(ans, sum(cnt[i-1:i+2]))
print(ans)

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

cnt = [0]*(10**5+5)
for i in a:
    cnt[i] += 1

ans = 0
for i in range(1, 10**5+3):
    ans = max(ans, sum(cnt[i-1:i+2]))
print(ans)
Buggy python submission (verdict: Runtime Error):
x, a, b = map(int,input().split())
print('A') if abs(x-a) < abs(s-b) else print('B')

Fixed submission:
x, a, b = map(int,input().split())
print('A') if abs(x-a) < abs(x-b) else print('B')
Buggy python submission (verdict: Runtime Error):
n = int(input())
b = m.bit_length() - 1
ans = int('0b1'+'0'*m, 2)
print(ans)

Fixed submission:
n = int(input())
b = n.bit_length() - 1
ans = int('0b1'+'0'*b, 2)
print(ans)
Buggy python submission (verdict: Runtime Error):
n, k = map(int,input().split())
a = list(map(int,input().split()))
a.sort(reverse=True)
print(a[0]+a[1]+a[2])

Fixed submission:
n, k = map(int,input().split())
a = list(map(int,input().split()))
a.sort(reverse=True)

ans = 0
for i in range(k):
    ans += a[i]
print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))

total = sum(a)
s = 0
i = 0
ans = total + 1
while True:
    s += a[i]
    total -= a[i]
    ans = min(ans, abs(s - total))
    i += 1
print(ans)

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

s = a[0]
t = sum(a) - a[0]

i = 0
ans = abs(s - t)
for i in range(1, n-1):
    s += a[i]
    t -= a[i]
    ans = min(ans, abs(s - t))
    i += 1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = []
for i in range(n):
    a.append(int(input()) - 1)

visited = [False] * n
f = 0
visited[f] = True
cnt = 0
while True:
    cnt += 1
    t = a[f]
    if t == 1:
        flg = True
        break
    if visited[t]:
        flg = False
        break
    f = t
print(cnt) if flg else print(-1)

Fixed submission:
n = int(input())
a = []
for i in range(n):
    a.append(int(input()) - 1)

visited = [False] * n
f = 0
visited[f] = True
cnt = 0
while True:
    cnt += 1
    t = a[f]
    if t == 1:
        flg = True
        break
    if visited[t]:
        flg = False
        break
    visited[t] = True
    f = t
print(cnt) if flg else print(-1)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = []
for i in range(n):
    a.append(int(input()) - 1)

visited = [False] * n
f = 0
cnt = 0
visited[f] = True
flg = True
while True:
    t = a[f]
    if visited[t]:
        flg = False
        break
    cnt += 1
    if t == 1:
        break
    f = t
print(cnt) if flg else print(-1)

Fixed submission:
n = int(input())
a = []
for i in range(n):
    a.append(int(input()) - 1)

visited = [False] * n
f = 0
visited[f] = True
cnt = 0
while True:
    cnt += 1
    t = a[f]
    if t == 1:
        flg = True
        break
    if visited[t]:
        flg = False
        break
    visited[t] = True
    f = t
print(cnt) if flg else print(-1)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = []
for i in range(n):
    a.append(int(input()) - 1)

visited = [False] * n
f = 0
cnt = 0
visited[f] = True
flg = True
while True:
    t = a[f]
    if visited[t]:
        flg = False
        break
    else:
        cnt += 1
        if t == 1:
            break
        f = t
print(cnt) if flg else print(-1)

Fixed submission:
n = int(input())
a = []
for i in range(n):
    a.append(int(input()) - 1)

visited = [False] * n
f = 0
visited[f] = True
cnt = 0
while True:
    cnt += 1
    t = a[f]
    if t == 1:
        flg = True
        break
    if visited[t]:
        flg = False
        break
    visited[t] = True
    f = t
print(cnt) if flg else print(-1)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = []
for i in range(n):
    a.append(int(input()) - 1)

visited = [False] * n
f = 0
cnt = 0
visited[f] = True
flg = True
while True:
    t = a[f]
    if visited[t]:
        flg = False
        break
    else:
        cnt += 1
        if t == 1:
            break
        f = t
print(cnt) if flg else print(-1)

Fixed submission:
n = int(input())
a = []
for i in range(n):
    a.append(int(input()) - 1)

visited = [False] * n
f = 0
visited[f] = True
cnt = 0
while True:
    cnt += 1
    t = a[f]
    if t == 1:
        flg = True
        break
    if visited[t]:
        flg = False
        break
    visited[t] = True
    f = t
print(cnt) if flg else print(-1)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = [int(input()) for i in range(n)]

ans = -1
for i in range(2**n):
    cnt = 0
    for j in range(n):
        if i >> j & 1:
            cnt += a[j]
    if cnt % 10 == 0:
        cnt = 0
    ans= max(ans, cnt)
print(ans)

Fixed submission:
n = int(input())
a = [int(input()) for i in range(n)]
a.sort()

ans = sum(a)
if ans % 10 != 0:
    print(ans)
    exit()
    
flg = False
for i in range(n):
    if a[i] % 10 != 0:
        ans -= a[i]
        flg = True
        break
print(ans) if flg else print(0)
Buggy python submission (verdict: Runtime Error):
x, y =  = map(int,input().split())
if abs(x-y) < 1:
    print('Brown')
else:
    print('Alice')

Fixed submission:
x, y = map(int,input().split())
if abs(x-y) <= 1:
    print('Brown')
else:
    print('Alice')
Buggy python submission (verdict: Runtime Error):
a, b, c =  = map(int,input().split())
print('YES') if a == b == c else print('NO')

Fixed submission:
a, b, c = map(int,input().split())
print('YES') if b - a == c - b else print('NO')
Buggy python submission (verdict: Runtime Error):
K, S = map(int, input().split())
 
cnt = 0
for i in range(K+1):
    for j in range(K+1):
        k = S - i - j
        if k >= 0 and k <= K:
            cnt += 1
print(cnt)

Fixed submission:
s = input()
a = [s[0:5], s[6:13], s[14:]]
print(' '.join(a))
Buggy python submission (verdict: Time Limit Exceeded):
K, S = map(int, input().split())
 
cnt = 0
for i in range(K+1):
    flg = False
    for j in range(K+1):
        if flg == True:
            break
        for k in range(K+1):
            ijk_sum = i + j + k
            if ijk_sum == S:
                flg = True
                lim_tmp = min(K - j, k)
                cnt += lim_tmp + 1
                break
print(cnt)

Fixed submission:
K, S = map(int, input().split())
 
cnt = 0
for i in range(K+1):
    for j in range(K+1):
        k = S - i - j
        if k >= 0 and k <= K:
            cnt += 1
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
K, S = map(int, input().split())
 
cnt = 0
for i in range(K+1):
    for j in range(K+1):
        for k in range(K+1):
            ijk_sum = i + j + k
            if ijk_sum == S:
                cnt +=1
                break
print(cnt)

Fixed submission:
K, S = map(int, input().split())
 
cnt = 0
for i in range(K+1):
    for j in range(K+1):
        k = S - i - j
        if k >= 0 and k <= K:
            cnt += 1
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
K, S = map(int, input().split())

cnt = 0
for i in range(K+1):
    for j in range(K+1):
        for k in range(K+1):
          ijk_sum = i + j + k
          if ijk_sum == S:
              cnt +=1
print(cnt)

Fixed submission:
K, S = map(int, input().split())
 
cnt = 0
for i in range(K+1):
    for j in range(K+1):
        k = S - i - j
        if k >= 0 and k <= K:
            cnt += 1
print(cnt)
Buggy python submission (verdict: Runtime Error):
a, o, b = input().split()
if o = '+':
    print(int(a) + int(b))
else:
    print(int(a) - int(b))

Fixed submission:
a, o, b = input().split()
if o == '+':
    print(int(a) + int(b))
else:
    print(int(a) - int(b))
Buggy python submission (verdict: Runtime Error):
def check(l, r):
    th = 1 + (r - l + 1) // 2 
    for i in range(26):
        if cnt[i] >= th:
            return True
    return False

s = input()
n = len(s)
si = [0] * n
for i in range(n):
    si[i] = ord(s[i]) - 97

l, r = 0, 2
cnt = [0]*26
for i in range(3):
    cnt[si[i]] += 1
while l < n-2 and r < n:
    # print(l, r, cnt)
    if check(l, r):
        print(l+1, r+1)
        exit()
    elif max(cnt) == (r-l) // 2:
        r += 1
        if r < n:
            cnt[si[r]] += 1
    else:
        cnt[si[l]] -= 1
        l += 1     
print(-1, -1)

Fixed submission:
def check(l, r):
    th = 1 + (r - l + 1) // 2 
    for i in range(26):
        if cnt[i] >= th:
            return True
    return False

s = input()
n = len(s)
si = [0] * n
for i in range(n):
    si[i] = ord(s[i]) - 97

l, r = 0, 1
cnt = [0]*26
for i in range(2):
    cnt[si[i]] += 1
while l < n-1 and r < n:
    if check(l, r):
        print(l+1, r+1)
        exit()
    elif max(cnt) == 1 + (r - l + 1) // 2 or r-l == 1:
        r += 1
        if r < n:
            cnt[si[r]] += 1
    else:
        cnt[si[l]] -= 1
        l += 1     
print(-1, -1)

Buggy python submission (verdict: Runtime Error):
def check(l, r):
    th = 1 + (r - l + 1) // 2 
    for i in range(26):
        if cnt[i] >= th:
            return True
    return False

s = input()
n = len(s)
si = [0] * n
for i in range(n):
    si[i] = ord(s[i]) - 97

l, r = 0, 2
cnt = [0]*26
for i in range(3):
    cnt[si[i]] += 1
while l < n-2 and r < n:
    # print(l, r, cnt)
    if check(l, r):
        print(l, r)
        exit()
    elif max(cnt) == (r-l) // 2:
        r += 1
        if r < n:
            cnt[si[r]] += 1
    else:
        cnt[si[l]] -= 1
        l += 1     
print(-1, -1)

Fixed submission:
def check(l, r):
    th = 1 + (r - l + 1) // 2 
    for i in range(26):
        if cnt[i] >= th:
            return True
    return False

s = input()
n = len(s)
si = [0] * n
for i in range(n):
    si[i] = ord(s[i]) - 97

l, r = 0, 1
cnt = [0]*26
for i in range(2):
    cnt[si[i]] += 1
while l < n-1 and r < n:
    if check(l, r):
        print(l+1, r+1)
        exit()
    elif max(cnt) == 1 + (r - l + 1) // 2 or r-l == 1:
        r += 1
        if r < n:
            cnt[si[r]] += 1
    else:
        cnt[si[l]] -= 1
        l += 1     
print(-1, -1)
Buggy python submission (verdict: Runtime Error):
def A(x):
  return x + x**2 + x**3



def main():
  print(A(input()))


if __name__ == '__main__':
  main()


Fixed submission:
def A(x):
  return x + x**2 + x**3


def B(n, k, p_list):
  pass


def C(N):
  pass


def main():
  print(A(int(input())))
  # letter = input()
  # A(letter)
  # for x in ['A', 'Z', 'a', 'z']:
  #   A(x)


if __name__ == '__main__':
  main()