Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
a = []
for i in range(M):
    a.append(int(input()))

for n, i in enumerate(a):
    if n > 0:
        if (a[n] - a[n-1]) == 1:
            print(0)
            exit()

def search(i, n):
    if i in a:
        return 0
    if i == n:
        return 1
    if i > n:
        return 0
    return search(i+1, n) + search(i+2, n)

ans = 1
start = 0
a.append(N+1)
for num in a:
    ans *= search(start, num-1)
    for i in range(1, N):
        start = num + i
        if start not in a:
            break

print(ans%1000000007)

Fixed submission:
N, M = map(int, input().split())
a = []
for i in range(M):
    a.append(int(input()))

for n, i in enumerate(a):
    if n > 0:
        if (a[n] - a[n-1]) == 1:
            print(0)
            exit()

dp = [-1] * (N+2)

dp[N] = 1
dp[N+1] = 0
for i in range(M):
    dp[a[i]] = 0

for i in range(N)[::-1]:
    if dp[i] == 0:
        continue
    dp[i] = dp[i+1] + dp[i+2]


print(dp[0]%1000000007)

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

for n, i in enumerate(a):
    if n > 0:
        if (a[n] - a[n-1]) == 1:
            print(0)
            exit()

def search(i, n):
    if i in a:
        return 0
    if i == n:
        return 1
    if i > n:
        return 0
    return search(i+1, n) + search(i+2, n)

ans = 1
start = 0
a.append(N+1)
for num in a:
    ans *= search(start, num-1)
    for i in range(1, N):
        start = num + i
        if start not in a:
            break

print(ans%1000000007)

Fixed submission:
N, M = map(int, input().split())
a = []
for i in range(M):
    a.append(int(input()))

for n, i in enumerate(a):
    if n > 0:
        if (a[n] - a[n-1]) == 1:
            print(0)
            exit()

dp = [-1] * (N+2)

dp[N] = 1
dp[N+1] = 0
for i in range(M):
    dp[a[i]] = 0

for i in range(N)[::-1]:
    if dp[i] == 0:
        continue
    dp[i] = dp[i+1] + dp[i+2]


print(dp[0]%1000000007)
Buggy python submission (verdict: Runtime Error):
import itertools

N, M = map(int, input().split())
k = []
for i in range(N):
    tmp = map(int, input().split())
    k.append(tmp)

p = input().split()

onoff = [0, 1]
kouho = list(itertools.product(onoff, repeat=N))

ans = 0
for li in kouho:
    for i in range(N):
        if p[i] == 0:
            li[i].count(0) % 2 == 0
            ans += 1
        else:
            li[i].count(0) % 2 == 1
            ans += 1
print(ans)

Fixed submission:
import itertools

N, M = map(int, input().split())
k = []
for i in range(M):
    tmp = [int(j) for j in input().split()]
    k.append(tmp)

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

onoff = [0, 1]
kouho = list(itertools.product(onoff, repeat=N))

ans = 0
for li in kouho:
    flag = True
    for i in range(M):
        end = k[i][0]+1
        sum = 0
        for j in range(1, end):
            sum += li[k[i][j]-1]
        if sum % 2 != p[i]:
            flag = False
            break
    if flag == True:
        ans += 1

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())

count = 0
ans=[]
for i in range(M):
    l, r = map(int, input().split())
    if count == 0:
        for j in range(l, r+1):
            ans.append(j)
    else:
        tmp = []
        for j in range(l, r+1):
            tmp.append(j)
        ans = list(set(tmp) & set(ans))
    count += 1

print(len(ans))


Fixed submission:

N, M = map(int, input().split())

L = []
R = []

for i in range(M):
    l, r = map(int, input().split())
    L.append(l)
    R.append(r)

maxl = max(L)
minr = min(R)

ans = minr - maxl + 1
if ans > 0:
    print(ans)
else:
    print(0)

Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())

L = []
R = []
LR = [int(i) for i in range(1, N+1)]
for i in range(M):
    l, r = map(int, input().split())
    L.append(l)
    R.append(r)
    LR.append(l)
    LR.append(r)

tmp = []
for gate in range(1, M+1):
    for i in range(L[gate-1], R[gate-1]+1):
        tmp.append(i)
    tmpLR = list(set(tmp) & set(LR))
    LR.clear()
    LR = tmpLR
    tmp.clear()

print(len(LR))

Fixed submission:

N, M = map(int, input().split())

L = []
R = []

for i in range(M):
    l, r = map(int, input().split())
    L.append(l)
    R.append(r)

maxl = max(L)
minr = min(R)

ans = minr - maxl + 1
if ans > 0:
    print(ans)
else:
    print(0)

Buggy python submission (verdict: Runtime Error):
    N, M = map(int, input().split())
     
    L = []
    R = []
    LR = [int(i) for i in range(1, N+1)]
    for i in range(M):
        l, r = map(int, input().split())
        L.append(l)
        R.append(r)
        LR.append(l)
        LR.append(r)
     
    tmp = []
    for gate in range(1, M+1):
        for i in range(L[gate-1], R[gate-1]+1):
            tmp.append(i)
        tmpLR = list(set(tmp) & set(LR))
        LR.clear()
        LR = tmpLR
        tmp.clear()
     
    print(len(LR))

Fixed submission:

N, M = map(int, input().split())

L = []
R = []

for i in range(M):
    l, r = map(int, input().split())
    L.append(l)
    R.append(r)

maxl = max(L)
minr = min(R)

ans = minr - maxl + 1
if ans > 0:
    print(ans)
else:
    print(0)

Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())

L = []
R = []
LR = [int(i) for i in range(1, N+1)]
for i in range(M):
    l, r = map(int, input().split())
    L.append(l)
    R.append(r)
    LR.append(l)
    LR.append(r)

tmp = []
for gate in range(1, M+1):
    for i in range(L[gate-1], R[gate-1]+1):
        tmp.append(i)
    tmpLR = list(set(tmp) & set(LR))
    LR.clear()
    LR = tmpLR
    tmp.clear()

print(len(LR))

Fixed submission:

N, M = map(int, input().split())

L = []
R = []

for i in range(M):
    l, r = map(int, input().split())
    L.append(l)
    R.append(r)

maxl = max(L)
minr = min(R)

ans = minr - maxl + 1
if ans > 0:
    print(ans)
else:
    print(0)
Buggy python submission (verdict: Time Limit Exceeded):
R, G, B, N = map(int, input().split())
     
ans = 0
for r in range(int(N/R)+1):
    for g in range(int(N/G)+1):
        if r*R + g*G <= N:
            if (N - (r*R + g*G))%B == 0:
                ans += 1
        else:
            break
     
print(ans)

Fixed submission:
R, G, B, N = map(int, input().split())
     
ans = 0
for r in range(int(N/R)+1):
    for g in range(int(N/G)+1):
        if r*R + g*G <= N:
            if (N - (r*R + g*G))%B == 0:
                ans += 1
     
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
R, G, B, N = map(int, input().split())

ans = 0
for r in range(int(N/R)+1):
    for g in range(int(N/G)+1):
        if r*R + g*G <= N:
            if (N - (r*R + g*G))%B == 0:
                ans += 1

print(ans)


Fixed submission:
R, G, B, N = map(int, input().split())
     
ans = 0
for r in range(int(N/R)+1):
    for g in range(int(N/G)+1):
        if r*R + g*G <= N:
            if (N - (r*R + g*G))%B == 0:
                ans += 1
     
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import itertools

N = int(input())
V = [int(i) for i in input().split()]
C = [int(i) for i in input().split()]

cand = [int(i) for i in range(N)]
ans = []
for i in range(N):
    hoge = list(itertools.combinations(tuple(cand), i))
    for t in hoge:
        tl = list(t)
        tmp = 0
        for j in tl:
            tmp += (V[j] - C[j])
        ans.append(tmp)
print(max(ans))     

Fixed submission:
N = int(input())
V = [int(i) for i in input().split()]
C = [int(i) for i in input().split()]
gap = []
for i in range(N):
    tmp = V[i]-C[i]
    if tmp > 0:
        gap.append(tmp)

ans = 0
for i in gap:
    ans += i

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import fractions, itertools
from functools import reduce

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

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

ans = 0
comblist = list(itertools.combinations(tuple(A), N-1))
for l in comblist:
    tmp = gcd(l)
    if tmp > ans:
        ans = tmp
print(ans)


Fixed submission:
import fractions

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

L = [0]
for i in range(N):
        L.append(fractions.gcd(L[i], A[i]))

R = [0] * (N+1)
for i in reversed(range(N)):
        R[i] = (fractions.gcd(R[i+1], A[i]))

ans = []
for i in range(N):
        ans.append(fractions.gcd(L[i], R[i+1]))

print(max(ans))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = input()

ans = 0
for i, s in enumerate(S):
    if i == N-1:
        break
    if s is '#':
        ans__ = 0
        flag = -1
        count = i
        for s_ in S[count+1:]:
            if count + 1 == N or s_ is '#':
                break
            if s_ is '.' :
                flag = 1
                ans__ += 1
        if flag == 1:
            ans_ = 1
            c = i
            while c >= 1:
                if S[c-1] is '#':
                    ans_ += 1
                c -= 1
            ans += min(ans_, ans__)

print(ans)


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

white_all = S.count('.')
ans = white_all

white = 0
black = 0
for i, s in enumerate(S):
    if s is '.':
        white += 1
    else:
        black += 1
    ans = min(black+(white_all-white), ans)

print(ans)
Buggy python submission (verdict: Runtime Error):
s = input()
S = list(s)

ans = 0
if len(S) == 1:
    print(ans)
    exit()
for i in range(1,len(S)):
    if S[i] is S[i-1]:
        if S[i] is '0':
            S[i] = '1'
        else:
            S[i] = '0'
        print(S)
        ans += 1
print(ans)

Fixed submission:
s = input()
S = list(s)

ans = 0
if len(S) == 1:
    print(ans)
    exit()
for i in range(1,len(S)):
    if S[i] is S[i-1]:
        if S[i] is '0':
            S[i] = '1'
        else:
            S[i] = '0'
        ans += 1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N, Q = map(int, input().split())
S = list(input())
lr = []
for i in range(Q):
    l, r = map(int, input().split())
    lr.append([l, r])

pair = [0] * len(S)
for i in range(len(S)-1):
    if S[i] is 'A' and S[i+1] is 'C':
        pair[i] = 1

for i in range(Q):
    ans = 0
    l = lr[i][0]-1
    r = lr[i][1]-1
    for j in range(l,r):
        ans += pair[j]
    print(ans)


Fixed submission:
N, Q = map(int, input().split())
S = list(input())
lr = []
for i in range(Q):
    l, r = map(int, input().split())
    lr.append([l, r])

pair = [0] * len(S)
for i in range(len(S)-1):
    if S[i] is 'A' and S[i+1] is 'C':
        pair[i+1] = pair[i] + 1
    else:
        pair[i+1] = pair[i]

for i in range(Q):
    ans = 0
    l = lr[i][0]-1
    r = lr[i][1]-1
    print(pair[r]-pair[l])

Buggy python submission (verdict: Time Limit Exceeded):
N, Q = map(int, input().split())
S = list(input())
lr = []
for i in range(Q):
    l, r = map(int, input().split())
    lr.append([l, r])

for i in range(Q):
    count = 0
    l = lr[i][0]-1
    r = lr[i][1]-1
    for j in range(l,r):
        if S[j] is 'A':
            if S[j+1] is 'C':
                count += 1
    print(count)

Fixed submission:
N, Q = map(int, input().split())
S = list(input())
lr = []
for i in range(Q):
    l, r = map(int, input().split())
    lr.append([l, r])

pair = [0] * len(S)
for i in range(len(S)-1):
    if S[i] is 'A' and S[i+1] is 'C':
        pair[i+1] = pair[i] + 1
    else:
        pair[i+1] = pair[i]

for i in range(Q):
    ans = 0
    l = lr[i][0]-1
    r = lr[i][1]-1
    print(pair[r]-pair[l])
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
h = [int(i) for i in input().split()]
h.extend([10**9]*1000)
dp = [10**9] * (N+1000)

dp[0] = 0

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

print(dp[N-1])

Fixed submission:
N, K = map(int, input().split())
h = [int(i) for i in input().split()]
h.extend([10**9]*1000)
dp = [10**9] * (N+1000)
 
dp[0] = 0
 
for i in range(N):
    for j in range(1, K+1):
        dp[i+j] = min(dp[i+j], dp[i] + abs(h[i] - h[i+j]))
 
print(dp[N-1])

Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())
h = [int(i) for i in input().split()]
h.extend([10**9]*10)
dp = [10**9] * (N+10)

dp[0] = 0

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

print(dp[N-1])

Fixed submission:
N, K = map(int, input().split())
h = [int(i) for i in input().split()]
h.extend([10**9]*1000)
dp = [10**9] * (N+1000)
 
dp[0] = 0
 
for i in range(N):
    for j in range(1, K+1):
        dp[i+j] = min(dp[i+j], dp[i] + abs(h[i] - h[i+j]))
 
print(dp[N-1])
Buggy python submission (verdict: Time Limit Exceeded):
N, W = map(int, input().split())
wv = [[0 for i in range(2)] for j in range(N)]

for i in range(N):
    w, v = map(int, input().split())
    wv[i] = [w, v]

dp = [[10**10 for i in range(2*10**6)] for j in range(2*N)]
dp[0][0] = 0

for i in range(N):
    for j in range(10**6):
        if j - wv[i][1] >= 0:
            dp[i+1][j] = min(dp[i+1][j], dp[i][j-wv[i][1]]+wv[i][0])
        dp[i+1][j] = min(dp[i+1][j], dp[i][j])

ans = 0
for i in range(10**6):
    if dp[N][i] <= W: 
        ans = i
print(ans)

Fixed submission:
N, W = map(int, input().split())
wv = [[0 for i in range(2)] for j in range(N)]

for i in range(N):
    w, v = map(int, input().split())
    wv[i] = [w, v]

dp = [[10**10 for i in range(10**5+100)] for j in range(150)]
dp[0][0] = 0

for i in range(N):
    for j in range(10**5+100):
        if j - wv[i][1] >= 0:
            dp[i+1][j] = min(dp[i+1][j], dp[i][j-wv[i][1]]+wv[i][0])
        dp[i+1][j] = min(dp[i+1][j], dp[i][j])

ans = 0
for i in range(10**5+100):
    if dp[N][i] <= W: 
        ans = i
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N, W = map(int, input().split())
wv = [[0 for i in range(2)] for j in range(N)]

for i in range(N):
    w, v = map(int, input().split())
    wv[i] = [w, v]

dp = [[10**10 for i in range(2*10**6)] for j in range(2*N)]
dp[0][0] = 0

for i in range(N):
    for j in range(10**6):
        if j - wv[i][1] >= 0:
            dp[i+1][j] = min(dp[i+1][j], dp[i][j-wv[i][1]]+wv[i][0])
        dp[i+1][j] = min(dp[i+1][j], dp[i][j])

ans = 0
for i in range(10**6):
    if dp[N][i] <= W: 
        ans = i
print(ans)


Fixed submission:
N, W = map(int, input().split())
wv = [[0 for i in range(2)] for j in range(N)]

for i in range(N):
    w, v = map(int, input().split())
    wv[i] = [w, v]

dp = [[10**10 for i in range(10**5+100)] for j in range(150)]
dp[0][0] = 0

for i in range(N):
    for j in range(10**5+100):
        if j - wv[i][1] >= 0:
            dp[i+1][j] = min(dp[i+1][j], dp[i][j-wv[i][1]]+wv[i][0])
        dp[i+1][j] = min(dp[i+1][j], dp[i][j])

ans = 0
for i in range(10**5+100):
    if dp[N][i] <= W: 
        ans = i
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = input()

def search(i):
        anti = [0,1,2,4,6,8,9]
        for j in anti:
                tmp = str(i).count(str(j))
                if tmp != 0:
                        return False

        cnt3 = str(i).count('3')
        if cnt3 == 0:
                return False
        cnt5 = str(i).count('5')
        if cnt5 == 0:
                return False
        cnt7 = str(i).count('7')
        if cnt7 == 0:
                return False

        return True

ans = 0
if int(N) < 357:
        print(ans)
        exit()

for i in range(357, int(N)+1):
        if search(i):
                ans += 1

print(ans)


Fixed submission:
N = input()

def search(i):
        if int(i) > int(N):
                return 0

        nums = [3, 5, 7]
        count = 0
        if all(i.count(str(n)) > 0 for n in nums):
                count = 1
        else:
                count = 0
        
        for n in nums:
                count += search(i + str(n))
        
        return count

print(search(str(0)))
Buggy python submission (verdict: Time Limit Exceeded):
N,M = map(int,input().split())

ypi = []
ipy = []
for i in range(M):
    p, y = map(int,input().split())
    ypi.append([y, p, i])
    ipy.append([i, p, y])

ypi.sort()

rank = [[] for i in range(N)]

for count in range(M):
    y, p, i = ypi[count]
    rank[p-1].append([i, p, y])

for count in range(M):
    i, p, y = ipy[count]
    ansp = p
    ansy = rank[p-1].index([i, p, y]) + 1

    print('{:06}'.format(ansp)+'{:06}'.format(ansy))

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

ypi = []

for i in range(M):
    p, y = map(int,input().split())
    ypi.append([y, p, i])

ypi.sort()

rank = [0] * N

ans = [''] * M
for count in range(M):
    y, p, i = ypi[count]
    rank[p-1] += 1
    ans[i] = '{:06}'.format(p)+'{:06}'.format(rank[p-1])

for s in ans:
    print(s)

Buggy python submission (verdict: Time Limit Exceeded):
N,M = map(int,input().split())

ypi = []
ipy = []
for i in range(M):
    p, y = map(int,input().split())
    ypi.append([y, p, i])
    ipy.append([i, p, y])

ypi.sort()

rank = [[] for i in range(N)]

for count in range(M):
    y, p, i = ypi[count]
    rank[p-1].append([i, p, y])

for count in range(M):
    i, p, y = ipy[count]
    ansp = p
    ansy = rank[p-1].index([i, p, y]) + 1

    print('{:06}'.format(ansp)+'{:06}'.format(ansy))

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

ypi = []

for i in range(M):
    p, y = map(int,input().split())
    ypi.append([y, p, i])

ypi.sort()

rank = [0] * N

ans = [''] * M
for count in range(M):
    y, p, i = ypi[count]
    rank[p-1] += 1
    ans[i] = '{:06}'.format(p)+'{:06}'.format(rank[p-1])

for s in ans:
    print(s)

Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())

city = [[0] * 100000 for j in range(N)]
citynum = [0] * 100000
citynum_ = [0] * 100000

for i in range(M):
    p, y = map(int, input().split())
    city[p-1][y] = i+1
    citynum[i+1] = p
    citynum_[i+1] = y

rank = [[0] * 100000 for j in range(N)]

for i in range(N):
    count = 0
    for j in range(100000):
        if city[i][j] != 0:
            count += 1
            rank[i][j] = count

citynum2 = [0] * 100000

for i in range(M):
    citynum2[citynum[i+1]] += 1
    ansp = citynum[i+1]
    ansy = rank[ansp-1][citynum_[i+1]]

    print('{:06}'.format(ansp)+'{:06}'.format(ansy))


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

ypi = []

for i in range(M):
    p, y = map(int,input().split())
    ypi.append([y, p, i])

ypi.sort()

rank = [0] * N

ans = [''] * M
for count in range(M):
    y, p, i = ypi[count]
    rank[p-1] += 1
    ans[i] = '{:06}'.format(p)+'{:06}'.format(rank[p-1])

for s in ans:
    print(s)
Buggy python submission (verdict: Runtime Error):
N = int(input())

x = []
y = []
h = []
for i in range(N):
    x_, y_, h_ = map(int, input().split())
    x.append(x_)
    y.append(y_)
    h.append(h_)

for i in range(0,101):
    for j in range(0,101):
        for hn in h:
            if hn > 0:
                tmph = hn + abs(i-x[n]) + abs(j-y[n])
                break
        count = 0
        for n in range(N):
            count += 1
            if h[n] != max(tmph - abs(i-x[n]) - abs(j-y[n]), 0):
                break
            if count == N:
                print(str(i) + ' ' + str(j) + ' ' + str(tmph))


Fixed submission:
N = int(input())

x = []
y = []
h = []
for i in range(N):
    x_, y_, h_ = map(int, input().split())
    x.append(x_)
    y.append(y_)
    h.append(h_)

for i in range(0,101):
    for j in range(0,101):
        for n, hn in enumerate(h):
            if hn > 0:
                tmph = hn + abs(i-x[n]) + abs(j-y[n])
                break
        count = 0
        for n in range(N):
            count += 1
            if h[n] != max(tmph - abs(i-x[n]) - abs(j-y[n]), 0):
                break
            if count == N:
                print(str(i) + ' ' + str(j) + ' ' + str(tmph))
Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())

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

if N == 1 or K == 1:
    print(x[0])
    exit()

suml = []
for left in x:
    if x.index(left) == len(x)-K+1:
        break
    tmp = abs(left) + abs(left - x[x.index(left)+K-1])
    suml.append(tmp)
ansl = min(suml)

sumr = []
for right in reversed(x):
    if x.index(right) == K-1:
        break
    tmp = abs(right) + abs(right - x[x.index(right)-K])
    sumr.append(tmp)
ansr = min(sumr)

print(min(ansl,ansr))


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

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

if N == 1 or K == 1:
    print(x[0])
    exit()

ans = 10**100
for i in range(N):
    if i < N-K+1:
        tmp1 = abs(x[i]) + abs(x[i] - x[i+K-1])
        tmp2 = abs(x[i+K-1]) + abs(x[i] - x[i+K-1])
        ans = min(tmp1, tmp2, ans)

print(ans)

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

xneg = []
xpos = []

for tmp in input().split():
    if int(tmp) < 0:
        xneg.append(int(tmp))
    else:
        xpos.append(int(tmp))

xneg.sort(reverse=True)
xpos.sort()

xp = 0
xn = 0
pre = 0
last1 = 0
last2 = 0
for i in range(K):
    if i == K-1:
        last1 = pre
        if len(xpos) > 0 and len(xneg) > 0:
            if xpos[xp] <= abs(xneg[xn]):
                last2 = xpos[xp]
            else:
                last2 = xneg[xn]
        elif len(xpos) > 0:
            last2 = xpos[xp]
        else:
            last2 = xneg[xn]
    else:
        if len(xpos) > 0 and len(xneg) > 0:
            if xpos[xp] <= abs(xneg[xn]):
                pre = xpos[xp]
                xp += 1
            else:
                pre = xneg[xn]
                xn += 1
        elif len(xpos) > 0:
            ans = xpos[K-1]
            print(ans)
            exit()
        else:
            ans = xneg[K-1]
            print(abs(ans))
            exit()

ans = 2*abs(min(last1,last2)) + abs(max(last1,last2))
print(ans)
    

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

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

if N == 1 or K == 1:
    print(x[0])
    exit()

ans = 10**100
for i in range(N):
    if i < N-K+1:
        tmp1 = abs(x[i]) + abs(x[i] - x[i+K-1])
        tmp2 = abs(x[i+K-1]) + abs(x[i] - x[i+K-1])
        ans = min(tmp1, tmp2, ans)

print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
memo = [-1] * 200000

def search(i): 
    if i == 0:
        return 0
    if memo[i] != -1:
        return memo[i]
    
    tmp = i
    cnt = 0
    while True: 
        n = 6 ** cnt
        if n > i:
            break       
        tmp = min(tmp, search(i-n)+1)
        cnt += 1
    cnt = 0
    while True:
        n = 9 ** cnt
        if n > i:
            break       
        tmp = min(tmp, search(i-n)+1)
        cnt += 1
    
    memo[i] = tmp
    return tmp

print(search(N))

Fixed submission:
N = int(input())

dp = [200000] * 200000
dp[0] = 0

for i in range(N+1):
    for j in range(i+1):
        tmp = 6**j
        if tmp > N or i - tmp < 0:
            break
        dp[i] = min(dp[i], dp[i-tmp]+1)
    for j in range(i+1):
        tmp = 9**j
        if tmp > N or i - tmp < 0:
            break
        dp[i] = min(dp[i], dp[i-tmp]+1)

print(dp[N])

Buggy python submission (verdict: Runtime Error):
N = int(input())
memo = [-1] * 100000

def search(i): 
    if i == 0:
        return 0
    if memo[i] != -1:
        return memo[i]
    
    tmp = i
    cnt = 0
    while True: 
        n = 6 ** cnt
        if n > i:
            break       
        tmp = min(tmp, search(i-n)+1)
        cnt += 1
    cnt = 0
    while True:
        n = 9 ** cnt
        if n > i:
            break       
        tmp = min(tmp, search(i-n)+1)
        cnt += 1
    
    memo[i] = tmp
    return tmp

print(search(N))

Fixed submission:
N = int(input())

dp = [200000] * 200000
dp[0] = 0

for i in range(N+1):
    for j in range(i+1):
        tmp = 6**j
        if tmp > N or i - tmp < 0:
            break
        dp[i] = min(dp[i], dp[i-tmp]+1)
    for j in range(i+1):
        tmp = 9**j
        if tmp > N or i - tmp < 0:
            break
        dp[i] = min(dp[i], dp[i-tmp]+1)

print(dp[N])
Buggy python submission (verdict: Runtime Error):
a, b, c, x, y = map(int, input().split())
n = min(x,y)
res = 0
if a+b > c*2:
    prod = c*n*2
    x -= n
    y -= n
    res += prod

if x > y:
    if a - c*2 > 0:
        res += c*2*x
        x -= x
else:
    if b - c*2 > 0:
        res += c*2*y
        y -= y

res += a*x + b*y
print(res)

Fixed submission:
s = input()

print(700+100*s.count('o'))