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

Fixed submission:
from decimal import *
N,A,B = map(int, input().split())

N -= 1
A -= 1
B -= 1

ans = 0
distAB = B - A

if distAB % 2 == 0:
    ans = Decimal(distAB) / Decimal(2)
else:
    if (N-B) < A:
        ans = (N-B+1) + (Decimal(distAB-1)/Decimal(2))
    else:
        ans = A+1 + (Decimal(distAB-1)/Decimal(2))

print(int(ans))

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

ans = 0
distAB = B - A

if distAB % 2 != 0:
    ans = distAB / 0

print(int(ans))

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

ans = 0
distAB = B - A

if distAB % 2 == 0:
    ans = distAB / 0

print(int(ans))

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

ans = 0
distAB = B - A

if distAB % 2 == 0:
    ans = distAB / 0
else:
    if (N-B) < A:
        ans = (N-B+1) + ((distAB-1)/2)
    else:
        ans = A+1 + ((distAB-1)/2)

print(int(ans))

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

ans = 0
distAB = B - A

if distAB % 2 == 0:
    ans = distAB / 2
else:
    ans = distAB / 0
print(int(ans))

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

ans = 0
distAB = B - A

if distAB % 2 == 0:
    ans = distAB / 0
else:
    if (N-B) < A:
        ans = (N-B+1) + ((distAB-1)/2)
    else:
        ans = A+1 + ((distAB-1)/2)

print(int(ans))

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

ans = 0
distAB = B - A

if distAB % 2 == 0:
    ans = distAB / 0
else:
    if (N-B) < A:
        ans = (N-B+1) + ((distAB-1)/2)-1
    else:
        ans = A+1 + ((distAB-1)/2)-1

print(int(ans))
Problem p02861 (python)

Fixed submission:
import math

N = int(input())
x = [0] * N
y = [0] * N
l = 0

for i in range(N):
  x[i], y[i] = map(int, input().split())

for i in range(N):
  for j in range(i+1, N):
    l += math.sqrt((x[i] - x[j])**2 + (y[i] - y[j])**2)

n = math.factorial(N)
m = 2 * math.factorial(N-1)
print(l * m / n)

Buggy submission (verdict: Runtime Error):
N = int(input())
p = list()
l = 0

for n in range(0, N):
  p.append(list(map(int, input().split())))

for i in range(0, len(p)):
  for j in range(i+1, len(p)):
    l += math.sqrt((p[i][0] - p[j][0])**2 + (p[i][1] - p[j][1])**2)

n = math.factorial(N)
m = 2 * math.factorial(N-1)
print(l * m / n)
Problem p02885 (python)

Fixed submission:
a,b = map(int,input().split())
c = a-b*2
if c <= 0:
  print(0)
else :
  print(c)

Buggy submission (verdict: Runtime Error):
a,b = int(input().split())
c = a-b*2
if c <= 0:
  print(0)
else :
  print(c)

Buggy submission (verdict: Runtime Error):
a,b = int(input().split())
c = a-b*2
if c <= 0:
  print(0)
else :
  print c
Problem p03351 (python)

Fixed submission:
import sys

def aa097():
    a,b,c,d = list(map(int, input().split()))
    if abs(a-c) <= d:
        print('Yes')
        sys.exit()

    if abs(a-b) <= d and abs(b-c) <= d:
        print('Yes')
        sys.exit()

    print('No')

aa097()

Buggy submission (verdict: Runtime Error):
def aa097():
    a,b,c,d = list(map(int, input().split()))
    if abs(a-c) <= d:
        print('Yes')
        sys.exit()

    if abs(a-b) <= d and abs(b-c) <= d:
        print('Yes')
        sys.exit()

    print('No')

aa097()
Problem p03401 (python)

Fixed submission:
def cc092():
    n = int(input())
    an = [0] + list(map(int, input().split())) + [0]

    c = 0
    p = 0
    for i in an:
        c += abs(p-i)
        p = i

    for i in range(1, n+1):
        cc = abs(an[i-1]-an[i+1]) - (abs(an[i-1]-an[i]) + abs(an[i]-an[i+1]))
        print(c+cc)

cc092()

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

    for i in range(0, n):
        bn = except_arr(an, i)
        bn.extend([0])
        pos = 0
        cost = 0
        for j in bn:
            cost += abs(pos-j)
            pos = j
        print(cost)

cc092()
Problem p03447 (python)

Fixed submission:
import math

def aa087():
    x = int(input())
    a = int(input())
    b = int(input())

    c = x - a
    d = math.floor(c/b)
    c -= b*d
    print(c)

aa087()

Buggy submission (verdict: Runtime Error):
def aa087():
    x = int(input())
    a = int(input())
    b = int(input())

    c = x - a
    d = math.floor(c/b)
    c -= b*d
    print(c)

aa087()
Problem p03456 (python)

Fixed submission:
import math

def bb086():
    a,b = list(input().split())
    c = int(math.sqrt(int(a+b)))
    d = str(c*c)
    print('Yes' if (a+b) == d else 'No')

bb086()

Buggy submission (verdict: Runtime Error):
def bb086():
    a,b = list(input().split())
    c = int(math.sqrt(int(a+b)))
    d = str(c*c)
    print('Yes' if (a+b) == d else 'No')

bb086()
Problem p02971 (python)

Fixed submission:
n = int(input())

a = [int(input()) for i in range(n)]

a_max = max(a)
a_max_count = a.count(a_max)

if a_max_count > 1:
  for i in range(n):
    print(a_max)
    
else:
  print(max(a[1:]))
  
  for i in range(1, n-1):
    if a[i] == a_max:
      print(max(max(a[:i]), max(a[i+1:])))
      
    else:
      print(a_max)

  print(max(a[:-1]))

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

a = [int(input()) for i in range(n)]

a_max = max(a)
a_max_count = a.count(a_max)

if a_max_count > 1:
  for i in range(n):
    print(a_max)
    
else:
  for i in range(n):
    if a[i] == a_max:
      print(max(max(a[:i]), max(a[i+1:])))
      
    else:
      print(a_max)
Problem p03145 (python)

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

print(int(a * b / 2))

Buggy submission (verdict: Runtime Error):
a, b, c = map(int, input())

print(a * b / 2)
Problem p03211 (python)

Fixed submission:

inn = str(input())

result = 999

for i in range(len(inn)-2):
  if i == len(inn) - 3:
    num = inn[i:]

  else:
    num = inn[i:i+3]

  sa = abs(753 - int(num))

  if sa < result:
    result = sa

print(result)

Buggy submission (verdict: Runtime Error):

inn = str(input())

result = 999

for i in range(len(inn)-2):
  if i == len(inn) - 3:
    num = inn[i:]

  else:
    num = inn[i:i+3]

  sa = abs(753 - innt(num))

  if sa < result:
    result = sa

prinnt(result)

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

result = 999

for i in range(len(in)-2):
  if i == len(in) - 3:
    num = in[i:]
  else:
    num = in[i:i+3]

  sa = abs(753 - int(num))

  if sa < result:
    result = sa

print(result)

Buggy submission (verdict: Runtime Error):

in = input()

result = 999

for i in range(len(in)-2):
  if i == len(in) - 3:
    num = in[I:]
  else:
    num = in[i:i+3]

  sa = abs(753 - int(num))

  if sa < result:
    result = sa

print(result)
Problem p03069 (python)

Fixed submission:
# coding: utf-8

N = int(input())
S = input().rstrip('#')

lb = 0
rw = S.count('.')
ans = lb + rw

for i in range(len(S)):
  if S[i] == '.':
    rw -= 1
  else:
    lb += 1
  ans = min(ans, rw + lb)

print(ans)

Buggy submission (verdict: Runtime Error):
# coding: utf-8

N = int(input())
S = input().rstrip('#')

lb = 0
rw = S.count('.')
ans = lb + rw

for i in range(N):
  if S[i] == '.':
    rw -= 1
  else:
    lb += 1
  ans = min(ans, rw + lb)

print(ans)
Problem p03078 (python)

Fixed submission:
# coding: utf-8

x, y, z, k = [int(i) for i in input().split()]

a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
c = [int(i) for i in input().split()]

ab = [ai + bi for ai in a for bi in b]
ab.sort(reverse=True)
ab = ab[:k]

abc = [abi + ci for abi in ab for ci in c]
abc.sort(reverse = True)

for i in range(len(abc)):
  if i < k:
    print(abc[i])
  else:
    break

Buggy submission (verdict: Runtime Error):
# coding: utf-8
import math 

N = int(input())
abcde = [int(input()) for _ in range(5)]

time = 0
n = N
last = 0 # 最後の1回で移動する人数
for i in range(5):
  time +=  math.ceil(n / abcde[i])
  last = n % abcde[i]
  if last == 0:
    last = abcde[i]
  if i < 4: 
    n = last + max((N-last) - (time-1) * abcde[i+1], 0)


print(time)
Problem p03079 (python)

Fixed submission:
# coding: utf-8

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

if A == B and B == C:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
# coding: utf-8

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

if A == B && B == C:
  print('Yes')
else:
  print('No')
Problem p03103 (python)

Fixed submission:
# coding: utf-8
import sys
input = sys.stdin.readline

N, M = [int(i) for i in input().split()]

plices = [[int(i) for i in input().split()] for _ in range(N)]

plices.sort(key = lambda x:x[0])

m = 0
cost = 0

for i in range(N):
    if m >= M:
        break
    buy = min(M - m, plices[i][1])
    cost += plices[i][0] * buy
    m += buy

print(cost)

Buggy submission (verdict: Runtime Error):
# coding: utf-8
from sys import stdin.readline as input
 
N, M = [int(i) for i in input().split()]
 
plices = [[int(i) for i in input().split()] for _ in range(N)]
 
plices.sort(key = lambda x:x[0])
 
m = 0
cost = 0
 
for i in range(N):
    if m >= M:
        break
    buy = min(M - m, plices[i][1])
    cost += plices[i][0] * buy
    m += buy
 
print(cost)
Problem p03838 (python)

Fixed submission:
# coding: utf-8
# Here your code !

x, y = [int(i) for i in input().split()]

alist = []

if (y > x) and (y - x) >= 0:
    alist.append(y - x)

if y < x:
    alist.append(abs(abs(x)-abs(y))+2)
    
if (abs(x) < abs(y) and x >= 0 and y <= 0):
    alist.append(abs(y)-abs(x)+1)

if (abs(x) > abs(y) and x <= 0 and y >= 0):
    alist.append(abs(x)-abs(y)+1)

if (abs(x) < abs(y) and x <= 0 and y >= 0):
    alist.append(abs(y) - abs(x) + 1)

if (abs(x) > abs(y) and x >= 0 and y <= 0):
    alist.append(abs(x) - abs(y) + 1)

if (abs(x) == abs(y)):
    alist.append(1)
    
print(min(alist))

Buggy submission (verdict: Runtime Error):
# coding: utf-8

I, O, T, J, L, S, Z = [int(i) for i in input().split()]

K = (I//2)*2 + O + (J//2)*2 + (L//2)*2
if I % 2 == 1 and J % 2 == 1 and L % 2 ==1:
    K += 3
elif (I % 2 + J % 2 + L % 2 == 2) and (I * J * L > 0):
    K += 1
print(K)
Problem p02898 (python)

Fixed submission:
x,y = map(float,input().split())	
li = list(map(float,input().split()))	
count=0
for i in li:
    if(y <= i):
        count+=1
print(count)

Buggy submission (verdict: Runtime Error):
x,y = map(int,input().split())	
c=input()
c.split()
print(y)
count=0
for i in c:
    if(float(y) <= float(i)):
        count+=1
print(count)
Problem p03434 (python)

Fixed submission:
a=int(input())

b=list(map(int, input().split()))
b.sort(reverse=True)
alice=0
bob=0
c=iter(b)
for i in c:
    alice+=i
    try:
    	bob+=next(c)
    except:
      break
print(alice-bob)

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

b=list(map(int, input().split()))
b.sort(reverse=True)
alice=0
bob=0
c=iter(b)
for i in c:
    alice+=i
    bob+=next(c)
print(alice-bob)

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

b=list(map(int, input().split()))
b.sort()
alice=0
bob=0

c=iter(b)
for i in c:
    alice=i
    bob=next(c)
print(alice-bob if alice>bob else bob-alice)

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

b=list(map(int, input().split()))
b.sort()
alice=0
bob=0

c=iter(b)
for i in c:
    alice=i
    bob=next(c)
print(alice-bob if alice>bob else bob-alice)
Problem p02842 (python)

Fixed submission:
import math

N = int(input())

if math.floor(math.floor((N) / 1.08) * 1.08) == N:
    print(math.floor((N) / 1.08))
elif math.floor(math.floor((N+1) / 1.08) * 1.08) == N:
    print(math.floor((N+1) / 1.08))
else:
    print(":(")

Buggy submission (verdict: Runtime Error):
import math

N = int(input())

predict_price1 = math.floor((N)  / 1.08)  # 整数で計算,切り捨て処理
predict_price2 = math.ceil(N+1)  / 1.08)  # 整数で計算,切り上げ処理

if predict_price1 == predict_price2:
    print(predict_price1)
else:
    print(":(")
Problem p02848 (python)

Fixed submission:

N = int(input())
S = list(input())

# ordで文字からunicode数字を返す
# chrでunicode数字から文字を返す

def chr_change(chr, N):
    """ print("chr is", chr)
    print("N is", N)
    print("ord(chr) is ", ord(chr))
     """
    Num_AtoZ = ord("Z") - ord("A")
    if ord(chr) + N > ord("Z"):
        chg_chr = ord(chr) + N - Num_AtoZ -1
    else:
        chg_chr = ord(chr) + N
    #print("chg_chr is", chg_chr)
    return chg_chr


for i in range(len(S)):
    tmp_chr = S[i]
    print(chr(chr_change(tmp_chr, N)), end = "")
print("\n")

Buggy submission (verdict: Runtime Error):

N = int(input())
S = list(input())

# ordで文字からunicode数字を返す
# chrでunicode数字から文字を返す

def chr_change(chr, N):
    """ print("chr is", chr)
    print("N is", N)
    print("ord(chr) is ", ord(chr))
     """
    Num_AtoZ = ord("Z") - ord("A")
    if ord(chr) + N > ord("Z"):
        chg_chr = ord(chr) + N - Num_AtoZ -1
    else:
        chg_chr = ord(chr) + N
    #print("chg_chr is", chg_chr)
    return chg_chr


for i in range(N):
    tmp_chr = S[i]
    print(chr(chr_change(tmp_chr, N)), end = "")
print("\n")
Problem p02900 (python)

Fixed submission:
import math

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

list_a = []
list_b = []
sqrt_a = math.sqrt(a)
sqrt_b = math.sqrt(b)


for i in range(2, int(sqrt_a) ):  
  if (a % (i) == 0):
    list_a.append( i )
    while( a % (i) == 0 ):
      a = a//(i)
if a > 1:
  list_a.append(a)
      
for i in range(2, int(sqrt_b) ):  
  if (b % (i) == 0):
    list_b.append( i )
    while( b % (i ) == 0 ):
      b = b//(i)
if b > 1:
  list_b.append(b)

#print(list_a)
#print(list_b)

set_a = set(list_a)
set_b = set(list_b)

set_ab = set_a & set_b
  
print(len(set_ab) + 1)

Buggy submission (verdict: Runtime Error):
import math

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

list_a = []
list_b = []
sqrt_a = math.sqrt(a)
sqrt_b = math.sqrt(b)


for i in range(2, float(sqrt_a) ):  
  if (a % (i) == 0):
    list_a.append( i )
    while( a % (i) == 0 ):
      a = a//(i)
      
for i in range(2, float(sqrt_b) ):  
  if (b % (i) == 0):
    list_b.append( i )
    while( b % (i ) == 0 ):
      b = b//(i)

#print(list_a)
#print(list_b)

set_a = set(list_a)
set_b = set(list_b)

set_ab = set_a & set_b
  
print(len(set_ab) + 1)
Problem p02999 (python)

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

print(0 if x < a else 10)

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

print(10 if x < a else 0)
Problem p03061 (python)

Fixed submission:
from fractions import gcd

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

L = [0]
R = [0]

for i in range(N):
    L.append(gcd(L[i], A[i]))  # 0, gcd(0,A[0]), gcd(0,A[0],A[1]) , ...
    R.append(gcd(R[i], A[N - i -1])) # 0 , gcd(0, A[N-1]), gcd(0, A[N-1], A[N-2]))..

R.reverse() # R is gcd(0,A[N-1]...A[0]), gcd(0,A[N-1]...A[1]),....
# pairs are 
#  L     :R
#  0    : (0,A[N-1],A[n-2], ... A[1])
#  A[0] : (0,A[N-1],A[n-2], ... A[2])
#  ...
#  A[0,1,..N-3] :(0,A[N-1]
#  A[0,1,..N-2] :(0)
print(max( (gcd(L[i], R[i+1]) for i in range(N))))

Buggy submission (verdict: Runtime Error):
from math import gcd

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

L = [0]
R = [0]

for i in range(N):
    L.append(gcd(L[i], A[i]))  # 0, gcd(0,A[0]), gcd(0,A[0],A[1]) , ...
    R.append(gcd(R[i], A[N - i -1])) # 0 , gcd(0, A[N-1]), gcd(0, A[N-1], A[N-2]))..

R.reverse() # R is gcd(0,...A[0]), gcd(0,...A[1]),....
# pairs are 
#  L     :R
#  0    : (0,A[N-1],A[n-2], ... A[1])
#  A[0] : (0,A[N-1],A[n-2], ... A[2])
#  ...
#  A[0,1,..N-3] :(0,A[N-1]
#  A[0,1,..N-2] :(0)
print(max( (gcd(L[i], R[i+1]) for i in range(N))))

Buggy submission (verdict: Runtime Error):
from math import gcd
from functools import reduce
N = int(input())
a = list(map(int, input().split()))

list_ans = []

for i in range(N):
    remove_a = a.pop(0)
    #print("a is",a)
    ans = reduce(gcd, a)
    list_ans.append(ans)
    a.append(remove_a)
    #print("fix a is",a)

print(max(list_ans))
Problem p03106 (python)

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

min_val  = min(a,b)
t = 0
for i in range(min_val,0,-1):
  if a%(i) == 0 and b%(i) == 0:
    t += 1
  if t == k:
    print(i)
    break

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

min_val  = min(a,b)
list = []
for i in range(min_val,0,-1):
  if a%(i+1) == 0 and b%(i+1) == 0:
    list.append(i+1)
    
print(list[k-1])
Problem p03161 (python)

Fixed submission:
n, k = list(map(int, input().split()))
h = list(map(int, input().split()))
inf = 10 ** 4 + 1
dp = [inf] * n
dp[0] = 0
for i in range(1,n):
    H = h[i]
    dp[i] = min([dp[j] + abs(h[j] - H) for j in range(max(0, i - k), i)])
print(dp[-1])

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

inf = 10 ** 4 + 1
dp = [inf] * n
dp[0] = 0

for i in range(1,N):
    H = h[i]
    dp[i] = min( dp[j] + abs(h[j] - H) for j in range(max(0, i-K),i))


print(dp[N-1])
Problem p03200 (python)

Fixed submission:
S = list(input())

#print(S)

n = 1 if S[0] == "W" else 0# number of white string
count = 0
for i in range(1, len(S)):
    if S[i] == "W":
        count += i - n
        n += 1
        #print("n is", n)
        #print("count is ", count)
print(count)

Buggy submission (verdict: Runtime Error):
if __name__ == "__main__":
    S = input()
    ans = 0
    bcount = 0
    for i in range(len(S)):
        if S[i] == 'B':
            bcount += 1
        else:
            ans += bcount
​
    print(ans)
Problem p03239 (python)

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

keep_cost = 1001
taken_t = 1001
for i in range(n):
    c,t = map(int, input().split())
    if T >= t:
        if c <= keep_cost:
            keep_cost = c
            taken_t = t

print(keep_cost if taken_t <= T else "TLE")

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

keep_cost = 1001

for i in range(n):
    c,t = map(int, input().split())
    if T >= t:
        if c <= keep_cost:
            keep_cost = c


print(keep_cost if keep_cos != 1001 else "TLE")
Problem p03262 (python)

Fixed submission:
from fractions import gcd
from functools import reduce

n, X = map(int, input().split())
x = list(map(int, input().split()))

x.append(X)
x = sorted(x)
diff_x = []
for i in range(len(x)-1):
    diff_x.append(x[i+ 1] - x[i])


ans = reduce(gcd, diff_x)

print(ans)

Buggy submission (verdict: Runtime Error):
from math import gcd
from functools import reduce

n, X = map(int, input().split())
x = list(map(int, input().split()))

x.append(X)
x = sorted(x)
diff_x = []
for i in range(len(x)-1):
    diff_x.append(x[i+ 1] - x[i])


ans = reduce(gcd, diff_x)

print(ans)
Problem p03281 (python)

Fixed submission:
n = int(input())

div_count = 0
sum = 0

for i in range(3,n+1,2):
    a = i
    j = 2
    div_count = 0
    while(j <= a):
        #print("a is",a)
        #print("j is",j)
        if a % j == 0:
            div_count += 1
            a //= j
            j += 1
        else:
            j += 1
    if div_count == 3:
        sum += 1

print(sum)

Buggy submission (verdict: Runtime Error):
from fractions import gcd
from functools import reduce
N = int(input())
a = list(map(int, input().split()))

list_ans = []

for i in range(N):
    remove_a = a.pop(0)
    #print("a is",a)
    ans = reduce(gcd, a)
    list_ans.append(ans)
    a.append(remove_a)
    #print("fix a is",a)

print(max(list_ans))
Problem p02865 (python)

Fixed submission:
N = int(input())

print((N-1)//2)

Buggy submission (verdict: Runtime Error):
CONST_DIVSOR = 998244353
N = int(input())
Ds = list(map(int, input().strip().split()))
counter = [0]*N
for D in Ds:
    counter[D] += 1
total = 0
cnt = 0
prenumi = 0
for i in range(N):
    if i == 0:
        if counter[i] == 1:
            total = 1
            prenumi = 1
            cnt = 1
        else:
            break
    else:
        numi = counter[i]
        if numi != 0:
            case = 1
            for j in range(numi):
                case = (case * prenumi) % CONST_DIVSOR
            total = (total * case) % CONST_DIVSOR
            prenumi = numi
            cnt += numi
        else:
            total = 0
            break
    # print(i,total,prenumi,cnt)
    if cnt >= N:
        break

print(total % CONST_DIVSOR)

Buggy submission (verdict: Runtime Error):
CONST_DIVSOR = 998244353
N = int(input())
Ds = list(map(int, input().strip().split()))
counter = [0]*N
for D in Ds:
    counter[D] += 1
total = 0
cnt = 0
prenumi = 0
for i in range(N):
    if i == 0:
        if counter[i] == 1:
            total = 1
            prenumi = 1
            cnt = 1
        else:
            break
    else:
        numi = counter[i]
        if numi != 0:
            case = 1
            for j in range(numi):
                case = (case * prenumi) % CONST_DIVSOR
            total = (total * case) % CONST_DIVSOR
            prenumi = numi
            cnt += numi
        else:
            total = 0
            break
    # print(i,total,prenumi,cnt)
    if cnt >= N:
        break

print(total % CONST_DIVSOR)
Problem p02818 (python)

Fixed submission:
def solve(a,b,k):
    if a==0 and b==0:
        return '0 0'
    if a>=k:
        str = '%d %d' % (a-k,b)
        return str
    else:
        b = b + a - k
        a = 0
        if b<0:
            return '0 0'
        str = '0 %d' % (b)
        return str 
        

a,b,k = map(int, input().split())
print(solve(a,b,k))

Buggy submission (verdict: Runtime Error):
a,b,k = map(int, input().split())
if a==0 and b==0:
    print(0)
else:
    a = a - k
    a2 = a
    if a<0:
        a=0
    b= b + a2
    if b<0:
        b=0
	print(a,b)

Buggy submission (verdict: Runtime Error):
a,b,k = map(int, input().split())
if a==0 and b==0:
    print(0)
else:
    a = a - k
    a2 = a
    if a<0:
        a=0
    b= b + a2
    if b<0:
        b=0
	print(a,b)

Buggy submission (verdict: Runtime Error):
a,b,k = map(int, input().split())
if a==0 and b==0:
    print(0)
else:
    a = a - k
    a2 = a
    if a<0:
        a=0
    b= b + a2
    if b<0:
        b=0
print(a,b)


1 3 1000
0 1
Problem p02841 (python)

Fixed submission:
Ma, Da = map(int, input().split())
Mb, Db = map(int, input().split())
if (Ma == 12 and Mb == 1) or Mb > Ma:
    print("1")
else:
    print("0")

Buggy submission (verdict: Runtime Error):
T1, T2 = map(int, input().split())
A1, A2 = map(int, input().split())
B1, B2 = map(int, input().split())

D1 = T1 * A1 - T1 * B1
D2 = T1 * A1 + T2 * A2 - T1 * B1 - T2 * B2

if D1 * D2 > 0:
    print(0)
elif D2 == 0:
    print("infinity")
else:
    c = 1
    D1 = abs(D2 - D1)
    D2 = abs(D2)
    Dp = D2
    while True:
        Dp += D2
        if Dp > D1:
            break
        elif Dp == D1:
            c += 1
            break
        c += 2
    print(c)
Problem p02909 (python)

Fixed submission:
S = input()
if S == "Sunny":
    print("Cloudy")
elif S == "Cloudy":
    print("Rainy")
elif S == "Rainy":
    print("Sunny")

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


class Node:
    def __init__(self, num_):
        self.num = num_
        self.children = {}  # dict

    def addChild(self, ch_, num_):
        self.children[ch_] = Node(num_)


ma_max = 0
Tr = {}
for i in range(0, N):
    tr = Tr
    ma = 0
    for j in range(i, N):
        if S[j] not in tr:
            tr[S[j]] = Node(j)
            tr = tr[S[j]].children
        else:
            if tr[S[j]].num >= i:
                ma = 0
            else:
                ma += 1
            tr = tr[S[j]].children
    ma_max = max(ma_max, ma)
    if N - i < ma_max:
        break

print(ma_max)