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

Fixed submission:
import sys
import os
sys.setrecursionlimit(100000000)

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

def gcd(x,y):
    if y <= 0:
        return x
    else:
        return gcd(y,x%y)

N = int(input())
T = [int(input()) for _ in range(N)]
if N == 1:
    print(T[0])
    sys.exit()

ans = lcm(T[0],T[1])
for i in range(2,N):
    ans = lcm(ans,T[i])
print(ans)

Buggy submission (verdict: Runtime Error):
import sys
import os
sys.setrecursionlimit(10000000000000)

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

def gcd(x,y):
    if y <= 0:
        return x
    else:
        return gcd(y,x%y)

N = int(input())
T = [int(input()) for _ in range(N)]
ans = lcm(T[0],T[1])
for i in range(2,N):
    ans = lcm(ans,T[i])
print(ans)

Buggy submission (verdict: Runtime Error):
import sys
import os
sys.setrecursionlimit(1000000000000000)

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

def gcd(x,y):
    if y <= 0:
        return x
    else:
        return gcd(y,x%y)

N = int(input())
T = [int(input()) for _ in range(N)]
ans = lcm(T[0],T[1])
for i in range(2,N):
    ans = lcm(ans,T[i])
print(ans)

Buggy submission (verdict: Runtime Error):
import sys
import os
sys.setrecursionlimit(100000000)
def lcm(x,y):
    return (x*y)//gcd(x,y)

def gcd(x,y):
    if y <= 0:
        return x
    else:
        return gcd(y,x%y)

N = int(input())
T = [int(input()) for _ in range(N)]
ans = lcm(T[0],T[1])
for i in range(2,N):
    ans = lcm(ans,T[i])
print(ans)

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(100000)

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

def gcd(x,y):
    if y <= 0:
        return x
    else:
        return gcd(y,x%y)

N = int(input())
T = [int(input()) for _ in range(N)]
ans = lcm(T[0],T[1])
for i in range(2,N):
    ans = lcm(ans,T[i])
print(ans)

Buggy submission (verdict: Runtime Error):
sys.setrecursionlimit(100000)
def lcm(x,y):
    return (x*y)//gcd(x,y)

def gcd(x,y):
    if y <= 0:
        return x
    else:
        return gcd(y,x%y)

N = int(input())
T = [int(input()) for _ in range(N)]
ans = lcm(T[0],T[1])
for i in range(2,N):
    ans = lcm(ans,T[i])
print(ans)
Problem p03778 (python)

Fixed submission:
W, a, b = map(int,input().split())
print(max(b-(a+W),(a-(b+W)),0))

Buggy submission (verdict: Runtime Error):
from collections import deque
def bfs():
    Q = deque()
    Q.append(0)
    #今の時刻
    i = 1
    while len(Q) > 0:
        x = Q.popleft()
        if x-i >= 0:
            T[i][x-i] = 1
            if x-i == X: return i
            Q.append(x-i)
        if 0 <= x and x <= X:
            T[i][x] = 1
            if x == X: return i
            Q.append(x)
        if x+i <= X:
            T[i][x+i] = 1
            if x+i == X: return i
            Q.append(x+i)
        i += 1

X = int(input())
INF = 10**9 +1
#時刻iで座標jに到着できるかどうか
T = [[0 for _ in range(X+1)] for _ in range(X**2)]
T[0][0] = 1
print(bfs())

Buggy submission (verdict: Runtime Error):
import sys
from collections import deque
def bfs():
    Q = deque()
    Q.append(0)
    #今の時刻
    i = 1
    while len(Q) > 0:
        x = Q.popleft()
        print(x)
        if x-i >= 0:
            T[i][x-i] = 1
            if x-i == X: return i
            Q.append(x-i)
        if 0 <= x and x <= X:
            T[i][x] = 1
            if x == X: return i
            Q.append(x)
        if x+i <= X:
            T[i][x+i] = 1
            if x+i == X: return i
            Q.append(x+i)
        i += 1

X = int(input())
INF = 10**9 +1
#時刻iで座標jに到着できるかどうか
T = [[0 for _ in range(X+1)] for _ in range(X**2)]
T[0][0] = 1
print(bfs())

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

def bfs():
    Q = deque()
    Q.append(0)
    #今の時刻
    i = 1
    while len(Q) > 0:
        x = Q.popleft()
        print(x)
        if x-i >= 0:
            T[i][x-i] = 1
            if x-i == X: return i
            Q.append(x-i)
        if 0 <= x and x <= X:
            T[i][x] = 1
            if x == X: return i
            Q.append(x)
        if x+i <= X:
            T[i][x+i] = 1
            if x+i == X: return i
            Q.append(x+i)
        i += 1

X = int(input())
INF = 10**9 +1
#時刻iで座標jに到着できるかどうか
T = [[0 for _ in range(X+1)] for _ in range(X**2)]
T[0][0] = 1
print(bfs())
Problem p03944 (python)

Fixed submission:
W, H, N = map(int,input().split())
#白い領域の端
l = 0
r = W
u = H
d = 0
for i in range(N):
    x, y, a = map(int,input().split())
    if a == 1:
        l = max(x,l)
    elif a == 2:
        r = min(x,r)
    elif a == 3:
        d = max(y,d)
    else:
        u = min(y,u)
print(max((r-l),0)*max((u-d),0))

Buggy submission (verdict: Runtime Error):
W, H, N = map(int,input().split())
#白い領域の端
l = 0
r = W
u = H
d = 0
for i in range(N):
    x, y, a = map(int,input().split())
    if a == 1:
        l = max(x,l)
    elif a == 2:
        r = min(x,r)
    elif a == 3:
        d = max(y,d)
    else:
        u = min(y,u)
print(max((r-l),0)*max((u-d),0)
Problem p03998 (python)

Fixed submission:
import sys
A = input()
B = input()
C = input()
A = list(A)
A.append("end")
B = list(B)
B.append("end")
C = list(C)
C.append("end")
i = 1
j = 0
k = 0
cur = A[0]
while i < len(A) and j < len(B) and k < len(C) :
    if cur == "a":
        cur = A[i]
        if cur == "end":
            print("A")
            sys.exit()
        i += 1
    elif cur == "b":
        cur = B[j]
        if cur == "end":
            print("B")
            sys.exit()
        j += 1
    elif cur == "c":
        cur = C[k]
        if cur == "end":
            print("C")
            sys.exit()
        k += 1

Buggy submission (verdict: Runtime Error):
A = input()
B = input()
C = input()
A = list(A)
A.append("end")
B = list(B)
B.append("end")
C = list(C)
C.append("end")
i = 1
j = 0
k = 0
cur = A[0]
while i < len(A) and j < len(B) and k < len(C) :
    if cur == "a":
        cur = A[i]
        if cur == "end":
            print("A")
            sys.exit()
        i += 1
    elif cur == "b":
        cur = B[j]
        if cur == "end":
            print("B")
            sys.exit()
        j += 1
    elif cur == "c":
        cur = C[k]
        if cur == "end":
            print("C")
            sys.exit()
        k += 1
Problem p02696 (python)

Fixed submission:
A, B, N = [eval(v) for v in input().strip().split(" ")]

if N < B:
    print(int(A * N / B) - A * int(N / B))
else:
    print(int(A * (B - 1) / B) - A * int((B - 1) / B))

Buggy submission (verdict: Runtime Error):
A, B, N = [int(v) for v in input().strip().spilt(" ")]

if N < B:
	print(int(A * N * B) - A * int(N / B))
else:
    print(int(A * (B - 1) * B) - A * int((B - 1) / B))
Problem p02705 (python)

Fixed submission:
R = float(input())
print(2*3.141592653589793*R)

Buggy submission (verdict: Runtime Error):
import math
if __name__ = "__main__":
	R = eval(input())
    print(math.pi*R**2)

Buggy submission (verdict: Runtime Error):
import math
R = input()
print(math.pi*R**2)
Problem p02641 (python)

Fixed submission:
X, N = map(int, input().split())
if N >= 1:
    P = sorted(list(map(int, input().split())))
else:
    P = []

c = 200
for x in range(-1, 102):
    if x in P:
        continue
    else:
        tmp = abs(X-x)
        if tmp < c:
            c = tmp
            ans = x
print(ans)

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

c = 100
for x in range(1, 101):
    if x in P:
        continue
    else:
        tmp = abs(X-x)
        if tmp < c:
            c = tmp
            ans = x
print(ans)
Problem p02642 (python)

Fixed submission:
N = int(input())
A = sorted(list(map(int, input().split())))
m = A[-1]+1
dp = [0]*(m*2)
ans = 0

for a in A:
    for i in range(0, m//a+1):
        dp[a*i] += 1
for a in A:
    if dp[a] == 1:
        ans += 1

print(ans)

Buggy submission (verdict: Runtime Error):
from math import sqrt
N = int(input())
A = sorted(list(map(int, input().split())))
m = 10**6
dp = [0]*10**6
ans = 0

for a in A:
    for i in range(1, m//a):
        dp[a*i] += 1
for a in A:
    if dp[a] == 1:
        ans += 1

print(ans)
Problem p02684 (python)

Fixed submission:
N, K = map(int, input().split())
A = list(map(int, input().split()))
idx = 1
S = [idx]
ed = set([idx])

for i in range(1, K+1):
    idx = A[idx-1]
    if idx in ed:
        start = S.index(idx)
        end = len(S)
        n = start + (K - start) % (end - start)
        print(S[n])
        break
    else:
        S.append(idx)
        ed.add(idx)
        continue
else:
    print(idx)

Buggy submission (verdict: Runtime Error):
from itertools import combinations
import numpy as np
N, M, X = map(int,input().split())
xx = np.array([X]*M)
C = {}
cs = []
for _ in range(N):
    c, *A = map(int,input().split())
    C[c] = A
    cs.append(c)
ans = float('inf')
for i in range(0, N+1):
    for comb in combinations(cs,i):
        tmp = 0
        x = xx.copy()
        for cos in comb:
            tmp += cos
            x -= np.array(C[cos])
        if len(x[x <= 0]) >= M:ans = min(ans,tmp)
if ans == float('inf'):ans = '-1'
print(ans)
Problem p02756 (python)

Fixed submission:
from collections import deque
S = deque(list(input()))
Q = int(input())
Flag = True
for _ in range(Q):
    q = input().split()
    if len(q) == 1:
        Flag = False if Flag else True
    else:
        if Flag:
            if q[1] == '1':
                S.appendleft(q[2])
            else:
                S.append(q[2])
        else:
            if q[1] == '1':
                S.append(q[2])
            else:
                S.appendleft(q[2])

if Flag:
    print(''.join(S))
else:
    print(''.join(reversed(S)))

Buggy submission (verdict: Runtime Error):
import collections

def bfs(N):
    S = "abcdefghij"
    result = []
    deq = collections.deque(["a"])

    while deq:
        s = deq.popleft()
        if len(s) == N:
            result.append(s)
            continue
        else:
            for i in S[:len(set(s))+1]:
                deq.append(s + i)
    return result

N = int(input())
ans = bfs(N)
for a in ans:
    print(a)
exit()

Buggy submission (verdict: Runtime Error):
#幅優先探索による全探索
from collections import deque

def bfs(N):
    S = "abcdefghij"
    result = []
    deq = deque(["a"])

    while deq:
        s = deq.popleft()
        if len(s) == N:
            result.append(s)
            continue
        else:
            for i in S[:len(set(s))+1]:
                deq.append(s + i)
    return result

N = int(input())
ans = bfs(N)
for a in ans:
    print(a)

Buggy submission (verdict: Runtime Error):
#幅優先探索による全探索
from collections import deque

def bfs(N):
    S = "abcdefghij"
    result = []
    deq = deque(["a"])

    while deq:
        s = deq.popleft()
        if len(s) == N:
            result.append(s)
            continue
        else:
            for i in S[:len(set(s))+1]:
                deq.append(s + i)
    return result

N = int(input())
ans = bfs(N)
print('\n'.join(ans))

Buggy submission (verdict: Runtime Error):
#幅優先探索による全探索
from collections import deque

def bfs(N):
    S = "abcdefghij"
    result = []
    deq = deque(["a"])

    while deq:
        s = deq.popleft()
        if len(s) == N:
            result.append(s + "\n")
            continue
        else:
            for i in S[:len(set(s))+1]:
                deq.append(s + i)
    return result

N = int(input())
ans = bfs(N)
print(''.join(ans))
Problem p02768 (python)

Fixed submission:
n, a, b = map(int, input().split())
mod = 10**9+7
total = pow(2, n, mod) - 1

def choose(n, r):
    res = 1
    fac = 1
    for i in range(r):
        res *= n-i
        res %= mod
        fac *= i+1
        fac %= mod
    return res*pow(fac, mod-2, mod)%mod

for i in [a, b]:
    total -= choose(n, i)

print(total%mod)

Buggy submission (verdict: Runtime Error):
import collections
n,a,b=map(int,input().split())
mod=10**9+7

N=collections.deque(list(reversed(range(1,n+1))))
dp_fac=[0]*n
dp_bunbo=[1]*n
for i in range(0,n):
    if i==0:
        dp_bunshi=N[0]%mod
    else:
        dp_bunbo[i]=((i+1)*dp_bunbo[i-1])%mod
        dp_bunshi=(N[i]*dp_bunshi)%mod
    dp_fac[i]=dp_bunshi//dp_bunbo[i]
ans=0
for j in range(0,n):
    if (j+1)==a or (j+1)==b:continue
    ans+=dp_fac[j]
print(ans)
Problem p02780 (python)

Fixed submission:
n,k=map(int,input().split())
p=[(i+1)/2 for i in map(float,input().split())]
MAX=sum(p[0:k])
s=[MAX]*n
for i in range(0,n-k):
    s[i+1]=p[i+k]+s[i]-p[i]
    MAX=max(MAX,s[i+1])
print(MAX)

Buggy submission (verdict: Runtime Error):
import numpy as np
n,k=map(int,input().split())
P=list(map(int,input().split()))
p=np.cumsum(P)
s=[0]*(n//k+1)
MAX=p[0]
ans=0
for i in range(0,n-k):
    MAX=max(MAX,p[i+k]-p[i])
    if MAX==p[i+k]-p[i]:
        s=i
for j in P[s+1:s+k+1]:
    ans+=(1+j)/2
print(ans)

Buggy submission (verdict: Runtime Error):
import numpy as np
n,k=map(int,input().split())
P=list(map(int,input().split()))
p=np.cumsum(P)
s=[0]*(n//k+1)
MAX=p[0]
ans=0
for i in range(0,n-k):
    MAX=max(MAX,p[i+k]-p[i])
    if MAX==p[i+k]-p[i]:
        s=i
for j in P[s+1:s+k+1]:
    ans+=np.cumsum(range(1,j+1))[-1]/j
print(ans)
Problem p02813 (python)

Fixed submission:
import itertools
n=int(input())
r=list(itertools.permutations(range(1,n+1)))
p=tuple(map(int,input().split()))
q=tuple(map(int,input().split()))
print(abs(r.index(p)-r.index(q)))

Buggy submission (verdict: Runtime Error):
import itertools

n = int(input())
N = [i for i in range(1,n+1)]
P = tuple(map(int, input().split()))
Q = tuple(map(int, input().split()))

for i, j in enumerate(itertools.permutations(N)):
    if j == P:
        a = i + 1
    elif j == Q:
        b = i + 1
print(abs(a - b))
Problem p02837 (python)

Fixed submission:
n = int(input())
testimony = [[] for _ in range(n)]

for i in range(n):
    num = int(input())
    for j in range(num):
        person, state = map(int, input().split())
        testimony[i].append([person-1, state])

honest = 0
for i in range(1, 2**n):
    flag = 0
    for j in range(n):
        if (i>>j)&1 == 1:
            for x, y in testimony[j]:
                if (i>>x)&1 != y:
                    flag = 1
    if flag == 0:
        honest = max(honest, bin(i)[2:].count('1'))

print(honest)

Buggy submission (verdict: Runtime Error):
n = int(input())
testimony = [[] for _ in range(n)]

for i in range(n):
    num = int(input())
    for j in range(num):
        person, state = map(int, input().split())
        testimony[i].append([person-1], state)

honest = 0
for i in range(1, 2**n):
    flag = 0
    for j in range(n):
        if (i>>j)&1 == 1:
            for x, y in testimony[j]:
                if (i>>x)&1 != y:
                    flag = 1
    if flag == 0:
        honest = max(honest, bin(i)[2:].count('1'))

print(honest)

Buggy submission (verdict: Runtime Error):
n = int(input())
testimony = [[] for _ in range(n)]

for i in range(n):
    num = int(input())
    for j in range(num):
        person, state = map(int, input().split())
        testimony[i].append([person-1], state)

honest = 0
for i in range(1, 2**n):
    flag = 0
    for j in range(n):
        if (i>>j)&1 == 1:
            for x, y in testimony[j]:
                if (i>>x)&1 != y:
                    flag = 1
                    break
    if flag == 0:
        honest = max(honest, bin(i)[2:].count('1'))

print(honest)
Problem p02841 (python)

Fixed submission:
m=input().split()
M=input().split()
 
if int(M[0]) - int(m[0]) == 1:
  print('1')
else:
  print('0')

Buggy submission (verdict: Runtime Error):
m,d=int(input()),input()
M,D=int(input()),input()

if M - m == 1:
  print('1')
else:
  print('0')
Problem p02865 (python)

Fixed submission:
N=int(input())
c=-(-N//2)-1
print(c)

Buggy submission (verdict: Runtime Error):
N=int(input())
print(rount(N/2)-1)

Buggy submission (verdict: Runtime Error):
N=int(input())/2
print(int(N)

Buggy submission (verdict: Runtime Error):
ans=0
N=int(input())
c=round(N/2)
for i in range(1,c):
    for j in range(c,i,-1):
        cnt=i+j
        if cnt=N:
            ans+=1
print(ans)

Buggy submission (verdict: Runtime Error):
ans=0
N=int(input())
c=round(N/2)
for i in range(1,c):
    for j in range(1,c-i):
        cnt=i+j
        if cnt=N:
            ans+=1
print(ans)

Buggy submission (verdict: Runtime Error):
ans=0
N=int(input())
c=round(N/2)
for i in range(1,c):
	for j in range(1,N-c):
    	cnt=i+j
        if cnt=N:
        	ans+=1
print(ans)

Buggy submission (verdict: Runtime Error):
ans=1
N=int(input())
c=int((N-1)/2)
for i in range(c):
	for j in range(c):
    	cnt=i+j
        if cnt=N:
        	ans+=1
print(ans)

Buggy submission (verdict: Runtime Error):
ans=1
N=int(input())
for i in range(N-1):
	for j in range(N-1):
    	cnt=i+j
        if cnt=N:
        	ans+=1
print(ans)
Problem p02882 (python)

Fixed submission:
import math
a, b, x = map(int, input().split())
c = (2*x)/(a**2)-b
if c <= 0:
    c = (2*x)/(a*b)
    print(math.degrees(math.atan2(b, c)))
else:
    print(math.degrees(math.atan2(b-c, a)))

Buggy submission (verdict: Runtime Error):
import math
a, b, x = map(int, input().split())
if a**2*b/2 >= 2*x:
    c = (2*x)/(a*b)
    print(math.degrees(math.atan(b, c)))
else:
    d = 2*(b-x/a/a)
    print(math.degrees(math.atan(d, a)))
Problem p02923 (python)

Fixed submission:
n=int(input())
if n==1:print('0'); exit()
h=list(map(int,input().split()))
ans=0
step=0
for i in range(n):
    cnt=0
    for j in range(n):
        if h[step]<h[step+1]: step+=1; break
        cnt+=1; step+=1
        if step+1==n: break
    ans=max(ans,cnt)
    if step+1==n: break
print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
h=list(map(int,input().split()))
ans=0
step=0
for i in range(n):
    cnt=0
    for j in range(n):
        if h[step]<h[step+1]: step+=1; break
        cnt+=1; step+=1
        if step+1==n:break
    ans=max(ans,cnt)
    if step+1==n: break
print(ans)
Problem p02995 (python)

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

Buggy submission (verdict: Runtime Error):
from math import gcd
a,b,c,d=map(int,input().split())
cd=(c*d)//gcd(c,d)
print(b-(b//c+b//d-b//cd)-((a-1)-((a-1)//c+(a-1)//d-(a-1)//cd)))
Problem p03030 (python)

Fixed submission:
n=int(input())
L=[]
for i in range(n):
    s,p=input().split()
    L.append([s,-int(p),i+1])
for l in sorted(L):
    print(l[2])

Buggy submission (verdict: Runtime Error):
n=int(input())
L=[]
for i in range(n):
    s,p=input().split()
    L.append(s,-int(p),i+1)
for l in sorted(L):
    print(l[2])
Problem p03061 (python)

Fixed submission:
from fractions import gcd

N = int(input())
A = list(map(int, input().split()))
L = [A[0]]
R = [A[-1]]

for i in range(N-1):
    L.append(gcd(L[-1], A[i+1]))
    R.append(gcd(R[-1], A[N-i-2]))

ans = max(L[-2], R[-2])
for i in range(1, N-1):
    ans = max(ans, gcd(L[i-1], R[-i-2]))

print(ans)

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

N = int(input())
A = list(map(int, input().split()))
L = [A[0]]
R = [A[-1]]

for i in range(N-1):
    L.append(gcd(L[-1], A[i+1]))
    R.append(gcd(R[-1], A[N-i-2]))
    print(L, R)
ans = max(L[-2], R[-2])
for i in range(1, N-1):
    ans = max(ans, gcd(L[i-1], R[-i-2]))

print(ans)
Problem p03109 (python)

Fixed submission:
print('Heisei' if input()<='2019/04/30' else 'TBD')

Buggy submission (verdict: Runtime Error):
from datetime import datetime as dt
import datetime
d1=dt.fromisoformat('2019/04/30'.replace('/', '-'))
d2=dt.fromisoformat(input().replace('/', '-'))
delta=d1-d2
print('Heisei' if delta.days >= 0 else 'TBD')

Buggy submission (verdict: Runtime Error):
from datetime import datetime as dt
d1=dt.fromisoformat('2019/04/30'.replace('/', '-'))
d2=dt.fromisoformat(input().replace('/', '-'))
delta=d1-d2
print('Heisei' if delta.days >= 0 else 'TBD')
Problem p03110 (python)

Fixed submission:
ans=0
n=int(input())
for _ in range(n):
    x,u=input().split()
    if u=='JPY':
        ans+=int(x)
    else:
        ans+=(float(x)*380000.0)
print(ans)

Buggy submission (verdict: Runtime Error):
ans=0
n=int(input())
for _ in range(n):
    x,u=input().split()
    if x=='JPY':
        ans+=int(u)
    else:
        ans+=(float(u)*380000.0)
print(ans)

Buggy submission (verdict: Runtime Error):
ans=0
n=int(input())
for _ in range(n):
    x,u=input().split()
    if x=='JPY':
        ans+=int(u)
    else:
        ans+=(int(u)*380000)
    ans=int(ans)
print(ans)

Buggy submission (verdict: Runtime Error):
ans=0
n=int(input())
for _ in range(n):
    x,u=input().split()
    if x=='JPY':
        ans+=int(u)
    else:
        ans+=(int(u)*380000)
print(ans)

Buggy submission (verdict: Runtime Error):
ans=0
n=int(input())
for _ in range(n):
    x,u=input().split()
    ans+=int(u) if x=='JPY' else int(u)*380000
print(ans)
Problem p03160 (python)

Fixed submission:
n=int(input())
l=list(map(int,input().split()))
dp=[0 for _ in range(n)]
dp[1]=abs(l[1]-l[0])

for i in range(2,n):
    single=abs(l[i]-l[i-1])+dp[i-1]
    double=abs(l[i]-l[i-2])+dp[i-2]
    dp[i]=min(single,double)

print(dp[n-1])

Buggy submission (verdict: Runtime Error):
import math
n=int(input())
l=list(map(int,input().split()))
dp=[math.inf for _ in range(n)]
dp[0]=0
dp[1]=abs(l[1]-l[0])

for i in range(2,n):
    single=abs(l[i]-l[i-1])+dp[i-1]
    double=abs(l[i]-l[i-2])+dp[i-2]
    dp[i]=min(single,double)

print(dp[n-1])
Problem p03244 (python)

Fixed submission:
from collections import Counter
n = int(input())
v = list(map(int, input().split()))
v1 = Counter(v[::2])
v2 = Counter(v[1::2])
E = v1.most_common()
O = v2.most_common()
if E[0][0] == O[0][0]:
    tmp1 = E[1][1] if len(E) > 1 else 0
    tmp2 = O[1][1] if len(O) > 1 else 0
    ans = min(n-E[0][1]-tmp2, n-tmp1-O[0][1])
else:
    ans = n-E[0][1]-O[0][1]
print(ans)

Buggy submission (verdict: Runtime Error):
from collections import Counter
n = int(input())
v = list(map(int, input().split()))
C1 = []
C2 = []
for i in range(n)[::2]:
    C1.append(v[i])
    C2.append(v[i+1])

C1 = Counter(C1).most_common()
C2 = Counter(C2).most_common()

if C1[0][0] != C2[0][0]:
    print(n-C1[0][1]-C2[0][1])
else:
    ans1 = n-C1[0][1]-C2[1][1]
    ans2 = n-C1[1][1]-C2[0][1]
    print(min(ans1, ans2))
Problem p03262 (python)

Fixed submission:
from fractions import gcd
N, X = map(int, input().split())
L = sorted(list(map(int, input().split())))

ans = abs(L[0]-X)
for x in L[1:]:
    ans = gcd(ans, abs(x-X))
print(ans)

Buggy submission (verdict: Runtime Error):
import bisect
N, X = map(int, input().split())
x = sorted(list(map(int, input().split()))+[X])

i = bisect.bisect_left(x, X)
print(min(abs(x[i-1]-x[i]), abs(x[i]-x[i+1])))

Buggy submission (verdict: Runtime Error):
import bisect
N, X = map(int, input().split())
x = sorted(list(map(int, input().split())))

i = bisect.bisect_left(x, X)
print(min(abs(x[i-1]-X), abs(X-x[i])))
Problem p03285 (python)

Fixed submission:
n = int(input())
for i in range(100):
  for j in range(100):
    if 4*i+7*j == n:
        print('Yes')
        exit(0)
print('No')

Buggy submission (verdict: Runtime Error):
n = int(innput())
f = 4
s = 7
for i in range(30):
  f = f*i
  for j in range(30):
    s = s*j
    if n%s == 0 or n%f == 0 or n%(f+s)==0:
      print('Yes')
      quit()
    if n < f+s:
      break
print('No')

Buggy submission (verdict: Runtime Error):
n = int(innput())
f = 4
s = 7
for i in range(30):
  f = f*i
  for j in range(30):
    s = s*j
    if n%s == 0 or n%f == 0 or n%(f+s)==0:
      print('Yes')
      quit()
   	if n < f+s:
      break
print('No')
Problem p03352 (python)

Fixed submission:
x=int(input())
c=1
for b in range(1,x):
    for p in range(2,x):
        if b**p<=x:c=max(c,b**p)
        else:break
print(c)

Buggy submission (verdict: Runtime Error):
x=int(input())
c=1
for b in range(1,x):
    for p in rangenge(2,x):
        if b**p<=x:c=max(c,b**p)
        else:break
print(c)
Problem p03386 (python)

Fixed submission:
a,b,k=map(int,input().split())
R=range(a,b+1)
for x in sorted(set(R[:k])|set(R[-k:])):
    print(x)

Buggy submission (verdict: Runtime Error):
a,b,k=map(int,input().split())
R=list(range(a,b+1))
for x in sorted(set(R[:k])|set(R[-k:])):
    print(x)