Buggy python submission (verdict: Time Limit Exceeded):
from math import hypot,atan2,pi,cos
N = int(input())
XY = [tuple(map(int,input().split())) for i in range(N)]

K = 200000
ans = 0
for i in range(K+1):
    t1 = 2*pi*i/K - pi
    r = 0
    for x,y in XY:
        t2 = atan2(y,x)
        a,b = (t1,t2) if t1<t2 else (t2,t1)
        if b-a > 3*pi/2:
            a += 2*pi
            a,b = b,a
        d = hypot(x,y) * cos(b-a)
        if d > 0:
            r += d
    ans = max(ans, r)
print(ans)

Fixed submission:
from math import hypot,atan2
N = int(input())
XY = [tuple(map(int,input().split())) for i in range(N)]
xy = sorted(XY, key=lambda x:atan2(x[1],x[0]))
xy += xy

ans = 0
for i in range(N):
    sx = sy = 0
    for j in range(N):
        x,y = xy[i+j]
        sx += x
        sy += y
        d = hypot(sx,sy)
        if d > ans:
            ans = d
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from math import hypot,atan2,pi,cos
N = int(input())
XY = [tuple(map(int,input().split())) for i in range(N)]

K = 300000
ans = 0
for i in range(K+1):
    t1 = 2*pi*i/K - pi
    r = 0
    for x,y in XY:
        t2 = atan2(y,x)
        a,b = (t1,t2) if t1<t2 else (t2,t1)
        if b-a > 3*pi/2:
            a += 2*pi
            a,b = b,a
        d = hypot(x,y) * cos(b-a)
        if d > 0:
            r += d
    ans = max(ans, r)
print(ans)

Fixed submission:
from math import hypot,atan2
N = int(input())
XY = [tuple(map(int,input().split())) for i in range(N)]
xy = sorted(XY, key=lambda x:atan2(x[1],x[0]))
xy += xy

ans = 0
for i in range(N):
    sx = sy = 0
    for j in range(N):
        x,y = xy[i+j]
        sx += x
        sy += y
        d = hypot(sx,sy)
        if d > ans:
            ans = d
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from math import hypot,atan2,pi,cos
N = int(input())
XY = [tuple(map(int,input().split())) for i in range(N)]

K = 400000
ans = 0
for i in range(K+1):
    t1 = 2*pi*i/K - pi
    r = 0
    for x,y in XY:
        t2 = atan2(y,x)
        a,b = (t1,t2) if t1<t2 else (t2,t1)
        if b-a > 3*pi/2:
            a += 2*pi
            a,b = b,a
        d = hypot(x,y) * cos(b-a)
        if d > 0:
            r += d
    ans = max(ans, r)
print(ans)

Fixed submission:
from math import hypot,atan2
N = int(input())
XY = [tuple(map(int,input().split())) for i in range(N)]
xy = sorted(XY, key=lambda x:atan2(x[1],x[0]))
xy += xy

ans = 0
for i in range(N):
    sx = sy = 0
    for j in range(N):
        x,y = xy[i+j]
        sx += x
        sy += y
        d = hypot(sx,sy)
        if d > ans:
            ans = d
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from math import hypot,atan2,pi,cos
N = int(input())
XY = [tuple(map(int,input().split())) for i in range(N)]

K = 500000
ans = 0
for i in range(K+1):
    t1 = 2*pi*i/K - pi
    r = 0
    for x,y in XY:
        t2 = atan2(y,x)
        a,b = (t1,t2) if t1<t2 else (t2,t1)
        if b-a > 3*pi/2:
            a += 2*pi
            a,b = b,a
        d = hypot(x,y) * cos(b-a)
        if d > 0:
            r += d
    ans = max(ans, r)
print(ans)

Fixed submission:
from math import hypot,atan2
N = int(input())
XY = [tuple(map(int,input().split())) for i in range(N)]
xy = sorted(XY, key=lambda x:atan2(x[1],x[0]))
xy += xy

ans = 0
for i in range(N):
    sx = sy = 0
    for j in range(N):
        x,y = xy[i+j]
        sx += x
        sy += y
        d = hypot(sx,sy)
        if d > ans:
            ans = d
print(ans)