Harryxun/GPT-100-sft-dataset huggingface dataset:
Problem p02897 (python)

Fixed submission:
n = int(raw_input())
if n ==1:
	print 1
else:
	if not n%2:
	  print(0.500000000)
	else:
	  print((int(n/2)+1)/float(n))

Buggy submission (verdict: Runtime Error):
n = int(raw_input())
if n ==1:
	print 1
else:
	if not n%2:
	  print(0.500000000)
	else:
	  print((int(n/2)+1)/float(n))

Buggy submission (verdict: Runtime Error):
n = int(raw_input())
n = n +0.000000
if not n%2:
  print 0.500000000
else:
  print((n/2)/n)

Buggy submission (verdict: Runtime Error):
n = int(raw_input())
if not n%2:
  print 0.500000000
else:
  print((n/2)/n)

Buggy submission (verdict: Runtime Error):
if N%2:
  return 0.6
else:
  return 0.5
Problem p02897 (python)

Fixed submission:
N = int(input())
 
if N % 2 != 0: s = (N+1)/(2*N) 
else: s = 1/2
  
print(s)

Buggy submission (verdict: Runtime Error):
N = int(input())

if N % 2 =! 0: s = (N+1) / (2*N) 
else: s = 1/2
print(s)
Problem p02897 (python)

Fixed submission:
x = int(input())
x_all = list(range(1, x+1))
x_odds = list(filter(lambda xx: xx % 2 == 1, x_all))
print(float(len(x_odds)) / len(x_all))

Buggy submission (verdict: Runtime Error):
x = list(range(1, int(input())+1)
x_odds = list(filter(lambda xx: xx % 2 == 1, x))
print(float(len(x_odds) / len(x))
Problem p02897 (python)

Fixed submission:
import sys
N = int(input())
print((int(N/2)+N%2)/N)

Buggy submission (verdict: Runtime Error):
import sys
N = input()
print((N/2+N%2)/2)

Buggy submission (verdict: Runtime Error):
N = input()
print((N/2+N%2)/2)

Buggy submission (verdict: Runtime Error):
N = imput()
print((N/2+N%2)/2)
Problem p02915 (python)

Fixed submission:
import sys
N=int(input())

print(pow(N,3))

Buggy submission (verdict: Runtime Error):
import sys
N=input()

print(pow(N,3))

Buggy submission (verdict: Runtime Error):
import sys
N=input()

pow(N,3)
Problem p02951 (python)

Fixed submission:
A, B, C = list(map(int, input().split()))
ans = B + C - A
if ans < 0:
  ans = 0
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
ans = 0
for i in range(1, N+1):
  if len(str(i)) % 2 == 1:
    ans += 1
print(ans)
Problem p03307 (python)

Fixed submission:
N = int(input())
if(N % 2 == 0):
    print(N)
else:
    print(N * 2)

Buggy submission (verdict: Runtime Error):
import math
N = int(input())
print(int((2 * N) // math.gcd(2, N)))

Buggy submission (verdict: Runtime Error):
import math
N = int(input())
print(int(2 * N /math.gcd(2, N)))
Problem p02897 (python)

Fixed submission:
n = int(input())
if n % 2 == 0:
  print(0.500000)
else:
  print((n//2+1) / n)

Buggy submission (verdict: Runtime Error):
n = input()
if n % 2:
  print(0.500000)
else:
  print((n//2+1) / n)
Problem p02897 (python)

Fixed submission:
n = int(input())
ns = n % 2
if n == 1:
    print(1)
elif ns == 0:
    print(0.5)
else:
    print(((n//2)+1)/n)

Buggy submission (verdict: Runtime Error):
n, k = map(int(), input().split())
j = 0
ki = [map(int(), input().split())]
for num in ki:
    if num < k:
        j += 1
print(j)

Buggy submission (verdict: Runtime Error):
n = input()
ns = n % 2
if n == 1:
    print(1)
elif ns == 0:
    print(0.5)
else:
    print(((n//2)+1)/n)

Buggy submission (verdict: Runtime Error):
n = input()
ns = n % 2
if n == 1:
    print(1)
elif ns == 0:
    print(1)
else:
    print((n//2)+1)

Buggy submission (verdict: Runtime Error):
n = input()
ns = n % 2
if n == 1:
    print(float(1)
elif ns == 0:
    print(float(0.5))
else:
    print(float(n//2+1))
Problem p02897 (python)

Fixed submission:
n = int(input())
if n % 2 == 0:
  print(1/2)
else:
  print((n/2 + 0.5)/n)

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
h = list(map(int,input().split()))
oppai = 0
for i in range(n):
  if h[i] >= k:
    oppai += 1
print(oppai)

Buggy submission (verdict: Runtime Error):
n = int(input)
if n % 2 == 0:
  print(1/2)
else:
  print((n/2 + 0.5)/n)

Buggy submission (verdict: Runtime Error):
n = float(input)
if n % 2 == 0:
  return 1/2
else:
  return (n/2 + 0.5)/n

Buggy submission (verdict: Runtime Error):
n = int(input())
if n % 2 == 0:
  return 1/2
else:
  return (n/2 + 0.5)/n

Buggy submission (verdict: Runtime Error):
n = input()
if n % 2 == 0:
  return 1/2
else:
  return (n/2 + 0.5)/n

Buggy submission (verdict: Runtime Error):
n = input
if n % 2 == 0:
  return 1/2
else:
  return (n/2 + 0.5)/n

Buggy submission (verdict: Runtime Error):
n = int(input)
if n % 2 == 0:
  return 1/2
else:
  return (n/2 + 0.5)/n
Problem p02915 (python)

Fixed submission:
n = int(input())
print(n ** 3)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
suf = 0
for i in range (n):
  if a[i]!= n-1:
  	men1 = a[i]
  	men2 = a[i + 1] 
  	suf += b[men1]
  	if (men1 + 1 == men2):
    	suf += c[men1]
  else:
    men1 = a[i]
    suf += b[men1]
print(suf)
Problem p02951 (python)

Fixed submission:
a, b, c = map(int, input().split())
print(max(-a + b + c, 0))

Buggy submission (verdict: Runtime Error):
a,b = map(int,input().split())
if (a+b) % 2 ==0:
  print((a + b)// 2)
else:
  print("IMPOSSIBLE")
Problem p02987 (python)

Fixed submission:
S = input()
if ((S[0] == S[1]) and (S[0] !=S[2]) and (S[2] == S[3]))or((S[0] != S[1]) and (S[0] ==S[2]) and (S[1] == S[3]))or((S[0] != S[1]) and (S[1] == S[2]) and (S[0] == S[3])):
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
S = input()
if ((S[0] == S[1]) and (S[0] !=S[2]) and (S[2] == S[3]))or
	((S[0] != S[1]) and (S[0] ==S[2]) and (S[1] == S[3]))or
	((S[0] != S[1]) and (S[1] == S[2]) and (S[0] == S[3])):
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
S = input()
if ((S[0] == S[1]) and (S[0] !==S[2]) and (S[2] == S[3]))or((S[0] != S[1]) and (S[0] ==S[2]) and (S[1] == S[3]))or((S[0] != S[1]) and (S[1] == S[2]) and (S[0] == S[3])):
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
S = input()
if ((S[0] == S[1]) and (S[0] !==S[2]) and (S[2] == S[3]))or
	((S[0] != S[1]) and (S[0] ==S[2]) and (S[1] == S[3]))or
	((S[0] != S[1]) and (S[1] == S[2]) and (S[0] == S[3])):
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
S = input()
if (S[0] == S[1] and S[0] !==S[2] and S[2] == S[3])or
(S[0] != S[1] and S[0] ==S[2] and S[1] == S[3])or
(S[0] != S[1] and S[1] == S[2] and S[0] == S[3]):
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
S = input()
n = 0
if S[1] not in S[0]:
  n += 1
if S[2] not in S[0,1]:
  n += 1
if S[3] not in S[0,2]:
  n += 1
if n == 2:
  print("Yes")
else:
  print("No")
Problem p03041 (python)

Fixed submission:
N, K = map(int, input().split())
S = list(input())
if S[K-1] == "A":
  S[K-1] = "a"
elif S[K-1] == "B":
  S[K-1] = "b"
else:
  S[K-1] = "c"
ans = "".join(S)
print(ans)

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
S = str(input())
if S[K-1] == "A":
  S[K-1] = "a"
elif S[K-1] == "B":
  S[K-1] = "b"
else:
  S[K-1] = "c"
print(S)

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
S = input()
if S[K-1] == "A":
  S[K-1] = "a"
elif S[K-1] == "B":
  S[K-1] = "b"
elif S[K-1] == "C":
  S[K-1] = "c"
else:
  continue
print(S)

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
S = input()
if S[K] == "A":
  S[K] = "a"
if S[K] == "B":
  S[K] = "b"
if S[K] == "C":
  S[K] = "c"
print(S)

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
S = input()
if S[K-1] == "A":
  S[K-1] = "a"
elif S[K-1] == "B":
  S[K-1] = "b"
else:
  S[K-1] = "c"
print(S)

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
S = input()
if S[K] == "A":
  S[K] = "a"
elif S[K] == "B":
  S[K] = "b"
else:
  S[K] = "c"
print(S)
Problem p02916 (python)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
bonus = 0
for i in  range(N-1):
  if A[i] + 1 == A[i+1]:
    bonus += C[A[i]-1]

    
print(sum(B)+bonus)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
bonus = 0
for i in  range(N):
  if A[i] + 1 == A[i+1]:
    bonus += C[A[i]-1]

    
print(sum(B)+bonus)
Problem p02933 (python)

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

if a>=3200:
  print(s)
  
else:
    print("red")

Buggy submission (verdict: Runtime Error):
a = int(input())
s = input()

if N>=3200:
  print(s)
  
else:
    print("red")

Buggy submission (verdict: Runtime Error):
N = int(input())

if N>=3200:
  print(s)
  
else:
    print("red")
Problem p02987 (python)

Fixed submission:
S = input()

if (S[0]==S[1] and S[2]==S[3] and S[1]!=S[2])or (S[1]==S[2] and S[0]==S[3] and S[0]!=S[1])or (S[0]==S[2] and S[1]==S[3] and S[1]!=S[2]):
  print("Yes")
else:
  print("No")

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

if (S[0]==S[1] and S[2]==S[3] and S[1]!=S[2])or (S[1]==S[2] and S[0]==S[3] and S[0]!=S[1])or (S[0]==S[2] and S[1]==S[3] and S[1]!=S[2]):
  print(Yes)
else:
  print(No)
Problem p02897 (python)

Fixed submission:
import math
N = int(input())
a = math.ceil(N/2)/N
print(a)

Buggy submission (verdict: Runtime Error):
import math
N = int(input())
a = math.celil(N/2)/N
print(a)
Problem p02897 (python)

Fixed submission:
import math
n = int(input())

if n == 1:
    print("{:.10f}".format(1))
    exit()

res = (n-math.floor(n/2))/n


print("{:.10f}".format(res))

Buggy submission (verdict: Runtime Error):
n = input()

res = (n-(n/2))/n

print(res)

Buggy submission (verdict: Runtime Error):
n = input()

res = (n-(n/2))/n

print(ress)
Problem p02989 (python)

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

arr = sorted(arr_input)
i = int(n/2)

ans = arr[i] - arr[i-1]

if ans == 0:
    print(0)
else:
    print(ans)

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

arr = sorted(arr_input)

ans = arr[n/2] - arr[n/2-1]

if ans == 0:
    print(0)
else:
    print(ans)
Problem p02933 (python)

Fixed submission:
a = int(input())
s = input()
if a >= 3200:
  print(s)
else:
  print('red')

Buggy submission (verdict: Runtime Error):
a = int(input())
s = input()
if a >= 3200:
  print(S)
else:
  print('red')
Problem p03135 (python)

Fixed submission:
T,X = map(int,input().split())
#世界Bで　X * t = 世界Aで　t ⇒　T = X * t  t = T / X
print(T/X)

Buggy submission (verdict: Runtime Error):
T = int(input())
X = int(input())
#世界Bで　X * t = 世界Aで　t ⇒　T = X * t  t = T / X
print(T / X)
Problem p02915 (python)

Fixed submission:
N=int(input())
print(N**3)

Buggy submission (verdict: Runtime Error):
N=int(input())
print(N**3
Problem p03011 (python)

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

A=sorted(A)
print(A[0]+A[1])

Buggy submission (verdict: Runtime Error):
N=int(input())
W=list(map(int,input().split()))

diff=[]
for i in range(N-1):
    diff.append(abs(sum(W[:i+1])-sum(W[i+1:])))
print(min(diff))
Problem p03012 (python)

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

diff=[]
for i in range(N-1):
    diff.append(abs(sum(W[:i+1])-sum(W[i+1:])))
print(min(diff))

Buggy submission (verdict: Runtime Error):
N=int(input())
W=list(map(int,input().split()))

diff=[]
for i in range(N-1):
    diff.append(abs(sum(W[:i+1])-sum(W[i+1:])))
print(min(diff)
Problem p03075 (python)

Fixed submission:
a=[0]*5
for i in range(5):
    a[i]=int(input().strip())
k=int(input().strip())
d=max(a)-min(a)
if d<=k:
    print("Yay!")
else:
    print(":(")

Buggy submission (verdict: Runtime Error):
`a=[0]*5
for i in range(5):
    a[i]=int(input().strip())
k=int(input().strip())
d=max(a)-min(a)
if d<=k:
    print("Yay!")
else:
    print(":(")
Problem p03127 (python)

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

def gcd(a,b):
    while b:
        a,b=b,a%b
    return a

A.sort()
y=A[0]
for i in range(1,N):
    y=gcd(y,A[i])
print(y)

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

while len(A)!=1:
#for i in range(2):
    A.sort()
    if A.count(0):A.remove(0)
    for i in range(len(A)-1):            
        A[i+1]=A[i+1]%A[0]

print(max(A))
Problem p03221 (python)

Fixed submission:
N,M=map(int,input().split())
birth=[]
for i in range(M):
    p,y=map(int,input().split())
    birth.append([i,p,y])

birth.sort(key=lambda x:(x[1],x[2]))

birth[0].append(0)
cnt=0
for i in range(M-1):
    if birth[i][1]==birth[i+1][1]:
        cnt+=1
    else:
        cnt=0
    birth[i+1].append(cnt)

birth.sort(key=lambda x:x[0])
for i in range(M):
    ans=str(birth[i][1]).zfill(6)+str(birth[i][3]+1).zfill(6)
    print(ans)

Buggy submission (verdict: Runtime Error):
for i in range(M):
    array=list(map(int,input().strip().split()))
    PY.append(array)

PY.sort()
city=0
order=0
for i in range(M):
    newcity=PY[i][0]
    if(newcity!=city):
        city=newcity
        order=1
    strcity=str(PY[i][0])
    strorder=str(order)
    upper='0'*(6-len(strcity))+strcity
    lower='0'*(6-len(strorder))+strorder
    order=order+1
    print(upper+lower)
Problem p03317 (python)

Fixed submission:
import math

N,K=map(int,input().split())
A=list(map(int,input().split()))

ans=math.ceil((N-1)/(K-1))
print(ans)

Buggy submission (verdict: Runtime Error):
import math

N,K=map(int,input().split())
A=[*map(int,input().split())]

ans=math.ceil((N-1)/(K-1))
print(ans)
Problem p03723 (python)

Fixed submission:
# 誰か奇数になったら終了
# A==B==C になったら-1

A,B,C=map(int,input().split())
cnt=0
ans=0
while A%2==0 and B%2==0 and C%2==0:
    if A==B==C:
        ans=-1
        break
    else:
        A,B,C=(B+C)//2,(C+A)//2,(A+B)//2
        cnt+=1
        ans=cnt
print(ans)

Buggy submission (verdict: Runtime Error):
# 誰か奇数になったら終了
# A==B==C になったら-1

A,B,C=map(int,input().split())
cnt=0
while A%2==0 and B%2==0 and C%2==0:
    if A==B==C:
        ans=-1
        break
    else:
        A,B,C=(B+C)//2,(C+A)//2,(A+B)//2
        cnt+=1
        ans=cnt
print(ans)
Problem p03745 (python)

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

n=int(raw_input().strip())
arr=map(int,raw_input().split())

b=0
cnt=0

for i in xrange(n-1):
    diff=arr[i+1]-arr[i]
    if b*diff<0:
        cnt+=1
        b=0
    elif b==0:
        b=diff
print cnt+1

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python

n=int(raw_input().strip())
arr=map(int,raw_input().split())

b=0
cnt=0

for i in xrange(n-1):
    diff=arr[i+1]-arr[i]
    if b*diff<0:
        cnt+=1
        b=0
    elif d==0:
        b=diff
print cnt+1
Problem p03785 (python)

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

from sys import stdin

N,C,K=map(int,raw_input().split())
T=map(int,stdin.read().split())

T.sort()
t_star=T[0]
b_star=0
cnt=0
for b,t in enumerate(T):
    if t-t_star>K or b-b_star+1>C:
        cnt+=1
        t_star=t
        b_star=b

print cnt+1

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python

from sys import stdin

N,C,K=map(int,raw_input(),split(" "))
T=map(int,stdin.read().split())

T.sort()
t_star=t[0]
b_star=0
cnt=0
for b,t in enumerate(T):
    if t-t_star>K or b-b_star+1==C:
        cnt+=1
        t_star=t
        b_star=b

print cnt
Problem p03803 (python)

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

numbers = raw_input().split()

A = int(numbers[0])
B = int(numbers[1])

if A == B :
   print "Draw"
elif A == 1:
   print "Alice"
elif B == 1:
   print "Bob"
elif A > B:
   print "Alice"
elif B > A:
   print "Bob"

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python
from itertools import permutations
N,M=map(int,raw_input().split())
path=[]
all_list=[]
count=0
 
for i in range(M):
    path.append(map(int,raw_input().split()))

NN=N*(N-1)/2
all_list=map(list,permutations(range(1,NN+1),2))
for i in range(len(all_list)):
    for j in range(M):
        if all_list[i]==path[j]:
            count=count+1
 
print count

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python

N,M=map(int,input().split())
path=[]
all_list=[]
count=0

for i in range(M):
    path.append(map(int,raw_input().split()))

NN=N*(N-1)/2
all_list=map(list,permutations(range(NN),2))
for i in all_list[i]:
    for j in path[j]:
        if all_list[i]==path[j]:
            count=count+1

print count

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python

N,M=input().split()
path=[]
all_list=[]
count=0

for i in range(M):
    path.append(map(int,raw_input().split()))

NN=N*(N-1)/2
all_list=map(list,permutations(range(NN),2))
for i in all_list[i]:
    for j in path[j]:
        if all_list[i]==path[j]:
            count=count+1

print count
Problem p02897 (python)

Fixed submission:
ans = int(input())
if ans == 1: print(ans)
elif ans % 2 == 1:
    print( (int(ans/2)+1)/ans )
elif ans % 2 ==0:
    print((int(ans/2))/ans)

Buggy submission (verdict: Runtime Error):
print(1/int(input))
Problem p02897 (python)

Fixed submission:
N = int(input())
odd = 0
for i in range(1, N + 1):
    if i % 2 != 0:
        odd += 1
print(odd / N)

Buggy submission (verdict: Runtime Error):
d, e = map(int, f.readline().strip().split())
g = list(map(int, f.readline().strip().split()))
#print(d, e)
#print(g)
total = 0
for i in g:
    if i >= e:
        total += 1
print(total)
Problem p02933 (python)

Fixed submission:
a = int(input())
s = input()
if a < 3200:
	print('red')
else:
	print(s)

Buggy submission (verdict: Runtime Error):
    def find(i, ss, step):
        for j in range(step, len(ss)):
            #print(i, j, ss[j])
            if i == ss[j]:
                a = j
                return a, step
        return -1
     
     
    s = input().strip()
    #print(s)
    t = input().strip()
    #print(t)
    ss = s * 100
    #print(ss)
    step = 0
    for i in t:
        a = find(i, ss, step)
        if a == -1:
            print(-1)
            break
        else:
            #print(a)
            step = a[0] + 1
            #print(step)
    if a != -1:
        print(step)
Problem p03107 (python)

Fixed submission:
N = input().strip()
#print(N)
length = len(N)
#print(length)
totalZeros = 0
totalOnes = 0
for i in N:
    if i == '0':
        totalZeros += 1
    else:
        totalOnes += 1
if totalOnes < totalZeros:
    answer = totalOnes * 2
else:
    answer = totalZeros * 2

print(answer)

Buggy submission (verdict: Runtime Error):
def remove01Pair(R):
    for i in range(len(R) - 1):
        #print(i)
        if R[i:i + 2] == '01':
            R = R[:i] + R[i + 2:]
            #print(R)
            return R
    flag[0] = 1
    return R

def remove10Pair(R):
    for i in range(len(R) - 1):
        #print(i)
        if R[i:i + 2] == '10':
            R = R[:i] + R[i + 2:]
            #print(R)
            return R
    flag[0] = 1
    return R

N = input().strip()
#print(N)
length = len(N)
#print(length)
flag = []
flag.append(0)
while flag[0] == 0:
    N = remove01Pair(N)
    #print(N)
    #time.sleep(1)
flag[0] = 0
while flag[0] == 0:
    N = remove10Pair(N)
    #print(N)
    #time.sleep(1)
#print()
#print(len(N))
f.close()
print(length - len(N))
Problem p03033 (python)

Fixed submission:
from heapq import heappush, heappop
import sys
from __pypy__ import builders
readline = sys.stdin.readline
N, Q = map(int, readline().split())
qs = [0]*N
for i in range(N):
    s, t, x = map(int, readline().split())
    qs[i] = (s-x, t-x, x)
qs.sort()

b = builders.StringBuilder(Q)
que = []
D = [int(readline()) for i in range(Q)]
j = 0
for d in D:
    while j < N and qs[j][0] <= d:
        s, t, x = qs[j]
        heappush(que, (x, t))
        j += 1
    while que and que[0][1] <= d:
        heappop(que)
    if que:
        b.append("%d\n" % que[0][0])
    else:
        b.append("-1\n")
sys.stdout.write(b.build())

Buggy submission (verdict: Runtime Error):
from heapq import heappush, heappop
import sys

ans = [None]*Q
def solve():
    readline = sys.stdin.readline
    N, Q = map(int, readline().split())
    qs = [0]*(N+1)
    for i in range(N):
        s, t, x = map(int, readline().split())
        qs[i] = (s-x, t-x, x)
    qs[N] = (10**10, 10**10, 0)
    qs.sort()

    que = []
    D = [int(readline()) for i in range(Q)]
    j = 0
    it = iter(qs).__next__
    s, t, x = it()
    v = w = N
    for d in D:
        while j < N and s <= d:
            heappush(que, (x, t))
            v, w = que[0]
            s, t, x = it()
        while que and w <= d:
            heappop(que)
            if que:
                v, w = que[0]
        if que:
            yield "%d\n" % v
        else:
            yield "-1\n"
ans[:] = solve()
sys.stdout.writelines(ans)

Buggy submission (verdict: Runtime Error):
from heapq import heappush, heappop
import sys, os
from __pypy__ import builders
readline = sys.stdin.readline
N, Q = map(int, readline().split())
qs = [0]*N
for i in range(N):
    s, t, x = map(int, readline().split())
    qs[i] = (s-x, t-x, x)
qs.sort()

b = builders.BytesBuilder(Q)
que = []
D = [int(readline()) for i in range(Q)]
j = 0
for d in D:
    while j < N and qs[j][0] <= d:
        s, t, x = qs[j]
        heappush(que, (x, t))
        j += 1
    while que and que[0][1] <= d:
        heappop(que)
    if que:
        b.append(b"%d\n" % que[0][0])
    else:
        b.append(b"-1\n")
os.write(1, b.build())
Problem p03036 (python)

Fixed submission:
r, D, x = map(int, input().split())
for i in range(10):
    x = r*x - D
    print(x)

Buggy submission (verdict: Runtime Error):
A, B = map(int, input().split())
if A >= 13:
    print(B)
elif A >= 6:
    print(B//2)
else:
    print(0)
Problem p03055 (python)

Fixed submission:
from collections import deque
import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline
N = int(readline())
if N == 1:
    print("First")
    exit(0)
G = [[] for i in range(N)]
for i in range(N-1):
    a, b = map(int, readline().split())
    G[a-1].append(b-1)
    G[b-1].append(a-1)
def bfs(s):
    dist = [None]*N
    que = deque([s])
    dist[s] = 0
    while que:
        v = que.popleft()
        d = dist[v]
        for w in G[v]:
            if dist[w] is not None:
                continue
            dist[w] = d + 1
            que.append(w)
    d = max(dist)
    return dist.index(d), d
u, _ = bfs(0)
v, d = bfs(u)

memo = [-1]*(d+2)
memo[0] = 0
memo[1] = 1
memo[2] = 0
for i in range(3, d+2):
    if memo[i-1] == 0 or memo[i-2] == 0:
        memo[i] = 1
    else:
        memo[i] = 0
print("First" if memo[d+1] else "Second")

Buggy submission (verdict: Runtime Error):
from collections import deque
import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline
N = int(readline())
G = [[] for i in range(N)]
for i in range(N-1):
    a, b = map(int, readline().split())
    G[a-1].append(b-1)
    G[b-1].append(a-1)
def bfs(s):
    dist = [None]*N
    que = deque([s])
    dist[s] = 0
    while que:
        v = que.popleft()
        d = dist[v]
        for w in G[v]:
            if dist[w] is not None:
                continue
            dist[w] = d + 1
            que.append(w)
    d = max(dist)
    return dist.index(d), d
u, _ = bfs(0)
v, d = bfs(u)

memo = [-1]*(d+2)
memo[0] = 0
memo[1] = 1
memo[2] = 0
def dfs(d):
    if memo[d] != -1:
        return memo[d]
    if dfs(d-1) == 0 or dfs(d-2) == 0:
        memo[d] = 1
        return 1
    memo[d] = 0
    return 0
print("First" if dfs(d+1) else "Second")
Problem p03332 (python)

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

fact = [1]*(N+1)
rev = [1]*(N+1)
for i in range(1, N+1):
    fact[i] = fact[i-1]*i % MOD
    rev[i] = pow(fact[i], MOD-2, MOD)

ans = 0
for a in range(N+1):
    if (K - a*A) >= 0 and (K - a*A) % B == 0:
        b = (K - a*A) // B
        if not 0 <= b <= N:
            continue
        ans += rev[a]*rev[N-a] * rev[b]*rev[N-b]
        ans %= MOD
ans *= fact[N]*fact[N]
ans %= MOD
print(ans)

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

fact = [1]*(N+1)
rev = [1]*(N+1)
for i in range(1, N+1):
    fact[i] = fact[i-1]*i % MOD
    rev[i] = pow(fact[i], MOD-2, MOD)

ans = 0
for a in range(N+1):
    if (K - a*A) >= 0 and (K - a*A) % B == 0:
        b = (K - a*A) // B
        ans += rev[a]*rev[N-a] * rev[b]*rev[N-b]
        ans %= MOD
ans *= fact[N]*fact[N]
ans %= MOD
print(ans)