Buggy python submission (verdict: Runtime Error):
def solve_():
    import itertools
    N, x = map(int, input().split())
    a = list(map(int, input().split()))
    s_cost = a.copy()
    cost = sum(s_cost)

    for k, i in itertools.product(range(1, N), range(N)):
        s_cost[i] = a[(i - k) % N] if s_cost > a[(i - k) % N] else s_cost[i]
        if i == N - 1 and cost > k*x + sum(s_cost):
            cost = k*x + sum(s_cost)
    
    print(cost)

solve()


Fixed submission:
N, x = list(map(int, input().split()))
a = list(map(int, input().split()))
s_cost = a.copy()
cost = sum(s_cost)
for k in range(1,N):
    for i in range(N):
        if s_cost[i] > a[(i-k)%N] :
            s_cost[i] = a[(i-k)%N]
    if cost > k*x + sum(s_cost):
        cost = k*x + sum(s_cost)
    else:
        break

print(cost)

Buggy python submission (verdict: Time Limit Exceeded):
N, x = list(map(int, input().split()))
a = list(map(int, input().split()))
s_cost = a.copy()
cost = sum(s_cost)
for k in range(1,N):
    for i in range(N):
        s_cost[i] = min(s_cost[i], a[(i-k)%N])
    # s_cost = [min(s_cost[x],a[y]) for (x,y) in zip( list(range(N)), list(range(N-k,N))+list(range(N-k)) )]
    if cost > k*x + sum(s_cost):
        cost = k*x + sum(s_cost)
    else:
        break

print(cost)


Fixed submission:
N, x = list(map(int, input().split()))
a = list(map(int, input().split()))
s_cost = a.copy()
cost = sum(s_cost)
for k in range(1,N):
    for i in range(N):
        if s_cost[i] > a[(i-k)%N] :
            s_cost[i] = a[(i-k)%N]
    if cost > k*x + sum(s_cost):
        cost = k*x + sum(s_cost)
    else:
        break

print(cost)

Buggy python submission (verdict: Time Limit Exceeded):
N, x = list(map(int, input().split()))
a = list(map(int, input().split()))
s_cost = a
cost = sum(s_cost)
for k in range(1,N):
    s_cost = [min(s_cost[x],a[y]) for (x,y) in zip( list(range(N)), [(x-k)%N for x in list(range(N))]) ]
    # s_cost = [min(s_cost[x],a[y]) for (x,y) in zip( list(range(N)), list(range(N-k,N))+list(range(N-k)) )]
    if cost > k*x + sum(s_cost):
        cost = k*x + sum(s_cost)
    else:
        break

print(cost)

Fixed submission:
N, x = list(map(int, input().split()))
a = list(map(int, input().split()))
s_cost = a.copy()
cost = sum(s_cost)
for k in range(1,N):
    for i in range(N):
        if s_cost[i] > a[(i-k)%N] :
            s_cost[i] = a[(i-k)%N]
    if cost > k*x + sum(s_cost):
        cost = k*x + sum(s_cost)
    else:
        break

print(cost)

Buggy python submission (verdict: Time Limit Exceeded):
N, x = list(map(int, input().split()))
a = list(map(int, input().split()))
s_cost = a.copy()
cost = sum(s_cost)
orig_list = list(range(N))
index_list = orig_list.copy()
for k in range(1,N):
    index_list = [x-1 for x in index_list]
    index_list =  [x%N for x in index_list]
    s_cost = [min(s_cost[x],a[y]) for (x,y) in zip( orig_list, index_list )]
    if cost > k*x + sum(s_cost):
        cost = k*x + sum(s_cost)
    else:
        break

print(cost)


Fixed submission:
N, x = list(map(int, input().split()))
a = list(map(int, input().split()))
s_cost = a.copy()
cost = sum(s_cost)
for k in range(1,N):
    for i in range(N):
        if s_cost[i] > a[(i-k)%N] :
            s_cost[i] = a[(i-k)%N]
    if cost > k*x + sum(s_cost):
        cost = k*x + sum(s_cost)
    else:
        break

print(cost)

Buggy python submission (verdict: Time Limit Exceeded):
N, x = list(map(int, input().split()))
a = list(map(int, input().split()))
s_cost = a
cost = sum(s_cost)
orig_list = list(range(N))
for k in range(1,N):
    s_cost = [min(s_cost[x],a[y]) for (x,y) in zip( orig_list, list(range(N-k,N))+list(range(N-k)) )]
    if cost > k*x + sum(s_cost):
        cost = k*x + sum(s_cost)
    else:
        break

print(cost)


Fixed submission:
N, x = list(map(int, input().split()))
a = list(map(int, input().split()))
s_cost = a.copy()
cost = sum(s_cost)
for k in range(1,N):
    for i in range(N):
        if s_cost[i] > a[(i-k)%N] :
            s_cost[i] = a[(i-k)%N]
    if cost > k*x + sum(s_cost):
        cost = k*x + sum(s_cost)
    else:
        break

print(cost)

Buggy python submission (verdict: Time Limit Exceeded):
N, x = list(map(int, input().split()))
a = list(map(int, input().split()))
s_cost = a
cost = sum(s_cost)
for k in range(1,N):
    s_cost = [min(s_cost[x],a[y]) for (x,y) in zip( list(range(N)), list(range(N-k,N))+list(range(N-k)) )]
    if cost > k*x + sum(s_cost):
        cost = k*x + sum(s_cost)
    else:
        break
print(cost)


Fixed submission:
N, x = list(map(int, input().split()))
a = list(map(int, input().split()))
s_cost = a.copy()
cost = sum(s_cost)
for k in range(1,N):
    for i in range(N):
        if s_cost[i] > a[(i-k)%N] :
            s_cost[i] = a[(i-k)%N]
    if cost > k*x + sum(s_cost):
        cost = k*x + sum(s_cost)
    else:
        break

print(cost)

Buggy python submission (verdict: Time Limit Exceeded):
N, x = list(map(int, input().split()))
a = list(map(int, input().split()))
s_cost = a
cost = sum(s_cost)
for k in range(0,N):
    s_cost = [min(s_cost[x],a[y]) for (x,y) in zip( list(range(N)), list(range(N-k,N))+list(range(N-k)) )]
    if cost >= k*x + sum(s_cost):
        cost = k*x + sum(s_cost)
        # cost = min(cost, k*x + sum(s_cost))
    else:
        break
print(cost)

Fixed submission:
N, x = list(map(int, input().split()))
a = list(map(int, input().split()))
s_cost = a.copy()
cost = sum(s_cost)
for k in range(1,N):
    for i in range(N):
        if s_cost[i] > a[(i-k)%N] :
            s_cost[i] = a[(i-k)%N]
    if cost > k*x + sum(s_cost):
        cost = k*x + sum(s_cost)
    else:
        break

print(cost)

Buggy python submission (verdict: Runtime Error):
N, x = list(map(int, input().split()))
a = list(map(int, input().split()))
s_cost = a
cost = sum(s_cost)
for k in xrange(0,N):
    s_cost = [min(s_cost[x],a[y]) for (x,y) in zip( list(xrange(N)), list(xrange(N-k,N))+list(xrange(N-k)) )]
    cost = min(cost, k*x + sum(s_cost))

print(cost)


Fixed submission:
N, x = list(map(int, input().split()))
a = list(map(int, input().split()))
s_cost = a.copy()
cost = sum(s_cost)
for k in range(1,N):
    for i in range(N):
        if s_cost[i] > a[(i-k)%N] :
            s_cost[i] = a[(i-k)%N]
    if cost > k*x + sum(s_cost):
        cost = k*x + sum(s_cost)
    else:
        break

print(cost)

Buggy python submission (verdict: Time Limit Exceeded):
N, x = list(map(int, input().split()))
a = list(map(int, input().split()))
s_cost = a
cost = sum(s_cost)
for k in range(1,N):
    for i in range(N):
        i_index = i-k
        if (i-k) == -1:
            i_index+=N
        s_cost[i] = min(s_cost[i], s_cost[i_index])
    cost = min(cost, k*x + sum(s_cost))

print(cost)

Fixed submission:
N, x = list(map(int, input().split()))
a = list(map(int, input().split()))
s_cost = a.copy()
cost = sum(s_cost)
for k in range(1,N):
    for i in range(N):
        if s_cost[i] > a[(i-k)%N] :
            s_cost[i] = a[(i-k)%N]
    if cost > k*x + sum(s_cost):
        cost = k*x + sum(s_cost)
    else:
        break

print(cost)

Buggy python submission (verdict: Runtime Error):
N, x = list(map(int, input().split()))
a = list(map(int, input().split()))
min_index = a.index(min(a))
index_list = list(range(min_index,N)) + list(range(min_index))
cost = a.copy()
c_count = [0]*N
for i in range(1,N):
    if cost[index_list[i]] => (cost[index_list[i-1]]+x):
        cost[index_list[i]] = cost[index_list[i-1]]+x
        c_count[index_list[i]] = c_count[index_list[i-1]]+1

print(sum(cost) - sum(c_count)*x + max(c_count)*x  )


Fixed submission:
N, x = list(map(int, input().split()))
a = list(map(int, input().split()))
s_cost = a.copy()
cost = sum(s_cost)
for k in range(1,N):
    for i in range(N):
        if s_cost[i] > a[(i-k)%N] :
            s_cost[i] = a[(i-k)%N]
    if cost > k*x + sum(s_cost):
        cost = k*x + sum(s_cost)
    else:
        break

print(cost)