Harryxun/stf_run huggingface dataset:
# Aizu Problem 0076: Treasure Hunt II
#
import sys, math, os

# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input.txt", "rt")


positions = {0: [0, 0], 1: [1, 1]}
direction = 135 * math.pi / 180
x, y = 1, 1
for step in range(2, 10):
    x += math.cos(direction)
    y += math.sin(direction)
    positions[step] = [x, y]
    direction = math.atan2(x, -y)

while True:
    n = int(input())
    if n == -1:
        break
    print("%.2f" % positions[n-1][0])
    print("%.2f" % positions[n-1][1])
    

### FIXED CODE ###

# Aizu Problem 0076: Treasure Hunt II
#
import sys, math, os

# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input.txt", "rt")


positions = {0: [0, 0], 1: [1, 1]}
direction = 135 * math.pi / 180
x, y = 1, 1
for step in range(2, 1001):
    x += math.cos(direction)
    y += math.sin(direction)
    positions[step] = [x, y]
    direction = math.atan2(x, -y)

while True:
    n = int(input())
    if n == -1:
        break
    print("%.2f" % positions[n-1][0])
    print("%.2f" % positions[n-1][1])
H,N = map(int,input().split())
magic = [list(map(int,input().split())) for i in range(N)]

INF = 10**10
#print(magic)

dp = [INF for i in range(H+AM+1)]
dp[0] = 0

for i in range(1,H+1):
    for j in range(N):
        if magic[j][0] > i:
            dp[i] = min(dp[i],magic[j][1])
        else:
            dp[i] = min(dp[i-magic[j][0]]+magic[j][1],dp[i])
ans = INF
print(dp[H])


### FIXED CODE ###

H,N = map(int,input().split())
magic = [list(map(int,input().split())) for i in range(N)]

INF = 10**10
#print(magic)

AM = 0
for i in range(N):
    AM = max(AM,magic[i][0])
#print(AM)


dp = [INF for i in range(H+AM+1)]
dp[0] = 0

for i in range(1,H+AM+1):
    for j in range(N):
        if magic[j][0] > i:
            dp[i] = min(dp[i],magic[j][1])
        else:
            dp[i] = min(dp[i-magic[j][0]]+magic[j][1],dp[i])
ans = INF
for i in range(H,H+AM+1):
    ans = min(ans,dp[i])
print(ans)
q = int(input())
ab = [tuple(map(int, input().split())) for _ in range(q)]



for a, b in ab:
    if a > b:
        large = a
        small = b
    elif a < b:
        large = b
        small = a
    else:
        print(2* a - 2)


    # 最大のxを探す
    low_x = 0 
    upper_x = large - small + 1

    while upper_x- low_x> 1:
        mid_x = (low_x + upper_x ) //2

        # a * bを満たすかチェック
        is_ok = True
        #for i in range(low_x, upper_x + 1):
        for i in range(mid_x // 2 -2 , mid_x // 2+3):
            if i< 0 and b -a < i:
                continue
            if (small + i) * (small + mid_x - i) >= large* small:
                is_ok = False
                break

        if is_ok:
            low_x = mid_x
            x = mid_x
        else:
            upper_x = mid_x
            x= mid_x


    print(2 * small -2  + low_x)



### FIXED CODE ###

q = int(input())
ab = [tuple(map(int, input().split())) for _ in range(q)]



for a, b in ab:
    if a > b:
        large = a
        small = b
    elif a < b:
        large = b
        small = a
    else:
        print(2* a - 2)
        continue


    # 最大のxを探す
    low_x = 0 
    upper_x = large - small + 1

    while upper_x- low_x> 1:
        mid_x = (low_x + upper_x ) //2

        # a * bを満たすかチェック
        is_ok = True
        for i in range(mid_x // 2 -2, mid_x //2 +3) :
            if i< 0 and b -a < i:
                continue
            if (small + i) * (small + mid_x - i) >= large* small:
                is_ok = False
                break

        if is_ok:
            low_x = mid_x
            x = mid_x
        else:
            upper_x = mid_x
            x= mid_x


    print(2 * small -2  + low_x)
import sys

w = sys.stdin.readline().rstrip().lower()
cnt = 0
while True:
    lines = sys.stdin.readline().rstrip()
    if not lines:
		break	
    words = lines.split( " " )
    for i in range( len( words ) ):
    	if w == words[i].lower():
			cnt = cnt + 1			
print( cnt )

### FIXED CODE ###

import sys

w = sys.stdin.readline().rstrip().lower()
cnt = 0
while True:
	lines = sys.stdin.readline().rstrip()
	if not lines:
		break
	for s in lines.split( " " ):
		if w == s.lower():
			cnt = cnt + 1	

print( cnt )
H, W = map(int, input().split())
graph = []
for _ in range(H):
    graph.append([0 if e == '.' else 1 for e in list(input())])

res = True

for i in range(1, W-1):
    for j in range(1, H-1):
        if graph[i][j] == 1 and graph[i + 1][j] == 0 and graph[i - 1][j] and graph[i][j + 1] and graph[i][j - 1]:
            res = False
            break
    if not res:
        break
print('Yes' if res else 'No')


### FIXED CODE ###

H, W = map(int, input().split())
graph = []
for _ in range(H):
    graph.append(list(input()))

res = True

for j in range(1, W-1):
    for i in range(1, H-1):
        if graph[i][j] == '#' and graph[i + 1][j] == '.' and graph[i - 1][j] == '.' and graph[i][j + 1] == '.' and graph[i][j - 1] == '.':
            print('No')
            exit()
print('Yes')
import itertools
import sys


def main(argv):
    inputs = [int(v.rstrip()) for v in argv]
    A = inputs[0]
    B = inputs[1]
    C = inputs[2]
    X = inputs[3]

    cnt = 0
    for n_500, n_100, n_50 in itertools.product(range(A), range(B), range(C)):
        if 500 * n_500 + 100 * n_100 + 50 * n_50 == X:
           cnt += 1

    print(cnt)


if __name__ == '__main__':
    main(sys.argv[1:])


### FIXED CODE ###

import itertools


def main():
    A = int(input()) + 1
    B = int(input()) + 1
    C = int(input()) + 1
    X = int(input())

    cnt = 0
    for n_500, n_100, n_50 in itertools.product(range(A), range(B), range(C)):
        y = 500 * n_500 + 100 * n_100 + 50 * n_50
        if y == X:
            cnt += 1
    print(cnt)


if __name__ == '__main__':
    main()
a = list(map(int, input().split()))
print(a[0] * b[1])

### FIXED CODE ###

a = list(map(int, input().split()))
print(a[0] * a[1])
import sys

def main(lines):
  line=lines[0]

if __name__ == '__main__':
    lines = []
    for l in sys.stdin
        lines.append(l.rstrip('\r\n'))
    main(lines)


### FIXED CODE ###

import sys
import math

def main(lines):
    line=lines.split()
    n = int(line[0])
    x = int(line[1])
    t = int(line[2])
    ans = math.ceil(n/x)*t
    print(ans)

if __name__ == '__main__':
    lines=input()
    main(lines)
import sys
import numpy as np

def main():
    lines = sys.stdin.readlines()

    # The number of rooms
    rooms = np.array([0] * 10)
    floors = np.array([rooms] * 3)
    buildings = np.array([floors] * 4)

    data_num = 0

    for index, line in enumerate(lines):
        #print(line)
        # rm '\n' from string of a line
        line = line.strip('\n')
        elems = line.split(" ")
        if index == 0:
            data_num = int(elems[0])
        else:
            b = int(elems[0]) - 1   # as index
            f = int(elems[1]) - 1   # as index
            r = int(elems[2]) - 1   # as index
            v = int(elems[3])       # as data
            # print v
            buildings[b][f][r] += v
            # print buildings

    for b_i in range(0, 4):
        for f_i in range(0, 3):
            for r_i in range(0, 10):
                sys.stdout.write(' %d' % buildings[b_i][f_i][r_i])
            sys.stdout.write('\n')
        print "####################"



if __name__ == "__main__":
    main()

### FIXED CODE ###

import sys

def main():
    lines = sys.stdin.readlines()

    # The number of rooms
    rooms = [0] * 10
    floors = [rooms] * 3
    buildings = [floors] * 4

    data_num = 0

    for index, line in enumerate(lines):
        #print(line)
        # rm '\n' from string of a line
        line = line.strip('\n')
        elems = line.split(" ")
        if index == 0:
            data_num = int(elems[0])
        else:
            b = int(elems[0]) - 1   # as index
            f = int(elems[1]) - 1   # as index
            r = int(elems[2]) - 1   # as index
            v = int(elems[3])       # as data
            # print v
            # print buildings[b][f][r]
            ans = []
            for b_i in range(0, 4):
                b_list = []
                for f_i in range(0, 3):
                    f_list = []
                    for r_i in range(0, 10):
                        if b == b_i and f == f_i and r == r_i:
                            f_list.append(buildings[b_i][f_i][r_i] + v)
                        else:
                            f_list.append(buildings[b_i][f_i][r_i])
                    b_list.append(f_list)
                ans.append(b_list)
            # print ans
            buildings = ans

    for b_i in range(0, 4):
        for f_i in range(0, 3):
            for r_i in range(0, 10):
                sys.stdout.write(' %d' % buildings[b_i][f_i][r_i])
            sys.stdout.write('\n')
        if b_i != 3:
            print "####################"



if __name__ == "__main__":
    main()
a=input() #len input
b=input() #string input
if len(b)>int(a): # if exceed the len given
    print(b[:int(a)],"...")
else:
    print(c)

### FIXED CODE ###

#K input for the range of S
K = int(input())
#input of lowercase english letters
S = input()
if len(S) > K:
    print(S[:K] + "...")
else:
    print(S)
import fractions
a,b=map(int, input().split())
f2=a*b//f # 最小公倍数はf2
print(f2)

### FIXED CODE ###

a, b = map(int, input().split())
m,n=max(a,b),min(a,b)
if m%n==0:
    print(m)
else:
    while m%n!=0 and n!=1:
        m%=n
        m,n=max(m,n),min(m,n)
    print(int(a*b/n))
import sys
sys.setrecursionlimit(500000)
def gcd(x , y):
    while y != 0:
        x , y = y , x % y
    return x
N = int(input())
A = list(map(int ,input().split()))
max_val = 0
if N == 2:
    print(max(A[1], A[0]))
    exit()
right = []
left = []
work_right = gcd(A[N - 2] , A[N - 1])
right.append(A[N - 1])
work_left = gcd(A[0] , A[1])
left.append(A[0])
for i in range(1 , N - 1):
    work_left = gcd(work_left , A[i])
    left.append(work_left)
    work_right = gcd(work_right , A[N - i - 1])
    right.append(work_right)
#print(right)
#print(left)
right.reverse()
max_val = 0
for i in range(N):
    if i == 0:
        max_val = right[0]
    elif i == N - 1:
        if max_val < left[-1]:
            max_val = left[N]
    else:
        tmp = gcd(right[i] , left[i - 1])
        if tmp > max_val:
            max_val = tmp
print(max_val)
'''
for i in range(N):
    work = A[:i] + A[i + 1:]
    for j in range(1 , len(work)):
        if j == 1:
            tmp = gcd(work[0],work[1])
        else:
            tmp = gcd(tmp , work[j])
    if max_val < tmp:
        max_val = tmp
print(max_val)


### FIXED CODE ###

import sys
sys.setrecursionlimit(500000)
def gcd(x , y):
    while y != 0:
        x , y = y , x % y
    return x
N = int(input())
A = list(map(int ,input().split()))
max_val = 0
if N == 2:
    print(max(A[1], A[0]))
    exit()
right = []
left = []
work_right = gcd(A[N - 2] , A[N - 1])
right.append(A[N - 1])
work_left = gcd(A[0] , A[1])
left.append(A[0])
for i in range(1 , N - 1):
    work_left = gcd(work_left , A[i])
    left.append(work_left)
    work_right = gcd(work_right , A[N - i - 1])
    right.append(work_right)
#print(right)
#print(left)
right.reverse()
max_val = 0
for i in range(N):
    if i == 0:
        max_val = right[0]
    elif i == N - 1:
        if max_val < left[-1]:
            max_val = left[-1]
    else:
        tmp = gcd(right[i] , left[i - 1])
        if tmp > max_val:
            max_val = tmp
print(max_val)
'''
for i in range(N):
    work = A[:i] + A[i + 1:]
    for j in range(1 , len(work)):
        if j == 1:
            tmp = gcd(work[0],work[1])
        else:
            tmp = gcd(tmp , work[j])
    if max_val < tmp:
        max_val = tmp
print(max_val)
'''
#include <bits/stdc++.h>
using namespace std;

int main(){
  int N, K, a, b, S, ans;
  cin >> N >> K;
  
  vector<int> C(100000);
  
  for (int i = 0; i < N; i++){
    cin >> a >> b;
    C.at(a-1) += b;
  }
  
  for (int i = 0; i < N; i++){
    S += C.at(i);
    if (S >= K){
      cout << i+1 << endl;
      break;
    }
  }
}

### FIXED CODE ###

A, B, C = map(int, input().split())
if A <= C and C <= B:
  print("Yes")
else:
  print("No")
S = input()
K = int(input())

if S[0] == '1':
  print(S[1])
else:
  print(S[0])

### FIXED CODE ###

S = input()
K = int(input())
count = 0

if S[0] != '1':
  print(S[0])
  exit()

for i in range(len(S)):
    if S[i] == '1':
      count += 1
    else:
      break

if count >= K:
  print(1)
else:
  print(S[count])
A=input().strip().sprit(' ')
B=input().strip().sprit(' ')
C=input().strip().sprit(' ')
D=input().strip().sprit(' ')
a=int(A)
b=int(B)
c=int(C)
d=int(D)

max=0
min=0

if a < c :
    max=c
else :
    max=a
    
if b > d :
    min=d
else :
    min=b
if ( min - max ) > 0 :
    print( min - max )
else :
    print(0)



### FIXED CODE ###



a,b,c,d=[int(i) for i in input().strip().split(' ')]

'''
入力は他の人のを見た
'''

max=0
min=0

if a < c :
    max=c
else :
    max=a
    
if b > d :
    min=d
else :
    min=b
if ( min - max ) > 0 :
    print( min - max )
else :
    print(0)
a = [input()for i in range(3)]
b = [input()for i in range(3)]
c = [input()for i in range(3)]

print(a[0] + b[1] + c[2])


### FIXED CODE ###

A, B, C = [input() for i in range(3)]

print(A[0] + B[1] + C[2])
a = int(input())
b = int(input())
c = int(input())
d = int(input())

num_listx = []
num_listy = []

for num in range(b):
  if num >= a and <= b:
    num_listx.append(num)
for nums in range(d):
  if nums >= c and <= d:
    num_listy.append(nums)
x = max(num_listx)
y = max(num_listy)
print(x*y)

### FIXED CODE ###

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

ans = max(a*c,a*d,b*c,b*d)

print(ans)
import sys

import numpy as np
import pandas as pd

n, m = map(int, input().split())
lines = sys.stdin.readlines()
lines = [list(map(float, line.strip().split())) for line in lines]
df = pd.DataFrame(lines,
                  columns = ["price", "stock"],
                  dtype = float
                  )
df = df.sort_values(by="price")
price = 0
for i in range(n):
    if m - df.iloc[i]["stock"] > 0:
        price += df.iloc[i]["price"] * df.iloc[i]["stock"]
        m -= df.iloc[i]["stock"]
    else:
        price += df.iloc[i]["price"] * m
        break
print(int(price))


### FIXED CODE ###

import sys
import numpy as np

n, m = map(float, input().split())
lines = sys.stdin.readlines()
lines = [list(map(float, line.strip().split())) for line in lines]
lines.sort()
price = 0
for line in lines:
    if m - line[1] > 0:
        price += line[0] * line[1]
        m -= line[1]
    else:
        price += line[0] * m
        break
print(int(price))
n = int(input())
ans = ''

for i in range(1,99):
    if n <= 26**i:
        n -= 1
        for j in range(i):
            ans += chr(ord('a')+N%26)
            n //= 26
        break
    else:
        n -= 26**i

print(ans[::-1])

### FIXED CODE ###

n = int(input())
ans = ''

for i in range(1,99):
    if n <= 26**i:
        n -= 1
        for j in range(i):
            ans += chr(ord('a')+n%26)
            n //= 26
        break
    else:
        n -= 26**i

print(ans[::-1])
l,n=map(int,input().split())
x=[int(input()) for i in range(n)]
y=x[::-1]
a=[]
b=[]
for j in x:
    a=abs(0-x[i])
    b=abs(l-y[i])
s=max(a[0],b[0])
for k in range(1,n):
    e+=max(a[k]+b[x])
print(e) 

### FIXED CODE ###

L,N = list(map(int,input().split()))
X=[]
Y=[]
SX=[0]
SY=[0]
sx=0
sy=0
for i in range(N):
   x=int(input())
   X.append(x)
   sx+=x
   SX.append(sx)
   Y.append(L-x)
   sy+=L-x
   SY.append(sy)   

max_score=0   
for i in range(N):
    if i>N-i-1:
        max_score=max(2*(SX[i]-SX[2*i-N])+2*(SY[N]-SY[i+1])+Y[i],max_score)
    elif i<N-i-1:
        max_score=max(2*(SX[i]-SX[0])+2*(SY[2*i+2]-SY[i+1])+X[i],max_score)

        
    ind = min(i,N-i-1)
    max_score=max(2*(SX[i]-SX[i-ind])+2*(SY[i+ind+1]-SY[i+1])+X[i],max_score)
    max_score=max(2*(SX[i]-SX[i-ind])+2*(SY[i+ind+1]-SY[i+1])+Y[i],max_score)


print(max_score)
#copy code.
S = int(raw_input())
??
h = S / 3600
m = S - 3600*h
s = m % 60
m = (m - s)/60
??
print str(h) + ":" + str(m) + ":" + str(s)

### FIXED CODE ###

S = int(raw_input())

h = S / 3600
m = S - 3600*h
s = m % 60
m = (m - s)/60

print str(h) + ":" + str(m) + ":" + str(s)
A, B, C, K = map(int, input().split())
result = 0

if A >= K:
    print(A)
elif (A + B) >= K:
    print(A)
else:
    if (A + B + C) > K:
        print(A - (K - (A + B))
    elif (A + B + C) <= K:
        print(A - C)

### FIXED CODE ###

A, B, C, K = map(int, input().split())
if A >= K:
    print(K)
elif (A + B) >= K:
    print(A)
elif (A + B + C) > K:
    print(A - (K - A - B))
elif (A + B + C) == K:
    print(A - C)
n=int(input())
dat = list(map(int, input().split()))
dan = []
for e in dat:
    e = str(bin(e))
    e=e[2:]
    e1=list(e)
    e1.reverse()
    
     
                

         
           




### FIXED CODE ###

import sys

def main():
    N = int(input())
    A = [int(_) for _ in input().split()]

    t = 0
    while True:
        for i in range(N):
            if A[i] % 2 == 0:
                A[i] //= 2
            else:
                print(t)
                sys.exit()
        t += 1

main()
# -*- coding: utf-8 -*-

s = str(raw_input())
q = int(raw_input())
for i in range(q):
    line = map(str, raw_input().split())
    com = line[0]
    a = int(line[1])
    b = int(line[2])
    if com == "print":
        print s[a:b+1]
    elif com == "reverse":
        len = len(s)
        s = s[0:a] + s[-len+b:-len+a-1:-1] + s[b+1:]
    elif com == "replace":
        p = line[3]
        s = s.replace(s[a:b+1], p)
    else:
        print "Error"

### FIXED CODE ###

# -*- coding: utf-8 -*-

s = str(raw_input())
q = int(raw_input())
for i in range(q):
    line = map(str, raw_input().split())
    com = line[0]
    a = int(line[1])
    b = int(line[2])
    if com == "print":
        print s[a:b+1]
    elif com == "reverse":
        tmp = s[::-1]
        s = s[:a] + tmp[len(tmp)-b-1:len(tmp)-a] + s[b+1:]
    elif com == "replace":
        p = line[3]
        s = s[:a] + p + s[b+1:]
    else:
        print "Error"
d = int(input())
string = 'Christmas'
for i range(25 - d):
  string += ' Eve'
print(string)


### FIXED CODE ###

d = int(input())
string = 'Christmas'
for i in range(25 - d):
  string += ' Eve'
print(string)
# coding: utf-8
# @????????? #?????? *?????????

def dfs(x, y, fru):
    # ???????????¨?????????.???????????????
    field[x][y] = '.'
    # 4??????????????????
    for dx in [-1,0,1]:
        nx = x + dx
        if 0 <= nx and nx < H and field[nx][y] == fru:
            dfs(nx,y,fru)
    for dy in [-1,0,1]:
        ny = y + dy
        if 0 <= ny and ny < W and field[x][ny] == fru:
            dfs(x,ny,fru)

def solv(H,W):
    count = 0
    for i in range(H):
        for j in range(W):
            if field[i][j] == '@':
                dfs(i,j,'@')
                count+=1
            elif field[i][j] == '#':
                dfs(i,j,'#')
                count+=1
            elif field[i][j] == '*':
                dfs(i,j,'*')
                count+=1
    print(count)

#x,y??§2??¶?????°???1?????§??\????????????????????\???????????°?????§????????¨???
f=0
while(f==0):
    H, W = map(int, input().split())
    if H != 0 and W != 0:
        field = [] # ????¨??????¨??????
        for i in range(H):
            field.append(list(input()))
        solv(H,W)
    else:
        f=1

### FIXED CODE ###

# coding: utf-8
# @????????? #?????? *?????????
import sys
sys.setrecursionlimit(10000000)

def dfs(x, y, fru):
    # ???????????¨?????????.???????????????
    field[x][y] = '.'
    # 4??????????????????
    for dx in [-1,0,1]:
        nx = x + dx
        if 0 <= nx and nx < H and field[nx][y] == fru:
            dfs(nx,y,fru)
    for dy in [-1,0,1]:
        ny = y + dy
        if 0 <= ny and ny < W and field[x][ny] == fru:
            dfs(x,ny,fru)

def solv(H,W):
    count = 0
    for i in range(H):
        for j in range(W):
            if field[i][j] != '.':
                dfs(i,j,field[i][j])
                count+=1
            # elif field[i][j] == '#':
            #     dfs(i,j,'#')
            #     count+=1
            # elif field[i][j] == '*':
            #     dfs(i,j,'*')
            #     count+=1
    print(count)

f = 0
while(f == 0):
    H, W = map(int, input().split())
    if H != 0 and W != 0:
        field = [] # ????¨??????¨?????????
        for i in range(H):
            field.append(list(input()))
        solv(H,W)
    else:
        f = 1
N = int(input())
h = list(map(int, input().split()))
c = []
tmp = 0
for x in reversed(range(len(h))):
  if len(h) == 1:
    c.append(0)
  elif h[x] <= h[x-1]:
    tmp += 1
  else:
    c.append(tmp)
    tmp = 0
print(sorted(c)[-1])


### FIXED CODE ###

N = int(input())
h = list(map(int, input().split()))
c = []
tmp = 0
for x in reversed(range(len(h))):
  if len(h) == 1:
    c.append(0)
  elif h[x] <= h[x-1]:
    tmp += 1
  else:
    c.append(tmp)
    tmp = 0
if len(c) == 0:
  c.append(tmp-1)
print(sorted(c)[-1])
n,m,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
x=[0]*n
y=[0]*m
x[0]=a[0]
y[0]=b[0]
for i in range(0,n-1):
    x[i+1]=x[i]+a[i+1]
for i in range(0,m-1):
    y[i+1]=y[i]+b[i+1]
ans,j=0,m
for i in range(n):
    if x[i]>k:
        break
    while y[j-1]>k-x[i]:
        j-=1
    ans=max(i+1+j,ans)
print(ans)

### FIXED CODE ###

n,m,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
x,y=[0],[0]
for i in range(n):
    x.append(a[i]+x[i])
for j in range(m):
    y.append(b[j]+y[j])

ans=0
j=m
for i in range(n+1):
    if x[i]>k:
        break
    while y[j]>k-x[i]:
        j-=1
    ans=max(i+j,ans)
print(ans)
N,A,B = map(int,input().split())
goal = ''
if A == 0:
  print(0)
if B == 0 and A != 0:
  print(N)
if A != 0:
  howmany = (N//min(A,B)) + 1
  for i in range(howmany):
    goal += A*"b"
    goal += B*"r"
  print(goal[0:N].count("b"))

### FIXED CODE ###

N,A,B = map(int,input().split())
R = N%(A+B)
res = (N//(A+B))*A
if R == 0:
  print(res)
else:
  if R<A:
    print(res+R)
  else:
    print(res+A)
N, K = map(int, input().split())
Alist = list(map(int, input().split()))

# ループする数を求める
loop_num = 2 * 10 ** 5
loop_start_point = -1
point = 1
count_list = [-1] * N

for i in range(K):
    #print("point:", point)
    count_list[point - 1] = i
    nextPoint = Alist[point - 1]

    if count_list[nextPoint - 1] != -1:
        loop_start_point = nextPoint
        loop_num = i - count_list[loop_start_point - 1] + 1
        break
    
    point = nextPoint

if loop_start_point == -1:
    #print(point)
else:
    point = loop_start_point
    progress_num = (K - count_list[loop_start_point-1]) % loop_num
    for i in range(progress_num):
        point = Alist[point - 1]
    #print("pro:", progress_num)
    #print("ls:", loop_start_point)
    #print("ln:", loop_num)
    print(point)

### FIXED CODE ###

N, K = map(int, input().split())
Alist = list(map(int, input().split()))

# ループする数を求める
loop_num = 2 * 10 ** 5
loop_start_point = -1
point = 1
count_list = [-1] * N

for i in range(K):
    #print("point:", point)
    count_list[point - 1] = i
    nextPoint = Alist[point - 1]

    if count_list[nextPoint - 1] != -1:
        loop_start_point = nextPoint
        loop_num = i - count_list[loop_start_point - 1] + 1
        break
    
    point = nextPoint

if loop_start_point == -1:
    print(point)
else:
    point = loop_start_point
    progress_num = (K - count_list[loop_start_point-1]) % loop_num
    for i in range(progress_num):
        point = Alist[point - 1]
    #print("pro:", progress_num)
    #print("ls:", loop_start_point)
    #print("ln:", loop_num)
    print(point)
N, M = map(int, input().split())
useful_num_list = list(map(int, input().split()))

need_matches = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]

dp = [-1] * (N+1)
dp[0] = 0
for i in range(1, N+1):
    max_scale = -1
    for num in useful_num_list:
        if need_matches[num] <= i:
            scale = dp[i-need_matches[num]] + 1
            if max_scale < scale:
                max_scale = scale
    dp[i] = max_scale

useful_num_list.sort(reverse=True)
ans =""
n = N
while n > 0:
    ans_scale = ""
    for num in useful_num_list:
        if dp[n] - 1 == dp[n - need_matches[num]]:
            ans_scale = str(num)
            n -= need_matches[num]
            break
    ans += ans_scale
print(ans)


### FIXED CODE ###

A, B = map(int, input().split())

if B % A == 0:
    print(A+B)
else:
    print(B-A)