Problem:
Problem A: How I Wonder What You Are! One of the questions children often ask is "How many stars are there in the sky?" Under ideal conditions, even with the naked eye, nearly eight thousands are observable in the northern hemisphere. With a decent telescope, you may find many more, but, as the sight field will be
limited, you may find much less at a time. Children may ask the same questions to their parents on a planet of some solar system billions
of light-years away from the Earth. Their telescopes are similar to ours with circular sight fields,
but alien kids have many eyes and can look into different directions at a time through many
telescopes. Given a set of positions of stars, a set of telescopes and the directions they are looking to, your
task is to count up how many stars can be seen through these telescopes. Input The input consists of one or more datasets. The number of datasets is less than 50. Each dataset
describes stars and the parameters of the telescopes used. The first line of a dataset contains a positive integer n not exceeding 500, meaning the number
of stars. Each of the n lines following it contains three decimal fractions, s x , s y , and s z . They
give the position ( s x , s y , s z ) of the star described in Euclidean coordinates. You may assume
-1000 ≤ s x ≤ 1000, -1000 ≤ s y ≤ 1000, -1000 ≤ s z ≤ 1000 and ( s x , s y , s z ) ≠ (0, 0, 0). Then comes a line containing a positive integer m not exceeding 50, meaning the number of
telescopes. Each of the following m lines contains four decimal fractions, t x , t y , t z , and φ , describing a telescope. The first three numbers represent the direction of the telescope. All the telescopes are at the
origin of the coordinate system (0, 0, 0) (we ignore the size of the planet). The three numbers give
the point ( t x , t y , t z ) which can be seen in the center of the sight through the telescope. You may
assume -1000 ≤ t x ≤ 1000, -1000 ≤ t y ≤ 1000, -1000 ≤ t z ≤ 1000 and ( t x , t y , t z ) ≠ (0, 0, 0). The fourth number φ (0 ≤ φ ≤ π /2) gives the angular radius, in radians, of the sight field of
the telescope. Let us defie that θ i,j is the angle between the direction of the i -th star and the center direction
of the j -th telescope and φ j is the angular radius of the sight field of the j -th telescope. The i -th star is observable through the j -th telescope if and only if θ i,j is less than . You may assume that | θ i,j - φ j | > 0.00000001 for all pairs of i and j .   Figure 1: Direction and angular radius of a telescope  The end of the input is indicated with a line containing a single zero. Output For each dataset, one line containing an integer meaning the number of stars observable through
the telescopes should be output. No other characters should be contained in the output. Note
that stars that can be seen through more than one telescope should not be counted twice or
more. Sample Input 3
100 0 500
-500.243 -200.1 -300.5
0 300 200
2
1 1 1 0.65
-1 0 0 1.57
3
1 0 0
0 1 0
0 0 1
4
1 -1 -1 0.9553
-1 1 -1 0.9554
-1 -1 1 0.9553
-1 1 -1 0.9554
3
1 0 0
0 1 0
0 0 1
4
1 -1 -1 0.9553
-1 1 -1 0.9553
-1 -1 1 0.9553
-1 1 -1 0.9553
0 Output for the Sample Input 2
1
0

Solution (Python):
import math


def solve_cos(star, telescope):
    inner = sum([i * j for i, j in zip(star, telescope)])
    dis_star = (sum(map(lambda a: a * a, star)))**(1 / 2)
    dis_telescope = (sum(map(lambda a: a * a, telescope)))**(1 / 2)
    return inner / (dis_star * dis_telescope)


while True:
    n = int(input())
    if n == 0:
        break
    stars = [list(map(float, input().split())) for i in range(n)]
    m = int(input())
    telescopes = [list(map(float, input().split())) for i in range(m)]

    count = 0
    for star in stars:
        for telescope in telescopes:
            cos1 = solve_cos(star, telescope[:-1])
            cos2 = math.cos(telescope[-1])
            if cos2 <= cos1:
                count += 1
                break

    print(count)

Solution (Python):
import math

while True:
    n = int(input())
    if not n:
        break

    stars = [list(map(float, input().split())) for i in range(n)]
    is_watch_star = [False for i in range(n)]
    scope = [list(map(float, input().split())) for j in range(int(input()))]

    for i in scope:
        a = (i[0] ** 2 + i[1] ** 2 + i[2] ** 2) ** 0.5
        for j in range(len(stars)):
            star = stars[j]
            b = (star[0] ** 2 + star[1] ** 2 + star[2] ** 2) ** 0.5
            if math.cos(i[3]) * a * b < i[0] * star[0] + i[1] * star[1] + i[2] * star[2]:
                is_watch_star[j] = True

    print(len(list(filter(lambda x:x, is_watch_star))))