Harryxun/stf_run huggingface dataset:
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
N = int(input())
AB = [tuple(map(int,input().split())) for i in range(N-1)]
if N==2:
    print(1,2)
    exit()
es = [[] for i in range(N)]
for a,b in AB:
    a,b = a-1,b-1
    es[a].append(b)
    es[b].append(a)

depth = [-1]*N
depth[0] = 0
def dfs(v,p=-1):
    for to in es[v]:
        if to==p: continue
        depth[to] = depth[v] + 1
        dfs(to,v)
dfs(0)

mem = [[[] for _ in range(2)] for _ in range(2)]
for i,d in enumerate(depth):
    if d==0: continue
    if d%2:
        mem[0][0].append(i)
        mem[1][1].append(i)
    else:
        mem[0][1].append(i)
        mem[1][0].append(i)

for k in range(2):
    ans = [None] * N
    for i in range(1,N+1):
        if i==3:
            ans[0] = 3
            continue
        if i%3==0:
            if len(mem[k][0])==0 and len(mem[k][1])==0:
                break
            if len(mem[k][0]) <= len(mem[k][1]):
                j = mem[k][1].pop()
            else:
                j = mem[k][0].pop()
        elif i%3==1:
            if len(mem[k][0])==0:
                break
            j = mem[k][0].pop()
        else:
            if len(mem[k][1])==0:
                break
            j = mem[k][1].pop()
        ans[j] = i
    else:
        print(*ans)
        exit()
assert False


### FIXED CODE ###

import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
N = int(input())
AB = [tuple(map(int,input().split())) for i in range(N-1)]
if N==2:
    print(1,2)
    exit()
es = [[] for i in range(N)]
for a,b in AB:
    a,b = a-1,b-1
    es[a].append(b)
    es[b].append(a)

depth = [-1]*N
depth[0] = 0
def dfs(v,p=-1):
    for to in es[v]:
        if to==p: continue
        depth[to] = depth[v] + 1
        dfs(to,v)
dfs(0)

g1 = []
g2 = []
for i,d in enumerate(depth):
    if d%2:
        g2.append(i)
    else:
        g1.append(i)
if len(g1) < len(g2):
    g1,g2 = g2,g1

ans = [None] * N
if len(g2) <= N//3:
    for n in range(1,N+1):
        if n%3==0:
            if g2:
                i = g2.pop()
            else:
                i = g1.pop()
        else:
            i = g1.pop()
        ans[i] = n
else:
    for n in range(1,N+1,3):
        i = g1.pop()
        ans[i] = n
    for n in range(2,N+1,3):
        i = g2.pop()
        ans[i] = n
    for n in range(3,N+1,3):
        if g1:
            i = g1.pop()
        else:
            i = g2.pop()
        ans[i] = n
print(*ans)
from operator import mul
from functools import reduce

def cmb(n,r):
  	if n == 1 or n == 0: return 0
    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

n=int(input())
a_lis=list(map(int,input().split()))

olt={i:0 for i in set(a_lis)}
for i in a_lis:
  olt[i]+=1
for j in range(n):
  index=a_lis[j]
  olt[index]-=1
  
  z=sum([cmb(k,2) for key,k in olt])
  print(z)
  olt[index]+=1

### FIXED CODE ###

def combi(count):
  if n==1:return 0
  elif n==2:return 1
  else:return int(count*(count-1)/2)
 
 
n=int(input())
alis=list(map(int,input().split()))
dick={st:0 for st in set(alis)}
for i in range(n):
  p=alis[i]
  dick[p]+=1
#print(dick)
point=0
for v in dick.values():
  point+=combi(v)
 
 
for i in range(n):
  idx=alis[i]
  minus=dick[idx]-1
  print(point-minus)
n=int(input())
i=1 
a=[0]
A=[0]

while i<=n:
    a.append(int(input()))
    A.append(1/a[i])
    A[0]+=A[i]
    i+=1

print(1/A[0])

### FIXED CODE ###

n=int(input())
i=1
a=list(map(int,input().split()))
A=[0]

while i<=n:
    A.append(1/a[i-1])
    A[0]+=A[i]
    i+=1

print(1/A[0])
import copy
import math

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

sorted_As = sorted(As,reverse = True)
cut_As = copy.copy(sorted_As)
count_list = [0]*len(sorted_As)

for i in range(K):
    index = cut_As.index(max(cut_As))
    count = count_list[index]
    count_list[index] += 1
    cut_As[index] = sorted_As[index] / (count+2)

'''
for i in range(K):
    count = count_list[0]
    count_list[0] += 1
    cut_As[0] = sorted_As[0] / (count+2)
    cut_As,sorted_As,count_list = (list(x) for x in zip(*sorted(zip(cut_As,sorted_As,count_list),reverse = True)))
'''

print(math.ceil(max(cut_As)))


### FIXED CODE ###

X = int(input())
if X >= 30:
    print("Yes")
else:
    print("No")
M,N=map(int,input().split())
X = list(map(int,input().split()))
X.sort()
xdelta = []

for i in range(len(X)-1):
	xdelta.append(abs(X[i+1]-X[i]))

if xdelta == []:
	print(int(sum(map(abs,X))))
else:
	for i in range(M-1):
		xdelta.pop(-1)
	print(sum(xdelta))

### FIXED CODE ###

N,M=map(int,input().split())
X = list(map(int,input().split()))
X.sort()
xdelta = []

for i in range(len(X)-1):
	xdelta.append(abs(X[i+1]-X[i]))

xdelta.sort()

if N < M:
	if N == 1:
		print(sum(xdelta))
	else:
		for i in range(N-1):
			xdelta.pop(-1)
		print(sum(xdelta))
else:
	print(0)
import collections

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

c = collections.Counter(s)
max_num = list(c.values())[0]
d = []
for key,value in c:
  if value == max_num:
    d.append(key)
  else:
    break
    
for i in sorted(d):
  print(i)
  



### FIXED CODE ###

import collections

N = int(input())
s = [input() for i in range(N)]

c = collections.Counter(s)
max_num = max(c.values())
d = []
for key,value in c.items():
  if value == max_num:
    d.append(key)

for i in sorted(d):
  print(i)
n,k=map(int,input().split())
a=[]
for x in range(n):
  a.append(int(input()))
ans=1000000009
sorted(a)
for y in range(n-k):
  ans(a[y+k-1]-a[y],ans)
  
print(ans)

### FIXED CODE ###

n,k=map(int,input().split())
a=[]
for x in range(n):
  a.append(int(input()))
ans=1000000009
a=sorted(a)
for y in range(n-k+1):
  ans=min(a[y+k-1]-a[y],ans)
  
print(ans)
x= input()

for i in range(10000)

	print("Case i: x)

	if x = 0:
	break

### FIXED CODE ###

import sys 

cnt =1

while 1:
    x = sys.stdin.readline().strip()
    if x == "0":
        break

    print("Case %d: %s"%(cnt,x))
    cnt+=1
n,m,k = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))

acum1 = [0]
for i in range(n):
    acum1.append(acum1[-1] + a[i])

acum2 = [0]
for i in range(m):
    acum2.append(acum2[-1]+b[i])
i = 0
ans = 0
while acum1[i]<k:
    j = m
    while acum2[j]>k-acum1[i] and j>0:
        j -= 1
    ans = max(ans,i+j)
    i+=1
print(ans)
        

### FIXED CODE ###

#　変数 n, m, k, arr1, arr2, acum1, acum2, ans

n, m, k = map(int, input().split())
arr1 = list(map(int, input().split()))
arr2 = list(map(int, input().split()))

acum1 = [0]
for i in range(n):
    acum1.append(acum1[-1] + arr1[i])
acum2 = [0]
for i in range(m):
    acum2.append(acum2[-1] + arr2[i])

ans = 0
j = m
for i in range(n+1):
    if acum1[i] > k:
        break
    while acum2[j] > k - acum1[i] and j > 0:
        j -= 1
    ans = max(ans, i+j)
print(ans)
s = input() + "0"
def d():
    for i in range(len(s)-1):
        if s[i] == s[i+1]:
            return str(i+1) + " " + str(i+2)
        elif i <= len(s)-2 and s[i] == s[i+2]:
            return str(i+1) + " " + str(i+3)
    return "-1 -1"
print(d())

### FIXED CODE ###

s = input()
n = len(s)
s += "0"
def d():
    for i in range(n-1):
        if s[i] == s[i+1]:
            return str(i+1) + " " + str(i+2)
        elif s[i] == s[i+2]:
            return str(i+1) + " " + str(i+3)
    return "-1 -1"
print(d())
N=int(input())
S=int(input().split())
i=0
while S%2!==0:
i+=1
print(i)


### FIXED CODE ###

N = int(input())
A = list(map(int,input().split()))
pre=0
ans = 0
while True:
  for i in range(N):
    if(A[i]/2)%1==0:
      pre+=1
  if pre == N:
      ans+=1
      A=[x/2 for x in A]
      pre =0
  else:
      print(ans)
      exit()
(A, B, C) = [int(x) for x in input().split(" ")]

if b - a == c - b:
	print("YES")
else:
	print("NO")


### FIXED CODE ###

(A, B, C) = [int(x) for x in input().split(" ")]

if B - A == C - B:
	print("YES")
else:
	print("NO")
n,c = map(int,input().split())
table = [0 for i in range(10**5+1)]
chan = [[] for _ in range(c+2)]

for _ in range(n):
    s,t,c = map(int,input().split())
    chan[c].append([s,t])

# 同チャンネルの連続番組を統合する
times = []
for i in range(c+2):
    arr = chan[i]
    if chan[i]==[] : continue
    for i in range(len(arr)):
        if i == len(arr)-1 : break
        if arr[i][1] == arr[i+1][0]:
            arr[i+1] = [arr[i][0], arr[i+1][1]]
            arr[i] = [1,0]
    times += arr

# いもす法
for ele in times:
    table[ele[0]] += 1
    table[ele[1]+1] -= 1

# 累積和の計算
for i in range(len(table)):
    if i==1 : continue
    table[i] += table[i-1]

print(max(table))



### FIXED CODE ###

import numpy as np

n,c = map(int,input().split())
table = np.zeros(10**5+2, dtype=np.int32)
chs = [[] for _ in range(c+1)]

for _ in range(n):
    s,t,c = map(int,input().split())
    chs[c].append([s,t])

# 同チャンネル内の連続番組を合体
times = []
for ch in chs:
    if not ch: continue
    ch.sort()
    for i in range(len(ch)):
        if i == 0: continue
        if ch[i-1][1] == ch[i][0]:
            ch[i] = [ch[i-1][0], ch[i][1]]
            ch[i-1] = []
    for arr in ch:
        if not arr: continue
        times.append(arr)

# いもす法
for arr in times:
    table[arr[0]] += 1
    table[arr[1]+1] -= 1

# 累積和の最大値
ans = table.cumsum().max()

print(ans)
S = list(input())
Q = int(input())
Qu= [list(input().split()) for _ in range(Q)]

r = 0

B = []
A = []

for i in range(Q):
  if int(Qu[i][0]) == 1:
    r = 1 - r
  else:
    F = int(Qu[i][1])
    C = Qu[i][2]
    F -= 1
    if F == r:
      B.append(C)
    else:
      A.append(C)

if r == 0:
  B.reverse()
  print("".join(B + S + A))
else:
  A.reverse()
  print("".join(A + S.reverse() + B))


### FIXED CODE ###

S = list(input())
Q = int(input())
Qu= [list(input().split()) for _ in range(Q)]

r = 0

B = []
A = []

for i in range(Q):
  if int(Qu[i][0]) == 1:
    r = 1 - r
  else:
    F = int(Qu[i][1])
    C = Qu[i][2]
    F -= 1
    if F == r:
      B.append(C)
    else:
      A.append(C)

if r == 0:
  B.reverse()
  print("".join(B + S + A))
else:
  A.reverse()
  S.reverse()
  print("".join(A + S + B))
n, q = map(int, input().split())

# 各ノードのリンクを記録
link_dict = dict()
for i in rage(n-1):
  a,b = map(int, input().split())
  if a in list(link_dict.keys()):
    link_dict(str(a-1)).add(b)
  else:
    link_dict(str(a-1)) = set(b)
  
# 各ノードの部分木の全てのノードをリストアップ
link_set = [set() for i in range(n-1)]
for i in list(link_dict.keys()).sort():
  link_set[int(i) - 1] = set(link_dict[i - 1])
  if int(i) < n - 1:
    for j in link_dict[str(int(i) - 1)]:
      if j < n - 1:
        link_set[i - 1] = link_set[i - 1] | link_set[j - 1]

# カウンターの計算を実施
counters = [0] * n
for i in range(q):
  p, x = map(int, input().split())
  counters[p - 1] += x
  for node in link_set[p - 1]:
    counters[node - 1] += x
str_counters = [str(c) for c in counters]
print(' '.join(str_counters))

### FIXED CODE ###

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

# 各ノードのリンクを記録
link_set = [set() for _ in range(n-1)]
for i in range(n-1):
  a, b = map(int, input().split())
  link_set[a - 1].add(b)

# カウンターの計算を実施 (O(QN)の計算を避けることがポイント)

## O(Q)の計算
counters = [0] * n
for i in range(q):
  p, x = map(int, input().split())
  counters[p - 1] += x
  
## O(N)の計算
for i in range(n - 1):
  for node in link_set[i]:
    counters[node - 1] += counters[i]

str_counters = [str(c) for c in counters]
print(' '.join(str_counters))
import sys

test =False
if test:
    N = 9
    items = [1,2,4,9,5,8,7,3,6]
else:
    N = int(raw_input())
    items = raw_input().split()
    items = [int(item) for item in items]
counter = 0
i = 0
if test:
    print items
while i < N:
    if i + 1 == items[i]:
        tmp = items[i+1]
        items[i+1] = items[i]
        items[i] = tmp
        counter += 1
        if test:
            print items
    i += 1
assert i == N
if items[N-1] == N:
    tmp = items[N]
    items[N] = items[N-1]
    items[N-1] = tmp
    counter += 1
    if test:
        print items
print counter


### FIXED CODE ###

import sys
import random


test =False
debug = False
loop = False

def main(N, items):
    counter = 0
    i = 0
    if test:
        print N, items
    if debug:
        print items
    while i < N - 1:
        if i + 1 == items[i]:
            tmp = items[i+1]
            items[i+1] = items[i]
            items[i] = tmp
            counter += 1
            if debug:
                print items
        i += 1
    assert i == N - 1
    if items[i] == N:
        tmp = items[i]
        items[i] = items[i-1]
        items[i-1] = tmp
        counter += 1
        if debug:
            print items
    print counter

if __name__ == "__main__":
    if test:
        if loop:
            while True:
                N = random.randint(2, 10)
                items = range(1, N + 1)
                assert len(items) == N
                random.shuffle(items)
                main(N, items)
        else:
            N = 4
            items = [3,2,1,4]
            main(N, items)
    else:
        N = int(raw_input())
        items = raw_input().split()
        items = [int(item) for item in items]
        main(N, items)
N, K = map(int, input().split())
A = list(map(int, input().split()))
l = [0 for _ in range(N)]

now = 0
l[now] = 1
count = 0
loop = []

while count < K:
    count += 1
    now = A[now]-1
    loop.append(now)
    if l[now] == 1:
        loop = loop[loop.index(now):-1]
        break
    else:
        l[now] = 1

if count == K:
    print(now + 1)
else:
    ans = loop[K % count]
    print(ans + 1)


### FIXED CODE ###

N, K = map(int, input().split())
A = list(map(int, input().split()))
l = [0 for _ in range(N)]

now = 0
l[now] = 1
count = 0
loop = [0]

while count < K:
    count += 1
    now = A[now]-1
    loop.append(now)
    if l[now] == 1:
        loop = loop[loop.index(now):-1]
        break
    else:
        l[now] = 1

if count == K:
    print(now + 1)
else:
    ans = loop[(K-count) % len(loop)]
    print(ans + 1)
graph = [[] for _ in range(N + 1)]
for a, b in AB:
  graph[a].append(b)
  graph[b].append(a)
  
def make_tree(graph, root) -> list, list:
  INF = 10 ** 15
  dist = [INF] * len(graph)
  parent = [-1] * len(graph)
  stack = [root]
  dist[root] = 0
  parent[root] = root
  while stack:
    s = stack.pop()
    for g in graph[s]:
      if dist[g] > dist[s] + 1:
        dist[g] = dist[s] + 1
        parent[g] = s
        stack.append(g)
  return dist, parent
 
def lca(u, v, dist, parent):
  distu, distv = dist[u], dist[v]
  if distu > distv:
    for _ in range(distu - distv):
      u = parent[u]
  if distv > distu:
    for _ in range(distv - distu):
      v = parent[v]
  while u != v:
    u, v = parent[u], parent[v]
  return u

# root = 1
# dist, parent = make_tree(graph, root)

### FIXED CODE ###

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

print("Yes" if N == M else "No")
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    N, K = LI()
    P = LI_()
    C = LI()

    # Pをサイクルに分割
    cycle_C = []
    visited = [False] * N
    for i in range(N):
        if not visited[i]:
            c = i
            tmp_C = [C[c]]
            while True:
                visited[c] = True
                c = P[c]
                if visited[c]:
                    cycle_C.append(tmp_C)
                    break
                tmp_C.append(C[c])
    # print(cycle_C)

    ans = -INF
    for i in cycle_C:
        cycle_sum = sum(i)
        # print(cycle_sum)

        # Kがサイクル長より大きく、1週の点数が正ならば、周回する
        if len(i) < K and cycle_sum > 0:
            # サイクルを2つくっつけて累積和を取り、その差を全探索
            i_cum = list(itertools.accumulate(i * 2, initial=0))
            tmp = -INF
            for j, k in itertools.combinations(range(len(i) * 2), 2):
                if k - j <= K % len(i):
                    tmp = max(i_cum[k] - i_cum[j], tmp)
            tmp += K // len(i) * cycle_sum 

        else:
            i_cum = list(itertools.accumulate(i * 2, initial=0))
            tmp = -INF
            for j, k in itertools.combinations(range(len(i) * 2), 2):
                if k - j <= K:
                    tmp = max(i_cum[k] - i_cum[j], tmp)

        ans = max(tmp, ans)

    print(ans)

if __name__ == '__main__':
    resolve()


### FIXED CODE ###

import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    N, K = LI()
    P = LI_()
    C = LI()

    ans = -INF
    for i in range(N):
        # iを含むサイクルの探索
        cycle = []
        c = i
        while True:
            c = P[c]
            cycle.append(c)
            if c == i:
                break
        len_cycle = len(cycle)
        # print(i, cycle, [C[j] for j in cycle])

        # 最大スコアの探索
        score = 0
        cycle_score_total = sum([C[j] for j in cycle])
        cycle_score_cum = list(itertools.accumulate([C[j] for j in cycle]))
        # 終了地点をjと決める
        for j in range(min(len_cycle, K)):
            score = cycle_score_cum[j]
            if cycle_score_total > 0:
                score += (K - j - 1) // len_cycle * cycle_score_total
            # print(j, score)
            ans = max(score, ans)

    print(ans)

if __name__ == '__main__':
    resolve()
a, b = map(int, input().split())
if a <= 8 and b b <= 8:
  print('Yay!')
else:
  print(':(')

### FIXED CODE ###

a, b = map(int, input().split())
if a <= 8 and b <= 8:
  print('Yay!')
else:
  print(':(')
N, K, Q = list(map(lambda n: int(n), input().split(" ")))
point = [K - Q] * N
for i in range(N):
  c = int(input())
  point[c - 1] += 1

print("\n".join(["YES" if p > 0 else "NO" for p in point]))

### FIXED CODE ###

N, K, Q = list(map(lambda n: int(n), input().split(" ")))
point = [K - Q] * N
for i in range(Q):
  c = int(input())
  point[c - 1] += 1

print("\n".join(["Yes" if p > 0 else "No" for p in point]))
import math

n = int(input())

check = {}
ans = 0

for _ in range(n):
    word = sorted(input())
    new_word = ''.join(list(sorted(word)))
    check.setdefault(new_word, 0)
    check[new_word] += 1

for k in check:
    if check[k] >= 2:
        ans += int(math.factorial(check[k])/2)

print(ans)

### FIXED CODE ###

import math

n = int(input())

check = {}
ans = 0

for _ in range(n):
    word = sorted(input())
    new_word = ''.join(list(word))
    check.setdefault(new_word, 0)
    check[new_word] += 1

for k in check:
    if check[k] >= 2:
        ans += int(math.factorial(check[k])/(math.factorial(check[k]-2)*2))

print(ans)
import fractions
import functools
import sys

n=int(input())
a = [int(i) for i in input().split()]
a.sort()

if len(a) == 2:
  print(max(a))
  sys.exit()
  
gcd_a = functools.reduce(fractions.gcd, a)
a=[i//gcd_a for i in a]

cnt = 0
for i in range(1,len(a)):
  if fractions.gcd(a[0],a[i]) == 1:
    so = i
    cnt+=1
    if cnt == 2:
      print(gcd_a)
      sys.exit()

gcd_0 = functools.reduce(fractions.gcd, a[1:])
a_i = [i for i in a if i != a[so]]
gcd_i = functools.reduce(fractions.gcd, a_i)

print(max(gcd_0,gcd_i)*gcd_a)
   

### FIXED CODE ###

import fractions
import functools
import sys

n=int(input())
a = [int(i) for i in input().split()]
a.sort()

if len(a) == 2:
  print(max(a))
  sys.exit()
  
gcd_a = functools.reduce(fractions.gcd, a)
a=[i//gcd_a for i in a]

so = 0
cnt = 0
gcd_0 = functools.reduce(fractions.gcd, a[1:])
for i in range(1,len(a)):
  if fractions.gcd(a[0],a[i]) == 1:
    so = i
    cnt+=1
    if cnt == 2:
      print(max(gcd_a,gcd_0*gcd_a))
      sys.exit()

a_i = [i for i in a if i != a[so]]
gcd_i = functools.reduce(fractions.gcd, a_i)

print(max(gcd_0,gcd_i)*gcd_a)
X, L = [int(input()) for i in range(2)]
li = sorted([input() for i in range(X)])
ans = ''

for i in li:
    ans += i

print(ans)

### FIXED CODE ###

X, L = list(map(int,input().split()))
li = sorted([input() for i in range(X)])
ans = ''

for i in li:
    ans += i

print(ans)
he = input()
lista = []
counter1, counter2 = 0,0

while True:
    inp = tuple(map(int,input().split()))
    if not inp:
        break
    counter1 += 1
    print(inp)
    
    if (abs(inp[1])+abs(inp[2])) in range(inp[0], 0, -2):
        counter2 += 1
    else:
        break

if counter1 == counter2:
    print('Yes')
else:
    print('No')

### FIXED CODE ###

n = int(input())
t_ = 0
xy_ = [0,0]
for _ in range(n):
    t, *xy = map(int, input().split())
    ta = t - t_
    xya = [abs(xy[0]-xy_[0]), abs(xy[1]-xy_[1])]
    if sum(xya) > ta or (ta - sum(xya))%2 != 0:
        print("No")
        break
    t_ = t
    xy_ = xy
else:
    print("Yes")
n=int(input())
s=list(input())
s.pop(n)
print(s.append(s.pop(n)))

### FIXED CODE ###

N = int(input())
S = [i for i in input()]
alpha=['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z']
ans=''
for c in S:
    cnt = alpha.index(c)+N
    if cnt > 25:
        cnt=cnt-26
    c = alpha[cnt]
    ans+=c
print(ans)
n = int(input())
if n%111 = 0:
  print(n)
else:
  print((n//111+1)*111)

### FIXED CODE ###

n = int(input())
print(n) if n%111 == 0 else print((n//111+1)*111)
import sys, math
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mod = 10**9 + 7

import collections

N, M, P = rl()
E = []
edges = collections.defaultdict(list)
redges = collections.defaultdict(list)
for i in range(M):
	a, b, c = rl()
	E.append((a-1, b-1, P-c))
	edges[a-1].append(b-1)
	redges[b-1].append(a-1)

visited = {}
def dfs(n):
	if n in visited: return
	visited[n] = 1
	for e in edges[n]:
		dfs(e)
rvisited = {}
def rdfs(n):
	if n in rvisited: return
	rvisited[n] = 1
	for e in redges[n]:
		rdfs(e)

dfs(0)
rdfs(N-1)

V = list(range(N))

def belmanford(V, E, s=0):
	D = [float('inf')] * len(V)
	D[s] = 0
	P = [None] * len(V)
	update = True
	step = 0
	while update:
		update = False
		for u, v, c in E:
			if u not in V: continue
			if v not in V: continue
			if D[v] > D[u] + c:
				D[v] = D[u] + c
				P[v] = (u, c)
				update = True
		step += 1
		if step > N:
			return None, None
	return D, P

D, P = belmanford(V, E)
if D == None:
	print(-1)
else:
	print(max(-D[N-1], 0))


### FIXED CODE ###

import sys, math
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mod = 10**9 + 7

import sys
sys.setrecursionlimit(1000000)

import collections

N, M, P = rl()
E = []
edges = collections.defaultdict(list)
redges = collections.defaultdict(list)
for i in range(M):
	a, b, c = rl()
	E.append((a-1, b-1, P-c))
	edges[a-1].append(b-1)
	redges[b-1].append(a-1)

visited = {}
def dfs(n):
	if n in visited: return
	visited[n] = 1
	for e in edges[n]:
		dfs(e)
rvisited = {}
def rdfs(n):
	if n in rvisited: return
	rvisited[n] = 1
	for e in redges[n]:
		rdfs(e)

dfs(0)
rdfs(N-1)
ok = [False] * N
for n in range(N):
	if n in visited and n in rvisited:
		ok[n] = True
V = list(range(N))

def belmanford(V, E, s=0):
	D = [float('inf')] * len(V)
	D[s] = 0
	P = [None] * len(V)
	update = True
	step = 0
	while update:
		update = False
		for u, v, c in E:
			if not ok[u]: continue
			if not ok[v]: continue
			if D[v] > D[u] + c:
				D[v] = D[u] + c
				P[v] = (u, c)
				update = True
		step += 1
		if step > N:
			return None, None
	return D, P

D, P = belmanford(V, E)
if D == None:
	print(-1)
else:
	print(max(-D[N-1], 0))
suuretu = [int(x) for x in input().split()]
answer = 0

for i in suuretu:
    answer += calculate(i)

def calculate(i):
    a = 0
    while i % 2 == 0:
        i = i / 2
        a += 1

    return a


print(answer)

### FIXED CODE ###

import math
n = int(input())
a = list(map(int,input().split()))
maxlog = int(math.log2(max(a)))
answer = 0
for _ in range(maxlog):
  a = [aa/2 for aa in a if aa%2==0]
  answer+= len(a)
  if not a:
    break
print(answer)