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

import copy
n=int(input())
box=list(map(int,input().split()))
for i in range(n):
    box_ano=copy.copy(box)
    del box_ano[i]
    count=abs(box_ano[0])+abs(box_ano[-1])
    for j in range(len(box_ano)):
        try:
            count +=abs(box_ano[j]-box_ano[j+1])
        except:continue
    print(count)

### FIXED CODE ###

import copy
n=int(input())
box=list(map(int,input().split()))
box.insert(0,0)
box.append(0)
count=0
for i in range(n+1):count +=abs(box[i]-box[i+1])
for j in range(1,n+1):
    print(count-(abs(box[j-1]-box[j])+abs(box[j]-box[j+1]))+abs(box[j-1]-box[j+1]))
### BUGGY CODE ###

import sys
input = sys.stdin.readline
h,w=map(int,input().split())
a=[]
for i in range(h):
    a.append(list(map(int,input().split())))
b=[]
for i in range(h):
    b.append(list(map(int,input().split())))
dp=[[set([]) for i in range(w)] for j in range(h)]
dp[0][0].add(a[0][0]-b[0][0])
dp[0][0].add(b[0][0]-a[0][0])
for i in range(h):
    for j in range(w):
        if i==j==0:
            continue
        if i==0:
            for k in dp[i][j-1]:
                if k<=7000:
                    dp[i][j].add(abs(k+a[i][j]-b[i][j]))
                    dp[i][j].add(abs(k+b[i][j]-a[i][j]))
        elif j==0:
            for k in dp[i-1][j]:
                if k<=7000:
                    dp[i][j].add(abs(k+a[i][j]-b[i][j]))
                    dp[i][j].add(abs(k+b[i][j]-a[i][j]))
        else:
            for k in (dp[i][j-1]|dp[i-1][j]):
                if k<=7000:
                    dp[i][j].add(abs(k+a[i][j]-b[i][j]))
                    dp[i][j].add(abs(k+b[i][j]-a[i][j]))             
#dp[h-1][w-1]
ans=10**10
for i in dp[h-1][w-1]:
    ans=min(ans,abs(i))
print(ans)


### FIXED CODE ###

import sys
input = sys.stdin.readline
H,W=map(int,input().split())
a = [[] for _ in range(H)]
for i in range(H):
    a[i] = list(map(int, input().split()))
b = [[] for _ in range(H)]
for i in range(H):
    b[i] = list(map(int, input().split()))

for i in range(H):
    for j in range(W):
        a[i][j] =abs(a[i][j]-b[i][j])

dp = [[set() for _ in range(W)] for _ in range(H)]
dp[0][0].add(a[0][0])
for i in range(1,H):
    t = a[i][0]
    tmp = set()
    for k in dp[i-1][0]:
        tmp.add(k+t)
        tmp.add(abs(k-t))
    dp[i][0] = tmp
for j in range(1,W):
    t = a[0][j]
    tmp = set()
    for k in dp[0][j-1]:
        tmp.add(k+t)
        tmp.add(abs(k-t))
    dp[0][j] = tmp
for i in range(1,H):
    for j in range(1,W):
        t = a[i][j]
        tmp = set()
        for k in (dp[i-1][j] | dp[i][j-1]):
            tmp.add(k+t)
            tmp.add(abs(k-t))
        dp[i][j] = tmp
        dp[i-1][j-1] = set()

ls = list(dp[H-1][W-1])
print(min(ls))
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10000000)
def input():
    return sys.stdin.readline()[:-1]
from bisect import *
from collections import *
from heapq import *
import itertools
INF = 10**10
MOD = 10**9+7

N, K = map(int, input().split())
P = [int(x) for x in input().split()]
s = set()
for i in range(N-K+1):
    s.add(tuple(P[:i]+sorted(P[i:i+K])+P[i+K:]))
print(len(s))


### FIXED CODE ###

import sys
sys.setrecursionlimit(10000000)
def input():
    return sys.stdin.readline()[:-1]
from bisect import *
from collections import *
from heapq import *
import itertools
INF = 10**10
MOD = 10**9+7

class UnionFind:

    def __init__(self, n):
        self.n = n
        self.par = [i for i in range(n)]
        self.height = [0] * n
        self.size = [1] * n

    def find(self, x):
        if self.par[x] == x:
            return x
        self.par[x] = self.find(self.par[x])
        return self.par[x]

    def getsize(self, x):
        return self.size[self.find(x)]

    def unite(self, x, y):
        x, y = self.find(x), self.find(y)
        if x == y:
            return
        if self.height[x] < self.height[y]:
            self.par[x] = y
            self.size[y] += self.size[x]
        else:
            self.par[y] = self.par[x]
            self.size[x] += self.size[y]
            if self.height[x] == self.height[x]:
                self.height[x] += 1

    def same(self, x, y):
        return self.find(x) == self.find(y)

def slide_min(a, k):
    n = len(a)
    b = [None] * (n-k+1)
    deq = deque()
    for i in range(n):
        while len(deq) > 0 and a[i] <= a[deq[-1]]:
            deq.pop()
        deq.append(i)
        if i-k+1 >= 0:
            b[i-k+1] = a[deq[0]]
            if deq[0] == i-k+1:
                deq.popleft()
    return b

def slide_max(a, k):
    n = len(a)
    b = [None] * (n-k+1)
    deq = deque()
    for i in range(n):
        while len(deq) > 0 and a[i] >= a[deq[-1]]:
            deq.pop()
        deq.append(i)
        if i-k+1 >= 0:
            b[i-k+1] = a[deq[0]]
            if deq[0] == i-k+1:
                deq.popleft()
    return b

N, K = map(int, input().split())
P = [int(x) for x in input().split()]
uf1 = UnionFind(N)
for i in range(N-1):
    if P[i] < P[i+1]:
        uf1.unite(i, i+1)
vs = []
for i in range(N-K+1):
    if uf1.same(i, i+K-1):
        vs.append(i)
uf2 = UnionFind(N)
if len(vs) > 1:
    for v1, v2 in zip(vs, vs[1:]):
        uf2.unite(v1, v2)
m, M = slide_min(P, K), slide_max(P, K)
for i in range(N-K):
    if P[i] == m[i] and P[i+K] == M[i+1]:
        uf2.unite(i, i+1)
s = set()
for i in range(N-K+1):
    s.add(uf2.find(i))
print(len(s))
### BUGGY CODE ###

def heikin(index, num, cnt):
    global A, ans, x, N
    if index < N:
        heikin(index+1, num + x[index], cnt+1)
        heikin(index+1, num, cnt)
    elif index == N:
        if num == A * cnt:
            ans += 1


if __name__ == "__main__":
    N, A = map(int, input().split())
    x = [i for i in map(int, input().split())]
    ans = 0
    heikin(0, 0, 0)
    print(ans-1)
    


### FIXED CODE ###


if __name__ == "__main__":
    N, A = map(int, input().split())
    x = [i-A for i in map(int, input().split())]
    X = max(x + [A])
    dp = [[0] * (2*N*X + 1) for _ in range(N+1)]
    for row in range(N+1):
        for column in range(2*N*X):
            if row == 0 and column == N*X:
                dp[row][column] = 1
            elif row >=1 and (column - x[row-1] < 0 or column - x[row-1] > 2*N*X):
                    dp[row][column] = dp[row-1][column]
            elif row >=1 and 0 <= column - x[row-1] <= 2*N*X:
                dp[row][column] = dp[row-1][column] + dp[row-1][column-x[row-1]]
            else:
                dp[row][column] = 0
    print(dp[N][N*X]-1)
### BUGGY CODE ###

N = int(input())
A = tuple(input().split())
B = []

for x in range(1,N+1):
    m = A.index(str(x)) + 1
    B.append(str(m))
print(" ".join(B))

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
B = [0] * (N +1)

for i in range(N):
    B[A[i]] = i+1

print(*B[1:])
### BUGGY CODE ###

from sys import stdin

def main():
    s = [int(x) if x != "?" else "?" for x in stdin.readline().rstrip()]

    dp = [1] + [0]*12
    mod = 10 ** 9 + 7

    for i in (range(0,len(s))):
        next_dp = [0]*13
        if s[i] == "?":
            for k in range(0, 10):
                for j in range(0, 13):
                    next_dp[(j*10+k)%13] += dp[j]
                    next_dp[(j*10+k)%13] %= mod

        else:
            k = s[i]
            for j in range(0, 13):
                    next_dp[(j*10+k)%13] += dp[j]
                    next_dp[(j*10+k)%13] %= mod

    #    mul = mul * 10 % 13
        dp = next_dp

    print(dp[5])

if __name__ == '__main__':
    main()

### FIXED CODE ###

from sys import stdin

def main():
    s = [int(x) if x != "?" else "?" for x in stdin.readline().rstrip()]

    dp = [1] + [0]*12
    mod = 10 ** 9 + 7

    for i in (range(0,len(s))):
        next_dp = [0]*13
        if s[i] == "?":
            for k in range(0, 10):
                for j in range(0, 13):
                    next_dp[(j*10+k)%13] += dp[j]
                    next_dp[(j*10+k)%13] %= mod

        else:
            k = s[i]
            for j in range(0, 13):
                    next_dp[(j*10+k)%13] += dp[j]
                    next_dp[(j*10+k)%13] %= mod

    #    mul = mul * 10 % 13
        dp = next_dp

    print(dp[5])

if __name__ == '__main__':
    main()
### BUGGY CODE ###

K,S=map(int,input().split())

count=0

for X in range(K+1):
    for Y in range(K+1):
        for Z in range(K+1):
            if X+Y+Z==S:
                count+=1

print(count)

### FIXED CODE ###

K,S=map(int,input().split())

count=0

for X in range(K+1):
        for Y in range(K+1):
            Z=S-X-Y
            if 0<=Z<=K:
                count+=1

print(count)
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10**6) #for deep recursion

N, Q = list(map(int, input().split()))
edges = [list(map(int, input().split())) for _ in range(N-1)]
counts = [0] * N
operations = [list(map(int, input().split())) for _ in range(Q)]

counts = [0] * N
for op in operations:
    p, x = op
    counts[p-1] += x
    
all_connected_vertices = {i: [] for i in range(1, 1+N)}
for a, b in edges:
    all_connected_vertices[a].append(b)
    all_connected_vertices[b].append(a)
    
def get_connected_vertices(v):
    return all_connected_vertices[v]
    
visited_vertices = [] 
def dfs(point, pre):
    visited_vertices.append(point)
    connected_vertices = get_connected_vertices(point)
    children = [v for v in connected_vertices if v != pre]
    for c in children:
        counts[c-1] += counts[point-1]
        dfs(c, point)
    
dfs(1, -1)
res = ""
for c in counts:
    res += " " + str(c)
    
print(res[1:])

### FIXED CODE ###

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6) #for deep recursion

N, Q = list(map(int, input().split()))
edges = [list(map(int, input().split())) for _ in range(N-1)]
operations = [list(map(int, input().split())) for _ in range(Q)]

counts = [0] * N
for op in operations:
    p, x = op
    counts[p-1] += x
    
all_connected_vertices = {i: [] for i in range(1, 1+N)}
for a, b in edges:
    all_connected_vertices[a].append(b)
    all_connected_vertices[b].append(a)
    
def dfs(point, pre):
    connected_vertices = all_connected_vertices[point]
    for c in connected_vertices:
        if c == pre:
            continue
        counts[c-1] += counts[point-1]
        dfs(c, point)
    
dfs(1, -1)
    
print(*counts)
### BUGGY CODE ###

n=int(input())
l_list = list(map(int,input().split()))
import numpy as np

l_np = np.array(l_list)

import itertools
comb_list = list(itertools.combinations(np.sort(l_np),3))
count = 0
for i in range(len(comb_list)):
    if comb_list[i][0] + comb_list[i][1] + comb_list[i][2] > comb_list[i][2] * 2:
        count += 1
print(count)

### FIXED CODE ###

N=int(input())
L_list = list(map(int,input().split()))

import bisect

L_list = sorted(L_list)
 
ans = 0
for a_index in range(0, N):
    for b_index in range(a_index+1, N):
        a = L_list[a_index]
        b = L_list[b_index]
        c_right_index = bisect.bisect_left(L_list, a+b)
        if c_right_index > b_index:
            ans += c_right_index - b_index - 1
        else:
            pass

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

x, y, z, k = map(int, input().split())
a = sorted(list(map(int, input().split())), reverse=True)
b = sorted(list(map(int, input().split())), reverse=True)
c = sorted(list(map(int, input().split())), reverse=True)

d = []
for i in range(len(a)):
    for j in range(len(b)):
        d.append(a[i]+b[j])

tmp = sorted(d, reverse=True)
if len(tmp) < k:
    use_tmp = tmp
else:
    use_tmp = tmp[0:k]
    
ans = []
for i in range(len(use_tmp)):
    for j in range(len(c)):
        ans.append(use_tmp[i]+c[j])
final_ans = sorted(ans, reverse=True)

for i in range(k):
    print(final_ans[i])

### FIXED CODE ###

x, y, z, k = map(int, input().split())
a = sorted(list(map(int, input().split())), reverse=True)
b = sorted(list(map(int, input().split())), reverse=True)
c = sorted(list(map(int, input().split())), reverse=True)

sumAB = sorted([ai + bi for ai in a for bi in b],reverse=True)[:k]
final_ans = sorted([ci + abi for ci in c for abi in sumAB],reverse = True)[:k]

for i in range(k):
    print(final_ans[i])
### BUGGY CODE ###

from collections import Counter
s = list(map(int, list(input())))[::-1]
n = len(s)
c = Counter([])
c[0]+=1
t = 0
ten = 1
for i in range(n):
    t = (t+s[i]*ten) % 2019
    ten*=10
    c[t]+=1
ans = 0
for v in c.values():
    ans+=v*(v-1)//2
print(ans)


### FIXED CODE ###

s = input()

n = len(s)
c = [0]*2019
c[0]+=1
t = 0
digit = 1
for ss in s[::-1]:
    t = (t+int(ss)*digit) % 2019
    digit = (digit * 10) % 2019
    c[t]+=1
ans = 0
ans = sum(cc*(cc-1)//2 for cc in c)
print(ans)
### BUGGY CODE ###

import sys
input = sys.stdin.readline

INF = float('inf')


def main():
    A, B, K = map(int, input().split())

    for _ in range(K):
        if A > 0:
            A -= 1
        elif B > 0:
            B -= 1
    print(A, B)


if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys
input = sys.stdin.readline

INF = float('inf')


def main():
    A, B, K = map(int, input().split())

    if A <= K:
        print(0, max(0, B - K + A))
    else:
        print(A - K, B)


if __name__ == '__main__':
    main()
### BUGGY CODE ###

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

ans = []
t = 0
for i in a:
  if t == 0: ans.append(i)
  else: ans.insert(0,i)
  t = 1 - t

if t == 0: print(*ans)
else: print(*ans[::-1])

### FIXED CODE ###

from collections import deque
n = int(input())
a = list(map(int, input().split()))

d = deque()
t = 0
for i in a:
  if t == 0: d.append(i)
  elif t == 1: d.appendleft(i)
  t = 1 - t
  
if t == 0: print(*d)
else: print(*list(reversed(d)))
### BUGGY CODE ###

import copy

N = int(input())
X = list(map(int, input().split()))
S_X = copy.copy(X)

for i in range(N // 2 + 1):
    for j in range(N - 1 - i):
        if(S_X[j] > S_X[j + 1]):
            tmp = S_X[j + 1]
            S_X[j + 1] = S_X[j]
            S_X[j] = tmp
# s_X = sorted(X)
miX = S_X[N // 2 - 1]
mi1X = S_X[N // 2]
# print(S_X, X)
# print(miX, mi1X)

# print(miX, mi1X)
# print(X)
for a in X:
    if(a <= miX):
        print(mi1X)
    else:
        print(miX)

### FIXED CODE ###

# import copy

N = int(input())
X = list(map(int, input().split()))
# S_X = copy.copy(X)
S_X = sorted(X)
miX = S_X[N // 2 - 1]
mi1X = S_X[N // 2]
# print(S_X, X)
# print(miX, mi1X)

# print(miX, mi1X)
# print(X)
for a in X:
    if(a <= miX):
        print(mi1X)
    else:
        print(miX)
### BUGGY CODE ###

N, M = [int(x) for x in input().split()]
INF = 10**9
dist = [INF] * N
ans = [-1] * N
to = [set() for _ in range(N)]
for _ in range(M):
    A, B = [int(x)-1 for x in input().split()]
    to[A].add(B)
    to[B].add(A)
bfs = [(0, 0, -1)]
while len(bfs):
    cur, d, p = bfs.pop()
    if d < dist[cur]:
        dist[cur] = d
        ans[cur] = p
    for v in to[cur]:
        if d+1 < dist[v]:
            bfs.append((v, d+1, cur))
    d += 1
print('Yes')
for a in ans[1:]:
    print(a+1)


### FIXED CODE ###

from collections import deque
N, M = [int(x) for x in input().split()]
INF = 10**6
dist = [INF] * N
ans = [-1] * N
to = [set() for _ in range(N)]
for _ in range(M):
    A, B = [int(x)-1 for x in input().split()]
    to[A].add(B)
    to[B].add(A)
bfs = deque([(0, 0, -1)])
while len(bfs):
    cur, d, p = bfs.popleft()
    if d >= dist[cur]: continue
    dist[cur] = d
    ans[cur] = p
    for v in to[cur]:
        if d+1 < dist[v]:
            bfs.append((v, d+1, cur))
print('Yes')
for a in ans[1:]:
    print(a+1)
### BUGGY CODE ###

N = int(input())
A,B = [],[]
for _ in range(N-1):
    array = list(map(int,input().split()))
    A.append(array[0])
    B.append(array[1])
from collections import defaultdict as ddict
import numpy as np
children = ddict(list)
for a,b in zip(A,B):
    children[a].append(b)
ans = ddict(int)
for child in sorted(children.keys()):
    used = np.zeros((100000),dtype="bool")
    used[ans[child]-1] = True
    for j in sorted(children[child]):
        temp = used.argmin()+1
        ans[j] = temp
        used[temp-1] = True
ans2 = [ans[b] for b in B]
print(max(ans2))
for a in ans2:
    print(a)

### FIXED CODE ###

N = int(input())
AB = [[]]*(N-1)
for i in range(N-1):
    AB[i] = list(map(int,input().split()))
from collections import defaultdict as ddict
from collections import deque
tree = ddict(list)
B = [0]*(N-1)
for i,ab in enumerate(AB):
    tree[ab[0]].append(ab[1])
    B[i] = ab[1]
# 各エッジの色を格納する変数の初期化
# C[0]は使わない
C = [0]*N
# 幅優先探索用のcue
Q = deque([1])
while Q:
    q = Q.popleft()
    c = 0
    for w in tree[q]:
        # 色をインクリメントした際に親の色とかぶったら更に1を加算する
        # 他は単純なインクリメント
        c += 1 + int(C[q-1] == c+1)
        # エッジの色を格納
        C[w-1] = c
        # 子供をcueに追加
        Q.append(w)
print(max(C))
for b in B:
    print(C[b-1])
### BUGGY CODE ###

N=int(input())
for i in range(1,N+1):
  cnt=0
  for x in range(1,i-2):
    for y in range(1,i-x+1):
      for z in range(1,i-x-y+1):
        if i==x**2+y**2+z**2+x*y+y*z+z*x:
          cnt+=1
  print(cnt)
      


### FIXED CODE ###

import sys
input = sys.stdin.readline
import math

N=int(input())
ans=[0]*(N+1)
sn=int(math.sqrt(N)+1)
for x in range(1,sn+1):
  for y in range(1,sn+1):
    for z in range(1,sn+1):
      i=x**2+y**2+z**2+x*y+y*z+z*x
      if 1<=i<=N:
        ans[i]+=1
for h in range(1,N+1):          
  print(ans[h])
### BUGGY CODE ###

n = int(input())
a = list(map(int, input().split()))
li = [0] * (n+1)
for i in range(len(a)):
	if li[a[i]] == 0:
		li[a[i]] = a.count(a[i])
#print(li)
li = li[1:]
print(*li, sep = "\n")


### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
li = [0] * (n+1)
for i in range(len(a)):
	li[a[i]] += 1
#print(li)
li = li[1:]
print(*li, sep = "\n")
### BUGGY CODE ###

a, b, c, k = map(int, input().split())

flag = True
for i in range(10**18):
    if k == 0:
        break
    if a == b and b == c:
        break
    A = a
    B = b
    C = c
    a = B + C
    b = A + C
    c = A + B
    if i == k - 1:
        break
    if abs(a - b) > 10**9:
        flag = False
        break
if flag:
    print(a - b)
else:
    print('Unfair')


### FIXED CODE ###

a, b, c, k = map(int, input().split())
x = a - b
if x > 10**18:
    print('Unfair')
elif k % 2 == 0:
    print(x)
else:
    print(-x)
### BUGGY CODE ###

from functools import reduce
import copy

def gcd( x, y ):
    while y != 0:
        x, y = y, x%y
    return x

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

result = 0
for i in range(n):
    tmp = copy.copy(a)
    tmp.pop(i)
    result = max(reduce(gcd, tmp), result)

print(result)


### FIXED CODE ###

from functools import reduce
import copy

def gcd( x, y ):
    while y != 0:
        x, y = y, x%y
    return x

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

result = 0
l = [0]*n
r = [0]*n
for i in range(n-1):
    l[i+1] = gcd(l[i],a[i])

for i in reversed(range(1, n)):
    r[i-1] = gcd(r[i], a[i])

ans = 0
for i in range(n):
    lr = gcd(l[i], r[i])
    ans = max(ans, lr)

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

import sys
input = sys.stdin.readline
# sys.setrecursionlimit(100000)


class Solver(object):
    def __init__(self):
        pass

    def solve(self, N, A_l):
        ans = 0
        for i in range(N-1):
            for j in range(i+1, N):
                ans += A_l[i] ^ A_l[j]
        return ans % (10**9 + 7)


def main():
    N = int(input())
    A_l = [int(i) for i in input().split()]
    solver = Solver()
    print(solver.solve(N, A_l))


if __name__ == "__main__":
    main()


### FIXED CODE ###

import sys
input = sys.stdin.readline
# sys.setrecursionlimit(100000)


def solve(n, arr):
    sum = 0
    bitcount = [0]*100
    for num in arr:
        b = reversed(bin(num)[2:])
        for i, s in enumerate(b):
            if i != "0":
                bitcount[i] += int(s)
    for i, b in enumerate(bitcount):
        sum += b * (n-b) * 2**i
    return sum % (10**9 + 7)


def main():
    N = int(input())
    A_l = [int(i) for i in input().split()]
    print(solve(N, A_l))


if __name__ == "__main__":
    main()
### BUGGY CODE ###

N = int(input())
S = input()
ls = list(S)
count = 0
for k in range(2,N):
  for j in range(1,k):
    for i in range(0,j):
      if ls[i] != ls[j] and ls[j] != ls[k] and ls[k] != ls[i] and 2 * j  != k + i:
        count += 1
print(count)

### FIXED CODE ###

import itertools
N = int(input())
S = input()
ls = list(S)

nr = len([r for r in S if r == 'R'])
nb = len([b for b in S if b == 'B'])
ng = len([g for g in S if g == 'G'])

ALL = nr * nb * ng
count = 0

RGBs = list(itertools.permutations(['R', 'G', 'B'], 3))

for i in range(N):
  for j in range(N-i*2):
    if (S[j], S[j+i], S[j+i*2]) in RGBs:
      count += 1
      
print(ALL - count)
### BUGGY CODE ###

mod = 10**9+7

def combi(m,n):
    child = 1
    mom = 1
    while n != 0:
        child *= m
        child %= mod
        mom *= n
        mom %= mod
        m -= 1
        n -= 1
    return (child*modpow(mom,mod-2))%mod

def modpow(m,n):
    if n == 0:
        return 1
    a = modpow(m,n//2)
    b = m if n % 2 else 1
    b *= a
    b %= mod
    b *= a
    b %= mod
    return b

X,Y = map(int,input().split())

A = (-1) * X +   2  * Y
B =   2  * X + (-1) * Y

if A % 3 or B % 3:
    print(0)
    exit()

A //= 3
B //= 3

print(combi(A+B,min(A,B)))

### FIXED CODE ###

mod = 10**9+7

FRAC_RANGE = 2000000
frac = [1] * FRAC_RANGE

for i in range(2,FRAC_RANGE):
    frac[i] = frac[i-1] * i % mod

def combi(n,k):
    a = frac[n]
    b = modpow(frac[k],mod-2)
    c = modpow(frac[n-k],mod-2)
    return a*b*c%mod

def bi(x):
    o = []
    while x != 0:
        o.append(x%2)
        x //= 2
    return o

def modpow(m,n):
    o = bi(n)
    p = [m]
    leo = len(o)
    while leo > len(p):
        a = p[-1]
        p.append(a*a%mod)
    b = 1
    for i in range(leo):
        if o[i] == 1:
            b *= p[i]
            b %= mod
    return b

X,Y = map(int,input().split())

A = (-1) * X +   2  * Y
B =   2  * X + (-1) * Y

if A % 3 or B % 3 or A < 0 or B < 0:
    print(0)
    exit()

A //= 3
B //= 3

print(combi(A+B,min(A,B)))
### BUGGY CODE ###

import math
import string


def readints():
    return list(map(int, input().split()))


def nCr(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))


def has_duplicates2(seq):  # リストに重複した要素があるか判定（要素にリストがある場合）
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor


# s = input()
# n = len(s)
# m = int(s)


# def check(l):
#     x = int("".join(list(map(str, l))))
#     return m >= x and (3 in l) and (5 in l) and (7 in l)


# def solve(l):
#     if len(l) == n:
#         if check(l):
#             # print(int("".join(list(map(str, l)))))
#             return 1
#         else:
#             return 0
#     a = solve(l+[3])
#     b = solve(l+[5])
#     c = solve(l+[7])
#     d = 0
#     if len(l) == 0 or l[-1] == 0:
#         d = solve(l+[0])
#     return a+b+c+d


# print(solve([]))

#n = readints()[0]
#
#ans = 0
#
# for i in range(n+1):
#    s = list(str(i))
#    a = s.count("3")
#    b = s.count("5")
#    c = s.count("7")
#    if a != 0 and b != 0 and c != 0 and a+b+c == len(s):
#        ans += 1
# print(ans)

n, a, b = map(int, input().split())
x = []
while(len(x) < n):
    for i in range(a):
        x.append('b')
    for i in range(b):
        x.append('r')
# print(x[:n])
# print(x)
xx = x[:n]
print(xx.count('b'))


### FIXED CODE ###

import math
import string


def readints():
    return list(map(int, input().split()))


def nCr(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor


n, a, b = map(int, input().split())
ans = n//(a+b)*a
x = n % (a+b)
ans += min(x, a)
print(ans)