Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
L_lst=sorted(list(map(int,input().split())))
cnt=0
for j in range(n-1,1,-1):
    i=j-1
    x=0
    while x<i:
        if L_lst[i]+L_lst[x]>L_lst[j]:
            cnt+=i-x
            i-=1
            x=0
        else:
            x+=1
print(cnt)

Fixed submission:
n=int(input())
L_lst=sorted(list(map(int,input().split())))
cnt=0
for j in range(n-1,1,-1):
    i=j-1
    x=0
    while x<i:
        if L_lst[i]+L_lst[x]>L_lst[j]:
            cnt+=i-x
            i-=1
        else:
            x+=1
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
L_lst=sorted(list(map(int,input().split())))
i=n-2
j=n-1
cnt=0
x=0
while j>1:
    while x<i:
        if L_lst[i]+L_lst[x]>L_lst[j]:
            cnt+=i-x
            i-=1
            x=0
        else:
            x+=1
    x=0
    j-=1
    i=j-1
print(cnt)

Fixed submission:
n=int(input())
L_lst=sorted(list(map(int,input().split())))
cnt=0
for j in range(n-1,1,-1):
    i=j-1
    x=0
    while x<i:
        if L_lst[i]+L_lst[x]>L_lst[j]:
            cnt+=i-x
            i-=1
        else:
            x+=1
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
L_lst=sorted(list(map(int,input().split())))
i=n-2
j=n-1
cnt=0
while j>1:
    x=0
    while x<i:
        if L_lst[i]+L_lst[x]>L_lst[j]:
            cnt+=i-x
            break
        else:
            x+=1
    i-=1
    if i==0 or (L_lst[j])//2 >= L_lst[i]:
        j-=1
        i=j-1
print(cnt)

Fixed submission:
n=int(input())
L_lst=sorted(list(map(int,input().split())))
cnt=0
for j in range(n-1,1,-1):
    i=j-1
    x=0
    while x<i:
        if L_lst[i]+L_lst[x]>L_lst[j]:
            cnt+=i-x
            i-=1
        else:
            x+=1
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
L_lst=sorted(list(map(int,input().split())))
i=n-2
j=n-1
cnt=0
while j>1:
    x_min=0
    x_max=i
    while x_max>x_min+1:
        x_mid=(x_max+x_min)//2
        if L_lst[x_mid]+L_lst[i]>L_lst[j]:
            x_max=x_mid
        else:
            x_min=x_mid
    if L_lst[x_min]+L_lst[i]>L_lst[j]:
        cnt+=i-x_min
    else:
        cnt+=max(i-x_min-1,0)
    i-=1
    if i==0 or (L_lst[j])//2 >= L_lst[i]:
        j-=1
        i=j-1
print(cnt)


Fixed submission:
n=int(input())
L_lst=sorted(list(map(int,input().split())))
cnt=0
for j in range(n-1,1,-1):
    i=j-1
    x=0
    while x<i:
        if L_lst[i]+L_lst[x]>L_lst[j]:
            cnt+=i-x
            i-=1
        else:
            x+=1
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
L_lst=sorted(list(map(int,input().split())))
i=n-2
j=n-1
cnt=0
while j>1:
    for x in range(i-1,-1,-1):
        if x==0:#0だとout of range
            if L_lst[x]+L_lst[i]>L_lst[j]:
                cnt+=1
        else:
            if L_lst[x]!=L_lst[x-1]:
                if L_lst[x]+L_lst[i]>L_lst[j]:
                    cnt+=1
                else:
                    break
    i-=1
    if i==0 or (L_lst[j])//2 >= L_lst[i]:
        j-=1
        i=j-1
print(cnt)


Fixed submission:
n=int(input())
L_lst=sorted(list(map(int,input().split())))
cnt=0
for j in range(n-1,1,-1):
    i=j-1
    x=0
    while x<i:
        if L_lst[i]+L_lst[x]>L_lst[j]:
            cnt+=i-x
            i-=1
        else:
            x+=1
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
L_lst=sorted(list(map(int,input().split())))
i=n-2
j=n-1
cnt=0
while j>1:
    for x in range(i-1,-1,-1):
        if x==0:#0だとout of range
            if abs(L_lst[i]-L_lst[j])<L_lst[x]<L_lst[i]+L_lst[j]:
                cnt+=1
        else:
            if L_lst[x]!=L_lst[x-1]:
                if abs(L_lst[i]-L_lst[j])<L_lst[x]<=L_lst[i]+L_lst[j]:
                    cnt+=1
    i-=1
    if i==0:
        j-=1
        i=j-1
print(cnt)

Fixed submission:
n=int(input())
L_lst=sorted(list(map(int,input().split())))
cnt=0
for j in range(n-1,1,-1):
    i=j-1
    x=0
    while x<i:
        if L_lst[i]+L_lst[x]>L_lst[j]:
            cnt+=i-x
            i-=1
        else:
            x+=1
print(cnt)