from typing import List
import math
import heapq


class Solution:
    def visiblePoints(self, points: List[List[int]], angle: int, location: List[int]) -> int:
        """
        https://stackoverflow.com/questions/42258637/how-to-know-the-angle-between-two-points
        """
        max_count = 0
        x, y = location[0], location[1]
        point_degree = []

        add_one = 0
        for point in points:
            if point == location:
                add_one = 1
            degree = math.degrees(math.atan2(
                point[1] - y, point[0] - x))
            if degree < 0:
                degree += 360
            point_degree.append((degree, point))

        point_degree.sort()

        max_count = 0
        candidate = []
        for degree, point in point_degree:
            while candidate and candidate[0][0] <= degree - angle:
                _, pt = heapq.heappop(candidate)
                if pt == location:
                    add_one = 1
            if point == location:
                add_one = 0
            heapq.heappush(candidate, (degree, point))
            max_count = max(max_count, len(candidate) + add_one)

        return max_count

# WA (solved => dirty logic of see if there is any "same location point" got picked or not)
#
# [[1,1],[2,2],[3,3],[4,4],[1,2],[2,1]]
# 0
# [1,1]
#
# 4

# WA (solved)
#
# [[0,0],[0,2]]
# 90
# [1,1]
#
# 2

# WA
#
# [[198768142,325231488],[730653894,526879029],[482566443,124650516],[301750308,786306795],[428637509,388444545],[824139468,560868920],[46101719,541790947],[33117389,306138652],[379129552,739264502],[632078701,382510936],[648669937,641406148],[402494603,290848535],[681757446,651339050],[755146968,328108553],[856055968,54585842],[642810790,781285498],[624780623,839525682],[225552068,597591380],[941428680,575243295],[904246597,409781914],[133988308,424694994],[263860625,642729245],[725256971,428462957],[951188673,24284291],[65878467,597579989],[423910337,760218568],[375233659,465709839],[39079416,44449206],[76488044,376497238],[768046853,401132958],[862857872,713625310],[834212457,613684155],[145940546,414657761],[438671565,895069996],[486059332,78047139],[539611528,236860222],[328891159,833572609],[561041358,896191043],[469734995,511499580],[868786087,593647615],[502014973,630219398],[834825976,939531210],[232809706,831430339],[446916520,518080962],[516594877,208057152],[851130172,768268153],[665228968,134767900],[347594646,46036486],[675842115,24895986],[877430373,353382710],[167579980,47992154],[125351210,769215749],[438404131,569154245],[604952972,128325995],[304627075,646626043],[651998767,527382342],[121415369,22955171],[46278664,726969424],[650197837,730272955],[326340006,424213045],[242071539,679004233],[208227275,449583956],[688763276,330569373],[657221239,659946024],[760680906,398786962],[695186876,163719246],[416909447,908414565],[59247263,674732497],[396812330,607544608],[752069054,728117920]]
# 86
# [136181398,475556834]
#
# 45

b4c48287dcf7036c73cc4f7c1f05d6f65ce6c493
<mask token>

<mask token>


class Solution:
    <mask token>

<mask token>


class Solution:

    def visiblePoints(self, points: List[List[int]], angle: int, location:
        List[int]) ->int:
        """
        https://stackoverflow.com/questions/42258637/how-to-know-the-angle-between-two-points
        """
        max_count = 0
        x, y = location[0], location[1]
        point_degree = []
        add_one = 0
        for point in points:
            if point == location:
                add_one = 1
            degree = math.degrees(math.atan2(point[1] - y, point[0] - x))
            if degree < 0:
                degree += 360
            point_degree.append((degree, point))
        point_degree.sort()
        max_count = 0
        candidate = []
        for degree, point in point_degree:
            while candidate and candidate[0][0] <= degree - angle:
                _, pt = heapq.heappop(candidate)
                if pt == location:
                    add_one = 1
            if point == location:
                add_one = 0
            heapq.heappush(candidate, (degree, point))
            max_count = max(max_count, len(candidate) + add_one)
        return max_count

from typing import List
import math
import heapq


class Solution:

    def visiblePoints(self, points: List[List[int]], angle: int, location:
        List[int]) ->int:
        """
        https://stackoverflow.com/questions/42258637/how-to-know-the-angle-between-two-points
        """
        max_count = 0
        x, y = location[0], location[1]
        point_degree = []
        add_one = 0
        for point in points:
            if point == location:
                add_one = 1
            degree = math.degrees(math.atan2(point[1] - y, point[0] - x))
            if degree < 0:
                degree += 360
            point_degree.append((degree, point))
        point_degree.sort()
        max_count = 0
        candidate = []
        for degree, point in point_degree:
            while candidate and candidate[0][0] <= degree - angle:
                _, pt = heapq.heappop(candidate)
                if pt == location:
                    add_one = 1
            if point == location:
                add_one = 0
            heapq.heappush(candidate, (degree, point))
            max_count = max(max_count, len(candidate) + add_one)
        return max_count

from typing import List
import math
import heapq


class Solution:
    def visiblePoints(self, points: List[List[int]], angle: int, location: List[int]) -> int:
        """
        https://stackoverflow.com/questions/42258637/how-to-know-the-angle-between-two-points
        """
        max_count = 0
        x, y = location[0], location[1]
        point_degree = []

        add_one = 0
        for point in points:
            if point == location:
                add_one = 1
            degree = math.degrees(math.atan2(
                point[1] - y, point[0] - x))
            if degree < 0:
                degree += 360
            point_degree.append((degree, point))

        point_degree.sort()

        max_count = 0
        candidate = []
        for degree, point in point_degree:
            while candidate and candidate[0][0] <= degree - angle:
                _, pt = heapq.heappop(candidate)
                if pt == location:
                    add_one = 1
            if point == location:
                add_one = 0
            heapq.heappush(candidate, (degree, point))
            max_count = max(max_count, len(candidate) + add_one)

        return max_count

# WA (solved => dirty logic of see if there is any "same location point" got picked or not)
#
# [[1,1],[2,2],[3,3],[4,4],[1,2],[2,1]]
# 0
# [1,1]
#
# 4

# WA (solved)
#
# [[0,0],[0,2]]
# 90
# [1,1]
#
# 2

# WA
#
# [[198768142,325231488],[730653894,526879029],[482566443,124650516],[301750308,786306795],[428637509,388444545],[824139468,560868920],[46101719,541790947],[33117389,306138652],[379129552,739264502],[632078701,382510936],[648669937,641406148],[402494603,290848535],[681757446,651339050],[755146968,328108553],[856055968,54585842],[642810790,781285498],[624780623,839525682],[225552068,597591380],[941428680,575243295],[904246597,409781914],[133988308,424694994],[263860625,642729245],[725256971,428462957],[951188673,24284291],[65878467,597579989],[423910337,760218568],[375233659,465709839],[39079416,44449206],[76488044,376497238],[768046853,401132958],[862857872,713625310],[834212457,613684155],[145940546,414657761],[438671565,895069996],[486059332,78047139],[539611528,236860222],[328891159,833572609],[561041358,896191043],[469734995,511499580],[868786087,593647615],[502014973,630219398],[834825976,939531210],[232809706,831430339],[446916520,518080962],[516594877,208057152],[851130172,768268153],[665228968,134767900],[347594646,46036486],[675842115,24895986],[877430373,353382710],[167579980,47992154],[125351210,769215749],[438404131,569154245],[604952972,128325995],[304627075,646626043],[651998767,527382342],[121415369,22955171],[46278664,726969424],[650197837,730272955],[326340006,424213045],[242071539,679004233],[208227275,449583956],[688763276,330569373],[657221239,659946024],[760680906,398786962],[695186876,163719246],[416909447,908414565],[59247263,674732497],[396812330,607544608],[752069054,728117920]]
# 86
# [136181398,475556834]
#
# 45
