Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
n = int(input())
A = list(map(int, input().split()))

dp = [0] * (2*(10**5) + 1)

for a in A:
    dp[a] += 1

for i in range(1, len(dp)):
    if dp[i]:
        for j in range(i+i, len(dp), i):
            dp[j] = 0
print(dp.count(1))


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

dp = [0] * (10**6+1)

for a in A:
    dp[a] += 1

for i in range(1, len(dp)):
    if dp[i]:
        for j in range(i+i, len(dp), i):
            dp[j] = 0
print(dp.count(1))

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

dp = [0] * (2*(10**5))

for a in A:
    dp[a] += 1

for i in range(1, len(dp)):
    if dp[i]:
        for j in range(i+i, len(dp), i):
            dp[j] = 0
print(dp.count(1))


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

dp = [0] * (10**6+1)

for a in A:
    dp[a] += 1

for i in range(1, len(dp)):
    if dp[i]:
        for j in range(i+i, len(dp), i):
            dp[j] = 0
print(dp.count(1))

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

ans = 0

for i in range(n):
    for j in range(n):
        if i == j:
            continue
        if A[i] % A[j] == 0:
            break
    else:
        ans += 1

print(ans)



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

dp = [0] * (10**6+1)

for a in A:
    dp[a] += 1

for i in range(1, len(dp)):
    if dp[i]:
        for j in range(i+i, len(dp), i):
            dp[j] = 0
print(dp.count(1))

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

for i in range(n):
    for j in range(n):
        if i == j:
            continue
        if A[i] % A[j] == 0:
            break
    else:
        ans += 1

print(ans)



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

dp = [0] * (10**6+1)

for a in A:
    dp[a] += 1

for i in range(1, len(dp)):
    if dp[i]:
        for j in range(i+i, len(dp), i):
            dp[j] = 0
print(dp.count(1))
Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())
A = list(map(int, input().split()))
borderline = sum(A) / (4 * m)

print('Yes' if sorted(A, reverse=True)[m-1] >= borderline else 'No')


Fixed submission:
x, y, z = map(int, input().split())

print(z, x, y)
Buggy python submission (verdict: Time Limit Exceeded):

def main():
    k = int(input())

    lunluns = list(range(1, 10))

    lunlun = -1

    for _ in range(k):
        lunlun = lunluns.pop(0)

        ones_place = lunlun % 10
        if ones_place > 0:
            lunluns.append(lunlun * 10 + ones_place -1)
        lunluns.append(lunlun * 10 + ones_place)
        if ones_place < 9:
            lunluns.append(lunlun * 10 + ones_place + 1)
    return lunlun

print(main())


Fixed submission:
from collections import deque

def main():
    k = int(input())

    lunluns = deque(range(1, 10))

    lunlun = -1

    for _ in range(k):
        lunlun = lunluns.popleft()

        ones_place = lunlun % 10
        if ones_place > 0:
            lunluns.append(lunlun * 10 + ones_place -1)
        lunluns.append(lunlun * 10 + ones_place)
        if ones_place < 9:
            lunluns.append(lunlun * 10 + ones_place + 1)
    return lunlun

print(main())

Buggy python submission (verdict: Time Limit Exceeded):

def main():
    k = int(input())

    lunluns = list(range(1, 10))

    lunlun = -1

    for _ in range(k):
        lunlun = lunluns.pop(0)

        ones_place = lunlun % 10
        if ones_place > 0:
            lunluns.append(lunlun * 10 + ones_place -1)
        lunluns.append(lunlun * 10 + ones_place)
        if ones_place < 9:
            lunluns.append(lunlun * 10 + ones_place + 1)
    return lunlun

print(main())


Fixed submission:
from collections import deque

def main():
    k = int(input())

    lunluns = deque(range(1, 10))

    lunlun = -1

    for _ in range(k):
        lunlun = lunluns.popleft()

        ones_place = lunlun % 10
        if ones_place > 0:
            lunluns.append(lunlun * 10 + ones_place -1)
        lunluns.append(lunlun * 10 + ones_place)
        if ones_place < 9:
            lunluns.append(lunlun * 10 + ones_place + 1)
    return lunlun

print(main())
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

strings = []

for i in range(N):
    strings.append(''.join(sorted(list(input()))))

ans = 0

for i in range(N-1):
    for j in range(i+1, N):
        if strings[i] == strings[j]:
            ans += 1

print(ans)

Fixed submission:
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0:
        return 1
    over = reduce(lambda x, y: x * y, range(n, n - r, -1))
    under = reduce(lambda x, y: x * y, range(1, r + 1))
    return over // under

N = int(input())

strings = {}
for i in range(N):
    key = ''.join(sorted(list(input())))
    strings.setdefault(key, 0)
    strings[key] += 1
ans = 0

for k, v in strings.items():
    if v > 1:
        ans += cmb(v, 2)

print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(n)

count = 0
for i in range(1, n+1):
  if len(str(i)) % 2 == 1:
    count += 1
print(count)

Fixed submission:
n = int(input())
 
count = 0
for i in range(1, n+1):
  if len(str(i)) % 2 == 1:
    count += 1
print(count)
Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8

n = int(input())

A = [int(input()) for _ in range(n)]

max_a = max(A)

for i in range(n):
    if max_a == A[i]:
        print(max(A[0:i] + A[i+1:n]))
    else:
        print(max_a)

Fixed submission:
# coding: utf-8

n = int(input())

A = [int(input()) for _ in range(n)]

s_A = sorted(A, reverse=True)

max_a, second_a = s_A[0], s_A[1]

for i in range(n):
    if A[i] == max_a:
        print(second_a)
    else:
        print(max_a)
Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8

a, b, c, d = map(int, input().split())

count = 0

for i in range(a, b+1):
    if i % c == 0 or i % d == 0:
        continue
    count += 1

print(count)



Fixed submission:
# coding: utf-8

import fractions

a, b, c, d = map(int, input().split())

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

a_c = (a-1) // c
a_d = (a-1) // d
a_cd = (a-1) // lcm(c, d)

b_c = b // c
b_d = b // d
b_cd = b // lcm(c, d)


print((b-a+1) - ((b_c + b_d - b_cd) - (a_c + a_d - a_cd)))
Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())

gates = []
for _ in range(m):
    gates.append(tuple(map(int, input().split())))

gates.sort(key=lambda x: (x[0], x[1]), reverse=True)

count = 0
for i in range(1, n+1):
    for gate in gates:
        if i < gate[0] or gate[1] < i :
            break
    else:
        count += 1
print(count)


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

gates = []
start, end = 1, n
for _ in range(m):
    L, R = map(int, input().split())
    if L > start:
        start = L
    if R < end:
        end = R

print(len(range(start, end+1)))

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

passed = set(range(1, n+1))
for _ in range(m):
    L, R = map(int, input().split())
    passed &= set(range(L, R+1))
print(len(passed))


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

gates = []
start, end = 1, n
for _ in range(m):
    L, R = map(int, input().split())
    if L > start:
        start = L
    if R < end:
        end = R

print(len(range(start, end+1)))

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

gates = []
for _ in range(m):
    gates.append(tuple(map(int, input().split())))

passed = set(range(gates[0][0], gates[0][1]+1))
for gate in gates[1:]:
    passed &= set(range(gate[0], gate[1]+1))
print(len(passed))


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

gates = []
start, end = 1, n
for _ in range(m):
    L, R = map(int, input().split())
    if L > start:
        start = L
    if R < end:
        end = R

print(len(range(start, end+1)))

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

gates = []
for _ in range(m):
    gates.append(tuple(map(int, input().split())))

count = 0
for i in range(1, n+1):
    if all(map(lambda gate: gate[0] <= i <= gate[1], gates)):
        count += 1
print(count)


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

gates = []
start, end = 1, n
for _ in range(m):
    L, R = map(int, input().split())
    if L > start:
        start = L
    if R < end:
        end = R

print(len(range(start, end+1)))
Buggy python submission (verdict: Runtime Error):
A, B, T = map(int, input.split())

print((T+0.5) // A * B)

Fixed submission:
# coding: utf-8

A, B, T = map(int, input().split())

def biscuit_generator(a, b, t):
    biscuit = 0
    t -= a
    while (t+0.5) > 0:
      biscuit += b
      t -= a

    return biscuit

print(biscuit_generator(A, B, T))
Buggy python submission (verdict: Runtime Error):
n = int(input().strip())
values = list(map(int, input().split()))
costs = list(map(int, input().split()))

sales = [v - c for v, c in zip(values, costs) if v > c else 0]

print(sum(sales))

Fixed submission:
# coding: utf-8

from itertools import combinations, chain

N = int(input())
values = map(int, input().split())
costs = map(int, input().split())

sales = [v - c for v, c in zip(values, costs)]

print(max(chain.from_iterable(map(sum, combinations(sales, i)) for i in range(0, N+1))))
Buggy python submission (verdict: Runtime Error):
x=input()
if x==0:
  print(1)
else if x==1:
  print(0)

Fixed submission:
x=int(input())
if x==0:
  print(1)
else:
  print(0)
Buggy python submission (verdict: Time Limit Exceeded):
N=input()
A=list(map(int,input().split()))
ans=0
M=10**9+7
for i in range(len(A)-1):
    for j in range(len(A)-i-1):
        ans+=A[i]*A[i+j+1]%M
        ans%=M
print(ans)

Fixed submission:
N=input()
A=list(map(int,input().split()))
ans=0
S=sum(A)
M=10**9+7
for i in A:
    S-=i
    ans+=i*S%M
    ans%=M
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N=input()
A=list(map(int,input().split()))
ans=0
for i in range(len(A)-1):
    for j in range(len(A)-i-1):
        ans+=A[i]*A[i+j+1]
        ans%=10**9+7
print(ans)

Fixed submission:
N=input()
A=list(map(int,input().split()))
ans=0
S=sum(A)
M=10**9+7
for i in A:
    S-=i
    ans+=i*S%M
    ans%=M
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N,A,B=map(int,input().split())
n=0
S=''
flag=False
while True:
    for i in range(A):
        S+='b'
        n+=1
        if n==N:
            flag=True
            break
    if flag:
        break
    
    for i in range(B):
        S+='r'
        n+=1
        if n==N:
            flag=True
            break
    if flag:
        break
    
cnt=0
for i in S:
    if i=='b':
        cnt+=1

print(cnt)

Fixed submission:
N,A,B=map(int,input().split())
cycle=A+B
a=N//cycle
b=N%cycle
if b>A:
    b=A
cnt=a*A+b
print(cnt)
Buggy python submission (verdict: Runtime Error):
N=int(input())
X=list(map(int,input().split()))
dispersion=[]
cnt=0
for i in range(min(X),max(X)):
    for j in range(N):
        cnt+=abs(X[j]-i)**2
    dispersion.append(cnt)
    cnt=0
print(min(dispersion))

Fixed submission:
N=int(input())
X=list(map(int,input().split()))
dispersion=[]
cnt=0
for i in range(100):
    for j in range(N):
        cnt+=abs(X[j]-i)**2
    dispersion.append(cnt)
    cnt=0
print(min(dispersion))

Buggy python submission (verdict: Runtime Error):
def rally():
    N=int(input())
    X=list(map(int,input().split()))
    dispersion=[]
    cnt=0
    for i in range(min(X),max(X)):
        for j in range(N):
            cnt+=abs(X[j]-i)**2
        dispersion.append(cnt)
        cnt=0
    print(min(dispersion))
    return 0
rally()


Fixed submission:
N=int(input())
X=list(map(int,input().split()))
dispersion=[]
cnt=0
for i in range(100):
    for j in range(N):
        cnt+=abs(X[j]-i)**2
    dispersion.append(cnt)
    cnt=0
print(min(dispersion))

Buggy python submission (verdict: Runtime Error):
def rally():
    N=int(input())
    X=list(map(int,input().split()))
    dispersion=[]
    cnt=0
    for i in range(min(X),max(X)):
        for j in range(N):
            cnt+=abs(X[j]-i)**2
        dispersion.append(cnt)
        cnt=0
    print(min(dispersion))

rally()

Fixed submission:
N=int(input())
X=list(map(int,input().split()))
dispersion=[]
cnt=0
for i in range(100):
    for j in range(N):
        cnt+=abs(X[j]-i)**2
    dispersion.append(cnt)
    cnt=0
print(min(dispersion))

Buggy python submission (verdict: Runtime Error):
def rally():
    N=input()
    X=list(map(int,input().split()))
    dispersion=[]
    cnt=0
    for i in range(min(X),max(X)):
        for j in X:
            cnt+=abs(j-i)**2
        dispersion.append(cnt)
        cnt=0
    print(min(dispersion))

rally()


Fixed submission:
N=int(input())
X=list(map(int,input().split()))
dispersion=[]
cnt=0
for i in range(100):
    for j in range(N):
        cnt+=abs(X[j]-i)**2
    dispersion.append(cnt)
    cnt=0
print(min(dispersion))

Buggy python submission (verdict: Runtime Error):
def rally():
    N=input()
    X=list(map(int,input().split()))
    dispersion=[]
    cnt=0
    for i in range(min(X),max(X)):
        for j in X:
            cnt+=(j-i)**2
        dispersion.append(cnt)
        cnt=0
    print(min(dispersion))

rally()

Fixed submission:
N=int(input())
X=list(map(int,input().split()))
dispersion=[]
cnt=0
for i in range(100):
    for j in range(N):
        cnt+=abs(X[j]-i)**2
    dispersion.append(cnt)
    cnt=0
print(min(dispersion))
Buggy python submission (verdict: Runtime Error):
ef remaining_ball():
    S,T=map(str,input().split())
    A,B=map(int,input().split())
    U=input()
    if U==S:
        A-=1
    else:
        B-=1
    print(A,B)
remaining_ball()

Fixed submission:
def remaining_ball():
    S,T=map(str,input().split())
    A,B=map(int,input().split())
    U=input()
    if U==S:
        A-=1
    else:
        B-=1
    print(A,B)
remaining_ball()
Buggy python submission (verdict: Time Limit Exceeded):
def exp_val(n):
    return (n+1)/2

def dice_in_line():
    K,N=map(int,input().split())
    p_n=list(map(int,input().split()))
    exp=[]
    for i in p_n:
        exp.append(exp_val(i))
    exp_sum=[]
    for i in range(K-N+1):
        exp_sum.append(sum(exp[i:i+N]))
    print(max(exp_sum))

dice_in_line()

Fixed submission:
def dice_in_line():
    N,K=map(int,input().split())
    p_n=list(map(int,input().split()))
    max=x=sum(p_n[:K])
    for i in range(N-K):
        x+=(p_n[K+i]-p_n[i])
        if max<x:
            max=x
    print((max+K)/2)

dice_in_line()

Buggy python submission (verdict: Time Limit Exceeded):
def exp_val(n):
    return (n+1)/2

def dice_in_line():
    K,N=map(int,input().split())
    p_n=list(map(int,input().split()))
    exp=[]
    for i in p_n:
        exp.append(exp_val(int(i)))
    exp_sum=[]
    for i in range(K-N+1):
        exp_sum.append(sum(exp[i:i+N]))
    print(max(exp_sum))

dice_in_line()

Fixed submission:
def dice_in_line():
    N,K=map(int,input().split())
    p_n=list(map(int,input().split()))
    max=x=sum(p_n[:K])
    for i in range(N-K):
        x+=(p_n[K+i]-p_n[i])
        if max<x:
            max=x
    print((max+K)/2)

dice_in_line()

Buggy python submission (verdict: Time Limit Exceeded):
def exp_val(n):
    return (n+1)/2

def dice_in_line():
    K,N=map(int,input().split())
    p_n=list(map(int,input().split()))
    exp=[]
    for i in p_n:
        exp.append(exp_val(int(i)))
    exp_sum=[]
    for i in range(K-N+1):
        exp_sum.append(sum(exp[i:i+N]))
    print(max(exp_sum))

dice_in_line()

Fixed submission:
def dice_in_line():
    N,K=map(int,input().split())
    p_n=list(map(int,input().split()))
    max=x=sum(p_n[:K])
    for i in range(N-K):
        x+=(p_n[K+i]-p_n[i])
        if max<x:
            max=x
    print((max+K)/2)

dice_in_line()
Buggy python submission (verdict: Runtime Error):
n = int(input())
return 0 if n == 1 else n

Fixed submission:
n = int(input())
print(0 if n == 1 else 1)
Buggy python submission (verdict: Runtime Error):
import random, string
def randomname(n):
   randlst = [random.choice(string.ascii_letters + string.digits) for i in range(n)]
   return ''.join(randlst)
S = input()
T = input()
l = len(T)
L = len(S)
before = randomname(l)
after = randomname(l)
for i in range(l):
   before[i] = '.'
   after[i] = '.'
S = before + S + after
max_ans = -1
for i in range(L+l+1):
   for j in range(l):
      ans = 0
      if T[j] == S[i + j]:
         ans += 1
   max_ans = max(max_ans, ans)
print(l - max_ans)

Fixed submission:

import random, string
S = input()
T = input()
l = len(T)
L = len(S)
max_ans = -1
for i in range(L):
   ans = 0
   if i + l > L:
      continue
   for j in range(l):
      if T[j] == S[i + j]:
            ans += 1
   max_ans = max(max_ans, ans)
print(l - max_ans)

Buggy python submission (verdict: Runtime Error):
S = input()
T = input()
l = len(T)
L = len(S)
max_ans = -1
for i in range(l):
   for j in range(l-i):
      ans = 0
      if T[i+j] == S[j]:
         ans += 1
   max_ans = max(max_ans, ans)
for i in range(L - l):
   for j in range(l):
      ans = 0
      if T[j] == S[j+i]:
         ans += 1
      max_ans = max(max_ans, ans)
for i in range(l):
    for j in range(i):
       if T[i-j] == S[L-j]:
          ans +=1
       max_ans = max(max_ans, ans)
print(l - max_ans)

Fixed submission:

import random, string
S = input()
T = input()
l = len(T)
L = len(S)
max_ans = -1
for i in range(L):
   ans = 0
   if i + l > L:
      continue
   for j in range(l):
      if T[j] == S[i + j]:
            ans += 1
   max_ans = max(max_ans, ans)
print(l - max_ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split()))
sum = 0
for i in range(1, N):
   sum +=A[i-1]
   sum = sum % (10**9 + 7)
   ans = ans + (sum * A[i]) % (10**9 + 7)
   ans = ans % (10**9 + 7)
print(ans)

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
sum = 0
ans = 0
for i in range(1, N):
   sum +=A[i-1]
   sum = sum % (10**9 + 7)
   ans = ans + (sum * A[i]) % (10**9 + 7)
   ans = ans % (10**9 + 7)
print(ans)

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split()))
sum = 0
for i in range(1, N):
   sum +=A[i-1]
   sum = sum % (10**9 + 7)
   ans += (sum * A[i]) % (10**9 + 7)
print(ans)

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
sum = 0
ans = 0
for i in range(1, N):
   sum +=A[i-1]
   sum = sum % (10**9 + 7)
   ans = ans + (sum * A[i]) % (10**9 + 7)
   ans = ans % (10**9 + 7)
print(ans)
Buggy python submission (verdict: Runtime Error):
import sys
import copy
R, C, K = map(int, input().split())
item = [[0]*C for _ in range(R)] 
for s in sys.stdin.readlines():
    r, c, v = map(int, s.split())
    r -= 1
    c -= 1
    item[r][c] = v
    
dp0 = [[0] * (C+1) for r in range(R+1)]
dp1 = [[0] * (C+1) for r in range(R+1)]
dp2 = [[0] * (C+1) for r in range(R+1)]
dp3 = [[0] * (C+1) for r in range(R+1)]
 
for r in range(R):
   for c in range(C):
      dp3[r][c] = max(dp3[r][c], dp2[r][c] + item[r][c])
      dp2[r][c] = max(dp2[r][c], dp1[r][c] + item[r][c])
      dp1[r][c] = max(dp1[r][c], dp0[r][c] + item[r][c])
      dp1[r][c+1] = max(dp1[r][c], dp1[r][c+1])
      dp2[r][c+1] = max(dp2[r][c], dp2[r][c+1])
      dp3[r][c+1] = max(dp3[r][c], dp3[r][c+1])
      dp0[r+1][c] = max(dp0[r+1][c], dp1[r][c])
      dp0[r+1][c] = max(dp0[r+1][c], dp2[r][c])
      dp0[r+1][c] = max(dp0[r+1][c], dp3[r][c])
ans = max(dp0[R-1][C-1], dp1[R-1][C-1])
ans = max(ans, dp3[R-1][C-1])
ans = max(ans, dp2[R-1][C-1])
print(ans)

Fixed submission:
str = input()
if 'R' in str:
   crs=1
   if 'RR' in str:
      crs=2
      if 'RRR' in str:
         crs=3
else:
    crs=0
print(crs)

Buggy python submission (verdict: Runtime Error):
import sys
import copy
R, C, K = map(int, input().split())
item = [[0] * C for _ in range(R)]  # dp配列と合わせるために, 0行目, 0列目を追加している.
for s in sys.stdin.readlines():
    r, c, v = map(int, s.split())
    r -= 1
    c -= 1
    item[r][c] = v
    
dp0 = [[0] * (C+1) for r in range(R+1)]
dp1 = [[0] * (C+1) for r in range(R+1)]
dp2 = [[0] * (C+1) for r in range(R+1)]
dp3 = [[0] * (C+1) for r in range(R+1)]
 
for r in range(R):
   for c in range(C):
      dp3[r][c] = max(dp3[r][c], dp2[r][c] + item[r][c])
      dp2[r][c] = max(dp2[r][c], dp1[r][c] + item[r][c])
      dp1[r][c] = max(dp1[r][c], dp0[r][c] + item[r][c])
      dp1[r][c+1] = max(dp1[r][c], dp1[r][c+1])
      dp2[r][c+1] = max(dp2[r][c], dp2[r][c+1])
      dp3[r][c+1] = max(dp3[r][c], dp3[r][c+1])
      dp0[r+1][c] = max(dp0[r+1][c], dp1[r][c])
      dp0[r+1][c] = max(dp0[r+1][c], dp2[r][c])
      dp0[r+1][c] = max(dp0[r+1][c], dp3[r][c])
ans = max(dp0[R-1][C-1], dp1[R-1][C-1])
ans = max(ans, dp3[R-1][C-1])
ans = max(ans, dp2[R-1][C-1])
print(ans)

Fixed submission:
str = input()
if 'R' in str:
   crs=1
   if 'RR' in str:
      crs=2
      if 'RRR' in str:
         crs=3
else:
    crs=0
print(crs)
Buggy python submission (verdict: Runtime Error):
X, K, D = input().split()
X = abs(X)
Q, mod = divmod(X, D)
if K < Q:
    ans = X - K*D
else:
    Rest = (K - Q)%2
    if Rest == 0:
         ans = mod
    else:
         ans = D - mod
print(ans)

Fixed submission:
s = input().split()
X=int(s[0])
K=int(s[1])
D=int(s[2])
q, mod = divmod(X, D)
if q < 0:
  q = -q
if 2*mod < D:
   if K < q:
      if X > 0:
         m = X - D*K
      else:
         m = X + D*K
   else:
       restmovement = (K-q)%2
       if restmovement==0:
          m = mod
       else:
          m = D - mod
else:
   if X > 0:
      if K < q+1:
         m = X - D*K
      else:
         restmovement = (K - q - 1)%2
         if restmovement==0:
                    m = D - mod
         else:
                    m = mod
   else:
       if K < q-1:
          m=X - D*K
       else:
          restmovement = (K+1-q)%2
          if restmovement==0:
                m = D-mod
          else:
                m = mod
if m < 0:
   print(-m)
else:
   print(m)
Buggy python submission (verdict: Runtime Error):
N, K = map(int,input().split())
A = sorted(map(int,input().split()))
start = 0
end = A[-1]
while end - start != 0:
   l = (start + end)/2
   count = 0
   for i in range(N):
      count += (A[i]-1)//l
   if count > K:
      start = int(l)
   else:
      end = int(l+1)
print(int(l)+1)

Fixed submission:
X = int(input())
if X > 29:
   print('Yes')
else:
   print('No')
Buggy python submission (verdict: Runtime Error):
import sys
N, D = map(int,input().split())
count = 0
for s in sys.stdin.readlines():
   X, Y = map(int, s.split())
   X = X / D
   Y = Y / D
   if X**2+Y**2 <= 1:
      count += 1
print(count)

Fixed submission:
import sys
N, D = map(int,input().split())
count = 0
for s in sys.stdin.readlines():
   X, Y = map(int, s.split())
   if X**2+Y**2 <= D**2:
      count += 1
print(count)
Buggy python submission (verdict: Runtime Error):
K = int(input())
r = 7 % K
ans = -1
for i in range(K):
   if r == 0:
      ans = i
      break
   r = 10r + 7
   r = r % K
print(ans)

Fixed submission:
K = int(input())
r = 7 % K
ans = -2
for i in range(K):
   if r == 0:
      ans = i
      break
   r = 10*r + 7
   r = r % K
print(ans+1)
Buggy python submission (verdict: Runtime Error):
N = int(input())
stone = list(map(input().split()))
R = stone.count('R')
ans = stone.count('W', 0, R-1)
print(ans)

Fixed submission:
N = int(input())
stone = input()
R = stone.count('R')
ans = stone.count('W', 0, R)
print(ans)
Buggy python submission (verdict: Runtime Error):
X, N = list(map(int, input().split()))
p = list(map(int, input().split()))
integer = [i+1 for i in range(100)]
for i in range(N):
   integer.remove(p[i])
integer = map(lambda x: x - X, integer)
l = len(integer)
ans = -200
for i in range(l):
   if abs(ans) > abs(integer[i]):
      ans = integer[i]
print(ans + X)

Fixed submission:
X, N = list(map(int, input().split()))
p = list(map(int, input().split()))
integer = [i for i in range(102)]
for i in range(N):
   integer.remove(p[i])
l = len(integer)
ans = -200
for i in range(l):
   if abs(ans) > abs(integer[i]-X):
      ans = integer[i] - X
print(ans + X)