CodeEff/ECCO huggingface dataset:
# Original solution
N = int(eval(input()))

d = {}
x = [0] * N
y = [0] * N
from collections import defaultdict
for i in range(N):
    x[i], y[i] = list(map(int, input().split()))

pqs = []
for i in range(N):
    for j in range(N):
        if i == j:
            continue

        dx = x[i] - x[j]
        dy = y[i] - y[j]
        pqs.append((dx, dy))

ans = N
for pq in pqs:
    p, q = pq
    count = 0
    for i in range(N):
        for j in range(N):
            if i == j:
                continue
            dx = x[i] - x[j]
            dy = y[i] - y[j]
            if dx == p and dy == q:
                count += 1
    ans = min(ans, N - count)

print(ans)

# Optimized solution
N = int(eval(input()))

xys = []
from collections import defaultdict
for i in range(N):
    x, y = list(map(int, input().split()))
    xys.append((x, y))
pqs = []
for xy1 in xys:
    x1, y1 = xy1

    for xy2 in xys:
        x2, y2 = xy2

        dx = x1 - x2
        dy = y1 - y2

        if dx != 0 or dy != 0:
            pqs.append((dx, dy))

ans = N
for pq in pqs:
    p, q = pq
    count = 0
    for xy1 in xys:
        x1, y1 = xy1

        for xy2 in xys:
            x2, y2 = xy2

            dx = x1 - x2
            dy = y1 - y2
            if dx == p and dy == q:
                count += 1

    ans = min(ans, N - count)

print(ans)
# Original solution
n = int(eval(input()))
x = []
y = []
for _ in range(n):
    line = list(map(int, input().split()))
    x.append(line[0])
    y.append(line[1])
if n >= 2:
    slope = []
    for i in range(n):
        for j in range(n):
            if i != j:
                X = x[j] - x[i]
                Y = y[j] - y[i]
                slope.append([X, Y])
    cnt = []
    for i in slope:
        cnt.append(slope.count(i))
    print((n - max(cnt)))
else:
    print((1))

# Optimized solution
n = int(eval(input()))
x = []
y = []
for _ in range(n):
    line = list(map(int, input().split()))
    x.append(line[0])
    y.append(line[1])
if n >= 2:
    slope = []
    for i in range(n):
        for j in range(i+1, n):
            X = x[j] - x[i]
            Y = y[j] - y[i]
            if X != 0:
                if X < 0:
                    X = -X
                    Y = -Y
            slope.append([X, Y])
            if X == 0:
                slope.append([X, -Y])
    cnt = []
    for i in slope:
        cnt.append(slope.count(i))
    print((n - max(cnt)))
else:
    print((1))
# Original solution
import sys
input = sys.stdin.readline
'''
allinputs = iter(input().splitlines())
input = lambda : next(allinputs)
#'''
N = int(eval(input()))
x, y = [0] * N, [0] * N

for i in range(N):
	x[i], y[i] = list(map(int, input().split()))

pq = []
m = 0

if N == 1:
	print((1))
else:	
	for i in range(N):
		for j in range(N):
			if i == j:
				continue
				
			p, q = x[j] - x[i], y[j] - y[i]
			pq.append([p, q])
			
	for i in range(len(pq) - 1):
		n = 0
		for j in range(i + 1, len(pq)):
			if pq[i] == pq[j]:
				n += 1
				
		if n > m:
			m = n
			
	cost = N - m - 1
	print(cost)


# Optimized solution
import sys
input = sys.stdin.readline
'''
allinputs = iter(input().splitlines())
input = lambda : next(allinputs)
#'''
N = int(eval(input()))
x, y = [0] * N, [0] * N

for i in range(N):
	x[i], y[i] = list(map(int, input().split()))

pq = []
m = 1

if N == 1:
	print((1))
else:	
	for i in range(N):
		for j in range(N):
			if i == j:
				continue
				
			p, q = x[j] - x[i], y[j] - y[i]
			pq.append([p, q])
			
	for i in range(len(pq) - 1):
		n = 1
		for j in range(i + 1, len(pq)):
			if pq[i] == pq[j]:
				n += 1
				
		if n > m:
			m = n
			
	cost = N - m
	print(cost)
# Original solution
import itertools

N = int(eval(input()))
balls = []

for i in range(N):
    x, y = list(map(int, input().split(' ')))
    balls.append((x,y))

if N == 1:
    print("1")
    exit()

ans = 100
for l in list(itertools.permutations(balls)):
    dic = {}
    px = l[0][0]
    py = l[0][1]
    t_max = 1
    for i in range(1,len(l)):
        dx = l[i][0] - px
        px = l[i][0]
        dy = l[i][1] - py
        py = l[i][1]
        if (dx,dy) not in list(dic.keys()):
            dic[(dx,dy)] = 1
        else:
            dic[(dx,dy)] += 1
            if (t_max < dic[(dx,dy)]):
                t_max = dic[(dx,dy)]
        kitai = + N - i
        if ans < (N - kitai):
            break
    d_max = t_max
    cost = N - d_max
    if (cost < ans):
        ans = cost
        if (ans == 1):
            print(ans)
            exit()

print(ans)


# Optimized solution
N = int(eval(input()))
balls = []
for i in range(N):
    x, y = list(map(int, input().split(' ')))
    balls.append((x,y))

if N == 1:
    print("1")
    exit()

dic = {}
for i in range(N):
    for j in range(i+1,N):
        dx = balls[j][0] - balls[i][0]
        dy = balls[j][1] - balls[i][1]
        if (dx,dy) not in list(dic.keys()):
            dic[(dx,dy)] = 1
        else:
            dic[(dx,dy)] += 1
        dx *= -1
        dy *= -1
        if (dx,dy) not in list(dic.keys()):
            dic[(dx,dy)] = 1
        else:
            dic[(dx,dy)] += 1

d_max = max(dic.values())
print((N - d_max))
# Original solution
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left, bisect_right
from copy import copy
inf=float('inf')
mod = 10**9+7
def INT_(n): return int(n)-1
def MI(): return list(map(int,input().split()))
def MF(): return list(map(float, input().split()))
def MI_(): return list(map(INT_,input().split()))
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in eval(input())]
def I(): return int(eval(input()))
def F(): return float(eval(input()))
def ST(): return input().replace('\n', '')
def main():

    N = I()
    XY = LLIN(N)
    if N == 1:
        print((1))
        exit()
    XY.sort()

    count = defaultdict(int)
    for i, (x1, y1) in enumerate(XY):
        for j, (x2, y2) in enumerate(XY[i+1:]):
            dx, dy = x1 - x2, y1 - y2
            count[(dx, dy)] += 1
    maxim = -inf
    for v in list(count.values()):
        maxim = max(maxim, v)
    print((N - maxim))
    
    
                        
if __name__ == '__main__':
    main()

# Optimized solution
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left, bisect_right
from copy import copy
inf=float('inf')
mod = 10**9+7
def INT_(n): return int(n)-1
def MI(): return list(map(int,input().split()))
def MF(): return list(map(float, input().split()))
def MI_(): return list(map(INT_,input().split()))
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in eval(input())]
def I(): return int(eval(input()))
def F(): return float(eval(input()))
def ST(): return input().replace('\n', '')
def main():

    N = I()
    XY = LLIN(N)
    XY.sort()
    if N == 1:
        print((1))
        exit()
    
    count = defaultdict(int)
    for i, (x1, y1) in enumerate(XY):
        for j, (x2, y2) in enumerate(XY[i+1:]):
            dx, dy = x1 - x2, y1 - y2
            count[(dx, dy)] += 1
    print((N - max(count.values())))
    
    
                        
if __name__ == '__main__':
    main()
# Original solution
import sys
def input(): return sys.stdin.readline().rstrip()
from itertools import combinations
from collections import Counter
def main():
    n=int(eval(input()))
    if n==1:
        print((1))
        sys.exit()
    XY=[tuple(map(int,input().split())) for i in range(n)]
    XY.sort()
    lis=list(combinations(XY,2))
    PQ=[]
    for l in lis:
        PQ.append((l[1][0]-l[0][0],l[1][1]-l[0][1]))
    x=Counter(PQ).most_common(1)[0][1]
    print((n-x))

if __name__=='__main__':
    main()

# Optimized solution
import sys
def input(): return sys.stdin.readline().rstrip()
from itertools import combinations
from collections import Counter
def main():
    n=int(eval(input()))
    if n==1:
        print((1))
        sys.exit()
    XY=[tuple(map(int,input().split())) for i in range(n)]
    XY.sort()
    PQ=[]
    for i in range(n-1):
        x1=XY[i]
        for j in range(i+1,n):
            x2=XY[j]
            PQ.append((x2[0]-x1[0],x2[1]-x1[1]))
    print((n-Counter(PQ).most_common(1)[0][1]))

if __name__=='__main__':
    main()
# Original solution
from collections import Counter
N=int(eval(input()))
balls=[tuple(map(int, input().split())) for _ in range(N)]

#2ボールの相対座標をぜんぶ調べる
R=[(x[0]-y[0],x[1]-y[1]) for x in balls for y in balls]
C=Counter(R).most_common()

#いちばん多い相対座標を(p,q)とする
#C[0]は(0,0)なので除外
if len(C)<=1:
    print(N)
else:
    print((N-(C[1][1])))

# Optimized solution
from collections import Counter
N=int(eval(input()))
B=[tuple(map(int, input().split())) for _ in range(N)]
R=[(x[0]-y[0],x[1]-y[1]) for x in B for y in B if x!=y]
C=Counter(R).most_common(1)
print((N-C[0][1] if C else N))
# Original solution
#!/usr/bin/env python3
from itertools import product
n = int(eval(input()))
xy = [list(map(int, input().split())) for _ in range(n)]

xy.sort(key=lambda x: (x[0], x[1]))
ps = set()
for i, j in product(list(range(n)), list(range(n))):
    if i >= j:
        continue
    ps.add(xy[j][0] - xy[i][0])
qs = set()
for i, j in product(list(range(n)), list(range(n))):
    if i >= j:
        continue
    qs.add(xy[j][1] - xy[i][1])

m = 0
for p, q in product(ps, qs):
    c = 0
    for i in range(n - 1):
        for j in range(i + 1, n):
            if xy[j][0] - xy[i][0] != p:
                continue
            if xy[j][1] - xy[i][1] != q:
                continue
            c += 1
            break
    m = max(m, c)

xy.sort(key=lambda x: (x[1], x[0]))
ps = set()
for i, j in product(list(range(n)), list(range(n))):
    if i >= j:
        continue
    ps.add(xy[j][0] - xy[i][0])
qs = set()
for i, j in product(list(range(n)), list(range(n))):
    if i >= j:
        continue
    qs.add(xy[j][1] - xy[i][1])

for p, q in product(ps, qs):
    c = 0
    for i in range(n - 1):
        for j in range(i + 1, n):
            if xy[j][0] - xy[i][0] != p:
                continue
            if xy[j][1] - xy[i][1] != q:
                continue
            c += 1
            break
    m = max(m, c)

print((n - m))


# Optimized solution
#!/usr/bin/env python3
from itertools import product
n = int(eval(input()))
xy = [list(map(int, input().split())) for _ in range(n)]

m = 0
xy.sort(key=lambda x: (x[0], x[1]))
for l in range(n - 1):
    for r in range(l + 1, n):
        p = xy[r][0] - xy[l][0]
        q = xy[r][1] - xy[l][1]
        c = 0
        for i in range(n - 1):
            for j in range(i + 1, n):
                if xy[j][0] - xy[i][0] != p: continue
                if xy[j][1] - xy[i][1] != q: continue
                c += 1
                break
        m = max(m, c)

xy.sort(key=lambda x: (x[1], x[0]))
for l in range(n - 1):
    for r in range(l + 1, n):
        p = xy[r][0] - xy[l][0]
        q = xy[r][1] - xy[l][1]
        c = 0
        for i in range(n - 1):
            for j in range(i + 1, n):
                if xy[j][0] - xy[i][0] != p: continue
                if xy[j][1] - xy[i][1] != q: continue
                c += 1
                break
        m = max(m, c)

print((n - m))
# Original solution
#!/usr/bin/env python3
from itertools import product
n = int(eval(input()))
x = [None] * n
y = [None] * n
for i in range(n):
    x[i], y[i] = list(map(int, input().split()))

ps = set()
qs = set()
for s, t in product(list(range(n)), repeat=2):
    if s == t:
        continue
    ps.add(x[t] - x[s])
    qs.add(y[t] - y[s])

m = 0
for p, q in product(ps, qs):
    c = 0
    for s, t in product(list(range(n)), repeat=2):
        if s == t:
            continue
        if x[t] - x[s] == p and y[t] - y[s] == q:
            c += 1
    m = max(m, c)

print((n - m))


# Optimized solution
#!/usr/bin/env python3
from itertools import product
n = int(eval(input()))
x = [None] * n
y = [None] * n
for i in range(n):
    x[i], y[i] = list(map(int, input().split()))

m = 0
for i, j in product(list(range(n)), repeat=2):
    if i == j:
        continue
    p = x[j] - x[i]
    q = y[j] - y[i]
    c = 0
    for s, t in product(list(range(n)), repeat=2):
        if s == t:
            continue
        if x[t] - x[s] == p and y[t] - y[s] == q:
            c += 1
    m = max(m, c)

print((n - m))
# Original solution
n = int(eval(input()))

points = [list(map(int, input().split(" "))) for _ in range(n)]
X = 0
Y = 1
ans = 10 ** 14
for i in range(n):
    for j in range(n):
        if i == j:
            continue
        x1, y1 = points[i]
        x2, y2 = points[j]
        p = x1 - x2
        q = y1 - y2
        cost = n
        for point1 in points:  # そのpointからcost0で遷移できる先があるかどうか
            fromx, fromy = point1
            for point2 in points:
                tox, toy = point2
                if fromx - tox == p and fromy - toy == q:
                    cost -= 1
                    break
        if ans > cost:
            ans = cost
if n == 1:
    print((1))
else:
    print(ans)


# Optimized solution
n = int(eval(input()))

points = [list(map(int, input().split(" "))) for _ in range(n)]
X = 0
Y = 1
ans = 10 ** 14
if n == 1:
    ans = 1
else:
    for i in range(n):
        for j in range(n):
            if i == j:
                continue
            x1, y1 = points[i]
            x2, y2 = points[j]
            p = x1 - x2
            q = y1 - y2
            cost = n
            for point1 in points:  # そのpointからcost0で遷移できる先があるかどうか
                fromx, fromy = point1
                for point2 in points:
                    tox, toy = point2
                    if fromx - tox == p and fromy - toy == q:
                        cost -= 1
                        break
            if ans > cost:
                ans = cost
print(ans)
# Original solution
from collections import defaultdict
inpl = lambda: list(map(int,input().split()))

N = int(eval(input()))
xy = []
field = defaultdict(int)
for _ in range(N):
    x, y = inpl()
    xy.append((x,y))
    field[(x,y)] = 1
xy.sort()

pq = set()
for i in range(N):
    for j in range(i+1,N):
        x1, y1 = xy[i]
        x2, y2 = xy[j]
        p, q = x2-x1, y2-y1
        pq.add((p,q))

ans = N
for p, q in pq:
    removed = defaultdict(int)
    cost = 0
    for x, y in xy:
        if removed[(x,y)]:
            continue
        else:
            removed[(x,y)] = 1
            cost += 1
            while True:
                x += p
                y += q
                if field[(x,y)]:
                    removed[(x,y)] = 1
                else:
                    break
    if cost < ans:
        ans = cost

print(ans)

# Optimized solution
from collections import defaultdict
inpl = lambda: list(map(int,input().split()))
 
N = int(eval(input()))
xy = []
for _ in range(N):
    x, y = inpl()
    xy.append((x,y))
xy.sort()

edges = defaultdict(int)
edges[(0,0)] = 0
for i in range(N):
    for j in range(i+1,N):
        x1, y1 = xy[i]
        x2, y2 = xy[j]
        p, q = x2-x1, y2-y1
        edges[(p,q)] += 1
 
print((N - max(edges.values())))
# Original solution
ans=float("INF")
n=int(eval(input()))
l=[list(map(int,input().split())) for i in range(n)]
if n==1:print((1));exit()
for i in range(n):
    for j in range(n):
        if i==j:continue
        p,q=l[i][0]-l[j][0],l[i][1]-l[j][1]
        ret=0
        pre=sorted(l,reverse=1,key=lambda x:p*x[0]+q*x[1])
        while pre:
            ret+=1
            x,y=pre.pop()
            while  [x+p,y+q] in pre:
                pre.remove([x+p,y+q])
                x,y=[x+p,y+q]
        ans=min(ans,ret)
print(ans)

# Optimized solution
ans=float("INF")
n=int(eval(input()))
l=[list(map(int,input().split())) for i in range(n)]

for i in range(n):
    for j in range(n):

        p,q=l[i][0]-l[j][0],l[i][1]-l[j][1]
        ret=0
        pre=sorted(l,reverse=1,key=lambda x:p*x[0]+q*x[1])
        while pre:
            ret+=1
            x,y=pre.pop()
            while  [x+p,y+q] in pre:
                pre.remove([x+p,y+q])
                x,y=[x+p,y+q]
        ans=min(ans,ret)
print(ans)
# Original solution
def gcd(a, b):
    if b < 0:
        return gcd(a, -b)
    if b == 0:
        return a
    else:
        return gcd(b, a%b)

def solve():
    N = int(input())
    xy = [None] * N
    for i in range(N):
        xi, yi = [int(_) for _ in input().split()]
        xy[i] = (xi, yi)
    xy.sort(key = lambda x: x[0])
    pq_set = []
    def AddToPQSet(ele):
        pq, i, j = ele
        # if len(pq_set) == 0 or pq_set[0][0] > pq:
        #     pq_set.insert(0, (pq, set()))
        #     pq_set[0][1].add(i)
        #     pq_set[0][1].add(j)
        added_flag = False
        for ind in range(0, len(pq_set)):
            if pq_set[ind][0] == pq:
                subset_added = False
                for subset in pq_set[ind][1]:
                    if i in subset:
                        subset.add(j)
                        subset_added = True
                    elif j in subset:
                        subset.add(i)
                        subset_added = True
                if not subset_added:
                    tmp_set = set()
                    tmp_set.add(i)
                    tmp_set.add(j)
                    pq_set[ind][1].append(tmp_set)
                added_flag = True
            elif pq_set[ind][0] > pq:
                tmp_set = set()
                tmp_set.add(i)
                tmp_set.add(j)
                pq_set.insert(ind, (pq, [tmp_set]))
                added_flag = True
        if not added_flag:
            tmp_set = set()
            tmp_set.add(i)
            tmp_set.add(j)
            pq_set.append((pq, [tmp_set]))
        # print pq
        # print "i = " + str(i) + ", j = " + str(j)
        # print pq_set

    for i in range(N):
        for j in range(i+1, N):
            p = xy[j][0] - xy[i][0]
            q = xy[j][1] - xy[i][1]
            _gcd = gcd(p,q)
            # print "i = " + str(i) + ", j = " + str(j)
            # print p, q, _gcd
            p = p / _gcd
            q = q / _gcd
            AddToPQSet(((p,q),i,j))

    maxcntpq = 0
    # print pq_set
    for i in range(len(pq_set)):
        if len(pq_set[i][1]) > maxcntpq:
            num_subset = len(pq_set[i][1])
            cnt = 0
            for subset in pq_set[i][1]:
                cnt += len(subset)
            cnt -= num_subset
            if cnt > maxcntpq:
                maxcntpq = cnt
    print(N - maxcntpq)

if __name__ == '__main__':
    solve()


# Optimized solution

def solve2():
    N = int(input())
    xy = [None] * N
    for i in range(N):
        xi, yi = [int(_) for _ in input().split()]
        xy[i] = (xi, yi)
    if N == 1:
        print(N)
        return
    xy.sort()
    dist = []
    for i in range(N):
        for j in range(i+1, N):
            p = xy[j][0] - xy[i][0]
            q = xy[j][1] - xy[i][1]
            dist.append((p,q))
    dist.sort()
    max_cnt = 0
    cnt = 1
    save = dist[0]
    for i in range(1, len(dist)):
        if dist[i] == save:
            cnt += 1
        else:
            max_cnt = max(cnt, max_cnt)
            cnt = 1
            save = dist[i]
    max_cnt = max(cnt, max_cnt)
    print(N - max_cnt)

if __name__ == '__main__':
    solve2()
# Original solution
import itertools
import collections
n=int(eval(input()))
s=[list(map(int, input().split())) for i in range(n)]
ans=[]
x=list(itertools.permutations(s))

if n==1:
    print(n)
else:
    v=[]
    r=[]
    for i in range(len(x)):
        e=[]
        v=[]
        for j in range(n-1):
            a=x[i][j][0]
            b=x[i][j+1][0]
            c=x[i][j][1]
            d=x[i][j+1][1]
            v.append(b-a)
            v.append(d-c) 
        q=[v[i:i+2] for i in range(0,len(v),2)]
        for i in range(len(q)):
            e.append(q.count(q[i]))
        r.append(max(e))
    print((n-max(r)))

# Optimized solution
n=int(eval(input()))
s=[list(map(int, input().split()))  for i in range(n)]
x=[]
if n==1:
    print((1))
    exit(0)

for i in range(n):
    for j in range(n):
        if i==j:
            continue
        t=(s[i][0]-s[j][0],s[i][1]-s[j][1])
        x.append(t)
        
ans = [x.count(x[i]) for i in range(len(x))]
print((n-max(ans)))
# Original solution
n=int(eval(input()))
s=[list(map(int, input().split()))  for i in range(n)]
x=[]
if n==1:
    print((1))
    exit(0)

for i in range(n):
    for j in range(n):
        if i==j:
            continue
        t=(s[i][0]-s[j][0],s[i][1]-s[j][1])
        x.append(t)
        
ans = [x.count(x[i]) for i in range(len(x))]
print((n-max(ans)))


# Optimized solution
n=int(eval(input()))
s=[list(map(int, input().split()))  for i in range(n)]
x=[]
if n==1:
    print((1))
    exit(0)

for i in range(n):
    for j in range(n):
        if i==j:
            continue
        t=(s[i][0]-s[j][0],s[i][1]-s[j][1])
        x.append(t)
        
ans = [x.count(i) for i in set(x)]
print((n-max(ans)))
# Original solution
N = int(eval(input()))
ratio = [tuple(map(int, input().split())) for _ in range(N)]
t,a = 1,1

for nt,na in ratio:
    if nt<t or na<a:
        r = max((t-1)//nt+1, (a-1)//na+1)
        nt *= r
        na *= r
    t,a = nt,na
    #print(t, a)
print((t+a))


# Optimized solution
N = int(eval(input()))
ratio = [tuple(map(int, input().split())) for _ in range(N)]
t,a = 1,1

for nt,na in ratio:
    if nt<t or na<a:
        r = max(-(-t//nt), -(-a//na))
        nt *= r
        na *= r
    t,a = nt,na
    #print(t, a)
print((t+a))
# Original solution
N = int(eval(input()))
pt = pa = 0
for _ in range(N):
    t,a = list(map(int,input().split()))
    if pt == 0:pt,pa = t,a
    else:
        if (pt <= t) and (pa <= a):pt,pa = t,a
        else:
            i = 2
            while True:
                if (pt <= t*i) and (pa <= a*i):
                    pt,pa = t*i,a*i
                    break
                i += 1
print((pt+pa))

# Optimized solution
N = int(eval(input()))
pt = pa = 0
for _ in range(N):
    t,a = list(map(int,input().split()))
    if pt == 0:
        pt,pa = t,a
    else:
        #print(pt,pa,t,a)
        if (pt <= t) and (pa <= a):
            pt,pa = t,a
        else:
            '''
            i = 2
            while True:
                if (pt <= t*i) and (pa <= a*i):
                    pt,pa = t*i,a*i
                    break
                i += 1
            '''
            if t == a:
                #that is t = a = 1
                maxta = max(pt,pa)
                pt = pa = maxta
            else:
                w1 = -1 * ((-1 *pt) // t)
                w2 = -1 * ((-1 *pa) // a)
                w = max(w1,w2)
                pt = w * t
                pa = w * a
                #print(pt,pa)
print((pt+pa))
# Original solution
import math
n=int(eval(input()))
t,a=1,1
for i in range(n):
    ti,ai=list(map(int,input().split()))
    m=max(math.ceil(t/ti), math.ceil(a/ai))
    while t > ti*m or a > ai*m:
        m+=1
    while t <= ti*(m-1) and a <= ai*(m-1):
        m-=1
    t,a=ti*m,ai*m
print((t+a))

# Optimized solution
n=int(eval(input()))
t,a=1,1
for i in range(n):
    ti,ai=list(map(int,input().split()))
    m=max((t+ti-1)//ti, (a+ai-1)//ai)
    t,a=ti*m,ai*m
print((t+a))