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

Fixed submission:
def canMakeNumber(k, s):
    k = str(k).zfill(3)
    dic = {0: False, 1: False, 2: False}
    rep = False
    for t in s:
        if dic[0] is False:
            if t == k[0]:
                dic[0] = True
        else:
            if dic[1] is False:
                if t == k[1]:
                    dic[1] = True
            else:
                if dic[2] is False:
                    if t == k[2]:
                        dic[2] = True
                else:
                    continue
    if dic[0] == dic[1] == dic[2] == True:
        rep = True
    return rep


N = int(input())
S = input()
ans = 0
for i in range(0, 1000):
    if canMakeNumber(i, str(S)):
        ans += 1
print(ans)

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

S_set = set(S)
ans = 0
for num in range(0, 1000):
    n0, n1, n2 = list(str(num).zfill(3))
    if n0 in S_set and n1 in S_set and n2 in S_set:
        idx0 = S.idx(n0)
        idx2 = N - S[::-1].idx(n2) - 1
        if idx0 < idx2:
            if n1 in S[idx0 + 1: idx2]:
                ans += 1
print(ans)
Problem p02898 (python)

Fixed submission:
n, k = map(int, input().split())
H = list(map(int, input().split()))
ans = 0
for h in H:
    if h >= k:
        ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
A = list(map(int, input().split()))
ans = [0] * n
for num, a in enumerate(A):
    ban = a + 1
    ans[ban - 2] = num + 1
ans = list(map(str, ans))
print(' '.join(ans))

Buggy submission (verdict: Runtime Error):
n = int(input())
if n % 2 == 0:
    a = n // 2
else:
    a = n // 2 + 1

print(a/n)
Problem p02909 (python)

Fixed submission:
s=input()
j=["Sunny","Cloudy","Rainy"]
j=j+j
print(j[j.index(s)+1])

Buggy submission (verdict: Runtime Error):
s=input()
j=["Sunny","Cloudy","Rainy"]
j=j+j
print(j[j.index(s)+1]
Problem p03006 (python)

Fixed submission:
N = int(input())
XY = [list(map(int, input().split())) for _ in range(N)]
if N == 1:
    print(1)
    exit()

XY.sort(key=lambda x: x[0])

PQ = {}

for i in range(N):
    x0, y0 = XY[i]
    for j in range(N):
        if i == j:
            continue
        x1, y1 = XY[j]
        p, q = x0 - x1, y0 - y1
        key = str(p) + ',' + str(q)
        if key in PQ:
            PQ[key] += 1
        else:
            PQ[key] = 1
ansL = PQ.values()
print(N - max(list(ansL)))

Buggy submission (verdict: Runtime Error):
N = int(input())
XY = [list(map(int, input().split())) for _ in range(N)]

XY.sort(key=lambda x: x[0])

PQ = {}

for i in range(N):
    x0, y0 = XY[i]
    for j in range(N):
        if i == j:
            continue
        x1, y1 = XY[j]
        p, q = x0 - x1, y0 - y1
        key = str(p) + ',' + str(q)
        if key in PQ:
            PQ[key] += 1
        else:
            PQ[key] = 1
ansL = PQ.values()
print(N - max(list(ansL)))
Problem p03026 (python)

Fixed submission:
import sys
from collections import deque
sys.setrecursionlimit(10**9)

N = int(input())
AB = [list(map(int, input().split())) for _ in range(N - 1)]
C = list(map(int, input().split()))

score = sum(C) - max(C)
C.sort(reverse=True)
C = deque(C)
con = [[] for _ in range(N + 1)]
ans = [0 for i in range(N + 1)]

for ab in AB:
    a, b = ab
    con[a].append(b)
    con[b].append(a)


def dfs(x):
    if len(C) == 0:
        return
    if ans[x] == 0:
        ans[x] = C[0]
        C.popleft()
        for c in con[x]:
            dfs(c)


dfs(1)
ans = list(map(str, ans))
print(score)
print(' '.join(ans[1:]))

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

N = int(input())
AB = [list(map(int, input().split())) for _ in range(N - 1)]
C = list(map(int, input().split()))
score = sum(C) - max(C)
C.sort(reverse=True)
C = deque(C)
con = [[] for _ in range(N + 1)]
ans = [0 for i in range(N + 1)]

for ab in AB:
    a, b = ab
    con[a].append(b)
    con[b].append(a)


def dfs(x):
    if len(C) == 0:
        return
    if ans[x] == 0:
        ans[x] = C[0]
        C.popleft()
        for c in con[x]:
            dfs(c)


dfs(1)
ans = list(map(str, ans))
print(score)
print(' '.join(ans[1:]))
Problem p03086 (python)

Fixed submission:
S = input()
S = S.replace('A', '*').replace('T', '*').replace('C', '*').replace('G', '*')

ans, count = 0, 0
for s in S:
    if s == '*':
        count += 1
        ans = max(ans, count)
    else:
        count = 0

print(ans)

Buggy submission (verdict: Runtime Error):
n = len(S)
ans_list = []
for i in range(n):
    for j in range(i + 1, n):
        T = S[i: j + 1]
        U = T.replace("A","").replace("C","").replace("G","").replace("T","")
        if U == "":
            ans_list.append(len(T))
print(max(ans_list))
Problem p03106 (python)

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

c=[]

for i in range(1,max(a,b)+1):
    if a % i == 0 and b % i == 0:
        c.append(i)
c.sort(reverse=True)

print(c[k-1])

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

aa =[]
bb=[]
cc=[]

for i in range(1,a):
    if a % i == 0:
        aa.append(i)

for i in range(1,b):
    if a % i == 0:
        bb.append(i)

if a==1:
    aa.append(1)

if b==1:
    bb.append(1)

cc=sorted(list(set(aa) & set(bb)),reverse=True)
print(cc[k-1])

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

aa =[]
bb=[]
cc=[]

for i in range(1,a):
    if a % i == 0:
        aa.append(i)

for i in range(1,b):
    if a % i == 0:
        bb.append(i)

if a==1:
    aa.append(1)

if b==1:
    bb.append(1)

cc=sorted(list(set(aa) & set(bb)))
print(cc[k-1])

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

aa =[]
bb=[]
cc=[]

for i in range(1,a):
    if a % i == 0:
        aa.append(i)

for i in range(1,b):
    if a % i == 0:
        bb.append(i)




cc=list(set(aa) & set(bb))
if cc==[]:
    print(1)
    exit()
print(cc[k-1])
Problem p03111 (python)

Fixed submission:
def Base_10_to_n(X, n):
    if (int(X/n)):
        return Base_10_to_n(int(X/n), n)+str(X%n)
    return str(X%n)

n,a,b,c=map(int,input().split())
L=[]
for _ in range(n):
    L.append(int(input()))

ans=99999
for i in range(4**len(L)):
    i_4_list=list(Base_10_to_n(i, 4).zfill(len(L)))
    at,bt,ct=[],[],[]
    for num,i_4 in enumerate(i_4_list):
        if i_4=='0':
            at.append(L[num])
        elif i_4=='1':
            bt.append(L[num])
        elif i_4=='2':
            ct.append(L[num])
        else:
            continue
    if min(len(at),len(bt),len(ct))>0:
        al=0
        al+=(len(at)+len(bt)+len(ct)-3)*10
        al+=(abs(sum(at)-a)+abs(sum(bt)-b)+abs(sum(ct)-c))
        if al < ans:
            ans=al
print(ans)

Buggy submission (verdict: Runtime Error):
def Base_10_to_n(X, n):
    if (int(X/n)):
        return Base_10_to_n(int(X/n), n)+str(X%n)
    return str(X%n)

n,a,b,c=map(int,input().split())
L=[]
for _ in range(n):
    L.append(int(input()))

ans=99999
for i in range(4**len(L)+1):
    i_4_list=list(Base_10_to_n(i, 4).zfill(len(L)))
    at,bt,ct=[],[],[]
    for num,i_4 in enumerate(i_4_list):
        if i_4=='0':
            at.append(L[num])
        elif i_4=='1':
            bt.append(L[num])
        elif i_4=='2':
            ct.append(L[num])
        else:
            continue
    if min(len(at),len(bt),len(ct))>0:
        al=0
        al+=(len(at)+len(bt)+len(ct)-3)*10
        al+=(abs(sum(at)-a)+abs(sum(bt)-b)+abs(sum(ct)-c))
        if al < ans:
            ans=al
print(ans)
Problem p03125 (python)

Fixed submission:
a,b=map(int,input().split())
print(a+b if b%a==0 else b-a)

Buggy submission (verdict: Runtime Error):
n=int(input())
a_s=list(map(int,input().split()))
while True:
    a_s=set(a_s)
    a_s.discard(0)
    a_s=list(a_s)
    index=a_s.index(min(a_s))
    for i in range(len(a_s)):
        if i!=index and min(a_s)!=0:
            a_s[i]=a_s[i]%min(a_s)
    if len(a_s)==1:
        break
print(sum(a_s))
Problem p03128 (python)

Fixed submission:
n,m=map(int,input().split())
A=list(input().split())
c=[0,2,5,5,4,5,6,3,7,6]

dp=['']*(n+1)
dp[0]=''
for i in range(1,n+1):
    max=''
    for j in range(m):
        if (i-c[int(A[j])]>0 and dp[i-c[int(A[j])]]!='') or (i-c[int(A[j])]==0):
            if len(dp[i-c[int(A[j])]]+A[j])>len(max):
                max=dp[i-c[int(A[j])]]+A[j]
            elif len(dp[i-c[int(A[j])]]+A[j])==len(max) and dp[i-c[int(A[j])]]+A[j]>max:
                max=dp[i-c[int(A[j])]]+A[j]
    dp[i]=max
print(dp[n])

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
A=list(input().split())
c=[0,2,5,5,4,5,6,3,7,6]

dp=['']*(n+1)
dp[0]=''
for i in range(1,n+1):
    max=''
    for j in range(m):
        if (i-c[int(A[j])]!=0 and dp[i-c[int(A[j])]]!='') or (i-c[int(A[j])]==0):
            if len(dp[i-c[int(A[j])]]+A[j])>len(max):
                max=dp[i-c[int(A[j])]]+A[j]
            elif len(dp[i-c[int(A[j])]]+A[j])==len(max) and dp[i-c[int(A[j])]]+A[j]>max:
                max=dp[i-c[int(A[j])]]+A[j]
    dp[i]=max
    #print(dp)
print(dp[n])
Problem p03145 (python)

Fixed submission:
x = input().split()
a = int(x[0])
b = int(x[1])
c = int(x[2])
s = int(a*b/2)
print(s)

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
TD = [list(map(int, input().split())) for _ in range(N)]

TD = sorted(TD, key=lambda x: x[0])

sushi0 = []
sushi1 = []

for i in range(N):
    if i == 0:
        sushi1.append(TD[0][1])
    else:
        if TD[i][0] == TD[i - 1][0]:
            sushi0.append(TD[i][1])
        else:
            sushi1.append(TD[i][1])

sushi0 = sorted(sushi0, reverse=True)
sushi1 = sorted(sushi1, reverse=True)

L = len(sushi1)
ans, rans = 0, 0
for i in range(1, L + 1):  # sushi1からi個選択 sushi0からは(K-i)個
    ans = sum(sushi1[0:i]) + (i**2) + sum(sushi0[0:K - i])
    rans = max(rans, ans)
print(rans)
Problem p03274 (python)

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

if N == 1:
    print(abs(X[0]))
    exit()


flg = False

for x in X:
    if x < 0:
        flg = True

if flg is False:
    print(X[K - 1])
    exit()

flag2 = False

for x in X:
    if x > 0:
        flag2 = True

if flag2 is False:
    X.reverse()
    print(abs(X[K - 1]))
    exit()


def sol(lft, rgt):
    if X[lft] < 0 and X[rgt] < 0:
        return float('inf')
    elif X[lft] <= 0:
        return min(2 * abs(X[lft]) + X[rgt], abs(X[lft]) + 2 * X[rgt])
    else:
        return float('inf')


lft, rgt = 0, 0
ans = float('inf')
while True:

    if rgt == N - 1:
        break

    if rgt - lft + 1 < K:
        rgt += 1
        if rgt - lft + 1 == K:
            ans = min(ans, sol(lft, rgt))
            lft += 1
print(ans)

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

if N == 1:
    print(abs(X[0]))
    exit()


flg = False

for x in X:
    if x < 0:
        flg = True

if flg is False:
    print(X[K - 1])
    exit()


def sol(lft, rgt):
    if X[lft] < 0 and X[rgt] < 0:
        return float('inf')
    elif X[lft] <= 0:
        return min(2 * abs(X[lft]) + X[rgt], abs(X[lft]) + 2 * X[rgt])
    else:
        return float('inf')


lft, rgt = 0, 0
ans = float('inf')
while True:

    if rgt == N:
        break

    if rgt - lft + 1 < K:
        rgt += 1
        if rgt - lft + 1 == K:
            ans = min(ans, sol(lft, rgt))
            lft += 1
print(ans)
Problem p03325 (python)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
B = 1
ans = 0
for i in range(N):
    for j in range(32, 0, -1):
        if A[i] % (2**j) == 0:
            ans += j
            A[i] = A[i] / (2**j)
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
B = 1
for a in A:
    if a % 2 == 0:
        B *= a
ans = 0
for i in range(100, 0, -1):
    if B % (2**i) == 0:
        ans += i
        B = B / (2**i)
print(ans)
Problem p03407 (python)

Fixed submission:
a,b,c=map(int,input().split())
print('Yes' if a+b >= c else 'No')

Buggy submission (verdict: Runtime Error):
a,b,c=map(int,input().split())
print('Yes' if a+b >= c else No)
Problem p03565 (python)

Fixed submission:
S, T = input(), input()
if len(T) > len(S):
    print('UNRESTORABLE')
    exit()

able_list = []

for i in range(len(S) - len(T) + 1):
    S_part = S[i:len(T) + i]
    for j in range(len(T)):
        if S_part[j] == T[j] or S_part[j] == '?':
            if j == len(T) - 1:
                able_list.append(S[0:i] + T + S[len(T) + i:])
            continue
        else:
            break

if not able_list:
    print('UNRESTORABLE')
    exit()

for i in range(len(able_list)):
    able_list[i] = able_list[i].replace('?', 'a')

able_list.sort()
print(able_list[0])

Buggy submission (verdict: Runtime Error):
S,T=input(),input()
s_list,t_list=list(reversed(list(S))),list(reversed(list(T)))
i=0
num=0
count=0
str=''
for i,s in enumerate(s_list):
    if num==len(T):
        end,start=i-1,i-len(T)
        break
    if s=='?' or s==t_list[num]:
        num+=1
        str+=s
    else:
        num,str=0,''
    if i==len(s_list)-1 and num<len(T):
        print('UNRESTORABLE')
        exit()
s_list[start:end+1]=t_list
print(''.join(s_list).replace('?','a')[::-1])

Buggy submission (verdict: Runtime Error):
S,T=input(),input()
s_list,t_list=list(reversed(list(S))),list(reversed(list(T)))
i=0
num=0
count=0
str=''
for i,s in enumerate(s_list):
    if num==len(T):
        end,start=i-1,i-len(T)
        break
    if s=='?' or s==t_list[num]:
        num+=1
        str+=s
    elif len(str)!=len(T):
        num,str=0,''
    if i==len(s_list)-1 and num<len(T):
        print('UNRESTORABLE')
        exit()
s_list[start:end+1]=t_list
print(''.join(s_list).replace('?','a')[::-1])
Problem p03607 (python)

Fixed submission:
import collections
n=int(input())
a=[input() for i in range(n)]
a_coll=dict(collections.Counter(a))
ans=0
for b in a_coll:
    if a_coll[b]%2==1:
        ans+=1
print(ans)

Buggy submission (verdict: Runtime Error):
import collections
start = time.time()
n=int(input())
a=[input() for i in range(n)]
a_coll=dict(collections.Counter(a))
ans=0
for b in a_coll:
    if a_coll[b]%2==1:
        ans+=1
print(ans)
Problem p03627 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10**9)
N = int(input())
A = list(map(int, input().split()))
A = sorted(A, reverse=True)


def chouhoukei(count, ans, num):
    if count == 4:
        return ans
    else:
        if num >= N - 1:
            return 0
        if A[num] == A[num + 1]:
            return chouhoukei(count + 2, ans * A[num], num + 2)
        else:
            return chouhoukei(count, ans, num + 1)


print(chouhoukei(0, 1, 0))

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10**10)
N = int(input())
A = list(map(int, input().split()))
A = sorted(A, reverse=True)


def chouhoukei(count, ans, num):
    if count == 4:
        return ans
    else:
        if num >= N:
            return 0
        if A[num] == A[num + 1]:
            return chouhoukei(count + 2, ans * A[num], num + 2)
        else:
            return chouhoukei(count, ans, num + 2)


print(chouhoukei(0, 1, 0))

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
A = sorted(A, reverse=True)


def chouhoukei(count, ans, num):
    if count == 4:
        return ans
    else:
        if num >= N:
            return 0
        if A[num] == A[num + 1]:
            return chouhoukei(count + 2, ans * A[num], num + 2)
        else:
            return chouhoukei(count, ans, num + 2)


print(chouhoukei(0, 1, 0))
Problem p03711 (python)

Fixed submission:
x,y=map(int,input().split())
a=[1,3,5,7,8,10,12]
b=[4,6,9,11]
c=[2]
d=[a,b,c]
for i in d:
    if x in i and y in i:
        print('Yes')
        exit()
print('No')

Buggy submission (verdict: Runtime Error):
x,y=map(int,input().split())
a=[1,3,5,7,8,10,12]
b=[4,6,9,11]
c=[2]
d=[a,b,c]
for i in d:
    if x in d[i] and y in d[i]:
        print('Yes')
        exit()
print('No')

Buggy submission (verdict: Runtime Error):
x,y=map(int,input().split())
a=[1,3,5,7,8,10,12]
b=[4,6,9,11]
c=[2]
if x,y in a or x,y in b or x,y in c:
    print('Yes')
else:
    print('No')
Problem p04013 (python)

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

# dp[i][j][k] i枚までj枚えらんで合計k
# 答えはdp[n][1..n][a..ak]
dp = [[[0] * 2700 for _ in range(52)]
      for __ in range(52)]

dp[0][0][0] = 1
for i in range(0, n):
    for j in range(0, n + 1):
        for k in range(n * max(X) + 1):
            dp[i + 1][j][k] += dp[i][j][k]  # 選ぶ
            dp[i + 1][j + 1][k + X[i]] += dp[i][j][k]  # 選ばない

ans = 0
for i in range(1, n+1):
    for j in range(a, 2501):
        if i * a == j:
            ans += dp[n][i][j]
print(ans)

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

# dp[i][j][k] i枚までj枚えらんで合計k
# 答えはdp[n][1..n][a..ak]
dp = [[[0] * 2502 for _ in range(52)]
      for __ in range(52)]

dp[0][0][0] = 1
for i in range(0, n):
    for j in range(0, n + 1):
        for k in range(n * max(X) + 1):
            dp[i + 1][j][k] += dp[i][j][k]  # 選ぶ
            dp[i + 1][j + 1][k + X[i]] += dp[i][j][k]  # 選ばない

ans = 0
for i in range(1, n+1):
    for j in range(a, 2501):
        if i * a == j:
            ans += dp[n][i][j]
print(ans)

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

# dp[i][j][k] i枚までj枚えらんで合計k
# 答えはdp[n][1..n][a..ak]
dp = [[[0] * 3500 for _ in range(51)]
      for __ in range(51)]

dp[0][0][0] = 1
for i in range(0, n):
    for j in range(0, n + 1):
        for k in range(n * max(X) + 1):
            dp[i + 1][j][k] += dp[i][j][k]  # 選ぶ
            dp[i + 1][j + 1][k + X[i]] += dp[i][j][k]  # 選ばない

ans = 0
for i in range(1, n+1):
    for j in range(a, 2501):
        if i * a == j:
            ans += dp[n][i][j]
print(ans)
Problem p04043 (python)

Fixed submission:
nums = list(map(int,input().split()))
if sum(nums) == 17 and 5 in nums and 7 in nums:
    print('YES')
else:
    print('NO')

Buggy submission (verdict: Runtime Error):
n = int(input())
print((1+n)*n/2)
Problem p03814 (python)

Fixed submission:
s = input()
a = s.index('A')
sr = s[::-1]
z = sr.index('Z')
print(len(s) - a - z)

Buggy submission (verdict: Runtime Error):
s = input()
a = s.index('a')
sr = s[::-1]
z = sr.index('z')
print(len(s) - a - z)

Buggy submission (verdict: Runtime Error):
s = input()
a = s.index('a')
sr = s[::-1]
z = sr.index('z')
print(s[a:-z])
Problem p02761 (python)

Fixed submission:
n, m = map(int, input().split())
d = {}
ok = True
for i in range(m):
    s, c = map(int, input().split())
    if s not in d:
        d[s] = c
    elif d[s] != c:
        ok = False
res = ''
if not ok:
    print(-1)
elif n == 1 and m == 0:
    print(0)
else:
    for i in range(1, n+1):
        if i not in d.keys():
            if res == '' or int(res) == 0:
                res += '1'
            else:
                res += '0'
        else:
            res += str(d[i])
    if len(res) == len(str(int(res))):
        print(res)
    else:
        print(-1)

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
d = {}
ok = True
for i in range(m):
    s, c = map(int, input().split())
    if s not in d:
        d[s] = c
    elif d[s] != c:
        ok = False
res = ''
if not ok:
    print(-1)
else:
    for i in range(1, n+1):
        if i not in d.keys():
            if int(res) == 0:
                res += '1'
            else:
                res += '0'
        else:
            res += str(d[i])
    if len(res) == len(str(int(res))):
        print(res)
    else:
        print(-1)
Problem p03160 (python)

Fixed submission:
import sys
sys.setrecursionlimit(1000000)

n = int(input())
h = list(map(int, input().split()))
cost = [-1] * n

def ans(n):
  if cost[n] != -1:
    return cost[n]
  cost[n] = min(ans(n-1) + abs(h[n-1] - h[n]), ans(n-2) + abs(h[n-2] - h[n]))
  return cost[n]

cost[0] = 0
cost[1] = abs(h[0] - h[1])
print(ans(n-1))

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

n = int(input())
h = list(map(int, input().split()))
cost = [-1] * n

def ans(n):
  if cost[n] != -1:
    return cost[n]
  cost[n] = min(ans(n-1) + abs(h[n-1] - h[n]), ans(n-2) + abs(h[n-2] - h[n]))
  return cost[n]

cost[0] = 0
cost[1] = abs(h[0] - h[1])
print(ans(n-1))

Buggy submission (verdict: Runtime Error):
n = int(input())
h = list(map(int, input().split()))
cost = [-1] * n

def ans(n):
  if cost[n] != -1:
    return cost[n]
  cost[n] = min(ans(n-1) + abs(h[n-1] - h[n]), ans(n-2) + abs(h[n-2] - h[n]))
  return cost[n]

cost[0] = 0
cost[1] = abs(h[0] - h[1])
print(ans(n-1))

Buggy submission (verdict: Runtime Error):
n = int(input())
h = list(map(int, input().split()))
cost = [-1 for i in range(n)]

def ans(k):
  if cost[k] != -1:
    return cost[k]
  cost[k] = min(ans(k-1) + abs(h[k-1] - h[k]), ans(k-2) + abs(h[k-2] - h[k]))
  return cost[k]

cost[0] = 0
cost[1] = abs(h[0] - h[1])
print(ans(n-1))

Buggy submission (verdict: Runtime Error):
n = int(input())
h = list(map(int, input().split()))
cost = [-1 for i in range(n)]

def ans(n):
  if cost[n] != -1:
    return cost[n]
  cost[n] = min(ans(n-1) + abs(h[n-1] - h[n]), ans(n-2) + abs(h[n-2] - h[n]))
  return cost[n]

cost[0] = 0
cost[1] = abs(h[0] - h[1])
print(ans(n-1))
Problem p02663 (python)

Fixed submission:
h1,m1,h2,m2,k=list(map(int,input().split()))
if m1==m2:
    m=0
    h=h2-h1
elif m2-m1>0:
    m=m2-m1
    h=h2-h1
else:
    m=60-m1+m2
    h=h2-h1-1
ans=(k-(m+h*60))*(-1)
if ans<=0:
    print(0)
else:
    print(ans)

Buggy submission (verdict: Runtime Error):
h1,m1,h2,m2,k=list(map(int,input().split()))
if m1=m2:
    m=0
    h=h2-h1
elif m2-m1>0:
    m=m2-m1
    h=h2-h1
else:
    m=60-m1+m2
    h=h2-h1-1
ans=k-m+h*60
if ans<=0:
    print(0)
else:
    print(ans)
Problem p02714 (python)

Fixed submission:
n=int(input())
s=input()

r_cnt=s.count("R")
g_cnt=s.count("G")
b_cnt=s.count("B")

ans=r_cnt*g_cnt*b_cnt

for i in range(n):
    for d in range(n):
        j=i+d
        k=j+d
        if k>=n:break
        if s[i]!=s[j] and s[j]!=s[k] and s[k]!=s[i]:
            ans -= 1

print(ans)

Buggy submission (verdict: Runtime Error):
print(sum([x for x in range(a,int(input())+1) if (x%3!=0)and(x%5!=0)]))
Problem p02717 (python)

Fixed submission:
x,y,z=list(map(int,input().split()))
print(z,x,y)

Buggy submission (verdict: Runtime Error):
x,y,z=list(map(int,input().split()))
a=x
b=y
c=z
print(c a b)