Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
N = int(input())
H = list(map(int, input().split()))  
H = list(reversed(H))  
if N==1:
    ans='Yes'
else:         
    for i in range(1, N):
        if H[i] - H[i-1] >= 2: #
            ans='No'
            break   
        elif H[i] - H[i-1] == 1: # 1 smaller
            H[i] -= 1
print(ans)  

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

H = list(reversed(H)) 
ans='Yes'
if N==1:
    ans='Yes'
else:         
    for i in range(1, N):
        if H[i] - H[i-1] >= 2: #
            ans='No'
            break   
        elif H[i] - H[i-1] == 1: # 1 smaller
            H[i] -= 1
print(ans)
Buggy python submission (verdict: Runtime Error):
L=int(input())
R=int(input())

if R - L >= 672:
    ans = 0
elif R * L < 2019:
    ans = L*(L+1)
else:
    ans = 2018
    for i in range(L, R):
        for j in range(L+1, R+1):
            mod=(i*j)%2019
            if mod < ans:
                ans = mod
print(ans)
    

Fixed submission:
L, R = list(map(int, input().split()))  


if R - L >= 672:
    ans = 0
elif R * L < 2019:
    ans = L*(L+1)
else:
    ans = 2018
    for i in range(L, R):
        for j in range(L+1, R+1):
            mod=(i*j)%2019
            if mod < ans:
                ans = mod
print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
W = list(map(int, input().split())) 

min_diff = 1000
tot_wt = sum(W)
for i in range(2**N):
    i_bit = list(map(int, list(np.binary_repr(i, N))))
    s1= np.dot(i_bit, W)
    s2 = tot_wt - s1
    if min_diff > abs(s1-s2):
        min_diff = abs(s1-s2)
        print(min_diff, i_bit)

Fixed submission:
N = int(input())
W = list(map(int, input().split())) 
min_diff = 1000
for i in range(N):
    s1 = sum(W[0:i+1])
    s2 = sum(W) - s1
    if min_diff > abs(s1-s2):
        min_diff = abs(s1-s2)
print(min_diff)
Buggy python submission (verdict: Runtime Error):
import numpy as np
N, K = map(int, input().split())

P=0
for i in range(1,N+1):
    if i < K:
        p = float((1/N)*(1/2)**np.ceil(np.log2(K/i)))
    elif  i > K:
        p = float(1/N)
    P += p
print(P)        

Fixed submission:
import numpy as np
N, K = map(int, input().split())

P=0
for i in range(1,N+1):
    if i < K:
        p = float((1/N)*(1/2)**np.ceil(np.log2(K/i)))
    elif  i >= K:
        p = float(1/N)
    P += p
print(P)
Buggy python submission (verdict: Runtime Error):
N = int(input())
v = list(map(int,input().split()))

v.sort()

res = v[0]

for i in range(i,N):
    res = (res + v[i]) / 2 

print(res)


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

v.sort()

res = v[0]

for i in range(1,N):
    res = (res + v[i]) / 2 

print(res)
Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: UTF-8 -*-
# ABC073_C

N = int(input())
list = []

for i in range(0, N, 1):
    x = input()
    if (x not in list):
        list.append(x)
    else:
        list.remove(x)
print(len(list))


Fixed submission:
# -*- coding: UTF-8 -*-
# ABC073_C

N = int(input())
ans = set()

for i in range(N):
    x = int(input())
    if (x in ans):
        ans.remove(x)
    else:
        ans.add(x)
print(len(ans))
Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: UTF-8 -*-
# ABC066_C

N = int(input())
tmp = input()
list = []
list = tmp.split()

ans = []
if (N % 2 == 0):
    for i in range(1, N + 1):
        x = list[i - 1]
        if (i % 2 != 0):
            ans.append(x)
        else:
            ans.insert(0, x)
else:
    for i in range(1, N + 1):
        x = list[i - 1]
        if (i % 2 != 0):
            ans.insert(0, x)
        else:
            ans.append(x)
for i in range(0, N):
    print(ans[i], end=" ")


Fixed submission:
# -*- coding: UTF-8 -*-
# ABC066_C

N = int(input())
tmp = input()
list = []
list = tmp.split()

if (N % 2 == 0):
    for i in range(N - 1, -1, -2):
        print(list[i], end=" ")
    for i in range(0, N, 2):
        print(list[i], end=" ")
else:
    for i in range(N - 1, -1, -2):
        print(list[i], end=" ")
    for i in range(1, N, 2):
        print(list[i], end=" ")
Buggy python submission (verdict: Runtime Error):
num1,num2 = map(int,input(),split())

 
num3 = num1 + num2
num4 = num1 - num2
num5 = num1 * num2
num6 = [num3, num4, num5]
 
print(max(num6))

Fixed submission:
num1,num2 = map(int,input().split())
 
num3 = num1 + num2
num4 = num1 - num2
num5 = num1 * num2
num6 = [num3, num4, num5]
 
print(max(num6))

Buggy python submission (verdict: Runtime Error):
num1,num2 = map(int,input(),split())
while str(num1).isdigit() == False:

    

num3 = int(num1) + int(num2)
num4 = int(num1) - int(num2)
num5 = int(num1) * int(num2)
num6 = [num3, num4, num5]
 
print(max(num6))

Fixed submission:
num1,num2 = map(int,input().split())
 
num3 = num1 + num2
num4 = num1 - num2
num5 = num1 * num2
num6 = [num3, num4, num5]
 
print(max(num6))

Buggy python submission (verdict: Runtime Error):
num1 = input("数字を入力してください")
while str(num1).isdigit() == False:
    print("error")
    num1 = input("数字を入力してください")
    
num2 = input("数字を入力してください")
while str(num2).isdigit() == False:
    print("error")
    num2 = input("数字を入力してください")
    
num3 = int(num1) + int(num2)
num4 = int(num1) - int(num2)
num5 = int(num1) * int(num2)
num6 = [num3, num4, num5]

if -100 < int(num1) < 100 and -100 < int(num2) < 100:
    print(max(num6))

Fixed submission:
num1,num2 = map(int,input().split())
 
num3 = num1 + num2
num4 = num1 - num2
num5 = num1 * num2
num6 = [num3, num4, num5]
 
print(max(num6))

Buggy python submission (verdict: Runtime Error):
num1 = int(input())
num2 = int(input())
num3 = num1 + num2
num4 = num1 - num2
num5 = num1 * num2
num6 = [num3, num4, num5]
print(max(num6))

Fixed submission:
num1,num2 = map(int,input().split())
 
num3 = num1 + num2
num4 = num1 - num2
num5 = num1 * num2
num6 = [num3, num4, num5]
 
print(max(num6))

Buggy python submission (verdict: Runtime Error):
num1 = int(input())
num2 = int(input())
num3 = num1 + num2
num4 = num1 - num2
num5 = num1 * num2
num6 = [num3, num4, num5]
print(max(num6))


Fixed submission:
num1,num2 = map(int,input().split())
 
num3 = num1 + num2
num4 = num1 - num2
num5 = num1 * num2
num6 = [num3, num4, num5]
 
print(max(num6))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
u = ["".join(sorted(list(input()))) for i in range(N)]
ans = 0
for i in range(N):
  ans += u[i:].count(u[i]) - 1
print(ans)

Fixed submission:
N = int(input())
u = ["".join(sorted(list(input()))) for i in range(N)]
d = {}
for i in range(N):
  if u[i] in d:
    d[u[i]] += 1
  else:
    d[u[i]] = 1
ans = sum((i * (i - 1)) // 2 for i in d.values())
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
u = ["".join(sorted(list(input()))) for i in range(N)]
ans = 0
for i in range(N):
  ans += u[i:].count(u[i]) - 1
print(ans)

Fixed submission:
N = int(input())
u = ["".join(sorted(list(input()))) for i in range(N)]
d = {}
for i in range(N):
  if u[i] in d:
    d[u[i]] += 1
  else:
    d[u[i]] = 1
ans = sum((i * (i - 1)) // 2 for i in d.values())
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
l, r = map(int, input().split())
a= 2019
for i in range(r - l):
    for j in range(i + 1, r - l + 1):
        tmp = (l + i) * (l + j) % 2019
        if a > tmp:
            a = tmp

print(a)

Fixed submission:
l, r = map(int, input().split())
a = 2019

for i in range(r - l):
    t = 2019
    for j in range(i + 1, r - l + 1):
        tmp = (l + i) * (l + j) % 2019
        if a > tmp:
            a = tmp
        if a == 0:
            print(a)
            exit()
#        if tmp > t:
#            break
#        t = tmp
        

print(a)
Buggy python submission (verdict: Runtime Error):
import math

def lcm(x, y):
    return (x * y) // math.gcd(x, y)

A, B, C, D = map(int, input().split())

sa = B - A + 1

C2 = (B // C) - ((A - 1) // C)
D2 = (B // D) - ((A - 1) // D)

CD = lcm(C, D)

CD2 = (B // CD) - ((A - 1) // CD)

print(sa - (C2 + D2 - CD2))

Fixed submission:
def gcd(a, b):
    while b != 0:
        a, b = b, a % b
    return a

def lcm(x, y):
    return (x * y) // gcd(x, y)

A, B, C, D = map(int, input().split())

sa = B - A + 1

C2 = (B // C) - ((A - 1) // C)
D2 = (B // D) - ((A - 1) // D)

CD = lcm(C, D)

CD2 = (B // CD) - ((A - 1) // CD)

print(sa - (C2 + D2 - CD2))
Buggy python submission (verdict: Runtime Error):
import numpy as np

N = int(input())
task = []
for i in range(N):
    a, b =map(int, input().split())
    task.append([a, b])

task = np.array(task)
task = task[np.argsort(task[:, 1])]

time = 0
for i in range(N):
    time += task[i, 0]
    if time > task[i, 1]:
        print("No")
        exit()

print("Yes")

Fixed submission:
import numpy as np

N = int(input())
task = []
for i in range(N):
    a, b =map(int, input().split())
    task.append([a, b])

task = np.array(task)
task = task[np.argsort(task[:, 1])]

time = 0
for i in range(N):
    time += task[i, 0]
    if time > task[i, 1]:
        print("No")
        exit()

print("Yes")
Buggy python submission (verdict: Runtime Error):
M = []
for i in range(5):
  M.append(int(input()))

T = M[:]
tmp = 10
for i in range(5):
  if tmp > M[i] % 10 > 0:
    tmp = M[i] % 10
    c = i
  M[i] = ((M[i] - 1) // 10 + 1) * 10
M[c] = T[c]
print(sum(M))

Fixed submission:
M = [int(input()) for i in range(5)]

a = [((i - 1) // 10 + 1) * 10 for i in M]
b = [(i - 1) % 10 for i in M]

ans = sum(a) + min(b) - 9
print(ans)

Buggy python submission (verdict: Runtime Error):
M = [int(input()) for i in range(5)]
T = M[:]
tmp = 10
for i in range(5):
    if tmp > M[i] % 10 > 0:
        tmp = M[i] % 10
        c = i
    M[i] = ((M[i] - 1) // 10 + 1) * 10
M[c] = T[c]
print(sum(M))

Fixed submission:
M = [int(input()) for i in range(5)]

a = [((i - 1) // 10 + 1) * 10 for i in M]
b = [(i - 1) % 10 for i in M]

ans = sum(a) + min(b) - 9
print(ans)

Buggy python submission (verdict: Runtime Error):
M = [int(input()) for i in range(5)]
T = M[:]
tmp = 10
for i in range(5):
  if tmp > M[i] % 10 > 0:
    tmp = M[i] % 10
    c = i
  if M[i] % 10 != 0:
    M[i] += 10 - (M[i] % 10)
M[c] = T[c]
print(sum(M))

Fixed submission:
M = [int(input()) for i in range(5)]

a = [((i - 1) // 10 + 1) * 10 for i in M]
b = [(i - 1) % 10 for i in M]

ans = sum(a) + min(b) - 9
print(ans)

Buggy python submission (verdict: Runtime Error):
M = [int(input()) for i in range(5)]
tmp = 10
for i in range(5):
  if tmp > M[i] % 10 > 0:
    tmp = M[i] % 10
    c = i
for i in range(5):
  if i != c and M[i] % 10 != 0:
    M[i] += 10 - (M[i] % 10)
print(sum(M))

Fixed submission:
M = [int(input()) for i in range(5)]

a = [((i - 1) // 10 + 1) * 10 for i in M]
b = [(i - 1) % 10 for i in M]

ans = sum(a) + min(b) - 9
print(ans)
Buggy python submission (verdict: Runtime Error):
prices = map(int, raw_input())
left = prices[0] - prices[1]
print left % prices[2]

Fixed submission:
x = int(raw_input())
a = int(raw_input())
b = int(raw_input())
left = x - a
print left % b
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python
from typing import List, Dict


def get_all_values(N: int, v: int) -> List[int]:
    all_values = []

    current = v
    while current < N:
        all_values.append(current)
        current *= v

    return all_values


def get_min_number(memo: Dict[int, int], all_values: List[int], N: int) -> int:
    if N in memo:
        return memo[N]

    if N in all_values:
        return 1
    elif N < 6:
        return N
    else:
        min_number: int = min(
            [get_min_number(memo, all_values, N - v) + 1 for v in all_values if N - v >= 0]
        )
        memo[N] = min_number
        return min_number


def solve(N: int) -> int:
    # Get all values and sort in descent order
    all_values: List[int] = [1] + get_all_values(N, 6) + get_all_values(N, 9)
    sorted_all_values: List[int] = list(reversed(sorted(all_values)))

    # Recursively get minimum number
    memo: Dict[int, int] = {}
    ans = get_min_number(memo, sorted_all_values, N)

    return ans


def main():
    # Input
    N = int(input())

    # Solve
    ans = solve(N)

    # Answer
    print(ans)


if __name__ == "__main__":
    main()


Fixed submission:
#!/usr/bin/env python


def get_all_values(N, v):
    all_values = []

    current = v
    while current <= N:
        all_values.append(current)
        current *= v

    return all_values


def get_min_number(memo, all_values, N):
    if N in memo:
        return memo[N]

    if N in all_values:
        return 1
    elif N < 6:
        return N
    else:
        min_number = min(
            [get_min_number(memo, all_values, N - v) + 1 for v in all_values if N - v > 0]
        )
        memo[N] = min_number
        return min_number


def solve(N):
    # Get all values and sort in descent order
    all_values = [1] + get_all_values(N, 6) + get_all_values(N, 9)
    sorted_all_values = list(reversed(sorted(all_values)))

    # Recursively get minimum number
    memo = {}
    ans = get_min_number(memo, sorted_all_values, N)

    return ans


def main():
    # Input
    N = int(input())

    # Solve
    ans = solve(N)

    # Answer
    print(ans)


if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
import sys
 
def solve(N: int, M: int, P: int, A: "List[int]", B: "List[int]", C: "List[int]"):
    dist = [sys.maxsize] * (N + 1)
 
    dist[1] = 0
    for _ in range(N):
        for j in range(M):
            weight = -(C[j] - P)
            if dist[B[j]] > dist[A[j]] + weight:
                dist[B[j]] = dist[A[j]] + weight
 
    result = -dist[N]
 
    for _ in range(N + 1):
        for j in range(M):
            weight = -(C[j] - P)
            if dist[B[j]] > dist[A[j]] + weight:
                dist[B[j]] = dist[A[j]] + weight
 
    if result != -dist[N]:
        print(-1)
    else:
        print(max(-dist[N], 0))
 
 
# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    P = int(next(tokens))  # type: int
    A = [int()] * (M)  # type: "List[int]"
    B = [int()] * (M)  # type: "List[int]"
    C = [int()] * (M)  # type: "List[int]"
    for i in range(M):
        A[i] = int(next(tokens))
        B[i] = int(next(tokens))
        C[i] = int(next(tokens))
    solve(N, M, P, A, B, C)
 
if __name__ == '__main__':
    main()

Fixed submission:
#!/usr/bin/env python3
import sys


def solve(A: int, B: int):
    print(max(A+B, A-B, A*B))


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(A, B)

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3
import sys
from collections import Counter
from scipy.special import comb

def solve(N: int, s: "List[str]"):
    print(sum([comb(v, 2, exact=True) for v in Counter(s).values()]))

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    s = [ ' '.join(sorted(next(tokens))) for _ in range(N) ]  # type: "List[str]"
    solve(N, sorted(s))

if __name__ == '__main__':
    main()


Fixed submission:
#!/usr/bin/env python3
import sys
from collections import Counter
from scipy.misc import comb

def solve(N: int, s: "List[str]"):
    print(sum([comb(v, 2, exact=True) for v in Counter(s).values()]))

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    s = [ ' '.join(sorted(next(tokens))) for _ in range(N) ]  # type: "List[str]"
    solve(N, sorted(s))

if __name__ == '__main__':
    main()

Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3
import sys
from collections import Counter
from scipy.special import comb

def solve(N: int, s: "List[str]"):
    print(sum([comb(v, 2, exact=True) for v in Counter(s).itervalues()]))

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    s = [ ' '.join(sorted(next(tokens))) for _ in range(N) ]  # type: "List[str]"
    solve(N, sorted(s))

if __name__ == '__main__':
    main()


Fixed submission:
#!/usr/bin/env python3
import sys
from collections import Counter
from scipy.misc import comb

def solve(N: int, s: "List[str]"):
    print(sum([comb(v, 2, exact=True) for v in Counter(s).values()]))

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    s = [ ' '.join(sorted(next(tokens))) for _ in range(N) ]  # type: "List[str]"
    solve(N, sorted(s))

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
import sys

def solve(N: int, M: int, P: int, A: "List[int]", B: "List[int]", C: "List[int]"):
    dist = [sys.maxsize] * (N + 1)

    dist[1] = 0
    for _ in range(N):
        for j in range(M):
            weight = -(C[j] - P)
            if dist[B[j]] > dist[A[j]] + weight:
                dist[B[j]] = dist[A[j]] + weight

    result = -dist[N]

    for _ in range(N + 1):
        for j in range(M):
            weight = -(C[j] - P)
            if dist[B[j]] > dist[A[j]] + weight:
                dist[B[j]] = dist[A[j]] + weight

    if result != -dist[N]:
        print(-1)
    else:
        print(max(-dist[N], 0))


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    P = int(next(tokens))  # type: int
    A = [int()] * (M)  # type: "List[int]"
    B = [int()] * (M)  # type: "List[int]"
    C = [int()] * (M)  # type: "List[int]"
    for i in range(M):
        A[i] = int(next(tokens))
        B[i] = int(next(tokens))
        C[i] = int(next(tokens))
    solve(N, M, P, A, B, C)

if __name__ == '__main__':
    main()


Fixed submission:
import sys

def solve(N: int, M: int, P: int, A: "List[int]", B: "List[int]", C: "List[int]"):
    dist = [sys.maxsize] * (N + 1)

    dist[1] = 0
    for _ in range(N):
        for j in range(M):
            weight = -(C[j] - P)
            if dist[B[j]] > dist[A[j]] + weight:
                dist[B[j]] = dist[A[j]] + weight

    result = -dist[N]

    for _ in range(N + 1):
        for j in range(M):
            weight = -(C[j] - P)
            if dist[B[j]] > dist[A[j]] + weight:
                dist[B[j]] = dist[A[j]] + weight

    if result != -dist[N]:
        print(-1)
    else:
        print(max(-dist[N], 0))


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    P = int(next(tokens))  # type: int
    A = [int()] * (M)  # type: "List[int]"
    B = [int()] * (M)  # type: "List[int]"
    C = [int()] * (M)  # type: "List[int]"
    for i in range(M):
        A[i] = int(next(tokens))
        B[i] = int(next(tokens))
        C[i] = int(next(tokens))
    solve(N, M, P, A, B, C)

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
def main():
	n=int(input())
	src = [int(item) for item in input().split()]
	dst = [int(item) for item in input().split()]
	q=set()
	ans=0
	def	SandQ(i):
		ri=i+1
		li=i-1
		if i==0:li=n-1
		if i==n-1:ri=0
		x=0
		if dst[i]-src[i]>=dst[ri]+dst[li]:
			x=(dst[i]-src[i])//(dst[ri]+dst[li])
			dst[i]-=(dst[ri]+dst[li])*x
			q.add(li)
			q.add(ri)
		return x;
	for i in range(n):
		ans+=SandQ(i)
	while len(q)>0:
		i=q.pop()
		ans+=SandQ(i)
	for i in range(n):
		if src[i]!=dst[i]:
			print(-1)
			exit()
	else:print(ans)
main()


Fixed submission:
def main():
	n=int(input())
	src = [int(item) for item in input().split()]
	dst = [int(item) for item in input().split()]
	ans=0
	def	SandQ(i):
		ri=i+1
		li=i-1
		if i==0:li=n-1
		if i==n-1:ri=0
		x=0
		if dst[i]-src[i]>=dst[ri]+dst[li]:
			x=(dst[i]-src[i])//(dst[ri]+dst[li])
			dst[i]-=(dst[ri]+dst[li])*x
			x+=SandQ(li)
			x+=SandQ(ri)
		return x;
	for i in range(n):
		ans+=SandQ(i)
	for i in range(n):
		if src[i]!=dst[i]:
			print(-1)
			exit()
	else:print(ans)
main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
	n=int(input())
#	for i in range(n):
	src = [int(item) for item in input().split()]
	dst = [int(item) for item in input().split()]
	q=set()
	s=set()
	ans=0
	def	SandQ(i):
		ri=i+1
		li=i-1
		if i==0:li=n-1
		if i==n-1:ri=0
		x=0
		if dst[i]-src[i]>=dst[ri]+dst[li]:
			x=(dst[i]-src[i])//(dst[ri]+dst[li])
			dst[i]-=(dst[ri]+dst[li])*x
			q.add(li)
			q.add(ri)
		if dst[i]<=src[i]:
			s.add(i)
#		print (i,dst,x)
		return x;
#	print(src)
#	print(dst)
	for i in range(n):
		ans+=SandQ(i)
	while len(q)>0:
		i=q.pop()
		ans+=SandQ(i)
	if len(s)!=n:print(-1)
	else:print(ans)
#	print(dst)
main()


Fixed submission:
def main():
	n=int(input())
	src = [int(item) for item in input().split()]
	dst = [int(item) for item in input().split()]
	ans=0
	def	SandQ(i):
		ri=i+1
		li=i-1
		if i==0:li=n-1
		if i==n-1:ri=0
		x=0
		if dst[i]-src[i]>=dst[ri]+dst[li]:
			x=(dst[i]-src[i])//(dst[ri]+dst[li])
			dst[i]-=(dst[ri]+dst[li])*x
			x+=SandQ(li)
			x+=SandQ(ri)
		return x;
	for i in range(n):
		ans+=SandQ(i)
	for i in range(n):
		if src[i]!=dst[i]:
			print(-1)
			exit()
	else:print(ans)
main()
Buggy python submission (verdict: Runtime Error):
A, B, K = map(int, input().split())

for i in range(K):
  if i % 2 == 0:
    B = B + A/2
    A = A/2
   else:
    A = A + B/2
    B = B/2 
print ('{} {}'.format(A,B))

Fixed submission:
S = str(input()).rstrip()

if len(S) == 2:
  print (S)
else:
  print (S[::-1])

Buggy python submission (verdict: Runtime Error):
S = input()

if len(S) == 2:
	print (S)
else:
	new_str_list = list(reversed(S))
	#print(new_str_list)
    print (new_str_list.join(''))

Fixed submission:
S = str(input()).rstrip()

if len(S) == 2:
  print (S)
else:
  print (S[::-1])

Buggy python submission (verdict: Runtime Error):
S= str(input())

if len(S) == 2:
  print (S)
 else:
	print (reversed(S))	

Fixed submission:
S = str(input()).rstrip()

if len(S) == 2:
  print (S)
else:
  print (S[::-1])