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

Fixed submission:
from math import floor, sqrt, ceil


def f(b, n):
    if b < 2:
        return 0

    if n < b:
        return n

    return f(b, floor(n / b)) + n % b


n = int(input())
s = int(input())

if n == s:
    print(n + 1)
    exit()

for b in range(2, floor(sqrt(n)) + 1):
    if f(b, n) == s:
        print(b)
        exit()

for p in range(1, ceil(sqrt(n)))[::-1]:
    b = (n - s) / p + 1
    if b.is_integer():
        b = int(b)
        if f(b, n) == s:
            print(b)
            exit()

print(-1)

Buggy submission (verdict: Runtime Error):
from math import floor, sqrt, ceil


def f(b, n):
    if n < b:
        return n

    return f(b, floor(n / b)) + n % b


n = int(input())
s = int(input())

if n == s:
    print(n + 1)
    exit()

for b in range(2, floor(sqrt(n)) + 1):
    if f(b, n) == s:
        print(b)
        exit()

for p in range(1, ceil(sqrt(n)))[::-1]:
    b = (n - s) / p + 1
    if b.is_integer():
        b = int(b)
        if f(b, n) == s:
            print(b)
            exit()

print(-1)
Problem p02658 (python)

Fixed submission:
def main():
    N=int(input())
    A=list(map(int,input().split()))
    if 0 in A:
      print('0')
      return
    p=1
    for i in A:
      p=p*i
      if p>1000000000000000000:
        print(-1)
        return
    print(p)    
main()

Buggy submission (verdict: Runtime Error):
def main():
N=int(input())
A=list(map(int,input().split()))
if A is 0:
  print(0)
  return
p=1
for i in A:
  p=p*i
  if p>1000000000000000000:
    print(-1)
    return
print(p)  
main()

Buggy submission (verdict: Runtime Error):
N=int(input())
A=list(map(int,input().split()))
if 0 in A:
  print(0)
  return
p=1
for i in A:
  p=p*i
  if p>1000000000000000000:
    print(-1)
    return
print(p)

Buggy submission (verdict: Runtime Error):
N=int(input())
A=list(map(int,input().split()))
if A is 0:
  print(0)
  return
p=1
for i in A:
  p=p*i
  if p>1000000000000000000:
    print(-1)
    return
print(p)
Problem p02706 (python)

Fixed submission:
N,Q = map(int, input().split())
l = list(map(int,input().split()))
 
ans = 0
for i in range(0,Q):
  ans = ans + l[i]
  
if(ans > N):
  print("-1")
else:
  print(N-ans)

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

ans = 0
for i in range(0,M):
  ans = ans + l[i]
  
if(ans > N):
  print("-1")
else:
  print(N-ans)
Problem p02818 (python)

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

t = a[0]-a[2]

if t<0:

    a[1] = a[1] +t
    if(a[1] < 0):
        a[1] = 0
    t = 0

print("%d %d"%(t,a[1]))

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

if(a[0] >= a[2]):
    a[0] = a[0] -a[2]
    a[2] = 0
     a[2] = a[2] - a[0]
elif(a[1] >= a[2]):
    a[0] = 0
    a[1] = a[1] -a[2]
else:
    a[1] = 0
print("%d %d"%(a[0],a[1]))

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

if((a[0]+a[1]) == a[2]):
    print("0 0")

if((a[0]+a[1]) != a[2])
for i in range(0, a[2]):
    if(a[0] >= 1):
        a[0] -= 1

    elif(a[1] >= 1):
        a[1] -= 1

print("%d %d"%(a[0],a[1]))
Problem p03030 (python)

Fixed submission:

N = int(input())
SP = []
for i in range(N):
    s, n = input().split()
    n = int(n)
    SP.append((s, -n, i))
SP.sort()

for s, n, i in SP:
    print(i+1)

Buggy submission (verdict: Runtime Error):

N = int(input())
SP = []
for i in range(N):
    s, p = input().split()
    p = int(p)
    SP.append((s, -n, i))
SP.sort()

for s, n, i in SP:
    print(i+1)
Problem p02641 (python)

Fixed submission:
x,n = map(int,input().split())
l = [int(x) for x in input().split()]
mp = [False]*101
for i in range(n):
    mp[l[i]] = True



queue = [x]
while(len(queue)>0):
    now = queue.pop(0)
    if(now <= 0 or now >=101):
        print(now)
        break
    if(mp[now]==False):
        print(now)
        break
    
    if(now==x):
        queue.append(now-1)
        queue.append(now+1)
    if(now < x):
        queue.append(now-1)
    if(now > x):
        queue.append(now+1)

Buggy submission (verdict: Runtime Error):
x,n = map(int,input().split())
l = [int(x) for x in input().split()]
mp = [False]*101
for i in range(n):
    mp[l[i]] = True



queue = [x]
while(len(queue)>0):
    now = queue.pop(0)
    if(mp[now]==False):
        print(now)
        exit()
    if(now <= 0 or now >=101):
        print(now)
        exit()
    
    queue.append(now-1)
    queue.append(now+1)

Buggy submission (verdict: Runtime Error):
x,n = map(int,input().split())
l = [int(x) for x in input().split()]
mp = [False]*101
for i in range(n):
    mp[l[i]] = True



queue = [x]
while(queue):
    now = queue.pop(0)
    if(mp[now]==False):
        print(now)
        exit()
    queue.append(now-1)
    queue.append(now+1)
Problem p02690 (python)

Fixed submission:
x = int(input())
sign = ((1,1),(1,-1),(-1,1),(-1,-1))
isloop=True
for a in range(10**3):
    if(isloop==False):
        break
    for b in range(10**3):
        if(isloop==False):
            break
        for s1,s2 in sign:
            if(isloop==False):
                break
            a1 = s1*a
            b1 = s2*b
            if((a1**5)==(x+b1**5)):
                print(a1,b1)
                isloop=False
                break

Buggy submission (verdict: Runtime Error):
n = int(input())
h_l = list(map(int,input().split()))
cnt = 0
for i in range(n):
    h_i = h_l[i]
    cnt += sum([1 for j in range(i,n) if((j-i)==(h_l[j]+h_i))])
            

print(cnt)
Problem p02719 (python)

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

def f(a,b):
    s = a//b 
    a = a-s*b
    ans = min(a,abs(a-b))
    return ans


if(n%k==0):
    print(0)
else:
    print(f(n,k))

Buggy submission (verdict: Runtime Error):
n,k = map(int,input().split())
from math import gcd

if(n%k==0):
    print(0)
else:
    print(gcd(n,k))
Problem p02882 (python)

Fixed submission:
a,b,x = map(int,input().split())
import math
m_cm3 = a*b*a
if(x >= (m_cm3/2)):
    s = 2*b - (2*x)/(a**2)
    s /= a
    ans = math.degrees(math.atan(s))
else:
    s = (a*b*b)/(2*x)
    ans = math.degrees(math.atan(s))

print(ans)

Buggy submission (verdict: Runtime Error):
a,b,x = map(int,input().split())
import math
m_cm3 = a*b*a
if(x >= (m_cm3/2)):
    s = 2*b - (2*x)/(a**2)
    s /= a
    ans = math.degrees(math.atan(s))
else:
    s = (2*x)/(a*b*b)
    ans = math.degrees(math.acos(s))

print(ans)
Problem p02900 (python)

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

from itertools import combinations

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

gcd_n = gcd(a,b)

#L = [i for i in range(1,gcd_n+1) if gcd_n%i==0]

def div(num):
    l = [1]
    if(num==1):
        return [1]
    while(num%2==0):
        num //=2
        l.append(2)
    f = 3
    while(f*f<=num):
        if num%f==0:
            num //= f
            l.append(f)
        else:
            f += 2
    
    if num!=1:
        l.append(num)
    return l

l = div(gcd_n)
cnt = 0
pre = 0
for i in range(len(l)):
    if pre==l[i]:
        continue
    pre = l[i]
    cnt += 1
print(cnt)

Buggy submission (verdict: Runtime Error):
a,b = map(int,input().split())
from math import gcd
print(gcd(a,b))

Buggy submission (verdict: Runtime Error):
a,b = map(int,input().split())
from math import gcd
from itertools import combinations
gcd_n = gcd(a,b)

L = [i for i in range(1,gcd_n+1) if gcd_n%i==0]

def div(num):
    l = [1]
    if(num==1):
        return [1]
    while(num%2==0):
        num //=2
        l.append(2)
    f = 3
    while(f*f<=num):
        if num%f==0:
            num //= f
            l.append(f)
        else:
            f += 2
    
    if num!=1:
        l.append(num)
    return l

l = div(gcd_n)
cnt = 0
pre = 0
for i in range(len(l)):
    if pre==l[i]:
        continue
    pre = l[i]
    cnt += 1
print(cnt)
Problem p02995 (python)

Fixed submission:
import fractions
a,b,c,d = map(int,input().split())
AdivC = (a-1)//c
BdivC = b//c
AdivD = (a-1)//d
BdivD = b//d
gc = fractions.gcd(c,d)
div = (c*d)//gc
AdivCandD = (a-1)//div
BdivCandD = b//div

divC = BdivC - AdivC
divD = BdivD - AdivD
divCandD = BdivCandD - AdivCandD
ans = b-a+1
ans = ans -(divC+divD-divCandD)
print(ans)

Buggy submission (verdict: Runtime Error):
import math
a,b,c,d = map(int,input().split())
AdivC = (a-1)//c
BdivC = b//c
AdivD = (a-1)//d
BdivD = b//d
gc = math.gcd(c,d)
div = (c*d)//gc
AdivCandD = (a-1)//div
BdivCandD = b//div

divC = BdivC - AdivC
divD = BdivD - AdivD
divCandD = BdivCandD - AdivCandD
ans = b-a+1
ans = ans -(divC+divD-divCandD)
print(ans)
Problem p03071 (python)

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

Buggy submission (verdict: Runtime Error):
a, b = int(input())
ans = 0
ans += max(a, b)*2 - 1
print(ans)
Problem p03087 (python)

Fixed submission:
n, q = map(int, input().split())
s = input()
num = [list(map(int, input().split())) for i in range(q)]
arr = [0]
tmp = 0
for i in range(n):
    if s[i:i+2] == 'AC':
        tmp += 1
    arr.append(tmp)

for left, right in num:
    ans = arr[right - 1] - arr[left - 1]
    print(ans)

Buggy submission (verdict: Runtime Error):
n, q = map(int, input().split())
s = input()
num = [list(map(int, input().split())) for i in range(q)]
arr = [0]
tmp = 0
for i in range(n):
    if s[i] == 'A' and s[i + 1] == 'C':
        tmp += 1
    arr.append(tmp)

for left, right in num:
    ans = arr[right - 1] - arr[left - 1]
    print(ans)

Buggy submission (verdict: Runtime Error):
n, q = map(int, input().split())
s = input()
num = [list(map(int, input().split())) for i in range(q)]
arr = [0]
tmp = 0
for i in range(n):
    arr.append(tmp)
    if s[i] == 'A' and s[i + 1] == 'C':
        tmp += 1

for left, right in num:
    ans = arr[right] - arr[left]
    print(ans)
Problem p04045 (python)

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

while 1:
    for n_i in str(n):
        if int(n_i) in unlike:
            n += 1
            break
    else:
        print(n)
        break

Buggy submission (verdict: Runtime Error):
n, k = map(int,input().split())
n = str(n)
unlike = list(map(int,input().split()))
like = []
ans = ''
for i in range(1, 10):
    if i not in unlike:
        like.append(i)

for num in range(len(n)):
    for i in like:
        if n[0] == 9 and (9 not in like):
            ans += like[0]
            break
        if int(n[num]) <= i:
            ans += str(i)
            break
    if len(ans) != (num + 1):
        for j in like:
            if int(ans[num - 1]) < j:
                ans[num - 1] == j
                break
    if num == 0:
        like.insert(0,0)
print(ans)
Problem p02642 (python)

Fixed submission:
def resolve():
    n=int(input())
    a=list(map(int,input().split()))
    a.sort()
    M=int(1e6+1)
    f=[0]*M
    for x in a:
        if f[x]!=0:
            f[x]+=1
            continue
        for nx in range(x,M,x):
            f[nx]+=1
    ans=0
    for x in a:
        if f[x]==1:ans+=1
    print(ans)
resolve()

Buggy submission (verdict: Runtime Error):
def resolve():
    n=int(input())
    a=list(map(int,input().split()))
    a.sort()
    if a[0]==a[1]:
        print(0)
        exit()
    f=[0]*(int(1e6)+1)
    ans=0
    for i in range(n):
        if f[a[i]]==0:
            ans+=1
            j=a[i]
            while j<=(int(1e6)):
                f[j]+=1
                j+=a[i]
    print(ans)
resolve()
Problem p03463 (python)

Fixed submission:
n,a,b=map(int,input().split())
if (a-b)%2==0:print('Alice')
else:print('Borys')

Buggy submission (verdict: Runtime Error):
n,a,b=map(int,input.split())
if (a-b)%2==0:print('Alice')
else:print('Borys')
Problem p03478 (python)

Fixed submission:
def sum(N):
    sum = 0
    while N > 0:
        sum += N%10
        N = N//10
    return sum

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

ans = 0

for n in range(1, N+1):
    if A <= sum(n) <= B:
        ans += n

print(ans)

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

ans = 0

for n in range(1, N+1):
    if A <= sum(n) <= B:
        ans += n

print(ans)
Problem p03730 (python)

Fixed submission:
import math

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

print('YES' if C % math.gcd(A,B) == 0 else 'NO')

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

print('YES' if C % gcd(A,B) == 0 else 'NO')
Problem p04044 (python)

Fixed submission:
N,L = map(int, input().split())
S = sorted(input() for _ in range(N))

print(''.join(S))

Buggy submission (verdict: Runtime Error):
N,L = map(int, input().split())
S = sorted(input() for _ in range(L))

print(''.join(S))
Problem p02582 (python)

Fixed submission:
s = input()
r = 3 if s == 'RRR' else 1
if 'RR' in s and s != 'RRR':
    r = 2
elif not 'R' in s:
    r = 0
print(r)

Buggy submission (verdict: Runtime Error):
s = input()
r = 3 if s == 'RRR' else r = 1
if 'RR' in s:
  r = 2
print(r)
Problem p02658 (python)

Fixed submission:
n = int(input())
ms = list(map(int, input().split()))
iter_ms = iter(ms) 
r = 1
if 0 in ms:
  r = 0
else:
    for i in range(n):
        x = next(iter_ms)
        r *= x
        if r > 10 ** 18:
            r = -1
            break
        
print(r)

Buggy submission (verdict: Runtime Error):
import itertools
import operator

n = int(input())
ms = list(map(int, input().split()))

if 0 in ms:
  r = 0
else:
  r = itertools.reduce(operator.mul, li)
if r > 10 ** 18:
  r = -1
print(r)
Problem p02628 (python)

Fixed submission:
n, k = map(int, input().split())
P = list(map(int, input().split()))
P = sorted(P)
ans = 0
for i in range(k):
    ans += P[i]
print(ans)

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

Fixed submission:
n = int(input())
A = list(map(int, input().split()))
ans = 1
A = sorted(A)
for i in range(n):
  ans *= A[i]
  if ans > 10**(18):
    print('-1')
    exit()
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
A = list(map(int, input().split()))
ans = 1
p = 0
if 0 in A:
  p -= 1
else:
  for i in range(n):
  	ans *= A[i]
  	if ans >= 10**(18):
    	p += 1
    	break
if p == 0:
  print(ans)
elif p == -1:
  print(0)
else:
  print(-1)
Problem p02548 (python)

Fixed submission:
import math
t = 1
for tc in range(t):
    n = int(input())
    ans = 0
    for i in range(1,n+1):
        j = 1
        ans += (n-1) // i
        # while i*j + 1 <= n:
        #     ans += 1
        #     j += 1
    print(ans)

Buggy submission (verdict: Runtime Error):
import math
t = 1
for tc in range(t):
    N = 1000005
    div = [0] * N
    for i in range(1,N):
        for j in range(i,N,i):
            div[j] += 1
    n = int(input())
    ans = 0
    for i in range(1,n):
        ans += div[n-c]
    print(ans)
Problem p02574 (python)

Fixed submission:
def prime(n):
    primes = [0, 1] * (n // 2 + 1)
    if n % 2 == 0:
        primes.pop()
    primes[1] = 0
    primes[2] = 1
    for p in range(3, n + 1, 2):
        if primes[p]:
            for q in range(p * p, n + 1, 2 * p):
                primes[q] = 0
    return primes
pp=prime(10**3)
p=[]
for i in range(2,1001):
  if pp[i]:
    p.append(i)
n=int(input())
a=list(map(int,input().split()))
def gcd(x,y):
  while y:
    x,y=y,x%y
  return x

g=a[0]
for i in a[1:]:
  g=gcd(g,i)
if g==1:
  mm=[0 for i in range(10**6+1)]
  f=True
  for i in a:
    if mm[i] and i!=1:
      f=False
      break
    mm[i]=1
    si=i**0.5
    for j in range(168):
      if p[j]>si:
        break
      if i%p[j]==0 and i!=p[j]:
        if mm[p[j]]:
          f=False
          break
        mm[p[j]]=1
        t=i//p[j]
        if mm[t] and t!=p[j]:
          f=False
          break
        mm[t]=1
    if not f:
      break
  if f:
    print("pairwise coprime")
  else:
    print("setwise coprime")
else:
  print("not coprime")

Buggy submission (verdict: Runtime Error):
import numpy as np
 
def prime(n):
    primes = np.zeros(n + 1, dtype=np.bool)
    primes[2] = 1
    primes[3::2] = 1
    for p in range(3, n + 1, 2):
        if primes[p]:
            primes[p * p::2 * p] = 0
    return primes
pp=prime(10**3)
p=[]
for i in range(2,1001):
  if pp[i]:
    p.append(i)
n=int(input())
a=list(map(int,input().split()))
def gcd(x,y):
  while y:
    x,y=y,x%y
  return x

g=a[0]
for i in a[1:]:
  g=gcd(g,i)
if g==1:
  mm=[0 for i in range(10**6+1)]
  f=True
  for i in a:
    if mm[i]:
      ptint(i)
      f=False
      break
    mm[i]=1
    for j in range(168):
      if i%p[j]==0:
        if mm[p[j]] and i!=p[j]:
          f=False
          break
        mm[p[j]]=1
        if mm[i//p[j]] and i//p[j]!=p[j] and i!=p[j]:
          f=False
          break
        mm[i//p[j]]=1
    if not f:
      break
  if f:
    print("pairwise coprime")
  else:
    print("setwise coprime")
else:
  print("not coprime")

Buggy submission (verdict: Runtime Error):
import numpy as np
 
def prime(n):
    primes = np.zeros(n + 1, dtype=np.bool)
    primes[2] = 1
    primes[3::2] = 1
    for p in range(3, n + 1, 2):
        if primes[p]:
            primes[p * p::2 * p] = 0
    return primes
pp=prime(10**3)
p=[]
for i in range(2,1001):
  if pp[i]:
    p.append(i)
n=int(input())
a=list(map(int,input().split()))
def gcd(x,y):
  while y:
    x,y=y,x%y
  return x

g=a[0]
for i in a[1:]:
  g=gcd(g,i)
if g==1:
  m=[0 for i in range(1001)]
  mm=[0 for i in range(10**6+1)]
  f=True
  for i in a:
    if mm[i]:
      f=False
      break
    mm[i]=1
    for j in range(168):
      if i%p[j]:
        if m[j]:
          f=False
          break
        m[j]=1
    if not f:
      break
  if f:
    print("pairwise coprime")
  else:
    print("setwise coprime")
else:
  print("not coprime")
Problem p02716 (python)

Fixed submission:
n=int(input())
if n%2:
  a=list(map(int,input().split()))
  s=[[a[0],0,0],[0,a[1],0],[a[0]+a[2],0,a[2]]]+[[0,0,0]for i in range(3,n)]
  for i in range(3,n):
    if i%2:
      s[i][1]=max(s[i-2][1],s[i-3][0])+a[i]
    else:
      s[i][0]=s[i-2][0]+a[i]
      s[i][2]=max([s[i-2][2],s[i-3][1],s[i-4][0]])+a[i]
  print(max([s[-1][2],s[-2][1],s[-3][0]]))
else:
  a=list(map(int,input().split()))
  s=[a[0],a[1]]+[0 for i in range(2,n)]
  for i in range(2,n):
    if i%2:
      s[i]=max([s[i-2],s[i-3]])+a[i]
    else:
      s[i]=s[i-2]+a[i]
  print(max(s[-2:]))

Buggy submission (verdict: Runtime Error):
n=int(input())
if n%2:
  a=list(map(int,input().split()))
  s=[[a[0],0,0],[0,a[1],0],[a[0]+a[2],0,a[2]],[0,max([a[0]+a[3],a[1]+a[3]]),0]]+[[0,0,0]for i in range(4,n)]
  for i in range(4,n):
    if i%2:
      s[i][1]=max(s[i-2][1],s[i-3][0])+a[i]
    else:
      s[i][0]=s[i-2][0]+a[i]
      s[i][2]=max([s[i-2][2],s[i-3][1],s[i-4][0]])+a[i]
  print(max([s[-1][2],s[-2][1],s[-3][0]]))
else:
  a=list(map(int,input().split()))
  s=[a[0],a[1]]+[0 for i in range(2,n)]
  for i in range(2,n):
    if i%2:
      s[i]=max([s[i-2],s[i-3]])+a[i]
    else:
      s[i]=s[i-2]+a[i]
  print(max(s[-2:]))
Problem p02733 (python)

Fixed submission:
h,w,kk=list(map(int,input().split()))
s=[list(map(int,list(input()))) for i in range(h)]
l=[]
for i in range(2**(h-1)):
  ll=[0]
  for j in range(h-1):
    if i & 2**j:
      ll.append(ll[-1]+1)
    else:
      ll.append(ll[-1])
  l.append(ll)

mc=w+h
for i in l:
  c=[0 for i in range(h)]
  cc=0
  f=1
  #print(i,0)
  for j in range(w):
    #print(c)
    ff=0
    for k in range(h):
      c[i[k]]+=s[k][j]
    for k in range(h):
      if c[k]>kk:
        ff=1
        break
    if ff:
      cc+=1
      c=[0 for i in range(h)]
      for k in range(h):
        c[i[k]]+=s[k][j]
      for k in range(h):
        if c[k]>kk:
          f=1
      if f:
        cc=w+h
        #print(c)
        break
    f=0
  #print(cc)
  if mc>cc+len(set(i))-1:
    mc=cc+len(set(i))-1
print(mc)

Buggy submission (verdict: Runtime Error):
h,w,kk=list(map(int,input().split()))
s=[list(map(int,list(input()))) for i in range(h)]
l=[]
for i in range(2**(h-1)):
  ll=[0]
  for j in range(h-1):
    if i & 2**j:
      ll.append(ll[-1]+1)
    else:
      ll.append(ll[-1])
  l.append(ll)

mc=w+h
for i in l:
  c=[0 for i in range(h)]
  cc=0
  f=1
  #print(i,0)
  for j in range(w):
    #print(c)
    ff=0
    for k in range(h):
      c[i[k]]+=s[k][j]
    for k in range(h):
      if c[k]>kk:
        ff=1
        break
    if ff:
      if f:
        cc=w+h
        print(c)
        break
      cc+=1
      c=[0 for i in range(h)]
      for k in range(h):
        c[i[k]]+=s[k][j]
    f=0
  #print(cc)
  if mc>cc+len(set(i)-1):
    mc=cc
print(mc)
Problem p02788 (python)

Fixed submission:
n,d,a=list(map(int,input().split()))
e=[]
for i in range(n):
  inp=list(map(int,input().split()))
  inp[1]=(inp[1]-1)//a+1
  e.append(inp)
e.sort()
sd=[0 for i in range(n)]
s=0
mx=0
i=0
j=0
while True:
  while e[i][1]+s<=mx:
    i+=1
    if i>=n:
      break
    s+=sd[i]
  while i<n and j<n and e[j][0]<=e[i][0]+2*d:
    j+=1
  if j<n:
      sd[j]+=e[i][1]+s-mx
      mx=e[i][1]+s
  else:
    if i>=n:
      break
    mx=e[i][1]+s
    
print(mx)

Buggy submission (verdict: Runtime Error):
n,d,a=list(map(int,input().split()))
e=[]
for i in range(n):
  inp=list(map(int,input().split()))
  inp[1]=(inp[1]-1)//a+1
  e.append(inp)
e.sort()
sd=[0 for i in range(n)]
s=0
mx=0
i=0
j=0
while True:
  while e[i][1]+s<=mx:
    i+=1
    if i>=n:
      break
    s+=sd[i]
  while i<n and j<n and e[j][0]<=e[i][0]+2*d:
    j+=1
  if j<n:
      sd[j]=e[i][1]+s-mx
      mx=e[i][1]+s
  else:
    if i>=n:
      break
    mx=e[i][1]+s
    
print(mx)

Buggy submission (verdict: Runtime Error):
n,d,a=list(map(int,input().split()))
e=[]
for i in range(n):
  inp=list(map(int,input().split()))
  inp[1]=(inp[1]-1)//a+1
  e.append(inp)
e.sort()
sd=[0 for i in range(n)]
s=0
mx=0
i=0
j=0
while True:
  while e[i][1]+s<=mx:
    i+=1
    if i>=n:
      break
    s+=sd[i]
  while i<n and j<n and e[j][0]<=e[i][0]+2*d:
    j+=1
  if j<n:
    sd[j]=e[i][1]+s-mx
    mx=e[i][1]+s
  else:
    if i>=n:
      break
    mx=e[i][1]+s
    
print(mx)

Buggy submission (verdict: Runtime Error):
n,d,a=list(map(int,input().split()))
e=[]
for i in range(n):
  inp=list(map(int,input().split()))
  inp[1]=inp[1]//a
  e.append(inp)
e.sort()
sd=[0 for i in range(n)]
s=0
mx=0
i=0
j=0
while True:
  while e[i][1]+s<=mx:
    i+=1
    if i>=n:
      break
    s+=sd[i]
  while i<n and j<n and e[j][0]<=e[i][0]+2*d:
    j+=1
  if j<n:
    sd[j]=e[i][1]+s-mx
    mx=e[i][1]+s
  else:
    if i>=n:
      break
    mx=e[i][1]+s
    
print(mx)
Problem p03337 (python)

Fixed submission:
a,b=list(map(int,input().split()))
print(max([a+b,a-b,a*b]))

Buggy submission (verdict: Runtime Error):
a,b=list(map(int,input().split()))
print(max([a+b,a-b,a*b])

Buggy submission (verdict: Runtime Error):
a,b=list(map(int,input().split()))
print(max(a+b,a-b,a*b)