Harryxun/stf_run huggingface dataset:
a=input()
if a[0]=="1":
  a[0]="9":
else:
  a[0]=="1"
if a[1]=="1":
  a[1]="9"
else:
  a[1]="1"
if a[2]=="1":
  a[2]="9"
else:
  a[2]="1"
print(a)

### FIXED CODE ###

a=input()
print(a.replace("1","8").replace("9","1").replace("8","9"))
from collections import Counter
n = int(input())
A = Counter(input())
B = Counter(input())
C = Counter(input())
D = A & B
E = D & C
print("".join(sorted(E.elements())))

### FIXED CODE ###

from collections import Counter
n=int(input())
s=Counter(input())
for i in range(n-1):
    s&=Counter(input())
print("".join(sorted(s.elements())))
n,m = map(int,input().split())

par = [[] for i in range(n)]
op = [[]for i in range(n)]
for i in range(n+m-1):
    x,y = map(int,input().split())
    x-=1
    y-=1
    par[y].append(x)
    op[x].append(y)

res = [-1]*n
x = -1

for i in range(n):
    if len(par[i])<=0:
        res[i] = 0
        x = i
        break


used = [0]*n
used[x]=1

def g(y):
    for pe in par[y]:
        if used[pe]==0:
            return False
    return True
    
#xの下のusedとresを埋める
def f(z):
    for e in op[z]:
        if used[e]==0 and g(e):
            used[e]=1
            res[e]=z+1
            f(e)
f(x)
for i in range(n):
    print(res[i])

### FIXED CODE ###

from collections import deque

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

up = [[] for i in range(n)]
down= [[]for i in range(n)]
for i in range(n+m-1):
    a,b = map(int,input().split())
    a -=1
    b -=1
    up[b].append(a)
    down[a].append(b)

res = [-1]*n
root = -1

for i in range(n):
    if len(up[i])==0:
        res[i] = 0
        root = i
        break

#0なら不使用
used = [0]*n
used[root]=1

#yの親に不使用が一つも存在しなければTrue
def g(y):
    for pe in up[y]:
        if used[pe]==0:
            return False
    return True
    
#zの下のusedとresを埋める
def f(z):
    for e in down[z]:
        if used[e]==0 and g(e):
            res[e]=z+1
            tank2.append(e)
            usedtank.append(e)
c = 1
tank = deque([root])
tank2 = deque([root])
usedtank = []
while c != n:
    tank = tank2
    tank2 = deque([])
    usedtank = []
    while len(tank)!=0:
        f(tank.popleft())
    for usede in usedtank:
        used[usede]=1
    c += len(tank2)
    
for i in range(n):
    print(res[i])
a, b, c = input().split()

if c - a - b > 0:
    if 4 * a * b < (c - a - b) ** 2:
        print("Yes")
    else:
        print("No")
else:
    print("No")


### FIXED CODE ###

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

if c - a - b > 0:
    if 4 * a * b < (c - a - b) ** 2:
        print("Yes")
    else:
        print("No")
else:
    print("No")
a,b,c=map(int,input().split())
if a==b==c:
    if a%2===b%2==c%2==0:
        print(-1)
    else:
        print(0)
    exit()
cnt=0
while a%2==b%2==c%2:
    A=a//2
    B=b//2
    C=c//2
    a,b,c=B+C,A+C,A+B
    cnt+=1
print(cnt)

### FIXED CODE ###

a,b,c=map(int,input().split())
if a==b==c:
    if a%2==b%2==c%2==0:
        print(-1)
    else:
        print(0)
    exit()
cnt=0
while a%2==b%2==c%2:
    A=a//2
    B=b//2
    C=c//2
    a,b,c=B+C,A+C,A+B
    cnt+=1
print(cnt)
N, T = map(int, input().split())
ans = 1000000
for i in range(N):
    c, t = map(int, input().split())
    if t <= T:
    ans = min(ans, c)
print(ans if ans < T else "TLE")


### FIXED CODE ###

N, T = map(int, input().split())
ans = 1000000
for i in range(N):
    c, t = map(int, input().split())
    if t <= T:
        ans = min(ans, c)
print("TLE" if ans == 1000000 else ans)
from collections import deque
import sys

def fnw(n,s):
    sm=deque([])
    if n<=len(s):
        for _ in range(n):
            sm.append(s.popleft())
    return ''.join(sm)

def jfws(s):
    fws=fnw(5,s)
    if fws=='dream':
        fws=fnw(2,s)
        if fws=='er':
            if s[0]=='a':
                s.extendleft(deque(reversed(list(fws))))
        else:
            s.extendleft(deque(reversed(list(fws))))
        return False
    elif fws=='erase':
        fws=fnw(1,s)
        if fws!='r':
            s.appendleft(fws)
        return False
    else:
        return True 

def main(s):
    while True:
        if not list(s):
            return 'Yes"
        if jfws(s):
            return 'NO'
    return 'Yes'

s=deque(sys.stdin.readline().strip())
print(main(s))



### FIXED CODE ###

from collections import deque
import sys

def fnw(n,s):
    sm=deque([])
    if n<=len(s):
        for _ in range(n):
            sm.append(s.popleft())
    return sm

def jfws(s):
    # print(s)
    sm=fnw(5,s)
    # print(sm)
    if ''.join(sm)=='dream':
        sm=fnw(2,s)
        if ''.join(sm)=='er':
            if bool(s):
                if s[0]=='a':
                    s.extendleft(deque(reversed(list(sm))))
        else:
            s.extendleft(deque(reversed(list(sm))))
        return False
    elif ''.join(sm)=='erase':
        sm=fnw(1,s)
        if ''.join(sm)!='r':
            s.extendleft(sm)
        return False
    else:
        return True 

def main(s):
    while len(s)>0:
        if jfws(s):
            return 'NO'
    return 'YES'

s=deque(sys.stdin.readline().strip())
print(main(s))
import bisect

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

#処理内容
def main():
	N = int(input())
	A = getlist()
	B = [0]
	for i in range(N):
		B.append(B[-1] + A[i])
	#print(B)
	ans = float("inf")
	for i in range(2, N - 2):
		Q = B[i]
		x = bisect.bisect_left(B, Q // 2)
		P = max(B[x], B[1])
		P2 = max(B[x - 1], B[1])
		Q3 = max(B[i] - B[i - 1], B[i] - B[x + 1])
		P3 = Q - Q3
		Q2 = Q - P2
		Q -= P
		S = B[N] - B[i]
		y = bisect.bisect_left(B, (B[i] + B[N]) // 2)
		R = max(B[y] - B[i] , B[i + 1] - B[i])
		R2 = max(B[y - 1] - B[i] , B[i + 1] - B[i])
		S3 = max(B[N] - B[N - 1], B[N] - B[y + 1])
		R3 = S - S3
		S2 = S - R2
		S -= R
		#print(P, Q, R, S)
		#print(sum([P, Q, R, S]))
		ans = min(ans, max(P, Q, R, S) - min(P, Q, R, S))
		ans = min(ans, max(P2, Q2, R2, S2) - min(P2, Q2, R2, S2))
		ans = min(ans, max(P3, Q3, R3, S3) - min(P3, Q3, R3, S3))
	print(ans)


if __name__ == '__main__':
	main()

### FIXED CODE ###

import bisect

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

#処理内容
def main():
	N = int(input())
	A = getlist()
	B = [0]
	for i in range(N):
		B.append(B[-1] + A[i])
	#print(B)
	ans = float("inf")
	for i in range(2, N - 1):
		Q = B[i]
		x = bisect.bisect_left(B, Q // 2)
		P = max(B[x], B[1])
		P = min(P, B[i - 1])
		if x >= 1:
			P2 = max(B[x - 1], B[1])
			Q2 = Q - P2
		Q3 = max(B[i] - B[i - 1], B[i] - B[x + 1])
		P3 = Q - Q3
		Q -= P

		S = B[N] - B[i]
		y = bisect.bisect_left(B, (B[i] + B[N]) // 2)
		R = max(B[y] - B[i] , B[i + 1] - B[i])
		R = min(R, B[N - 1] - B[i])
		R2 = max(B[y - 1] - B[i] , B[i + 1] - B[i])
		S2 = S - R2
		if y < N:
			S3 = max(B[N] - B[N - 1], B[N] - B[y + 1])
			R3 = S - S3
		S -= R
		ans = min(ans, max(P, Q, R, S) - min(P, Q, R, S))
		ans = min(ans, max(P3, Q3, R, S) - min(P3, Q3, R, S))
		ans = min(ans, max(P, Q, R2, S2) - min(P, Q, R2, S2))
		ans = min(ans, max(P3, Q3, R2, S2) - min(P3, Q3, R2, S2))
		if x >= 1:
			ans = min(ans, max(P2, Q2, R, S) - min(P2, Q2, R, S))
			ans = min(ans, max(P2, Q2, R2, S2) - min(P2, Q2, R2, S2))
		if y < N:
			ans = min(ans, max(P, Q, R3, S3) - min(P, Q, R3, S3))
			ans = min(ans, max(P3, Q3, R3, S3) - min(P3, Q3, R3, S3))
		if x >= 1 and y < N:
			ans = min(ans, max(P2, Q2, R3, S3) - min(P2, Q2, R3, S3))
	print(ans)

if __name__ == '__main__':
	main()
a,b = map(int,input().split())
 
print(max(int(A+B,A-B,A*B)))

### FIXED CODE ###

a,b = map(int,input().split())
 
print(max(int(a+b),int(a-b),int(a*b)))
N = int(input())
S = list(input().split())
 
ans = 1
for i in range(N - 1):
    if S[i] != S[i + 1]:
        ans = ans + 1
print(ans)

### FIXED CODE ###

A, B = map(int, input().split())
if A - 2 * B < 0 or A-2*B == 0:
    print(0)
else:
    print(A - 2 * B)
import math
from collections import deque


def main():
    s = list(input())
    k = int(input())
    lst = []
    cnt = 1
    flg = 0
    ans = 0

    for i in range(len(s)-1):
        if s[i + 1] == s[i]:
            cnt += 1
        else:
            lst.append(cnt)
            cnt = 1
            flg = 1
    if flg == 0:
        print(s * k // 2)
        return
    ans += sum(map(lambda x: x // 2, lst[1:len(lst)-1]))*k
    if s[-1] == s[0]:
        ans += (lst[0] + lst[-1]) // 2 * (k - 1)
        ans += lst[0] // 2 + lst[-1] // 2
    else:
        ans += (lst[0] // 2 + lst[-1] // 2) * k
    print(ans)


if __name__ == "__main__":
    main()


### FIXED CODE ###



def main():
    s = list(input())
    k = int(input())
    lst = []
    cnt = 1
    flg = 0
    ans = 0
    prev = s[0]
    for i in range(1, len(s)):
        if prev == s[i]:
            cnt += 1
        else:
            lst.append(cnt)
            cnt = 1
            prev = s[i]
            flg = 1
    lst.append(cnt)
    if len(lst) == 1:
        ans = len(s) * k // 2
    else:
        ans += sum(list(map(lambda x: x // 2, lst[1:len(lst)-1]))) * k
        # for l in lst[1: len(lst) - 1]:
        #     ans += l // 2 * k
        if s[-1] == s[0]:
            ans += (lst[0] + lst[-1]) // 2 * (k - 1)
            ans += lst[0] // 2 + lst[-1] // 2
        else:
            ans += (lst[0] // 2 + lst[-1] // 2) * k
    print(ans)


if __name__ == "__main__":
    main()
N, M = map(int, input().split())
P = [0] * N

wa = 0
for _ in range(M):
  p, s = input().split()
  index = int(p)-1
  if s == 'AC':
    wa += P[index]
    P[index] = -1
  elif :
    if P[index] != -1
      P[index] += 1
  
print(P.count(-1), wa)

### FIXED CODE ###

N, M = map(int, input().split())
P = [0] * N

wa = 0
for _ in range(M):
  p, s = input().split()
  index = int(p)-1
  if s == 'WA' and P[index] != -1:
      P[index] += 1
  elif P[index] > -1:
    wa += P[index]
    P[index] = -1
  
print(P.count(-1), wa)
def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()
 
def solve(n):
	#n = readInt()
	i = 1
	maxk = 26
	while 1:
		if n<=maxk:
			ke = i
			break
		else:
			i+=1
			maxk =maxk + 26**i
	#print(ke)
	#ke 桁数
	tar = n
	l= []
	while 1:
		if tar<=26:
			l.append(tar)
			break
		else:
			t = tar%(26**(i-1))
			#t = tar//(26**(i-1))
			t = (tar-t)//(26**(i-1))
			t = min(t,26)
			if t==0:
				l[-1]-=1
				t=26
			l.append(t)
			tar = tar - t*(26**(i-1))
			i-=1
 
	print("".join([chr(96+i) for i in l]))
 
solve(924093)
#for i in range(1,1000000,26**2):
#	print(i)
#	solve(i)

### FIXED CODE ###

def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()
 
def solve(n):
	#n = readInt()
	i = 1
	maxk = 26
	while 1:
		if n<=maxk:
			ke = i
			break
		else:
			i+=1
			maxk =maxk + 26**i
	#print(ke)
	#ke 桁数
	tar = n
	l= []
	while 1:
		a = tar//26
		b = tar%26
		if b==0:
			a-=1
			b = 26
		l.append(chr(ord("a")-1+b))
		tar = a
		if tar==0:
			break
 
	print("".join(l[::-1]))
 
solve(readInt())
#for i in range(1,1000000,26**2):
#	print(i)
#	solve(i)
import math
N,K = map(int,input().split())


print(sum([(1/N)*(0.5)**math.ceil(math.log2(math.ceil(K/i))) if i<K else 1/N for i in range(1,N+1)])

### FIXED CODE ###

import math
N,K = map(int,input().split())


print('{:.12f}'.format(sum([(1/N)*(0.5)**math.ceil(math.log2(math.ceil(K/i))) if i<K else 1/N for i in range(1,N+1)])))
a = int(input())
print(int(k/2) * int((k+1)/ 2))


### FIXED CODE ###

a = int(input())
print(int(a/2) * int((a+1)/ 2))
import math
print(ceil(int(input()) / 2))

### FIXED CODE ###

x = int(input())
div, mod = divmod(x, 2)
if mod:
  div += 1
print(div)
import fractions
import numpy as np
import math

N, M = map(int, input().split())
a = np.array(list(map(int, input().split()))) / 2

def lcm(a, b):
    return a * b / fractions.gcd(a, b)
    
def check_two(num):
    count = 0
    while num % 2 == 0:
        num /= 2
        count += 1
    return count

two_nums = [check_two(i) for i in a]
if len(set(two_nums)) > 1:
    print(0)
    exit()

my_lcm = lcm(a[0], a[1])
for i in range(2, len(a)):
    my_lcm = lcm(my_lcm, a[i])
    if my_lcm > N:
        print(0)
        exit()
    
ans = M // my_lcm
print(math.ceil(ans / 2))

### FIXED CODE ###

import fractions
import math
 
N, M = map(int, input().split())
a = list(map(int, input().split()))
a = [i // 2 for i in a]
 
def lcm(a, b):
    return a * b // fractions.gcd(a, b)
    
def check_two(num):
    count = 0
    while num % 2 == 0:
        num //= 2
        count += 1
    return count

two_num = check_two(a[0])

for i in range(1, len(a)):
    if two_num != check_two(a[i]):
        print(0)
        exit()
 
my_lcm = a[0]
for i in range(1, len(a)):
    my_lcm = lcm(my_lcm, a[i])
    if my_lcm > M:
        print(0)
        exit()
    
ans = M // my_lcm
print(math.ceil(ans / 2))
N,K=map(int,input().split())
if(N%K==0):
  print(0)
 else:
  print(1)

### FIXED CODE ###

N,K=map(int,input().split())
if(N%K==0):
  print(0)
else:
  print(1)
N, M, K = map(int, input().split())

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

books = 0

p1 = 0
p2 = 0

while K > 0 and ( p1 < N or p2 < M ):
    books += 1

    if p1 < N and A[p1] < B[p2]:
        # print("chosen", "p1", p1)
        K -= A[p1]
        p1 += 1

    elif p2 < M:
        # print("chosen", "p2", p2)
        K -= B[p2]
        p2 += 1

    # print(K, p1, p2)

if K < 0:
    books -= 1
print(books)

### FIXED CODE ###

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

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

A.insert(0, 0)
B.insert(0,0)

# convert to the cumulative/prefix sum
for i in range(1, len(A)):
    A[i] += A[i-1]

for i in range(1, len(B)):
    B[i] += B[i-1]

# print(A)
# print(B)

books_stack_a = 0

books_stack_b = M

cur_max = 0

for books_stack_a in range(0, N + 1):
    if A[books_stack_a] > K:
        break
    diff = K - A[books_stack_a]
    while diff < B[books_stack_b]:
        books_stack_b -= 1

    cur_max = max(cur_max, books_stack_b + books_stack_a)

print(cur_max)
#! /usr/bin/env python3

import sys
import numpy as np
int1 = lambda x: int(x) - 1
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)
MOD = pow(10, 9) + 7

N, K, *A = map(int, read().split())

if K == N:
    ans = 1
    for a in A:
        ans *= a
        ans %= MOD
    print(ans)
    sys.exit()

A_pos = [a for a in A if a >= 0]
A_neg = [a for a in A if a < 0]

if len(A_pos) == 0:
    if K % 2 == 1:
        A = sorted(A, key=lambda x: abs(x))
    else:
        A = sorted(A, key=lambda x: -abs(x))
    ans = 1
    for a in A_neg[:K]:
        ans *= a
        ans %= MOD
    print(ans)
    sys.exit()

A_pos = sorted(A_pos, key=lambda x: -abs(x))
A_neg = sorted(A_neg, key=lambda x: -abs(x))
ans = 1
r = K
if r % 2 == 1:
    ans *= A_pos[0]
    ans %= MOD
    A_pos = A_pos[1:]
    r -= 1

while r > 0:
    if len(A_pos) <= 1:
        ans *= A_neg[0] * A_neg[1]
        ans %= MOD
    elif len(A_neg) <= 1:
        ans *= A_pos[0] * A_pos[1]
        ans %= MOD
    else:
        acc_pos = A_pos[0] * A_pos[1]
        acc_neg = A_neg[0] * A_neg[1]

    if acc_pos > acc_neg:
        ans *= acc_pos
        ans %= MOD
    else:
        ans *= acc_neg
        ans %= MOD
    r -= 2
print(ans % MOD)


### FIXED CODE ###

#! /usr/bin/env python3

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)
MOD = pow(10, 9) + 7

N, K, *A = map(int, read().split())

if K == N:
    ans = 1
    for a in A:
        ans = ans * a % MOD
    print(ans)
    sys.exit()

A_pos = [a for a in A if a >= 0]
A_neg = [a for a in A if a < 0]

if len(A_pos) == 0:
    if K % 2 == 1:
        A_neg.sort(reverse=True)
    else:
        A_neg.sort()
    ans = 1
    for a in A_neg[:K]:
        ans = ans * a % MOD
    print(ans)
    sys.exit()

A_pos.sort()
A_neg.sort(reverse=True)
ans = 1
r = K
if r % 2 == 1:
    ans = ans * A_pos.pop() % MOD
    r -= 1

while r > 0:
    if len(A_pos) <= 1:
        ans = ans * A_neg.pop() * A_neg.pop() % MOD
    elif len(A_neg) <= 1:
        ans = ans * A_pos.pop() * A_pos.pop() % MOD

    else:
        acc_pos = A_pos[-1] * A_pos[-2]
        acc_neg = A_neg[-1] * A_neg[-2]

        if acc_pos > acc_neg:
            ans = ans * A_pos.pop() * A_pos.pop() % MOD
        else:
            ans = ans * A_neg.pop() * A_neg.pop() % MOD
    r -= 2
print(ans % MOD)
n=int(input())
d=list(map(int,input().split()))
ans=1
a=1
b=1
d=sorted(d)
if d[0]!=0 or d[1]==0:
    ans=0
else:
    if d[-1]==d[-2]:
        for i in range(1,n-1):
            if d[i]==d[i+1]:
                a+=1
            else:
                ans=ans*(b**a)
                b=a
                a=1
    else:
        for j in range(1,n-1):
            if d[i]==d[i+1]:
                a+=1
            else:
                ans=ans*(b**a)
                b=a
                a=1
            ans=ans*b
ans=ans%998244353
print(ans)
      

### FIXED CODE ###

n=int(input())
d=list(map(int,input().split()))
ans=1
a=1
b=1
if n==1 or d[0]!=0:
    ans=0
d=sorted(d)
for j in range(0,n-1):
        if d[j+1]-d[j]>1:
            ans=0
            break
        
if d[0]!=0 or d[1]==0:
    ans=0
else:
    for i in range(1,n-1):
        if d[i]==d[i+1]:
            a+=1
        else:
            ans=ans*(b**a)
            b=a
            a=1
ans=ans*(b**a)
ans=ans%998244353
print(ans)
n, q = map(int, input().split())
edges = [[] for i in range(n)]
counter = [0] * n
for i in range(n - 1):
    a, b = map(int, input().split())
    edges[a - 1].append(b - 1)
    edges[b - 1].append(a - 1)
for i in range(q):
    p, x = map(int, input().split())
    counter[p - 1] += x
def dfs(now, prev):
    for next in edges[now]:
        if next == prev:
            continue
        counter[next] += counter[now]
        dfs(next, now)
dfs(0, -1)
print(*counter)

### FIXED CODE ###

import sys
sys.setrecursionlimit(10 ** 6)
n, q = map(int, input().split())
edges = [[] for i in range(n)]
counter = [0] * n
for i in range(n - 1):
    a, b = map(int, input().split())
    edges[a - 1].append(b - 1)
    edges[b - 1].append(a - 1)
for i in range(q):
    p, x = map(int, input().split())
    counter[p - 1] += x
def dfs(now, prev):
    for next in edges[now]:
        if next == prev:
            continue
        counter[next] += counter[now]
        dfs(next, now)
dfs(0, -1)
print(*counter)
N, M = map(int, input().split())
A = list(map(int, input().split()))
BC = {}
result_m = 0
for m in range(M):
  B, C = map(int, input().split())
  if BC.get(C) != None:
    BC[C] += B
  else:
    BC[C] = B
A.sort()
BC = sorted(BC.items(), reverse=True)
count = 0
for m in range(len(BC)):
  if A[count]>BC[m][0]:
    break
  for i in range(BC[m][1]):
    if BC[m][0] > A[count]:
      A[count] = BC[m][0]
      count+=1
print(sum(A))

### FIXED CODE ###

N, M = map(int, input().split())
A = list(map(int, input().split()))
BC = {}
result_m = 0
for m in range(M):
  B, C = map(int, input().split())
  if BC.get(C) != None:
    BC[C] += B
  else:
    BC[C] = B
A.sort()
BC = sorted(BC.items(), reverse=True)
count = 0
for m in range(len(BC)):
  if count>=len(A):
    break
  if A[count]>BC[m][0]:
    break
  for i in range(BC[m][1]):
    if count>=len(A):
      break
    if BC[m][0] > A[count]:
      A[count] = BC[m][0]
      count+=1
print(sum(A))
n, k = map(int, raw_input().split())
d = map(int, raw_input().split())
def use_d(n):
    for i in list(str(n)):
        if int(i) in d:
            return True
    else:
        return False
while n < 100000:
    if use_d(n):
        n += 1
    else:
        print n
        sys.exit()

### FIXED CODE ###

import itertools,math,bisect,pprint,sys

n, k = map(int, raw_input().split())
d = map(int, raw_input().split())
def use_d(n):
    for i in list(str(n)):
        if int(i) in d:
            return True
    else:
        return False
while n < 100000:
    if use_d(n):
        n += 1
    else:
        print n
        sys.exit()
N = int(input())
S = list(input())
 
ansAC = 0
ansWA = 0
ansTLE = 0
ansRE = 0
 
for i in S:
  if i == "AC":
    ansAC += 1
  elif i == "TLE":
    ansTLE += 1
  elif i == "WA":
    ansWA += 1
  elif i == "RE":
    ansRE += 1
print("AC x " + ansAC)
print("WA x " + ansWA)
print("TLE x " + ansTLE)
print("RE x " + ansRE)

### FIXED CODE ###

N = int(input())
ansAC = 0
ansWA = 0
ansTLE = 0
ansRE = 0
 
for i in range(N):
  S = input()
  if S == "AC":
    ansAC += 1
  elif S == "TLE":
    ansTLE += 1
  elif S == "WA":
    ansWA += 1
  elif S == "RE":
    ansRE += 1
print("AC x " + str(ansAC))
print("WA x " + str(ansWA))
print("TLE x " + str(ansTLE))
print("RE x " + str(ansRE))
# 09-Computation-Min_Max_and_Sum.py

# ????°????????????§??????????¨????
# n ????????´??° ai(i=1,2,...n)?????\?????????????????????????°????????????§??????????¨????????±???????????????°????????????????????????????????????

# Input
# ??????????????´??°?????° n ???????????????????????????????????? n ????????´??° ai ????????????????????§?????????????????????
# Output
# ????°????????????§??????????¨????????????????????????§????????????????????????????????????

# Constraints
# 0<n???10000
# ???1000000???ai???1000000
# Sample Input
# 5
# 10 1 5 4 17
# Sample Output
# 1 17 37

num = int(input())
num_min = 1000001
num_max = -1000001
num_sum = 0

a = []
a=[ *map(int,input().split() ) ]

for i in range(num):
	if a[i]<num_min:
		num_min = a[i]

	if a[i]>num_max:
		num_max = a[i]

	num_sum+=a[i]

print("{0} {1} {2}".format(num_min,num_max,num_sum) );

### FIXED CODE ###

# 09-Computation-Min_Max_and_Sum.py

# ????°????????????§??????????¨????
# n ????????´??° ai(i=1,2,...n)?????\?????????????????????????°????????????§??????????¨????????±???????????????°????????????????????????????????????

# Input
# ??????????????´??°?????° n ???????????????????????????????????? n ????????´??° ai ????????????????????§?????????????????????
# Output
# ????°????????????§??????????¨????????????????????????§????????????????????????????????????

# Constraints
# 0<n???10000
# ???1000000???ai???1000000
# Sample Input
# 5
# 10 1 5 4 17
# Sample Output
# 1 17 37

num_min = 1000001
num_max = -1000001
num_sum = 0
num = int(input())

# a = []
# a = [ *map(int,input().split() ) ]
a = input().split()

for i in range(num):
	a[i]=int(a[i])
	if a[i]<num_min:
		num_min = a[i]

	if a[i]>num_max:
		num_max = a[i]

	num_sum+=a[i]

print("{0} {1} {2}".format(num_min,num_max,num_sum) );
n,a,b = map(int, input().split())

s = 'b'*a+'r'*b
x = n//(a+b) 
y = n%(a+b) 

print(x*a+s[:y].count('b'))

### FIXED CODE ###

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

ans = n//(a+b)*a 
x = n%(a+b) 

if x<=a:
  ans += x
else:
  ans += a

print(ans)