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

Fixed submission:
n,m = map(int, input().split( ))
p= [i for i in range(n)]+[n+j for j in range(m)]
rk = [0]*(n+m)
def rt(a):
    if a==p[a]:
        return a
    p[a] = rt(p[a])
    return p[a]
def uni(a,b):
    ra = rt(a);rb=rt(b)
    if ra==rb:
        return
    if rk[ra]>rk[rb]:
        p[rb] = ra
    else:
        if rk[ra]==rk[rb]:
            p[ra] = rb
            rk[rb]+=1
        else:
            p[ra]=rb 
    return

kl = {}
for i in range(n):
    ki,*li, = map(int, input().split( ))
    kl[i] = li
for ki in kl:
    for j in range(len(kl[ki])):
        kl[ki][j]-=1

for ki in kl:
    for lij in kl[ki]:
        uni(ki,lij+n)
for i in range(n):
    rt(i)
if len(set(p[:n]))==1:
    print("YES")
else:
    print("NO")

Buggy submission (verdict: Runtime Error):
n,m = map(int, input().split( ))
p= [i for i in range(n)]+[n+j for j in range(m)]
rk = [0]*(n+m)
def rt(a):
    if a==p[a]:
        return a
    p[a] = rt(p[a])
    return p[a]
def uni(a,b):
    ra = rt(a);rb=rt(b)
    if ra==rb:
        return
    if rk[ra]>rk[rb]:
        p[rb] = ra
    else:
        if rk[ra]==rk[rb]:
            p[ra] = rb
            rk[ra]+=1
        else:
            p[ra]=rb 
    return

kl = {}
for i in range(n):
    ki,*li, = map(int, input().split( ))
    kl[i] = li
for ki in kl:
    for j in range(len(kl[ki])):
        kl[ki][j]-=1

for ki in kl:
    for lij in kl[ki]:
        uni(ki,lij+n)
for i in range(n):
    rt(i)
if len(set(p[:n]))==1:
    print("YES")
else:
    print("NO")
Problem p04013 (python)

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

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

for i in range(n):
    x[i] -= a

mx = 0
for i in range(n):
    mx += abs(x[i])
mx +=1

dp = [[0 for i in range(3*mx)] for j in range(n)]
dp[0][0] += 1
dp[0][x[0]] += 1

for i in range(1,n) :
    for j in range(-mx,mx):
        dp[i][j] += dp[i-1][j-x[i]]
        dp[i][j] += dp[i-1][j]
    #print(*dp[i])
print(dp[n-1][0]-1)

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

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

for i in range(n):
    x[i] -= a
mx = max(x)*n+1

dp = [[0 for i in range(3*mx)] for j in range(n)]
dp[0][0] += 1
dp[0][x[0]] += 1

for i in range(1,n) :
    for j in range(-mx,mx):
        dp[i][j] += dp[i-1][j-x[i]]
        dp[i][j] += dp[i-1][j]
    #print(*dp[i])
print(dp[n-1][0]-1)
Problem p04031 (python)

Fixed submission:
#numpy使ってみる
import numpy as np
n = int(input())
a = np.array(list(map(int, input().split( ))))

ans = 10**10

for i in range(-100,101):
    tmp = ((a-i)**2).sum()
    ans = min(tmp,ans)
print(ans)

Buggy submission (verdict: Runtime Error):
#numpy使ってみる
import numpy as np
n = int(input())
a = np.array(list(map(int, input().split( ))))

ans = 10**10

for i in range(-100,101):
    tmp = ((a-i)**2).sum()
    ans = min(tmp,ans)
print(ans)
Problem p02641 (python)

Fixed submission:
X, N = map(int, input().split())
p = list(map(int, input().split()))

if len(p) == 0:
    print(X)
    exit()

if not X in p:
    print(X)
    exit()

small = [i for i in range(-101, X)]
big = [i for i in range(X+1, 102)]
small.reverse()
for i in range(max(len(big),len(small))):
    if not small[i] in p:
        print(small[i])
        exit()
    elif not big[i] in p:
        print(big[i])
        exit()

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

if len(p) == 0:
    print(X)
    exit()

if not X in p:
    print(X)
    exit()

small = [i for i in range(-1, X)]
big = [i for i in range(X+1, 101)]
small.reverse()
print(small)
print(big)
print(max(len(big),len(small)))
for i in range(max(len(big),len(small))):
    if not small[i] in p:
        print(small[i])
        exit()
    elif not big[i] in p:
        print(big[i])
        exit()

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

if len(p) == 0:
    print(X)
    exit()

if not X in p:
    print(X)
    exit()

small = [i for i in range(1, X)]
big = [i for i in range(X+1, 101)]

small.reverse()
for i in range(max(len(big),len(small))):
    if not small[i] in p:
        print(small[i])
        exit()
    elif not big[i] in p:
        print(big[i])
        exit()
Problem p02658 (python)

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

ans = 1
if 0 in A:
    print(0)
else:
    for i in A:
        ans *= i
        if ans > 1000000000000000000:
            print(-1)
            exit()
    print(ans)

Buggy submission (verdict: Runtime Error):
ans = 1
if 0 in A:
    print(-1)
else:
    for i in A:
        ans *= i
        if ans > 1000000000000000000:
            print(-1)
            exit()
print(ans)
Problem p02730 (python)

Fixed submission:
S = input()
N = len(S)
zen = S[:int((N-1)/2)]
kou = S[int((N+3)/2)-1:]
if S == S[::-1] and zen == zen[::-1] and kou == kou[::-1]:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
S = input()
N = len(S)
zen = S[:int((N-1)/2)]
kou = S[int((N+3)/2)-1:]
if S = S[::-1] and zen == zen[::-1] and kou == kou[::-1]:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
S = input()
N = len(S)
zen = S[:int((N-1)/2)]
kou = S[int((N+3)/2)-1:]
if zen == zen[::-1] and kou == kou[::-1]
    print("Yes")
else:
    print("No")
Problem p02534 (python)

Fixed submission:
n = int(input())
s = "ACL"
print(s*n)

Buggy submission (verdict: Runtime Error):
a =input()
b =input()
c =input()
d =input()

if c <= a <= d or c >= b <= d:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
a =input()
b =input()
c =input()
d =input()

if a >= c and a <= d or b >= c and b <= d:
  print("Yes")
else:
  print("No")

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

if a >= c and a <= d or b >= c and b <= d:
  print("Yes")
else:
  print("No")
Problem p03643 (python)

Fixed submission:
n=input()
print('ABC'+n)

Buggy submission (verdict: Runtime Error):
n=input()
print(n[3]+n[4]+n[5])
Problem p03759 (python)

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

print('YES' if b-a==c-b else 'NO')

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

print('YES' if b-a==c-b else 'NO')
Problem p03773 (python)

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

if a+b>=24:
    print((a+b)-24)
else:
    print(a+b)

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

if a+b>24:
    print((a+b)-24)
else:
    print(a+b)
Problem p02630 (python)

Fixed submission:
import collections
n = int(input())
# w = list(map(int, input().split()))
#n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
# data = [list(map(int, input().split())) for i in range(n)]
q = int(input())
#p = list(map(int, input().split()))
#a = list(map(int, input().split()))
# ab_sorted = sorted(ab, key=lambda x: x[0])
bc = [list(map(int, input().split())) for i in range(q)]
# print(min(15*n, 100*(n//10+1), 100*(n//10)+15*(n % 10)))
a_count = collections.Counter(a)
a_list = dict(list(a_count.items()))
#print(a_list)
total = sum(a)
for b, c in bc:
    if b in a_list:
        total += (c-b)*a_list[b]
        num = a_list[b]
        a_list[b] = 0
        if c in a_list:
            a_list[c] += num
        else:
            a_list[c] = num
            
    print(total)

Buggy submission (verdict: Runtime Error):
n = int(input())
# w = list(map(int, input().split()))
#n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
# data = [list(map(int, input().split())) for i in range(n)]
q = int(input())
#p = list(map(int, input().split()))
#a = list(map(int, input().split()))
# ab_sorted = sorted(ab, key=lambda x: x[0])
bc = [list(map(int, input().split())) for i in range(q)]
# print(min(15*n, 100*(n//10+1), 100*(n//10)+15*(n % 10)))
a_count = collections.Counter(a)
a_list = dict(list(a_count.items()))
#print(a_list)
total = sum(a)
for b, c in bc:
    if b in a_list:
        total += (c-b)*a_list[b]
        num = a_list[b]
        a_list[b] = 0
        if c in a_list:
            a_list[c] += num
        else:
            a_list[c] = num
            
    print(total)
Problem p02678 (python)

Fixed submission:
from collections import deque
# from math import factorial
import itertools
import collections
import math
import sys
sys.setrecursionlimit(2000000)
n, m = list(map(int, input().split()))
room = [[] for i in range(n)]
for i in range(m):
    a, b = list(map(int, input().split()))
    room[a-1].append(b-1)
    room[b-1].append(a-1)

ans = [-1]*n


def bfs(i):
    q = deque()
    q.append(i)
    while q:
        x = q.popleft()
        for i in range(len(room[x])):
            if ans[room[x][i]] == -1:
                q.append(room[x][i])
                ans[room[x][i]] = x
    return


bfs(0)
print("Yes")
for i in range(1, n):
    print(ans[i]+1)

Buggy submission (verdict: Runtime Error):
n, m = list(map(int, input().split()))
# a = list(map(int, input().split()))
# ab = [list(map(int, input().split())) for i in range(n)]
# n = int(input())
# n, m = list(map(int, input().split()))
# ab_sorted = sorted(ab, key=lambda x: x[0])
room = [[] for i in range(n)]
for i in range(m):
    a, b = list(map(int, input().split()))
    room[a-1].append(b-1)
    room[b-1].append(a-1)


def search(i):
    q = deque()
    q.append(i)
    while q:
        x = q.popleft()
        if 0 in room[x]:
            return x
        else:
            for i in range(len(room[x])):
                q.append(room[x][i])


print("Yes")
for i in range(1, n):
    if 0 in room[i]:
        print(1)
    else:
        a = search(i)
        print(a+1)
Problem p02684 (python)

Fixed submission:
n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
a = [aa-1 for aa in a]
check = [0 for i in range(n)]

count = 0
point = 0
check[0] = 1
path = [0]
for i in range(min(n, k)):
    if i == 0 or check[point] == 0:
        check[point] = i+1
        point = a[point]
        path.append(point)
    else:
        break


cycle_len = len(path)-check[point]
pre = check[point]
if pre > k:
    print(path[k])
else:
    k -= pre
    k %= cycle_len
    print(path[pre+k]+1)

Buggy submission (verdict: Runtime Error):
n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
a = [aa-1 for aa in a]
check = [0 for i in range(n)]

count = 0
point = 0
check[0] = 1
path = [0]
for i in range(min(n, k)):
    if i == 0 or check[point] == 0:
        check[point] = 1
        point = a[point]
        path.append(point)
    else:
        break

for i in range(len(path)):
    if path[i] == point:
        break
    else:
        count += 1

k -= count
p = k % (len(path)-count-1)

for i in range(p):
    point = a[point]
  
print(point+1)
Problem p02720 (python)

Fixed submission:
from collections import deque
k = int(input())
q = deque([1, 2, 3, 4, 5, 6, 7, 8, 9])
for i in range(k):
    x = q.popleft()
    a = 10*x+(x % 10)
    if x % 10 != 0:
        q.append(a-1)
    q.append(a)
    if x % 10 != 9:
        q.append(a+1)

print(x)

Buggy submission (verdict: Runtime Error):
k = int(input())
#n, k = list(map(int, input().split()))
#a = list(map(int, input().split()))
q = deque([1, 2, 3, 4, 5, 6, 7, 8, 9])
for i in range(k):
    x = q.popleft()
    a = 10*x+(x % 10)
    if x % 10 != 0:
        q.append(a-1)
    q.append(a)
    if x % 10 != 9:
        q.append(a+1)

print(x)
Problem p02780 (python)

Fixed submission:
import math
import itertools
#n = int(input())
#n, d = list(input().split())
n, k= list(map(int, input().split()))
p = list(map(int, input().split()))
point = []
rui = []

def s(n):
    if(n==1):
        return 1
    else:
        return (n*(n+1))/2


#for は一重まで
for i in range(n):
    point.append(s(p[i])/p[i])
    if i==0:
        rui.append(point[0])
    else:
        rui.append(rui[i-1]+point[i])


m = 0
a = 0
for i in range(n-k+1):
    if i==0:
        a = rui[i+k-1]
    else:
        a = rui[i+k-1]-rui[i-1]
    
   # print(a)
    if a > m:
        m = a



#print(point)
#print(rui)
print(m)

Buggy submission (verdict: Runtime Error):
import math
import itertools
#n = int(input())
#n, d = list(input().split())
n, k= list(map(int, input().split()))
p = list(map(int, input().split()))
point = []
rui = []

def s(n):
    if(n==1):
        return 1
    else:
        return n+s(n-1)


#for は一重まで
for i in range(n):
    point.append(s(p[i])/p[i])
    if i==0:
        rui.append(point[0])
    else:
        rui.append(rui[i-1]+point[i])


m = 0
a = 0
for i in range(n-k+1):
    if i==0:
        a = rui[i+k-1]
    else:
        a = rui[i+k-1]-rui[i-1]
    
   # print(a)
    if a > m:
        m = a



#print(point)
#print(rui)
print(m)

Buggy submission (verdict: Runtime Error):
import math
import itertools
#n = int(input())
#n, d = list(input().split())
n, k= list(map(int, input().split()))
p = list(map(int, input().split()))
point = []
rui = []

def s(n):
    if(n==1):
        return 1
    else:
        return n+s(n-1)


#for は一重まで
for i in range(n):
    point.append(s(p[i])/p[i])
    if i==0:
        rui.append(point[0])
    else:
        rui.append(rui[i-1]+point[i])


m = 0
a = 0
for i in range(n-k+1):
    if i==0:
        a = rui[i+k-1]
    else:
        a = rui[i+k-1]-rui[i-1]
    
    print(a)
    if a > m:
        m = a



#print(point)
#print(rui)
print(m)
Problem p02922 (python)

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

if b==1:
    print(0)
else:
    tap = 1
    n = a
    while n < b:
        n -= 1
        n += a
        tap+=1

    print(tap)

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

if b==1:
    print(0)
else:
    tap = 1
    n = a
    while n < b:
        n -= 1
        n += a
        tap+=1

print(tap)
Problem p02983 (python)

Fixed submission:
l, r = list(map(int, input().split()))
# b = list(map(int, input().split()))
# 2019=3*673
ans = 2019
for i in range(l, r+1):
    for j in range(i+1, r+1):
        if (i*j) % 2019 == 0:
            print(0)
            exit()
        else:
            if (i*j) % 2019 < ans:
                ans = (i*j) % 2019

print(ans)

Buggy submission (verdict: Runtime Error):
if r-l >= 2019:  # 2019の倍数がある
    ans = 0
elif r-l >= 673:  # 673の倍数,3の倍数がある
    ans = 0
elif l <= 2019 and 2019 <= r:  # 2019がある
    ans = 0
elif l <= 673 and 673 <= r and r-l >= 3:  # 673があって,3の倍数もある
    ans = 0
elif r-l >= (r % 2019):  # lとrの間に2019の倍数がある
    ans = 0
elif r-l >= (r % 673) and r-l >= 3:  # lとrの間に673の倍数があって,3の倍数もある
    ans = 0
else:
    ans = (l*(l+1)) % 2019

print(ans)
Problem p02993 (python)

Fixed submission:

S = list(input())
count = 0
bad = False

for i in range(len(S)-1):
    if S[i]==S[i+1]:
        bad = True


#print(bad)

if bad:
    print("Bad")
else:
    print("Good")

Buggy submission (verdict: Runtime Error):
import math
from functools import reduce
from fractions import gcd
#import math
#import itertools
#import statistics
#import numpy as np
#import collections
#n = int(input())
a, b, c, d = list(map(int, input().split()))
#b = list(map(int, input().split()))

#10 11  13 14 15  17  19 20 21 22 23  25 26 27 28 29 
# 31  33 34 35  37 38 39  
lcm = a*b/gcd(a, b)
diff = b-a+1
d1 = (b//c - a//c)
d2 = (b//d - a//d)
a1 =  int((b//lcm-a//lcm))

print(diff-d1-d2+a1)
Problem p02995 (python)

Fixed submission:
from fractions import gcd
a, b, c, d = list(map(int, input().split()))
#b = list(map(int, input().split()))
total = b-a+1
lcm = int((c*d)/gcd(c, d))

d1 = b//c - a//c
d2 = b//d - a//d
add = b//lcm - a//lcm
if a % c == 0:
    d1 += 1
if a % d == 0:
    d2 += 1
if a % lcm == 0:
    add += 1

print(total-d1-d2+add)

Buggy submission (verdict: Runtime Error):
import math
# import itertools
# import statistics
# import numpy as np
#n = int(input())
a, b, c, d = list(map(int, input().split()))
#b = list(map(int, input().split()))
total = b-a+1
lcm = int((c*d)/math.gcd(c, d))

d1 = b//c - a//c
d2 = b//d - a//d
add = b//lcm - a//lcm
if a % c == 0:
    d1 += 1
if a % d == 0:
    d2 += 1

print(total-d1-d2+add)

Buggy submission (verdict: Runtime Error):
import math
from functools import reduce
#import math
#import itertools
#import statistics
#import numpy as np
#import collections
#n = int(input())
a, b, c, d = list(map(int, input().split()))
#b = list(map(int, input().split()))

#10 11  13 14 15  17  19 20 21 22 23  25 26 27 28 29 
# 31  33 34 35  37 38 39  
lcm = a*b/math.gcd(a, b)
diff = b-a+1
d1 = (b//c - a//c)
d2 = (b//d - a//d)
a1 =  int((b//lcm-a//lcm))

print(diff-d1-d2+a1)

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

#10 11  13 14 15  17  19 20 21 22 23  25 26 27 28 29 
# 31  33 34 35  37 38 39  
lcm = a*b/math.gcd(a, b)
diff = b-a+1
d1 = (b//c - a//c)
d2 = (b//d - a//d)
a1 =  int((b//lcm-a//lcm))

print(diff-d1-d2+a1)
Problem p03032 (python)

Fixed submission:
n, k = list(map(int, input().split()))
v = list(map(int, input().split()))
l = 0
r = 0
a = 0
m = min(n, k)+1
have = []
total = 0
ans = 0
for r in range(m):
    for l in range(m-r):
        have = []
        have.append(v[:r])
        if l != 0:
            have.append(v[-l:])
        else:
            have.append([])
        a = k-l-r
        data = have[0]+have[1]
        data.sort()
        for i in range(len(data)):
            if i < a and data[i] < 0:
                data[i] = 0
        total = sum(data)
        if total > ans:
            ans = total
print(ans)

Buggy submission (verdict: Runtime Error):
n, k = list(map(int, input().split()))
v = list(map(int, input().split()))
l = 0
r = 0
a = 0
m = min(n, k)
have = []
total = 0
ans = 0
for r in range(m):
    for l in range(m-r):
        have = []
        have.append(v[:r])
        if l != 0:
            have.append(v[-l:])
        else:
            have.append([])
        a = m-l-r
        data = have[0]+have[1]
        data.sort()
        for i in range(a):
            if data[i] < 0:
                data[i] = 0
        total = sum(data)
        if total > ans:
            ans = total
print(ans)
Problem p03035 (python)

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

if data[0] >= 13:
    print(int(data[1]))
elif data[0] >= 6:
    print(int(data[1]/2))
else:
    print(0)

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

if data[0] >= 13:
    print(int(data[1]))
elif data[0] >= 6:
    print(int(data[1]/2)
else:
    print(0)
Problem p03071 (python)

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

# AA AB BB
max = max(data[0]+data[0]-1, data[0]+data[1], data[1]+data[1]-1)

print(max)

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

ans = data[2]-(data[0]-data[1])

if ans > 0:
     print(ans)
else:
    print("0")
Problem p03087 (python)

Fixed submission:
import math
# import itertools
# import statistics
# import numpy as np
#n = int(input())
n, q = list(map(int, input().split()))
#b = list(map(int, input().split()))
s = input()
lr = []
for i in range(q):
    x, y = list(map(int, input().split()))
    lr.append([x, y])

ac_count = [0]*int(len(s))
point = 0
for i in range(len(s)-1):
    if s[i] == "A" and s[i+1] == "C":
        ac_count[i] += point+0.5
        point += 0.5
        ac_count[i+1] += point+0.5
        point += 0.5
    else:
        ac_count[i] = point
ac_count[-1] = point
for i in range(q):
    print(math.floor(ac_count[lr[i][1]-1])-math.floor(ac_count[lr[i][0]-1]))

Buggy submission (verdict: Runtime Error):
import math
# import itertools
# import statistics
# import numpy as np
#n = int(input())
n, q = list(map(int, input().split()))
#b = list(map(int, input().split()))
s = input()
lr = []
for i in range(q):
    x, y = list(map(int, input().split()))
    lr.append([x, y])

ac_count = [0]*int(len(s))
point = 0
for i in range(len(s)):
    if s[i] == "A" and s[i+1] == "C":
        ac_count[i] += point+0.5
        point += 0.5
        ac_count[i+1] += point+0.5
        point += 0.5
    else:
        ac_count[i] = point

for i in range(q):
    print(math.floor(ac_count[lr[i][1]-1])-math.floor(ac_count[lr[i][0]-1]))
Problem p03125 (python)

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

if data[1]%data[0] == 0:
    print(sum(data))
else:
    print(data[1]-data[0])

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

count = int(data[1]/data[0])

if count > data[2]:
    print(data[2])
else:
    print(count)
Problem p03147 (python)

Fixed submission:
n = int(input())
#n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
# abc = [int(input()) for i in range(5)]

if n == 1:
    print(a[0])
    exit()

up = True
ans = 0
for i in range(n-1):
    if a[i] <= a[i+1]:
        if up == False:
            ans -= a[i]
        up = True
    else:
        if up == True:
            ans += a[i]
        up = False

if a[-2] <= a[-1]:
    ans += a[-1]

print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
#n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
# abc = [int(input()) for i in range(5)]
up = True
ans = 0
for i in range(n-1):
    if a[i] <= a[i+1]:
        if up == False:
            ans -= a[i]
        up = True
    else:
        if up == True:
            ans += a[i]
        up = False

if a[-2] <= a[-1]:
    ans += a[-1]

print(ans)
Problem p03262 (python)

Fixed submission:
import math
from functools import reduce
import fractions
#import math
#import itertools
#import statistics
#import numpy as np
#import collections
#n = int(input())
n, k  = list(map(int, input().split()))
x = list(map(int, input().split()))
x.append(k)
x.sort()

def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)

dif = []
for i in range(n):
    dif.append(x[i+1]-x[i])

ans = gcd_list(dif)
print(ans)

Buggy submission (verdict: Runtime Error):
import math
from functools import reduce
#import math
#import itertools
#import statistics
#import numpy as np
#import collections
#n = int(input())
n, k  = list(map(int, input().split()))
x = list(map(int, input().split()))
x.append(k)
x.sort()


def gcd_list(numbers):
    return reduce(math.gcd, numbers)

dif = []
for i in range(n):
    dif.append(x[i+1]-x[i])

ans = gcd_list(dif)
print(ans)
Problem p03294 (python)

Fixed submission:
from fractions import gcd
from functools import reduce
#from collections import deque
# from math import factorial
# import collections
import sys
sys.setrecursionlimit(2000000)
# import itertools
# import statistics
# import numpy as np
n = input()
#n, m = list(map(int, input().split()))
a = list(map(int, input().split()))


def lcm_base(x, y):
    return (x * y) // gcd(x, y)


def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)


b = lcm_list(a)-1
f = 0
for i in a:
    f += b % i

print(f)

Buggy submission (verdict: Runtime Error):
from fractions import gcd
from functools import reduce
#from collections import deque
# from math import factorial
# import collections
import math
import sys
sys.setrecursionlimit(2000000)
# import itertools
# import statistics
# import numpy as np
n = input()
#n, m = list(map(int, input().split()))
a = list(map(int, input().split()))

def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)


def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)


b = lcm_list(a)-1
f = 0
for i in a:
    f += b % i

print(f)

Buggy submission (verdict: Runtime Error):
from fractions import gcd
from functools import reduce
import math
import sys
sys.setrecursionlimit(2000000)
n = input()
a = list(map(int, input().split()))
def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)
def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)
b = lcm_list(a)-1
f = 0
for i in a:
    f += b % i

print(f)
Problem p03328 (python)

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

diff = b-a
tall = diff*(diff+1)/2
print(int(tall-b))

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

def calc(n):
    if n==1:
        return 1
    else:
        return n+calc(n-1)


diff = b-a
tall = calc(diff)
print(tall-b)