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

Fixed submission:
import sys

def main():

	N = int(input())
	
	d = {}
	for i in range(N):
		A = input()
		d[A] = 0
	print(len(d))
	
if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import sys

def main():

	N = int(input())
	
	d = {}
	for i in range(N):
		A = int(input())
		d[A] = 0
	print(len(d))
	
if __name__ == "__main__":
    main()
Problem p02897 (python)

Fixed submission:
import sys

def main():

	p = 0

	args = sys.argv
	n = int(input())
	
	print((int(n/2) + n%2 )/n)

if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import sys

def main():

	p = 0

	args = sys.argv
	n = int(args[1])
	
	print((int(n/2) + n%2 )/n)

if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import sys

	p = 0

	args = sys.argv
	n = int(args[1])
	for i in range(1, n+1):
		if i % 2 == 1:
			p = p + 1
	
	print(p/n)

Buggy submission (verdict: Runtime Error):
import sys

def main():

	p = 0

	args = sys.argv
	n = int(args[1])
	for i in range(1, n+1):
		if i % 2 == 1:
			p = p + 1
	
	print(p/n)

if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import sys

def main():

	p = 0

	args = sys.argv
	n = int(args[1])
	for i in range(1, n):
		if i % 2 == 1:
			p = p + 1
	
	print(p/n)

if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import sys

def main():

	p = 0

	args = sys.argv
	n = int(args[1])
	for i in range(1, n):
		if i % 2 == 1:
			p = p + 1
	
	print(p/n)

if __name__ == "__main__":
    main()
Problem p02659 (python)

Fixed submission:
a,b=map(int,input().replace('.', '').split())
print(a*b//100)

Buggy submission (verdict: Runtime Error):
a,b=map(int,input().split(" "))
print(a*(b*100)/100)

Buggy submission (verdict: Runtime Error):
a,b=map(int,input().split(""))
print(a*(b*100)/100)
Problem p02729 (python)

Fixed submission:
import math
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
n,m = map(int,input().split())
if n<2 and m<2:
    print(0)
elif n<2:
    print(combinations_count(m,2))
elif m<2:
    print(combinations_count(n,2))
else:
    print(combinations_count(n,2)+combinations_count(m,2))

Buggy submission (verdict: Runtime Error):
import math
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
n,m = map(int,input().split())
if n<1 and m<1:
    print(0)
elif n<1:
    print(combinations_count(m,2))
elif m<1:
    print(combinations_count(n,2))
else:
    print(combinations_count(n,2)+combinations_count(m,2))
Problem p03835 (python)

Fixed submission:
k,s = map(int,input().split())
ans = 0
for i in range(k+1):
	for j in range(k+1):
		z = s-i-j
		if(0 <= z and z <= k):
			ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
k,s = map(int,input().split())
ans = 0
for i in range(k+1):
	for j in range(k+1):
		z = s-x-y
		if(0 <= z and z <= k):
			ans += 1
print(ans)
Problem p02753 (python)

Fixed submission:
def yesno(S):
  if S=="AAA" or S=="BBB":
    return "No"
  else:
    return "Yes"
  
S=input()
print(yesno(S))

Buggy submission (verdict: Runtime Error):
def yesno(S):
  if S==AAA or S==BBB:
    return No
  else:
    return Yes
  
print(yesno(S))
Problem p02570 (python)

Fixed submission:
import numpy as np

D, T, S = map(int, input().split())

if S*T >= D:
    print('Yes')
else:
    print('No')

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

D, T, S = map(int, input().split())

if S*T >= D:
    print(Yes)
elif:
    print(No)
Problem p02594 (python)

Fixed submission:
x = int(input())

if x >= 30:
  print('Yes')
elif x < 30:
  print('No')

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

if x >= 30:
  print('Yes')
elif x < 30:
  print('No')
else:
  print('No')

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

if x >= 30:
  print('Yes')
elif x < 30:
  print('No')
Problem p02597 (python)

Fixed submission:
n = int(input())
C = input()
print(C[:C.count('R')].count("W"))

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(input())
print(C[:C.count('R')].count("W"))
Problem p02773 (python)

Fixed submission:
l =[]
r=[]
n = int(input())
for i in range(n):
    l.append(input())
d={}
for i in l:
    if i in d:
        d[i]+=1
    else:
        d[i]=1
print()
m = max(d.values())
for key,value in d.items():
    if value==m:
        r.append(key)
sorted_r = sorted(r)
print(*sorted_r,sep='\n')

Buggy submission (verdict: Runtime Error):

r=[]
import sys

n = int(sys.stdin.readline())
sn = sys.stdin.read().split()

d={}
for i in l:
    if i in d:
        d[i]+=1
    else:
        d[i]=1

m = max(d.values())
for key,value in d.items():
    if value==m:
        r.append(key)
sorted_r = sorted(r)
print(*sorted_r,sep='\n')

Buggy submission (verdict: Runtime Error):

r=[]
import sys

n = int(sys.stdin.readline())
sn = sys.stdin.read().split()

d={}
for i in l:
    if i in d:
        d[i]+=1
    else:
        d[i]=1

m = max(d.values())
for key,value in d.items():
    if value==m:
        r.append(key)
sorted_r = sorted(r)
print(*sorted_r,sep='\n')
Problem p02779 (python)

Fixed submission:
from collections import Counter
import sys
n = int(input())
l = sys.stdin.read().split()
c = Counter(l)
m = max(c.values())

if(m==1):
    print("YES")
else:
    print("NO")

Buggy submission (verdict: Runtime Error):
from collections import Counter
import sys
n = int(input())
l = sys.stdin.read().split()
c = counter(l)
m = max(c.values())

if(m==1):
    print("YES")
else:
    print("NO")

Buggy submission (verdict: Runtime Error):
from collections import Counter
import sys
n = int(input())
l = sys.stdin.read().split()
c = counter(l)
m = max(c.value())

if(m==1):
    print("YES")
else:
    print("NO")

Buggy submission (verdict: Runtime Error):
n = int(input())
flag = 1
l = []
for i in range(n):
    a = int(input())
    if a in l:
        flag = 0
        break
    else:
        l.append(a)
if(flag==1):
    print("YES")
else:
    print("NO")
Problem p02793 (python)

Fixed submission:
def gcd(x, y):
    x = x % y
    if x == 0:
        return y
    return gcd(y, x)

def lcm(x, y):
    return x // gcd(x, y) * y
n = int(input())
a = list(map(int, input().split(' ')))
l = 1
for ai in a:
    l = lcm(l, ai)
mod = 1000000007
ans = 0
for ai in a:
    ans += l // ai
ans %= mod
print(ans)

Buggy submission (verdict: Runtime Error):
import math

def lcm(x, y):
    return x // math.gcd(x, y) * y
n = int(input())
a = list(map(int, input().split(' ')))
l = 1
for ai in a:
    l = lcm(l, ai)
mod = 1000000007
ans = 0
for ai in a:
    ans += l // ai
ans %= mod
print(ans)
Problem p02753 (python)

Fixed submission:
while True:
    sta = input()
    if len(sta) == 3:
        break

judge = ""
count = 0
result = ""
station = [sta[0], sta[1], sta[2]]
for ss in station:
    if count == 0:
        judge = ss
    else:
        if ss == judge:
            result = "No"
        else:
            result = "Yes"
            break
            
    count = 1
print(result)

Buggy submission (verdict: Runtime Error):
a,b = map(int, input().split())
j = -1
for t in range(1009):
    if int(t*0.08) == a and int(t*0.1) == b:
        j = t
        break

print(j)

Buggy submission (verdict: Runtime Error):
n, a, b = map(int, input().split())
    
l = ""
flag = True
count = 0
while True:
    if flag == True:
        for x in range(a):
            l += "b"
        flag = False
    else:
        for y in range(b):
            l += "r"
        flag = True

    if len(l) >= n:
        break
         
for c in l:
    if c == "b":
        count += 1

print(count)

Buggy submission (verdict: Runtime Error):
n, a, b = map(int, input().split())
    
l = ""
flag = True
count = 0
while True:
    if flag == True:
        for x in range(a):
            l += "b"
            if len(l) == n:
                break
        flag = False
    else:
        for y in range(b):
            l += "r"
            if len(l) == n:
                break
        flag = True

    if len(l) >= n:
        break
         
for c in l:
    if c == "b":
        count += 1

print(count)
Problem p02570 (python)

Fixed submission:
d, t, s = [list(map(int, s.split())) for s in open(0)][0]
if t >= d/s:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
2000 20 100
Problem p03053 (python)

Fixed submission:
def main():
    H, W = map(int, input().split())
    m = []
    m.append([True] * (W + 2))
    for _ in range(H):
        m.append([True] + [c == '#' for c in input()] + [True])
    m.append([True] * (W + 2))
    queue = []
    for i in range(1, H + 1):
        for j in range(1, W + 1):
            if m[i][j]:
                queue.append((i, j))
    ans = -1
    while queue:
        ans += 1
        tmp = []
        for x, y in queue:
            if not m[x - 1][y]:
                m[x - 1][y] = True
                tmp.append((x - 1, y))
            if not m[x + 1][y]:
                m[x + 1][y] = True
                tmp.append((x + 1, y))
            if not m[x][y - 1]:
                m[x][y - 1] = True
                tmp.append((x, y - 1))
            if not m[x][y + 1]:
                m[x][y + 1] = True
                tmp.append((x, y + 1))
        queue = tmp
    print(ans)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
_in = list(open(0))
h, w = list(map(int, _in[0].split()))

s = []
for i, y in enumerate(_in[1:]):
    for j, x in enumerate(y):
        if x == '#':
            s.append((i+1,j+1))

a = [[False]*(w+2)]
a += [[False] + [True]*w + [False] for _ in range(h)]
a += [[False]*(w+2)]
display(a)

ans = 0
while True:
    ns = []
    for i, j in s:
        a[i][j] = False

        if a[i-1][j]:
            ns.append((i-1, j))
        if a[i+1][j]:
            ns.append((i+1, j))
        if a[i][j-1]:
            ns.append((i, j-1))
        if a[i][j+1]:
            ns.append((i, j+1))
        
    if not ns:
        break
    s = ns
    ans += 1
    
print(ans)

Buggy submission (verdict: Runtime Error):
_in = list(open(0))
h, w = list(map(int, _in[0].split()))

s = []
for i, y in enumerate(_in[1:]):
    a.append([])
    for j, x in enumerate(y):
        if x == '#':
            s.append((i,j,0))

a = [[-1]*w for _ in range(h)]

while s:
    q, s = s[0], s[1:]
    if a[q[0]][q[1]] != -1:
        continue
    
    a[q[0]][q[1]] = q[2]
    ans = q[2]
    
    if q[0]>0:
        s.append((q[0]-1, q[1], q[2]+1))
    if q[0]<h-1:
        s.append((q[0]+1, q[1], q[2]+1))
    if q[1]>0:
        s.append((q[0], q[1]-1, q[2]+1))
    if q[1]<w-1:
        s.append((q[0], q[1]+1, q[2]+1))
        
print(ans)
Problem p02689 (python)

Fixed submission:
N,M=map(int, input().split())
yoi = []
for i in range(N):
  yoi.append(True)
H=list(map(int, input().split()))
for i in range(M):
  A,B=map(int, input().split())
  if H[A-1]<=H[B-1]: yoi[A-1]=False
  if H[B-1]<=H[A-1]: yoi[B-1]=False 
print(len([1 for x in yoi if x==True]))

Buggy submission (verdict: Runtime Error):
N,M=map(int, input().split())
yoi = []
for i in range(N):
  yoi.append(True)
H=list(map(int, input().split()))
for i in ranage(M):
  A,B=map(int, input().split())
  if H[A-1]<=H[B-1]: yoi[A-1]=False
  if H[B-1]<=H[A-1]: yoi[B-1]=False 
print(len([1 for x in yoi if x==True]))
Problem p02701 (python)

Fixed submission:
import numpy as np
N=int(input())
S_list = np.zeros(N)
#S_list = np.zeros(N,dtype=str)
e_list = "abcdefghijklmnopqrstuvwxyz"

for i in range(N):
  s = input()
  n = 0
  for k in range(len(s)):
    n = n + (e_list.index(s[k])+1)*(100**k)
  S_list[i] = n
print(len(np.unique(S_list)))

Buggy submission (verdict: Runtime Error):
N=int(input())
S_list = []
for i in range(N):
  s = str(input())
  if not (s in S_list):
#    S_list.append(s)
print(len(S_list))
Problem p02707 (python)

Fixed submission:
import numpy as np
N=int(input())
A_np = np.zeros(N)
A=list(map(int, input().split()))
for Ai in A:
  A_np[Ai-1] = A_np[Ai-1] + 1
for i in range(N):
  print('{:.0f}'.format(A_np[i]))

Buggy submission (verdict: Runtime Error):
N=int(input())
A=list(map(int, input().split()))
for i in [1:N+1]:
  print(len([1 for x in A if x==i]))
Problem p02723 (python)

Fixed submission:
S=input()
if(S[2]==S[3] and S[5]==S[4]):
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
S=map(int, input().split())
if S[2]==S[3] and S[4]==S[5]:
  print('Yes')
else:
  print('No')
Problem p02790 (python)

Fixed submission:
a,b=map(int, input().split())
ans = ""
for i in range(max([a,b])):
  ans = ans + str(min([a,b]))
print(ans)

Buggy submission (verdict: Runtime Error):
a,b=map(int, input().split())
ans = ""
for i in range(max([a,b])):
  ans = ans + min([a,b])
print(ans)
Problem p02831 (python)

Fixed submission:
import fractions
a,b=map(int, input().split())
print(round(a*b/fractions.gcd(a, b)))

Buggy submission (verdict: Runtime Error):
import fractions
a,b=map(int, input().split())
print(’{:.0f}’.format(a*b/fractions.gcd(a, b)))
Problem p02860 (python)

Fixed submission:
N=int(input())
S=str(input())
if N%2!=0:
  print('No')
elif S[0:round(N/2)]==S[round(N/2):N]:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
N=int(input())
S=str(input())
if N%2!=0:
  print('No')
elif S[0:N/2-1]==S[N/2:N-1]:
  print('Yes')
else:
  print('No')
Problem p02987 (python)

Fixed submission:
S=str(input())
if S[0]==S[1] and S[1]==S[2] and S[2]==S[3]:
  print('No')
elif S[0]==S[1] and S[2]==S[3]:
  print('Yes')
elif S[0]==S[2] and S[1]==S[3]:
  print('Yes')
elif S[0]==S[3] and S[1]==S[2]:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
S=str(input())
if S[0]==S[1] and S[2]==S[3]:
  print('Yes')
else if S[0]==S[2] and S[1]==S[3]:
  print('Yes')
else if S[0]==S[3] and S[1]==S[2]:
  print('Yes')
else:
  print('No')
Problem p03011 (python)

Fixed submission:
P,Q,R=map(int, input().split())
print(min([P+Q,Q+R,R+P]))

Buggy submission (verdict: Runtime Error):
a,b,c=map(int, input().split())
print(min([a+b,b+c,c+a])
Problem p03075 (python)

Fixed submission:
aru = False
antenas = []
for i in range(5):
  k=int(input())
  antenas.append(k)
k=int(input())
for i in range(5):
  for t in range(i,5):
    if abs(antenas[i]-antenas[t])>k:
      aru = True
if aru:
  print(':(')
else:
  print("Yay!")

Buggy submission (verdict: Runtime Error):
aru = False
antenas = []
for i in range(5):
  k=int(input())
  antenas.append(n)
k=int(input())
for i in range(4):
  if abs(antenas[i]-antenas[i+1])>k:
    aru = True
if aru:
  print(':(')
else:
  print("Yay!")
Problem p03242 (python)

Fixed submission:
S = str(input())
print( 100*(10-int(S[0])) + 10*(10-int(S[1])) + 1*(10-int(S[2])) )

Buggy submission (verdict: Runtime Error):
S=str(input())
if S[0]=='1':s[0]='9'
if S[0]=='9':s[0]='1'
if S[1]=='1':s[1]='9'
if S[1]=="9":s[1]="1"
if S[2]=='1':s[2]='9'
if S[2]=='9':s[2]='1'
print(s)

Buggy submission (verdict: Runtime Error):
S=str(input())
if S[0]=='1':S[0]='9'
if S[0]=='9':S[0]='1'
if S[1]=='1':S[1]='9'
if S[1]=='9':S[1]='1'
if S[2]=='1':S[2]='9'
if S[2]=='9':S[2]='1'
print(S)
Problem p03265 (python)

Fixed submission:
x1,y1,x2,y2=map(int, input().split())
print(x2+y1-y2,y2-x1+x2,x1-x2+x2+y1-y2,y1-y2+y2-x1+x2)

Buggy submission (verdict: Runtime Error):
x1,y1,x2,y2=map(int, input().split())
print(x2+y1-y2,y2-x1+x2,x1-x2+x3,y1-y2+y3)
Problem p03315 (python)

Fixed submission:
S=str(input())
k = 0
for i in range(4):
  if S[i] == '+':
    k = k + 1
  else:
    k = k - 1
print(k)

Buggy submission (verdict: Runtime Error):
S=str(input())
k = 0
for i in Range(S):
  if S[i] == '+':
    k = k + 1
  else:
    k = k - 1
print(k)
Problem p03774 (python)

Fixed submission:
def distance(a,b,c,d):
  return abs(a-c)+abs(b-d)

N,M=map(int, input().split())
Alist = []
Blist = []
for i in range(N):
  a,b=map(int, input().split())
  Alist.append(a)
  Blist.append(b)
Clist = []
Dlist = []
for i in range(M):
  c,d=map(int, input().split())
  Clist.append(c)
  Dlist.append(d)

for i in range(N):
  min_d = 10**10
  a = Alist[i]
  b = Blist[i]
  for k in range(M):
    c = Clist[k]
    d = Dlist[k]
    if min_d > distance(a,b,c,d):
      min_d = distance(a,b,c,d)
      kiroku = k
#    print(a,b,c,d,distance(a,b,c,d),min_d)
  print(kiroku+1)

Buggy submission (verdict: Runtime Error):
def distance(a,b,c,d):
  return abs(a-c)+abs(b-d)

N,M=map(int, input().split())
Alist = []
Blist = []
for i in range(N):
  a,b=map(int, input().split())
  Alist.append(a)
  Blist.append(b)
Clist = []
Dlist = []
for i in range(M):
  c,d=map(int, input().split())
  Clist.append(c)
  Dlist.append(d)

for i in range(N):
  min_d = 10*10
  a = Alist[i]
  for k in range(M):
    b = Blist[k]
    if min_d > distance(a[0],a[1],b[0],b[1]):
      min_d = distance(a[0],a[1],b[0],b[1])
      kiroku = k
  print(k)
Problem p03834 (python)

Fixed submission:
S=str(input())
print(S[0:5]+' '+S[6:13]+' '+S[14:19])

Buggy submission (verdict: Runtime Error):
S=str(input())
print(S[0:5]+' '+S[6:13]+' 'S[14:19])
Problem p02572 (python)

Fixed submission:
m = 10**9 + 7
n = int(input())
an = list(map(int, input().split()))
wa = []
total = 0
for i in reversed(range(1, len(an))):
    total = total + an[i]
    wa.append(total)
wa = sorted(wa, reverse=True)
ans = 0
for i in range(0, n-1):
#     print(an[i] * wa[i])
    ans = ans + an[i] * (wa[i]%m)
    ans = ans % m
print(ans)

Buggy submission (verdict: Runtime Error):
import numpy as np
m = 10**9 + 7
n = int(input())
an = list(map(int, input().split()))

an_np = np.array(an)
an_col = np.zeros((n-1,n-1))
summary = 0
zero = np.zeros((1,n-1))
for i in range(0, n-1):
    tmp = np.array(an_np[i+1: n])
    an_col[i] = np.append(tmp, zero)[:n-1]

print(int(sum(sum(np.multiply(an_np[:-1], an_col) % m)%m)%m))
Problem p02699 (python)

Fixed submission:
s, w = map(int, input().split())

if s <= w:
    print('unsafe')
else:
    print('safe')

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

count = 0
if  len(s) < 4:
    print(0)
else:
    for i in range(len(s) -4 + 1):
        for j in range(len(s) - 4 + 1 - i):
#             print(i, j + 4, s[i : j + 4 + i])
            if int(s[i : j + 4 + i]) % 2019 == 0:
                count+=1
#                 print(s[i : j + 4 + i])
    print(count)
Problem p02723 (python)

Fixed submission:
S = input()
if (S[2] == S[3]) and (S[4] == S[5]):
    print('Yes')
else:
    print('No')

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

An = list(map(int, input().split()))

node = [An[i+1] - An[i]  for i in range(len(An) - 1)]

node = node[:] + [k - An[n-1] + An[0]]

print(k - max(node))

Buggy submission (verdict: Runtime Error):
k, n = map(int, input().split())
 
An = list(map(int, input().split()))
 
mn = 0
Amax = max(An)
Amin = min(An)
for i in range(len(An)):
    cal = 0
    A = An[i:]  + An[:i]
    for i in range(len(A)-1):
        if A[i] == Amax and A[i+1] == Amin:
            cal += A[i+1] + k - A[i]
        elif A[i] == Amin and A[i+1] == Amax:
            cal += A[i] + k - A[i+1]
        elif A[i+1] >= A[i]:
            cal += A[i+1] - A[i]
        else:
            cal += A[i] - A[i+1]
        
        if mn > 0 and cal > mn:
            break
    
    if mn ==0 or mn > cal:
        mn = cal
        
rAn = An[:]
rAn.reverse()
for i in range(len(rAn)):
    cal = 0
    A = rAn[i:]  + rAn[:i]
    for i in range(len(A)-1):
        if A[i] == Amax and A[i+1] == Amin:
            cal += A[i+1] + k - A[i]
        elif A[i] == Amin and A[i+1] == Amax:
            cal += A[i] + k - A[i+1]
        elif A[i+1] >= A[i]:
            cal += A[i+1] - A[i]
        else:
            cal += A[i] - A[i+1]
            
        if mn > 0 and cal > mn:
            break
 
    if mn ==0 or mn > cal:
        mn = cal
print(mn)
Problem p02725 (python)

Fixed submission:
k, n = map(int, input().split())
 
An = list(map(int, input().split()))
 
node = [An[i+1] - An[i]  for i in range(len(An) - 1)]
 
node = node[:] + [k - An[n-1] + An[0]]
 
print(k - max(node))

Buggy submission (verdict: Runtime Error):
k, n = map(int, input().split())
 
An = list(map(int, input().split()))
 
mn = 0
Amax = max(An)
Amin = min(An)
for i in range(len(An)):
    cal = 0
    A = An[i:]  + An[:i]
    for i in range(len(A)-1):
        if A[i] == Amax and A[i+1] == Amin:
            cal += A[i+1] + k - A[i]
        elif A[i] == Amin and A[i+1] == Amax:
            cal += A[i] + k - A[i+1]
        elif A[i+1] >= A[i]:
            cal += A[i+1] - A[i]
        else:
            cal += A[i] - A[i+1]
        
        if mn > 0 and cal > mn:
            break
    
    if mn ==0 or mn > cal:
        mn = cal
        
rAn = An[:]
rAn.reverse()
for i in range(len(rAn)):
    cal = 0
    A = rAn[i:]  + rAn[:i]
    for i in range(len(A)-1):
        if A[i] == Amax and A[i+1] == Amin:
            cal += A[i+1] + k - A[i]
        elif A[i] == Amin and A[i+1] == Amax:
            cal += A[i] + k - A[i+1]
        elif A[i+1] >= A[i]:
            cal += A[i+1] - A[i]
        else:
            cal += A[i] - A[i+1]
            
        if mn > 0 and cal > mn:
            break
 
    if mn ==0 or mn > cal:
        mn = cal
print(mn)
k, n = map(int, input().split())

An = list(map(int, input().split()))

mn = 0
Amax = max(An)
Amin = min(An)
for i in range(len(An)):
    cal = 0
    A = An[i:]  + An[:i]
    for i in range(len(A)-1):
        if A[i] == Amax and A[i+1] == Amin:
            cal += A[i+1] + k - A[i]
        elif A[i] == Amin and A[i+1] == Amax:
            cal += A[i] + k - A[i+1]
        elif A[i+1] >= A[i]:
            cal += A[i+1] - A[i]
        else:
            cal += A[i] - A[i+1]
        
        if mn > 0 and cal > mn:
            break
    
    if mn ==0 or mn > cal:
        mn = cal
        
rAn = An[:]
rAn.reverse()
for i in range(len(rAn)):
    cal = 0
    A = rAn[i:]  + rAn[:i]
    for i in range(len(A)-1):
        if A[i] == Amax and A[i+1] == Amin:
            cal += A[i+1] + k - A[i]
        elif A[i] == Amin and A[i+1] == Amax:
            cal += A[i] + k - A[i+1]
        elif A[i+1] >= A[i]:
            cal += A[i+1] - A[i]
        else:
            cal += A[i] - A[i+1]
            
        if mn > 0 and cal > mn:
            break

    if mn ==0 or mn > cal:
        mn = cal
print(mn)
Problem p02754 (python)

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

n_div_ab = n // (a+b)
n_mod_ab = n % (a+b)
if a == 0:
    res = 0
elif n_mod_ab // a > 0:
    res = a
else:
    res = n_mod_ab

print(n_div_ab * a + res)

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

n_div_ab = n // (a+b)
n_mod_ab = n % (a+b)
if a == 0:
    res = 0
if n_mod_ab // a > 0:
    res = n_mod_ab // a * a
else:
    res = n_mod_ab
print(n_div_ab * a + res)

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

n_div_ab = n // (a+b)
n_mod_ab = n % (a+b)
if n_mod_ab // a > 0:
    res = n_mod_ab // a * a
else:
    res = n_mod_ab
print(n_div_ab * a + res)
Problem p02859 (python)

Fixed submission:
r = int(input())
print(r * r)

Buggy submission (verdict: Runtime Error):
N = int(input())
xy = []
for i in range(N):
    a, b = (int(x) for x in input().split())
    xy.append([a, b])
    
def distance(d, xy, i, j):
    return (
              (xy[i][0] - xy[j][0]) ** 2
            + (xy[i][1] - xy[j][1]) ** 2
        ) ** 0.5
 
import itertools
d = []
l1 = [x for x in range(N)]
for v in itertools.permutations(l1, N):
    l2 = list(v)
    d0 = []
    for c in range(N-1):
        i = l2[c]
        j = l2[c+1]
        d0.append(distance(d, xy, i, j))
    d.append(sum(d0))
 
print(sum(d) / len(d))