Harryxun/stf_run huggingface dataset:
10 13 15
3
1
4
1
5
9
2
6
5
3
5
8
9
7
9

### FIXED CODE ###

#!/usr/bin/env python3
a,b,c=map(int,input().split())
d=[b]*a
for i in[int(input())-1for _ in range(0,c)]:d[i]+=1
for i in d:print("Yes")if i-c>0 else print("No")
a, b = map(int, input().split())
prinr(a*b)

### FIXED CODE ###

a, b = map(int, input().split())
print(a*b)
print('ATCG'['TAGC'.index()])

### FIXED CODE ###

print('ATCG'['TAGC'.index(input())])
N, M = map(int, input().split())

inputs = [[i for i in input().split()] for _ in range(N)]

ans = set(inputs[0])
for item in inputs:
    ans &= set(inputs[1:])

print(len(ans))


### FIXED CODE ###

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

inputs = [[i for i in input().split()] for _ in range(N)]

ans = set(inputs[0])
for item in range(N):
    ans = ans & set(inputs[item][1:])

print(len(ans))
from sys import exit
from collections import defaultdict
n,x = open(0).read().split()
n = int(n)
cnt = x.count('1') 
digits = list(map(int, list(x)))
x = int(x, 2)

d = defaultdict(int)
d[0] = 0
def calc(m):
    if m not in d:
        nxt = m % bin(m).count('1')
        d[m] = calc(nxt) + 1
    return d[m]

if n == 1:
    print(calc(x^1))
    exit()

mmod = cnt - 1
pmod = cnt + 1

if mmod > 0:
    mx = x % mmod
px = x % pmod

mbase = 1
pbase = 1

ans = []
while digits:
    digit = digits.pop()
    if digit:
        ans.append(calc((mx - mbase)%mmod) + 1)
    else:
        ans.append(calc((px + pbase)%pmod) + 1)
    if mmod > 0:
        mbase = (mbase * 2) % mmod
    pbase = (pbase * 2) % pmod

while ans:
    print(ans.pop())

### FIXED CODE ###

from sys import exit
from collections import defaultdict
n,x = open(0).read().split()
n = int(n)
cnt = x.count('1') 
digits = list(map(int, list(x)))
x = int(x, 2)

d = defaultdict(int)
d[0] = 0
def calc(m):
    if m not in d:
        nxt = m % bin(m).count('1')
        d[m] = calc(nxt) + 1
    return d[m]

if n == 1:
    print(calc(x^1))
    exit()

mmod = cnt - 1
pmod = cnt + 1

if mmod > 0:
    mx = x % mmod
px = x % pmod

mbase = 1
pbase = 1

ans = []
while digits:
    digit = digits.pop()
    
    if digit and mmod <= 0:
        ans.append(0)
    else:
        if digit:
            nx = (mx - mbase)%mmod
        else:
            nx = (px + pbase)%pmod
        ans.append(calc(nx) + 1)

    if mmod > 0:
        mbase = (mbase * 2) % mmod
    pbase = (pbase * 2) % pmod

while ans:
    print(ans.pop())
N, K = map(int,input().split()) # 複数の数字を変数に格納

from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under
  
red = N - K
blue = K
division = 10 ** 9 + 7

for i in range(K):
    if i > red:
        print("0")
    else:
        tmp_blue = cmb(blue-1,i)
        tmp_red = 1
        for j in range(i+1):
            tmp_red = tmp_red * (red+1-j) / (j+1) 
        result = int(tmp_blue * tmp_red % division)
        print("{}".format(result))


### FIXED CODE ###

N, K = map(int,input().split()) # 複数の数字を変数に格納

red = N - K
blue = K
division = 10 ** 9 + 7

from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under % division
  
for i in range(K):
    if i > red:
        print("0")
    else:
        tmp_blue = cmb(blue-1,i) % division
        tmp_red = cmb(red+1,red-i)
        result = int(tmp_blue * tmp_red % division)
        print("{}".format(result))
N=int(input())

M=[[0]*10 for _ in range(10)]

for i in range(1,N+1):
  S=str(i)
  M[int(S[0])][int(S[-1])]+=1
  
for i in range(10):
  for j in range(10):
    ans+=M[i][j]*M[j][i]
    
print(ans)

### FIXED CODE ###

N=int(input())

M=[[0]*10 for _ in range(10)]
for i in range(1,N+1):
  S=str(i)
  f=int(S[0])
  b=int(S[-1])
  M[f][b]+=1
  
ans=0
for i in range(10):
  for j in range(10):
    ans+=M[i][j]*M[j][i]
    
print(ans)
#奇数文字目がすべて R, U, D のいずれか。
#偶数文字目がすべて L, U, D のいずれか。

#文字列の入力
S = input()
S_list = []
S_list = list(S)
counter = 0

for i in range(len(S_list)):
  #奇数
  if(i%2 == 0):
    if((S_list[i] == "R")or(S_list[i] == "U")or(S_list[i] == "D")):
      counter = counter + 1
  else:
    if((S_list[i] == "L")or(S_list[i] == "U")or(S_list[i] == "D")):
      counter = counter + 1
      
if(counter = len(S_list)):
  print("Yes")
else:
  print("No")

### FIXED CODE ###

#奇数文字目がすべて R, U, D のいずれか。
#偶数文字目がすべて L, U, D のいずれか。

#文字列の入力
S = input()
S_list = []
S_list = list(S)
counter = 0

for i in range(len(S_list)):
  #奇数
  if(i%2 == 0):
    if((S_list[i] == "R")or(S_list[i] == "U")or(S_list[i] == "D")):
      counter = counter + 1
  else:
    if((S_list[i] == "L")or(S_list[i] == "U")or(S_list[i] == "D")):
      counter = counter + 1
      
if(counter == len(S_list)):
  print("Yes")
else:
  print("No")
#ARC069A

n,m=map(int,raw_input().split())
if n>m*2:
 res=c/2
else:
 res=n+(m-2*n)/4
print res


### FIXED CODE ###

#ARC069A

n,m=map(int,raw_input().split())
if n>m/2:
 res=m/2
else:
 res=n+(m-2*n)/4
print res
a,b = map(int, input().split)
c = a * b
if c % 2 == 0:
	print('Even')
  else:
  	print('Odd')

### FIXED CODE ###

a,b = map(int, input().split())
c = a * b
if c % 2 == 0:
	print('Even')
else:
  	print('Odd')
N = int(input().split())

i = 0
while True:

    if i ** 2 > N:
        print ((i-1)**2)
        break

### FIXED CODE ###


N = int(input())

i = 0
while True:

    if i ** 2 > N:
        print ((i-1)**2)
        break

    i += 1
import sys
from collections import deque
sys.setrecursionlimit(10**8)

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

Kuro = 0
Shiro = 0
for j in range(H):
    for i in range(W):
        if S[j][i]=='.':
            Shiro += 1
Dis =[[0]*W for i in range(H)]
X =[-1, 0, 1, 0]
Y =[0, -1, 0, 1]
q = deque()
q.append((0,0))
while True:
    y,x = q.popleft()
    if (y==H-1) and (x==W-1):
        break
    for i in range(4):
        nx = x + X[i]
        ny = y + Y[i]
        if (0<= nx < W) and(0 <= ny < H) and (S[ny][nx]=='.') and(Dis[ny][nx] ==0):
            q.append((ny,nx))
            Dis[ny][nx] = Dis[y][x] +1

print(Shiro-Dis[H-1][W-1]-1)    

### FIXED CODE ###

import sys
from collections import deque
sys.setrecursionlimit(10**8)

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

Kuro = 0
Shiro = 0
for j in range(H):
    for i in range(W):
        if S[j][i]=='.':
            Shiro += 1
Dis =[[-1]*W for i in range(H)]
X =[-1, 0, 1, 0]
Y =[0, -1, 0, 1]
q = deque()
q.append((0,0))
Dis[0][0] = 0
a=deque()
while (q != a):
    y,x = q.popleft()
    if (y==H-1) and (x==W-1):
        break
    for i in range(4):
        nx = x + X[i]
        ny = y + Y[i]
        if (0<= nx < W) and(0 <= ny < H) and (S[ny][nx]=='.') and (Dis[ny][nx] ==-1):
            q.append((ny,nx))
            Dis[ny][nx] = Dis[y][x] +1

if (Dis[H-1][W-1]==-1):
    print(-1)
else:
    print(Shiro-Dis[H-1][W-1]-1)
from collections import Counter

def main():
    n = int(input())
    a = Counter(map(int, input().split()))
    temp, a = listed(a)
    q = int(input())
    bc = [tuple(map(int, input().split())) for _ in range(q)]
    
    for b, c in bc:
        t = a[b]
        if t == 0:
            print(temp)
            continue
        a[b] = 0
        temp -= b*t
        a[c] += t
        temp += c*t
        print(temp)

def listed(a):
    x = [0] * 10**5
    kei = 0
    for i,v in a.items():
        x[i] = v
        kei += i*v
    return kei, x

if __name__ == '__main__':
    main()

### FIXED CODE ###

from collections import Counter

def main():
    n = int(input())
    a = Counter(map(int, input().split()))
    temp, a = listed(a)
    q = int(input())
    bc = [tuple(map(int, input().split())) for _ in range(q)]
    
    for b, c in bc:
        t = a[b]
        if t == 0:
            print(temp)
            continue
        a[b] = 0
        temp -= b*t
        a[c] += t
        temp += c*t
        print(temp)

def listed(a):
    x = [0] * (10**5 + 1)
    kei = 0
    for i,v in a.items():
        x[i] = v
        kei += i*v
    return kei, x

if __name__ == '__main__':
    main()
inputEnzan=input().split()
stack=[]
while True:
    if "-"in inputEnzan or "+"in inputEnzan or "*"in inputEnzan :
        index=0
        while index <len(inputEnzan):
            if inputEnzan[index]=="-" or inputEnzan[index]=="+" or inputEnzan[index]=="*":
                if stack!=[]:
                    if inputEnzan[index]=="-":
                        inputEnzan[index]=stack[0]-stack[1]
                    elif inputEnzan[index]=="+":
                        inputEnzan[index]=stack[0]+stack[1]
                    else:
                        inputEnzan[index]=stack[0]*stack[1]
                    inputEnzan[index-1]="null"
                    inputEnzan[index-2]="null"
                    stack.clear()
                else:
                    pass
            else:
                stack.append(int(inputEnzan[index]))
                
            index+=1
        while True:
            if not "null" in inputEnzan:
                break
            inputEnzan.remove("null")   
    else:
        print(inputEnzan[0])
        break


### FIXED CODE ###

class stack:
    def __init__(self):
        self.s = []
    def push(self, x):
        self.s.append(x)
    def pop(self):
        ret = self.s[-1]
        del self.s[-1]
        return ret
    def size(self):
        return len(self.s)

inputL = input().split()
s = stack()
for char in inputL:
    if char == '+':
        b = s.pop()
        a = s.pop()
        s.push(a+b)
    elif char == '-':
        b = s.pop()
        a = s.pop()
        s.push(a-b)
    elif char == '*':
        b = s.pop()
        a = s.pop()
        s.push(a*b)
    elif char == '/':
        b = s.pop()
        a = s.pop()
        s.push(a/b)
    else:
        s.push(int(char))
print(s.pop())
import math

"""
def gcd(a,b):
    if a>b:swap(a,b)
    if a==0:return b
    return gcd(b%a,a)
"""

a,b=map(int,input().split())
g=math.gcd(a,b)
#print(g)
ans=1
i=2
while i*i<=g:
    if(g%i==0):
        ans+=1
        g/=i
    i=i+1
if(g!=1):ans+=1
print(ans)

### FIXED CODE ###


import fractions

"""
def gcd(a,b):
    if a>b:swap(a,b)
    if a==0:return b
    return gcd(b%a,a)
"""

a,b=map(int,input().split())
g=fractions.gcd(a,b)
#print(g)
ans=1
i=2
while i*i<=g:
    if(g%i==0):
        ans+=1
        while g%i==0:
            g/=i
    i=i+1
if(g!=1):ans+=1
print(ans)
import math

n, q = map(int, input().split(" "))
abL = [list(map(int, input().split(" "))) for _ in range(n - 1)]
pxL = [list(map(int, input().split(" "))) for _ in range(q)]

to = [[] for _ in range(2 * 10**6)]
ans = [0 for _ in range(n)]


def dfs(v, p=-1):
    for u in to[v]:
        if u == p:
            continue
        ans[u] += ans[v]
        dfs(u, v)


for a, b in abL:
    a -= 1
    b -= 1
    to[a].append(b)
    to[b].append(a)

for p, x in pxL:
    p -= 1
    ans[p] += x

dfs(0)

for a in ans:
    print(a)

### FIXED CODE ###

import math
import sys

sys.setrecursionlimit(200005)

n, q = map(int, input().split(" "))
abL = [list(map(int, input().split(" "))) for _ in range(n - 1)]
pxL = [list(map(int, input().split(" "))) for _ in range(q)]

to = [[] for _ in range(200005)]
ans = [0 for _ in range(n + 1)]


def dfs(v, p=-1):
    for u in to[v]:
        if u == p:
            continue
        ans[u] += ans[v]
        dfs(u, v)


for a, b in abL:
    a -= 1
    b -= 1
    to[a].append(b)
    to[b].append(a)

for p, x in pxL:
    p -= 1
    ans[p] += x

dfs(0)

for a in ans[:n]:
    print(a)
import math
import sys
import collections
import bisect
import sympy
readline = sys.stdin.readline


def main():
    n = int(readline().rstrip())
    s = readline().rstrip()
    cnt = 0
    for i in range(1000):
        x = str(i).zfill(3)
        a = s[:-1].find(x[0])
        if a != -1:
            b = s[a + 1: -1].find(x[1])
            if b != -1:
                c = s[a + b + 2:].find(x[2])
                if c != -1:
                    cnt += 1

    print(cnt)


if __name__ == '__main__':
    main()


### FIXED CODE ###

import math
import sys
import collections
import bisect
readline = sys.stdin.readline


def main():
    n = int(readline().rstrip())
    s = readline().rstrip()
    cnt = 0
    for i in range(1000):
        x = str(i).zfill(3)
        a = s[:-1].find(x[0])
        if a != -1:
            b = s[a + 1: -1].find(x[1])
            if b != -1:
                c = s[a + b + 2:].find(x[2])
                if c != -1:
                    cnt += 1

    print(cnt)


if __name__ == '__main__':
    main()
def encode(message): 
    encoded_message = "" 
    i = 0
   
    while (i <= len(message)-1): 
        count = 1
        ch = message[i] 
        j = i 
        while (j < len(message)-1): 
            if (message[j] == message[j+1]): 
                count = count+1
                j = j+1
            else: 
                break
        encoded_message=encoded_message+str(count)+ch 
        i = j+1
    return encoded_message 

def solve():
    s = input()
    t = encode(s).split('L')

    ans = []
    for i in range(len(t)-1):
        l = t[i]
        if (int(l[0])-int(l[2]))%2 == 1:
            x = (int(l[0])+int(l[2]))//2
            if int(l[0])%2 == 0:
                ans = ans + ['0']*(int(l[0])-1) + [str(x)] + [str(x+1)] + ['0']*(int(l[2])-1)
            else:
                ans = ans + ['0']*(int(l[0])-1) + [str(x+1)] + [str(x)] + ['0']*(int(l[2])-1)
        elif (int(l[2])-int(l[0]))%2 == 1:
            x = (int(l[0])+int(l[2]))//2
            if int(l[2])%2 == 0:
                ans = ans + ['0']*(int(l[0])-1) + [str(x)] + [str(x+1)] + ['0']*(int(l[2])-1)
            else:
                ans = ans + ['0']*(int(l[0])-1) + [str(x+1)] + [str(x)] + ['0']*(int(l[2])-1)
        else:
            x = (int(l[0])+int(l[2]))//2
            ans = ans + ['0']*(int(l[0])-1) + [str(x)]*2 + ['0']*(int(l[2])-1)
        

    return ' '.join(ans)

print(solve())

### FIXED CODE ###

S = input()
 
def solve(S):
    buf = [1] * len(S)
 
    for i in range(len(buf) - 2):
        if S[i] == "R" and S[i+1] == "R":
            buf[i+2] += buf[i]
            buf[i] = 0
 
    for i in range(len(buf) - 1, 1, -1):
        if S[i] == "L" and S[i-1] == "L":
            buf[i-2] += buf[i]
            buf[i] = 0
 
    return " ".join(map(str, buf))
 
print(solve(S))
N, M = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(M)]

res = [""] * M
ctr = [0] * (M + 1)
for i, (p, y) in sorted(enumerate(X), key=lambda x: (x[1][0], x[1][1])):
    ctr[p] += 1
    res[i] = "{:0>6}{:0>6}".format(p, ctr[p])

print(*res, sep="\n")


### FIXED CODE ###

N, M = map(int, input().split())
P, Y = zip(*(map(int, input().split()) for _ in range(M)))
ans = ['' for _ in range(M)]
c = [1 for _ in range(N + 1)]

for i, t in sorted(enumerate(zip(P, Y)), key=lambda x: x[1][1]):
  ans[i] = '{:06}{:06}'.format(t[0], c[t[0]])
  c[t[0]] += 1
  
print('\n'.join(ans))
N = int(input())
A = [int(input()) for n in range(N)]
L = [False for i in range(max(A))]

for a in A:
    L[a] = not L[a]
print(sum(L))


### FIXED CODE ###

N = int(input())
A = [int(input()) for n in range(N)]
A = sorted(A)

res = []
tmp = A[0]
count = 1
for i in range(1,N):
    if A[i] == tmp:
        count += 1
    else:
        res.append(count%2 != 0)
        count = 1
    tmp = A[i]
res.append(count%2 != 0)

print(sum(res))
n,m = map(int,input().split())

a = []
for i in range(m):
    a.append(int(input()))

d = [a[0]-1]
for j in range(1,m):
    d.append(a[j]-a[j-1]-2)

d.append(n-a[m-1]-1)

mm = max(d)

fiblist = [0] * (mm+100)
fiblist[0] = 1
fiblist[1] = 1

for p in range(2,mm+100):
    fiblist[p] = (fiblist[p-1]+fiblist[p-2]) % 1000000007

#print(d)

if (-1 in d) or (-2 in d):
    print(0)
else:
    ans = 1
    for k in range(m+1):
        ans = (ans * fiblist[d[k]]) % 1000000007

    print(ans)


### FIXED CODE ###

fiblist = [0] * 100001
fiblist[0] = 1
fiblist[1] = 1
for p in range(2,100001):
    fiblist[p] = (fiblist[p-1]+fiblist[p-2]) % 1000000007

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

if m == 0:
    print(fiblist[n])
else:
    a = []
    for i in range(m):
        a.append(int(input()))

    d = [a[0]-1]
    for j in range(1,m):
        d.append(a[j]-a[j-1]-2)

    d.append(n-a[m-1]-1)




#print(d)

    if (-1 in d) or (-2 in d):
        print(0)
    else:
        ans = 1
        for k in range(m+1):
            ans = (ans * fiblist[d[k]]) % 1000000007

        print(ans)
a,b,c,d = map(int,input().split())
b_c = b//c
b_d = b//d
a_c = (a-1)//c
a_d = (a-1)//d
b_cd = b//int((c*d)/math.gcd(c, d))
a_cd = (a-1)//int((c*d)/math.gcd(c, d))
print((b-a+1)-(b_c+b_d-b_cd-(a_c+a_d-a_cd)))

### FIXED CODE ###

def gcd(a, b):
    # ユークリッド互除法により最大公約数を求める。
    if a < b:
        a, b = b, a

    if a % b == 0:
        return b
    else:
        return gcd(b, a % b)
a,b,c,d = map(int,input().split())
b_c = b//c
b_d = b//d
a_c = (a-1)//c
a_d = (a-1)//d
b_cd = b//int((c*d)/gcd(c, d))
a_cd = (a-1)//int((c*d)/gcd(c, d))
print((b-a+1)-(b_c+b_d-b_cd-(a_c+a_d-a_cd)))
n = input()
print(" ".join(input().split()).reveres)

### FIXED CODE ###

n = int(input())
print(" ".join(input().split()[::-1]))
n,m=map(int,input().split())
l=[set(map(int,input().split())) for _ in range(m)]
S=set()
G=set()
for x in l:
	if 1 in x:S.add(max(x))
	elif n in x:G.add(min(x))
S=sorted(S)
G=sorted(G)
i=0
Glen=len(G)
for x in S:
	if i==Glen:break
	elif G[i]<x:
		while i<Glen and G[i]<x:
			i+=1
	if x==G[i]:
		print('POSSIBLE')
		exit()
print('IMPOSSIBLE')

### FIXED CODE ###

n,m=map(int,input().split())
l=[set(map(int,input().split())) for _ in range(m)]
S=set()
G=set()
for x in l:
	if 1 in x:S.add(max(x))
	elif n in x:G.add(min(x))
S=sorted(S)
G=sorted(G)
i=0
Glen=len(G)
for x in S:
	if i==Glen:break
	elif G[i]<x:
		while i<Glen and G[i]<x:
			i+=1
	if i<Glen and x==G[i]:
		print('POSSIBLE')
		exit()
print('IMPOSSIBLE')
N, D= map(int,input().split())
arr = [list(map(int,input().split())) for _ in range(N)]
count=0
for i in range(N):
    for j in range(i+1,N):
        tmp = 0
        for k in range(D):
            if i != j:
                tmp += (arr[i][k]-arr[j][k])**2
        tmp = tmp**0.5
        if tmp == int(tmp)
            count = count+1
print(count)

### FIXED CODE ###

N, D= map(int,input().split())
arr = [list(map(int,input().split())) for _ in range(N)]
count=0
for i in range(N):
    for j in range(i+1,N):
        tmp = 0
        for k in range(D):
            if i != j:
                tmp += (arr[i][k]-arr[j][k])**2
        tmp = tmp**0.5
        if tmp.is_integer():
            count = count+1
print(count)
import math
N, D = map(int, input().split())
X = []

for _ in range(N):
    X.append(list(map(int, input().split())))

cnt = 0
for i in range(0, len(X)):
    sum = 0
    for j in range(0, len(X[i])):
        if i >= len(X[i]):
            sum += X[i][j] - X[0][j]
        else:
            sum += (X[i][j] - X[i+1][j])**2

    if math.sqrt(sum).is_integer():
        cnt += 1
print(cnt)


### FIXED CODE ###

import math
N, D = map(int, input().split())
X = []

for _ in range(N):
    X.append(list(map(int, input().split())))

cnt = 0
for i in range(N):
    for j in range(i+1, N):
        sum = 0
        for k in range(D):
            sum += (X[i][k] - X[j][k])**2
        if math.sqrt(sum).is_integer():
            cnt += 1
print(cnt)
N, M = map(int, input().split())
A = list(map(int, input().split()))

tab = [6, 2, 5, 5, 4, 5, 6, 3, 7, 6]
A_cmp = {}
for Ai in sorted(A):
    A_cmp[tab[Ai]] = Ai
A = list(A_cmp.values())
A = A[::-1]
# print("#", A)

memo = [None] * (N + 1)
memo[0] = 0

import sys
sys.setrecursionlimit(100000)

def dp(X):
    if memo[X] != None: return memo[X]
    if X < 0: return -(1000000007)
    #
    rets = []
    for i, Ai in enumerate(A):
        rets.append(dp(X - tab[Ai]) + 1)
    #
    ret = max(rets)
    memo[X] = ret
    return ret

ans_len = dp(N)

N_tmp = N
ans = ''
for i in range(ans_len):
    for j, Aj in enumerate(A):
        if j < j_str: continue
        if dp(N_tmp) - 1 == dp(N_tmp - tab[Aj]):
            ans += str(Aj)
            N_tmp -= tab[Aj]
            break

print(ans)


### FIXED CODE ###

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

tab = [6, 2, 5, 5, 4, 5, 6, 3, 7, 6]
A_cmp = {}
for Ai in sorted(A):
    A_cmp[tab[Ai]] = Ai
A = list(A_cmp.values())
A.sort(key=lambda x: -x)

memo = [None] * (N + 1)
memo[0] = 0

import sys
sys.setrecursionlimit(100000)

def dp(X):
    if X < 0: return -(1000000007)
    if memo[X] != None: return memo[X]
    #
    rets = []
    for i, Ai in enumerate(A):
        rets.append(dp(X - tab[Ai]) + 1)
    #
    ret = max(rets)
    memo[X] = ret
    return ret

ans_len = dp(N)

N_tmp = N
ans = ''
for i in range(ans_len):
    for j, Aj in enumerate(A):
        if dp(N_tmp) - 1 == dp(N_tmp - tab[Aj]):
            ans += str(Aj)
            N_tmp -= tab[Aj]
            break

print(ans)
def main():
    n = int(input())
    s = [input() for i in range(n)]

    AB = 0
    B_ = 0
    _A = 0
    B_A = 0
    for ss in s:
        for i in range(len(ss)-1):
            if ss[i:i+2] == 'AB':
                AB += 1
        if ss[0] == 'B':
            if ss[-1] == 'A':
                B_A += 1
            else:
                B_ += 1
        elif ss[-1] == 'A':
            _A += 1
    if _A == B_ && _A > 1:
        print(AB + max((B_A - 1), 0) + max(min(B_ + int(B_A > 0), _A), min(B_, _A + int(B_A > 0))) + 1)
    else:
        print(AB + max((B_A - 1), 0) + max(min(B_ + int(B_A > 0), _A), min(B_, _A + int(B_A > 0))))
    # print(AB, B_, _A, B_A)

if __name__ == '__main__':
    main()


### FIXED CODE ###

def main():
    n = int(input())
    s = [input() for i in range(n)]

    AB = 0
    B_ = 0
    _A = 0
    B_A = 0
    for ss in s:
        for i in range(len(ss)-1):
            if ss[i:i+2] == 'AB':
                AB += 1
        if ss[0] == 'B':
            if ss[-1] == 'A':
                B_A += 1
            else:
                B_ += 1
        elif ss[-1] == 'A':
            _A += 1
    if B_A > 0:
        if _A > 0 and B_ > 0:
            print(AB + (B_A - 1) + 2 + min(_A - 1, B_ - 1))
        elif _A == 0 and B_ == 0:
            print(AB + (B_A - 1))
        else:
            print(AB + (B_A - 1) + 1)
    else:
        print(AB + min(_A, B_))

if __name__ == '__main__':
    main()
N = int(input())

dicts = {}

for _ in range(N):
    S = input()
    if S in dicts:
        dicts[S] += 1
    else:
        dicts[S] = 1

dicts = sorted(dicts.items(), key=lambda x:x[1])
max_list = []

buf = dicts[1][1]
for k, v in dicts:
    if v == buf:
        max_list.append(k)
    else:
        break

for k in max_list:
    print(k)

### FIXED CODE ###

N = int(input())

dicts = {}

for _ in range(N):
    S = input()
    if S in dicts:
        dicts[S] += 1
    else:
        dicts[S] = 1

dicts = sorted(dicts.items(), key=lambda x:x[1], reverse=True)
max_list = []

buf = dicts[0][1]
for k, v in dicts:
    if v == buf:
        max_list.append(k)
    else:
        break

for k in sorted(max_list):
    print(k)
n = input().split()
ans = n.replace("1", "a")
ans = n.replace("9", "1")
ans = n.replace("a", "9")
print(int(ans))

### FIXED CODE ###

n = int(input())
print(1110-n)
a, b, k = map(int, input().split())

if a-k>=0:
    print(int(a-k),int(b))
elif a+b<k:
    print(0,0)
else:
    print(0,int(a+b-k))

### FIXED CODE ###

s, t = map(str, input().split())

print(str(t+s))