from math import gcd def make(): s = 0 v = [] for i in range(3, 100000): for j in range(i // 2 + 1): if gcd(i, j) == 1: s += i v.append((i - j, j)) if len(v) == 125000: return s, v return s, v s, v = make() v.sort(key=lambda t: t[1] / t[0]) print(1000000) x = s y = 0 for d in range(8): dir_x = [-1, -1, 1, 1][d // 2] dir_y = [1, -1, -1, 1][d // 2] swap = d % 4 // 2 == d % 2 dv = v if not d % 2 == 1 else v[::-1] for dx, dy in dv: print(x, y) if swap: x += dir_x * dy y += dir_y * dx else: x += dir_x * dx y += dir_y * dy