Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin
import math
a, b = [int(x) for x in stdin.readline().rstrip().split()]
nums = [x for x in range(a,b+1)]
li1 = nums[::2]
li2 = list(set(nums)-set(li1))
if len(li1) > len(li2):
    li2.append(0)
elif len(li2) > len(li1):
    li1.appen(0)
from operator import xor
combined2 = list(map(xor, li1, li2))
def constructXOR(A, n):
    XOR = 0
    for i in range(0, n):
        XOR ^= A[i]
    return XOR
result = constructXOR(combined2, len(combined2))
print(result)

Fixed submission:
from sys import exit, stdin

A, B = [int(_) for _ in stdin.readline().rstrip().split()]

def oddsolve(x):
    return int((x+1)/2)%2

def solve(x):
    if x % 2 == 1:
        return oddsolve(x)
    else:
        return oddsolve(x+1) ^ (x+1)

print(solve(B) ^ solve(A-1))
Buggy python submission (verdict: Runtime Error):
n=int(input())
a_list=list(map(int, input().split()))
a_list.sort()
 
a,b=a_list[:2][0], a_list[:2][1]
while 1:
  if a>b:
    a=a-b
  elif a<b:
    b=b-a
  elif a==b:
    print(a)
    break
n=int(input())
a_list=list(map(int, input().split()))
a_list.sort()

a,b=a_list[:2][0], a_list[:2][1]
while 1:
  if a>b:
    a=a-b
  elif a<b:
    b=b-a
  elif a==b:
    print(a)
    break


Fixed submission:
import fractions
from functools import reduce
from sys import stdin
N = int(stdin.readline().rstrip())
A = [int(_) for _ in stdin.readline().rstrip().split()]
def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)
print(gcd_list(A))
Buggy python submission (verdict: Runtime Error):
from sys import stdin
N = int(stdin.readline().rstrip())
A = stdin.readline().rstrip()
B = stdin.readline().rstrip()
C = stdin.readline().rstrip()
ans = 0 
for i in range(N):
    ans += len(set(A[i], B[i], C[i]))-1
print(ans)

Fixed submission:
from sys import stdin
N = int(stdin.readline().rstrip())
A = stdin.readline().rstrip()
B = stdin.readline().rstrip()
C = stdin.readline().rstrip()
ans = 0 
for i in range(N):
    ans += len(set([A[i], B[i], C[i]]))-1
print(ans)
Buggy python submission (verdict: Runtime Error):
from math import factorial
from sys import exit, stdin
N = int(stdin.readline().rstrip())
H = [int(_) for _ in stdin.readline().rstrip().split()]
ans = 0
for i in range(1,n):
    if H[i-1] > H[i]:
        ans += H[i-1]-H[i]
ans += H[-1]
print(ans)

Fixed submission:
from math import factorial
from sys import exit, stdin
N = int(stdin.readline().rstrip())
H = [int(_) for _ in stdin.readline().rstrip().split()]
ans = 0
for i in range(1,N):
    if H[i-1] > H[i]:
        ans += H[i-1]-H[i]
ans += H[-1]
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin
N, K = [int(_) for _ in stdin.readline().rstrip().split()] 
H = [int(_) for _ in stdin.readline().rstrip().split()] 
dp = [10**9] * N
dp[0] = 0
for i in range(N-1):
  for j in range(1, min(K+1, N-i)):
    dp[i+j] = min(dp[i] + abs(H[i]-H[i+j]), dp[i+j])
print(dp[N-1])

Fixed submission:
from sys import stdin
N, K = [int(_) for _ in stdin.readline().rstrip().split()] 
H = [int(_) for _ in stdin.readline().rstrip().split()] 
dp = [10**9] * N
dp[0] = 0
for i in range(N-1):
  for j in range(1, min(K+1, N-i)):
    dp[i+j] = min(dp[i] + abs(H[i]-H[i+j]), dp[i+j])
print(dp[N-1])
Buggy python submission (verdict: Runtime Error):
from sys import stdin
s=[int(x) for x in list(stdin.readline().rstrip())]
abs_seven=[abs(7-i) for i in s]
min_num=min(abs_seven)
indices=[]
nums=[]
for i, n in enumerate(abs_seven):
    if n == min_num:
        indices.append(i)

for i in indices:
    try:
        n=s[i:i+3]
        nums.append(n[0]*100+n[1]*10+n[2])
    except:
        pass
nums=[abs(753-n) for n in nums]
print(min(nums))


Fixed submission:
from sys import stdin
s=stdin.readline().rstrip()
print(min([abs(int(s[i:i+3])-753) for i,n in enumerate(s[:-2])]))

Buggy python submission (verdict: Runtime Error):
from sys import stdin
s=[int(x) for x in list(stdin.readline().rstrip())]
abs_seven=[abs(7-i) for i in s]
min_num=min(abs_seven)
indices=[]
nums=[]
for i, n in enumerate(abs_seven):
    if n == min_num:
        indices.append(i)

for i in indices:
    try:
        n=s[i:i+3]
        nums.append(n[0]*100+n[1]*10+n[2])
    except:
        pass
nums=[abs(753-n) for n in nums]
print(min(nums))


Fixed submission:
from sys import stdin
s=stdin.readline().rstrip()
print(min([abs(int(s[i:i+3])-753) for i,n in enumerate(s[:-2])]))
Buggy python submission (verdict: Runtime Error):
from sys import stdin
x1, y1, x2, y2 = [int(x) for x in stdin.readline.rstrip().split()]
print(x2-(y2-y1), y2+(x2-x1), x1-(y2-y1), y1+(x2-x1))

Fixed submission:
from sys import stdin
x1, y1, x2, y2 = [int(x) for x in stdin.readline().rstrip().split()]
print(x2-(y2-y1), y2+(x2-x1), x1-(y2-y1), y1+(x2-x1))
Buggy python submission (verdict: Runtime Error):
from sys import stdin
n, k=[int(x) for x in stdin.readlint().rstrip().split()]
if n%k == 1:
  print(1)
else:
  print(0)

Fixed submission:
from sys import stdin
n, k=[int(x) for x in stdin.readline().rstrip().split()]
if n%k >= 1:
  print(1)
else:
  print(0)
Buggy python submission (verdict: Runtime Error):
from sys import stdin
n = int(stdin.readline.rstrip())
if n<1200:
  print('ABC')
elif n>=1200 and n<2800:
  print('ARC')
elif n>=2800:
  print('AGC')

Fixed submission:
from sys import stdin
n = int(stdin.readline().rstrip())
if n<1200:
  print('ABC')
elif n>=1200 and n<2800:
  print('ARC')
elif n>=2800:
  print('AGC')
Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin
N = int(stdin.readline().rstrip())
six_pows = [6**i for i in range(10)]
nine_pows = [9**i for i in range(10)]

ans = float("inf")

for i in range(N+1):
    count = 0
    tmp = i
    while tmp > 0:
        j = 0
        while six_pows[j] <= tmp:
            j += 1
        tmp -= six_pows[j-1]
        count += 1 

    tmp = N - i
    while tmp > 0:
        j = 0
        while nine_pows[j] <= tmp:
            j += 1
        tmp -= nine_pows[j-1]
        count += 1
    
    ans = min(ans, count)

print(ans)

Fixed submission:
from sys import stdin
N = int(stdin.readline().rstrip())
six_pows = [6**i for i in range(10)]
nine_pows = [9**i for i in range(10)]

ans = float("inf")

for i in range(N+1):
    count = 0
    tmp = i
    while tmp > 0:
        j = 0
        while six_pows[j] <= tmp:
            j += 1
        tmp -= six_pows[j-1]
        count += 1 

    tmp = N - i
    while tmp > 0:
        j = 0
        while nine_pows[j] <= tmp:
            j += 1
        tmp -= nine_pows[j-1]
        count += 1
    
    ans = min(ans, count)

print(ans)
Buggy python submission (verdict: Runtime Error):
from sys import stdin
X = int(stdin.readline().rstrip())
exps=[]
for i in range(1,X+1):
    for j in range(2,X+1):
        if 1 <= i**j <= X:
            exps.append(i**j)
        else:
            break
print(max(exps))


Fixed submission:
from sys import stdin
X = int(stdin.readline().rstrip())
exps=[1]
for i in range(1,X+1):
    for j in range(2,X+1):
        if 1 <= i**j <= X:
            exps.append(i**j)
        else:
            break
print(max(exps))

Buggy python submission (verdict: Runtime Error):
from sys import stdin
X = int(stdin.readline().rstrip())
exps=[]
for i in range(1,X+1):
    for j in range(2,X+1):
        if 1 <= i**j <= X:
            exps.append(i**j)
print(max(exps))


Fixed submission:
from sys import stdin
X = int(stdin.readline().rstrip())
exps=[1]
for i in range(1,X+1):
    for j in range(2,X+1):
        if 1 <= i**j <= X:
            exps.append(i**j)
        else:
            break
print(max(exps))

Buggy python submission (verdict: Runtime Error):
from sys import stdin
X = int(stdin.readline().rstrip())
exps=[]
for i in range(1,X+1):
    for j in range(2,X+1):
        if 1 <= i**j <= X:
            exps.append(i**j)
print(max(exps))

Fixed submission:
from sys import stdin
X = int(stdin.readline().rstrip())
exps=[1]
for i in range(1,X+1):
    for j in range(2,X+1):
        if 1 <= i**j <= X:
            exps.append(i**j)
        else:
            break
print(max(exps))
Buggy python submission (verdict: Runtime Error):
from sys import stdin
a,b,x = [int(x) for x in stdin.readline().rstrip().split()]
 
if a>x or:
  print('NO')
elif a<x and (x-a)>b:
  print('NO')
else:
  print('YES')

Fixed submission:
from sys import stdin
a,b,x = [int(x) for x in stdin.readline().rstrip().split()]
 
if a>x:
  print('NO')
elif a<x and (x-a)>b:
  print('NO')
else:
  print('YES')

Buggy python submission (verdict: Runtime Error):
from sys import stdin
a,b,x = [int(x) for x in stdin.readline().rstrip().split()]

if a>x or:
  print('NO')
elif a<x and x-a>b:
  print('NO')
else:
  print('YES')

Fixed submission:
from sys import stdin
a,b,x = [int(x) for x in stdin.readline().rstrip().split()]
 
if a>x:
  print('NO')
elif a<x and (x-a)>b:
  print('NO')
else:
  print('YES')
Buggy python submission (verdict: Time Limit Exceeded):
from scipy.misc import comb
from sys import stdin
N = int(stdin.readline().rstrip())
A = [int(_) for _ in stdin.readline().rstrip().split()]
A.sort()
max_a = A[-1]
A.pop(N-1)
ans = 0
ans_a = 0
for a in A:
    tmp = comb(max_a, a, exact=True)
    if tmp > ans:
        ans = tmp
        ans_a = a
print(max_a, ans_a)

Fixed submission:
from sys import stdin
N = int(stdin.readline().rstrip())
A = [int(_) for _ in stdin.readline().rstrip().split()]
A.sort()
max_a = A[-1]
print(max_a, min(A, key=lambda a:abs(max_a-a*2)))

Buggy python submission (verdict: Runtime Error):
from scipy.special import comb
from sys import stdin
N = int(stdin.readline().rstrip())
A = [int(_) for _ in stdin.readline().rstrip().split()]
A.sort()
max_a = A[-1]
A.pop(N-1)
ans = 0
ans_a = 0
for a in A:
    tmp = comb(max_a, a, exact=True)
    if tmp > ans:
        ans = tmp
        ans_a = a
print(max_a, ans_a)

Fixed submission:
from sys import stdin
N = int(stdin.readline().rstrip())
A = [int(_) for _ in stdin.readline().rstrip().split()]
A.sort()
max_a = A[-1]
print(max_a, min(A, key=lambda a:abs(max_a-a*2)))

Buggy python submission (verdict: Runtime Error):
from scipy.special import comb
from sys import stdin
N = int(stdin.readline().rstrip())
A = [int(_) for _ in stdin.readline().rstrip().split()]
A.sort()
max_a = A[-1]
A.pop(N-1)
ans = 0
ans_a = 0
for a in A:
    tmp = comb(max_a, a)
    if tmp > ans:
        ans = tmp
        ans_a = a
print(max_a, ans_a)

Fixed submission:
from sys import stdin
N = int(stdin.readline().rstrip())
A = [int(_) for _ in stdin.readline().rstrip().split()]
A.sort()
max_a = A[-1]
print(max_a, min(A, key=lambda a:abs(max_a-a*2)))

Buggy python submission (verdict: Runtime Error):
from itertools import combinations
from sys import exit, stdin
N = int(stdin.readline().rstrip())
A = [int(_) for _ in stdin.readline().rstrip().split()]
A.sort()
max_a = A[-1]
A.pop(N-1)
ans = 0
ans_a = 0
for a in A:
    tmp = len(list(combinations(range(max_a), a)))
    if tmp > ans:
        ans = tmp
        ans_a = a
print(max_a, ans_a)

Fixed submission:
from sys import stdin
N = int(stdin.readline().rstrip())
A = [int(_) for _ in stdin.readline().rstrip().split()]
A.sort()
max_a = A[-1]
print(max_a, min(A, key=lambda a:abs(max_a-a*2)))

Buggy python submission (verdict: Runtime Error):
from itertools import combinations
from sys import exit, stdin
N = int(stdin.readline().rstrip())
A = [int(_) for _ in stdin.readline().rstrip().split()]
A.sort()
max_a = A[-1]
A.pop(N-1)
ans = 0
for a in A:
    tmp = len(list(combinations(range(max_a), a)))
    if tmp > ans:
        ans = tmp
print(ans)

Fixed submission:
from sys import stdin
N = int(stdin.readline().rstrip())
A = [int(_) for _ in stdin.readline().rstrip().split()]
A.sort()
max_a = A[-1]
print(max_a, min(A, key=lambda a:abs(max_a-a*2)))
Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin
a,b,k = [int(_) for _ in stdin.readline().rstrip().split()]
nums = [_ for _ in range(a,b+1)]
ans = nums[:k]+nums[-k:]
if len(nums) < k*2:
    ans = list(set(ans))
    ans.sort()
for i in ans:
    print(i)

Fixed submission:
from sys import stdin
a,b,k = [int(_) for _ in stdin.readline().rstrip().split()]
for i in range(a, min(b,a+k-1)+1):
    print(i)
for i in range(max(a+k,b-k+1), b+1):
    print(i)
Buggy python submission (verdict: Time Limit Exceeded):
import fractions
from functools import reduce
from sys import stdin
N = int(stdin.readline().rstrip())
A = [int(_) for _ in stdin.readline().rstrip().split()]
for n in range(N):
    path = [0]+A[0:n]+A[n+1:]+[0]
    print(sum(abs(path[i]-path[i-1]) for i, _ in enumerate(path)))

Fixed submission:
from sys import stdin
N = int(stdin.readline().rstrip())
A = [0]+[int(_) for _ in stdin.readline().rstrip().split()]+[0]
S = sum(abs(A[i+1]-A[i]) for i in range(N+1))
for i in range(1,N+1):
    print(S-abs(A[i-1]-A[i])-abs(A[i]-A[i+1])+abs(A[i-1]-A[i+1]))
Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin
n = int(stdin.readline().rstrip())
def lucas(n):
    if n==0:
        return 2
    elif n==1:
        return 1
    else:
        return lucas(n-1)+lucas(n-2)

print(lucas(n))

Fixed submission:
from sys import stdin
from functools import lru_cache
n = int(stdin.readline().rstrip())
@lru_cache(maxsize=86)
def lucas(n):
    if n==0:
        return 2
    elif n==1:
        return 1
    else:
        return lucas(n-1)+lucas(n-2)

print(lucas(n))
Buggy python submission (verdict: Time Limit Exceeded):
from sys import exit, stdin
N = int(stdin.readline().rstrip())
for i in range(1, 3501):
    for j in range(1, 3501):
            div = 4*i*j-N*i-N*j
            if div <= 0:
                continue
            if (N*i*j) % div == 0:
                print(i, j, (N*i*j) // div)
                exit()

Fixed submission:
from sys import exit, stdin
N = int(stdin.readline().rstrip())
for i in range(1, 3501):
    for j in range(1, 3501):
            div = 4*i*j-N*i-N*j
            if div <= 0:
                continue
            if (N*i*j) % div == 0:
                print(i, j, (N*i*j) // div)
                exit()
Buggy python submission (verdict: Runtime Error):
from sys import stdin
N = int(stdin.readline().rstrip())
K = int(stdin.readline().rstrip())
X = [int(_) for _ in stdin.readline().rstrip().split()]
ans = 0
for i in x:
    if i < K - i:
        ans += 2 * i
    else:
        ans += 2 * (K - i)
print(ans)

Fixed submission:
from sys import stdin
n = int(stdin.readline().rstrip())
a = int(stdin.readline().rstrip())
print(n*n-a)

Buggy python submission (verdict: Runtime Error):
from sys import stdin
N = int(stdin.readline().rstrip())
K = int(stdin.readline().rstrip())
X = [int(_) for _ in stdin.readline().rstrip().split()]
ans = 0
for i in x:
    if i < K - i:
        ans += 2 * i
    else:
        ans += 2 * (K - i)
print(route)

Fixed submission:
from sys import stdin
n = int(stdin.readline().rstrip())
a = int(stdin.readline().rstrip())
print(n*n-a)
Buggy python submission (verdict: Runtime Error):
from sys import stdin
N = int(stdin.readline().rstrip())
K = int(stdin.readline().rstrip())
X = [int(_) for _ in stdin.readline().rstrip().split()]
ans = 0
for i in x:
    if i < K - i:
        ans += 2 * i
    else:
        ans += 2 * (K - i)
print(ans)

Fixed submission:
from sys import stdin
N = int(stdin.readline().rstrip())
K = int(stdin.readline().rstrip())
X = [int(_) for _ in stdin.readline().rstrip().split()]
ans = 0
for i in X:
    if i < K - i:
        ans += 2 * i
    else:
        ans += 2 * (K - i)
print(ans)

Buggy python submission (verdict: Runtime Error):
from sys import stdin
N = int(stdin.readline().rstrip())
K = int(stdin.readline().rstrip())
X = [int(_) for _ in stdin.readline().rstrip().split()]
ans = 0
for i in x:
    if i < K - i:
        ans += 2 * i
    else:
        ans += 2 * (K - i)
print(route)

Fixed submission:
from sys import stdin
N = int(stdin.readline().rstrip())
K = int(stdin.readline().rstrip())
X = [int(_) for _ in stdin.readline().rstrip().split()]
ans = 0
for i in X:
    if i < K - i:
        ans += 2 * i
    else:
        ans += 2 * (K - i)
print(ans)
Buggy python submission (verdict: Runtime Error):
from sys import exit, stdin
N = int(stdin.readline().rstrip())
A = [int(_) for _ in stdin.readline().rstrip().split()]
count, ignore = 0, 0
for i, a in enumerate(A):
    if ignore == 1:
        ignore = 0
        continue
    if a-1 == i:
        count += 1
        if A[i+1] != i+1:
            ignore = 1
print(count)

Fixed submission:
from sys import exit, stdin
N = int(stdin.readline().rstrip())
A = [int(_) for _ in stdin.readline().rstrip().split()]
count, ignore = 0, 0
for i, a in enumerate(A):
    if ignore == 1:
        ignore = 0
        continue
    if a-1 == i:
        count += 1
        if i != N-1:
            if A[i+1] != i+1:
                ignore = 1
print(count)
Buggy python submission (verdict: Runtime Error):
from collections import Counter
from sys import stdin
N = int(stdin.readline().rstrip())
A = Counter([int(_) for _ in stdin.readline().rstrip().split()]).most_common()
B = [t for t in A if t[1] >= 2]
B.sort(reverse=True)
print(B[0][0]*B[1][0])

Fixed submission:
import sys
from collections import Counter
from sys import stdin
N = int(stdin.readline().rstrip())
A = Counter([int(_) for _ in stdin.readline().rstrip().split()]).most_common()
B = [t for t in A if t[1] >= 2]
B.sort(reverse=True)
if len(B) < 2:
    print(0)
    sys.exit()
if B[0][1] >= 4:
    print(B[0][0]**2)
else:
    print(B[0][0]*B[1][0])
Buggy python submission (verdict: Runtime Error):
from sys import stdin
a, b = [int(x) for x in stdin.readline().rstrip().split()]
if (a+b)/3:
  print('Possible')
else:
  print('Impossible')
from sys import stdin
a, b = [int(x) for x in stdin.readline().rstrip().split()]
if (a+b)%3 == 0:
  print('Possible')
else:
  print('Impossible')


Fixed submission:
from sys import stdin
a, b = [int(x) for x in stdin.readline().rstrip().split()]

if a%3==0 or b%3==0 or (a+b)%3==0:
  print('Possible')
else:
  print('Impossible')
Buggy python submission (verdict: Runtime Error):
N, K = [int(_) for _ in stdin.readline().rstrip().split()]
L = sorted([int(_) for _ in stdin.readline().rstrip().split()], reverse=True)
print(sum(L[:k]))

Fixed submission:
from sys import stdin
N, K = [int(_) for _ in stdin.readline().rstrip().split()]
L = sorted([int(_) for _ in stdin.readline().rstrip().split()], reverse=True)
print(sum(L[:K]))
Buggy python submission (verdict: Time Limit Exceeded):
from math import ceil
from sys import stdin
N = int(stdin.readline().rstrip())
A = [int(_) for _ in stdin.readline().rstrip().split()]
ans = 10**10
x = 0
for i in range(N-1):
    x+=A[i]
    ans = min(ans, abs(sum(A)-2*x))
print(ans)

Fixed submission:
from math import ceil
from sys import stdin
N = int(stdin.readline().rstrip())
A = [int(_) for _ in stdin.readline().rstrip().split()]
Asum = sum(A)
ans = 10**10
x = 0
for i in range(N-1):
    x+=A[i]
    ans = min(ans, abs(Asum-2*x))
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from math import ceil
from sys import stdin
N = int(stdin.readline().rstrip())
A = [int(_) for _ in stdin.readline().rstrip().split()]
ans = 10**10
for i in range(N-1):
    ans = min(ans, abs(sum(A[:i+1])-sum(A[i+1:])))
print(ans)

Fixed submission:
from math import ceil
from sys import stdin
N = int(stdin.readline().rstrip())
A = [int(_) for _ in stdin.readline().rstrip().split()]
Asum = sum(A)
ans = 10**10
x = 0
for i in range(N-1):
    x+=A[i]
    ans = min(ans, abs(Asum-2*x))
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
from itertools import permutations
from sys import exit, stdin
N, M = [int(_) for _ in stdin.readline().rstrip().split()]
p_n = len(list(permutations(i for i in range(N))))
p_m = len(list(permutations(i for i in range(M))))
if abs(N-M)==0:
    print(2*p_n*p_m)
elif abs(N-M)==1:
    print(p_n*p_m)
else:
    print(0)

Fixed submission:
from math import factorial
from sys import exit, stdin
N, M = [int(_) for _ in stdin.readline().rstrip().split()]
p_n = factorial(N)
p_m = factorial(M)
NUM = 10**9+7
if abs(N-M)==0:
    ans = 2*p_n*p_m
elif abs(N-M)==1:
    ans = p_n*p_m
else:
    ans = 0
print(ans%NUM)
Buggy python submission (verdict: Time Limit Exceeded):
from sys import exit, stdin
N, K = [int(_) for _ in stdin.readline().rstrip().split()]
AB = []
for i in range(N):
    a, b = stdin.readline().rstrip().split()
    for j in range(int(b)):
        AB.append(int(a))
AB.sort()
print(AB[K-1])

Fixed submission:
from sys import exit, stdin
N, K = [int(_) for _ in stdin.readline().rstrip().split()]
AB = [list(map(int, stdin.readline().rstrip().split())) for _ in range(N)]
AB.sort(key=lambda ab:ab[0])
total_index = 0
for ab in AB:
    total_index += ab[1]
    if total_index >= K:
        print(ab[0])
        exit()
Buggy python submission (verdict: Runtime Error):
from sys import exit, stdin
N, M = [int(_) for _ in stdin.readline().rstrip().split()]
r = M-2*N
if r <= 0:
    print(N//2)
else:
    pritnt(N+r//4)

Fixed submission:
from sys import exit, stdin
N, M = [int(_) for _ in stdin.readline().rstrip().split()]
r = M-2*N
if r <= 0:
    print(M//2)
else:
    print(N+r//4)
Buggy python submission (verdict: Runtime Error):
from sys import stdin
N = int(stdin.readline().rstrip())
AB = [list(map(int, stdin.readline().rstrip().split())) for _ in range(N)]
ans = 0
for i in range(N-1, -1, -1):
  	a, b = AB[i]
	ans += (b - (a + ans) % b) % b
print(ans)

Fixed submission:
from sys import stdin
N = int(stdin.readline().rstrip())
AB = [list(map(int, stdin.readline().rstrip().split())) for _ in range(N)]
ans = 0
for i in range(N-1, -1, -1):
  a, b = AB[i]
  ans += (b - (a + ans) % b) % b
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin
A, B, X = [int(_) for _ in stdin.readline().rstrip().split()]
ans = 0
for i in range(A, B+1):
  if i % X == 0:
    ans += 1
print(ans)

Fixed submission:
from sys import stdin
A, B, X = [int(_) for _ in stdin.readline().rstrip().split()]
print(B//X - (A-1)//X)
Buggy python submission (verdict: Runtime Error):
import math
n,d=map(int,input().split(' '))
cnt=0
while n>0:
    x,y=map(int,input().split(' '))
    res=math.sqrt(x**2+y**2)
    if res<=d:
        cnt+=1
print(cnt)


Fixed submission:
import math
n,d=map(int,input().split(' '))
cnt=0
while n>0:
    x,y=map(int,input().split(' '))
    res=math.sqrt(x**2+y**2)
    if res<=d:
        cnt+=1
    n=n-1
print(cnt)
Buggy python submission (verdict: Runtime Error):
int(input())

if X >= 30:
  print("Yes")
else:
  print("No")


Fixed submission:
X = int(input())

if X >= 30:
  print("Yes")
else:
  print("No")

Buggy python submission (verdict: Runtime Error):
int(input(X))

if X >= 30:
  print("Yes")
else:
  print("No")

Fixed submission:
X = int(input())

if X >= 30:
  print("Yes")
else:
  print("No")

Buggy python submission (verdict: Runtime Error):
int(input())
-40 <= X <= 40
if X >= 30:
  print("Yes")
else:
  print("No")


Fixed submission:
X = int(input())

if X >= 30:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int,input().split()))

res = 1
for i in A:
    res *= i

if res > 10**18:
    print(-1)
else:
    print(res)

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

res = 1
for i in A:
    if res > 10**18:
        print(-1)
        sys.exit()
    res *= i

if res > 10**18:
    print(-1)
else:
    print(res)
Buggy python submission (verdict: Runtime Error):
N,K = map(int,input().split())
d = int(input())
A = [list(map(int,input().split())) for _ in range(N)]
print(N-d)

Fixed submission:
N,K = map(int,input().split())
res = [0] * N
for i in range(K):
    d = int(input())
    A = list(map(int,input().split()))
    for j in A:
        res[j-1] +=1
print(res.count(0))