Harryxun/stf_run huggingface dataset:
def main():
	H, W, A, B = map(int, input().split())
	H, W= H-1, W-1
	DIV = 10**9+7

	fact = [0]*(H+W-A+1)
	inverse = [0]*(H+W-A+1)
	inv_cal = [0]*(H+W-A+1)
	fact[:2] = [1, 1]
	inverse[:2] = [1, 1]
	inv_cal[:2] = [0, 1]

	for i in range(2, H+W-A+1):
		fact[i] = (fact[i-1]*i%DIV)
		inv_cal[i] = (-inv_cal[DIV%i]*(DIV//i))%DIV
		inverse[i] = inverse[i-1]*inv_cal[i]%DIV

	def C(n, r):
		ans = fact[n]*inverse[r]%DIV
		return ans*inverse[n-r]%DIV

	ans = 0
	for x in range(B, W+1):
		y = H-A
		tmp = (C(x+y, x)%DIV)*(C(H+W-x-y-1, W-x)%DIV)%DIV
		ans += tmp
		ans %= DIV

	print(ans)


if __name__ == '__main__':
	main()

### FIXED CODE ###

def main():
	H, W, A, B = map(int, input().split())
	H, W= H-1, W-1
	DIV = 10**9+7
	size = H+W+1

	fact = [0]*size
	inverse = [0]*size
	inv_cal = [0]*size
	fact[:2] = [1, 1]
	inverse[:2] = [1, 1]
	inv_cal[:2] = [0, 1]

	for i in range(2, size):
		fact[i] = (fact[i-1]*i%DIV)
		inv_cal[i] = (-inv_cal[DIV%i]*(DIV//i))%DIV
		inverse[i] = inverse[i-1]*inv_cal[i]%DIV

	def C(n, r):
		ans = fact[n]*inverse[r]%DIV
		return ans*inverse[n-r]%DIV

	ans = 0
	for x in range(B, W+1):
		y = H-A
		tmp = (C(x+y, x)%DIV)*(C(H+W-x-y-1, W-x)%DIV)%DIV
		ans += tmp
		ans %= DIV

	print(ans)


if __name__ == '__main__':
	main()
s_dash = input()
t = input()
n = len(s_dash)
m = len(t)


f n < m:
    print("UNRESTORABLE")
    exit()

for i in range(n - m + 1):
    flag = True
    for j in range(m):
      if s_dash[i+j] != "?" and s_dash[i+j] != t[j]:
        flag = False
        break
    if flag:
      ans = list(s_dash)
      ans[i:i+m] = list(t)
      ans = "".join(ans).replace("?", "a")
      print(ans)
      exit()
      
print("UNRESTORABLE")
      

### FIXED CODE ###

S = input()
T = input()
if len(S) < len(T):
    print("UNRESTORABLE")
    exit()
for i in range(len(S) - len(T), -1, -1):
    for s, t in zip(S[i:i+len(T)], T):
        if s != "?" and s != t:
            break
    else:
        S = list(S)
        S[i:i+len(T)] = list(T)
        S = "".join(S).replace("?", "a")
        print(S)
        exit()
print("UNRESTORABLE")
import math
a,b = map(int,float,input().split())
print(math.floor(a*b))


### FIXED CODE ###

from decimal import Decimal
import math
a,b = map(Decimal,input().split())
ans = a*b
print(math.floor(ans))
a,b=map(int,input().split())
x=0
for i:
  if (a-1)*i+1<b:
    x+=1
  else:
    exit()
print(x)

### FIXED CODE ###

import math
a,b=map(int,input().split())
c=a-1
d=b-1
print(math.ceil(d/c))
a,b=map(int,input().split())
print(a*b)


### FIXED CODE ###

S=list(map(int,input().split()))
for i in range(5):
    if S[i]==0:
        print(i+1)
A = map(int, input().split())
if A.sort() == [5,7,7]:
  print("YES")
eles:
  print("NO")

### FIXED CODE ###

A = list(map(int, input().split()))
A.sort()
if A == [5,5,7]:
  print("YES")
else:
  print("NO")
K = int(input())
X = int(input())

if K*500 >= X:
  print("Yes")



### FIXED CODE ###

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

if K*500 >= X:
  print("Yes")
else:
  print("No")
N = int(input())
ans = 0

for i in range(N):
  a,b = map(str, input().split())
  if b =="JPY":
    ans += int(a)
  else:
    ans += int(a)*380000
print(ans)


### FIXED CODE ###

y,m,d = map(int, input().split("/"))
if  m >= 5 :
  print("TBD")
else:
  print("Heisei")
N = int(input())
test = list(map(int,input().split()))
M = int(input()) 
  
for _ in range(M):
  a,b = map(int,input().split())
  print(sum(test) - test[a] + b)

### FIXED CODE ###

a = input().split()

if a[1] == "+":
  print(int(a[0]) + int(a[2]))
else:
  print(int(a[0]) - int(a[2]))
N, M = map(int, input().split()) 
ans = []
if M % 2 != 0:
    for i in range((M + 1)//2):
        ans.append((1 + i, M + 1 - i))
        
    for j in range((M - 1)//2):
        ans.append((M + 2 + j, 2*M + 1 - j))
else:
    for i in range(M//2):
        ans.append((1 + i, M + 1 - i))
        ans.append((M + 2 + j, 2*M + 1 - j))
              
for i in range(M):
    print(*ans[i])

### FIXED CODE ###

N, M = map(int, input().split()) 
ans = []
if M % 2 != 0:
    for i in range((M + 1)//2):
        ans.append((1 + i, M + 1 - i))
        
    for j in range((M - 1)//2):
        ans.append((M + 2 + j, 2*M + 1 - j))
else:
    for i in range(M//2):
        ans.append((1 + i, M + 1 - i))
        ans.append((M + 2 + i, 2*M + 1 - i))
              
for i in range(M):
    print(*ans[i])
S = input()
len(S)=p
t=0
for n in range(p):
  if S[n]=S[p-n-1]:
    continue
  else:
    t+=1
print(t)

### FIXED CODE ###

S = input()
p=len(S)
t=0
for n in range(p):
  if S[n]!=S[p-n-1]:
    t+=1
print(int(t/2))
S = input()
ans = 'Yes'
if S = 'AAA' or S = 'BBB':
  ans = 'No'
print(ans)

### FIXED CODE ###

S = input()
ans = 'Yes'
if S == 'AAA' or S == 'BBB':
  ans = 'No'
print(ans)
N=list(input().split)

n=reversed(N)

if n[0]=="2" or n[0]=="4" or n[0]=="5" or n[0]=="7" or n[0]=="9":
    print(hon)
if n[0]=="0" or n[0]=="1" or n[0]=="6" or n[0]=="8":
    print(pon)
if n[0]=="3":
    print(bon)

### FIXED CODE ###

n=list(input())

n==n.reverse()

if (n[0]=="2" or n[0]=="4" or n[0]=="5" or n[0]=="7" or n[0]=="9"):
    print("hon")
elif (n[0]=="0" or n[0]=="1" or n[0]=="6" or n[0]=="8"):
    print("pon")
elif (n[0]=="3"):
    print("bon")
N=int(input);print(N*(N%2+1))

### FIXED CODE ###

N=int(input());print(N*(N%2+1))
n = 10**4
tmp = [0]*(10**4)
for x in range(1,int(-(-n**0.5//1))+1):
    for y in range(1,x+1):
        for z in range(1, y+1):
            if x*x + y*y + z*z + x*y + y*z + z*x < 10**4:
                if x == y and y == z and z == x:
                    tmp[x*x + y*y + z*z + x*y + y*z + z*x] +=1
                elif x == y or y == z or z == x:
                    tmp[x*x + y*y + z*z + x*y + y*z + z*x]  += 3
                else:
                    tmp[x*x + y*y + z*z + x*y + y*z + z*x]  += 6
for i in range(1, N+1):
    print(tmp[i])

### FIXED CODE ###

N = int(input())
n = 10**4
tmp = [0]*((10**4)+1)
for x in range(1,int(-(-n**0.5//1))+1):
    for y in range(1,x+1):
        for z in range(1, y+1):
            if x*x + y*y + z*z + x*y + y*z + z*x <= 10**4:
                if x == y and y == z and z == x:
                    tmp[x*x + y*y + z*z + x*y + y*z + z*x] +=1
                elif x == y or y == z or z == x:
                    tmp[x*x + y*y + z*z + x*y + y*z + z*x]  += 3
                else:
                    tmp[x*x + y*y + z*z + x*y + y*z + z*x]  += 6
for i in range(1, N+1):
    print(tmp[i])
print(input().rfind("Z")-input().find("A")+1)

### FIXED CODE ###

s=input()
print(s.rfind("Z")-s.find("A")+1)
N=int(input())
s = [input() for _ in range(N)]
M=int(input())
t = [input() for _ in range(M)]

l = list(set(s)) 

for k in range(len(l)):
    cnt = max(cnt, s.count(l[k]) - t.count(l[k]))

print(cnt)

### FIXED CODE ###

N=int(input())
s = [input() for _ in range(N)]
M=int(input())
t = [input() for _ in range(M)]

l = list(set(s)) 

cnt=0
for k in range(len(l)):
    cnt = max(cnt, s.count(l[k]) - t.count(l[k]))

print(cnt)
A，B，C = list(map(str, input().split()))
vincent = A + B + C
vincent1 = list(set(vincent))
if len(vincent1) == 2:
  print('Yes')
else:
  print('No')


### FIXED CODE ###

A, B, C = list(map(int, input().split()))
vincent = [A,B,C]
vincent1 = list(set(vincent))
if len(vincent1) == 2:
    print("Yes")
else:
    print("No")
n = int(input())
l = list(map(int, input().split()))
l.sort()
sum = 0
for i in range(n-1):
	sum += i
if sum > a[n-1]:
	print('Yes')
else:
	print('No')

### FIXED CODE ###

n = int(input())
l = list(map(int, input().split()))
l.sort()
sum = 0
for i in range(n-1):
	sum += l[i]
if sum > l[n-1]:
	print('Yes')
else:
	print('No')
x,y = [input().split()]
if x == y:
  print('=')
elif x > y:
  print('>')
else:
  print('<')

### FIXED CODE ###

x,y = input().split()
if x == y:
  print('=')
elif x > y:
  print('>')
else:
  print('<')
n = int(input())

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

for A in range(n):
    if A == A//3 or A == A//5:
        print("APPROVED")
    else:
        print("DENIED")

### FIXED CODE ###

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

if a==b and a!=c:
    print("Yes")
elif a==c and a!=b:
    print("Yes")
elif b==c and b!=a:
    print("Yes")
else:
    print("No")
if n % 2 != 0:
    print("No")
else:
    s_1 = s[:int(n/2)]
    s_2 = s[int(n/2):]
    if s_1 == s_2:
        print("Yes")
    else:
        print("No")

### FIXED CODE ###

n = int(input())
s = input()

if n % 2 != 0:
    print("No")
else:
    s_1 = s[:int(n/2)]
    s_2 = s[int(n/2):]
    if (s_1 == s_2):
        print("Yes")
    else:
        print("No")
# ABC122-C
import numpy as np
N, Q = map(int, input().split())
S = input()
lr = [list(map(int, input().split())) for _ in range(Q)]
ind = []
for i in range(N-1):
    if S[i] == "A" and S[i+1] == "C":
        ind.append(i+1)
##print(ind)
ind = np.array(ind)
##print(ind)
for i in range(Q):
    print(np.count_nonzero((lr[i][0] <= ind) & (ind <= lr[i][1] - 1)))

### FIXED CODE ###

b = input()
if b == "A":
    print("T")
elif b == "T":
    print("A")
elif b == "C":
    print("G")
else:
    print("C")
S = input()
if S = "ABC":
  print("ARC")
elif S = "ARC":
  print("ABC")

### FIXED CODE ###

S = input()
if S[1]=="B":
  print("ARC")
else:
  print("ABC")
N = int(input())

counter = 0
for number_cake in range(0,N):
	for number_donut in range(0,N):
		if(N == number_cake*4+number_donut*7):
			counter += 1

if(counter > 0):
	print("Yes")
else:
	print("No")


### FIXED CODE ###

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

if N % K == 0:
	print("0")
	exit()
print("1")
X = int(input())

def prime_factors(n):
    i = 2
    factors = []
    while i * i <= n:
        if n % i:
            i += 1
        else:
            n //= i
            factors.append(i)
    if n > 1:
        factors.append(n)
    return factors

xfactor = prime_factors(X)

for i in (0, len(xfactor)-1):
	for j in range (-1000000, 1000000):
		if xfactor[i]*(5*j^4-10*j^3*xfactor[i]^1+10*j^2*xfactor[i]^2-5*j^1*xfactor[i]^3-xfactor[i]^4) == X:
			print(j, j-xfactor[i])
			exit()

### FIXED CODE ###

X = int(input())

for i in range (-1000, 1000):
	for j in range (-1000,1000):
		if i**5-j**5 == X:
			print(i, j)
			exit()
a,b=int(input(),split())
print (a * b,(a + b) * 2)

### FIXED CODE ###

a,b=map(int,input().split())
print (a * b,(a + b) * 2)
def cin():
    return input().split()
def qpow(a,b,p):
    if p == 1:
        return 0
    a = (a%p+p)%p
    ans = 1
    while b!=0:
        if (b&1) != 0:
            ans = (ans * a) % p
        b >>= 1
        a = a * a  % p
    return ans

def f(x):
    ans = 0
    if x == 0:
        return ans
    for i in range(31):
        if ((x>>i)&1) == 1:
            ans += 1
    return f(x%ans) + 1

n = int(input())
x = list(input())
x = x[::-1]
cnt = 0;l = len(x)
r1 = 0;r2 = 0
for i in x:
    if i == '1':
        cnt += 1
i = 0
while i < l:
    if x[i] == '1':
        r1 += qpow(2,i,cnt+1)
        r2 += qpow(2,i,cnt-1)
    i += 1
i = 0
a = []
while i < l:
    if x[i] == '0':
        t = f((r1+qpow(2,i,cnt+1))%(cnt+1))+ 1
    else:
        t = f((r1-qpow(2,i,cnt-1)+(cnt-1))%(cnt-1)) + 1
    i += 1
    a.append(t)
a = a[::-1]
for i in a:
    print(i)




### FIXED CODE ###

def cin():
    return input().split()
def qpow(a,b,p):
    if p == 1 or p == 0:
        return 0
    a = (a%p+p)%p
    ans = 1
    while b!=0:
        if (b&1) != 0:
            ans = (ans * a) % p
        b >>= 1
        a = a * a  % p
    return ans

def f(n):
    if n == 0:
        return 0
    return f(n % bin(n).count("1")) + 1

n = int(input())
x = list(input())
x = x[::-1]
cnt = 0;l = len(x)
r1 = 0;r2 = 0
for i in x:
    if i == '1':
        cnt += 1
i = 0
while i < l:
    if x[i] == '1':
        r1 += qpow(2,i,cnt+1)
        r2 += qpow(2,i,cnt-1)
    i += 1
i = 0
a = []
while i < l:
    if x[i] == '0':
        t = f((r1+qpow(2,i,cnt+1))%(cnt+1))+ 1
    else:
        if cnt-1 !=  0:
            t = f((r2-qpow(2,i,cnt-1)+(cnt-1))%(cnt-1)) + 1
        else:
            t = 0
    i += 1
    a.append(t)
a = a[::-1]
for i in a:
    print(i)
import sys

sys.setrecursionlimit(100001)


def get_ncr(div):
    cache = {}

    def f(*args):
        if args in cache:
            return cache[args]
        n, r = args
        if r == 0 or n == r:
            cache[args] = 1
            return 1
        cache[args] = (f(n - 1, r) + f(n - 1, r - 1)) % div
        return cache[args]

    return f


def find_duplicated(aa):
    appeared = [-1] * (n + 1)
    for i, a in enumerate(aa):
        if appeared[a] >= 0:
            return appeared[a], i
        appeared[a] = i


n = int(input())
aa = list(map(int, input().split()))
i1, i2 = find_duplicated(aa)
between_n = i2 - i1 + 1
outside_n = n + 1 - between_n
div = int(1e9 + 7)
ncr = get_ncr(div)

for part_n in range(1, n + 2):
    sub = ncr(outside_n, part_n - 1) if outside_n >= part_n - 1 else 0
    print((ncr(n + 1, part_n) - sub) % div)


### FIXED CODE ###

def ncr(n, r):
    return fact[n] * inv_fact[r] * inv_fact[n - r] % div


def find_duplicated(aa):
    appeared = [-1] * (n + 1)
    for i, a in enumerate(aa):
        if appeared[a] >= 0:
            return appeared[a], i
        appeared[a] = i


div = int(1e9 + 7)
n = int(input())
aa = list(map(int, input().split()))

fact, inv_fact = [1], [1]
fact_tmp = 1
for i in range(1, n + 2):
    fact_tmp *= i
    fact_tmp %= div
    fact.append(fact_tmp)
    inv_fact.append(pow(fact_tmp, div - 2, div))

i1, i2 = find_duplicated(aa)
outside_n = n + 1 - (i2 - i1 + 1)

for part_n in range(1, n + 2):
    sub = ncr(outside_n, part_n - 1) if outside_n >= part_n - 1 else 0
    print((ncr(n + 1, part_n) - sub) % div)
S_str=str(input())
S_list=list(S_str)
S=int(S_str)
N=len(S_str)

mod=[0]*2018
mod[0]=1

for i in range(N):
    #print(i+1,S,S%2019)
    mod[S%2019]+=1
    S-=int(S_list[i])*(10**(N-1-i))

def culc(x):
    return x*(x-1)//2


ans=0
for j in range(len(mod)):
    ans+=culc(mod[j])

print(ans)




### FIXED CODE ###

S_str=str(input())
S=int(S_str[-1])
N=len(S_str)

mod=[0]*2019
mod[0]=1
now=S%2019
mod[now]+=1

for i in range(N-1)[::-1]:
    #print(i+1,S,S%2019)
    next=pow(10,N-1-i,2019)
    next=(next*int(S_str[i]))%2019
    now=(now+next)%2019
    mod[now]+=1

    

def culc(x):
    return x*(x-1)//2


ans=0
for j in range(len(mod)):
    ans+=culc(mod[j])

print(ans)
N, M = map(int, input().split())

import math

divisor=[]
for i in range(1, math.ceil(math.sqrt(M))+1):
    if M%i==0:
        divisor.append(i)
#print(divisor)

divisor+=[M//val for val in reversed(divisor)]
#print(divisor)
for val in divisor:
    if val>=N:
        print(M//val)
        break

### FIXED CODE ###

N = int(input())
if N==1:
    print('Hello World')
else:
    A=int(input())
    B=int(input())
    print(A+B)
N, X, M = map(int, input().split())
check = [0]*(M+1)
check[X] += 1
A = X
while True:
    A = (A**2)%M
    if check[A] != 0:
        last_count = sum(check)
        target_value = A
        break
    check[A] += 1
A2 = X
first_count = 0
while True:
    first_count += 1
    A2 = (A2**2)%M
    if A2 == target_value:
        break

roop_count = last_count-first_count
A3 = target_value
mass = A3
for i in range(roop_count-1):
    A3 = (A3**2)%M
    mass += A3
ans = X
A = X
for i in range(min(N,first_count)-1):
    A = (A**2)%M
    ans += A
if N > first_count:
    ans += ((N-first_count)//roop_count)*mass
    A4 = target_value
    if (N-first_count)%roop_count >= 1:
        ans += A4
    for i in range(((N-first_count)%roop_count)-1):
        A4 = (A4**2)%M
        ans += A4

print(ans)

### FIXED CODE ###

N, X, M = map(int, input().split())
if X <= 1:
    print(X*N)
    exit()
check = [0]*(M+1)
check[X] += 1
A = X
last_count = 0
while True:
    A = (A**2)%M
    if check[A] != 0:
        last_count = sum(check)
        target_value = A
        break
    check[A] += 1
A2 = X
first_count = 0
while A2 != target_value:
    first_count += 1
    A2 = (A2**2)%M

roop_count = last_count-first_count

A3 = target_value
mass = A3
for i in range(roop_count-1):
    A3 = (A3**2)%M
    mass += A3
if roop_count == 0:
    print(N*X)
    exit()
if first_count != 0:
    ans = X
    A = X
    for i in range(min(N,first_count)-1):
        A = (A**2)%M
        ans += A
else:
    ans = 0
if N > first_count:
    ans += ((N-first_count)//roop_count)*mass
    A4 = target_value
    if (N-first_count)%roop_count >= 1:
        ans += A4
    for i in range(((N-first_count)%roop_count)-1):
        A4 = (A4**2)%M
        ans += A4
print(ans)
N, M = map(int, input().split())
list=[]
s={}
for i in range(N):
    list.append(input().split()[1:])
    a = set(list)
    s = s & a
print(len(s)) 

### FIXED CODE ###

N, M = map(int, input().split())
list=[]
s=set(range(1, M+1))
for i in range(N):
    K, *A = map(int, input().split())
    s &= set(A)
print(len(s))
s_=input()
t=input()

filled_idx=[i for i in range(len(s_)) if s_[i]!="?"]

t_s=len(s_)-len(t)
t_e=t_s+len(t)
for t_s in range(t_s,-1,-1):
    s=s_[:t_s]+t+s_[t_e:]
    if(all(s[i]==s_[i] for i in filled_idx)):
        s=s.replace("?","a")
        print(s)
        break
else:
    print("UNRESTORABLE")

### FIXED CODE ###

s_=input()
t=input()
 
filled_idx=[i for i in range(len(s_)) if s_[i]!="?"]
 
for t_s in range(len(s_)-len(t),-1,-1):
    t_e=t_s+len(t)
    s=s_[:t_s]+t+s_[t_e:]
    if(all(s[i]==s_[i] for i in filled_idx)):
        s=s.replace("?","a")
        print(s)
        break
else:
    print("UNRESTORABLE")
import math
import itertools

def swap(a,b):
    return max(a,b),min(a,b)

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

N = int(input())
an = [int(input()) for i in range(N)]
#an = [5,10,12]
an.sort()

max_v = 0
max_e = None
for c in itertools.combinations(an, 2):
    v = comb(swap(c))
    if v > max_v:
        max_v = v
        max_e = swap(c)
    #print(c, comb(*c))

print(max_e)


### FIXED CODE ###

import math
import itertools

def swap(a,b):
    return max(a,b),min(a,b)

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

_ = input()
an = list(map(int,input().split()))
#an = [5,10,12]
an.sort()
target = an[-1]/2
res = min(enumerate(an), key=lambda x: abs(target - x[1]))
print(an[-1], res[1])
print(8 - (X // 200 - 2))

### FIXED CODE ###

print(8 - (int(input()) // 200 - 2))
N, Y = map(int, input().split())
for x in range(N+1):
	for y in range(N+1-x):
		for z in range(N+1-x-y):
   			if (Y==10000*x+5000*y+1000*z):
    			print(x,y,z)
    			exit()
print(-1,-1,-1)

### FIXED CODE ###

N, Y = map(int, input().split())
 
for x in range(N+1):
  for y in range(N-x+1):
    z = N - x - y
    if 10000 * x + 5000 * y + 1000 * z == Y:
      print(x,y,z)
      exit()
print(-1,-1,-1)
import math

n = int(input())
a = [int(x) for x in input().split(" ")]
a.sort()
g = a[n - 1]

for i in range(1, n):
    g = math.gcd(g, a[i])

print(g)


### FIXED CODE ###

def gcd(a, b):
    while b != a:
        if a < b:
            b = b % a
            if b == 0:
                return a
        elif b < a:
            a = a % b
            if a == 0:
                return b
    return a

def m(a):
    a.sort()
    l = len(a)
    b = []
    for i in range(l // 2):
        b.append(gcd(a[i], a[l - i - 1]))
    if l % 2 == 1:
        b.append(a[l // 2])
    return list(set(b))

    
n = int(input())
a = [int(x) for x in input().split(" ")]

while len(a) > 1:
    a = m(a)

print(a[0])
B, K = map(int, input().split())
if K >= A:
  print(0, max(0, B-K+A))
else:
  print(A-K, B)

### FIXED CODE ###

def resolve():
    A, B, K = map(int, input().split())
    if K >= A:
        print(0, max(0, B - K + A))
    else:
        print(A - K, B)

resolve()
A = [list(map(int, input().split())) for _ in range(3)]
n = input()
B = list(map(int, input().split()))
ans = False

bingolist = []
for i in range(3):
  bingolist.append([A[i][0], A[i][1], A[i][2]])
  bingolist.append([A[0][i], A[1][i], A[2][i]])

bingolist.append([A[0][0], A[1][1], A[2][2]])
bingolist.append([A[2][0], A[1][1], A[0][2]])

for i in bingolist:
  ans = True if (i[0] in B and i[1] in B and i[2] in B)
  
print(ans)

### FIXED CODE ###

A = [list(map(int, input().split())) for _ in range(3)]
n = int(input())
B = [int(input()) for _ in range(n)]
ans = False

bingolist = []
for i in range(3):
  bingolist.append([A[i][0], A[i][1], A[i][2]])
  bingolist.append([A[0][i], A[1][i], A[2][i]])

bingolist.append([A[0][0], A[1][1], A[2][2]])
bingolist.append([A[2][0], A[1][1], A[0][2]])

for i in bingolist:
  if i[0] in B and i[1] in B and i[2] in B: ans = True
  
print("Yes" if ans else "No")
N = int(input())
Edges = list([] for _ in range(N))
for n in range (N-1):
    x, y = map(int, input().split())
    Edges[x-1].append(y-1)
    Edges[y-1].append(x-1)

def dfs(cur_node, parent_node):
    grundy = 0
    for child_node in Edges[cur_node]:
        if child_node == parent_node:
            continue
        else:
            grundy ^= (dfs(child_node, cur_node) + 1)
    return grundy

G = dfs(0, -1)
if G == 0:
    print("Bob")
else:
    print("Alice")

### FIXED CODE ###

import sys
sys.setrecursionlimit(pow(10,6))

N = int(input())
Edges = list([] for _ in range(N))
for n in range (N-1):
    x, y = map(int, input().split())
    Edges[x-1].append(y-1)
    Edges[y-1].append(x-1)

def dfs(cur_node, parent_node):
    grundy = 0
    for child_node in Edges[cur_node]:
        if child_node == parent_node:
            continue
        else:
            grundy ^= (dfs(child_node, cur_node) + 1)
    return grundy

G = dfs(0, -1)
if G == 0:
    print("Bob")
else:
    print("Alice")
d=int(input())
c=map(int,input().split())
d=[0]*26
for i in range(365):
  s=map(int,input().split())
  m=-1<<64
  for j in range(26):
    alt=s[j]+c[j](i+1-d[j])+sum([-c[k]*(i+1-d[k]) for k in range(26)])
    if alt>m:
      m=alt
      t=j
  print(j+1)
  d[j]=i+1


### FIXED CODE ###

for i in range(365):print((19-i)%26+1)
cnt = 0
n = int(input())
for i int rangr(1, n + 1):
  p = map(int, input().split()
  if int(i) != p :
    cnt += 1
    if cnt >= 2:
      break
if cnt <= 1 :
  print("YES")
else :
   print("NO)

### FIXED CODE ###

cnt = 0
n = int(input())
p = list(map(int, input().split()))
for i in range(1, n + 1):
  if int(i) != p[i - 1] :
    cnt += 1
    if cnt >= 3:
      break
if cnt <= 2 :
  print("YES")
else :
   print("NO")
import math

a, b, x = map(int, input().split())

def calc_theta(a, b, x):
    if x > 0.5 * a ** 2 * b:
        tmp = (a ** 3) / (2 * (a **2 * b - x))
    else:
        tmp = (2 * x) / (a ** 2 * b)
    return 90 - math.degrees(math.atan(tmp))

ans = calc_theta(a, b, x)

print(ans)






### FIXED CODE ###

import math

a, b, x = map(int, input().split())

def calc_theta(a, b, x):
    if x >= 0.5 * a ** 2 * b:
        # tmp = (a ** 3) / (2 * ((a **2) * b - x)) これだと 0divになる
        tmp = (2/a)*(b-(x/a**2))
    else:
        tmp = (a * b * b) / (2 * x)
    return math.degrees(math.atan(tmp))

ans = calc_theta(a, b, x)

print('{:.10f}'.format(ans))
#include <bits/stdc++.h>
using namespace std;

int main()
{
  int N;
  cin >> N;
  vector<long long> a(N);
  for (int i = 0; i < N; ++i)
    cin >> a[i];
  long long res = 0, cur_sum = 0;
  for (int i = 0; i < N;)
  {
    int j = i;
    while (j < N && a[j])
      cur_sum += a[j++];
    res += cur_sum / 2;
    cur_sum = 0;
    i = j + 1;
  }
  cout << res << endl;
}

### FIXED CODE ###

n = int(input())
a = [int(input()) for _ in range(n)]
ans = 0
cur_sum = 0  # 0が入るまでのsum
for i in range(n):
    if a[i] == 0:
        ans += cur_sum // 2
        cur_sum = 0
    else:
        cur_sum += a[i]
ans += cur_sum // 2
print(ans)
import sys
import collections
tmp=sys.stdin.readline()
def main():
   cnt=[0]*2019
   cnt[0]+=1
   for i in reversed(range(len(tmp))):
      cnt[int(tmp[i:])%2019] += 1
   cnt=collections.Counter(cnt).items()
   ans=0
   for i,j in cnt:
      if i > 1:
         ans+=i*(i-1)//2*j
   print(ans)

if __name__ == "__main__":
    main()

### FIXED CODE ###

import sys
tmp=sys.stdin.readline().rstrip()
def main():
   ans=0
   cnt=[0]*2019
   cnt[0]+=1
   t=0
   d=1
   for i in reversed(tmp):
      t=(t+int(i)*d)%2019
      cnt[t]+=1
      d=d*10%2019
   for i in cnt:
      ans+=i*(i-1)//2
   print(ans)
if __name__ == "__main__":
    main()
n,a,b=map(int,input().split())
if a==0:
  print('0')
elif (a+b)*(10**100 )<=n:
  print(a*(10**100))
    
else:
  amari=n%(a+b)
  cnt=int(n/(a+b))
if amari<=a:
  print(cnt*a+amari)
else:
  print(cnt*(a+1))

### FIXED CODE ###

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