Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
x, y, z, k = map(int,input().split())
a =list(map(int,input().split()))
b =list(map(int,input().split()))
c =list(map(int,input().split()))
c.sort(reverse=True)
ab = [0]*(x*y)
l = 0
for i in range(x):
    for j in range(y):
        ab[l] = a[i] + b[j]
        l += 1

ab.sort(reverse=True)
#print(ab)
q = 0
i = 0
j = 0
ans = [0]*(k*k)
l = 0
for i in range(min(k,x*y)):
    for j in range(min(k,z)):
        ans[l] = ab[i] + c[j]
        l += 1

ans.sort(reverse=True)
#print(ans)
for i in range(k):
    print(ans[i])


Fixed submission:
x, y, z, k = map(int,input().split())
a =list(map(int,input().split()))
b =list(map(int,input().split()))
c =list(map(int,input().split()))
c.sort(reverse=True)
ab = [0]*(x*y)
l = 0
for i in range(x):
    for j in range(y):
        ab[l] = a[i] + b[j]
        l += 1

ab.sort(reverse=True)
#print(ab)
q = 0
i = 0
j = 0
ans = [0]*(k*k)
l = 0
for i in range(min(k,x*y)):
    for j in range(min(k,z)):
        ans[l] = ab[i] + c[j]
        l += 1

ans.sort(reverse=True)
#print(ans)
for i in range(k):
    print(ans[i])
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
b = list(map(int,input().split()))

ans = []
def solve(b,i):
    if i == 0:
        return True
    for j in range(i-1,-1,-1):
        if b[j] == j+1:
            p = b[:j] + b[j+1:]
            if solve(p,i-1):
                ans.append(j+1)
                return True


    return False

solve(b,n)
if len(ans) == n:
    for i in range(n):
        print(ans[i])
else:
    print(-1)

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

ans = []
def solve(b,i):
    if i == 0:
        return True
    for j in range(i-1,-1,-1):
        if b[j] > j+1:
            return False
        if b[j] == j+1:
            p = b[:j] + b[j+1:]
            if solve(p,i-1):
                ans.append(j+1)
                return True

    return False

solve(b,n)
if len(ans) == n:
    for i in range(n):
        print(ans[i])
else:
    print(-1)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
b = list(map(int,input().split()))

q = []
for i in range(1,n+1):
    q.append([b[i-1],i])
ans = []
def solve(q,i):
    if i == 0:
        return True
    for j in range(i):
        if q[j][0] == j+1:
            p = q[:j] + q[j+1:]
            if solve(p,i-1):
                ans.append(j+1)
                return True


    return False

solve(q,n)
if len(ans) == n:
    for i in range(n):
        print(ans[i])
else:
    print(-1)

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

ans = []
def solve(b,i):
    if i == 0:
        return True
    for j in range(i-1,-1,-1):
        if b[j] > j+1:
            return False
        if b[j] == j+1:
            p = b[:j] + b[j+1:]
            if solve(p,i-1):
                ans.append(j+1)
                return True

    return False

solve(b,n)
if len(ans) == n:
    for i in range(n):
        print(ans[i])
else:
    print(-1)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
b = list(map(int,input().split()))

q = []
for i in range(1,n+1):
    q.append([b[i-1],i])
ans = []
def solve(q,i):
    if i == 0:
        return True
    for j in range(i):
        if q[j][0] == j+1:
            p = q[:j] + q[j+1:]
            if solve(p,i-1):
                ans.append(j+1)
                return True


    return

solve(q,n)
if len(ans) == n:
    for i in range(n):
        print(ans[i])
else:
    print(-1)

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

ans = []
def solve(b,i):
    if i == 0:
        return True
    for j in range(i-1,-1,-1):
        if b[j] > j+1:
            return False
        if b[j] == j+1:
            p = b[:j] + b[j+1:]
            if solve(p,i-1):
                ans.append(j+1)
                return True

    return False

solve(b,n)
if len(ans) == n:
    for i in range(n):
        print(ans[i])
else:
    print(-1)
Buggy python submission (verdict: Runtime Error):
n,m = map(int,input().split())
AB = [list(map(int,input().split())) for i in range(n)]
AB.sort(reverse = True)
c = 0
ans = 0
i = 0
while c < m:
  if  c + AB[i][1] <= m:
    c += AB[i][1]
    ans += AB[i][0]*AB[i][1]
    i += 1
  else:
    ans += Ab[i][0]*(m-c)
    break

print(ans)

Fixed submission:
n,m = map(int,input().split())
AB = [list(map(int,input().split())) for i in range(n)]
AB.sort()
c = 0
ans = 0
i = 0
while c < m:
  if  c + AB[i][1] <= m:
    c += AB[i][1]
    ans += AB[i][0]*AB[i][1]
    i += 1
  else:
    ans += AB[i][0]*(m-c)
    break

print(ans)
Buggy python submission (verdict: Runtime Error):
from fractions import gcd
a,b,k = map(int,input().split())
x = gcd(a,b)
now = 1
for i in range(x-1,-1,-1):
    if x%i == 0:now += 1
    if now == k:
        print(i)
        exit()

Fixed submission:
import fractions
a,b,k = map(int,input().split())
q = fractions.gcd(a,b)
count = 0
for i in range(q,-1,-1):
    if q%i == 0:
        count += 1
        if count == k:
            print(i)
            exit()
Buggy python submission (verdict: Time Limit Exceeded):
n,m = map(int,input().split())
AB = [list(map(int,input().split())) for i in range(m)]
#入力
AB.reverse()
ans = [0]*(m+1)
ans[m] = n*(n-1)//2
class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n+1)]
        self.rank = [0] * (n+1)

    # 検索
    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    # 併合
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
        else:
            self.par[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    # 同じ集合に属するか判定
    def same_check(self, x, y):
        return self.find(x) == self.find(y)

    # 属している集合の要素数
    def search(self,x):
        count = 0
        for y in range(1,n+1):
            if UnionFind.same_check(self,x,y):
                count += 1
        return count
uf = UnionFind(n)

for i in range(m):
    a = AB[i][0]
    b = AB[i][1]
    #print(a,b)
    if uf.same_check(a,b):
        ans[m-i-1] = ans[m-i]
        continue
    else:
        s = uf.search(a)
        t = uf.search(b)
        #print(s,t)
        uf.union(a,b)
        ans[m-i-1] = ans[m-i] + s*(s-1)//2 + t*(t-1)//2 - (s+t)*(s+t-1)//2
for i in range(1,m+1):
    print(ans[i])

Fixed submission:
n,m = map(int,input().split())
AB = [list(map(int,input().split())) for i in range(m)]
#入力
AB.reverse()
ans = [0]*(m+1)
ans[m] = n*(n-1)//2
class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n+1)]
        self.rank = [0] * (n+1)
        self.count = [1]* (n+1)

    # 検索
    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    # 併合
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
            self.count[y] += self.count[x]
            self.count[x] = 0
        else:
            self.par[y] = x
            self.count[x] += self.count[y]
            self.count[y] = 0
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1


    # 同じ集合に属するか判定
    def same_check(self, x, y):
        return self.find(x) == self.find(y)

    # 属している集合の要素数
    def search(self,x):
        q = UnionFind.find(self,x)
        return self.count[q]

uf = UnionFind(n)

for i in range(m):
    a = AB[i][0]
    b = AB[i][1]
    #print(a,b)
    if uf.same_check(a,b):
        ans[m-i-1] = ans[m-i]
        continue
    else:
        s = uf.search(a)
        t = uf.search(b)
        #print(s,t)
        uf.union(a,b)
        ans[m-i-1] = ans[m-i] + s*(s-1)//2 + t*(t-1)//2 - (s+t)*(s+t-1)//2
for i in range(1,m+1):
    print(ans[i])
Buggy python submission (verdict: Runtime Error):
n,a,b,c = map(int,input().split())
l=[int(input()) for i in range(n)]
answer = 10*100
for i in range(1,2**(2*n)):
    a_u = []
    b_u = []
    c_u = []
    ans = 0
    j = i
    counte = 0
    while counte <= n:
        if j%4 == 0:
            a_u.append(l[counte])
        if j%4 == 1:
            b_u.append(l[counte])
        if j%4 == 2:
            c_u.append(l[counte])
        j = j//4
        counte += 1
    if len(a_u)*len(b_u)*len(c_u) > 0:
        ans += abs(sum(a_u)-a) + 10*(len(a_u)-1)
        ans += abs(sum(b_u)-b) + 10*(len(b_u)-1)
        ans += abs(sum(c_u)-c) + 10*(len(c_u)-1)
        answer = min(ans,answer)

print(answer)

Fixed submission:
n, a, b, c = map(int,input().split())
L = [int(input()) for i in range(n)]
ans = 10**10

for i in range(4**n):
    ta, tb, tc = 0, 0, 0
    tmp = 0
    for j in range(n):
        k = (i>>(2*j)) & 3
        if k == 1:
            if ta > 0:
                tmp += 10
            ta += L[j]
        elif k == 2:
            if tb > 0:
                tmp += 10
            tb += L[j]
        elif k == 3:
            if tc > 0:
                tmp += 10
            tc += L[j]
    if ta * tb * tc == 0:
        continue
    tmp += abs(a - ta) + abs(b - tb) + abs(c - tc)
    ans = min(ans,tmp)

print(ans)
Buggy python submission (verdict: Runtime Error):
all_match = [2,5,5,4,5,6,3,7,6]

n,m = map(int,input().split())
a = list(map(int,input().split()))
a.sort(reverse=True)
match = []
for num in a:
    match.append(all_match[num-1])

dp = [-10**7 for i in range(n+1)] #桁数
dp[0] = 0

for i in range(1,n+1):
    possible = []
    for honsu in match:
        if i >= honsu:
            possible.append(dp[i-honsu] + 1)
    if len(possible)>0:
        dp[i] = max(possible)

length = dp[n]
ans = 0
now = n
for i in range(length):
    for j in range(m):
        if dp[now-match[j]] == dp[now]-1:
            ans += a[j]*10**(length-i-1)
            now -= match[j]
            break

print(ans)

Fixed submission:
all_match = [2,5,5,4,5,6,3,7,6]

n,m = map(int,input().split())
a = list(map(int,input().split()))
a.sort(reverse=True)
match = []
for num in a:
    match.append(all_match[num-1])

dp = [-10**7 for i in range(n+1)] #桁数
dp[0] = 0

for i in range(1,n+1):
    possible = []
    for honsu in match:
        if i >= honsu:
            possible.append(dp[i-honsu] + 1)
    if len(possible)>0:
        dp[i] = max(possible)

length = dp[n]
ans = 0
now = n
for i in range(length):
    for j in range(m):
        if now >= match[j]:
            if dp[now-match[j]] == dp[now]-1:
                ans += a[j]*10**(length-i-1)
                now -= match[j]
                break

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
t = input()
m = len(s)
n = len(t)

dp = [[-1]*(n+1) for i in range(m+1)]
dp[0][0] = 0
for i in range(n+1):
    dp[0][i] = 0
for i in range(m+1):
    dp[i][0] = 0
ans = [[""]*(n+1) for i in range(m+1)]
for i in range(1,m+1):
    for j in range(1,n+1):
        if s[i-1] == t[j-1]:
            ans[i][j] = ans[i-1][j-1] + t[j-1]
            dp[i][j] = dp[i-1][j-1] + 1
        else:
            if dp[i-1][j] < dp[i][j-1]:
                dp[i][j] = dp[i][j-1]
                ans[i][j] = ans[i][j-1]
            else:
                dp[i][j] = dp[i-1][j]
                ans[i][j] = ans[i-1][j]

print(ans[m][n])

Fixed submission:
s = input()
t = input()
s_length = len(s)
t_length = len(t)

dp = [[0 for j in range(t_length+1)] for i in range(s_length+1)]
#dp[i][j] = s[:i]とt[:j]に置けるLCS
for i in range(s_length):
    for j in range(t_length):
        if s[i] == t[j]:
            dp[i+1][j+1] = dp[i][j]+1
        else:
            dp[i+1][j+1] = max(dp[i+1][j],dp[i][j+1])

#print(dp)
#print(dp[s_length][t_length])

ans = ""
i = s_length
j = t_length
while i>0 and j > 0:
    if dp[i][j] == dp[i-1][j]:
        i -= 1
    elif dp[i][j] == dp[i][j-1]:
        j -= 1
    else:
        i -= 1
        j -= 1
        ans = s[i] + ans

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
t = input()
m = len(s)
n = len(t)

dp = [[-1]*(n+1) for i in range(m+1)]
dp[0][0] = 0
for i in range(n+1):
    dp[0][i] = 0
for i in range(m+1):
    dp[i][0] = 0
ans = [[""]*(n+1) for i in range(m+1)]
for i in range(1,m+1):
    for j in range(1,n+1):
        if s[i-1] == t[j-1]:
            ans[i][j] = ans[i-1][j-1] + t[j-1]
            dp[i][j] = dp[i-1][j-1] + 1
        else:
            if dp[i-1][j] < dp[i][j-1]:
                dp[i][j] = dp[i][j-1]
                ans[i][j] = ans[i][j-1]
            else:
                dp[i][j] = dp[i-1][j]
                ans[i][j] = ans[i-1][j]

print(ans[m][n])

Fixed submission:
s = input()
t = input()
s_length = len(s)
t_length = len(t)

dp = [[0 for j in range(t_length+1)] for i in range(s_length+1)]
#dp[i][j] = s[:i]とt[:j]に置けるLCS
for i in range(s_length):
    for j in range(t_length):
        if s[i] == t[j]:
            dp[i+1][j+1] = dp[i][j]+1
        else:
            dp[i+1][j+1] = max(dp[i+1][j],dp[i][j+1])

#print(dp)
#print(dp[s_length][t_length])

ans = ""
i = s_length
j = t_length
while i>0 and j > 0:
    if dp[i][j] == dp[i-1][j]:
        i -= 1
    elif dp[i][j] == dp[i][j-1]:
        j -= 1
    else:
        i -= 1
        j -= 1
        ans = s[i] + ans

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n,p = map(int,input().split())
if n == 1:
    print(p)
    exit()
i =2
ans =1
while i**n <= p:
    if p%(i**n)==0:
        ans *= i
        p =p//(i**n)
    else:
        i += 1
print(ans)


Fixed submission:
n,p = map(int,input().split())
if n == 1:
    print(p)
    exit()
if n >=40:
    print(1)
    exit()
i =2
ans =1
while i**n <= p:
    if p%(i**n)==0:
        ans *= i
        p =p//(i**n)

    else:
        i += 1
print(ans)

Buggy python submission (verdict: Runtime Error):
n,p = map(int,input().split())
if n == 1:
    print(p)
    exit()
if p == 1:
    print(1)
    exit()
for i in range(2,int(p**(1/n)+2)):
    if p%(i**n)==0:
        ans = i
print(ans)


Fixed submission:
n,p = map(int,input().split())
if n == 1:
    print(p)
    exit()
if n >=40:
    print(1)
    exit()
i =2
ans =1
while i**n <= p:
    if p%(i**n)==0:
        ans *= i
        p =p//(i**n)

    else:
        i += 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n,p = map(int,input().split())
if n == 1:
    print(p)
    exit()
if p == 1:
    print(1)
    exit()
for i in range(1,int(p**(1/n)+2)):
    if p%(i**n)==0:
        ans = i
print(ans)


Fixed submission:
n,p = map(int,input().split())
if n == 1:
    print(p)
    exit()
if n >=40:
    print(1)
    exit()
i =2
ans =1
while i**n <= p:
    if p%(i**n)==0:
        ans *= i
        p =p//(i**n)

    else:
        i += 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n,p = map(int,input().split())
if n == 1:
    print(p)
    exit()
i =1
ans =1
while i**n <= p:
    if p%(i**n)==0:
        ans *= i
        p =p//(i**n)
        i =1
    i += 1
print(ans)


Fixed submission:
n,p = map(int,input().split())
if n == 1:
    print(p)
    exit()
if n >=40:
    print(1)
    exit()
i =2
ans =1
while i**n <= p:
    if p%(i**n)==0:
        ans *= i
        p =p//(i**n)

    else:
        i += 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n,p = map(int,input().split())
if n == 1:
    print(p)
    exit()
q = int(p**(1/n))+1
i =q
while q>0:
    if p%(q**n)==0:
        print(q)
        exit()
    else:
        q -= 1
print(1)

Fixed submission:
n,p = map(int,input().split())
if n == 1:
    print(p)
    exit()
if n >=40:
    print(1)
    exit()
i =2
ans =1
while i**n <= p:
    if p%(i**n)==0:
        ans *= i
        p =p//(i**n)

    else:
        i += 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n,p = map(int,input().split())
if n == 1:
    print(p)
    exit()
i =1
while i**n <= p:
    if p%(i**n)==0:
        ans = i
    i += 1
print(ans)

Fixed submission:
n,p = map(int,input().split())
if n == 1:
    print(p)
    exit()
if n >=40:
    print(1)
    exit()
i =2
ans =1
while i**n <= p:
    if p%(i**n)==0:
        ans *= i
        p =p//(i**n)

    else:
        i += 1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n,m=map(int,input().split())
p=[]
for i in range(m):
    p.append(list(map(int,input().split())))
    p[i].append(i)
p.sort(key=lambda x:x[1])
count=0
for i in range(1,n+1):
    count = 0
    j=0
    while j<m:
        if p[j][0]==i:
            count +=1
            ans1 = '{0:06d}'.format(p[j][0])
            ans2 = '{0:06d}'.format(count)
            p[j].append(ans1 + ans2)
        j +=1
p.sort(key=lambda x: x[2])
for i in range(m):
    print(p[i][3])

Fixed submission:
n,m=map(int,input().split())
p=[]
for i in range(m):
    p.append(list(map(int,input().split())))
    p[i].append(i)
p.sort(key=lambda x:x[1])
p.sort(key=lambda x:x[0])
count=0
j=0
for i in range(m):
    if p[i][0] != j:
        count = 1
        j=p[i][0]
    else:
        count += 1
    ans1 = '{0:06d}'.format(p[i][0])
    ans2 = '{0:06d}'.format(count)
    p[i].append(ans1 + ans2)
p.sort(key=lambda x: x[2])
for i in range(m):
    print(p[i][3])
Buggy python submission (verdict: Runtime Error):
n = int(input())
for k in range(2,n + 1):
    if k * (k - 1) // 2 == n:
        print("Yes")
        break
    if k * (k - 1) // 2 > n:
        print("No")
        exit()

print(k)
answer = [[] for _ in range(k)]

num = [[i,j] for i in range(k) for j in range(i+1,k)]

for i,st in enumerate(num):
    s,t = st
    answer[s].append(i + 1)
    answer[t].append(i + 1)

for ans in answer:
    print(k-1,*ans)


Fixed submission:
n=int(input())
k=2
while n>=k*(k-1)/2:
    if n==k*(k-1)/2:
        print('Yes')
        print(k)
        a=list([] for i in range(k))
        t=1
        for i in range(0,k):
            for j in range(1,k-i):
                a[i].append(t)
                a[i+j].append(t)
                t+=1
        for i in range(k):
            print(str(k-1)+" "+" ".join(map(str,a[i])))
        exit()
    else:
        k+=1
print('No')
Buggy python submission (verdict: Runtime Error):
from collections import Counter
n=int(input())
v=list(map(int,input().split()))
a=Counter(v[::2]).most_common() #(数字,何回出現)が出現回数が大きい方から
b=Counter(v[1::2]).most_common()
if len(a)==1:
    a.append([0,0])
if len(b)==1:
    b.append([0,0])
if a[0][0]==b[0][0]:
    print(min(n-a[1,1]-b[0,1],n-a[0,1]-b[1,1]))
else:
    print(n-a[0,1]-b[0,1])


Fixed submission:
from collections import Counter
n=int(input())
v=list(map(int,input().split()))
a=Counter(v[::2]).most_common() #(数字,何回出現)が出現回数が大きい方から
b=Counter(v[1::2]).most_common()
if len(a)==1:
    a.append([0,0])
if len(b)==1:
    b.append([0,0])
if a[0][0]==b[0][0]:
    print(min(n-a[1][1]-b[0][1],n-a[0][1]-b[1][1]))
else:
    print(n-a[0][1]-b[0][1])

Buggy python submission (verdict: Runtime Error):
from collections import Counter
n=int(input())
v=list(map(int,input().split()))
a=Counter(v[::2]).most_common() #(数字,何回出現)が出現回数が大きい方から
b=Counter(v[1::2]).most_common()
if len(a)==1:
    a.append([0,0])
if len(b)==1:
    b.append([0,0])
if a[0,0]==b[0,0]:
    print(min(n-a[1,1]-b[0,1],n-a[0,1]-b[1,1]))
else:
    print(n-a[0,1]-b[0,1])


Fixed submission:
from collections import Counter
n=int(input())
v=list(map(int,input().split()))
a=Counter(v[::2]).most_common() #(数字,何回出現)が出現回数が大きい方から
b=Counter(v[1::2]).most_common()
if len(a)==1:
    a.append([0,0])
if len(b)==1:
    b.append([0,0])
if a[0][0]==b[0][0]:
    print(min(n-a[1][1]-b[0][1],n-a[0][1]-b[1][1]))
else:
    print(n-a[0][1]-b[0][1])
Buggy python submission (verdict: Runtime Error):
import math
N,X=map(int,input().split())
x=list(map(int,input().split()))
d=abs(x[0]-X)
if N==1:
    print(d)
    exit()
for i in range(1,len(x)):
    d=math.gcd(d,abs(x[i]-X))
print(d)

Fixed submission:
import fractions
N,X=map(int,input().split())
x=list(map(int,input().split()))
d=abs(x[0]-X)
if N==1:
    print(d)
    exit()
for i in range(1,len(x)):
    d=fractions.gcd(d,abs(x[i]-X))
print(d)

Buggy python submission (verdict: Runtime Error):
import math
N,X=map(int,input().split())
x=list(map(int,input().split()))
d=abs(x[0]-X)
for i in range(1,len(x)):
    d=math.gcd(d,abs(x[i]-X))
print(d)

Fixed submission:
import fractions
N,X=map(int,input().split())
x=list(map(int,input().split()))
d=abs(x[0]-X)
if N==1:
    print(d)
    exit()
for i in range(1,len(x)):
    d=fractions.gcd(d,abs(x[i]-X))
print(d)

Buggy python submission (verdict: Runtime Error):
import sys
import math
N,X=map(int,input().split())
x=list(map(int,input().split()))
d=abs(x[0]-X)
for i in range(1,len(x)):
    d=math.gcd(d,abs(x[i]-X))
print(d)

Fixed submission:
import fractions
N,X=map(int,input().split())
x=list(map(int,input().split()))
d=abs(x[0]-X)
if N==1:
    print(d)
    exit()
for i in range(1,len(x)):
    d=fractions.gcd(d,abs(x[i]-X))
print(d)
Buggy python submission (verdict: Runtime Error):
n,k=map(int,input().split())
x=list(map(int,input().split()))
for i in range(n-k+1):
    if i==0:
        a=min(abs(x[i])+abs(x[i]-x[i+k-1]),abs(x[i+k-1])+abs(x[i]-x[i+k-1]))
    else:
        a=min(ans,min(abs(x[i])+abs(x[i]-x[i+k-1]),abs(x[i+k-1])+abs(x[i]-x[i+k-1])))
print(a)

Fixed submission:
n,k=map(int,input().split())
x=list(map(int,input().split()))
for i in range(n-k+1):
    if i==0:
        a=min(abs(x[i])+abs(x[i]-x[i+k-1]),abs(x[i+k-1])+abs(x[i]-x[i+k-1]))
    else:
        a=min(a,min(abs(x[i])+abs(x[i]-x[i+k-1]),abs(x[i+k-1])+abs(x[i]-x[i+k-1])))
print(a)
Buggy python submission (verdict: Time Limit Exceeded):
n,m,Q = map(int,input().split())
LR = []
pon = []
for _ in range(m):
    LR.append(list(map(int,input().split())))
for _ in range(Q):
    p,q = map(int,input().split())
    ans = 0
    for i in range(m):
        if p<=LR[i][0] and LR[i][1] <= q:
            ans += 1
    pon.append(ans)
for i in range(Q):
    print(pon[i])

Fixed submission:
n, m, Q = map(int, input().split())
data = [[0]*(n+2) for i in range(n+2)]
for i in range(m):
    l, r = map(int, input().split())
    data[l][r] += 1

for i in range(n+2):
    for j in range(n+1):
        data[i][j+1] += data[i][j]

for i in range(n+1, -1, -1):
    for j in range(n+2):
        data[i-1][j] += data[i][j]

for i in range(Q):
    p, q = map(int, input().split())
    print(data[p][q])

Buggy python submission (verdict: Runtime Error):
n,m,q = map(int,input().split())
LR = []
ansl = []
for _ in range(m):
    LR.append(list(map(int,input().split())))
for _ in range(q):
    p,q = map(int,input().split())
    ans = 0
    for i in range(m):
        if p<=LR[i][0] and LR[i][1] <= q:
            ans += 1
    ansl.append(ans)
for i in range(q):
    print(ansl[i])

Fixed submission:
n, m, Q = map(int, input().split())
data = [[0]*(n+2) for i in range(n+2)]
for i in range(m):
    l, r = map(int, input().split())
    data[l][r] += 1

for i in range(n+2):
    for j in range(n+1):
        data[i][j+1] += data[i][j]

for i in range(n+1, -1, -1):
    for j in range(n+2):
        data[i-1][j] += data[i][j]

for i in range(Q):
    p, q = map(int, input().split())
    print(data[p][q])
Buggy python submission (verdict: Runtime Error):
a_list=list(map(int,input().split()))
ans=abs(a[0]-a[1])+abs(a[0]-a[2])
ans=min(ans,abs(a[1]-a[0])+abs(a[1]-a[2]))
ans=min(ans,abs(a[2]-a[1])+abs(a[0]-a[2]))
print(ans)

Fixed submission:
a=list(map(int,input().split()))
ans=abs(a[0]-a[1])+abs(a[0]-a[2])
ans=min(ans,abs(a[1]-a[0])+abs(a[1]-a[2]))
ans=min(ans,abs(a[2]-a[1])+abs(a[0]-a[2]))
print(ans)

Buggy python submission (verdict: Runtime Error):
a_list=list(int,input().split())
ans=abs(a[0]-a[1])+abs(a[0]-a[2])
ans=min(ans,abs(a[1]-a[0])+abs(a[1]-a[2]))
ans=min(ans,abs(a[2]-a[1])+abs(a[0]-a[2]))
print(ans)

Fixed submission:
a=list(map(int,input().split()))
ans=abs(a[0]-a[1])+abs(a[0]-a[2])
ans=min(ans,abs(a[1]-a[0])+abs(a[1]-a[2]))
ans=min(ans,abs(a[2]-a[1])+abs(a[0]-a[2]))
print(ans)