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

Fixed submission:
# coding: utf-8

def greatest_common_divisor(N, M):
    assert N >= M
    while M != 0:
        N, M = M, N%M
    return N

def prime_divisor(N):
    temp = N
    for n in range(2, int(-(-N**0.5//1))+1):
        if temp % n == 0:
            while temp % n == 0:
                temp //= n
            yield n
    if temp != 1:
        yield temp
        

def main():
    a, b = input().split()
    a, b = int(a), int(b)

    if a > b:
        a, b = b, a

    gcd = greatest_common_divisor(b, a)
    pdiv = [pd for pd in prime_divisor(gcd)]
    print(len(pdiv)+1)

main()

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

def greatest_common_divisor(a, b):
    assert a > b
    while b != 0:
        a, b = b, a%b
    return a

def main():
    a, b = input().split()
    a, b = int(a), int(b)

    if b > a:
        a, b = b, a

    relative_primes = []
    gcd = greatest_common_divisor(a, b)
    for i in range(2, gcd+1):
        if gcd % i > 0:
            continue
            
        flg = True
        for rp in relative_primes:
            if i % rp == 0:
                flg = False
                continue
        if flg:
            relative_primes.append(i)
    print(len(relative_primes)+1)
    

main()

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

def main():
    a, b = input().split()
    a, b = int(a), int(b)

    if b > a:
        a, b = b, a

    relative_primes = []
    greatest_cd = gcd(a, b)
    for i in range(2, greatest_cd+1):
        if greatest_cd % i > 0:
            continue
            
        flg = True
        for rp in relative_primes:
            if i % rp == 0:
                flg = False
                continue
        if flg:
            relative_primes.append(i)
    print(len(relative_primes)+1)
    

main()

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

def main():
    a, b = input().split()
    a, b = int(a), int(b)

    if b > a:
        a, b = b, a

    gcd = math.gcd(a, b)
    relative_primes = []
    for i in range(2, gcd+1):
        if gcd % i > 0:
            continue
            
        flg = True
        for rp in relative_primes:
            if i % rp == 0:
                flg = False
                continue
        if flg:
            relative_primes.append(i)
    print(len(relative_primes)+1)
    

main()
Problem p02910 (python)

Fixed submission:
# coding: utf-8
def is_easy(steps):
    for i, step in enumerate(steps):
        if i % 2 == 0 and step == 'L':
            return 'No'
        elif i % 2 == 1 and step == 'R':
            return 'No'
    return 'Yes'
  
steps = input()
print(is_easy(steps))

Buggy submission (verdict: Runtime Error):
# coding: utf-8
def is_easy(steps):
  for i, step in enumerate(steps):
    if i % 2 == 0 and step == 'L':
      return 'No'
  	elif i % 2 == 1 and step == 'R':
      return 'No'
	return 'Yes'
  
steps = input()
print(is_easy(steps))

Buggy submission (verdict: Runtime Error):
# coding: utf-8
import numpy as np
step_strings = {'L': 0, 'U': 1, 'D': 2, 'R': 3}
steps = input()
steps = np.array([step_strings[s] for s in steps])
steps_index = (np.arange(steps.size) + 1) % 2
if steps[steps_index == 0].max() < 3 and steps[steps_index == 1].min() > 0:
	print('Yes')
else:
  	print('No')
Problem p02947 (python)

Fixed submission:
N = int(input())
S_lists = [input() for i in range(N)]

S_dict = {}

for S in S_lists:
    S_list = list(S)
    S_list.sort()

    S_str = "".join(S_list)
    if S_str in S_dict.keys():
        S_dict[S_str] = S_dict[S_str] + 1
    else:
        S_dict[S_str] = 1

answer = 0
for v in S_dict.values():
    if v > 1:
        answer += int(v * (v - 1) / 2)

print(answer)

Buggy submission (verdict: Runtime Error):
import math

N = int(input())
S_lists = [input() for i in range(N)]

S_dict = {}

for S in S_lists:
    S_list = list(S)
    S_list.sort()

    S_str = "".join(S_list)
    if S_str in S_dict.keys():
        S_dict[S_str] = S_dict[S_str] + 1
    else:
        S_dict[S_str] = 1

answer = 0
for v in S_dict.values():
    if v > 1:
        answer += int(math.factorial(v) / 2)

print(answer)
Problem p03721 (python)

Fixed submission:
#N,Kの取得
N,K = list(map(int,input().split()))

#[(a_1,b_1),(a_2,b_2),...]の形でリストを作成
numList = []
for a,b in [ map(int,input().split()) for _ in range(N) ]:
	numList.append((a,b))

#作成したリストを、aの大きさで昇順ソート
numList = sorted(numList,key=lambda x:x[0])

#小さい順に要素数bを足していき、Kを超えた段階で出力、終了
count = 0
for a,b in numList:
	count += b
	if count>=K:
		print(a)
		quit()

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

c = []

for i in range(N):
	c.append(input().split())

d = []
e = []

for j in range(N):
	e.append(c[j][0])
	e = e * c[j][1]
	d = d + e
	e = []

d.sort()

print(d[K-1])

Buggy submission (verdict: Runtime Error):
#N,Kの取得
N,K = list(map(int,input().split()))

#[(a_1,b_1),(a_2,b_2),...]の形でリストを作成
numList = [ map(int,input().split()) for _ in range(N) ]

#作成したリストを、aの大きさで昇順ソート
numList = sorted(numList,key=lambda x:x[0])

#小さい順に要素数bを足していき、Kを超えた段階で出力、終了
count = 0
for a,b in numList:
	count += b
	if count>=K:
		print(a)
		quit()
Problem p03741 (python)

Fixed submission:
import numpy as np
import math

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

maenogoukei = a[0]
goukei = a[0]
kaisuu = 0

if goukei == 0:
	kaisuu += 1
	maenogoukei = -1 
	goukei = maenogoukei



for a_i in a[1:]:
	goukei += a_i
	if maenogoukei > 0 and goukei >= 0:
		kaisuu += goukei + 1
		goukei = -1
		maenogoukei = -1
	elif maenogoukei < 0 and goukei <= 0:
		kaisuu += -goukei + 1
		goukei = 1
		maenogoukei = 1
	else:
		maenogoukei += a_i




maenogoukei2 = a[0]
goukei2 = a[0]
kaisuu2 = 0

if goukei2 == 0:
	kaisuu2 += 1
	maenogoukei2 = 1 
	goukei2 = 1
else:
	kaisuu2 += abs(goukei2) + 1
	maenogoukei2 = - int(np.sign(a[0]))
	goukei2 = - int(np.sign(a[0]))


for a_i2 in a[1:]:
	goukei2 += a_i2
	if maenogoukei2 > 0 and goukei2 >= 0:
		kaisuu2 += goukei2 + 1
		goukei2 = -1
		maenogoukei2 = -1
	elif maenogoukei2 < 0 and goukei2 <= 0:
		kaisuu2 += -goukei2 + 1
		goukei2 = 1
		maenogoukei2 = 1
	else:
		maenogoukei2 += a_i2

print( min([kaisuu,kaisuu2]) )

Buggy submission (verdict: Runtime Error):
import numpy as np
import math

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

maenogoukei = a[0]
goukei = a[0]
kaisuu = 0

if goukei == 0:
	kaisuu += 1
	maenogoukei = -1 
	goukei = maenogoukei



for a_i in a[1:]:
	goukei += a_i
	if maenogoukei > 0 and goukei >= 0:
		kaisuu += goukei + 1
		goukei = -1
		maenogoukei = -1
	elif maenogoukei < 0 and goukei <= 0:
		kaisuu += -goukei + 1
		goukei = 1
		maenogoukei = 1
	else:
		maenogoukei += a_i




maenogoukei2 = a[0]
goukei2 = a[0]
kaisuu2 = 0

if goukei2 == 0:
	kaisuu2 += 1
	maenogoukei2 = 1 
	goukei2 = 1
else:
	kaisuu2 += math.abs(goukei2) + 1
	maenogoukei2 = - int(np.sign(a[0]))
	goukei2 = - int(np.sign(a[0]))


for a_i2 in a[1:]:
	goukei2 += a_i2
	if maenogoukei2 > 0 and goukei2 >= 0:
		kaisuu2 += goukei2 + 1
		goukei2 = -1
		maenogoukei2 = -1
	elif maenogoukei2 < 0 and goukei2 <= 0:
		kaisuu2 += -goukei2 + 1
		goukei2 = 1
		maenogoukei2 = 1
	else:
		maenogoukei2 += a_i2

print( min([kaisuu,kaisuu2]) )
Problem p02786 (python)

Fixed submission:
import math
n = int(input())
n = int(math.log2(n))+1
print(2**n-1)

Buggy submission (verdict: Runtime Error):
n = int(input())
n = int(log2(n))+1
print(2**n-1)
Problem p02747 (python)

Fixed submission:
S=str(input())
if len(S)%2 != 0:
  print("No")
  exit()
for i in range(int(len(S)/2)):
  if S[i*2]!="h":
    print("No")
    exit()
  if S[i*2+1]!="i":
    print("No")
    exit()
print("Yes")

Buggy submission (verdict: Runtime Error):
S=input()
if len(S)%2 != 0:
  print("No")
  exit()
for i in range(int(len(S)/2)):
  if S[i*2]!="h":
    print("No")
    exit()
  if S[i*2+1]!="i":
    Print("No")
    exit()
print("Yes")
Problem p03109 (python)

Fixed submission:
input=input()
if input < "2019/04/31":
  print("Heisei")
else:
  print("TBD")

Buggy submission (verdict: Runtime Error):
n=int(input())
i=0
JPY=0
while n > i:
  i=i+1
  a,b=map(str,input().split())
  a = float(a)
  if b == "JPY":
    JPY=JPY+a
  else:
    JPY=JPY+a*380000
print(JPY)
Problem p02755 (python)

Fixed submission:
import math

S = input().split(' ')
A = int(S[0])
B = int(S[1])
p = -1
for x in range(2100):
    if math.floor(x*0.08) == A and math.floor(x*0.1) == B:
        p = x
        break
print(p)

Buggy submission (verdict: Runtime Error):
S = Input().split(' ')
A = int(S[0])
B = int(S[1])
A_t = A/0.08
B_t = B/0.1
if A_t == B_t:
    print(A_t)
else:
    print(-1)
Problem p03478 (python)

Fixed submission:
n, a, b = map(int, input().split())
ans = 0
for i in range(n+1):
  if a <= sum(list(map(int, list(str(i))))) <= b:
    ans += i
print(ans)

Buggy submission (verdict: Runtime Error):
N, A, B =map(int(), input().split())
ans = 0
for i in range(1, N+1):
    if A <= sum(list(map(int, list(str(i))))) <= B:
        ans += i
print(ans)
Problem p03494 (python)

Fixed submission:
N = int(input())
A = [int(x) for x in input().split()]


flag = True
count=0
while(flag):
    for i in range(N):
        if A[i]%2 == 1 :
            flag=False
            break
        else:
            A[i] /= 2
    if flag:
        count += 1

print(count)

Buggy submission (verdict: Runtime Error):
A = [int(x) for x in input().split()]
N = int(input())

flag = True
count=0
while(flag):
    for i in range(N):
        if A[i]%2 == 1 :
            flag=False
            break
        else:
            A[i] /= 2
    if flag:
        count += 1

print(count)
Problem p02747 (python)

Fixed submission:
s = input()

num = len(s)
if num % 2 != 0:
    print('No')
else:
    hitachi = 'hi' * int(num / 2)
    if hitachi == s:
        print('Yes')
    else:
        print('No')

Buggy submission (verdict: Runtime Error):
lines = []
line = input()
s = line.split(' ')
entries = int(s[2]) + 2
for i in range(entries+1):
    lines.append(line.split(' '))
    if i < entries:
        line = input()

discounts = []
for idx, line in enumerate(lines):
    if idx == 0:
        A = line[0]
        B = line[1]
        M = line[2]
    elif idx == 1:
        refrigerators = line
    elif idx == 2:
        microwaves = line
    else:
        discounts.append(line)

ref_reg = int(10 ** 5)
for r in refrigerators:
    reg = int(r)
    if ref_reg > reg:
        ref_reg = reg

ref_mic = int(10 ** 5)
for m in microwaves:
    mic = int(m)
    if ref_mic > mic:
        ref_mic = mic

ref_min = ref_reg + ref_mic
for discount in discounts:
     d = int(refrigerators[int(discount[0])-1]) + int(microwaves[int(discount[1])-1]) - int(discount[2])
     if d < ref_min:
         ref_min = d       
         
print(ref_min)

Buggy submission (verdict: Runtime Error):
impotr re
s = input()

pattern = 'hi'
m = re.search(pattern, s)
if m:
  print('Yes')
else:
  print('No')
Problem p02747 (python)

Fixed submission:

string_in = input()
n_str = len(string_in)
string_in = string_in.replace("hi", '%d'%(1))
if n_str == string_in.count('%d'%(1))*2:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):

from copy import deepcopy
string_in = input("input : ")
check_str = "hi"

max_count = string_in.count(check_str)
check_obj = ["hi"*i for i in range(1,max_count+1)][::-1]
string_in4 = deepcopy(string_in)
count = 0
for i in range(len(check_obj)):
  i_str = str(check_obj[i])
  string_in4 = string_in4.replace(i_str, '%d'%(i))
  count += string_in4.count('%d'%(i))

  if count==0:
    print("No")
    else:
      print("Yes")
Problem p02748 (python)

Fixed submission:
A, B, M = map(int, input().split())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
x = [0 for i in range(M)]
y = [0 for i in range(M)]
c = [0 for i in range(M)]
for i in range(M):
  x[i], y[i], c[i] = map(int, input().split())
non_coupon_val = min(a) + min(b)
coupon_val_arr = [0 for i in range(M)]
for i in range(M):
  coupon_val_arr[i] = a[x[i]-1] + b[y[i]-1] - c[i]
coupon_val = min(coupon_val_arr)
print(min([non_coupon_val, coupon_val]))

Buggy submission (verdict: Runtime Error):
A, B, M = map(int, input().split())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
x = [0 for i in range(M)]
y = [0 for i in range(M)]
c = [0 for i in range(M)]
for i in range(M):
  x[i], y[i], c[i] = map(int, input().split())
non_coupon_val = min(a) + min(b)
coupon_val_arr = [0 for i in range(M)]
for i in range(M):
  coupon_val_arr[i] = a[x[i]] + b[y[i]] - c[i]
coupon_val = min(coupon_val_arr)
print(min([non_coupon_val, coupon_val]))

Buggy submission (verdict: Runtime Error):

A, B, M = map(int, input().split())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
x = [0 for i in range(M)]
y = [0 for i in range(M)]
c = [0 for i in range(M)]
for i in range(M):
  x[i], y[i], c[i] = map(int, input().split())
non_coupon_val = min(a) + min(b)
coupon_val_arr = [0 for i in range(M)]
for i in range(M):
  coupon_val_arr[i] = a[x[i]] + b[y[i]] - c[i]
  coupon_val = min(coupon_val_arr)
print(min([non_coupon_val, coupon_val]))

Buggy submission (verdict: Runtime Error):

import numpy as np
A, B, M = map(int, input().split())
a = np.array([int(i) for i in input().split()], dtype=int)
b = np.array([int(i) for i in input().split()], dtype=int)
x = np.zeros(M, dtype=int)
y = np.zeros(M, dtype=int)
c = np.zeros(M, dtype=int)
for i in range(M):
  x[i], y[i], c[i] = map(int, input().split())

non_coupon_val = np.min(a) + np.min(b)
coupon_val_arr = np.zeros(M)
for i in range(M):
  coupon_val_arr[i] = a[x[i]] + b[y[i]] - c[i]
  coupon_val = np.min(coupon_val_arr)
print(np.min([non_coupon_val, coupon_val]))
Problem p03408 (python)

Fixed submission:
N = int(input())
S = [input() for i in range(N)]
M = int(input())
T = [input() for i in range(M)]

sCount = {}
for s in S:
    sCount[s] = S.count(s)

tCount = {}
for t in T:
    tCount[t] = T.count(t)

union = sCount.keys() & tCount.keys()
ans = sCount;
for i in union:
    ans[i] = sCount[i] - tCount[i]
    
if max(ans.values()) >= 0:
    print(max(ans.values()))
else:
    print(0)

Buggy submission (verdict: Runtime Error):
N = int(input())
S = [input() for i in range(N)]
M = int(input())
T = [input() for i in range(N)]

sCount = {}
for s in S:
    sCount[s] = S.count(s)

tCount = {}
for t in T:
    tCount[t] = T.count(t)

union = sCount.keys() & tCount.keys()
ans = sCount;
for i in union:
    ans[i] = sCount[i] - tCount[i]
    
print(max(ans.values()))
Problem p03455 (python)

Fixed submission:
x = list(map(int, input().split()))
a = x[0]
b=x[1]

if a*b % 2 == 0:
  print("Even")
else:
  print("Odd")

Buggy submission (verdict: Runtime Error):
print(list(map(int, input().split())))
if a*b % 2 == 0:
  print("Even")
else:
  print("Odd")
Problem p03636 (python)

Fixed submission:
s = input()
initial = s[0]
final = s[len(s) - 1]
print(initial + str(len(s)-2) + final)

Buggy submission (verdict: Runtime Error):
s = input()
initial = s[0]
final = s[len(s) - 1]
print(initial + str(len(s - 2)) + final)
Problem p03739 (python)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
currentSum = 0
count1 = 0
count2 = 0
count3 = 0
count4 = 0

for i in range(N):
    restSum = currentSum
    currentSum += A[i]
    if currentSum <= 0 and restSum < 0:
        count1 += abs(currentSum) + 1
        currentSum = 1
    elif currentSum >= 0 and restSum > 0:
        count1 += abs(currentSum) + 1
        currentSum = -1
    elif currentSum == 0 and restSum == 0:
        count1 += 1
        currentSum = -1

currentSum = 0
for i in range(N):
    restSum = currentSum
    currentSum += A[i]
    if currentSum <= 0 and restSum < 0:
        count2 += abs(currentSum) + 1
        currentSum = 1
    elif currentSum >= 0 and restSum > 0:
        count2 += abs(currentSum) + 1
        currentSum = -1
    elif currentSum == 0 and restSum == 0:
        count2 += 1
        currentSum = 1

currentSum = 0
for i in range(N):
    restSum = currentSum
    currentSum += A[i]
    if currentSum <= 0 and restSum < 0:
        count3 += abs(currentSum) + 1
        currentSum = 1
    elif currentSum >= 0 and restSum > 0:
        count3 += abs(currentSum) + 1
        currentSum = -1
    elif A[i] <= 0 and restSum == 0:
        count3 += abs(currentSum) + 1
        currentSum = 1
        
currentSum = 0
for i in range(N):
    restSum = currentSum
    currentSum += A[i]
    if currentSum <= 0 and restSum < 0:
        count4 += abs(currentSum) + 1
        currentSum = 1
    elif currentSum >= 0 and restSum > 0:
        count4 += abs(currentSum) + 1
        currentSum = -1
    elif A[i] >= 0 and restSum == 0:
        count4 += abs(currentSum) + 1
        currentSum = -1
        
print(min(count1, count2, count3, count4))

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

currentSum = 0
for i in range(N):
    restSum = currentSum
    currentSum += A[i]
    if currentSum <= 0 and restSum < 0:
        count3 += abs(currentSum) + 1
        currentSum = 1
    elif currentSum >= 0 and restSum > 0:
        count3 += abs(currentSum) + 1
        currentSum = -1
    elif A[i] <= 0 and restSum == 0:
        count3 += abs(currentSum) + 1
        currentSum = 1
        
currentSum = 0
for i in range(N):
    restSum = currentSum
    currentSum += A[i]
    if currentSum <= 0 and restSum < 0:
        count4 += abs(currentSum) + 1
        currentSum = 1
    elif currentSum >= 0 and restSum > 0:
        count4 += abs(currentSum) + 1
        currentSum = -1
    elif A[i] >= 0 and restSum == 0:
        count4 += abs(currentSum) + 1
        currentSum = -1
        
print(count1, count2, count3, count4)
Problem p02784 (python)

Fixed submission:
H,N = map(int,input().split())
A = list(map(int,input().split()))
if sum(A) < H:
  print("No")
else:
  print("Yes")

Buggy submission (verdict: Runtime Error):
H,N = map(int,input().split())
Alist = []
for i in range(N):
  A = int(input())
  Alist.append(A)
print(Alist)
Problem p02921 (python)

Fixed submission:
s = input ()
t = input ()
count = 0
for i in range(3):
  if s[i]==t[i]:
    count += 1
print (count)

Buggy submission (verdict: Runtime Error):
A,B=map(int,input().split())
set = 0
for i in range(1,20):
  if B==1:
    set -=1
    break
  elif A == B:
    set +=1
    break
  elif ((A-1)*i)+A >= B:
    set +=1
    break
  else:
    set +=1
print(set+1)
Problem p03086 (python)

Fixed submission:
S = input()
l = len(S)
count=0
ans= 0
for i in range(l):
  if S[i] in ["A" ,"C" ,"G","T"]:
    count +=1
  else:
    count=0
  ans = max(count,ans)
print(ans)

Buggy submission (verdict: Runtime Error):
S = input()
l = len(S)
count=0
ans=[]
for i in range(l):
  if S[i]=="A" or S[i]=="C" or S[i]=="G" or S[i]=="T":
    count +=1
  else:
    ans.append(count)
    count=0

print(max(ans))
Problem p02747 (python)

Fixed submission:
S = input()
ans = ''
flag = False
for i in range(5):
    ans += 'hi'
    if ans == S:
        flag = True

print('Yes' if flag else 'No')

Buggy submission (verdict: Runtime Error):
S = input()
if len(S) == 1:
    print('No')
elif len(S) == 2:
    if S[0] == 'h' and S[1] == 'i':
        print('Yes')
    else:
        print('No')
else:
    for i in range(len(S)-2):
        if S[i] == 'h' and S[i + 1] == 'i' and S[i + 2] != 'i':
            print('Yes')
            exit(1)
    print('No')
Problem p02748 (python)

Fixed submission:
A, B, M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ans = min(a) + min(b)

for i in range(M):
    x, y, c = map(int, input().split())
    ans = min(ans, a[x-1] + b[y-1] - c)
print(ans)

Buggy submission (verdict: Runtime Error):
A, B, M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ans = min(a) + min(b)

for i in range(M):
    x, y, c = map(int, input().split())
    ans = min(ans, a[x-1] + a[y-1] - c)
print(ans)

Buggy submission (verdict: Runtime Error):
A, B, M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ans = min(a) + min(b)

for i in range(M):
    x, y, c = map(int, input().split())
    ans = min(ans, a[x-1] + a[y-1] - c)
print(ans)
Problem p02761 (python)

Fixed submission:

def solve(x):
    x = str(x)
    if len(x) != N:
        return False
    for s, c in P:
        if x[s - 1] != str(c):
            return False
    return True

if __name__ == "__main__":
    N, M = map(int, input().split())
    P = [list(map(int, input().split())) for i in range(M)]
    ans = 10**N
    for i in range(10 ** N - 1, -1, -1):
        if solve(i):
            ans = min(ans, i)
            
    print(ans if ans != 10**N else -1)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
P = [input().split() for i in range(M)]
k3, k2, k1 = 0, 0, 0

if N == 3:
    for i in range(M):
        if P[i][0] == '1':
            if k3 != 0:
                k3 = min(k3, int(P[i][1]))
            else:
                k3 = int(P[i][1])
        elif P[i][0] == '2':
            if k2 != 0:
                k2 = min(k2, int(P[i][1]))
            else:
                k2 = int(P[i][1])
        else:
            if k1 != 0:
                k1 = min(k1, int(P[i][1]))
            else:
                k1 = int(P[i][1])
    ans = k3 * 100 + k2 * 10 + k1
    ans = ans if M > 0 and len(str(ans)) == 3  else - 1
    print(ans)

elif N == 2:
    for i in range(M):
        if P[i][0] == '1':
            print(-1)
            exit(1)
        elif P[i][0] == '2':
            if k2 != 0:
                k2 = min(k2, int(P[i][1]))
            else:
                k2 = int(P[i][1])
        else:
            if k1 != 0:
                k1 = min(k1, int(P[i][1]))
            else:
                k1 = int(P[i][1])

    ans = k3 * 100 + k2 * 10 + k1
    ans = ans if M > 0 and len(str(ans)) == 2  else - 1
    print(ans)
        
        
else:
    for i in range(M):
        if P[i][0] == '1' or P[i][0] == '2':
            print(-1)
            exit(1)
        else:
            if k1 != 0:
                k1 = min(k1, int(P[i][1]))
            else:
                k1 = int(P[i][1])

    ans = k3 * 100 + k2 * 10 + k1
    ans = ans if M > 0 and len(str(ans)) == 1  else - 1
    print(ans)
Problem p02818 (python)

Fixed submission:
import math
A, B, K = map(int, input().split())

if A >= K:
    A = A - K
    print(A, end=" ")
    print(B)
    exit(0)

if K > A:
    K = K - A
    A = 0
    if K >= B:
        B = 0
        print(A, end=" ")
        print(B)
        exit(0)
    if B > K:
        B = B - K
        print(A, end=" ")
        print(B)
        exit(0)

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

gcd = math.gcd(A, B)
A = A // gcd
B = B // gcd

    
for i in range(K):
    if A >= 1:
        A -= 1
    elif B >= 1:
        B -= 1
    if A == 0 and B == 0:
        break

print(A, end=" ")
print(B)
Problem p02861 (python)

Fixed submission:

from math import sqrt 
N = int(input())
k = [list(map(int, input().split())) for _ in range(N)]
result = 0
for i in range(N):
    for j in range(N):
        if i != j:
            result += sqrt((k[i][0] - k[j][0]) * (k[i][0] - k[j][0]) + (k[i][1] - k[j][1]) * (k[i][1] - k[j][1]))
print(result / N)

Buggy submission (verdict: Runtime Error):
from math import sqrt 
N = int(input())
k = [[int(i) for i in input().split()] for i in range(N)]
result = 0
for i in range(N):
    for j in range(N):
        if i != j:
            result += sqrt((k[i][0] - k[j][0]) * (k[i][0] - k[j][0]) + k[i][1] - k[j][1]) * (k[i][1] - k[j][1]))
print(result / N)
Problem p02923 (python)

Fixed submission:
N = int(input())
H = list(map(int, input().split()))
ans = 0
c = 0
H.reverse()

for i in range(1, len(H)):
    if H[i] >= H[i - 1]:
        c += 1
    else:
        c = 0
    ans = max(c, ans)

print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
H = list(map(int, input().split()))
count = []
c = 0
H.reverse()

for i in range(1, len(H)):
    if H[i] >= H[i - 1]:
         c += 1
         continue
    count.append(c)
    c = 0


print(max(count))