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

Fixed submission:
k,x = list(map(int, input().split()))
posi = [str(p) for p in range(x-k+1, x+k)]
print(' '.join(posi))

Buggy submission (verdict: Runtime Error):
k,x = list(map(int, input().split()))
posi = [p for p in range(x-k+1, x+k-1)]
print(' '.join(posi))
Problem p02947 (python)

Fixed submission:
from operator import mul
from functools import reduce
def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

N = int(input())
str_dict = {}
for n in range(N):
  l = ''.join(sorted(input()))
  if l in str_dict:
    str_dict[l] += 1
  else:
    str_dict[l] = 1
print(sum([cmb(v,2) if v>= 2 else 0 for v in str_dict.values()]))

Buggy submission (verdict: Runtime Error):
from operator import mul
from functools import reduce
def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

N = int(input())
str_dict = {}
for n in range(N):
  l = ''.join(sorted(input()))
  if l in str_dict:
    str_dict[l] += 1
  else:
    str_dict[l] = 1
print(sum([cmb(v,2) for v in str_dict.values() if v >= 2 else 0]))

Buggy submission (verdict: Runtime Error):
from operator import mul
from functools import reduce
def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

N = int(input())
str_dict = {}
for n in range(N):
  l = ''.join(sorted(input()))
  if l in str_dict:
    str_dict[l] += 1
  else:
    str_dict[l] = 1
print(sum([cmb(v,2) for v in str_dict.values()]))
Problem p03369 (python)

Fixed submission:
s = input()
cnt = 0
for c in s:
  if c == 'o':
    cnt += 1
print(700 + cnt*100)

Buggy submission (verdict: Runtime Error):
s = input()
cnt = 0
for c in s:
  if c == 'o':
    cnt++
print(700 + cnt*100)
Problem p03370 (python)

Fixed submission:
N, X = map(int, input().split())
m = [int(input()) for i in range(N)]
 
X -= sum(m)
if X > 0:
	print( N + X//min(m))
else:
  print(N)

Buggy submission (verdict: Runtime Error):
N X = map(int, input().split())
m = [int(input()) for i in range(N)]

X -= sum(m)
if X > 0:
	print( N + X//min(m))
else:
  print(N)
Problem p03760 (python)

Fixed submission:
o = list(input())
e = list(input())
j = 0
k = 0
ans = ""
for i in range(0, len(o) + len(e)):
    if i%2 == 0:
        ans += o[j]
        j += 1
    else:
        ans += e[k]
        k += 1
print(ans)

Buggy submission (verdict: Runtime Error):
o = input().split("")
e = input().split("")
j = 0
k = 0
ans = ""
for i in range(len(o) + len(e)):
Problem p03761 (python)

Fixed submission:
n = int(input())
s = [list(input()) for i in range(n)]
ans = sorted(list(set(s[0])))
numbers = [100 for i in range(len(ans))]
for i in range(n):
  for j in range(len(ans)):
    numbers[j] = min(numbers[j], s[i].count(ans[j]))
ret = ""
for i in range(len(ans)):
  ret += ans[i]*numbers[i]
print(ret)

Buggy submission (verdict: Runtime Error):
n = int(input())
ans = sorted(list(input()))
count = [50 for i in range(len(ans))]
s = [list(input()) for i in range(1,n)]
for i in range(1,n):
  for j in range(len(ans)):
    count[j] = s[i].count(ans[j])
for i in range(len(ans)):
  ret += ans[j]*count[j]
print(ret)

Buggy submission (verdict: Runtime Error):
n = int(input())
s = [sorted(list(input())) for i in range(n)]
rem  = s[0]
for i in range(1,n):
    tmp = rem[:]
    for j in s[i]:
        try:
            tmp.remove(j)
        except:
            pass
    for k in tmp:
        try:                                                                                                                                                                    
    rem.remove(k)
        except:
            pass
print(''.join(rem))
Problem p03762 (python)

Fixed submission:
in1 = list(input().split())
nx = int(in1[0])
ny = int(in1[1])
x = list(input().split())
y = list(input().split())
sx = sum([ int(x[i])*(2*i - nx + 1) for i in range(nx) ])
sy = sum([ int(y[i])*(2*i - ny + 1) for i in range(ny) ])
print(sx*sy%(10**9 + 7))

Buggy submission (verdict: Runtime Error):
in1 = list(input().split())
nx = in[0]
ny = in[y]
x = list(input().split())
y = list(input().split())
lx = sum([ x[i]*(2*i - x - 1) for i in range(nx) ])
ly = sum([ y[i]*(2*i - x - 1) for i in range(ny) ])
print(lx*ly%(10**9 + 7))
Problem p02887 (python)

Fixed submission:
N = int(input())
S = list(input())
i = 0
count = 0
while i < N-1:
    while S[i] == S[i+1]:
      i += 1
      if i == N-1:
        break
    if i == N-1:
      break
    count +=1
    i +=1
count +=1
print(count)

Buggy submission (verdict: Runtime Error):
N = int(input())
S = list(input())
i = 0
count = 0
while i <= N-1:
    while S[i] == S[i+1]:
      i += 1
      if i == N-1:
        break
    count +=1
    i +=1
    if i == N-1:
      count += 1
      break
print(count)

Buggy submission (verdict: Runtime Error):
N = int(input())
S = list(input())
i = 0
count = 0
while i <= N-1:
    while S[i] == S[i+1]:
      i += 1
    count +=1
    i +=1
    if i == N-1:
      count += 1
      break
print(count)

Buggy submission (verdict: Runtime Error):
N = int(input())
S = list(input())
i = 0
count = 0
while i < N:
    while S[i] == S[i-1]:
      i += 1
    count +=1
    i +=1
print(count)
Problem p02909 (python)

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

Buggy submission (verdict: Runtime Error):
today_wheather = input()
if today_wheather == "Sunny":
  print("Cloudy")
elif today_wheather == "Cloudy":
  print("Rainy")
else today_wheather == "Rainy":
  print("Sunny")

Buggy submission (verdict: Runtime Error):
today_wheather = input()
if today_wheather == "Sunny":
  print("Cloudy")
elif today_wheather == "Cloudy":
  print("Rainy")
else today_wheather == "Rainy":
  print("Sunny")

Buggy submission (verdict: Runtime Error):
today_wheather = input()
if today_wheather == "Sunny":
  print("Cloudy")
elif today_wheather == "Cloudy":
  print("Rainy")
else today_wheather == "Rainy":
  print("Sunny")
Problem p02910 (python)

Fixed submission:
Dance = input()
i = 0
flag = 0
for char in Dance:
  if i%2 == 1:
    if char == "R":
      flag = 1
      break
  else:
    if char == "L":
      flag = 1
      break
  i+=1
  
if flag == 0:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):

Dance = input()
i = 0
flag = 0
for char in Dance:
  if i%2 == 0:
    if char == R:
      flag = 1
      break
  else:
    if char == L:
      flag = 1
      break
  i+=1
  
if flag == 0:
  print("Yes")
else:
  print("No")
Problem p02934 (python)

Fixed submission:
def convert_Arc(x):
  return 1/x

N = int(input())
An = list(map(int,input().split()))
arcAn = list(map(convert_Arc,An))
sum = 0
for i in range(N):
  sum += arcAn[i]
Arc_sum = convert_Arc(sum)
print(Arc_sum)

Buggy submission (verdict: Runtime Error):
dif convert_Arc(x):
  return 1/x

N = int(input())
An = list(map(int,input().split()))
arcAn = map(convert_Arc,An)
sum = 0
for i in range(N):
  sum += arcAn[i]
Arc_sum = convert_Arc(sum)
print(Arc_sum)
Problem p02887 (python)

Fixed submission:
N=int(input())
S=list(input())
L=[]
if N!=1:
    for i in range(N-1):
        if S[i]!=S[i+1]:
            L.append(S[i+1])

print(len(L)+1)

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


while N!=1:
    for i in range(N-1):
        if S[i]==S[i+1]:
            S[i]='K'
            c=1
    if c==0:
        break
    while 'K' in S:
        S.remove('K')
        N-=1
        c=0
print(len(S))
Problem p03280 (python)

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

print((A-1)*(B-1))

Buggy submission (verdict: Runtime Error):
A=int(input())
B=int(input())
print((A-1)*(B-1))
Problem p03282 (python)

Fixed submission:
S=int(input())
K=int(input())

a=[]
while S !=0:
  s=S%10
  a.append(s)
  S //=10
m=0

for i in range(1,len(a)+1):
  if a[-i]!=1:
    if i>K:
      ans=1
    else:
      ans=i
    break
  else:
    ans=1

print(a[-ans])

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

a=[]
while S !=0:
  s=S%10
  a.append(s)
  S //=10
m=0

for i in range(1,len(a)+1):
  if a[-i]!=1:
    ans=i
    break

print(a[-ans])

Buggy submission (verdict: Runtime Error):
S=int(input())
K=int(input())
a=[]
while S !=0:
  s=S%10
  a.append(s)
  S //=10
m=0
for i in range(1,len(a)+1):
  m += a[-i]*5000000000000000
  if m>=K:
    ans=i
    break
print(a[-ans])
Problem p03284 (python)

Fixed submission:
a=list(map(int, input().split()))
n=a[0]
k=a[1]
if n%k==0:
    print('0')
else:
    print('1')

Buggy submission (verdict: Runtime Error):
n=a[0]
k=a[1]
if n%k==0:
    print('0')
else:
    print('1')
Problem p03455 (python)

Fixed submission:
a, b=(int(i) for i in input().split())
c=a*b
if c%2==1:
  print('Odd')
else:
  print('Even')

Buggy submission (verdict: Runtime Error):
l=map(int,input().split())
c=l[0]*l[1]
if c%2==1:
  print('Odd')
else:
  print('Even')

Buggy submission (verdict: Runtime Error):
l=map(int,raw_input().split())
c=l[0]*l[1]
if c%2==1:
  print('Odd')
else:
  print('Even')

Buggy submission (verdict: Runtime Error):
l=map(int(),raw_input().split())
c=l[0]*l[1]
if c%2==1:
  print('Odd')
else:
  print('Even')

Buggy submission (verdict: Runtime Error):
l=map(int(),input().split())
c=l[0]*l[1]
if c%2==1:
  print('Odd')
else:
  print('Even')

Buggy submission (verdict: Runtime Error):
l=map(int(),input.split())
c=l[0]*l[1]
if c%2==1:
  print('Odd')
else:
  print('Even')

Buggy submission (verdict: Runtime Error):
l=map(str(),input.split())
c=l[0]*l[1]
if c%2==1:
  print('Odd')
else:
  print('Even')

Buggy submission (verdict: Runtime Error):
a=input()
b=input()
c=a*b
d=c%2
if d==1:
  print('Odd')
else:
  print('Even')
Problem p03493 (python)

Fixed submission:
k=input()
n=0
if int(k[0])==1:
    n+=1
if int(k[1])==1:
    n+=1
if int(k[2])==1:
    n+=1
print(n)

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

n=0
def power(figure):
    if figure%2==0:
        return True
    else:
        return False

while len(list(filter(power,l)))==N:
    n+=1
    k=map(lambda x: x/2,l)
    l=list(k)


print(n)

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

n=0
def power(figure):
    if figure%2==0:
        return True
    else:
        return False

while len(list(filter(power,l)))==N:
    n+=1
    k=map(lambda x: x/2,l)
    l=list(k)


print(n)
Problem p03059 (python)

Fixed submission:
a, b, t = map(int, input().split())
print(int(((t + 0.5) // a) * b))

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

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

rs, ls = [0], [0]
for i in range(n-1):
  rs.append(gcd(rs[i], a[i]))
  ls.append(gcd(ls[i], a[-i-1]))

print(max(gcd(r, l) for r, l in zip(rs, ls[::-1])))
Problem p03062 (python)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
abs_a = list(map(abs, a))
print(sum(abs_a) if len([i for i in a if i < 0]) % 2 == 0 else sum(abs_a) - 2 * min(abs_a))

Buggy submission (verdict: Runtime Error):
n = int(input())
a = map(int, input().split()
abs_a = list(map(abs, a)))
print(sum(abs_a) if len([i for i in a if i < 0]) % 2 == 0 else sum(abs_a) - 2 * min(a))

Buggy submission (verdict: Runtime Error):
n = int(input())
a = map(int, input().split())
print(sum(a) - 2 * min(a))
Problem p03076 (python)

Fixed submission:
from math import ceil
ts = [int(input()) for _ in range(5)]
m = 10 - min([t % 10 for t in ts if not t % 10 == 0] + [10])
tss = [ceil(t / 10) * 10 for t in ts]
print(sum(tss) - m)

Buggy submission (verdict: Runtime Error):
from math import ceil
ts = [int(input()) for _ in range(5)]
m = 10 - min([t % 10 for t in ts if not t % 10 == 0])
tss = [ceil(t / 10) * 10 for t in ts]
print(sum(tss) - m)
Problem p03251 (python)

Fixed submission:
H, M, X, Y = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
 
r = any(all(i < z for i in x) and all(i >= z for i in y) for z in range(X+1, Y+1))
print("No War" if r else "War")

Buggy submission (verdict: Runtime Error):
H, M, X, Y = map(int, input().split())
x = map(int, input().split())
y = map(int, input().split())
for z in range(x+1, y+1):
  r = any(i < z for i in x) and any(i < z for i in y)
  if r:
    print("No War")
    break
  else:
    print("War")
Problem p03359 (python)

Fixed submission:
a, b = map(int, input().split())
print(a if a <= b else a - 1)

Buggy submission (verdict: Runtime Error):
a, b, c = sorted(map(int, input().split()), reverse=True)
k = int(intput())
print(a*2**k + b + c)
Problem p03360 (python)

Fixed submission:
a, b, c = sorted(map(int, input().split()), reverse=True)
k = int(input())
print(a*2**k + b + c)

Buggy submission (verdict: Runtime Error):
a, b, c = sorted(map(int, input().split()), reverse=True)
k = int(intpu())
print(a*2**k + b + c)
Problem p03386 (python)

Fixed submission:
a, b, k = map(int, input().split())
if a + k > b:
  a_k = b
else:
  a_k = a + k

if b - k < a:
  b_k = a
else:
  b_k = b - k
  
if a == b:
  a_k = a + 1
  b_k = b + 1

result = list(set([i for i in range(a, a_k)] + [i for i in range(b_k + 1, b + 1)]))
result.sort()
for n in result:
  print(n)

Buggy submission (verdict: Runtime Error):
a, b, k = map(int, input().split())
if a + k >= b:
  a_k = b
else:
  a_k = a + k

if b - k <= 0:
  b_k = a
else:
  b_k = b - k


result = sort(list(set([i for i in range(a, a_k + 1)] + [i for i in range(b_k, b + 1)])))
for n in result:
  print(n)
Problem p03387 (python)

Fixed submission:
n = list(map(int, input().split()))
print((max(n)*3-sum(n))//2 if (max(n) + sum(n)) % 2 == 0 else ((max(n)+1)*3-sum(n))//2)

Buggy submission (verdict: Runtime Error):
n = map(int, input().split())
print((max(n)*3-sum(n))/2 if (sum(n)+max(n))%2 == 0 else ((max(n)+1)*3-sum(n))/2)
Problem p03544 (python)

Fixed submission:
def fib(n):
   a, b = 2, 1
   for i in range(n):
     a, b = b, a+b
   print(b)
 
fib(int(input())-1)

Buggy submission (verdict: Runtime Error):
def fib(n):
   a, b = 2, 1
   for i in range(n):
     a, b = b, a+b
    print(b)

fib(int(input())-1)
Problem p03624 (python)

Fixed submission:
a = sorted(set([chr(i) for i in range(97, 97+26)]) - set(list(input())))
print(a[0] if a != [] else None)

Buggy submission (verdict: Runtime Error):
print(sorted(set([chr(i) for i in range(97, 97+26)]) - set(list(input())))[0])
Problem p03712 (python)

Fixed submission:
h, w = map(int, input().split())
a = ["#"*(w+2)] + ["#" + input() + "#" for i in range(h)] + ["#"*(w+2)]
for s in a:
  print(s)

Buggy submission (verdict: Runtime Error):
h, w = map(int, input().split())
a = ["#"*(w+2)] + ["#" + input() + "#" for i in h] + ["#"*(w+2)]
for s in a:
  print(s)
Problem p03760 (python)

Fixed submission:
odd, even = input(), input()
p = "".join([o+e for o, e in zip(odd, even)])
if len(odd) != len(even):
  p += odd[-1]
print(p)

Buggy submission (verdict: Runtime Error):
print("".join([o, e for o, e zip(input(), input())]))
Problem p04011 (python)

Fixed submission:
N, K, X, Y = [int(input()) for i in range(4)]
print(X*K+Y*(N-K) if N-K > 0 else X*N)

Buggy submission (verdict: Runtime Error):
N, K, X, K = [int(input()) for i in range(4)]
print(X*K+Y*(N-K if N-K > 0 else 0))

Buggy submission (verdict: Runtime Error):
N, K, X, H = [int(input()) for i in range(4)]
print(X*K+Y*(N-K))
Problem p02995 (python)

Fixed submission:
import fractions
# input process
inputData = input().split()
A = int(inputData[0])
B = int(inputData[1])
C = int(inputData[2])
D = int(inputData[3])

C_q_num = (B // C) - (A // C)
if (A % C) == 0:
    C_q_num += 1
D_q_num = (B // D) - (A // D)
if (A % D) == 0:
    D_q_num += 1
CD_lcm = (C * D) // fractions.gcd(C, D)
CD_q_num = (B // CD_lcm) - (A // CD_lcm)
if (A % CD_lcm) == 0:
    CD_q_num += 1
print((B - A + 1) - C_q_num - D_q_num + CD_q_num)

Buggy submission (verdict: Runtime Error):
import math
# input process
inputData = input().split()
A = int(inputData[0])
B = int(inputData[1])
C = int(inputData[2])
D = int(inputData[3])

C_q_num = (B // C) - (A // C)
if (B % C) == 0:
    C_q_num += 1
D_q_num = (B // D) - (A // D)
if (B % D) == 0:
    C_q_num += 1
CD_lcm = (C * D) // math.gcd(C, D)
CD_q_num = (B // CD_lcm) - (A // CD_lcm)
if (B % CD_lcm) == 0:
    CD_q_num += 1
print((B - A + 1) - C_q_num - D_q_num + CD_q_num)

Buggy submission (verdict: Runtime Error):
import math
# input process
inputData = input().split()
A = int(inputData[0])
B = int(inputData[1])
C = int(inputData[2])
D = int(inputData[3])

C_q_num = (B // C) - (A // C)
D_q_num = (B // D) - (A // D)
CD_lcm = (C * D) // math.gcd(C, D)
CD_q_num = (B // CD_lcm) - (A // CD_lcm) + 1
print((B-A) - C_q_num - D_q_num + CD_q_num)
Problem p03030 (python)

Fixed submission:
# input
N = int(input())
SA = [str(input()) for i in range(N)]

# process
cities = list(set([x.split()[0] for x in SA]))
cities.sort()

for y in cities:
    each_SA = []
    for i in SA:
        if i.split()[0] == y:
            each_SA.append(i)
    each_points = [int(x.split()[1]) for x in each_SA]
    each_points.sort(reverse=True)
    for j in each_points:
        print(SA.index(y + ' ' + str(j)) + 1)

Buggy submission (verdict: Runtime Error):
# input
N = int(input())
SA = [str(input()) for i in range(N)]

# process
cities = list(set([x.split()[0] for x in SA]))
cities.sort()

for y in cities:
    each_SA = [i for i in SA if y in i]
    each_points = [int(x.split()[1]) for x in each_SA]
    each_points.sort(reverse=True)
    for j in each_points:
        print(SA.index(y + ' ' + str(j)) + 1)

Buggy submission (verdict: Runtime Error):
# input
N = int(input())
SA = [str(input()) for i in range(N)]

# process
cities = list(set([x.split()[0] for x in SA]))
cities.sort()
print(cities)

for y in cities:
    each_SA = [i for i in SA if y in i]
    each_points = [int(x.split()[1]) for x in each_SA]
    each_points.sort(reverse=True)
    for j in each_points:
        print(SA.index(y + ' ' + str(j)) + 1)
Problem p03047 (python)

Fixed submission:
Array = [int(x) for x in input().split()]
N = Array[0]
K = Array[1]

print(N-(K-1))

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

print(N-(K-1))
Problem p03059 (python)

Fixed submission:
from math import floor

# input process
inputData = input().split()
# A秒後
A = int(inputData[0])
# B枚ずつ
B = int(inputData[1])
# T+0.5秒後まで
T = int(inputData[2])

# calculation process
prodCount = int(floor((float(T) + 0.5) // float(A)))
biscuitTotal = prodCount * B

# output process
print(biscuitTotal)

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

# Common divisor
def gcd(x, y):
    if y == 0:
        return x
    else:
        return gcd(y, x % y) #再帰定義

def gcd_wrapper(x, y):
    if x >= y:
        return gcd(x, y)
    else:
        return gcd(y, x)

if N == 2:
    print(max(A))
else:
    CD = []
    CD_alt = []
    for index, array_val in enumerate(A):
        if index != 0:
            CD.append(gcd_wrapper(A[0], array_val))
        if index != 1:
            CD_alt.append(gcd_wrapper(A[1], array_val))
    sorted_CD = sorted(CD)
    sorted_CD_alt = sorted(CD_alt)
    print(max([max(sorted_CD[0:2]), max(sorted_CD_alt[0:2])]))

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

# Common divisor
def gcd(x, y):
    if y == 0:
        return x
    else:
        return gcd(y, x % y) #再帰定義

def gcd_wrapper(x, y):
    if x >= y:
        return gcd(x, y)
    else:
        return gcd(y, x)

if N == 2:
    print(max(A))
else:
    CD = []
    CD_alt = []
    for index, array_val in enumerate(A):
        if index != 0:
            CD.append(gcd_wrapper(A[0], array_val))
        if index != 1:
            CD_alt.append(gcd_wrapper(A[1], array_val))
    sorted_CD = sorted(CD)
    sorted_CD_alt = sorted(CD_alt)
    if sorted_CD[0] == sorted_CD[1]:
        result = sorted_CD[0]
    else:
        result = sorted_CD[1]
    if sorted_CD_alt[0] == sorted_CD_alt[1]:
        result_alt = sorted_CD_alt[0]
    else:
        result_alt = sorted_CD_alt[1]
    print(max([result, result_alt]))

Buggy submission (verdict: Runtime Error):
import heapq

# input
N = int(input())
A = [int(x) for x in input().split()]

# Common divisor
def gcd(x, y):
    if y == 0:
        return x
    else:
        return gcd(y, x % y)

CD = []
for i in A[1:]:
    if A[0] >= i:
        CD.append(gcd(A[0], i))
    else:
        CD.append(gcd(i, A[0]))


print(max(heapq.nsmallest(2, CD)))

Buggy submission (verdict: Runtime Error):
import heapq

# input
N = int(input())
A = [int(x) for x in input().split()]

# Common divisor
def gcd(x, y):
    if y == 0:
        return x
    else:
        return gcd(y, x % y) #再帰定義

CD = []
for i in A[1:]:
    if A[0] >= i:
        CD.append(gcd(A[0], i))
    else:
        CD.append(gcd(i, A[0]))


print(min(heapq.nlargest(2, CD)))

Buggy submission (verdict: Runtime Error):
import heapq

# input
N = int(input())
A = [int(x) for x in input().split()]

# N = 3
# A = [12, 15, 18]
# A = [random.randint(0, 1000000) for i in range(100)]
# process

# Common divisor
def gcd(x, y):
    if y == 0:
        return x
    else:
        return gcd(y, x % y) #再帰定義

CD = []
for i in A[1:]:
    if A[0] >= i:
        CD.append(gcd(A[0], i))
    else:
        CD.append(gcd(i, A[0]))


print(min(heapq.nlargest(2, CD)))
Problem p02971 (python)

Fixed submission:
from heapq import heappush, heappop

N = int(input())
A = [int(input()) for i in range(N)]
hq = []
for i in range(N):
    heappush(hq, -A[i])
max1 = -heappop(hq)
max2 = -heappop(hq)
ans = [0] * N
for i in range(N):
    if A[i] == max1:
        ans[i] = max2
    else:
        ans[i] = max1
print(*ans, sep="\n")

Buggy submission (verdict: Runtime Error):
from heapq import heappush, heappop

N = int(input())
A = [int(input()) for i in range(N)]
hq = []
for i in range(N):
    heappush(hq, -A[i])
max1 = -heappop(hq)
while True:
    max2 = -heappop(hq)
    if max2 != max1:
        break
ans = [0] * N
for i in range(N):
    if A[i] == max1:
        ans[i] = max2
    else:
        ans[i] = max1
print(*ans, sep="\n")
Problem p02995 (python)

Fixed submission:
from fractions import gcd

A, B, C, D = map(int, input().split())
C_div = B // C - (A - 1) // C
D_div = B // D - (A - 1) // D
CD = C * D // gcd(C, D)
CD_div = B // CD - (A - 1) // CD
print(B - A + 1 - C_div - D_div + CD_div)

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

A, B, C, D = map(int, input().split())
C_div = B // C - (A - 1) // C
D_div = B // D - (A - 1) // D
CD = C * D // gcd(C, D)
CD_div = B // CD - (A - 1) // CD
print(B - A + 1 - C_div - D_div + CD_div)
Problem p03494 (python)

Fixed submission:
ans = 10**9
N=int(input())
A=list(map(int,input().split()))
for i in A:
    p=0
    while i%2==0:
        i //= 2
        p += 1
    if p<ans:
        ans=p
print(ans)

Buggy submission (verdict: Runtime Error):
ans = 10**9
N=int(input())
A=list(map(int,input().split()))
for i in A:
    p=0
    while i%2==0:
        i //= 2
        p += 1
    if p<ans:
        ans=p
print(ans)a
Problem p04047 (python)

Fixed submission:
# encoding: utf-8

n = int(raw_input())
l = map(int, raw_input().split())
l.sort()
print sum(l[::2])

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

n, x = map(int, raw_input().split())

ac_bc = n - x
s = ac_bc / 3
l = ac_bc - s
print ac_bc + s * 3 + l * 3