Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
A,B,C = map(int,input().split())
if C-A+B>0:
    print(C=A+B)
else:
    print(0)


Fixed submission:
A,B,C = map(int,input().split())
if C-A+B>0:
    print(C-A+B)
else:
    print(0)

Buggy python submission (verdict: Runtime Error):
A,B,C = map(int,input().split())
if C-A+B>0:print(C=A+B)
else:print(0)


Fixed submission:
A,B,C = map(int,input().split())
if C-A+B>0:
    print(C-A+B)
else:
    print(0)

Buggy python submission (verdict: Runtime Error):
A,B,C = map(int,input().split())
if C-A+B>0:print(C=A+B)
else:print(0)


Fixed submission:
A,B,C = map(int,input().split())
if C-A+B>0:
    print(C-A+B)
else:
    print(0)
Buggy python submission (verdict: Runtime Error):
N,D=map(int,input().split())
print(math.ceil(N/(2*D+1)))


Fixed submission:
import math
N,D=map(int,input().split())
print(math.ceil(N/(2*D+1)))
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
number=[]
for i in range(N):
    number.append(int(input()))
for i in range(N):
    a = number[i]
    del number[i]
    print(max(number))
    number.insert(i,a)

Fixed submission:
N = int(input())
number = []
for i in range(N):
    number.append(int(input()))
sorted_number = sorted(number,reverse=True)
max_number = sorted_number[0]
second_number = sorted_number[1]

for i in number:
    if i != max_number:
        print(max_number)
    else:
        print(second_number)
Buggy python submission (verdict: Runtime Error):
N,X=map(int,input().split())
length=list(map(int,input().split()))
ans=0
D=0

for i in range(N+1):
    if D<=X:
        ans+=1
        D = D + length[i]
print(ans)

Fixed submission:
N, X = map(int, input().split())
S = list(map(int, input().split()))
l = len(S)

ans = 1
num = 0

for i in range(l):
	num += S[i]
	if num <= X:
		ans += 1

print(ans)

Buggy python submission (verdict: Runtime Error):
N,X=map(int,input().split())
length=list(map(int,input().split()))
ans=0
D=0

for i in range(N+1):
    if D<=X:
        ans+=1
    else:
        break
    D=D+length[i]
print(ans)


Fixed submission:
N, X = map(int, input().split())
S = list(map(int, input().split()))
l = len(S)

ans = 1
num = 0

for i in range(l):
	num += S[i]
	if num <= X:
		ans += 1

print(ans)

Buggy python submission (verdict: Runtime Error):
N,X=map(int,input().split())
length=list(map(int,input().split()))
ans=0
D=0
i=0
while True:
    if D<=X:
        ans+=1
    else:
        break
    D=D+length[i]
    i+=1
print(ans)

Fixed submission:
N, X = map(int, input().split())
S = list(map(int, input().split()))
l = len(S)

ans = 1
num = 0

for i in range(l):
	num += S[i]
	if num <= X:
		ans += 1

print(ans)
Buggy python submission (verdict: Runtime Error):
#C - Forbidden List
X,N= map(int,input().split())
p= list(map(int,input().split()))
A= list(range(1,X+1))
for i in range(N):
    A.remove(p[i])

D = 101
ans = 0
for j in range(len(A)):
    if D >= abs(X - A[j]):
        D = abs(X - A[j])
        ans = A[j]
    else:
        pass
print(ans)

Fixed submission:
"""#D - Not Divisible
N= map(int,input().split())
A= list(map(int,input().split()))"""


#C - Forbidden List
X,N= map(int,input().split())
p= list(map(int,input().split()))
A= list(range(-200,200))
#print(A)
for i in range(N):
    A.remove(p[i])

D = 201
ans = -100
for j in range(len(A)):
    if D > abs(X - A[j]):
        D = abs(X - A[j])
        ans = A[j]

    else:
        pass
print(ans)
Buggy python submission (verdict: Runtime Error):
A,B= input().split()
A = int(A)
B2 = int(B*1000)
#print(A*B*100000)
print(int(A*B2/1000))

Fixed submission:
#C - Multiplication 3
from decimal import Decimal
A,B= map(str,input().split())
A2 = Decimal(A)
B2 = Decimal(B)
#print(A*B*100000)
print(int(A2*B2))

Buggy python submission (verdict: Runtime Error):
A,B= input().split()
A = int(A)
B2 = B*1000
#print(A*B*100000)
print(int(A*B2/1000))

Fixed submission:
#C - Multiplication 3
from decimal import Decimal
A,B= map(str,input().split())
A2 = Decimal(A)
B2 = Decimal(B)
#print(A*B*100000)
print(int(A2*B2))

Buggy python submission (verdict: Runtime Error):
A,B= map(input().split())
A = int(A)
B2 = B*1000
#print(A*B*100000)
print(int(A*B2/1000))

Fixed submission:
#C - Multiplication 3
from decimal import Decimal
A,B= map(str,input().split())
A2 = Decimal(A)
B2 = Decimal(B)
#print(A*B*100000)
print(int(A2*B2))
Buggy python submission (verdict: Time Limit Exceeded):
#C - Sum of gcd of Tuples (Easy)
K = int(input())
DP =[]
ans = 0
import math
from functools import reduce
def gcd(*numbers):
    return reduce(math.gcd, numbers)


def gcd_list(numbers):
    return reduce(math.gcd, numbers)


for i in range(1, K + 1):
    for j in range(1, K + 1):
        for k in range(1, K + 1):
            a = gcd_list([i, j, k])
            DP.append(a)

for l in range(len(DP)):
    ans += DP[l]
print(ans)

Fixed submission:
#C - Sum of gcd of Tuples (Easy)
K = int(input())
DP =[]
ans = 0
import math
# from functools import reduce
# def gcd(*numbers):
#     return reduce(math.gcd, numbers)


# def gcd_list(numbers):
#     return reduce(math.gcd, numbers)

for i in range(1, K + 1):
    for j in range(1, K + 1):
        a = math.gcd(i,j)
        for k in range(1,K+1):
            b = math.gcd(a,k)
            ans += b

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
#C - Sum of gcd of Tuples (Easy)
K = int(input())
sum = 0

import fractions
def N_gcd(ans):
    ans2 = ans[0]
    for n in range(1, 3):
        ans2 = fractions.gcd(ans2, ans[n])
    return ans2

for i in range(1,K+1):
    for j in range(1,K+1):
            for k in range(1,K+1):
                a = [i,j,k]
                sum += N_gcd(a)


print(sum)

Fixed submission:
#C - Sum of gcd of Tuples (Easy)
K = int(input())
DP =[]
ans = 0
import math
# from functools import reduce
# def gcd(*numbers):
#     return reduce(math.gcd, numbers)


# def gcd_list(numbers):
#     return reduce(math.gcd, numbers)

for i in range(1, K + 1):
    for j in range(1, K + 1):
        a = math.gcd(i,j)
        for k in range(1,K+1):
            b = math.gcd(a,k)
            ans += b

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
#C - Sum of gcd of Tuples (Easy)
K = int(input())
sum = 0
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

def gcd_list(numbers):
    return reduce(math.gcd, numbers)

for i in range(1,K+1):
    for j in range(1,K+1):
        for k in range(1,K+1):
            sum += gcd_list([i,j,k])

print(sum)

Fixed submission:
#C - Sum of gcd of Tuples (Easy)
K = int(input())
DP =[]
ans = 0
import math
# from functools import reduce
# def gcd(*numbers):
#     return reduce(math.gcd, numbers)


# def gcd_list(numbers):
#     return reduce(math.gcd, numbers)

for i in range(1, K + 1):
    for j in range(1, K + 1):
        a = math.gcd(i,j)
        for k in range(1,K+1):
            b = math.gcd(a,k)
            ans += b

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
#D - String Formation
S = list(str(input()))
Q = int(input())
q = [input().split() for i in range(Q)]

#print(S)
#print(q)

for i in range(Q):
    tmp1 = ""
    if q[i][0] == '1':
        S = S[::-1]
       # tmp1 = S[0]
       # S[0] = S[-1]
       # S[-1] = tmp1
    else:
        if q[i][1] == "1":
            S.insert(0,q[i][2])
        else:
            S.append(q[i][2])
ans = ''.join(S)
print(ans)

Fixed submission:
#D - String Formation
S=input()
Q=int(input())
query=[]
for _ in range(Q):
    query.append(input().split())

flag = True
t=""
u=""

for i in query:
    if i[0]=="1":
        u,t=t,u
        flag = not flag
#        S=S[::-1]
    else:
        if i[1]=="1":
            t+=i[2]
        else:
            u+=i[2]
if flag:
    print(t[::-1]+S+u)
else:
    print(t[::-1]+S[::-1]+u)

Buggy python submission (verdict: Time Limit Exceeded):
#D - String Formation
S = list(str(input()))
Q = int(input())
q = [input().split() for i in range(Q)]

#print(S)
#print(q)

for i in range(Q):
    tmp1 = ""
    if q[i][0] == '1':
        S.reverse()
       # tmp1 = S[0]
       # S[0] = S[-1]
       # S[-1] = tmp1
    else:
        if q[i][1] == "1":
            S.insert(0,q[i][2])
        else:
            S.append(q[i][2])
ans = ''.join(S)
print(ans)

Fixed submission:
#D - String Formation
S=input()
Q=int(input())
query=[]
for _ in range(Q):
    query.append(input().split())

flag = True
t=""
u=""

for i in query:
    if i[0]=="1":
        u,t=t,u
        flag = not flag
#        S=S[::-1]
    else:
        if i[1]=="1":
            t+=i[2]
        else:
            u+=i[2]
if flag:
    print(t[::-1]+S+u)
else:
    print(t[::-1]+S[::-1]+u)

Buggy python submission (verdict: Time Limit Exceeded):
#D - String Formation
S = list(str(input()))
Q = int(input())
q = [input().split() for i in range(Q)]

#print(S)
#print(q)

for i in range(Q):
    tmp1 = ""
    if q[i][0] == '1':
        S.reverse()
       # tmp1 = S[0]
       # S[0] = S[-1]
       # S[-1] = tmp1
    else:
        if q[i][1] == "1":
            S.insert(0,q[i][2])
        else:
            S.append(q[i][2])
ans = ''.join(S)
print(ans)

Fixed submission:
#D - String Formation
S=input()
Q=int(input())
query=[]
for _ in range(Q):
    query.append(input().split())

flag = True
t=""
u=""

for i in query:
    if i[0]=="1":
        u,t=t,u
        flag = not flag
#        S=S[::-1]
    else:
        if i[1]=="1":
            t+=i[2]
        else:
            u+=i[2]
if flag:
    print(t[::-1]+S+u)
else:
    print(t[::-1]+S[::-1]+u)
Buggy python submission (verdict: Time Limit Exceeded):
#D - Dice in Line
N,K = map(int,input().split())
p = list(map(int, input().split()))
sum = 0
sum_t = 0
for i in range(N-K+1):
    sum_t = 0
    for j in range(i, i+K):
        sum_t += ((1+p[j])*p[j])/(2*p[j])

    if sum_t >= sum:
        sum = sum_t
    else:
        pass

print(sum)

Fixed submission:
#D - Dice in Line
N,K = map(int,input().split())
p = list(map(int, input().split()))
S = [0]*N
s = 0
s_t = 0
S[0] = (1+p[0])/2

if N == 1:
    print(S[0])
    exit()
else:
    pass

for i in range(N-1):
    S[i+1] =S[i]+(1+p[i+1])/2

if N == K:
    print(S[N-1])
    exit()
else:
    pass

for j in range(N-K):
    s_t = S[j+K]-S[j]
    if s_t >= s:
        s = s_t
    else:
        pass

print(s)
Buggy python submission (verdict: Runtime Error):
# C - Snack
import math
A,B = map(int, input().split())
ans = (A * B) // math.gcd(A, B)
print(ans)

Fixed submission:
# C - Snack
import fractions
A,B = map(int, input().split())
ans = (A * B) // fractions.gcd(A, B)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
# C - 100 to 105
X = int(input())

for a in range(5001):
    for b in range(5001-100*a):
        for c in range(5001-100*a-101*b):
            for d in range(5001-100*a-101*b-102*c):
                for e in range(5001-100*a-101*b-102*c-103*d):
                    for f in range(5001-100*a-101*b-102*c*103*d-104*e):
                        if 100*a+101*b+102*c+103*d+104*e+105*f == X:
                            print(1)
                            exit()
                        else:
                            pass
print(0)

Fixed submission:
# C - 100 to 105
X = int(input())

for a in range(2501):
    for b in range(2501-100*a):
        for c in range(2501-100*a-101*b):
            for d in range(2501-100*a-101*b-102*c):
                for e in range(2501-100*a-101*b-102*c-103*d):
                    for f in range(2501-100*a-101*b-102*c*103*d-104*e):
                        if 100*a+101*b+102*c+103*d+104*e+105*f == X:
                            print(1)
                            exit()
                        else:
                            pass
print(0)

Buggy python submission (verdict: Runtime Error):
for a in range(500):
    for b in range(500-100*a):
        for c in range(500-100*a-101*b):
            for d in range(500-100*a-101*b-102*c):
                for e in range(500-100*a-101*b-102*c-103*d):
                    for f in range(500--100*a-101*b-102*c*103*d-104*e):
                        if 100*a+101*b+102*c+103*d+104*e+105*f == X:
                            print(1)
                            exit()
                        else:
                            pass
print(0)

Fixed submission:
# C - 100 to 105
X = int(input())

for a in range(2501):
    for b in range(2501-100*a):
        for c in range(2501-100*a-101*b):
            for d in range(2501-100*a-101*b-102*c):
                for e in range(2501-100*a-101*b-102*c-103*d):
                    for f in range(2501-100*a-101*b-102*c*103*d-104*e):
                        if 100*a+101*b+102*c+103*d+104*e+105*f == X:
                            print(1)
                            exit()
                        else:
                            pass
print(0)
Buggy python submission (verdict: Time Limit Exceeded):
# C - Attack Survival
N, K, Q = map(int, input().split())
a = [int(input()) for i in range(Q)]
A = 1 - (K-Q)
# print(N,K,Q,a,A)
for i in range(N):
    if a.count(i+1) >= A:
        print('Yes')
    else:
        print('No')


Fixed submission:
# C - Attack Survival
from collections import Counter

N, K, Q = map(int, input().split())
a = [int(input()) for i in range(Q)]
A = Counter(a)
B = 1 - (K-Q)

for i in range(N):
    if A[i+1] >= B:
        print('Yes')
    else:
        print('No')

Buggy python submission (verdict: Time Limit Exceeded):
# C - Attack Survival
N, K, Q = map(int, input().split())
a = [int(input()) for i in range(Q)]
for i in range(N):
    if K-Q+(a.count(i+1)) > 0:
        print('Yes')
    else:
        print('No')

Fixed submission:
# C - Attack Survival
from collections import Counter

N, K, Q = map(int, input().split())
a = [int(input()) for i in range(Q)]
A = Counter(a)
B = 1 - (K-Q)

for i in range(N):
    if A[i+1] >= B:
        print('Yes')
    else:
        print('No')
Buggy python submission (verdict: Runtime Error):

A_new = A
count = 1
while A_new <= B:
    if A_new == B:
        break
    else:
        A_new += A-1
        count += 1
print(count)


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


A_new = A
if B == 1:
    count = 0    
else:
    count = 1
    while A_new <= B:
        if A_new == B:
            break
        else:
            A_new = A_new-1
            A_new += A
            count += 1
print(count)
Buggy python submission (verdict: Runtime Error):
# # C - Lower
N = int(input())
H = list(map(int, input().split()))
count = []

for i in range(N):
    count_i = 0
    for j in range(i,N-1):
        if H[j] - H[j+1] >= 0:
            count_i += 1
            if j+1 == N-1:
                count.append(count_i)
            else:
                pass
        else:
            count.append(count_i)
            break

print(max(count))

Fixed submission:
# C - Lower
N = int(input())
H = list(map(int, input().split()))
max = 0
count_i = 0
for i in range(N-1):
    if H[i] >= H[i+1]:
        count_i += 1
    else:
        if max > count_i:
            count_i = 0
        else:
            max = count_i
            count_i = 0

    if max > count_i:
        pass
    else:
        max = count_i
print(max)
Buggy python submission (verdict: Runtime Error):
# D - ModSum
import numpy as np
N = int(input())

if N > 1:
    N_1 = np.array(list(range(1, N+1)))
    P_1 = np.array(list(range(2, N+1)))
    P_1 = np.append(P_1, 1)
    ans = sum(N_1 % P_1)
    print(ans)
else:
    print(0)

Fixed submission:
# D - ModSum
N = int(input())

ans = (N*(N-1))//2
print(int(ans))

Buggy python submission (verdict: Runtime Error):
# D - ModSum
import numpy as np
N = int(input())

if N > 1:
    N_1 = np.array(list(range(1, N+1)))
    P_1 = np.array(list(range(2, N+1)))
    P_1 = np.append(P_1, 1)

    ans = sum(N_1 % P_1)
    print(ans)
else:
    print(0)

Fixed submission:
# D - ModSum
N = int(input())

ans = (N*(N-1))//2
print(int(ans))

Buggy python submission (verdict: Runtime Error):
# D - ModSum
import numpy as np
N = int(input())

N_1 = np.array(list(range(1, N+1)))
P_1 = np.array(list(range(2,N+1)))
P_1 = np.append(P_1, 1)

ans = sum(N_1 % P_1)
print(ans)

Fixed submission:
# D - ModSum
N = int(input())

ans = (N*(N-1))//2
print(int(ans))
Buggy python submission (verdict: Runtime Error):
N = int(input())
H = list(map(int,input().split()))

for i in range(N-1):
	if H[i] < H[i+1]:
        pass
    else:
        H[i] = H[i]-1


count = 0
for k in range(N-1):
    if H[k] <= H[k + 1]:
        count = count + 1
    else:
        count = -1
        break

if 0 <= count <= N:
    print("Yes")
else:
    print("No")


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

for i in range(1, N):
    H[i] = H[i] - 1
    if H[i] < H[i-1]:
        H[i] = H[i] + 1
    else:
        pass


count = 0
for k in range(N-1):
    if H[k] <= H[k + 1]:
        count = count + 1
    else:
        count = -1
        break

if 0 <= count <= N:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Time Limit Exceeded):
# C - Exception Handling
N = int(input())
A = [int(input()) for i in range(N)]

#print(A)
max1 = max(A)

for i in range(N):
    if A[i] == max1:
        tmp =A[i]
        A[i] = 0
        print(max(A))
        A[i] = tmp
    else:
        print(max1)

Fixed submission:
# C - Exception Handling
N = int(input())
A = [int(input()) for i in range(N)]

#print(A)
max1 = sorted(A, reverse=True)
max2 = max1[0]

for i in range(N):
    if A[i] == max2:
        print(max1[1])

    else:
        print(max2)

Buggy python submission (verdict: Time Limit Exceeded):
# C - Exception Handling
N = int(input())
A = [int(input()) for i in range(N)]

#print(A)

for i in range(N):
    tmp = A[i]
    A[i] = 0
    print(max(A))
    A[i] = tmp


Fixed submission:
# C - Exception Handling
N = int(input())
A = [int(input()) for i in range(N)]

#print(A)
max1 = sorted(A, reverse=True)
max2 = max1[0]

for i in range(N):
    if A[i] == max2:
        print(max1[1])

    else:
        print(max2)
Buggy python submission (verdict: Runtime Error):
# B - Bounding
N, X = map(int,input().split())
L = list(map(int, input().split()))
D = 0
count = 0

for i in range(N+1):
    if D <= X:
        D += L[i]
        count += 1
    else:
        break
print(count)

Fixed submission:
# B - Bounding
N, X = map(int,input().split())
L = list(map(int, input().split()))
D = 0
count = 1

for i in range(N):
    D += L[i]
    if D <= X:
        count += 1
    else:
        break

print(count)
Buggy python submission (verdict: Runtime Error):
# B - Balance
N = int(input())
W = list(map(int, input().split()))
sum1 = 0
sum2 = 0
i = 0
while sum1 <= sum(W)/2:
    sum1 += W[i]
    sum2 = sum1 + W[i+1]
    i += 1

ans = min(abs(sum(W)-sum1-sum1),abs(sum(W)-sum2 - sum2))

#ans = abs(sum(W) - sum1-sum1)
print(ans)



Fixed submission:
# B - Balance
N = int(input())
W = list(map(int, input().split()))
sum_l = 0
sum_r = sum(W)
abs_W =[]
for i in range(N):
    sum_l += W[i]
    sum_r -= W[i]
    abs_W.append(abs(sum_r - sum_l))

print(min(abs_W))

Buggy python submission (verdict: Runtime Error):
# B - Balance
N = int(input())
W = list(map(int, input().split()))
sum1 = 0

i = 0
while sum1 <= sum(W)/2:
    sum1 += W[i]
    i += 1
    sum2 = sum1 + W[i+1]

ans = min(abs(sum(W)-sum1-sum1),abs(sum(W)-sum2-sum2))

#ans = abs(sum(W) - sum1-sum1)
print(ans)

Fixed submission:
# B - Balance
N = int(input())
W = list(map(int, input().split()))
sum_l = 0
sum_r = sum(W)
abs_W =[]
for i in range(N):
    sum_l += W[i]
    sum_r -= W[i]
    abs_W.append(abs(sum_r - sum_l))

print(min(abs_W))

Buggy python submission (verdict: Runtime Error):
# B - Balance
N = int(input())
W = list(map(int, input().split()))
sum1 = 0

i = 0
while sum1 < sum(W)/2:
    sum1 += W[i]
    i += 1
    sum2 = sum1 + W[i+1]

ans = min(abs(sum(W)-sum1-sum1),abs(sum(W)-sum2-sum2))

print(ans)

Fixed submission:
# B - Balance
N = int(input())
W = list(map(int, input().split()))
sum_l = 0
sum_r = sum(W)
abs_W =[]
for i in range(N):
    sum_l += W[i]
    sum_r -= W[i]
    abs_W.append(abs(sum_r - sum_l))

print(min(abs_W))
Buggy python submission (verdict: Runtime Error):
# B - Stone Monument
N, M = map(int,input().split())

tmp= (M-N)*( M-N+1)/2

ans( tmp-N)

Fixed submission:
# B - Stone Monument
a,b =map(int,input().split())

tmp= (b-a)*( b-a-1)/2

print(  int(tmp-a))
Buggy python submission (verdict: Time Limit Exceeded):
#C - Attention
N = int(input())
S = input()
DP = []
tmpw = 0
tmpe = 0
ans = 10**9
for i in range(N):
    tmpw = S[:i].count('W')
    tmpe = S[i+1:].count('E')
    if ans >= tmpe+tmpw:
        ans = tmpe+tmpw
    else:
        pass

print(ans)

Fixed submission:
#C - Attention
N = int(input())
S = input()
DP_w= []
DP_e = []
tmp = 0
tmpw = 0
tmpe = 0
ans = 10**9
for i in range(N):
    if S[i] == "W":
        tmpw += 1
        DP_w.append(tmpw)
    else:
        DP_w.append(tmpw)

for j in range(N-1,-1,-1):
    if S[j] == "E":
        tmpe += 1
        DP_e.append(tmpe)
    else:
        DP_e.append(tmpe)

DP_e.reverse()
for k in range(N):
    ans = min(ans,DP_w[k]+DP_e[k]-1)

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
#C - Attention
N = int(input())
S = input()
DP = []
tmpw = 0
tmpe = 0
for i in range(N):
    tmpw = S[:i].count('W')
    tmpe = S[i+1:].count('E')
    DP.append(tmpw+tmpe)

print(min(DP))

Fixed submission:
#C - Attention
N = int(input())
S = input()
DP_w= []
DP_e = []
tmp = 0
tmpw = 0
tmpe = 0
ans = 10**9
for i in range(N):
    if S[i] == "W":
        tmpw += 1
        DP_w.append(tmpw)
    else:
        DP_w.append(tmpw)

for j in range(N-1,-1,-1):
    if S[j] == "E":
        tmpe += 1
        DP_e.append(tmpe)
    else:
        DP_e.append(tmpe)

DP_e.reverse()
for k in range(N):
    ans = min(ans,DP_w[k]+DP_e[k]-1)

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
#C - Traveling Plan
N = int(input())
A = list(map(int, input().split()))
DP = []
ans = []
DP.append(abs(0-A[0]))
for i in range(1,N):
    DP.append(abs(A[i]-A[i-1]))

for j in range(N):
    DP2 = DP[:]
    #DP2.pop(j)

    if j == 0:
        DP2[j+1] = abs(A[j+1])
        tmp = sum(DP2)-DP2[0]+abs(A[N - 1])
    elif j == N-1:
        tmp = sum(DP2)-DP2[N-1]+abs(A[N - 2])
    else:
        tmp = sum(DP2) + abs(A[N - 1])-DP2[j]-DP2[j+1]+abs(A[j+1]-A[j-1])
    ans.append(tmp)

for i in range(len(ans)):
    print(ans[i])


Fixed submission:
#C - Traveling Plan
N = int(input())
A = list(map(int, input().split()))
DP = []
ans = []
DP.append(abs(0-A[0]))
for i in range(1,N):
    DP.append(abs(A[i]-A[i-1]))

sum_DP = sum(DP)

for j in range(N):
    if j == 0:
        tmp = sum_DP-DP[0]-DP[1]+abs(A[1])+abs(A[N - 1])
    elif j == N-1:
        tmp = sum_DP-DP[N-1]+abs(A[N - 2])
    else:
        tmp = sum_DP + abs(A[N - 1])-DP[j]-DP[j+1]+abs(A[j+1]-A[j-1])
    ans.append(tmp)

for i in range(len(ans)):
    print(ans[i])
Buggy python submission (verdict: Time Limit Exceeded):
# C - Good Sequence
N = int(input())
a = list(map(int, input().split()))
count = 0

a.sort(reverse=True)
a_1 = list(set(a))
for i in range(len(a_1)):
    if a_1[i] == a.count(a_1[i]):
        pass
    elif a_1[i] < a.count(a_1[i]):
        count += a.count(a_1[i])-a_1[i]
    else:
        count += a.count(a_1[i])

print(count)

Fixed submission:
# C - Good Sequence
import collections
N = int(input())
a = list(map(int, input().split()))
count = 0

a_1 = collections.Counter(a)

for k,v in a_1.items():
    if k <= v:
        count += v-k
    else:
        count += v

print(count)

Buggy python submission (verdict: Time Limit Exceeded):
# C - Good Sequence
N = int(input())
a = list(map(int, input().split()))
count = 0

for i in range(N):
    if a[i] == a.count(a[i]):
        pass
    else:
        a[i] = ''
        count += 1

print(count)

Fixed submission:
# C - Good Sequence
import collections
N = int(input())
a = list(map(int, input().split()))
count = 0

a_1 = collections.Counter(a)

for k,v in a_1.items():
    if k <= v:
        count += v-k
    else:
        count += v

print(count)