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

Fixed submission:
S = input()

max_length = 0
for i in range(len(S)):
  if S[i] in "ACGT":
    if i == len(S) - 1:
      length = 1
    else:
      for j in range(i+1, len(S)):
        if S[j] in "ACGT":
          length = j - i + 1
        else:
          length = j - i
          break

    if length > max_length:
      max_length = length

print(max_length)

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

max_length = 0
for i in range(len(S)):
  if S[i] in "ACGT":
    if i == len(S) - 1:
      length = 1
    else:
      for j in range(i+1, len(S)):
        if S[j] in "ACGT":
          length = j - i + 1
        else:
          break

    if length > max_length:
      max_length = length

print(max_length)

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

length = 0
for i in range(len(S)):
  if S[i] in "ACGT":
    for j in range(i+1, len(S)):
      if S[j] in "ACGT":
        continue
      else:
        break
    if j - i > length:
      length = j - i

print(length)
Problem p03200 (python)

Fixed submission:
s = input()

answer = 0
black_count = 0
for i in range(len(s)):
    if s[i] == "B":
        black_count += 1
    else:
        answer += black_count

print(answer)

Buggy submission (verdict: Runtime Error):
from collections import Counter

n = int(input())
nums = sorted(list(map(int, input().split())), reverse=True)

num_map = Counter(nums)

answer = 0
for num in nums:
    pair = (1 << (num.bit_length())) - num

    if num_map[num] > 0 and num_map[pair]:
        if num == pair and num_map[num] > 1:
            answer += 1
            num_map[num] -= 2
        else:
            answer += 1
            num_map[num] -= 1
            num_map[pair] -= 1

print(answer)
Problem p03245 (python)

Fixed submission:
from functools import reduce
import math

n = int(input())
coord = [tuple(map(int, input().split())) for i in range(n)]

# parity check and get max
x, y = coord[0]
p = (x + y) & 1
limit = 0
for x, y in coord:
    if p != (x + y) & 1:
        print(-1)
        exit()
    lim = abs(x) + abs(y)
    if lim > limit:
        limit = lim

limit = round(math.log2(limit))
if p == 1:
    d = [2 ** i for i in reversed(range(limit + 1))]
else:
    d = [1] + [2 ** i for i in reversed(range(limit + 1))]

print(len(d))
print(reduce((lambda acc, dist: str(acc) + " " + str(dist)), d))

for x, y in coord:
    u = x + y
    v = x - y

    command = ""
    for i in range(len(d)):
        if u >= 0 and v >= 0:
            command += "R"
            u -= d[i]
            v -= d[i]
        elif u >= 0 > v:
            command += "U"
            u -= d[i]
            v += d[i]
        elif u < 0 <= v:
            command += "D"
            u += d[i]
            v -= d[i]
        elif u < 0 and v < 0:
            command += "L"
            u += d[i]
            v += d[i]

    print(command)

Buggy submission (verdict: Runtime Error):
n = int(input())
coordinates = []
distance = []

for i in range(n):
    coordinate = list(map(int, input().split()))
    coordinates.append(coordinate)
    distance.append(abs(coordinate[0]) + abs(coordinate[1]))

p = distance[0] & 1
for dist in distance:
    if p != dist & 1:
        print(-1)
        exit()

m = max(distance)
print(m)
print("1" + " 1" * (m - 1))

for i in range(n):
    result = "RL" * ((m - distance[i]) // 2)
    if coordinates[i][0] < 0:
        result += "L" * -coordinates[i][0]
    else:
        result += "R" * coordinates[i][0]
    if coordinates[i][1] < 0:
        result += "D" * -coordinates[i][1]
    else:
        result += "U" * coordinates[i][1]
    print(result)

Buggy submission (verdict: Runtime Error):
n = int(input())
coordinates = []
distance = []

for i in range(n):
    coordinate = list(map(int, input().split()))
    coordinates.append(coordinate)
    distance.append(abs(coordinate[0]) + abs(coordinate[1]))

p = distance[0] & 1
for dist in distance:
    if p != dist & 1:
        print(-1)
        exit()

m = max(distance)
print(m)
print("1" + " 1" * (m - 1))

for i in range(n):
    result = "RL" * ((m - distance[i]) // 2)
    if coordinates[i][0] < 0:
        result += "L" * -coordinates[i][0]
    else:
        result += "R" * coordinates[i][0]
    if coordinates[i][1] < 0:
        result += "D" * -coordinates[i][1]
    else:
        result += "U" * coordinates[i][1]
    print(result)
Problem p03246 (python)

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

nums1 = nums[0::2]
nums2 = nums[1::2]

bug1 = [0] * 1000000
bug2 = [0] * 1000000

for num in nums1:
    bug1[num] += 1

for num in nums2:
    bug2[num] += 1

max_v_1 = max(bug1)
max_i_1 = bug1.index(max_v_1)
max_v_2 = max(bug2)
max_i_2 = bug2.index(max_v_2)

if max_i_1 == max_i_2:
    bug1[max_i_1] = 0
    bug2[max_i_2] = 0
    sec_max_v_1 = max(bug1)
    sec_max_v_2 = max(bug2)
    print(n - min(max_v_1, max_v_2) - max(sec_max_v_1, sec_max_v_2))
else:
    print(n - max_v_1 - max_v_2)

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

nums1 = nums[0::2]
nums2 = nums[1::2]

bug1 = [0] * 100000
bug2 = [0] * 100000

for num in nums1:
    bug1[num] += 1

for num in nums2:
    bug2[num] += 1

max_v_1 = max(bug1)
max_i_1 = bug1.index(max_v_1)
max_v_2 = max(bug2)
max_i_2 = bug2.index(max_v_2)

if max_i_1 == max_i_2:
    bug1[max_i_1] = 0
    bug2[max_i_2] = 0
    sec_max_v_1 = max(bug1)
    sec_max_v_2 = max(bug2)
    print(n - min(max_v_1, max_v_2) - max(sec_max_v_1, sec_max_v_2))
else:
    print(n - max_v_1 - max_v_2)
Problem p03289 (python)

Fixed submission:
def isNotLower(s):
  return not (ord('a') <= ord(s) <= ord('z'))

S = input()

if S[0] != 'A':
  print("WA")
  exit()

if S[2:-1].count('C') != 1:
  print("WA")
  exit()

upper_limit = 2 # only 'A', 'C'
for s in S:
  if isNotLower(s):
    upper_limit -= 1

  if upper_limit < 0:
    print("WA")
    exit()

print("AC")

Buggy submission (verdict: Runtime Error):
def is_upper_case(s):
  return not (ord('a') <= ord(s) <= ord('z'))

S = input()

if S[0] != 'A':
  print("WA")
  exit()

if S[2:-1].count('C') != 1:
  print("WA")
  exit()

upper_num = map(is_upper_case, S).count(True)

if upper_num != 2: # expected only 'A', 'C'
  print("WA")
  exit()

print("AC")
Problem p03493 (python)

Fixed submission:
marbleNum = input().count("1")
print(marbleNum)

Buggy submission (verdict: Runtime Error):
input()
nums = input().split()
result = 18 # 制約 Ai < 10^9より
for num in nums:
  num = int(num)
  div_times = 0
  while (num & 1) == 0:
    num = num >> 1
    div_times += 1
  if div_times < result:
    result = div_times
print(result)

Buggy submission (verdict: Runtime Error):
input()
nums = input().split()
result = 18 # 制約 Ai < 10^9より
for num in nums:
  num = int(num)
  div_times = 0
  while (num & 1) == 0:
    num = num >> 1
    div_times += 1
  if div_times < result:
    result = div_times
print(result)
Problem p03244 (python)

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

even = []
odd = []

for index, i in enumerate(li):
    if index % 2 == 0:
        even.append(i)
    elif index % 2 != 0:
        odd.append(i)

from collections import Counter
so_ev = Counter(even).most_common(2)
so_od = Counter(odd).most_common(2)

if so_ev[0][0] == so_od[0][0]:
    if len(so_ev) == 1 and len(so_od) == 1:
        print(n - so_ev[0][1])
    else:
        print(min(n - so_ev[1][1] - so_od[0][1], n - so_ev[0][1] - so_od[1][1]))
else:
    print(n - so_ev[0][1] - so_od[0][1])

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

import collections
odd = collections.defaultdict(lambda : 0)
even = collections.defaultdict(lambda: 0)

for index, i in enumerate(li):
    if index % 2 == 0:
        even[i] += 1
    elif index % 2 != 0:
        odd[i] += 1

# odd = list(filter(lambda x: x % 2 != 0, li))
sorted_odd = [(k, odd[k]) for k in sorted(odd, key=odd.get, reverse=True)]
max_odd = sorted_odd[0]
# even = list(filter(lambda x: x % 2 == 0, li))
sorted_even = [(k, even[k]) for k in sorted(even, key=even.get, reverse=True)]
max_even = sorted_even[0]

if max_odd[0] == max_even[0] and len(sorted_odd) == 1 and len(sorted_even) == 1:
    print(int(n / 2))
elif max_odd[0] == max_even[0]:
    if len(sorted_odd) >= 2:
        print(int(n/2 - sorted_odd[1] + n/2 - max_even[1]))
    elif len(sorted_even) >= 2:
        print(int(n/2 - sorted_even[1] + n/2 - max_odd[1]))
else:
    print(int(n/2 - max_odd[1] + n/2 - max_even[1]))
Problem p03493 (python)

Fixed submission:
t=list(raw_input())
count=0
for i in t:
    if i == "1":
        count+=1
print count

Buggy submission (verdict: Runtime Error):
t=raw_input().split(“”)
count=0
for i in t:
    if i == “1”:
        count+=1
print count
Problem p03494 (python)

Fixed submission:
raw_input()
t=map(int, raw_input().split(" "))
count=0

while True:
    flag=True
    for i in t:
        if i % 2 != 0:
            flag=False
    if not flag:
        break
    else:
        t = [x / 2 for x in t]
        count+=1
        
print count

Buggy submission (verdict: Runtime Error):
raw_input()
t=map(int, raw_input().split(" "))
count=0

while True:
    for i in t:
        flag=True
        if i % 2 != 0:
            flag=False
    if !flag:
        break
    else:
        t = [x / 2 for x in t]
        count+=1
        
print count
Problem p03282 (python)

Fixed submission:
s = input()
n = len(s)
k = int(input())
ans = "1"
for i in range(min(n, k)):
    ss = s[i]
    if ss != "1":
        ans = ss
        break
print(ans)

Buggy submission (verdict: Runtime Error):
s = input()
n = len(s)
k = int(input())
ans = "1"
for i in range(min(n, k)+1):
    ss = s[i]
    if ss != "1":
        ans = ss
        break
print(ans)

Buggy submission (verdict: Runtime Error):
s = input()
k = int(input())
ans = "1"
for i in range(k+1):
    ss = s[i]
    if ss != "1":
        ans = ss
        break
print(ans)
Problem p03285 (python)

Fixed submission:
n = int(input())
flag = False
for x in range(100):
    for y in range(100):
        if 4*x+7*y==n:
            flag = True
if flag:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
n = int(input())
flag = False
for x in range(100):
    for y in range(100):
        flag = (4*x+7*y==n)
if flag:
    print("Yes")
else
    print("No")
Problem p03361 (python)

Fixed submission:
h, w = input().split()
h = int(h)
w = int(w)
field = []
for _ in range(h):
    field.append(input())
    
ans = True
for i in range(h):
    for j in range(w):
        if field[i][j] == '#':
            temp = 1
            dd = [(1, 0), (-1, 0), (0, 1), (0, -1)]
            for ddd in dd:
                dx, dy = ddd
                nx, ny = i + dx, j + dy
                if nx >= 0 and nx < h and ny >= 0 and ny < w and field[nx][ny] == '#':
                    temp += 1
            if temp == 1:
                ans = False
                break

if ans:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
h, w = input().split()
h = int(h)
w = int(w)
field = []
for _ in range(h):
    field.append(input())
    
ans = True
for i in range(h):
    for j in range(w):
        if field[i][j] == '#':
            temp = 1
            dd = [(1, 0), (-1, 0), (0, 1), (0, -1)]
            for ddd in dd:
                dx, dy = ddd
                nx, ny = x + dx, y + dy
                if nx >= 0 and nx < h and ny >= 0 and ny < w and field[nx][ny] == '#':
                    temp += 1
            if temp == 1:
                ans = False
                break

if ans:
    print("Yes")
else:
    print("No")
Problem p03372 (python)

Fixed submission:
n, c = input().split()
n = int(n)
c = int(c)
x = [0]
v = [0]
gs1 = [0]
gs2 = [0]
gs3 = [0]
gs4 = [0]
s = 0
for i in range(n):
    xx, vv = input().split()
    xx = int(xx)
    vv = int(vv)
    x.append(xx)
    v.append(vv)
    s += vv
    f = s - xx
    gs1.append(max(gs1[-1], f))
    f = s - 2 * xx
    gs2.append(max(gs2[-1], f))
s = 0
for i in range(-1, -n - 1, -1):
    s += v[i]
    f = s - (c - x[i])
    gs3.append(max(gs3[-1], f))
    f = s - 2 * (c - x[i])
    gs4.append(max(gs4[-1], f))
ans = 0
for i in range(n + 1):
    ans = max(ans, gs1[i] + gs4[n - i], gs2[i] + gs3[n - i])
print(ans)

Buggy submission (verdict: Runtime Error):
#import sys
#lines = sys.stdin.readlines()
#lines = lines.split('\n')
n, c = input().split()
#n, c = lines[0].split()
n = int(n)
c = int(c)
x = [0]
v = [0]
sv = [0]
ssv = 0
for i in range(n):
    xx, vv = input().split()
#    xx, vv = lines[i + 1].split()
    xx = int(xx)
    vv = int(vv)
    x.append(xx)
    v.append(vv)
    ssv += vv
    sv.append(ssv)
ans = -10**15
for i in range(0, n + 1, 1):
    for j in range(-1, -n +  i - 1, -1):
        e1 = sv[i] - x[i]
        e2 = sv[-1] - sv[j - 1] - (c - x[j])
        e3 = e1 + e2 - x[i]
        e3 = e1 + e2 - (c - x[j])
        ans = max([ans, e1, e2, e3, e4])
print(ans)

Buggy submission (verdict: Runtime Error):
import sys
lines = sys.stdin.readlines()
lines = lines.split('\n')
#n, c = input().split()
n, c = lines[0].split()
n = int(n)
c = int(c)
x = [0]
v = [0]
sv = [0]
ssv = 0
for i in range(n):
#    xx, vv = input().split()
    xx, vv = lines[i + 1].split()
    xx = int(xx)
    vv = int(vv)
    x.append(xx)
    v.append(vv)
    ssv += vv
    sv.append(ssv)
ans = -10**15
for i in range(0, n + 1, 1):
    for j in range(-1, -n +  i - 1, -1):
        e1 = sv[i] - x[i]
        e2 = sv[-1] - sv[j - 1] - (c - x[j])
        e3 = e1 + e2 - x[i]
        e3 = e1 + e2 - (c - x[j])
        ans = max([ans, e1, e2, e3, e4])
print(ans)

Buggy submission (verdict: Runtime Error):
n,c=input().split()
n=int(n)
c=int(c)
x=[]
v=[]
e=[]
v_max=10**9
c_max=10**14
for _ in range(n):
    s = input().split()
    x.append(int(s[0]))
    v.append(int(s[1]))
    e.append(int(s[1])-int(s[0]))
ans=0
l=set()
while True:
    p = 0
    ee_max = 0
    for i in range(p, n):
        if i in l:
            continue
        ee = e[i]
        if ee > ee_max and max_ee > 0:
            p = i
            ee_max = ee
    if ee_max <= 0:
        break
    ans = ans + e[p]
    l.add(p)
    #for i in range(n):
    #    x[i] = min(abs(x[i]-x[p]), c-abs(x[i]-x[p]))
    #    e[i] = x[i] - v[i]
print(ans)
Problem p03377 (python)

Fixed submission:
a, b, c = input().split()
a = int(a)
b = int(b)
c = int(c)
if a <= c and a + b >= c:
    print("YES")
else:
    print("NO")

Buggy submission (verdict: Runtime Error):
a, b, x = input().split()
a = int(a)
b = int(b)
c = int(c)
if a <= x and a + b >= x:
    print("YES")
else:
    print("NO")

Buggy submission (verdict: Runtime Error):
function main()
    a, b, x = split(readline())
    a = parse(Int, a)
    b = parse(Int, b)
    x = parse(Int, x)    
    if a <= x && a + b >= x
        println("YES")
    else
        println("NO")
    end
end
main()
Problem p03543 (python)

Fixed submission:
N = int(input())
n=1
p=-1
for i in range(4):
    t= N % 10
    if p == t:
        n = n + 1
        if n == 3: break
    else:
        n = 1
    p=t
    N = int(N / 10)
ans = "Yes" if n == 3 else "No"
print(ans)

Buggy submission (verdict: Runtime Error):
N = input()
n=1
p=-1
for i in range(4):
    t= N % 10
    if p == t:
        n = n + 1
    p=t
    N = int(N / 10)
ans = "YES" if n >= 3 else "NO"
print(ans)
Problem p02909 (python)

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

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

Buggy submission (verdict: Runtime Error):
S==input()
if S=='Sunny':
  print('Cloudy')
elif S=='Cloudy':
  print('Rainy')
elif S=='Rainy':
  print('Sunny')

Buggy submission (verdict: Runtime Error):
S==input()
if S=='Sunny':
  print'Cloudy'
elif S=='Cloudy':
  print'Rainy'
elif S=='Rainy':
  print'Sunny'
Problem p02909 (python)

Fixed submission:
weather_forecast = {
	'Sunny': 'Cloudy',
	'Cloudy': 'Rainy',
	'Rainy': 'Sunny'
}
 
print(weather_forecast[input()])

Buggy submission (verdict: Runtime Error):
def solve():
  weather_dictionary = {
    'Sunny': 'Cloudy',
    'Coludy': 'Rainy',
    'Rainy': 'Sunny'
  }

  print(weather_dictionary[input()])
  

if __name__ == '__main__':
  solve()

Buggy submission (verdict: Runtime Error):
# 一日ごとに晴れ(Sunny)、くもり(Cloudy)、雨(Rainy)

weather_forecast {
	'Sunny': 'Cloudy',
	'Cloudy': 'Rainy',
	'Rainy': 'Sunny'
}

print(weather_forecast[intput()])
Problem p02945 (python)

Fixed submission:
a, b = [int(i) for i in input().split(' ')]
result = [a+b, a-b, a*b]
print(max(result))

Buggy submission (verdict: Runtime Error):
a, b = [int(i) for i in input().split(' ')]
result = [a+b, a-b, a*b]
print(result.max())

Buggy submission (verdict: Runtime Error):
a, b = [int(i) for i in input().split(' ')]
result = []
result.append(a + b)
result.append(a - b)
result.append(a * b)

print(result.max())
Problem p02899 (python)

Fixed submission:
n = int(input())
a = map(int,input().split())
f = {}
count = 1
for i in a:
  f[count] = i
  count+=1
inv_map = {v: k for k, v in f.items()}
[print(inv_map[i],end=' ') for i in range(1,n+1)]

Buggy submission (verdict: Runtime Error):
n = int(input())
a = map(int,input().split())
f = {}
count = 0
for i in a:
  count=+1
  f[count] = i
inv_map = {v: k for k, v in f.items()}
print inv_map[i] for i in range(n)
Problem p02952 (python)

Fixed submission:
N = int(input())
nm = len(str(N))-1
summ = 0
for i in range(nm):
    if i ==0:
      summ += 9
    elif i%2 ==0:
      summ += (10**(i+1)-10**(i))
if nm%2 == 0:
    summ += N-(10**nm)+1
print(summ)

Buggy submission (verdict: Runtime Error):
N = int(input())
nm = N//10
sum = 0
for i range(nm):
    if N%2 ==0:
        sum += (10**i-1)
if nm%2 != 0:
    sum += N-(10**nm)+1
Problem p02957 (python)

Fixed submission:
A, B = map(int,input().split())
K = (A+B)//2
if (A+B) % 2 == 0:
    print(K)
else:
    print('IMPOSSIBLE')

Buggy submission (verdict: Runtime Error):
A, B = input().strip()
K = (A+B)//2
if (A+B)%2 == 0:
    print (K)
else:
    print('IMPOSSIBLE')
Problem p02969 (python)

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

Buggy submission (verdict: Runtime Error):
N = int(input())
As = []
for i in range(N):
    As.append(int(input())
for j in range(N):
    instAs = As
    instAs.pop(j)
    print(max(instAs)
Problem p02971 (python)

Fixed submission:
import copy
N = int(input())
As = []
for i in range(N):
    As.append(int(input()))
maxA = max(As)
instA = As.copy()
instA.remove(maxA)
secA = max(instA)
for i in range(N):
    if As[i] == maxA:
        print(secA)
    else:
        print(maxA)

Buggy submission (verdict: Runtime Error):
import copy
N = int(input())
As = []
for i in range(N):
    As.append(int(input()))
for j in range(N):
    instAs = copy.copy(As)
    instAs.pop(j)
    print(max(instAs))import copy
N = int(input())
As = []
for i in range(N):
    As.append(int(input()))
maxA = max(As)
instA = copy.copy(As)
instA.remove(maxA)
secA = max(instA)
for i in range(N):
    if As[i] == maxA:
        print(secA)
    else:
        print(maxA)

Buggy submission (verdict: Runtime Error):
import copy
N = int(input())
As = []
for i in range(N):
    As.append(int(input()))
for j in range(N):
    instAs = copy.copy(As)
    instAs.pop(j)
    print(max(instAs))import copy
N = int(input())
As = []
for i in range(N):
    As.append(int(input()))
maxA = max(As)
instA = As.copy()
instA.remove(maxA)
secA = max(instA)
for i in range(N):
    if As[i] == maxA:
        print(secA)
    else:
        print(maxA)

Buggy submission (verdict: Runtime Error):
import copy
N = int(input())
As = []
for i in range(N):
    As.append(int(input()))
for j in range(N):
    instAs = copy.copy(As)
    instAs.pop(j)
    print(max(instAs))import copy
N = int(input())
As = []
for i in range(N):
    As.append(int(input()))
maxA = max(As)
instA = As.copy()
instA.remove(maxA)
secA = max(instA)
for i in range(N):
    if As[i] == maxA:
        print(secA)
    else:
        print(maxA)

Buggy submission (verdict: Runtime Error):
import copy
N = int(input())
As = []
for i in range(N):
    As.append(int(input()))
for j in range(N):
    instAs = copy.copy(As)
    instAs.pop(j)
    print(max(instAs))import copy
N = int(input())
As = []
for i in range(N):
    As.append(int(input()))
maxA = max(As)
instA = As.copy()
instA.remove(maxA)
secA = max(instA)
for i in range(N):
    if As[i] == maxA:
        print(secA)
    else:
        print(maxA)

Buggy submission (verdict: Runtime Error):
N = int(input())
As = []
for i in range(N):
  As.append(int(input())

for j in range(N):
  instAs = As
  instAs.pop(j)
  print(max(instAs))
Problem p03210 (python)

Fixed submission:
X = int(input())
if X == 7 or X == 5 or X == 3:
    print("YES")
else:
    print("NO")

Buggy submission (verdict: Runtime Error):
X = int(input())
X = 7 or X = 5 or X =3:
    print("YES")
else:
    print("NO")
Problem p03227 (python)

Fixed submission:
S = input()
if len(S) ==2:
    print(S)
else:
    print(S[::-1])

Buggy submission (verdict: Runtime Error):
S = input()
if len(S) ==2:
    print(S)
else:
　print(S[::-1])
Problem p03262 (python)

Fixed submission:
def gcd(a,b):
    if b > 0:
        c = a % b
        return(gcd(b,c))
    elif b == 0:
        return(a)

N, X = map(int,input().split())
x = list(input().split())
x = [abs(X-int(i)) for i in x]
for i in x:
    if i == x[0]:
        a = i
    else:
        a = gcd(a,i)
print(a)

Buggy submission (verdict: Runtime Error):
def gcd(a,b):
    if b > 0:
        c = a % b
        print(gcd(b,c))
    elif b == 0:
        print(a)

N, X = map(int,input().split())
x = list(input().split())
x = [abs(X-int(i)) for i in x]
for i in x:
    if i == x[0]:
        a = i
    else:
        a = gcd(a,i)
print(a)

Buggy submission (verdict: Runtime Error):
def gcd(a,b):
    if b > 0:
        c = a % b
        gcd(b,c)
    elif b == 0:
        print(a)

N, X = map(int,input().split())
x = list(input().split())
x = [abs(X-int(i)) for i in x]
for i in x:
    if i == x[0]:
        a = i
    else:
        a = gcd(a,i)
print(a)

Buggy submission (verdict: Runtime Error):
N, X = map(int,input().split())
x = list(input().split())
x = sorted([int(i) for i in x])
diff = []
res = 10**10
for i in x:
    if i !=x[0]:
        diff.append(i-old)
    res = min(abs(X-i),res)
    old = i
res = min(min(diff),res)
print(res)
Problem p03294 (python)

Fixed submission:

N = int(input())
a = input().split()
a = [int(i) for i in a]
res_list = {}
def gcd(a,b):
    while b:
        a, b = b, a % b
    return a
def lcm(x,y):
    return (x * y) // gcd(x, y)
for i in range(len(a)):
    if i == 0:
        res = a[i]
        continue
    else:
        res = lcm(res,a[i])
res2 = 0
for i in a:
    res2 += (res-1) % i
print(res2)

Buggy submission (verdict: Runtime Error):
import math
N = int(input())
a = input().split()
a = [int(i) for i in a]
res_list = {}
def lcm(x,y):
    return (x * y) // math.gcd(x, y)
for i in range(len(a)):
    if i == 0:
        res = a[i]
        continue
    else:
        res = lcm(res,a[i])
res2 = 0
for i in a:
    res2 += (res-1) % i
print(res2)