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

Fixed submission:
s = list( str( input() ) )
check = [ x == s[0] for x in s ]
if len( set(s) ) == 2 and sum( check ) == 2 :
   print( "Yes" )
else : 
   print( "No" )

Buggy submission (verdict: Runtime Error):
s = str( input() )
check = [ x == set(s)[0] for x in list(s) ]
if len( set(s) ) == 2 and sum( check ) == 2 :
   print( "Yes" )
else : 
   print( "No" )
Problem p03041 (python)

Fixed submission:
N, K = map( int, input().split() )
S = list( input() )
S[ K - 1 ] = S[ K - 1 ].lower()
print( "".join(S) )

Buggy submission (verdict: Runtime Error):
K = map( int, input().split() )
S = list( input() )
S[ K - 1 ] = S[ K - 1 ].lower
print( "".join(S) )

Buggy submission (verdict: Runtime Error):
N, K = map( int, input().split() )
S = str( input() )
S[ K - 1 ] = S[ K - 1 ].lower()
print( S )

Buggy submission (verdict: Runtime Error):
N, K = map( int, input().split() )
S = str( input() )
S[ K - 1 ] = S[ K - 1 ].lower
print( S )
Problem p03803 (python)

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

if A == 1 :
   A = 14
if B == 1 :
   B = 14

if A > B :
   print( "Alice" )
elif A < B :
   print( "Bob" )
else : 
   print( "Draw" )

Buggy submission (verdict: Runtime Error):
A, B = map( int, input().split() )
if A > B :
   print( "Alice" )
elseif A < B :
   print( "Bob" )
else : 
   print( "Draw" )
Problem p03834 (python)

Fixed submission:
s = list( map( str, input().split(",") ) )
print( s[0] + " " + s[1] + " " + s[2] )

Buggy submission (verdict: Runtime Error):
s = map( str, input().split(",") )
print( s[0] + " " + s[1] + " " + s[2] )
Problem p02847 (python)

Fixed submission:
S = str(input())

x = 0

if S == "MON":
    x += 6
elif S == "TUE":
    x += 5
elif S == "WED":
    x += 4
elif S == "THU":
    x += 3
elif S == "FRI":
    x += 2
elif S == "SAT":
    x += 1
elif S == "SUN":
    x += 7

print(x)

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

low = 0
high = 10 ** 10

for i in range(10 ** 9):

    if high - low == 1:
        if A * high + B * len(str(high)) <= X:
            print(high)
            break
        else:
            print(low)
            break

    if (high - low) % 2 == 0:
        N = (high - low) // 2 + low
        tmp = A * N + B * len(str(N))

        if tmp < X:
            low = N
        elif tmp > X:
            high = N
        elif tmp == X:
            print(N)
            break

    else:
        N = (high - low) / 2 + low
        floor = int(N)
        ceil = floor + 1

        tmp_floor = A * floor + B * len(str(floor))
        tmp_ceil = A * ceil + B * len(str(ceil))

        if tmp_floor < tmp_ceil < X:
            low = ceil
        elif X < tmp_floor < tmp_ceil:
            high = floor
        elif tmp_floor < X < tmp_ceil:
            low = floor
            high = ceil
        elif X == tmp_floor:
            print(N)
            break
        elif X == tmp_ceil:
            print(N)
            break
Problem p03127 (python)

Fixed submission:
N=int(input())
a_list=[]
a_list = list(map(int, input().split())) # "1 2 3"と入力
min_num=min(a_list)
nokori_list=[i%min_num for i in a_list if i%min_num!=0]
if len(nokori_list)==0:
    print(min_num)
else:    
    while len(nokori_list)!=0:
        if len(nokori_list)==0:
            answer=min_num
            break
        else:
            nokori_list.append(min_num)
            min_num=min(nokori_list)
            new_list=[i%min_num for i in nokori_list if i%min_num!=0]
            nokori_list=new_list
        answer=min_num
    print(answer)

Buggy submission (verdict: Runtime Error):
N=int(input())
a_list=[]
a_list = list(map(int, input().split())) # "1 2 3"と入力
min_num=min(a_list)
nokori_list=[i%min_num for i in a_list if i%min_num!=0]

if len(nokori_list)==0:
    print(min_num)
else:
    can_min=min(nokori_list)
    futuer_min=min_num%can_min
    while futuer_min>0:
        big=max(can_min,futuer_min)
        small=min(can_min,futuer_min)
        futuer_min=big%small
        if futuer_min==0:
            answer=small
            break
        answer=small
    print(answer)

Buggy submission (verdict: Runtime Error):
N=int(input())
a_list=[]
a_list = list(map(int, input().split())) # "1 2 3"と入力
min_num=min(a_list)
nokori_list=[i%min_num for i in a_list if i%min_num!=0]
answer=0
if len(nokori_list)==0:
    print(min_num)
else:
    can_min=min(nokori_list)
    futuer_min=min_num%can_min
    while futuer_min>0:
        big=max(can_min,futuer_min)
        small=min(can_min,futuer_min)
        futuer_min=big%small
        if futuer_min==0:
            answer=small
            break
    	answer=small
    print(answer)

Buggy submission (verdict: Runtime Error):
N=int(input())
a_list=[]
a_list = list(map(int, input().split())) # "1 2 3"と入力
min_num=min(a_list)
nokori_list=[i%min_num for i in a_list if i%min_num!=0]
answer=0
if len(nokori_list)==0:
    print(min_num)
else:
    can_min=min(nokori_list)
    futuer_min=min_num%can_min
    while futuer_min>0:
        big=max(can_min,futuer_min)
        small=min(can_min,futuer_min)
        futuer_min=big%small
        if futuer_min==0:
            answer=small
            break
    answer=small
    print(answer)
Problem p02777 (python)

Fixed submission:
S, T = input().split()
A, B = input().split()
U = input()

ans1 = int(A)
ans2 = int(B)
if S == U:
  ans1 = ans1 - 1
if T == U:
  ans2 = ans2 - 1

print(ans1, ans2)

Buggy submission (verdict: Runtime Error):
N, K = input().split()
P = input().split()
P.sort(reverse=True)
sum = 0
for k in range(int(K)):
  p = int(P[k])
  sum += (p / 2) + 0.5
print(sum)
Problem p02779 (python)

Fixed submission:
N = input()
A = input().split()
a = []
for s in A:
	a.append(int(s))
if len(set(a)) == len(a):
  print('YES')
else:
  print('NO')

Buggy submission (verdict: Runtime Error):
N, K = input().split()
P = input().split()
max_sum = 0
for i in range(int(N)-int(K) + 1):
  sum = 0
  for k in range(i, i + int(K)):
    print(k)
    p = int(P[k])
    sum += (p / 2) + 0.5
    if max_sum < sum:
      max_sum = sum
print(float(max_sum))
Problem p02880 (python)

Fixed submission:
N = int(input())
for i in range(1, 10):
  for j in range(1, 10):
    if (i * j == N):
      print('Yes')
      exit()
else:
  print('No')

Buggy submission (verdict: Runtime Error):
N = int(input())
for i in range(1, N + 1):
  	if (N % i == 0):
    	N = N // i
        break
else:
  print('No')
  exit()

for i in range(1, N + 1):
  if (N % i == 0):
    print('Yes')
    exit()
else:
  print('No')
  exit()
Problem p02881 (python)

Fixed submission:
N = int(input())
i = 1
ans = N
while (i ** 2 <= N):
  if (N % i == 0):
    ans = min(ans, N // i + i - 2)
  i += 1

print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
fac = []
for i in range(1, N**(1/2) + 1):
  if (N % i == 0 and N // i <= i):
    print(N // i + i - 2)
    exit()

Buggy submission (verdict: Runtime Error):
N = int(input())
fac = []
for i in range(1, N**(1/2) + 1):
  if (N % i == 0 and N // i <= i):
    print(N // i + i - 2)
    exit()
Problem p03038 (python)

Fixed submission:
import sys
input = sys.stdin.readline
N, M = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
sortsecond = lambda val: val[1]
x = [list(map(int, input().split())) for _ in range(M)]
x.sort(key=sortsecond)

i = 0
for j in range(M):
  times = x[-(j+1)][0]
  num = x[-(j+1)][1]
  while (times > 0):
    try:
      tmp = A[i]
    except IndexError:
      print(sum(A))
      exit()
    
    if (tmp < num):
      A[i] = num
    else:
      print(sum(A))
      exit()
    times -= 1
    i += 1

print(sum(A))

Buggy submission (verdict: Runtime Error):
import sys
import numpy as np
input = sys.stdin.readline
N, M = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
sortsecond = lambda val: val[1]
x = [list(map(int, input().split())) for _ in range(M)]
x.sort(key=sortsecond)

i = 0
for j in range(M):
  times = x[-(j+1)][0]
  num = x[-(j+1)][1]
  while (times > 0):
    try:
      tmp = A[i]
    except IndexError:
      print(sum(A))
      exit()
    
    if (tmp < num):
      A[i] = num
    else:
      print(sum(A))
      exit()
    times -= 1
    i += 1

print(sum(A))
Problem p03207 (python)

Fixed submission:
p = [int(input()) for i in range(int(input()))]
print(sum(p)-max(p)//2)

Buggy submission (verdict: Runtime Error):
print(sum(p)-max([int(input()) for i in range(int(input()))])//2)
Problem p03208 (python)

Fixed submission:
N, K = map(int, input().split())
h = sorted([int(input()) for _ in range(N)])
print(min([h[i+K-1]-h[i] for i in range(N - K + 1)]))

Buggy submission (verdict: Runtime Error):
N, K, *H = map(int, open(0).read().split())
H.sort()
a=float('inf')
for i in range(N-K+1):
    a=min(a,H[i+k-1]-H[i])
print(a)
Problem p03209 (python)

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


def pi(n):
    return 2**(n+1)-1


def ai(n):
    return 2**(n+2) - 3


def f(n, x):
    if n == 0:
        return 1
    else:
        if x == 1:
            return 0
        elif (1 < x) and (x <= 1 + ai(n-1)):
            return f(n - 1, x - 1)
        elif x == 2 + ai(n - 1):
            return pi(n - 1) + 1
        elif (2 + ai(n - 1) < x) and (x <= 2 + 2 * ai(n - 1)):
            return pi(n-1) + 1 + f(n-1, x-2-ai(n-1))
        elif x >= ai(n):
            return pi(n)


print(f(n, x))

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


def pi(n):
    return 2**(n+1)-1


def ai(n):
    return 2**(n+2) - 3


def f(n, x):
    if N == 0:
        return 0 if X <= 0 else 1
    elif (1 < x) and (x <= 1 + ai(n-1)):
        return f(n - 1, x - 1)
    elif x == 2 + ai(n - 1):
        return pi(n - 1) + 1
    elif (2 + ai(n - 1) < x) and (x <= 2 + 2 * ai(n - 1)):
        return pi(n-1) + 1 + f(n-1, x-2-ai(n-1))
    elif x >= ai(n):
        return pi(n)


print(f(n, x))

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


def pi(n):
    if n == 1:
        return 3
    return 2*pi(n-1)+1


def ai(n):
    if n == 1:
        return 5
    return 2*ai(n-1) + 3


def f(n, x):
    if x == 1:
        return 0
    elif (1 < x) and (x <= 1 + ai(n-1)):
        return f(n - 1, x - 1)
    elif x == 2 + ai(n - 1):
        return pi(n - 1) + 1
    elif (2 + ai(n - 1) < x) and (x <= 2 + 2 * ai(n - 1)):
        return pi(n-1) + 1 + f(n-1, x-2-ai(n-1))
    elif x == ai(n):
        return pi(n)


print(f(n, x))
Problem p02881 (python)

Fixed submission:
import sys
import os
import itertools

n = int(input())

def make_divisors(n):
    divisors = {}
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors[i] = n//i
            if i != n // i:
                divisors[i] = n//i

    return divisors

ans = make_divisors(n)
m = max(ans)
print( (m-1) + ans[m]-1)

Buggy submission (verdict: Runtime Error):
import sys
import os
import itertools

n = int(input())

def is_prime(n):
    for p in range(2, n):
        if n % p == 0:
            return p, n//p
        else:
            return 0, 0

a, b = is_prime(n)
if a:
    print((a-1)+(b-1))
else:
    print(n-1)
Problem p03307 (python)

Fixed submission:
# A - Multiple of 2 and N
# https://beta.atcoder.jp/contests/abc102/tasks/abc102_a

# A_Multiple_of_2_and_N.py

N = int(input())

if N == 1:
    print(2)
elif N%2 == 0:
    print(N)
else:
    print(N*2)

Buggy submission (verdict: Runtime Error):
# C - Linear Approximation
# https://beta.atcoder.jp/contests/abc102/tasks/arc100_a

# C_Linear_Approximation.py

N = int(input())
a = list(map(int, input().strip().split(" ")))

for i in range(N):
    a[i] = a[i] - (i+1)

a.sort()
if N % 2 != 0:
    mid = (N-1)//2
else:
    mid = N // 2 
b = a[mid]

sadness_left = b * mid - sum(a[:mid])
sadness = sum(a) - b * N + sadness_left * 2

print(sadness)

# 中央値を取るのがみそ

Buggy submission (verdict: Runtime Error):
# C - Linear Approximation
# https://beta.atcoder.jp/contests/abc102/tasks/arc100_a

# C_Linear_Approximation.py

# 7
# 1 1 1 1 2 3 4
#import sys

N = int(input())
a = list(map(int, input().strip().split(" ")))

for i in range(N):
    a[i] = a[i] - (i+1)

a.sort()
if N % 2 != 0:
    mid = (N-1)//2
else:
    mid = N // 2 -1
b = a[mid]

sadness_left = b * mid - sum(a[:mid])
sadness = sum(a) - b * N + sadness_left * 2

print(sadness)
Problem p03327 (python)

Fixed submission:
# https://beta.atcoder.jp/contests/abc099/tasks/abc099_a
# A - ABD

# A_ABD.py

N = int(input())

C_or_D = (N-1) // 999


name = ""

if C_or_D == 0:
    name += "ABC"
    #n = N
elif C_or_D == 1:
    name += "ABD"
    #n = '{0:03d}'.format(N - 999)

#ame += str(n)

print(name)

Buggy submission (verdict: Runtime Error):
# https://beta.atcoder.jp/contests/abc099/tasks/abc099_a
# A - ABD

# A_ABD.py

N = int(input())

C_or_D = (N-1) // 999


name = ""

if C_or_D == 0:
    name += "ABC"
    #n = N
elif C_or_D == 1:
    name += "ABD"
    #n = '{0:03d}'.format(N - 999)

name += str(n)

print(name)
Problem p02793 (python)

Fixed submission:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
n=int(input())
a=[int(x) for x in input().split()]
mod=10**9+7
lcm=1
from fractions import gcd
for ai in a:
    lcm=ai*lcm//gcd(ai,lcm)
ans=0
for ai in a:
    ans+=lcm//ai
print(ans%mod)

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python
# -*- coding: utf-8 -*-
n=int(input())
a=[int(x) for x in input().split()]
mod=10**9+7
b=[]
lcm=1
from math import gcd
for ai in a:
    lcm=ai*lcm//gcd(ai,lcm)
ans=0
for ai in a:
    ans+=lcm//ai
    ans%=mod
print(ans)

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python
# -*- coding: utf-8 -*-
n=int(input())
a=[int(x) for x in input().split()]
mod=10**9+7
b=[]
lcm=1
from math import gcd
for ai in a:
    lcm=ai*lcm//gcd(ai,lcm)
ans=0
for ai in a:
    ans+=lcm//ai
    ans%=mod
print(ans)
Problem p02984 (python)

Fixed submission:
n=int(input())
dam=[int(x) for x in input().split()]
yama=[0]*n
dam_sum=sum(dam)//2
diff=0
if n in (1,2):
    for j in range(n):
        diff=0
        for i in range(n):
            if i%2==0:
                continue
            diff+=dam[(i+j)%n]
        yama[j]=dam_sum - diff
        yama[j]*=2
else:
    diff_same=0
    for i in range(n):
            if i%2==0:
                continue
            diff_same+=dam[(i)%n]
    yama[0]=dam_sum - diff_same
    yama[0]*=2
    diff_odd=0
    for i in range(n):
            if i%2==0:
                continue
            diff_odd+=dam[(i+1)%n]
    yama[1]=dam_sum - diff_odd
    yama[1]*=2
    for j in range(2,n):
        if j%2==0:
            diff_same-=dam[(j-1)%n]
            diff_same+=dam[(j-2)%n]
            yama[j]=dam_sum - diff_same
        else:
            diff_odd-=dam[(j-1)%n]
            diff_odd+=dam[(j-2)%n]
            yama[j]=dam_sum - diff_odd
        yama[j]*=2
print(" ".join([str(x) for x in yama]))

Buggy submission (verdict: Runtime Error):
import numpy as np
n=int(input())
dam=[int(x)*2 for x in input().split()]
a=[[0]*n for x in range(n)]
for i in range(n):
    a[i][i],a[i][(i+1)%n]=1,1
a=np.array(a)
dam=np.array(dam)
ans=np.linalg.solve(a,dam)
print(" ".join([str(int(ans[i])) for i in range(n)]))
Problem p03250 (python)

Fixed submission:
a,b,c=[int(x) for x in input().split()]
print(max(a,b,c)*10+a+b+c-max(a,b,c))

Buggy submission (verdict: Runtime Error):
a,b,c=[int(x) for x in input()]
print(max(a,b,c)*10+a+b+c-min(a,b,c))
Problem p03317 (python)

Fixed submission:
n,k=[int(x) for x in input().split()]
a=[int(x) for x in input().split()]
import math
print(math.ceil((len(a)-1)/(k-1)))

Buggy submission (verdict: Runtime Error):
n,k=[int(x) for x in input().split()]
a=[int(x) for x in input().split()]
index1=a.index(1)
if k>=index1+1 or n-(index1+1)<=k:
    print(round((len(a)-1)/(k-1)))
else:
    ans=float("inf")
    for i in range(k):
        ans=min(ans,1+round((index1+1-k+i)/k)+round(n-(index1+1+i))/k))
    print(ans)
Problem p03075 (python)

Fixed submission:
a,b,c,d,e,k = [int(input()) for x in range(6)]
if e-a <= k:
    print("Yay!")
else:
    print(":(")

Buggy submission (verdict: Runtime Error):
a,b,c,d,e,k = [int(input()) for x in range()]
if e-a <= k:
    print("Yay!")
else:
    print(":(")
Problem p02859 (python)

Fixed submission:
n = int(input())

print(n * n)

Buggy submission (verdict: Runtime Error):
n = int(input())
s = input()
if(n % 2 == 1):
    print("No")
else:
    if (s[:(n//2)] == s[(n//2):]):
        print("Yes")
    else:
        print("No")
Problem p02862 (python)

Fixed submission:
import math

# 有理数型をインポート

# 組合せの総数
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n
 
    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]
 
    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot
 
    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])
 
    return result


X, Y = (int(i) for i in input().split())

i = (2*X-Y)//3
j = (2*Y-X)//3

if(  i < 0 or j < 0 or (2*X-Y)%3!=0 or (2*Y-X)%3!=0 ):
    print(0)
else:
    print(cmb(i+j, i) % 1000000007)

Buggy submission (verdict: Runtime Error):
import math

# 有理数型をインポート

# 組合せの総数
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n
 
    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]
 
    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot
 
    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])
 
    return result


X, Y = (int(i) for i in input().split())

i = (2*X-Y)//3
j = (2*Y-X)//3

if(  n < 0 or m < 0  ):
    print(0)
else:
    print(cmb(i+j, i) % 1000000007)

Buggy submission (verdict: Runtime Error):
import math

# 有理数型をインポート

# 組合せの総数
def calc(a, b, p):
    if (b == 0):
        return 1
    elif (b % 2 == 0):
        d = calc(a, b // 2, p)
        return (d * d) % p
    else:
        return (a * calc(a, b - 1, p)) % p

X, Y = (int(i) for i in input().split())

i = (2*X-Y)//3
j = (2*Y-X)//3

if(  ((2*X-Y)%3)!=0 or (2*Y-X)%3!=0  ):
    print(0)
else:
    print(calc(i+j, i, 1000000007))

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

def combinations_count(n, r):
    ''' 組み合わせ '''
    return factorial(n) // (factorial(n - r) * factorial(r))

X, Y = (int(i) for i in input().split())

i = (2*X-Y)//3
j = (2*Y-X)//3

if(  ((2*X-Y)%3)!=0 or (2*Y-X)%3!=0  ):
    print(0)
else:
    print(combinations_count(i+j, i))

Buggy submission (verdict: Runtime Error):
import math


X, Y = (int(i) for i in input().split())

i = (2*X-Y)//3
j = (2*Y-X)//3

if(  ((2*X-Y)%3)!=0 or (2*Y-X)%3!=0  ):
    print(0)
else:
    print( (math.factorial(i+j)/math.factorial(i)/math.factorial(j) ) % 1000000007 )

Buggy submission (verdict: Runtime Error):
import math


X, Y = (int(i) for i in input().split())

i = (2*X-Y)//3
j = (2*Y-X)//3

if(  ((2*X-Y)%3)!=0 or (2*Y-X)%3!=0  ):
    print(0)
else:
    print(math.factorial(i+j)/math.factorial(i)/math.factorial(j))
Problem p03038 (python)

Fixed submission:
n, m = (int(i) for i in input().split())
a = list(map(int, input().split()))
bc = [list(map(int, input().split())) for _ in range(m)]
a.sort()
bc.sort(key=lambda x:x[1], reverse=True)

# print(a)
# print(bc)

index = 0
break_flag = False

for i in range(m):
    for j in range(bc[i][0]):
        if (index < n):
            if(a[index] < bc[i][1]):
                a[index] = bc[i][1]
                index += 1
                # print(a)
            else:
                break_flag = True
                break
        else:
            break_flag = True
            break
    if  break_flag:
        break
print(sum(a))

Buggy submission (verdict: Runtime Error):
n, m = (int(i) for i in input().split())
a = list(map(int, input().split()))
bc = [list(map(int, input().split())) for _ in range(m)]
a.sort()
bc.sort(key=lambda x:x[1], reverse=True)

print(a)
print(bc)

index = 0
break_flag = False

for i in range(m):
    for j in range(bc[i][0]):
        if(a[index] < bc[i][1] and index < n):
            a[index] = bc[i][1]
            index += 1
            print(a)
        else:
            break_flag = True
            break
    if  break_flag:
        break
print(sum(a))

Buggy submission (verdict: Runtime Error):
n, m = (int(i) for i in input().split())
a = list(map(int, input().split()))
bc = [list(map(int, input().split())) for _ in range(m)]
a.sort()
bc.sort(key=lambda x:x[1], reverse=True)
# print(a)
# print(bc)

index = 0
break_flag = False

for i in range(m):
    for j in range(bc[i][0]):
        if(a[index] < bc[i][1]):
            a[index] = bc[i][1]
            index += 1
            # print(a)
        else:
            break_flag = True
            break
    if  break_flag:
        break
print(sum(a))
Problem p03127 (python)

Fixed submission:
N = int(input())
A = list(int(i) for i in input().split())

A.sort()


if((A[1] - A[0]) == 0):
    min_HP = A[0]
    print(min_HP)
else:
    min_HP = A[1] - A[0]
    while((A[1] - A[0]) > 0):
        A.insert(0, A[1] - A[0])
        A.sort()
        if((A[1] - A[0]) == 0):
            break
        min_HP = A[1] - A[0]

    # そのループでまだmin_HPが更新されていない
    while(True):
        min_flag = False
        for a in A:
            if ((a % min_HP) < min_HP and (a % min_HP) > 0):
                min_HP = a % min_HP
                min_flag = True
        if( min_HP > 0 and min_flag ):
            continue
        else:
            break
    print(min_HP)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(int(i) for i in input().split())

A.sort()


if((A[1] - A[0]) == 0):
    min_HP = A[0]
    print(min_HP)
else:
    min_HP = A[1] - A[0]
    while((A[1] - A[0]) > 0):
        A.insert(0, A[1] - A[0])
        A.sort()
        if((A[1] - A[0]) == 0):
            break
        min_HP = A[1] - A[0]

    # そのループでまだmin_HPが更新されていない
    min_flag = False
    while(True):
        for a in A:
            if ((a % min_HP) < min_HP and (a % min_HP) > 0):
                min_HP = tmp_min
                min_flag = True
        if( min_HP > 0 and min_flag ):
            continue
        else:
            break
    print(min_HP)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(int(i) for i in input().split())

A.sort()


if((A[1] - A[0]) == 0):
    min_HP = A[0]
else:
    min_HP = 0
    while((A[1] - A[0]) > 0):
        A.insert(0, A[1] - A[0])
        A.sort()
        if((A[1] - A[0]) == 0):
            break
        min_HP = A[1] - A[0]

tmp_min = min_HP
for a in A:
    if ((a % tmp_min) < min_HP and (a % tmp_min) > 0):
        min_HP = tmp_min

print(min_HP)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(int(i) for i in input().split())

A.sort()


if((A[1] - A[0]) == 0):
    min_HP = A[0]
else:
    min_HP = 0
    while((A[1] - A[0]) > 0):
        A.insert(0, A[1] - A[0])
        A.sort()
        if((A[1] - A[0]) == 0):
            break
        min_HP = A[1] - A[0]

tmp_min = min_HP
for a in A:
    if ((a % tmp_min) < min_HP):
        min_HP = tmp_min

print(min_HP)