Harryxun/stf_run huggingface dataset:
def make_tree(node):
    for i in tree_list[node]:
        if i != tree_dic[node]["p"]:
            tree_dic[node]["c"].append(i)
            tree_dic[i]["p"] = node
            make_tree(i)

n, q = map(int, input().split())
tree_list = [[] for _ in range(n)]
for i in range(n-1):
    a, b = map(int, input().split())
    tree_list[a-1].append(b-1)
    tree_list[b-1].append(a-1)

tree_dic = {} #tree_dic = {i:{p:j, c:[k, l]}}
for i in range(n):
    tree_dic[i] = {"p": -1, "c": [], "x": 0}

make_tree(0)
# print(tree_dic)
for i in range(q):
    p, x = map(int, input().split())
    tree_dic[p-1]["x"] += x
# print(tree_dic)

x_list = [0 for _ in range(n)]

import queue
next_visit = queue.Queue()
next_visit.put(0)
while not next_visit.empty():
    i = next_visit.get()
    tmp = tree_dic[i]["x"]
    if i != 0:
        tmp += x_list[tree_dic[i]["p"]]
    x_list[i] = tmp
    for j in tree_dic[i]["c"]:
        next_visit.put(j)

for i in x_list:
    print(i, end=" ")

### FIXED CODE ###

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

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

tree = [[] for _ in range(n)]

app = set([0])

import queue
next = queue.Queue()
next.put(0)
# print(tree_candidate)
while not next.empty():
    i = next.get()
    for j in tree_candidate[i]:
        if not j in app:
            tree[i].append(j)
            app.add(j)
            next.put(j)

cnts = [0 for _ in range(n)]
for i in range(q):
    p, x = map(int, input().split())
    cnts[p-1] += x
    # print(x, p, tree[p-1], cnts)

next = queue.Queue()
next.put(0)

while not next.empty():
    i = next.get()
    for j in tree[i]:
        cnts[j] += cnts[i]
        next.put(j)

for i in cnts:
    print(i, end=' ')
K, X = map(int, input().split())
if K*500 => X:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

K, X = map(int, input().split())
if K*500 >= X:
  print("Yes")
else:
  print("No")
H,W,M = map(int,input().split())
l = [[0]*W for _ in range(H)]
tate,yoko = [0]*W,[0]*H
memo = []
for _ in range(M):
  h,w = map(int,input().split())
  h -= 1
  w -= 1
  tate[w] += 1
  yoko[h] += 1
  l[h][w] = 1
  memo.append([h,w])
tateArr,yokoArr = [],[]

t,y = max(tate),max(yoko)
for i in range(W):
  if tate[i] == t:
    tateArr.append(i)
for i in range(H):
  if yoko[i] == y:
    yokoArr.append(i)
for i,j in memo:
  if j not in tateArr and i not in yokoArr:
    print(t+y)
    exit()
print(t+y-1)

### FIXED CODE ###

H,W,M = map(int,input().split())
tate,yoko = [0]*W,[0]*H
ans = 0
memo = set([])
for _ in range(M):
  h,w = map(int,input().split())
  h -= 1
  w -= 1
  tate[w] += 1
  yoko[h] += 1
  memo.add((h,w))
tateArr,yokoArr = [],[]
ans = 0
t,y = max(tate),max(yoko)
for i in range(W):
  if tate[i] == t:
    tateArr.append(i)
for i in range(H):
  if yoko[i] == y:
    yokoArr.append(i)
for i in yokoArr:
  for j in tateArr:
    if (i,j) not in memo:
      print(t+y)
      exit()

print(t+y-1)
s = input()
print chr(ord(s[0]) + 1)

### FIXED CODE ###

s = input()
print(chr(ord(s[0]) + 1))
def Int():
    return int(input())
def Ints():
    return map(int,input().split())
def IntList():
    return list(Ints())
def IntMat(N):
    return [IntList() for i in range(N)]

N,M,S = Ints()
from collections import defaultdict
Graph  = defaultdict(list)

for i in range(M):
    u,v,a,b = Ints()
    Graph[u].append([v,a,b])
    Graph[v].append([u,a,b])

City = [0]*N
for i in range(N):
    c,d = Ints()
    City[i] = [c,d]

import heapq
visited = [-1]*(N+1)
visited[0] = 1
que = []
# [time, nowhere, money, flag, visited]
heapq.heappush(que, [0, 1, S, 0])
ans = [-1]*(N+1)
Min = [[10**16]*5000 for i in range(N+1)]
#print(Graph)
while visited != [1]*(N+1):
    #print(que)
    time, nowhere, money, flag = heapq.heappop(que)
    #print(time, nowhere, money, flag)
    #route[nowhere] = 1
    Min[nowhere][money] = min(Min[nowhere][money], time)
    if visited[nowhere] == -1:
        visited[nowhere] = 1
        ans[nowhere] = time
    if flag == 0:
        c,d = City[nowhere-1]
        if money >= 5000:
            heapq.heappush(que, [time+d, nowhere, money+c, 1])
        else:
            heapq.heappush(que, [time+d, nowhere, money+c, 0])
    for (to,a,b) in Graph[nowhere]:
        #if not to in route:
        if money-a >= 0:
            if Min[to][money-a] > time+b:
                heapq.heappush(que, [time+b, to, money-a, flag])

for i in range(2,N+1):
    print(ans[i])

### FIXED CODE ###

def Int():
    return int(input())
def Ints():
    return map(int,input().split())
def IntList():
    return list(Ints())
def IntMat(N):
    return [IntList() for i in range(N)]

N,M,S = Ints()
from collections import defaultdict
Graph  = defaultdict(list)

for i in range(M):
    u,v,a,b = Ints()
    Graph[u-1].append([v-1,a,b])
    Graph[v-1].append([u-1,a,b])

City = [0]*N
for i in range(N):
    c,d = Ints()
    City[i] = [c,d]

import heapq
que = []
# [time, nowhere, money, flag, visited]
heapq.heappush(que, [0, 0, min(S,5000)])
ans = [[10**16]*5001 for i in range(N)]
#Min = [[10**16]*5001 for i in range(N+1)]
#print(Graph)
while que != []:
    time, nowhere, money = heapq.heappop(que)
    #print('here',time,nowhere,money)
    if time <= ans[nowhere][money]:
        ans[nowhere][money] = time
        c,d = City[nowhere]
        if time+d < ans[nowhere][min(5000,money+c)]:
            ans[nowhere][min(5000,money+c)] = time+d
            #print('to',time+d, nowhere, min(5000,money+c))
            heapq.heappush(que, [time+d, nowhere, min(5000,money+c)])
        for (to,a,b) in Graph[nowhere]:
            if 0 <= money - a and time+b < ans[to][min(5000,money-a)]:
                ans[to][min(5000,money-a)] = time+b
                #print('to',time+b, to, min(5000,money-a))
                heapq.heappush(que, [time+b, to, min(5000,money-a)])

for i in range(1,N):
    print(min(ans[i]))
n = int(input())
cards = {} #空の辞書
for i in range(n):
    card = input()
    cards[card] = 1
    
#print(cards)

for c in ['S', 'H', 'C', 'D']:
    for n in range(1,14):
        card = c + ' ' + str(n)
        if not key in cards:
            print(key)


### FIXED CODE ###

n = int(input())
cards = {} #空の辞書
for i in range(n):
    card = input()
    cards[card] = 1
    
#print(cards)

for c in ['S', 'H', 'C', 'D']:
    for n in range(1,14):
        key = c + ' ' + str(n)
        if not key in cards:
            print(key)
N=int(input())
A=[int(c) for c in input().split()]

#どうするか
#-1 -1  1
# 1 -1 -1
#-1  1 -1

#偶数個の数値を自由に反転できるとして見ていい

positive=[]
negative=[]
for a in A:
	if(a>=0):
		positive.append(a)
	else:
		negative.append(a)
if(len(negative)%2==0):#偶数個なら全部ひっくり返せばいい
	print(sum(positive)-sum(negative))
else:#奇数個なら, もっとも大きなもの以外をひっくり返す
	#あるいは, 最後にpositive最小とnegative最大をひっくり返すこともありうる	
	max_nega=max(negative)
	min_posi=min(positive)
	if(-1*max_nega>min_posi):
		print(sum(positive)-sum(negative)-2*min_posi)
	else:
		
		print(sum(positive)-sum(negative)+2*max_nega)








### FIXED CODE ###

N=int(input())
A=[int(c) for c in input().split()]

#どうするか
#-1 -1  1
# 1 -1 -1
#-1  1 -1

#偶数個の数値を自由に反転できるとして見ていい

positive=[]
negative=[]
for a in A:
	if(a>=0):
		positive.append(a)
	else:
		negative.append(a)
if(len(negative)%2==0):#偶数個なら全部ひっくり返せばいい
	print(sum(positive)-sum(negative))
else:#奇数個なら, もっとも大きなもの以外をひっくり返す
	#あるいは, 最後にpositive最小とnegative最大をひっくり返すこともありうる	
	if(len(positive)==0):
		print(-sum(negative)+2*max(negative))
	
	else:
		max_nega=max(negative)
		min_posi=min(positive)
		if(-1*max_nega>min_posi):
			print(sum(positive)-sum(negative)-2*min_posi)
		else:	
			print(sum(positive)-sum(negative)+2*max_nega)
n = map(int, input.split())
a = list(map(int, input().split()))
print(max(a) - min(a))

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
print(max(a) - min(a))
def main18():
    strbuf = input('');
    num = int(strbuf);
    if(num<1200):
        printf("ABC");
    elif(num<2800):
        printf("ARC");
    else:
        printf("AGC");


if __name__ == '__main__':
    main18()

### FIXED CODE ###


def main17():
    strbuf = "U"
    strbuf2 = "N"
    strbuf3 = "K"
    print(strbuf + strbuf2 + strbuf3)

def main18():
    strbuf = input('');
    num = int(strbuf);
    if(num<1200):
        print("ABC");
    elif(num<2800):
        print("ARC");
    else:
        print("AGC");


if __name__ == '__main__':
    main18()
X = input()
happier = (X % 500) * 1000
happy = ((X % 500) % 5) * 5
print(happier + happy)


### FIXED CODE ###

x = int(input())
happy500 = (x // 500) * 1000
happy5 = ((x % 500) // 5) * 5
print(happy500 + happy5)
a,b=map(int, input().split())
c=list(map(int, input().split()))
l =[]
ans = 0

def abc(n):
    return (n+1)/2

cb = list(map(abc,c))

s = sum(cb[:b])
l.append(s)

for i in range(b,a+1):
    s = s - cb[i-b] + cb[b]
    l.append(s)

L = sorted(l)
print(L[-1])

### FIXED CODE ###

a,b=map(int, input().split())
c=list(map(int, input().split()))
l =[]
ans = 0

def abc(n):
    return (n+1)/2

cb = list(map(abc,c))

s = sum(cb[:b])
l.append(s)

for i in range(b,a):
    s = s - cb[i-b] + cb[i]
    l.append(s)

L = sorted(l)
print(L[-1])
N = int(input())
D = list(map(int,input().split()))

a = [0 for _ in range(N-1)]

for d in D:
  a[d] += 1


ans = 0
for i in range(N-1):
  if i == 0:
    ans += a[i]
  else:
    ans *= a[i] % 998244353

print(ans)






### FIXED CODE ###

N = int(input())
D = list(map(int,input().split()))
_mod = 998244353

a = [0 for _ in range(N)]

for d in D:
  a[d] += 1

ans = 0

if a[0] != 1 or D[0] != 0:
  print(ans)
  exit()

cnt = 0
for i in range(N):
  cnt += a[i]
  if i == 0:
    ans = 1
  else:
    if a[i] == 0:
      if cnt == N:
        break
      else:
        ans = 0
    else:
      temp = a[i-1] ** a[i]
      ans = (ans * temp ) % _mod

print(ans)
S = input()
T = input()
rec = []
for i in range(len(S)):
    flag = True
    Z = S
    for j in range(len(T)):
        if Z[i] == T[j]:
            for e in range(i-j):
                if Z[e] == "?":
                    Z = Z.replace("?","a",1)
            print(Z[i])
            print(T[j])
            for k in range(len(T)-j+1):
                if Z[i+k-j] == T[k]:
                    continue
                elif Z[i+k-j] == "?":

                    Z = Z.replace("?",T[k],1)
                    print(Z)
                else:
                    flag = False
            if flag:
                Z = Z.replace("?", "a")
                rec.append(Z)
if rec == []:
    print("UNRESTORABLE")
else:
    print(rec[-1])

### FIXED CODE ###

S = input()
T = input()
rec = []
for i in range(len(S)):
    flag = True
    Z = S
    for j in range(len(T)):
        if Z[i] == T[j]:
            if len(S)-i < len(T):
                flag = False
                break
            for e in range(i - j):
                if Z[e] == "?":
                    Z = Z.replace("?", "a", 1)
            for k in range(len(T)):
                if Z[i + k - j] == T[k]:
                    continue
                elif Z[i + k - j] == "?":
                    Z = Z.replace("?", T[k], 1)
                else:
                    flag = False
            if flag:
                Z = Z.replace("?", "a")
                rec.append(Z)
        elif Z[i] == "?":
            if len(S)-i < len(T):
                flag = False
                break
            for e in range(i):
                if Z[e] == "?":
                    Z = Z.replace("?", "a", 1)
            for k in range(len(T)):
                if Z[i + k] == T[k]:
                    continue
                elif Z[i + k] == "?":
                    Z = Z.replace("?", T[k], 1)
                else:
                    flag = False
            if flag:
                Z = Z.replace("?", "a")
                rec.append(Z)

if rec == []:
    print("UNRESTORABLE")
else:
    print(rec[-1])
n, k = map(int, input().split())
a_sort = sorted(list(map(int, input().split())))

def SUM(a):
    count = 0
    comb = 1
    for i, num in enumerate(a):
        if i == k-1:
            count += num
        elif i > k-1:
            comb = comb * i // (i-k+1)
            count = (count + (comb * num)) % (10**9+7)
    return count

Max = SUM(a_sort)
Min = SUM(a_sort.reverse())

print((Max - Min + (10**9+7)) % (10**9+7))

### FIXED CODE ###

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
 
class Combination():
    # コンストラクタ
    def __init__(self, N:int, P:int):
        self.N = N
        self.P = P
 
        # fact[i] = (i! mod P)
        self.fact = [1, 1]   
        # factinv[i] = ((i!)^(-1) mod P)
        self.factinv = [1, 1]
        # factinv 計算用
        self.inv = [0, 1]    
 
        for i in range(2, N+1):
            self.fact.append((self.fact[-1] * i) % P)
            self.inv.append((-self.inv[P % i] * (P // i)) % P)
            self.factinv.append((self.factinv[-1] * self.inv[-1]) % P)
    
    # nCk (mod P)   (ただし、n<=N)
    def getComb(self, n:int, k:int):
        if (k < 0) or (n < k):
            return 0
        k = min(k, n - k)
        return self.fact[n] * self.factinv[k] * self.factinv[n-k] % self.P
 
def main():
    N,K = map(int,input().split())
    A = sorted([int(i) for i in input().split()])
 
    mod = 10**9+7
 
    COMB = Combination(N,mod)
 
    cmb = [0] * (N-K+1)
    for i in range(N-K+1):
        cmb[i] = COMB.getComb(i+(K-1),K-1)
 
    sum_max = 0
    for i in range(K-1,N):
        sum_max = (sum_max + cmb[i-(K-1)] * A[i]) % mod
 
    sum_min = 0
    for i in range(N-K,-1,-1):
        sum_min = (sum_min + cmb[(N-K)-i] * A[i]) % mod
 
    answer = sum_max - sum_min
    print(answer % mod)
 
if __name__ == "__main__":
    main()
print("HD"[len(set(input().split()))])

### FIXED CODE ###

print("$HD"[len(set(input().split()))])
import math

ABC = input().split()

a = int(ABC[0])
b = int(ABC[1])
c = int(ABC[2])
#a = b = c = pow(10,9)

l = 2*math.sqrt(a*b)
r = c - a - b

lint = int(l)

rl = r-l

# print(str(l) + " " + str(r))

# print(str(l-float(lint)) + " " + str(rl))

# print(math.isclose(0,rl))

if 0 < rl or math.isclose(0,rl):
    print("Yes")
else:
    print("No")




### FIXED CODE ###

import math

ABC = input().split()

a = int(ABC[0])
b = int(ABC[1])
c = int(ABC[2])
#a = b = c = pow(10,9)

l2  = 4 * a * b
r = c - a - b
r2 = r * r

# if l2 < r2:
#     print("Yes")
# else:
#     print("No")

if r > 0 :
    if l2 < r2:
        print("Yes")
    else:
        print("No")
else:
    print("No")
from collections import defaultdict
from heapq import heappush, heappop


n, k = map(int, input().split())
dic = defaultdict(list)
for _ in range(n):
    t, d = map(int, input().split())
    dic[t].append(d)

maxs = []
for key in dic:
    dic[key].sort()
    maxs.append((dic[key].pop(), key))

maxs.sort(reverse=True)
queSize = 0
que = []
queScore = 0
defaultScore = 0
cnt = 0
ans = 0
for v, key in maxs:
    defaultScore += v + cnt * 2 + 1
    cnt += 1
    for add in dic[key]:
        heappush(que, add)
        queSize += 1
        queScore += add
    while queSize > k - cnt:
        queScore -= heappop(que)
        queSize -= 1
    ans = max(ans, defaultScore + queScore)

print(ans)


### FIXED CODE ###

from collections import defaultdict
from heapq import heappush, heappop


n, k = map(int, input().split())
dic = defaultdict(list)
for _ in range(n):
    t, d = map(int, input().split())
    dic[t].append(d)

maxs = []
for key in dic:
    dic[key].sort()
    maxs.append((dic[key].pop(), key))

maxs.sort(reverse=True)
queSize = 0
que = []
queScore = 0
defaultScore = 0
cnt = 0
ans = 0
for v, key in maxs:
    defaultScore += v + cnt * 2 + 1
    cnt += 1
    if cnt >= k:
        ans = max(ans, defaultScore)
        break
    for add in dic[key]:
        heappush(que, add)
        queSize += 1
        queScore += add
    while queSize > k - cnt:
        queScore -= heappop(que)
        queSize -= 1
    ans = max(ans, defaultScore + queScore)

print(ans)
import math
# A, B, H, M = 3, 4, 9, 0
A, B, H, M = map(int, input().split())

sa = abs(H* 30-M*5.5)
cos = abs(math.cos(math.radians(sa)))
ans = math.sqrt(A**2 + B**2 - 2*A*B*cos)
print(ans)

### FIXED CODE ###

one = int(input()) % 10


hon_list = [2, 4, 5, 7, 9]

if one in hon_list:
    print('hon')
elif 3 == one:
    print('bon')
else:
    print('pon')
isExist = [0]*2001 
n = int( input() )
A = [ int( val ) for val in input().split( ' ' ) ]
q = int( input() )
M = [ int( val ) for val in input().split( ' ' ) ]
for i in range( 0, q ):
	if 1 == isExist[ M[i] ]:
		print( "yes" )
	else:
		print( "no" )

### FIXED CODE ###

def solve( p, t ):
	global isExist, n, A
	isExist[ t ] = True
	if p < n:
		solve( p+1, t-A[p] )
		solve( p+1, t )
	else:
		return

isExist = [False]*2001 
n = int( input() )
A = [ int( val ) for val in input().rstrip().split( ' ' ) ]
q = int( input() )
M = [ int( val ) for val in input().rstrip().split( ' ' ) ]
s = sum( A )
solve( 0, s )
for i in range( 0, q ):
	if isExist[ M[i] ]:
		print( "yes" )
	else:
		print( "no" )
N = int(input())
A = list(map(int,input().split()))
frag = 0
tmp = 0

for i in range(0,N):
    if A[i] > A[i+1]:
        A[i] -= 1
        tmp = A[i]
        if A[i-1] > A[i] or tmp > A[i+1]:
            frag += 1
            break

if frag >= 1:
    print("No")
else:
    print("Yes")

### FIXED CODE ###

N = int(input())
A = list(map(int,input().split()))
pre = -999
frag = 0

for i in range(N):
    if A[i]-1 >= pre:
        pre = A[i] - 1
    elif A[i] >= pre:
        pre = A[i]
    else:
        frag += 1
        break
        
if frag == 1:
    print("No")
else:
    print("Yes")
R, G, B, N = map(int, input().split())

cnt = 0

maxr = N // R + 1
maxg = N // G + 1
maxb = N // B + 

for r in range(0, maxr+1):
  for g in range(0, maxg+1):
    for b in range(0, maxb+1):
      p = R*r + G*g + B*b
      if p == N:
        cnt += 1
        break
      elif p > N: break
        
print(cnt)

### FIXED CODE ###

###template###
import sys
input = sys.stdin.readline
def mi(): return map(int, input().split())
###template###

Rt, Gt, Bt, N = mi()

R = max(Rt, Gt, Bt)
B = min(Rt, Gt, Bt)
G = Rt+Gt+Bt-R-B

cnt = 0
if G == 1 and B == 1:
  for i in range(N//R+1):
    cnt += (N-R*i)+1
  print(cnt)
  exit()

for i in range(N//R+1):
  for j in range((N-R*i)//G+1):
    #残り必要ボール数
    if (N - R*i - G*j)%B == 0:
      cnt += 1

print(cnt)
[n,m]=list(map(int,input().split()))
ab=[]
for i in range(m):
    ab.append(list(map(int,input().split())))

chizu=[[] for i in range(n+1)]
ans=[0]*(n+1)
ans[1]=-1

for i in range(m):
    chizu[ab[i][0]].append(ab[i][1])
    chizu[ab[i][1]].append(ab[i][0])

kaisu=[chizu[1]]
for i in chizu[1]:
    ans[i]=1

j=-1
counter=len(chizu[1])
while True:
    j+=1
    for now in kaisu[j]:#スタートからj距離の点たちについて操作
        kari=[]
        for i in chizu[now]:#ある点から隣り合う点決めていく
           if ans[i]==0:
                ans[i]=now
                kari.append(ans[i])
                counter+=1
        kaisu.append(kari)
    if counter==n-1:
        break

print("Yes")
for i in range(2,n+1):
    print(ans[i])

### FIXED CODE ###

[n,m]=list(map(int,input().split()))
ab=[]
for i in range(m):
    ab.append(list(map(int,input().split())))

chizu=[[] for i in range(n+1)]
ans=[0]*(n+1)
ans[1]=-1

for i in range(m):
    chizu[ab[i][0]].append(ab[i][1])
    chizu[ab[i][1]].append(ab[i][0])

kaisu=[chizu[1]]
for i in chizu[1]:
    ans[i]=1

error=0
j=-1
counter=len(chizu[1])
while True:
    j+=1
    if len(kaisu)<=j:
        error=0
        break
    for now in kaisu[j]:#スタートからj+1距離の点たちについて操作
        kari=[]
        for i in chizu[now]:#ある点から隣り合う点決めていく
           if ans[i]==0:#未到達であれば
                ans[i]=now
                kari.append(i)
                counter+=1
        kaisu.append(kari)
    if counter==n-1:
        break

if error==0:
    print("Yes")
    for i in range(2,n+1):
        print(ans[i])
    

elif error==1:
    print("No")
import math
def lcm(x, y):
    return (x * y) // math.gcd(x, y)
n = int(input())
print(lcm(2,n))

### FIXED CODE ###

def gcd(a, b):
	while b:
		a, b = b, a % b
	return a
def lcm(a, b):
	return a * b // gcd (a, b)
n = int(input())
print(lcm(2,n))
abk = input_line.split(input()) 
ABK = [int(n) for n in abk]

while ABK[0] > 0:
    ABK[0] -= 1
    ABK[2] -= 1
    if ABK[2] < 1:
        break
else:
    pass
while ABK[1] > 0:
    ABK[1] -= 1
    ABK[2] -= 1
    if ABK[2] < 1:
        break
else:
    pass
#else:
print(ABK[0],ABK[1])
    

### FIXED CODE ###


input_line = input()
abk = input_line.split(" ") 
ABK = [int(n) for n in abk]



if ABK[0] + ABK[1] <= ABK[2]:
    A = 0
    B = 0

elif ABK[0] <= ABK[2] and ABK[1] > ABK[2] - ABK[0]:
    A = 0
    B = ABK[1] -  (ABK[2] - ABK[0])

elif ABK[0] > ABK[2]:
    A = ABK[0] - ABK[2]
    B = ABK[1]

    
print(A," ",B)
input("")
print(3 6 9 12 13 15 18 21 23 24 27 30)

### FIXED CODE ###

n = int(input())
result = ""
for s in range(1, n+1):
    if s % 3 == 0:
        result += " "+str(s)
    else:
        for i in str(s):
            if i == "3":
                result += " "+str(s)
                break
print(result)
n=int(input())
d=list(map(int,input().split()))
m=n/2
d.sort()
print(d[m+1]-d[m])


### FIXED CODE ###

n=int(input())
d=list(map(int,input().split()))
m=int(n/2)
d=sorted(d)
print(d[m]-d[m-1])
a,b= map(int, input().split())
print(6-a+b)

### FIXED CODE ###

a = int(input())
b = int(input())
print(6-a-b)
a,b = (int(x) for in input().split())
if a > b:
	print(“a > b”)
if a < b:
	print(“a < b”)
if a = b:
	print(“a = b”)
 


### FIXED CODE ###

a,b = map(int, input().split())
if a > b:
 print("a > b")
elif a < b:
 print("a < b")
else:
 print("a == b")
N,D=map(int,input().split())
ans=0

for i in  range(N):
    x,y=map(int,input().split())
    if(D*D>=x*x+y*y):ans+=1
    
    
print(ans)

### FIXED CODE ###

x=int(input())
if(x>=30):
    print("Yes")
else:
    print("No")
s = input()
for i in range(len(s)):
  if s[i] == "?":
    s[i] = "D"
print(s)

### FIXED CODE ###

s = input()
j = ""
for i in range(len(s)):
  if s[i] == "?":
    j = j + "D"
  else:
    j = j + s[i]
print(j)
n, x = map(int, (input().split()))
a, p = [1], [1]
for i in range(n):
    a.append(a[i] * 2 + 3)
    p.append(p[i] * 2 + 1)
print("a = {}".format(a))
print("p = {}".format(p))

def f(n, x):
    if n == 0:
        return 0 if x <= 0 else 1
    elif x <= 1+a[n-1]:
        return f(n-1, x-1)
    elif x == a[n-1]+2:
        return p[n-1]+1
    elif x <= 2*a[n-1]+3
        return p[n-1]+1 + f(n-1, x-2-a[n-1])
print(f(n, x))

### FIXED CODE ###

n, x = map(int, (input().split()))
a, p = [1], [1]
for i in range(n):
    a.append(a[i] * 2 + 3)
    p.append(p[i] * 2 + 1)

def f(n, x):
    if n == 0:
        return 0 if x <= 0 else 1
    elif x <= 1+a[n-1]:
        return f(n-1, x-1)
    else:
        return p[n-1]+1 + f(n-1, x-2-a[n-1])
print(f(n, x))
N = int(input())
A = []
A.append(N//100)
A.append(N//10-A)
A.append(N-A-B)
for i in range(3):
    if A[i]==1:
        A[i]=9
    if A[i]==9:
        A[i]=1
print(A[0]*100+A[1]*10+A[2])

### FIXED CODE ###

N = int(input())
A = []
a = N//100
b = N//10-a*10
c = N - a*100 - b*10
A.append(a)
A.append(b)
A.append(c)
for i in range(3):
    if A[i]==1:
        A[i]=9
    elif A[i]==9:
        A[i]=1
print(A[0]*100+A[1]*10+A[2])