ZhenlongDai/ACPR huggingface dataset:
Problem: p03160
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
N = int(input())
*h, = map(int, input().split())

dp = [0] * N
dp[1] = h[1] - h[0]
for i in range(2, N):
    c1, c2 = abs(h[i - 1] - h[i]) + dp[i - 1], abs(h[i - 2] - h[i]) + dp[i - 2]
    if c1 < c2:
        dp[i] = c1
    else:
        dp[i] = c2

print(dp[N - 1])


Failing test case input:
4
34 11 -4 -1

Expected output:
35


Actual output:
-11


Fixed submission (verdict: Accepted):
N = int(input())
*h, = map(int, input().split())

dp = [0] * N
dp[1] = abs(h[1] - h[0])
for i in range(2, N):
    c1, c2 = abs(h[i - 1] - h[i]) + dp[i - 1], abs(h[i - 2] - h[i]) + dp[i - 2]
    if c1 < c2:
        dp[i] = c1
    else:
        dp[i] = c2

print(dp[N - 1])

Problem: p03160
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())

steps = [int(i) for i in input().split()]
dp = ['inf'] * n

dp[0:2] = steps[0], abs(steps[0] - steps[1])

for i in range(2, n):
    if dp[i-2] + abs(steps[i] - steps[i-2]) >= dp[i-1] + abs(steps[i] - steps[i-1]):
        dp[i] = dp[i-1] + abs(steps[i] - steps[i-1])
    else:
        dp[i] = dp[i-2] + abs(steps[i] - steps[i-2])

print(dp[n-1])

Failing test case input:
6
2 0 18 50 65 14

Expected output:
84


Actual output:
86


Fixed submission (verdict: Accepted):
n = int(input())

steps = [int(i) for i in input().split()]
dp = ['inf'] * n

dp[0:2] = 0, abs(steps[0] - steps[1])

for i in range(2, n):
    if dp[i-2] + abs(steps[i] - steps[i-2]) >= dp[i-1] + abs(steps[i] - steps[i-1]):
        dp[i] = dp[i-1] + abs(steps[i] - steps[i-1])
    else:
        dp[i] = dp[i-2] + abs(steps[i] - steps[i-2])

print(dp[n-1])

Problem: p03160
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N=int(input())

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

pos = 0

cost = [0]

for i in range(1,N):
  back_1 = abs(h_list[i] - h_list[i-1])
  if i>1:
    back_2 = abs(h_list[i] - h_list[i-2])
  if i>1:
    cost.append( (back_2 + cost[i-2] )if back_1 > back_2 else (back_1 + cost[i-1]))
  else:
    cost.append( back_1 + cost[i-1])
  
print(cost[N-1])

Failing test case input:
6
3 0 1 45 52 10

Expected output:
81


Actual output:
83


Fixed submission (verdict: Accepted):
N=int(input())

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

pos = 0

cost = [0]

for i in range(1,N):
  back_1 = abs(h_list[i] - h_list[i-1])
  if i>1:
    back_2 = abs(h_list[i] - h_list[i-2])
  if i>1:
    cost.append( (back_2 + cost[i-2] )if (back_1 + cost[i-1]) > (back_2 + cost[i-2] ) else (back_1 + cost[i-1]))
  else:
    cost.append( back_1 + cost[i-1])
    
  
print(cost[N-1])
Problem: p03160
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
costlist = list(map(int,input().split()))
DP = [0 for i in range(N)]
DP[1]=abs(costlist[1]-costlist[0])
for i in range(N-2):
    probmin1 = abs(costlist[i+2]-costlist[i+1]) + costlist[i+1]
    probmin2 = abs(costlist[i+2]-costlist[i]) + costlist[i]
    plusmin = min(probmin1,probmin2) 
    DP[i+2]=plusmin
print(DP[-1])

Failing test case input:
4
-2 1 2 -52

Expected output:
56


Actual output:
54


Fixed submission (verdict: Accepted):
N = int(input())
costlist = list(map(int,input().split()))
DP = [0 for i in range(N)]
DP[1]=abs(costlist[1]-costlist[0])
for i in range(N-2):
    probmin1 = abs(costlist[i+2]-costlist[i+1]) + DP[i+1]
    probmin2 = abs(costlist[i+2]-costlist[i]) + DP[i]
    plusmin = min(probmin1,probmin2) 
    DP[i+2]=plusmin
print(DP[-1])

Problem: p03160
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
li=[int(k) for k in input().split()]
dp=[0]*(n)
dp[0]=li[0]
dp[1]=abs(li[1]-li[0])
for i in range(2,n):
  dp[i]=min(abs(li[i]-dp[i-1]),abs(li[i]-dp[i-2]))
print(dp[n-1]) 


Failing test case input:
4
30 283 0 7

Expected output:
37


Actual output:
23


Fixed submission (verdict: Accepted):
n=int(input())
li=[int(k) for k in input().split()]
dp=[0]*(n)
dp[0]=0
dp[1]=abs(li[1]-li[0])

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

print(dp[n-1])

Problem: p03160
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
H = list(map(int,input().split(' ')))
dp = [float('inf')]*N
dp[0] = 0
dp[1] = abs(H[1] - H[0])

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


Failing test case input:
4
2 77 54 37

Expected output:
69


Actual output:
52
69
69


Fixed submission (verdict: Accepted):
N = int(input())
H = list(map(int,input().split(' ')))
dp = [float('inf')]*N
dp[0] = 0
dp[1] = abs(H[1] - H[0])

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

print(dp[-1])

Problem: p03160
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
n = int(input())

l = [0] + [int(i) for i in input().split()]

ans = [0]*(n+2)

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


print(ans[-2])

Failing test case input:
2
14 2

Expected output:
12


Actual output:
2


Fixed submission (verdict: Accepted):
n = int(input())

l = [int(i) for i in input().split()]

ans = [0]*(n+1)
ans[1] = abs(l[0]-l[1])
for i in range(2,n):
    ans[i]=min(ans[i-1]+abs(l[i-1]-l[i]),ans[i-2]+abs(l[i-2]-l[i]))


print(ans[-2])
Problem: p03160
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
N=int(input())
K=1
h=[int(i) for i in input().split()]
dp=[float("inf")]*N
dp[0]=0
for i in range(N):
  for k in range(1,K+1):
    if i+k>=N:
      break
    dp[i+k]=min(dp[i+k],dp[i]+abs(h[i]-h[i+k]))
print(dp[N-1])
    


Failing test case input:
4
10 30 40 20

Expected output:
30

Actual output:
50


Fixed submission (verdict: Accepted):
N=int(input())
K=2
h=[int(i) for i in input().split()]
dp=[float("inf")]*N
dp[0]=0
for i in range(N):
  for k in range(1,K+1):
    if i+k>=N:
      break
    dp[i+k]=min(dp[i+k],dp[i]+abs(h[i]-h[i+k]))
print(dp[N-1])

Problem: p03160
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
import math

N = int(input())
h = list(map(int, input().split()))

dp = list([math.inf for i in range(N)])  
dp[0] = 0
for i in range(N):
    a = dp[i]
    b = dp[i - 1] + abs(h[i] - h[i - 1])
    if a > b:
        dp[i] = b
    else:
        dp[i] = a
    if i > 1:
        b2 = dp[i - 2] + abs(h[i] - h[i - 2])
        if a > b2:
            dp[i] = b2
        else:
            dp[i] = a

print(dp[N - 1])


Failing test case input:
6
30 10 60 10 60 57

Expected output:
33


Actual output:
67


Fixed submission (verdict: Accepted):
import math

N = int(input())
h = list(map(int, input().split()))

dp = list([math.inf for i in range(N)])  
dp[0] = 0
for i in range(N):
    a = dp[i]
    b = dp[i - 1] + abs(h[i] - h[i - 1])
    if a > b:
        dp[i] = b
    else:
        dp[i] = a
    a = dp[i]
    if i > 1:
        b2 = dp[i - 2] + abs(h[i] - h[i - 2])
        if a > b2:
            dp[i] = b2
        else:
            dp[i] = a

print(dp[N - 1])

Problem: p03160
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import sys






input = sys.stdin.readline
N = int(input())
H = list(map(int,input().split()))

dp = 0
i = 0
while i<N-1:
    if i == N-2:
        dp += abs(H[N-1]-H[i])
        break
    if abs(H[i+1]-H[i]) < abs(H[i+2]-H[i]):
        dp += abs(H[i+1]-H[i])
        i += 1
    else:
        dp += abs(H[i+2]-H[i])
        i += 2
print(dp)
        

Failing test case input:
4
8 146 162 28

Expected output:
256


Actual output:
288


Fixed submission (verdict: Accepted):
import sys



input = sys.stdin.readline
N = int(input())
H = list(map(int,input().split()))

dp = 0
i = 0
dp = [0]*(N)
for i in range(1,N):
    if i ==1:
        dp[i] = dp[i-1] + abs(H[i]-H[i-1])
        continue
    dp[i] = min(dp[i-1] + abs(H[i]-H[i-1]),dp[i-2] + abs(H[i]-H[i-2]))

print(dp[N-1])

Problem: p03160
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
hL = list(map(int, input().split()))

dp = [10**10] * (n+1)
dp[0] = 0
dp[1] = hL[0]
dp[2] = min(abs(hL[1]-hL[0]), hL[1])
for i in range(3,n+1):
    dp[i] = min(dp[i-1]+abs(hL[i-1]-hL[i-2]), dp[i-2]+abs(hL[i-1]-hL[i-3]))
print(dp[n])


Failing test case input:
4
43 11 -2 2

Expected output:
41


Actual output:
20


Fixed submission (verdict: Accepted):
n = int(input())
hL = list(map(int, input().split()))

dp = [10**10]*n
dp[0] = 0
dp[1] = abs(hL[1] - hL[0])
for i in range(2,n):
    dp[i] = min(dp[i-1]+abs(hL[i]-hL[i-1]), dp[i-2]+abs(hL[i]-hL[i-2]))
print(dp[n-1])
Problem: p03160
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from sys import stdin

n = int(stdin.readline().rstrip())
li = list(map(int,stdin.readline().rstrip().split()))

def score(li,n):
    dp = [-1 for _ in li]
    dp[0] = li[0]
    dp[1] = abs(li[1]-li[0])
    if n == 1:
        return dp[0]
    elif n == 2:
        return dp[1]
    else:
        for i in range(2,n):
            if dp[i] == -1:
                dp[i] = min(dp[i-2]+abs(li[i]-li[i-2]),dp[i-1]+abs(li[i]-li[i-1]))
        return(dp[n-1])
    
print(score(li,n))

Failing test case input:
6
30 0 26 33 122 14

Expected output:
30


Actual output:
60


Fixed submission (verdict: Accepted):
from sys import stdin

n = int(stdin.readline().rstrip())
li = list(map(int,stdin.readline().rstrip().split()))

def score(li,n):
    dp = [-1 for _ in li]
    dp[0] = 0
    dp[1] = abs(li[1]-li[0])
    if n == 1:
        return dp[0]
    elif n == 2:
        return dp[1]
    else:
        for i in range(2,n):
            dp[i] = min(dp[i-2]+abs(li[i]-li[i-2]),dp[i-1]+abs(li[i]-li[i-1]))
        return(dp[n-1])
    
print(score(li,n))

Problem: p03160
Buggy submission (Python (3.8.2), verdict: Wrong Answer):




N = int(input())
h = list(map(int, input().split()))

dp = list()


dp.append(0)
dp.append(dp[0] + h[1] - h[0])

for i in range(2, N):
	dp.append(min(dp[i-2] + h[i] - h[i-2], dp[i-1] + h[i] - h[i-1]))

print(dp[N-1])

Failing test case input:
4
0 0 -1 -101

Expected output:
101


Actual output:
-101


Fixed submission (verdict: Accepted):




N = int(input())
h = list(map(int, input().split()))

dp = list()


dp.append(0)
dp.append(dp[0] + abs(h[1] - h[0]))

for i in range(2, N):
	dp.append(min(dp[i-2] + abs(h[i] - h[i-2]), dp[i-1] + abs(h[i] - h[i-1])))


print(dp[N-1])

Problem: p03160
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
a = list(map(int, input().split()))

dp = []
def mins(minval, val):
  if minval < val:
    return minval
  else:
    return val
for i in range(N):

  dp.append(10000000)
for i in range(len(a)):

  if i == 0:
    dp[0] = 0

  if i == 1:

    dp[1]= a[1] - a[0]

  dp[i] = min(dp[i], dp[i-1] + abs(a[i-1] - a[i]))
  dp[i] = min(dp[i], dp[i-2] + abs(a[i-2] - a[i]))
  
print(dp[N-1])  

Failing test case input:
2
44 1

Expected output:
43


Actual output:
-43


Fixed submission (verdict: Accepted):
N = int(input())
a = list(map(int, input().split()))
dp = []

def mins(minval, val):
	if minval < val:
			return minval
	else:
			return val

for i in range(N):
	dp.append(1000000000000)

for i in range(len(a)):
	if i == 0:
		dp[0] = 0
	if i == 2:
		dp[1]= abs(a[1] - a[0])
	
	
	dp[i] = min(dp[i], dp[i-1] + abs(a[i-1] - a[i]))
	dp[i] = min(dp[i], dp[i-2] + abs(a[i-2] - a[i]))

print(dp[N-1])
Problem: p03160
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N=int(input())

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

pos = N-1

cost = 0

while pos > 0:
  back_1 = abs(h_list[pos] - h_list[pos-1])
  
  if pos==1:
    cost += back_1
    pos -= 1
    break
  else:
    back_2 = abs(h_list[pos] - h_list[pos-2])
  
  if back_1 > back_2:
    cost += back_2
    pos -= 2
  elif back_1 <= back_2:
    cost += back_1
    pos -= 1
    
print(cost)

Failing test case input:
6
30 12 21 33 60 18

Expected output:
36


Actual output:
54


Fixed submission (verdict: Accepted):
N=int(input())

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

pos = 0

cost = [0]

for i in range(1,N):
  back_1 = abs(h_list[i] - h_list[i-1])
  if i>1:
    back_2 = abs(h_list[i] - h_list[i-2])
  if i>1:
    cost.append( (back_2 + cost[i-2] )if (back_1 + cost[i-1]) > (back_2 + cost[i-2] ) else (back_1 + cost[i-1]))
  else:
    cost.append( back_1 + cost[i-1])
    
  
print(cost[N-1])

Problem: p03160
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
h=[int(i) for i in input().split()]
li=[float('inf')]*(n)

li[0]=0
li[1]=h[1]-h[0]
for i in range(2,n):
    li[i] = min(li[i],li[i-1]+abs(h[i-1]-h[i]),li[i-2]+abs(h[i-2]-h[i]))

print(li[-1])
    
    

Failing test case input:
6
30 12 60 33 60 9

Expected output:
63


Actual output:
27


Fixed submission (verdict: Accepted):
n=int(input())
h=[int(i) for i in input().split()]
li=[float('inf')]*(n)

li[0]=0
li[1]=abs(h[1]-h[0])
for i in range(2,n):
    li[i] = min(li[i],li[i-1]+abs(h[i-1]-h[i]),li[i-2]+abs(h[i-2]-h[i]))

print(li[-1])

Problem: p03160
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
h=[int(x) for x in input().split()]
cost=[0]
cost.append(abs(h[0]-h[1]))
for p in range(2,n):
    cost.append(min(cost[p-1]+abs(h[p]-h[p-1]),abs(h[p]-h[p-2])+cost[p-2]))
print(cost)
print(cost[n-1])

Failing test case input:
2
-48 -1

Expected output:
47


Actual output:
[0, 47]
47


Fixed submission (verdict: Accepted):
n=int(input())
h=[int(x) for x in input().split()]
cost=[0]
cost.append(abs(h[0]-h[1]))
for p in range(2,n):
    cost.append(min(cost[p-1]+abs(h[p]-h[p-1]),abs(h[p]-h[p-2])+cost[p-2]))
print(cost[n-1])

Problem: p03160
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
h_s = list(map(int, input().split()))
h_s = [abs(h_s[0]-h) for h in h_s]+[0]*10

dp = [float("inf")]*(N+10)
dp[0] = 0

for i in range(N):
    for j in range(1, 3):
        dp[i+j] = min(dp[i+j], dp[i]+abs(h_s[i]-h_s[i+j]))

print(dp[N-1])

Failing test case input:
6
30 10 60 10 60 57

Expected output:
33


Actual output:
27


Fixed submission (verdict: Accepted):
N = int(input())
h_s = list(map(int, input().split()))+[0]*10

dp = [float("inf")]*(N+10)
dp[0] = 0

for i in range(N):
    for j in range(1, 3):
        dp[i+j] = min(dp[i+j], dp[i]+abs(h_s[i]-h_s[i+j]))

print(dp[N-1])
Problem: p03160
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
h = list(map(int, input().split()))
dp = [float('inf')] * n
dp[0] = 0
dp[1] = abs(h[0] - h[1])
for i in range(2, n - 1):
    dp[i] = max((dp[i - 2] + abs(h[i - 2] - h[i])), (dp[i - 1] + abs(h[i - 1] - h[i])))
print(dp[n - 1])

Failing test case input:
4
0 1 2 -111

Expected output:
113


Actual output:
inf


Fixed submission (verdict: Accepted):
n = int(input())
h = list(map(int, input().split()))
dp = [float('inf')] * n
dp[0] = 0
dp[1] = abs(h[0] - h[1])
for i in range(2, n):
    dp[i] = min((dp[i - 2] + abs(h[i - 2] - h[i])), (dp[i - 1] + abs(h[i - 1] - h[i])))
print(dp[-1])

Problem: p03160
Buggy submission (Python (3.8.2), verdict: Wrong Answer):

n = int(input())
arr = list(map(int, input().split()))

cost = [0]*n
cost[0] = arr[0]
for i in range(1, n):
  if i > 1:
    cost[i] = min(abs(arr[i]-arr[i-2])+cost[i-2], abs(arr[i]-arr[i-1])+cost[i-1])
  else:
    cost[i] = abs(arr[i]-arr[i-1])
    
print(cost[-1])

Failing test case input:
6
2 -2 0 4 49 15

Expected output:
17


Actual output:
19


Fixed submission (verdict: Accepted):
n = int(input())
arr = list(map(int, input().split()))
  
cost = [0]*n
cost[0] = 0
for i in range(1, n):
  if i > 1:
    cost[i] = min(abs(arr[i]-arr[i-2])+cost[i-2], abs(arr[i]-arr[i-1])+cost[i-1])
  elif i == 1:
    cost[i] = abs(arr[i]-arr[i-1])

print(cost[-1])

Problem: p03160
Buggy submission (Python (3.8.2), verdict: Wrong Answer):


def solution(h):
    n = len(h)
    if n == 1:
        return 0
    elif n == 2:
        return abs(h[1]-h[0])
    dp = [0]*(n)
    dp[1]  = abs(h[1]-h[0]) 
    for i in range(2,n):
        dp[i] = min( dp[i-1]+abs(h[i]-h[i-1]) , dp[i-2]+abs(h[i]-h[i-2]) )
    print(*dp)
    return dp[n-1]

N = int(input())
h = list(map(int,input().split()))
res = solution(h)
print(res,end="\n")


Failing test case input:
4
1 -1 2 -156

Expected output:
157


Actual output:
0 2 1 157
157


Fixed submission (verdict: Accepted):


def solution(h):
    n = len(h)
    INF = float('inf')
    dp = [INF]*n
    dp[0] = 0
    for i in range(n):
        for j in range(i+1,i+3):
            if j < n:
                dp[j] = min(dp[j] , dp[i]+abs(h[i]-h[j]) )
    
    return dp[n-1]

N = int(input())
h = list(map(int,input().split()))
res = solution(h)
print(res)

Problem: p03160
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
n = int(input())
a = list(map(int,input().split()))
cost = [0] * n
cost[1] = abs(a[1]-a[0])
for i in range(2,n):
    cost[i] = min(cost[i-1]+abs(a[i]-a[i-1]),cost[i-2]+abs(a[i]-a[i-2]))
print(cost)
print(cost[n-1])

Failing test case input:
4
0 -4 2 22

Expected output:
22


Actual output:
[0, 4, 2, 22]
22


Fixed submission (verdict: Accepted):
n = int(input())
a = list(map(int,input().split()))
cost = [0] * n
cost[1] = abs(a[1]-a[0])
for i in range(2,n):
    cost[i] = min(cost[i-1]+abs(a[i]-a[i-1]),cost[i-2]+abs(a[i]-a[i-2]))

print(cost[n-1])
Problem: p03160
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n=int(input())
rec=list(map(int,input().split()))
s=[rec[0],abs(rec[1]-rec[0])]
for i in range(2,n):
        total2=abs(rec[i]-rec[i-2])+s[i-2]
        total1=abs(rec[i]-rec[i-1])+s[i-1]
        s.append(min(total2,total1))
print(s[-1])

Failing test case input:
6
3 0 1 45 52 26

Expected output:
65


Actual output:
67


Fixed submission (verdict: Accepted):
n=int(input())
rec=list(map(int,input().split()))
s=[0,abs(rec[1]-rec[0])]
for i in range(2,n):
        total2=abs(rec[i]-rec[i-2])+s[i-2]
        total1=abs(rec[i]-rec[i-1])+s[i-1]
        s.append(min(total2,total1))
print(s[-1])

Problem: p03160
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
stage = list(map(int, input().split(" ")))

INF = float('inf')
DP = [INF for i in range(N)]

for i in range(N):
    if i == 1:
        DP[i] = abs(stage[i] - stage[i-1])
    elif i == 2:
        DP[i] = min(abs(stage[i] - stage[i-2]), DP[i-1] + abs(stage[i] - stage[i-2]))
    else:
        DP[i] = min(DP[i-1] + abs(stage[i] - stage[i-1]), DP[i-2] + abs(stage[i] - stage[i-2]))

print(DP)
print(DP[N-1])

Failing test case input:
4
5 14 40 20

Expected output:
15


Actual output:
[inf, 9, 35, 15]
15


Fixed submission (verdict: Accepted):
N = int(input())
stage = list(map(int, input().split(" ")))

INF = float('inf')
DP = [INF for i in range(N)]

for i in range(N):
    if i == 1:
        DP[i] = abs(stage[i] - stage[i-1])
    elif i == 2:
        DP[i] = min(abs(stage[i] - stage[i-2]), DP[i-1] + abs(stage[i] - stage[i-2]))
    else:
        DP[i] = min(DP[i-1] + abs(stage[i] - stage[i-1]), DP[i-2] + abs(stage[i] - stage[i-2]))

print(DP[N-1])

Problem: p03160
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
N = int(input())
H = [0] + list(map(int, input().split()))

DP = [0]*(N+1)

for i in range(1, N+1):
    if i == 1:
        DP[i] = H[1]
        continue
    if i == 2:
        DP[i] = abs(H[1] - H[2])
        continue
    c1 = abs(H[i-1] - H[i])
    c2 = abs(H[i-2] - H[i])
    DP[i] = min(DP[i-1] + c1, DP[i-2] + c2)


print(DP[N])


Failing test case input:
6
30 10 35 18 154 1

Expected output:
39


Actual output:
45


Fixed submission (verdict: Accepted):
N = int(input())
H = [0] + list(map(int, input().split()))

DP = [0]*(N+1)

for i in range(2, N+1):
    if i == 2:
        DP[i] = abs(H[1] - H[2])
        continue
    c1 = abs(H[i-1] - H[i])
    c2 = abs(H[i-2] - H[i])
    DP[i] = min(DP[i-1] + c1, DP[i-2] + c2)


print(DP[N])
Problem: p03160
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
N = int(input())
*h, = map(int, input().split())

dp = [0] * N
dp[1] = h[1] - h[0]
for i in range(2, N):
    c1, c2 = abs(h[i] - h[i - 1]), abs(h[i] - h[i - 2])
    if c1 < c2:
        dp[i] = dp[i - 1] + c1
    else:
        dp[i] = dp[i - 2] + c2

print(dp[N - 1])


Failing test case input:
6
30 12 60 33 60 18

Expected output:
54


Actual output:
18


Fixed submission (verdict: Accepted):
N = int(input())
*h, = map(int, input().split())

dp = [0] * N
dp[1] = abs(h[1] - h[0])
for i in range(2, N):
    c1, c2 = abs(h[i - 1] - h[i]) + dp[i - 1], abs(h[i - 2] - h[i]) + dp[i - 2]
    if c1 < c2:
        dp[i] = c1
    else:
        dp[i] = c2

print(dp[N - 1])

Problem: p03160
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
h = [int(x) for x in input().split()]

dp = [1000000 for _ in range(N)]
dp[0] = 0
dp[1] = abs(h[1] - h[0])

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

Failing test case input:
6
2 0 26 92 65 14

Expected output:
114


Actual output:
1000000


Fixed submission (verdict: Accepted):
N = int(input())
h = [int(x) for x in input().split()]

dp = [1000000 for _ in range(N)]
dp[0] = 0
dp[1] = abs(h[1] - h[0])

for i in range(2, N):


    dp[i] = min(dp[i-1] + abs(h[i] - h[i-1]), dp[i-2] + abs(h[i] - h[i-2]))
print(dp[-1])

Problem: p03160
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
h = [int(x) for x in input().split()]
inf = float('inf')
dp = [inf] * n  
dp[0] = 0
dp[1] = abs(h[1] - h[0])
for i in range(1, n):
    if abs(h[i] - h[i-1]) < abs(h[i] - h[i-2]):
        dp[i] = dp[i-1] + abs(h[i] - h[i-1])
    else:
        dp[i] = dp[i-2] + abs(h[i] - h[i-2])
print(dp[-1])

Failing test case input:
4
8 146 105 28

Expected output:
174


Actual output:
inf


Fixed submission (verdict: Accepted):
n = int(input())
h = [int(x) for x in input().split()]
inf = float('inf')
dp = [inf] * n  
dp[0] = 0
for i in range(1, n):
    if i == 1:
        dp[i] = abs(h[i] - h[i-1])
    elif (dp[i-1] + abs(h[i] - h[i-1])) < (dp[i-2] + abs(h[i] - h[i-2])):
        dp[i] = dp[i-1] + abs(h[i] - h[i-1])
    else:
        dp[i] = dp[i-2] + abs(h[i] - h[i-2])
print(dp[-1])
Problem: p03160
Buggy submission (Python (3.4.3), verdict: Wrong Answer):

 
import math
import itertools
import sys
 

N = int(input())
S = str(input())

h = [0]
h += map(int, S.split())

dp = [0 for _ in range(N+1)]

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


print (dp[N])




Failing test case input:
2
-51 0

Expected output:
51


Actual output:
0


Fixed submission (verdict: Accepted):

 
import math
import itertools
import sys
 

N = int(input())
S = str(input())

h = [0]
h += map(int, S.split())

dp = [0 for _ in range(N+1)]

for i in range(0, N+1) :
  if i == 0 or i == 1:
    dp[i] = 0
  elif i == 2 :
    dp[i] = abs(h[i] - h[i-1])
  else :
    before1 = abs(h[i] - h[i-1]) + dp[i-1]
    before2 = abs(h[i] - h[i-2]) + dp[i-2]
    dp[i] = min(before1, before2)


print (dp[N])

Problem: p03160
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
A=list(map(int,input().split()))
inf=float("inf")
dp=[inf for i in range(n)]
dp[0]=0
dp[1]=abs(A[1]-A[0])
for i in range(2,n):
	dp[i]=min(dp[i],abs(A[i-1]-A[i]),abs(A[i-2]-A[i]))
print(dp[n-1])


Failing test case input:
4
4 91 105 28

Expected output:
150


Actual output:
63


Fixed submission (verdict: Accepted):
n=int(input())
A=list(map(int,input().split()))
inf=float("inf")
dp=[inf for i in range(n)]
dp[0]=0
dp[1]=abs(A[1]-A[0])
for i in range(2,n):
	dp[i]=min(dp[i],abs(A[i-1]-A[i])+dp[i-1],abs(A[i-2]-A[i])+dp[i-2])
print(dp[n-1])

Problem: p03160
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n = int(input())
h = list(map(int, input().split()))

dp = [0, abs(h[1]-h[0])]

for i in range(2, n-1):
    dp.append(min(dp[i-1] + abs(h[i]-h[i+1]), dp[i-2] + abs(h[i-2]-h[i])))

dp.append(dp[n-2] + abs(h[n-1]-h[n-2]))

print(dp[n-1])

Failing test case input:
6
30 0 26 33 122 14

Expected output:
30


Actual output:
208


Fixed submission (verdict: Accepted):
n = int(input())
h = list(map(int, input().split()))

dp = [0, abs(h[1]-h[0])]

for i in range(2, n):
    dp.append(min(dp[i-1] + abs(h[i-1]-h[i]), dp[i-2] + abs(h[i-2]-h[i])))

print(dp[-1])

Problem: p03160
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
N = int(input())
h = list(map(int,input().split()))

dp = [float('inf')]*N

dp[0] = 0
dp[1] = 0

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

print(dp[N-1])

Failing test case input:
4
0 -1 2 -258

Expected output:
258


Actual output:
257


Fixed submission (verdict: Accepted):
N = int(input())
h = list(map(int,input().split()))

dp = [float('inf')]*N

dp[0] = 0
dp[1] = abs(h[1]-h[0])

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

print(dp[N-1])
Problem: p03160
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
N = int(input())
h = list(map(int,input().split()))
A = [float('inf')] * (N)
A[0] = 0

if N > 2:
    for i in range(N-2):
        p = A[i] + abs(h[i+1] - h[i])
        q = A[i] + abs(h[i+2] - h[i])
        if  p < A[i+1]:
            A[i+1] = p
        if q < A[i+2]:
            A[i+2] = q
    print(A[N-1])

else:
    print(abs(h[1]-h[0]))

Failing test case input:
4
8 289 2 28

Expected output:
32


Actual output:
542


Fixed submission (verdict: Accepted):
N = int(input())
h = list(map(int,input().split()))
A = [float('inf')] * (N)
A[0] = 0
A[1] = abs(h[1]-h[0])

if N > 2:
    for i in range(2,N):
        p = A[i-1] + abs(h[i-1] - h[i])
        q = A[i-2] + abs(h[i-2] - h[i])
        if  p < A[i]:
            A[i] = p
        if q < A[i]:
            A[i] = q
    print(A[N-1])

else:
    print(abs(h[1]-h[0]))

Problem: p03160
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
li = list(map(int,input().split()))
if len(li) == 1:
    print(li[0])
    exit()
dp = [0,abs(li[1]-li[0])]
print(dp)
for i in range(2,N):
    dp.append(min(dp[i-1]+abs(li[i]-li[i-1]), dp[i-2]+abs(li[i]-li[i-2])))
print(dp[N-1])


Failing test case input:
4
2 77 54 13

Expected output:
93


Actual output:
[0, 75]
93


Fixed submission (verdict: Accepted):
N = int(input())
li = list(map(int,input().split()))
if len(li) == 1:
    print(li[0])
    exit()
dp = [0,abs(li[1]-li[0])]
for i in range(2,N):
    dp.append(min(dp[i-1]+abs(li[i]-li[i-1]), dp[i-2]+abs(li[i]-li[i-2])))
print(dp[N-1])

Problem: p03160
Buggy submission (Python (3.8.2), verdict: Wrong Answer):


def solution(h):
    n = len(h)
    INF = float('inf')
    dp = [INF]*n
    dp[0] = 0
    for i in range(n):
        for j in range(i+1,i+3):
            if j < n:
                dp[j] = min(dp[j] , dp[i]+abs(h[i]-h[j]) )
    print(*dp)
    return dp[n-1]

N = int(input())
h = list(map(int,input().split()))
res = solution(h)
print(res,end="")


Failing test case input:
4
2 91 52 13

Expected output:
89


Actual output:
0 89 50 89
89

Fixed submission (verdict: Accepted):


def solution(h):
    n = len(h)
    INF = float('inf')
    dp = [INF]*n
    dp[0] = 0
    for i in range(n):
        for j in range(i+1,i+3):
            if j < n:
                dp[j] = min(dp[j] , dp[i]+abs(h[i]-h[j]) )
    
    return dp[n-1]

N = int(input())
h = list(map(int,input().split()))
res = solution(h)
print(res)
Problem: p03160
Buggy submission (Python (3.4.3), verdict: Wrong Answer):

dp = []
for i in range(100001):
    dp.append(float('inf'))


N = int(input())
h = list(map(int, input().split()))

dp[0] = 0
dp[1] = abs(h[1] - h[0])


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

for i in range(N):
    print(dp[i])

Failing test case input:
4
4 146 105 28

Expected output:
178


Actual output:
0
142
101
178


Fixed submission (verdict: Accepted):

dp = []
for i in range(100001):
    dp.append(float('inf'))


N = int(input())
h = list(map(int, input().split()))

dp[0] = 0
dp[1] = abs(h[1] - h[0])


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

print(dp[N-1])

Problem: p03160
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N=int(input())
line=input().split(" ")
dp=[]
for i in range(N):
    line[i]=int(line[i])
    dp.append(10000000000)
dp[0]=0
dp[1]=abs(line[1]-line[0])
for j in range(2,N):
    dp[j]=min(dp[j], dp[j-1]+abs(line[j]-line[j-1]))
    dp[j]=min(dp[j], dp[j-2]+abs(line[j]-line[j-2]))
print(dp)

Failing test case input:
6
2 -2 1 4 65 18

Expected output:
18


Actual output:
[0, 4, 1, 4, 65, 18]


Fixed submission (verdict: Accepted):
N=int(input())
line=input().split(" ")
dp=[]
for i in range(N):
    line[i]=int(line[i])
    dp.append(10000000000)
dp[0]=0
dp[1]=abs(line[1]-line[0])
for j in range(2,N):
    dp[j]=min(dp[j], dp[j-1]+abs(line[j]-line[j-1]))
    dp[j]=min(dp[j], dp[j-2]+abs(line[j]-line[j-2]))
print(dp[N-1])

Problem: p03160
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
N = int(input())
h = list(map(int, input().split()))
dp = [0]*N
dp[1] = abs(h[0]-h[1])
for i in range(2, N):
    s1, s2 = abs(h[i]-h[i-1]), abs(h[i]-h[i-2])
    if s1 < s2:
        dp[i] = s1+dp[i-1]
    else:
        dp[i] = s2+dp[i-2]
print(dp[-1])

Failing test case input:
4
2 77 45 13

Expected output:
75


Actual output:
139


Fixed submission (verdict: Accepted):
N = int(input())
h = list(map(int, input().split()))
dp = [0]*N
dp[1] = abs(h[0]-h[1])
for i in range(2, N):
    s1, s2 = dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2])
    if s1 < s2:
        dp[i] = s1
    else:
        dp[i] = s2
print(dp[-1])

Problem: p03160
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
hs =[0]+ list(map(int, input().split()))
dp = [0] * (N+1)
for i in range(2, N+1):
    dp[i] = min(dp[i-1]+abs(hs[i]-hs[i-1]), dp[i-2]+abs(hs[i]-hs[i-2]))
print(dp[N])

Failing test case input:
4
-1 1 2 -52

Expected output:
55


Actual output:
54


Fixed submission (verdict: Accepted):
N = int(input())
hs =[10**6]+ list(map(int, input().split()))
dp = [0] * (N+1)
for i in range(2, N+1):
    dp[i] = min(dp[i-1]+abs(hs[i]-hs[i-1]), dp[i-2]+abs(hs[i]-hs[i-2]))
print(dp[N])
Problem: p02571
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
S = input()
T = input()

minCount = len(T)
for i in range(len(S)-len(T)):
    count = 0
    for j in range(len(T)):
        if S[i+j] != T[j]:
            count += 1
    minCount = min(minCount, count)

print(minCount)


Failing test case input:
apfeesrceo
cdarotb

Expected output:
6


Actual output:
7


Fixed submission (verdict: Accepted):
S = input()
T = input()

minCount = len(T)
for i in range(len(S)-len(T)+1):
    count = 0
    for j in range(len(T)):
        if S[i+j] != T[j]:
            count += 1
    minCount = min(minCount, count)

print(minCount)

Problem: p02571
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
s = input()
t = input()
x = len(t)
res= 0
for i in range(len(s) - x):
    tmp = s[i:x]
    cntmp = 0
    for j in range(x):
        if t[j] == s[j]:
            cntmp += 1
    res = max(res, cntmp)
print(x-res)


Failing test case input:
oecqsdefpa
btdqep`

Expected output:
5


Actual output:
6


Fixed submission (verdict: Accepted):
s = input()
t = input()
x = len(t)
mx= 0

res= 0
for i in range(len(s) - x+1):
    
    tmp = s[i:i+x]
    cntmp = 0
    for j in range(x):
        if t[j] == tmp[j]:
            cntmp += 1
    
    res = max(res, cntmp)
print(x-res)

Problem: p02571
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
S=input()
T=input()

max_ans=0
for i in range(len(S)):
  max_n = 0
  for j in range(len(T)):
    if len(S) > i + j:
      if S[i+j]==T[j]:
      	max_n=max_n+1
      else:
        if max_ans <= max_n:
          max_ans=max_n
        
print(len(T)-max_ans)

Failing test case input:
cabaac
bba

Expected output:
1


Actual output:
2


Fixed submission (verdict: Accepted):
S=input()
T=input()

max_ans=0
for i in range(len(S)):
  max_n = 0
  for j in range(len(T)):
    if len(S) >= i + len(T):
      if S[i+j]==T[j]:
      	max_n=max_n+1
  
  if max_ans <= max_n:
    max_ans=max_n

print(len(T)-max_ans)

Problem: p02571
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
s = input()
t = input()
maxi = 0 
for i in range(len(s)):
    maxG = 0
    print(s[i:len(t)+i])
    if len(s[i:len(t)+i]) >= len(t):
        for l, j in zip(s[i:len(t)+i], t):
            if l == j:
                maxG += 1
        maxi = max(maxi, maxG)
    else:
        break
print(len(t)-maxi)


Failing test case input:
cpfedsqaeo
btdqep_

Expected output:
6


Actual output:
cpfedsq
pfedsqa
fedsqae
edsqaeo
dsqaeo
6


Fixed submission (verdict: Accepted):
s = input()
t = input()
maxi = 0 
for i in range(len(s)):
    maxG = 0
    if len(s[i:len(t)+i]) >= len(t):
        for l, j in zip(s[i:len(t)+i], t):
            if l == j:
                maxG += 1
        maxi = max(maxi, maxG)
print(len(t)-maxi)
Problem: p02571
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
S = input()
T = input()

if S in T:
    print('0')
else:
    count = 0
    for i in range(len(S) - len(T)):
        tmp = 0
        for p in range(len(T)):
            if S[i + p] == T[p]:
                tmp += 1
        
        if count < tmp:
            count = tmp
    
    print(len(T) - count)

Failing test case input:
apfedqsceo
btprcda

Expected output:
6


Actual output:
7


Fixed submission (verdict: Accepted):
S = input()
T = input()

if S in T:
    print('0')
else:
    count = 0
    for i in range(len(S) - len(T) + 1):
        tmp = 0
        for p in range(len(T)):
            if S[i + p] == T[p]:
                tmp += 1
        
        if count < tmp:
            count = tmp
    
    print(len(T) - count)

Problem: p02571
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
import sys
from collections import deque

import math

def S(): return sys.stdin.readline().rstrip()
def SL(): return map(str,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def IL(): return map(int,sys.stdin.readline().rstrip().split())

def solve():
    lent = len(t)
    for i in range(lent,-1,-1):
        for j in range(lent-i+1):
            if lent<i+j:    break
            if t[j:i+j] in s[j:]:
                return lent-i
    return lent

if __name__=='__main__':
    s = S()
    t = S()
    print(solve())

Failing test case input:
cpfedsqbdo
pafqdtb

Expected output:
5


Actual output:
6


Fixed submission (verdict: Accepted):
import sys
from collections import deque

import math

def S(): return sys.stdin.readline().rstrip()
def SL(): return map(str,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def IL(): return map(int,sys.stdin.readline().rstrip().split())

def solve():
    lent = len(t)
    lens = len(s)
    ans = lent
    for i in range(lens-lent+1):
        tmp = 0
        for j in range(lent):
            if t[j] != s[j+i]:
                tmp += 1
        ans = min(ans,tmp)
    print(ans)
    return

if __name__=='__main__':
    s = S()
    t = S()
    solve()

Problem: p02571
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
S = input()
T = input()

ans = len(T)
l = len(T)
for m in range (len(S)-l):
    diff = 0
    for i in range (l):
        if S[m+i] != T[i]:
            diff+=1
    ans = min(ans, diff)

print(ans)

Failing test case input:
ccbaac
aac

Expected output:
0


Actual output:
2


Fixed submission (verdict: Accepted):
S = input()
T = input()

ans = len(T)
l = len(T)
for m in range (len(S)-l+1):
    diff = 0
    for i in range (l):
        if S[m+i] != T[i]:
            diff+=1
    ans = min(ans, diff)

print(ans)
Problem: p02571
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
s = input()
t = input()
ans = len(t)
for i in range(0, (len(s)-len(t)+1)):
    diff = 0
    for j in range(i, len(t)):
        if t[j] == s[i+j]:
            diff += 1
    ans = min(ans, len(t)-diff)
print(ans)

Failing test case input:
fabccc
aac

Expected output:
1


Actual output:
2


Fixed submission (verdict: Accepted):
s = input()
t = input()
ans = len(t)
for i in range(0, (len(s)-len(t)+1)):
    diff = 0
    for j in range(0, len(t)):
        if t[j] == s[i+j]:
            diff += 1
    ans = min(ans, len(t)-diff)
print(ans)

Problem: p02571
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
S = input()
T = input()
k = 0
x = 0
for i in range(len(S)-len(T)+1):
    s = S[i:]
    if k<=x:
        k = x
    x = 0
    for j in range(len(T)):
        if s[j] == T[j]:
            x += 1
print(len(T)-k)

Failing test case input:
apfedsqceo
btpqcda

Expected output:
5


Actual output:
7


Fixed submission (verdict: Accepted):
S = input()
T = input()
k = 0
x = 0
for i in range(len(S)-len(T)+1):
    s = S[i:]
    for j in range(len(T)):
        if s[j] == T[j]:
            x += 1
    if k<=x:
        k = x
    x = 0
print(len(T)-k)

Problem: p02571
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
import bisect,collections,copy,itertools,math,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def main():
    s = S()
    t = S()
    s = list(s)
    t = list(t)
    slen = len(s)
    tlen = len(t)
    ans = float("inf")

    for i in range(tlen):
        char = t[i]
        for j in range(i,slen-(tlen-i-1)):
            aaa = s[j]
            if aaa==char:
                rng = s[j:j+tlen-i]
                ex = t[i:]
                cnt = 0
                for x,y in zip(rng,ex):
                    if x == y:
                        cnt += 1
                ans = min(ans, tlen-cnt)

    print(ans)

main()            


Failing test case input:
e`bccc
aaa

Expected output:
3


Actual output:
inf


Fixed submission (verdict: Accepted):
import bisect,collections,copy,itertools,math,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def main():
    s = S()
    t = S()
    s = list(s)
    t = list(t)
    slen = len(s)
    tlen = len(t)
    ans = float("inf")

    for i in range(tlen):
        char = t[i]
        for j in range(i,slen-(tlen-i-1)):
            aaa = s[j]
            if aaa==char:
                rng = s[j:j+tlen-i]
                ex = t[i:]
                cnt = 0
                for x,y in zip(rng,ex):
                    if x == y:
                        cnt += 1
                ans = min(ans, tlen-cnt)
    if ans == float("inf"):
        ans = tlen
    print(ans)

main()
Problem: p02571
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
s = input()
t = input()

ans = len(t)
for i in range(len(s)-len(t)+1):
  tmp=0
  for j in range(len(t)):
    if t[j] == s[i+j]:
      tmp+=1
  ans = min(tmp,ans)
  
print(ans)

Failing test case input:
apfeeqsceo
btorcda

Expected output:
6


Actual output:
0


Fixed submission (verdict: Accepted):
s = input()
t = input()

ans = len(t)
for i in range(len(s)-len(t)+1):
  tmp=0
  for j in range(len(t)):
    if t[j] != s[i+j]:
      tmp+=1
  ans = min(tmp,ans)
  
print(ans)

Problem: p02571
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
S = input()
T = input()

lT = len(T)
ans = lT
for i in range(len(S) - lT):
    tmp = 0
    for j in range(lT):
        if S[i + j] != T[j]:
            tmp += 1
    ans = min(ans, tmp)
print(ans)

Failing test case input:
apfedsqceo
btprcda

Expected output:
6


Actual output:
7


Fixed submission (verdict: Accepted):
S = input()
T = input()

lT = len(T)
ans = lT
for i in range(len(S) - lT + 1):
    tmp = 0
    for j in range(lT):
        if S[i + j] != T[j]:
            tmp += 1
    ans = min(ans, tmp)
print(ans)

Problem: p02571
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
S = input()
T = input()

ans = 1000

for i in range(len(S)-len(T)):
    s = S[i:i+len(T)]
    con = 0
    for j in range(len(T)):
        if s[j] != T[j]:
           con += 1
    if con <= ans:
        ans = con

print(ans)

Failing test case input:
apfedsqceo
btpqcda

Expected output:
5


Actual output:
7


Fixed submission (verdict: Accepted):
S = input()
T = input()
 
ans = 10000
 
for i in range(len(S)-len(T)+1):
    s = S[i:i+len(T)]
    con = 0
    for j in range(len(T)):
        if s[j] != T[j]:
           con += 1
    if con <= ans:
        ans = con
 
print(ans)

Problem: p02571
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
def resolve():
    s = input()
    t = input()
    ans = 0

    for i in range(len(t)):
        for j in range(i, len(t)):
            test = t[i:j+1]

            if test in s[i:len(s)-(len(t)-j)]:
                ans = max(ans, len(test))

    print(len(t)-ans)
resolve()

Failing test case input:
ccbaac
aac

Expected output:
0


Actual output:
2


Fixed submission (verdict: Accepted):
def resolve():
    s = input()
    t = input()
    ans = 10**4

    for i in range(len(s)-len(t)+1):
        ch = 0
        for j in range(len(t)):
            if s[i+j] != t[j]:
                ch += 1
        ans = min(ch, ans)
    print(ans)

resolve()

Problem: p02571
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
s = input()
t = input()

n, m = len(s), len(t)

ma = 0
for i in range(n-m):
    tmp = 0
    s_sub = s[i:n]
    for j in range(m):
        if s_sub[j] == t[j]:
            tmp += 1
    ma = max(ma, tmp)

print(m - ma)

Failing test case input:
oeaqsdefpc
btdqep`

Expected output:
5


Actual output:
6


Fixed submission (verdict: Accepted):
s = input()
t = input()

n, m = len(s), len(t)

ma = 0
for i in range(n-m+1):
    tmp = 0
    s_sub = s[i:i+m]
    for j in range(m):
        if s_sub[j] == t[j]:
            tmp += 1
    ma = max(ma, tmp)

print(m - ma)
Problem: p02571
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
s=input()
t=input()

max=0
count=0
for i in range(len(s)-len(t)):
    count=0
    for j in range(len(t)):
        if s[i+j]==t[j]:
            count+=1
    if max < count:
        max=count
        

print(len(t)-max)

Failing test case input:
cbbaac
aab

Expected output:
1


Actual output:
2


Fixed submission (verdict: Accepted):
s=input()
t=input()

max=0
count=0
for i in range(len(s)-len(t)+1):
    count=0
    for j in range(len(t)):
        if s[i+j]==t[j]:
            count+=1
    if count > max:
        max=count
        
print(len(t)-max)

Problem: p02571
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
from sys import stdin, stdout, setrecursionlimit
from collections import deque, defaultdict, Counter
from heapq import heappush, heappop
from functools import lru_cache
import math


rl = lambda: stdin.readline()
rll = lambda: stdin.readline().split()
rli = lambda: map(int, stdin.readline().split())
rlf = lambda: map(float, stdin.readline().split())

INF, NINF = float('inf'), float('-inf')
MOD = 10**9 + 7

def main():
	s, t = rll()[0], rll()[0]
	m = len(t)
	ans = INF 

	def do(start):
		x = 0
		for i in range(m):
			if start + i >= len(s):
				return INF
			if t[i] != s[start + i]: 
				x += 1
		return x

	for i in range(m):
		ans = min(ans, do(i))
	print(ans)

	stdout.close()

if __name__ == "__main__":
	main()

Failing test case input:
cbc`cd
`ab

Expected output:
2


Actual output:
3


Fixed submission (verdict: Accepted):
from sys import stdin, stdout, setrecursionlimit
from collections import deque, defaultdict, Counter
from heapq import heappush, heappop
from functools import lru_cache
import math


rl = lambda: stdin.readline()
rll = lambda: stdin.readline().split()
rli = lambda: map(int, stdin.readline().split())
rlf = lambda: map(float, stdin.readline().split())

INF, NINF = float('inf'), float('-inf')
MOD = 10**9 + 7

def main():
	s, t = rll()[0], rll()[0]
	m = len(t)
	ans = INF 

	def do(start):
		x = 0
		for i in range(m):
			if start + i >= len(s):
				return INF
			if t[i] != s[start + i]: 
				x += 1
		return x

	for i in range(len(s)):
		ans = min(ans, do(i))
	print(ans)

	stdout.close()

if __name__ == "__main__":
	main()

Problem: p02571
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
s=input()
t=input()
ans=float('inf')
for i in range(len(s)-len(t)):
  tmp=0
  for j in range(len(t)):
    if t[j]==s[i+j]:
      pass
    else:
      tmp+=1
  ans=min(ans,tmp)
print(ans)

Failing test case input:
cbc`cd
`aa

Expected output:
2


Actual output:
3


Fixed submission (verdict: Accepted):
s=input()
t=input()
ans=float('inf')
for i in range(len(s)-len(t)+1):
  tmp=0
  for j in range(len(t)):
    if t[j]==s[i+j]:
      pass
    else:
      tmp+=1
  ans=min(ans,tmp)
print(ans)
Problem: p02571
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
S = input()
T = input()

Min = 100000

for i in range(len(S) - len(T) + 1):
    count = 0
    for n in range(len(T)):
        if S[i + n] != T[n]:
            count += 1
    if count < Min:
        Min = count

print(count)

Failing test case input:
e`bccc
aab

Expected output:
2


Actual output:
3


Fixed submission (verdict: Accepted):
S = input()
T = input()

Min = 100000

for i in range(len(S) - len(T) + 1):
    count = 0
    for n in range(len(T)):
        if S[i + n] != T[n]:
            count += 1
    if count < Min:
        Min = count

print(Min)

Problem: p02571
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
a = input()
b = input()

T=1000

for i in range(len(a)-len(b)+1):
  ans = 0
  for j in range(len(b)):
    if a[i+j]!=b[j]:
      ans +=1
      ans = min(T, ans)
print(ans)
        
  


Failing test case input:
ccabac
bba

Expected output:
1


Actual output:
2


Fixed submission (verdict: Accepted):
a = input()
b = input()

T=1000

for i in range(len(a)-len(b)+1):
  ans = 0
  for j in range(len(b)):
    if a[i+j]!=b[j]:
      ans +=1
  T = min(T, ans)
print(T)

Problem: p02571
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
S = input()
T = input()

len_S = len(S)
len_T = len(T)

ans = len_T
for i in range(len_S - len_T):
    match = 0
    for s, t in zip(S[i:i + len_T], T):
        if s == t:
            match += 1
    change = len_T - match
    ans = min(ans, change)

print(ans)

Failing test case input:
apfeeqsceo
btprcda

Expected output:
6


Actual output:
7


Fixed submission (verdict: Accepted):
S = input()
T = input()

len_S = len(S)
len_T = len(T)

ans = len_T
for i in range(0, len_S - len_T + 1):
    match = 0
    for s, t in zip(S[i:i + len_T], T):
        if s == t:
            match += 1
    change = len_T - match
    ans = min(ans, change)

print(ans)

Problem: p02571
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
s=str(input())
t=str(input())
ans=0
for i in range(0,len(s)-len(t)):
  tmp=0
  for j in range(len(t)):
    if s[i+j]==t[j]:
      tmp=tmp+1
  ans=max(ans,tmp)
print(len(t)-ans)

Failing test case input:
cbc`cd
`ab

Expected output:
2


Actual output:
3


Fixed submission (verdict: Accepted):
s=str(input())
t=str(input())
ans=0
for i in range(0,len(s)-len(t)+1):
  tmp=0
  for j in range(len(t)):
    if s[i+j]==t[j]:
      tmp=tmp+1
  ans=max(ans,tmp)
print(len(t)-ans)

Problem: p02571
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
s = input()
t = input()
L = len(s)
l = len(t)
p = L-l
ans = l
for i in range(l):
    for j in range(i+1,l+1):
        
        if s[i:j+p].count(t[i:j])>0:
                ans = min(ans,l-len(t[i:j]))
print(ans)

Failing test case input:
cc`cbc
`ab

Expected output:
1


Actual output:
2


Fixed submission (verdict: Accepted):
s = input()
t = input()
L = len(s)
l = len(t)
p = L-l
li = []
for i in range(p+1):
    ns = s[i:i+l]
    num = 0
    for j in range(l):
        if ns[j]!=t[j]:
            num +=1
    li += [num]
print(min(li))