Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

from math import factorial

def main():
    N = int(input())
    A = list(map(int, input().split()))

    A.sort()
    n = A[-1]
    maxc = 0
    fn = factorial(n)
    for r in A[:-1]:
        comb = (fn // factorial(n - r)) // factorial(r)
        if maxc < comb:
            ans = r
            maxc = comb
    print(n, ans)

main()


### FIXED CODE ###

import bisect

def main():
    N = int(input())
    A = list(map(int, input().split()))

    A.sort()
    n = A[-1]
    i = bisect.bisect_left(A, n / 2)
    if n / 2 - A[i-1] <= A[i] - n / 2:
        r = A[i-1]
    else:
        r = A[i]
    print(n, r)

main()
### BUGGY CODE ###

import queue
H,W = map(int,input().split())
INF = 10**10
all_map = [[INF for i in range(W)]for i in range(H)]
q = queue.Queue()
for i in range(H):
  a = list(input())
  for w in range(W):
    if a[w]=='#':
      all_map[i][w] = 0
      q.put([i-1,w])
      q.put([i+1,w])
      q.put([i,w-1])
      q.put([i,w+1])

while not(q.empty()):
  p = q.get()
  h,w = p[0],p[1]
  if h<0 or H<=h or w<0 or W<=w:
    continue
  if all_map[h][w]!=INF:
    continue
  ####
  s = []
  if 0<=h-1:
    q.put([h-1,w])
    s.append(all_map[h-1][w])
  if h+1<H:
    q.put([h+1,w])
    s.append(all_map[h+1][w])
  if 0<=w-1:
    q.put([h,w-1])
    s.append(all_map[h][w-1])
  if w+1<W:
    q.put([h,w+1])
    s.append(all_map[h][w+1])
  all_map[h][w] = min(s)+1

res = 0
for i in range(H):
  res = max(res,max(all_map[i]))
print(res)

### FIXED CODE ###

H,W = map(int,input().split())
A = [list(input()) for i in range(H)]
S = [[0]*W for i in range(H)]
for h in range(H):
    for w in range(W):
        if A[h][w]=="#":
            S[h][w] = H*W
for h in range(H):
    a = 0
    for w in range(W):
        S[h][w] = max(a,S[h][w])
        a = max(a,S[h][w])-1
    for w in range(W)[::-1]:
        S[h][w] = max(a,S[h][w])
        a = max(a,S[h][w])-1
for w in range(W):
    a = 0
    for h in range(H):
        S[h][w] = max(a,S[h][w])
        a = max(a,S[h][w])-1
    for h in range(H)[::-1]:
        S[h][w] = max(a,S[h][w])
        a = max(a,S[h][w])-1
ans = H*W
for h in range(H):
    for w in range(W):
        ans = min(ans,S[h][w])
print(H*W-ans)
### BUGGY CODE ###

n,m=map(int,input().split())
for i in range((m//n)+1,0,-1):
    if(m%i==0 and m//i>=n):
        print(i)
        break

### FIXED CODE ###

n,m=map(int,input().split())
i=1
x=[]
while(i*i<=m):
    if(m%i==0):
        x.append(i)
        x.append(m//i)
    i+=1
x.sort()
for xi in x:
    if(xi>=n):
        print(m//xi)
        break
### BUGGY CODE ###

# -*- coding: utf-8 -*-
n = int(input())
l = [int(i) for i in input().split()]
if n > 1:
  for j in range(n):
    if j != n - 1 and max(l[: j + 1]) - min(l[j + 1 :]) >= 2:
      print('No')
      exit()
print('Yes')

### FIXED CODE ###

# -*- coding: utf-8 -*-
n = int(input())
li = [int(a) for a in input().split()]
ans = 'Yes'

if n > 1:
  for i in range(n-1):
    if li[-(i+2)] <= li[-(i+1)]:
      pass
    elif li[-(i+2)] - 1 <= li[-(i+1)]:
      li[-(i+2)] = li[-(i+2)] - 1
    else:
      ans = 'No'
      break

print(ans)
### BUGGY CODE ###

n,a=map(int,input().split())
N=list(map(int,input().split()))
from functools import lru_cache
@lru_cache(maxsize=400000)
def cal(a,b,c):
    if a==b==c==0:
        return 1
    if a>=1 and c<N[a-1]:
        return cal(a-1,b,c)
    if a>=1 and b>=1and c>=N[a-1]:
        return(cal(a-1,b,c)+cal(a-1,b-1,c-N[a-1]))
    else:
        return 0
    
ans=0
for k in range(n):
    ans+=cal(n,k+1,(k+1)*a)
print(ans)

### FIXED CODE ###

n,a=map(int,input().split())
lists=list(map(int,input().split()))

for i in range(n):
    lists[i]-=a
answer=0
dp=[[0 for i in range(5001)] for _ in range(51)]
#dp[i][j]で0からi枚目まで好きなように選択してそのそうわがｊ-2500となるような撮り方の総数
#最終的に求めるのはdp[i][0]である

for i in range(n+1):
    for j in range(4951):
        if i>=1 and j>=lists[i-1]:
            dp[i][j]=dp[i-1][j-lists[i-1]]+dp[i-1][j]
        if i>=1 and j<lists[i-1]:
            dp[i][j]=dp[i-1][j]
        else:
            if j==2500 and i==0:
                dp[i][j]=1
            elif j!=2500 and i==0:
                dp[i][j]=0
print(dp[n][2500]-1)
### BUGGY CODE ###

N = int(input())
T = []
for i in range(N):
    t=int(input())
    T.append(t)

m = max(T)
ans = m
while(1):
    flag = True
    for i in range(N):
        if ans % T[i] != 0:
            flag = False
            break
    if flag:
        print(ans)
        exit()
    else:
        ans += m

### FIXED CODE ###

N = int(input())
T = []
for i in range(N):
    t=int(input())
    T.append(t)

import fractions

T.sort(reverse=True)
ans = T[0]
for i in range(1,N):
    gcd = fractions.gcd(ans,T[i])
    ans = (ans*T[i])//gcd
print(ans)
### BUGGY CODE ###

n, k, q = map(int, input().split())

a = list(map(int, [input() for i in range(q)]))
b = [k]*n

cnt = k-q

for j in range(1,n+1):
    if cnt+a.count(j)>0:
        print("Yes")
    else:
        print("No")

### FIXED CODE ###

n, k, q = map(int, input().split())
b=[k-q]*n

for i in range(q):
    ctn = int(input())
    b[ctn-1]+=1

for j in range(n):
    if b[j]>0:
        print("Yes")
    else:
        print("No")
### BUGGY CODE ###

from collections import defaultdict
N, P = map(int,input().split())
S = input()

if P==5:
    ans = 0
    for i,m in enumerate(S):
        if m == '5' or m == '0':
            ans += i+1
elif P==2:
    ans = 0
    for i,m in enumerate(S):
        if int(m) % 2 ==0:
            ans += i+1
else:
    primdic = defaultdict(int)
    for i in range(N):
        # i~右端までの数字のmodPをキーにする
        primdic[int(S[i:])%P] += 1
    # 文字なしの時はあまり0なので
    primdic[0] += 1
    ans = 0
    for value in primdic.values():
        ans += value*(value-1)//2
print(ans)

### FIXED CODE ###

from collections import defaultdict
N, P = map(int,input().split())
S = input()

if P==5:
    ans = 0
    for i,m in enumerate(S):
        if m == '5' or m == '0':
            ans += i+1
elif P==2:
    ans = 0
    for i,m in enumerate(S):
        if int(m) % 2 ==0:
            ans += i+1
else:
    S = S[::-1]
    primdic = defaultdict(int)
    before = 0
    for i in range(0,N):
        now = (int(S[i])*pow(10,i,P)+before)%P
        primdic[now] += 1
        before = now
    # 文字なしの時はあまり0なので
    primdic[0] += 1
    ans = 0
    for value in primdic.values():
        ans += value*(value-1)//2
print(ans)
### BUGGY CODE ###

import math
n, x, y = map(int,input().split())
num = [0 for i in range(n)]

for i in range(n):
    for j in range(i+1,n):
        num[min([j-i,int(math.fabs(j-y+1))+1+int(math.fabs(i-x+1))])] += 1

for i in range(1,n):
    print(num[i])


### FIXED CODE ###

n, x, y = map(int,input().split())
num = [0 for i in range(n)]

for i in range(1,n+1):
    for j in range(i+1,n+1):
        ban = min([j-i,abs(x-i)+1+abs(y-j)])
        num[ban] += 1

for i in range(1,n):
    print(num[i])
### BUGGY CODE ###

import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n, m = na()
li = na()
list.sort(li)
ls = []
for i in range(len(li)-1):
    ls.append(li[i+1]-li[i])
if len(ls) < n - 1:
    print(0)
else:
    for j in range(n - 1):
        if len(ls) > 0:
            ls.remove(max(ls))
    print(sum(ls))

### FIXED CODE ###

import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n, m = na()
li = na()
ls = []
list.sort(li)
for i in range(len(li) - 1):
    ls.append(li[i + 1] - li[i])
ls = sorted(ls, reverse=True)
print(sum(ls[n-1:]))
### BUGGY CODE ###

import numpy as np
N,K = map(int, input().split())
h = []
sum = []
for i in range(N):
    h.append(int(input()))
h = np.array(h)
h = np.sort(h) # sorted; ascending
for i in range(N-K+1):
    sum = np.append(sum,h[i+K-1]-h[i])
print(int(min(sum)))

### FIXED CODE ###

N,K = map(int, input().split())
h = [int(input()) for i in range(N)]
h.sort()
print(min(h[i+K-1]-h[i] for i in range(N-K+1)))
### BUGGY CODE ###

h,w,k=map(int,input().split())
x1,y1,x2,y2=map(lambda x:int(x)-1,input().split())
c=[input() for _ in range(h)]
"""
ha=[]
for i in range(h):
  for j in range(w):
    if c[i][j]=='@':
      ha.append([i,j])
"""
from collections import deque
seen=[[0]*w for _ in range(h)]
todo=deque([[0,x1,y1]])
seen[x1][x2]=1
while todo:
  t,x,y=todo.popleft()

  if x==x2 and y==y2:
    print(t)
    exit(0)
  if x>0:
    for xi in range(x-1,max(x-k,0)-1,-1):
      if c[xi][y]=='@':break
      if seen[xi][y]==1:continue
      seen[xi][y]=1
      todo.append([t+1,xi,y])
  if x<h-1:
    for xi in range(x+1,min(x+k,h-1)+1):
      if c[xi][y]=='@':break
      if seen[xi][y]==1:continue
      seen[xi][y]=1
      todo.append([t+1,xi,y])
  if y>0:
    for yi in range(y-1,max(y-k,0)-1,-1):
      if c[x][yi]=='@':break
      if seen[x][yi]==1:continue
      seen[x][yi]=1
      todo.append([t+1,x,yi])
  if y<w-1:
    for yi in range(y+1,min(y+k,w-1)+1):
      if c[x][yi]=='@':break
      if seen[x][yi]==1:continue
      seen[x][yi]=1
      todo.append([t+1,x,yi])
print(-1)


### FIXED CODE ###

from collections import deque
h,w,k=map(int,input().split())
x1,y1,x2,y2=map(lambda x:int(x)-1,input().split())
cmap=[input() for _ in range(h)]
inf=float('inf')
seen=[[[(inf,inf)]*4 for _ in range(w)] for _ in range(h)]
D=[(-1,0),(0,1),(1,0),(0,-1)]# 上:0, 右:1, 下:2, 左:3
q=deque()
for d in range(4):
  seen[x1][y1][d]=(1,0)
  q.append((x1, y1, d, 1, 0)) # (x, y, 進行方向[d], 移動回数[c], 進行済マス数[k])
while q:
  x,y,d,c,k_=q.popleft()
  # nx, ny: 次の座標
  # nd: 次の進行方向
  # nc: 次の移動回数
  # nk: 次の進行済マス数
  for nd in range(4):
    if nd==d:
      dx,dy=D[nd]
      nk=1 if k_==k else k_+1
      nc=c+1 if k_==k else c
    else:
      dx,dy=0,0
      nk=0
      nc=c+1
    nx=x+dx;ny=y+dy
    if 0<=nx<h and 0<=ny<w and cmap[nx][ny]!='@' and seen[nx][ny][nd]>(nc,nk):
      seen[nx][ny][nd]=(nc,nk)
      if nc==c: # 同一方向に進むケースは次のループで一番はじめに処理する。
        q.appendleft((nx,ny,nd,nc,nk))
      else:
        q.append((nx,ny,nd,nc,nk))
ans=inf
for d in range(4):
  ans=min(ans,seen[x2][y2][d][0])
ans=-1 if ans==inf else ans
print(ans)
### BUGGY CODE ###

from sys import stdin


def LI(): return list(map(int, stdin.readline().split()))


inf = 1000000007

N, K = LI()
graph = [[] for _ in range(N)]
for i in range(N - 1):
    a, b = LI()
    graph[a - 1].append(b - 1)
    graph[b - 1].append(a - 1)

stack = [0]
ans = 1
done = [False for _ in range(N)]
cnt = 0
parent = -1
while len(stack) > 0:
    now = stack.pop(0)
    done[now] = True
    cnt = 0
    for x in graph[now]:
        if not done[x]:
            cnt += 1
            stack.append(x)
    if now == 0:
        temp = 1
        for i in range(cnt):
            ans = (K - 1 - i) * ans % inf
    else:
        temp = 1
        for i in range(cnt):
            ans = (K - 2 - i) * ans % inf
print(ans * K % inf)

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**7)
INF=10**9+7
def LI(): return list(map(int, sys.stdin.readline().split()))
 
def main():
    n, k = LI()
    graph=[[] for i in range(n)]
    for i in range(n-1):
        a,b=LI()
        graph[a-1].append(b-1)
        graph[b-1].append(a-1)
    ans=1
    check=[False]*n
    stack=[0]
    ans=1
    while len(stack)>0:
        x=stack.pop()
        check[x]=True
        count=0
        for i in graph[x]:
            if not check[i]:
                count+=1
                stack.append(i)
        if x==0:
            temp=1
            for i in range(count):
                temp=temp*(k-1-i)%INF
            ans=ans*temp%INF
        else:
            temp=1
            for i in range(count):
                temp=temp*(k-2-i)%INF
            ans=ans*temp%INF
    print((ans*k)%INF)
 
 
if __name__ == "__main__":
    main()
### BUGGY CODE ###

n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
ab=lambda i,j:a[i] if abs(i-j)%2==0 else b[i]
inf=10**9
dp=[n*[inf]for _ in range(2**n)]
dp[0][0]=0
for i in range(n):dp[2**i][i]=i
for bit in range(1,2**n):
  m=[0]*n
  ii=0
  for i in range(n):
    if bit&2**i:
      m[i]=ii
      ii+=1
  bit_count=ii
  for i in range(n):
    if bit&2**i==0:
      m[i]=ii
      ii+=1
  for i in range(n):
    if bit&2**i:continue
    ci=ab(i,bit_count)
    for j in range(n):
      if bit&2**j==0:continue
      cj=ab(j,bit_count-1)
      if cj>ci:continue
      dp[bit|2**i][i]=min(dp[bit|2**i][i],dp[bit][j]+m[i]-bit_count)
ans=inf
for i in range(n):ans=min(ans,dp[-1][i])
if ans==inf:ans=-1
print(ans)

### FIXED CODE ###

class BinaryIndexedTree():
  def __init__(self,n):self.bit=[0]*n
  def add(self,i,x):
    i+=1
    while i<=len(self.bit):
      self.bit[i-1]+=x
      i+=i&-i
  def sum_1(self,i):
    a=0
    i+=1
    while i:
      a+=self.bit[i-1]
      i-=i&-i
    return a
  def sum(self,i,j):
    a=self.sum_1(j-1)
    if i!=0:a-=self.sum_1(i-1)
    return a
def tentousu(a):
  bit=BinaryIndexedTree(n)
  b=[0]*n
  for i in range(n):
    b[a[i]]=i
  ans=0
  for i in range(n):
    j=b[i]+bit.sum(b[i]+1,n)
    ans+=j-i
    bit.add(b[i],1)
  return ans
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
for i in range(1,n,2):a[i],b[i]=b[i],a[i]
ans=inf=float('inf')
for i in range(2**n):
  s=bin(i)[2:].zfill(n)
  if s.count("0")!=n//2:continue
  ac=[]
  bc=[]
  for j in range(n):
    if s[j]=="1":ac.append((a[j],j))
    else:bc.append((b[j],j))
  ac.sort()
  bc.sort()
  x=[]
  for j in range(n):
    if j%2:x.append(bc[j//2])
    else:x.append(ac[j//2])
  f=False
  for j in range(1,n):
    if x[j-1][0]>x[j][0]:f=True
  if f:continue
  m=[]
  for j in range(n):m.append(x[j][1])
  ans=min(ans,tentousu(m))
if ans==inf:ans=-1
print(ans)
### BUGGY CODE ###

import math

K = int(input())
ans = 0
for i in range(K):
    for j in range(K):
        for k in range(K):
            gcd_0 = math.gcd(i+1,j+1)
            ans += math.gcd(gcd_0,k+1)

print(ans)

### FIXED CODE ###

import math

K = int(input())
ans = 0
for i in range(K):
    for j in range(K):
        for k in range(K):
            gcd_0 = math.gcd(i+1,j+1)
            ans += math.gcd(gcd_0,k+1)

print(ans)
### BUGGY CODE ###

#５回目、2020-0612
#幅優先探索
def bfs(u):
    dq =deque()
    passed =set([u])
    for i in range(1,N+1): #全頂点を始点としてBSFで距離
        dq.append(i)
        dist[(i,i)] =0   
        while dq:
            now =dq.popleft()
            for next in connection[now]:
                if next not in passed and i !=next:
                    dist[(i,next)] =dist[(i,now)] +1
                    ans[dist[(i,next)]].append((i,next))
                    dq.append(next)
                    passed.add(next)
        passed.clear()

    return dist

#初期入力
from collections import deque 
N, x, y = map(int, input().split())

# 構造
connection ={i:set() for i in range(1,N+1)}
for i in range(1,N):
    connection[i  ].add(i+1)
    connection[i+1].add(i)
connection[x].add(y)
connection[y].add(x)

#始点からの距離をBFS
ans ={(i):[] for i in range(0,N) }
dist ={(i,j):None for i in range(1,N) for j in range(i,N+1)}
bfs(1)

#答え出力
for i in range(1,N):        
    print(len(ans[i])//2)

### FIXED CODE ###

N, X, Y = map(int, input().split())
D = [None] + [0] * (N - 1) #最低距離が1からNまでの個数を表示するリストを作る(YZT さんのコメント)

#各最低距離の個数カウント
for i in range(1, N):                           # i 出発
    for j in range(i + 1, N + 1):               # j 到着
        d = min(abs(j - i),                     # 近道をしない
                abs(X - i) + 1 + abs(j - Y),    # 「+1」は近道の距離、X < Y　
                abs(Y - i) + 1 + abs(j - X))    # 「+1」は近道の距離、Y < X　
        D[d] += 1                               # 距離ｄごとにカウント
        # print(abs(j-i),abs(X-i)+1 , abs(j-Y) , abs(Y - i) + 1,abs(j - X)," ",d,D," ",i,j)
    
for d in D[1:]: #最低距離は１だから距離０は使わないが、添え字＝距離とすることでわかりやすい
    print(d)
### BUGGY CODE ###

from itertools import accumulate

n = int(input())
s = input()
acc_cnt_a = [0] * (n + 1)
acc_cnt_b = [0] * (n + 1)
acc_cnt_ab = [0] * (n + 1)
c_loc = []
cnt_a = 0
for i, c in enumerate(s):
    if c == 'D':
        acc_cnt_a[i + 1] += 1
        cnt_a += 1
    elif c == 'M':
        acc_cnt_b[i + 1] += 1
        acc_cnt_ab[i + 1] += cnt_a
    elif c == 'C':
        c_loc.append(i + 1)
acc_cnt_a = list(accumulate(acc_cnt_a))
acc_cnt_b = list(accumulate(acc_cnt_b))
acc_cnt_ab = list(accumulate(acc_cnt_ab))

q = int(input())
buf = []
for k in map(int, input().split()):
    ans = 0
    for r in c_loc:
        l = max(0, r - k)
        rejected_a = acc_cnt_a[l]
        cnt_internal_b = acc_cnt_b[r] - acc_cnt_b[l]
        cnt_internal_ab = acc_cnt_ab[r] - acc_cnt_ab[l]
        ans += cnt_internal_ab - rejected_a * cnt_internal_b
    buf.append(ans)
print('\n'.join(map(str, buf)))


### FIXED CODE ###

from itertools import accumulate

n = int(input())
s = input()
acc_cnt_a = [0] * (n + 1)
acc_cnt_b = [0] * (n + 1)
acc_cnt_ab = [0] * (n + 1)
c_loc = []
cnt_a = 0
for i, c in enumerate(s):
    if c == 'D':
        acc_cnt_a[i] += 1
        cnt_a += 1
    elif c == 'M':
        acc_cnt_b[i] += 1
        acc_cnt_ab[i] += cnt_a
    elif c == 'C':
        c_loc.append(i + 1)
acc_cnt_a = [0] + list(accumulate(acc_cnt_a))
acc_cnt_b = [0] + list(accumulate(acc_cnt_b))
acc_cnt_ab = [0] + list(accumulate(acc_cnt_ab))

q = int(input())
buf = []
for k in map(int, input().split()):
    ans = 0
    for r in c_loc:
        l = r - k
        if l > 0:
            rejected_a = acc_cnt_a[l]
            cnt_internal_b = acc_cnt_b[r] - acc_cnt_b[l]
            cnt_internal_ab = acc_cnt_ab[r] - acc_cnt_ab[l]
            ans += cnt_internal_ab - rejected_a * cnt_internal_b
        else:
            ans += acc_cnt_ab[r]
    buf.append(ans)
print('\n'.join(map(str, buf)))
### BUGGY CODE ###

import math
a,b = map(int, input().split())
i = 1
while True:
  if math.floor(i*0.08) == a and math.floor(i*0.1) == b:
    print(i)
    break
  if math.floor(i*0.08) > a or math.floor(i*0.1) > b:
    print(-1)
    break

### FIXED CODE ###

import math
a,b = map(int, input().split())
i = 1
while True:
  if math.floor(i*0.08) == a and math.floor(i*0.1) == b:
    print(i)
    break
  if math.floor(i*0.08) > a or math.floor(i*0.1) > b:
    print(-1)
    break
  i += 1
### BUGGY CODE ###

x=int(input())
for i in range(-x*999,x):i,j=i%x,i//x;i**5-x-j**5or exit(print(i,j))

### FIXED CODE ###

x,r=int(input()),range(-99,120);[i**5-x-j**5or exit(print(i,j))for i in r for j in r]
### BUGGY CODE ###

n, m, qn = map(int, input().split())
t = [list(map(int, input().split())) for _ in range(m)]
qs = [list(map(int, input().split())) for _ in range(qn)]

r = dict()
for i in range(1, n + 1):
    r[i] = set()
    
l = dict()
for i in range(1, n + 1):
    l[i] = set()

for x in range(len(t)):
    L, R = t[x]
    for i in range(R, n + 1):
        l[i].add(x)
    for i in range(1, L + 1):
        r[i].add(x)

for p, q in qs:
    print(len(r[p] & l[q]))

### FIXED CODE ###

def arr(row, column, value): return [[value for _ in range(column)] for _ in range(row)]

n, m, q = map(int, input().split())

sum_range = arr(n + 1, n + 1, 0)
#sum_range[0][0] - sum_range[n][n]まで
#初期値0
#行列値は1からnを取るが、累積和を加算する過程で行列を1引いたものを参照するので、[0][0]がエラーにならないと便利？

for _ in range(m):
    L, R = map(int, input().split())
    sum_range[L][R] += 1#(L, R)間を運行す列車の数を代入
    
for L in range(1, n + 1):
    for R in range(1, n + 1):
        #累積和を取る（53:44あたり）
        #https://www.youtube.com/watch?v=OdJH-io-sVw
        sum_range[L][R] += sum_range[L - 1][R]
        sum_range[L][R] += sum_range[L][R - 1]
        sum_range[L][R] -= sum_range[L - 1][R - 1]

#print(sum_range)
for _ in range(q):
    p, q = map(int, input().split())
    ans = sum_range[q][q] - sum_range[p - 1][q] - sum_range[q][p - 1] + sum_range[p - 1][p - 1]
    print(ans)
### BUGGY CODE ###

n,a,b=map(int, input().split())
mode = 0
cnt = 0
tmp = 0
for i in range(1,n+1):
    if a == 0: break
    if a+b == n: 
        cnt += a
        break
    if mode == 0 and tmp <= a:
        cnt += 1
        tmp += 1
    elif tmp == a and mode == 0:
        tmp = 0
        mode = 1

    if mode == 1 and tmp <= b:
        tmp += 1
    elif tmp == b and mode == 1:
        tmp = 0
        mode = 0
print(cnt)
    
    


### FIXED CODE ###

import math
n,a,b=map(int, input().split())
cnt = 0
mode = 0
if a == 0:
    cnt = 0
elif a+b == n:
    cnt = a
else:
    roop = math.floor(n / (a+b))
    anc_a = a*roop
    n_b = n-(roop*(a+b))
    while True:
        if n_b >= a and mode == 0:
            n_b = n_b - a
            cnt += a
            mode = 1
        elif mode == 1:
            n_b = n_b-b
            mode = 0
        elif n_b < a and mode == 0:
            cnt += n_b
            n_b = n_b -a
        if n_b <= 0:
            break
    cnt += anc_a 
print(cnt)
### BUGGY CODE ###

import collections
N = int(input()) 
S = [0]*N
for i in range(N):
    S[i] = input()
c = collections.Counter(S)
values,counts = zip(*c.most_common())
X = c.most_common()[0][1]
list = []
for i in range(0,len(c.most_common())):
    if c.most_common()[i][1] == X:
        list.append(c.most_common()[i][0])
list.sort()
for i in range(len(list)):
    print(list[i])

### FIXED CODE ###

import collections
N = int(input()) 
S = [0]*N
m = 0
for i in range(N):
    S[i] = input()
c = collections.Counter(S)
values,counts = zip(*c.most_common())
X = c.most_common()[0][1]
list = []
for i in range(0,len(c.most_common())):
    if counts[i] == X:
        list.append(values[i])
        m+=1
    else:
        break
list.sort()
for i in range(0,m):
    print(list[i])