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

Fixed submission:
n = int(input())
T = [0] + [None] * n
X = [0] + [None] * n
Y = [0] + [None] * n
for i in range(1, n + 1):
  T[i], X[i], Y[i] = map(int, input().split())

for i in range(len(T) - 1):
  dt = T[i + 1] - T[i]
  dx = abs(X[i + 1] - X[i])
  dy = abs(Y[i + 1] - Y[i])
  if (dt % 2 == (dx + dy) % 2 and (dx + dy) <= dt):
    res = True
  else:
    print('No')
    exit()

print('Yes')

Buggy submission (verdict: Runtime Error):
n = int(input())
T = [0] + [None] * n
X = [0] + [None] * n
Y = [0] + [None] * n
for i in range(1, n + 1):
  T[i], X[i], Y[i] = map(int, input().split())

for i in range(len(T) - 1):
  dt = abs(T[i + 1] - T[i])
  dx = abs(X[i + 1] - X[i])
  dy = abs(Y[i + 1] - Y[i])
  if (dt % 2 == (dx + dy) % 2 and (dx + dy) <= dt):
    res = res and True
  else:
    res = False

if (res):
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
n = int(input())
T = [0] + [None] * n
X = [0] + [None] * n
Y = [0] + [None] * n
for i in range(1, n + 1):
  T[i], X[i], Y[i] = map(int, input().split())

for i in range(len(T) - 1):
  dt = T[i + 1] - T[i]
  dx = X[i + 1] - X[i]
  dy = Y[i + 1] - Y[i]
  if (dt % 2 == (dx + dy) % 2 and (dx + dy) <= dt):
    res = res and True
  else:
    res = False

if (res):
  print('Yes')
else:
  print('No')
Problem p03493 (python)

Fixed submission:
s = input()
print(s.count('1'))

Buggy submission (verdict: Runtime Error):
s = inupt()
print(s.count('1'))
Problem p03588 (python)

Fixed submission:
n = int(input())
A = [None] * n
B = [None] * n
for i in range(n):
    A[i], B[i] = list(map(int, input().split()))

print(A[B.index(min(B))] + min(B))

Buggy submission (verdict: Runtime Error):
n = int(input())
A = [None] * n
B = [None] * n
for i in range(n):
    A[i], B[i] = list(map(int, input().split()))

print(A[B.index(min_point)] + min(B))
Problem p03693 (python)

Fixed submission:
r, g, b = map(int, input().split())
if ((100 * r + 10 * g + b) % 4 == 0):
  print('YES')
else:
  print('NO')

Buggy submission (verdict: Runtime Error):
r, g, b = map(int, input().split())
if (100 * a + 10 * b + c % 4 == 0):
  print('YES')
else:
  print('NO')
Problem p03759 (python)

Fixed submission:
a, b, c = map(int, input().split())
d = b - a
e = c - b
if (d == e):
  print('YES')
else:
  print('NO')

Buggy submission (verdict: Runtime Error):
a, b, c = map(int, input().split())
if (b − a == c − b):
  print('YES')
else:
  print('NO')
Problem p03795 (python)

Fixed submission:
n = int(input())
print(800 * n - 200 * (n//15))

Buggy submission (verdict: Runtime Error):
n = input()
print(800 * n - 200 * (n//15))
Problem p02801 (python)

Fixed submission:
s = input()

l = [
    "a",
    "b",
    "c",
    "d",
    "e",
    "f",
    "g",
    "h",
    "i",
    "j",
    "k",
    "l",
    "m",
    "n",
    "o",
    "p",
    "q",
    "r",
    "s",
    "t",
    "u",
    "v",
    "w",
    "x",
    "y",
    "z"
]

print(l[l.index(s)+1])

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

l = [
    "a",
    "b",
    "c",
    "d",
    "e",
    "f",
    "g",
    "h",
    "i",
    "j",
    "k",
    "l",
    "m",
    "n",
    "o",
    "p",
    "q",
    "r",
    "s",
    "t",
    "u",
    "v",
    "w",
    "x",
    "y",
]

print(l[l.index(s)+1])
Problem p02910 (python)

Fixed submission:
s = input()

flg = 0
for i, c in enumerate(s):
  if i%2!=0:
    if c in ["L", "U", "D"]:
      continue
    else:
      flg = 1
      break
  else:
    if c in ["R", "U", "D"]:
      continue
    else:
      flg = 1
      break

ans = "Yes" if not flg else "No"
print(ans)

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

flg = 0
for i, c in enumrate(range(s)):
  if i%2!=0:
    if c in ["R", "U", "D"]:
      continue
    else:
      flg = 1
      break
  else:
    if c in ["R", "U", "D"]:
      continue
    else:
      flg = 1
      break
    
ans = "Yes" if flg else "No"
print(ans)
Problem p03557 (python)

Fixed submission:
import sys

import time


def main():
        n = sys.stdin.readline()

        astr = sys.stdin.readline()
        bstr = sys.stdin.readline()
        cstr = sys.stdin.readline()

        a = list(map(int, astr.strip().split(' ')))
        b = list(map(int, bstr.strip().split(' ')))
        c = list(map(int, cstr.strip().split(' ')))

        a.sort()
        b.sort()
        c.sort()

        cnt = 0

        bc = []
        sum = 0
        timesum = 0
        for bi in reversed(b):
                sum += len(c) - binary(bi,c)
                bc.append(sum)
        bc.reverse()

        cnt = 0
        for ai in a:
                bi = binary(ai, b)
                if(bi < len(bc)):
                    cnt += bc[bi]

        print(cnt)


def binary(x, li):
    upper = len(li)
    lower = -1
    index = int((upper + lower) / 2)

    while upper - lower > 1:
        if (x < li[index]):
            upper = index
        else:
            lower = index
        index = int((upper + lower)/2)
    
    return upper


main()

Buggy submission (verdict: Runtime Error):
import sys


def main():
        n = sys.stdin.readline()

        astr = sys.stdin.readline()
        bstr = sys.stdin.readline()
        cstr = sys.stdin.readline()

        a = list(map(int, astr.strip().split(' ')))
        b = list(map(int, bstr.strip().split(' ')))
        c = list(map(int, cstr.strip().split(' ')))

        a.sort()
        b.sort()
        c.sort()

        cnt = 0

        bc = []
        sum = 0
        for bi in reversed(b):
                ct = c[binary(bi, c):]
                sum += len(ct)
                bc.append(sum)
        bc.reverse()

        cnt = 0
        for ai in a:
                bi = binary(ai, b)
                cnt += bc[bi]

        print(cnt)


def binary(x, li):
    upper = len(li)
    lower = -1
    index = int((upper + lower) / 2)


    while upper - lower > 1:
        if (x < li[index]):
            upper = index
        else:
            lower = index
        index = int((upper + lower)/2)
    
    return upper


main()
Problem p03309 (python)

Fixed submission:
# C - Linear Approximation
# https://beta.atcoder.jp/contests/abc102/tasks/arc100_a

# C_Linear_Approximation.py

# 7
# 1 1 1 1 2 3 4
#import sys

N = int(input())
a = list(map(int, input().strip().split(" ")))

for i in range(N):
    a[i] = a[i] - (i+1)

a.sort()
if N % 2 != 0:
    mid = (N-1)//2
else:
    mid = N // 2 -1
b = a[mid]

sadness_left = b * mid - sum(a[:mid])
sadness = sum(a) - b * N + sadness_left * 2

print(sadness)

Buggy submission (verdict: Runtime Error):
# C - Linear Approximation
# https://beta.atcoder.jp/contests/abc102/tasks/arc100_a

# C_Linear_Approximation.py

# 7
# 1 1 1 1 2 3 4
#import sys

N = int(input())
a = list(map(int, input().strip().split(" ")))

for i in range(N):
    a[i] = a[i] - (i+1)

a.sort()
if N % 2 != 0:
    mid = (N-1)/2 +1
else:
    mid = N / 2
b = a[mid]

sadness_left = b * (mid-1) - sum(a[:mid])
sadness = sum(a) - b * N + sadness_left * 2

print(sadness)
Problem p03316 (python)

Fixed submission:
# https://beta.atcoder.jp/contests/abc101/tasks/abc101_b
# B - Digit Sums

# B_Digit_Sums.py

N = int(input())
str_N = str(N)

S_N = 0
for i in range(len(str_N)):
    S_N += ( N % (10 ** (i+1)) ) // (10 ** i)

if N % S_N == 0:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
# https://beta.atcoder.jp/contests/abc101/tasks/abc101_b
# B - Digit Sums

# B_Digit_Sums.py

N = int(input())
str_N = str(N)

S_N = 0
for i in range(str_N):
    S_N += ( N % (10 ** (i+1)) ) // ( N // (10 ** i) )
print(S_N)
Problem p03324 (python)

Fixed submission:
# https://abc100.contest.atcoder.jp/tasks/abc100_b
# B - Ringos Favorite Numbers

# B_Ringos_Favorite_Numbers.py

D, N = map(int, input().strip().split(" "))

if D == 0:
    #n = N
    #order_100 = -1
    #while n >= 1:
    #    n = n / 100
    #    order_100 += 1

    #if order_100 == 0:
    if N <= 99:
        print(N)
    else:
        print(101)

elif D == 1:
    if N <= 99:
        print(N*100)
    else:
        print(10100)
elif D == 2:
    if N <= 99:
        print(N*10000)
    else:
        print(1010000)

Buggy submission (verdict: Runtime Error):
# https://abc100.contest.atcoder.jp/tasks/abc100_b
# B - Ringos Favorite Numbers

# B_Ringos_Favorite_Numbers.py

D, N = map(int, input().strip().split(" "))

if D == 0:
    print(N)
else:
    if D == 1:
        n = [i*100 for i in range(1, 100)]
    else:
        n = [i*10000 for i in range(1, 100)]
    print(n[N-1])

Buggy submission (verdict: Runtime Error):
#
# B - Ringo's Favorite Numbers

# B_Ringos_Favorite_Numbers.py

m = 100

D, N = map(int, input().strip().split(" "))


if D == 0:
    print(N)
else:
    if D == 1:
        n = [i*100 for i in range(1, 100)]
    else:
        n = [i*10000 for i in range(1, 100)]
    print(n[N-1])
Problem p02789 (python)

Fixed submission:
if len(set(input().split()))==1:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
if len(set(input().split()))1:
    print("Yes")
else:
    print("No")
Problem p02801 (python)

Fixed submission:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import string
print(string.ascii_lowercase[string.ascii_lowercase.index(input())+1])

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import string
print(string.ascii_lowercase[string.ascii_lowercase.index(input()+1])
Problem p02850 (python)

Fixed submission:
n=int(input())
path_color=[None]*(n-1)
tree_path=[[] for x in range(n)]
path_num_to_edges=[]
tree_edge_flag=set()
for i in range(n-1):
    ai,bi=[int(x) -1 for x in input().split()]
    tree_path[ai].append((bi,i))
    tree_path[bi].append((ai,i))
    path_num_to_edges.append((ai,bi))

path_color[0]=1
from collections import deque
d=deque()
for i in path_num_to_edges[0]:
    d.append(i)
while d:
    temp_edge=d.pop()
    if temp_edge in tree_edge_flag:
        continue
    tree_edge_flag.add(temp_edge)
    new_path_color=1
    for other_edge,path_num in tree_path[temp_edge]:
        if path_color[path_num]!=None:
            old_color=path_color[path_num]
            break
    for other_edge,path_num in tree_path[temp_edge]:
        if path_color[path_num]!=None:
            continue
        if new_path_color==old_color:
            new_path_color+=1
        path_color[path_num]=new_path_color
        new_path_color+=1
        d.append(other_edge)

print(max(path_color))
for i in path_color:
    print(i)

Buggy submission (verdict: Runtime Error):
n=int(input())
path_color=[None]*(n-1)
tree_path=[[] for x in range(n)]
path_num_to_edges=[]
tree_edge_flag=set()
for i in range(n-1):
    ai,bi=[int(x) -1 for x in input().split()]
    tree_path[ai].append((bi,i))
    tree_path[bi].append((ai,i))
    path_num_to_edges.append((ai,bi))

path_color[0]=1
from collections import deque
d=deque()
d.append(0)
while d:
    temp=d.pop()
    temp_color=path_color[temp]
    edges=path_num_to_edges[temp]
    for edge in edges:
        new_path_color=1
        if edge in tree_edge_flag:
            continue
        tree_edge_flag.add(edge)
        for other_edge,path_num in tree_path[edge]:
            if path_color[path_num]!=None:
                continue
            if other_edge in tree_edge_flag:
                continue
            tree_edge_flag.add(other_edge)
            if new_path_color==temp_color:
                new_path_color+=1
            path_color[path_num]=new_path_color
            new_path_color+=1
            d.append(path_num)


print(max(path_color))
for i in path_color:
    print(i)
Problem p02995 (python)

Fixed submission:
def divide(num):
    return b//num - (a-1)//num
import fractions
a,b,c,d=map(int,input().split())
lcm=c*d//fractions.gcd(c,d)
print(b - (a - 1) - (divide(c) + divide(d) - divide(lcm)))

Buggy submission (verdict: Runtime Error):
def divide(num):
    return b//num - (a-1)//num
import math
a,b,c,d=map(int,input().split())
lcm=c*d//math.gcd(c,d)
print(b - (a - 1) - (divide(c) + divide(d) - divide(lcm)))
Problem p03061 (python)

Fixed submission:
n=int(input())
a=[int(x) for x in input().split()]
anses=set()
for i in [0,1]:
    for j in range(1, int(a[i]**0.5)+1):
        if a[i] % j == 0:
            anses.add(j)
            if j != a[i] // j:
                anses.add(a[i] // j)
anses=sorted(anses,reverse=True)
for ans in anses:
    solvenum=0
    for j in a:
        if j%ans==0:
            solvenum+=1
    if solvenum==n or solvenum==n-1:
        print(ans)
        break

Buggy submission (verdict: Runtime Error):
# coding: utf-8
# Your code here!
n=int(input())
a=[int(x) for x in input().split()]
from collections import defaultdict
import math
d=defaultdict(int)
num_n=[]
num_n_1=[]
for ai in a:
    for i in range(1,int(math.sqrt(ai))+1):
        if ai%i==0:
            d[i]+=1
            d[ai//i]+=1
for key in d.keys():
    if d[key]==n:
        num_n.append(key)
    elif d[key]==n-1:
        num_n_1.append(key)
anses=[]
if num_n_1:
    anses.append(max(num_n_1))
if num_n:
    anses.append(max(num_n))
print(max(anses))
Problem p03105 (python)

Fixed submission:
a,b,c=[int(x) for x in input().split()]
print(min(b//a,c))

Buggy submission (verdict: Runtime Error):
a,b,c=[int(x) for x input().split()]
print(b//a,c)
Problem p03240 (python)

Fixed submission:
n=int(input())
x,y,h=[],[],[]
for _ in [0]*n:
    xi,yi,hi=[int(x) for x in input().split()]
    x.append(xi)
    y.append(yi)
    h.append(hi)
diff = 0
if min(h)>=10:
    diff=min(h)-5
h=[i-diff for i in h]
# print(h)
def pattern(cx,cy,H):
    for i in range(n):
        # print(cx,x[i],cy,y[i],H,h[i],max(H-abs(x[i]-cx)-abs(y[i]-cy),0))
        if max(H-abs(x[i]-cx)-abs(y[i]-cy),0)!=h[i]:
            return False
    return True
from itertools import product
for H in range(1,1000):
    for cx,cy, in product(range(101),range(101)):
        if pattern(cx,cy,H):
            print(cx,cy,H+diff)
            import sys
            sys.exit()

Buggy submission (verdict: Runtime Error):
3
99 1 191
100 1 192
99 0 192
Problem p03281 (python)

Fixed submission:
n=int(input())
print(len([i for i in range (1,n+1) if i%2 == 1 and len([1 for x in range(1,i+1) if i%x==0]) == 8]))

Buggy submission (verdict: Runtime Error):
n=int(input())
print(len([i for i in range (1,int(input())+1) if i%2 == 1 and len([1 for x in range(1,i+1) if i%x==0]) == 8]))
Problem p03294 (python)

Fixed submission:
n=int(input())
a=[int(x) for x in input().split()]
print(sum([(ai-1)%ai for ai in a]))

Buggy submission (verdict: Runtime Error):
# coding: utf-8
# Your code here!
n=int(input())
a=[int(x) for x in input().split()]
import math
def prod(lists):
    ans=1
    for i in lists:
        ans=ans*i
    return ans
def gcd(numbers):
    ans=numbers[0]
    for i in numbers:
        ans=math.gcd(ans,i)
    return ans
lcm=prod(a)//gcd(a)
print(sum([(lcm-1)%ai for ai in a]))

Buggy submission (verdict: Runtime Error):
n=int(input())
a=[int(x) for x in input().split()]
import math
def prod(lists):
    ans=1
    for i in lists:
        ans=ans*i
    return ans
def gcd(numbers):
    ans=numbers[0]
    for i in numbers:
        ans=math.gcd(ans,i)
    return ans
lcm=prod(a)//gcd(a)
print(sum([(lcm-1)%ai for ai in a]))

Buggy submission (verdict: Runtime Error):
n=int(input())
a=[int(x) for x in input().split()]
import math
def prod(lists):
    ans=1
    for i in lists:
        ans=ans*i
    return ans
def gcd(numbers):
    ans=numbers[0]
    for i in numbers:
        ans=math.gcd(ans,i)
    return ans
lcm=prod(a)//gcd(a)
print(sum([(lcm-1)%ai for ai in a]))

Buggy submission (verdict: Runtime Error):
n=int(input())
a=[int(x) for x in input().split()]
import math
from functools import reduce
def prod(lists):
    ans=1
    for i in lists:
        ans=ans*i
    return ans
def gcd(numbers):
    return reduce(math.gcd, numbers)
lcm=prod(a)//gcd(a)
print(sum([(lcm-1)%ai for ai in a]))

Buggy submission (verdict: Runtime Error):
n=int(input())
a=[int(x) for x in input().split()]
import math
from functools import reduce,partial
import operator
prod = partial(reduce, operator.mul)
def gcd(numbers):
    return reduce(math.gcd, numbers)
lcm=prod(a)//gcd(a)
print(sum([(lcm-1)%ai for ai in a]))

Buggy submission (verdict: Runtime Error):
n=int(input())
a=[int(x) for x in input().split()]
import numpy as np
import math
from functools import reduce,partial
import operator
prod = partial(reduce, operator.mul)
def gcd(numbers):
    return reduce(math.gcd, numbers)
lcm=prod(a)//gcd(a)
print(sum([(lcm-1)%ai for ai in a]))

Buggy submission (verdict: Runtime Error):
n=int(input())
a=[int(x) for x in input().split()]
import numpy as np
import math
from functools import reduce
def gcd(numbers):
    return reduce(math.gcd, numbers)
lcm=np.prod(a)//gcd(a)
print(sum([(lcm-1)%ai for ai in a]))
Problem p03302 (python)

Fixed submission:
a,b=[int(x) for x in input().split()]
if a+b==15:
    print("+")
elif a*b==15:
    print("*")
else:
    print("x")

Buggy submission (verdict: Runtime Error):
a,b=[int(x) for x in input()]
if a+b==15:
    print("+")
elif a*b==15:
    print("*")
else:
    print("x")
Problem p03324 (python)

Fixed submission:
d,n=[int(x) for x in input().split()]
if n==100:
    n+=1
if d==0:
    print(n)
elif d==1:
    print(100*n)
else:
    print(n*100**2)

Buggy submission (verdict: Runtime Error):
if n==100:
    n+=1
if d==0:
    print(n)
elif d==1:
    print(100*n)
else:
    print(n*100**2)
Problem p03359 (python)

Fixed submission:
a,b=[int(x) for x in input().split()]
if a<=b:
    print(a)
else:
    print(a-1)

Buggy submission (verdict: Runtime Error):
a,b=[int(x) for x input().split()]
if a<=b:
    print(a)
else:
    print(a-1)
Problem p03060 (python)

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

W = [v-c for v, c in zip(V, C) if (v-c) > 0]
print(sum(W))

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

W = [v-c for v, c in zip(V, C) if (v-c) > 0]
print(sum(W)
Problem p03068 (python)

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

t = S[K-1]
newS = [s if s == t else '*' for s in S]
print(''.join(newS))

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

t = S[K]
newS = [s if s == t else '*' for s in S]
print(''.join(newS))
Problem p03076 (python)

Fixed submission:
nums = [int(input()) for _ in range(5)]

h = [i % 10 for i in nums if i%10 != 0]
min1 = 0 if len(h)==0 else min(h)

amount = 0
last = True
for i in nums:
  if last and i% 10 == min1:
    amount += i
    last = False
  else:
    amount += (i //10 + 1)*10 if i %10 != 0 else (i//10)*10
print(amount)

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

min1 = min([i % 10 for i in nums if i%10 != 0])

amount = 0
last = True
for i in nums:
  if last and i% 10 == min1:
    amount += i
    last = False
  else:
    amount += (i //10 + 1)*10 if i %10 != 0 else (i//10)*10
print(amount)
Problem p03106 (python)

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

for i in range(min(A,B), 0, -1):
  if (A % i == 0) and (B%i == 0):
    K-=1
  if K == 0:
    print(i)
    sys.exit()

Buggy submission (verdict: Runtime Error):
import sys
A, B, K = map(int, input().split())

s = 0
def sp(R):
  if R==1:
    return {1:1}
  dic = {}
  I = int(R)
  s=0
  while s==0:
    for i in range(2, R+1):
      if I%i==0:
        I=I/i
        if I==1:
          s=1
        if i not in dic:
          dic[i] = 0
        dic[i] += 1
        break
  return dic

a = sp(A)
b = sp(B)
c = []

if A == 1 and B == 1:
  print(1)
  sys.exit()
elif A == 1:
  for i in range(0, max(b.keys())+1):
    if i in b:
      t = b[i]
      c.append([i**j for j in range(t+1)])
elif B == 1:
  for i in range(0, max(a.keys())+1):
    if (i in a):
      t = a[i]
      c.append([i**j for j in range(t+1)])
else:
  for i in range(0, max(max(a.keys()), max(b.keys()))+1):
    if (i in a) and (i in b):
      t = min(a[i], b[i])
      c.append([i**j for j in range(t+1)])

arr = []
import itertools
from functools import reduce
for i in itertools.product(*c):
  v = reduce(lambda x,y:x*y,i)
  if v not in arr:
    arr.append(v)

arr.sort(reverse=True)

print(arr[K-1])

Buggy submission (verdict: Runtime Error):
A, B, K = map(int, input().split())

s = 0
def sp(R):
  if R == 1:
    return {1:1}
  dic = {}
  I = int(R)
  s=0
  while s==0:
    for i in range(2, R+1):
      if I%i==0:
        I=I/i
        if I==1:
          s=1
        if i not in dic:
          dic[i] = 0
        dic[i] += 1
        break
  return dic

a = sp(A)
b = sp(B)

c = []
for i in range(0, max(max(a.keys()), max(b.keys()))+1):
  if (i in a) and (i in b):
    t = min(a[i], b[i])
    c.append([i**j for j in range(t+1)])

arr = []
import itertools
from functools import reduce
for i in itertools.product(*c):
  v = reduce(lambda x,y:x*y,i)
  if v not in arr:
    arr.append(v)

arr.sort(reverse=True)

print(arr[K-1])
Problem p03160 (python)

Fixed submission:
N = int(input())
h = [int(i) for i in input().split()]+[0 for _ in range(2)]
dp = [float('inf') for _ in range(N+2)]

dp[0] = 0
for i in range(N-1):
  dp[i+1] = min(dp[i]+abs(h[i]-h[i+1]), dp[i+1])
  dp[i+2] = min(dp[i]+abs(h[i]-h[i+2]), dp[i+2])
print(dp[N-1])

Buggy submission (verdict: Runtime Error):
N = int(input())
H = list(map(int,input().split())) + [0]
dp = [-1]*N

def dfs(pos):
  if pos >= N:
    return 99999999
  if pos == N-1:
    return 0
  if dp[pos] != -1:
    return dp[pos]
  s1 = dfs(pos+1) + abs(H[pos+1] - H[pos])
  s2 = dfs(pos+2) + abs(H[pos+2] - H[pos])
  dp[pos] = min(s1, s2)
  return dp[pos]

print(dfs(0))

Buggy submission (verdict: Runtime Error):
N = int(input())
H = list(map(int,input().split()))
dp = [-1]*N

def dfs(pos):
  if pos >= N:
    return 99999999
  if pos == N-1:
    return 0
  if pos == N-2:
    return abs(H[pos+1] - H[pos])
  if dp[pos] != -1:
    return dp[pos]
  s1 = dfs(pos+1) + abs(H[pos+1] - H[pos])
  s2 = dfs(pos+2) + abs(H[pos+2] - H[pos])
  dp[pos] = min(s1, s2)
  return dp[pos]

print(dfs(0))
Problem p03162 (python)

Fixed submission:
N= int(input())
X = [list(map(int, input().split())) for _ in range(N)]
L = 3
dp = [[0 for _ in range(3)] for _ in range(N+1)]

dp[0] = [0,0,0]
for i in range(N):
  dp[i+1] = [max([dp[i][k] for k in range(L) if k != j]) + X[i][j] for j in range(L)]

print(max(dp[-1]))

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

dp = [-1]*N

def dfs(i, prev):
    if i >= N:
      return 0
    maxp = -99999999
    for j in range(3):
      if prev == j:
        continue
      maxp = max(maxp, dfs(i+1, j) + T[i][j])
    return maxp

print(dfs(0,-1))
Problem p02786 (python)

Fixed submission:
import math
h = int(input())
c = 0
while h > 1:
    h /= 2
    c += 1
if h == 1:
    print(int("1"*(c+1),2))
else:
    print(int("1"*c,2))

Buggy submission (verdict: Runtime Error):
import math
h = int(input())
i = int(math.ceil(h/2))
print(int("1"*(i+1), 2))
Problem p02817 (python)

Fixed submission:
A, B = input().split()
print(B+A)

Buggy submission (verdict: Runtime Error):
import itertools
N,M = map(int,input().split())
A = sorted(map(int,input().split()))[::-1]

print(sum(sorted([sum(i) for i in itertools.product(A, repeat=2)])[::-1][:M]))
Problem p03079 (python)

Fixed submission:
s = input().split(" ")
if s[0] == s[1] == s[2]:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
s = input().split("")
if s[0] == s[1] == s[2]:
  print("Yes")
else:
  print("No")