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

Fixed submission:
a = input()
b = input()

a_len = len(a)
b_r = b[:-1]

if b_r == a and a_len <= 10 and a_len >= 1:
 	print("Yes")
else:
	print("No")

Buggy submission (verdict: Runtime Error):
a = list(map(int,input().split()))
 
 
one = a[0]
zero = a[1]
mone = a[2]
num = a[3]
 
ans = 0
if one >= num:
    print(num)
else:
    ans += one
    num -= one
    if zero >= num:
        print(ans)
    else:
        num -= zero
        print(one - num)

Buggy submission (verdict: Runtime Error):
str = input().split()
a = str[0]
a_len = len(a)
b = str[1]
b_r = str[:-1]


if b_r[0] == a and a_len <= 10 and a_len >= 1:
 	print("Yes")
else:
	print("No")

Buggy submission (verdict: Runtime Error):
str = input().split()
a = str[0]
a_len = len(a)
b = str[1]
b_r = str[:-1]


if b_r == a and a_len <= 10 and a_len >= 1:
 	print("Yes")
else:
	print("No")
Problem p02684 (python)

Fixed submission:
N, K = map(int, input().split())
A = list(map(int,input().split()))
b = [0]*N
next_town = 1
for i in range(N+1):
    if b[next_town-1] != 0:
        start = next_town
        cycle = i - b[next_town-1]
#        print("start: "+str(start))
#        print("cycle: "+str(cycle))
        break
    b[next_town-1] = i
    next_town = A[next_town-1]
    
next_town = 1
if b[start-1] >= K:
    for i in range(K):
        next_town = A[next_town-1]
    print(next_town)
else:
    next_town = start
    for i in range((K-b[start-1])%cycle):
        next_town = A[next_town-1]
    print(next_town)

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

b = [1]
i = 0
while True:
    if A[i] in b:
#        print("m: "+str(b.index(A[i])))
#        print("n: "+str(len(b)-A[i]))
        m = b.index(A[i])
        n = len(b)-b.index(A[i])
        cycle = (K-m)%n
        position = A[i] - 1
        break
    b.append(A[i])
    i = A[i] - 1
    
tmp = 0
if K <= cycle:
	for i in range(K):
		next_town = A[tmp]
		tmp = next_town - 1
	print(next_town)
else:
	for i in range(cycle):
		next_town = A[position]
		position = next_town -1
	print(next_town)

Buggy submission (verdict: Runtime Error):
import sys
s = sys.stdin.readlines()
N, K = map(int, s[0].split())
A = list(map(int, s[1].split()))
 
b = [1]
i = 0
while True:
    if A[i] in b:
#        print("m: "+str(b.index(A[i])))
#        print("n: "+str(len(b)-A[i]))
        m = b.index(A[i])
        n = len(b)-b.index(A[i])
        K = (K-m)%n + m
        break
    b.append(A[i])
    i = A[i] - 1
    
tmp = 0
for i in range(K):
    next_town = A[tmp]
    tmp = next_town - 1
print(next_town)

Buggy submission (verdict: Runtime Error):
import sys
s = sys.stdin.readlines()
N, K = map(int, s[0].split())
A = list(map(int, s[1].split()))

b = [1]
i = 0
while True:
    if A[i] in b:
#        print("m: "+str(b.index(A[i])))
#        print("n: "+str(len(b)-A[i]))
        m = b.index(A[i])
        n = len(b)-A[i]
        K = (K-m)%n + m
        break
    b.append(A[i])
    i = A[i] - 1
    
tmp = 0
for i in range(K):
    next_town = A[tmp]
    tmp = next_town - 1
print(next_town)
Problem p02683 (python)

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

a = [[0 for i in range(m)] for _ in range(n)]
c = [0] * n
for sankousyo in range(n):
    c_and_a = list(map(int,input().split()))
    c[sankousyo] = c_and_a[0]
    a[sankousyo] = c_and_a[1:]
    
cost = [0] * (2**n)
INF = 10**12
res_cost = INF
for i in range(2**n):
    understandings = [0] * m
    cost_sum = 0
    for j in range(n):
        if (i >> j) & 1:

            cost_sum += c[j]
            
            for k in range(m):
                understandings[k] = understandings[k] + a[j][k]

    res = True
    for j in range(m):
        if understandings[j] < x:
            res = False 

    if res:
        if res_cost > cost_sum:
            res_cost = cost_sum

if res_cost == INF:
    print(-1)
else:
    print(res_cost)

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

a = [[0 for i in range(m)] for _ in range(n)]
c = [0] * n
for sankousyo in range(n):
    c_and_a = list(map(int,input().split()))
    c[sankousyo] = c_and_a[0]
    a[sankousyo] = c_and_a[1:]
    
cost = [0] * (2**n)
INF = 10**12
res_cost = INF
for i in range(2**n):
    understandings = [0] * m
    cost_sum = 0
    for j in range(n):
        if (i >> j) & 1:

            cost_sum += c[j]
            
            for k in range(m):
                understandings[k] = understandings[k] + a[j][k]

    res = True
    for j in range(n):
        if understandings[j] < x:
            res = False 

    if res:
        if res_cost > cost_sum:
            res_cost = cost_sum

if res_cost == INF:
    print(-1)
else:
    print(f"お会計は{res_cost}円です")
Problem p02687 (python)

Fixed submission:
S = input()
assert S == "ABC" or "ARC", "Sは、ABCまたはARCです"
if S == "ABC":
    print("ARC")
else:
    print("ABC")

Buggy submission (verdict: Runtime Error):
S = input()
assert S == ("ABC" or "ARC"), "Sは、ABCまたはARCです"
if S == "ABC":
    print("ARC")
else:
    print("ABC")
Problem p02718 (python)

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

l=sorted(l,reverse=True)

l_sum=sum(l)
ans="Yes"

if l[m-1]<(l_sum/4/m):
  ans="No"
    
print(ans)

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

l=sorted(l,reverse=True)

l_sum=sum(l)
ans="Yes"

for i in range(m):
  if l[m]<(l_sum/4/m):
    ans="No"
    break
    
print(ans)

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

l=sorted(l,reverse=True)

l_sum=sum(l)
ans="Yes"

for i in range(m):
  if l[m]<(l_sum*1/4/m):
    ans="No"
    break
    
print(ans)
Problem p02952 (python)

Fixed submission:
n=int(input())

if n<100:
  print(min(n,9))
elif n<10000:
  print(min(n-90,909))
else:
  print(min(n-9090,90909))

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

if n<100:
  print(min(n,9))
elif n<10000:
  print(min(n-90),909)
else:
  print(min(n-9090),90909)

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

x=0
if n1=1:
  x=n
elif n1=2:
  x=9
elif n1=3:
  x=9+(n-99)
elif n1=4:
  x=9+90
elif n1=5:
  x=9+900+(n-999)
elif n1=6:
  x=9+900+90000
  
print(x)

Buggy submission (verdict: Runtime Error):
n=int(input())
n1=len([i for i in str(n)])

x=0
if n1=1:
  x=n
elif n1=2:
  x=9
elif n1=3:
  x=9+(n-99)
elif n1=4:
  x=9+90
elif n1=5:
  x=9+900+(n-999)
elif n1=6:
  x=9+900+90000
  
print(x)

Buggy submission (verdict: Runtime Error):
n=int(input())
n1=[int(i) for i in str(n)]
n2=len(n1)

x=0
if n1=1:
  x=n
elif n1=2:
  x=9
elif n1=3:
  x=9+(n-99)
elif n1=4:
  x=9+900
elif n1=5:
  x=9+900+(n-999)
  
print(x)
Problem p02971 (python)

Fixed submission:
N=int(input())

l=list(int(input()) for i in range(N))

sort_l=sorted(l,reverse=True)

for i in range(N):
  if l[i]==sort_l[0]:
    print(sort_l[1])
  else:
    print(sort_l[0])

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

list=[]
for _ in range(n-1):
  list.append(int(input()))

for i in range(n-1):
  print(max(list.pop(i+1)))
Problem p02981 (python)

Fixed submission:
n,a,b=map(int,input().split())
print(min(n*a,b))

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

print(min(n*a,b))
Problem p02982 (python)

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

l=[]
for _ in range(n):
  l1=list(map(int,input().split()))
  l.append(l1)

import math

ans=[]
for a in range(n):
  for b in range(n):
    x=0
    for c in range(d):
      D=(l[a][c]-l[b][c])**2
      x+=D
    y=math.sqrt(x)
    ans.append(y.is_integer())
      
ans=(ans.count(True)-n)//2
print(ans)

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

l=[]
for _ in range(n):
  l1=[map(int,input().split())]
  l.append(l1)

import math

ans=[]
for a in range(n):
  for b in range(n):
    x=0
    for c in range(d):
      D=(l[a][c]-l[b][c])**2
      x+=D
    y=math.sqrt(x)
    ans.append(y.is_integer())
      
ans=(ans.count(True)-n)//2
print(ans)

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

l=[]
for _ in range(n):
  l1=[map(int,input().split())]
  l.append(l1)

import math

ans=[]
for a in range(n):
  for b in range(n):
    x=0
    for c in range(d):
      D=(l[a][c]-l[b][c])**2
      x+=D
    y=math.sqrt(x)
    ans.append(isinstance(y,int))
      
ans=(ans.count(True)-n)//2
print(ans)

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

l=[]
for _ in range(n):
  l1=[map(int,input().split())]
  l.append(l1)

import math

ans=[]
for a in range(n):
  for b in range(n):
    a=0
    for c in range(d):
      D=(l[a][c]-l[b][c])**2
      a+=D
    ans.append(isinstance(math.sqrt(a),int))
      
ans=(ans.count(True)-n)//2
print(ans)

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

l=[]
for _ in range(n):
  l1=[map(int,input().split())]
  l.append(l1)

import math

ans=[]
for a in range(n):
  for b in range(n):
    a=0
    for c in range(d):
      D=(l[a][c]-l[b][c])**2
      a+=D
    ans.append(isinstance(math.sqrt(a),int))
      
ans=sum(ans)-n
print(ans)
Problem p02994 (python)

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

l=[a+i-1 for i in range(1,n+1)]

import numpy as np
b=min(np.abs(l))

if b==0:
  l.remove(0)
elif b in l:
  l.remove(b)
elif -b in l:
  l.remove(-b)
  
print(sum(l))

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

apples=[a+i for i in ragen(n)]
eat=min(apples,key=lambda x:abs(x))
res=sum(apples)-eat

print(res)

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

l=[a+i-1 for i in range(1,n+1)]

import numpy as np
b=min(np.abs(l))

if b==0:
  l.remove(0)
else:
  l.remove([b,-b],1)
  
print(sum(l))

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

l=[a+i-1 for i in range(1,n+1)]

import numpy as np
b=min(np.abs(l))

if b==0:
  l.remove(0)
else:
  l.remove([b,-b])
  
print(sum(l))

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

l=[a+i-1 for i in range(1,n+1)]
b=min(abs(l))

if b==0:
  l.remove(0)
else:
  l.remove([b,-b])
  
print(sum(l))
Problem p02999 (python)

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

if x<a:
  print(0)
else:
  print(10)

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

if x<a:
  print(0)
else:
  print(10)

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

if x<a:
  print(0)
else:
  print(10)

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

if x<a:
  print('0')
else:
  print('10')
Problem p03000 (python)

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

ans=1
a=0
for i in range(n):
  a+=l[i]
  if a>x:
    break
  else:
    ans+=1
    
print(ans)

Buggy submission (verdict: Runtime Error):
n,x=map(int,input().split())
l=[int(input()) for _ in range(n)]

ans=0
a=0
for i in range(n):
  if a<=x:
    a+=l[0]
    ans+=1
        
print(ans)

Buggy submission (verdict: Runtime Error):
n,x=map(int,input().split())
l=[int(input()) for _ in range(n)]

ans=0
a=0
for i in range(n):
  if i==0:
    ans+=1
    continue
  else:
    if a<=x:
      ans+=1
      a+=l[i-1]
    else:
      break

print(ans)
Problem p03059 (python)

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

print(t//a*b)

Buggy submission (verdict: Runtime Error):
a,b,t=map(int,input().split())
 
ans=[]
while a<=t+0.5:
  ans.appen(b)
  a+=a
  
print(sum(ans))
Problem p03060 (python)

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

ans=0
for i in range(n):
  if a[i]>b[i]:
    ans+=a[i]-b[i]

print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=[int(input()) for _ range(n)]
b=[int(input()) for _ range(n)]

ans=0
for i in range(n):
  if a[i]>b[i]:
    ans+=a[i]

print(ans)
Problem p03071 (python)

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

if a==b:
  print(2*a)
  
else:
  print(2*max(a,b)-1)

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

if a=b:
  print(2*a)
  
else:
  print(2*max(a,b)-1)

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

ans=0

if a=b:
  ans+=2*a
  print(ans)
else:
  ans+=2*max(a,b)-1
  print(ans)

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

ans=0

if a=b:
  ans+=2*a
  print(ans)
else:
  ans+=2*max(a,b)-1
  print(ans)

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

ans=0

if a=b:
  ans+=2*a
  print(ans)
else:
  ans+=2*max(a,b)-1
  print(ans)
Problem p02909 (python)

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

Buggy submission (verdict: Runtime Error):
if S=="Sunny":
    S="cloudy"
elif S=="cloudy":
    S="Rainy"
elif S=="Rainy":
    S="Sunny"
Problem p02910 (python)

Fixed submission:
S=input()
e=S[0::2]
o=S[1::2]
for i in range(len(e)):
    if e[i]=="L":
        print("No")
        break
else:
    for j in range(len(o)):
        if o[j]=="R":
            print("No")
            break 
    else:
        print("Yes")

Buggy submission (verdict: Runtime Error):
S=input()
e=S[0::2]
o=S[1::2]
for i in range(len(e)):
    if s[i]=="L":
        print("No")
        break
else:
  for j in range(len(o)):
    if o[j]=="R":
        print("No")
        break 
  else:
    print("Yes")
Problem p02696 (python)

Fixed submission:
import math

A,B,N = map(int,input().split())
if B>N:
  print( math.floor(A*N/B) - A * math.floor(N/B))
  exit()
print( math.floor(A*(B-1)/B) - A * math.floor((B-1)/B))

Buggy submission (verdict: Runtime Error):
A,B,N =map(int,input().split())
ans =0
for x in range(1,N+1):
  num = math.floor(A*x/B) - A * math.floor(x/B)
  if num > ans:
    ans = num

print(ans)
Problem p02717 (python)

Fixed submission:
X,Y,Z = map(int, input().split())
print(Z,X,Y)

Buggy submission (verdict: Runtime Error):
X=int(input())
Y=int(input())
Z=int(input())
print(Z,X,Y)

Buggy submission (verdict: Runtime Error):
X=int(input())
Y=int(input())
Z=int(input())
print(Z)
print(X)
print(Y)
Problem p02718 (python)

Fixed submission:
N,M = map(int,input().split())
a = input().split()
ans =0
for i in a:
  if int(i) >= sum(map(int,a))* 1/(4*M):
    ans+=1

if ans >= M:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
N,M = map(int,input().split())
a = input().split()
for i in a:
  if int(i) >= sum(map(int,a))* 1/(4*M):
    ans+=1

if ans >= M:
  print("Yes")
else:
  print("No")
Problem p03448 (python)

Fixed submission:
A = int(input())
B = int(input())
C = int(input())
X = int(input())
count = 0
for i in range(A+1):
  for j in range(B+1):
    for k in range(C+1):
      if 500*i + 100*j + 50*k == X:
        count+=1
print(count)

Buggy submission (verdict: Runtime Error):
A = int(input())
B = int(input())
C = int(input())
X = int(input())
count = 0
for i in range(A+1):
  for j in ramge(B+1):
    for k in range(C+1):
      if 500*i + 100*j + 50*k == X:
        count+=1
print(count)
Problem p03478 (python)

Fixed submission:
def digitSum(n):
  #数値を文字列に変換
  s = str(n)
  #1文字ずつ数値化し配列にする
  array = list(map(int,s))
  #合計値を返す
  return sum(array)


N,A,B = map(int,input().split())
a = 0
for i in range(N+1):
  if digitSum(i) <= B and digitSum(i) >= A:
    a +=i
print(a)

Buggy submission (verdict: Runtime Error):
def digitSum(n):
  #数値を文字列に変換
  s = str(n)
  #1文字ずつ数値化し配列にする
  array = list(map(int,s))
  #合計値を返す
  return sum(array)


N,A,B = map(int,input().split())
sum = 0
for i in range(N+1):
  if digitSum(i) <=B and digitSum(i)>=A:
    sum +=i
print(sum)
Problem p03493 (python)

Fixed submission:
num = 0
s = input()
for i in s:
  if int(i) == 1:
    num += 1
print(num)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = [int(i) for i in input().split()]
en = 0
con = True
while con :
	en += 1
	for i in range(N) :
		if A[i] % 2 == 0 :
			A[i] = int( A[i] / 2 ) 
		else :
			en -= 1
			con = False
			break
print(en)

Buggy submission (verdict: Runtime Error):
s = input()
for i in s:
  if int(i) == 1:
    num += 1
print(num)
Problem p03494 (python)

Fixed submission:
N = int(input())
A = [int(i) for i in input().split()]
en = 0
con = True
while con :
	en += 1
	for i in range(N) :
		if A[i] % 2 == 0 :
			A[i] = int( A[i] / 2 ) 
		else :
			en -= 1
			con = False
			break
print(en)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = [int(i) for i in input().split()]
count = 0
can = True
while can :
	count += 1
	for i in range(N) :
		if A[i] % 2 == 0 :
			A[i] = int( A[i] / 2 ) 
		else :
			count -= 1
			can = False
			break
print(en)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = [input() for i in range(N)]
count = 0 
can = True
while can:
  count += 1
  for i in range(N):
    if A[i]%2 == 0:
      A[i] = int(A[i]/2)
    else:
      count-=0
      can = False
      break
print(count)
Problem p02677 (python)

Fixed submission:

import math

# 標準入力
A,B,H,M=map(int,input().split())

# 角度の差が出る
A_RAD = float((H*60+M)/720*2*math.pi)
B_RAD = float(M/60*2*math.pi)
AB_RAD = A_RAD - B_RAD

C = math.sqrt(A**2+B**2-2*A*B*math.cos(AB_RAD))

print(C)

Buggy submission (verdict: Runtime Error):

# 標準入力
A,B,H,M=map(int,input().split())

# 角度の差が出る
A_RAD = float((H*60+M)/720*2*math.pi)
B_RAD = float(M/60*2*math.pi)
AB_RAD = A_RAD - B_RAD

C = math.sqrt(A**2+B**2-2*A*B*math.cos(AB_RAD))

print(C)
Problem p02683 (python)

Fixed submission:
def solve(i, cost, know, x, a):
    global res
    if i == len(a):
        for j in range(m):
            if know[j] < x:
                return
        res = min(res, cost)
        return
    solve(i + 1, cost, know, x, a)
    for j in range(m):
        know[j] += a[i][j + 1]
    solve(i + 1, cost + a[i][0], know, x, a)
    for j in range(m):
        know[j] -= a[i][j + 1]
n, m, x = [int(i) for i in input().split()]
a = [[int(i) for i in input().split()] for j in range(n)]
know = [0] * (m)
res = 10 ** 7
solve(0, 0, know, x, a)
print(res if res != 10 ** 7 else - 1)

Buggy submission (verdict: Runtime Error):
def solve(i, cost, know, x, a):
    global res
    if i == len(a):
        for j in range(m):
            if know[j] < x:
                return
        res = min(res, cost)
        return
    solve(i + 1, cost, know, x, a)
    for j in range(m):
        know[j] += a[i][j + 1]
    solve(i + 1, cost + a[i][0], know, x, a)
    for j in range(m):
        know[j] -= a[i][j + 1]
fin = open('input.txt', 'r')
n, m, x = [int(i) for i in input().split()]
a = [[int(i) for i in input().split()] for j in range(n)]
know = [0] * (m)
res = 10 ** 7
solve(0, 0, know, x, a)
print(res if res != 10 ** 7 else - 1)
Problem p02686 (python)

Fixed submission:
def result(m, b):
    sum1 = m
    resmin = m
    for i in range(len(b)):
        resmin += b[i][0]
        if resmin < 0:
            return -1
        else:
            resmin += b[i][1] - b[i][0]
    for i in range(len(b)):
        sum1 += b[i][1]
    if sum1 != 0:
        return -1
    return 0
n = int(input().strip('\n'))
resmin = 10 ** 7
set_pos = []
set_neg = []
for i in range(n):
    a = input().strip('\n')
    loc_min = 10 ** 7
    total = 0
    flag = True
    tmp = 0
    for j in range(len(a)):
        if a[j] == '(':
            tmp += 1
        else:
            tmp -= 1
        if tmp < loc_min:
            loc_min = tmp
    total = tmp
    if total >= 0:
        set_pos.append((loc_min, total))
    else:
        set_neg.append((loc_min, total))
total_pos = 0
set_pos = sorted(set_pos, key = lambda l: l[0], reverse = True)
for elem in set_pos:
    if total_pos + elem[0] < 0:
        flag = False
    total_pos += elem[1]   
b = sorted(set_neg, key = lambda l: l[1] - l[0], reverse = True)
#print(b)
#print(set_pos, b)
res = result(total_pos, b)
print('No' if (res == -1 or not flag) else 'Yes')

Buggy submission (verdict: Runtime Error):
def result(m, b):
    sum1 = m
    resmin = m
    for i in range(len(b)):
        resmin += b[i][0]
        if resmin < 0:
            return -1
        else:
            resmin += b[i][1] - b[i][0]
    for i in range(len(b)):
        sum1 += b[i][1]
    if sum1 != 0:
        return -1
    return 0
fin = open('input.txt', 'r')
n = int(fin.readline().strip('\n'))
resmin = 10 ** 7
set_pos = []
set_neg = []
for i in range(n):
    a = fin.readline().strip('\n')
    loc_min = 10 ** 7
    total = 0
    flag = True
    tmp = 0
    for j in range(len(a)):
        if a[j] == '(':
            tmp += 1
        else:
            tmp -= 1
        if tmp < loc_min:
            loc_min = tmp
    total = tmp
    if total >= 0:
        set_pos.append((loc_min, total))
    else:
        set_neg.append((loc_min, total))
total_pos = 0
set_pos = sorted(set_pos, key = lambda l: l[0], reverse = True)
for elem in set_pos:
    if total_pos + elem[0] < 0:
        flag = False
    total_pos += elem[1]   
b = sorted(set_neg, key = lambda l: l[1] - l[0], reverse = True)
#print(b)
print(set_pos, b)
res = result(total_pos, b)
print('No' if (res == -1 or not flag) else 'Yes')
Problem p02696 (python)

Fixed submission:
import math
a,b,n = map(int,input().split())
x = 0
ans = 0
if b > n:
    x = n
    ans = math.floor(a*n/b) - a*math.floor(n/b)
else:
    n = b-1
    ans = math.floor(a*n/b) - a*math.floor(n/b)
print(ans)

Buggy submission (verdict: Runtime Error):
import math
a,b,n = map(int,input().split())
x = 0
ans = 0
if b > n:
    x = n
    ans = math.floor(a*n/b) - a*math.floor(n/b)
else:
    n = b-1
    ans = ath.floor(a*n/b) - a*math.floor(n/b)
print(ans)
Problem p02714 (python)

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

r_cnt = s.count('R')
g_cnt = s.count('G')
b_cnt = s.count('B')

ans = r_cnt*g_cnt*b_cnt

for i in range(n):
    for d in range(n):
        j = i + d
        k = j + d
        if k >= n:
            break
        if s[i] != s[j] and s[i] != s[k] and s[j]!=s[k]:
            ans -= 1
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
s = list(input())
#
ans = 0
def R(x):
    if x == 0:
        if s[0] == 'R':
            return 1
        else:
            return 0
    else:
        if s[x] == 'R':
            return R(x-1) + 1
        else:
            return R(x-1)
def B(x):
    if x == 0:
        if s[0] == 'B':
            return 1
        else:
            return 0
    else:
        if s[x] == 'B':
            return B(x-1) + 1
        else:
            return B(x-1)
def G(x):
    if x == 0:
        if s[0] == 'G':
            return 1
        else:
            return 0
    else:
        if s[x] == 'G':
            return G(x-1) + 1
        else:
            return G(x-1)

for i in range(n-2):
    for j in range(i+1,n-1):
        if s[i] != s[j]:
            if s[i] != 'R' and s[j] != 'R':
                if 2*j-i <= n-1 and s[2*j-i] == 'R':
                    ans += R(n-1) - R(j) - 1
                else:
                    ans += R(n-1) - R(j)
            elif  s[i] != 'B' and s[j] != 'B':
                if 2*j - i <= n-1 and s[2*j-i] == 'B':
                    ans += B(n-1) - B(j) - 1
                else:
                    ans += B(n-1) - B(j)
            elif s[i] != 'G' and s[j] != 'G':
                if 2*j - i <= n-1 and s[2*j-i] == 'G':
                    ans += G(n-1) - G(j) - 1
                else:
                    ans += G(n-1) - G(j)
        else:
            pass
print(ans)
Problem p02717 (python)

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

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10**6)
MOD = 1000000007

k = int(input())
number = 9

ans = 0
for i in range(10,10**6):
    check = 'OK'
    l = len(str(i))
    keta = list(str(i))
    for j in range(l-1):
        if abs(int(keta[j]) - int(keta[j+1])) <= 1:
            pass
        else:
            check = 'NG'
    if check == 'OK':
        number += 1
        if number == k:
            ans = i%MOD
            break
if k <= 9:
    print(k)
else:
    print(ans%MOD)
Problem p02741 (python)

Fixed submission:
a = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
k = int(input())
print(a[k-1])

Buggy submission (verdict: Runtime Error):
from decimal import *

getcontext().prec = 20
a,b,c = map(int,input().split())
a = int(Decimal(a))
b = int(Decimal(b))
c = int(Decimal(c))
if a*b < 1/4 * (c-a-b)**2:
    print('Yes')
else:
    print('No')